1 /* This NetX test concentrates on the basic TCP operation.  */
2 
3 #include   "nx_tcp.h"
4 #include   "tx_api.h"
5 #include   "nx_api.h"
6 #include   "nx_ip.h"
7 #include   "nx_packet.h"
8 
9 extern void  test_control_return(UINT status);
10 
11 #if !defined(NX_DISABLE_ERROR_CHECKING) && !defined(NX_DISABLE_IPV4)
12 
13 #define     DEMO_STACK_SIZE         2048
14 
15 /* Define the ThreadX and NetX object control blocks...  */
16 
17 static TX_THREAD               thread_0;
18 
19 static NX_PACKET_POOL          pool_0;
20 #ifdef __PRODUCT_NETXDUO__
21 static NX_PACKET_POOL          invalid_pool;
22 #endif /* __PRODUCT_NETXDUO__ */
23 static NX_IP                   ip_0;
24 static NX_IP                   ip_1;
25 static NX_IP                   invalid_ip;
26 static NX_TCP_SOCKET           client_socket;
27 static NX_TCP_SOCKET           server_socket;
28 static NX_TCP_SOCKET           invalid_socket;
29 
30 /* Define the counters used in the demo application...  */
31 static ULONG                   error_counter =     0;
32 
33 
34 /* Define thread prototypes.  */
35 static void    thread_0_entry(ULONG thread_input);
36 static void    tcp_receive_notify(NX_TCP_SOCKET *socket_ptr);
37 #if defined(NX_ENABLE_TCP_QUEUE_DEPTH_UPDATE_NOTIFY) && defined(__PRODUCT_NETXDUO__)
38 static void    tcp_socket_queue_depth_notify(NX_TCP_SOCKET *socket_ptr);
39 #endif
40 #ifdef __PRODUCT_NETXDUO__
41 static void    window_update_notify(NX_TCP_SOCKET *socket_ptr);
42 #endif /* __PRODUCT_NETXDUO__ */
43 extern void    _nx_ram_network_driver_256(struct NX_IP_DRIVER_STRUCT *driver_req);
44 
45 
46 /* Define what the initial system looks like.  */
47 
48 #ifdef CTEST
test_application_define(void * first_unused_memory)49 VOID test_application_define(void *first_unused_memory)
50 #else
51 void    netx_tcp_nxe_api_test_application_define(void *first_unused_memory)
52 #endif
53 {
54 
55 CHAR    *pointer;
56 UINT    status;
57 
58 
59     /* Setup the working pointer.  */
60     pointer =  (CHAR *) first_unused_memory;
61 
62     /* Create the main thread.  */
63     tx_thread_create(&thread_0, "thread 0", thread_0_entry, 0,
64             pointer, DEMO_STACK_SIZE,
65             4, 4, TX_NO_TIME_SLICE, TX_AUTO_START);
66 
67     pointer =  pointer + DEMO_STACK_SIZE;
68 
69     /* Initialize the NetX system.  */
70     nx_system_initialize();
71 
72     /* Create a packet pool.  */
73     status =  nx_packet_pool_create(&pool_0, "NetX Main Packet Pool", 256, pointer, 8192);
74     pointer = pointer + 8192;
75 
76     if (status)
77         error_counter++;
78 
79     /* Create an IP instance.  */
80     status = nx_ip_create(&ip_0, "NetX IP Instance 0", IP_ADDRESS(1, 2, 3, 4), 0xFFFFFF00UL, &pool_0, _nx_ram_network_driver_256,
81                     pointer, 2048, 1);
82     pointer =  pointer + 2048;
83 
84     /* Create another IP instance.  */
85     status += nx_ip_create(&ip_1, "NetX IP Instance 1", IP_ADDRESS(1, 2, 3, 5), 0xFFFFFF00UL, &pool_0, _nx_ram_network_driver_256,
86                     pointer, 2048, 1);
87     pointer =  pointer + 2048;
88 
89     if (status)
90         error_counter++;
91 
92     /* Enable ARP and supply ARP cache memory for IP Instance 0.  */
93     status =  nx_arp_enable(&ip_0, (void *) pointer, 1024);
94     pointer = pointer + 1024;
95 
96     /* Enable ARP and supply ARP cache memory for IP Instance 1.  */
97     status +=  nx_arp_enable(&ip_1, (void *) pointer, 1024);
98     pointer = pointer + 1024;
99 
100     /* Check ARP enable status.  */
101     if (status)
102         error_counter++;
103 }
104 
105 
106 /* Define the test threads.  */
107 
thread_0_entry(ULONG thread_input)108 static void    thread_0_entry(ULONG thread_input)
109 {
110 
111 UINT        status;
112 NX_PACKET   *packet;
113 NX_PACKET   *unknow_packet;
114 #ifdef __PRODUCT_NETXDUO__
115 NX_PACKET   invalid_packet;
116 NX_PACKET   *invalid_packet_2;
117 #endif /* __PRODUCT_NETXDUO__ */
118 #ifdef FEATURE_NX_IPV6
119 NXD_ADDRESS ip_address;
120 NXD_ADDRESS nxd_ip_address;
121 #endif
122 UINT        port;
123 UINT        free_port;
124 ULONG       mss, peer_mss, peer_ip_address, peer_port, bytes_available;
125 ULONG       tcp_packets_sent, tcp_bytes_sent, tcp_packets_received, tcp_bytes_received, tcp_invalid_packets, tcp_receive_packets_dropped, tcp_checksum_errors, tcp_connections, tcp_disconnections, tcp_connections_dropped, tcp_retransmit_packets;
126 ULONG       packets_sent, bytes_sent, packets_received, bytes_received, retransmit_packets, packets_queued, checksum_errors, socket_state, transmit_queue_depth, transmit_window, receive_window;
127 
128     /* Print out some test information banners.  */
129     printf("NetX Test:   TCP NXE API Test..........................................");
130 
131     /* Check for earlier error.  */
132     if (error_counter)
133     {
134 
135         printf("ERROR!\n");
136         test_control_return(1);
137     }
138 
139     /************************************************/
140     /* Tested the nxe_tcp_enable api                */
141     /************************************************/
142 
143     /* Enable the TCP feature for invalid IP instance.  */
144     status = nx_tcp_enable(&invalid_ip);
145 
146     /* Check for error.  */
147     if (status != NX_PTR_ERROR)
148     {
149 
150         printf("ERROR!\n");
151         test_control_return(1);
152     }
153 
154     /* Enable the TCP feature for valid IP instance.  */
155     status = nx_tcp_enable(&ip_0);
156 
157     /* Check for error.  */
158     if (status)
159     {
160 
161         printf("ERROR!\n");
162         test_control_return(1);
163     }
164 
165     /* Enable the TCP feature for valid IP instance.  */
166     status = nx_tcp_enable(&ip_1);
167 
168     /* Check for error.  */
169     if (status)
170     {
171 
172         printf("ERROR!\n");
173         test_control_return(1);
174     }
175 
176     /* Enable the TCP feature again.  */
177     status = nx_tcp_enable(&ip_0);
178 
179     /* Check for error.  */
180     if (status != NX_ALREADY_ENABLED)
181     {
182 
183         printf("ERROR!\n");
184         test_control_return(1);
185     }
186 
187     /************************************************/
188     /* Tested the nxe_tcp_socket_create api         */
189     /************************************************/
190 
191     /* Create the TCP socket for invalid IP instance.  */
192     status =  nx_tcp_socket_create(NX_NULL, &client_socket, "Client Socket",
193                                    NX_IP_NORMAL, NX_FRAGMENT_OKAY, NX_IP_TIME_TO_LIVE, 200,
194                                    NX_NULL, NX_NULL);
195 
196     /* Check for error.  */
197     if (status != NX_PTR_ERROR)
198     {
199 
200         printf("ERROR!\n");
201         test_control_return(1);
202     }
203 
204     /* Create the TCP socket for invalid IP instance.  */
205     status =  nx_tcp_socket_create(&invalid_ip, &client_socket, "Client Socket",
206                                    NX_IP_NORMAL, NX_FRAGMENT_OKAY, NX_IP_TIME_TO_LIVE, 200,
207                                    NX_NULL, NX_NULL);
208 
209     /* Check for error.  */
210     if (status != NX_PTR_ERROR)
211     {
212 
213         printf("ERROR!\n");
214         test_control_return(1);
215     }
216 
217     /* Create the TCP socket for invalid socket.  */
218     status =  nx_tcp_socket_create(&ip_0, NX_NULL, "Client Socket",
219                                    NX_IP_NORMAL, NX_FRAGMENT_OKAY, NX_IP_TIME_TO_LIVE, 200,
220                                    NX_NULL, NX_NULL);
221 
222     /* Check for error.  */
223     if (status != NX_PTR_ERROR)
224     {
225 
226         printf("ERROR!\n");
227         test_control_return(1);
228     }
229 
230     /* Set the invalid IP instance parameter.  */
231     invalid_ip.nx_ip_id = NX_IP_ID;
232 
233     /* Create the TCP socket with invalid structure size.  */
234     status =  _nxe_tcp_socket_create(&ip_0, &client_socket, "Client Socket",
235                                    NX_IP_NORMAL, NX_FRAGMENT_OKAY, NX_IP_TIME_TO_LIVE, 200,
236                                    NX_NULL, NX_NULL, sizeof(NX_TCP_SOCKET) + 1);
237 
238     /* Check for error.  */
239     if (status != NX_PTR_ERROR)
240     {
241 
242         printf("ERROR!\n");
243         test_control_return(1);
244     }
245 
246     /* Create the TCP socket for IP instance with  socket.  */
247     status =  nx_tcp_socket_create(&invalid_ip, &client_socket, "Client Socket",
248                                    NX_IP_NORMAL, NX_FRAGMENT_OKAY, NX_IP_TIME_TO_LIVE, 200,
249                                    NX_NULL, NX_NULL);
250 
251     /* Check for error.  */
252     if (status != NX_NOT_ENABLED)
253     {
254 
255         printf("ERROR!\n");
256         test_control_return(1);
257     }
258 
259     /* Create the TCP socket with invalid type of service.  */
260     status =  nx_tcp_socket_create(&ip_0, &client_socket, "Client Socket",
261                                    0xFFFFFFFF, NX_FRAGMENT_OKAY, NX_IP_TIME_TO_LIVE, 200,
262                                    NX_NULL, NX_NULL);
263 
264     /* Check for error.  */
265     if (status != NX_OPTION_ERROR)
266     {
267 
268         printf("ERROR!\n");
269         test_control_return(1);
270     }
271 
272     /* Create the TCP socket with invalid type of fragment.  */
273     status =  nx_tcp_socket_create(&ip_0, &client_socket, "Client Socket",
274                                    NX_IP_NORMAL, 0xFFFFFFFF, NX_IP_TIME_TO_LIVE, 200,
275                                    NX_NULL, NX_NULL);
276 
277     /* Check for error.  */
278     if (status != NX_OPTION_ERROR)
279     {
280 
281         printf("ERROR!\n");
282         test_control_return(1);
283     }
284 
285     /* Create the TCP socket with invalid time of live.  */
286     status =  nx_tcp_socket_create(&ip_0, &client_socket, "Client Socket",
287                                    NX_IP_NORMAL, NX_DONT_FRAGMENT, 0xFFFFFFFF, 200,
288                                    NX_NULL, NX_NULL);
289 
290     /* Check for error.  */
291     if (status != NX_OPTION_ERROR)
292     {
293 
294         printf("ERROR!\n");
295         test_control_return(1);
296     }
297 
298     /* Create the TCP socket with invalid window size.  */
299     status =  nx_tcp_socket_create(&ip_0, &client_socket, "Client Socket",
300                                    NX_IP_NORMAL, NX_FRAGMENT_OKAY, NX_IP_TIME_TO_LIVE, 0,
301                                    NX_NULL, NX_NULL);
302 
303     /* Check for error.  */
304     if (status != NX_OPTION_ERROR)
305     {
306 
307         printf("ERROR!\n");
308         test_control_return(1);
309     }
310 
311 #ifdef __PRODUCT_NETXDUO__
312 
313     /* Create the TCP socket with invalid window size.  */
314     status =  nx_tcp_socket_create(&ip_0, &client_socket, "Client Socket",
315                                    NX_IP_NORMAL, NX_FRAGMENT_OKAY, NX_IP_TIME_TO_LIVE, (1 << 30),
316                                    NX_NULL, NX_NULL);
317 
318     /* Check for error.  */
319     if (status != NX_OPTION_ERROR)
320     {
321 
322         printf("ERROR!\n");
323         test_control_return(1);
324     }
325 #endif
326 
327     /* Create the TCP socket with valid parameters.  */
328     status =  nx_tcp_socket_create(&ip_0, &client_socket, "Client Socket",
329                                    NX_IP_NORMAL, NX_FRAGMENT_OKAY, NX_IP_TIME_TO_LIVE, 200,
330                                    NX_NULL, NX_NULL);
331 
332     /* Check for error.  */
333     if (status)
334     {
335 
336         printf("ERROR!\n");
337         test_control_return(1);
338     }
339 
340     /* Create the TCP socket with valid parameters.  */
341     status =  nx_tcp_socket_create(&ip_1, &server_socket, "Server Socket",
342                                    NX_IP_NORMAL, NX_FRAGMENT_OKAY, NX_IP_TIME_TO_LIVE, 200,
343                                    NX_NULL, NX_NULL);
344 
345     /* Check for error.  */
346     if (status)
347     {
348 
349         printf("ERROR!\n");
350         test_control_return(1);
351     }
352 
353     /* Create the same Client socket again.  */
354     status =  nx_tcp_socket_create(&ip_0, &client_socket, "Client Socket",
355                                    NX_IP_NORMAL, NX_FRAGMENT_OKAY, NX_IP_TIME_TO_LIVE, 200,
356                                    NX_NULL, NX_NULL);
357 
358     /* Check for error.  */
359     if (status != NX_PTR_ERROR)
360     {
361 
362         printf("ERROR!\n");
363         test_control_return(1);
364     }
365 
366     /************************************************/
367     /* Tested the nxe_tcp_free_port_find api        */
368     /************************************************/
369 
370     /* Find the free port with invalid IP instance.  */
371     status =  nx_tcp_free_port_find(NX_NULL, 80, &free_port);
372 
373     /* Check for error.  */
374     if (status != NX_PTR_ERROR)
375     {
376 
377         printf("ERROR!\n");
378         test_control_return(1);
379     }
380 
381     /* Clear the invalid IP instance ID.  */
382     invalid_ip.nx_ip_id = NX_NULL;
383 
384     /* Find the free port with invalid IP instance ID.  */
385     status =  nx_tcp_free_port_find(&invalid_ip, 80, &free_port);
386 
387     /* Check for error.  */
388     if (status != NX_PTR_ERROR)
389     {
390 
391         printf("ERROR!\n");
392         test_control_return(1);
393     }
394 
395     /* Find the free port with invalid free port pointer.  */
396     status =  nx_tcp_free_port_find(&ip_0, 80, NX_NULL);
397 
398     /* Check for error.  */
399     if (status != NX_PTR_ERROR)
400     {
401 
402         printf("ERROR!\n");
403         test_control_return(1);
404     }
405 
406     /* Set the invalid IP instance ID.  */
407     invalid_ip.nx_ip_id = NX_IP_ID;
408 
409     /* Find the free port when disable the TCP feature.  */
410     status =  nx_tcp_free_port_find(&invalid_ip, 80, &free_port);
411 
412     /* Check for error.  */
413     if (status != NX_NOT_ENABLED)
414     {
415 
416         printf("ERROR!\n");
417         test_control_return(1);
418     }
419 
420     /* Find the free port with invalid port.  */
421     status =  nx_tcp_free_port_find(&ip_0, 0xFFFFFFFF, &free_port);
422 
423     /* Check for error.  */
424     if (status != NX_INVALID_PORT)
425     {
426 
427         printf("ERROR!\n");
428         test_control_return(1);
429     }
430 
431     /************************************************/
432     /* Tested the nxe_tcp_info_get api              */
433     /************************************************/
434 
435     /* Get the TCP information with invalid IP instance.  */
436     status =  nx_tcp_info_get(NX_NULL, &tcp_packets_sent, &tcp_bytes_sent, &tcp_packets_received, &tcp_bytes_received,
437                               &tcp_invalid_packets, &tcp_receive_packets_dropped, &tcp_checksum_errors, &tcp_connections,
438                               &tcp_disconnections, &tcp_connections_dropped, &tcp_retransmit_packets);
439 
440     /* Check for error.  */
441     if (status != NX_PTR_ERROR)
442     {
443 
444         printf("ERROR!\n");
445         test_control_return(1);
446     }
447 
448     /* Clear the invalid IP instance ID.  */
449     invalid_ip.nx_ip_id = NX_NULL;
450 
451     /* Get the TCP information with invalid IP instance ID.  */
452     status =  nx_tcp_info_get(&invalid_ip, &tcp_packets_sent, &tcp_bytes_sent, &tcp_packets_received, &tcp_bytes_received,
453                               &tcp_invalid_packets, &tcp_receive_packets_dropped, &tcp_checksum_errors, &tcp_connections,
454                               &tcp_disconnections, &tcp_connections_dropped, &tcp_retransmit_packets);
455 
456     /* Check for error.  */
457     if (status != NX_PTR_ERROR)
458     {
459 
460         printf("ERROR!\n");
461         test_control_return(1);
462     }
463 
464     /* Set the invalid IP instance ID.  */
465     invalid_ip.nx_ip_id = NX_IP_ID;
466 
467     /* Get the TCP information when disable the TCP feature.  */
468     status =  nx_tcp_info_get(&invalid_ip, &tcp_packets_sent, &tcp_bytes_sent, &tcp_packets_received, &tcp_bytes_received,
469                               &tcp_invalid_packets, &tcp_receive_packets_dropped, &tcp_checksum_errors, &tcp_connections,
470                               &tcp_disconnections, &tcp_connections_dropped, &tcp_retransmit_packets);
471 
472     /* Check for error.  */
473     if (status != NX_NOT_ENABLED)
474     {
475 
476         printf("ERROR!\n");
477         test_control_return(1);
478     }
479 
480 
481     /************************************************/
482     /* Tested the nxe_tcp_client_socket_bind api    */
483     /************************************************/
484 
485     /* Bind the port with invalid socket.  */
486     status =  nx_tcp_client_socket_bind(NX_NULL, 80, 5 * NX_IP_PERIODIC_RATE);
487 
488     /* Check for error.  */
489     if (status != NX_PTR_ERROR)
490     {
491 
492         printf("ERROR!\n");
493         test_control_return(1);
494     }
495 
496     /* Clear the socket ID.  */
497     invalid_socket.nx_tcp_socket_id  = NX_NULL;
498 
499     /* Bind the port with invalid socket ID.  */
500     status =  nx_tcp_client_socket_bind(&invalid_socket, 80, 5 * NX_IP_PERIODIC_RATE);
501 
502     /* Check for error.  */
503     if (status != NX_PTR_ERROR)
504     {
505 
506         printf("ERROR!\n");
507         test_control_return(1);
508     }
509 
510     /* Set the socket ID.  */
511     invalid_socket.nx_tcp_socket_id  = NX_TCP_ID;
512 
513     /* Disable the TCP feature for invalid IP instance.  */
514     invalid_socket.nx_tcp_socket_ip_ptr = (NX_IP *)&invalid_ip;
515     invalid_socket.nx_tcp_socket_ip_ptr -> nx_ip_tcp_packet_receive = NX_NULL;
516 
517     /* Bind the port when disable TCP feature.  */
518     status =  nx_tcp_client_socket_bind(&invalid_socket, 80, 5 * NX_IP_PERIODIC_RATE);
519 
520     /* Check for error.  */
521     if (status != NX_NOT_ENABLED)
522     {
523 
524         printf("ERROR!\n");
525         test_control_return(1);
526     }
527 
528     /* Bind the port with invalid prot.  */
529     status =  nx_tcp_client_socket_bind(&client_socket, 0xFFFFFFFF, 5 * NX_IP_PERIODIC_RATE);
530 
531     /* Check for error.  */
532     if (status != NX_INVALID_PORT)
533     {
534 
535         printf("ERROR!\n");
536         test_control_return(1);
537     }
538 
539 
540     /************************************************/
541     /* Tested the nxe_tcp_client_socket_connect api */
542     /************************************************/
543 
544     /* Connect the TCP with invalid socket.  */
545     status =  nx_tcp_client_socket_connect(NX_NULL, IP_ADDRESS(1, 2, 3, 5), 80, 5 * NX_IP_PERIODIC_RATE);
546 
547     /* Check for error.  */
548     if (status != NX_PTR_ERROR)
549     {
550 
551         printf("ERROR!\n");
552         test_control_return(1);
553     }
554 
555     /* Clear the socket ID.  */
556     invalid_socket.nx_tcp_socket_id  = NX_NULL;
557 
558     /* Connect the TCP with invalid socket ID.  */
559     status =  nx_tcp_client_socket_connect(&invalid_socket, IP_ADDRESS(1, 2, 3, 5), 80, 5 * NX_IP_PERIODIC_RATE);
560 
561     /* Check for error.  */
562     if (status != NX_PTR_ERROR)
563     {
564 
565         printf("ERROR!\n");
566         test_control_return(1);
567     }
568 
569     /* Set the socket ID.  */
570     invalid_socket.nx_tcp_socket_id  = NX_TCP_ID;
571 
572     /* Disable the TCP feature for invalid IP instance.  */
573     invalid_socket.nx_tcp_socket_ip_ptr = (NX_IP *)&invalid_ip;
574     invalid_socket.nx_tcp_socket_ip_ptr -> nx_ip_tcp_packet_receive = NX_NULL;
575 
576     /* Connect the TCP when disable the TCP feature.  */
577     status =  nx_tcp_client_socket_connect(&invalid_socket, IP_ADDRESS(1, 2, 3, 5), 80, 5 * NX_IP_PERIODIC_RATE);
578 
579     /* Check for error.  */
580     if (status != NX_NOT_ENABLED)
581     {
582 
583         printf("ERROR!\n");
584         test_control_return(1);
585     }
586 
587     /* Connect the TCP with invalid IP address.  */
588     status =  nx_tcp_client_socket_connect(&client_socket, IP_ADDRESS(0, 0, 0, 0), 80, 5 * NX_IP_PERIODIC_RATE);
589 
590     /* Check for error.  */
591 #ifdef __PRODUCT_NETXDUO__
592     if (status != NX_IP_ADDRESS_ERROR)
593 #else
594     if (status != NX_NOT_BOUND)
595 #endif
596     {
597 
598         printf("ERROR!\n");
599         test_control_return(1);
600     }
601 
602     /* Connect the TCP with invalid IP address.  */
603     status =  nx_tcp_client_socket_connect(&client_socket, IP_ADDRESS(255, 255, 255, 255), 80, 5 * NX_IP_PERIODIC_RATE);
604 
605     /* Check for error.  */
606     if (status != NX_IP_ADDRESS_ERROR)
607     {
608 
609         printf("ERROR!\n");
610         test_control_return(1);
611     }
612 
613     /* Connect the TCP with invalid port.  */
614     status =  nx_tcp_client_socket_connect(&client_socket, IP_ADDRESS(1, 2, 3, 5), 0xFFFFFFFF, 5 * NX_IP_PERIODIC_RATE);
615 
616     /* Check for error.  */
617     if (status != NX_INVALID_PORT)
618     {
619 
620         printf("ERROR!\n");
621         test_control_return(1);
622     }
623 
624 #ifdef FEATURE_NX_IPV6
625     /*************************************************/
626     /* Tested the nxde_tcp_client_socket_connect api */
627     /*************************************************/
628 
629     /* Set the IP address.  */
630     ip_address.nxd_ip_version = NX_IP_VERSION_V4;
631     ip_address.nxd_ip_address.v4 = IP_ADDRESS(1, 2, 3, 5);
632 
633     /* Connect the TCP with invalid socket.  */
634     status =  nxd_tcp_client_socket_connect(NX_NULL, &ip_address, 80, 5 * NX_IP_PERIODIC_RATE);
635 
636     /* Check for error.  */
637     if (status != NX_PTR_ERROR)
638     {
639 
640         printf("ERROR!\n");
641         test_control_return(1);
642     }
643 
644     /* Clear the socket ID.  */
645     invalid_socket.nx_tcp_socket_id  = NX_NULL;
646 
647     /* Connect the TCP with invalid socket ID.  */
648     status =  nxd_tcp_client_socket_connect(&invalid_socket, &ip_address, 80, 5 * NX_IP_PERIODIC_RATE);
649 
650     /* Check for error.  */
651     if (status != NX_PTR_ERROR)
652     {
653 
654         printf("ERROR!\n");
655         test_control_return(1);
656     }
657 
658     /* Set the socket ID.  */
659     invalid_socket.nx_tcp_socket_id  = NX_TCP_ID;
660 
661     /* Disable the TCP feature for invalid IP instance.  */
662     invalid_socket.nx_tcp_socket_ip_ptr = (NX_IP *)&invalid_ip;
663     invalid_socket.nx_tcp_socket_ip_ptr -> nx_ip_tcp_packet_receive = NX_NULL;
664 
665     /* Connect the TCP when disable the TCP feature.  */
666     status =  nxd_tcp_client_socket_connect(&invalid_socket, &ip_address, 80, 5 * NX_IP_PERIODIC_RATE);
667 
668     /* Check for error.  */
669     if (status != NX_NOT_ENABLED)
670     {
671 
672         printf("ERROR!\n");
673         test_control_return(1);
674     }
675 
676     /* Connect the TCP with invalid IP address.  */
677     status =  nxd_tcp_client_socket_connect(&client_socket, NX_NULL, 80, 5 * NX_IP_PERIODIC_RATE);
678 
679     /* Check for error.  */
680     if (status != NX_IP_ADDRESS_ERROR)
681     {
682 
683         printf("ERROR!\n");
684         test_control_return(1);
685     }
686 
687     /* Set the IP address as invalid version.  */
688     ip_address.nxd_ip_version = 0x80;
689     ip_address.nxd_ip_address.v4 = IP_ADDRESS(1, 2, 3, 5);
690 
691     /* Connect the TCP with invalid IP address.  */
692     status =  nxd_tcp_client_socket_connect(&client_socket, &ip_address, 80, 5 * NX_IP_PERIODIC_RATE);
693 
694     /* Check for error.  */
695     if (status != NX_IP_ADDRESS_ERROR)
696     {
697 
698         printf("ERROR!\n");
699         test_control_return(1);
700     }
701 
702     /* Set the IP address as invalid address.  */
703     ip_address.nxd_ip_version = NX_IP_VERSION_V4;
704     ip_address.nxd_ip_address.v4 = IP_ADDRESS(255, 255, 255, 255);
705 
706     /* Connect the TCP with invalid IP address.  */
707     status =  nxd_tcp_client_socket_connect(&client_socket, &ip_address, 80, 5 * NX_IP_PERIODIC_RATE);
708 
709     /* Check for error.  */
710     if (status != NX_IP_ADDRESS_ERROR)
711     {
712 
713         printf("ERROR!\n");
714         test_control_return(1);
715     }
716 
717     /* Set the IP address as invalid address.  */
718     ip_address.nxd_ip_version = NX_IP_VERSION_V4;
719     ip_address.nxd_ip_address.v4 = IP_ADDRESS(128, 0, 0, 1);
720 
721     /* Connect the TCP with valid IP address and invalid port.  */
722     status =  nxd_tcp_client_socket_connect(&client_socket, &ip_address, 0xFFFFFFFF, 5 * NX_IP_PERIODIC_RATE);
723 
724     /* Check for error.  */
725     if (status != NX_INVALID_PORT)
726     {
727 
728         printf("ERROR!\n");
729         test_control_return(1);
730     }
731 
732     /* Set the IP address as valid address.  */
733     ip_address.nxd_ip_version = NX_IP_VERSION_V4;
734     ip_address.nxd_ip_address.v4 = IP_ADDRESS(192, 0, 0, 1);
735 
736     /* Connect the TCP with invalid port.  */
737     status =  nxd_tcp_client_socket_connect(&client_socket, &ip_address, 0xFFFFFFFF, 5 * NX_IP_PERIODIC_RATE);
738 
739     /* Check for error.  */
740     if (status != NX_INVALID_PORT)
741     {
742 
743         printf("ERROR!\n");
744         test_control_return(1);
745     }
746 #endif
747 
748     /************************************************/
749     /* Tested the nxe_tcp_client_socket_port_get api*/
750     /************************************************/
751 
752     /* Get the Client socket port with invalid socket.  */
753     status =  nx_tcp_client_socket_port_get(NX_NULL, &port);
754 
755     /* Check for error.  */
756     if (status != NX_PTR_ERROR)
757     {
758 
759         printf("ERROR!\n");
760         test_control_return(1);
761     }
762 
763     /* Clear the socket ID.  */
764     invalid_socket.nx_tcp_socket_id  = NX_NULL;
765 
766     /* Get the Client socket port with invalid socket ID.  */
767     status =  nx_tcp_client_socket_port_get(&invalid_socket, &port);
768 
769     /* Check for error.  */
770     if (status != NX_PTR_ERROR)
771     {
772 
773         printf("ERROR!\n");
774         test_control_return(1);
775     }
776 
777     /* Get the Client socket port with invalid port pointer.  */
778     status =  nx_tcp_client_socket_port_get(&client_socket, NX_NULL);
779 
780     /* Check for error.  */
781     if (status != NX_PTR_ERROR)
782     {
783 
784         printf("ERROR!\n");
785         test_control_return(1);
786     }
787 
788     /* Set the socket ID.  */
789     invalid_socket.nx_tcp_socket_id  = NX_TCP_ID;
790 
791     /* Disable the TCP feature for invalid IP instance.  */
792     invalid_socket.nx_tcp_socket_ip_ptr = (NX_IP *)&invalid_ip;
793     invalid_socket.nx_tcp_socket_ip_ptr -> nx_ip_tcp_packet_receive = NX_NULL;
794 
795     /* Get the Client socket port when disable TCP feature.  */
796     status =  nx_tcp_client_socket_port_get(&invalid_socket, &port);
797 
798     /* Check for error.  */
799     if (status != NX_NOT_ENABLED)
800     {
801 
802         printf("ERROR!\n");
803         test_control_return(1);
804     }
805 
806     /************************************************/
807     /* Tested the nxe_tcp_client_socket_unbind api  */
808     /************************************************/
809 
810     /* Unbind the Client socket with invalid socket.  */
811     status =  nx_tcp_client_socket_unbind(NX_NULL);
812 
813     /* Check for error.  */
814     if (status != NX_PTR_ERROR)
815     {
816 
817         printf("ERROR!\n");
818         test_control_return(1);
819     }
820 
821     /* Clear the socket ID.  */
822     invalid_socket.nx_tcp_socket_id  = NX_NULL;
823 
824     /* Unbind the Client socket with invalid socket ID.  */
825     status =  nx_tcp_client_socket_unbind(&invalid_socket);
826 
827     /* Check for error.  */
828     if (status != NX_PTR_ERROR)
829     {
830 
831         printf("ERROR!\n");
832         test_control_return(1);
833     }
834 
835     /* Set the socket ID.  */
836     invalid_socket.nx_tcp_socket_id  = NX_TCP_ID;
837 
838     /* Disable the TCP feature for invalid IP instance.  */
839     invalid_socket.nx_tcp_socket_ip_ptr = (NX_IP *)&invalid_ip;
840     invalid_socket.nx_tcp_socket_ip_ptr -> nx_ip_tcp_packet_receive = NX_NULL;
841 
842     /* Unbind the Client socket when disable the TCP feature.  */
843     status =  nx_tcp_client_socket_unbind(&invalid_socket);
844 
845     /* Check for error.  */
846     if (status != NX_NOT_ENABLED)
847     {
848 
849         printf("ERROR!\n");
850         test_control_return(1);
851     }
852 
853     /************************************************/
854     /* Tested the nxe_tcp_server_socket_accept api  */
855     /************************************************/
856 
857     /* Accept the Server socket with invalid socket.  */
858     status =  nx_tcp_server_socket_accept(NX_NULL, 5 * NX_IP_PERIODIC_RATE);
859 
860     /* Check for error.  */
861     if (status != NX_PTR_ERROR)
862     {
863 
864         printf("ERROR!\n");
865         test_control_return(1);
866     }
867 
868     /* Clear the socket ID.  */
869     invalid_socket.nx_tcp_socket_id  = NX_NULL;
870 
871     /* Accept the Server socket with invalid socket ID.  */
872     status =  nx_tcp_server_socket_accept(&invalid_socket, 5 * NX_IP_PERIODIC_RATE);
873 
874     /* Check for error.  */
875     if (status != NX_PTR_ERROR)
876     {
877 
878         printf("ERROR!\n");
879         test_control_return(1);
880     }
881 
882     /* Set the socket ID.  */
883     invalid_socket.nx_tcp_socket_id  = NX_TCP_ID;
884 
885     /* Disable the TCP feature for invalid IP instance.  */
886     invalid_socket.nx_tcp_socket_ip_ptr = (NX_IP *)&invalid_ip;
887     invalid_socket.nx_tcp_socket_ip_ptr -> nx_ip_tcp_packet_receive = NX_NULL;
888 
889     /* Accept the Server socket when disable TCP feature.  */
890     status =  nx_tcp_server_socket_accept(&invalid_socket, 5 * NX_IP_PERIODIC_RATE);
891 
892     /* Check for error.  */
893     if (status != NX_NOT_ENABLED)
894     {
895 
896         printf("ERROR!\n");
897         test_control_return(1);
898     }
899 
900     /************************************************/
901     /* Tested the nxe_tcp_server_socket_listen api  */
902     /************************************************/
903 
904     /* Listen the Server socket with invalid IP instance.  */
905     status =  nx_tcp_server_socket_listen(NX_NULL, 8080, &server_socket, 5, NX_NULL);
906 
907     /* Check for error.  */
908     if (status != NX_PTR_ERROR)
909     {
910 
911         printf("ERROR!\n");
912         test_control_return(1);
913     }
914 
915     /* Clear the IP instance ID.  */
916     invalid_ip.nx_ip_id   = NX_NULL;
917 
918     /* Listen the Server socket with invalid IP instance ID.  */
919     status =  nx_tcp_server_socket_listen(&invalid_ip, 8080, &server_socket, 5, NX_NULL);
920 
921     /* Check for error.  */
922     if (status != NX_PTR_ERROR)
923     {
924 
925         printf("ERROR!\n");
926         test_control_return(1);
927     }
928 
929     /* Listen the Server socket with invalid socket.  */
930     status =  nx_tcp_server_socket_listen(&ip_1, 8080, NX_NULL, 5, NX_NULL);
931 
932     /* Check for error.  */
933     if (status != NX_PTR_ERROR)
934     {
935 
936         printf("ERROR!\n");
937         test_control_return(1);
938     }
939 
940     /* Clear the socket ID.  */
941     invalid_socket.nx_tcp_socket_id  = NX_NULL;
942 
943     /* Listen the Server socket with invalid socket ID.  */
944     status =  nx_tcp_server_socket_listen(&ip_1, 8080, &invalid_socket, 5, NX_NULL);
945 
946     /* Check for error.  */
947     if (status != NX_PTR_ERROR)
948     {
949 
950         printf("ERROR!\n");
951         test_control_return(1);
952     }
953 
954     /* Set the IP instance ID.  */
955     invalid_ip.nx_ip_id = NX_IP_ID;
956 
957     /* Disable the TCP feature for invalid IP instance.  */
958     invalid_ip.nx_ip_tcp_packet_receive = NX_NULL;
959 
960     /* Listen the Server socket when disable the TCP feature.  */
961     status =  nx_tcp_server_socket_listen(&invalid_ip, 8080, &server_socket, 5, NX_NULL);
962 
963     /* Check for error.  */
964     if (status != NX_NOT_ENABLED)
965     {
966 
967         printf("ERROR!\n");
968         test_control_return(1);
969     }
970 
971     /* Listen the Server socket with invalid port.  */
972     status =  nx_tcp_server_socket_listen(&ip_1, 0, &server_socket, 5, NX_NULL);
973 
974     /* Check for error.  */
975     if (status != NX_INVALID_PORT)
976     {
977 
978         printf("ERROR!\n");
979         test_control_return(1);
980     }
981 
982     /* Listen the Server socket with invalid port.  */
983     status =  nx_tcp_server_socket_listen(&ip_1, 0xFFFFFFFF, &server_socket, 5, NX_NULL);
984 
985     /* Check for error.  */
986     if (status != NX_INVALID_PORT)
987     {
988 
989         printf("ERROR!\n");
990         test_control_return(1);
991     }
992 
993     /************************************************/
994     /* Tested the nxe_tcp_server_socket_relisten api*/
995     /************************************************/
996 
997     /* Relisten the Server socket with invalid IP instance.  */
998     status =  nx_tcp_server_socket_relisten(NX_NULL, 8080, &server_socket);
999 
1000     /* Check for error.  */
1001     if (status != NX_PTR_ERROR)
1002     {
1003 
1004         printf("ERROR!\n");
1005         test_control_return(1);
1006     }
1007 
1008     /* Clear the IP instance ID.  */
1009     invalid_ip.nx_ip_id   = NX_NULL;
1010 
1011     /* Relisten the Server socket with invalid IP instance ID.  */
1012     status =  nx_tcp_server_socket_relisten(&invalid_ip, 8080, &server_socket);
1013 
1014     /* Check for error.  */
1015     if (status != NX_PTR_ERROR)
1016     {
1017 
1018         printf("ERROR!\n");
1019         test_control_return(1);
1020     }
1021 
1022     /* Relisten the Server socket with invalid socket.  */
1023     status =  nx_tcp_server_socket_relisten(&ip_1, 8080, NX_NULL);
1024 
1025     /* Check for error.  */
1026     if (status != NX_PTR_ERROR)
1027     {
1028 
1029         printf("ERROR!\n");
1030         test_control_return(1);
1031     }
1032 
1033     /* Clear the socket ID.  */
1034     invalid_socket.nx_tcp_socket_id  = NX_NULL;
1035 
1036     /* Relisten the Server socket with invalid socket ID.  */
1037     status =  nx_tcp_server_socket_relisten(&ip_1, 8080, &invalid_socket);
1038 
1039     /* Check for error.  */
1040     if (status != NX_PTR_ERROR)
1041     {
1042 
1043         printf("ERROR!\n");
1044         test_control_return(1);
1045     }
1046 
1047     /* Set the IP instance ID.  */
1048     invalid_ip.nx_ip_id = NX_IP_ID;
1049 
1050     /* Disable the TCP feature for invalid IP instance.  */
1051     invalid_ip.nx_ip_tcp_packet_receive = NX_NULL;
1052 
1053     /* Relisten the Server socket when disable the TCP feature.  */
1054     status =  nx_tcp_server_socket_relisten(&invalid_ip, 8080, &server_socket);
1055 
1056     /* Check for error.  */
1057     if (status != NX_NOT_ENABLED)
1058     {
1059 
1060         printf("ERROR!\n");
1061         test_control_return(1);
1062     }
1063 
1064     /* Relisten the Server socket with invalid port.  */
1065     status =  nx_tcp_server_socket_relisten(&ip_1, 0, &server_socket);
1066 
1067     /* Check for error.  */
1068     if (status != NX_INVALID_PORT)
1069     {
1070 
1071         printf("ERROR!\n");
1072         test_control_return(1);
1073     }
1074 
1075     /* Relisten the Server socket with invalid port.  */
1076     status =  nx_tcp_server_socket_relisten(&ip_1, 0xFFFFFFFF, &server_socket);
1077 
1078     /* Check for error.  */
1079     if (status != NX_INVALID_PORT)
1080     {
1081 
1082         printf("ERROR!\n");
1083         test_control_return(1);
1084     }
1085 
1086     /************************************************/
1087     /* Tested the nxe_tcp_server_socket_unaccept api*/
1088     /************************************************/
1089 
1090     /* Unaccept the Server socket with invalid socket.  */
1091     status =  nx_tcp_server_socket_unaccept(NX_NULL);
1092 
1093     /* Check for error.  */
1094     if (status != NX_PTR_ERROR)
1095     {
1096 
1097         printf("ERROR!\n");
1098         test_control_return(1);
1099     }
1100 
1101     /* Clear the socket ID.  */
1102     invalid_socket.nx_tcp_socket_id  = NX_NULL;
1103 
1104     /* Unaccept the Server socket with invalid socket ID.  */
1105     status =  nx_tcp_server_socket_unaccept(&invalid_socket);
1106 
1107     /* Check for error.  */
1108     if (status != NX_PTR_ERROR)
1109     {
1110 
1111         printf("ERROR!\n");
1112         test_control_return(1);
1113     }
1114 
1115     /* Set the socket ID.  */
1116     invalid_socket.nx_tcp_socket_id  = NX_TCP_ID;
1117 
1118     /* Disable the TCP feature for invalid IP instance.  */
1119     invalid_socket.nx_tcp_socket_ip_ptr = (NX_IP *)&invalid_ip;
1120     invalid_socket.nx_tcp_socket_ip_ptr -> nx_ip_tcp_packet_receive = NX_NULL;
1121 
1122     /* Unaccept the Server socket when disable TCP feature.  */
1123     status =  nx_tcp_server_socket_unaccept(&invalid_socket);
1124 
1125     /* Check for error.  */
1126     if (status != NX_NOT_ENABLED)
1127     {
1128 
1129         printf("ERROR!\n");
1130         test_control_return(1);
1131     }
1132 
1133     /************************************************/
1134     /* Tested the nxe_tcp_server_socket_unlisten api*/
1135     /************************************************/
1136 
1137     /* Unlisten the Server socket with invalid IP instance.  */
1138     status =  nx_tcp_server_socket_unlisten(NX_NULL, 8080);
1139 
1140     /* Check for error.  */
1141     if (status != NX_PTR_ERROR)
1142     {
1143 
1144         printf("ERROR!\n");
1145         test_control_return(1);
1146     }
1147 
1148     /* Clear the IP instance ID.  */
1149     invalid_ip.nx_ip_id   = NX_NULL;
1150 
1151     /* Unlisten the Server socket with invalid IP instance ID.  */
1152     status =  nx_tcp_server_socket_unlisten(&invalid_ip, 8080);
1153 
1154     /* Check for error.  */
1155     if (status != NX_PTR_ERROR)
1156     {
1157 
1158         printf("ERROR!\n");
1159         test_control_return(1);
1160     }
1161 
1162     /* Set the IP instance ID.  */
1163     invalid_ip.nx_ip_id = NX_IP_ID;
1164 
1165     /* Disable the TCP feature for invalid IP instance.  */
1166     invalid_ip.nx_ip_tcp_packet_receive = NX_NULL;
1167 
1168     /* Unlisten the Server socket when disable the TCP feature.  */
1169     status =  nx_tcp_server_socket_unlisten(&invalid_ip, 8080);
1170 
1171     /* Check for error.  */
1172     if (status != NX_NOT_ENABLED)
1173     {
1174 
1175         printf("ERROR!\n");
1176         test_control_return(1);
1177     }
1178 
1179     /* Unlisten the Server socket with invalid port.  */
1180     status =  nx_tcp_server_socket_unlisten(&ip_1, 0);
1181 
1182     /* Check for error.  */
1183     if (status != NX_INVALID_PORT)
1184     {
1185 
1186         printf("ERROR!\n");
1187         test_control_return(1);
1188     }
1189 
1190     /* Unlisten the Server socket with invalid port.  */
1191     status =  nx_tcp_server_socket_unlisten(&ip_1, 0xFFFFFFFF);
1192 
1193     /* Check for error.  */
1194     if (status != NX_INVALID_PORT)
1195     {
1196 
1197         printf("ERROR!\n");
1198         test_control_return(1);
1199     }
1200 
1201     /************************************************/
1202     /* Tested the nxe_tcp_socket_bytes_available api*/
1203     /************************************************/
1204 
1205     /* Get the Server socket available bytes with invalid socket.  */
1206     status =  nx_tcp_socket_bytes_available(NX_NULL, &bytes_available);
1207 
1208     /* Check for error.  */
1209     if (status != NX_PTR_ERROR)
1210     {
1211 
1212         printf("ERROR!\n");
1213         test_control_return(1);
1214     }
1215 
1216     /* Clear the socket ID.  */
1217     invalid_socket.nx_tcp_socket_id  = NX_NULL;
1218 
1219     /* Get the Server socket available bytes with invalid socket ID.  */
1220     status =  nx_tcp_socket_bytes_available(&invalid_socket, &bytes_available);
1221 
1222     /* Check for error.  */
1223     if (status != NX_PTR_ERROR)
1224     {
1225 
1226         printf("ERROR!\n");
1227         test_control_return(1);
1228     }
1229 
1230     /* Get the Server socket available bytes with invalid bytes available pointer.  */
1231     status =  nx_tcp_socket_bytes_available(&server_socket, NX_NULL);
1232 
1233     /* Check for error.  */
1234     if (status != NX_PTR_ERROR)
1235     {
1236 
1237         printf("ERROR!\n");
1238         test_control_return(1);
1239     }
1240 
1241     /* Set the socket ID.  */
1242     invalid_socket.nx_tcp_socket_id  = NX_TCP_ID;
1243 
1244     /* Disable the TCP feature for invalid IP instance.  */
1245     invalid_socket.nx_tcp_socket_ip_ptr = (NX_IP *)&invalid_ip;
1246     invalid_socket.nx_tcp_socket_ip_ptr -> nx_ip_tcp_packet_receive = NX_NULL;
1247 
1248     /* Get the Server socket available bytes when disable the TCP feature.  */
1249     status =  nx_tcp_socket_bytes_available(&invalid_socket, &bytes_available);
1250 
1251     /* Check for error.  */
1252     if (status != NX_NOT_ENABLED)
1253     {
1254 
1255         printf("ERROR!\n");
1256         test_control_return(1);
1257     }
1258 
1259     /************************************************/
1260     /* Tested the nxe_tcp_socket_disconnect api     */
1261     /************************************************/
1262 
1263     /* Disconnect the TCP with invalid socket.  */
1264     status =  nx_tcp_socket_disconnect(NX_NULL, 5 * NX_IP_PERIODIC_RATE);
1265 
1266     /* Check for error.  */
1267     if (status != NX_PTR_ERROR)
1268     {
1269 
1270         printf("ERROR!\n");
1271         test_control_return(1);
1272     }
1273 
1274     /* Clear the socket ID.  */
1275     invalid_socket.nx_tcp_socket_id  = NX_NULL;
1276 
1277     /* Disconnect the TCP with invalid socket ID.  */
1278     status =  nx_tcp_socket_disconnect(&invalid_socket, 5 * NX_IP_PERIODIC_RATE);
1279 
1280     /* Check for error.  */
1281     if (status != NX_PTR_ERROR)
1282     {
1283 
1284         printf("ERROR!\n");
1285         test_control_return(1);
1286     }
1287 
1288     /* Set the socket ID.  */
1289     invalid_socket.nx_tcp_socket_id  = NX_TCP_ID;
1290 
1291     /* Disable the TCP feature for invalid IP instance.  */
1292     invalid_socket.nx_tcp_socket_ip_ptr = (NX_IP *)&invalid_ip;
1293     invalid_socket.nx_tcp_socket_ip_ptr -> nx_ip_tcp_packet_receive = NX_NULL;
1294 
1295     /* Disconnect the TCP when disable TCP feature.  */
1296     status =  nx_tcp_socket_disconnect(&invalid_socket, 5 * NX_IP_PERIODIC_RATE);
1297 
1298     /* Check for error.  */
1299     if (status != NX_NOT_ENABLED)
1300     {
1301 
1302         printf("ERROR!\n");
1303         test_control_return(1);
1304     }
1305 
1306     /************************************************/
1307     /* Tested the nxe_tcp_socket_info_get api       */
1308     /************************************************/
1309 
1310     /* Get the TCP socket information with invalid socket.  */
1311     status =  nx_tcp_socket_info_get(NX_NULL, &packets_sent, &bytes_sent,
1312                                      &packets_received, &bytes_received,
1313                                      &retransmit_packets, &packets_queued,
1314                                      &checksum_errors, &socket_state,
1315                                      &transmit_queue_depth, &transmit_window,
1316                                      &receive_window);
1317 
1318     /* Check for error.  */
1319     if (status != NX_PTR_ERROR)
1320     {
1321 
1322         printf("ERROR!\n");
1323         test_control_return(1);
1324     }
1325 
1326     /* Clear the socket ID.  */
1327     invalid_socket.nx_tcp_socket_id  = NX_NULL;
1328 
1329     /* Get the TCP socket information with invalid socket ID.  */
1330     status =  nx_tcp_socket_info_get(&invalid_socket, &packets_sent, &bytes_sent,
1331                                      &packets_received, &bytes_received,
1332                                      &retransmit_packets, &packets_queued,
1333                                      &checksum_errors, &socket_state,
1334                                      &transmit_queue_depth, &transmit_window,
1335                                      &receive_window);
1336 
1337     /* Check for error.  */
1338     if (status != NX_PTR_ERROR)
1339     {
1340 
1341         printf("ERROR!\n");
1342         test_control_return(1);
1343     }
1344 
1345     /* Set the socket ID.  */
1346     invalid_socket.nx_tcp_socket_id  = NX_TCP_ID;
1347 
1348     /* Disable the TCP feature for invalid IP instance.  */
1349     invalid_socket.nx_tcp_socket_ip_ptr = (NX_IP *)&invalid_ip;
1350     invalid_socket.nx_tcp_socket_ip_ptr -> nx_ip_tcp_packet_receive = NX_NULL;
1351 
1352     /* Get the TCP socket information when disable TCP feature.  */
1353     status =  nx_tcp_socket_info_get(&invalid_socket, &packets_sent, &bytes_sent,
1354                                      &packets_received, &bytes_received,
1355                                      &retransmit_packets, &packets_queued,
1356                                      &checksum_errors, &socket_state,
1357                                      &transmit_queue_depth, &transmit_window,
1358                                      &receive_window);
1359 
1360     /* Check for error.  */
1361     if (status != NX_NOT_ENABLED)
1362     {
1363 
1364         printf("ERROR!\n");
1365         test_control_return(1);
1366     }
1367 
1368     /************************************************/
1369     /* Tested the nxe_tcp_socket_mss_get api       */
1370     /************************************************/
1371 
1372     /* Get the socket mss with invalid socket.  */
1373     status =  nx_tcp_socket_mss_get(NX_NULL, &mss);
1374 
1375     /* Check for error.  */
1376     if (status != NX_PTR_ERROR)
1377     {
1378 
1379         printf("ERROR!\n");
1380         test_control_return(1);
1381     }
1382 
1383     /* Clear the socket ID.  */
1384     invalid_socket.nx_tcp_socket_id  = NX_NULL;
1385 
1386     /* Get the socket mss with invalid socket.  */
1387     status =  nx_tcp_socket_mss_get(&invalid_socket, &mss);
1388 
1389     /* Check for error.  */
1390     if (status != NX_PTR_ERROR)
1391     {
1392 
1393         printf("ERROR!\n");
1394         test_control_return(1);
1395     }
1396 
1397     /* Get the socket mss with invalid mss pointer.  */
1398     status =  nx_tcp_socket_mss_get(&client_socket, NX_NULL);
1399 
1400     /* Check for error.  */
1401     if (status != NX_PTR_ERROR)
1402     {
1403 
1404         printf("ERROR!\n");
1405         test_control_return(1);
1406     }
1407 
1408     /* Set the socket ID.  */
1409     invalid_socket.nx_tcp_socket_id  = NX_TCP_ID;
1410 
1411     /* Disable the TCP feature for invalid IP instance.  */
1412     invalid_socket.nx_tcp_socket_ip_ptr = (NX_IP *)&invalid_ip;
1413     invalid_socket.nx_tcp_socket_ip_ptr -> nx_ip_tcp_packet_receive = NX_NULL;
1414 
1415     /* Get the socket mss when disable TCP feature.  */
1416     status =  nx_tcp_socket_mss_get(&invalid_socket, &mss);
1417 
1418     /* Check for error.  */
1419     if (status != NX_NOT_ENABLED)
1420     {
1421 
1422         printf("ERROR!\n");
1423         test_control_return(1);
1424     }
1425 
1426     /************************************************/
1427     /* Tested the nxe_tcp_socket_mss_peer_get api   */
1428     /************************************************/
1429 
1430     /* Get the peer socket mss with invalid socket.  */
1431     status =  nx_tcp_socket_mss_peer_get(NX_NULL, &peer_mss);
1432 
1433     /* Check for error.  */
1434     if (status != NX_PTR_ERROR)
1435     {
1436 
1437         printf("ERROR!\n");
1438         test_control_return(1);
1439     }
1440 
1441     /* Clear the socket ID.  */
1442     invalid_socket.nx_tcp_socket_id  = NX_NULL;
1443 
1444     /* Get the peer socket mss with invalid socket.  */
1445     status =  nx_tcp_socket_mss_peer_get(&invalid_socket, &peer_mss);
1446 
1447     /* Check for error.  */
1448     if (status != NX_PTR_ERROR)
1449     {
1450 
1451         printf("ERROR!\n");
1452         test_control_return(1);
1453     }
1454 
1455     /* Get the peer socket mss with invalid mss pointer.  */
1456     status =  nx_tcp_socket_mss_peer_get(&client_socket, NX_NULL);
1457 
1458     /* Check for error.  */
1459     if (status != NX_PTR_ERROR)
1460     {
1461 
1462         printf("ERROR!\n");
1463         test_control_return(1);
1464     }
1465 
1466     /* Set the socket ID.  */
1467     invalid_socket.nx_tcp_socket_id  = NX_TCP_ID;
1468 
1469     /* Disable the TCP feature for invalid IP instance.  */
1470     invalid_socket.nx_tcp_socket_ip_ptr = (NX_IP *)&invalid_ip;
1471     invalid_socket.nx_tcp_socket_ip_ptr -> nx_ip_tcp_packet_receive = NX_NULL;
1472 
1473     /* Get the peer socket mss when disable TCP feature.  */
1474     status =  nx_tcp_socket_mss_peer_get(&invalid_socket, &peer_mss);
1475 
1476     /* Check for error.  */
1477     if (status != NX_NOT_ENABLED)
1478     {
1479 
1480         printf("ERROR!\n");
1481         test_control_return(1);
1482     }
1483 
1484     /************************************************/
1485     /* Tested the nxe_tcp_socket_mss_set api        */
1486     /************************************************/
1487 
1488     /* Set the socket mss with invalid socket.  */
1489     status =  nx_tcp_socket_mss_set(NX_NULL, 512);
1490 
1491     /* Check for error.  */
1492     if (status != NX_PTR_ERROR)
1493     {
1494 
1495         printf("ERROR!\n");
1496         test_control_return(1);
1497     }
1498 
1499     /* Clear the socket ID.  */
1500     invalid_socket.nx_tcp_socket_id  = NX_NULL;
1501 
1502     /* Set the socket mss with invalid socket.  */
1503     status =  nx_tcp_socket_mss_set(&invalid_socket, 512);
1504 
1505     /* Check for error.  */
1506     if (status != NX_PTR_ERROR)
1507     {
1508 
1509         printf("ERROR!\n");
1510         test_control_return(1);
1511     }
1512 
1513     /* Set the socket ID.  */
1514     invalid_socket.nx_tcp_socket_id  = NX_TCP_ID;
1515 
1516     /* Disable the TCP feature for invalid IP instance.  */
1517     invalid_socket.nx_tcp_socket_ip_ptr = (NX_IP *)&invalid_ip;
1518     invalid_socket.nx_tcp_socket_ip_ptr -> nx_ip_tcp_packet_receive = NX_NULL;
1519 
1520     /* Set the socket mss when disable TCP feature.  */
1521     status =  nx_tcp_socket_mss_set(&invalid_socket, 512);
1522 
1523     /* Check for error.  */
1524     if (status != NX_NOT_ENABLED)
1525     {
1526 
1527         printf("ERROR!\n");
1528         test_control_return(1);
1529     }
1530 
1531     /************************************************/
1532     /* Tested the nxe_tcp_socket_peer_info_get api  */
1533     /************************************************/
1534 
1535     /* Get peer socket information with invalid socket.  */
1536     status =  nx_tcp_socket_peer_info_get(NX_NULL, &peer_ip_address, &peer_port);
1537 
1538     /* Check for error.  */
1539     if (status != NX_PTR_ERROR)
1540     {
1541 
1542         printf("ERROR!\n");
1543         test_control_return(1);
1544     }
1545 
1546     /* Clear the socket ID.  */
1547     invalid_socket.nx_tcp_socket_id  = NX_NULL;
1548 
1549     /* Get peer socket information with invalid socket ID.  */
1550     status =  nx_tcp_socket_peer_info_get(&invalid_socket, &peer_ip_address, &peer_port);
1551 
1552     /* Check for error.  */
1553     if (status != NX_PTR_ERROR)
1554     {
1555 
1556         printf("ERROR!\n");
1557         test_control_return(1);
1558     }
1559 
1560     /* Get peer socket information with invalid peer IP address pointer.  */
1561     status =  nx_tcp_socket_peer_info_get(&client_socket, NX_NULL, &peer_port);
1562 
1563     /* Check for error.  */
1564 #ifdef __PRODUCT_NETXDUO__
1565     if (status != NX_PTR_ERROR)
1566 #else
1567     if (status != NX_NOT_CONNECTED)
1568 #endif
1569     {
1570 
1571         printf("ERROR!\n");
1572         test_control_return(1);
1573     }
1574 
1575     /* Get peer socket information with invalid peer port pointer.  */
1576     status =  nx_tcp_socket_peer_info_get(&client_socket, &peer_ip_address, NX_NULL);
1577 
1578     /* Check for error.  */
1579 #ifdef __PRODUCT_NETXDUO__
1580     if (status != NX_PTR_ERROR)
1581 #else
1582     if (status != NX_NOT_CONNECTED)
1583 #endif
1584     {
1585 
1586         printf("ERROR!\n");
1587         test_control_return(1);
1588     }
1589 
1590     /* Set the socket ID.  */
1591     invalid_socket.nx_tcp_socket_id  = NX_TCP_ID;
1592 
1593     /* Disable the TCP feature for invalid IP instance.  */
1594     invalid_socket.nx_tcp_socket_ip_ptr = (NX_IP *)&invalid_ip;
1595     invalid_socket.nx_tcp_socket_ip_ptr -> nx_ip_tcp_packet_receive = NX_NULL;
1596 
1597     /* Get peer socket information when disable TCP feature.  */
1598     status =  nx_tcp_socket_peer_info_get(&invalid_socket, &peer_ip_address, &peer_port);
1599 
1600     /* Check for error.  */
1601     if (status != NX_NOT_ENABLED)
1602     {
1603 
1604         printf("ERROR!\n");
1605         test_control_return(1);
1606     }
1607 
1608 
1609 #ifdef FEATURE_NX_IPV6
1610     /************************************************/
1611     /* Tested the nxde_tcp_socket_peer_info_get api */
1612     /************************************************/
1613 
1614     /* Get peer socket information with invalid socket.  */
1615     status =  nxd_tcp_socket_peer_info_get(NX_NULL, &nxd_ip_address, &peer_port);
1616 
1617     /* Check for error.  */
1618     if (status != NX_PTR_ERROR)
1619     {
1620 
1621         printf("ERROR!\n");
1622         test_control_return(1);
1623     }
1624 
1625     /* Clear the socket ID.  */
1626     invalid_socket.nx_tcp_socket_id  = NX_NULL;
1627 
1628     /* Get peer socket information with invalid socket ID.  */
1629     status =  nxd_tcp_socket_peer_info_get(&invalid_socket, &nxd_ip_address, &peer_port);
1630 
1631     /* Check for error.  */
1632     if (status != NX_PTR_ERROR)
1633     {
1634 
1635         printf("ERROR!\n");
1636         test_control_return(1);
1637     }
1638 
1639     /* Get peer socket information with invalid peer IP address pointer.  */
1640     status =  nxd_tcp_socket_peer_info_get(&client_socket, NX_NULL, &peer_port);
1641 
1642     /* Check for error.  */
1643     if (status != NX_PTR_ERROR)
1644     {
1645 
1646         printf("ERROR!\n");
1647         test_control_return(1);
1648     }
1649 
1650     /* Get peer socket information with invalid peer port pointer.  */
1651     status =  nxd_tcp_socket_peer_info_get(&client_socket, &nxd_ip_address, NX_NULL);
1652 
1653     /* Check for error.  */
1654     if (status != NX_PTR_ERROR)
1655     {
1656 
1657         printf("ERROR!\n");
1658         test_control_return(1);
1659     }
1660 
1661     /* Set the socket ID.  */
1662     invalid_socket.nx_tcp_socket_id  = NX_TCP_ID;
1663 
1664     /* Disable the TCP feature for invalid IP instance.  */
1665     invalid_socket.nx_tcp_socket_ip_ptr = (NX_IP *)&invalid_ip;
1666     invalid_socket.nx_tcp_socket_ip_ptr -> nx_ip_tcp_packet_receive = NX_NULL;
1667 
1668     /* Get peer socket information when disable TCP feature.  */
1669     status =  nxd_tcp_socket_peer_info_get(&invalid_socket, &nxd_ip_address, &peer_port);
1670 
1671     /* Check for error.  */
1672     if (status != NX_NOT_ENABLED)
1673     {
1674 
1675         printf("ERROR!\n");
1676         test_control_return(1);
1677     }
1678 #endif
1679 
1680 
1681 #if defined(NX_ENABLE_TCP_QUEUE_DEPTH_UPDATE_NOTIFY) && defined(__PRODUCT_NETXDUO__)
1682     /*******************************************************/
1683     /* Tested the nxe_tcp_socket_queue_depth_notify_set api*/
1684     /*******************************************************/
1685 
1686     /* Set the queue depth notify function with invalid socket.  */
1687     status =  nx_tcp_socket_queue_depth_notify_set(NX_NULL, tcp_socket_queue_depth_notify);
1688 
1689     /* Check for error.  */
1690     if (status != NX_PTR_ERROR)
1691     {
1692 
1693         printf("ERROR!\n");
1694         test_control_return(1);
1695     }
1696 
1697     /* Clear the socket ID.  */
1698     invalid_socket.nx_tcp_socket_id  = NX_NULL;
1699 
1700     /* Set the queue depth notify function with invalid socket ID.  */
1701     status =  nx_tcp_socket_queue_depth_notify_set(&invalid_socket, tcp_socket_queue_depth_notify);
1702 
1703     /* Check for error.  */
1704     if (status != NX_PTR_ERROR)
1705     {
1706 
1707         printf("ERROR!\n");
1708         test_control_return(1);
1709     }
1710 
1711     /* Set the queue depth notify function with invalid callback pointer.  */
1712     status =  nx_tcp_socket_queue_depth_notify_set(&client_socket, NX_NULL);
1713 
1714     /* Check for error.  */
1715     if (status != NX_PTR_ERROR)
1716     {
1717 
1718         printf("ERROR!\n");
1719         test_control_return(1);
1720     }
1721 
1722     /* Set the socket ID.  */
1723     invalid_socket.nx_tcp_socket_id  = NX_TCP_ID;
1724 
1725     /* Disable the TCP feature for invalid IP instance.  */
1726     invalid_socket.nx_tcp_socket_ip_ptr = (NX_IP *)&invalid_ip;
1727     invalid_socket.nx_tcp_socket_ip_ptr -> nx_ip_tcp_packet_receive = NX_NULL;
1728 
1729     /* Set the queue depth notify function when disable TCP feature.  */
1730     status =  nx_tcp_socket_queue_depth_notify_set(&invalid_socket, tcp_socket_queue_depth_notify);
1731 
1732     /* Check for error.  */
1733     if (status != NX_NOT_ENABLED)
1734     {
1735 
1736         printf("ERROR!\n");
1737         test_control_return(1);
1738     }
1739 #endif
1740 
1741     /************************************************/
1742     /* Tested the nxe_tcp_socket_receive api        */
1743     /************************************************/
1744 
1745     /* Receive a TCP message with invalid socket.  */
1746     status =  nx_tcp_socket_receive(NX_NULL, &packet, 5 * NX_IP_PERIODIC_RATE);
1747 
1748     /* Check for error.  */
1749     if (status != NX_PTR_ERROR)
1750     {
1751 
1752         printf("ERROR!\n");
1753         test_control_return(1);
1754     }
1755 
1756     /* Clear the socket ID.  */
1757     invalid_socket.nx_tcp_socket_id  = NX_NULL;
1758 
1759     /* Receive a TCP message with invalid socket ID.  */
1760     status =  nx_tcp_socket_receive(&invalid_socket, &packet, 5 * NX_IP_PERIODIC_RATE);
1761 
1762     /* Check for error.  */
1763     if (status != NX_PTR_ERROR)
1764     {
1765 
1766         printf("ERROR!\n");
1767         test_control_return(1);
1768     }
1769 
1770     /* Receive a TCP message with invalid packet pointer.  */
1771     status =  nx_tcp_socket_receive(&server_socket, NX_NULL, 5 * NX_IP_PERIODIC_RATE);
1772 
1773     /* Check for error.  */
1774     if (status != NX_PTR_ERROR)
1775     {
1776 
1777         printf("ERROR!\n");
1778         test_control_return(1);
1779     }
1780 
1781     /* Set the socket ID.  */
1782     invalid_socket.nx_tcp_socket_id  = NX_TCP_ID;
1783 
1784     /* Disable the TCP feature for invalid IP instance.  */
1785     invalid_socket.nx_tcp_socket_ip_ptr = (NX_IP *)&invalid_ip;
1786     invalid_socket.nx_tcp_socket_ip_ptr -> nx_ip_tcp_packet_receive = NX_NULL;
1787 
1788     /* Receive a TCP message with invalid packet pointer.  */
1789     status =  nx_tcp_socket_receive(&invalid_socket, &packet, 5 * NX_IP_PERIODIC_RATE);
1790 
1791     /* Check for error.  */
1792     if (status != NX_NOT_ENABLED)
1793     {
1794 
1795         printf("ERROR!\n");
1796         test_control_return(1);
1797     }
1798 
1799     /************************************************/
1800     /* Tested the nxe_tcp_socket_receive_notify api */
1801     /************************************************/
1802 
1803     /* Set the socket receive notify function with invalid socket.  */
1804     status =  nx_tcp_socket_receive_notify(NX_NULL, tcp_receive_notify);
1805 
1806     /* Check for error.  */
1807     if (status != NX_PTR_ERROR)
1808     {
1809 
1810         printf("ERROR!\n");
1811         test_control_return(1);
1812     }
1813 
1814     /* Clear the socket ID.  */
1815     invalid_socket.nx_tcp_socket_id  = NX_NULL;
1816 
1817     /* Set the socket receive notify function with invalid socket.  */
1818     status =  nx_tcp_socket_receive_notify(&invalid_socket, tcp_receive_notify);
1819 
1820     /* Check for error.  */
1821     if (status != NX_PTR_ERROR)
1822     {
1823 
1824         printf("ERROR!\n");
1825         test_control_return(1);
1826     }
1827 
1828 #ifdef __PRODUCT_NETXDUO__
1829     /* Clear socket receive notify function.  */
1830     status =  nx_tcp_socket_receive_notify(&server_socket, NX_NULL);
1831 
1832     /* Check for error.  */
1833     if (status)
1834     {
1835 
1836         printf("ERROR!\n");
1837         test_control_return(1);
1838     }
1839 
1840     /* Set the socket ID.  */
1841     invalid_socket.nx_tcp_socket_id  = NX_TCP_ID;
1842 
1843     /* Disable the TCP feature for invalid IP instance.  */
1844     invalid_socket.nx_tcp_socket_ip_ptr = (NX_IP *)&invalid_ip;
1845     invalid_socket.nx_tcp_socket_ip_ptr -> nx_ip_tcp_packet_receive = NX_NULL;
1846 
1847     /* Set the socket receive notify function when disable TCP feature.  */
1848     status =  nx_tcp_socket_receive_notify(&invalid_socket, tcp_receive_notify);
1849 
1850     /* Check for error.  */
1851     if (status != NX_NOT_ENABLED)
1852     {
1853 
1854         printf("ERROR!\n");
1855         test_control_return(1);
1856     }
1857 #endif /* __PRODUCT_NETXDUO__ */
1858 
1859     /************************************************/
1860     /* Tested the nxe_tcp_socket_send api           */
1861     /************************************************/
1862 
1863     /* Allocate a packet.  */
1864     status =  nx_packet_allocate(&pool_0, &packet, NX_TCP_PACKET, NX_WAIT_FOREVER);
1865 
1866     /* Check status.  */
1867     if (status != NX_SUCCESS)
1868     {
1869         printf("ERROR!\n");
1870         test_control_return(1);
1871     }
1872 
1873     /* Send the packet with invalid socket.  */
1874     status =  nx_tcp_socket_send(NX_NULL, packet, 5 * NX_IP_PERIODIC_RATE);
1875 
1876     /* Check for error.  */
1877     if (status != NX_PTR_ERROR)
1878     {
1879 
1880         printf("ERROR!\n");
1881         test_control_return(1);
1882     }
1883 
1884     /* Clear the socket ID.  */
1885     invalid_socket.nx_tcp_socket_id  = NX_NULL;
1886 
1887     /* Send the packet with invalid socket.  */
1888     status =  nx_tcp_socket_send(&invalid_socket, packet, 5 * NX_IP_PERIODIC_RATE);
1889 
1890     /* Check for error.  */
1891     if (status != NX_PTR_ERROR)
1892     {
1893 
1894         printf("ERROR!\n");
1895         test_control_return(1);
1896     }
1897 
1898     /* Send the packet with invalid packet.  */
1899     unknow_packet = NX_NULL;
1900     status =  nx_tcp_socket_send(&client_socket, unknow_packet, 5 * NX_IP_PERIODIC_RATE);
1901 
1902     /* Check for error.  */
1903     if (status != NX_INVALID_PACKET)
1904     {
1905 
1906         printf("ERROR!\n");
1907         test_control_return(1);
1908     }
1909 
1910 #ifdef __PRODUCT_NETXDUO__
1911     /* Send the packet with freed packet.  */
1912     packet -> nx_packet_union_next.nx_packet_tcp_queue_next = (NX_PACKET *)NX_PACKET_FREE;
1913     status =  nx_tcp_socket_send(&client_socket, packet, 5 * NX_IP_PERIODIC_RATE);
1914 
1915     /* Check for error.  */
1916     if (status != NX_INVALID_PACKET)
1917     {
1918 
1919         printf("ERROR!\n");
1920         test_control_return(1);
1921     }
1922     packet -> nx_packet_union_next.nx_packet_tcp_queue_next = (NX_PACKET *)NX_PACKET_ALLOCATED;
1923 #endif
1924 
1925     /* Set the socket ID.  */
1926     invalid_socket.nx_tcp_socket_id  = NX_TCP_ID;
1927 
1928     /* Disable the TCP feature for invalid IP instance.  */
1929     invalid_socket.nx_tcp_socket_ip_ptr = (NX_IP *)&invalid_ip;
1930     invalid_socket.nx_tcp_socket_ip_ptr -> nx_ip_tcp_packet_receive = NX_NULL;
1931 
1932     /* Send the packet when disable TCP feature.  */
1933     status =  nx_tcp_socket_send(&invalid_socket, packet, 5 * NX_IP_PERIODIC_RATE);
1934 
1935     /* Check for error.  */
1936     if (status != NX_NOT_ENABLED)
1937     {
1938 
1939         printf("ERROR!\n");
1940         test_control_return(1);
1941     }
1942 
1943 #ifdef __PRODUCT_NETXDUO__
1944     /* Set the socket ID, tcp_packet_receive and connect IP address.  */
1945     invalid_socket.nx_tcp_socket_id  = NX_TCP_ID;
1946     invalid_socket.nx_tcp_socket_ip_ptr = (NX_IP *)&invalid_ip;
1947     invalid_socket.nx_tcp_socket_ip_ptr -> nx_ip_tcp_packet_receive = _nx_tcp_packet_receive;
1948     invalid_socket.nx_tcp_socket_connect_ip.nxd_ip_version = NX_NULL;
1949 
1950     /* Send the packet with invalid connect IP address.  */
1951     status =  nx_tcp_socket_send(&invalid_socket, packet, 5 * NX_IP_PERIODIC_RATE);
1952 
1953     /* Check for error.  */
1954     if (status != NX_NOT_CONNECTED)
1955     {
1956 
1957         printf("ERROR!\n");
1958         test_control_return(1);
1959     }
1960 
1961     /* Set the socket ID, tcp_packet_receive and connect IP address.  */
1962     invalid_socket.nx_tcp_socket_id  = NX_TCP_ID;
1963     invalid_socket.nx_tcp_socket_ip_ptr = (NX_IP *)&invalid_ip;
1964     invalid_socket.nx_tcp_socket_ip_ptr -> nx_ip_tcp_packet_receive = _nx_tcp_packet_receive;
1965     invalid_socket.nx_tcp_socket_connect_ip.nxd_ip_version = NX_IP_VERSION_V4;
1966 
1967     /* Send the invalid packet that prepend pointer is less than data start.  */
1968     invalid_packet_2 = (NX_PACKET *) &invalid_packet;
1969     invalid_packet_2 -> nx_packet_pool_owner = (NX_PACKET_POOL *) &invalid_pool;
1970     invalid_packet_2 -> nx_packet_pool_owner -> nx_packet_pool_id = NX_PACKET_POOL_ID;
1971     invalid_packet_2 -> nx_packet_data_start = (UCHAR *)0x20;
1972     invalid_packet_2 -> nx_packet_prepend_ptr = (UCHAR *)0x10;
1973     invalid_packet_2 -> nx_packet_append_ptr = (UCHAR *)0x30;
1974     invalid_packet_2 -> nx_packet_data_end = (UCHAR *)0x40;
1975     invalid_packet_2 -> nx_packet_union_next.nx_packet_tcp_queue_next = (NX_PACKET *) NX_PACKET_ALLOCATED;
1976     status =  nx_tcp_socket_send(&invalid_socket, invalid_packet_2, 5 * NX_IP_PERIODIC_RATE);
1977 
1978     /* Check for error.  */
1979     if (status != NX_UNDERFLOW)
1980     {
1981 
1982         printf("ERROR!\n");
1983         test_control_return(1);
1984     }
1985 
1986     /* Append packet with invalid packet that prepend pointer is less than data start.  */
1987     invalid_packet_2 = (NX_PACKET *) &invalid_packet;
1988     invalid_packet_2 -> nx_packet_pool_owner = (NX_PACKET_POOL *) &invalid_pool;
1989     invalid_packet_2 -> nx_packet_pool_owner -> nx_packet_pool_id = NX_PACKET_POOL_ID;
1990     invalid_packet_2 -> nx_packet_data_start = (UCHAR *)0x10;
1991     invalid_packet_2 -> nx_packet_prepend_ptr = (UCHAR *)0x40;
1992     invalid_packet_2 -> nx_packet_append_ptr = (UCHAR *)0x80;
1993     invalid_packet_2 -> nx_packet_data_end = (UCHAR *)0x60;
1994     invalid_packet_2 -> nx_packet_union_next.nx_packet_tcp_queue_next = (NX_PACKET *) NX_PACKET_ALLOCATED;
1995     status =  nx_tcp_socket_send(&invalid_socket, invalid_packet_2, 5 * NX_IP_PERIODIC_RATE);
1996 
1997     /* Check for error.  */
1998     if (status != NX_OVERFLOW)
1999     {
2000 
2001         printf("ERROR!\n");
2002         test_control_return(1);
2003     }
2004 
2005     /* Release the packet*/
2006     status =  nx_packet_release(packet);
2007 
2008     /* Check for error.  */
2009     if (status)
2010     {
2011 
2012         printf("ERROR!\n");
2013         test_control_return(1);
2014     }
2015 #endif /* __PRODUCT_NETXDUO__ */
2016 
2017     /************************************************/
2018     /* Tested the nxe_tcp_socket_state_wait api     */
2019     /************************************************/
2020 
2021     /* Wait for state with invalid socket.  */
2022     status =  nx_tcp_socket_state_wait(NX_NULL, NX_TCP_ESTABLISHED, 5 * NX_IP_PERIODIC_RATE);
2023 
2024     /* Check for error.  */
2025     if (status != NX_PTR_ERROR)
2026     {
2027 
2028         printf("ERROR!\n");
2029         test_control_return(1);
2030     }
2031 
2032     /* Clear the socket ID.  */
2033     invalid_socket.nx_tcp_socket_id  = NX_NULL;
2034 
2035     /* Wait for state with invalid socket ID.  */
2036     status =  nx_tcp_socket_state_wait(&invalid_socket, NX_TCP_ESTABLISHED, 5 * NX_IP_PERIODIC_RATE);
2037 
2038     /* Check for error.  */
2039     if (status != NX_PTR_ERROR)
2040     {
2041 
2042         printf("ERROR!\n");
2043         test_control_return(1);
2044     }
2045 
2046     /* Set the socket ID.  */
2047     invalid_socket.nx_tcp_socket_id  = NX_TCP_ID;
2048 
2049     /* Disable the TCP feature for invalid IP instance.  */
2050     invalid_socket.nx_tcp_socket_ip_ptr = (NX_IP *)&invalid_ip;
2051     invalid_socket.nx_tcp_socket_ip_ptr -> nx_ip_tcp_packet_receive = NX_NULL;
2052 
2053     /* Wait for state when disable TCP feature.  */
2054     status =  nx_tcp_socket_state_wait(&invalid_socket, NX_TCP_ESTABLISHED, 5 * NX_IP_PERIODIC_RATE);
2055 
2056     /* Check for error.  */
2057     if (status != NX_NOT_ENABLED)
2058     {
2059 
2060         printf("ERROR!\n");
2061         test_control_return(1);
2062     }
2063 
2064     /* Wait for state with invalid desired state.  */
2065     status =  nx_tcp_socket_state_wait(&client_socket, 0, 5 * NX_IP_PERIODIC_RATE);
2066 
2067     /* Check for error.  */
2068     if (status != NX_OPTION_ERROR)
2069     {
2070 
2071         printf("ERROR!\n");
2072         test_control_return(1);
2073     }
2074 
2075     /* Wait for state with invalid desired state.  */
2076     status =  nx_tcp_socket_state_wait(&client_socket, NX_TCP_LAST_ACK + 1, 5 * NX_IP_PERIODIC_RATE);
2077 
2078     /* Check for error.  */
2079     if (status != NX_OPTION_ERROR)
2080     {
2081 
2082         printf("ERROR!\n");
2083         test_control_return(1);
2084     }
2085 
2086     /***************************************************/
2087     /* Tested the nxe_tcp_socket_transmit_configure api*/
2088     /***************************************************/
2089 
2090     /* Configure the socket further with invalid socket.  */
2091     status =  nx_tcp_socket_transmit_configure(NX_NULL, 10, 300, 10, 0);
2092 
2093     /* Check for error.  */
2094     if (status != NX_PTR_ERROR)
2095     {
2096 
2097         printf("ERROR!\n");
2098         test_control_return(1);
2099     }
2100 
2101     /* Clear the socket ID.  */
2102     invalid_socket.nx_tcp_socket_id  = NX_NULL;
2103 
2104     /* Configure the socket further with invalid socket ID.  */
2105     status =  nx_tcp_socket_transmit_configure(&invalid_socket, 10, 300, 10, 0);
2106 
2107     /* Check for error.  */
2108     if (status != NX_PTR_ERROR)
2109     {
2110 
2111         printf("ERROR!\n");
2112         test_control_return(1);
2113     }
2114 
2115     /* Configure the socket further with invalid max queue depth.  */
2116     status =  nx_tcp_socket_transmit_configure(&server_socket, 0, 300, 10, 0);
2117 
2118     /* Check for error.  */
2119     if (status != NX_OPTION_ERROR)
2120     {
2121 
2122         printf("ERROR!\n");
2123         test_control_return(1);
2124     }
2125 
2126 #ifdef __PRODUCT_NETXDUO__
2127     /* Set the socket ID.  */
2128     invalid_socket.nx_tcp_socket_id  = NX_TCP_ID;
2129 
2130     /* Disable the TCP feature for invalid IP instance.  */
2131     invalid_socket.nx_tcp_socket_ip_ptr = (NX_IP *)&invalid_ip;
2132     invalid_socket.nx_tcp_socket_ip_ptr -> nx_ip_tcp_packet_receive = NX_NULL;
2133 
2134     /* Configure the socket further when disable TCP feature.  */
2135     status =  nx_tcp_socket_transmit_configure(&invalid_socket, 10, 300, 10, 0);
2136 
2137     /* Check for error.  */
2138     if (status != NX_NOT_ENABLED)
2139     {
2140 
2141         printf("ERROR!\n");
2142         test_control_return(1);
2143     }
2144 
2145     /*********************************************************/
2146     /* Tested the nxe_tcp_socket_window_update_notify_set api*/
2147     /*********************************************************/
2148 
2149     /* Set the queue depth notify function with invalid socket.  */
2150     status =  nx_tcp_socket_window_update_notify_set(NX_NULL, window_update_notify);
2151 
2152     /* Check for error.  */
2153     if (status != NX_PTR_ERROR)
2154     {
2155 
2156         printf("ERROR!\n");
2157         test_control_return(1);
2158     }
2159 
2160     /* Clear the socket ID.  */
2161     invalid_socket.nx_tcp_socket_id  = NX_NULL;
2162 
2163     /* Set the queue depth notify function with invalid socket.  */
2164     status =  nx_tcp_socket_window_update_notify_set(&invalid_socket, window_update_notify);
2165 
2166     /* Check for error.  */
2167     if (status != NX_PTR_ERROR)
2168     {
2169 
2170         printf("ERROR!\n");
2171         test_control_return(1);
2172     }
2173 
2174     /* Set the queue depth notify function with invalid notify function.  */
2175     status =  nx_tcp_socket_window_update_notify_set(&client_socket, NX_NULL);
2176 
2177     /* Check for error.  */
2178     if (status != NX_PTR_ERROR)
2179     {
2180 
2181         printf("ERROR!\n");
2182         test_control_return(1);
2183     }
2184 
2185     /* Set the socket ID.  */
2186     invalid_socket.nx_tcp_socket_id  = NX_TCP_ID;
2187 
2188     /* Disable the TCP feature for invalid IP instance.  */
2189     invalid_socket.nx_tcp_socket_ip_ptr = (NX_IP *)&invalid_ip;
2190     invalid_socket.nx_tcp_socket_ip_ptr -> nx_ip_tcp_packet_receive = NX_NULL;
2191 
2192     /* Set the queue depth notify function when disable TCP feature.  */
2193     status =  nx_tcp_socket_window_update_notify_set(&invalid_socket, window_update_notify);
2194 
2195     /* Check for error.  */
2196     if (status != NX_NOT_ENABLED)
2197     {
2198 
2199         printf("ERROR!\n");
2200         test_control_return(1);
2201     }
2202 
2203     /************************************************/
2204     /* Tested the nxe_tcp_socket_delete api         */
2205     /************************************************/
2206 
2207     /* Delete the TCP socket with invalid socket.  */
2208     status =  nx_tcp_socket_delete(NX_NULL);
2209 
2210     /* Check for error.  */
2211     if (status != NX_PTR_ERROR)
2212     {
2213 
2214         printf("ERROR!\n");
2215         test_control_return(1);
2216     }
2217 
2218     /* Clear the socket ID.  */
2219     invalid_socket.nx_tcp_socket_id  = NX_NULL;
2220 
2221     /* Delete the TCP socket with invalid socket ID.  */
2222     status =  nx_tcp_socket_delete(&invalid_socket);
2223 
2224     /* Check for error.  */
2225     if (status != NX_PTR_ERROR)
2226     {
2227 
2228         printf("ERROR!\n");
2229         test_control_return(1);
2230     }
2231 
2232     /* Set the socket ID.  */
2233     invalid_socket.nx_tcp_socket_id  = NX_TCP_ID;
2234 
2235     /* Disable the TCP feature for invalid IP instance.  */
2236     invalid_socket.nx_tcp_socket_ip_ptr = (NX_IP *)&invalid_ip;
2237     invalid_socket.nx_tcp_socket_ip_ptr -> nx_ip_tcp_packet_receive = NX_NULL;
2238 
2239     /* Delete the TCP socket when disable TCP feature.  */
2240     status =  nx_tcp_socket_delete(&invalid_socket);
2241 
2242     /* Check for error.  */
2243     if (status != NX_NOT_ENABLED)
2244     {
2245 
2246         printf("ERROR!\n");
2247         test_control_return(1);
2248     }
2249 
2250 #ifdef NX_ENABLE_LOW_WATERMARK
2251     /* Clear the socket ID.  */
2252     invalid_socket.nx_tcp_socket_id  = NX_NULL;
2253 
2254     /* Set receive queue to invalid socket. */
2255     status = nx_tcp_socket_receive_queue_max_set(&invalid_socket, 10);
2256 
2257     /* Check for error.  */
2258     if (status != NX_PTR_ERROR)
2259     {
2260 
2261         printf("ERROR!\n");
2262         test_control_return(1);
2263     }
2264 #endif /* NX_ENABLE_LOW_WATERMARK */
2265 #endif /* __PRODUCT_NETXDUO__ */
2266 
2267     printf("SUCCESS!\n");
2268     test_control_return(0);
2269 }
2270 
2271 #if defined(NX_ENABLE_TCP_QUEUE_DEPTH_UPDATE_NOTIFY) && defined(__PRODUCT_NETXDUO__)
tcp_socket_queue_depth_notify(NX_TCP_SOCKET * socket_ptr)2272 static void  tcp_socket_queue_depth_notify(NX_TCP_SOCKET *socket_ptr)
2273 {
2274 }
2275 #endif
2276 #ifdef __PRODUCT_NETXDUO__
window_update_notify(NX_TCP_SOCKET * socket_ptr)2277 static void  window_update_notify(NX_TCP_SOCKET *socket_ptr)
2278 {
2279 }
2280 #endif /* __PRODUCT_NETXDUO__ */
tcp_receive_notify(NX_TCP_SOCKET * socket_ptr)2281 static void  tcp_receive_notify(NX_TCP_SOCKET *socket_ptr)
2282 {
2283 }
2284 #else
2285 
2286 #ifdef CTEST
test_application_define(void * first_unused_memory)2287 VOID test_application_define(void *first_unused_memory)
2288 #else
2289 void    netx_tcp_nxe_api_test_application_define(void *first_unused_memory)
2290 #endif
2291 {
2292 
2293     /* Print out test information banner.  */
2294     printf("NetX Test:   TCP NXE API Test..........................................N/A\n");
2295 
2296     test_control_return(3);
2297 }
2298 #endif
2299