1 /***************************************************************************
2  * Copyright (c) 2024 Microsoft Corporation
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the MIT License which is available at
6  * https://opensource.org/licenses/MIT.
7  *
8  * SPDX-License-Identifier: MIT
9  **************************************************************************/
10 
11 
12 /**************************************************************************/
13 /**************************************************************************/
14 /**                                                                       */
15 /** NetX Component                                                        */
16 /**                                                                       */
17 /**   Internet Control Message Protocol (ICMP)                            */
18 /**                                                                       */
19 /**************************************************************************/
20 /**************************************************************************/
21 
22 #define NX_SOURCE_CODE
23 
24 
25 /* Include necessary system files.  */
26 
27 #include "nx_api.h"
28 #include "nx_packet.h"
29 #include "nx_icmp.h"
30 #include "nx_icmpv6.h"
31 
32 #ifndef NX_DISABLE_IPV4
33 /**************************************************************************/
34 /*                                                                        */
35 /*  FUNCTION                                               RELEASE        */
36 /*                                                                        */
37 /*    _nx_icmp_packet_process                             PORTABLE C      */
38 /*                                                           6.1          */
39 /*  AUTHOR                                                                */
40 /*                                                                        */
41 /*    Yuxin Zhou, Microsoft Corporation                                   */
42 /*                                                                        */
43 /*  DESCRIPTION                                                           */
44 /*                                                                        */
45 /*    This function examines the incoming ICMP received packet and        */
46 /*    route the packet to the appropriate ICMP packet process handler.    */
47 /*                                                                        */
48 /*  INPUT                                                                 */
49 /*                                                                        */
50 /*    ip_ptr                                Pointer to IP control block   */
51 /*    packet_ptr                            ICMP packet pointer           */
52 /*                                                                        */
53 /*  OUTPUT                                                                */
54 /*                                                                        */
55 /*    None                                                                */
56 /*                                                                        */
57 /*  CALLS                                                                 */
58 /*                                                                        */
59 /*  _nx_icmpv4_packet_process               Process received ICMPv4 packet*/
60 /*  _nx_icmpv6_packet_process               Process received ICMPv6 packet*/
61 /*                                                                        */
62 /*  CALLED BY                                                             */
63 /*                                                                        */
64 /*    _nx_icmp_packet_receive               ICMP packet receive           */
65 /*    _nx_icmp_queue_process                ICMP packet queue processing  */
66 /*                                                                        */
67 /*  RELEASE HISTORY                                                       */
68 /*                                                                        */
69 /*    DATE              NAME                      DESCRIPTION             */
70 /*                                                                        */
71 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
72 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
73 /*                                            resulting in version 6.1    */
74 /*                                                                        */
75 /**************************************************************************/
_nx_icmp_packet_process(NX_IP * ip_ptr,NX_PACKET * packet_ptr)76 VOID  _nx_icmp_packet_process(NX_IP *ip_ptr, NX_PACKET *packet_ptr)
77 {
78 
79     /* Add debug information. */
80     NX_PACKET_DEBUG(__FILE__, __LINE__, packet_ptr);
81 
82     /* FEATURE_NX_IPV6 not defined */
83     if (ip_ptr -> nx_ip_icmpv4_packet_process)
84     {
85         ip_ptr -> nx_ip_icmpv4_packet_process(ip_ptr, packet_ptr);
86         return;
87     }
88 
89 #ifndef NX_DISABLE_ICMP_INFO
90     ip_ptr -> nx_ip_icmp_invalid_packets++;
91 #endif /* NX_DISABLE_ICMP_INFO */
92 
93     _nx_packet_release(packet_ptr);
94 }
95 #endif /* !NX_DISABLE_IPV4  */
96 
97