xref: /freebsd/sys/netinet6/nd6.h (revision 5b27b045791fb93e20506422eb9fff4bb856e78a)
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 
4caf43b02SWarner Losh /*-
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
915b27b045SSUZUKI Shinsuke #define ND6_IFF_PREFER_SOURCE	0x4 /* XXX: not related to ND. */
925b27b045SSUZUKI Shinsuke #define ND6_IFF_IFDISABLED	0x8 /* IPv6 operation is disabled due to
935b27b045SSUZUKI Shinsuke 				     * DAD failure.  (XXX: not ND-specific)
945b27b045SSUZUKI Shinsuke 				     */
95686cdd19SJun-ichiro itojun Hagino 
9631b1bfe1SHajimu UMEMOTO #ifdef _KERNEL
9731b1bfe1SHajimu UMEMOTO #define ND_IFINFO(ifp) \
9831b1bfe1SHajimu UMEMOTO 	(((struct in6_ifextra *)(ifp)->if_afdata[AF_INET6])->nd_ifinfo)
9931b1bfe1SHajimu UMEMOTO #define IN6_LINKMTU(ifp) \
10031b1bfe1SHajimu UMEMOTO 	((ND_IFINFO(ifp)->linkmtu && ND_IFINFO(ifp)->linkmtu < (ifp)->if_mtu) \
10131b1bfe1SHajimu UMEMOTO 	    ? ND_IFINFO(ifp)->linkmtu \
10231b1bfe1SHajimu UMEMOTO 	    : ((ND_IFINFO(ifp)->maxmtu && ND_IFINFO(ifp)->maxmtu < (ifp)->if_mtu) \
10331b1bfe1SHajimu UMEMOTO 		? ND_IFINFO(ifp)->maxmtu : (ifp)->if_mtu))
10431b1bfe1SHajimu UMEMOTO #endif
10531b1bfe1SHajimu UMEMOTO 
10682cd038dSYoshinobu Inoue struct in6_nbrinfo {
10782cd038dSYoshinobu Inoue 	char ifname[IFNAMSIZ];	/* if name, e.g. "en0" */
10882cd038dSYoshinobu Inoue 	struct in6_addr addr;	/* IPv6 address of the neighbor */
10982cd038dSYoshinobu Inoue 	long	asked;		/* number of queries already sent for this addr */
11082cd038dSYoshinobu Inoue 	int	isrouter;	/* if it acts as a router */
11182cd038dSYoshinobu Inoue 	int	state;		/* reachability state */
11282cd038dSYoshinobu Inoue 	int	expire;		/* lifetime for NDP state transition */
11382cd038dSYoshinobu Inoue };
11482cd038dSYoshinobu Inoue 
11582cd038dSYoshinobu Inoue #define DRLSTSIZ 10
11682cd038dSYoshinobu Inoue #define PRLSTSIZ 10
11782cd038dSYoshinobu Inoue struct	in6_drlist {
11882cd038dSYoshinobu Inoue 	char ifname[IFNAMSIZ];
11982cd038dSYoshinobu Inoue 	struct {
12082cd038dSYoshinobu Inoue 		struct	in6_addr rtaddr;
12182cd038dSYoshinobu Inoue 		u_char	flags;
12282cd038dSYoshinobu Inoue 		u_short	rtlifetime;
12382cd038dSYoshinobu Inoue 		u_long	expire;
12482cd038dSYoshinobu Inoue 		u_short if_index;
12582cd038dSYoshinobu Inoue 	} defrouter[DRLSTSIZ];
12682cd038dSYoshinobu Inoue };
12782cd038dSYoshinobu Inoue 
12833841545SHajimu UMEMOTO struct	in6_defrouter {
12933841545SHajimu UMEMOTO 	struct	sockaddr_in6 rtaddr;
13033841545SHajimu UMEMOTO 	u_char	flags;
13133841545SHajimu UMEMOTO 	u_short	rtlifetime;
13233841545SHajimu UMEMOTO 	u_long	expire;
13333841545SHajimu UMEMOTO 	u_short if_index;
13423cd8d58SHidetoshi Shimokawa };
13533841545SHajimu UMEMOTO 
136f95d4633SHajimu UMEMOTO #ifdef _KERNEL
137f95d4633SHajimu UMEMOTO struct	in6_oprlist {
138f95d4633SHajimu UMEMOTO 	char ifname[IFNAMSIZ];
139f95d4633SHajimu UMEMOTO 	struct {
140f95d4633SHajimu UMEMOTO 		struct	in6_addr prefix;
141f95d4633SHajimu UMEMOTO 		struct prf_ra raflags;
142f95d4633SHajimu UMEMOTO 		u_char	prefixlen;
143f95d4633SHajimu UMEMOTO 		u_char	origin;
144f95d4633SHajimu UMEMOTO 		u_long vltime;
145f95d4633SHajimu UMEMOTO 		u_long pltime;
146f95d4633SHajimu UMEMOTO 		u_long expire;
147f95d4633SHajimu UMEMOTO 		u_short if_index;
148f95d4633SHajimu UMEMOTO 		u_short advrtrs; /* number of advertisement routers */
149f95d4633SHajimu UMEMOTO 		struct	in6_addr advrtr[DRLSTSIZ]; /* XXX: explicit limit */
150f95d4633SHajimu UMEMOTO 	} prefix[PRLSTSIZ];
151f95d4633SHajimu UMEMOTO };
152f95d4633SHajimu UMEMOTO #endif
153f95d4633SHajimu UMEMOTO 
15482cd038dSYoshinobu Inoue struct	in6_prlist {
15582cd038dSYoshinobu Inoue 	char ifname[IFNAMSIZ];
15682cd038dSYoshinobu Inoue 	struct {
15782cd038dSYoshinobu Inoue 		struct	in6_addr prefix;
15882cd038dSYoshinobu Inoue 		struct prf_ra raflags;
15982cd038dSYoshinobu Inoue 		u_char	prefixlen;
160686cdd19SJun-ichiro itojun Hagino 		u_char	origin;
16188ff5695SSUZUKI Shinsuke 		u_int32_t vltime;
16288ff5695SSUZUKI Shinsuke 		u_int32_t pltime;
16388ff5695SSUZUKI Shinsuke 		time_t expire;
16482cd038dSYoshinobu Inoue 		u_short if_index;
16582cd038dSYoshinobu Inoue 		u_short advrtrs; /* number of advertisement routers */
16682cd038dSYoshinobu Inoue 		struct	in6_addr advrtr[DRLSTSIZ]; /* XXX: explicit limit */
16782cd038dSYoshinobu Inoue 	} prefix[PRLSTSIZ];
16882cd038dSYoshinobu Inoue };
16982cd038dSYoshinobu Inoue 
17033841545SHajimu UMEMOTO struct in6_prefix {
17133841545SHajimu UMEMOTO 	struct	sockaddr_in6 prefix;
17233841545SHajimu UMEMOTO 	struct prf_ra raflags;
17333841545SHajimu UMEMOTO 	u_char	prefixlen;
17433841545SHajimu UMEMOTO 	u_char	origin;
175f95d4633SHajimu UMEMOTO 	u_int32_t vltime;
176f95d4633SHajimu UMEMOTO 	u_int32_t pltime;
177f95d4633SHajimu UMEMOTO 	time_t expire;
17833841545SHajimu UMEMOTO 	u_int32_t flags;
17933841545SHajimu UMEMOTO 	int refcnt;
18033841545SHajimu UMEMOTO 	u_short if_index;
18133841545SHajimu UMEMOTO 	u_short advrtrs; /* number of advertisement routers */
18233841545SHajimu UMEMOTO 	/* struct sockaddr_in6 advrtr[] */
18323cd8d58SHidetoshi Shimokawa };
18433841545SHajimu UMEMOTO 
18533841545SHajimu UMEMOTO #ifdef _KERNEL
18633841545SHajimu UMEMOTO struct	in6_ondireq {
18733841545SHajimu UMEMOTO 	char ifname[IFNAMSIZ];
18833841545SHajimu UMEMOTO 	struct {
18933841545SHajimu UMEMOTO 		u_int32_t linkmtu;	/* LinkMTU */
19033841545SHajimu UMEMOTO 		u_int32_t maxmtu;	/* Upper bound of LinkMTU */
19133841545SHajimu UMEMOTO 		u_int32_t basereachable; /* BaseReachableTime */
19233841545SHajimu UMEMOTO 		u_int32_t reachable;	/* Reachable Time */
19333841545SHajimu UMEMOTO 		u_int32_t retrans;	/* Retrans Timer */
19433841545SHajimu UMEMOTO 		u_int32_t flags;	/* Flags */
19533841545SHajimu UMEMOTO 		int recalctm;		/* BaseReacable re-calculation timer */
19633841545SHajimu UMEMOTO 		u_int8_t chlim;		/* CurHopLimit */
19733841545SHajimu UMEMOTO 		u_int8_t receivedra;
19833841545SHajimu UMEMOTO 	} ndi;
19933841545SHajimu UMEMOTO };
20033841545SHajimu UMEMOTO #endif
20133841545SHajimu UMEMOTO 
20282cd038dSYoshinobu Inoue struct	in6_ndireq {
20382cd038dSYoshinobu Inoue 	char ifname[IFNAMSIZ];
20482cd038dSYoshinobu Inoue 	struct nd_ifinfo ndi;
20582cd038dSYoshinobu Inoue };
20682cd038dSYoshinobu Inoue 
207686cdd19SJun-ichiro itojun Hagino struct	in6_ndifreq {
208686cdd19SJun-ichiro itojun Hagino 	char ifname[IFNAMSIZ];
209686cdd19SJun-ichiro itojun Hagino 	u_long ifindex;
210686cdd19SJun-ichiro itojun Hagino };
211686cdd19SJun-ichiro itojun Hagino 
21233841545SHajimu UMEMOTO /* Prefix status */
21333841545SHajimu UMEMOTO #define NDPRF_ONLINK		0x1
21433841545SHajimu UMEMOTO #define NDPRF_DETACHED		0x2
215686cdd19SJun-ichiro itojun Hagino 
21682cd038dSYoshinobu Inoue /* protocol constants */
21782cd038dSYoshinobu Inoue #define MAX_RTR_SOLICITATION_DELAY	1	/* 1sec */
21882cd038dSYoshinobu Inoue #define RTR_SOLICITATION_INTERVAL	4	/* 4sec */
21982cd038dSYoshinobu Inoue #define MAX_RTR_SOLICITATIONS		3
22082cd038dSYoshinobu Inoue 
22182cd038dSYoshinobu Inoue #define ND6_INFINITE_LIFETIME		0xffffffff
22282cd038dSYoshinobu Inoue 
22382cd038dSYoshinobu Inoue #ifdef _KERNEL
22482cd038dSYoshinobu Inoue /* node constants */
22582cd038dSYoshinobu Inoue #define MAX_REACHABLE_TIME		3600000	/* msec */
22682cd038dSYoshinobu Inoue #define REACHABLE_TIME			30000	/* msec */
22782cd038dSYoshinobu Inoue #define RETRANS_TIMER			1000	/* msec */
22882cd038dSYoshinobu Inoue #define MIN_RANDOM_FACTOR		512	/* 1024 * 0.5 */
22982cd038dSYoshinobu Inoue #define MAX_RANDOM_FACTOR		1536	/* 1024 * 1.5 */
23033841545SHajimu UMEMOTO #define DEF_TEMP_VALID_LIFETIME		604800	/* 1 week */
23133841545SHajimu UMEMOTO #define DEF_TEMP_PREFERRED_LIFETIME	86400	/* 1 day */
23233841545SHajimu UMEMOTO #define TEMPADDR_REGEN_ADVANCE		5	/* sec */
23333841545SHajimu UMEMOTO #define MAX_TEMP_DESYNC_FACTOR		600	/* 10 min */
23482cd038dSYoshinobu Inoue #define ND_COMPUTE_RTIME(x) \
235a02e1e2bSHajimu UMEMOTO 		(((MIN_RANDOM_FACTOR * (x >> 10)) + (arc4random() & \
23682cd038dSYoshinobu Inoue 		((MAX_RANDOM_FACTOR - MIN_RANDOM_FACTOR) * (x >> 10)))) /1000)
23782cd038dSYoshinobu Inoue 
238686cdd19SJun-ichiro itojun Hagino TAILQ_HEAD(nd_drhead, nd_defrouter);
23982cd038dSYoshinobu Inoue struct	nd_defrouter {
240686cdd19SJun-ichiro itojun Hagino 	TAILQ_ENTRY(nd_defrouter) dr_entry;
24182cd038dSYoshinobu Inoue 	struct	in6_addr rtaddr;
24288ff5695SSUZUKI Shinsuke 	u_char	flags;		/* flags on RA message */
24382cd038dSYoshinobu Inoue 	u_short	rtlifetime;
24482cd038dSYoshinobu Inoue 	u_long	expire;
24582cd038dSYoshinobu Inoue 	struct  ifnet *ifp;
24682cd038dSYoshinobu Inoue };
24782cd038dSYoshinobu Inoue 
24882cd038dSYoshinobu Inoue struct nd_prefix {
24982cd038dSYoshinobu Inoue 	struct ifnet *ndpr_ifp;
250e3975643SJake Burkholder 	LIST_ENTRY(nd_prefix) ndpr_entry;
25182cd038dSYoshinobu Inoue 	struct sockaddr_in6 ndpr_prefix;	/* prefix */
25282cd038dSYoshinobu Inoue 	struct in6_addr ndpr_mask; /* netmask derived from the prefix */
25382cd038dSYoshinobu Inoue 	struct in6_addr ndpr_addr; /* address that is derived from the prefix */
25482cd038dSYoshinobu Inoue 	u_int32_t ndpr_vltime;	/* advertised valid lifetime */
25582cd038dSYoshinobu Inoue 	u_int32_t ndpr_pltime;	/* advertised preferred lifetime */
25682cd038dSYoshinobu Inoue 	time_t ndpr_expire;	/* expiration time of the prefix */
25782cd038dSYoshinobu Inoue 	time_t ndpr_preferred;	/* preferred time of the prefix */
25882cd038dSYoshinobu Inoue 	struct prf_ra ndpr_flags;
25933841545SHajimu UMEMOTO 	u_int32_t ndpr_stateflags; /* actual state flags */
26082cd038dSYoshinobu Inoue 	/* list of routers that advertise the prefix: */
261e3975643SJake Burkholder 	LIST_HEAD(pr_rtrhead, nd_pfxrouter) ndpr_advrtrs;
26282cd038dSYoshinobu Inoue 	u_char	ndpr_plen;
26333841545SHajimu UMEMOTO 	int	ndpr_refcnt;	/* reference couter from addresses */
26482cd038dSYoshinobu Inoue };
26582cd038dSYoshinobu Inoue 
266686cdd19SJun-ichiro itojun Hagino #define ndpr_next		ndpr_entry.le_next
267686cdd19SJun-ichiro itojun Hagino 
26882cd038dSYoshinobu Inoue #define ndpr_raf		ndpr_flags
26982cd038dSYoshinobu Inoue #define ndpr_raf_onlink		ndpr_flags.onlink
27082cd038dSYoshinobu Inoue #define ndpr_raf_auto		ndpr_flags.autonomous
27182cd038dSYoshinobu Inoue 
27282cd038dSYoshinobu Inoue /*
27382cd038dSYoshinobu Inoue  * We keep expired prefix for certain amount of time, for validation purposes.
27482cd038dSYoshinobu Inoue  * 1800s = MaxRtrAdvInterval
27582cd038dSYoshinobu Inoue  */
27682cd038dSYoshinobu Inoue #define NDPR_KEEP_EXPIRED	(1800 * 2)
27782cd038dSYoshinobu Inoue 
27882cd038dSYoshinobu Inoue /*
27982cd038dSYoshinobu Inoue  * Message format for use in obtaining information about prefixes
28082cd038dSYoshinobu Inoue  * from inet6 sysctl function
28182cd038dSYoshinobu Inoue  */
28282cd038dSYoshinobu Inoue struct inet6_ndpr_msghdr {
28382cd038dSYoshinobu Inoue 	u_short	inpm_msglen;	/* to skip over non-understood messages */
2842fa72ea7SJeroen Ruigrok van der Werven 	u_char	inpm_version;	/* future binary compatibility */
28582cd038dSYoshinobu Inoue 	u_char	inpm_type;	/* message type */
28682cd038dSYoshinobu Inoue 	struct in6_addr inpm_prefix;
28782cd038dSYoshinobu Inoue 	u_long	prm_vltim;
28882cd038dSYoshinobu Inoue 	u_long	prm_pltime;
28982cd038dSYoshinobu Inoue 	u_long	prm_expire;
29082cd038dSYoshinobu Inoue 	u_long	prm_preferred;
29182cd038dSYoshinobu Inoue 	struct in6_prflags prm_flags;
29282cd038dSYoshinobu Inoue 	u_short	prm_index;	/* index for associated ifp */
29382cd038dSYoshinobu Inoue 	u_char	prm_plen;	/* length of prefix in bits */
29482cd038dSYoshinobu Inoue };
29582cd038dSYoshinobu Inoue 
29682cd038dSYoshinobu Inoue #define prm_raf_onlink		prm_flags.prf_ra.onlink
29782cd038dSYoshinobu Inoue #define prm_raf_auto		prm_flags.prf_ra.autonomous
29882cd038dSYoshinobu Inoue 
29982cd038dSYoshinobu Inoue #define prm_statef_onlink	prm_flags.prf_state.onlink
30082cd038dSYoshinobu Inoue 
30182cd038dSYoshinobu Inoue #define prm_rrf_decrvalid	prm_flags.prf_rr.decrvalid
30282cd038dSYoshinobu Inoue #define prm_rrf_decrprefd	prm_flags.prf_rr.decrprefd
30382cd038dSYoshinobu Inoue 
30482cd038dSYoshinobu Inoue #define ifpr2ndpr(ifpr)	((struct nd_prefix *)(ifpr))
30582cd038dSYoshinobu Inoue #define ndpr2ifpr(ndpr)	((struct ifprefix *)(ndpr))
30682cd038dSYoshinobu Inoue 
30782cd038dSYoshinobu Inoue struct nd_pfxrouter {
308e3975643SJake Burkholder 	LIST_ENTRY(nd_pfxrouter) pfr_entry;
309686cdd19SJun-ichiro itojun Hagino #define pfr_next pfr_entry.le_next
31082cd038dSYoshinobu Inoue 	struct nd_defrouter *router;
31182cd038dSYoshinobu Inoue };
31282cd038dSYoshinobu Inoue 
313e3975643SJake Burkholder LIST_HEAD(nd_prhead, nd_prefix);
31482cd038dSYoshinobu Inoue 
31582cd038dSYoshinobu Inoue /* nd6.c */
31682cd038dSYoshinobu Inoue extern int nd6_prune;
31782cd038dSYoshinobu Inoue extern int nd6_delay;
31882cd038dSYoshinobu Inoue extern int nd6_umaxtries;
31982cd038dSYoshinobu Inoue extern int nd6_mmaxtries;
32082cd038dSYoshinobu Inoue extern int nd6_useloopback;
321686cdd19SJun-ichiro itojun Hagino extern int nd6_maxnudhint;
32233841545SHajimu UMEMOTO extern int nd6_gctimer;
32382cd038dSYoshinobu Inoue extern struct llinfo_nd6 llinfo_nd6;
32482cd038dSYoshinobu Inoue extern struct nd_ifinfo *nd_ifinfo;
32582cd038dSYoshinobu Inoue extern struct nd_drhead nd_defrouter;
32682cd038dSYoshinobu Inoue extern struct nd_prhead nd_prefix;
32733841545SHajimu UMEMOTO extern int nd6_debug;
32833841545SHajimu UMEMOTO 
32907eb2995SHajimu UMEMOTO #define nd6log(x)	do { if (nd6_debug) log x; } while (/*CONSTCOND*/ 0)
33033841545SHajimu UMEMOTO 
33133841545SHajimu UMEMOTO extern struct callout nd6_timer_ch;
33282cd038dSYoshinobu Inoue 
333686cdd19SJun-ichiro itojun Hagino /* nd6_rtr.c */
334686cdd19SJun-ichiro itojun Hagino extern int nd6_defifindex;
33533841545SHajimu UMEMOTO extern int ip6_desync_factor;	/* seconds */
33633841545SHajimu UMEMOTO extern u_int32_t ip6_temp_preferred_lifetime; /* seconds */
33733841545SHajimu UMEMOTO extern u_int32_t ip6_temp_valid_lifetime; /* seconds */
33833841545SHajimu UMEMOTO extern int ip6_temp_regen_advance; /* seconds */
339686cdd19SJun-ichiro itojun Hagino 
34082cd038dSYoshinobu Inoue union nd_opts {
341fe01034aSHajimu UMEMOTO 	struct nd_opt_hdr *nd_opt_array[8];	/* max = target address list */
34282cd038dSYoshinobu Inoue 	struct {
34382cd038dSYoshinobu Inoue 		struct nd_opt_hdr *zero;
34482cd038dSYoshinobu Inoue 		struct nd_opt_hdr *src_lladdr;
34582cd038dSYoshinobu Inoue 		struct nd_opt_hdr *tgt_lladdr;
34682cd038dSYoshinobu Inoue 		struct nd_opt_prefix_info *pi_beg; /* multiple opts, start */
34782cd038dSYoshinobu Inoue 		struct nd_opt_rd_hdr *rh;
34882cd038dSYoshinobu Inoue 		struct nd_opt_mtu *mtu;
34982cd038dSYoshinobu Inoue 		struct nd_opt_hdr *search;	/* multiple opts */
35082cd038dSYoshinobu Inoue 		struct nd_opt_hdr *last;	/* multiple opts */
35182cd038dSYoshinobu Inoue 		int done;
35282cd038dSYoshinobu Inoue 		struct nd_opt_prefix_info *pi_end;/* multiple opts, end */
35382cd038dSYoshinobu Inoue 	} nd_opt_each;
35482cd038dSYoshinobu Inoue };
35582cd038dSYoshinobu Inoue #define nd_opts_src_lladdr	nd_opt_each.src_lladdr
35682cd038dSYoshinobu Inoue #define nd_opts_tgt_lladdr	nd_opt_each.tgt_lladdr
35782cd038dSYoshinobu Inoue #define nd_opts_pi		nd_opt_each.pi_beg
35882cd038dSYoshinobu Inoue #define nd_opts_pi_end		nd_opt_each.pi_end
35982cd038dSYoshinobu Inoue #define nd_opts_rh		nd_opt_each.rh
36082cd038dSYoshinobu Inoue #define nd_opts_mtu		nd_opt_each.mtu
36182cd038dSYoshinobu Inoue #define nd_opts_search		nd_opt_each.search
36282cd038dSYoshinobu Inoue #define nd_opts_last		nd_opt_each.last
36382cd038dSYoshinobu Inoue #define nd_opts_done		nd_opt_each.done
36482cd038dSYoshinobu Inoue 
36582cd038dSYoshinobu Inoue /* XXX: need nd6_var.h?? */
36682cd038dSYoshinobu Inoue /* nd6.c */
36782cd038dSYoshinobu Inoue void nd6_init __P((void));
36831b1bfe1SHajimu UMEMOTO struct nd_ifinfo *nd6_ifattach __P((struct ifnet *));
36931b1bfe1SHajimu UMEMOTO void nd6_ifdetach __P((struct nd_ifinfo *));
370686cdd19SJun-ichiro itojun Hagino int nd6_is_addr_neighbor __P((struct sockaddr_in6 *, struct ifnet *));
37182cd038dSYoshinobu Inoue void nd6_option_init __P((void *, int, union nd_opts *));
37282cd038dSYoshinobu Inoue struct nd_opt_hdr *nd6_option __P((union nd_opts *));
37382cd038dSYoshinobu Inoue int nd6_options __P((union nd_opts *));
37482cd038dSYoshinobu Inoue struct	rtentry *nd6_lookup __P((struct in6_addr *, int, struct ifnet *));
37582cd038dSYoshinobu Inoue void nd6_setmtu __P((struct ifnet *));
37682cd038dSYoshinobu Inoue void nd6_timer __P((void *));
377686cdd19SJun-ichiro itojun Hagino void nd6_purge __P((struct ifnet *));
37833841545SHajimu UMEMOTO struct llinfo_nd6 *nd6_free __P((struct rtentry *));
379686cdd19SJun-ichiro itojun Hagino void nd6_nud_hint __P((struct rtentry *, struct in6_addr *, int));
38007eb2995SHajimu UMEMOTO int nd6_resolve __P((struct ifnet *, struct rtentry *, struct mbuf *,
38107eb2995SHajimu UMEMOTO 	struct sockaddr *, u_char *));
3828071913dSRuslan Ermilov void nd6_rtrequest __P((int, struct rtentry *, struct rt_addrinfo *));
38382cd038dSYoshinobu Inoue int nd6_ioctl __P((u_long, caddr_t, struct ifnet *));
38482cd038dSYoshinobu Inoue struct rtentry *nd6_cache_lladdr __P((struct ifnet *, struct in6_addr *,
38582cd038dSYoshinobu Inoue 	char *, int, int, int));
386686cdd19SJun-ichiro itojun Hagino int nd6_output __P((struct ifnet *, struct ifnet *, struct mbuf *,
387686cdd19SJun-ichiro itojun Hagino 	struct sockaddr_in6 *, struct rtentry *));
38882cd038dSYoshinobu Inoue int nd6_storelladdr __P((struct ifnet *, struct rtentry *, struct mbuf *,
38982cd038dSYoshinobu Inoue 	struct sockaddr *, u_char *));
39033841545SHajimu UMEMOTO int nd6_need_cache __P((struct ifnet *));
39182cd038dSYoshinobu Inoue 
39282cd038dSYoshinobu Inoue /* nd6_nbr.c */
39382cd038dSYoshinobu Inoue void nd6_na_input __P((struct mbuf *, int, int));
39433841545SHajimu UMEMOTO void nd6_na_output __P((struct ifnet *, const struct in6_addr *,
39533841545SHajimu UMEMOTO 	const struct in6_addr *, u_long, int, struct sockaddr *));
39682cd038dSYoshinobu Inoue void nd6_ns_input __P((struct mbuf *, int, int));
39733841545SHajimu UMEMOTO void nd6_ns_output __P((struct ifnet *, const struct in6_addr *,
39833841545SHajimu UMEMOTO 	const struct in6_addr *, struct llinfo_nd6 *, int));
39982cd038dSYoshinobu Inoue caddr_t nd6_ifptomac __P((struct ifnet *));
40082cd038dSYoshinobu Inoue void nd6_dad_start __P((struct ifaddr *, int *));
40133841545SHajimu UMEMOTO void nd6_dad_stop __P((struct ifaddr *));
40282cd038dSYoshinobu Inoue void nd6_dad_duplicated __P((struct ifaddr *));
40382cd038dSYoshinobu Inoue 
40482cd038dSYoshinobu Inoue /* nd6_rtr.c */
40582cd038dSYoshinobu Inoue void nd6_rs_input __P((struct mbuf *, int, int));
40682cd038dSYoshinobu Inoue void nd6_ra_input __P((struct mbuf *, int, int));
40782cd038dSYoshinobu Inoue void prelist_del __P((struct nd_prefix *));
40882cd038dSYoshinobu Inoue void defrouter_addreq __P((struct nd_defrouter *));
40982cd038dSYoshinobu Inoue void defrouter_delreq __P((struct nd_defrouter *, int));
410686cdd19SJun-ichiro itojun Hagino void defrouter_select __P((void));
41182cd038dSYoshinobu Inoue void defrtrlist_del __P((struct nd_defrouter *));
41282cd038dSYoshinobu Inoue void prelist_remove __P((struct nd_prefix *));
41382cd038dSYoshinobu Inoue int prelist_update __P((struct nd_prefix *, struct nd_defrouter *,
41482cd038dSYoshinobu Inoue 	struct mbuf *));
41533841545SHajimu UMEMOTO int nd6_prelist_add __P((struct nd_prefix *, struct nd_defrouter *,
41633841545SHajimu UMEMOTO 	struct nd_prefix **));
41733841545SHajimu UMEMOTO int nd6_prefix_onlink __P((struct nd_prefix *));
41833841545SHajimu UMEMOTO int nd6_prefix_offlink __P((struct nd_prefix *));
419686cdd19SJun-ichiro itojun Hagino void pfxlist_onlink_check __P((void));
42007eb2995SHajimu UMEMOTO struct nd_defrouter *defrouter_lookup __P((struct in6_addr *, struct ifnet *));
42133841545SHajimu UMEMOTO struct nd_prefix *nd6_prefix_lookup __P((struct nd_prefix *));
42207eb2995SHajimu UMEMOTO int in6_init_prefix_ltimes __P((struct nd_prefix *));
42382cd038dSYoshinobu Inoue void rt6_flush __P((struct in6_addr *, struct ifnet *));
424686cdd19SJun-ichiro itojun Hagino int nd6_setdefaultiface __P((int));
42533841545SHajimu UMEMOTO int in6_tmpifadd __P((const struct in6_ifaddr *, int));
42682cd038dSYoshinobu Inoue 
42782cd038dSYoshinobu Inoue #endif /* _KERNEL */
42882cd038dSYoshinobu Inoue 
42982cd038dSYoshinobu Inoue #endif /* _NETINET6_ND6_H_ */
430