1 /**************************************************************************/
2 /*                                                                        */
3 /*       Copyright (c) Microsoft Corporation. All rights reserved.        */
4 /*                                                                        */
5 /*       This software is licensed under the Microsoft Software License   */
6 /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
7 /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
8 /*       and in the root directory of this software.                      */
9 /*                                                                        */
10 /**************************************************************************/
11 
12 
13 /**************************************************************************/
14 /**************************************************************************/
15 /**                                                                       */
16 /** NetX Component                                                        */
17 /**                                                                       */
18 /**   Internet Control Message Protocol (ICMP)                            */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 #define NX_SOURCE_CODE
24 
25 
26 /* Include necessary system files.  */
27 
28 #include "nx_api.h"
29 #include "nx_icmp.h"
30 
31 #ifndef NX_DISABLE_IPV4
32 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _nx_icmp_queue_process                              PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Yuxin Zhou, Microsoft Corporation                                   */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function processes the ICMP receive packet queue.              */
45 /*                                                                        */
46 /*  INPUT                                                                 */
47 /*                                                                        */
48 /*    ip_ptr                                Pointer to IP control block   */
49 /*                                                                        */
50 /*  OUTPUT                                                                */
51 /*                                                                        */
52 /*    None                                                                */
53 /*                                                                        */
54 /*  CALLS                                                                 */
55 /*                                                                        */
56 /*    _nx_icmp_packet_process               Process ICMP packet           */
57 /*                                                                        */
58 /*  CALLED BY                                                             */
59 /*                                                                        */
60 /*    _nx_ip_thread_entry                   IP helper thread processing   */
61 /*                                                                        */
62 /*  RELEASE HISTORY                                                       */
63 /*                                                                        */
64 /*    DATE              NAME                      DESCRIPTION             */
65 /*                                                                        */
66 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
67 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
68 /*                                            resulting in version 6.1    */
69 /*                                                                        */
70 /**************************************************************************/
_nx_icmp_queue_process(NX_IP * ip_ptr)71 VOID  _nx_icmp_queue_process(NX_IP *ip_ptr)
72 {
73 
74 TX_INTERRUPT_SAVE_AREA
75 
76 NX_PACKET *queue_head;
77 NX_PACKET *packet_ptr;
78 
79 
80     /* Disable interrupts.  */
81     TX_DISABLE
82 
83     /* Remove the ICMP message queue from the IP structure.  */
84     queue_head =  ip_ptr -> nx_ip_icmp_queue_head;
85     ip_ptr -> nx_ip_icmp_queue_head =  NX_NULL;
86 
87     /* Restore interrupts.  */
88     TX_RESTORE
89 
90     /* Walk through the entire ICMP message queue and process packets
91        one by one.  */
92     while (queue_head)
93     {
94 
95         /* Pickup the first queued ICMP message and remove it from the
96            ICMP queue.  */
97         packet_ptr =  queue_head;
98         queue_head =  queue_head -> nx_packet_queue_next;
99         packet_ptr -> nx_packet_queue_next =  NX_NULL;
100 
101         /* Process the packet.  */
102         _nx_icmp_packet_process(ip_ptr, packet_ptr);
103     }
104 }
105 #endif /* !NX_DISABLE_IPV4  */
106 
107