xref: /freebsd/sys/netinet6/nd6.h (revision f95d46333db63ce9df4e8a2ca8c5c09bc0edfe72)
1686cdd19SJun-ichiro itojun Hagino /*	$FreeBSD$	*/
288ff5695SSUZUKI Shinsuke /*	$KAME: nd6.h,v 1.76 2001/12/18 02:10:31 itojun Exp $	*/
3686cdd19SJun-ichiro itojun Hagino 
482cd038dSYoshinobu Inoue /*
582cd038dSYoshinobu Inoue  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
682cd038dSYoshinobu Inoue  * All rights reserved.
782cd038dSYoshinobu Inoue  *
882cd038dSYoshinobu Inoue  * Redistribution and use in source and binary forms, with or without
982cd038dSYoshinobu Inoue  * modification, are permitted provided that the following conditions
1082cd038dSYoshinobu Inoue  * are met:
1182cd038dSYoshinobu Inoue  * 1. Redistributions of source code must retain the above copyright
1282cd038dSYoshinobu Inoue  *    notice, this list of conditions and the following disclaimer.
1382cd038dSYoshinobu Inoue  * 2. Redistributions in binary form must reproduce the above copyright
1482cd038dSYoshinobu Inoue  *    notice, this list of conditions and the following disclaimer in the
1582cd038dSYoshinobu Inoue  *    documentation and/or other materials provided with the distribution.
1682cd038dSYoshinobu Inoue  * 3. Neither the name of the project nor the names of its contributors
1782cd038dSYoshinobu Inoue  *    may be used to endorse or promote products derived from this software
1882cd038dSYoshinobu Inoue  *    without specific prior written permission.
1982cd038dSYoshinobu Inoue  *
2082cd038dSYoshinobu Inoue  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
2182cd038dSYoshinobu Inoue  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2282cd038dSYoshinobu Inoue  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2382cd038dSYoshinobu Inoue  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
2482cd038dSYoshinobu Inoue  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2582cd038dSYoshinobu Inoue  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2682cd038dSYoshinobu Inoue  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2782cd038dSYoshinobu Inoue  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2882cd038dSYoshinobu Inoue  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2982cd038dSYoshinobu Inoue  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3082cd038dSYoshinobu Inoue  * SUCH DAMAGE.
3182cd038dSYoshinobu Inoue  */
3282cd038dSYoshinobu Inoue 
3382cd038dSYoshinobu Inoue #ifndef _NETINET6_ND6_H_
3482cd038dSYoshinobu Inoue #define _NETINET6_ND6_H_
3582cd038dSYoshinobu Inoue 
36686cdd19SJun-ichiro itojun Hagino /* see net/route.h, or net/if_inarp.h */
37686cdd19SJun-ichiro itojun Hagino #ifndef RTF_ANNOUNCE
38686cdd19SJun-ichiro itojun Hagino #define RTF_ANNOUNCE	RTF_PROTO2
39686cdd19SJun-ichiro itojun Hagino #endif
40686cdd19SJun-ichiro itojun Hagino 
4182cd038dSYoshinobu Inoue #include <sys/queue.h>
4233841545SHajimu UMEMOTO #include <sys/callout.h>
4382cd038dSYoshinobu Inoue 
4482cd038dSYoshinobu Inoue struct	llinfo_nd6 {
4582cd038dSYoshinobu Inoue 	struct	llinfo_nd6 *ln_next;
4682cd038dSYoshinobu Inoue 	struct	llinfo_nd6 *ln_prev;
4782cd038dSYoshinobu Inoue 	struct	rtentry *ln_rt;
4882cd038dSYoshinobu Inoue 	struct	mbuf *ln_hold;	/* last packet until resolved/timeout */
4982cd038dSYoshinobu Inoue 	long	ln_asked;	/* number of queries already sent for this addr */
5082cd038dSYoshinobu Inoue 	u_long	ln_expire;	/* lifetime for NDP state transition */
5182cd038dSYoshinobu Inoue 	short	ln_state;	/* reachability state */
5282cd038dSYoshinobu Inoue 	short	ln_router;	/* 2^0: ND6 router bit */
53686cdd19SJun-ichiro itojun Hagino 	int	ln_byhint;	/* # of times we made it reachable by UL hint */
5482cd038dSYoshinobu Inoue };
5582cd038dSYoshinobu Inoue 
5682cd038dSYoshinobu Inoue #define ND6_LLINFO_NOSTATE	-2
5733841545SHajimu UMEMOTO /*
5833841545SHajimu UMEMOTO  * We don't need the WAITDELETE state any more, but we keep the definition
5933841545SHajimu UMEMOTO  * in a comment line instead of removing it. This is necessary to avoid
6033841545SHajimu UMEMOTO  * unintentionally reusing the value for another purpose, which might
6133841545SHajimu UMEMOTO  * affect backward compatibility with old applications.
6233841545SHajimu UMEMOTO  * (20000711 jinmei@kame.net)
6333841545SHajimu UMEMOTO  */
6433841545SHajimu UMEMOTO /* #define ND6_LLINFO_WAITDELETE	-1 */
6582cd038dSYoshinobu Inoue #define ND6_LLINFO_INCOMPLETE	0
6682cd038dSYoshinobu Inoue #define ND6_LLINFO_REACHABLE	1
6782cd038dSYoshinobu Inoue #define ND6_LLINFO_STALE	2
6882cd038dSYoshinobu Inoue #define ND6_LLINFO_DELAY	3
6982cd038dSYoshinobu Inoue #define ND6_LLINFO_PROBE	4
7082cd038dSYoshinobu Inoue 
71686cdd19SJun-ichiro itojun Hagino #define ND6_IS_LLINFO_PROBREACH(n) ((n)->ln_state > ND6_LLINFO_INCOMPLETE)
72686cdd19SJun-ichiro itojun Hagino 
7382cd038dSYoshinobu Inoue struct nd_ifinfo {
7482cd038dSYoshinobu Inoue 	u_int32_t linkmtu;		/* LinkMTU */
7582cd038dSYoshinobu Inoue 	u_int32_t maxmtu;		/* Upper bound of LinkMTU */
7682cd038dSYoshinobu Inoue 	u_int32_t basereachable;	/* BaseReachableTime */
7782cd038dSYoshinobu Inoue 	u_int32_t reachable;		/* Reachable Time */
7882cd038dSYoshinobu Inoue 	u_int32_t retrans;		/* Retrans Timer */
79686cdd19SJun-ichiro itojun Hagino 	u_int32_t flags;		/* Flags */
8082cd038dSYoshinobu Inoue 	int recalctm;			/* BaseReacable re-calculation timer */
8182cd038dSYoshinobu Inoue 	u_int8_t chlim;			/* CurHopLimit */
8231b1bfe1SHajimu UMEMOTO 	u_int8_t initialized; /* Flag to see the entry is initialized */
8388ff5695SSUZUKI Shinsuke 	/* the following 3 members are for privacy extension for addrconf */
8433841545SHajimu UMEMOTO 	u_int8_t randomseed0[8]; /* upper 64 bits of MD5 digest */
8533841545SHajimu UMEMOTO 	u_int8_t randomseed1[8]; /* lower 64 bits (usually the EUI64 IFID) */
8633841545SHajimu UMEMOTO 	u_int8_t randomid[8];	/* current random ID */
8782cd038dSYoshinobu Inoue };
8882cd038dSYoshinobu Inoue 
89686cdd19SJun-ichiro itojun Hagino #define ND6_IFF_PERFORMNUD	0x1
9007cf047dSHajimu UMEMOTO #define ND6_IFF_ACCEPT_RTADV	0x2
91686cdd19SJun-ichiro itojun Hagino 
9231b1bfe1SHajimu UMEMOTO #ifdef _KERNEL
9331b1bfe1SHajimu UMEMOTO #define ND_IFINFO(ifp) \
9431b1bfe1SHajimu UMEMOTO 	(((struct in6_ifextra *)(ifp)->if_afdata[AF_INET6])->nd_ifinfo)
9531b1bfe1SHajimu UMEMOTO #define IN6_LINKMTU(ifp) \
9631b1bfe1SHajimu UMEMOTO 	((ND_IFINFO(ifp)->linkmtu && ND_IFINFO(ifp)->linkmtu < (ifp)->if_mtu) \
9731b1bfe1SHajimu UMEMOTO 	    ? ND_IFINFO(ifp)->linkmtu \
9831b1bfe1SHajimu UMEMOTO 	    : ((ND_IFINFO(ifp)->maxmtu && ND_IFINFO(ifp)->maxmtu < (ifp)->if_mtu) \
9931b1bfe1SHajimu UMEMOTO 		? ND_IFINFO(ifp)->maxmtu : (ifp)->if_mtu))
10031b1bfe1SHajimu UMEMOTO #endif
10131b1bfe1SHajimu UMEMOTO 
10282cd038dSYoshinobu Inoue struct in6_nbrinfo {
10382cd038dSYoshinobu Inoue 	char ifname[IFNAMSIZ];	/* if name, e.g. "en0" */
10482cd038dSYoshinobu Inoue 	struct in6_addr addr;	/* IPv6 address of the neighbor */
10582cd038dSYoshinobu Inoue 	long	asked;		/* number of queries already sent for this addr */
10682cd038dSYoshinobu Inoue 	int	isrouter;	/* if it acts as a router */
10782cd038dSYoshinobu Inoue 	int	state;		/* reachability state */
10882cd038dSYoshinobu Inoue 	int	expire;		/* lifetime for NDP state transition */
10982cd038dSYoshinobu Inoue };
11082cd038dSYoshinobu Inoue 
11182cd038dSYoshinobu Inoue #define DRLSTSIZ 10
11282cd038dSYoshinobu Inoue #define PRLSTSIZ 10
11382cd038dSYoshinobu Inoue struct	in6_drlist {
11482cd038dSYoshinobu Inoue 	char ifname[IFNAMSIZ];
11582cd038dSYoshinobu Inoue 	struct {
11682cd038dSYoshinobu Inoue 		struct	in6_addr rtaddr;
11782cd038dSYoshinobu Inoue 		u_char	flags;
11882cd038dSYoshinobu Inoue 		u_short	rtlifetime;
11982cd038dSYoshinobu Inoue 		u_long	expire;
12082cd038dSYoshinobu Inoue 		u_short if_index;
12182cd038dSYoshinobu Inoue 	} defrouter[DRLSTSIZ];
12282cd038dSYoshinobu Inoue };
12382cd038dSYoshinobu Inoue 
12433841545SHajimu UMEMOTO struct	in6_defrouter {
12533841545SHajimu UMEMOTO 	struct	sockaddr_in6 rtaddr;
12633841545SHajimu UMEMOTO 	u_char	flags;
12733841545SHajimu UMEMOTO 	u_short	rtlifetime;
12833841545SHajimu UMEMOTO 	u_long	expire;
12933841545SHajimu UMEMOTO 	u_short if_index;
13023cd8d58SHidetoshi Shimokawa };
13133841545SHajimu UMEMOTO 
132f95d4633SHajimu UMEMOTO #ifdef _KERNEL
133f95d4633SHajimu UMEMOTO struct	in6_oprlist {
134f95d4633SHajimu UMEMOTO 	char ifname[IFNAMSIZ];
135f95d4633SHajimu UMEMOTO 	struct {
136f95d4633SHajimu UMEMOTO 		struct	in6_addr prefix;
137f95d4633SHajimu UMEMOTO 		struct prf_ra raflags;
138f95d4633SHajimu UMEMOTO 		u_char	prefixlen;
139f95d4633SHajimu UMEMOTO 		u_char	origin;
140f95d4633SHajimu UMEMOTO 		u_long vltime;
141f95d4633SHajimu UMEMOTO 		u_long pltime;
142f95d4633SHajimu UMEMOTO 		u_long expire;
143f95d4633SHajimu UMEMOTO 		u_short if_index;
144f95d4633SHajimu UMEMOTO 		u_short advrtrs; /* number of advertisement routers */
145f95d4633SHajimu UMEMOTO 		struct	in6_addr advrtr[DRLSTSIZ]; /* XXX: explicit limit */
146f95d4633SHajimu UMEMOTO 	} prefix[PRLSTSIZ];
147f95d4633SHajimu UMEMOTO };
148f95d4633SHajimu UMEMOTO #endif
149f95d4633SHajimu UMEMOTO 
15082cd038dSYoshinobu Inoue struct	in6_prlist {
15182cd038dSYoshinobu Inoue 	char ifname[IFNAMSIZ];
15282cd038dSYoshinobu Inoue 	struct {
15382cd038dSYoshinobu Inoue 		struct	in6_addr prefix;
15482cd038dSYoshinobu Inoue 		struct prf_ra raflags;
15582cd038dSYoshinobu Inoue 		u_char	prefixlen;
156686cdd19SJun-ichiro itojun Hagino 		u_char	origin;
15788ff5695SSUZUKI Shinsuke 		u_int32_t vltime;
15888ff5695SSUZUKI Shinsuke 		u_int32_t pltime;
15988ff5695SSUZUKI Shinsuke 		time_t expire;
16082cd038dSYoshinobu Inoue 		u_short if_index;
16182cd038dSYoshinobu Inoue 		u_short advrtrs; /* number of advertisement routers */
16282cd038dSYoshinobu Inoue 		struct	in6_addr advrtr[DRLSTSIZ]; /* XXX: explicit limit */
16382cd038dSYoshinobu Inoue 	} prefix[PRLSTSIZ];
16482cd038dSYoshinobu Inoue };
16582cd038dSYoshinobu Inoue 
16633841545SHajimu UMEMOTO struct in6_prefix {
16733841545SHajimu UMEMOTO 	struct	sockaddr_in6 prefix;
16833841545SHajimu UMEMOTO 	struct prf_ra raflags;
16933841545SHajimu UMEMOTO 	u_char	prefixlen;
17033841545SHajimu UMEMOTO 	u_char	origin;
171f95d4633SHajimu UMEMOTO 	u_int32_t vltime;
172f95d4633SHajimu UMEMOTO 	u_int32_t pltime;
173f95d4633SHajimu UMEMOTO 	time_t expire;
17433841545SHajimu UMEMOTO 	u_int32_t flags;
17533841545SHajimu UMEMOTO 	int refcnt;
17633841545SHajimu UMEMOTO 	u_short if_index;
17733841545SHajimu UMEMOTO 	u_short advrtrs; /* number of advertisement routers */
17833841545SHajimu UMEMOTO 	/* struct sockaddr_in6 advrtr[] */
17923cd8d58SHidetoshi Shimokawa };
18033841545SHajimu UMEMOTO 
18133841545SHajimu UMEMOTO #ifdef _KERNEL
18233841545SHajimu UMEMOTO struct	in6_ondireq {
18333841545SHajimu UMEMOTO 	char ifname[IFNAMSIZ];
18433841545SHajimu UMEMOTO 	struct {
18533841545SHajimu UMEMOTO 		u_int32_t linkmtu;	/* LinkMTU */
18633841545SHajimu UMEMOTO 		u_int32_t maxmtu;	/* Upper bound of LinkMTU */
18733841545SHajimu UMEMOTO 		u_int32_t basereachable; /* BaseReachableTime */
18833841545SHajimu UMEMOTO 		u_int32_t reachable;	/* Reachable Time */
18933841545SHajimu UMEMOTO 		u_int32_t retrans;	/* Retrans Timer */
19033841545SHajimu UMEMOTO 		u_int32_t flags;	/* Flags */
19133841545SHajimu UMEMOTO 		int recalctm;		/* BaseReacable re-calculation timer */
19233841545SHajimu UMEMOTO 		u_int8_t chlim;		/* CurHopLimit */
19333841545SHajimu UMEMOTO 		u_int8_t receivedra;
19433841545SHajimu UMEMOTO 	} ndi;
19533841545SHajimu UMEMOTO };
19633841545SHajimu UMEMOTO #endif
19733841545SHajimu UMEMOTO 
19882cd038dSYoshinobu Inoue struct	in6_ndireq {
19982cd038dSYoshinobu Inoue 	char ifname[IFNAMSIZ];
20082cd038dSYoshinobu Inoue 	struct nd_ifinfo ndi;
20182cd038dSYoshinobu Inoue };
20282cd038dSYoshinobu Inoue 
203686cdd19SJun-ichiro itojun Hagino struct	in6_ndifreq {
204686cdd19SJun-ichiro itojun Hagino 	char ifname[IFNAMSIZ];
205686cdd19SJun-ichiro itojun Hagino 	u_long ifindex;
206686cdd19SJun-ichiro itojun Hagino };
207686cdd19SJun-ichiro itojun Hagino 
20833841545SHajimu UMEMOTO /* Prefix status */
20933841545SHajimu UMEMOTO #define NDPRF_ONLINK		0x1
21033841545SHajimu UMEMOTO #define NDPRF_DETACHED		0x2
211686cdd19SJun-ichiro itojun Hagino 
21282cd038dSYoshinobu Inoue /* protocol constants */
21382cd038dSYoshinobu Inoue #define MAX_RTR_SOLICITATION_DELAY	1	/* 1sec */
21482cd038dSYoshinobu Inoue #define RTR_SOLICITATION_INTERVAL	4	/* 4sec */
21582cd038dSYoshinobu Inoue #define MAX_RTR_SOLICITATIONS		3
21682cd038dSYoshinobu Inoue 
21782cd038dSYoshinobu Inoue #define ND6_INFINITE_LIFETIME		0xffffffff
21882cd038dSYoshinobu Inoue 
21982cd038dSYoshinobu Inoue #ifdef _KERNEL
22082cd038dSYoshinobu Inoue /* node constants */
22182cd038dSYoshinobu Inoue #define MAX_REACHABLE_TIME		3600000	/* msec */
22282cd038dSYoshinobu Inoue #define REACHABLE_TIME			30000	/* msec */
22382cd038dSYoshinobu Inoue #define RETRANS_TIMER			1000	/* msec */
22482cd038dSYoshinobu Inoue #define MIN_RANDOM_FACTOR		512	/* 1024 * 0.5 */
22582cd038dSYoshinobu Inoue #define MAX_RANDOM_FACTOR		1536	/* 1024 * 1.5 */
22633841545SHajimu UMEMOTO #define DEF_TEMP_VALID_LIFETIME		604800	/* 1 week */
22733841545SHajimu UMEMOTO #define DEF_TEMP_PREFERRED_LIFETIME	86400	/* 1 day */
22833841545SHajimu UMEMOTO #define TEMPADDR_REGEN_ADVANCE		5	/* sec */
22933841545SHajimu UMEMOTO #define MAX_TEMP_DESYNC_FACTOR		600	/* 10 min */
23082cd038dSYoshinobu Inoue #define ND_COMPUTE_RTIME(x) \
23182cd038dSYoshinobu Inoue 		(((MIN_RANDOM_FACTOR * (x >> 10)) + (random() & \
23282cd038dSYoshinobu Inoue 		((MAX_RANDOM_FACTOR - MIN_RANDOM_FACTOR) * (x >> 10)))) /1000)
23382cd038dSYoshinobu Inoue 
234686cdd19SJun-ichiro itojun Hagino TAILQ_HEAD(nd_drhead, nd_defrouter);
23582cd038dSYoshinobu Inoue struct	nd_defrouter {
236686cdd19SJun-ichiro itojun Hagino 	TAILQ_ENTRY(nd_defrouter) dr_entry;
23782cd038dSYoshinobu Inoue 	struct	in6_addr rtaddr;
23888ff5695SSUZUKI Shinsuke 	u_char	flags;		/* flags on RA message */
23982cd038dSYoshinobu Inoue 	u_short	rtlifetime;
24082cd038dSYoshinobu Inoue 	u_long	expire;
24182cd038dSYoshinobu Inoue 	struct  ifnet *ifp;
24282cd038dSYoshinobu Inoue };
24382cd038dSYoshinobu Inoue 
24482cd038dSYoshinobu Inoue struct nd_prefix {
24582cd038dSYoshinobu Inoue 	struct ifnet *ndpr_ifp;
246e3975643SJake Burkholder 	LIST_ENTRY(nd_prefix) ndpr_entry;
24782cd038dSYoshinobu Inoue 	struct sockaddr_in6 ndpr_prefix;	/* prefix */
24882cd038dSYoshinobu Inoue 	struct in6_addr ndpr_mask; /* netmask derived from the prefix */
24982cd038dSYoshinobu Inoue 	struct in6_addr ndpr_addr; /* address that is derived from the prefix */
25082cd038dSYoshinobu Inoue 	u_int32_t ndpr_vltime;	/* advertised valid lifetime */
25182cd038dSYoshinobu Inoue 	u_int32_t ndpr_pltime;	/* advertised preferred lifetime */
25282cd038dSYoshinobu Inoue 	time_t ndpr_expire;	/* expiration time of the prefix */
25382cd038dSYoshinobu Inoue 	time_t ndpr_preferred;	/* preferred time of the prefix */
25482cd038dSYoshinobu Inoue 	struct prf_ra ndpr_flags;
25533841545SHajimu UMEMOTO 	u_int32_t ndpr_stateflags; /* actual state flags */
25682cd038dSYoshinobu Inoue 	/* list of routers that advertise the prefix: */
257e3975643SJake Burkholder 	LIST_HEAD(pr_rtrhead, nd_pfxrouter) ndpr_advrtrs;
25882cd038dSYoshinobu Inoue 	u_char	ndpr_plen;
25933841545SHajimu UMEMOTO 	int	ndpr_refcnt;	/* reference couter from addresses */
26082cd038dSYoshinobu Inoue };
26182cd038dSYoshinobu Inoue 
262686cdd19SJun-ichiro itojun Hagino #define ndpr_next		ndpr_entry.le_next
263686cdd19SJun-ichiro itojun Hagino 
26482cd038dSYoshinobu Inoue #define ndpr_raf		ndpr_flags
26582cd038dSYoshinobu Inoue #define ndpr_raf_onlink		ndpr_flags.onlink
26682cd038dSYoshinobu Inoue #define ndpr_raf_auto		ndpr_flags.autonomous
26782cd038dSYoshinobu Inoue 
26882cd038dSYoshinobu Inoue /*
26982cd038dSYoshinobu Inoue  * We keep expired prefix for certain amount of time, for validation purposes.
27082cd038dSYoshinobu Inoue  * 1800s = MaxRtrAdvInterval
27182cd038dSYoshinobu Inoue  */
27282cd038dSYoshinobu Inoue #define NDPR_KEEP_EXPIRED	(1800 * 2)
27382cd038dSYoshinobu Inoue 
27482cd038dSYoshinobu Inoue /*
27582cd038dSYoshinobu Inoue  * Message format for use in obtaining information about prefixes
27682cd038dSYoshinobu Inoue  * from inet6 sysctl function
27782cd038dSYoshinobu Inoue  */
27882cd038dSYoshinobu Inoue struct inet6_ndpr_msghdr {
27982cd038dSYoshinobu Inoue 	u_short	inpm_msglen;	/* to skip over non-understood messages */
2802fa72ea7SJeroen Ruigrok van der Werven 	u_char	inpm_version;	/* future binary compatibility */
28182cd038dSYoshinobu Inoue 	u_char	inpm_type;	/* message type */
28282cd038dSYoshinobu Inoue 	struct in6_addr inpm_prefix;
28382cd038dSYoshinobu Inoue 	u_long	prm_vltim;
28482cd038dSYoshinobu Inoue 	u_long	prm_pltime;
28582cd038dSYoshinobu Inoue 	u_long	prm_expire;
28682cd038dSYoshinobu Inoue 	u_long	prm_preferred;
28782cd038dSYoshinobu Inoue 	struct in6_prflags prm_flags;
28882cd038dSYoshinobu Inoue 	u_short	prm_index;	/* index for associated ifp */
28982cd038dSYoshinobu Inoue 	u_char	prm_plen;	/* length of prefix in bits */
29082cd038dSYoshinobu Inoue };
29182cd038dSYoshinobu Inoue 
29282cd038dSYoshinobu Inoue #define prm_raf_onlink		prm_flags.prf_ra.onlink
29382cd038dSYoshinobu Inoue #define prm_raf_auto		prm_flags.prf_ra.autonomous
29482cd038dSYoshinobu Inoue 
29582cd038dSYoshinobu Inoue #define prm_statef_onlink	prm_flags.prf_state.onlink
29682cd038dSYoshinobu Inoue 
29782cd038dSYoshinobu Inoue #define prm_rrf_decrvalid	prm_flags.prf_rr.decrvalid
29882cd038dSYoshinobu Inoue #define prm_rrf_decrprefd	prm_flags.prf_rr.decrprefd
29982cd038dSYoshinobu Inoue 
30082cd038dSYoshinobu Inoue #define ifpr2ndpr(ifpr)	((struct nd_prefix *)(ifpr))
30182cd038dSYoshinobu Inoue #define ndpr2ifpr(ndpr)	((struct ifprefix *)(ndpr))
30282cd038dSYoshinobu Inoue 
30382cd038dSYoshinobu Inoue struct nd_pfxrouter {
304e3975643SJake Burkholder 	LIST_ENTRY(nd_pfxrouter) pfr_entry;
305686cdd19SJun-ichiro itojun Hagino #define pfr_next pfr_entry.le_next
30682cd038dSYoshinobu Inoue 	struct nd_defrouter *router;
30782cd038dSYoshinobu Inoue };
30882cd038dSYoshinobu Inoue 
309e3975643SJake Burkholder LIST_HEAD(nd_prhead, nd_prefix);
31082cd038dSYoshinobu Inoue 
31182cd038dSYoshinobu Inoue /* nd6.c */
31282cd038dSYoshinobu Inoue extern int nd6_prune;
31382cd038dSYoshinobu Inoue extern int nd6_delay;
31482cd038dSYoshinobu Inoue extern int nd6_umaxtries;
31582cd038dSYoshinobu Inoue extern int nd6_mmaxtries;
31682cd038dSYoshinobu Inoue extern int nd6_useloopback;
317686cdd19SJun-ichiro itojun Hagino extern int nd6_maxnudhint;
31833841545SHajimu UMEMOTO extern int nd6_gctimer;
31982cd038dSYoshinobu Inoue extern struct llinfo_nd6 llinfo_nd6;
32082cd038dSYoshinobu Inoue extern struct nd_ifinfo *nd_ifinfo;
32182cd038dSYoshinobu Inoue extern struct nd_drhead nd_defrouter;
32282cd038dSYoshinobu Inoue extern struct nd_prhead nd_prefix;
32333841545SHajimu UMEMOTO extern int nd6_debug;
32433841545SHajimu UMEMOTO 
32507eb2995SHajimu UMEMOTO #define nd6log(x)	do { if (nd6_debug) log x; } while (/*CONSTCOND*/ 0)
32633841545SHajimu UMEMOTO 
32733841545SHajimu UMEMOTO extern struct callout nd6_timer_ch;
32882cd038dSYoshinobu Inoue 
329686cdd19SJun-ichiro itojun Hagino /* nd6_rtr.c */
330686cdd19SJun-ichiro itojun Hagino extern int nd6_defifindex;
33133841545SHajimu UMEMOTO extern int ip6_desync_factor;	/* seconds */
33233841545SHajimu UMEMOTO extern u_int32_t ip6_temp_preferred_lifetime; /* seconds */
33333841545SHajimu UMEMOTO extern u_int32_t ip6_temp_valid_lifetime; /* seconds */
33433841545SHajimu UMEMOTO extern int ip6_temp_regen_advance; /* seconds */
335686cdd19SJun-ichiro itojun Hagino 
33682cd038dSYoshinobu Inoue union nd_opts {
337f95d4633SHajimu UMEMOTO 	struct nd_opt_hdr *nd_opt_array[13];	/* max = target address list */
33882cd038dSYoshinobu Inoue 	struct {
33982cd038dSYoshinobu Inoue 		struct nd_opt_hdr *zero;
34082cd038dSYoshinobu Inoue 		struct nd_opt_hdr *src_lladdr;
34182cd038dSYoshinobu Inoue 		struct nd_opt_hdr *tgt_lladdr;
34282cd038dSYoshinobu Inoue 		struct nd_opt_prefix_info *pi_beg; /* multiple opts, start */
34382cd038dSYoshinobu Inoue 		struct nd_opt_rd_hdr *rh;
34482cd038dSYoshinobu Inoue 		struct nd_opt_mtu *mtu;
345686cdd19SJun-ichiro itojun Hagino 		struct nd_opt_hdr *six;
346f95d4633SHajimu UMEMOTO 		struct nd_opt_advinterval *adv;
347f95d4633SHajimu UMEMOTO 		struct nd_opt_homeagent_info *hai;
348f95d4633SHajimu UMEMOTO 		struct nd_opt_hdr *src_addrlist;
349f95d4633SHajimu UMEMOTO 		struct nd_opt_hdr *tgt_addrlist;
35082cd038dSYoshinobu Inoue 		struct nd_opt_hdr *search;	/* multiple opts */
35182cd038dSYoshinobu Inoue 		struct nd_opt_hdr *last;	/* multiple opts */
35282cd038dSYoshinobu Inoue 		int done;
35382cd038dSYoshinobu Inoue 		struct nd_opt_prefix_info *pi_end;/* multiple opts, end */
35482cd038dSYoshinobu Inoue 	} nd_opt_each;
35582cd038dSYoshinobu Inoue };
35682cd038dSYoshinobu Inoue #define nd_opts_src_lladdr	nd_opt_each.src_lladdr
35782cd038dSYoshinobu Inoue #define nd_opts_tgt_lladdr	nd_opt_each.tgt_lladdr
35882cd038dSYoshinobu Inoue #define nd_opts_pi		nd_opt_each.pi_beg
35982cd038dSYoshinobu Inoue #define nd_opts_pi_end		nd_opt_each.pi_end
36082cd038dSYoshinobu Inoue #define nd_opts_rh		nd_opt_each.rh
36182cd038dSYoshinobu Inoue #define nd_opts_mtu		nd_opt_each.mtu
362686cdd19SJun-ichiro itojun Hagino #define nd_opts_adv		nd_opt_each.adv
363686cdd19SJun-ichiro itojun Hagino #define nd_opts_hai		nd_opt_each.hai
364f95d4633SHajimu UMEMOTO #define nd_opts_src_addrlist	nd_opt_each.src_addrlist
365f95d4633SHajimu UMEMOTO #define nd_opts_tgt_addrlist	nd_opt_each.tgt_addrlist
36682cd038dSYoshinobu Inoue #define nd_opts_search		nd_opt_each.search
36782cd038dSYoshinobu Inoue #define nd_opts_last		nd_opt_each.last
36882cd038dSYoshinobu Inoue #define nd_opts_done		nd_opt_each.done
36982cd038dSYoshinobu Inoue 
37082cd038dSYoshinobu Inoue /* XXX: need nd6_var.h?? */
37182cd038dSYoshinobu Inoue /* nd6.c */
37282cd038dSYoshinobu Inoue void nd6_init __P((void));
37331b1bfe1SHajimu UMEMOTO struct nd_ifinfo *nd6_ifattach __P((struct ifnet *));
37431b1bfe1SHajimu UMEMOTO void nd6_ifdetach __P((struct nd_ifinfo *));
375686cdd19SJun-ichiro itojun Hagino int nd6_is_addr_neighbor __P((struct sockaddr_in6 *, struct ifnet *));
37682cd038dSYoshinobu Inoue void nd6_option_init __P((void *, int, union nd_opts *));
37782cd038dSYoshinobu Inoue struct nd_opt_hdr *nd6_option __P((union nd_opts *));
37882cd038dSYoshinobu Inoue int nd6_options __P((union nd_opts *));
37982cd038dSYoshinobu Inoue struct	rtentry *nd6_lookup __P((struct in6_addr *, int, struct ifnet *));
38082cd038dSYoshinobu Inoue void nd6_setmtu __P((struct ifnet *));
38182cd038dSYoshinobu Inoue void nd6_timer __P((void *));
382686cdd19SJun-ichiro itojun Hagino void nd6_purge __P((struct ifnet *));
38333841545SHajimu UMEMOTO struct llinfo_nd6 *nd6_free __P((struct rtentry *));
384686cdd19SJun-ichiro itojun Hagino void nd6_nud_hint __P((struct rtentry *, struct in6_addr *, int));
38507eb2995SHajimu UMEMOTO int nd6_resolve __P((struct ifnet *, struct rtentry *, struct mbuf *,
38607eb2995SHajimu UMEMOTO 	struct sockaddr *, u_char *));
3878071913dSRuslan Ermilov void nd6_rtrequest __P((int, struct rtentry *, struct rt_addrinfo *));
38882cd038dSYoshinobu Inoue int nd6_ioctl __P((u_long, caddr_t, struct ifnet *));
38982cd038dSYoshinobu Inoue struct rtentry *nd6_cache_lladdr __P((struct ifnet *, struct in6_addr *,
39082cd038dSYoshinobu Inoue 	char *, int, int, int));
391686cdd19SJun-ichiro itojun Hagino int nd6_output __P((struct ifnet *, struct ifnet *, struct mbuf *,
392686cdd19SJun-ichiro itojun Hagino 	struct sockaddr_in6 *, struct rtentry *));
39382cd038dSYoshinobu Inoue int nd6_storelladdr __P((struct ifnet *, struct rtentry *, struct mbuf *,
39482cd038dSYoshinobu Inoue 	struct sockaddr *, u_char *));
39533841545SHajimu UMEMOTO int nd6_need_cache __P((struct ifnet *));
39682cd038dSYoshinobu Inoue 
39782cd038dSYoshinobu Inoue /* nd6_nbr.c */
39882cd038dSYoshinobu Inoue void nd6_na_input __P((struct mbuf *, int, int));
39933841545SHajimu UMEMOTO void nd6_na_output __P((struct ifnet *, const struct in6_addr *,
40033841545SHajimu UMEMOTO 	const struct in6_addr *, u_long, int, struct sockaddr *));
40182cd038dSYoshinobu Inoue void nd6_ns_input __P((struct mbuf *, int, int));
40233841545SHajimu UMEMOTO void nd6_ns_output __P((struct ifnet *, const struct in6_addr *,
40333841545SHajimu UMEMOTO 	const struct in6_addr *, struct llinfo_nd6 *, int));
40482cd038dSYoshinobu Inoue caddr_t nd6_ifptomac __P((struct ifnet *));
40582cd038dSYoshinobu Inoue void nd6_dad_start __P((struct ifaddr *, int *));
40633841545SHajimu UMEMOTO void nd6_dad_stop __P((struct ifaddr *));
40782cd038dSYoshinobu Inoue void nd6_dad_duplicated __P((struct ifaddr *));
40882cd038dSYoshinobu Inoue 
40982cd038dSYoshinobu Inoue /* nd6_rtr.c */
41082cd038dSYoshinobu Inoue void nd6_rs_input __P((struct mbuf *, int, int));
41182cd038dSYoshinobu Inoue void nd6_ra_input __P((struct mbuf *, int, int));
41282cd038dSYoshinobu Inoue void prelist_del __P((struct nd_prefix *));
41382cd038dSYoshinobu Inoue void defrouter_addreq __P((struct nd_defrouter *));
41482cd038dSYoshinobu Inoue void defrouter_delreq __P((struct nd_defrouter *, int));
415686cdd19SJun-ichiro itojun Hagino void defrouter_select __P((void));
41682cd038dSYoshinobu Inoue void defrtrlist_del __P((struct nd_defrouter *));
41782cd038dSYoshinobu Inoue void prelist_remove __P((struct nd_prefix *));
41882cd038dSYoshinobu Inoue int prelist_update __P((struct nd_prefix *, struct nd_defrouter *,
41982cd038dSYoshinobu Inoue 	struct mbuf *));
42033841545SHajimu UMEMOTO int nd6_prelist_add __P((struct nd_prefix *, struct nd_defrouter *,
42133841545SHajimu UMEMOTO 	struct nd_prefix **));
42233841545SHajimu UMEMOTO int nd6_prefix_onlink __P((struct nd_prefix *));
42333841545SHajimu UMEMOTO int nd6_prefix_offlink __P((struct nd_prefix *));
424686cdd19SJun-ichiro itojun Hagino void pfxlist_onlink_check __P((void));
42507eb2995SHajimu UMEMOTO struct nd_defrouter *defrouter_lookup __P((struct in6_addr *, struct ifnet *));
42633841545SHajimu UMEMOTO struct nd_prefix *nd6_prefix_lookup __P((struct nd_prefix *));
42707eb2995SHajimu UMEMOTO int in6_init_prefix_ltimes __P((struct nd_prefix *));
42882cd038dSYoshinobu Inoue void rt6_flush __P((struct in6_addr *, struct ifnet *));
429686cdd19SJun-ichiro itojun Hagino int nd6_setdefaultiface __P((int));
43033841545SHajimu UMEMOTO int in6_tmpifadd __P((const struct in6_ifaddr *, int));
43182cd038dSYoshinobu Inoue 
43282cd038dSYoshinobu Inoue #endif /* _KERNEL */
43382cd038dSYoshinobu Inoue 
43482cd038dSYoshinobu Inoue #endif /* _NETINET6_ND6_H_ */
435