1 /* This NetX test concentrates on the IP Delete operation. */
2
3 #include "tx_api.h"
4 #include "nx_api.h"
5 #include "nx_ip.h"
6 #include "nx_icmp.h"
7 #include "nx_igmp.h"
8 #include "nx_arp.h"
9 #include "nx_rarp.h"
10 #include "nx_udp.h"
11 #include "nx_tcp.h"
12
13 extern void test_control_return(UINT status);
14
15 #if !defined(NX_DISABLE_IPV4)
16
17 #define DEMO_STACK_SIZE 2048
18
19
20 /* Define the ThreadX and NetX object control blocks... */
21
22 static TX_THREAD ntest_0;
23 static TX_THREAD ntest_1;
24
25 static NX_PACKET_POOL pool_0;
26 static NX_IP ip_0;
27 static NX_IP ip_1;
28 static NX_IP ip_2;
29
30
31 /* Define the counters used in the test application... */
32
33 static ULONG error_counter;
34 static NX_TCP_SOCKET client_socket;
35 static NX_UDP_SOCKET socket_0;
36 static UCHAR ip_stack[2048];
37 static UCHAR ip_stack_1[2048];
38 static UCHAR ip_stack_2[2048];
39 static UCHAR arp_stack[1024];
40 static UCHAR ping_done;
41
42
43 /* Define thread prototypes. */
44
45 static void ntest_0_entry(ULONG thread_input);
46 static void ntest_1_entry(ULONG thread_input);
47 extern void _nx_ram_network_driver_256(struct NX_IP_DRIVER_STRUCT *driver_req);
48 static void _nx_ram_network_driver_test(NX_IP_DRIVER *driver_req_ptr);
49
50
51 /* Define what the initial system looks like. */
52
53 #ifdef CTEST
test_application_define(void * first_unused_memory)54 VOID test_application_define(void *first_unused_memory)
55 #else
56 void netx_ip_delete_test_application_define(void *first_unused_memory)
57 #endif
58 {
59
60 CHAR *pointer;
61 UINT status;
62
63 /* Initialize the counters. */
64 error_counter = 0;
65 ping_done = NX_FALSE;
66
67 /* Setup the working pointer. */
68 pointer = (CHAR *) first_unused_memory;
69
70 /* Create the main thread. */
71 tx_thread_create(&ntest_0, "thread 0", ntest_0_entry, 0,
72 pointer, DEMO_STACK_SIZE,
73 4, 4, TX_NO_TIME_SLICE, TX_AUTO_START);
74 pointer = pointer + DEMO_STACK_SIZE;
75
76 /* Create the main thread. */
77 tx_thread_create(&ntest_1, "thread 1", ntest_1_entry, 0,
78 pointer, DEMO_STACK_SIZE,
79 3, 3, TX_NO_TIME_SLICE, TX_DONT_START);
80 pointer = pointer + DEMO_STACK_SIZE;
81
82 /* Initialize the NetX system. */
83 nx_system_initialize();
84
85 /* Create a packet pool. */
86 status = nx_packet_pool_create(&pool_0, "NetX Main Packet Pool", 256, pointer, 8192);
87 pointer = pointer + 8192;
88
89 if (status)
90 error_counter++;
91
92 /* Create IP instances. */
93 status = nx_ip_create(&ip_0, "NetX IP Instance 0", IP_ADDRESS(1, 2, 3, 9), 0xFFFFFF00UL, &pool_0, _nx_ram_network_driver_256,
94 ip_stack, sizeof(ip_stack), 1);
95
96 if (status)
97 error_counter++;
98
99 /* Enable ARP and supply ARP cache memory for IP Instance 0. */
100 status = nx_arp_enable(&ip_0, arp_stack, sizeof(arp_stack));
101
102 if (status)
103 error_counter++;
104
105 /* Enable TCP processing for IP instances. */
106 status = nx_tcp_enable(&ip_0);
107
108 if (status)
109 error_counter++;
110
111 /* Enable UDP traffic. */
112 status = nx_udp_enable(&ip_0);
113
114 if (status)
115 error_counter++;
116 }
117
118
119 /* Define the test threads. */
120
ntest_0_entry(ULONG thread_input)121 static void ntest_0_entry(ULONG thread_input)
122 {
123
124 UINT status;
125 NX_PACKET *packet_ptr;
126 UINT old_threshold;
127 #ifdef FEATURE_NX_IPV6
128 NXD_ADDRESS ipv6_address;
129 #endif /* FEATURE_NX_IPV6 */
130
131
132 /* Print out test information banner. */
133 printf("NetX Test: IP Delete Operation Test..................................");
134
135 /* Check for earlier error. */
136 if (error_counter)
137 {
138
139 printf("ERROR!\n");
140 test_control_return(1);
141 }
142
143 /* Create a socket. */
144 status = nx_tcp_socket_create(&ip_0, &client_socket, "Client Socket",
145 NX_IP_NORMAL, NX_FRAGMENT_OKAY, NX_IP_TIME_TO_LIVE, 200,
146 NX_NULL, NX_NULL);
147
148 /* Check for error. */
149 if (error_counter)
150 {
151
152 printf("ERROR!\n");
153 test_control_return(1);
154 }
155
156 /* Bind the socket. */
157 status = nx_tcp_client_socket_bind(&client_socket, 12, NX_WAIT_FOREVER);
158
159 /* Check status. */
160 if (status)
161 {
162 printf("ERROR!\n");
163 test_control_return(1);
164 }
165
166 /* Create a UDP socket. */
167 status = nx_udp_socket_create(&ip_0, &socket_0, "Socket 0", NX_IP_NORMAL, NX_FRAGMENT_OKAY, 0x80, 5);
168
169 /* Check status. */
170 if (status)
171 {
172 printf("ERROR!\n");
173 test_control_return(1);
174 }
175
176 /* Bind the UDP socket to the IP port. */
177 status = nx_udp_socket_bind(&socket_0, 0x88, TX_WAIT_FOREVER);
178
179 /* Check status. */
180 if (status)
181 {
182
183 printf("ERROR!\n");
184 test_control_return(1);
185 }
186
187 /* Delete the IP instance. */
188 status = nx_ip_delete(&ip_0);
189
190 /* Check for an error. */
191 if (status != NX_SOCKETS_BOUND)
192 {
193
194 printf("ERROR!\n");
195 test_control_return(1);
196 }
197
198 /* Unbind the socket. */
199 status = nx_tcp_client_socket_unbind(&client_socket);
200
201 /* Check status. */
202 if (status)
203 {
204 printf("ERROR!\n");
205 test_control_return(1);
206 }
207
208 /* Delete the socket. */
209 status = nx_tcp_socket_delete(&client_socket);
210
211 /* Check for error. */
212 if (status)
213 {
214
215 printf("ERROR!\n");
216 test_control_return(1);
217 }
218
219 /* Delete the IP instance. */
220 status = nx_ip_delete(&ip_0);
221
222 /* Check for an error. */
223 if (status != NX_SOCKETS_BOUND)
224 {
225
226 printf("ERROR!\n");
227 test_control_return(1);
228 }
229
230 /* Create a socket. */
231 status = nx_tcp_socket_create(&ip_0, &client_socket, "Client Socket",
232 NX_IP_NORMAL, NX_FRAGMENT_OKAY, NX_IP_TIME_TO_LIVE, 200,
233 NX_NULL, NX_NULL);
234
235 /* Check for error. */
236 if (error_counter)
237 {
238
239 printf("ERROR!\n");
240 test_control_return(1);
241 }
242
243 /* Bind the socket. */
244 status = nx_tcp_client_socket_bind(&client_socket, 12, NX_WAIT_FOREVER);
245
246 /* Check status. */
247 if (status)
248 {
249 printf("ERROR!\n");
250 test_control_return(1);
251 }
252
253 /* Unbind the UDP socket. */
254 status = nx_udp_socket_unbind(&socket_0);
255
256 /* Check status. */
257 if (status)
258 {
259
260 printf("ERROR!\n");
261 test_control_return(1);
262 }
263
264 /* Delete the UDP socket. */
265 status = nx_udp_socket_delete(&socket_0);
266
267 /* Check status. */
268 if (status)
269 {
270
271 printf("ERROR!\n");
272 test_control_return(1);
273 }
274
275 /* Delete the IP instance. */
276 status = nx_ip_delete(&ip_0);
277
278 /* Check for an error. */
279 if (status != NX_SOCKETS_BOUND)
280 {
281
282 printf("ERROR!\n");
283 test_control_return(1);
284 }
285
286 /* Unbind the socket. */
287 status = nx_tcp_client_socket_unbind(&client_socket);
288
289 /* Check status. */
290 if (status)
291 {
292 printf("ERROR!\n");
293 test_control_return(1);
294 }
295
296 /* Delete the socket. */
297 status = nx_tcp_socket_delete(&client_socket);
298
299 /* Check for error. */
300 if (status)
301 {
302
303 printf("ERROR!\n");
304 test_control_return(1);
305 }
306
307 /* Delete the IP instance. */
308 status = nx_ip_delete(&ip_0);
309
310 /* Check for an error. */
311 if (status)
312 {
313
314 printf("ERROR!\n");
315 test_control_return(1);
316 }
317
318 /* Create IP instances. */
319 status = nx_ip_create(&ip_0, "NetX IP Instance 0", IP_ADDRESS(1, 2, 3, 9), 0xFFFFFF00UL, &pool_0, _nx_ram_network_driver_256,
320 ip_stack, sizeof(ip_stack), 1);
321
322 /* Create IP instances. */
323 status += nx_ip_create(&ip_1, "NetX IP Instance 1", IP_ADDRESS(2, 2, 3, 9), 0xFFFFFF00UL, &pool_0, _nx_ram_network_driver_256,
324 ip_stack_1, sizeof(ip_stack_1), 1);
325
326 /* Create IP instances. */
327 status += nx_ip_create(&ip_2, "NetX IP Instance 2", IP_ADDRESS(3, 2, 3, 9), 0xFFFFFF00UL, &pool_0, _nx_ram_network_driver_256,
328 ip_stack_2, sizeof(ip_stack_2), 1);
329
330 /* Check for an error. */
331 if (status)
332 {
333
334 printf("ERROR!\n");
335 test_control_return(1);
336 }
337
338 /* Delete IP instances. */
339 status = nx_ip_delete(&ip_2);
340 status += nx_ip_delete(&ip_1);
341 status += nx_ip_delete(&ip_0);
342
343 /* Check for an error. */
344 if (status)
345 {
346
347 printf("ERROR!\n");
348 test_control_return(1);
349 }
350
351 /* Check RAW queue is cleared after IP is deleted. */
352 /* Create IP instances. */
353 status = nx_ip_create(&ip_0, "NetX IP Instance 0", IP_ADDRESS(1, 2, 3, 9), 0xFFFFFF00UL, &pool_0, _nx_ram_network_driver_256,
354 ip_stack, sizeof(ip_stack), 1);
355
356 /* Enable RAW traffic. */
357 status += nx_ip_raw_packet_enable(&ip_0);
358
359 /* Allocate a packet. */
360 status += nx_packet_allocate(&pool_0, &packet_ptr, NX_IP_PACKET, NX_WAIT_FOREVER);
361 status += nx_packet_data_append(packet_ptr, "ABC", 3, &pool_0, NX_WAIT_FOREVER);
362
363 /* Send the RAW packet. */
364 status += nx_ip_raw_packet_send(&ip_0, packet_ptr, IP_ADDRESS(1, 2, 3, 9), NX_IP_NORMAL);
365
366 /* Delete the IP instance. */
367 status += nx_ip_delete(&ip_0);
368
369 /* Check for error and pool available. */
370 if ((status) || (pool_0.nx_packet_pool_total != pool_0.nx_packet_pool_available))
371 {
372
373 printf("ERROR!\n");
374 test_control_return(1);
375 }
376
377 #ifndef NX_DISABLE_LOOPBACK_INTERFACE
378 /* Check RAW queue is cleared after IP is deleted. */
379 /* Create IP instances. */
380 status = nx_ip_create(&ip_0, "NetX IP Instance 0", IP_ADDRESS(1, 2, 3, 9), 0xFFFFFF00UL, &pool_0, _nx_ram_network_driver_256,
381 ip_stack, sizeof(ip_stack), 1);
382
383 /* Enable RAW traffic. */
384 status += nx_ip_raw_packet_enable(&ip_0);
385
386 /* Allocate a packet. */
387 status += nx_packet_allocate(&pool_0, &packet_ptr, NX_IP_PACKET, NX_WAIT_FOREVER);
388 status += nx_packet_data_append(packet_ptr, "ABC", 3, &pool_0, NX_WAIT_FOREVER);
389
390 /* Send the RAW packet. */
391 status += nx_ip_raw_packet_send(&ip_0, packet_ptr, IP_ADDRESS(127, 0, 0, 1), NX_IP_NORMAL);
392
393 /* Delete the IP instance. */
394 status += nx_ip_delete(&ip_0);
395
396 /* Check for error and pool available. */
397 if ((status) || (pool_0.nx_packet_pool_total != pool_0.nx_packet_pool_available))
398 {
399
400 printf("ERROR!\n");
401 test_control_return(1);
402 }
403 #endif /* NX_DISABLE_LOOPBACK_INTERFACE */
404
405
406 #ifndef NX_ENABLE_ICMP_ADDRESS_CHECK
407 /* Check ICMP queue is cleared after IP is deleted. */
408 /* Create IP instances. */
409 status = nx_ip_create(&ip_0, "NetX IP Instance 0", IP_ADDRESS(1, 2, 3, 9), 0xFFFFFF00UL, &pool_0, _nx_ram_network_driver_256,
410 ip_stack, sizeof(ip_stack), 1);
411
412 /* Enable ICMP. */
413 status += nx_icmp_enable(&ip_0);
414
415 /* Allocate a packet. */
416 status += nx_packet_allocate(&pool_0, &packet_ptr, NX_IP_PACKET, NX_WAIT_FOREVER);
417 status += nx_packet_data_append(packet_ptr, "ABCEFGHIJKLMNOPQRSTUVWXYZ", 26, &pool_0, NX_WAIT_FOREVER);
418
419 /* Disable preemption temporarily. */
420 tx_thread_preemption_change(&ntest_0, 0, &old_threshold);
421
422 /* Call _nx_icmp_packet_receive to directly receive the packet. */
423 _nx_icmp_packet_receive(&ip_0, packet_ptr);
424
425 /* Delete the IP instance. */
426 status += nx_ip_delete(&ip_0);
427
428 /* Restore preemption. */
429 tx_thread_preemption_change(&ntest_0, old_threshold, &old_threshold);
430
431 /* Check for error and pool available. */
432 if ((status) || (pool_0.nx_packet_pool_total != pool_0.nx_packet_pool_available))
433 {
434
435 printf("ERROR!\n");
436 test_control_return(1);
437 }
438 #endif /* NX_ENABLE_ICMP_ADDRESS_CHECK */
439
440
441 /* Check IGMP queue is cleared after IP is deleted. */
442 /* Create IP instances. */
443 status = nx_ip_create(&ip_0, "NetX IP Instance 0", IP_ADDRESS(1, 2, 3, 9), 0xFFFFFF00UL, &pool_0, _nx_ram_network_driver_256,
444 ip_stack, sizeof(ip_stack), 1);
445
446 /* Enable IGMP. */
447 status += nx_igmp_enable(&ip_0);
448
449 /* Allocate a packet. */
450 status += nx_packet_allocate(&pool_0, &packet_ptr, NX_IP_PACKET, NX_WAIT_FOREVER);
451 status += nx_packet_data_append(packet_ptr, "ABCEFGHIJKLMNOPQRSTUVWXYZ", 26, &pool_0, NX_WAIT_FOREVER);
452
453 /* Disable preemption temporarily. */
454 tx_thread_preemption_change(&ntest_0, 0, &old_threshold);
455
456 /* Call _nx_igmp_packet_receive to directly receive the packet. */
457 _nx_igmp_packet_receive(&ip_0, packet_ptr);
458
459 /* Delete the IP instance. */
460 status += nx_ip_delete(&ip_0);
461
462 /* Restore preemption. */
463 tx_thread_preemption_change(&ntest_0, old_threshold, &old_threshold);
464
465 /* Check for error and pool available. */
466 if ((status) || (pool_0.nx_packet_pool_total != pool_0.nx_packet_pool_available))
467 {
468
469 printf("ERROR!\n");
470 test_control_return(1);
471 }
472
473
474 /* Check TCP queue is cleared after IP is deleted. */
475 /* Create IP instances. */
476 status = nx_ip_create(&ip_0, "NetX IP Instance 0", IP_ADDRESS(1, 2, 3, 9), 0xFFFFFF00UL, &pool_0, _nx_ram_network_driver_256,
477 ip_stack, sizeof(ip_stack), 1);
478
479 /* Enable TCP. */
480 status += nx_tcp_enable(&ip_0);
481
482 /* Allocate a packet. */
483 status += nx_packet_allocate(&pool_0, &packet_ptr, NX_IP_PACKET, NX_WAIT_FOREVER);
484 status += nx_packet_data_append(packet_ptr, "ABCEFGHIJKLMNOPQRSTUVWXYZ", 26, &pool_0, NX_WAIT_FOREVER);
485
486 /* Disable preemption temporarily. */
487 tx_thread_preemption_change(&ntest_0, 0, &old_threshold);
488
489 /* Call _nx_tcp_packet_receive to directly receive the packet. */
490 _nx_tcp_packet_receive(&ip_0, packet_ptr);
491
492 /* Delete the IP instance. */
493 status += nx_ip_delete(&ip_0);
494
495 /* Restore preemption. */
496 tx_thread_preemption_change(&ntest_0, old_threshold, &old_threshold);
497
498 /* Check for error and pool available. */
499 if ((status) || (pool_0.nx_packet_pool_total != pool_0.nx_packet_pool_available))
500 {
501
502 printf("ERROR!\n");
503 test_control_return(1);
504 }
505
506
507 /* Check UDP queue is cleared after IP is deleted. */
508 /* Create IP instances. */
509 status = nx_ip_create(&ip_0, "NetX IP Instance 0", IP_ADDRESS(1, 2, 3, 9), 0xFFFFFF00UL, &pool_0, _nx_ram_network_driver_256,
510 ip_stack, sizeof(ip_stack), 1);
511
512 /* Enable UDP. */
513 status += nx_tcp_enable(&ip_0);
514
515 /* Allocate a packet. */
516 status += nx_packet_allocate(&pool_0, &packet_ptr, NX_IP_PACKET, NX_WAIT_FOREVER);
517 status += nx_packet_data_append(packet_ptr, "ABCEFGHIJKLMNOPQRSTUVWXYZ", 26, &pool_0, NX_WAIT_FOREVER);
518
519 /* Disable preemption temporarily. */
520 tx_thread_preemption_change(&ntest_0, 0, &old_threshold);
521
522 /* Call _nx_udp_packet_receive to directly receive the packet. */
523 _nx_udp_packet_receive(&ip_0, packet_ptr);
524
525 /* Delete the IP instance. */
526 status += nx_ip_delete(&ip_0);
527
528 /* Restore preemption. */
529 tx_thread_preemption_change(&ntest_0, old_threshold, &old_threshold);
530
531 /* Check for error and pool available. */
532 if ((status) || (pool_0.nx_packet_pool_total != pool_0.nx_packet_pool_available))
533 {
534
535 printf("ERROR!\n");
536 test_control_return(1);
537 }
538
539
540 /* Check ARP queue is cleared after IP is deleted. */
541 /* Create IP instances. */
542 status = nx_ip_create(&ip_0, "NetX IP Instance 0", IP_ADDRESS(1, 2, 3, 9), 0xFFFFFF00UL, &pool_0, _nx_ram_network_driver_256,
543 ip_stack, sizeof(ip_stack), 1);
544
545 /* Enable ARP. */
546 status += nx_arp_enable(&ip_0, arp_stack, sizeof(arp_stack));
547
548 /* Allocate a packet. */
549 status += nx_packet_allocate(&pool_0, &packet_ptr, NX_IP_PACKET, NX_WAIT_FOREVER);
550 status += nx_packet_data_append(packet_ptr, "ABCEFGHIJKLMNOPQRSTUVWXYZ", 26, &pool_0, NX_WAIT_FOREVER);
551
552 /* Disable preemption temporarily. */
553 tx_thread_preemption_change(&ntest_0, 0, &old_threshold);
554
555 /* Call _nx_arp_packet_deferred_receive to directly receive the packet. */
556 _nx_arp_packet_deferred_receive(&ip_0, packet_ptr);
557
558 /* Delete the IP instance. */
559 status += nx_ip_delete(&ip_0);
560
561 /* Restore preemption. */
562 tx_thread_preemption_change(&ntest_0, old_threshold, &old_threshold);
563
564 /* Check for error and pool available. */
565 if ((status) || (pool_0.nx_packet_pool_total != pool_0.nx_packet_pool_available))
566 {
567
568 printf("ERROR!\n");
569 test_control_return(1);
570 }
571
572
573 /* Check RARP queue is cleared after IP is deleted. */
574 /* Create IP instances. */
575 status = nx_ip_create(&ip_0, "NetX IP Instance 0", IP_ADDRESS(0, 0, 0, 0), 0xFFFFFF00UL, &pool_0, _nx_ram_network_driver_256,
576 ip_stack, sizeof(ip_stack), 1);
577
578 /* Enable RARP. */
579 status += nx_rarp_enable(&ip_0);
580 tx_thread_sleep(NX_IP_PERIODIC_RATE);
581
582 /* Allocate a packet. */
583 status += nx_packet_allocate(&pool_0, &packet_ptr, NX_IP_PACKET, NX_WAIT_FOREVER);
584 status += nx_packet_data_append(packet_ptr, "ABCEFGHIJKLMNOPQRSTUVWXYZ", 26, &pool_0, NX_WAIT_FOREVER);
585
586 /* Disable preemption temporarily. */
587 tx_thread_preemption_change(&ntest_0, 0, &old_threshold);
588
589 /* Call _nx_rarp_packet_deferred_receive to directly receive the packet. */
590 _nx_rarp_packet_deferred_receive(&ip_0, packet_ptr);
591
592 /* Delete the IP instance. */
593 status += nx_ip_delete(&ip_0);
594
595 /* Restore preemption. */
596 tx_thread_preemption_change(&ntest_0, old_threshold, &old_threshold);
597
598 /* Check for error and pool available. */
599 if ((status) || (pool_0.nx_packet_pool_total != pool_0.nx_packet_pool_available))
600 {
601
602 printf("ERROR!\n");
603 test_control_return(1);
604 }
605
606 #ifdef FEATURE_NX_IPV6
607 /* Test packet queued on ND cache. */
608 /* Create IP instances. */
609 nx_ip_create(&ip_0, "NetX IP Instance 0", IP_ADDRESS(1, 2, 3, 9), 0xFFFFFF00UL, &pool_0, _nx_ram_network_driver_256,
610 ip_stack, sizeof(ip_stack), 1);
611
612 nxd_ipv6_enable(&ip_0);
613 nxd_icmp_enable(&ip_0);
614 nxd_ipv6_address_set(&ip_0, 0, NX_NULL, 10, NX_NULL);
615 tx_thread_sleep(5 * NX_IP_PERIODIC_RATE);
616 ipv6_address.nxd_ip_version = NX_IP_VERSION_V6;
617 ipv6_address.nxd_ip_address.v6[0] = 0xFE800000;
618 ipv6_address.nxd_ip_address.v6[1] = 0;
619 ipv6_address.nxd_ip_address.v6[2] = 0;
620 ipv6_address.nxd_ip_address.v6[3] = 1;
621 nxd_icmp_ping(&ip_0, &ipv6_address, "", 0, &packet_ptr, NX_NO_WAIT);
622
623 /* Delete the IP instance. */
624 nx_ip_delete(&ip_0);
625
626 /* Check for pool available. */
627 if (pool_0.nx_packet_pool_total != pool_0.nx_packet_pool_available)
628 {
629
630 printf("ERROR!\n");
631 test_control_return(1);
632 }
633 #endif /* FEATURE_NX_IPV6 */
634
635
636 #ifdef __PRODUCT_NETXDUO__
637 /* Check ICMP suspension list is cleared after IP is deleted. */
638 /* Create IP instances. */
639 status = nx_ip_create(&ip_0, "NetX IP Instance 0", IP_ADDRESS(1, 2, 3, 9), 0xFFFFFF00UL, &pool_0, _nx_ram_network_driver_256,
640 ip_stack, sizeof(ip_stack), 1);
641
642 /* Enable ARP and ICMP. */
643 status += nx_arp_enable(&ip_0, arp_stack, sizeof(arp_stack));
644 status += nx_icmp_enable(&ip_0);
645
646 /* Resume thread 1 and let it start to ping. */
647 tx_thread_resume(&ntest_1);
648
649 /* Delete the IP instance. */
650 status += nx_ip_delete(&ip_0);
651
652 /* Check for error and pool available. */
653 if ((status) || (pool_0.nx_packet_pool_total != pool_0.nx_packet_pool_available) ||
654 (ping_done == NX_FALSE))
655 {
656
657 printf("ERROR!\n");
658 test_control_return(1);
659 }
660 #endif /* __PRODUCT_NETXDUO__ */
661
662 /* Create IP instances. */
663 status = nx_ip_create(&ip_0, "NetX IP Instance 0", IP_ADDRESS(1, 2, 3, 9), 0xFFFFFF00UL, &pool_0, _nx_ram_network_driver_test,
664 ip_stack, sizeof(ip_stack), 1);
665
666 /* Delete IP with sleep in driver. */
667 status += nx_ip_delete(&ip_0);
668 if (status || error_counter)
669 {
670
671 printf("ERROR!\n");
672 test_control_return(1);
673 }
674
675
676 /* Output successful. */
677 printf("SUCCESS!\n");
678 test_control_return(0);
679 }
680
681
ntest_1_entry(ULONG thread_input)682 static void ntest_1_entry(ULONG thread_input)
683 {
684 NX_PACKET *packet_ptr;
685 UINT status;
686
687 /* Ping an address not existed. */
688 status = nx_icmp_ping(&ip_0, IP_ADDRESS(1, 2, 3, 4), "", 0, &packet_ptr, NX_WAIT_FOREVER);
689
690 if (status == NX_SUCCESS)
691 {
692
693 /* No response should be received. */
694 printf("ERROR!\n");
695 test_control_return(1);
696 }
697
698 ping_done = NX_TRUE;
699 }
700
_nx_ram_network_driver_test(NX_IP_DRIVER * driver_req_ptr)701 static void _nx_ram_network_driver_test(NX_IP_DRIVER *driver_req_ptr)
702 {
703 if (driver_req_ptr -> nx_ip_driver_command == NX_LINK_UNINITIALIZE)
704 {
705 if (tx_thread_sleep(1))
706 {
707 error_counter++;
708 }
709 }
710 _nx_ram_network_driver_256(driver_req_ptr);
711 }
712
713 #else
714
715 #ifdef CTEST
test_application_define(void * first_unused_memory)716 VOID test_application_define(void *first_unused_memory)
717 #else
718 void netx_ip_delete_test_application_define(void *first_unused_memory)
719 #endif
720 {
721
722 /* Print out test information banner. */
723 printf("NetX Test: IP Delete Operation Test..................................N/A\n");
724
725 test_control_return(3);
726 }
727 #endif
728