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