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