1 
2 #include "nx_api.h"
3 
4 #ifdef __PRODUCT_NETXDUO__
5 
6 #include "netx_mdns_test.h"
7 
8 /* Frame (75 bytes) */
9 static const unsigned char pkt1[75] = {
10 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb, 0x00, 0x11, /* ..^..... */
11 0x22, 0x33, 0x44, 0x57, 0x08, 0x00, 0x45, 0x00, /* "3DW..E. */
12 0x00, 0x3d, 0x00, 0x02, 0x40, 0x00, 0xff, 0x11, /* .=..@... */
13 0x90, 0x93, 0x0a, 0x00, 0x00, 0x1f, 0xe0, 0x00, /* ........ */
14 0x00, 0xfb, 0x14, 0xe9, 0x14, 0xe9, 0x00, 0x29, /* .......) */
15 0x66, 0xba, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, /* f....... */
16 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x5f, /* ......._ */
17 0x69, 0x70, 0x70, 0x04, 0x5f, 0x74, 0x63, 0x70, /* ipp._tcp */
18 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x00, 0x00, /* .local.. */
19 0x0c, 0x00, 0x01                                /* ... */
20 };
21 
22 /* Frame (276 bytes) */
23 static const unsigned char pkt2[276] = {
24 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb, 0x00, 0x11, /* ..^..... */
25 0x22, 0x33, 0x44, 0x56, 0x08, 0x00, 0x45, 0x00, /* "3DV..E. */
26 0x01, 0x06, 0x00, 0x07, 0x40, 0x00, 0xff, 0x11, /* ....@... */
27 0xd9, 0x1c, 0xc0, 0xa8, 0x00, 0x1f, 0xe0, 0x00, /* ........ */
28 0x00, 0xfb, 0x14, 0xe9, 0x14, 0xe9, 0x00, 0xf2, /* ........ */
29 0x15, 0xc4, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, /* ........ */
30 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x04, 0x5f, /* ......._ */
31 0x69, 0x70, 0x70, 0x04, 0x5f, 0x74, 0x63, 0x70, /* ipp._tcp */
32 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x00, 0x00, /* .local.. */
33 0x0c, 0x00, 0x01, 0x00, 0x00, 0x00, 0x78, 0x00, /* ......x. */
34 0x23, 0x11, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, /* #.Simple */
35 0x20, 0x57, 0x65, 0x62, 0x20, 0x53, 0x65, 0x72, /*  Web Ser */
36 0x76, 0x65, 0x72, 0x04, 0x5f, 0x69, 0x70, 0x70, /* ver._ipp */
37 0x04, 0x5f, 0x74, 0x63, 0x70, 0x05, 0x6c, 0x6f, /* ._tcp.lo */
38 0x63, 0x61, 0x6c, 0x00, 0x11, 0x53, 0x69, 0x6d, /* cal..Sim */
39 0x70, 0x6c, 0x65, 0x20, 0x57, 0x65, 0x62, 0x20, /* ple Web  */
40 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x04, 0x5f, /* Server._ */
41 0x69, 0x70, 0x70, 0x04, 0x5f, 0x74, 0x63, 0x70, /* ipp._tcp */
42 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x00, 0x00, /* .local.. */
43 0x21, 0x80, 0x01, 0x00, 0x00, 0x00, 0x78, 0x00, /* !.....x. */
44 0x15, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x90, 0x07, /* ........ */
45 0x75, 0x62, 0x75, 0x6e, 0x74, 0x75, 0x31, 0x05, /* ubuntu1. */
46 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x00, 0x11, 0x53, /* local..S */
47 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x57, 0x65, /* imple We */
48 0x62, 0x20, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, /* b Server */
49 0x04, 0x5f, 0x69, 0x70, 0x70, 0x04, 0x5f, 0x74, /* ._ipp._t */
50 0x63, 0x70, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, /* cp.local */
51 0x00, 0x00, 0x10, 0x80, 0x01, 0x00, 0x00, 0x00, /* ........ */
52 0x78, 0x00, 0x14, 0x08, 0x70, 0x61, 0x70, 0x65, /* x...pape */
53 0x72, 0x3d, 0x41, 0x34, 0x0a, 0x76, 0x65, 0x72, /* r=A4.ver */
54 0x73, 0x69, 0x6f, 0x6e, 0x3d, 0x30, 0x31, 0x07, /* sion=01. */
55 0x75, 0x62, 0x75, 0x6e, 0x74, 0x75, 0x31, 0x05, /* ubuntu1. */
56 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x00, 0x00, 0x01, /* local... */
57 0x80, 0x01, 0x00, 0x00, 0x00, 0x78, 0x00, 0x04, /* .....x.. */
58 0xc0, 0xa8, 0x00, 0x1f                          /* ....     */
59 };
60 
61 /* Frame (75 bytes) */
62 static const unsigned char pkt3[75] = {
63 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb, 0x00, 0x11, /* ..^..... */
64 0x22, 0x33, 0x44, 0x57, 0x08, 0x00, 0x45, 0x00, /* "3DW..E. */
65 0x00, 0x3d, 0x00, 0x02, 0x40, 0x00, 0xff, 0x11, /* .=..@... */
66 0x90, 0x93, 0x0a, 0x00, 0x00, 0x1f, 0xe0, 0x00, /* ........ */
67 0x00, 0xfb, 0x14, 0xe9, 0x14, 0xe9, 0x00, 0x29, /* .......) */
68 0x66, 0xba, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, /* f....... */
69 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x5f, /* ......._ */
70 0x69, 0x70, 0x70, 0x04, 0x5f, 0x74, 0x63, 0x70, /* ipp._tcp */
71 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x00, 0x00, /* .local.. */
72 0x0c, 0x00, 0x01                                /* ... */
73 };
74 
75 static MDNS_QUERY_INFO mdns_query = {NX_NULL, "_ipp._tcp", NX_NULL};
76 #define resonable_error 10
77 
78 MDNS_TEST_SEQ mdns_query_rr_timeout[] = {
79     {TITLE, "RR timeout", 10, 0},
80 
81     /* Waiting for probing and announcing.  */
82     {WAIT, NX_NULL, 0, 5},
83 
84     /* Add query. */
85     {MDNS_QUERY, (char*)&mdns_query, 0, 0},
86     {MDNS_CHECK_DATA_V4, (char*)&pkt1[0], sizeof(pkt1), 5},
87 
88     /* Inject a response. */
89     {INJECT, (char*)&pkt2[0], sizeof(pkt2), 0},
90 
91     /* Reset timer. */
92     {MDNS_TIMER_RESET, NX_NULL, 0, 0},
93 
94     /* TTL is 120s. */
95     /* Issue a query at 80%, 85%, 90%, 95% of the record lifetime. */
96     {WAIT, NX_NULL, 0, 95},
97     {DUMP, NX_NULL, 0, 0},
98 
99     /* Check data.  */
100     {MDNS_CHECK_DATA_V4, (char*)&pkt3[0], sizeof(pkt3), 10},
101 
102     /* Check timer in range 96~99s (80%-82%). */
103     {MDNS_TIMER_CHECK, NX_NULL, 150 + resonable_error, 9750},
104     {DUMP, NX_NULL, 0, 0},
105 
106     /* Check data.  */
107     {MDNS_CHECK_DATA_V4, (char*)&pkt3[0], sizeof(pkt3), 10},
108 
109     /* Check timer in range 102~105 (85%-87%). */
110     {MDNS_TIMER_CHECK, NX_NULL, 150 + resonable_error, 10350},
111     {DUMP, NX_NULL, 0, 0},
112 
113     /* Check data.  */
114     {MDNS_CHECK_DATA_V4, (char*)&pkt3[0], sizeof(pkt3), 10},
115 
116     /* Check timer in range 108~111 (90%-92%). */
117     {MDNS_TIMER_CHECK, NX_NULL, 150 + resonable_error, 10950},
118     {DUMP, NX_NULL, 0, 0},
119 
120     /* Check data.  */
121     {MDNS_CHECK_DATA_V4, (char*)&pkt3[0], sizeof(pkt3), 10},
122 
123     /* Check timer in range 114~117 (95%-97%). */
124     {MDNS_TIMER_CHECK, NX_NULL, 150 + resonable_error, 11550},
125 
126     /* The record should be deleted. */
127     {WAIT, NX_NULL, 0, 7},
128     {MDNS_CHECK_RR_COUNT_REMOTE, NX_NULL, 0, 0},
129 
130     /* Delete the query. */
131     {MDNS_QUERY_DELETE, NX_NULL, 0, 0},
132     {DUMP, NX_NULL, 0, 0},
133 
134     /* Inject a response. */
135     {INJECT, (char*)&pkt2[0], sizeof(pkt2), 0},
136 
137     /* No cache maintenance is expected. */
138     {MDNS_REJECT_ANY_V4, NX_NULL, 0, 120},
139 
140     /* The record should be deleted. */
141     {WAIT, NX_NULL, 0, 2},
142     {MDNS_CHECK_RR_COUNT_REMOTE, NX_NULL, 0, 0},
143 };
144 
145 int mdns_query_rr_timeout_size = sizeof(mdns_query_rr_timeout) / sizeof(MDNS_TEST_SEQ);
146 
147 #endif /* __PRODUCT_NETXDUO__  */
148 
149