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_ip.h"
30 #include "nx_arp.h"
31 
32 
33 /* Bring in externs for caller checking code.  */
34 
35 NX_CALLER_CHECKING_EXTERNS
36 
37 
38 /**************************************************************************/
39 /*                                                                        */
40 /*  FUNCTION                                               RELEASE        */
41 /*                                                                        */
42 /*    _nxe_arp_info_get                                   PORTABLE C      */
43 /*                                                           6.1          */
44 /*  AUTHOR                                                                */
45 /*                                                                        */
46 /*    Yuxin Zhou, Microsoft Corporation                                   */
47 /*                                                                        */
48 /*  DESCRIPTION                                                           */
49 /*                                                                        */
50 /*    This function checks for errors in the ARP information get          */
51 /*    function call.                                                      */
52 /*                                                                        */
53 /*  INPUT                                                                 */
54 /*                                                                        */
55 /*    ip_ptr                                IP instance pointer           */
56 /*    arp_requests_sent                     Destination for number of ARP */
57 /*                                            requests sent               */
58 /*    arp_requests_received                 Destination for number of ARP */
59 /*                                            requests received           */
60 /*    arp_responses_sent                    Destination for number of ARP */
61 /*                                            responses sent              */
62 /*    arp_responses_received                Destination for number of ARP */
63 /*                                            responses received          */
64 /*    arp_dynamic_entries                   Destination for number of ARP */
65 /*                                            dynamic entries             */
66 /*    arp_static_entries                    Destination for number of ARP */
67 /*                                            static entries              */
68 /*    arp_aged_entries                      Destination for number of ARP */
69 /*                                            aged entries                */
70 /*    arp_invalid_messages                  Destination for number of ARP */
71 /*                                            invalid messages            */
72 /*                                                                        */
73 /*  OUTPUT                                                                */
74 /*                                                                        */
75 /*    status                                Completion status             */
76 /*                                                                        */
77 /*  CALLS                                                                 */
78 /*                                                                        */
79 /*    _nx_arp_info_get                      Actual ARP information get    */
80 /*                                            function                    */
81 /*                                                                        */
82 /*  CALLED BY                                                             */
83 /*                                                                        */
84 /*    Application Code                                                    */
85 /*                                                                        */
86 /*  RELEASE HISTORY                                                       */
87 /*                                                                        */
88 /*    DATE              NAME                      DESCRIPTION             */
89 /*                                                                        */
90 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
91 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
92 /*                                            resulting in version 6.1    */
93 /*                                                                        */
94 /**************************************************************************/
_nxe_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)95 UINT  _nxe_arp_info_get(NX_IP *ip_ptr, ULONG *arp_requests_sent, ULONG *arp_requests_received,
96                         ULONG *arp_responses_sent, ULONG *arp_responses_received,
97                         ULONG *arp_dynamic_entries, ULONG *arp_static_entries,
98                         ULONG *arp_aged_entries, ULONG *arp_invalid_messages)
99 {
100 
101 #ifndef NX_DISABLE_IPV4
102 UINT status;
103 
104 
105     /* Check for invalid input pointers.  */
106     if ((ip_ptr == NX_NULL) || (ip_ptr -> nx_ip_id != NX_IP_ID))
107     {
108         return(NX_PTR_ERROR);
109     }
110 
111     /* Check to see if ARP is enabled.  */
112     if (!ip_ptr -> nx_ip_arp_allocate)
113     {
114         return(NX_NOT_ENABLED);
115     }
116 
117     /* Check for appropriate caller.  */
118     NX_THREADS_ONLY_CALLER_CHECKING
119 
120     /* Call actual ARP information get function.  */
121     status =  _nx_arp_info_get(ip_ptr, arp_requests_sent, arp_requests_received,
122                                arp_responses_sent, arp_responses_received,
123                                arp_dynamic_entries, arp_static_entries,
124                                arp_aged_entries, arp_invalid_messages);
125 
126     /* Return completion status.  */
127     return(status);
128 #else /* NX_DISABLE_IPV4  */
129     NX_PARAMETER_NOT_USED(ip_ptr);
130     NX_PARAMETER_NOT_USED(arp_requests_sent);
131     NX_PARAMETER_NOT_USED(arp_requests_received);
132     NX_PARAMETER_NOT_USED(arp_responses_sent);
133     NX_PARAMETER_NOT_USED(arp_responses_received);
134     NX_PARAMETER_NOT_USED(arp_dynamic_entries);
135     NX_PARAMETER_NOT_USED(arp_static_entries);
136     NX_PARAMETER_NOT_USED(arp_aged_entries);
137     NX_PARAMETER_NOT_USED(arp_invalid_messages);
138 
139     return(NX_NOT_SUPPORTED);
140 #endif /* !NX_DISABLE_IPV4  */
141 }
142 
143