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
31
32 /**************************************************************************/
33 /* */
34 /* FUNCTION RELEASE */
35 /* */
36 /* _nx_icmp_info_get PORTABLE C */
37 /* 6.1 */
38 /* AUTHOR */
39 /* */
40 /* Yuxin Zhou, Microsoft Corporation */
41 /* */
42 /* DESCRIPTION */
43 /* */
44 /* This function retrieves the selected ICMP information for the */
45 /* caller. */
46 /* */
47 /* INPUT */
48 /* */
49 /* ip_ptr Pointer to IP instance */
50 /* pings_sent Destination for number of */
51 /* pings sent */
52 /* ping_timeouts Destination for number of */
53 /* ping timeouts */
54 /* ping_threads_suspended Destination for number of */
55 /* threads suspended on pings */
56 /* ping_responses_received Destination for number of */
57 /* ping responses received */
58 /* icmp_checksum_errors Destination for number of */
59 /* ICMP checksum errors */
60 /* icmp_unhandled_messages Destination for number of */
61 /* unhandled ICMP messages */
62 /* */
63 /* OUTPUT */
64 /* */
65 /* None */
66 /* */
67 /* CALLS */
68 /* */
69 /* tx_mutex_get Obtain protection mutex */
70 /* tx_mutex_put Release protection mutex */
71 /* */
72 /* CALLED BY */
73 /* */
74 /* Application Code */
75 /* */
76 /* RELEASE HISTORY */
77 /* */
78 /* DATE NAME DESCRIPTION */
79 /* */
80 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
81 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
82 /* resulting in version 6.1 */
83 /* */
84 /**************************************************************************/
_nx_icmp_info_get(NX_IP * ip_ptr,ULONG * pings_sent,ULONG * ping_timeouts,ULONG * ping_threads_suspended,ULONG * ping_responses_received,ULONG * icmp_checksum_errors,ULONG * icmp_unhandled_messages)85 UINT _nx_icmp_info_get(NX_IP *ip_ptr, ULONG *pings_sent, ULONG *ping_timeouts,
86 ULONG *ping_threads_suspended, ULONG *ping_responses_received,
87 ULONG *icmp_checksum_errors, ULONG *icmp_unhandled_messages)
88 {
89
90 /* Obtain protection on this IP instance. */
91 tx_mutex_get(&(ip_ptr -> nx_ip_protection), TX_WAIT_FOREVER);
92
93 /* Determine if pings sent is wanted. */
94 if (pings_sent)
95 {
96
97 /* Return the number of pings sent by this IP instance. */
98 *pings_sent = ip_ptr -> nx_ip_pings_sent;
99 }
100
101 /* Determine if ping timeouts is wanted. */
102 if (ping_timeouts)
103 {
104
105 /* Return the number of ping timeouts by this IP instance. */
106 *ping_timeouts = ip_ptr -> nx_ip_ping_timeouts;
107 }
108
109 /* Determine if ping threads suspended is wanted. */
110 if (ping_threads_suspended)
111 {
112
113 /* Return the number of ping threads suspended by this IP instance. */
114 *ping_threads_suspended = ip_ptr -> nx_ip_ping_threads_suspended;
115 }
116
117 /* Determine if ping responses received is wanted. */
118 if (ping_responses_received)
119 {
120
121 /* Return the number of ping responses received by this IP instance. */
122 *ping_responses_received = ip_ptr -> nx_ip_ping_responses_received;
123 }
124
125 /* Determine if ICMP checksum errors is wanted. */
126 if (icmp_checksum_errors)
127 {
128
129 /* Return the number of ICMP checksum errors detected by this IP instance. */
130 *icmp_checksum_errors = ip_ptr -> nx_ip_icmp_checksum_errors;
131 }
132
133 /* Determine if ICMP unhandled messages is wanted. */
134 if (icmp_unhandled_messages)
135 {
136
137 /* Return the number of ICMP unhandled messages by this IP instance. */
138 *icmp_unhandled_messages = ip_ptr -> nx_ip_icmp_unhandled_messages;
139 }
140
141 /* Release protection. */
142 tx_mutex_put(&(ip_ptr -> nx_ip_protection));
143
144 /* Return a successful status. */
145 return(NX_SUCCESS);
146 }
147
148