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_icmp.h"
29 
30 /**************************************************************************/
31 /*                                                                        */
32 /*  FUNCTION                                               RELEASE        */
33 /*                                                                        */
34 /*    _nx_icmp_enable                                     PORTABLE C      */
35 /*                                                           6.1          */
36 /*  AUTHOR                                                                */
37 /*                                                                        */
38 /*    Yuxin Zhou, Microsoft Corporation                                   */
39 /*                                                                        */
40 /*  DESCRIPTION                                                           */
41 /*                                                                        */
42 /*    This function enables the ICMP management component for the         */
43 /*    specified IP instance.                                              */
44 /*                                                                        */
45 /*  INPUT                                                                 */
46 /*                                                                        */
47 /*    ip_ptr                                IP instance pointer           */
48 /*                                                                        */
49 /*  OUTPUT                                                                */
50 /*                                                                        */
51 /*    status                                Completion status             */
52 /*                                                                        */
53 /*  CALLS                                                                 */
54 /*                                                                        */
55 /*    None                                                                */
56 /*                                                                        */
57 /*  CALLED BY                                                             */
58 /*                                                                        */
59 /*    Application Code                                                    */
60 /*                                                                        */
61 /*  RELEASE HISTORY                                                       */
62 /*                                                                        */
63 /*    DATE              NAME                      DESCRIPTION             */
64 /*                                                                        */
65 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
66 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
67 /*                                            resulting in version 6.1    */
68 /*                                                                        */
69 /**************************************************************************/
_nx_icmp_enable(NX_IP * ip_ptr)70 UINT  _nx_icmp_enable(NX_IP *ip_ptr)
71 {
72 
73 #ifndef NX_DISABLE_IPV4
74     /* If trace is enabled, insert this event into the trace buffer.  */
75     NX_TRACE_IN_LINE_INSERT(NX_TRACE_ICMP_ENABLE, ip_ptr, 0, 0, 0, NX_TRACE_ICMP_EVENTS, 0, 0);
76 
77     /* Setup the ICMP packet queue processing routine.  */
78     ip_ptr -> nx_ip_icmp_queue_process =  _nx_icmp_queue_process;
79 
80     /* Setup the ICMP packet receiving routine, thereby enabling ICMP traffic.  */
81     ip_ptr -> nx_ip_icmp_packet_receive =  _nx_icmp_packet_receive;
82 
83     /* Setup the ICMPv4 packet process routine */
84     ip_ptr -> nx_ip_icmpv4_packet_process = _nx_icmpv4_packet_process;
85 
86     /* Return a successful status!  */
87     return(NX_SUCCESS);
88 #else /* NX_DISABLE_IPV4  */
89     NX_PARAMETER_NOT_USED(ip_ptr);
90 
91     return(NX_NOT_SUPPORTED);
92 #endif /* !NX_DISABLE_IPV4  */
93 }
94 
95