1139826Simp/*-
253541Sshin * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
353541Sshin * All rights reserved.
453541Sshin *
553541Sshin * Redistribution and use in source and binary forms, with or without
653541Sshin * modification, are permitted provided that the following conditions
753541Sshin * are met:
853541Sshin * 1. Redistributions of source code must retain the above copyright
953541Sshin *    notice, this list of conditions and the following disclaimer.
1053541Sshin * 2. Redistributions in binary form must reproduce the above copyright
1153541Sshin *    notice, this list of conditions and the following disclaimer in the
1253541Sshin *    documentation and/or other materials provided with the distribution.
1353541Sshin * 3. Neither the name of the project nor the names of its contributors
1453541Sshin *    may be used to endorse or promote products derived from this software
1553541Sshin *    without specific prior written permission.
1653541Sshin *
1753541Sshin * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
1853541Sshin * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1953541Sshin * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2053541Sshin * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
2153541Sshin * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2253541Sshin * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2353541Sshin * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2453541Sshin * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2553541Sshin * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2653541Sshin * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2753541Sshin * SUCH DAMAGE.
28174510Sobrien *
29174510Sobrien *	$KAME: nd6.h,v 1.76 2001/12/18 02:10:31 itojun Exp $
30174510Sobrien * $FreeBSD$
3153541Sshin */
3253541Sshin
3353541Sshin#ifndef _NETINET6_ND6_H_
3462587Sitojun#define _NETINET6_ND6_H_
3553541Sshin
3662587Sitojun/* see net/route.h, or net/if_inarp.h */
3762587Sitojun#ifndef RTF_ANNOUNCE
3862587Sitojun#define RTF_ANNOUNCE	RTF_PROTO2
3962587Sitojun#endif
4062587Sitojun
4153541Sshin#include <sys/queue.h>
4278064Sume#include <sys/callout.h>
4353541Sshin
44186119Sqinglistruct llentry;
45151539Ssuz
4662587Sitojun#define ND6_LLINFO_NOSTATE	-2
4778064Sume/*
4878064Sume * We don't need the WAITDELETE state any more, but we keep the definition
4978064Sume * in a comment line instead of removing it. This is necessary to avoid
5078064Sume * unintentionally reusing the value for another purpose, which might
5178064Sume * affect backward compatibility with old applications.
5278064Sume * (20000711 jinmei@kame.net)
5378064Sume */
5478064Sume/* #define ND6_LLINFO_WAITDELETE	-1 */
5562587Sitojun#define ND6_LLINFO_INCOMPLETE	0
5662587Sitojun#define ND6_LLINFO_REACHABLE	1
5762587Sitojun#define ND6_LLINFO_STALE	2
5862587Sitojun#define ND6_LLINFO_DELAY	3
5962587Sitojun#define ND6_LLINFO_PROBE	4
6053541Sshin
6162587Sitojun#define ND6_IS_LLINFO_PROBREACH(n) ((n)->ln_state > ND6_LLINFO_INCOMPLETE)
62186119Sqingli#define ND6_LLINFO_PERMANENT(n) (((n)->la_expire == 0) && ((n)->ln_state > ND6_LLINFO_INCOMPLETE))
6362587Sitojun
6453541Sshinstruct nd_ifinfo {
6562587Sitojun	u_int32_t linkmtu;		/* LinkMTU */
6662587Sitojun	u_int32_t maxmtu;		/* Upper bound of LinkMTU */
6762587Sitojun	u_int32_t basereachable;	/* BaseReachableTime */
6862587Sitojun	u_int32_t reachable;		/* Reachable Time */
6962587Sitojun	u_int32_t retrans;		/* Retrans Timer */
7062587Sitojun	u_int32_t flags;		/* Flags */
7162587Sitojun	int recalctm;			/* BaseReacable re-calculation timer */
7262587Sitojun	u_int8_t chlim;			/* CurHopLimit */
73121161Sume	u_int8_t initialized; /* Flag to see the entry is initialized */
7495023Ssuz	/* the following 3 members are for privacy extension for addrconf */
7578064Sume	u_int8_t randomseed0[8]; /* upper 64 bits of MD5 digest */
7678064Sume	u_int8_t randomseed1[8]; /* lower 64 bits (usually the EUI64 IFID) */
7778064Sume	u_int8_t randomid[8];	/* current random ID */
7853541Sshin};
7953541Sshin
8062587Sitojun#define ND6_IFF_PERFORMNUD	0x1
81118498Sume#define ND6_IFF_ACCEPT_RTADV	0x2
82238273Shrs#define ND6_IFF_PREFER_SOURCE	0x4 /* Not used in FreeBSD. */
83151474Ssuz#define ND6_IFF_IFDISABLED	0x8 /* IPv6 operation is disabled due to
84151474Ssuz				     * DAD failure.  (XXX: not ND-specific)
85151474Ssuz				     */
86151539Ssuz#define ND6_IFF_DONT_SET_IFROUTE	0x10
87197138Shrs#define ND6_IFF_AUTO_LINKLOCAL	0x20
88222728Shrs#define	ND6_IFF_NO_RADR		0x40
89245230Sume#define ND6_IFF_NO_PREFER_IFACE	0x80 /* XXX: not related to ND. */
90285825Shrs#define ND6_IFF_NO_DAD		0x100
9162587Sitojun
92186119Sqingli#define	ND6_CREATE		LLE_CREATE
93186119Sqingli#define	ND6_EXCLUSIVE		LLE_EXCLUSIVE
94186119Sqingli
95121161Sume#ifdef _KERNEL
96121161Sume#define ND_IFINFO(ifp) \
97121161Sume	(((struct in6_ifextra *)(ifp)->if_afdata[AF_INET6])->nd_ifinfo)
98121161Sume#define IN6_LINKMTU(ifp) \
99121161Sume	((ND_IFINFO(ifp)->linkmtu && ND_IFINFO(ifp)->linkmtu < (ifp)->if_mtu) \
100121161Sume	    ? ND_IFINFO(ifp)->linkmtu \
101121161Sume	    : ((ND_IFINFO(ifp)->maxmtu && ND_IFINFO(ifp)->maxmtu < (ifp)->if_mtu) \
102121161Sume		? ND_IFINFO(ifp)->maxmtu : (ifp)->if_mtu))
103121161Sume#endif
104121161Sume
10553541Sshinstruct in6_nbrinfo {
10662587Sitojun	char ifname[IFNAMSIZ];	/* if name, e.g. "en0" */
10762587Sitojun	struct in6_addr addr;	/* IPv6 address of the neighbor */
10853541Sshin	long	asked;		/* number of queries already sent for this addr */
10953541Sshin	int	isrouter;	/* if it acts as a router */
11053541Sshin	int	state;		/* reachability state */
11153541Sshin	int	expire;		/* lifetime for NDP state transition */
11253541Sshin};
11353541Sshin
11462587Sitojun#define DRLSTSIZ 10
11562587Sitojun#define PRLSTSIZ 10
11653541Sshinstruct	in6_drlist {
11762587Sitojun	char ifname[IFNAMSIZ];
11853541Sshin	struct {
11953541Sshin		struct	in6_addr rtaddr;
12053541Sshin		u_char	flags;
12153541Sshin		u_short	rtlifetime;
12253541Sshin		u_long	expire;
12362587Sitojun		u_short if_index;
12453541Sshin	} defrouter[DRLSTSIZ];
12553541Sshin};
12653541Sshin
12778064Sumestruct	in6_defrouter {
12878064Sume	struct	sockaddr_in6 rtaddr;
12978064Sume	u_char	flags;
13078064Sume	u_short	rtlifetime;
13178064Sume	u_long	expire;
13278064Sume	u_short if_index;
13381369Ssimokawa};
13478064Sume
135121472Sume#ifdef _KERNEL
136121472Sumestruct	in6_oprlist {
137121472Sume	char ifname[IFNAMSIZ];
138121472Sume	struct {
139121472Sume		struct	in6_addr prefix;
140121472Sume		struct prf_ra raflags;
141121472Sume		u_char	prefixlen;
142121472Sume		u_char	origin;
143121472Sume		u_long vltime;
144121472Sume		u_long pltime;
145121472Sume		u_long expire;
146121472Sume		u_short if_index;
147121472Sume		u_short advrtrs; /* number of advertisement routers */
148121472Sume		struct	in6_addr advrtr[DRLSTSIZ]; /* XXX: explicit limit */
149121472Sume	} prefix[PRLSTSIZ];
150121472Sume};
151121472Sume#endif
152121472Sume
15353541Sshinstruct	in6_prlist {
15462587Sitojun	char ifname[IFNAMSIZ];
15553541Sshin	struct {
15653541Sshin		struct	in6_addr prefix;
15762587Sitojun		struct prf_ra raflags;
15853541Sshin		u_char	prefixlen;
15962587Sitojun		u_char	origin;
16095023Ssuz		u_int32_t vltime;
16195023Ssuz		u_int32_t pltime;
16295023Ssuz		time_t expire;
16362587Sitojun		u_short if_index;
16462587Sitojun		u_short advrtrs; /* number of advertisement routers */
16553541Sshin		struct	in6_addr advrtr[DRLSTSIZ]; /* XXX: explicit limit */
16653541Sshin	} prefix[PRLSTSIZ];
16753541Sshin};
16853541Sshin
16978064Sumestruct in6_prefix {
17078064Sume	struct	sockaddr_in6 prefix;
17178064Sume	struct prf_ra raflags;
17278064Sume	u_char	prefixlen;
17378064Sume	u_char	origin;
174121472Sume	u_int32_t vltime;
175121472Sume	u_int32_t pltime;
176121472Sume	time_t expire;
17778064Sume	u_int32_t flags;
17878064Sume	int refcnt;
17978064Sume	u_short if_index;
18078064Sume	u_short advrtrs; /* number of advertisement routers */
18178064Sume	/* struct sockaddr_in6 advrtr[] */
18281369Ssimokawa};
18378064Sume
18478064Sume#ifdef _KERNEL
18578064Sumestruct	in6_ondireq {
18678064Sume	char ifname[IFNAMSIZ];
18778064Sume	struct {
18878064Sume		u_int32_t linkmtu;	/* LinkMTU */
18978064Sume		u_int32_t maxmtu;	/* Upper bound of LinkMTU */
19078064Sume		u_int32_t basereachable; /* BaseReachableTime */
19178064Sume		u_int32_t reachable;	/* Reachable Time */
19278064Sume		u_int32_t retrans;	/* Retrans Timer */
19378064Sume		u_int32_t flags;	/* Flags */
19478064Sume		int recalctm;		/* BaseReacable re-calculation timer */
19578064Sume		u_int8_t chlim;		/* CurHopLimit */
19678064Sume		u_int8_t receivedra;
19778064Sume	} ndi;
19878064Sume};
19978064Sume#endif
20078064Sume
20153541Sshinstruct	in6_ndireq {
20262587Sitojun	char ifname[IFNAMSIZ];
20362587Sitojun	struct nd_ifinfo ndi;
20453541Sshin};
20553541Sshin
20662587Sitojunstruct	in6_ndifreq {
20762587Sitojun	char ifname[IFNAMSIZ];
20862587Sitojun	u_long ifindex;
20962587Sitojun};
21062587Sitojun
21178064Sume/* Prefix status */
21278064Sume#define NDPRF_ONLINK		0x1
21378064Sume#define NDPRF_DETACHED		0x2
21462587Sitojun
21553541Sshin/* protocol constants */
21695023Ssuz#define MAX_RTR_SOLICITATION_DELAY	1	/* 1sec */
21795023Ssuz#define RTR_SOLICITATION_INTERVAL	4	/* 4sec */
21862587Sitojun#define MAX_RTR_SOLICITATIONS		3
21953541Sshin
22062587Sitojun#define ND6_INFINITE_LIFETIME		0xffffffff
22153541Sshin
22253541Sshin#ifdef _KERNEL
22353541Sshin/* node constants */
22462587Sitojun#define MAX_REACHABLE_TIME		3600000	/* msec */
22562587Sitojun#define REACHABLE_TIME			30000	/* msec */
22662587Sitojun#define RETRANS_TIMER			1000	/* msec */
22762587Sitojun#define MIN_RANDOM_FACTOR		512	/* 1024 * 0.5 */
22862587Sitojun#define MAX_RANDOM_FACTOR		1536	/* 1024 * 1.5 */
22978064Sume#define DEF_TEMP_VALID_LIFETIME		604800	/* 1 week */
23078064Sume#define DEF_TEMP_PREFERRED_LIFETIME	86400	/* 1 day */
23178064Sume#define TEMPADDR_REGEN_ADVANCE		5	/* sec */
23278064Sume#define MAX_TEMP_DESYNC_FACTOR		600	/* 10 min */
23362587Sitojun#define ND_COMPUTE_RTIME(x) \
234121807Sume		(((MIN_RANDOM_FACTOR * (x >> 10)) + (arc4random() & \
23553541Sshin		((MAX_RANDOM_FACTOR - MIN_RANDOM_FACTOR) * (x >> 10)))) /1000)
23653541Sshin
23762587SitojunTAILQ_HEAD(nd_drhead, nd_defrouter);
238299145Smarkjstruct nd_defrouter {
23962587Sitojun	TAILQ_ENTRY(nd_defrouter) dr_entry;
240299145Smarkj	struct in6_addr rtaddr;
241299145Smarkj	u_char	raflags;	/* flags on RA message */
24253541Sshin	u_short	rtlifetime;
24353541Sshin	u_long	expire;
244299145Smarkj	struct ifnet *ifp;
245151539Ssuz	int	installed;	/* is installed into kernel routing table */
246303458Ssbruno	u_int	refcnt;
24753541Sshin};
24853541Sshin
249151539Ssuzstruct nd_prefixctl {
250151539Ssuz	struct ifnet *ndpr_ifp;
251151539Ssuz
252151539Ssuz	/* prefix */
253151539Ssuz	struct sockaddr_in6 ndpr_prefix;
254151539Ssuz	u_char	ndpr_plen;
255151539Ssuz
256151539Ssuz	u_int32_t ndpr_vltime;	/* advertised valid lifetime */
257151539Ssuz	u_int32_t ndpr_pltime;	/* advertised preferred lifetime */
258151539Ssuz
259151539Ssuz	struct prf_ra ndpr_flags;
260151539Ssuz};
261151539Ssuz
262151539Ssuz
26353541Sshinstruct nd_prefix {
26462587Sitojun	struct ifnet *ndpr_ifp;
26560938Sjake	LIST_ENTRY(nd_prefix) ndpr_entry;
26662587Sitojun	struct sockaddr_in6 ndpr_prefix;	/* prefix */
26762587Sitojun	struct in6_addr ndpr_mask; /* netmask derived from the prefix */
268151539Ssuz
26962587Sitojun	u_int32_t ndpr_vltime;	/* advertised valid lifetime */
27062587Sitojun	u_int32_t ndpr_pltime;	/* advertised preferred lifetime */
271151539Ssuz
27262587Sitojun	time_t ndpr_expire;	/* expiration time of the prefix */
27362587Sitojun	time_t ndpr_preferred;	/* preferred time of the prefix */
274151539Ssuz	time_t ndpr_lastupdate; /* reception time of last advertisement */
275151539Ssuz
27662587Sitojun	struct prf_ra ndpr_flags;
27778064Sume	u_int32_t ndpr_stateflags; /* actual state flags */
27853541Sshin	/* list of routers that advertise the prefix: */
27960938Sjake	LIST_HEAD(pr_rtrhead, nd_pfxrouter) ndpr_advrtrs;
28053541Sshin	u_char	ndpr_plen;
28178064Sume	int	ndpr_refcnt;	/* reference couter from addresses */
28253541Sshin};
28353541Sshin
28462587Sitojun#define ndpr_raf		ndpr_flags
28562587Sitojun#define ndpr_raf_onlink		ndpr_flags.onlink
28662587Sitojun#define ndpr_raf_auto		ndpr_flags.autonomous
287151539Ssuz#define ndpr_raf_router		ndpr_flags.router
28853541Sshin
28953541Sshin/*
29053541Sshin * Message format for use in obtaining information about prefixes
29153541Sshin * from inet6 sysctl function
29253541Sshin */
29353541Sshinstruct inet6_ndpr_msghdr {
29453541Sshin	u_short	inpm_msglen;	/* to skip over non-understood messages */
29572093Sasmodai	u_char	inpm_version;	/* future binary compatibility */
29653541Sshin	u_char	inpm_type;	/* message type */
29762587Sitojun	struct in6_addr inpm_prefix;
29853541Sshin	u_long	prm_vltim;
29953541Sshin	u_long	prm_pltime;
30053541Sshin	u_long	prm_expire;
30153541Sshin	u_long	prm_preferred;
30262587Sitojun	struct in6_prflags prm_flags;
30353541Sshin	u_short	prm_index;	/* index for associated ifp */
30453541Sshin	u_char	prm_plen;	/* length of prefix in bits */
30553541Sshin};
30653541Sshin
30762587Sitojun#define prm_raf_onlink		prm_flags.prf_ra.onlink
30862587Sitojun#define prm_raf_auto		prm_flags.prf_ra.autonomous
30953541Sshin
31062587Sitojun#define prm_statef_onlink	prm_flags.prf_state.onlink
31153541Sshin
31262587Sitojun#define prm_rrf_decrvalid	prm_flags.prf_rr.decrvalid
31362587Sitojun#define prm_rrf_decrprefd	prm_flags.prf_rr.decrprefd
31453541Sshin
31553541Sshinstruct nd_pfxrouter {
31660938Sjake	LIST_ENTRY(nd_pfxrouter) pfr_entry;
31762587Sitojun	struct nd_defrouter *router;
31853541Sshin};
31953541Sshin
32060938SjakeLIST_HEAD(nd_prhead, nd_prefix);
32153541Sshin
32253541Sshin/* nd6.c */
323195699SrwatsonVNET_DECLARE(int, nd6_prune);
324195699SrwatsonVNET_DECLARE(int, nd6_delay);
325195699SrwatsonVNET_DECLARE(int, nd6_umaxtries);
326195699SrwatsonVNET_DECLARE(int, nd6_mmaxtries);
327195699SrwatsonVNET_DECLARE(int, nd6_useloopback);
328195699SrwatsonVNET_DECLARE(int, nd6_maxnudhint);
329195699SrwatsonVNET_DECLARE(int, nd6_gctimer);
330195699SrwatsonVNET_DECLARE(struct nd_drhead, nd_defrouter);
331195699SrwatsonVNET_DECLARE(struct nd_prhead, nd_prefix);
332195699SrwatsonVNET_DECLARE(int, nd6_debug);
333195699SrwatsonVNET_DECLARE(int, nd6_onlink_ns_rfc4861);
334195727Srwatson#define	V_nd6_prune			VNET(nd6_prune)
335195727Srwatson#define	V_nd6_delay			VNET(nd6_delay)
336195727Srwatson#define	V_nd6_umaxtries			VNET(nd6_umaxtries)
337195727Srwatson#define	V_nd6_mmaxtries			VNET(nd6_mmaxtries)
338195727Srwatson#define	V_nd6_useloopback		VNET(nd6_useloopback)
339195727Srwatson#define	V_nd6_maxnudhint		VNET(nd6_maxnudhint)
340195727Srwatson#define	V_nd6_gctimer			VNET(nd6_gctimer)
341195727Srwatson#define	V_nd_defrouter			VNET(nd_defrouter)
342195727Srwatson#define	V_nd_prefix			VNET(nd_prefix)
343195727Srwatson#define	V_nd6_debug			VNET(nd6_debug)
344195727Srwatson#define	V_nd6_onlink_ns_rfc4861		VNET(nd6_onlink_ns_rfc4861)
345207369Sbz
346303458Ssbruno/* Lock for the prefix and default router lists. */
347303458SsbrunoVNET_DECLARE(struct rwlock, nd6_lock);
348303458Ssbruno#define	V_nd6_lock			VNET(nd6_lock)
349303458Ssbruno
350303458Ssbruno#define	ND6_RLOCK()			rw_rlock(&V_nd6_lock)
351303458Ssbruno#define	ND6_RUNLOCK()			rw_runlock(&V_nd6_lock)
352303458Ssbruno#define	ND6_WLOCK()			rw_wlock(&V_nd6_lock)
353303458Ssbruno#define	ND6_WUNLOCK()			rw_wunlock(&V_nd6_lock)
354303458Ssbruno#define	ND6_WLOCK_ASSERT()		rw_assert(&V_nd6_lock, RA_WLOCKED)
355303458Ssbruno#define	ND6_RLOCK_ASSERT()		rw_assert(&V_nd6_lock, RA_RLOCKED)
356303458Ssbruno#define	ND6_LOCK_ASSERT()		rw_assert(&V_nd6_lock, RA_LOCKED)
357303458Ssbruno#define	ND6_UNLOCK_ASSERT()		rw_assert(&V_nd6_lock, RA_UNLOCKED)
358303458Ssbruno
359207369Sbz#define nd6log(x)	do { if (V_nd6_debug) log x; } while (/*CONSTCOND*/ 0)
360207369Sbz
361207369SbzVNET_DECLARE(struct callout, nd6_timer_ch);
362195727Srwatson#define	V_nd6_timer_ch			VNET(nd6_timer_ch)
36378064Sume
36462587Sitojun/* nd6_rtr.c */
365195699SrwatsonVNET_DECLARE(int, nd6_defifindex);
366195699SrwatsonVNET_DECLARE(int, ip6_desync_factor);	/* seconds */
367195699SrwatsonVNET_DECLARE(u_int32_t, ip6_temp_preferred_lifetime); /* seconds */
368195699SrwatsonVNET_DECLARE(u_int32_t, ip6_temp_valid_lifetime); /* seconds */
369195699SrwatsonVNET_DECLARE(int, ip6_temp_regen_advance); /* seconds */
370195727Srwatson#define	V_nd6_defifindex		VNET(nd6_defifindex)
371195727Srwatson#define	V_ip6_desync_factor		VNET(ip6_desync_factor)
372195727Srwatson#define	V_ip6_temp_preferred_lifetime	VNET(ip6_temp_preferred_lifetime)
373195727Srwatson#define	V_ip6_temp_valid_lifetime	VNET(ip6_temp_valid_lifetime)
374195727Srwatson#define	V_ip6_temp_regen_advance	VNET(ip6_temp_regen_advance)
375195699Srwatson
37653541Sshinunion nd_opts {
377282622Shiren	struct nd_opt_hdr *nd_opt_array[16];	/* max = ND_OPT_NONCE */
37853541Sshin	struct {
37962587Sitojun		struct nd_opt_hdr *zero;
38062587Sitojun		struct nd_opt_hdr *src_lladdr;
38162587Sitojun		struct nd_opt_hdr *tgt_lladdr;
38295023Ssuz		struct nd_opt_prefix_info *pi_beg; /* multiple opts, start */
38362587Sitojun		struct nd_opt_rd_hdr *rh;
38462587Sitojun		struct nd_opt_mtu *mtu;
385282622Shiren		struct nd_opt_hdr *__res6;
386282622Shiren		struct nd_opt_hdr *__res7;
387282622Shiren		struct nd_opt_hdr *__res8;
388282622Shiren		struct nd_opt_hdr *__res9;
389282622Shiren		struct nd_opt_hdr *__res10;
390282622Shiren		struct nd_opt_hdr *__res11;
391282622Shiren		struct nd_opt_hdr *__res12;
392282622Shiren		struct nd_opt_hdr *__res13;
393282622Shiren		struct nd_opt_nonce *nonce;
394282622Shiren		struct nd_opt_hdr *__res15;
39562587Sitojun		struct nd_opt_hdr *search;	/* multiple opts */
39662587Sitojun		struct nd_opt_hdr *last;	/* multiple opts */
39762587Sitojun		int done;
39862587Sitojun		struct nd_opt_prefix_info *pi_end;/* multiple opts, end */
39953541Sshin	} nd_opt_each;
40053541Sshin};
40162587Sitojun#define nd_opts_src_lladdr	nd_opt_each.src_lladdr
40262587Sitojun#define nd_opts_tgt_lladdr	nd_opt_each.tgt_lladdr
40362587Sitojun#define nd_opts_pi		nd_opt_each.pi_beg
40462587Sitojun#define nd_opts_pi_end		nd_opt_each.pi_end
40562587Sitojun#define nd_opts_rh		nd_opt_each.rh
40662587Sitojun#define nd_opts_mtu		nd_opt_each.mtu
407282622Shiren#define nd_opts_nonce		nd_opt_each.nonce
40862587Sitojun#define nd_opts_search		nd_opt_each.search
40962587Sitojun#define nd_opts_last		nd_opt_each.last
41062587Sitojun#define nd_opts_done		nd_opt_each.done
41153541Sshin
41253541Sshin/* XXX: need nd6_var.h?? */
41353541Sshin/* nd6.c */
414241916Sdelphijvoid nd6_init(void);
415193731Szec#ifdef VIMAGE
416241916Sdelphijvoid nd6_destroy(void);
417193731Szec#endif
418241916Sdelphijstruct nd_ifinfo *nd6_ifattach(struct ifnet *);
419241916Sdelphijvoid nd6_ifdetach(struct nd_ifinfo *);
420241916Sdelphijint nd6_is_addr_neighbor(struct sockaddr_in6 *, struct ifnet *);
421241916Sdelphijvoid nd6_option_init(void *, int, union nd_opts *);
422241916Sdelphijstruct nd_opt_hdr *nd6_option(union nd_opts *);
423241916Sdelphijint nd6_options(union nd_opts *);
424241916Sdelphijstruct	llentry *nd6_lookup(struct in6_addr *, int, struct ifnet *);
425241916Sdelphijvoid nd6_setmtu(struct ifnet *);
426241916Sdelphijvoid nd6_llinfo_settimer(struct llentry *, long);
427241916Sdelphijvoid nd6_llinfo_settimer_locked(struct llentry *, long);
428241916Sdelphijvoid nd6_timer(void *);
429241916Sdelphijvoid nd6_purge(struct ifnet *);
430241916Sdelphijvoid nd6_nud_hint(struct rtentry *, struct in6_addr *, int);
431241916Sdelphijint nd6_resolve(struct ifnet *, struct rtentry *, struct mbuf *,
432241916Sdelphij	struct sockaddr *, u_char *);
433241916Sdelphijvoid nd6_rtrequest(int, struct rtentry *, struct rt_addrinfo *);
434241916Sdelphijint nd6_ioctl(u_long, caddr_t, struct ifnet *);
435241916Sdelphijstruct llentry *nd6_cache_lladdr(struct ifnet *, struct in6_addr *,
436241916Sdelphij	char *, int, int, int);
437241916Sdelphijint nd6_output(struct ifnet *, struct ifnet *, struct mbuf *,
438241916Sdelphij	struct sockaddr_in6 *, struct rtentry *);
439282622Shirenvoid nd6_grab_holdchain(struct llentry *, struct mbuf **,
440282622Shiren    struct sockaddr_in6 *);
441282622Shirenint nd6_flush_holdchain(struct ifnet *, struct ifnet *, struct mbuf *,
442282622Shiren    struct sockaddr_in6 *);
443241916Sdelphijint nd6_need_cache(struct ifnet *);
444241916Sdelphijint nd6_storelladdr(struct ifnet *, struct mbuf *,
445249925Sglebius	const struct sockaddr *, u_char *, struct llentry **);
44653541Sshin
44753541Sshin/* nd6_nbr.c */
448241916Sdelphijvoid nd6_na_input(struct mbuf *, int, int);
449241916Sdelphijvoid nd6_na_output(struct ifnet *, const struct in6_addr *,
450241916Sdelphij	const struct in6_addr *, u_long, int, struct sockaddr *);
451241916Sdelphijvoid nd6_ns_input(struct mbuf *, int, int);
452241916Sdelphijvoid nd6_ns_output(struct ifnet *, const struct in6_addr *,
453282622Shiren	const struct in6_addr *, struct llentry *, uint8_t *);
454241916Sdelphijcaddr_t nd6_ifptomac(struct ifnet *);
455282622Shirenvoid nd6_dad_init(void);
456241916Sdelphijvoid nd6_dad_start(struct ifaddr *, int);
457241916Sdelphijvoid nd6_dad_stop(struct ifaddr *);
45853541Sshin
45953541Sshin/* nd6_rtr.c */
460241916Sdelphijvoid nd6_rs_input(struct mbuf *, int, int);
461241916Sdelphijvoid nd6_ra_input(struct mbuf *, int, int);
462241916Sdelphijvoid defrouter_reset(void);
463241916Sdelphijvoid defrouter_select(void);
464303458Ssbrunovoid defrouter_ref(struct nd_defrouter *);
465303458Ssbrunovoid defrouter_rele(struct nd_defrouter *);
466303458Ssbrunobool defrouter_remove(struct in6_addr *, struct ifnet *);
467303458Ssbrunovoid defrouter_unlink(struct nd_defrouter *, struct nd_drhead *);
468303458Ssbrunovoid defrouter_del(struct nd_defrouter *);
469241916Sdelphijvoid prelist_remove(struct nd_prefix *);
470241916Sdelphijint nd6_prelist_add(struct nd_prefixctl *, struct nd_defrouter *,
471241916Sdelphij	struct nd_prefix **);
472241916Sdelphijvoid pfxlist_onlink_check(void);
473241916Sdelphijstruct nd_defrouter *defrouter_lookup(struct in6_addr *, struct ifnet *);
474303458Ssbrunostruct nd_defrouter *defrouter_lookup_locked(struct in6_addr *, struct ifnet *);
475241916Sdelphijstruct nd_prefix *nd6_prefix_lookup(struct nd_prefixctl *);
476241916Sdelphijvoid rt6_flush(struct in6_addr *, struct ifnet *);
477241916Sdelphijint nd6_setdefaultiface(int);
478241916Sdelphijint in6_tmpifadd(const struct in6_ifaddr *, int, int);
47953541Sshin
48053541Sshin#endif /* _KERNEL */
48153541Sshin
48253541Sshin#endif /* _NETINET6_ND6_H_ */
483