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_ipv6_nd_cache_entry_set PORTABLE C */
46 /* 6.1 */
47 /* AUTHOR */
48 /* */
49 /* Yuxin Zhou, Microsoft Corporation */
50 /* */
51 /* DESCRIPTION */
52 /* */
53 /* This function performs error checking for the service that adds an */
54 /* IPv6-MAC mapped entry to the neighbor discovery cache. */
55 /* */
56 /* INPUT */
57 /* */
58 /* ip_ptr Pointer to the IP instance */
59 /* dest_ip Pointer to the IP address */
60 /* to add (map) */
61 /* interface_index Index to the network */
62 /* interface */
63 /* mac Pointer to the MAC address to */
64 /* be added (map) */
65 /* */
66 /* OUTPUT */
67 /* */
68 /* status Completion status */
69 /* */
70 /* CALLS */
71 /* */
72 /* _nxd_nd_cache_entry_set Actual function to add an */
73 /* entry to the cache. */
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_entry_set(NX_IP * ip_ptr,ULONG * dest_ip,UINT interface_index,CHAR * mac)88 UINT _nxde_nd_cache_entry_set(NX_IP *ip_ptr, ULONG *dest_ip, UINT interface_index, CHAR *mac)
89 {
90 #ifdef FEATURE_NX_IPV6
91
92 /* Check for validate user input. */
93 if ((ip_ptr == NX_NULL) || (ip_ptr -> nx_ip_id != NX_IP_ID) || (dest_ip == NX_NULL) || (mac == NX_NULL))
94 {
95 return(NX_PTR_ERROR);
96 }
97
98 /* Validate the interface. */
99 if (interface_index >= NX_MAX_PHYSICAL_INTERFACES)
100 {
101 return(NX_INVALID_INTERFACE);
102 }
103
104 /* Check for appropriate caller. */
105 NX_INIT_AND_THREADS_CALLER_CHECKING
106
107 /* Call the actual service and return completion status. */
108 return(_nxd_nd_cache_entry_set(ip_ptr, dest_ip, interface_index, mac));
109
110 #else /* !FEATURE_NX_IPV6 */
111 NX_PARAMETER_NOT_USED(ip_ptr);
112 NX_PARAMETER_NOT_USED(dest_ip);
113 NX_PARAMETER_NOT_USED(interface_index);
114 NX_PARAMETER_NOT_USED(mac);
115
116 return(NX_NOT_SUPPORTED);
117
118 #endif /* FEATURE_NX_IPV6 */
119 }
120
121