blob: 98b477f776d1cf5242423531c118b842156b30ef (
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
/***************************************************************************
* 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_slow_periodic_update PORTABLE C */
/* 6.4.3 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function handles the ND entries in REACHABLE, STALE, and */
/* DELAY states. It decrements the timer tick. If the timer ticks */
/* reach zero, the entry is moved to the next state. */
/* */
/* Note that the only cache entries whose timer ticks are being */
/* decremented in this function are states whose timer tick was set in */
/* effectively in seconds (as compared with the fast periodic update */
/* where cache entry'timer ticks' are updated in as timer ticks. This */
/* is intentional and correct behavior. */
/* */
/* INPUT */
/* */
/* ip_ptr Pointer to the IP instance */
/* */
/* OUTPUT */
/* */
/* NONE */
/* */
/* CALLS */
/* */
/* tx_mutex_get Obtain protection mutex */
/* tx_mutex_put Release protection mutex */
/* */
/* CALLED BY */
/* */
/* _nx_ip_thread_entry */
/* */
/**************************************************************************/
VOID _nx_nd_cache_slow_periodic_update(NX_IP *ip_ptr)
{
INT i;
/* Check all entries in the ND cache for timer expiration. */
for (i = 0; i < NX_IPV6_NEIGHBOR_CACHE_SIZE; i++)
{
/* Skip the invalid or empty ones. */
if (ip_ptr -> nx_ipv6_nd_cache[i].nx_nd_cache_nd_status == ND_CACHE_STATE_INVALID)
{
continue;
}
/* No need to update the static entries! */
if (ip_ptr -> nx_ipv6_nd_cache[i].nx_nd_cache_is_static)
{
continue;
}
/* If this is a reachable entry... */
if (ip_ptr -> nx_ipv6_nd_cache[i].nx_nd_cache_nd_status == ND_CACHE_STATE_REACHABLE)
{
ip_ptr -> nx_ipv6_nd_cache[i].nx_nd_cache_timer_tick--;
/* And we have timed out... */
if (ip_ptr -> nx_ipv6_nd_cache[i].nx_nd_cache_timer_tick == 0)
{
/* Time to move the state into the STALE state. */
ip_ptr -> nx_ipv6_nd_cache[i].nx_nd_cache_nd_status = ND_CACHE_STATE_STALE;
}
}
/* Entries in the delay state are set to be 'probed'. */
else if (ip_ptr -> nx_ipv6_nd_cache[i].nx_nd_cache_nd_status == ND_CACHE_STATE_DELAY)
{
ip_ptr -> nx_ipv6_nd_cache[i].nx_nd_cache_timer_tick--;
/* Has the timeout expired? */
if (ip_ptr -> nx_ipv6_nd_cache[i].nx_nd_cache_timer_tick == 0)
{
/* Set to the probe state. We do not send out NS;
the nd_cache_fast_periodic_update will handle the
processing of this entry now. */
ip_ptr -> nx_ipv6_nd_cache[i].nx_nd_cache_nd_status = ND_CACHE_STATE_PROBE;
ip_ptr -> nx_ipv6_nd_cache[i].nx_nd_cache_num_solicit = NX_MAX_UNICAST_SOLICIT;
}
}
else if (ip_ptr -> nx_ipv6_nd_cache[i].nx_nd_cache_nd_status == ND_CACHE_STATE_STALE)
{
/* When the entry is in stale mode, we actually increment the timer_tick.
The larger the timer_tick value, the longer then entry has been in
stale mode. This makes the entry a target for recycling (being replaced
by a newer reachable entry). */
ip_ptr -> nx_ipv6_nd_cache[i].nx_nd_cache_timer_tick++;
}
}
}
#endif /* FEATURE_NX_IPV6 */
|