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 /* Include necessary system files. */
25
26 #include "nx_api.h"
27 #include "nx_icmpv6.h"
28
29 #ifdef FEATURE_NX_IPV6
30
31
32
33 /**************************************************************************/
34 /* */
35 /* FUNCTION RELEASE */
36 /* */
37 /* _nx_icmp_ping6 PORTABLE C */
38 /* 6.1 */
39 /* AUTHOR */
40 /* */
41 /* Yuxin Zhou, Microsoft Corporation */
42 /* */
43 /* DESCRIPTION */
44 /* */
45 /* This function builds an ICMPv6 ping request packet and calls the */
46 /* associated driver to send it out on the network. The function will */
47 /* then suspend for the specified time waiting for the ICMP ping */
48 /* response. */
49 /* */
50 /* Note that for multicast or link local destination addresses, NetX */
51 /* Duo will default to the primary interface. To specify a non primary*/
52 /* interface to send pings out on with these address destination */
53 /* address types, use the nx_icmp_interface_ping6 service. */
54 /* */
55 /* INPUT */
56 /* */
57 /* ip_ptr Pointer to IP instance */
58 /* ip_address IPv6 address to ping */
59 /* data_ptr Pointer to user data to */
60 /* include in ping packet */
61 /* data_size Size of user data */
62 /* response_ptr Pointer to response packet */
63 /* wait_option Time out on packet allocate */
64 /* and sending packet */
65 /* */
66 /* OUTPUT */
67 /* */
68 /* status Actual completion status */
69 /* */
70 /* CALLS */
71 /* */
72 /* _nxd_ipv6_interface_find Finds outgoing interface */
73 /* _nx_icmp_interface_ping6 Handle details of sending pings*/
74 /* */
75 /* CALLED BY */
76 /* */
77 /* Application Code */
78 /* */
79 /* RELEASE HISTORY */
80 /* */
81 /* DATE NAME DESCRIPTION */
82 /* */
83 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
84 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
85 /* resulting in version 6.1 */
86 /* */
87 /**************************************************************************/
_nx_icmp_ping6(NX_IP * ip_ptr,NXD_ADDRESS * ip_address,CHAR * data_ptr,ULONG data_size,NX_PACKET ** response_ptr,ULONG wait_option)88 UINT _nx_icmp_ping6(NX_IP *ip_ptr, NXD_ADDRESS *ip_address, CHAR *data_ptr, ULONG data_size,
89 NX_PACKET **response_ptr, ULONG wait_option)
90 {
91
92 UINT status;
93 NXD_IPV6_ADDRESS *outgoing_address;
94
95 /* Clear the destination pointer. */
96 *response_ptr = NX_NULL;
97
98 /* Find a suitable outgoing interface. */
99 status = _nxd_ipv6_interface_find(ip_ptr, ip_address -> nxd_ip_address.v6,
100 &outgoing_address, NX_NULL);
101
102 /* Cannot find usable outgoing interface. */
103 if (status != NX_SUCCESS)
104 {
105 return(status);
106 }
107
108 /* Now send the actual ping packet. */
109 /*lint -e{644} suppress variable might not be initialized, since "outgoing_address" was initialized in _nxd_ipv6_interface_find. */
110 status = _nx_icmp_interface_ping6(ip_ptr, ip_address, data_ptr, data_size, outgoing_address, response_ptr, wait_option);
111
112 return(status);
113 }
114
115 #endif /* FEATURE_NX_IPV6 */
116
117