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 #include "nx_icmpv6.h"
31 
32 
33 /**************************************************************************/
34 /*                                                                        */
35 /*  FUNCTION                                               RELEASE        */
36 /*                                                                        */
37 /*    _nxd_icmp_ping                                      PORTABLE C      */
38 /*                                                           6.1          */
39 /*  AUTHOR                                                                */
40 /*                                                                        */
41 /*    Yuxin Zhou, Microsoft Corporation                                   */
42 /*                                                                        */
43 /*  DESCRIPTION                                                           */
44 /*                                                                        */
45 /*    Depending on the destination IP address, this function performs     */
46 /*    ICMP ping or ICMPv6 ping.                                           */
47 /*                                                                        */
48 /*  INPUT                                                                 */
49 /*                                                                        */
50 /*    ip_ptr                                Pointer to IP instance        */
51 /*    ip_address                            IP address to ping            */
52 /*    data_ptr                              User Data pointer             */
53 /*    data_size                             Size of User Data             */
54 /*    response_ptr                          Pointer to Response Packet    */
55 /*    wait_option                           Suspension option             */
56 /*                                                                        */
57 /*  OUTPUT                                                                */
58 /*                                                                        */
59 /*    NX_SUCCESS                            Successful completion         */
60 /*    NX_NOT_SUPPORTED                      IPv6 or ICMP not enabled      */
61 /*    status                                Actual completion status      */
62 /*                                                                        */
63 /*  CALLS                                                                 */
64 /*                                                                        */
65 /*    _nx_icmp_ping                         IPv4 ICMP ping routine.       */
66 /*    _nx_icmp_ping6                        IPv6 ICMP ping routine.       */
67 /*                                                                        */
68 /*  CALLED BY                                                             */
69 /*                                                                        */
70 /*    Application Code                                                    */
71 /*                                                                        */
72 /*  RELEASE HISTORY                                                       */
73 /*                                                                        */
74 /*    DATE              NAME                      DESCRIPTION             */
75 /*                                                                        */
76 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
77 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
78 /*                                            resulting in version 6.1    */
79 /*                                                                        */
80 /**************************************************************************/
_nxd_icmp_ping(NX_IP * ip_ptr,NXD_ADDRESS * ip_address,CHAR * data_ptr,ULONG data_size,NX_PACKET ** response_ptr,ULONG wait_option)81 UINT  _nxd_icmp_ping(NX_IP *ip_ptr, NXD_ADDRESS *ip_address, CHAR *data_ptr, ULONG data_size,
82                      NX_PACKET **response_ptr, ULONG wait_option)
83 {
84 
85 UINT status = NX_NOT_SUPPORTED;
86 
87 #ifndef NX_DISABLE_IPV4
88     if (ip_address -> nxd_ip_version == NX_IP_VERSION_V4)
89     {
90         status = _nx_icmp_ping(ip_ptr, ip_address -> nxd_ip_address.v4, data_ptr, data_size,
91                                response_ptr, wait_option);
92     }
93 #endif /* !NX_DISABLE_IPV4  */
94 
95 #ifdef FEATURE_NX_IPV6
96     if (ip_address -> nxd_ip_version == NX_IP_VERSION_V6)
97     {
98         status = _nx_icmp_ping6(ip_ptr, ip_address, data_ptr, data_size,
99                                 response_ptr, wait_option);
100     }
101 #endif /* FEATURE_NX_IPV6 */
102 
103     return(status);
104 }
105 
106