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