]> git.saurik.com Git - apple/xnu.git/blob - bsd/netinet6/nd6.h
xnu-1504.7.4.tar.gz
[apple/xnu.git] / bsd / netinet6 / nd6.h
1 /*
2 * Copyright (c) 2009 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 /* $FreeBSD: src/sys/netinet6/nd6.h,v 1.2.2.3 2001/08/13 01:10:49 simokawa Exp $ */
30 /* $KAME: nd6.h,v 1.55 2001/04/27 15:09:49 itojun Exp $ */
31
32 /*
33 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
34 * All rights reserved.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 * 1. Redistributions of source code must retain the above copyright
40 * notice, this list of conditions and the following disclaimer.
41 * 2. Redistributions in binary form must reproduce the above copyright
42 * notice, this list of conditions and the following disclaimer in the
43 * documentation and/or other materials provided with the distribution.
44 * 3. Neither the name of the project nor the names of its contributors
45 * may be used to endorse or promote products derived from this software
46 * without specific prior written permission.
47 *
48 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
49 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * SUCH DAMAGE.
59 */
60
61 #ifndef _NETINET6_ND6_H_
62 #define _NETINET6_ND6_H_
63 #include <sys/appleapiopts.h>
64
65 /* see net/route.h, or net/if_inarp.h */
66 #ifndef RTF_ANNOUNCE
67 #define RTF_ANNOUNCE RTF_PROTO2
68 #endif
69
70 #include <sys/queue.h>
71
72 #ifdef KERNEL_PRIVATE
73 #include <kern/locks.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 mbuf *ln_hold; /* last packet until resolved/timeout */
86 long ln_asked; /* number of queries already sent for this addr */
87 u_int32_t ln_expire; /* lifetime for NDP state transition */
88 short ln_state; /* reachability state */
89 short ln_router; /* 2^0: ND6 router bit */
90 int ln_byhint; /* # of times we made it reachable by UL hint */
91 u_int32_t ln_flags; /* flags; see below */
92 };
93
94 /* Values for ln_flags */
95 #define ND6_LNF_TIMER_SKIP 0x1 /* modified by nd6_timer() */
96 #define ND6_LNF_IN_USE 0x2 /* currently in llinfo_nd6 list */
97 #endif /* KERNEL_PRIVATE */
98
99 #define ND6_LLINFO_PURGE -3
100 #define ND6_LLINFO_NOSTATE -2
101 /*
102 * We don't need the WAITDELETE state any more, but we keep the definition
103 * in a comment line instead of removing it. This is necessary to avoid
104 * unintentionally reusing the value for another purpose, which might
105 * affect backward compatibility with old applications.
106 * (20000711 jinmei@kame.net)
107 */
108 /* #define ND6_LLINFO_WAITDELETE -1 */
109 #define ND6_LLINFO_INCOMPLETE 0
110 #define ND6_LLINFO_REACHABLE 1
111 #define ND6_LLINFO_STALE 2
112 #define ND6_LLINFO_DELAY 3
113 #define ND6_LLINFO_PROBE 4
114
115 #ifdef KERNEL_PRIVATE
116 #define ND6_IS_LLINFO_PROBREACH(n) ((n)->ln_state > ND6_LLINFO_INCOMPLETE)
117 #endif /* KERNEL_PRIVATE */
118
119 #if !defined(KERNEL_PRIVATE)
120 struct nd_ifinfo {
121 #else
122 /* For binary compatibility, this structure must not change */
123 struct nd_ifinfo_compat {
124 #endif /* !KERNEL_PRIVATE */
125 u_int32_t linkmtu; /* LinkMTU */
126 u_int32_t maxmtu; /* Upper bound of LinkMTU */
127 u_int32_t basereachable; /* BaseReachableTime */
128 u_int32_t reachable; /* Reachable Time */
129 u_int32_t retrans; /* Retrans Timer */
130 u_int32_t flags; /* Flags */
131 int recalctm; /* BaseReacable re-calculation timer */
132 u_int8_t chlim; /* CurHopLimit */
133 u_int8_t receivedra;
134 /* the following 3 members are for privacy extension for addrconf */
135 u_int8_t randomseed0[8]; /* upper 64 bits of MD5 digest */
136 u_int8_t randomseed1[8]; /* lower 64 bits (usually the EUI64 IFID) */
137 u_int8_t randomid[8]; /* current random ID */
138 };
139
140 #if defined(KERNEL_PRIVATE)
141 struct nd_ifinfo {
142 u_int32_t linkmtu; /* LinkMTU */
143 u_int32_t maxmtu; /* Upper bound of LinkMTU */
144 u_int32_t basereachable; /* BaseReachableTime */
145 u_int32_t reachable; /* Reachable Time */
146 u_int32_t retrans; /* Retrans Timer */
147 u_int32_t flags; /* Flags */
148 int recalctm; /* BaseReacable re-calculation timer */
149 u_int8_t chlim; /* CurHopLimit */
150 u_int8_t receivedra;
151 /* the following 3 members are for privacy extension for addrconf */
152 u_int8_t randomseed0[8]; /* upper 64 bits of MD5 digest */
153 u_int8_t randomseed1[8]; /* lower 64 bits (usually the EUI64 IFID) */
154 u_int8_t randomid[8]; /* current random ID */
155 /* keep track of routers and prefixes on this link */
156 int32_t nprefixes;
157 int32_t ndefrouters;
158 };
159 #endif /* KERNEL_PRIVATE */
160
161 #define ND6_IFF_PERFORMNUD 0x1
162
163 struct in6_nbrinfo {
164 char ifname[IFNAMSIZ]; /* if name, e.g. "en0" */
165 struct in6_addr addr; /* IPv6 address of the neighbor */
166 long asked; /* number of queries already sent for this addr */
167 int isrouter; /* if it acts as a router */
168 int state; /* reachability state */
169 int expire; /* lifetime for NDP state transition */
170 };
171
172 #if defined(KERNEL_PRIVATE)
173 struct in6_nbrinfo_32 {
174 char ifname[IFNAMSIZ];
175 struct in6_addr addr;
176 u_int32_t asked;
177 int isrouter;
178 int state;
179 int expire;
180 };
181
182 struct in6_nbrinfo_64 {
183 char ifname[IFNAMSIZ];
184 struct in6_addr addr;
185 long asked;
186 int isrouter __attribute__((aligned(8)));
187 int state;
188 int expire;
189 } __attribute__((aligned(8)));
190 #endif /* KERNEL_PRIVATE */
191
192 #define DRLSTSIZ 10
193 #define PRLSTSIZ 10
194
195 struct in6_drlist {
196 char ifname[IFNAMSIZ];
197 struct {
198 struct in6_addr rtaddr;
199 u_char flags;
200 u_short rtlifetime;
201 u_long expire;
202 u_short if_index;
203 } defrouter[DRLSTSIZ];
204 };
205
206 #if defined(KERNEL_PRIVATE)
207 struct in6_drlist_32 {
208 char ifname[IFNAMSIZ];
209 struct {
210 struct in6_addr rtaddr;
211 u_char flags;
212 u_short rtlifetime;
213 u_int32_t expire;
214 u_short if_index;
215 } defrouter[DRLSTSIZ];
216 };
217
218 struct in6_drlist_64 {
219 char ifname[IFNAMSIZ];
220 struct {
221 struct in6_addr rtaddr;
222 u_char flags;
223 u_short rtlifetime;
224 u_long expire __attribute__((aligned(8)));
225 u_short if_index __attribute__((aligned(8)));
226 } defrouter[DRLSTSIZ] __attribute__((aligned(8)));
227 };
228 #endif /* KERNEL_PRIVATE */
229
230 struct in6_defrouter {
231 struct sockaddr_in6 rtaddr;
232 u_char flags;
233 u_short rtlifetime;
234 u_long expire;
235 u_short if_index;
236 };
237
238 #if defined(KERNEL_PRIVATE)
239 struct in6_defrouter_32 {
240 struct sockaddr_in6 rtaddr;
241 u_char flags;
242 u_short rtlifetime;
243 u_int32_t expire;
244 u_short if_index;
245 };
246
247 struct in6_defrouter_64 {
248 struct sockaddr_in6 rtaddr;
249 u_char flags;
250 u_short rtlifetime;
251 u_long expire __attribute__((aligned(8)));
252 u_short if_index __attribute__((aligned(8)));
253 } __attribute__((aligned(8)));
254 #endif /* KERNEL_PRIVATE */
255
256 struct in6_prlist {
257 char ifname[IFNAMSIZ];
258 struct {
259 struct in6_addr prefix;
260 struct prf_ra raflags;
261 u_char prefixlen;
262 u_char origin;
263 u_long vltime;
264 u_long pltime;
265 u_long expire;
266 u_short if_index;
267 u_short advrtrs; /* number of advertisement routers */
268 struct in6_addr advrtr[DRLSTSIZ]; /* XXX: explicit limit */
269 } prefix[PRLSTSIZ];
270 };
271
272 #if defined(KERNEL_PRIVATE)
273 struct in6_prlist_32 {
274 char ifname[IFNAMSIZ];
275 struct {
276 struct in6_addr prefix;
277 struct prf_ra raflags;
278 u_char prefixlen;
279 u_char origin;
280 u_int32_t vltime;
281 u_int32_t pltime;
282 u_int32_t expire;
283 u_short if_index;
284 u_short advrtrs;
285 struct in6_addr advrtr[DRLSTSIZ];
286 } prefix[PRLSTSIZ];
287 };
288
289 struct in6_prlist_64 {
290 char ifname[IFNAMSIZ];
291 struct {
292 struct in6_addr prefix;
293 struct prf_ra raflags;
294 u_char prefixlen;
295 u_char origin;
296 u_long vltime __attribute__((aligned(8)));
297 u_long pltime __attribute__((aligned(8)));
298 u_long expire __attribute__((aligned(8)));
299 u_short if_index;
300 u_short advrtrs;
301 u_int32_t pad;
302 struct in6_addr advrtr[DRLSTSIZ];
303 } prefix[PRLSTSIZ];
304 };
305 #endif /* KERNEL_PRIVATE */
306
307 struct in6_prefix {
308 struct sockaddr_in6 prefix;
309 struct prf_ra raflags;
310 u_char prefixlen;
311 u_char origin;
312 u_long vltime;
313 u_long pltime;
314 u_long expire;
315 u_int32_t flags;
316 int refcnt;
317 u_short if_index;
318 u_short advrtrs; /* number of advertisement routers */
319 /* struct sockaddr_in6 advrtr[] */
320 };
321
322 #if defined(KERNEL_PRIVATE)
323 struct in6_prefix_32 {
324 struct sockaddr_in6 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_int32_t flags;
332 int refcnt;
333 u_short if_index;
334 u_short advrtrs;
335 /* struct sockaddr_in6 advrtr[] */
336 };
337
338 struct in6_prefix_64 {
339 struct sockaddr_in6 prefix;
340 struct prf_ra raflags;
341 u_char prefixlen;
342 u_char origin;
343 u_long vltime __attribute__((aligned(8)));
344 u_long pltime __attribute__((aligned(8)));
345 u_long expire __attribute__((aligned(8)));
346 u_int32_t flags __attribute__((aligned(8)));
347 int refcnt;
348 u_short if_index;
349 u_short advrtrs;
350 /* struct sockaddr_in6 advrtr[] */
351 };
352 #endif /* KERNEL_PRIVATE */
353
354 struct in6_ondireq {
355 char ifname[IFNAMSIZ];
356 struct {
357 u_int32_t linkmtu; /* LinkMTU */
358 u_int32_t maxmtu; /* Upper bound of LinkMTU */
359 u_int32_t basereachable; /* BaseReachableTime */
360 u_int32_t reachable; /* Reachable Time */
361 u_int32_t retrans; /* Retrans Timer */
362 u_int32_t flags; /* Flags */
363 int recalctm; /* BaseReacable re-calculation timer */
364 u_int8_t chlim; /* CurHopLimit */
365 u_int8_t receivedra;
366 } ndi;
367 };
368
369 #if !defined(KERNEL_PRIVATE)
370 struct in6_ndireq {
371 char ifname[IFNAMSIZ];
372 struct nd_ifinfo ndi;
373 };
374 #else
375 struct in6_ndireq {
376 char ifname[IFNAMSIZ];
377 struct nd_ifinfo_compat ndi;
378 };
379 #endif /* !KERNEL_PRIVATE */
380
381 struct in6_ndifreq {
382 char ifname[IFNAMSIZ];
383 u_long ifindex;
384 };
385
386 #if defined(KERNEL_PRIVATE)
387 struct in6_ndifreq_32 {
388 char ifname[IFNAMSIZ];
389 u_int32_t ifindex;
390 };
391
392 struct in6_ndifreq_64 {
393 char ifname[IFNAMSIZ];
394 u_long ifindex __attribute__((aligned(8)));
395 };
396 #endif /* KERNEL_PRIVATE */
397
398 /* Prefix status */
399 #define NDPRF_ONLINK 0x1
400 #define NDPRF_DETACHED 0x2
401
402 /* protocol constants */
403 #define MAX_RTR_SOLICITATION_DELAY 1 /*1sec*/
404 #define RTR_SOLICITATION_INTERVAL 4 /*4sec*/
405 #define MAX_RTR_SOLICITATIONS 3
406
407 #define ND6_INFINITE_LIFETIME 0xffffffff
408
409 #ifdef KERNEL_PRIVATE
410 /*
411 * Protects nd_ifinfo[]
412 */
413 __private_extern__ lck_rw_t *nd_if_rwlock;
414
415 #define ND_IFINFO(ifp) \
416 ((ifp)->if_index < nd_ifinfo_indexlim ? &nd_ifinfo[(ifp)->if_index] : NULL)
417
418 /*
419 * In a more readable form, we derive linkmtu based on:
420 *
421 * if (ND_IFINFO(ifp)->linkmtu && ND_IFINFO(ifp)->linkmtu < ifp->if_mtu)
422 * linkmtu = ND_IFINFO(ifp)->linkmtu;
423 * else if ((ND_IFINFO(ifp)->maxmtu && ND_IFINFO(ifp)->maxmtu < ifp->if_mtu))
424 * linkmtu = ND_IFINFO(ifp)->maxmtu;
425 * else
426 * linkmtu = ifp->if_mtu;
427 */
428 #define IN6_LINKMTU(ifp) \
429 (ND_IFINFO(ifp) == NULL ? (ifp)->if_mtu : \
430 ((ND_IFINFO(ifp)->linkmtu && \
431 ND_IFINFO(ifp)->linkmtu < (ifp)->if_mtu) ? ND_IFINFO(ifp)->linkmtu : \
432 ((ND_IFINFO(ifp)->maxmtu && ND_IFINFO(ifp)->maxmtu < (ifp)->if_mtu) ? \
433 ND_IFINFO(ifp)->maxmtu : (ifp)->if_mtu)))
434
435 /* node constants */
436 #define MAX_REACHABLE_TIME 3600000 /* msec */
437 #define REACHABLE_TIME 30000 /* msec */
438 #define RETRANS_TIMER 1000 /* msec */
439 #define MIN_RANDOM_FACTOR 512 /* 1024 * 0.5 */
440 #define MAX_RANDOM_FACTOR 1536 /* 1024 * 1.5 */
441 #define DEF_TEMP_VALID_LIFETIME 604800 /* 1 week */
442 #define DEF_TEMP_PREFERRED_LIFETIME 86400 /* 1 day */
443 #define TEMPADDR_REGEN_ADVANCE 5 /* sec */
444 #define MAX_TEMP_DESYNC_FACTOR 600 /* 10 min */
445 #define ND_COMPUTE_RTIME(x) \
446 (((MIN_RANDOM_FACTOR * (x >> 10)) + (random() & \
447 ((MAX_RANDOM_FACTOR - MIN_RANDOM_FACTOR) * (x >> 10)))) /1000)
448
449 TAILQ_HEAD(nd_drhead, nd_defrouter);
450 struct nd_defrouter {
451 TAILQ_ENTRY(nd_defrouter) dr_entry;
452 struct in6_addr rtaddr;
453 u_char flags; /* flags on RA message */
454 u_short rtlifetime;
455 u_int32_t expire;
456 u_int32_t advint; /* Mobile IPv6 addition (milliseconds) */
457 u_int32_t advint_expire; /* Mobile IPv6 addition */
458 int advints_lost; /* Mobile IPv6 addition */
459 struct ifnet *ifp;
460 };
461
462 struct nd_prefix {
463 struct ifnet *ndpr_ifp;
464 LIST_ENTRY(nd_prefix) ndpr_entry;
465 struct sockaddr_in6 ndpr_prefix; /* prefix */
466 struct in6_addr ndpr_mask; /* netmask derived from the prefix */
467 struct in6_addr ndpr_addr; /* address that is derived from the prefix */
468 u_int32_t ndpr_vltime; /* advertised valid lifetime */
469 u_int32_t ndpr_pltime; /* advertised preferred lifetime */
470 time_t ndpr_expire; /* expiration time of the prefix */
471 time_t ndpr_preferred; /* preferred time of the prefix */
472 struct prf_ra ndpr_flags;
473 u_int32_t ndpr_stateflags; /* actual state flags */
474 /* list of routers that advertise the prefix: */
475 LIST_HEAD(pr_rtrhead, nd_pfxrouter) ndpr_advrtrs;
476 u_char ndpr_plen;
477 int ndpr_refcnt; /* reference counter from addresses */
478 int ndpr_usecnt; /* actual use count; prevents free */
479 };
480
481 #define ndpr_next ndpr_entry.le_next
482
483 #define ndpr_raf ndpr_flags
484 #define ndpr_raf_onlink ndpr_flags.onlink
485 #define ndpr_raf_auto ndpr_flags.autonomous
486
487 /*
488 * We keep expired prefix for certain amount of time, for validation purposes.
489 * 1800s = MaxRtrAdvInterval
490 */
491 #define NDPR_KEEP_EXPIRED (1800 * 2)
492
493 /*
494 * Message format for use in obtaining information about prefixes
495 * from inet6 sysctl function
496 */
497 struct inet6_ndpr_msghdr {
498 u_short inpm_msglen; /* to skip over non-understood messages */
499 u_char inpm_version; /* future binary compatibility */
500 u_char inpm_type; /* message type */
501 struct in6_addr inpm_prefix;
502 u_int32_t prm_vltim;
503 u_int32_t prm_pltime;
504 u_int32_t prm_expire;
505 u_int32_t prm_preferred;
506 struct in6_prflags prm_flags;
507 u_short prm_index; /* index for associated ifp */
508 u_char prm_plen; /* length of prefix in bits */
509 };
510
511 #define prm_raf_onlink prm_flags.prf_ra.onlink
512 #define prm_raf_auto prm_flags.prf_ra.autonomous
513
514 #define prm_statef_onlink prm_flags.prf_state.onlink
515
516 #define prm_rrf_decrvalid prm_flags.prf_rr.decrvalid
517 #define prm_rrf_decrprefd prm_flags.prf_rr.decrprefd
518
519 #define ifpr2ndpr(ifpr) ((struct nd_prefix *)(ifpr))
520 #define ndpr2ifpr(ndpr) ((struct ifprefix *)(ndpr))
521
522 struct nd_pfxrouter {
523 LIST_ENTRY(nd_pfxrouter) pfr_entry;
524 #define pfr_next pfr_entry.le_next
525 struct nd_defrouter *router;
526 };
527
528 LIST_HEAD(nd_prhead, nd_prefix);
529
530 /* nd6.c */
531 extern int nd6_prune;
532 extern int nd6_delay;
533 extern int nd6_umaxtries;
534 extern int nd6_mmaxtries;
535 extern int nd6_useloopback;
536 extern int nd6_maxnudhint;
537 extern int nd6_gctimer;
538 extern struct llinfo_nd6 llinfo_nd6;
539 extern struct nd_ifinfo *nd_ifinfo;
540 extern struct nd_drhead nd_defrouter;
541 extern struct nd_prhead nd_prefix;
542 extern int nd6_debug;
543 extern size_t nd_ifinfo_indexlim;
544
545 #define nd6log(x) do { if (nd6_debug) log x; } while (0)
546
547 extern struct callout nd6_timer_ch;
548
549 /* nd6_rtr.c */
550 extern int nd6_defifindex;
551 extern int ip6_desync_factor; /* seconds */
552 extern u_int32_t ip6_temp_preferred_lifetime; /* seconds */
553 extern u_int32_t ip6_temp_valid_lifetime; /* seconds */
554 extern int ip6_temp_regen_advance; /* seconds */
555
556 union nd_opts {
557 struct nd_opt_hdr *nd_opt_array[9]; /*max = home agent info*/
558 struct {
559 struct nd_opt_hdr *zero;
560 struct nd_opt_hdr *src_lladdr;
561 struct nd_opt_hdr *tgt_lladdr;
562 struct nd_opt_prefix_info *pi_beg; /* multiple opts, start */
563 struct nd_opt_rd_hdr *rh;
564 struct nd_opt_mtu *mtu;
565 struct nd_opt_hdr *six;
566 struct nd_opt_advint *adv;
567 struct nd_opt_hai *hai;
568 struct nd_opt_hdr *search; /* multiple opts */
569 struct nd_opt_hdr *last; /* multiple opts */
570 int done;
571 struct nd_opt_prefix_info *pi_end;/* multiple opts, end */
572 } nd_opt_each;
573 };
574 #define nd_opts_src_lladdr nd_opt_each.src_lladdr
575 #define nd_opts_tgt_lladdr nd_opt_each.tgt_lladdr
576 #define nd_opts_pi nd_opt_each.pi_beg
577 #define nd_opts_pi_end nd_opt_each.pi_end
578 #define nd_opts_rh nd_opt_each.rh
579 #define nd_opts_mtu nd_opt_each.mtu
580 #define nd_opts_adv nd_opt_each.adv
581 #define nd_opts_hai nd_opt_each.hai
582 #define nd_opts_search nd_opt_each.search
583 #define nd_opts_last nd_opt_each.last
584 #define nd_opts_done nd_opt_each.done
585
586 /* XXX: need nd6_var.h?? */
587 /* nd6.c */
588 extern void nd6_init(void);
589 extern int nd6_ifattach(struct ifnet *);
590 extern int nd6_is_addr_neighbor(struct sockaddr_in6 *, struct ifnet *, int);
591 extern void nd6_option_init(void *, int, union nd_opts *);
592 extern struct nd_opt_hdr *nd6_option(union nd_opts *);
593 extern int nd6_options(union nd_opts *);
594 extern struct rtentry *nd6_lookup(struct in6_addr *, int, struct ifnet *, int);
595 extern void nd6_setmtu(struct ifnet *);
596 extern void nd6_timer(void *);
597 extern void nd6_purge(struct ifnet *);
598 extern void nd6_free(struct rtentry *);
599 extern void nd6_nud_hint(struct rtentry *, struct in6_addr *, int);
600 extern int nd6_resolve(struct ifnet *, struct rtentry *,
601 struct mbuf *, struct sockaddr *, u_char *);
602 extern void nd6_rtrequest(int, struct rtentry *, struct sockaddr *);
603 extern int nd6_ioctl(u_long, caddr_t, struct ifnet *);
604 extern void nd6_cache_lladdr(struct ifnet *, struct in6_addr *,
605 char *, int, int, int);
606 extern int nd6_output(struct ifnet *, struct ifnet *, struct mbuf *,
607 struct sockaddr_in6 *, struct rtentry *, int);
608 extern int nd6_storelladdr(struct ifnet *, struct rtentry *, struct mbuf *,
609 struct sockaddr *, u_char *);
610 extern int nd6_need_cache(struct ifnet *);
611 extern void nd6_drain(void *);
612
613 /* nd6_nbr.c */
614 extern void nd6_na_input(struct mbuf *, int, int);
615 extern void nd6_na_output(struct ifnet *, const struct in6_addr *,
616 const struct in6_addr *, u_int32_t, int, struct sockaddr *);
617 extern void nd6_ns_input(struct mbuf *, int, int);
618 extern void nd6_ns_output(struct ifnet *, const struct in6_addr *,
619 const struct in6_addr *, struct llinfo_nd6 *, int, int);
620 extern caddr_t nd6_ifptomac(struct ifnet *);
621 extern void nd6_dad_start(struct ifaddr *, int *);
622 extern void nd6_dad_stop(struct ifaddr *);
623 extern void nd6_dad_duplicated(struct ifaddr *);
624
625 /* nd6_rtr.c */
626 extern void nd6_rs_input(struct mbuf *, int, int);
627 extern void nd6_ra_input(struct mbuf *, int, int);
628 extern void prelist_del(struct nd_prefix *);
629 extern void defrouter_addreq(struct nd_defrouter *);
630 extern void defrouter_delreq(struct nd_defrouter *, int);
631 extern void defrouter_select(void);
632 extern void defrtrlist_del(struct nd_defrouter *, int);
633 extern void prelist_remove(struct nd_prefix *, int);
634 extern int prelist_update(struct nd_prefix *, struct nd_defrouter *,
635 struct mbuf *);
636 extern int nd6_prelist_add(struct nd_prefix *, struct nd_defrouter *,
637 struct nd_prefix **);
638 extern int nd6_prefix_onlink(struct nd_prefix *, int, int);
639 extern int nd6_prefix_offlink(struct nd_prefix *);
640 extern void pfxlist_onlink_check(int);
641 extern struct nd_defrouter *defrouter_lookup(struct in6_addr *, struct ifnet *);
642 extern struct nd_prefix *nd6_prefix_lookup(struct nd_prefix *);
643 extern int in6_init_prefix_ltimes(struct nd_prefix *ndpr);
644 extern void rt6_flush(struct in6_addr *, struct ifnet *);
645 extern int nd6_setdefaultiface(int);
646 extern int in6_tmpifadd(const struct in6_ifaddr *, int, int);
647 extern void ndpr_hold(struct nd_prefix *, boolean_t);
648 extern void ndpr_rele(struct nd_prefix *, boolean_t);
649 #endif /* KERNEL_PRIVATE */
650
651 #ifdef KERNEL
652
653 /*!
654 @function nd6_lookup_ipv6
655 @discussion This function will check the routing table for a cached
656 neighbor discovery entry or trigger an neighbor discovery query
657 to resolve the IPv6 address to a link-layer address.
658
659 nd entries are stored in the routing table. This function will
660 lookup the IPv6 destination in the routing table. If the
661 destination requires forwarding to a gateway, the route of the
662 gateway will be looked up. The route entry is inspected to
663 determine if the link layer destination address is known. If
664 unknown, neighbor discovery will be used to resolve the entry.
665 @param interface The interface the packet is being sent on.
666 @param ip6_dest The IPv6 destination of the packet.
667 @param ll_dest On output, the link-layer destination.
668 @param ll_dest_len The length of the buffer for ll_dest.
669 @param hint Any routing hint passed down from the protocol.
670 @param packet The packet being transmitted.
671 @result May return an error such as EHOSTDOWN or ENETUNREACH. If
672 this function returns EJUSTRETURN, the packet has been queued
673 and will be sent when the address is resolved. If any other
674 value is returned, the caller is responsible for disposing of
675 the packet.
676 */
677 extern errno_t nd6_lookup_ipv6(ifnet_t interface,
678 const struct sockaddr_in6 *ip6_dest, struct sockaddr_dl *ll_dest,
679 size_t ll_dest_len, route_t hint, mbuf_t packet);
680
681 #endif /* KERNEL */
682 #endif /* _NETINET6_ND6_H_ */