1 /***************************************************************************
2 * Copyright (c) 2024 Microsoft Corporation
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the MIT License which is available at
6 * https://opensource.org/licenses/MIT.
7 *
8 * SPDX-License-Identifier: MIT
9 **************************************************************************/
10
11
12 /**************************************************************************/
13 /**************************************************************************/
14 /** */
15 /** NetX Component */
16 /** */
17 /** Neighbor Discovery Cache */
18 /** */
19 /**************************************************************************/
20 /**************************************************************************/
21
22 #define NX_SOURCE_CODE
23
24
25 /* Include necessary system files. */
26
27 #include "nx_api.h"
28 #include "nx_nd_cache.h"
29 #ifdef FEATURE_NX_IPV6
30 #include "nx_ip.h"
31 #include "nx_ipv6.h"
32
33 /* Bring in externs for caller checking code. */
34 NX_CALLER_CHECKING_EXTERNS
35
36
37 #endif /* FEATURE_NX_IPV6 */
38
39
40 /**************************************************************************/
41 /* */
42 /* FUNCTION RELEASE */
43 /* */
44 /* _nxde_ipv6_nd_cache_entry_set PORTABLE C */
45 /* 6.1 */
46 /* AUTHOR */
47 /* */
48 /* Yuxin Zhou, Microsoft Corporation */
49 /* */
50 /* DESCRIPTION */
51 /* */
52 /* This function performs error checking for the service that adds an */
53 /* IPv6-MAC mapped entry to the neighbor discovery cache. */
54 /* */
55 /* INPUT */
56 /* */
57 /* ip_ptr Pointer to the IP instance */
58 /* dest_ip Pointer to the IP address */
59 /* to add (map) */
60 /* interface_index Index to the network */
61 /* interface */
62 /* mac Pointer to the MAC address to */
63 /* be added (map) */
64 /* */
65 /* OUTPUT */
66 /* */
67 /* status Completion status */
68 /* */
69 /* CALLS */
70 /* */
71 /* _nxd_nd_cache_entry_set Actual function to add an */
72 /* entry to the cache. */
73 /* */
74 /* CALLED BY */
75 /* */
76 /* Application Code */
77 /* */
78 /* RELEASE HISTORY */
79 /* */
80 /* DATE NAME DESCRIPTION */
81 /* */
82 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
83 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
84 /* resulting in version 6.1 */
85 /* */
86 /**************************************************************************/
_nxde_nd_cache_entry_set(NX_IP * ip_ptr,ULONG * dest_ip,UINT interface_index,CHAR * mac)87 UINT _nxde_nd_cache_entry_set(NX_IP *ip_ptr, ULONG *dest_ip, UINT interface_index, CHAR *mac)
88 {
89 #ifdef FEATURE_NX_IPV6
90
91 /* Check for validate user input. */
92 if ((ip_ptr == NX_NULL) || (ip_ptr -> nx_ip_id != NX_IP_ID) || (dest_ip == NX_NULL) || (mac == NX_NULL))
93 {
94 return(NX_PTR_ERROR);
95 }
96
97 /* Validate the interface. */
98 if (interface_index >= NX_MAX_PHYSICAL_INTERFACES)
99 {
100 return(NX_INVALID_INTERFACE);
101 }
102
103 /* Check for appropriate caller. */
104 NX_INIT_AND_THREADS_CALLER_CHECKING
105
106 /* Call the actual service and return completion status. */
107 return(_nxd_nd_cache_entry_set(ip_ptr, dest_ip, interface_index, mac));
108
109 #else /* !FEATURE_NX_IPV6 */
110 NX_PARAMETER_NOT_USED(ip_ptr);
111 NX_PARAMETER_NOT_USED(dest_ip);
112 NX_PARAMETER_NOT_USED(interface_index);
113 NX_PARAMETER_NOT_USED(mac);
114
115 return(NX_NOT_SUPPORTED);
116
117 #endif /* FEATURE_NX_IPV6 */
118 }
119
120