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_packet.h"
30 #include "nx_icmp.h"
31 #include "nx_icmpv6.h"
32 
33 #ifndef NX_DISABLE_IPV4
34 /**************************************************************************/
35 /*                                                                        */
36 /*  FUNCTION                                               RELEASE        */
37 /*                                                                        */
38 /*    _nx_icmp_packet_process                             PORTABLE C      */
39 /*                                                           6.1          */
40 /*  AUTHOR                                                                */
41 /*                                                                        */
42 /*    Yuxin Zhou, Microsoft Corporation                                   */
43 /*                                                                        */
44 /*  DESCRIPTION                                                           */
45 /*                                                                        */
46 /*    This function examines the incoming ICMP received packet and        */
47 /*    route the packet to the appropriate ICMP packet process handler.    */
48 /*                                                                        */
49 /*  INPUT                                                                 */
50 /*                                                                        */
51 /*    ip_ptr                                Pointer to IP control block   */
52 /*    packet_ptr                            ICMP packet pointer           */
53 /*                                                                        */
54 /*  OUTPUT                                                                */
55 /*                                                                        */
56 /*    None                                                                */
57 /*                                                                        */
58 /*  CALLS                                                                 */
59 /*                                                                        */
60 /*  _nx_icmpv4_packet_process               Process received ICMPv4 packet*/
61 /*  _nx_icmpv6_packet_process               Process received ICMPv6 packet*/
62 /*                                                                        */
63 /*  CALLED BY                                                             */
64 /*                                                                        */
65 /*    _nx_icmp_packet_receive               ICMP packet receive           */
66 /*    _nx_icmp_queue_process                ICMP packet queue processing  */
67 /*                                                                        */
68 /*  RELEASE HISTORY                                                       */
69 /*                                                                        */
70 /*    DATE              NAME                      DESCRIPTION             */
71 /*                                                                        */
72 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
73 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
74 /*                                            resulting in version 6.1    */
75 /*                                                                        */
76 /**************************************************************************/
_nx_icmp_packet_process(NX_IP * ip_ptr,NX_PACKET * packet_ptr)77 VOID  _nx_icmp_packet_process(NX_IP *ip_ptr, NX_PACKET *packet_ptr)
78 {
79 
80     /* Add debug information. */
81     NX_PACKET_DEBUG(__FILE__, __LINE__, packet_ptr);
82 
83     /* FEATURE_NX_IPV6 not defined */
84     if (ip_ptr -> nx_ip_icmpv4_packet_process)
85     {
86         ip_ptr -> nx_ip_icmpv4_packet_process(ip_ptr, packet_ptr);
87         return;
88     }
89 
90 #ifndef NX_DISABLE_ICMP_INFO
91     ip_ptr -> nx_ip_icmp_invalid_packets++;
92 #endif /* NX_DISABLE_ICMP_INFO */
93 
94     _nx_packet_release(packet_ptr);
95 }
96 #endif /* !NX_DISABLE_IPV4  */
97 
98