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_ipv6.h"
32 #endif /* FEATURE_NX_IPV6 */
33
34
35 /**************************************************************************/
36 /* */
37 /* FUNCTION RELEASE */
38 /* */
39 /* _nxd_nd_cache_entry_set PORTABLE C */
40 /* 6.1 */
41 /* AUTHOR */
42 /* */
43 /* Yuxin Zhou, Microsoft Corporation */
44 /* */
45 /* DESCRIPTION */
46 /* */
47 /* This function creates an entry with the specified IPv6 address and */
48 /* hardware MAC address mapping and adds it to the Neighbor Discovery */
49 /* (ND) cache. */
50 /* */
51 /* INPUT */
52 /* */
53 /* ip_ptr Pointer to the IP instance */
54 /* dest_ip Pointer to the IP address */
55 /* to add (map) */
56 /* interface_index Index to the network */
57 /* interface */
58 /* mac Pointer to the MAC address to */
59 /* be added (map) */
60 /* */
61 /* OUTPUT */
62 /* */
63 /* status Completion status */
64 /* */
65 /* CALLS */
66 /* */
67 /* _nx_nd_cache_add Actual function to add an */
68 /* entry to the cache. */
69 /* */
70 /* CALLED BY */
71 /* */
72 /* Application Code */
73 /* */
74 /* RELEASE HISTORY */
75 /* */
76 /* DATE NAME DESCRIPTION */
77 /* */
78 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
79 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
80 /* resulting in version 6.1 */
81 /* */
82 /**************************************************************************/
_nxd_nd_cache_entry_set(NX_IP * ip_ptr,ULONG * dest_ip,UINT interface_index,CHAR * mac)83 UINT _nxd_nd_cache_entry_set(NX_IP *ip_ptr, ULONG *dest_ip, UINT interface_index, CHAR *mac)
84 {
85 #ifdef FEATURE_NX_IPV6
86
87 ND_CACHE_ENTRY *nd_cache_entry;
88 UINT status;
89
90
91 /* If trace is enabled, insert this event into the trace buffer. */
92 NX_TRACE_IN_LINE_INSERT(NXD_TRACE_ND_CACHE_ENTRY_SET, dest_ip[3], ((mac[0] << 16) | mac[1]), ((mac[2] << 24) | (mac[3] << 16) | (mac[4] << 8) | mac[5]),
93 0, NX_TRACE_ARP_EVENTS, 0, 0);
94
95 /* Call the actual cache entry add service. */
96 status = _nx_nd_cache_add(ip_ptr, dest_ip, ip_ptr -> nx_ipv6_address[interface_index].nxd_ipv6_address_attached, mac, 1, ND_CACHE_STATE_REACHABLE, &(ip_ptr -> nx_ipv6_address[interface_index]), &nd_cache_entry);
97
98 return(status);
99
100 #else /* !FEATURE_NX_IPV6 */
101 NX_PARAMETER_NOT_USED(ip_ptr);
102 NX_PARAMETER_NOT_USED(dest_ip);
103 NX_PARAMETER_NOT_USED(interface_index);
104 NX_PARAMETER_NOT_USED(mac);
105
106 return(NX_NOT_SUPPORTED);
107
108 #endif /* FEATURE_NX_IPV6 */
109 }
110
111