blob: 75a9d4c4e3fd179361cff6278c4e747f20bf4fe8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
/***************************************************************************
* Copyright (c) 2024 Microsoft Corporation
* Copyright (c) 2025-present Eclipse ThreadX Contributors
*
* This program and the accompanying materials are made available under the
* terms of the MIT License which is available at
* https://opensource.org/licenses/MIT.
*
* SPDX-License-Identifier: MIT
**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/** */
/** NetX Component */
/** */
/** Neighbor Discovery Cache */
/** */
/**************************************************************************/
/**************************************************************************/
#define NX_SOURCE_CODE
/* Include necessary system files. */
#include "nx_api.h"
#include "nx_ipv6.h"
#include "nx_nd_cache.h"
#ifdef FEATURE_NX_IPV6
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* nx_nd_cache_find_entry PORTABLE C */
/* 6.4.3 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This internal function finds an entry in the ND cache that is */
/* mapped to the specified IPv6 address. */
/* */
/* INPUT */
/* */
/* ip_ptr IP instance pointer */
/* dest_ip The IP address to match */
/* nd_cache_entry User specified storage space of pointer to */
/* the corresponding ND cache. */
/* */
/* OUTPUT */
/* */
/* status NX_SUCCESS: The ND cache entry is located. */
/* nd_cache_entry contains valid value. */
/* NX_NOT_SUCCESSFUL: The ND cache entry */
/* cannot be found, or nd_cache_entry is */
/* NULL. */
/* */
/* CALLS */
/* */
/* None */
/* */
/* CALLED BY */
/* */
/* Application Code */
/* */
/**************************************************************************/
UINT _nx_nd_cache_find_entry(NX_IP *ip_ptr,
ULONG *dest_ip, ND_CACHE_ENTRY **nd_cache_entry)
{
UINT i;
UINT index;
/* Initialize the return value. */
*nd_cache_entry = NX_NULL;
/* Compute a simple hash based on the dest_ip */
index = (UINT)((dest_ip[0] + dest_ip[1] + dest_ip[2] + dest_ip[3]) %
(NX_IPV6_NEIGHBOR_CACHE_SIZE));
for (i = 0; i < NX_IPV6_NEIGHBOR_CACHE_SIZE; i++)
{
if ((ip_ptr -> nx_ipv6_nd_cache[index].nx_nd_cache_nd_status != ND_CACHE_STATE_INVALID) &&
(ip_ptr -> nx_ipv6_nd_cache[index].nx_nd_cache_interface_ptr) &&
(CHECK_IPV6_ADDRESSES_SAME(&ip_ptr -> nx_ipv6_nd_cache[index].nx_nd_cache_dest_ip[0], dest_ip)))
{
/* find the entry */
*nd_cache_entry = &ip_ptr -> nx_ipv6_nd_cache[index];
return(NX_SUCCESS);
}
index++;
/* Check for overflow */
if (index == NX_IPV6_NEIGHBOR_CACHE_SIZE)
{
index = 0;
}
}
return(NX_NOT_SUCCESSFUL);
}
#endif /* FEATURE_NX_IPV6 */
|