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_ip.h"
29 #include "nx_icmp.h"
30
31
32 /* Bring in externs for caller checking code. */
33
34 NX_CALLER_CHECKING_EXTERNS
35
36
37 /**************************************************************************/
38 /* */
39 /* FUNCTION RELEASE */
40 /* */
41 /* _nxe_icmp_ping PORTABLE C */
42 /* 6.1 */
43 /* AUTHOR */
44 /* */
45 /* Yuxin Zhou, Microsoft Corporation */
46 /* */
47 /* DESCRIPTION */
48 /* */
49 /* This function checks for errors in the ICMP ping function call. */
50 /* */
51 /* INPUT */
52 /* */
53 /* ip_ptr Pointer to IP instance */
54 /* ip_address IP address to ping */
55 /* data_ptr User Data pointer */
56 /* data_size Size of User Data */
57 /* response_ptr Pointer to Response Packet */
58 /* wait_option Suspension option */
59 /* */
60 /* OUTPUT */
61 /* */
62 /* None */
63 /* */
64 /* CALLS */
65 /* */
66 /* _nx_icmp_ping Actual ICMP ping function */
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 /**************************************************************************/
_nxe_icmp_ping(NX_IP * ip_ptr,ULONG ip_address,CHAR * data_ptr,ULONG data_size,NX_PACKET ** response_ptr,ULONG wait_option)81 UINT _nxe_icmp_ping(NX_IP *ip_ptr, ULONG ip_address,
82 CHAR *data_ptr, ULONG data_size,
83 NX_PACKET **response_ptr, ULONG wait_option)
84 {
85
86 #ifndef NX_DISABLE_IPV4
87 UINT status;
88
89
90 /* Check for invalid input pointers. */
91 if ((ip_ptr == NX_NULL) || (ip_ptr -> nx_ip_id != NX_IP_ID) || (response_ptr == NX_NULL))
92 {
93 return(NX_PTR_ERROR);
94 }
95
96 /* Check for invalid IP address. */
97 if (!ip_address)
98 {
99 return(NX_IP_ADDRESS_ERROR);
100 }
101
102 /* Check to see if ICMP is enabled. */
103 if (!ip_ptr -> nx_ip_icmp_packet_receive)
104 {
105 return(NX_NOT_ENABLED);
106 }
107
108 /* Check for appropriate caller. */
109 NX_THREADS_ONLY_CALLER_CHECKING
110
111 /* Call actual ICMP ping function. */
112 status = _nx_icmp_ping(ip_ptr, ip_address, data_ptr, data_size,
113 response_ptr, wait_option);
114
115 /* Return completion status. */
116 return(status);
117 #else /* NX_DISABLE_IPV4 */
118 NX_PARAMETER_NOT_USED(ip_ptr);
119 NX_PARAMETER_NOT_USED(ip_address);
120 NX_PARAMETER_NOT_USED(data_ptr);
121 NX_PARAMETER_NOT_USED(data_size);
122 NX_PARAMETER_NOT_USED(response_ptr);
123 NX_PARAMETER_NOT_USED(wait_option);
124
125 return(NX_NOT_SUPPORTED);
126 #endif /* !NX_DISABLE_IPV4 */
127 }
128
129