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 /** Address Resolution Protocol (ARP) */
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_arp.h"
29
30
31 /**************************************************************************/
32 /* */
33 /* FUNCTION RELEASE */
34 /* */
35 /* _nx_arp_info_get PORTABLE C */
36 /* 6.1 */
37 /* AUTHOR */
38 /* */
39 /* Yuxin Zhou, Microsoft Corporation */
40 /* */
41 /* DESCRIPTION */
42 /* */
43 /* This function obtains ARP information for the specified IP */
44 /* instance. */
45 /* */
46 /* INPUT */
47 /* */
48 /* ip_ptr IP instance pointer */
49 /* arp_requests_sent Destination for number of ARP */
50 /* requests sent */
51 /* arp_requests_received Destination for number of ARP */
52 /* requests received */
53 /* arp_responses_sent Destination for number of ARP */
54 /* responses sent */
55 /* arp_responses_received Destination for number of ARP */
56 /* responses received */
57 /* arp_dynamic_entries Destination for number of ARP */
58 /* dynamic entries */
59 /* arp_static_entries Destination for number of ARP */
60 /* static entries */
61 /* arp_aged_entries Destination for number of ARP */
62 /* aged entries */
63 /* arp_invalid_messages Destination for number of ARP */
64 /* invalid messages */
65 /* */
66 /* OUTPUT */
67 /* */
68 /* status Completion status */
69 /* */
70 /* CALLS */
71 /* */
72 /* tx_mutex_get Obtain protection mutex */
73 /* tx_mutex_put Release protection mutex */
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_arp_info_get(NX_IP * ip_ptr,ULONG * arp_requests_sent,ULONG * arp_requests_received,ULONG * arp_responses_sent,ULONG * arp_responses_received,ULONG * arp_dynamic_entries,ULONG * arp_static_entries,ULONG * arp_aged_entries,ULONG * arp_invalid_messages)88 UINT _nx_arp_info_get(NX_IP *ip_ptr, ULONG *arp_requests_sent, ULONG *arp_requests_received,
89 ULONG *arp_responses_sent, ULONG *arp_responses_received,
90 ULONG *arp_dynamic_entries, ULONG *arp_static_entries,
91 ULONG *arp_aged_entries, ULONG *arp_invalid_messages)
92 {
93
94 #ifndef NX_DISABLE_IPV4
95 /* If trace is enabled, insert this event into the trace buffer. */
96 NX_TRACE_IN_LINE_INSERT(NX_TRACE_ARP_INFO_GET, ip_ptr, ip_ptr -> nx_ip_arp_requests_sent, ip_ptr -> nx_ip_arp_responses_received, ip_ptr -> nx_ip_arp_requests_received, NX_TRACE_ARP_EVENTS, 0, 0);
97
98 /* Obtain protection on this IP instance. */
99 tx_mutex_get(&(ip_ptr -> nx_ip_protection), TX_WAIT_FOREVER);
100
101 /* Determine if ARP requests sent is wanted. */
102 if (arp_requests_sent)
103 {
104
105 /* Return the number of ARP requests sent by this IP instance. */
106 *arp_requests_sent = ip_ptr -> nx_ip_arp_requests_sent;
107 }
108
109 /* Determine if ARP requests received is wanted. */
110 if (arp_requests_received)
111 {
112
113 /* Return the number of ARP requests received by this IP instance. */
114 *arp_requests_received = ip_ptr -> nx_ip_arp_requests_received;
115 }
116
117 /* Determine if ARP responses sent is wanted. */
118 if (arp_responses_sent)
119 {
120
121 /* Return the number of ARP responses sent by this IP instance. */
122 *arp_responses_sent = ip_ptr -> nx_ip_arp_responses_sent;
123 }
124
125 /* Determine if ARP responses received is wanted. */
126 if (arp_responses_received)
127 {
128
129 /* Return the number of ARP responses received by this IP instance. */
130 *arp_responses_received = ip_ptr -> nx_ip_arp_responses_received;
131 }
132
133 /* Determine if ARP dynamic entries is wanted. */
134 if (arp_dynamic_entries)
135 {
136
137 /* Return the number of ARP dynamic entries in this IP instance. */
138 *arp_dynamic_entries = ip_ptr -> nx_ip_arp_dynamic_active_count;
139 }
140
141 /* Determine if ARP static entries is wanted. */
142 if (arp_static_entries)
143 {
144
145 /* Return the number of ARP static entries in this IP instance. */
146 *arp_static_entries = ip_ptr -> nx_ip_arp_static_entries;
147 }
148
149 /* Determine if ARP aged entries is wanted. */
150 if (arp_aged_entries)
151 {
152
153 /* Return the number of ARP aged entries by this IP instance. */
154 *arp_aged_entries = ip_ptr -> nx_ip_arp_aged_entries;
155 }
156
157 /* Determine if ARP invalid messages is wanted. */
158 if (arp_invalid_messages)
159 {
160
161 /* Return the number of ARP invalid messages handled by this IP instance. */
162 *arp_invalid_messages = ip_ptr -> nx_ip_arp_invalid_messages;
163 }
164
165 /* Release the protection. */
166 tx_mutex_put(&(ip_ptr -> nx_ip_protection));
167
168 /* Return status to the caller. */
169 return(NX_SUCCESS);
170 #else /* NX_DISABLE_IPV4 */
171 NX_PARAMETER_NOT_USED(ip_ptr);
172 NX_PARAMETER_NOT_USED(arp_requests_sent);
173 NX_PARAMETER_NOT_USED(arp_requests_received);
174 NX_PARAMETER_NOT_USED(arp_responses_sent);
175 NX_PARAMETER_NOT_USED(arp_responses_received);
176 NX_PARAMETER_NOT_USED(arp_dynamic_entries);
177 NX_PARAMETER_NOT_USED(arp_static_entries);
178 NX_PARAMETER_NOT_USED(arp_aged_entries);
179 NX_PARAMETER_NOT_USED(arp_invalid_messages);
180
181 return(NX_NOT_SUPPORTED);
182 #endif /* !NX_DISABLE_IPV4 */
183 }
184
185