1 /* This NetX test concentrates on the basic BSD UDP non-blocking bind to a specific address and connect + send operation.  */
2 
3 
4 #include   "tx_api.h"
5 #include   "nx_api.h"
6 #if defined(NX_BSD_ENABLE) && !defined(NX_DISABLE_IPV4)
7 
8 #ifdef FEATURE_NX_IPV6
9 #include   "nx_ipv6.h"
10 #endif
11 #include   "nx_icmpv6.h"
12 #include   "nx_ipv4.h"
13 #include   "nxd_bsd.h"
14 #define     DEMO_STACK_SIZE         4096
15 
16 
17 /* Define the ThreadX and NetX object control blocks...  */
18 
19 static TX_THREAD               ntest_0;
20 static TX_THREAD               ntest_1;
21 
22 static NX_PACKET_POOL          pool_0;
23 static NX_IP                   ip_0;
24 static NX_IP                   ip_1;
25 static ULONG                   bsd_thread_area[DEMO_STACK_SIZE / sizeof(ULONG)];
26 #define BSD_THREAD_PRIORITY    2
27 #define NUM_CLIENTS            20
28 /* Define the counters used in the test application...  */
29 
30 static ULONG                   error_counter;
31 
32 
33 /* Define thread prototypes.  */
34 
35 static void    ntest_0_entry(ULONG thread_input);
36 static void    ntest_1_entry(ULONG thread_input);
37 extern void    test_control_return(UINT status);
38 extern void    _nx_ram_network_driver_256(struct NX_IP_DRIVER_STRUCT *driver_req);
39 static void    validate_bsd_structure(void);
40 static TX_SEMAPHORE sema;
41 extern NX_BSD_SOCKET  nx_bsd_socket_array[NX_BSD_MAX_SOCKETS];
42 extern TX_BLOCK_POOL nx_bsd_socket_block_pool;
43 
44 #ifdef FEATURE_NX_IPV6
45 static NXD_ADDRESS ipv6_address_ip0[3][3];
46 static NXD_ADDRESS ipv6_address_ip1[3][3];
47 static char *bsd6_msg[3][3] = {{"BSD6_MSG IF0 LLA", "BSD6_MSG  IF0  GA0", "MSD6_MSG IF0   GA1"},
48                                {"BSD6_MSG IF1 LLA", "BSD6_MSG  IF1  GA0", "MSD6_MSG IF1   GA1"},
49                                {"BSD6_MSG IF2 LLA", "BSD6_MSG  IF2  GA0", "MSD6_MSG IF2   GA1"}};
50 #endif /* FEATURE_NX_IPV6 */
51 static char *bsd4_msg[3] = {"BSD4_MSG 0", "BSD4_MSG  1", "MSD4_MSG   2"};
52 
53 static void validate_bsd_structure(void);
54 
55 #define IP0_IF0_V4_ADDR   IP_ADDRESS(1,2,3,4)
56 #define IP0_IF1_V4_ADDR   IP_ADDRESS(2,2,3,4)
57 #define IP0_IF2_V4_ADDR   IP_ADDRESS(3,2,3,4)
58 
59 #define IP1_IF0_V4_ADDR   IP_ADDRESS(1,2,3,5)
60 #define IP1_IF1_V4_ADDR   IP_ADDRESS(2,2,3,5)
61 #define IP1_IF2_V4_ADDR   IP_ADDRESS(3,2,3,5)
62 
63 #define ITERATIONS  100
64 static ULONG ip0_address[3] = {IP0_IF0_V4_ADDR, IP0_IF1_V4_ADDR, IP0_IF2_V4_ADDR};
65 static ULONG ip1_address[3] = {IP1_IF0_V4_ADDR, IP1_IF1_V4_ADDR, IP1_IF2_V4_ADDR};
66 /* Define what the initial system looks like.  */
67 
68 #ifdef __PRODUCT_NETX__
69 #define NX_IPV4_HEADER  NX_IP_HEADER
70 #endif
71 
72 #ifdef CTEST
test_application_define(void * first_unused_memory)73 VOID test_application_define(void *first_unused_memory)
74 #else
75 void    netx_bsd_udp_bind_connect_test_application_define(void *first_unused_memory)
76 #endif
77 {
78 
79 CHAR    *pointer;
80 UINT    status;
81 
82 
83     /* Setup the working pointer.  */
84     pointer =  (CHAR *) first_unused_memory;
85 
86     error_counter =  0;
87 
88     /* Create the main thread.  */
89     tx_thread_create(&ntest_0, "thread 0", ntest_0_entry, 0,
90                      pointer, DEMO_STACK_SIZE,
91                      3, 3, TX_NO_TIME_SLICE, TX_AUTO_START);
92 
93     pointer =  pointer + DEMO_STACK_SIZE;
94 
95     /* Create the main thread.  */
96     tx_thread_create(&ntest_1, "thread 1", ntest_1_entry, 0,
97                      pointer, DEMO_STACK_SIZE,
98                      4, 4, TX_NO_TIME_SLICE, TX_AUTO_START);
99 
100     pointer =  pointer + DEMO_STACK_SIZE;
101 
102 
103     /* Initialize the NetX system.  */
104     nx_system_initialize();
105 
106     /* Create a packet pool.  */
107     status =  nx_packet_pool_create(&pool_0, "NetX Main Packet Pool", 256, pointer, (256 + sizeof(NX_PACKET)) * (NUM_CLIENTS + 4) * 2);
108     pointer = pointer + (256 + sizeof(NX_PACKET)) * (NUM_CLIENTS + 4) * 2;
109 
110     if (status)
111         error_counter++;
112 
113     /* Create an IP instance.  */
114     status = nx_ip_create(&ip_0, "NetX IP Instance 0", IP0_IF0_V4_ADDR, 0xFFFFFF00UL, &pool_0, _nx_ram_network_driver_256,
115                     pointer, 2048, 1);
116     pointer =  pointer + 2048;
117 
118     /* Attach a 2nd interface */
119     status += nx_ip_interface_attach(&ip_0, "ip_0_second", IP0_IF1_V4_ADDR, 0xFFFFFF00UL,  _nx_ram_network_driver_256);
120     status += nx_ip_interface_attach(&ip_0, "ip_0_third", IP0_IF2_V4_ADDR, 0xFFFFFF00UL,  _nx_ram_network_driver_256);
121 
122     /* Create another IP instance.  */
123     status += nx_ip_create(&ip_1, "NetX IP Instance 1", IP1_IF0_V4_ADDR, 0xFFFFFF00UL, &pool_0, _nx_ram_network_driver_256,
124                     pointer, 2048, 2);
125     pointer =  pointer + 2048;
126 
127     status += nx_ip_interface_attach(&ip_1, "ip_1_second", IP1_IF1_V4_ADDR, 0xFFFFFF00UL,  _nx_ram_network_driver_256);
128     status += nx_ip_interface_attach(&ip_1, "ip_1_third", IP1_IF2_V4_ADDR, 0xFFFFFF00UL,  _nx_ram_network_driver_256);
129     if (status)
130         error_counter++;
131 
132     /* Enable ARP and supply ARP cache memory for IP Instance 0.  */
133     status =  nx_arp_enable(&ip_0, (void *) pointer, 1024);
134     pointer = pointer + 1024;
135     if (status)
136         error_counter++;
137 
138     /* Enable ARP and supply ARP cache memory for IP Instance 1.  */
139     status  =  nx_arp_enable(&ip_1, (void *) pointer, 1024);
140     pointer = pointer + 1024;
141     if (status)
142         error_counter++;
143 
144     /* Enable UDP processing for both IP instances.  */
145     status =  nx_udp_enable(&ip_0);
146     status += nx_udp_enable(&ip_1);
147 
148     /* Enable BSD */
149     status += bsd_initialize(&ip_0, &pool_0, (CHAR*)&bsd_thread_area[0], sizeof(bsd_thread_area), BSD_THREAD_PRIORITY);
150 
151     /* Check UDP enable and BSD init status.  */
152     if (status)
153         error_counter++;
154 
155     status = tx_semaphore_create(&sema, "test done", 0);
156     if (status)
157         error_counter++;
158 }
159 
160 
161 
162 
163 #ifdef FEATURE_NX_IPV6
test_udp6_on_interface_address(int iface,int address)164 static void test_udp6_on_interface_address(int iface, int address)
165 {
166 int                 sockfd;
167 struct sockaddr_in6 remote_addr, local_addr;
168 int                 ret;
169 
170 
171     sockfd = socket(AF_INET6, SOCK_DGRAM, 0);
172     if(sockfd < 0)
173         error_counter++;
174 
175     memset(&local_addr, 0, sizeof(local_addr));
176     local_addr.sin6_port = htons(12345);
177     local_addr.sin6_family = AF_INET6;
178     if(iface != 3)
179     {
180         local_addr.sin6_addr._S6_un._S6_u32[0] = htonl(ipv6_address_ip0[iface][address].nxd_ip_address.v6[0]);
181         local_addr.sin6_addr._S6_un._S6_u32[1] = htonl(ipv6_address_ip0[iface][address].nxd_ip_address.v6[1]);
182         local_addr.sin6_addr._S6_un._S6_u32[2] = htonl(ipv6_address_ip0[iface][address].nxd_ip_address.v6[2]);
183         local_addr.sin6_addr._S6_un._S6_u32[3] = htonl(ipv6_address_ip0[iface][address].nxd_ip_address.v6[3]);
184     }
185 
186 
187     ret = bind(sockfd, (struct sockaddr*)&local_addr, sizeof(local_addr));
188     if(ret < 0)
189         error_counter++;
190 
191     remote_addr.sin6_family = AF_INET6;
192     remote_addr.sin6_addr._S6_un._S6_u32[0] = htonl(ipv6_address_ip1[iface][address].nxd_ip_address.v6[0]);
193     remote_addr.sin6_addr._S6_un._S6_u32[1] = htonl(ipv6_address_ip1[iface][address].nxd_ip_address.v6[1]);
194     remote_addr.sin6_addr._S6_un._S6_u32[2] = htonl(ipv6_address_ip1[iface][address].nxd_ip_address.v6[2]);
195     remote_addr.sin6_addr._S6_un._S6_u32[3] = htonl(ipv6_address_ip1[iface][address].nxd_ip_address.v6[3]);
196 
197     remote_addr.sin6_port = htons(12346);
198 
199     ret = connect(sockfd, (struct sockaddr*)&remote_addr, sizeof(remote_addr));
200     if(ret < 0)
201         error_counter++;
202 
203 
204     ret = send(sockfd, bsd6_msg[iface][address], strlen(bsd6_msg[iface][address]), 0);
205     if(ret != (INT)strlen(bsd6_msg[iface][address]))
206         error_counter++;
207 
208     /* Close downt he socket. */
209     ret = soc_close(sockfd);
210     if(ret < 0)
211         error_counter++;
212 
213 }
214 
215 
216 #endif /* FEATURE_NX_IPV6 */
217 
test_udp4_on_interface(int i)218 static void    test_udp4_on_interface(int i)
219 {
220 
221 int                 sockfd;
222 struct sockaddr_in  remote_addr, local_addr;
223 int                 ret;
224 
225 
226     sockfd = socket(AF_INET, SOCK_DGRAM, 0);
227     if(sockfd < 0)
228         error_counter++;
229 
230     local_addr.sin_family = AF_INET;
231     local_addr.sin_port = htons(12345);
232     local_addr.sin_addr.s_addr = htonl(ip0_address[i]);
233 
234     ret = bind(sockfd, (struct sockaddr*)&local_addr, sizeof(local_addr));
235     if(ret < 0)
236         error_counter++;
237 
238     remote_addr.sin_family = AF_INET;
239     remote_addr.sin_port = htons(12346);
240     remote_addr.sin_addr.s_addr = htonl(ip1_address[i]);
241 
242     ret = connect(sockfd, (struct sockaddr*)&remote_addr, sizeof(remote_addr));
243     if(ret < 0)
244         error_counter++;
245 
246     ret = send(sockfd, bsd4_msg[i], strlen(bsd4_msg[i]), 0);
247     if(ret != (int)strlen(bsd4_msg[i]))
248         error_counter++;
249 
250 
251     /* Close downt he socket. */
252     ret = soc_close(sockfd);
253     if(ret < 0)
254         error_counter++;
255 
256 }
257 
258 
259 
260 /* Define the test threads.  */
ntest_0_entry(ULONG thread_input)261 static void    ntest_0_entry(ULONG thread_input)
262 {
263 #ifdef FEATURE_NX_IPV6
264 static char mac_ip0[6];
265 static char mac_ip1[6];
266 int i,j;
267 UINT status;
268 int addr_index;
269 #endif
270 int iface;
271 
272 
273     printf("NetX Test:   Basic BSD UDP Bind Connect Send Test..........");
274 
275     /* Check for earlier error.  */
276     if (error_counter)
277     {
278 
279         printf("ERROR!\n");
280         test_control_return(1);
281     }
282 
283 #ifdef FEATURE_NX_IPV6
284 
285     for(i = 0; i < 3; i++)
286     {
287         mac_ip0[0] = (char)(ip_0.nx_ip_interface[i].nx_interface_physical_address_msw >> 8);
288         mac_ip0[1] = ip_0.nx_ip_interface[i].nx_interface_physical_address_msw & 0xFF;
289         mac_ip0[2] = (ip_0.nx_ip_interface[i].nx_interface_physical_address_lsw >> 24) & 0xff;
290         mac_ip0[3] = (ip_0.nx_ip_interface[i].nx_interface_physical_address_lsw >> 16) & 0xff;
291         mac_ip0[4] = (ip_0.nx_ip_interface[i].nx_interface_physical_address_lsw >> 8) & 0xff;
292         mac_ip0[5] = ip_0.nx_ip_interface[i].nx_interface_physical_address_lsw  & 0xff;
293 
294         mac_ip1[0] = (char)(ip_1.nx_ip_interface[i].nx_interface_physical_address_msw >> 8);
295         mac_ip1[1] = ip_1.nx_ip_interface[i].nx_interface_physical_address_msw & 0xFF;
296         mac_ip1[2] = (ip_1.nx_ip_interface[i].nx_interface_physical_address_lsw >> 24) & 0xff;
297         mac_ip1[3] = (ip_1.nx_ip_interface[i].nx_interface_physical_address_lsw >> 16) & 0xff;
298         mac_ip1[4] = (ip_1.nx_ip_interface[i].nx_interface_physical_address_lsw >> 8) & 0xff;
299         mac_ip1[5] = ip_1.nx_ip_interface[i].nx_interface_physical_address_lsw  & 0xff;
300 
301         for(j = 0; j < 3; j ++)
302         {
303             if(j == 0)
304             {
305                 /* First set up IPv6 linklocal addresses. */
306                 ipv6_address_ip0[i][j].nxd_ip_version = NX_IP_VERSION_V6;
307                 ipv6_address_ip0[i][j].nxd_ip_address.v6[0] = 0xfe800000;
308                 ipv6_address_ip0[i][j].nxd_ip_address.v6[1] = 0x00000000;
309                 ipv6_address_ip0[i][j].nxd_ip_address.v6[2] = ((mac_ip0[0] | 0x2) << 24) | (mac_ip0[1] << 16) | (mac_ip0[2] << 8) | 0xFF;
310                 ipv6_address_ip0[i][j].nxd_ip_address.v6[3] = (0xFE << 24) | ((mac_ip0[3] | 0x2) << 16) | (mac_ip0[4] << 8) | mac_ip0[5];
311 
312                 ipv6_address_ip1[i][j].nxd_ip_version = NX_IP_VERSION_V6;
313                 ipv6_address_ip1[i][j].nxd_ip_address.v6[0] = 0xfe800000;
314                 ipv6_address_ip1[i][j].nxd_ip_address.v6[1] = 0x00000000;
315                 ipv6_address_ip1[i][j].nxd_ip_address.v6[2] =
316                     ((mac_ip1[0] | 0x2) << 24) | (mac_ip1[1] << 16) | (mac_ip1[2] << 8) | 0xFF;
317                 ipv6_address_ip1[i][j].nxd_ip_address.v6[3] =
318                     (0xFE << 24) | ((mac_ip1[3] | 0x2) << 16) | (mac_ip1[4] << 8) | mac_ip1[5];
319 
320                 status = nxd_ipv6_address_set(&ip_0, i, &ipv6_address_ip0[i][j], 10, NX_NULL);
321                 status += nxd_ipv6_address_set(&ip_1, i, &ipv6_address_ip1[i][j], 10, NX_NULL);
322             }
323             else
324             {
325                 /* Global Adddress */
326                 ipv6_address_ip0[i][j].nxd_ip_version = NX_IP_VERSION_V6;
327                 ipv6_address_ip0[i][j].nxd_ip_address.v6[0] = 0x20000000 + i;
328                 ipv6_address_ip0[i][j].nxd_ip_address.v6[1] = j;
329                 ipv6_address_ip0[i][j].nxd_ip_address.v6[2] = ipv6_address_ip0[i][0].nxd_ip_address.v6[2];
330                 ipv6_address_ip0[i][j].nxd_ip_address.v6[3] = ipv6_address_ip0[i][0].nxd_ip_address.v6[3];
331 
332                 ipv6_address_ip1[i][j].nxd_ip_version = NX_IP_VERSION_V6;
333                 ipv6_address_ip1[i][j].nxd_ip_address.v6[0] = 0x20000000 + i;
334                 ipv6_address_ip1[i][j].nxd_ip_address.v6[1] = j;
335                 ipv6_address_ip1[i][j].nxd_ip_address.v6[2] = ipv6_address_ip1[i][0].nxd_ip_address.v6[2];
336                 ipv6_address_ip1[i][j].nxd_ip_address.v6[3] = ipv6_address_ip1[i][0].nxd_ip_address.v6[3];
337 
338 
339                 status = nxd_ipv6_address_set(&ip_0, i, &ipv6_address_ip0[i][j], 64, NX_NULL);
340                 status += nxd_ipv6_address_set(&ip_1, i, &ipv6_address_ip1[i][j], 64, NX_NULL);
341             }
342             status += nxd_nd_cache_entry_set(&ip_0, ipv6_address_ip1[i][j].nxd_ip_address.v6, 0,  mac_ip1);
343             status += nxd_nd_cache_entry_set(&ip_1, ipv6_address_ip0[i][j].nxd_ip_address.v6, 0,  mac_ip0);
344         }
345 
346     }
347 
348 
349 
350     status += nxd_ipv6_enable(&ip_0);
351     status += nxd_ipv6_enable(&ip_1);
352 
353 
354 
355     if(status)
356         error_counter++;
357 #endif
358 
359     /* Wait for the semaphore to signal the other party is ready. */
360     tx_semaphore_get(&sema, 2 * NX_IP_PERIODIC_RATE);
361 
362     for(iface = 0; iface < 3; iface++)
363     {
364         test_udp4_on_interface(iface);
365 
366         tx_semaphore_get(&sema, 2 * NX_IP_PERIODIC_RATE);
367 
368 #ifdef FEATURE_NX_IPV6
369         for(addr_index = 1; addr_index < 3; addr_index++)
370         {
371 
372             test_udp6_on_interface_address(iface, addr_index);
373 
374             tx_semaphore_get(&sema, 2 * NX_IP_PERIODIC_RATE);
375         }
376 
377 #endif
378     }
379 
380 
381     tx_semaphore_delete(&sema);
382 
383     validate_bsd_structure();
384 
385     if(error_counter)
386         printf("ERROR!\n");
387     else
388         printf("SUCCESS!\n");
389 
390     if(error_counter)
391         test_control_return(1);
392 
393     test_control_return(0);
394 }
395 
ntest_1_entry(ULONG thread_input)396 static void    ntest_1_entry(ULONG thread_input)
397 {
398 ULONG           actual_status;
399 UINT            status;
400 UINT            iface;
401 NX_PACKET       *packet_ptr;
402 NX_UDP_SOCKET   server_socket;
403 ULONG           peer_ip;
404 UINT            peer_port;
405 NX_IPV4_HEADER *ipv4_header;
406 #ifdef FEATURE_NX_IPV6
407 NX_IPV6_HEADER  *ipv6_header;
408 UINT            addr_index;
409 NXD_ADDRESS     peer6_ip;
410 #endif
411     /* Ensure the IP instance has been initialized.  */
412     status =  nx_ip_status_check(&ip_1, NX_IP_INITIALIZE_DONE, &actual_status, 1 * NX_IP_PERIODIC_RATE);
413 
414     status =  nx_udp_socket_create(&ip_1, &server_socket, "Server Socket",
415                                    NX_IP_NORMAL, NX_FRAGMENT_OKAY, NX_IP_TIME_TO_LIVE, 10);
416 
417     if(status)
418         error_counter++;
419 
420     status = nx_udp_socket_bind(&server_socket, 12346, NX_WAIT_FOREVER);
421 
422     tx_semaphore_put(&sema);
423 
424 
425     for(iface = 0; iface < 3; iface++)
426     {
427 
428         status = nx_udp_socket_receive(&server_socket, &packet_ptr, NX_WAIT_FOREVER);
429 
430         /* Check status...  */
431         if (status != NX_SUCCESS)
432             error_counter++;
433         else
434         {
435 #ifdef __PRODUCT_NETXDUO__
436             ipv4_header = (NX_IPV4_HEADER*)packet_ptr -> nx_packet_ip_header;
437 #else
438             ipv4_header = (NX_IPV4_HEADER*)(packet_ptr -> nx_packet_prepend_ptr - 28);
439 #endif
440             status = nx_udp_source_extract(packet_ptr, &peer_ip,  &peer_port);
441             if(status != NX_SUCCESS)
442                 error_counter++;
443             if(peer_ip != ip0_address[iface])
444                 error_counter++;
445             if(peer_port != 12345)
446                 error_counter++;
447             if(ipv4_header -> nx_ip_header_destination_ip != ip1_address[iface])
448                 error_counter++;
449             if((packet_ptr -> nx_packet_length != strlen(bsd4_msg[iface])) ||
450                (memcmp(packet_ptr -> nx_packet_prepend_ptr, bsd4_msg[iface], packet_ptr -> nx_packet_length)))
451                 error_counter++;
452 
453             nx_packet_release(packet_ptr);
454         }
455 
456         tx_semaphore_put(&sema);
457 
458 #ifdef FEATURE_NX_IPV6
459         for(addr_index = 1; addr_index < 3; addr_index++)
460         {
461             status = nx_udp_socket_receive(&server_socket, &packet_ptr, NX_WAIT_FOREVER);
462 
463             if(status != NX_SUCCESS)
464                 error_counter++;
465             else
466             {
467                 ipv6_header = (NX_IPV6_HEADER*)packet_ptr -> nx_packet_ip_header;
468                 status = nxd_udp_source_extract(packet_ptr, &peer6_ip, &peer_port);
469                 if(status != NX_SUCCESS)
470                     error_counter++;
471                 if((peer6_ip.nxd_ip_version != NX_IP_VERSION_V6) ||
472                    (peer6_ip.nxd_ip_address.v6[0] != ipv6_address_ip0[iface][addr_index].nxd_ip_address.v6[0]) ||
473                    (peer6_ip.nxd_ip_address.v6[1] != ipv6_address_ip0[iface][addr_index].nxd_ip_address.v6[1]) ||
474                    (peer6_ip.nxd_ip_address.v6[2] != ipv6_address_ip0[iface][addr_index].nxd_ip_address.v6[2]) ||
475                    (peer6_ip.nxd_ip_address.v6[3] != ipv6_address_ip0[iface][addr_index].nxd_ip_address.v6[3]))
476                     error_counter++;
477                 if((ipv6_header -> nx_ip_header_destination_ip[0] != ipv6_address_ip1[iface][addr_index].nxd_ip_address.v6[0]) ||
478                    (ipv6_header -> nx_ip_header_destination_ip[1] != ipv6_address_ip1[iface][addr_index].nxd_ip_address.v6[1]) ||
479                    (ipv6_header -> nx_ip_header_destination_ip[2] != ipv6_address_ip1[iface][addr_index].nxd_ip_address.v6[2]) ||
480                    (ipv6_header -> nx_ip_header_destination_ip[3] != ipv6_address_ip1[iface][addr_index].nxd_ip_address.v6[3]))
481                     error_counter++;
482                 if(peer_port != 12345)
483                     error_counter++;
484 
485                 if((packet_ptr -> nx_packet_length != strlen(bsd6_msg[iface][addr_index])) ||
486                    (memcmp(packet_ptr -> nx_packet_prepend_ptr, bsd6_msg[iface][addr_index], packet_ptr -> nx_packet_length)))
487                     error_counter++;
488 
489                 nx_packet_release(packet_ptr);
490 
491                 tx_semaphore_put(&sema);
492             }
493         }
494 #endif
495     }
496 }
497 
validate_bsd_structure(void)498 static void validate_bsd_structure(void)
499 {
500 int i;
501     /* Make sure every BSD socket should be free by now. */
502 
503     for(i = 0; i < NX_BSD_MAX_SOCKETS; i++)
504     {
505         if(nx_bsd_socket_array[i].nx_bsd_socket_status_flags & NX_BSD_SOCKET_IN_USE)
506         {
507             error_counter++;
508         }
509 
510         if(nx_bsd_socket_array[i].nx_bsd_socket_tcp_socket ||
511            nx_bsd_socket_array[i].nx_bsd_socket_udp_socket)
512         {
513             error_counter++;
514         }
515     }
516 
517     /* Make sure all the NX SOCKET control blocks are released. */
518     if(nx_bsd_socket_block_pool.tx_block_pool_available !=
519        nx_bsd_socket_block_pool.tx_block_pool_total)
520     {
521         error_counter++;
522     }
523 
524     /* Make sure all the sockets are released */
525     if(ip_0.nx_ip_tcp_created_sockets_ptr ||
526        ip_0.nx_ip_udp_created_sockets_ptr)
527     {
528         error_counter++;
529         return;
530     }
531 }
532 
533 #else
534 extern void       test_control_return(UINT status);
535 
536 #ifdef CTEST
test_application_define(void * first_unused_memory)537 VOID test_application_define(void *first_unused_memory)
538 #else
539 void    netx_bsd_udp_bind_connect_test_application_define(void *first_unused_memory)
540 #endif
541 {
542 
543     /* Print out test information banner.  */
544     printf("NetX Test:   Basic BSD UDP Bind Connect Send Test..........N/A\n");
545 
546     test_control_return(3);
547 }
548 #endif
549