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 /* FUNCTION RELEASE */
43 /* */
44 /* _nxde_nd_cache_ip_address_find PORTABLE C */
45 /* 6.1 */
46 /* AUTHOR */
47 /* */
48 /* Yuxin Zhou, Microsoft Corporation */
49 /* */
50 /* DESCRIPTION */
51 /* */
52 /* This function performs error checking in finding ND cache entry. */
53 /* */
54 /* INPUT */
55 /* */
56 /* ip_ptr Pointer to IP instance */
57 /* ip_address Pointer to the IP address */
58 /* to search for */
59 /* physical_msw Physical address, most */
60 /* significant word */
61 /* physical_lsw Physical address, least */
62 /* significant word */
63 /* interface_index Index to the network */
64 /* interface through which the */
65 /* node is reachable. */
66 /* */
67 /* OUTPUT */
68 /* */
69 /* status Completion status */
70 /* */
71 /* CALLS */
72 /* */
73 /* _nxd_ipv6_nd_cache_ip_address_find Find entry by mac address. */
74 /* */
75 /* CALLED BY */
76 /* */
77 /* Application Code */
78 /* */
79 /* RELEASE HISTORY */
80 /* */
81 /* DATE NAME DESCRIPTION */
82 /* */
83 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
84 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
85 /* resulting in version 6.1 */
86 /* */
87 /**************************************************************************/
_nxde_nd_cache_ip_address_find(NX_IP * ip_ptr,NXD_ADDRESS * ip_address,ULONG physical_msw,ULONG physical_lsw,UINT * interface_index)88 UINT _nxde_nd_cache_ip_address_find(NX_IP *ip_ptr,
89 NXD_ADDRESS *ip_address,
90 ULONG physical_msw,
91 ULONG physical_lsw,
92 UINT *interface_index)
93 {
94 #ifdef FEATURE_NX_IPV6
95
96 /* Check for invalid input pointers. */
97 if ((ip_ptr == NX_NULL) || (ip_ptr -> nx_ip_id != NX_IP_ID))
98 {
99 return(NX_PTR_ERROR);
100 }
101
102 /* Check for valid address pointer. */
103 if (ip_address == NX_NULL)
104 {
105 return(NX_PTR_ERROR);
106 }
107
108 if (interface_index == NX_NULL)
109 {
110 return(NX_PTR_ERROR);
111 }
112
113 /* Check for valid MAC hardware address input. */
114 if ((physical_msw == 0) && (physical_lsw == 0))
115 {
116 return(NX_INVALID_PARAMETERS);
117 }
118
119 /* Check for appropriate caller. */
120 NX_THREADS_ONLY_CALLER_CHECKING
121
122 /* Call the actual service and return completion status. */
123 return(_nxd_nd_cache_ip_address_find(ip_ptr, ip_address, physical_msw, physical_lsw, interface_index));
124
125 #else /* !FEATURE_NX_IPV6 */
126 NX_PARAMETER_NOT_USED(ip_ptr);
127 NX_PARAMETER_NOT_USED(ip_address);
128 NX_PARAMETER_NOT_USED(physical_msw);
129 NX_PARAMETER_NOT_USED(physical_lsw);
130 NX_PARAMETER_NOT_USED(interface_index);
131
132 return(NX_NOT_SUPPORTED);
133
134 #endif /* FEATURE_NX_IPV6 */
135 }
136
137