Select one of the symbols to view example projects that use it.
 
Outline
...
...
...
...
#define NX_SOURCE_CODE
#include "nx_api.h"
#include "tx_thread.h"
#include "nx_udp.h"
#include "nx_packet.h"
#include "nx_icmpv4.h"
#include "nx_ipv6.h"
#include "nx_icmpv6.h"
...
...
_nx_udp_packet_receive(NX_IP *, NX_PACKET *)
Files
loading...
CodeScopeSTM32 Libraries and Samplesnetxduocommon/src/nx_udp_packet_receive.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/**************************************************************************/ /* */ /* Copyright (c) Microsoft Corporation. All rights reserved. */ /* */ /* This software is licensed under the Microsoft Software License */ /* Terms for Microsoft Azure RTOS. Full text of the license can be */ /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ /* and in the root directory of this software. */ /* */... /**************************************************************************/ ... /**************************************************************************/ /**************************************************************************/ /** */ /** NetX Component */ /** */ /** User Datagram Protocol (UDP) */ /** */... /**************************************************************************/ /**************************************************************************/ #define NX_SOURCE_CODE /* Include necessary system files. */ #include "nx_api.h" #include "tx_thread.h" #include "nx_udp.h" #include "nx_packet.h" #include "nx_icmpv4.h" 5 includes #ifdef FEATURE_NX_IPV6 /* for ICMPv6 destination unreachable */ #include "nx_ipv6.h" #include "nx_icmpv6.h" /* ... */ #endif /* FEATURE_NX_IPV6 */ ... /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _nx_udp_packet_receive PORTABLE C */ /* 6.1 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ /* */ /* DESCRIPTION */ /* */ /* This function receives a UDP packet from the IP receive processing */ /* and places on the appropriate socket's input queue. */ /* */ /* INPUT */ /* */ /* ip_ptr Pointer to IP control block */ /* packet_ptr Pointer to packet received */ /* */ /* OUTPUT */ /* */ /* None */ /* */ /* CALLS */ /* */ /* _nx_packet_release Packet release function */ /* tx_mutex_get Get protection mutex */ /* tx_mutex_put Release protection mutex */ /* _tx_thread_system_resume Resume suspended thread */ /* (nx_udp_receive_callback) Packet receive notify function*/ /* */ /* CALLED BY */ /* */ /* _nx_ip_packet_receive Dispatch received IP packets */ /* */ /* RELEASE HISTORY */ /* */ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ /* */... /**************************************************************************/ VOID _nx_udp_packet_receive(NX_IP *ip_ptr, NX_PACKET *packet_ptr) { TX_INTERRUPT_SAVE_AREA VOID (*receive_callback)(struct NX_UDP_SOCKET_STRUCT *socket_ptr); UINT index; UINT port; TX_THREAD *thread_ptr; NX_UDP_SOCKET *socket_ptr; NX_UDP_HEADER *udp_header_ptr; /* Add debug information. */ NX_PACKET_DEBUG(__FILE__, __LINE__, packet_ptr); #ifndef NX_DISABLE_UDP_INFO /* Increment the total UDP receive packets count. */ ip_ptr -> nx_ip_udp_packets_received++;/* ... */ #endif #ifndef NX_DISABLE_RX_SIZE_CHECKING /* Check for valid packet length. */ if (packet_ptr -> nx_packet_length < sizeof(NX_UDP_HEADER)) { #ifndef NX_DISABLE_UDP_INFO /* Increment the UDP invalid packet error. */ ip_ptr -> nx_ip_udp_invalid_packets++;/* ... */ #endif /* Invalid packet length, just release it. */ _nx_packet_release(packet_ptr); /* The function is complete, just return! */ return; }if (packet_ptr -> nx_packet_length < sizeof(NX_UDP_HEADER)) { ... } /* ... */#endif /* Pickup the pointer to the head of the UDP packet. */ /*lint -e{927} -e{826} suppress cast of pointer to pointer, since it is necessary */ udp_header_ptr = (NX_UDP_HEADER *)packet_ptr -> nx_packet_prepend_ptr; /* Endian swapping logic. If NX_LITTLE_ENDIAN is specified, these macros will swap the endian of the UDP header. *//* ... */ NX_CHANGE_ULONG_ENDIAN(udp_header_ptr -> nx_udp_header_word_0); NX_CHANGE_ULONG_ENDIAN(udp_header_ptr -> nx_udp_header_word_1); #ifndef NX_DISABLE_RX_SIZE_CHECKING /* Check for valid packet length. */ if (packet_ptr -> nx_packet_length < (((udp_header_ptr -> nx_udp_header_word_1) >> NX_SHIFT_BY_16) & NX_LOWER_16_MASK)) { #ifndef NX_DISABLE_UDP_INFO /* Increment the UDP invalid packet error. */ ip_ptr -> nx_ip_udp_invalid_packets++;/* ... */ #endif /* Invalid packet length, just release it. */ _nx_packet_release(packet_ptr); /* The function is complete, just return! */ return; }if (packet_ptr -> nx_packet_length < (((udp_header_ptr -> nx_udp_header_word_1) >> NX_SHIFT_BY_16) & NX_LOWER_16_MASK)) { ... } /* ... */#endif #ifdef NX_IPSEC_ENABLE /* Recompute the packet length in case TFC padding is present. */ packet_ptr -> nx_packet_length = (((udp_header_ptr -> nx_udp_header_word_1) >> NX_SHIFT_BY_16) & NX_LOWER_16_MASK);/* ... */ #endif /* NX_IPSEC_ENABLE */ /* Pickup the destination UDP port. */ port = (UINT)(udp_header_ptr -> nx_udp_header_word_0 & NX_LOWER_16_MASK); /* Calculate the hash index in the UDP port array of the associated IP instance. */ index = (UINT)((port + (port >> 8)) & NX_UDP_PORT_TABLE_MASK); /* Determine if the caller is a thread. If so, we should use the protection mutex to avoid having the port list examined while we are traversing it. If this routine is called from an ISR nothing needs to be done since bind/unbind are not allowed from ISRs. *//* ... */ if ((_tx_thread_current_ptr) && (TX_THREAD_GET_SYSTEM_STATE() == 0)) { /* Get mutex protection. */ tx_mutex_get(&(ip_ptr -> nx_ip_protection), NX_WAIT_FOREVER); }if ((_tx_thread_current_ptr) && (TX_THREAD_GET_SYSTEM_STATE() == 0)) { ... } /* Search the bound sockets in this index for the particular port. */ socket_ptr = ip_ptr -> nx_ip_udp_port_table[index]; /* Determine if there are any sockets bound on this port index. */ if (!socket_ptr) { #ifndef NX_DISABLE_IPV4 #ifndef NX_DISABLE_ICMPV4_ERROR_MESSAGE /* If ICMPv4 is enabled, send Destination unreachable. */ if ((packet_ptr -> nx_packet_ip_version == NX_IP_VERSION_V4) && (ip_ptr -> nx_ip_icmpv4_packet_process)) { /* Restore UDP header. */ NX_CHANGE_ULONG_ENDIAN(udp_header_ptr -> nx_udp_header_word_0); NX_CHANGE_ULONG_ENDIAN(udp_header_ptr -> nx_udp_header_word_1); /* Send out ICMP error message if dest is not multicast. */ NX_ICMPV4_SEND_DEST_UNREACHABLE(ip_ptr, packet_ptr, NX_ICMP_PORT_UNREACH_CODE); }if ((packet_ptr -> nx_packet_ip_version == NX_IP_VERSION_V4) && (ip_ptr -> nx_ip_icmpv4_packet_process)) { ... } /* ... */#endif /* NX_DISABLE_ICMPV4_ERROR_MESSAGE *//* ... */ #endif /* !NX_DISABLE_IPV4 */ #ifdef FEATURE_NX_IPV6 #ifndef NX_DISABLE_ICMPV6_ERROR_MESSAGE /* If ICMPv6 is enabled, send Destination unreachable. */ if (packet_ptr -> nx_packet_ip_version == NX_IP_VERSION_V6) { NX_IPV6_HEADER *ip_header; /*lint -e{927} -e{826} suppress cast of pointer to pointer, since it is necessary */ ip_header = (NX_IPV6_HEADER *)packet_ptr -> nx_packet_ip_header; if ((ip_header -> nx_ip_header_destination_ip[0] & (ULONG)0xFF000000) != (ULONG)0xFF000000) { /* Restore UDP header. */ NX_CHANGE_ULONG_ENDIAN(udp_header_ptr -> nx_udp_header_word_0); NX_CHANGE_ULONG_ENDIAN(udp_header_ptr -> nx_udp_header_word_1); /* Send out ICMP error message if dest is not multicast. */ NX_ICMPV6_SEND_DEST_UNREACHABLE(ip_ptr, packet_ptr, NX_ICMPV6_DEST_UNREACHABLE_CODE); }if ((ip_header -> nx_ip_header_destination_ip[0] & (ULONG)0xFF000000) != (ULONG)0xFF000000) { ... } }if (packet_ptr -> nx_packet_ip_version == NX_IP_VERSION_V6) { ... } /* ... */#endif /* NX_DISABLE_ICMPV6_ERROR_MESSAGE *//* ... */ #endif /* FEATURE_NX_IPV6 */ #ifndef NX_DISABLE_UDP_INFO /* Increment the no port for delivery count. */ ip_ptr -> nx_ip_udp_no_port_for_delivery++; /* Increment the total UDP receive packets dropped count. */ ip_ptr -> nx_ip_udp_receive_packets_dropped++;/* ... */ #endif /* Determine if the caller is a thread. If so, release the mutex protection previously setup. */ if ((_tx_thread_current_ptr) && (TX_THREAD_GET_SYSTEM_STATE() == 0)) { /* Release mutex protection. */ tx_mutex_put(&(ip_ptr -> nx_ip_protection)); }if ((_tx_thread_current_ptr) && (TX_THREAD_GET_SYSTEM_STATE() == 0)) { ... } /* Release the packet. */ _nx_packet_release(packet_ptr); /* Just return. */ return; }if (!socket_ptr) { ... } /* Loop to examine the list of bound ports on this index. */ do { /* Determine if the port has been found. */ if (socket_ptr -> nx_udp_socket_port == port) { /* Yes, we have a match. */ #ifndef NX_DISABLE_UDP_INFO /* Increment the total number of packets received for this socket. */ socket_ptr -> nx_udp_socket_packets_received++; /* Increment the total UDP receive bytes. */ ip_ptr -> nx_ip_udp_bytes_received += packet_ptr -> nx_packet_length - (ULONG)sizeof(NX_UDP_HEADER); socket_ptr -> nx_udp_socket_bytes_received += packet_ptr -> nx_packet_length - (ULONG)sizeof(NX_UDP_HEADER);/* ... */ #endif /* If trace is enabled, insert this event into the trace buffer. */ NX_TRACE_IN_LINE_INSERT(NX_TRACE_INTERNAL_UDP_RECEIVE, ip_ptr, socket_ptr, packet_ptr, udp_header_ptr -> nx_udp_header_word_0, NX_TRACE_INTERNAL_EVENTS, 0, 0); /* Get out of the search loop. */ break; }if (socket_ptr -> nx_udp_socket_port == port) { ... } else { /* Move to the next entry in the bound index. */ socket_ptr = socket_ptr -> nx_udp_socket_bound_next; }else { ... } ...} while (socket_ptr != ip_ptr -> nx_ip_udp_port_table[index]); /* Determine if the caller is a thread. If so, release the mutex protection previously setup. */ if ((_tx_thread_current_ptr) && (TX_THREAD_GET_SYSTEM_STATE() == 0)) { /* Release mutex protection. */ tx_mutex_put(&(ip_ptr -> nx_ip_protection)); }if ((_tx_thread_current_ptr) && (TX_THREAD_GET_SYSTEM_STATE() == 0)) { ... } /* Determine if a match was found. */ if (socket_ptr -> nx_udp_socket_port != port) { #ifndef NX_DISABLE_UDP_INFO /* Increment the no port for delivery count. */ ip_ptr -> nx_ip_udp_no_port_for_delivery++; /* Increment the total UDP receive packets dropped count. */ ip_ptr -> nx_ip_udp_receive_packets_dropped++;/* ... */ #endif #if !defined(NX_DISABLE_IPV4) && !defined(NX_DISABLE_ICMPV4_ERROR_MESSAGE) /* If ICMPv4 is enabled, send Destination unreachable. */ if ((packet_ptr -> nx_packet_ip_version == NX_IP_VERSION_V4) && (ip_ptr -> nx_ip_icmpv4_packet_process)) { /* Restore UDP header. */ NX_CHANGE_ULONG_ENDIAN(udp_header_ptr -> nx_udp_header_word_0); NX_CHANGE_ULONG_ENDIAN(udp_header_ptr -> nx_udp_header_word_1); /* Send out ICMP error message if dest is not multicast. */ NX_ICMPV4_SEND_DEST_UNREACHABLE(ip_ptr, packet_ptr, NX_ICMP_PORT_UNREACH_CODE); }if ((packet_ptr -> nx_packet_ip_version == NX_IP_VERSION_V4) && (ip_ptr -> nx_ip_icmpv4_packet_process)) { ... } /* ... */#endif /* !NX_DISABLE_IPV4 && !NX_DISABLE_ICMPV4_ERROR_MESSAGE */ #if defined(FEATURE_NX_IPV6) && !defined(NX_DISABLE_ICMPV6_ERROR_MESSAGE) /* If ICMPv6 is enabled, send Destination unreachable. */ if (packet_ptr -> nx_packet_ip_version == NX_IP_VERSION_V6) { NX_IPV6_HEADER *ip_header; /*lint -e{927} -e{826} suppress cast of pointer to pointer, since it is necessary */ ip_header = (NX_IPV6_HEADER *)packet_ptr -> nx_packet_ip_header; /* Send out ICMP error message if dest is not multicast. */ if ((ip_header -> nx_ip_header_destination_ip[0] & (ULONG)0xFF000000) != (ULONG)0xFF000000) { /* Restore UDP header. */ NX_CHANGE_ULONG_ENDIAN(udp_header_ptr -> nx_udp_header_word_0); NX_CHANGE_ULONG_ENDIAN(udp_header_ptr -> nx_udp_header_word_1); NX_ICMPV6_SEND_DEST_UNREACHABLE(ip_ptr, packet_ptr, NX_ICMPV6_DEST_UNREACHABLE_CODE); }if ((ip_header -> nx_ip_header_destination_ip[0] & (ULONG)0xFF000000) != (ULONG)0xFF000000) { ... } }if (packet_ptr -> nx_packet_ip_version == NX_IP_VERSION_V6) { ... } /* ... */#endif /* FEATURE_NX_IPV6 && !NX_DISABLE_ICMPV6_ERROR_MESSAGE */ /* No socket structure bound to this port, just release the packet. */ _nx_packet_release(packet_ptr); return; }if (socket_ptr -> nx_udp_socket_port != port) { ... } /* Disable interrupts. */ TX_DISABLE /* Determine if the socket is still valid. */ if (socket_ptr -> nx_udp_socket_id != NX_UDP_ID) { #ifndef NX_DISABLE_UDP_INFO /* Increment the no port for delivery count. */ ip_ptr -> nx_ip_udp_no_port_for_delivery++; /* Increment the total UDP receive packets dropped count. */ ip_ptr -> nx_ip_udp_receive_packets_dropped++; /* Increment the total UDP receive packets dropped count for this socket. */ socket_ptr -> nx_udp_socket_packets_dropped++;/* ... */ #endif /* Restore interrupts. */ TX_RESTORE /* Release the packet. */ _nx_packet_release(packet_ptr); /* Return to caller. */ return; }if (socket_ptr -> nx_udp_socket_id != NX_UDP_ID) { ... } /* Pickup the receive notify function. */ receive_callback = socket_ptr -> nx_udp_receive_callback; /* Determine if we need to update the UDP port head pointer. This should only be done if the found socket pointer is not the head pointer and the mutex for this IP instance is available. *//* ... */ if ((socket_ptr != ip_ptr -> nx_ip_udp_port_table[index]) && (!ip_ptr -> nx_ip_protection.tx_mutex_ownership_count)) { /* Move the port head pointer to this socket. */ ip_ptr -> nx_ip_udp_port_table[index] = socket_ptr; }if ((socket_ptr != ip_ptr -> nx_ip_udp_port_table[index]) && (!ip_ptr -> nx_ip_protection.tx_mutex_ownership_count)) { ... } /* Determine if there is thread waiting for a packet from this port. */ thread_ptr = socket_ptr -> nx_udp_socket_receive_suspension_list; if (thread_ptr) { /* Remove the suspended thread from the list. */ /* See if this is the only suspended thread on the list. */ if (thread_ptr == thread_ptr -> tx_thread_suspended_next) { /* Yes, the only suspended thread. */ /* Update the head pointer. */ socket_ptr -> nx_udp_socket_receive_suspension_list = NX_NULL; }if (thread_ptr == thread_ptr -> tx_thread_suspended_next) { ... } else { /* At least one more thread is on the same expiration list. */ /* Update the list head pointer. */ socket_ptr -> nx_udp_socket_receive_suspension_list = thread_ptr -> tx_thread_suspended_next; /* Update the links of the adjacent threads. */ (thread_ptr -> tx_thread_suspended_next) -> tx_thread_suspended_previous = thread_ptr -> tx_thread_suspended_previous; (thread_ptr -> tx_thread_suspended_previous) -> tx_thread_suspended_next = thread_ptr -> tx_thread_suspended_next; }else { ... } /* Decrement the suspension count. */ socket_ptr -> nx_udp_socket_receive_suspended_count--; /* Prepare for resumption of the first thread. */ /* Clear cleanup routine to avoid timeout. */ thread_ptr -> tx_thread_suspend_cleanup = TX_NULL; /* Temporarily disable preemption. */ _tx_thread_preempt_disable++; /* Return this block pointer to the suspended thread waiting for a block. *//* ... */ *((NX_PACKET **)thread_ptr -> tx_thread_additional_suspend_info) = packet_ptr; /* Add debug information. */ NX_PACKET_DEBUG(__FILE__, __LINE__, packet_ptr); /* Restore interrupts. */ TX_RESTORE /* Put return status into the thread control block. */ thread_ptr -> tx_thread_suspend_status = NX_SUCCESS; /* Resume thread. */ _tx_thread_system_resume(thread_ptr); }if (thread_ptr) { ... } else { /* No, queue the thread in the socket's receive packet queue. */ #ifdef NX_ENABLE_LOW_WATERMARK /* Check low watermark. */ if (packet_ptr -> nx_packet_pool_owner -> nx_packet_pool_available < packet_ptr -> nx_packet_pool_owner -> nx_packet_pool_low_watermark) { #ifndef NX_DISABLE_UDP_INFO /* Increment the total UDP receive packets dropped count. */ ip_ptr -> nx_ip_udp_receive_packets_dropped++; /* Increment the total UDP receive packets dropped count for this socket. */ socket_ptr -> nx_udp_socket_packets_dropped++;/* ... */ #endif /* Restore interrupts. */ TX_RESTORE /* Release the packet. */ _nx_packet_release(packet_ptr); /* Just return. */ return; }if (packet_ptr -> nx_packet_pool_owner -> nx_packet_pool_available < packet_ptr -> nx_packet_pool_owner -> nx_packet_pool_low_watermark) { ... } /* ... */#endif /* NX_ENABLE_LOW_WATERMARK */ /* Place the packet at the end of the socket's receive queue. */ if (socket_ptr -> nx_udp_socket_receive_head) { /* Add the new packet to a nonempty list. */ (socket_ptr -> nx_udp_socket_receive_tail) -> nx_packet_queue_next = packet_ptr; socket_ptr -> nx_udp_socket_receive_tail = packet_ptr; packet_ptr -> nx_packet_queue_next = NX_NULL; /* Increment the number of packets queued. */ socket_ptr -> nx_udp_socket_receive_count++; /* Determine if the maximum queue depth has been reached. */ if (socket_ptr -> nx_udp_socket_receive_count > socket_ptr -> nx_udp_socket_queue_maximum) { /* We have exceeded the queue depth, so remove the first item in the queue (which is the oldest). *//* ... */ packet_ptr = socket_ptr -> nx_udp_socket_receive_head; socket_ptr -> nx_udp_socket_receive_head = packet_ptr -> nx_packet_queue_next; /* Decrement the number of packets queued. */ socket_ptr -> nx_udp_socket_receive_count--; #ifndef NX_DISABLE_UDP_INFO /* Increment the total UDP receive packets dropped count. */ ip_ptr -> nx_ip_udp_receive_packets_dropped++; /* Increment the total UDP receive packets dropped count for this socket. */ socket_ptr -> nx_udp_socket_packets_dropped++;/* ... */ #endif /* Restore interrupts. */ TX_RESTORE /* Release the packet. */ _nx_packet_release(packet_ptr); }if (socket_ptr -> nx_udp_socket_receive_count > socket_ptr -> nx_udp_socket_queue_maximum) { ... } else { /* Restore interrupts. */ TX_RESTORE }else { ... } }if (socket_ptr -> nx_udp_socket_receive_head) { ... } else { /* Add the new packet to an empty list. */ socket_ptr -> nx_udp_socket_receive_head = packet_ptr; socket_ptr -> nx_udp_socket_receive_tail = packet_ptr; packet_ptr -> nx_packet_queue_next = NX_NULL; /* Increment the number of packets queued. */ socket_ptr -> nx_udp_socket_receive_count++; /* Restore interrupts. */ TX_RESTORE }else { ... } /* Add debug information. */ NX_PACKET_DEBUG(NX_PACKET_UDP_RECEIVE_QUEUE, __LINE__, packet_ptr); }else { ... } /* Determine if there is a socket receive notification function specified. */ if (receive_callback) { /* Yes, notification is requested. Call the application's receive notification function for this socket. *//* ... */ (receive_callback)(socket_ptr); }if (receive_callback) { ... } }{ ... }