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_ip.h"
30 #include "nx_rarp.h"
31 
32 /* Bring in externs for caller checking code.  */
33 NX_CALLER_CHECKING_EXTERNS
34 
35 
36 /**************************************************************************/
37 /*                                                                        */
38 /*  FUNCTION                                               RELEASE        */
39 /*                                                                        */
40 /*    _nxe_rarp_info_get                                  PORTABLE C      */
41 /*                                                           6.1          */
42 /*  AUTHOR                                                                */
43 /*                                                                        */
44 /*    Yuxin Zhou, Microsoft Corporation                                   */
45 /*                                                                        */
46 /*  DESCRIPTION                                                           */
47 /*                                                                        */
48 /*    This function checks for errors in the RARP information get         */
49 /*    function call.                                                      */
50 /*                                                                        */
51 /*  INPUT                                                                 */
52 /*                                                                        */
53 /*    ip_ptr                                IP instance pointer           */
54 /*    rarp_requests_sent                    Destination for the number of */
55 /*                                            RARP requests sent          */
56 /*    rarp_responses_received               Destination for the number of */
57 /*                                            RARP responses received     */
58 /*    rarp_invalid_messages                 Destination for the number of */
59 /*                                            RARP invalid messages (or   */
60 /*                                            unhandled)                  */
61 /*                                                                        */
62 /*  OUTPUT                                                                */
63 /*                                                                        */
64 /*    status                                Completion status             */
65 /*                                                                        */
66 /*  CALLS                                                                 */
67 /*                                                                        */
68 /*    _nx_rarp_info_get                     Actual RARP information get   */
69 /*                                            function                    */
70 /*                                                                        */
71 /*  CALLED BY                                                             */
72 /*                                                                        */
73 /*    Application Code                                                    */
74 /*                                                                        */
75 /*  RELEASE HISTORY                                                       */
76 /*                                                                        */
77 /*    DATE              NAME                      DESCRIPTION             */
78 /*                                                                        */
79 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
80 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
81 /*                                            resulting in version 6.1    */
82 /*                                                                        */
83 /**************************************************************************/
_nxe_rarp_info_get(NX_IP * ip_ptr,ULONG * rarp_requests_sent,ULONG * rarp_responses_received,ULONG * rarp_invalid_messages)84 UINT  _nxe_rarp_info_get(NX_IP *ip_ptr, ULONG *rarp_requests_sent, ULONG *rarp_responses_received,
85                          ULONG *rarp_invalid_messages)
86 {
87 
88 #ifndef NX_DISABLE_IPV4
89 UINT status;
90 
91 
92     /* Check for invalid input pointers.  */
93     if ((ip_ptr == NX_NULL) || (ip_ptr -> nx_ip_id != NX_IP_ID))
94     {
95         return(NX_PTR_ERROR);
96     }
97 
98     /* Check to see if RARP is enabled.  */
99     if ((!ip_ptr -> nx_ip_rarp_queue_process) && (ip_ptr -> nx_ip_rarp_responses_received == 0))
100     {
101         return(NX_NOT_ENABLED);
102     }
103 
104     /* Check for appropriate caller.  */
105     NX_INIT_AND_THREADS_CALLER_CHECKING
106 
107     /* Call actual RARP information get function.  */
108     status =  _nx_rarp_info_get(ip_ptr, rarp_requests_sent, rarp_responses_received, rarp_invalid_messages);
109 
110     /* Return completion status.  */
111     return(status);
112 #else /* NX_DISABLE_IPV4  */
113     NX_PARAMETER_NOT_USED(ip_ptr);
114     NX_PARAMETER_NOT_USED(rarp_requests_sent);
115     NX_PARAMETER_NOT_USED(rarp_responses_received);
116     NX_PARAMETER_NOT_USED(rarp_invalid_messages);
117 
118     return(NX_NOT_SUPPORTED);
119 #endif /* !NX_DISABLE_IPV4  */
120 }
121 
122