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 /**   Neighbor Discovery Cache                                            */
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_nd_cache.h"
30 #ifdef FEATURE_NX_IPV6
31 #include "nx_ip.h"
32 #include "nx_ipv6.h"
33 
34 /* Bring in externs for caller checking code.  */
35 NX_CALLER_CHECKING_EXTERNS
36 
37 
38 #endif /* FEATURE_NX_IPV6 */
39 
40 
41 /**************************************************************************/
42 /*                                                                        */
43 /*  FUNCTION                                               RELEASE        */
44 /*                                                                        */
45 /*    _nxde_nd_cache_hardware_address_find                PORTABLE C      */
46 /*                                                           6.1          */
47 /*  AUTHOR                                                                */
48 /*                                                                        */
49 /*    Yuxin Zhou, Microsoft Corporation                                   */
50 /*                                                                        */
51 /*  DESCRIPTION                                                           */
52 /*                                                                        */
53 /*    This function performs error checking on the service for finding a  */
54 /*    neighbor discovery (ND) cache entry service.                        */
55 /*                                                                        */
56 /*  INPUT                                                                 */
57 /*                                                                        */
58 /*    ip_ptr                                IP instance pointer           */
59 /*    ip_address                            Pointer to the IP address to  */
60 /*                                            search for                  */
61 /*    physical_msw                          Physical address, most        */
62 /*                                            signifcant word             */
63 /*    physical_lsw                          Physical address, least       */
64 /*                                            signifcant word             */
65 /*    interface_index                       Pointer to interface through  */
66 /*                                            which the neighbor can be   */
67 /*                                            reached.                    */
68 /*                                                                        */
69 /*  OUTPUT                                                                */
70 /*                                                                        */
71 /*    status                                Completion status             */
72 /*                                                                        */
73 /*  CALLS                                                                 */
74 /*                                                                        */
75 /*    _nxd_nd_cache_hardware_address_find  Find entry by IP address       */
76 /*                                                                        */
77 /*  CALLED BY                                                             */
78 /*                                                                        */
79 /*    Application Code                                                    */
80 /*                                                                        */
81 /*  RELEASE HISTORY                                                       */
82 /*                                                                        */
83 /*    DATE              NAME                      DESCRIPTION             */
84 /*                                                                        */
85 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
86 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
87 /*                                            resulting in version 6.1    */
88 /*                                                                        */
89 /**************************************************************************/
_nxde_nd_cache_hardware_address_find(NX_IP * ip_ptr,NXD_ADDRESS * ip_address,ULONG * physical_msw,ULONG * physical_lsw,UINT * interface_index)90 UINT  _nxde_nd_cache_hardware_address_find(NX_IP *ip_ptr,
91                                            NXD_ADDRESS *ip_address,
92                                            ULONG *physical_msw,
93                                            ULONG *physical_lsw,
94                                            UINT *interface_index)
95 {
96 #ifdef FEATURE_NX_IPV6
97 
98     /* Check for invalid input pointers.  */
99     if ((ip_ptr == NX_NULL) || (ip_ptr -> nx_ip_id != NX_IP_ID))
100     {
101         return(NX_PTR_ERROR);
102     }
103 
104     /* Check for invalid IP and MAC address input*/
105     if ((ip_address == NX_NULL) || (physical_msw == NX_NULL) || (physical_lsw == NX_NULL))
106     {
107         return(NX_PTR_ERROR);
108     }
109 
110     /* Check the address is an IPv6 address. */
111     if (ip_address -> nxd_ip_version != NX_IP_VERSION_V6)
112     {
113         return(NX_INVALID_PARAMETERS);
114     }
115 
116     if (interface_index == NX_NULL)
117     {
118         return(NX_PTR_ERROR);
119     }
120 
121     /* Check for appropriate caller.  */
122     NX_THREADS_ONLY_CALLER_CHECKING
123 
124     /* Call the actual service and return completion status. */
125     return(_nxd_nd_cache_hardware_address_find(ip_ptr, ip_address, physical_msw, physical_lsw, interface_index));
126 
127 #else /* !FEATURE_NX_IPV6 */
128     NX_PARAMETER_NOT_USED(ip_ptr);
129     NX_PARAMETER_NOT_USED(ip_address);
130     NX_PARAMETER_NOT_USED(physical_msw);
131     NX_PARAMETER_NOT_USED(physical_lsw);
132     NX_PARAMETER_NOT_USED(interface_index);
133 
134     return(NX_NOT_SUPPORTED);
135 
136 #endif /* FEATURE_NX_IPV6 */
137 }
138 
139