xref: /freebsd/sys/netinet6/in6_var.h (revision 31b1bfe1b0a6223ca75c72fd80c2a02c33a1fd20)
1686cdd19SJun-ichiro itojun Hagino /*	$FreeBSD$	*/
233841545SHajimu UMEMOTO /*	$KAME: in6_var.h,v 1.56 2001/03/29 05:34:31 itojun Exp $	*/
3686cdd19SJun-ichiro itojun Hagino 
476429de4SYoshinobu Inoue /*
576429de4SYoshinobu Inoue  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
676429de4SYoshinobu Inoue  * All rights reserved.
776429de4SYoshinobu Inoue  *
876429de4SYoshinobu Inoue  * Redistribution and use in source and binary forms, with or without
976429de4SYoshinobu Inoue  * modification, are permitted provided that the following conditions
1076429de4SYoshinobu Inoue  * are met:
1176429de4SYoshinobu Inoue  * 1. Redistributions of source code must retain the above copyright
1276429de4SYoshinobu Inoue  *    notice, this list of conditions and the following disclaimer.
1376429de4SYoshinobu Inoue  * 2. Redistributions in binary form must reproduce the above copyright
1476429de4SYoshinobu Inoue  *    notice, this list of conditions and the following disclaimer in the
1576429de4SYoshinobu Inoue  *    documentation and/or other materials provided with the distribution.
1676429de4SYoshinobu Inoue  * 3. Neither the name of the project nor the names of its contributors
1776429de4SYoshinobu Inoue  *    may be used to endorse or promote products derived from this software
1876429de4SYoshinobu Inoue  *    without specific prior written permission.
1976429de4SYoshinobu Inoue  *
2076429de4SYoshinobu Inoue  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
2176429de4SYoshinobu Inoue  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2276429de4SYoshinobu Inoue  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2376429de4SYoshinobu Inoue  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
2476429de4SYoshinobu Inoue  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2576429de4SYoshinobu Inoue  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2676429de4SYoshinobu Inoue  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2776429de4SYoshinobu Inoue  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2876429de4SYoshinobu Inoue  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2976429de4SYoshinobu Inoue  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3076429de4SYoshinobu Inoue  * SUCH DAMAGE.
3176429de4SYoshinobu Inoue  */
3276429de4SYoshinobu Inoue 
3376429de4SYoshinobu Inoue /*
3476429de4SYoshinobu Inoue  * Copyright (c) 1985, 1986, 1993
3576429de4SYoshinobu Inoue  *	The Regents of the University of California.  All rights reserved.
3676429de4SYoshinobu Inoue  *
3776429de4SYoshinobu Inoue  * Redistribution and use in source and binary forms, with or without
3876429de4SYoshinobu Inoue  * modification, are permitted provided that the following conditions
3976429de4SYoshinobu Inoue  * are met:
4076429de4SYoshinobu Inoue  * 1. Redistributions of source code must retain the above copyright
4176429de4SYoshinobu Inoue  *    notice, this list of conditions and the following disclaimer.
4276429de4SYoshinobu Inoue  * 2. Redistributions in binary form must reproduce the above copyright
4376429de4SYoshinobu Inoue  *    notice, this list of conditions and the following disclaimer in the
4476429de4SYoshinobu Inoue  *    documentation and/or other materials provided with the distribution.
4576429de4SYoshinobu Inoue  * 3. All advertising materials mentioning features or use of this software
4676429de4SYoshinobu Inoue  *    must display the following acknowledgement:
4776429de4SYoshinobu Inoue  *	This product includes software developed by the University of
4876429de4SYoshinobu Inoue  *	California, Berkeley and its contributors.
4976429de4SYoshinobu Inoue  * 4. Neither the name of the University nor the names of its contributors
5076429de4SYoshinobu Inoue  *    may be used to endorse or promote products derived from this software
5176429de4SYoshinobu Inoue  *    without specific prior written permission.
5276429de4SYoshinobu Inoue  *
5376429de4SYoshinobu Inoue  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
5476429de4SYoshinobu Inoue  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5576429de4SYoshinobu Inoue  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
5676429de4SYoshinobu Inoue  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
5776429de4SYoshinobu Inoue  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5876429de4SYoshinobu Inoue  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
5976429de4SYoshinobu Inoue  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
6076429de4SYoshinobu Inoue  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
6176429de4SYoshinobu Inoue  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
6276429de4SYoshinobu Inoue  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
6376429de4SYoshinobu Inoue  * SUCH DAMAGE.
6476429de4SYoshinobu Inoue  *
6576429de4SYoshinobu Inoue  *	@(#)in_var.h	8.1 (Berkeley) 6/10/93
6676429de4SYoshinobu Inoue  */
6776429de4SYoshinobu Inoue 
6876429de4SYoshinobu Inoue #ifndef _NETINET6_IN6_VAR_H_
6976429de4SYoshinobu Inoue #define _NETINET6_IN6_VAR_H_
7076429de4SYoshinobu Inoue 
7176429de4SYoshinobu Inoue /*
7276429de4SYoshinobu Inoue  * Interface address, Internet version.  One of these structures
7376429de4SYoshinobu Inoue  * is allocated for each interface with an Internet address.
7476429de4SYoshinobu Inoue  * The ifaddr structure contains the protocol-independent part
7576429de4SYoshinobu Inoue  * of the structure and is assumed to be first.
7676429de4SYoshinobu Inoue  */
7776429de4SYoshinobu Inoue 
7876429de4SYoshinobu Inoue /*
7976429de4SYoshinobu Inoue  * pltime/vltime are just for future reference (required to implements 2
8076429de4SYoshinobu Inoue  * hour rule for hosts).  they should never be modified by nd6_timeout or
8176429de4SYoshinobu Inoue  * anywhere else.
8276429de4SYoshinobu Inoue  *	userland -> kernel: accept pltime/vltime
8388ff5695SSUZUKI Shinsuke  *	kernel -> userland: throw up everything
8476429de4SYoshinobu Inoue  *	in kernel: modify preferred/expire only
8576429de4SYoshinobu Inoue  */
8676429de4SYoshinobu Inoue struct in6_addrlifetime {
8776429de4SYoshinobu Inoue 	time_t ia6t_expire;	/* valid lifetime expiration time */
8876429de4SYoshinobu Inoue 	time_t ia6t_preferred;	/* preferred lifetime expiration time */
8976429de4SYoshinobu Inoue 	u_int32_t ia6t_vltime;	/* valid lifetime */
9076429de4SYoshinobu Inoue 	u_int32_t ia6t_pltime;	/* prefix lifetime */
9176429de4SYoshinobu Inoue };
9276429de4SYoshinobu Inoue 
9331b1bfe1SHajimu UMEMOTO struct nd_ifinfo;
9431b1bfe1SHajimu UMEMOTO struct scope6_id;
9531b1bfe1SHajimu UMEMOTO struct in6_ifextra {
9631b1bfe1SHajimu UMEMOTO 	struct in6_ifstat *in6_ifstat;
9731b1bfe1SHajimu UMEMOTO 	struct icmp6_ifstat *icmp6_ifstat;
9831b1bfe1SHajimu UMEMOTO 	struct nd_ifinfo *nd_ifinfo;
9931b1bfe1SHajimu UMEMOTO 	struct scope6_id *scope6_id;
10031b1bfe1SHajimu UMEMOTO };
10131b1bfe1SHajimu UMEMOTO 
10276429de4SYoshinobu Inoue struct	in6_ifaddr {
10376429de4SYoshinobu Inoue 	struct	ifaddr ia_ifa;		/* protocol-independent info */
10476429de4SYoshinobu Inoue #define	ia_ifp		ia_ifa.ifa_ifp
10576429de4SYoshinobu Inoue #define ia_flags	ia_ifa.ifa_flags
10676429de4SYoshinobu Inoue 	struct	sockaddr_in6 ia_addr;	/* interface address */
10776429de4SYoshinobu Inoue 	struct	sockaddr_in6 ia_net;	/* network number of interface */
10876429de4SYoshinobu Inoue 	struct	sockaddr_in6 ia_dstaddr; /* space for destination addr */
10976429de4SYoshinobu Inoue 	struct	sockaddr_in6 ia_prefixmask; /* prefix mask */
11076429de4SYoshinobu Inoue 	u_int32_t ia_plen;		/* prefix length */
11176429de4SYoshinobu Inoue 	struct	in6_ifaddr *ia_next;	/* next in6 list of IP6 addresses */
11276429de4SYoshinobu Inoue 	int	ia6_flags;
11376429de4SYoshinobu Inoue 
11433841545SHajimu UMEMOTO 	struct in6_addrlifetime ia6_lifetime;
11576429de4SYoshinobu Inoue 	struct ifprefix *ia6_ifpr; /* back pointer to ifprefix */
11633841545SHajimu UMEMOTO 
1177efe5d92SHajimu UMEMOTO 	/* back pointer to the ND prefix (for autoconfigured addresses only) */
1187efe5d92SHajimu UMEMOTO 	struct nd_prefix *ia6_ndpr;
11976429de4SYoshinobu Inoue };
12076429de4SYoshinobu Inoue 
12176429de4SYoshinobu Inoue /*
12276429de4SYoshinobu Inoue  * IPv6 interface statistics, as defined in RFC2465 Ipv6IfStatsEntry (p12).
12376429de4SYoshinobu Inoue  */
12476429de4SYoshinobu Inoue struct in6_ifstat {
125686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_in_receive;	/* # of total input datagram */
126686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_in_hdrerr;	/* # of datagrams with invalid hdr */
127686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_in_toobig;	/* # of datagrams exceeded MTU */
128686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_in_noroute;	/* # of datagrams with no route */
129686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_in_addrerr;	/* # of datagrams with invalid dst */
130686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_in_protounknown;	/* # of datagrams with unknown proto */
13176429de4SYoshinobu Inoue 					/* NOTE: increment on final dst if */
132686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_in_truncated;	/* # of truncated datagrams */
133686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_in_discard;	/* # of discarded datagrams */
13476429de4SYoshinobu Inoue 					/* NOTE: fragment timeout is not here */
135686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_in_deliver;	/* # of datagrams delivered to ULP */
13676429de4SYoshinobu Inoue 					/* NOTE: increment on final dst if */
137686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_out_forward;	/* # of datagrams forwarded */
13876429de4SYoshinobu Inoue 					/* NOTE: increment on outgoing if */
139686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_out_request;	/* # of outgoing datagrams from ULP */
14076429de4SYoshinobu Inoue 					/* NOTE: does not include forwrads */
141686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_out_discard;	/* # of discarded datagrams */
142686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_out_fragok;	/* # of datagrams fragmented */
143686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_out_fragfail;	/* # of datagrams failed on fragment */
144686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_out_fragcreat;	/* # of fragment datagrams */
14576429de4SYoshinobu Inoue 					/* NOTE: this is # after fragment */
146686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_reass_reqd;	/* # of incoming fragmented packets */
14776429de4SYoshinobu Inoue 					/* NOTE: increment on final dst if */
148686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_reass_ok;		/* # of reassembled packets */
14976429de4SYoshinobu Inoue 					/* NOTE: this is # after reass */
15076429de4SYoshinobu Inoue 					/* NOTE: increment on final dst if */
151686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_reass_fail;	/* # of reass failures */
15276429de4SYoshinobu Inoue 					/* NOTE: may not be packet count */
15376429de4SYoshinobu Inoue 					/* NOTE: increment on final dst if */
154686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_in_mcast;		/* # of inbound multicast datagrams */
155686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_out_mcast;	/* # of outbound multicast datagrams */
15676429de4SYoshinobu Inoue };
15776429de4SYoshinobu Inoue 
15876429de4SYoshinobu Inoue /*
15976429de4SYoshinobu Inoue  * ICMPv6 interface statistics, as defined in RFC2466 Ipv6IfIcmpEntry.
16076429de4SYoshinobu Inoue  * XXX: I'm not sure if this file is the right place for this structure...
16176429de4SYoshinobu Inoue  */
16276429de4SYoshinobu Inoue struct icmp6_ifstat {
16376429de4SYoshinobu Inoue 	/*
16476429de4SYoshinobu Inoue 	 * Input statistics
16576429de4SYoshinobu Inoue 	 */
16676429de4SYoshinobu Inoue 	/* ipv6IfIcmpInMsgs, total # of input messages */
167686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_in_msg;
16876429de4SYoshinobu Inoue 	/* ipv6IfIcmpInErrors, # of input error messages */
169686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_in_error;
17076429de4SYoshinobu Inoue 	/* ipv6IfIcmpInDestUnreachs, # of input dest unreach errors */
171686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_in_dstunreach;
17276429de4SYoshinobu Inoue 	/* ipv6IfIcmpInAdminProhibs, # of input administratively prohibited errs */
173686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_in_adminprohib;
17476429de4SYoshinobu Inoue 	/* ipv6IfIcmpInTimeExcds, # of input time exceeded errors */
175686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_in_timeexceed;
17676429de4SYoshinobu Inoue 	/* ipv6IfIcmpInParmProblems, # of input parameter problem errors */
177686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_in_paramprob;
17876429de4SYoshinobu Inoue 	/* ipv6IfIcmpInPktTooBigs, # of input packet too big errors */
179686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_in_pkttoobig;
18076429de4SYoshinobu Inoue 	/* ipv6IfIcmpInEchos, # of input echo requests */
181686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_in_echo;
18276429de4SYoshinobu Inoue 	/* ipv6IfIcmpInEchoReplies, # of input echo replies */
183686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_in_echoreply;
18476429de4SYoshinobu Inoue 	/* ipv6IfIcmpInRouterSolicits, # of input router solicitations */
185686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_in_routersolicit;
18676429de4SYoshinobu Inoue 	/* ipv6IfIcmpInRouterAdvertisements, # of input router advertisements */
187686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_in_routeradvert;
18876429de4SYoshinobu Inoue 	/* ipv6IfIcmpInNeighborSolicits, # of input neighbor solicitations */
189686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_in_neighborsolicit;
19076429de4SYoshinobu Inoue 	/* ipv6IfIcmpInNeighborAdvertisements, # of input neighbor advertisements */
191686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_in_neighboradvert;
19276429de4SYoshinobu Inoue 	/* ipv6IfIcmpInRedirects, # of input redirects */
193686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_in_redirect;
19476429de4SYoshinobu Inoue 	/* ipv6IfIcmpInGroupMembQueries, # of input MLD queries */
195686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_in_mldquery;
19676429de4SYoshinobu Inoue 	/* ipv6IfIcmpInGroupMembResponses, # of input MLD reports */
197686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_in_mldreport;
19876429de4SYoshinobu Inoue 	/* ipv6IfIcmpInGroupMembReductions, # of input MLD done */
199686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_in_mlddone;
20076429de4SYoshinobu Inoue 
20176429de4SYoshinobu Inoue 	/*
20276429de4SYoshinobu Inoue 	 * Output statistics. We should solve unresolved routing problem...
20376429de4SYoshinobu Inoue 	 */
20476429de4SYoshinobu Inoue 	/* ipv6IfIcmpOutMsgs, total # of output messages */
205686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_out_msg;
20676429de4SYoshinobu Inoue 	/* ipv6IfIcmpOutErrors, # of output error messages */
207686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_out_error;
20876429de4SYoshinobu Inoue 	/* ipv6IfIcmpOutDestUnreachs, # of output dest unreach errors */
209686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_out_dstunreach;
21076429de4SYoshinobu Inoue 	/* ipv6IfIcmpOutAdminProhibs, # of output administratively prohibited errs */
211686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_out_adminprohib;
21276429de4SYoshinobu Inoue 	/* ipv6IfIcmpOutTimeExcds, # of output time exceeded errors */
213686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_out_timeexceed;
21476429de4SYoshinobu Inoue 	/* ipv6IfIcmpOutParmProblems, # of output parameter problem errors */
215686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_out_paramprob;
21676429de4SYoshinobu Inoue 	/* ipv6IfIcmpOutPktTooBigs, # of output packet too big errors */
217686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_out_pkttoobig;
21876429de4SYoshinobu Inoue 	/* ipv6IfIcmpOutEchos, # of output echo requests */
219686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_out_echo;
22076429de4SYoshinobu Inoue 	/* ipv6IfIcmpOutEchoReplies, # of output echo replies */
221686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_out_echoreply;
22276429de4SYoshinobu Inoue 	/* ipv6IfIcmpOutRouterSolicits, # of output router solicitations */
223686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_out_routersolicit;
22476429de4SYoshinobu Inoue 	/* ipv6IfIcmpOutRouterAdvertisements, # of output router advertisements */
225686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_out_routeradvert;
22676429de4SYoshinobu Inoue 	/* ipv6IfIcmpOutNeighborSolicits, # of output neighbor solicitations */
227686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_out_neighborsolicit;
22876429de4SYoshinobu Inoue 	/* ipv6IfIcmpOutNeighborAdvertisements, # of output neighbor advertisements */
229686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_out_neighboradvert;
23076429de4SYoshinobu Inoue 	/* ipv6IfIcmpOutRedirects, # of output redirects */
231686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_out_redirect;
23276429de4SYoshinobu Inoue 	/* ipv6IfIcmpOutGroupMembQueries, # of output MLD queries */
233686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_out_mldquery;
23476429de4SYoshinobu Inoue 	/* ipv6IfIcmpOutGroupMembResponses, # of output MLD reports */
235686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_out_mldreport;
23676429de4SYoshinobu Inoue 	/* ipv6IfIcmpOutGroupMembReductions, # of output MLD done */
237686cdd19SJun-ichiro itojun Hagino 	u_quad_t ifs6_out_mlddone;
23876429de4SYoshinobu Inoue };
23976429de4SYoshinobu Inoue 
24076429de4SYoshinobu Inoue struct	in6_ifreq {
24176429de4SYoshinobu Inoue 	char	ifr_name[IFNAMSIZ];
24276429de4SYoshinobu Inoue 	union {
24376429de4SYoshinobu Inoue 		struct	sockaddr_in6 ifru_addr;
24476429de4SYoshinobu Inoue 		struct	sockaddr_in6 ifru_dstaddr;
24562f76486SMaxim Sobolev 		int	ifru_flags;
24676429de4SYoshinobu Inoue 		int	ifru_flags6;
24776429de4SYoshinobu Inoue 		int	ifru_metric;
24876429de4SYoshinobu Inoue 		caddr_t	ifru_data;
24976429de4SYoshinobu Inoue 		struct in6_addrlifetime ifru_lifetime;
25076429de4SYoshinobu Inoue 		struct in6_ifstat ifru_stat;
25176429de4SYoshinobu Inoue 		struct icmp6_ifstat ifru_icmp6stat;
252686cdd19SJun-ichiro itojun Hagino 		u_int32_t ifru_scope_id[16];
25376429de4SYoshinobu Inoue 	} ifr_ifru;
25476429de4SYoshinobu Inoue };
25576429de4SYoshinobu Inoue 
25676429de4SYoshinobu Inoue struct	in6_aliasreq {
25776429de4SYoshinobu Inoue 	char	ifra_name[IFNAMSIZ];
25876429de4SYoshinobu Inoue 	struct	sockaddr_in6 ifra_addr;
25976429de4SYoshinobu Inoue 	struct	sockaddr_in6 ifra_dstaddr;
26076429de4SYoshinobu Inoue 	struct	sockaddr_in6 ifra_prefixmask;
26176429de4SYoshinobu Inoue 	int	ifra_flags;
26276429de4SYoshinobu Inoue 	struct in6_addrlifetime ifra_lifetime;
26376429de4SYoshinobu Inoue };
26476429de4SYoshinobu Inoue 
26576429de4SYoshinobu Inoue /* prefix type macro */
26676429de4SYoshinobu Inoue #define IN6_PREFIX_ND	1
26776429de4SYoshinobu Inoue #define IN6_PREFIX_RR	2
26876429de4SYoshinobu Inoue 
26976429de4SYoshinobu Inoue /*
27076429de4SYoshinobu Inoue  * prefix related flags passed between kernel(NDP related part) and
27176429de4SYoshinobu Inoue  * user land command(ifconfig) and daemon(rtadvd).
27276429de4SYoshinobu Inoue  */
27376429de4SYoshinobu Inoue struct in6_prflags {
27476429de4SYoshinobu Inoue 	struct prf_ra {
27576429de4SYoshinobu Inoue 		u_char onlink : 1;
27676429de4SYoshinobu Inoue 		u_char autonomous : 1;
27776429de4SYoshinobu Inoue 		u_char reserved : 6;
27876429de4SYoshinobu Inoue 	} prf_ra;
27976429de4SYoshinobu Inoue 	u_char prf_reserved1;
28076429de4SYoshinobu Inoue 	u_short prf_reserved2;
28176429de4SYoshinobu Inoue 	/* want to put this on 4byte offset */
28276429de4SYoshinobu Inoue 	struct prf_rr {
28376429de4SYoshinobu Inoue 		u_char decrvalid : 1;
28476429de4SYoshinobu Inoue 		u_char decrprefd : 1;
28576429de4SYoshinobu Inoue 		u_char reserved : 6;
28676429de4SYoshinobu Inoue 	} prf_rr;
28776429de4SYoshinobu Inoue 	u_char prf_reserved3;
28876429de4SYoshinobu Inoue 	u_short prf_reserved4;
28976429de4SYoshinobu Inoue };
29076429de4SYoshinobu Inoue 
29176429de4SYoshinobu Inoue struct  in6_prefixreq {
29276429de4SYoshinobu Inoue 	char	ipr_name[IFNAMSIZ];
29376429de4SYoshinobu Inoue 	u_char	ipr_origin;
29476429de4SYoshinobu Inoue 	u_char	ipr_plen;
29576429de4SYoshinobu Inoue 	u_int32_t ipr_vltime;
29676429de4SYoshinobu Inoue 	u_int32_t ipr_pltime;
29776429de4SYoshinobu Inoue 	struct in6_prflags ipr_flags;
29876429de4SYoshinobu Inoue 	struct	sockaddr_in6 ipr_prefix;
29976429de4SYoshinobu Inoue };
30076429de4SYoshinobu Inoue 
30176429de4SYoshinobu Inoue #define PR_ORIG_RA	0
30276429de4SYoshinobu Inoue #define PR_ORIG_RR	1
30376429de4SYoshinobu Inoue #define PR_ORIG_STATIC	2
30476429de4SYoshinobu Inoue #define PR_ORIG_KERNEL	3
30576429de4SYoshinobu Inoue 
30676429de4SYoshinobu Inoue #define ipr_raf_onlink		ipr_flags.prf_ra.onlink
30776429de4SYoshinobu Inoue #define ipr_raf_auto		ipr_flags.prf_ra.autonomous
30876429de4SYoshinobu Inoue 
30976429de4SYoshinobu Inoue #define ipr_statef_onlink	ipr_flags.prf_state.onlink
31076429de4SYoshinobu Inoue 
31176429de4SYoshinobu Inoue #define ipr_rrf_decrvalid	ipr_flags.prf_rr.decrvalid
31276429de4SYoshinobu Inoue #define ipr_rrf_decrprefd	ipr_flags.prf_rr.decrprefd
31376429de4SYoshinobu Inoue 
31476429de4SYoshinobu Inoue struct	in6_rrenumreq {
31576429de4SYoshinobu Inoue 	char	irr_name[IFNAMSIZ];
31676429de4SYoshinobu Inoue 	u_char	irr_origin;
31776429de4SYoshinobu Inoue 	u_char	irr_m_len;	/* match len for matchprefix */
31876429de4SYoshinobu Inoue 	u_char	irr_m_minlen;	/* minlen for matching prefix */
31976429de4SYoshinobu Inoue 	u_char	irr_m_maxlen;	/* maxlen for matching prefix */
32076429de4SYoshinobu Inoue 	u_char	irr_u_uselen;	/* uselen for adding prefix */
32176429de4SYoshinobu Inoue 	u_char	irr_u_keeplen;	/* keeplen from matching prefix */
32276429de4SYoshinobu Inoue 	struct irr_raflagmask {
32376429de4SYoshinobu Inoue 		u_char onlink : 1;
32476429de4SYoshinobu Inoue 		u_char autonomous : 1;
32576429de4SYoshinobu Inoue 		u_char reserved : 6;
32676429de4SYoshinobu Inoue 	} irr_raflagmask;
32776429de4SYoshinobu Inoue 	u_int32_t irr_vltime;
32876429de4SYoshinobu Inoue 	u_int32_t irr_pltime;
32976429de4SYoshinobu Inoue 	struct in6_prflags irr_flags;
33076429de4SYoshinobu Inoue 	struct	sockaddr_in6 irr_matchprefix;
33176429de4SYoshinobu Inoue 	struct	sockaddr_in6 irr_useprefix;
33276429de4SYoshinobu Inoue };
33376429de4SYoshinobu Inoue 
33476429de4SYoshinobu Inoue #define irr_raf_mask_onlink	irr_raflagmask.onlink
33576429de4SYoshinobu Inoue #define irr_raf_mask_auto	irr_raflagmask.autonomous
33676429de4SYoshinobu Inoue #define irr_raf_mask_reserved	irr_raflagmask.reserved
33776429de4SYoshinobu Inoue 
33876429de4SYoshinobu Inoue #define irr_raf_onlink		irr_flags.prf_ra.onlink
33976429de4SYoshinobu Inoue #define irr_raf_auto		irr_flags.prf_ra.autonomous
34076429de4SYoshinobu Inoue 
34176429de4SYoshinobu Inoue #define irr_statef_onlink	irr_flags.prf_state.onlink
34276429de4SYoshinobu Inoue 
34376429de4SYoshinobu Inoue #define irr_rrf			irr_flags.prf_rr
34476429de4SYoshinobu Inoue #define irr_rrf_decrvalid	irr_flags.prf_rr.decrvalid
34576429de4SYoshinobu Inoue #define irr_rrf_decrprefd	irr_flags.prf_rr.decrprefd
34676429de4SYoshinobu Inoue 
34776429de4SYoshinobu Inoue /*
34876429de4SYoshinobu Inoue  * Given a pointer to an in6_ifaddr (ifaddr),
34976429de4SYoshinobu Inoue  * return a pointer to the addr as a sockaddr_in6
35076429de4SYoshinobu Inoue  */
35176429de4SYoshinobu Inoue #define IA6_IN6(ia)	(&((ia)->ia_addr.sin6_addr))
35276429de4SYoshinobu Inoue #define IA6_DSTIN6(ia)	(&((ia)->ia_dstaddr.sin6_addr))
35376429de4SYoshinobu Inoue #define IA6_MASKIN6(ia)	(&((ia)->ia_prefixmask.sin6_addr))
35476429de4SYoshinobu Inoue #define IA6_SIN6(ia)	(&((ia)->ia_addr))
35576429de4SYoshinobu Inoue #define IA6_DSTSIN6(ia)	(&((ia)->ia_dstaddr))
35676429de4SYoshinobu Inoue #define IFA_IN6(x)	(&((struct sockaddr_in6 *)((x)->ifa_addr))->sin6_addr)
35776429de4SYoshinobu Inoue #define IFA_DSTIN6(x)	(&((struct sockaddr_in6 *)((x)->ifa_dstaddr))->sin6_addr)
35876429de4SYoshinobu Inoue 
35976429de4SYoshinobu Inoue #define IFPR_IN6(x)	(&((struct sockaddr_in6 *)((x)->ifpr_prefix))->sin6_addr)
36076429de4SYoshinobu Inoue 
36176429de4SYoshinobu Inoue #ifdef _KERNEL
36276429de4SYoshinobu Inoue #define IN6_ARE_MASKED_ADDR_EQUAL(d, a, m)	(	\
36376429de4SYoshinobu Inoue 	(((d)->s6_addr32[0] ^ (a)->s6_addr32[0]) & (m)->s6_addr32[0]) == 0 && \
36476429de4SYoshinobu Inoue 	(((d)->s6_addr32[1] ^ (a)->s6_addr32[1]) & (m)->s6_addr32[1]) == 0 && \
36576429de4SYoshinobu Inoue 	(((d)->s6_addr32[2] ^ (a)->s6_addr32[2]) & (m)->s6_addr32[2]) == 0 && \
36676429de4SYoshinobu Inoue 	(((d)->s6_addr32[3] ^ (a)->s6_addr32[3]) & (m)->s6_addr32[3]) == 0 )
36776429de4SYoshinobu Inoue #endif
36876429de4SYoshinobu Inoue 
36976429de4SYoshinobu Inoue #define SIOCSIFADDR_IN6		 _IOW('i', 12, struct in6_ifreq)
37076429de4SYoshinobu Inoue #define SIOCGIFADDR_IN6		_IOWR('i', 33, struct in6_ifreq)
371686cdd19SJun-ichiro itojun Hagino 
372686cdd19SJun-ichiro itojun Hagino #ifdef _KERNEL
373686cdd19SJun-ichiro itojun Hagino /*
374686cdd19SJun-ichiro itojun Hagino  * SIOCSxxx ioctls should be unused (see comments in in6.c), but
375686cdd19SJun-ichiro itojun Hagino  * we do not shift numbers for binary compatibility.
376686cdd19SJun-ichiro itojun Hagino  */
37776429de4SYoshinobu Inoue #define SIOCSIFDSTADDR_IN6	 _IOW('i', 14, struct in6_ifreq)
37876429de4SYoshinobu Inoue #define SIOCSIFNETMASK_IN6	 _IOW('i', 22, struct in6_ifreq)
379686cdd19SJun-ichiro itojun Hagino #endif
380686cdd19SJun-ichiro itojun Hagino 
381686cdd19SJun-ichiro itojun Hagino #define SIOCGIFDSTADDR_IN6	_IOWR('i', 34, struct in6_ifreq)
38276429de4SYoshinobu Inoue #define SIOCGIFNETMASK_IN6	_IOWR('i', 37, struct in6_ifreq)
38376429de4SYoshinobu Inoue 
38476429de4SYoshinobu Inoue #define SIOCDIFADDR_IN6		 _IOW('i', 25, struct in6_ifreq)
38576429de4SYoshinobu Inoue #define SIOCAIFADDR_IN6		 _IOW('i', 26, struct in6_aliasreq)
38676429de4SYoshinobu Inoue 
38776429de4SYoshinobu Inoue #define SIOCSIFPHYADDR_IN6       _IOW('i', 70, struct in6_aliasreq)
38876429de4SYoshinobu Inoue #define	SIOCGIFPSRCADDR_IN6	_IOWR('i', 71, struct in6_ifreq)
38976429de4SYoshinobu Inoue #define	SIOCGIFPDSTADDR_IN6	_IOWR('i', 72, struct in6_ifreq)
39076429de4SYoshinobu Inoue 
39176429de4SYoshinobu Inoue #define SIOCGIFAFLAG_IN6	_IOWR('i', 73, struct in6_ifreq)
39276429de4SYoshinobu Inoue 
39376429de4SYoshinobu Inoue #define SIOCGDRLST_IN6		_IOWR('i', 74, struct in6_drlist)
39476429de4SYoshinobu Inoue #define SIOCGPRLST_IN6		_IOWR('i', 75, struct in6_prlist)
39533841545SHajimu UMEMOTO #ifdef _KERNEL
39633841545SHajimu UMEMOTO #define OSIOCGIFINFO_IN6	_IOWR('i', 76, struct in6_ondireq)
39733841545SHajimu UMEMOTO #endif
39833841545SHajimu UMEMOTO #define SIOCGIFINFO_IN6		_IOWR('i', 108, struct in6_ndireq)
39976429de4SYoshinobu Inoue #define SIOCSNDFLUSH_IN6	_IOWR('i', 77, struct in6_ifreq)
40076429de4SYoshinobu Inoue #define SIOCGNBRINFO_IN6	_IOWR('i', 78, struct in6_nbrinfo)
40176429de4SYoshinobu Inoue #define SIOCSPFXFLUSH_IN6	_IOWR('i', 79, struct in6_ifreq)
40276429de4SYoshinobu Inoue #define SIOCSRTRFLUSH_IN6	_IOWR('i', 80, struct in6_ifreq)
40376429de4SYoshinobu Inoue 
40476429de4SYoshinobu Inoue #define SIOCGIFALIFETIME_IN6	_IOWR('i', 81, struct in6_ifreq)
40576429de4SYoshinobu Inoue #define SIOCSIFALIFETIME_IN6	_IOWR('i', 82, struct in6_ifreq)
40676429de4SYoshinobu Inoue #define SIOCGIFSTAT_IN6		_IOWR('i', 83, struct in6_ifreq)
40776429de4SYoshinobu Inoue #define SIOCGIFSTAT_ICMP6	_IOWR('i', 84, struct in6_ifreq)
40876429de4SYoshinobu Inoue 
409686cdd19SJun-ichiro itojun Hagino #define SIOCSDEFIFACE_IN6	_IOWR('i', 85, struct in6_ndifreq)
410686cdd19SJun-ichiro itojun Hagino #define SIOCGDEFIFACE_IN6	_IOWR('i', 86, struct in6_ndifreq)
411686cdd19SJun-ichiro itojun Hagino 
412686cdd19SJun-ichiro itojun Hagino #define SIOCSIFINFO_FLAGS	_IOWR('i', 87, struct in6_ndireq) /* XXX */
413686cdd19SJun-ichiro itojun Hagino 
414686cdd19SJun-ichiro itojun Hagino #define SIOCSSCOPE6		_IOW('i', 88, struct in6_ifreq)
415686cdd19SJun-ichiro itojun Hagino #define SIOCGSCOPE6		_IOWR('i', 89, struct in6_ifreq)
416686cdd19SJun-ichiro itojun Hagino #define SIOCGSCOPE6DEF		_IOWR('i', 90, struct in6_ifreq)
417686cdd19SJun-ichiro itojun Hagino 
41876429de4SYoshinobu Inoue #define SIOCSIFPREFIX_IN6	_IOW('i', 100, struct in6_prefixreq) /* set */
41976429de4SYoshinobu Inoue #define SIOCGIFPREFIX_IN6	_IOWR('i', 101, struct in6_prefixreq) /* get */
42076429de4SYoshinobu Inoue #define SIOCDIFPREFIX_IN6	_IOW('i', 102, struct in6_prefixreq) /* del */
42176429de4SYoshinobu Inoue #define SIOCAIFPREFIX_IN6	_IOW('i', 103, struct in6_rrenumreq) /* add */
42276429de4SYoshinobu Inoue #define SIOCCIFPREFIX_IN6	_IOW('i', 104, \
42376429de4SYoshinobu Inoue 				     struct in6_rrenumreq) /* change */
42476429de4SYoshinobu Inoue #define SIOCSGIFPREFIX_IN6	_IOW('i', 105, \
42576429de4SYoshinobu Inoue 				     struct in6_rrenumreq) /* set global */
42676429de4SYoshinobu Inoue 
42776429de4SYoshinobu Inoue #define SIOCGETSGCNT_IN6	_IOWR('u', 106, \
42876429de4SYoshinobu Inoue 				      struct sioc_sg_req6) /* get s,g pkt cnt */
42976429de4SYoshinobu Inoue #define SIOCGETMIFCNT_IN6	_IOWR('u', 107, \
43076429de4SYoshinobu Inoue 				      struct sioc_mif_req6) /* get pkt cnt per if */
43176429de4SYoshinobu Inoue 
43276429de4SYoshinobu Inoue #define IN6_IFF_ANYCAST		0x01	/* anycast address */
43376429de4SYoshinobu Inoue #define IN6_IFF_TENTATIVE	0x02	/* tentative address */
43476429de4SYoshinobu Inoue #define IN6_IFF_DUPLICATED	0x04	/* DAD detected duplicate */
43576429de4SYoshinobu Inoue #define IN6_IFF_DETACHED	0x08	/* may be detached from the link */
43676429de4SYoshinobu Inoue #define IN6_IFF_DEPRECATED	0x10	/* deprecated address */
43733841545SHajimu UMEMOTO #define IN6_IFF_NODAD		0x20	/* don't perform DAD on this address
43833841545SHajimu UMEMOTO 					 * (used only at first SIOC* call)
43933841545SHajimu UMEMOTO 					 */
44033841545SHajimu UMEMOTO #define IN6_IFF_AUTOCONF	0x40	/* autoconfigurable address. */
44133841545SHajimu UMEMOTO #define IN6_IFF_TEMPORARY	0x80	/* temporary (anonymous) address. */
44233841545SHajimu UMEMOTO #define IN6_IFF_NOPFX		0x8000	/* skip kernel prefix management.
44333841545SHajimu UMEMOTO 					 * XXX: this should be temporary.
44433841545SHajimu UMEMOTO 					 */
44576429de4SYoshinobu Inoue 
44676429de4SYoshinobu Inoue /* do not input/output */
44776429de4SYoshinobu Inoue #define IN6_IFF_NOTREADY (IN6_IFF_TENTATIVE|IN6_IFF_DUPLICATED)
44876429de4SYoshinobu Inoue 
44976429de4SYoshinobu Inoue #ifdef _KERNEL
450686cdd19SJun-ichiro itojun Hagino #define IN6_ARE_SCOPE_CMP(a,b) ((a)-(b))
451686cdd19SJun-ichiro itojun Hagino #define IN6_ARE_SCOPE_EQUAL(a,b) ((a)==(b))
452686cdd19SJun-ichiro itojun Hagino #endif
453686cdd19SJun-ichiro itojun Hagino 
454686cdd19SJun-ichiro itojun Hagino #ifdef _KERNEL
45576429de4SYoshinobu Inoue extern struct in6_ifaddr *in6_ifaddr;
45676429de4SYoshinobu Inoue 
45776429de4SYoshinobu Inoue extern struct icmp6stat icmp6stat;
45876429de4SYoshinobu Inoue #define in6_ifstat_inc(ifp, tag) \
45976429de4SYoshinobu Inoue do {								\
46031b1bfe1SHajimu UMEMOTO 	if (ifp)						\
46131b1bfe1SHajimu UMEMOTO 		((struct in6_ifextra *)((ifp)->if_afdata[AF_INET6]))->in6_ifstat->tag++; \
4627efe5d92SHajimu UMEMOTO } while (/*CONSTCOND*/ 0)
46376429de4SYoshinobu Inoue 
46476429de4SYoshinobu Inoue extern struct in6_addr zeroin6_addr;
46576429de4SYoshinobu Inoue extern u_char inet6ctlerrmap[];
466686cdd19SJun-ichiro itojun Hagino extern unsigned long in6_maxmtu;
46776429de4SYoshinobu Inoue #ifdef MALLOC_DECLARE
46876429de4SYoshinobu Inoue MALLOC_DECLARE(M_IPMADDR);
4697efe5d92SHajimu UMEMOTO #endif /* MALLOC_DECLARE */
47076429de4SYoshinobu Inoue 
47176429de4SYoshinobu Inoue /*
47276429de4SYoshinobu Inoue  * Macro for finding the internet address structure (in6_ifaddr) corresponding
47376429de4SYoshinobu Inoue  * to a given interface (ifnet structure).
47476429de4SYoshinobu Inoue  */
475686cdd19SJun-ichiro itojun Hagino 
47676429de4SYoshinobu Inoue #define IFP_TO_IA6(ifp, ia)				\
47776429de4SYoshinobu Inoue /* struct ifnet *ifp; */				\
47876429de4SYoshinobu Inoue /* struct in6_ifaddr *ia; */				\
47976429de4SYoshinobu Inoue do {									\
48076429de4SYoshinobu Inoue 	struct ifaddr *ifa;						\
481686cdd19SJun-ichiro itojun Hagino 	for (ifa = (ifp)->if_addrlist.tqh_first; ifa; ifa = ifa->ifa_list.tqe_next) {	\
48276429de4SYoshinobu Inoue 		if (!ifa->ifa_addr)					\
48376429de4SYoshinobu Inoue 			continue;					\
48476429de4SYoshinobu Inoue 		if (ifa->ifa_addr->sa_family == AF_INET6)		\
48576429de4SYoshinobu Inoue 			break;						\
48676429de4SYoshinobu Inoue 	}								\
48776429de4SYoshinobu Inoue 	(ia) = (struct in6_ifaddr *)ifa;				\
4887efe5d92SHajimu UMEMOTO } while (/*CONSTCOND*/ 0)
489686cdd19SJun-ichiro itojun Hagino 
49076429de4SYoshinobu Inoue #endif /* _KERNEL */
49176429de4SYoshinobu Inoue 
49276429de4SYoshinobu Inoue /*
49376429de4SYoshinobu Inoue  * Multi-cast membership entry.  One for each group/ifp that a PCB
49476429de4SYoshinobu Inoue  * belongs to.
49576429de4SYoshinobu Inoue  */
49676429de4SYoshinobu Inoue struct in6_multi_mship {
49776429de4SYoshinobu Inoue 	struct	in6_multi *i6mm_maddr;	/* Multicast address pointer */
498e3975643SJake Burkholder 	LIST_ENTRY(in6_multi_mship) i6mm_chain;  /* multicast options chain */
49976429de4SYoshinobu Inoue };
50076429de4SYoshinobu Inoue 
50176429de4SYoshinobu Inoue struct	in6_multi {
502e3975643SJake Burkholder 	LIST_ENTRY(in6_multi) in6m_entry; /* list glue */
50376429de4SYoshinobu Inoue 	struct	in6_addr in6m_addr;	/* IP6 multicast address */
50476429de4SYoshinobu Inoue 	struct	ifnet *in6m_ifp;	/* back pointer to ifnet */
50576429de4SYoshinobu Inoue 	struct	ifmultiaddr *in6m_ifma;	/* back pointer to ifmultiaddr */
50676429de4SYoshinobu Inoue 	u_int	in6m_refcount;		/* # membership claims by sockets */
50776429de4SYoshinobu Inoue 	u_int	in6m_state;		/* state of the membership */
50876429de4SYoshinobu Inoue 	u_int	in6m_timer;		/* MLD6 listener report timer */
50976429de4SYoshinobu Inoue };
51076429de4SYoshinobu Inoue 
51176429de4SYoshinobu Inoue #ifdef _KERNEL
512e3975643SJake Burkholder extern LIST_HEAD(in6_multihead, in6_multi) in6_multihead;
51376429de4SYoshinobu Inoue 
51476429de4SYoshinobu Inoue /*
51576429de4SYoshinobu Inoue  * Structure used by macros below to remember position when stepping through
51688ff5695SSUZUKI Shinsuke  * all of the in6_multi records.
51776429de4SYoshinobu Inoue  */
51876429de4SYoshinobu Inoue struct	in6_multistep {
51976429de4SYoshinobu Inoue 	struct	in6_ifaddr *i_ia;
52076429de4SYoshinobu Inoue 	struct	in6_multi *i_in6m;
52176429de4SYoshinobu Inoue };
52276429de4SYoshinobu Inoue 
52376429de4SYoshinobu Inoue /*
52476429de4SYoshinobu Inoue  * Macros for looking up the in6_multi record for a given IP6 multicast
52576429de4SYoshinobu Inoue  * address on a given interface. If no matching record is found, "in6m"
52676429de4SYoshinobu Inoue  * returns NLL.
52776429de4SYoshinobu Inoue  */
52876429de4SYoshinobu Inoue 
52976429de4SYoshinobu Inoue #define IN6_LOOKUP_MULTI(addr, ifp, in6m)			\
53076429de4SYoshinobu Inoue /* struct in6_addr addr; */					\
53176429de4SYoshinobu Inoue /* struct ifnet *ifp; */					\
53276429de4SYoshinobu Inoue /* struct in6_multi *in6m; */					\
53376429de4SYoshinobu Inoue do { \
53433841545SHajimu UMEMOTO 	struct ifmultiaddr *ifma; \
5356817526dSPoul-Henning Kamp 	TAILQ_FOREACH(ifma, &(ifp)->if_multiaddrs, ifma_link) { \
53676429de4SYoshinobu Inoue 		if (ifma->ifma_addr->sa_family == AF_INET6 \
53776429de4SYoshinobu Inoue 		    && IN6_ARE_ADDR_EQUAL(&((struct sockaddr_in6 *)ifma->ifma_addr)->sin6_addr, \
53876429de4SYoshinobu Inoue 					  &(addr))) \
53976429de4SYoshinobu Inoue 			break; \
54076429de4SYoshinobu Inoue 	} \
54176429de4SYoshinobu Inoue 	(in6m) = (struct in6_multi *)(ifma ? ifma->ifma_protospec : 0); \
54276429de4SYoshinobu Inoue } while(0)
54376429de4SYoshinobu Inoue 
54476429de4SYoshinobu Inoue /*
54576429de4SYoshinobu Inoue  * Macro to step through all of the in6_multi records, one at a time.
54676429de4SYoshinobu Inoue  * The current position is remembered in "step", which the caller must
54776429de4SYoshinobu Inoue  * provide.  IN6_FIRST_MULTI(), below, must be called to initialize "step"
54876429de4SYoshinobu Inoue  * and get the first record.  Both macros return a NULL "in6m" when there
54976429de4SYoshinobu Inoue  * are no remaining records.
55076429de4SYoshinobu Inoue  */
55176429de4SYoshinobu Inoue #define IN6_NEXT_MULTI(step, in6m)					\
55276429de4SYoshinobu Inoue /* struct in6_multistep step; */					\
55376429de4SYoshinobu Inoue /* struct in6_multi *in6m; */						\
55476429de4SYoshinobu Inoue do { \
55576429de4SYoshinobu Inoue 	if (((in6m) = (step).i_in6m) != NULL) \
556686cdd19SJun-ichiro itojun Hagino 		(step).i_in6m = (step).i_in6m->in6m_entry.le_next; \
55776429de4SYoshinobu Inoue } while(0)
55876429de4SYoshinobu Inoue 
55976429de4SYoshinobu Inoue #define IN6_FIRST_MULTI(step, in6m)		\
56076429de4SYoshinobu Inoue /* struct in6_multistep step; */		\
56176429de4SYoshinobu Inoue /* struct in6_multi *in6m */			\
56276429de4SYoshinobu Inoue do { \
563686cdd19SJun-ichiro itojun Hagino 	(step).i_in6m = in6_multihead.lh_first; \
56476429de4SYoshinobu Inoue 		IN6_NEXT_MULTI((step), (in6m)); \
56576429de4SYoshinobu Inoue } while(0)
56676429de4SYoshinobu Inoue 
56776429de4SYoshinobu Inoue struct	in6_multi *in6_addmulti __P((struct in6_addr *, struct ifnet *,
56876429de4SYoshinobu Inoue 	int *));
56976429de4SYoshinobu Inoue void	in6_delmulti __P((struct in6_multi *));
57076429de4SYoshinobu Inoue extern int in6_ifindex2scopeid __P((int));
57133841545SHajimu UMEMOTO extern int in6_mask2len __P((struct in6_addr *, u_char *));
57276429de4SYoshinobu Inoue extern void in6_len2mask __P((struct in6_addr *, int));
5737efe5d92SHajimu UMEMOTO int	in6_control __P((struct socket *, u_long, caddr_t, struct ifnet *,
5747efe5d92SHajimu UMEMOTO 	struct thread *));
57533841545SHajimu UMEMOTO int	in6_update_ifa __P((struct ifnet *, struct in6_aliasreq *,
57633841545SHajimu UMEMOTO 	struct in6_ifaddr *));
57733841545SHajimu UMEMOTO void	in6_purgeaddr __P((struct ifaddr *));
57833841545SHajimu UMEMOTO int	in6if_do_dad __P((struct ifnet *));
57933841545SHajimu UMEMOTO void	in6_purgeif __P((struct ifnet *));
58076429de4SYoshinobu Inoue void	in6_savemkludge __P((struct in6_ifaddr *));
58131b1bfe1SHajimu UMEMOTO void	*in6_domifattach __P((struct ifnet *));
58231b1bfe1SHajimu UMEMOTO void	in6_domifdetach __P((struct ifnet *, void *));
58376429de4SYoshinobu Inoue void	in6_setmaxmtu   __P((void));
58476429de4SYoshinobu Inoue void	in6_restoremkludge __P((struct in6_ifaddr *, struct ifnet *));
585686cdd19SJun-ichiro itojun Hagino void	in6_purgemkludge __P((struct ifnet *));
586686cdd19SJun-ichiro itojun Hagino struct in6_ifaddr *in6ifa_ifpforlinklocal __P((struct ifnet *, int));
5877efe5d92SHajimu UMEMOTO struct in6_ifaddr *in6ifa_ifpwithaddr __P((struct ifnet *, struct in6_addr *));
58833841545SHajimu UMEMOTO char	*ip6_sprintf __P((const struct in6_addr *));
589686cdd19SJun-ichiro itojun Hagino int	in6_addr2scopeid __P((struct ifnet *, struct in6_addr *));
59076429de4SYoshinobu Inoue int	in6_matchlen __P((struct in6_addr *, struct in6_addr *));
5917efe5d92SHajimu UMEMOTO int	in6_are_prefix_equal __P((struct in6_addr *, struct in6_addr *, int));
5927efe5d92SHajimu UMEMOTO void	in6_prefixlen2mask __P((struct in6_addr *, int));
5937efe5d92SHajimu UMEMOTO int	in6_prefix_ioctl __P((struct socket *, u_long, caddr_t,
5947efe5d92SHajimu UMEMOTO 	struct ifnet *));
5957efe5d92SHajimu UMEMOTO int	in6_prefix_add_ifid __P((int, struct in6_ifaddr *));
5967efe5d92SHajimu UMEMOTO void	in6_prefix_remove_ifid __P((int, struct in6_ifaddr *));
597686cdd19SJun-ichiro itojun Hagino void	in6_purgeprefix __P((struct ifnet *));
59833841545SHajimu UMEMOTO 
59933841545SHajimu UMEMOTO int	in6_is_addr_deprecated __P((struct sockaddr_in6 *));
60033841545SHajimu UMEMOTO struct inpcb;
60133841545SHajimu UMEMOTO int in6_embedscope __P((struct in6_addr *, const struct sockaddr_in6 *,
60233841545SHajimu UMEMOTO 	struct inpcb *, struct ifnet **));
60333841545SHajimu UMEMOTO int in6_recoverscope __P((struct sockaddr_in6 *, const struct in6_addr *,
60433841545SHajimu UMEMOTO 	struct ifnet *));
60533841545SHajimu UMEMOTO void in6_clearscope __P((struct in6_addr *));
60676429de4SYoshinobu Inoue #endif /* _KERNEL */
60776429de4SYoshinobu Inoue 
60876429de4SYoshinobu Inoue #endif /* _NETINET6_IN6_VAR_H_ */
609