Select one of the symbols to view example projects that use it.
 
Outline
...
...
...
...
#define NX_SOURCE_CODE
#include "nx_api.h"
#include "nx_ipv6.h"
...
Files
netxduo
addons
common
drivers
inc
src
crypto_libraries
nx_secure
ports
threadx
filex
usbx
HAL
CMSIS
lan8742
SourceVuSTM32 Libraries and Samplesnetxduocommon/src/nxd_ipv6_interface_find.c
 
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/**************************************************************************/ /* */ /* Copyright (c) Microsoft Corporation. All rights reserved. */ /* */ /* This software is licensed under the Microsoft Software License */ /* Terms for Microsoft Azure RTOS. Full text of the license can be */ /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ /* and in the root directory of this software. */ /* */... /**************************************************************************/ ... /**************************************************************************/ /**************************************************************************/ /** */ /** NetX Component */ /** */ /** Internet Protocol (IP) */ /** */... /**************************************************************************/ /**************************************************************************/ #define NX_SOURCE_CODE /* Include necessary system files. */ #include "nx_api.h" #include "nx_ipv6.h" #ifdef FEATURE_NX_IPV6... /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _nxd_ipv6_interface_find PORTABLE C */ /* 6.1 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ /* */ /* DESCRIPTION */ /* */ /* This function finds a suitable outgoing interface based on the */ /* destination IP address. */ /* */ /* INPUT */ /* */ /* ip_ptr Pointer to IP control block */ /* dest_address Destination IP address */ /* ipv6_interface_index Index interface to use as the */ /* outgoing interface. */ /* ipv6_address_index Address index to use as the */ /* source address */ /* if_ptr Outgoing interface if not null*/ /* */ /* OUTPUT */ /* */ /* status */ /* */ /* CALLS */ /* */ /* None */ /* */ /* CALLED BY */ /* */ /* Internal function. */ /* */ /* RELEASE HISTORY */ /* */ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ /* */... /**************************************************************************/ UINT _nxd_ipv6_interface_find(NX_IP *ip_ptr, ULONG *dest_address, NXD_IPV6_ADDRESS **ipv6_addr, NX_INTERFACE *if_ptr) { UINT i; NXD_IPV6_ADDRESS *ipv6_address; NX_IPV6_DEFAULT_ROUTER_ENTRY *rt_entry; UINT start_index; UINT end_index; ULONG address_type = IPv6_Address_Type(dest_address); /* ipv6_addr must not be NULL. */ NX_ASSERT(ipv6_addr != NX_NULL); #ifdef NX_ENABLE_IPV6_MULTICAST /* Check for a multicast destination address.*/ if (address_type & IPV6_ADDRESS_MULTICAST) { /* Search the address whether match our mld join list. */ for (i = 0; i < NX_MAX_MULTICAST_GROUPS; i++) { /* Skip empty entries. */ if (ip_ptr -> nx_ipv6_multicast_entry[i].nx_ip_mld_join_interface_list == NX_NULL) { continue; }if (ip_ptr -> nx_ipv6_multicast_entry[i].nx_ip_mld_join_interface_list == NX_NULL) { ... } /* Skip not matched interface. */ if (if_ptr && (ip_ptr -> nx_ipv6_multicast_entry[i].nx_ip_mld_join_interface_list != if_ptr)) { continue; }if (if_ptr && (ip_ptr -> nx_ipv6_multicast_entry[i].nx_ip_mld_join_interface_list != if_ptr)) { ... } /* Skip multicast entry whose related interface is down. */ if (ip_ptr -> nx_ipv6_multicast_entry[i].nx_ip_mld_join_interface_list -> nx_interface_link_up == NX_FALSE) { continue; }if (ip_ptr -> nx_ipv6_multicast_entry[i].nx_ip_mld_join_interface_list -> nx_interface_link_up == NX_FALSE) { ... } if (CHECK_IPV6_ADDRESSES_SAME(ip_ptr -> nx_ipv6_multicast_entry[i].nx_ip_mld_join_list, dest_address)) { *ipv6_addr = ip_ptr -> nx_ipv6_multicast_entry[i].nx_ip_mld_join_interface_list -> nxd_interface_ipv6_address_list_head; /* Check whether there's address on the interface. */ if (*ipv6_addr == NX_NULL) { return(NX_NO_INTERFACE_ADDRESS); }if (*ipv6_addr == NX_NULL) { ... } /* The address must be valid in list queue of interface. */ NX_ASSERT((*ipv6_addr) -> nxd_ipv6_address_valid); return(NX_SUCCESS); }if (CHECK_IPV6_ADDRESSES_SAME(ip_ptr -> nx_ipv6_multicast_entry[i].nx_ip_mld_join_list, dest_address)) { ... } }for (i = 0; i < NX_MAX_MULTICAST_GROUPS; i++) { ... } }if (address_type & IPV6_ADDRESS_MULTICAST) { ... } /* ... */#endif /* NX_ENABLE_IPV6_MULTICAST */ /* Loop through addresses. */ if (address_type & IPV6_ADDRESS_UNICAST) { /* Unicast address. Is the destination one of local address? */ for (i = 0; i < NX_MAX_IPV6_ADDRESSES; i++) { /* Compare the address. */ if ((ip_ptr -> nx_ipv6_address[i].nxd_ipv6_address_valid) && (CHECK_IPV6_ADDRESSES_SAME(ip_ptr -> nx_ipv6_address[i].nxd_ipv6_address, dest_address))) { /* Found a proper address. */ *ipv6_addr = &(ip_ptr -> nx_ipv6_address[i]); return(NX_SUCCESS); }if ((ip_ptr -> nx_ipv6_address[i].nxd_ipv6_address_valid) && (CHECK_IPV6_ADDRESSES_SAME(ip_ptr -> nx_ipv6_address[i].nxd_ipv6_address, dest_address))) { ... } }for (i = 0; i < NX_MAX_IPV6_ADDRESSES; i++) { ... } }if (address_type & IPV6_ADDRESS_UNICAST) { ... } if (if_ptr) { /* Search addresses from specified interface only. */ start_index = if_ptr -> nx_interface_index; end_index = (UINT)(if_ptr -> nx_interface_index + 1); }if (if_ptr) { ... } else { /* Search addressed from all interfaces. */ start_index = 0; end_index = NX_MAX_PHYSICAL_INTERFACES; }else { ... } /* Loop through interfaces. */ for (i = start_index; i < end_index; i++) { /* Skip interface which is down. */ if (ip_ptr -> nx_ip_interface[i].nx_interface_link_up == NX_FALSE) { continue; }if (ip_ptr -> nx_ip_interface[i].nx_interface_link_up == NX_FALSE) { ... } /* Point to the first address unit in the interface. */ for (ipv6_address = ip_ptr -> nx_ip_interface[i].nxd_interface_ipv6_address_list_head; ipv6_address; ipv6_address = ipv6_address -> nxd_ipv6_address_next) { /* Skip address that is not valid. */ if (ipv6_address -> nxd_ipv6_address_state != NX_IPV6_ADDR_STATE_VALID) { continue; }if (ipv6_address -> nxd_ipv6_address_state != NX_IPV6_ADDR_STATE_VALID) { ... } if (address_type & IPV6_ADDRESS_LINKLOCAL) { /* Destination address is link local. */ if (IPv6_Address_Type(ipv6_address -> nxd_ipv6_address) & IPV6_ADDRESS_LINKLOCAL) { /* Found link local address as source. */ break; }if (IPv6_Address_Type(ipv6_address -> nxd_ipv6_address) & IPV6_ADDRESS_LINKLOCAL) { ... } }if (address_type & IPV6_ADDRESS_LINKLOCAL) { ... } else if (_nxd_ipv6_find_max_prefix_length(dest_address, ipv6_address -> nxd_ipv6_address, ipv6_address -> nxd_ipv6_address_prefix_length) >= ipv6_address -> nxd_ipv6_address_prefix_length) { /* Found a proper outgoing address. */ break; }else if (_nxd_ipv6_find_max_prefix_length(dest_address, ipv6_address -> nxd_ipv6_address, ipv6_address -> nxd_ipv6_address_prefix_length) >= ipv6_address -> nxd_ipv6_address_prefix_length) { ... } /* Check for a multicast destination address.*/ else if (address_type & IPV6_ADDRESS_MULTICAST) { /* This indicates a global IP multicast. */ /* So we need to make a best guess at the address index of the host global address. *//* ... */ /* Determine(LLA vs Global IP address type from the higher order bytes. */ if ((dest_address[0] & 0x000F0000) == 0x00020000) { /* Check for a link local IP address. */ if (IPv6_Address_Type(ipv6_address -> nxd_ipv6_address) & IPV6_ADDRESS_LINKLOCAL) { /* This will do! */ break; }if (IPv6_Address_Type(ipv6_address -> nxd_ipv6_address) & IPV6_ADDRESS_LINKLOCAL) { ... } }if ((dest_address[0] & 0x000F0000) == 0x00020000) { ... } /* Check for a global IP address. */ else if (IPv6_Address_Type(ipv6_address -> nxd_ipv6_address) & IPV6_ADDRESS_GLOBAL) { /* This will do! */ break; }else if (IPv6_Address_Type(ipv6_address -> nxd_ipv6_address) & IPV6_ADDRESS_GLOBAL) { ... } }else if (address_type & IPV6_ADDRESS_MULTICAST) { ... } }for (ipv6_address = ip_ptr -> nx_ip_interface[i].nxd_interface_ipv6_address_list_head; ipv6_address; ipv6_address = ipv6_address -> nxd_ipv6_address_next) { ... } if (ipv6_address) { /* Found a proper address. */ *ipv6_addr = ipv6_address; return(NX_SUCCESS); }if (ipv6_address) { ... } }for (i = start_index; i < end_index; i++) { ... } #ifndef NX_DISABLE_LOOPBACK_INTERFACE /* Get ipv6 address in the loop back interface. */ ipv6_address = ip_ptr -> nx_ip_interface[NX_LOOPBACK_INTERFACE].nxd_interface_ipv6_address_list_head; if (ipv6_address) { /* Check whether the destination is loop back address. */ if (CHECK_IPV6_ADDRESSES_SAME(ipv6_address -> nxd_ipv6_address, dest_address)) { *ipv6_addr = ipv6_address; return(NX_SUCCESS); }if (CHECK_IPV6_ADDRESSES_SAME(ipv6_address -> nxd_ipv6_address, dest_address)) { ... } }if (ipv6_address) { ... } /* ... */#endif /* NX_DISABLE_LOOPBACK_INTERFACE */ /* Is the destination address gloabl? */ if (address_type & IPV6_ADDRESS_GLOBAL) { /* Yes. Check default router. */ for (i = 0; i < NX_IPV6_DEFAULT_ROUTER_TABLE_SIZE; i++) { rt_entry = &ip_ptr -> nx_ipv6_default_router_table[i]; /* Skip invalid entries. */ if (rt_entry -> nx_ipv6_default_router_entry_flag == 0) { continue; }if (rt_entry -> nx_ipv6_default_router_entry_flag == 0) { ... } /* Skip interface which is down. */ if (rt_entry -> nx_ipv6_default_router_entry_interface_ptr -> nx_interface_link_up == NX_FALSE) { continue; }if (rt_entry -> nx_ipv6_default_router_entry_interface_ptr -> nx_interface_link_up == NX_FALSE) { ... } /* Skip not matched interface. */ if (if_ptr && (rt_entry -> nx_ipv6_default_router_entry_interface_ptr != if_ptr)) { continue; }if (if_ptr && (rt_entry -> nx_ipv6_default_router_entry_interface_ptr != if_ptr)) { ... } /* Get first address from interface. */ ipv6_address = rt_entry -> nx_ipv6_default_router_entry_interface_ptr -> nxd_interface_ipv6_address_list_head; while (ipv6_address) { /* Check for a valid address. */ if (ipv6_address -> nxd_ipv6_address_state != NX_IPV6_ADDR_STATE_VALID) { ipv6_address = ipv6_address -> nxd_ipv6_address_next; }if (ipv6_address -> nxd_ipv6_address_state != NX_IPV6_ADDR_STATE_VALID) { ... } /* Check for link-local address. */ else if (IPv6_Address_Type(ipv6_address -> nxd_ipv6_address) & IPV6_ADDRESS_LINKLOCAL) { ipv6_address = ipv6_address -> nxd_ipv6_address_next; }else if (IPv6_Address_Type(ipv6_address -> nxd_ipv6_address) & IPV6_ADDRESS_LINKLOCAL) { ... } else { *ipv6_addr = ipv6_address; /* Found global address as link-local address. */ return(NX_SUCCESS); }else { ... } }while (ipv6_address) { ... } }for (i = 0; i < NX_IPV6_DEFAULT_ROUTER_TABLE_SIZE; i++) { ... } }if (address_type & IPV6_ADDRESS_GLOBAL) { ... } /* No available interface. */ return(NX_NO_INTERFACE_ADDRESS); }_nxd_ipv6_interface_find (NX_IP *ip_ptr, ULONG *dest_address, NXD_IPV6_ADDRESS **ipv6_addr, NX_INTERFACE *if_ptr) { ... } /* ... */ #endif /* FEATURE_NX_IPV6 */
Details
Show:
from
Types: Columns:
This file uses the notable symbols shown below. Click anywhere in the file to view more details.