xref: /freebsd/sys/netinet6/in6_var.h (revision bb06a80cf60b3afba459b72b2b2842898938fecf)
1caf43b02SWarner Losh /*-
251369649SPedro F. Giffuni  * SPDX-License-Identifier: BSD-3-Clause
351369649SPedro F. Giffuni  *
476429de4SYoshinobu Inoue  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
576429de4SYoshinobu Inoue  * All rights reserved.
676429de4SYoshinobu Inoue  *
776429de4SYoshinobu Inoue  * Redistribution and use in source and binary forms, with or without
876429de4SYoshinobu Inoue  * modification, are permitted provided that the following conditions
976429de4SYoshinobu Inoue  * are met:
1076429de4SYoshinobu Inoue  * 1. Redistributions of source code must retain the above copyright
1176429de4SYoshinobu Inoue  *    notice, this list of conditions and the following disclaimer.
1276429de4SYoshinobu Inoue  * 2. Redistributions in binary form must reproduce the above copyright
1376429de4SYoshinobu Inoue  *    notice, this list of conditions and the following disclaimer in the
1476429de4SYoshinobu Inoue  *    documentation and/or other materials provided with the distribution.
1576429de4SYoshinobu Inoue  * 3. Neither the name of the project nor the names of its contributors
1676429de4SYoshinobu Inoue  *    may be used to endorse or promote products derived from this software
1776429de4SYoshinobu Inoue  *    without specific prior written permission.
1876429de4SYoshinobu Inoue  *
1976429de4SYoshinobu Inoue  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
2076429de4SYoshinobu Inoue  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2176429de4SYoshinobu Inoue  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2276429de4SYoshinobu Inoue  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
2376429de4SYoshinobu Inoue  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2476429de4SYoshinobu Inoue  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2576429de4SYoshinobu Inoue  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2676429de4SYoshinobu Inoue  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2776429de4SYoshinobu Inoue  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2876429de4SYoshinobu Inoue  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2976429de4SYoshinobu Inoue  * SUCH DAMAGE.
30b48287a3SDavid E. O'Brien  *
31b48287a3SDavid E. O'Brien  *	$KAME: in6_var.h,v 1.56 2001/03/29 05:34:31 itojun Exp $
3276429de4SYoshinobu Inoue  */
3376429de4SYoshinobu Inoue 
34caf43b02SWarner Losh /*-
3576429de4SYoshinobu Inoue  * Copyright (c) 1985, 1986, 1993
3676429de4SYoshinobu Inoue  *	The Regents of the University of California.  All rights reserved.
3776429de4SYoshinobu Inoue  *
3876429de4SYoshinobu Inoue  * Redistribution and use in source and binary forms, with or without
3976429de4SYoshinobu Inoue  * modification, are permitted provided that the following conditions
4076429de4SYoshinobu Inoue  * are met:
4176429de4SYoshinobu Inoue  * 1. Redistributions of source code must retain the above copyright
4276429de4SYoshinobu Inoue  *    notice, this list of conditions and the following disclaimer.
4376429de4SYoshinobu Inoue  * 2. Redistributions in binary form must reproduce the above copyright
4476429de4SYoshinobu Inoue  *    notice, this list of conditions and the following disclaimer in the
4576429de4SYoshinobu Inoue  *    documentation and/or other materials provided with the distribution.
46fbbd9655SWarner Losh  * 3. Neither the name of the University nor the names of its contributors
4776429de4SYoshinobu Inoue  *    may be used to endorse or promote products derived from this software
4876429de4SYoshinobu Inoue  *    without specific prior written permission.
4976429de4SYoshinobu Inoue  *
5076429de4SYoshinobu Inoue  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
5176429de4SYoshinobu Inoue  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5276429de4SYoshinobu Inoue  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
5376429de4SYoshinobu Inoue  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
5476429de4SYoshinobu Inoue  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5576429de4SYoshinobu Inoue  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
5676429de4SYoshinobu Inoue  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
5776429de4SYoshinobu Inoue  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
5876429de4SYoshinobu Inoue  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5976429de4SYoshinobu Inoue  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
6076429de4SYoshinobu Inoue  * SUCH DAMAGE.
6176429de4SYoshinobu Inoue  *
6276429de4SYoshinobu Inoue  *	@(#)in_var.h	8.1 (Berkeley) 6/10/93
63b48287a3SDavid E. O'Brien  * $FreeBSD$
6476429de4SYoshinobu Inoue  */
6576429de4SYoshinobu Inoue 
6676429de4SYoshinobu Inoue #ifndef _NETINET6_IN6_VAR_H_
6776429de4SYoshinobu Inoue #define _NETINET6_IN6_VAR_H_
6876429de4SYoshinobu Inoue 
6933cde130SBruce M Simpson #include <sys/tree.h>
7002185396SGleb Smirnoff #include <sys/counter.h>
7133cde130SBruce M Simpson 
7233cde130SBruce M Simpson #ifdef _KERNEL
7368eba526SAndrey V. Elsukov #include <sys/fnv_hash.h>
7433cde130SBruce M Simpson #include <sys/libkern.h>
7533cde130SBruce M Simpson #endif
7633cde130SBruce M Simpson 
7776429de4SYoshinobu Inoue /*
7876429de4SYoshinobu Inoue  * Interface address, Internet version.  One of these structures
7976429de4SYoshinobu Inoue  * is allocated for each interface with an Internet address.
8076429de4SYoshinobu Inoue  * The ifaddr structure contains the protocol-independent part
8176429de4SYoshinobu Inoue  * of the structure and is assumed to be first.
8276429de4SYoshinobu Inoue  */
8376429de4SYoshinobu Inoue 
8476429de4SYoshinobu Inoue /*
8576429de4SYoshinobu Inoue  * pltime/vltime are just for future reference (required to implements 2
8676429de4SYoshinobu Inoue  * hour rule for hosts).  they should never be modified by nd6_timeout or
8776429de4SYoshinobu Inoue  * anywhere else.
8876429de4SYoshinobu Inoue  *	userland -> kernel: accept pltime/vltime
8988ff5695SSUZUKI Shinsuke  *	kernel -> userland: throw up everything
9076429de4SYoshinobu Inoue  *	in kernel: modify preferred/expire only
9176429de4SYoshinobu Inoue  */
9276429de4SYoshinobu Inoue struct in6_addrlifetime {
9376429de4SYoshinobu Inoue 	time_t ia6t_expire;	/* valid lifetime expiration time */
9476429de4SYoshinobu Inoue 	time_t ia6t_preferred;	/* preferred lifetime expiration time */
9576429de4SYoshinobu Inoue 	u_int32_t ia6t_vltime;	/* valid lifetime */
9676429de4SYoshinobu Inoue 	u_int32_t ia6t_pltime;	/* prefix lifetime */
9776429de4SYoshinobu Inoue };
9876429de4SYoshinobu Inoue 
9931b1bfe1SHajimu UMEMOTO struct nd_ifinfo;
10031b1bfe1SHajimu UMEMOTO struct scope6_id;
1016e6b3f7cSQing Li struct lltable;
1029e62a5a3SGleb Smirnoff struct mld_ifsoftc;
103f3e1324bSStephen Hurd struct in6_multi;
10433cde130SBruce M Simpson 
10531b1bfe1SHajimu UMEMOTO struct in6_ifextra {
1062841260cSAndrey V. Elsukov 	counter_u64_t *in6_ifstat;
1072841260cSAndrey V. Elsukov 	counter_u64_t *icmp6_ifstat;
10831b1bfe1SHajimu UMEMOTO 	struct nd_ifinfo *nd_ifinfo;
10931b1bfe1SHajimu UMEMOTO 	struct scope6_id *scope6_id;
1106e6b3f7cSQing Li 	struct lltable *lltable;
1119e62a5a3SGleb Smirnoff 	struct mld_ifsoftc *mld_ifinfo;
11231b1bfe1SHajimu UMEMOTO };
11331b1bfe1SHajimu UMEMOTO 
1146e6b3f7cSQing Li #define	LLTABLE6(ifp)	(((struct in6_ifextra *)(ifp)->if_afdata[AF_INET6])->lltable)
1156e6b3f7cSQing Li 
116e072c794SGleb Smirnoff #ifdef _KERNEL
117f3e1324bSStephen Hurd 
118f3e1324bSStephen Hurd SLIST_HEAD(in6_multi_head, in6_multi);
119f3e1324bSStephen Hurd MALLOC_DECLARE(M_IP6MADDR);
120f3e1324bSStephen Hurd 
12176429de4SYoshinobu Inoue struct	in6_ifaddr {
12276429de4SYoshinobu Inoue 	struct	ifaddr ia_ifa;		/* protocol-independent info */
12376429de4SYoshinobu Inoue #define	ia_ifp		ia_ifa.ifa_ifp
12476429de4SYoshinobu Inoue #define ia_flags	ia_ifa.ifa_flags
12576429de4SYoshinobu Inoue 	struct	sockaddr_in6 ia_addr;	/* interface address */
12676429de4SYoshinobu Inoue 	struct	sockaddr_in6 ia_net;	/* network number of interface */
12776429de4SYoshinobu Inoue 	struct	sockaddr_in6 ia_dstaddr; /* space for destination addr */
12876429de4SYoshinobu Inoue 	struct	sockaddr_in6 ia_prefixmask; /* prefix mask */
12976429de4SYoshinobu Inoue 	u_int32_t ia_plen;		/* prefix length */
1300f8d79d9SMatt Macy 	CK_STAILQ_ENTRY(in6_ifaddr)	ia_link;	/* list of IPv6 addresses */
13176429de4SYoshinobu Inoue 	int	ia6_flags;
13276429de4SYoshinobu Inoue 
13333841545SHajimu UMEMOTO 	struct in6_addrlifetime ia6_lifetime;
134743eee66SSUZUKI Shinsuke 	time_t	ia6_createtime; /* the creation time of this address, which is
135743eee66SSUZUKI Shinsuke 				 * currently used for temporary addresses only.
136743eee66SSUZUKI Shinsuke 				 */
137743eee66SSUZUKI Shinsuke 	time_t	ia6_updatetime;
13833841545SHajimu UMEMOTO 
1397efe5d92SHajimu UMEMOTO 	/* back pointer to the ND prefix (for autoconfigured addresses only) */
1407efe5d92SHajimu UMEMOTO 	struct nd_prefix *ia6_ndpr;
14109a52a55SJINMEI Tatuya 
14209a52a55SJINMEI Tatuya 	/* multicast addresses joined from the kernel */
14309a52a55SJINMEI Tatuya 	LIST_HEAD(, in6_multi_mship) ia6_memberships;
14468eba526SAndrey V. Elsukov 	/* entry in bucket of inet6 addresses */
1450f8d79d9SMatt Macy 	CK_LIST_ENTRY(in6_ifaddr) ia6_hash;
14676429de4SYoshinobu Inoue };
14776429de4SYoshinobu Inoue 
14880af0152SRobert Watson /* List of in6_ifaddr's. */
1490f8d79d9SMatt Macy CK_STAILQ_HEAD(in6_ifaddrhead, in6_ifaddr);
1500f8d79d9SMatt Macy CK_LIST_HEAD(in6_ifaddrlisthead, in6_ifaddr);
151e072c794SGleb Smirnoff #endif	/* _KERNEL */
15280af0152SRobert Watson 
1537fc91b3fSHajimu UMEMOTO /* control structure to manage address selection policy */
1547fc91b3fSHajimu UMEMOTO struct in6_addrpolicy {
1557fc91b3fSHajimu UMEMOTO 	struct sockaddr_in6 addr; /* prefix address */
1567fc91b3fSHajimu UMEMOTO 	struct sockaddr_in6 addrmask; /* prefix mask */
1577fc91b3fSHajimu UMEMOTO 	int preced;		/* precedence */
1587fc91b3fSHajimu UMEMOTO 	int label;		/* matching label */
1597fc91b3fSHajimu UMEMOTO 	u_quad_t use;		/* statistics */
1607fc91b3fSHajimu UMEMOTO };
1617fc91b3fSHajimu UMEMOTO 
16276429de4SYoshinobu Inoue /*
16376429de4SYoshinobu Inoue  * IPv6 interface statistics, as defined in RFC2465 Ipv6IfStatsEntry (p12).
16476429de4SYoshinobu Inoue  */
16576429de4SYoshinobu Inoue struct in6_ifstat {
166c80211e3SAndrey V. Elsukov 	uint64_t ifs6_in_receive;	/* # of total input datagram */
167c80211e3SAndrey V. Elsukov 	uint64_t ifs6_in_hdrerr;	/* # of datagrams with invalid hdr */
168c80211e3SAndrey V. Elsukov 	uint64_t ifs6_in_toobig;	/* # of datagrams exceeded MTU */
169c80211e3SAndrey V. Elsukov 	uint64_t ifs6_in_noroute;	/* # of datagrams with no route */
170c80211e3SAndrey V. Elsukov 	uint64_t ifs6_in_addrerr;	/* # of datagrams with invalid dst */
171c80211e3SAndrey V. Elsukov 	uint64_t ifs6_in_protounknown;	/* # of datagrams with unknown proto */
17276429de4SYoshinobu Inoue 					/* NOTE: increment on final dst if */
173c80211e3SAndrey V. Elsukov 	uint64_t ifs6_in_truncated;	/* # of truncated datagrams */
174c80211e3SAndrey V. Elsukov 	uint64_t ifs6_in_discard;	/* # of discarded datagrams */
17576429de4SYoshinobu Inoue 					/* NOTE: fragment timeout is not here */
176c80211e3SAndrey V. Elsukov 	uint64_t ifs6_in_deliver;	/* # of datagrams delivered to ULP */
17776429de4SYoshinobu Inoue 					/* NOTE: increment on final dst if */
178c80211e3SAndrey V. Elsukov 	uint64_t ifs6_out_forward;	/* # of datagrams forwarded */
17976429de4SYoshinobu Inoue 					/* NOTE: increment on outgoing if */
180c80211e3SAndrey V. Elsukov 	uint64_t ifs6_out_request;	/* # of outgoing datagrams from ULP */
18176429de4SYoshinobu Inoue 					/* NOTE: does not include forwrads */
182c80211e3SAndrey V. Elsukov 	uint64_t ifs6_out_discard;	/* # of discarded datagrams */
183c80211e3SAndrey V. Elsukov 	uint64_t ifs6_out_fragok;	/* # of datagrams fragmented */
184c80211e3SAndrey V. Elsukov 	uint64_t ifs6_out_fragfail;	/* # of datagrams failed on fragment */
185c80211e3SAndrey V. Elsukov 	uint64_t ifs6_out_fragcreat;	/* # of fragment datagrams */
18676429de4SYoshinobu Inoue 					/* NOTE: this is # after fragment */
187c80211e3SAndrey V. Elsukov 	uint64_t ifs6_reass_reqd;	/* # of incoming fragmented packets */
18876429de4SYoshinobu Inoue 					/* NOTE: increment on final dst if */
189c80211e3SAndrey V. Elsukov 	uint64_t ifs6_reass_ok;		/* # of reassembled packets */
19076429de4SYoshinobu Inoue 					/* NOTE: this is # after reass */
19176429de4SYoshinobu Inoue 					/* NOTE: increment on final dst if */
192c80211e3SAndrey V. Elsukov 	uint64_t ifs6_reass_fail;	/* # of reass failures */
19376429de4SYoshinobu Inoue 					/* NOTE: may not be packet count */
19476429de4SYoshinobu Inoue 					/* NOTE: increment on final dst if */
195c80211e3SAndrey V. Elsukov 	uint64_t ifs6_in_mcast;		/* # of inbound multicast datagrams */
196c80211e3SAndrey V. Elsukov 	uint64_t ifs6_out_mcast;	/* # of outbound multicast datagrams */
19776429de4SYoshinobu Inoue };
19876429de4SYoshinobu Inoue 
19976429de4SYoshinobu Inoue /*
20076429de4SYoshinobu Inoue  * ICMPv6 interface statistics, as defined in RFC2466 Ipv6IfIcmpEntry.
20176429de4SYoshinobu Inoue  * XXX: I'm not sure if this file is the right place for this structure...
20276429de4SYoshinobu Inoue  */
20376429de4SYoshinobu Inoue struct icmp6_ifstat {
20476429de4SYoshinobu Inoue 	/*
20576429de4SYoshinobu Inoue 	 * Input statistics
20676429de4SYoshinobu Inoue 	 */
20776429de4SYoshinobu Inoue 	/* ipv6IfIcmpInMsgs, total # of input messages */
208c80211e3SAndrey V. Elsukov 	uint64_t ifs6_in_msg;
20976429de4SYoshinobu Inoue 	/* ipv6IfIcmpInErrors, # of input error messages */
210c80211e3SAndrey V. Elsukov 	uint64_t ifs6_in_error;
21176429de4SYoshinobu Inoue 	/* ipv6IfIcmpInDestUnreachs, # of input dest unreach errors */
212c80211e3SAndrey V. Elsukov 	uint64_t ifs6_in_dstunreach;
21376429de4SYoshinobu Inoue 	/* ipv6IfIcmpInAdminProhibs, # of input administratively prohibited errs */
214c80211e3SAndrey V. Elsukov 	uint64_t ifs6_in_adminprohib;
21576429de4SYoshinobu Inoue 	/* ipv6IfIcmpInTimeExcds, # of input time exceeded errors */
216c80211e3SAndrey V. Elsukov 	uint64_t ifs6_in_timeexceed;
21776429de4SYoshinobu Inoue 	/* ipv6IfIcmpInParmProblems, # of input parameter problem errors */
218c80211e3SAndrey V. Elsukov 	uint64_t ifs6_in_paramprob;
21976429de4SYoshinobu Inoue 	/* ipv6IfIcmpInPktTooBigs, # of input packet too big errors */
220c80211e3SAndrey V. Elsukov 	uint64_t ifs6_in_pkttoobig;
22176429de4SYoshinobu Inoue 	/* ipv6IfIcmpInEchos, # of input echo requests */
222c80211e3SAndrey V. Elsukov 	uint64_t ifs6_in_echo;
22376429de4SYoshinobu Inoue 	/* ipv6IfIcmpInEchoReplies, # of input echo replies */
224c80211e3SAndrey V. Elsukov 	uint64_t ifs6_in_echoreply;
22576429de4SYoshinobu Inoue 	/* ipv6IfIcmpInRouterSolicits, # of input router solicitations */
226c80211e3SAndrey V. Elsukov 	uint64_t ifs6_in_routersolicit;
22776429de4SYoshinobu Inoue 	/* ipv6IfIcmpInRouterAdvertisements, # of input router advertisements */
228c80211e3SAndrey V. Elsukov 	uint64_t ifs6_in_routeradvert;
22976429de4SYoshinobu Inoue 	/* ipv6IfIcmpInNeighborSolicits, # of input neighbor solicitations */
230c80211e3SAndrey V. Elsukov 	uint64_t ifs6_in_neighborsolicit;
23176429de4SYoshinobu Inoue 	/* ipv6IfIcmpInNeighborAdvertisements, # of input neighbor advertisements */
232c80211e3SAndrey V. Elsukov 	uint64_t ifs6_in_neighboradvert;
23376429de4SYoshinobu Inoue 	/* ipv6IfIcmpInRedirects, # of input redirects */
234c80211e3SAndrey V. Elsukov 	uint64_t ifs6_in_redirect;
23576429de4SYoshinobu Inoue 	/* ipv6IfIcmpInGroupMembQueries, # of input MLD queries */
236c80211e3SAndrey V. Elsukov 	uint64_t ifs6_in_mldquery;
23776429de4SYoshinobu Inoue 	/* ipv6IfIcmpInGroupMembResponses, # of input MLD reports */
238c80211e3SAndrey V. Elsukov 	uint64_t ifs6_in_mldreport;
23976429de4SYoshinobu Inoue 	/* ipv6IfIcmpInGroupMembReductions, # of input MLD done */
240c80211e3SAndrey V. Elsukov 	uint64_t ifs6_in_mlddone;
24176429de4SYoshinobu Inoue 
24276429de4SYoshinobu Inoue 	/*
24376429de4SYoshinobu Inoue 	 * Output statistics. We should solve unresolved routing problem...
24476429de4SYoshinobu Inoue 	 */
24576429de4SYoshinobu Inoue 	/* ipv6IfIcmpOutMsgs, total # of output messages */
246c80211e3SAndrey V. Elsukov 	uint64_t ifs6_out_msg;
24776429de4SYoshinobu Inoue 	/* ipv6IfIcmpOutErrors, # of output error messages */
248c80211e3SAndrey V. Elsukov 	uint64_t ifs6_out_error;
24976429de4SYoshinobu Inoue 	/* ipv6IfIcmpOutDestUnreachs, # of output dest unreach errors */
250c80211e3SAndrey V. Elsukov 	uint64_t ifs6_out_dstunreach;
25176429de4SYoshinobu Inoue 	/* ipv6IfIcmpOutAdminProhibs, # of output administratively prohibited errs */
252c80211e3SAndrey V. Elsukov 	uint64_t ifs6_out_adminprohib;
25376429de4SYoshinobu Inoue 	/* ipv6IfIcmpOutTimeExcds, # of output time exceeded errors */
254c80211e3SAndrey V. Elsukov 	uint64_t ifs6_out_timeexceed;
25576429de4SYoshinobu Inoue 	/* ipv6IfIcmpOutParmProblems, # of output parameter problem errors */
256c80211e3SAndrey V. Elsukov 	uint64_t ifs6_out_paramprob;
25776429de4SYoshinobu Inoue 	/* ipv6IfIcmpOutPktTooBigs, # of output packet too big errors */
258c80211e3SAndrey V. Elsukov 	uint64_t ifs6_out_pkttoobig;
25976429de4SYoshinobu Inoue 	/* ipv6IfIcmpOutEchos, # of output echo requests */
260c80211e3SAndrey V. Elsukov 	uint64_t ifs6_out_echo;
26176429de4SYoshinobu Inoue 	/* ipv6IfIcmpOutEchoReplies, # of output echo replies */
262c80211e3SAndrey V. Elsukov 	uint64_t ifs6_out_echoreply;
26376429de4SYoshinobu Inoue 	/* ipv6IfIcmpOutRouterSolicits, # of output router solicitations */
264c80211e3SAndrey V. Elsukov 	uint64_t ifs6_out_routersolicit;
26576429de4SYoshinobu Inoue 	/* ipv6IfIcmpOutRouterAdvertisements, # of output router advertisements */
266c80211e3SAndrey V. Elsukov 	uint64_t ifs6_out_routeradvert;
26776429de4SYoshinobu Inoue 	/* ipv6IfIcmpOutNeighborSolicits, # of output neighbor solicitations */
268c80211e3SAndrey V. Elsukov 	uint64_t ifs6_out_neighborsolicit;
26976429de4SYoshinobu Inoue 	/* ipv6IfIcmpOutNeighborAdvertisements, # of output neighbor advertisements */
270c80211e3SAndrey V. Elsukov 	uint64_t ifs6_out_neighboradvert;
27176429de4SYoshinobu Inoue 	/* ipv6IfIcmpOutRedirects, # of output redirects */
272c80211e3SAndrey V. Elsukov 	uint64_t ifs6_out_redirect;
27376429de4SYoshinobu Inoue 	/* ipv6IfIcmpOutGroupMembQueries, # of output MLD queries */
274c80211e3SAndrey V. Elsukov 	uint64_t ifs6_out_mldquery;
27576429de4SYoshinobu Inoue 	/* ipv6IfIcmpOutGroupMembResponses, # of output MLD reports */
276c80211e3SAndrey V. Elsukov 	uint64_t ifs6_out_mldreport;
27776429de4SYoshinobu Inoue 	/* ipv6IfIcmpOutGroupMembReductions, # of output MLD done */
278c80211e3SAndrey V. Elsukov 	uint64_t ifs6_out_mlddone;
27976429de4SYoshinobu Inoue };
28076429de4SYoshinobu Inoue 
28176429de4SYoshinobu Inoue struct	in6_ifreq {
28276429de4SYoshinobu Inoue 	char	ifr_name[IFNAMSIZ];
28376429de4SYoshinobu Inoue 	union {
28476429de4SYoshinobu Inoue 		struct	sockaddr_in6 ifru_addr;
28576429de4SYoshinobu Inoue 		struct	sockaddr_in6 ifru_dstaddr;
28662f76486SMaxim Sobolev 		int	ifru_flags;
28776429de4SYoshinobu Inoue 		int	ifru_flags6;
28876429de4SYoshinobu Inoue 		int	ifru_metric;
28976429de4SYoshinobu Inoue 		caddr_t	ifru_data;
29076429de4SYoshinobu Inoue 		struct in6_addrlifetime ifru_lifetime;
29176429de4SYoshinobu Inoue 		struct in6_ifstat ifru_stat;
29276429de4SYoshinobu Inoue 		struct icmp6_ifstat ifru_icmp6stat;
293686cdd19SJun-ichiro itojun Hagino 		u_int32_t ifru_scope_id[16];
29476429de4SYoshinobu Inoue 	} ifr_ifru;
29576429de4SYoshinobu Inoue };
29676429de4SYoshinobu Inoue 
29776429de4SYoshinobu Inoue struct	in6_aliasreq {
29876429de4SYoshinobu Inoue 	char	ifra_name[IFNAMSIZ];
29976429de4SYoshinobu Inoue 	struct	sockaddr_in6 ifra_addr;
30076429de4SYoshinobu Inoue 	struct	sockaddr_in6 ifra_dstaddr;
30176429de4SYoshinobu Inoue 	struct	sockaddr_in6 ifra_prefixmask;
30276429de4SYoshinobu Inoue 	int	ifra_flags;
30376429de4SYoshinobu Inoue 	struct in6_addrlifetime ifra_lifetime;
30408b68b0eSGleb Smirnoff 	int	ifra_vhid;
30576429de4SYoshinobu Inoue };
30676429de4SYoshinobu Inoue 
30771212473SGleb Smirnoff /* pre-10.x compat */
30871212473SGleb Smirnoff struct	oin6_aliasreq {
30971212473SGleb Smirnoff 	char	ifra_name[IFNAMSIZ];
31071212473SGleb Smirnoff 	struct	sockaddr_in6 ifra_addr;
31171212473SGleb Smirnoff 	struct	sockaddr_in6 ifra_dstaddr;
31271212473SGleb Smirnoff 	struct	sockaddr_in6 ifra_prefixmask;
31371212473SGleb Smirnoff 	int	ifra_flags;
31471212473SGleb Smirnoff 	struct in6_addrlifetime ifra_lifetime;
31571212473SGleb Smirnoff };
31671212473SGleb Smirnoff 
31776429de4SYoshinobu Inoue /* prefix type macro */
31876429de4SYoshinobu Inoue #define IN6_PREFIX_ND	1
31976429de4SYoshinobu Inoue #define IN6_PREFIX_RR	2
32076429de4SYoshinobu Inoue 
32176429de4SYoshinobu Inoue /*
32276429de4SYoshinobu Inoue  * prefix related flags passed between kernel(NDP related part) and
32376429de4SYoshinobu Inoue  * user land command(ifconfig) and daemon(rtadvd).
32476429de4SYoshinobu Inoue  */
32576429de4SYoshinobu Inoue struct in6_prflags {
32676429de4SYoshinobu Inoue 	struct prf_ra {
32776429de4SYoshinobu Inoue 		u_char onlink : 1;
32876429de4SYoshinobu Inoue 		u_char autonomous : 1;
3298036234cSAlexander V. Chernikov 		u_char ra_derived: 1;
3308036234cSAlexander V. Chernikov 		u_char reserved : 5;
33176429de4SYoshinobu Inoue 	} prf_ra;
33276429de4SYoshinobu Inoue 	u_char prf_reserved1;
33376429de4SYoshinobu Inoue 	u_short prf_reserved2;
33476429de4SYoshinobu Inoue 	/* want to put this on 4byte offset */
33576429de4SYoshinobu Inoue 	struct prf_rr {
33676429de4SYoshinobu Inoue 		u_char decrvalid : 1;
33776429de4SYoshinobu Inoue 		u_char decrprefd : 1;
33876429de4SYoshinobu Inoue 		u_char reserved : 6;
33976429de4SYoshinobu Inoue 	} prf_rr;
34076429de4SYoshinobu Inoue 	u_char prf_reserved3;
34176429de4SYoshinobu Inoue 	u_short prf_reserved4;
34276429de4SYoshinobu Inoue };
34376429de4SYoshinobu Inoue 
34476429de4SYoshinobu Inoue struct  in6_prefixreq {
34576429de4SYoshinobu Inoue 	char	ipr_name[IFNAMSIZ];
34676429de4SYoshinobu Inoue 	u_char	ipr_origin;
34776429de4SYoshinobu Inoue 	u_char	ipr_plen;
34876429de4SYoshinobu Inoue 	u_int32_t ipr_vltime;
34976429de4SYoshinobu Inoue 	u_int32_t ipr_pltime;
35076429de4SYoshinobu Inoue 	struct in6_prflags ipr_flags;
35176429de4SYoshinobu Inoue 	struct	sockaddr_in6 ipr_prefix;
35276429de4SYoshinobu Inoue };
35376429de4SYoshinobu Inoue 
35476429de4SYoshinobu Inoue #define PR_ORIG_RA	0
35576429de4SYoshinobu Inoue #define PR_ORIG_RR	1
35676429de4SYoshinobu Inoue #define PR_ORIG_STATIC	2
35776429de4SYoshinobu Inoue #define PR_ORIG_KERNEL	3
35876429de4SYoshinobu Inoue 
35976429de4SYoshinobu Inoue #define ipr_raf_onlink		ipr_flags.prf_ra.onlink
36076429de4SYoshinobu Inoue #define ipr_raf_auto		ipr_flags.prf_ra.autonomous
3618036234cSAlexander V. Chernikov #define ipr_raf_ra_derived	ipr_flags.prf_ra.ra_derived
36276429de4SYoshinobu Inoue 
36376429de4SYoshinobu Inoue #define ipr_statef_onlink	ipr_flags.prf_state.onlink
36476429de4SYoshinobu Inoue 
36576429de4SYoshinobu Inoue #define ipr_rrf_decrvalid	ipr_flags.prf_rr.decrvalid
36676429de4SYoshinobu Inoue #define ipr_rrf_decrprefd	ipr_flags.prf_rr.decrprefd
36776429de4SYoshinobu Inoue 
36876429de4SYoshinobu Inoue struct	in6_rrenumreq {
36976429de4SYoshinobu Inoue 	char	irr_name[IFNAMSIZ];
37076429de4SYoshinobu Inoue 	u_char	irr_origin;
37176429de4SYoshinobu Inoue 	u_char	irr_m_len;	/* match len for matchprefix */
37276429de4SYoshinobu Inoue 	u_char	irr_m_minlen;	/* minlen for matching prefix */
37376429de4SYoshinobu Inoue 	u_char	irr_m_maxlen;	/* maxlen for matching prefix */
37476429de4SYoshinobu Inoue 	u_char	irr_u_uselen;	/* uselen for adding prefix */
37576429de4SYoshinobu Inoue 	u_char	irr_u_keeplen;	/* keeplen from matching prefix */
37676429de4SYoshinobu Inoue 	struct irr_raflagmask {
37776429de4SYoshinobu Inoue 		u_char onlink : 1;
37876429de4SYoshinobu Inoue 		u_char autonomous : 1;
37976429de4SYoshinobu Inoue 		u_char reserved : 6;
38076429de4SYoshinobu Inoue 	} irr_raflagmask;
38176429de4SYoshinobu Inoue 	u_int32_t irr_vltime;
38276429de4SYoshinobu Inoue 	u_int32_t irr_pltime;
38376429de4SYoshinobu Inoue 	struct in6_prflags irr_flags;
38476429de4SYoshinobu Inoue 	struct	sockaddr_in6 irr_matchprefix;
38576429de4SYoshinobu Inoue 	struct	sockaddr_in6 irr_useprefix;
38676429de4SYoshinobu Inoue };
38776429de4SYoshinobu Inoue 
38876429de4SYoshinobu Inoue #define irr_raf_mask_onlink	irr_raflagmask.onlink
38976429de4SYoshinobu Inoue #define irr_raf_mask_auto	irr_raflagmask.autonomous
39076429de4SYoshinobu Inoue #define irr_raf_mask_reserved	irr_raflagmask.reserved
39176429de4SYoshinobu Inoue 
39276429de4SYoshinobu Inoue #define irr_raf_onlink		irr_flags.prf_ra.onlink
39376429de4SYoshinobu Inoue #define irr_raf_auto		irr_flags.prf_ra.autonomous
39476429de4SYoshinobu Inoue 
39576429de4SYoshinobu Inoue #define irr_statef_onlink	irr_flags.prf_state.onlink
39676429de4SYoshinobu Inoue 
39776429de4SYoshinobu Inoue #define irr_rrf			irr_flags.prf_rr
39876429de4SYoshinobu Inoue #define irr_rrf_decrvalid	irr_flags.prf_rr.decrvalid
39976429de4SYoshinobu Inoue #define irr_rrf_decrprefd	irr_flags.prf_rr.decrprefd
40076429de4SYoshinobu Inoue 
40176429de4SYoshinobu Inoue /*
40276429de4SYoshinobu Inoue  * Given a pointer to an in6_ifaddr (ifaddr),
40376429de4SYoshinobu Inoue  * return a pointer to the addr as a sockaddr_in6
40476429de4SYoshinobu Inoue  */
40576429de4SYoshinobu Inoue #define IA6_IN6(ia)	(&((ia)->ia_addr.sin6_addr))
40676429de4SYoshinobu Inoue #define IA6_DSTIN6(ia)	(&((ia)->ia_dstaddr.sin6_addr))
40776429de4SYoshinobu Inoue #define IA6_MASKIN6(ia)	(&((ia)->ia_prefixmask.sin6_addr))
40876429de4SYoshinobu Inoue #define IA6_SIN6(ia)	(&((ia)->ia_addr))
40976429de4SYoshinobu Inoue #define IA6_DSTSIN6(ia)	(&((ia)->ia_dstaddr))
41076429de4SYoshinobu Inoue #define IFA_IN6(x)	(&((struct sockaddr_in6 *)((x)->ifa_addr))->sin6_addr)
41176429de4SYoshinobu Inoue #define IFA_DSTIN6(x)	(&((struct sockaddr_in6 *)((x)->ifa_dstaddr))->sin6_addr)
41219dc6445SKristof Provost #define IFA_MASKIN6(x)	(&((struct sockaddr_in6 *)((x)->ifa_netmask))->sin6_addr)
41376429de4SYoshinobu Inoue 
41476429de4SYoshinobu Inoue #define IFPR_IN6(x)	(&((struct sockaddr_in6 *)((x)->ifpr_prefix))->sin6_addr)
41576429de4SYoshinobu Inoue 
41676429de4SYoshinobu Inoue #ifdef _KERNEL
41776429de4SYoshinobu Inoue #define IN6_ARE_MASKED_ADDR_EQUAL(d, a, m)	(	\
41876429de4SYoshinobu Inoue 	(((d)->s6_addr32[0] ^ (a)->s6_addr32[0]) & (m)->s6_addr32[0]) == 0 && \
41976429de4SYoshinobu Inoue 	(((d)->s6_addr32[1] ^ (a)->s6_addr32[1]) & (m)->s6_addr32[1]) == 0 && \
42076429de4SYoshinobu Inoue 	(((d)->s6_addr32[2] ^ (a)->s6_addr32[2]) & (m)->s6_addr32[2]) == 0 && \
42176429de4SYoshinobu Inoue 	(((d)->s6_addr32[3] ^ (a)->s6_addr32[3]) & (m)->s6_addr32[3]) == 0 )
4221dc8f6a8SAlexander V. Chernikov #define IN6_MASK_ADDR(a, m)	do { \
4231dc8f6a8SAlexander V. Chernikov 	(a)->s6_addr32[0] &= (m)->s6_addr32[0]; \
4241dc8f6a8SAlexander V. Chernikov 	(a)->s6_addr32[1] &= (m)->s6_addr32[1]; \
4251dc8f6a8SAlexander V. Chernikov 	(a)->s6_addr32[2] &= (m)->s6_addr32[2]; \
4261dc8f6a8SAlexander V. Chernikov 	(a)->s6_addr32[3] &= (m)->s6_addr32[3]; \
4271dc8f6a8SAlexander V. Chernikov } while (0)
42876429de4SYoshinobu Inoue #endif
42976429de4SYoshinobu Inoue 
43076429de4SYoshinobu Inoue #define SIOCSIFADDR_IN6		 _IOW('i', 12, struct in6_ifreq)
43176429de4SYoshinobu Inoue #define SIOCGIFADDR_IN6		_IOWR('i', 33, struct in6_ifreq)
432686cdd19SJun-ichiro itojun Hagino 
433686cdd19SJun-ichiro itojun Hagino #ifdef _KERNEL
434686cdd19SJun-ichiro itojun Hagino /*
435686cdd19SJun-ichiro itojun Hagino  * SIOCSxxx ioctls should be unused (see comments in in6.c), but
436686cdd19SJun-ichiro itojun Hagino  * we do not shift numbers for binary compatibility.
437686cdd19SJun-ichiro itojun Hagino  */
43876429de4SYoshinobu Inoue #define SIOCSIFDSTADDR_IN6	 _IOW('i', 14, struct in6_ifreq)
43976429de4SYoshinobu Inoue #define SIOCSIFNETMASK_IN6	 _IOW('i', 22, struct in6_ifreq)
440686cdd19SJun-ichiro itojun Hagino #endif
441686cdd19SJun-ichiro itojun Hagino 
442686cdd19SJun-ichiro itojun Hagino #define SIOCGIFDSTADDR_IN6	_IOWR('i', 34, struct in6_ifreq)
44376429de4SYoshinobu Inoue #define SIOCGIFNETMASK_IN6	_IOWR('i', 37, struct in6_ifreq)
44476429de4SYoshinobu Inoue 
44576429de4SYoshinobu Inoue #define SIOCDIFADDR_IN6		 _IOW('i', 25, struct in6_ifreq)
44671212473SGleb Smirnoff #define OSIOCAIFADDR_IN6	 _IOW('i', 26, struct oin6_aliasreq)
44771212473SGleb Smirnoff #define SIOCAIFADDR_IN6		 _IOW('i', 27, struct in6_aliasreq)
44876429de4SYoshinobu Inoue 
44976429de4SYoshinobu Inoue #define SIOCSIFPHYADDR_IN6       _IOW('i', 70, struct in6_aliasreq)
45076429de4SYoshinobu Inoue #define	SIOCGIFPSRCADDR_IN6	_IOWR('i', 71, struct in6_ifreq)
45176429de4SYoshinobu Inoue #define	SIOCGIFPDSTADDR_IN6	_IOWR('i', 72, struct in6_ifreq)
45276429de4SYoshinobu Inoue 
45376429de4SYoshinobu Inoue #define SIOCGIFAFLAG_IN6	_IOWR('i', 73, struct in6_ifreq)
45476429de4SYoshinobu Inoue 
45533841545SHajimu UMEMOTO #ifdef _KERNEL
45633841545SHajimu UMEMOTO #define OSIOCGIFINFO_IN6	_IOWR('i', 76, struct in6_ondireq)
45733841545SHajimu UMEMOTO #endif
45833841545SHajimu UMEMOTO #define SIOCGIFINFO_IN6		_IOWR('i', 108, struct in6_ndireq)
459b9204379SSUZUKI Shinsuke #define SIOCSIFINFO_IN6		_IOWR('i', 109, struct in6_ndireq)
46076429de4SYoshinobu Inoue #define SIOCSNDFLUSH_IN6	_IOWR('i', 77, struct in6_ifreq)
46176429de4SYoshinobu Inoue #define SIOCGNBRINFO_IN6	_IOWR('i', 78, struct in6_nbrinfo)
46276429de4SYoshinobu Inoue #define SIOCSPFXFLUSH_IN6	_IOWR('i', 79, struct in6_ifreq)
46376429de4SYoshinobu Inoue #define SIOCSRTRFLUSH_IN6	_IOWR('i', 80, struct in6_ifreq)
46476429de4SYoshinobu Inoue 
46576429de4SYoshinobu Inoue #define SIOCGIFALIFETIME_IN6	_IOWR('i', 81, struct in6_ifreq)
46676429de4SYoshinobu Inoue #define SIOCGIFSTAT_IN6		_IOWR('i', 83, struct in6_ifreq)
46776429de4SYoshinobu Inoue #define SIOCGIFSTAT_ICMP6	_IOWR('i', 84, struct in6_ifreq)
46876429de4SYoshinobu Inoue 
469686cdd19SJun-ichiro itojun Hagino #define SIOCSDEFIFACE_IN6	_IOWR('i', 85, struct in6_ndifreq)
470686cdd19SJun-ichiro itojun Hagino #define SIOCGDEFIFACE_IN6	_IOWR('i', 86, struct in6_ndifreq)
471686cdd19SJun-ichiro itojun Hagino 
472686cdd19SJun-ichiro itojun Hagino #define SIOCSIFINFO_FLAGS	_IOWR('i', 87, struct in6_ndireq) /* XXX */
473686cdd19SJun-ichiro itojun Hagino 
474686cdd19SJun-ichiro itojun Hagino #define SIOCSSCOPE6		_IOW('i', 88, struct in6_ifreq)
475686cdd19SJun-ichiro itojun Hagino #define SIOCGSCOPE6		_IOWR('i', 89, struct in6_ifreq)
476686cdd19SJun-ichiro itojun Hagino #define SIOCGSCOPE6DEF		_IOWR('i', 90, struct in6_ifreq)
477686cdd19SJun-ichiro itojun Hagino 
47876429de4SYoshinobu Inoue #define SIOCSIFPREFIX_IN6	_IOW('i', 100, struct in6_prefixreq) /* set */
47976429de4SYoshinobu Inoue #define SIOCGIFPREFIX_IN6	_IOWR('i', 101, struct in6_prefixreq) /* get */
48076429de4SYoshinobu Inoue #define SIOCDIFPREFIX_IN6	_IOW('i', 102, struct in6_prefixreq) /* del */
48176429de4SYoshinobu Inoue #define SIOCAIFPREFIX_IN6	_IOW('i', 103, struct in6_rrenumreq) /* add */
48276429de4SYoshinobu Inoue #define SIOCCIFPREFIX_IN6	_IOW('i', 104, \
48376429de4SYoshinobu Inoue 				     struct in6_rrenumreq) /* change */
48476429de4SYoshinobu Inoue #define SIOCSGIFPREFIX_IN6	_IOW('i', 105, \
48576429de4SYoshinobu Inoue 				     struct in6_rrenumreq) /* set global */
48676429de4SYoshinobu Inoue 
48776429de4SYoshinobu Inoue #define SIOCGETSGCNT_IN6	_IOWR('u', 106, \
48876429de4SYoshinobu Inoue 				      struct sioc_sg_req6) /* get s,g pkt cnt */
48976429de4SYoshinobu Inoue #define SIOCGETMIFCNT_IN6	_IOWR('u', 107, \
49076429de4SYoshinobu Inoue 				      struct sioc_mif_req6) /* get pkt cnt per if */
49176429de4SYoshinobu Inoue 
4927fc91b3fSHajimu UMEMOTO #define SIOCAADDRCTL_POLICY	_IOW('u', 108, struct in6_addrpolicy)
4937fc91b3fSHajimu UMEMOTO #define SIOCDADDRCTL_POLICY	_IOW('u', 109, struct in6_addrpolicy)
4947fc91b3fSHajimu UMEMOTO 
49576429de4SYoshinobu Inoue #define IN6_IFF_ANYCAST		0x01	/* anycast address */
49676429de4SYoshinobu Inoue #define IN6_IFF_TENTATIVE	0x02	/* tentative address */
49776429de4SYoshinobu Inoue #define IN6_IFF_DUPLICATED	0x04	/* DAD detected duplicate */
49876429de4SYoshinobu Inoue #define IN6_IFF_DETACHED	0x08	/* may be detached from the link */
49976429de4SYoshinobu Inoue #define IN6_IFF_DEPRECATED	0x10	/* deprecated address */
50033841545SHajimu UMEMOTO #define IN6_IFF_NODAD		0x20	/* don't perform DAD on this address
501fb583bd2SHiroki Sato 					 * (obsolete)
50233841545SHajimu UMEMOTO 					 */
50333841545SHajimu UMEMOTO #define IN6_IFF_AUTOCONF	0x40	/* autoconfigurable address. */
50433841545SHajimu UMEMOTO #define IN6_IFF_TEMPORARY	0x80	/* temporary (anonymous) address. */
5055dbfa43fSAndrey V. Elsukov #define	IN6_IFF_PREFER_SOURCE	0x0100	/* preferred address for SAS */
50676429de4SYoshinobu Inoue 
50776429de4SYoshinobu Inoue /* do not input/output */
50876429de4SYoshinobu Inoue #define IN6_IFF_NOTREADY (IN6_IFF_TENTATIVE|IN6_IFF_DUPLICATED)
50976429de4SYoshinobu Inoue 
51076429de4SYoshinobu Inoue #ifdef _KERNEL
511686cdd19SJun-ichiro itojun Hagino #define IN6_ARE_SCOPE_CMP(a,b) ((a)-(b))
512686cdd19SJun-ichiro itojun Hagino #define IN6_ARE_SCOPE_EQUAL(a,b) ((a)==(b))
513686cdd19SJun-ichiro itojun Hagino #endif
514686cdd19SJun-ichiro itojun Hagino 
515686cdd19SJun-ichiro itojun Hagino #ifdef _KERNEL
516eddfbb76SRobert Watson VNET_DECLARE(struct in6_ifaddrhead, in6_ifaddrhead);
51768eba526SAndrey V. Elsukov VNET_DECLARE(struct in6_ifaddrlisthead *, in6_ifaddrhashtbl);
51868eba526SAndrey V. Elsukov VNET_DECLARE(u_long, in6_ifaddrhmask);
5191e77c105SRobert Watson #define	V_in6_ifaddrhead		VNET(in6_ifaddrhead)
52068eba526SAndrey V. Elsukov #define	V_in6_ifaddrhashtbl		VNET(in6_ifaddrhashtbl)
52168eba526SAndrey V. Elsukov #define	V_in6_ifaddrhmask		VNET(in6_ifaddrhmask)
52268eba526SAndrey V. Elsukov 
52368eba526SAndrey V. Elsukov #define	IN6ADDR_NHASH_LOG2		8
52468eba526SAndrey V. Elsukov #define	IN6ADDR_NHASH			(1 << IN6ADDR_NHASH_LOG2)
52568eba526SAndrey V. Elsukov #define	IN6ADDR_HASHVAL(x)		(in6_addrhash(x))
52668eba526SAndrey V. Elsukov #define	IN6ADDR_HASH(x) \
52768eba526SAndrey V. Elsukov     (&V_in6_ifaddrhashtbl[IN6ADDR_HASHVAL(x) & V_in6_ifaddrhmask])
52868eba526SAndrey V. Elsukov 
52968eba526SAndrey V. Elsukov static __inline uint32_t
530343e440fSAndrey V. Elsukov in6_addrhash(const struct in6_addr *in6)
53168eba526SAndrey V. Elsukov {
53268eba526SAndrey V. Elsukov 	uint32_t x;
53368eba526SAndrey V. Elsukov 
53468eba526SAndrey V. Elsukov 	x = in6->s6_addr32[0] ^ in6->s6_addr32[1] ^ in6->s6_addr32[2] ^
53568eba526SAndrey V. Elsukov 	    in6->s6_addr32[3];
53668eba526SAndrey V. Elsukov 	return (fnv_32_buf(&x, sizeof(x), FNV1_32_INIT));
53768eba526SAndrey V. Elsukov }
538d1da0a06SRobert Watson 
539cc0a3c8cSAndrey V. Elsukov extern struct rmlock in6_ifaddr_lock;
540cc0a3c8cSAndrey V. Elsukov #define	IN6_IFADDR_LOCK_ASSERT()	rm_assert(&in6_ifaddr_lock, RA_LOCKED)
541cc0a3c8cSAndrey V. Elsukov #define	IN6_IFADDR_RLOCK(t)		rm_rlock(&in6_ifaddr_lock, (t))
542cc0a3c8cSAndrey V. Elsukov #define	IN6_IFADDR_RLOCK_ASSERT()	rm_assert(&in6_ifaddr_lock, RA_RLOCKED)
543cc0a3c8cSAndrey V. Elsukov #define	IN6_IFADDR_RUNLOCK(t)		rm_runlock(&in6_ifaddr_lock, (t))
544cc0a3c8cSAndrey V. Elsukov #define	IN6_IFADDR_WLOCK()		rm_wlock(&in6_ifaddr_lock)
545cc0a3c8cSAndrey V. Elsukov #define	IN6_IFADDR_WLOCK_ASSERT()	rm_assert(&in6_ifaddr_lock, RA_WLOCKED)
546cc0a3c8cSAndrey V. Elsukov #define	IN6_IFADDR_WUNLOCK()		rm_wunlock(&in6_ifaddr_lock)
547d1da0a06SRobert Watson 
54876429de4SYoshinobu Inoue #define in6_ifstat_inc(ifp, tag) \
54976429de4SYoshinobu Inoue do {								\
55031b1bfe1SHajimu UMEMOTO 	if (ifp)						\
5512841260cSAndrey V. Elsukov 		counter_u64_add(((struct in6_ifextra *)		\
5522841260cSAndrey V. Elsukov 		    ((ifp)->if_afdata[AF_INET6]))->in6_ifstat[	\
5532841260cSAndrey V. Elsukov 		    offsetof(struct in6_ifstat, tag) / sizeof(uint64_t)], 1);\
5547efe5d92SHajimu UMEMOTO } while (/*CONSTCOND*/ 0)
55576429de4SYoshinobu Inoue 
55682cea7e6SBjoern A. Zeeb VNET_DECLARE(unsigned long, in6_maxmtu);
55782cea7e6SBjoern A. Zeeb #define	V_in6_maxmtu			VNET(in6_maxmtu)
55876429de4SYoshinobu Inoue #endif /* _KERNEL */
55976429de4SYoshinobu Inoue 
56076429de4SYoshinobu Inoue /*
56133cde130SBruce M Simpson  * IPv6 multicast MLD-layer source entry.
56276429de4SYoshinobu Inoue  */
56333cde130SBruce M Simpson struct ip6_msource {
56433cde130SBruce M Simpson 	RB_ENTRY(ip6_msource)	im6s_link;	/* RB tree links */
56533cde130SBruce M Simpson 	struct in6_addr		im6s_addr;
56633cde130SBruce M Simpson 	struct im6s_st {
56733cde130SBruce M Simpson 		uint16_t	ex;		/* # of exclusive members */
56833cde130SBruce M Simpson 		uint16_t	in;		/* # of inclusive members */
56933cde130SBruce M Simpson 	}			im6s_st[2];	/* state at t0, t1 */
57033cde130SBruce M Simpson 	uint8_t			im6s_stp;	/* pending query */
57176429de4SYoshinobu Inoue };
57233cde130SBruce M Simpson RB_HEAD(ip6_msource_tree, ip6_msource);
57376429de4SYoshinobu Inoue 
57433cde130SBruce M Simpson /*
57533cde130SBruce M Simpson  * IPv6 multicast PCB-layer source entry.
57633cde130SBruce M Simpson  *
57733cde130SBruce M Simpson  * NOTE: overlapping use of struct ip6_msource fields at start.
57833cde130SBruce M Simpson  */
57933cde130SBruce M Simpson struct in6_msource {
58033cde130SBruce M Simpson 	RB_ENTRY(ip6_msource)	im6s_link;	/* Common field */
58133cde130SBruce M Simpson 	struct in6_addr		im6s_addr;	/* Common field */
58233cde130SBruce M Simpson 	uint8_t			im6sl_st[2];	/* state before/at commit */
58376429de4SYoshinobu Inoue };
58476429de4SYoshinobu Inoue 
58576429de4SYoshinobu Inoue #ifdef _KERNEL
58633cde130SBruce M Simpson /*
58733cde130SBruce M Simpson  * IPv6 source tree comparison function.
58833cde130SBruce M Simpson  *
58933cde130SBruce M Simpson  * An ordered predicate is necessary; bcmp() is not documented to return
59033cde130SBruce M Simpson  * an indication of order, memcmp() is, and is an ISO C99 requirement.
59133cde130SBruce M Simpson  */
59233cde130SBruce M Simpson static __inline int
59333cde130SBruce M Simpson ip6_msource_cmp(const struct ip6_msource *a, const struct ip6_msource *b)
59433cde130SBruce M Simpson {
59533cde130SBruce M Simpson 
59633cde130SBruce M Simpson 	return (memcmp(&a->im6s_addr, &b->im6s_addr, sizeof(struct in6_addr)));
59733cde130SBruce M Simpson }
59833cde130SBruce M Simpson RB_PROTOTYPE(ip6_msource_tree, ip6_msource, im6s_link, ip6_msource_cmp);
59933cde130SBruce M Simpson 
60033cde130SBruce M Simpson /*
60133cde130SBruce M Simpson  * IPv6 multicast PCB-layer group filter descriptor.
60233cde130SBruce M Simpson  */
60333cde130SBruce M Simpson struct in6_mfilter {
60433cde130SBruce M Simpson 	struct ip6_msource_tree	im6f_sources; /* source list for (S,G) */
60533cde130SBruce M Simpson 	u_long			im6f_nsrc;    /* # of source entries */
60633cde130SBruce M Simpson 	uint8_t			im6f_st[2];   /* state before/at commit */
60759854ecfSHans Petter Selasky 	struct in6_multi       *im6f_in6m;    /* associated multicast address */
60859854ecfSHans Petter Selasky 	STAILQ_ENTRY(in6_mfilter) im6f_entry; /* list entry */
60933cde130SBruce M Simpson };
61033cde130SBruce M Simpson 
61133cde130SBruce M Simpson /*
61259854ecfSHans Petter Selasky  * Helper types and functions for IPv4 multicast filters.
61359854ecfSHans Petter Selasky  */
61459854ecfSHans Petter Selasky STAILQ_HEAD(ip6_mfilter_head, in6_mfilter);
61559854ecfSHans Petter Selasky 
61659854ecfSHans Petter Selasky struct in6_mfilter *ip6_mfilter_alloc(int mflags, int st0, int st1);
61759854ecfSHans Petter Selasky void ip6_mfilter_free(struct in6_mfilter *);
61859854ecfSHans Petter Selasky 
61959854ecfSHans Petter Selasky static inline void
62059854ecfSHans Petter Selasky ip6_mfilter_init(struct ip6_mfilter_head *head)
62159854ecfSHans Petter Selasky {
62259854ecfSHans Petter Selasky 
62359854ecfSHans Petter Selasky 	STAILQ_INIT(head);
62459854ecfSHans Petter Selasky }
62559854ecfSHans Petter Selasky 
62659854ecfSHans Petter Selasky static inline struct in6_mfilter *
62759854ecfSHans Petter Selasky ip6_mfilter_first(const struct ip6_mfilter_head *head)
62859854ecfSHans Petter Selasky {
62959854ecfSHans Petter Selasky 
63059854ecfSHans Petter Selasky 	return (STAILQ_FIRST(head));
63159854ecfSHans Petter Selasky }
63259854ecfSHans Petter Selasky 
63359854ecfSHans Petter Selasky static inline void
63459854ecfSHans Petter Selasky ip6_mfilter_insert(struct ip6_mfilter_head *head, struct in6_mfilter *imf)
63559854ecfSHans Petter Selasky {
63659854ecfSHans Petter Selasky 
63759854ecfSHans Petter Selasky 	STAILQ_INSERT_TAIL(head, imf, im6f_entry);
63859854ecfSHans Petter Selasky }
63959854ecfSHans Petter Selasky 
64059854ecfSHans Petter Selasky static inline void
64159854ecfSHans Petter Selasky ip6_mfilter_remove(struct ip6_mfilter_head *head, struct in6_mfilter *imf)
64259854ecfSHans Petter Selasky {
64359854ecfSHans Petter Selasky 
64459854ecfSHans Petter Selasky 	STAILQ_REMOVE(head, imf, in6_mfilter, im6f_entry);
64559854ecfSHans Petter Selasky }
64659854ecfSHans Petter Selasky 
64759854ecfSHans Petter Selasky #define	IP6_MFILTER_FOREACH(imf, head) \
64859854ecfSHans Petter Selasky 	STAILQ_FOREACH(imf, head, im6f_entry)
64959854ecfSHans Petter Selasky 
65059854ecfSHans Petter Selasky static inline size_t
65159854ecfSHans Petter Selasky ip6_mfilter_count(struct ip6_mfilter_head *head)
65259854ecfSHans Petter Selasky {
65359854ecfSHans Petter Selasky 	struct in6_mfilter *imf;
65459854ecfSHans Petter Selasky 	size_t num = 0;
65559854ecfSHans Petter Selasky 
65659854ecfSHans Petter Selasky 	STAILQ_FOREACH(imf, head, im6f_entry)
65759854ecfSHans Petter Selasky 		num++;
65859854ecfSHans Petter Selasky 	return (num);
65959854ecfSHans Petter Selasky }
66059854ecfSHans Petter Selasky 
66159854ecfSHans Petter Selasky /*
66233cde130SBruce M Simpson  * Legacy KAME IPv6 multicast membership descriptor.
66333cde130SBruce M Simpson  */
66433cde130SBruce M Simpson struct in6_multi_mship {
66533cde130SBruce M Simpson 	struct	in6_multi *i6mm_maddr;
66633cde130SBruce M Simpson 	LIST_ENTRY(in6_multi_mship) i6mm_chain;
66733cde130SBruce M Simpson };
66833cde130SBruce M Simpson 
66933cde130SBruce M Simpson /*
67033cde130SBruce M Simpson  * IPv6 group descriptor.
67133cde130SBruce M Simpson  *
67233cde130SBruce M Simpson  * For every entry on an ifnet's if_multiaddrs list which represents
67333cde130SBruce M Simpson  * an IP multicast group, there is one of these structures.
67433cde130SBruce M Simpson  *
67533cde130SBruce M Simpson  * If any source filters are present, then a node will exist in the RB-tree
67633cde130SBruce M Simpson  * to permit fast lookup by source whenever an operation takes place.
67733cde130SBruce M Simpson  * This permits pre-order traversal when we issue reports.
67833cde130SBruce M Simpson  * Source filter trees are kept separately from the socket layer to
67933cde130SBruce M Simpson  * greatly simplify locking.
68033cde130SBruce M Simpson  *
68133cde130SBruce M Simpson  * When MLDv2 is active, in6m_timer is the response to group query timer.
68233cde130SBruce M Simpson  * The state-change timer in6m_sctimer is separate; whenever state changes
68333cde130SBruce M Simpson  * for the group the state change record is generated and transmitted,
68433cde130SBruce M Simpson  * and kept if retransmissions are necessary.
68533cde130SBruce M Simpson  *
68633cde130SBruce M Simpson  * FUTURE: in6m_link is now only used when groups are being purged
68733cde130SBruce M Simpson  * on a detaching ifnet. It could be demoted to a SLIST_ENTRY, but
68833cde130SBruce M Simpson  * because it is at the very start of the struct, we can't do this
68933cde130SBruce M Simpson  * w/o breaking the ABI for ifmcstat.
69033cde130SBruce M Simpson  */
69133cde130SBruce M Simpson struct in6_multi {
69233cde130SBruce M Simpson 	struct	in6_addr in6m_addr;	/* IPv6 multicast address */
69333cde130SBruce M Simpson 	struct	ifnet *in6m_ifp;	/* back pointer to ifnet */
69433cde130SBruce M Simpson 	struct	ifmultiaddr *in6m_ifma;	/* back pointer to ifmultiaddr */
69533cde130SBruce M Simpson 	u_int	in6m_refcount;		/* reference count */
69633cde130SBruce M Simpson 	u_int	in6m_state;		/* state of the membership */
69733cde130SBruce M Simpson 	u_int	in6m_timer;		/* MLD6 listener report timer */
69833cde130SBruce M Simpson 
69933cde130SBruce M Simpson 	/* New fields for MLDv2 follow. */
7009e62a5a3SGleb Smirnoff 	struct mld_ifsoftc	*in6m_mli;	/* MLD info */
70133cde130SBruce M Simpson 	SLIST_ENTRY(in6_multi)	 in6m_nrele;	/* to-be-released by MLD */
7022cd6ad76SHans Petter Selasky 	SLIST_ENTRY(in6_multi)	 in6m_defer;	/* deferred MLDv1 */
70333cde130SBruce M Simpson 	struct ip6_msource_tree	 in6m_srcs;	/* tree of sources */
70433cde130SBruce M Simpson 	u_long			 in6m_nsrc;	/* # of tree entries */
70533cde130SBruce M Simpson 
706a99c84d4SGleb Smirnoff 	struct mbufq		 in6m_scq;	/* queue of pending
70733cde130SBruce M Simpson 						 * state-change packets */
70833cde130SBruce M Simpson 	struct timeval		 in6m_lastgsrtv;	/* last G-S-R query */
70933cde130SBruce M Simpson 	uint16_t		 in6m_sctimer;	/* state-change timer */
71033cde130SBruce M Simpson 	uint16_t		 in6m_scrv;	/* state-change rexmit count */
71133cde130SBruce M Simpson 
71233cde130SBruce M Simpson 	/*
71333cde130SBruce M Simpson 	 * SSM state counters which track state at T0 (the time the last
71433cde130SBruce M Simpson 	 * state-change report's RV timer went to zero) and T1
71533cde130SBruce M Simpson 	 * (time of pending report, i.e. now).
71633cde130SBruce M Simpson 	 * Used for computing MLDv2 state-change reports. Several refcounts
71733cde130SBruce M Simpson 	 * are maintained here to optimize for common use-cases.
71833cde130SBruce M Simpson 	 */
71933cde130SBruce M Simpson 	struct in6m_st {
72033cde130SBruce M Simpson 		uint16_t	iss_fmode;	/* MLD filter mode */
72133cde130SBruce M Simpson 		uint16_t	iss_asm;	/* # of ASM listeners */
72233cde130SBruce M Simpson 		uint16_t	iss_ex;		/* # of exclusive members */
72333cde130SBruce M Simpson 		uint16_t	iss_in;		/* # of inclusive members */
72433cde130SBruce M Simpson 		uint16_t	iss_rec;	/* # of recorded sources */
72533cde130SBruce M Simpson 	}			in6m_st[2];	/* state at t0, t1 */
72633cde130SBruce M Simpson };
72733cde130SBruce M Simpson 
7282cd6ad76SHans Petter Selasky void in6m_disconnect_locked(struct in6_multi_head *inmh, struct in6_multi *inm);
7292cd6ad76SHans Petter Selasky 
73033cde130SBruce M Simpson /*
73133cde130SBruce M Simpson  * Helper function to derive the filter mode on a source entry
73233cde130SBruce M Simpson  * from its internal counters. Predicates are:
73333cde130SBruce M Simpson  *  A source is only excluded if all listeners exclude it.
73433cde130SBruce M Simpson  *  A source is only included if no listeners exclude it,
73533cde130SBruce M Simpson  *  and at least one listener includes it.
73633cde130SBruce M Simpson  * May be used by ifmcstat(8).
73733cde130SBruce M Simpson  */
73833cde130SBruce M Simpson static __inline uint8_t
73933cde130SBruce M Simpson im6s_get_mode(const struct in6_multi *inm, const struct ip6_msource *ims,
74033cde130SBruce M Simpson     uint8_t t)
74133cde130SBruce M Simpson {
74233cde130SBruce M Simpson 
74333cde130SBruce M Simpson 	t = !!t;
74433cde130SBruce M Simpson 	if (inm->in6m_st[t].iss_ex > 0 &&
74533cde130SBruce M Simpson 	    inm->in6m_st[t].iss_ex == ims->im6s_st[t].ex)
74633cde130SBruce M Simpson 		return (MCAST_EXCLUDE);
74733cde130SBruce M Simpson 	else if (ims->im6s_st[t].in > 0 && ims->im6s_st[t].ex == 0)
74833cde130SBruce M Simpson 		return (MCAST_INCLUDE);
74933cde130SBruce M Simpson 	return (MCAST_UNDEFINED);
75033cde130SBruce M Simpson }
75133cde130SBruce M Simpson 
75233cde130SBruce M Simpson /*
75333cde130SBruce M Simpson  * Lock macros for IPv6 layer multicast address lists.  IPv6 lock goes
75433cde130SBruce M Simpson  * before link layer multicast locks in the lock order.  In most cases,
75533cde130SBruce M Simpson  * consumers of IN_*_MULTI() macros should acquire the locks before
75633cde130SBruce M Simpson  * calling them; users of the in_{add,del}multi() functions should not.
75733cde130SBruce M Simpson  */
758f3e1324bSStephen Hurd extern struct mtx in6_multi_list_mtx;
759f3e1324bSStephen Hurd extern struct sx in6_multi_sx;
760f3e1324bSStephen Hurd 
761f3e1324bSStephen Hurd #define	IN6_MULTI_LIST_LOCK()		mtx_lock(&in6_multi_list_mtx)
762f3e1324bSStephen Hurd #define	IN6_MULTI_LIST_UNLOCK()	mtx_unlock(&in6_multi_list_mtx)
763f3e1324bSStephen Hurd #define	IN6_MULTI_LIST_LOCK_ASSERT()	mtx_assert(&in6_multi_list_mtx, MA_OWNED)
764f3e1324bSStephen Hurd #define	IN6_MULTI_LIST_UNLOCK_ASSERT() mtx_assert(&in6_multi_list_mtx, MA_NOTOWNED)
765f3e1324bSStephen Hurd 
766f3e1324bSStephen Hurd #define	IN6_MULTI_LOCK()		sx_xlock(&in6_multi_sx)
767f3e1324bSStephen Hurd #define	IN6_MULTI_UNLOCK()	sx_xunlock(&in6_multi_sx)
768f3e1324bSStephen Hurd #define	IN6_MULTI_LOCK_ASSERT()	sx_assert(&in6_multi_sx, SA_XLOCKED)
769f3e1324bSStephen Hurd #define	IN6_MULTI_UNLOCK_ASSERT() sx_assert(&in6_multi_sx, SA_XUNLOCKED)
77033cde130SBruce M Simpson 
7712cd6ad76SHans Petter Selasky /*
7722cd6ad76SHans Petter Selasky  * Get the in6_multi pointer from a ifmultiaddr.
7732cd6ad76SHans Petter Selasky  * Returns NULL if ifmultiaddr is no longer valid.
7742cd6ad76SHans Petter Selasky  */
7752cd6ad76SHans Petter Selasky static __inline struct in6_multi *
7762cd6ad76SHans Petter Selasky in6m_ifmultiaddr_get_inm(struct ifmultiaddr *ifma)
7772cd6ad76SHans Petter Selasky {
7782cd6ad76SHans Petter Selasky 
7792cd6ad76SHans Petter Selasky 	return ((ifma->ifma_addr->sa_family != AF_INET6 ||
7802cd6ad76SHans Petter Selasky 	    (ifma->ifma_flags & IFMA_F_ENQUEUED) == 0) ? NULL :
7812cd6ad76SHans Petter Selasky 	    ifma->ifma_protospec);
7822cd6ad76SHans Petter Selasky }
783b6f6f880SMatt Macy 
784361ac40bSJustin Hibbits struct in6_multi *
785361ac40bSJustin Hibbits in6m_lookup_locked(struct ifnet *ifp, const struct in6_addr *mcaddr);
78633cde130SBruce M Simpson 
78733cde130SBruce M Simpson /*
78833cde130SBruce M Simpson  * Wrapper for in6m_lookup_locked().
78933cde130SBruce M Simpson  *
790b8a6e03fSGleb Smirnoff  * SMPng: Assumes network epoch entered and that IN6_MULTI_LOCK() isn't held.
79133cde130SBruce M Simpson  */
79233cde130SBruce M Simpson static __inline struct in6_multi *
79333cde130SBruce M Simpson in6m_lookup(struct ifnet *ifp, const struct in6_addr *mcaddr)
79433cde130SBruce M Simpson {
79533cde130SBruce M Simpson 	struct in6_multi *inm;
79633cde130SBruce M Simpson 
797b8a6e03fSGleb Smirnoff 	NET_EPOCH_ASSERT();
798b8a6e03fSGleb Smirnoff 
799f3e1324bSStephen Hurd 	IN6_MULTI_LIST_LOCK();
80033cde130SBruce M Simpson 	inm = in6m_lookup_locked(ifp, mcaddr);
801f3e1324bSStephen Hurd 	IN6_MULTI_LIST_UNLOCK();
80233cde130SBruce M Simpson 
80333cde130SBruce M Simpson 	return (inm);
80433cde130SBruce M Simpson }
80533cde130SBruce M Simpson 
80633cde130SBruce M Simpson /* Acquire an in6_multi record. */
80733cde130SBruce M Simpson static __inline void
80833cde130SBruce M Simpson in6m_acquire_locked(struct in6_multi *inm)
80933cde130SBruce M Simpson {
81033cde130SBruce M Simpson 
811f3e1324bSStephen Hurd 	IN6_MULTI_LIST_LOCK_ASSERT();
81233cde130SBruce M Simpson 	++inm->in6m_refcount;
81333cde130SBruce M Simpson }
81433cde130SBruce M Simpson 
815f3e1324bSStephen Hurd static __inline void
816f3e1324bSStephen Hurd in6m_acquire(struct in6_multi *inm)
817f3e1324bSStephen Hurd {
818f3e1324bSStephen Hurd 	IN6_MULTI_LIST_LOCK();
819f3e1324bSStephen Hurd 	in6m_acquire_locked(inm);
820f3e1324bSStephen Hurd 	IN6_MULTI_LIST_UNLOCK();
821f3e1324bSStephen Hurd }
822f3e1324bSStephen Hurd 
823f3e1324bSStephen Hurd static __inline void
824f3e1324bSStephen Hurd in6m_rele_locked(struct in6_multi_head *inmh, struct in6_multi *inm)
825f3e1324bSStephen Hurd {
826f3e1324bSStephen Hurd 	KASSERT(inm->in6m_refcount > 0, ("refcount == %d inm: %p", inm->in6m_refcount, inm));
827f3e1324bSStephen Hurd 	IN6_MULTI_LIST_LOCK_ASSERT();
828f3e1324bSStephen Hurd 
829f3e1324bSStephen Hurd 	if (--inm->in6m_refcount == 0) {
830f9be0386SMatt Macy 		MPASS(inm->in6m_ifp == NULL);
831f3e1324bSStephen Hurd 		inm->in6m_ifma->ifma_protospec = NULL;
832b6f6f880SMatt Macy 		MPASS(inm->in6m_ifma->ifma_llifma == NULL);
833f3e1324bSStephen Hurd 		SLIST_INSERT_HEAD(inmh, inm, in6m_nrele);
834f3e1324bSStephen Hurd 	}
835f3e1324bSStephen Hurd }
836f3e1324bSStephen Hurd 
83733cde130SBruce M Simpson struct ip6_moptions;
83833cde130SBruce M Simpson struct sockopt;
83928c00100SMatt Macy struct inpcbinfo;
8402f23f45bSAlexander V. Chernikov struct rib_head;
841*bb06a80cSAlexander V. Chernikov struct ucred;
84233cde130SBruce M Simpson 
84333cde130SBruce M Simpson /* Multicast KPIs. */
84433cde130SBruce M Simpson int	im6o_mc_filter(const struct ip6_moptions *, const struct ifnet *,
84533cde130SBruce M Simpson 	    const struct sockaddr *, const struct sockaddr *);
846f3e1324bSStephen Hurd int in6_joingroup(struct ifnet *, const struct in6_addr *,
84733cde130SBruce M Simpson 	    struct in6_mfilter *, struct in6_multi **, int);
848f3e1324bSStephen Hurd int	in6_leavegroup(struct in6_multi *, struct in6_mfilter *);
849f3e1324bSStephen Hurd int	in6_leavegroup_locked(struct in6_multi *, struct in6_mfilter *);
85033cde130SBruce M Simpson void	in6m_clear_recorded(struct in6_multi *);
85133cde130SBruce M Simpson void	in6m_commit(struct in6_multi *);
85233cde130SBruce M Simpson void	in6m_print(const struct in6_multi *);
85333cde130SBruce M Simpson int	in6m_record_source(struct in6_multi *, const struct in6_addr *);
854f3e1324bSStephen Hurd void	in6m_release_list_deferred(struct in6_multi_head *);
8553689652cSHans Petter Selasky void	in6m_release_wait(void *);
856cb6bb230SMatt Macy void	ip6_freemoptions(struct ip6_moptions *);
85733cde130SBruce M Simpson int	ip6_getmoptions(struct inpcb *, struct sockopt *);
85833cde130SBruce M Simpson int	ip6_setmoptions(struct inpcb *, struct sockopt *);
85933cde130SBruce M Simpson 
860743eee66SSUZUKI Shinsuke /* flags to in6_update_ifa */
861743eee66SSUZUKI Shinsuke #define IN6_IFAUPDATE_DADDELAY	0x1 /* first time to configure an address */
862743eee66SSUZUKI Shinsuke 
8636f56329aSXin LI int	in6_mask2len(struct in6_addr *, u_char *);
864f277746eSGleb Smirnoff int	in6_control(struct socket *, u_long, void *, struct ifnet *,
8656f56329aSXin LI 	struct thread *);
866*bb06a80cSAlexander V. Chernikov int	in6_control_ioctl(u_long, void *, struct ifnet *, struct ucred *);
8676f56329aSXin LI int	in6_update_ifa(struct ifnet *, struct in6_aliasreq *,
8686f56329aSXin LI 	struct in6_ifaddr *, int);
8699080e7d0SAlexander V. Chernikov void	in6_prepare_ifra(struct in6_aliasreq *, const struct in6_addr *,
8709080e7d0SAlexander V. Chernikov 	const struct in6_addr *);
871e437991fSAlexander V. Chernikov int	in6_addifaddr(struct ifnet *, struct in6_aliasreq *, struct in6_ifaddr *);
8726f56329aSXin LI void	in6_purgeaddr(struct ifaddr *);
873f9e0752eSAlexander V. Chernikov void	in6_purgeifaddr(struct in6_ifaddr *);
8746f56329aSXin LI int	in6if_do_dad(struct ifnet *);
8756f56329aSXin LI void	in6_savemkludge(struct in6_ifaddr *);
8766f56329aSXin LI void	*in6_domifattach(struct ifnet *);
8776f56329aSXin LI void	in6_domifdetach(struct ifnet *, void *);
8781a75e3b2SAlexander V. Chernikov int	in6_domifmtu(struct ifnet *);
8792f23f45bSAlexander V. Chernikov struct rib_head *in6_inithead(uint32_t fibnum);
8802f23f45bSAlexander V. Chernikov void	in6_detachhead(struct rib_head *rh);
8816f56329aSXin LI void	in6_setmaxmtu(void);
8826f56329aSXin LI int	in6_if2idlen(struct ifnet *);
8836f56329aSXin LI struct in6_ifaddr *in6ifa_ifpforlinklocal(struct ifnet *, int);
88491bfd68eSAlexander V. Chernikov struct in6_ifaddr *in6ifa_ifpwithaddr(struct ifnet *, const struct in6_addr *);
8858268d82cSAlexander V. Chernikov struct in6_ifaddr *in6ifa_ifwithaddr(const struct in6_addr *, uint32_t, bool);
886af805644SHiroki Sato struct in6_ifaddr *in6ifa_llaonifp(struct ifnet *);
8876f56329aSXin LI int	in6_addr2zoneid(struct ifnet *, struct in6_addr *, u_int32_t *);
8886f56329aSXin LI int	in6_matchlen(struct in6_addr *, struct in6_addr *);
8896f56329aSXin LI int	in6_are_prefix_equal(struct in6_addr *, struct in6_addr *, int);
8906f56329aSXin LI void	in6_prefixlen2mask(struct in6_addr *, int);
8916f56329aSXin LI int	in6_prefix_ioctl(struct socket *, u_long, caddr_t,
8926f56329aSXin LI 	struct ifnet *);
8936f56329aSXin LI int	in6_prefix_add_ifid(int, struct in6_ifaddr *);
8946f56329aSXin LI void	in6_prefix_remove_ifid(int, struct in6_ifaddr *);
8956f56329aSXin LI void	in6_purgeprefix(struct ifnet *);
89633841545SHajimu UMEMOTO 
8976f56329aSXin LI int	in6_is_addr_deprecated(struct sockaddr_in6 *);
8986f56329aSXin LI int	in6_src_ioctl(u_long, caddr_t);
899db566a23SBjoern A. Zeeb 
900f6b84910SAlexander V. Chernikov void	in6_newaddrmsg(struct in6_ifaddr *, int);
901d6cd20ccSKUROSAWA Takahiro 
902d6cd20ccSKUROSAWA Takahiro void	in6_purge_proxy_ndp(struct ifnet *);
903db566a23SBjoern A. Zeeb /*
904db566a23SBjoern A. Zeeb  * Extended API for IPv6 FIB support.
905db566a23SBjoern A. Zeeb  */
9065a1842a2SAndrey V. Elsukov struct mbuf *ip6_tryforward(struct mbuf *);
90776429de4SYoshinobu Inoue #endif /* _KERNEL */
90876429de4SYoshinobu Inoue 
90976429de4SYoshinobu Inoue #endif /* _NETINET6_IN6_VAR_H_ */
910