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