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 /** Reverse Address Resolution Protocol (RARP) */
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_rarp.h"
29
30
31 /**************************************************************************/
32 /* */
33 /* FUNCTION RELEASE */
34 /* */
35 /* _nx_rarp_info_get PORTABLE C */
36 /* 6.1 */
37 /* AUTHOR */
38 /* */
39 /* Yuxin Zhou, Microsoft Corporation */
40 /* */
41 /* DESCRIPTION */
42 /* */
43 /* This function obtains RARP information for the specified IP */
44 /* instance. */
45 /* */
46 /* INPUT */
47 /* */
48 /* ip_ptr IP instance pointer */
49 /* rarp_requests_sent Destination for the number of */
50 /* RARP requests sent */
51 /* rarp_responses_received Destination for the number of */
52 /* RARP responses received */
53 /* rarp_invalid_messages Destination for the number of */
54 /* RARP invalid messages (or */
55 /* unhandled) */
56 /* */
57 /* OUTPUT */
58 /* */
59 /* status Completion status */
60 /* */
61 /* CALLS */
62 /* */
63 /* None */
64 /* */
65 /* CALLED BY */
66 /* */
67 /* Application Code */
68 /* */
69 /* RELEASE HISTORY */
70 /* */
71 /* DATE NAME DESCRIPTION */
72 /* */
73 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
74 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
75 /* resulting in version 6.1 */
76 /* */
77 /**************************************************************************/
_nx_rarp_info_get(NX_IP * ip_ptr,ULONG * rarp_requests_sent,ULONG * rarp_responses_received,ULONG * rarp_invalid_messages)78 UINT _nx_rarp_info_get(NX_IP *ip_ptr, ULONG *rarp_requests_sent, ULONG *rarp_responses_received,
79 ULONG *rarp_invalid_messages)
80 {
81
82 #ifndef NX_DISABLE_IPV4
83 TX_INTERRUPT_SAVE_AREA
84
85
86 /* If trace is enabled, insert this event into the trace buffer. */
87 NX_TRACE_IN_LINE_INSERT(NX_TRACE_RARP_INFO_GET, ip_ptr, ip_ptr -> nx_ip_rarp_requests_sent, ip_ptr -> nx_ip_rarp_responses_received, ip_ptr -> nx_ip_rarp_invalid_messages, NX_TRACE_RARP_EVENTS, 0, 0);
88
89 /* Disable interrupts. */
90 TX_DISABLE
91
92 /* Determine if RARP requests sent is wanted. */
93 if (rarp_requests_sent)
94 {
95
96 /* Return the number of RARP requests sent by this IP instance. */
97 *rarp_requests_sent = ip_ptr -> nx_ip_rarp_requests_sent;
98 }
99
100 /* Determine if RARP responses received is wanted. */
101 if (rarp_responses_received)
102 {
103
104 /* Return the number of RARP responses received by this IP instance. */
105 *rarp_responses_received = ip_ptr -> nx_ip_rarp_responses_received;
106 }
107
108 /* Determine if RARP invalid (or unhandled) messages is wanted. */
109 if (rarp_invalid_messages)
110 {
111
112 /* Return the number of RARP invalid messages received by this IP instance. */
113 *rarp_invalid_messages = ip_ptr -> nx_ip_rarp_invalid_messages;
114 }
115
116 /* Restore interrupts. */
117 TX_RESTORE
118
119 /* Return successful completion. */
120 return(NX_SUCCESS);
121 #else /* NX_DISABLE_IPV4 */
122 NX_PARAMETER_NOT_USED(ip_ptr);
123 NX_PARAMETER_NOT_USED(rarp_requests_sent);
124 NX_PARAMETER_NOT_USED(rarp_responses_received);
125 NX_PARAMETER_NOT_USED(rarp_invalid_messages);
126
127 return(NX_NOT_SUPPORTED);
128 #endif /* !NX_DISABLE_IPV4 */
129 }
130
131