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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
/***************************************************************************
* 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 */
/** */
/** Internet Protocol (IP) */
/** */
/**************************************************************************/
/**************************************************************************/
#define NX_SOURCE_CODE
/* Include necessary system files. */
#include "nx_api.h"
#include "nx_ip.h"
#include "nx_ipv6.h"
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _nxd_ipv6_address_delete PORTABLE C */
/* 6.4.3 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function removes the IPv6 address at the specified address list */
/* index on the IP instance. */
/* */
/* INPUT */
/* */
/* ip_ptr IP control block pointer */
/* address_index Index into IPv6 address list */
/* */
/* OUTPUT */
/* */
/* status Completion status */
/* */
/* CALLS */
/* */
/* tx_mutex_get Get protection mutex */
/* tx_mutex_put Put protection mutex */
/* nx_ipv6_multicast_leave Leave IPv6 multicast group */
/* [ipv6_address_change_notify] User callback function */
/* */
/* CALLED BY */
/* */
/* Application Code */
/* */
/**************************************************************************/
UINT _nxd_ipv6_address_delete(NX_IP *ip_ptr, UINT address_index)
{
#ifdef FEATURE_NX_IPV6
UINT result;
NXD_IPV6_ADDRESS *ipv6_address, *address_list;
#ifdef NX_ENABLE_IPV6_ADDRESS_CHANGE_NOTIFY
VOID (*address_change_notify)(NX_IP *, UINT, UINT, UINT, ULONG *);
UINT if_index;
ULONG obsoleted_address[4];
address_change_notify = NX_NULL;
#endif /* NX_ENABLE_IPV6_ADDRESS_CHANGE_NOTIFY */
result = NX_NO_INTERFACE_ADDRESS;
/* Place protection while the IPv6 address is modified. */
tx_mutex_get(&(ip_ptr -> nx_ip_protection), TX_WAIT_FOREVER);
/* Get the ip address. */
ipv6_address = &ip_ptr -> nx_ipv6_address[address_index];
/* Check the validity of the address. */
if (ipv6_address -> nxd_ipv6_address_valid)
{
/* Delete the information in the list. */
address_list = ipv6_address -> nxd_ipv6_address_attached -> nxd_interface_ipv6_address_list_head;
/* The delete address is in the head of the list. */
if (ipv6_address == address_list)
{
ipv6_address -> nxd_ipv6_address_attached -> nxd_interface_ipv6_address_list_head = ipv6_address -> nxd_ipv6_address_next;
result = NX_SUCCESS;
}
else
{
/* Find the address in the list. */
while (address_list && (address_list -> nxd_ipv6_address_next != ipv6_address))
{
/* Move to the next address. */
address_list = address_list -> nxd_ipv6_address_next;
}
/* Break out of the while loop, either the address has been found, or the end of the list has been reached. */
if (address_list)
{
address_list -> nxd_ipv6_address_next = ipv6_address -> nxd_ipv6_address_next;
result = NX_SUCCESS;
}
}
if (result == NX_SUCCESS)
{
ULONG multicast_address[4];
SET_SOLICITED_NODE_MULTICAST_ADDRESS(multicast_address, ipv6_address -> nxd_ipv6_address);
/* First remove the corresponding solicited node multicast address. */
_nx_ipv6_multicast_leave(ip_ptr, &multicast_address[0], ipv6_address -> nxd_ipv6_address_attached);
#ifdef NX_ENABLE_IPV6_ADDRESS_CHANGE_NOTIFY
/* Pickup the current notification callback and additional information pointers. */
address_change_notify = ip_ptr -> nx_ipv6_address_change_notify;
obsoleted_address[0] = ipv6_address -> nxd_ipv6_address[0];
obsoleted_address[1] = ipv6_address -> nxd_ipv6_address[1];
obsoleted_address[2] = ipv6_address -> nxd_ipv6_address[2];
obsoleted_address[3] = ipv6_address -> nxd_ipv6_address[3];
if_index = ipv6_address -> nxd_ipv6_address_attached -> nx_interface_index;
#endif /* NX_ENABLE_IPV6_ADDRESS_CHANGE_NOTIFY */
/* At this point ipv6_address is off the interface IPv6 address list. */
memset(ipv6_address, 0, sizeof(NXD_IPV6_ADDRESS));
/* Set index of ipv6_address. */
ipv6_address -> nxd_ipv6_address_index = (UCHAR)address_index;
}
}
/* Release the protection while the IPv6 address is modified. */
tx_mutex_put(&(ip_ptr -> nx_ip_protection));
#ifdef NX_ENABLE_IPV6_ADDRESS_CHANGE_NOTIFY
/* Is the application configured for notification of address changes and/or
prefix_length change? */
if (address_change_notify && (result == NX_SUCCESS))
{
/* Yes, call the application's address change notify function. */
/*lint -e{644} suppress variable might not be initialized, since "if_index" was initialized as long as result is NX_SUCCESS. */
(address_change_notify)(ip_ptr, NX_IPV6_ADDRESS_MANUAL_DELETE, if_index, address_index, &obsoleted_address[0]);
}
#endif /* NX_ENABLE_IPV6_ADDRESS_CHANGE_NOTIFY */
/* Return completion status. */
return(result);
#else /* !FEATURE_NX_IPV6 */
NX_PARAMETER_NOT_USED(ip_ptr);
NX_PARAMETER_NOT_USED(address_index);
return(NX_NOT_SUPPORTED);
#endif /* FEATURE_NX_IPV6 */
}
|