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 /* Bring in externs for caller checking code.  */
33 
34 NX_CALLER_CHECKING_EXTERNS
35 
36 
37 /**************************************************************************/
38 /*                                                                        */
39 /*  FUNCTION                                               RELEASE        */
40 /*                                                                        */
41 /*    _nxe_arp_hardware_address_find                      PORTABLE C      */
42 /*                                                           6.1          */
43 /*  AUTHOR                                                                */
44 /*                                                                        */
45 /*    Yuxin Zhou, Microsoft Corporation                                   */
46 /*                                                                        */
47 /*  DESCRIPTION                                                           */
48 /*                                                                        */
49 /*    This function checks for errors in the ARP hardware address find    */
50 /*    function call.                                                      */
51 /*                                                                        */
52 /*  INPUT                                                                 */
53 /*                                                                        */
54 /*    ip_ptr                                IP instance pointer           */
55 /*    ip_address                            IP Address to search for      */
56 /*    physical_msw                          Physical address MSW pointer  */
57 /*    physical_lsw                          Physical address LSW pointer  */
58 /*                                                                        */
59 /*  OUTPUT                                                                */
60 /*                                                                        */
61 /*    status                                Completion status             */
62 /*                                                                        */
63 /*  CALLS                                                                 */
64 /*                                                                        */
65 /*    _nx_arp_hardware_address_find         Actual hardware address find  */
66 /*                                            function                    */
67 /*                                                                        */
68 /*  CALLED BY                                                             */
69 /*                                                                        */
70 /*    Application Code                                                    */
71 /*                                                                        */
72 /*  RELEASE HISTORY                                                       */
73 /*                                                                        */
74 /*    DATE              NAME                      DESCRIPTION             */
75 /*                                                                        */
76 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
77 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
78 /*                                            resulting in version 6.1    */
79 /*                                                                        */
80 /**************************************************************************/
_nxe_arp_hardware_address_find(NX_IP * ip_ptr,ULONG ip_address,ULONG * physical_msw,ULONG * physical_lsw)81 UINT  _nxe_arp_hardware_address_find(NX_IP *ip_ptr, ULONG ip_address,
82                                      ULONG *physical_msw, ULONG *physical_lsw)
83 {
84 
85 #ifndef NX_DISABLE_IPV4
86 UINT status;
87 
88 
89     /* Check for invalid input pointers.  */
90     if ((ip_ptr == NX_NULL) || (ip_ptr -> nx_ip_id != NX_IP_ID) || (physical_msw == NX_NULL) || (physical_lsw == NX_NULL))
91     {
92         return(NX_PTR_ERROR);
93     }
94 
95     /* Check for invalid IP address.  */
96     if (!ip_address)
97     {
98         return(NX_IP_ADDRESS_ERROR);
99     }
100 
101     /* Check to see if ARP is enabled.  */
102     if (!ip_ptr -> nx_ip_arp_allocate)
103     {
104         return(NX_NOT_ENABLED);
105     }
106 
107     /* Check for appropriate caller.  */
108     NX_THREADS_ONLY_CALLER_CHECKING
109 
110     /* Call actual ARP hardware address find function.  */
111     status =  _nx_arp_hardware_address_find(ip_ptr, ip_address, physical_msw, physical_lsw);
112 
113     /* Return completion status.  */
114     return(status);
115 #else /* NX_DISABLE_IPV4  */
116     NX_PARAMETER_NOT_USED(ip_ptr);
117     NX_PARAMETER_NOT_USED(ip_address);
118     NX_PARAMETER_NOT_USED(physical_msw);
119     NX_PARAMETER_NOT_USED(physical_lsw);
120 
121     return(NX_NOT_SUPPORTED);
122 #endif /* !NX_DISABLE_IPV4  */
123 }
124 
125