2 * Copyright (c) 2000-2011 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
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 $ */
33 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
34 * All rights reserved.
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
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.
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
61 #ifndef _NETINET6_ND6_H_
62 #define _NETINET6_ND6_H_
63 #include <sys/appleapiopts.h>
65 /* see net/route.h, or net/if_inarp.h */
67 #define RTF_ANNOUNCE RTF_PROTO2
70 #include <sys/queue.h>
72 #ifdef XNU_KERNEL_PRIVATE
73 #include <kern/locks.h>
77 * The following are protected by rnh_lock
79 struct llinfo_nd6
*ln_next
;
80 struct llinfo_nd6
*ln_prev
;
81 struct rtentry
*ln_rt
;
83 * The following are protected by rt_lock
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 struct if_llreach
*ln_llreach
; /* link-layer reachability record */
93 u_int64_t ln_lastused
; /* last used timestamp */
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 /* XNU_KERNEL_PRIVATE */
101 #define ND6_LLINFO_PURGE -3
102 #define ND6_LLINFO_NOSTATE -2
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)
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
117 #ifdef XNU_KERNEL_PRIVATE
118 #define ND6_IS_LLINFO_PROBREACH(n) ((n)->ln_state > ND6_LLINFO_INCOMPLETE)
119 #define ND6_LLINFO_PERMANENT(n) (((n)->ln_expire == 0) && ((n)->ln_state > ND6_LLINFO_INCOMPLETE))
120 #define ND6_IFF_PERFORMNUD 0x1
121 #define ND6_IFF_ACCEPT_RTADV 0x2 /* APPLE: not used. Innterface specific router advertisments are
122 * handled with a specific ifnet flag: IFEF_ACCEPT_RTADVD
124 #define ND6_IFF_PREFER_SOURCE 0x4 /* APPLE: NOT USED not related to ND. */
125 #define ND6_IFF_IFDISABLED 0x8 /* IPv6 operation is disabled due to
126 * DAD failure. (XXX: not ND-specific)
128 #define ND6_IFF_DONT_SET_IFROUTE 0x10 /* NOT USED */
130 #endif /* XNU_KERNEL_PRIVATE */
132 #if !defined(XNU_KERNEL_PRIVATE)
135 /* For binary compatibility, this structure must not change */
136 struct nd_ifinfo_compat
{
137 #endif /* !XNU_KERNEL_PRIVATE */
138 u_int32_t linkmtu
; /* LinkMTU */
139 u_int32_t maxmtu
; /* Upper bound of LinkMTU */
140 u_int32_t basereachable
; /* BaseReachableTime */
141 u_int32_t reachable
; /* Reachable Time */
142 u_int32_t retrans
; /* Retrans Timer */
143 u_int32_t flags
; /* Flags */
144 int recalctm
; /* BaseReacable re-calculation timer */
145 u_int8_t chlim
; /* CurHopLimit */
147 /* the following 3 members are for privacy extension for addrconf */
148 u_int8_t randomseed0
[8]; /* upper 64 bits of MD5 digest */
149 u_int8_t randomseed1
[8]; /* lower 64 bits (usually the EUI64 IFID) */
150 u_int8_t randomid
[8]; /* current random ID */
153 #if defined(XNU_KERNEL_PRIVATE)
155 u_int32_t linkmtu
; /* LinkMTU */
156 u_int32_t maxmtu
; /* Upper bound of LinkMTU */
157 u_int32_t basereachable
; /* BaseReachableTime */
158 u_int32_t reachable
; /* Reachable Time */
159 u_int32_t retrans
; /* Retrans Timer */
160 u_int32_t flags
; /* Flags */
161 int recalctm
; /* BaseReacable re-calculation timer */
162 u_int8_t chlim
; /* CurHopLimit */
163 u_int8_t initialized
; /* Flag to see the entry is initialized */
164 /* the following 3 members are for privacy extension for addrconf */
165 u_int8_t randomseed0
[8]; /* upper 64 bits of MD5 digest */
166 u_int8_t randomseed1
[8]; /* lower 64 bits (usually the EUI64 IFID) */
167 u_int8_t randomid
[8]; /* current random ID */
168 /* keep track of routers and prefixes on this link */
172 #endif /* XNU_KERNEL_PRIVATE */
174 #define ND6_IFF_PERFORMNUD 0x1
177 char ifname
[IFNAMSIZ
]; /* if name, e.g. "en0" */
178 struct in6_addr addr
; /* IPv6 address of the neighbor */
179 long asked
; /* number of queries already sent for this addr */
180 int isrouter
; /* if it acts as a router */
181 int state
; /* reachability state */
182 int expire
; /* lifetime for NDP state transition */
185 #if defined(XNU_KERNEL_PRIVATE)
186 struct in6_nbrinfo_32
{
187 char ifname
[IFNAMSIZ
];
188 struct in6_addr addr
;
195 struct in6_nbrinfo_64
{
196 char ifname
[IFNAMSIZ
];
197 struct in6_addr addr
;
199 int isrouter
__attribute__((aligned(8)));
202 } __attribute__((aligned(8)));
203 #endif /* XNU_KERNEL_PRIVATE */
209 char ifname
[IFNAMSIZ
];
211 struct in6_addr rtaddr
;
216 } defrouter
[DRLSTSIZ
];
219 #if defined(XNU_KERNEL_PRIVATE)
220 struct in6_drlist_32
{
221 char ifname
[IFNAMSIZ
];
223 struct in6_addr rtaddr
;
228 } defrouter
[DRLSTSIZ
];
231 struct in6_drlist_64
{
232 char ifname
[IFNAMSIZ
];
234 struct in6_addr rtaddr
;
237 u_long expire
__attribute__((aligned(8)));
238 u_short if_index
__attribute__((aligned(8)));
239 } defrouter
[DRLSTSIZ
] __attribute__((aligned(8)));
241 #endif /* XNU_KERNEL_PRIVATE */
243 /* valid values for stateflags */
244 #define NDDRF_INSTALLED 0x1 /* installed in the routing table */
245 #define NDDRF_IFSCOPE 0x2 /* installed as a scoped route */
246 #define NDDRF_STATIC 0x4 /* for internal use only */
247 #ifdef XNU_KERNEL_PRIVATE
248 #define NDDRF_PROCESSED 0x10
251 struct in6_defrouter
{
252 struct sockaddr_in6 rtaddr
;
260 #if defined(XNU_KERNEL_PRIVATE)
261 struct in6_defrouter_32
{
262 struct sockaddr_in6 rtaddr
;
270 struct in6_defrouter_64
{
271 struct sockaddr_in6 rtaddr
;
275 u_long expire
__attribute__((aligned(8)));
276 u_short if_index
__attribute__((aligned(8)));
277 } __attribute__((aligned(8)));
278 #endif /* XNU_KERNEL_PRIVATE */
281 char ifname
[IFNAMSIZ
];
283 struct in6_addr prefix
;
284 struct prf_ra raflags
;
291 u_short advrtrs
; /* number of advertisement routers */
292 struct in6_addr advrtr
[DRLSTSIZ
]; /* XXX: explicit limit */
296 #if defined(XNU_KERNEL_PRIVATE)
297 struct in6_prlist_32
{
298 char ifname
[IFNAMSIZ
];
300 struct in6_addr prefix
;
301 struct prf_ra raflags
;
309 struct in6_addr advrtr
[DRLSTSIZ
];
313 struct in6_prlist_64
{
314 char ifname
[IFNAMSIZ
];
316 struct in6_addr prefix
;
317 struct prf_ra raflags
;
320 u_long vltime
__attribute__((aligned(8)));
321 u_long pltime
__attribute__((aligned(8)));
322 u_long expire
__attribute__((aligned(8)));
326 struct in6_addr advrtr
[DRLSTSIZ
];
329 #endif /* XNU_KERNEL_PRIVATE */
332 struct sockaddr_in6 prefix
;
333 struct prf_ra raflags
;
342 u_short advrtrs
; /* number of advertisement routers */
343 /* struct sockaddr_in6 advrtr[] */
346 #if defined(XNU_KERNEL_PRIVATE)
347 struct in6_prefix_32
{
348 struct sockaddr_in6 prefix
;
349 struct prf_ra raflags
;
358 u_short advrtrs
; /* number of advertisement routers */
359 /* struct sockaddr_in6 advrtr[] */
362 struct in6_prefix_64
{
363 struct sockaddr_in6 prefix
;
364 struct prf_ra raflags
;
367 u_long vltime
__attribute__((aligned(8)));
368 u_long pltime
__attribute__((aligned(8)));
369 u_long expire
__attribute__((aligned(8)));
370 u_int32_t flags
__attribute__((aligned(8)));
374 /* struct sockaddr_in6 advrtr[] */
376 #endif /* XNU_KERNEL_PRIVATE */
379 char ifname
[IFNAMSIZ
];
381 u_int32_t linkmtu
; /* LinkMTU */
382 u_int32_t maxmtu
; /* Upper bound of LinkMTU */
383 u_int32_t basereachable
; /* BaseReachableTime */
384 u_int32_t reachable
; /* Reachable Time */
385 u_int32_t retrans
; /* Retrans Timer */
386 u_int32_t flags
; /* Flags */
387 int recalctm
; /* BaseReacable re-calculation timer */
388 u_int8_t chlim
; /* CurHopLimit */
393 #if !defined(XNU_KERNEL_PRIVATE)
395 char ifname
[IFNAMSIZ
];
396 struct nd_ifinfo ndi
;
400 char ifname
[IFNAMSIZ
];
401 struct nd_ifinfo_compat ndi
;
403 #endif /* !XNU_KERNEL_PRIVATE */
406 char ifname
[IFNAMSIZ
];
410 #define MAX_RTR_SOLICITATION_DELAY 1 /* 1sec */
411 #define RTR_SOLICITATION_INTERVAL 4 /* 4sec */
413 #if defined(XNU_KERNEL_PRIVATE)
414 struct in6_ndifreq_32
{
415 char ifname
[IFNAMSIZ
];
419 struct in6_ndifreq_64
{
420 char ifname
[IFNAMSIZ
];
421 u_long ifindex
__attribute__((aligned(8)));
423 #endif /* XNU_KERNEL_PRIVATE */
426 #define NDPRF_ONLINK 0x1
427 #define NDPRF_DETACHED 0x2
428 #define NDPRF_STATIC 0x100
429 #define NDPRF_IFSCOPE 0x1000
430 #ifdef XNU_KERNEL_PRIVATE
431 #define NDPRF_PROCESSED 0x08000
434 /* protocol constants */
435 #define MAX_RTR_SOLICITATION_DELAY 1 /*1sec*/
436 #define RTR_SOLICITATION_INTERVAL 4 /*4sec*/
437 #define MAX_RTR_SOLICITATIONS 3
439 #define ND6_INFINITE_LIFETIME 0xffffffff
440 #define ND6_MAX_LIFETIME 0x7fffffff
442 #ifdef XNU_KERNEL_PRIVATE
444 * Protects nd_ifinfo[]
446 __private_extern__ lck_rw_t
*nd_if_rwlock
;
448 #define ND_IFINFO(ifp) \
449 ((ifp)->if_index < nd_ifinfo_indexlim ? &nd_ifinfo[(ifp)->if_index] : NULL)
452 * In a more readable form, we derive linkmtu based on:
454 * if (ND_IFINFO(ifp)->linkmtu && ND_IFINFO(ifp)->linkmtu < ifp->if_mtu)
455 * linkmtu = ND_IFINFO(ifp)->linkmtu;
456 * else if ((ND_IFINFO(ifp)->maxmtu && ND_IFINFO(ifp)->maxmtu < ifp->if_mtu))
457 * linkmtu = ND_IFINFO(ifp)->maxmtu;
459 * linkmtu = ifp->if_mtu;
461 #define IN6_LINKMTU(ifp) \
462 (ND_IFINFO(ifp) == NULL ? (ifp)->if_mtu : \
463 ((ND_IFINFO(ifp)->linkmtu && \
464 ND_IFINFO(ifp)->linkmtu < (ifp)->if_mtu) ? ND_IFINFO(ifp)->linkmtu : \
465 ((ND_IFINFO(ifp)->maxmtu && ND_IFINFO(ifp)->maxmtu < (ifp)->if_mtu) ? \
466 ND_IFINFO(ifp)->maxmtu : (ifp)->if_mtu)))
469 #define MAX_REACHABLE_TIME 3600000 /* msec */
470 #define REACHABLE_TIME 30000 /* msec */
471 #define RETRANS_TIMER 1000 /* msec */
472 #define MIN_RANDOM_FACTOR 512 /* 1024 * 0.5 */
473 #define MAX_RANDOM_FACTOR 1536 /* 1024 * 1.5 */
474 #define DEF_TEMP_VALID_LIFETIME 604800 /* 1 week */
475 #define DEF_TEMP_PREFERRED_LIFETIME 86400 /* 1 day */
476 #define TEMPADDR_REGEN_ADVANCE 5 /* sec */
477 #define MAX_TEMP_DESYNC_FACTOR 600 /* 10 min */
478 #define ND_COMPUTE_RTIME(x) \
479 (((MIN_RANDOM_FACTOR * (x >> 10)) + (random() & \
480 ((MAX_RANDOM_FACTOR - MIN_RANDOM_FACTOR) * (x >> 10)))) /1000)
482 TAILQ_HEAD(nd_drhead
, nd_defrouter
);
483 struct nd_defrouter
{
484 decl_lck_mtx_data(, nddr_lock
);
485 uint32_t nddr_refcount
;
487 TAILQ_ENTRY(nd_defrouter
) dr_entry
;
488 struct in6_addr rtaddr
;
489 u_char flags
; /* flags on RA message */
496 void (*nddr_trace
) /* callback fn for tracing refs */
497 (struct nd_defrouter
*, int);
500 #define NDDR_LOCK_ASSERT_HELD(_nddr) \
501 lck_mtx_assert(&(_nddr)->nddr_lock, LCK_MTX_ASSERT_OWNED)
503 #define NDDR_LOCK_ASSERT_NOTHELD(_nddr) \
504 lck_mtx_assert(&(_nddr)->nddr_lock, LCK_MTX_ASSERT_NOTOWNED)
506 #define NDDR_LOCK(_nddr) \
507 lck_mtx_lock(&(_nddr)->nddr_lock)
509 #define NDDR_LOCK_SPIN(_nddr) \
510 lck_mtx_lock_spin(&(_nddr)->nddr_lock)
512 #define NDDR_CONVERT_LOCK(_nddr) do { \
513 NDPR_LOCK_ASSERT_HELD(_nddr); \
514 lck_mtx_convert_spin(&(_nddr)->nddr_lock); \
517 #define NDDR_UNLOCK(_nddr) \
518 lck_mtx_unlock(&(_nddr)->nddr_lock)
520 #define NDDR_ADDREF(_nddr) \
521 nddr_addref(_nddr, 0)
523 #define NDDR_ADDREF_LOCKED(_nddr) \
524 nddr_addref(_nddr, 1)
526 #define NDDR_REMREF(_nddr) do { \
527 (void) nddr_remref(_nddr, 0); \
530 #define NDDR_REMREF_LOCKED(_nddr) \
531 nddr_remref(_nddr, 1)
534 decl_lck_mtx_data(, ndpr_lock
);
535 u_int32_t ndpr_refcount
; /* reference count */
536 u_int32_t ndpr_debug
; /* see ifa_debug flags */
537 struct ifnet
*ndpr_ifp
;
538 LIST_ENTRY(nd_prefix
) ndpr_entry
;
539 struct sockaddr_in6 ndpr_prefix
; /* prefix */
540 struct in6_addr ndpr_mask
; /* netmask derived from the prefix */
541 struct in6_addr ndpr_addr
; /* address that is derived from the prefix */
542 u_int32_t ndpr_vltime
; /* advertised valid lifetime */
543 u_int32_t ndpr_pltime
; /* advertised preferred lifetime */
544 time_t ndpr_preferred
; /* preferred time of the prefix */
545 time_t ndpr_expire
; /* expiration time of the prefix */
546 time_t ndpr_lastupdate
; /* reception time of last advertisement */
547 struct prf_ra ndpr_flags
;
548 u_int32_t ndpr_stateflags
; /* actual state flags */
549 /* list of routers that advertise the prefix: */
550 LIST_HEAD(pr_rtrhead
, nd_pfxrouter
) ndpr_advrtrs
;
552 int ndpr_addrcnt
; /* reference counter from addresses */
553 void (*ndpr_trace
) /* callback fn for tracing refs */
554 (struct nd_prefix
*, int);
557 #define ndpr_next ndpr_entry.le_next
559 #define ndpr_raf ndpr_flags
560 #define ndpr_raf_onlink ndpr_flags.onlink
561 #define ndpr_raf_auto ndpr_flags.autonomous
562 #define ndpr_raf_router ndpr_flags.router
564 * We keep expired prefix for certain amount of time, for validation purposes.
565 * 1800s = MaxRtrAdvInterval
567 #define NDPR_KEEP_EXPIRED (1800 * 2)
569 #define NDPR_LOCK_ASSERT_HELD(_ndpr) \
570 lck_mtx_assert(&(_ndpr)->ndpr_lock, LCK_MTX_ASSERT_OWNED)
572 #define NDPR_LOCK_ASSERT_NOTHELD(_ndpr) \
573 lck_mtx_assert(&(_ndpr)->ndpr_lock, LCK_MTX_ASSERT_NOTOWNED)
575 #define NDPR_LOCK(_ndpr) \
576 lck_mtx_lock(&(_ndpr)->ndpr_lock)
578 #define NDPR_LOCK_SPIN(_ndpr) \
579 lck_mtx_lock_spin(&(_ndpr)->ndpr_lock)
581 #define NDPR_CONVERT_LOCK(_ndpr) do { \
582 NDPR_LOCK_ASSERT_HELD(_ndpr); \
583 lck_mtx_convert_spin(&(_ndpr)->ndpr_lock); \
586 #define NDPR_UNLOCK(_ndpr) \
587 lck_mtx_unlock(&(_ndpr)->ndpr_lock)
589 #define NDPR_ADDREF(_ndpr) \
590 ndpr_addref(_ndpr, 0)
592 #define NDPR_ADDREF_LOCKED(_ndpr) \
593 ndpr_addref(_ndpr, 1)
595 #define NDPR_REMREF(_ndpr) do { \
596 (void) ndpr_remref(_ndpr, 0); \
599 #define NDPR_REMREF_LOCKED(_ndpr) \
600 ndpr_remref(_ndpr, 1)
603 * Message format for use in obtaining information about prefixes
604 * from inet6 sysctl function
606 struct inet6_ndpr_msghdr
{
607 u_short inpm_msglen
; /* to skip over non-understood messages */
608 u_char inpm_version
; /* future binary compatibility */
609 u_char inpm_type
; /* message type */
610 struct in6_addr inpm_prefix
;
612 u_int32_t prm_pltime
;
613 u_int32_t prm_expire
;
614 u_int32_t prm_preferred
;
615 struct in6_prflags prm_flags
;
616 u_short prm_index
; /* index for associated ifp */
617 u_char prm_plen
; /* length of prefix in bits */
620 #define prm_raf_onlink prm_flags.prf_ra.onlink
621 #define prm_raf_auto prm_flags.prf_ra.autonomous
623 #define prm_statef_onlink prm_flags.prf_state.onlink
625 #define prm_rrf_decrvalid prm_flags.prf_rr.decrvalid
626 #define prm_rrf_decrprefd prm_flags.prf_rr.decrprefd
628 #define ifpr2ndpr(ifpr) ((struct nd_prefix *)(ifpr))
629 #define ndpr2ifpr(ndpr) ((struct ifprefix *)(ndpr))
631 struct nd_pfxrouter
{
632 LIST_ENTRY(nd_pfxrouter
) pfr_entry
;
633 #define pfr_next pfr_entry.le_next
634 struct nd_defrouter
*router
;
637 LIST_HEAD(nd_prhead
, nd_prefix
);
640 extern int nd6_prune
;
641 extern int nd6_delay
;
642 extern int nd6_umaxtries
;
643 extern int nd6_mmaxtries
;
644 extern int nd6_useloopback
;
645 extern int nd6_accept_6to4
;
646 extern int nd6_maxnudhint
;
647 extern int nd6_gctimer
;
648 extern struct llinfo_nd6 llinfo_nd6
;
649 extern struct nd_ifinfo
*nd_ifinfo
;
650 extern struct nd_drhead nd_defrouter
;
651 extern struct nd_prhead nd_prefix
;
652 extern int nd6_debug
;
653 extern size_t nd_ifinfo_indexlim
;
654 extern int nd6_onlink_ns_rfc4861
;
656 #define nd6log(x) do { if (nd6_debug >= 1) log x; } while (0)
657 #define nd6log2(x) do { if (nd6_debug >= 2) log x; } while (0)
660 extern int nd6_defifindex
;
661 extern int ip6_desync_factor
; /* seconds */
662 /* ND6_INFINITE_LIFETIME does not apply to temporary addresses */
663 extern u_int32_t ip6_temp_preferred_lifetime
; /* seconds */
664 extern u_int32_t ip6_temp_valid_lifetime
; /* seconds */
665 extern int ip6_temp_regen_advance
; /* seconds */
668 struct nd_opt_hdr
*nd_opt_array
[8]; /* max = target address list */
670 struct nd_opt_hdr
*zero
;
671 struct nd_opt_hdr
*src_lladdr
;
672 struct nd_opt_hdr
*tgt_lladdr
;
673 struct nd_opt_prefix_info
*pi_beg
; /* multiple opts, start */
674 struct nd_opt_rd_hdr
*rh
;
675 struct nd_opt_mtu
*mtu
;
676 struct nd_opt_hdr
*search
; /* multiple opts */
677 struct nd_opt_hdr
*last
; /* multiple opts */
679 struct nd_opt_prefix_info
*pi_end
;/* multiple opts, end */
682 #define nd_opts_src_lladdr nd_opt_each.src_lladdr
683 #define nd_opts_tgt_lladdr nd_opt_each.tgt_lladdr
684 #define nd_opts_pi nd_opt_each.pi_beg
685 #define nd_opts_pi_end nd_opt_each.pi_end
686 #define nd_opts_rh nd_opt_each.rh
687 #define nd_opts_mtu nd_opt_each.mtu
688 #define nd_opts_search nd_opt_each.search
689 #define nd_opts_last nd_opt_each.last
690 #define nd_opts_done nd_opt_each.done
692 /* XXX: need nd6_var.h?? */
694 extern void nd6_init(void);
695 extern int nd6_ifattach(struct ifnet
*);
696 extern int nd6_is_addr_neighbor(struct sockaddr_in6
*, struct ifnet
*, int);
697 extern void nd6_option_init(void *, int, union nd_opts
*);
698 extern struct nd_opt_hdr
*nd6_option(union nd_opts
*);
699 extern int nd6_options(union nd_opts
*);
700 extern struct rtentry
*nd6_lookup(struct in6_addr
*, int, struct ifnet
*, int);
701 extern void nd6_setmtu(struct ifnet
*);
702 extern void nd6_timer(void *);
703 extern void nd6_purge(struct ifnet
*);
704 extern void nd6_free(struct rtentry
*);
705 extern void nd6_nud_hint(struct rtentry
*, struct in6_addr
*, int);
706 extern int nd6_resolve(struct ifnet
*, struct rtentry
*,
707 struct mbuf
*, struct sockaddr
*, u_char
*);
708 extern void nd6_rtrequest(int, struct rtentry
*, struct sockaddr
*);
709 extern int nd6_ioctl(u_long
, caddr_t
, struct ifnet
*);
710 extern void nd6_cache_lladdr(struct ifnet
*, struct in6_addr
*,
711 char *, int, int, int);
712 extern int nd6_output(struct ifnet
*, struct ifnet
*, struct mbuf
*,
713 struct sockaddr_in6
*, struct rtentry
*);
714 extern int nd6_storelladdr(struct ifnet
*, struct rtentry
*, struct mbuf
*,
715 struct sockaddr
*, u_char
*);
716 extern int nd6_need_cache(struct ifnet
*);
717 extern void nd6_drain(void *);
720 extern void nd6_nbr_init(void);
721 extern void nd6_na_input(struct mbuf
*, int, int);
722 extern void nd6_na_output(struct ifnet
*, const struct in6_addr
*,
723 const struct in6_addr
*, u_int32_t
, int, struct sockaddr
*);
724 extern void nd6_ns_input(struct mbuf
*, int, int);
725 extern void nd6_ns_output(struct ifnet
*, const struct in6_addr
*,
726 const struct in6_addr
*, struct llinfo_nd6
*, int);
727 extern caddr_t
nd6_ifptomac(struct ifnet
*);
728 extern void nd6_dad_start(struct ifaddr
*, int *);
729 extern void nd6_dad_stop(struct ifaddr
*);
730 extern void nd6_dad_duplicated(struct ifaddr
*, boolean_t
);
731 extern void nd6_llreach_alloc(struct rtentry
*, struct ifnet
*, void *,
732 unsigned int, boolean_t
);
733 extern void nd6_llreach_set_reachable(struct ifnet
*, void *, unsigned int);
734 extern void nd6_llreach_use(struct llinfo_nd6
*);
737 extern void nd6_rtr_init(void);
738 extern void nd6_rs_input(struct mbuf
*, int, int);
739 extern void nd6_ra_input(struct mbuf
*, int, int);
740 extern void prelist_del(struct nd_prefix
*);
741 extern void defrouter_addreq(struct nd_defrouter
*, boolean_t
);
742 extern void defrouter_delreq(struct nd_defrouter
*);
743 extern void defrouter_select(struct ifnet
*);
744 extern void defrouter_reset(void);
745 extern int defrtrlist_ioctl(u_long
, caddr_t
);
746 extern void defrtrlist_del(struct nd_defrouter
*);
747 extern int defrtrlist_add_static(struct nd_defrouter
*);
748 extern int defrtrlist_del_static(struct nd_defrouter
*);
749 extern void prelist_remove(struct nd_prefix
*);
750 extern int prelist_update(struct nd_prefix
*, struct nd_defrouter
*,
752 extern int nd6_prelist_add(struct nd_prefix
*, struct nd_defrouter
*,
753 struct nd_prefix
**, boolean_t
);
754 extern int nd6_prefix_onlink(struct nd_prefix
*);
755 extern int nd6_prefix_onlink_scoped(struct nd_prefix
*, unsigned int);
756 extern int nd6_prefix_offlink(struct nd_prefix
*);
757 extern void pfxlist_onlink_check(void);
758 extern struct nd_defrouter
*defrouter_lookup(struct in6_addr
*, struct ifnet
*);
759 extern struct nd_prefix
*nd6_prefix_lookup(struct nd_prefix
*);
760 extern int in6_init_prefix_ltimes(struct nd_prefix
*ndpr
);
761 extern void rt6_flush(struct in6_addr
*, struct ifnet
*);
762 extern int nd6_setdefaultiface(int);
763 extern int in6_tmpifadd(const struct in6_ifaddr
*, int, int);
764 extern void nddr_addref(struct nd_defrouter
*, int);
765 extern struct nd_defrouter
*nddr_remref(struct nd_defrouter
*, int);
766 extern void ndpr_addref(struct nd_prefix
*, int);
767 extern struct nd_prefix
*ndpr_remref(struct nd_prefix
*, int);
768 #endif /* XNU_KERNEL_PRIVATE */
773 @function nd6_lookup_ipv6
774 @discussion This function will check the routing table for a cached
775 neighbor discovery entry or trigger an neighbor discovery query
776 to resolve the IPv6 address to a link-layer address.
778 nd entries are stored in the routing table. This function will
779 lookup the IPv6 destination in the routing table. If the
780 destination requires forwarding to a gateway, the route of the
781 gateway will be looked up. The route entry is inspected to
782 determine if the link layer destination address is known. If
783 unknown, neighbor discovery will be used to resolve the entry.
784 @param interface The interface the packet is being sent on.
785 @param ip6_dest The IPv6 destination of the packet.
786 @param ll_dest On output, the link-layer destination.
787 @param ll_dest_len The length of the buffer for ll_dest.
788 @param hint Any routing hint passed down from the protocol.
789 @param packet The packet being transmitted.
790 @result May return an error such as EHOSTDOWN or ENETUNREACH. If
791 this function returns EJUSTRETURN, the packet has been queued
792 and will be sent when the address is resolved. If any other
793 value is returned, the caller is responsible for disposing of
796 extern errno_t
nd6_lookup_ipv6(ifnet_t interface
,
797 const struct sockaddr_in6
*ip6_dest
, struct sockaddr_dl
*ll_dest
,
798 size_t ll_dest_len
, route_t hint
, mbuf_t packet
);
801 #endif /* _NETINET6_ND6_H_ */