1 /* This NetX test concentrates on fragment IPv6 packet with hop by hop option. */
2
3 #include "nx_api.h"
4 #include "nx_ram_network_driver_test_1500.h"
5
6 extern void test_control_return(UINT status);
7 #if !defined(NX_DISABLE_FRAGMENTATION) && defined(FEATURE_NX_IPV6) && !defined(NX_ENABLE_INTERFACE_CAPABILITY)
8 #define DEMO_STACK_SIZE 2048
9
10
11 /* Define the ThreadX and NetX object control blocks... */
12
13 static TX_THREAD ntest_0;
14
15 static NX_PACKET_POOL pool_0;
16 static NX_IP ip_0;
17 static NX_IP ip_1;
18 static NXD_ADDRESS addr_0, addr_1;
19
20 /* Define the counters used in the test application... */
21
22 static ULONG error_counter;
23
24
25 /* Define thread prototypes. */
26
27 static void ntest_0_entry(ULONG thread_input);
28 extern void _nx_ram_network_driver_512(struct NX_IP_DRIVER_STRUCT *driver_req);
29 extern UINT (*advanced_packet_process_callback)(NX_IP *ip_ptr, NX_PACKET *packet_ptr, UINT *operation_ptr, UINT *delay_ptr);
30 static UINT packet_process(NX_IP *ip_ptr, NX_PACKET *packet_ptr, UINT *operation_ptr, UINT *delay_ptr);
31
32 /* ICMPv6 echo request packet with hop by hop option.
33 * src: 0xFE80::1
34 * dst: 0xFE80::2
35 * length of ping data: 1400. */
36 static char icmp_pkt[] = {
37 0xa4, 0x1f, 0x72, 0x53, 0xa0, 0xf7, 0x18, 0x03, /* ..rS.... */
38 0x73, 0x29, 0x5f, 0x66, 0x86, 0xdd, 0x60, 0x00, /* s)_f..`. */
39 0x00, 0x00, 0x05, 0x88, 0x00, 0x40, 0xfe, 0x80, /* .....@.. */
40 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
41 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xfe, 0x80, /* ........ */
42 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
43 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x3a, 0x00, /* ......:. */
44 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, /* ........ */
45 0x18, 0xd2, 0x00, 0x00, 0x00, 0x00, 0x61, 0x62, /* ......ab */
46 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, /* cdefghij */
47 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, /* klmnopqr */
48 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, /* stuvwabc */
49 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, /* defghijk */
50 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, /* lmnopqrs */
51 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, /* tuvwabcd */
52 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, /* efghijkl */
53 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, /* mnopqrst */
54 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, /* uvwabcde */
55 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, /* fghijklm */
56 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, /* nopqrstu */
57 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, /* vwabcdef */
58 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, /* ghijklmn */
59 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, /* opqrstuv */
60 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* wabcdefg */
61 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, /* hijklmno */
62 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* pqrstuvw */
63 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, /* abcdefgh */
64 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, /* ijklmnop */
65 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, /* qrstuvwa */
66 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, /* bcdefghi */
67 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, /* jklmnopq */
68 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, /* rstuvwab */
69 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, /* cdefghij */
70 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, /* klmnopqr */
71 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, /* stuvwabc */
72 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, /* defghijk */
73 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, /* lmnopqrs */
74 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, /* tuvwabcd */
75 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, /* efghijkl */
76 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, /* mnopqrst */
77 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, /* uvwabcde */
78 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, /* fghijklm */
79 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, /* nopqrstu */
80 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, /* vwabcdef */
81 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, /* ghijklmn */
82 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, /* opqrstuv */
83 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* wabcdefg */
84 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, /* hijklmno */
85 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* pqrstuvw */
86 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, /* abcdefgh */
87 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, /* ijklmnop */
88 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, /* qrstuvwa */
89 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, /* bcdefghi */
90 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, /* jklmnopq */
91 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, /* rstuvwab */
92 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, /* cdefghij */
93 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, /* klmnopqr */
94 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, /* stuvwabc */
95 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, /* defghijk */
96 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, /* lmnopqrs */
97 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, /* tuvwabcd */
98 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, /* efghijkl */
99 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, /* mnopqrst */
100 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, /* uvwabcde */
101 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, /* fghijklm */
102 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, /* nopqrstu */
103 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, /* vwabcdef */
104 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, /* ghijklmn */
105 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, /* opqrstuv */
106 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* wabcdefg */
107 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, /* hijklmno */
108 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* pqrstuvw */
109 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, /* abcdefgh */
110 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, /* ijklmnop */
111 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, /* qrstuvwa */
112 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, /* bcdefghi */
113 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, /* jklmnopq */
114 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, /* rstuvwab */
115 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, /* cdefghij */
116 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, /* klmnopqr */
117 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, /* stuvwabc */
118 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, /* defghijk */
119 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, /* lmnopqrs */
120 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, /* tuvwabcd */
121 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, /* efghijkl */
122 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, /* mnopqrst */
123 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, /* uvwabcde */
124 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, /* fghijklm */
125 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, /* nopqrstu */
126 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, /* vwabcdef */
127 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, /* ghijklmn */
128 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, /* opqrstuv */
129 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* wabcdefg */
130 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, /* hijklmno */
131 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* pqrstuvw */
132 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, /* abcdefgh */
133 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, /* ijklmnop */
134 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, /* qrstuvwa */
135 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, /* bcdefghi */
136 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, /* jklmnopq */
137 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, /* rstuvwab */
138 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, /* cdefghij */
139 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, /* klmnopqr */
140 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, /* stuvwabc */
141 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, /* defghijk */
142 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, /* lmnopqrs */
143 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, /* tuvwabcd */
144 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, /* efghijkl */
145 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, /* mnopqrst */
146 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, /* uvwabcde */
147 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, /* fghijklm */
148 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, /* nopqrstu */
149 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, /* vwabcdef */
150 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, /* ghijklmn */
151 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, /* opqrstuv */
152 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* wabcdefg */
153 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, /* hijklmno */
154 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* pqrstuvw */
155 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, /* abcdefgh */
156 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, /* ijklmnop */
157 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, /* qrstuvwa */
158 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, /* bcdefghi */
159 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, /* jklmnopq */
160 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, /* rstuvwab */
161 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, /* cdefghij */
162 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, /* klmnopqr */
163 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, /* stuvwabc */
164 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, /* defghijk */
165 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, /* lmnopqrs */
166 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, /* tuvwabcd */
167 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, /* efghijkl */
168 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, /* mnopqrst */
169 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, /* uvwabcde */
170 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, /* fghijklm */
171 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, /* nopqrstu */
172 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, /* vwabcdef */
173 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, /* ghijklmn */
174 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, /* opqrstuv */
175 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* wabcdefg */
176 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, /* hijklmno */
177 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* pqrstuvw */
178 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, /* abcdefgh */
179 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, /* ijklmnop */
180 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, /* qrstuvwa */
181 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, /* bcdefghi */
182 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, /* jklmnopq */
183 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, /* rstuvwab */
184 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, /* cdefghij */
185 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, /* klmnopqr */
186 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, /* stuvwabc */
187 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, /* defghijk */
188 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, /* lmnopqrs */
189 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, /* tuvwabcd */
190 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, /* efghijkl */
191 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, /* mnopqrst */
192 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, /* uvwabcde */
193 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, /* fghijklm */
194 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, /* nopqrstu */
195 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, /* vwabcdef */
196 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, /* ghijklmn */
197 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, /* opqrstuv */
198 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* wabcdefg */
199 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, /* hijklmno */
200 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* pqrstuvw */
201 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, /* abcdefgh */
202 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, /* ijklmnop */
203 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, /* qrstuvwa */
204 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, /* bcdefghi */
205 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, /* jklmnopq */
206 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, /* rstuvwab */
207 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, /* cdefghij */
208 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, /* klmnopqr */
209 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, /* stuvwabc */
210 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, /* defghijk */
211 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, /* lmnopqrs */
212 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, /* tuvwabcd */
213 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, /* efghijkl */
214 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, /* mnopqrst */
215 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, /* uvwabcde */
216 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, /* fghijklm */
217 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, /* nopqrstu */
218 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, /* vwabcdef */
219 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, /* ghijklmn */
220 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74 /* opqrst */
221 };
222
223 /* Define what the initial system looks like. */
224
225 #ifdef CTEST
test_application_define(void * first_unused_memory)226 VOID test_application_define(void *first_unused_memory)
227 #else
228 void netx_ipv6_hop_by_hop_fragment_test_application_define(void *first_unused_memory)
229 #endif
230 {
231
232 CHAR *pointer;
233 UINT status;
234
235
236 /* Setup the working pointer. */
237 pointer = (CHAR *) first_unused_memory;
238
239 /* Create the main thread. */
240 tx_thread_create(&ntest_0, "thread 0", ntest_0_entry, 0,
241 pointer, DEMO_STACK_SIZE,
242 4, 4, TX_NO_TIME_SLICE, TX_AUTO_START);
243 pointer = pointer + DEMO_STACK_SIZE;
244
245 /* Initialize the NetX system. */
246 nx_system_initialize();
247
248 /* Create a packet pool. */
249 status = nx_packet_pool_create(&pool_0, "NetX Main Packet Pool", 1536, pointer, 15360);
250 pointer = pointer + 15360;
251
252 if (status)
253 error_counter++;
254
255 /* Create an IP instance. */
256 status = nx_ip_create(&ip_0, "NetX IP Instance 0", IP_ADDRESS(1, 2, 3, 4), 0xFFFFFF00UL, &pool_0, _nx_ram_network_driver_512,
257 pointer, 2048, 1);
258 pointer = pointer + 2048;
259
260 /* Create an IP instance. */
261 status += nx_ip_create(&ip_1, "NetX IP Instance 1", IP_ADDRESS(1, 2, 3, 5), 0xFFFFFF00UL, &pool_0, _nx_ram_network_driver_512,
262 pointer, 2048, 1);
263 pointer = pointer + 2048;
264
265 /* Enable ICMP processing. */
266 status += nxd_icmp_enable(&ip_0);
267 status += nxd_icmp_enable(&ip_1);
268
269 /* Enable IPv6 */
270 status += nxd_ipv6_enable(&ip_0);
271 status += nxd_ipv6_enable(&ip_1);
272
273 /* Enable fragmentation */
274 status += nx_ip_fragment_enable(&ip_0);
275 status += nx_ip_fragment_enable(&ip_1);
276
277 /* Enable RAW packet for IP_0.*/
278 status += nx_ip_raw_packet_enable(&ip_0);
279
280 /* Check status. */
281 if(status)
282 error_counter++;
283 }
284
285
286
287 /* Define the test threads. */
288
ntest_0_entry(ULONG thread_input)289 static void ntest_0_entry(ULONG thread_input)
290 {
291
292 UINT status;
293 NX_PACKET *packet_ptr;
294
295
296 /* Print out test information banner. */
297 printf("NetX Test: IPv6 Hop by Hop Fragment Test.............................");
298
299 /* Check for earlier error. */
300 if (error_counter)
301 {
302
303 printf("ERROR!\n");
304 test_control_return(1);
305 }
306
307 /* Set IPv6 address. */
308 addr_0.nxd_ip_version = NX_IP_VERSION_V6;
309 addr_0.nxd_ip_address.v6[0] = 0xFE800000;
310 addr_0.nxd_ip_address.v6[1] = 0x00000000;
311 addr_0.nxd_ip_address.v6[2] = 0x00000000;
312 addr_0.nxd_ip_address.v6[3] = 0x00000001;
313 addr_1.nxd_ip_version = NX_IP_VERSION_V6;
314 addr_1.nxd_ip_address.v6[0] = 0xFE800000;
315 addr_1.nxd_ip_address.v6[1] = 0x00000000;
316 addr_1.nxd_ip_address.v6[2] = 0x00000000;
317 addr_1.nxd_ip_address.v6[3] = 0x00000002;
318
319 status = nxd_ipv6_address_set(&ip_0, 0, &addr_0, 10, NX_NULL);
320 status += nxd_ipv6_address_set(&ip_1, 0, &addr_1, 10, NX_NULL);
321
322 /* Check status */
323 if(status)
324 {
325
326 printf("ERROR!\n");
327 test_control_return(1);
328 }
329
330 /* DAD. */
331 tx_thread_sleep(5 * NX_IP_PERIODIC_RATE);
332
333 /* Set driver filter to replace echo request packet. */
334 advanced_packet_process_callback = packet_process;
335
336 /* Ping IP_1. */
337 status = nxd_icmp_ping(&ip_0, &addr_1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 28, &packet_ptr, NX_IP_PERIODIC_RATE);
338
339 /* Check status */
340 if(status)
341 {
342
343 printf("ERROR!\n");
344 test_control_return(1);
345 }
346
347 /* Check the length. */
348 if (packet_ptr -> nx_packet_length != 1400)
349 {
350
351 printf("ERROR!\n");
352 test_control_return(1);
353 }
354
355 nx_packet_release(packet_ptr);
356
357 printf("SUCCESS!\n");
358 test_control_return(0);
359 }
360
361
packet_process(NX_IP * ip_ptr,NX_PACKET * packet_ptr,UINT * operation_ptr,UINT * delay_ptr)362 static UINT packet_process(NX_IP *ip_ptr, NX_PACKET *packet_ptr, UINT *operation_ptr, UINT *delay_ptr)
363 {
364 NX_PACKET *my_packet;
365
366 if ((ip_ptr == &ip_0) && (packet_ptr -> nx_packet_length == 76))
367 {
368
369 /* Drop the packet. */
370 *operation_ptr = NX_RAMDRIVER_OP_DROP;
371
372 /* Inject Echo Request packet. */
373 if (nx_packet_allocate(&pool_0, &my_packet, NX_IPv6_PACKET, NX_WAIT_FOREVER) == NX_SUCCESS)
374 {
375
376 /* Fill in the packet with data. Skip the MAC and IPv6 header. */
377 memcpy(my_packet -> nx_packet_prepend_ptr, &icmp_pkt[54], sizeof(icmp_pkt) - 54);
378 my_packet -> nx_packet_length = sizeof(icmp_pkt) - 54;
379 my_packet -> nx_packet_append_ptr = my_packet -> nx_packet_prepend_ptr + my_packet -> nx_packet_length;
380
381 /* Send by RAW service. */
382 nxd_ip_raw_packet_send(ip_ptr, my_packet, &addr_1, NX_PROTOCOL_NEXT_HEADER_HOP_BY_HOP, 255, NX_IP_NORMAL);
383 }
384 }
385
386 return NX_TRUE;
387 }
388 #else
389 #ifdef CTEST
test_application_define(void * first_unused_memory)390 VOID test_application_define(void *first_unused_memory)
391 #else
392 void netx_ipv6_hop_by_hop_fragment_test_application_define(void *first_unused_memory)
393 #endif
394 {
395
396 /* Print out some test information banners. */
397 printf("NetX Test: IPv6 Hop by Hop Fragment Test.............................N/A\n");
398 test_control_return(3);
399 }
400 #endif /* NX_DISABLE_ICMP_INFO */
401