]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Copyright (c) 2000-2016 Apple Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * This file contains Original Code and/or Modifications of Original Code | |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. The rights granted to you under the License | |
10 | * may not be used to create, or enable the creation or redistribution of, | |
11 | * unlawful or unlicensed copies of an Apple operating system, or to | |
12 | * circumvent, violate, or enable the circumvention or violation of, any | |
13 | * terms of an Apple operating system software license agreement. | |
14 | * | |
15 | * Please obtain a copy of the License at | |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
18 | * The Original Code and all software distributed under the License are | |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
23 | * Please see the License for the specific language governing rights and | |
24 | * limitations under the License. | |
25 | * | |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ | |
27 | */ | |
28 | /* | |
29 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. | |
30 | * All rights reserved. | |
31 | * | |
32 | * Redistribution and use in source and binary forms, with or without | |
33 | * modification, are permitted provided that the following conditions | |
34 | * are met: | |
35 | * 1. Redistributions of source code must retain the above copyright | |
36 | * notice, this list of conditions and the following disclaimer. | |
37 | * 2. Redistributions in binary form must reproduce the above copyright | |
38 | * notice, this list of conditions and the following disclaimer in the | |
39 | * documentation and/or other materials provided with the distribution. | |
40 | * 3. Neither the name of the project nor the names of its contributors | |
41 | * may be used to endorse or promote products derived from this software | |
42 | * without specific prior written permission. | |
43 | * | |
44 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND | |
45 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
46 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
47 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE | |
48 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
49 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
50 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
51 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
52 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
53 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
54 | * SUCH DAMAGE. | |
55 | */ | |
56 | ||
57 | #ifndef _NETINET6_ND6_H_ | |
58 | #define _NETINET6_ND6_H_ | |
59 | #include <sys/appleapiopts.h> | |
60 | #include <net/net_kev.h> | |
61 | ||
62 | /* see net/route.h, or net/if_inarp.h */ | |
63 | #ifndef RTF_ANNOUNCE | |
64 | #define RTF_ANNOUNCE RTF_PROTO2 | |
65 | #endif | |
66 | ||
67 | #include <sys/queue.h> | |
68 | ||
69 | #ifdef BSD_KERNEL_PRIVATE | |
70 | #include <net/flowadv.h> | |
71 | #include <kern/locks.h> | |
72 | #include <sys/tree.h> | |
73 | #include <netinet6/nd6_var.h> | |
74 | ||
75 | struct llinfo_nd6 { | |
76 | /* | |
77 | * The following are protected by rnh_lock | |
78 | */ | |
79 | struct llinfo_nd6 *ln_next; | |
80 | struct llinfo_nd6 *ln_prev; | |
81 | struct rtentry *ln_rt; | |
82 | /* | |
83 | * The following are protected by rt_lock | |
84 | */ | |
85 | struct ifnet *ln_exclifp; /* excluded interface (prefix proxy) */ | |
86 | struct mbuf *ln_hold; /* last packet until resolved/timeout */ | |
87 | uint32_t ln_asked; /* # of queries already sent for this addr */ | |
88 | short ln_state; /* reachability state */ | |
89 | short ln_router; /* 2^0: ND6 router bit */ | |
90 | u_int32_t ln_flags; /* flags; see below */ | |
91 | u_int64_t ln_expire; /* lifetime for NDP state transition */ | |
92 | u_int64_t ln_lastused; /* last used timestamp */ | |
93 | struct if_llreach *ln_llreach; /* link-layer reachability record */ | |
94 | }; | |
95 | ||
96 | /* Values for ln_flags */ | |
97 | #define ND6_LNF_TIMER_SKIP 0x1 /* modified by nd6_timer() */ | |
98 | #define ND6_LNF_IN_USE 0x2 /* currently in llinfo_nd6 list */ | |
99 | #endif /* BSD_KERNEL_PRIVATE */ | |
100 | ||
101 | #define ND6_LLINFO_PURGE -3 | |
102 | #define ND6_LLINFO_NOSTATE -2 | |
103 | /* | |
104 | * We don't need the WAITDELETE state any more, but we keep the definition | |
105 | * in a comment line instead of removing it. This is necessary to avoid | |
106 | * unintentionally reusing the value for another purpose, which might | |
107 | * affect backward compatibility with old applications. | |
108 | * (20000711 jinmei@kame.net) | |
109 | */ | |
110 | /* #define ND6_LLINFO_WAITDELETE -1 */ | |
111 | #define ND6_LLINFO_INCOMPLETE 0 | |
112 | #define ND6_LLINFO_REACHABLE 1 | |
113 | #define ND6_LLINFO_STALE 2 | |
114 | #define ND6_LLINFO_DELAY 3 | |
115 | #define ND6_LLINFO_PROBE 4 | |
116 | ||
117 | #ifdef BSD_KERNEL_PRIVATE | |
118 | ||
119 | #define ND6_CACHE_STATE_TRANSITION(ln, nstate) do {\ | |
120 | if (nd6_debug >= 1) {\ | |
121 | nd6log((LOG_INFO,\ | |
122 | "[%s:%d]: NDP cache entry changed from %s -> %s",\ | |
123 | __FILE__,\ | |
124 | __LINE__,\ | |
125 | ndcache_state2str((ln)->ln_state),\ | |
126 | ndcache_state2str(nstate)));\ | |
127 | if ((ln)->ln_rt)\ | |
128 | nd6log((LOG_INFO,\ | |
129 | " for address: %s.\n",\ | |
130 | ip6_sprintf(&SIN6(rt_key((ln)->ln_rt))->sin6_addr)));\ | |
131 | else\ | |
132 | nd6log((LOG_INFO, "\n"));\ | |
133 | }\ | |
134 | (ln)->ln_state = nstate;\ | |
135 | } while(0) | |
136 | ||
137 | #define ND6_IS_LLINFO_PROBREACH(n) ((n)->ln_state > ND6_LLINFO_INCOMPLETE) | |
138 | #define ND6_LLINFO_PERMANENT(n) \ | |
139 | (((n)->ln_expire == 0) && ((n)->ln_state > ND6_LLINFO_INCOMPLETE)) | |
140 | ||
141 | #define ND6_EUI64_GBIT 0x01 | |
142 | #define ND6_EUI64_UBIT 0x02 | |
143 | ||
144 | #define ND6_EUI64_TO_IFID(in6) \ | |
145 | do {(in6)->s6_addr[8] ^= ND6_EUI64_UBIT; } while (0) | |
146 | ||
147 | #define ND6_EUI64_GROUP(in6) ((in6)->s6_addr[8] & ND6_EUI64_GBIT) | |
148 | #define ND6_EUI64_INDIVIDUAL(in6) (!ND6_EUI64_GROUP(in6)) | |
149 | #define ND6_EUI64_LOCAL(in6) ((in6)->s6_addr[8] & ND6_EUI64_UBIT) | |
150 | #define ND6_EUI64_UNIVERSAL(in6) (!ND6_EUI64_LOCAL(in6)) | |
151 | #define ND6_IFID_LOCAL(in6) (!ND6_EUI64_LOCAL(in6)) | |
152 | #define ND6_IFID_UNIVERSAL(in6) (!ND6_EUI64_UNIVERSAL(in6)) | |
153 | #endif /* BSD_KERNEL_PRIVATE */ | |
154 | ||
155 | #if !defined(BSD_KERNEL_PRIVATE) | |
156 | struct nd_ifinfo { | |
157 | #else | |
158 | /* For binary compatibility, this structure must not change */ | |
159 | /* NOTE: nd_ifinfo is defined in nd6_var.h */ | |
160 | struct nd_ifinfo_compat { | |
161 | #endif /* !BSD_KERNEL_PRIVATE */ | |
162 | u_int32_t linkmtu; /* LinkMTU */ | |
163 | u_int32_t maxmtu; /* Upper bound of LinkMTU */ | |
164 | u_int32_t basereachable; /* BaseReachableTime */ | |
165 | u_int32_t reachable; /* Reachable Time */ | |
166 | u_int32_t retrans; /* Retrans Timer */ | |
167 | u_int32_t flags; /* Flags */ | |
168 | int recalctm; /* BaseReacable re-calculation timer */ | |
169 | u_int8_t chlim; /* CurHopLimit */ | |
170 | u_int8_t receivedra; | |
171 | /* the following 3 members are for privacy extension for addrconf */ | |
172 | u_int8_t randomseed0[8]; /* upper 64 bits of SHA1 digest */ | |
173 | u_int8_t randomseed1[8]; /* lower 64 bits (usually the EUI64 IFID) */ | |
174 | u_int8_t randomid[8]; /* current random ID */ | |
175 | }; | |
176 | ||
177 | #define ND6_IFF_PERFORMNUD 0x1 | |
178 | #if defined(PRIVATE) | |
179 | ||
180 | /* | |
181 | * APPLE: not used. Interface specific router advertisements are handled with a | |
182 | * specific ifnet flag: IFEF_ACCEPT_RTADVD | |
183 | */ | |
184 | #define ND6_IFF_ACCEPT_RTADV 0x2 | |
185 | ||
186 | /* APPLE: NOT USED not related to ND. */ | |
187 | #define ND6_IFF_PREFER_SOURCE 0x4 | |
188 | ||
189 | /* IPv6 operation is disabled due to * DAD failure. (XXX: not ND-specific) */ | |
190 | #define ND6_IFF_IFDISABLED 0x8 | |
191 | ||
192 | #define ND6_IFF_DONT_SET_IFROUTE 0x10 /* NOT USED */ | |
193 | #endif /* PRIVATE */ | |
194 | #define ND6_IFF_PROXY_PREFIXES 0x20 | |
195 | #define ND6_IFF_IGNORE_NA 0x40 | |
196 | #if defined(PRIVATE) | |
197 | #define ND6_IFF_INSECURE 0x80 | |
198 | #endif | |
199 | #define ND6_IFF_REPLICATED 0x100 /* sleep proxy registered */ | |
200 | #define ND6_IFF_DAD 0x200 /* Perform DAD on the interface */ | |
201 | ||
202 | struct in6_nbrinfo { | |
203 | char ifname[IFNAMSIZ]; /* if name, e.g. "en0" */ | |
204 | struct in6_addr addr; /* IPv6 address of the neighbor */ | |
205 | long asked; /* # of queries already sent for this addr */ | |
206 | int isrouter; /* if it acts as a router */ | |
207 | int state; /* reachability state */ | |
208 | int expire; /* lifetime for NDP state transition */ | |
209 | }; | |
210 | ||
211 | #if defined(BSD_KERNEL_PRIVATE) | |
212 | struct in6_nbrinfo_32 { | |
213 | char ifname[IFNAMSIZ]; | |
214 | struct in6_addr addr; | |
215 | u_int32_t asked; | |
216 | int isrouter; | |
217 | int state; | |
218 | int expire; | |
219 | }; | |
220 | ||
221 | struct in6_nbrinfo_64 { | |
222 | char ifname[IFNAMSIZ]; | |
223 | struct in6_addr addr; | |
224 | long asked; | |
225 | int isrouter __attribute__((aligned(8))); | |
226 | int state; | |
227 | int expire; | |
228 | } __attribute__((aligned(8))); | |
229 | #endif /* BSD_KERNEL_PRIVATE */ | |
230 | ||
231 | #define DRLSTSIZ 10 | |
232 | #define PRLSTSIZ 10 | |
233 | ||
234 | struct in6_drlist { | |
235 | char ifname[IFNAMSIZ]; | |
236 | struct { | |
237 | struct in6_addr rtaddr; | |
238 | u_char flags; | |
239 | u_short rtlifetime; | |
240 | u_long expire; | |
241 | u_short if_index; | |
242 | } defrouter[DRLSTSIZ]; | |
243 | }; | |
244 | ||
245 | #if defined(BSD_KERNEL_PRIVATE) | |
246 | struct in6_drlist_32 { | |
247 | char ifname[IFNAMSIZ]; | |
248 | struct { | |
249 | struct in6_addr rtaddr; | |
250 | u_char flags; | |
251 | u_short rtlifetime; | |
252 | u_int32_t expire; | |
253 | u_short if_index; | |
254 | } defrouter[DRLSTSIZ]; | |
255 | }; | |
256 | ||
257 | struct in6_drlist_64 { | |
258 | char ifname[IFNAMSIZ]; | |
259 | struct { | |
260 | struct in6_addr rtaddr; | |
261 | u_char flags; | |
262 | u_short rtlifetime; | |
263 | u_long expire __attribute__((aligned(8))); | |
264 | u_short if_index __attribute__((aligned(8))); | |
265 | } defrouter[DRLSTSIZ] __attribute__((aligned(8))); | |
266 | }; | |
267 | #endif /* BSD_KERNEL_PRIVATE */ | |
268 | ||
269 | /* valid values for stateflags */ | |
270 | #define NDDRF_INSTALLED 0x1 /* installed in the routing table */ | |
271 | #define NDDRF_IFSCOPE 0x2 /* installed as a scoped route */ | |
272 | #define NDDRF_STATIC 0x4 /* for internal use only */ | |
273 | #define NDDRF_MAPPED 0x8 /* Default router addr is mapped to a different one for routing */ | |
274 | ||
275 | struct in6_defrouter { | |
276 | struct sockaddr_in6 rtaddr; | |
277 | u_char flags; | |
278 | u_char stateflags; | |
279 | u_short rtlifetime; | |
280 | u_long expire; | |
281 | u_short if_index; | |
282 | }; | |
283 | ||
284 | #if defined(BSD_KERNEL_PRIVATE) | |
285 | struct in6_defrouter_32 { | |
286 | struct sockaddr_in6 rtaddr; | |
287 | u_char flags; | |
288 | u_char stateflags; | |
289 | u_short rtlifetime; | |
290 | u_int32_t expire; | |
291 | u_short if_index; | |
292 | }; | |
293 | ||
294 | struct in6_defrouter_64 { | |
295 | struct sockaddr_in6 rtaddr; | |
296 | u_char flags; | |
297 | u_char stateflags; | |
298 | u_short rtlifetime; | |
299 | u_long expire __attribute__((aligned(8))); | |
300 | u_short if_index __attribute__((aligned(8))); | |
301 | } __attribute__((aligned(8))); | |
302 | #endif /* BSD_KERNEL_PRIVATE */ | |
303 | ||
304 | struct in6_prlist { | |
305 | char ifname[IFNAMSIZ]; | |
306 | struct { | |
307 | struct in6_addr prefix; | |
308 | struct prf_ra raflags; | |
309 | u_char prefixlen; | |
310 | u_char origin; | |
311 | u_long vltime; | |
312 | u_long pltime; | |
313 | u_long expire; | |
314 | u_short if_index; | |
315 | u_short advrtrs; /* number of advertisement routers */ | |
316 | struct in6_addr advrtr[DRLSTSIZ]; /* XXX: explicit limit */ | |
317 | } prefix[PRLSTSIZ]; | |
318 | }; | |
319 | ||
320 | #if defined(BSD_KERNEL_PRIVATE) | |
321 | struct in6_prlist_32 { | |
322 | char ifname[IFNAMSIZ]; | |
323 | struct { | |
324 | struct in6_addr prefix; | |
325 | struct prf_ra raflags; | |
326 | u_char prefixlen; | |
327 | u_char origin; | |
328 | u_int32_t vltime; | |
329 | u_int32_t pltime; | |
330 | u_int32_t expire; | |
331 | u_short if_index; | |
332 | u_short advrtrs; | |
333 | struct in6_addr advrtr[DRLSTSIZ]; | |
334 | } prefix[PRLSTSIZ]; | |
335 | }; | |
336 | ||
337 | struct in6_prlist_64 { | |
338 | char ifname[IFNAMSIZ]; | |
339 | struct { | |
340 | struct in6_addr prefix; | |
341 | struct prf_ra raflags; | |
342 | u_char prefixlen; | |
343 | u_char origin; | |
344 | u_long vltime __attribute__((aligned(8))); | |
345 | u_long pltime __attribute__((aligned(8))); | |
346 | u_long expire __attribute__((aligned(8))); | |
347 | u_short if_index; | |
348 | u_short advrtrs; | |
349 | u_int32_t pad; | |
350 | struct in6_addr advrtr[DRLSTSIZ]; | |
351 | } prefix[PRLSTSIZ]; | |
352 | }; | |
353 | #endif /* BSD_KERNEL_PRIVATE */ | |
354 | ||
355 | struct in6_prefix { | |
356 | struct sockaddr_in6 prefix; | |
357 | struct prf_ra raflags; | |
358 | u_char prefixlen; | |
359 | u_char origin; | |
360 | u_long vltime; | |
361 | u_long pltime; | |
362 | u_long expire; | |
363 | u_int32_t flags; | |
364 | int refcnt; | |
365 | u_short if_index; | |
366 | u_short advrtrs; /* number of advertisement routers */ | |
367 | /* struct sockaddr_in6 advrtr[] */ | |
368 | }; | |
369 | ||
370 | #if defined(BSD_KERNEL_PRIVATE) | |
371 | struct in6_prefix_32 { | |
372 | struct sockaddr_in6 prefix; | |
373 | struct prf_ra raflags; | |
374 | u_char prefixlen; | |
375 | u_char origin; | |
376 | u_int32_t vltime; | |
377 | u_int32_t pltime; | |
378 | u_int32_t expire; | |
379 | u_int32_t flags; | |
380 | int refcnt; | |
381 | u_short if_index; | |
382 | u_short advrtrs; /* number of advertisement routers */ | |
383 | /* struct sockaddr_in6 advrtr[] */ | |
384 | }; | |
385 | ||
386 | struct in6_prefix_64 { | |
387 | struct sockaddr_in6 prefix; | |
388 | struct prf_ra raflags; | |
389 | u_char prefixlen; | |
390 | u_char origin; | |
391 | u_long vltime __attribute__((aligned(8))); | |
392 | u_long pltime __attribute__((aligned(8))); | |
393 | u_long expire __attribute__((aligned(8))); | |
394 | u_int32_t flags __attribute__((aligned(8))); | |
395 | int refcnt; | |
396 | u_short if_index; | |
397 | u_short advrtrs; | |
398 | /* struct sockaddr_in6 advrtr[] */ | |
399 | }; | |
400 | #endif /* BSD_KERNEL_PRIVATE */ | |
401 | ||
402 | struct in6_ondireq { | |
403 | char ifname[IFNAMSIZ]; | |
404 | struct { | |
405 | u_int32_t linkmtu; /* LinkMTU */ | |
406 | u_int32_t maxmtu; /* Upper bound of LinkMTU */ | |
407 | u_int32_t basereachable; /* BaseReachableTime */ | |
408 | u_int32_t reachable; /* Reachable Time */ | |
409 | u_int32_t retrans; /* Retrans Timer */ | |
410 | u_int32_t flags; /* Flags */ | |
411 | int recalctm; /* BaseReacable re-calculation timer */ | |
412 | u_int8_t chlim; /* CurHopLimit */ | |
413 | u_int8_t receivedra; | |
414 | } ndi; | |
415 | }; | |
416 | ||
417 | #if !defined(BSD_KERNEL_PRIVATE) | |
418 | struct in6_ndireq { | |
419 | char ifname[IFNAMSIZ]; | |
420 | struct nd_ifinfo ndi; | |
421 | }; | |
422 | #else | |
423 | struct in6_ndireq { | |
424 | char ifname[IFNAMSIZ]; | |
425 | struct nd_ifinfo_compat ndi; | |
426 | }; | |
427 | #endif /* !BSD_KERNEL_PRIVATE */ | |
428 | ||
429 | struct in6_ndifreq { | |
430 | char ifname[IFNAMSIZ]; | |
431 | u_long ifindex; | |
432 | }; | |
433 | ||
434 | #define MAX_RTR_SOLICITATION_DELAY 1 /* 1sec */ | |
435 | #define RTR_SOLICITATION_INTERVAL 4 /* 4sec */ | |
436 | ||
437 | #if defined(BSD_KERNEL_PRIVATE) | |
438 | struct in6_ndifreq_32 { | |
439 | char ifname[IFNAMSIZ]; | |
440 | u_int32_t ifindex; | |
441 | }; | |
442 | ||
443 | struct in6_ndifreq_64 { | |
444 | char ifname[IFNAMSIZ]; | |
445 | u_long ifindex __attribute__((aligned(8))); | |
446 | }; | |
447 | #endif /* BSD_KERNEL_PRIVATE */ | |
448 | ||
449 | /* Prefix status */ | |
450 | #define NDPRF_ONLINK 0x1 | |
451 | #define NDPRF_DETACHED 0x2 | |
452 | #define NDPRF_STATIC 0x100 | |
453 | #define NDPRF_IFSCOPE 0x1000 | |
454 | #define NDPRF_PRPROXY 0x2000 | |
455 | #ifdef BSD_KERNEL_PRIVATE | |
456 | #define NDPRF_PROCESSED_ONLINK 0x08000 | |
457 | #define NDPRF_PROCESSED_SERVICE 0x10000 | |
458 | #define NDPRF_DEFUNCT 0x20000 | |
459 | #endif | |
460 | ||
461 | /* protocol constants */ | |
462 | #define MAX_RTR_SOLICITATION_DELAY 1 /* 1sec */ | |
463 | #define RTR_SOLICITATION_INTERVAL 4 /* 4sec */ | |
464 | #define MAX_RTR_SOLICITATIONS 3 | |
465 | ||
466 | #define ND6_INFINITE_LIFETIME 0xffffffff | |
467 | #define ND6_MAX_LIFETIME 0x7fffffff | |
468 | ||
469 | #ifdef BSD_KERNEL_PRIVATE | |
470 | #define ND_IFINFO(ifp) \ | |
471 | ((ifp == NULL) ? NULL : \ | |
472 | ((IN6_IFEXTRA(ifp) == NULL) ? NULL : \ | |
473 | (&IN6_IFEXTRA(ifp)->nd_ifinfo))) | |
474 | ||
475 | /* | |
476 | * In a more readable form, we derive linkmtu based on: | |
477 | * | |
478 | * if (ifp == NULL) | |
479 | * linkmtu = IPV6_MMTU | |
480 | * else if (ND_IFINFO(ifp) == NULL || !ND_IFINFO(ifp)->initialized) | |
481 | * linkmtu = ifp->if_mtu; | |
482 | * else if (ND_IFINFO(ifp)->linkmtu && ND_IFINFO(ifp)->linkmtu < ifp->if_mtu) | |
483 | * linkmtu = ND_IFINFO(ifp)->linkmtu; | |
484 | * else if ((ND_IFINFO(ifp)->maxmtu && ND_IFINFO(ifp)->maxmtu < ifp->if_mtu)) | |
485 | * linkmtu = ND_IFINFO(ifp)->maxmtu; | |
486 | * else | |
487 | * linkmtu = ifp->if_mtu; | |
488 | */ | |
489 | #define IN6_LINKMTU(ifp) \ | |
490 | (ifp == NULL ? IPV6_MMTU : \ | |
491 | (ND_IFINFO(ifp) == NULL || !ND_IFINFO(ifp)->initialized) ? \ | |
492 | (ifp)->if_mtu : ((ND_IFINFO(ifp)->linkmtu && \ | |
493 | ND_IFINFO(ifp)->linkmtu < (ifp)->if_mtu) ? ND_IFINFO(ifp)->linkmtu : \ | |
494 | ((ND_IFINFO(ifp)->maxmtu && ND_IFINFO(ifp)->maxmtu < (ifp)->if_mtu) ? \ | |
495 | ND_IFINFO(ifp)->maxmtu : (ifp)->if_mtu))) | |
496 | ||
497 | /* node constants */ | |
498 | #define MAX_REACHABLE_TIME 3600000 /* msec */ | |
499 | #define REACHABLE_TIME 30000 /* msec */ | |
500 | #define RETRANS_TIMER 1000 /* msec */ | |
501 | #define MIN_RANDOM_FACTOR 512 /* 1024 * 0.5 */ | |
502 | #define MAX_RANDOM_FACTOR 1536 /* 1024 * 1.5 */ | |
503 | #define DEF_TEMP_VALID_LIFETIME 604800 /* 1 week */ | |
504 | #define DEF_TEMP_PREFERRED_LIFETIME 86400 /* 1 day */ | |
505 | #define TEMPADDR_REGEN_ADVANCE 5 /* sec */ | |
506 | #define MAX_TEMP_DESYNC_FACTOR 600 /* 10 min */ | |
507 | #define ND_COMPUTE_RTIME(x) \ | |
508 | (((MIN_RANDOM_FACTOR * (x >> 10)) + (RandomULong() & \ | |
509 | ((MAX_RANDOM_FACTOR - MIN_RANDOM_FACTOR) * (x >> 10)))) /1000) | |
510 | ||
511 | /* prefix expiry times */ | |
512 | #define ND6_PREFIX_EXPIRY_UNSPEC -1 | |
513 | #define ND6_PREFIX_EXPIRY_NEVER 0 | |
514 | ||
515 | TAILQ_HEAD(nd_drhead, nd_defrouter); | |
516 | struct nd_defrouter { | |
517 | decl_lck_mtx_data(, nddr_lock); | |
518 | TAILQ_ENTRY(nd_defrouter) dr_entry; | |
519 | struct in6_addr rtaddr; | |
520 | u_int32_t nddr_refcount; | |
521 | u_int32_t nddr_debug; | |
522 | u_int64_t expire; | |
523 | u_int64_t base_calendartime; /* calendar time at creation */ | |
524 | u_int64_t base_uptime; /* uptime at creation */ | |
525 | u_char flags; /* flags on RA message */ | |
526 | u_char stateflags; | |
527 | u_short rtlifetime; | |
528 | int err; | |
529 | struct ifnet *ifp; | |
530 | struct in6_addr rtaddr_mapped; /* Mapped gateway address for routing */ | |
531 | void (*nddr_trace)(struct nd_defrouter *, int); /* trace callback fn */ | |
532 | }; | |
533 | ||
534 | #define NDDR_LOCK_ASSERT_HELD(_nddr) \ | |
535 | lck_mtx_assert(&(_nddr)->nddr_lock, LCK_MTX_ASSERT_OWNED) | |
536 | ||
537 | #define NDDR_LOCK_ASSERT_NOTHELD(_nddr) \ | |
538 | lck_mtx_assert(&(_nddr)->nddr_lock, LCK_MTX_ASSERT_NOTOWNED) | |
539 | ||
540 | #define NDDR_LOCK(_nddr) \ | |
541 | lck_mtx_lock(&(_nddr)->nddr_lock) | |
542 | ||
543 | #define NDDR_LOCK_SPIN(_nddr) \ | |
544 | lck_mtx_lock_spin(&(_nddr)->nddr_lock) | |
545 | ||
546 | #define NDDR_CONVERT_LOCK(_nddr) do { \ | |
547 | NDPR_LOCK_ASSERT_HELD(_nddr); \ | |
548 | lck_mtx_convert_spin(&(_nddr)->nddr_lock); \ | |
549 | } while (0) | |
550 | ||
551 | #define NDDR_UNLOCK(_nddr) \ | |
552 | lck_mtx_unlock(&(_nddr)->nddr_lock) | |
553 | ||
554 | #define NDDR_ADDREF(_nddr) \ | |
555 | nddr_addref(_nddr, 0) | |
556 | ||
557 | #define NDDR_ADDREF_LOCKED(_nddr) \ | |
558 | nddr_addref(_nddr, 1) | |
559 | ||
560 | #define NDDR_REMREF(_nddr) do { \ | |
561 | (void) nddr_remref(_nddr, 0); \ | |
562 | } while (0) | |
563 | ||
564 | #define NDDR_REMREF_LOCKED(_nddr) \ | |
565 | nddr_remref(_nddr, 1) | |
566 | ||
567 | /* define struct prproxy_sols_tree */ | |
568 | RB_HEAD(prproxy_sols_tree, nd6_prproxy_soltgt); | |
569 | ||
570 | struct nd_prefix { | |
571 | decl_lck_mtx_data(, ndpr_lock); | |
572 | u_int32_t ndpr_refcount; /* reference count */ | |
573 | u_int32_t ndpr_debug; /* see ifa_debug flags */ | |
574 | struct ifnet *ndpr_ifp; | |
575 | struct rtentry *ndpr_rt; | |
576 | LIST_ENTRY(nd_prefix) ndpr_entry; | |
577 | struct sockaddr_in6 ndpr_prefix; /* prefix */ | |
578 | struct in6_addr ndpr_mask; /* netmask derived from the prefix */ | |
579 | struct in6_addr ndpr_addr; /* address that is derived from the prefix */ | |
580 | u_int32_t ndpr_vltime; /* advertised valid lifetime */ | |
581 | u_int32_t ndpr_pltime; /* advertised preferred lifetime */ | |
582 | u_int64_t ndpr_preferred; /* preferred time of the prefix */ | |
583 | u_int64_t ndpr_expire; /* expiration time of the prefix */ | |
584 | u_int64_t ndpr_lastupdate; /* rx time of last advertisement */ | |
585 | u_int64_t ndpr_base_calendartime; /* calendar time at creation */ | |
586 | u_int64_t ndpr_base_uptime; /* uptime at creation */ | |
587 | struct prf_ra ndpr_flags; | |
588 | unsigned int ndpr_genid; /* protects ndpr_advrtrs */ | |
589 | u_int32_t ndpr_stateflags; /* actual state flags */ | |
590 | /* list of routers that advertise the prefix: */ | |
591 | LIST_HEAD(pr_rtrhead, nd_pfxrouter) ndpr_advrtrs; | |
592 | u_char ndpr_plen; | |
593 | int ndpr_addrcnt; /* reference counter from addresses */ | |
594 | u_int32_t ndpr_allmulti_cnt; /* total all-multi reqs */ | |
595 | u_int32_t ndpr_prproxy_sols_cnt; /* total # of proxied NS */ | |
596 | struct prproxy_sols_tree ndpr_prproxy_sols; /* tree of proxied NS */ | |
597 | void (*ndpr_trace)(struct nd_prefix *, int); /* trace callback fn */ | |
598 | }; | |
599 | ||
600 | #define ndpr_next ndpr_entry.le_next | |
601 | ||
602 | #define ndpr_raf ndpr_flags | |
603 | #define ndpr_raf_onlink ndpr_flags.onlink | |
604 | #define ndpr_raf_auto ndpr_flags.autonomous | |
605 | #define ndpr_raf_router ndpr_flags.router | |
606 | /* | |
607 | * We keep expired prefix for certain amount of time, for validation purposes. | |
608 | * 1800s = MaxRtrAdvInterval | |
609 | */ | |
610 | #define NDPR_KEEP_EXPIRED (1800 * 2) | |
611 | ||
612 | #define NDPR_LOCK_ASSERT_HELD(_ndpr) \ | |
613 | lck_mtx_assert(&(_ndpr)->ndpr_lock, LCK_MTX_ASSERT_OWNED) | |
614 | ||
615 | #define NDPR_LOCK_ASSERT_NOTHELD(_ndpr) \ | |
616 | lck_mtx_assert(&(_ndpr)->ndpr_lock, LCK_MTX_ASSERT_NOTOWNED) | |
617 | ||
618 | #define NDPR_LOCK(_ndpr) \ | |
619 | lck_mtx_lock(&(_ndpr)->ndpr_lock) | |
620 | ||
621 | #define NDPR_LOCK_SPIN(_ndpr) \ | |
622 | lck_mtx_lock_spin(&(_ndpr)->ndpr_lock) | |
623 | ||
624 | #define NDPR_CONVERT_LOCK(_ndpr) do { \ | |
625 | NDPR_LOCK_ASSERT_HELD(_ndpr); \ | |
626 | lck_mtx_convert_spin(&(_ndpr)->ndpr_lock); \ | |
627 | } while (0) | |
628 | ||
629 | #define NDPR_UNLOCK(_ndpr) \ | |
630 | lck_mtx_unlock(&(_ndpr)->ndpr_lock) | |
631 | ||
632 | #define NDPR_ADDREF(_ndpr) \ | |
633 | ndpr_addref(_ndpr, 0) | |
634 | ||
635 | #define NDPR_ADDREF_LOCKED(_ndpr) \ | |
636 | ndpr_addref(_ndpr, 1) | |
637 | ||
638 | #define NDPR_REMREF(_ndpr) do { \ | |
639 | (void) ndpr_remref(_ndpr, 0); \ | |
640 | } while (0) | |
641 | ||
642 | #define NDPR_REMREF_LOCKED(_ndpr) \ | |
643 | ndpr_remref(_ndpr, 1) | |
644 | ||
645 | /* | |
646 | * Message format for use in obtaining information about prefixes | |
647 | * from inet6 sysctl function | |
648 | */ | |
649 | struct inet6_ndpr_msghdr { | |
650 | u_short inpm_msglen; /* to skip over non-understood messages */ | |
651 | u_char inpm_version; /* future binary compatibility */ | |
652 | u_char inpm_type; /* message type */ | |
653 | struct in6_addr inpm_prefix; | |
654 | u_int32_t prm_vltim; | |
655 | u_int32_t prm_pltime; | |
656 | u_int32_t prm_expire; | |
657 | u_int32_t prm_preferred; | |
658 | struct in6_prflags prm_flags; | |
659 | u_short prm_index; /* index for associated ifp */ | |
660 | u_char prm_plen; /* length of prefix in bits */ | |
661 | }; | |
662 | ||
663 | #define prm_raf_onlink prm_flags.prf_ra.onlink | |
664 | #define prm_raf_auto prm_flags.prf_ra.autonomous | |
665 | ||
666 | #define prm_statef_onlink prm_flags.prf_state.onlink | |
667 | ||
668 | #define prm_rrf_decrvalid prm_flags.prf_rr.decrvalid | |
669 | #define prm_rrf_decrprefd prm_flags.prf_rr.decrprefd | |
670 | ||
671 | struct nd_pfxrouter { | |
672 | LIST_ENTRY(nd_pfxrouter) pfr_entry; | |
673 | #define pfr_next pfr_entry.le_next | |
674 | struct nd_defrouter *router; | |
675 | }; | |
676 | ||
677 | LIST_HEAD(nd_prhead, nd_prefix); | |
678 | ||
679 | struct nd_prefix_list { | |
680 | struct nd_prefix_list *next; | |
681 | struct nd_prefix pr; | |
682 | }; | |
683 | #endif /* BSD_KERNEL_PRIVATE */ | |
684 | ||
685 | #if defined(PRIVATE) | |
686 | struct kev_nd6_ndfailure { | |
687 | struct net_event_data link_data; | |
688 | }; | |
689 | ||
690 | struct kev_nd6_ndalive { | |
691 | struct net_event_data link_data; | |
692 | }; | |
693 | ||
694 | /* ND6 RA L2 source address length */ | |
695 | #define ND6_ROUTER_LL_SIZE 64 | |
696 | ||
697 | struct nd6_ra_prefix { | |
698 | struct sockaddr_in6 prefix; | |
699 | struct prf_ra raflags; | |
700 | u_int32_t prefixlen; | |
701 | u_int32_t origin; | |
702 | u_int64_t vltime; | |
703 | u_int64_t pltime; | |
704 | u_int64_t expire; | |
705 | u_int32_t flags; | |
706 | u_int32_t refcnt; | |
707 | u_int32_t if_index; | |
708 | u_int32_t pad; | |
709 | }; | |
710 | ||
711 | /* ND6 router advertisement valid bits */ | |
712 | #define KEV_ND6_DATA_VALID_MTU (0x1 << 0) | |
713 | #define KEV_ND6_DATA_VALID_PREFIX (0x1 << 1) | |
714 | ||
715 | struct kev_nd6_ra_data { | |
716 | u_int8_t lladdr[ND6_ROUTER_LL_SIZE]; | |
717 | u_int32_t lladdrlen; | |
718 | u_int32_t mtu; | |
719 | u_int32_t list_index; | |
720 | u_int32_t list_length; | |
721 | u_int32_t flags; | |
722 | struct nd6_ra_prefix prefix; | |
723 | u_int32_t pad; | |
724 | }; | |
725 | ||
726 | struct nd6_lookup_ipv6_args { | |
727 | char ifname[IFNAMSIZ]; | |
728 | struct sockaddr_in6 ip6_dest; | |
729 | u_int32_t ll_dest_len; | |
730 | union { | |
731 | char buffer[256]; | |
732 | struct sockaddr_dl _sdl; | |
733 | } ll_dest_; | |
734 | }; | |
735 | #define ll_dest_sdl ll_dest_._sdl | |
736 | ||
737 | #endif /* PRIVATE */ | |
738 | ||
739 | #if defined(BSD_KERNEL_PRIVATE) | |
740 | /* nd6.c */ | |
741 | extern int nd6_prune; | |
742 | extern int nd6_prune_lazy; | |
743 | extern int nd6_delay; | |
744 | extern int nd6_umaxtries; | |
745 | extern int nd6_mmaxtries; | |
746 | extern int nd6_useloopback; | |
747 | extern int nd6_accept_6to4; | |
748 | extern int nd6_maxnudhint; | |
749 | extern int nd6_gctimer; | |
750 | extern struct llinfo_nd6 llinfo_nd6; | |
751 | extern struct nd_drhead nd_defrouter; | |
752 | extern struct nd_prhead nd_prefix; | |
753 | extern int nd6_debug; | |
754 | extern int nd6_onlink_ns_rfc4861; | |
755 | extern int nd6_optimistic_dad; | |
756 | ||
757 | #define nd6log(x) do { if (nd6_debug >= 1) log x; } while (0) | |
758 | #define nd6log2(x) do { if (nd6_debug >= 2) log x; } while (0) | |
759 | ||
760 | #define ND6_OPTIMISTIC_DAD_LINKLOCAL (1 << 0) | |
761 | #define ND6_OPTIMISTIC_DAD_AUTOCONF (1 << 1) | |
762 | #define ND6_OPTIMISTIC_DAD_TEMPORARY (1 << 2) | |
763 | #define ND6_OPTIMISTIC_DAD_DYNAMIC (1 << 3) | |
764 | #define ND6_OPTIMISTIC_DAD_SECURED (1 << 4) | |
765 | #define ND6_OPTIMISTIC_DAD_MANUAL (1 << 5) | |
766 | ||
767 | /* nd6_rtr.c */ | |
768 | extern int nd6_defifindex; | |
769 | extern int ip6_desync_factor; /* seconds */ | |
770 | /* ND6_INFINITE_LIFETIME does not apply to temporary addresses */ | |
771 | extern u_int32_t ip6_temp_preferred_lifetime; /* seconds */ | |
772 | extern u_int32_t ip6_temp_valid_lifetime; /* seconds */ | |
773 | extern int ip6_temp_regen_advance; /* seconds */ | |
774 | ||
775 | union nd_opts { | |
776 | struct nd_opt_hdr *nd_opt_array[16]; /* max = target address list */ | |
777 | struct { | |
778 | struct nd_opt_hdr *zero; | |
779 | struct nd_opt_hdr *src_lladdr; | |
780 | struct nd_opt_hdr *tgt_lladdr; | |
781 | struct nd_opt_prefix_info *pi_beg; /* multiple opts, start */ | |
782 | struct nd_opt_rd_hdr *rh; | |
783 | struct nd_opt_mtu *mtu; | |
784 | struct nd_opt_hdr *__res6; | |
785 | struct nd_opt_hdr *__res7; | |
786 | struct nd_opt_hdr *__res8; | |
787 | struct nd_opt_hdr *__res9; | |
788 | struct nd_opt_hdr *__res10; | |
789 | struct nd_opt_hdr *__res11; | |
790 | struct nd_opt_hdr *__res12; | |
791 | struct nd_opt_hdr *__res13; | |
792 | struct nd_opt_nonce *nonce; | |
793 | struct nd_opt_hdr *__res15; | |
794 | struct nd_opt_hdr *search; /* multiple opts */ | |
795 | struct nd_opt_hdr *last; /* multiple opts */ | |
796 | int done; | |
797 | struct nd_opt_prefix_info *pi_end; /* multiple opts, end */ | |
798 | } nd_opt_each; | |
799 | }; | |
800 | #define nd_opts_src_lladdr nd_opt_each.src_lladdr | |
801 | #define nd_opts_tgt_lladdr nd_opt_each.tgt_lladdr | |
802 | #define nd_opts_pi nd_opt_each.pi_beg | |
803 | #define nd_opts_pi_end nd_opt_each.pi_end | |
804 | #define nd_opts_rh nd_opt_each.rh | |
805 | #define nd_opts_mtu nd_opt_each.mtu | |
806 | #define nd_opts_nonce nd_opt_each.nonce | |
807 | #define nd_opts_search nd_opt_each.search | |
808 | #define nd_opts_last nd_opt_each.last | |
809 | #define nd_opts_done nd_opt_each.done | |
810 | ||
811 | /* XXX: need nd6_var.h?? */ | |
812 | /* nd6.c */ | |
813 | extern int nd6_sched_timeout_want; | |
814 | extern void nd6_sched_timeout(struct timeval *, struct timeval *); | |
815 | extern void nd6_init(void); | |
816 | extern void nd6_ifreset(struct ifnet *ifp); | |
817 | extern void nd6_ifattach(struct ifnet *); | |
818 | extern int nd6_is_addr_neighbor(struct sockaddr_in6 *, struct ifnet *, int); | |
819 | extern void nd6_option_init(void *, int, union nd_opts *); | |
820 | extern struct nd_opt_hdr *nd6_option(union nd_opts *); | |
821 | extern int nd6_options(union nd_opts *); | |
822 | extern struct rtentry *nd6_lookup(struct in6_addr *, int, struct ifnet *, int); | |
823 | extern void nd6_setmtu(struct ifnet *); | |
824 | extern void nd6_purge(struct ifnet *); | |
825 | extern void nd6_free(struct rtentry *); | |
826 | extern void nd6_nud_hint(struct rtentry *, struct in6_addr *, int); | |
827 | extern int nd6_resolve(struct ifnet *, struct rtentry *, | |
828 | struct mbuf *, struct sockaddr *, u_char *); | |
829 | extern void nd6_rtrequest(int, struct rtentry *, struct sockaddr *); | |
830 | extern int nd6_ioctl(u_long, caddr_t, struct ifnet *); | |
831 | extern void nd6_cache_lladdr(struct ifnet *, struct in6_addr *, | |
832 | char *, int, int, int); | |
833 | extern int nd6_output_list(struct ifnet *, struct ifnet *, struct mbuf *, | |
834 | struct sockaddr_in6 *, struct rtentry *, struct flowadv *); | |
835 | extern int nd6_output(struct ifnet *, struct ifnet *, struct mbuf *, | |
836 | struct sockaddr_in6 *, struct rtentry *, struct flowadv *); | |
837 | extern int nd6_storelladdr(struct ifnet *, struct rtentry *, struct mbuf *, | |
838 | struct sockaddr *, u_char *); | |
839 | extern int nd6_need_cache(struct ifnet *); | |
840 | extern void nd6_drain(void *); | |
841 | extern void nd6_post_msg(u_int32_t, struct nd_prefix_list *, u_int32_t, | |
842 | u_int32_t, char *, u_int32_t); | |
843 | extern int nd6_setifinfo(struct ifnet *, u_int32_t, u_int32_t); | |
844 | extern const char *ndcache_state2str(short); | |
845 | extern void ln_setexpire(struct llinfo_nd6 *, uint64_t); | |
846 | ||
847 | /* nd6_nbr.c */ | |
848 | extern void nd6_nbr_init(void); | |
849 | extern void nd6_na_input(struct mbuf *, int, int); | |
850 | extern void nd6_na_output(struct ifnet *, const struct in6_addr *, | |
851 | const struct in6_addr *, u_int32_t, int, struct sockaddr *); | |
852 | extern void nd6_ns_input(struct mbuf *, int, int); | |
853 | extern void nd6_ns_output(struct ifnet *, const struct in6_addr *, | |
854 | const struct in6_addr *, struct llinfo_nd6 *, uint8_t *); | |
855 | extern caddr_t nd6_ifptomac(struct ifnet *); | |
856 | extern void nd6_dad_start(struct ifaddr *, int *); | |
857 | extern void nd6_dad_stop(struct ifaddr *); | |
858 | extern void nd6_dad_duplicated(struct ifaddr *); | |
859 | extern void nd6_llreach_alloc(struct rtentry *, struct ifnet *, void *, | |
860 | unsigned int, boolean_t); | |
861 | extern void nd6_llreach_set_reachable(struct ifnet *, void *, unsigned int); | |
862 | extern void nd6_llreach_use(struct llinfo_nd6 *); | |
863 | extern void nd6_alt_node_addr_decompose(struct ifnet *, struct sockaddr *, | |
864 | struct sockaddr_dl *, struct sockaddr_in6 *); | |
865 | extern void nd6_alt_node_present(struct ifnet *, struct sockaddr_in6 *, | |
866 | struct sockaddr_dl *, int32_t, int, int); | |
867 | extern void nd6_alt_node_absent(struct ifnet *, struct sockaddr_in6 *); | |
868 | ||
869 | /* nd6_rtr.c */ | |
870 | extern void nd6_rtr_init(void); | |
871 | extern void nd6_rs_input(struct mbuf *, int, int); | |
872 | extern void nd6_ra_input(struct mbuf *, int, int); | |
873 | extern void prelist_del(struct nd_prefix *); | |
874 | extern void defrouter_select(struct ifnet *); | |
875 | extern void defrouter_reset(void); | |
876 | extern int defrtrlist_ioctl(u_long, caddr_t); | |
877 | extern void defrtrlist_del(struct nd_defrouter *); | |
878 | extern int defrtrlist_add_static(struct nd_defrouter *); | |
879 | extern int defrtrlist_del_static(struct nd_defrouter *); | |
880 | extern void prelist_remove(struct nd_prefix *); | |
881 | extern int prelist_update(struct nd_prefix *, struct nd_defrouter *, | |
882 | struct mbuf *, int); | |
883 | extern int nd6_prelist_add(struct nd_prefix *, struct nd_defrouter *, | |
884 | struct nd_prefix **, boolean_t); | |
885 | extern int nd6_prefix_onlink(struct nd_prefix *); | |
886 | extern int nd6_prefix_onlink_scoped(struct nd_prefix *, unsigned int); | |
887 | extern int nd6_prefix_offlink(struct nd_prefix *); | |
888 | extern void pfxlist_onlink_check(void); | |
889 | extern struct nd_defrouter *defrouter_lookup(struct in6_addr *, struct ifnet *); | |
890 | extern struct nd_prefix *nd6_prefix_lookup(struct nd_prefix *, int); | |
891 | extern int in6_init_prefix_ltimes(struct nd_prefix *ndpr); | |
892 | extern void rt6_flush(struct in6_addr *, struct ifnet *); | |
893 | extern int nd6_setdefaultiface(int); | |
894 | extern int in6_tmpifadd(const struct in6_ifaddr *, int); | |
895 | extern void nddr_addref(struct nd_defrouter *, int); | |
896 | extern struct nd_defrouter *nddr_remref(struct nd_defrouter *, int); | |
897 | extern uint64_t nddr_getexpire(struct nd_defrouter *); | |
898 | extern void ndpr_addref(struct nd_prefix *, int); | |
899 | extern struct nd_prefix *ndpr_remref(struct nd_prefix *, int); | |
900 | extern uint64_t ndpr_getexpire(struct nd_prefix *); | |
901 | ||
902 | /* nd6_prproxy.c */ | |
903 | struct ip6_hdr; | |
904 | extern u_int32_t nd6_prproxy; | |
905 | extern void nd6_prproxy_init(void); | |
906 | extern int nd6_if_prproxy(struct ifnet *, boolean_t); | |
907 | extern void nd6_prproxy_prelist_update(struct nd_prefix *, struct nd_prefix *); | |
908 | extern boolean_t nd6_prproxy_ifaddr(struct in6_ifaddr *); | |
909 | extern void nd6_proxy_find_fwdroute(struct ifnet *, struct route_in6 *); | |
910 | extern boolean_t nd6_prproxy_isours(struct mbuf *, struct ip6_hdr *, | |
911 | struct route_in6 *, unsigned int); | |
912 | extern void nd6_prproxy_ns_output(struct ifnet *, struct ifnet *, | |
913 | struct in6_addr *, struct in6_addr *, struct llinfo_nd6 *); | |
914 | extern void nd6_prproxy_ns_input(struct ifnet *, struct in6_addr *, | |
915 | char *, int, struct in6_addr *, struct in6_addr *, uint8_t *nonce); | |
916 | extern void nd6_prproxy_na_input(struct ifnet *, struct in6_addr *, | |
917 | struct in6_addr *, struct in6_addr *, int); | |
918 | extern void nd6_prproxy_sols_reap(struct nd_prefix *); | |
919 | extern void nd6_prproxy_sols_prune(struct nd_prefix *, u_int32_t); | |
920 | extern int nd6_if_disable(struct ifnet *, boolean_t); | |
921 | void in6_ifaddr_set_dadprogress(struct in6_ifaddr *ia); | |
922 | #endif /* BSD_KERNEL_PRIVATE */ | |
923 | ||
924 | #ifdef KERNEL | |
925 | ||
926 | /* | |
927 | * @function nd6_lookup_ipv6 | |
928 | * @discussion This function will check the routing table for a cached | |
929 | * neighbor discovery entry or trigger an neighbor discovery query | |
930 | * to resolve the IPv6 address to a link-layer address. | |
931 | * nd entries are stored in the routing table. This function will | |
932 | * lookup the IPv6 destination in the routing table. If the | |
933 | * destination requires forwarding to a gateway, the route of the | |
934 | * gateway will be looked up. The route entry is inspected to | |
935 | * determine if the link layer destination address is known. If | |
936 | * unknown, neighbor discovery will be used to resolve the entry. | |
937 | * @param interface The interface the packet is being sent on. | |
938 | * @param ip6_dest The IPv6 destination of the packet. | |
939 | * @param ll_dest On output, the link-layer destination. | |
940 | * @param ll_dest_len The length of the buffer for ll_dest. | |
941 | * @param hint Any routing hint passed down from the protocol. | |
942 | * @param packet The packet being transmitted. | |
943 | * @result May return an error such as EHOSTDOWN or ENETUNREACH. If | |
944 | * this function returns EJUSTRETURN, the packet has been queued | |
945 | * and will be sent when the address is resolved. If any other | |
946 | * value is returned, the caller is responsible for disposing of | |
947 | * the packet. | |
948 | */ | |
949 | extern errno_t nd6_lookup_ipv6(ifnet_t interface, | |
950 | const struct sockaddr_in6 *ip6_dest, struct sockaddr_dl *ll_dest, | |
951 | size_t ll_dest_len, route_t hint, mbuf_t packet); | |
952 | ||
953 | #endif /* KERNEL */ | |
954 | ||
955 | /* nd6_send.c */ | |
956 | #ifdef BSD_KERNEL_PRIVATE | |
957 | /* | |
958 | * nd6_send_opmode | |
959 | * | |
960 | * value using CGA tx SEND rx SEND | |
961 | * -------- --------- ------- ------- | |
962 | * DISABLED NO NO NO | |
963 | * QUIET YES NO NO | |
964 | */ | |
965 | extern int nd6_send_opstate; | |
966 | ||
967 | #define ND6_SEND_OPMODE_DISABLED 0 | |
968 | #define ND6_SEND_OPMODE_CGA_QUIET 1 | |
969 | ||
970 | #endif /* BSD_KERNEL_PRIVATE */ | |
971 | #endif /* _NETINET6_ND6_H_ */ |