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 Management (ND CAHCE) */ 18 /** */ 19 /**************************************************************************/ 20 /**************************************************************************/ 21 22 23 /**************************************************************************/ 24 /* */ 25 /* APPLICATION INTERFACE DEFINITION RELEASE */ 26 /* */ 27 /* nx_nd_cache.h PORTABLE C */ 28 /* 6.1 */ 29 /* AUTHOR */ 30 /* */ 31 /* Yuxin Zhou, Microsoft Corporation */ 32 /* */ 33 /* DESCRIPTION */ 34 /* */ 35 /* This file defines the basic Application Interface (API) to the */ 36 /* high-performance NetX IPv6 Neighbor Discovery Cache implementation */ 37 /* for the ThreadX real-time kernel. All service prototypes and data */ 38 /* structure definitions are defined in this file. Please note that */ 39 /* basic data type definitions and other architecture-specific */ 40 /* information is contained in the file nx_port.h. */ 41 /* */ 42 /* It is assumed that nx_api.h and nx_port.h have already been */ 43 /* included. */ 44 /* */ 45 /* This header file is for NetX Duo internal use only. Application */ 46 /* shall not include this file directly. */ 47 /* */ 48 /* RELEASE HISTORY */ 49 /* */ 50 /* DATE NAME DESCRIPTION */ 51 /* */ 52 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ 53 /* 09-30-2020 Yuxin Zhou Modified comment(s), */ 54 /* resulting in version 6.1 */ 55 /* */ 56 /**************************************************************************/ 57 58 #ifndef NX_ND_CACHE_H 59 #define NX_ND_CACHE_H 60 61 62 #include "nx_ip.h" 63 #include "nx_ipv6.h" 64 65 #ifdef FEATURE_NX_IPV6 66 67 68 /* Symbols used the states of ND entries. */ 69 #define ND_CACHE_STATE_INVALID 0 70 #define ND_CACHE_STATE_INCOMPLETE 1 71 #define ND_CACHE_STATE_REACHABLE 2 72 #define ND_CACHE_STATE_STALE 3 73 #define ND_CACHE_STATE_DELAY 4 74 #define ND_CACHE_STATE_PROBE 5 75 #define ND_CACHE_STATE_CREATED 6 76 77 /* 78 * Define values used for Neighbor Discovery protocol. 79 * The default values are suggested by RFC2461, chapter 10. 80 */ 81 82 83 #ifndef NX_MAX_MULTICAST_SOLICIT 84 /* Max multicast NS messages */ 85 #define NX_MAX_MULTICAST_SOLICIT 3 86 #endif 87 88 #ifndef NX_MAX_UNICAST_SOLICIT 89 /* Max unicast NS messages. */ 90 #define NX_MAX_UNICAST_SOLICIT 3 91 #endif 92 93 #ifndef NX_REACHABLE_TIME 94 /* Max reachable time, in seconds. */ 95 #define NX_REACHABLE_TIME 30 96 #endif 97 98 #ifndef NX_RETRANS_TIMER 99 /* Max retrans timer, in milliseconds. */ 100 #define NX_RETRANS_TIMER 1000 101 #endif 102 103 #ifndef NX_DELAY_FIRST_PROBE_TIME 104 #define NX_DELAY_FIRST_PROBE_TIME 5 105 #endif 106 107 /* Declare internal functions */ 108 UINT _nx_nd_cache_interface_entries_delete(NX_IP *ip_ptr, UINT index); 109 110 /* Add en entry to the cache. */ 111 UINT _nx_nd_cache_add(NX_IP *ip_ptr, ULONG *dest_ip, NX_INTERFACE *if_index, CHAR *mac, INT IsStatic, INT status, NXD_IPV6_ADDRESS *nxd_interface, ND_CACHE_ENTRY **entry); 112 113 114 /* Delete an entry based on IP address. */ 115 UINT _nx_nd_cache_delete_internal(NX_IP *ip_ptr, ND_CACHE_ENTRY *entry); 116 117 /* 100ms periodic update. */ 118 VOID _nx_nd_cache_fast_periodic_update(NX_IP *ip_ptr); 119 120 /* Find cache entry based on neighbor IP address. */ 121 UINT _nx_nd_cache_find_entry(NX_IP *ip_ptr, ULONG *dest_ip, ND_CACHE_ENTRY **entry); 122 123 /* Find cache entry based on neighbor IP address. If not found, create new entry. */ 124 UINT _nx_nd_cache_add_entry(NX_IP *ip_ptr, ULONG *dest_ip, NXD_IPV6_ADDRESS *nxd_address, ND_CACHE_ENTRY **entry); 125 126 /* Find cache entry based on LLA. */ 127 UINT _nx_nd_cache_find_entry_by_mac_addr(NX_IP *ip_ptr, ULONG physical_msw, ULONG physical_lsw, ND_CACHE_ENTRY **entry); 128 129 /* The real function that invalidates the whole cache. */ 130 VOID _nxd_nd_cache_invalidate_internal(NX_IP *ip_ptr); 131 132 /* One second periodic update. */ 133 VOID _nx_nd_cache_slow_periodic_update(NX_IP *ip_ptr); 134 135 /* Invalidate a given entry from the neighbor discovery table. */ 136 VOID _nx_invalidate_destination_entry(NX_IP *ip_ptr, ULONG *next_hop_ip); 137 #endif /* FEATURE_NX_IPV6 */ 138 139 140 /* Delete an entry based on IP address. */ 141 UINT _nxd_nd_cache_entry_delete(NX_IP *ip_ptr, ULONG *dest_ip); 142 UINT _nxde_nd_cache_entry_delete(NX_IP *ip_ptr, ULONG *dest_ip); 143 144 /* Create an IPv6-MAC mapping to the ND cache entry. */ 145 UINT _nxd_nd_cache_entry_set(NX_IP *ip_ptr, ULONG *dest_ip, UINT if_index, CHAR *mac); 146 UINT _nxde_nd_cache_entry_set(NX_IP *ip_ptr, ULONG *dest_ip, UINT if_index, CHAR *mac); 147 148 /* Invalidate the whole cache. */ 149 UINT _nxd_nd_cache_invalidate(NX_IP *ip_ptr); 150 UINT _nxde_nd_cache_invalidate(NX_IP *ip_ptr); 151 152 UINT _nxd_nd_cache_ip_address_find(NX_IP *ip_ptr, NXD_ADDRESS *ip_address, ULONG physical_msw, ULONG physical_lsw, UINT *if_index); 153 UINT _nxde_nd_cache_ip_address_find(NX_IP *ip_ptr, NXD_ADDRESS *ip_address, ULONG physical_msw, ULONG physical_lsw, UINT *if_index); 154 155 UINT _nxd_nd_cache_hardware_address_find(NX_IP *ip_ptr, NXD_ADDRESS *ip_address, ULONG *physical_msw, ULONG *physical_lsw, UINT *if_index); 156 UINT _nxde_nd_cache_hardware_address_find(NX_IP *ip_ptr, NXD_ADDRESS *ip_address, ULONG *physical_msw, ULONG *physical_lsw, UINT *if_index); 157 158 #endif /* NX_ND_CACHE_H */ 159 160