1ca915d33Sroot /*-
2*d4a07e70Sfengbojiang  * SPDX-License-Identifier: BSD-3-Clause
3*d4a07e70Sfengbojiang  *
4ca915d33Sroot  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
5ca915d33Sroot  * All rights reserved.
6ca915d33Sroot  *
7ca915d33Sroot  * Redistribution and use in source and binary forms, with or without
8ca915d33Sroot  * modification, are permitted provided that the following conditions
9ca915d33Sroot  * are met:
10ca915d33Sroot  * 1. Redistributions of source code must retain the above copyright
11ca915d33Sroot  *    notice, this list of conditions and the following disclaimer.
12ca915d33Sroot  * 2. Redistributions in binary form must reproduce the above copyright
13ca915d33Sroot  *    notice, this list of conditions and the following disclaimer in the
14ca915d33Sroot  *    documentation and/or other materials provided with the distribution.
15ca915d33Sroot  * 3. Neither the name of the project nor the names of its contributors
16ca915d33Sroot  *    may be used to endorse or promote products derived from this software
17ca915d33Sroot  *    without specific prior written permission.
18ca915d33Sroot  *
19ca915d33Sroot  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
20ca915d33Sroot  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21ca915d33Sroot  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22ca915d33Sroot  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
23ca915d33Sroot  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24ca915d33Sroot  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25ca915d33Sroot  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26ca915d33Sroot  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27ca915d33Sroot  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28ca915d33Sroot  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29ca915d33Sroot  * SUCH DAMAGE.
30ca915d33Sroot  *
31ca915d33Sroot  *	$KAME: ip6_var.h,v 1.62 2001/05/03 14:51:48 itojun Exp $
32ca915d33Sroot  */
33ca915d33Sroot 
34ca915d33Sroot /*-
35ca915d33Sroot  * Copyright (c) 1982, 1986, 1993
36ca915d33Sroot  *	The Regents of the University of California.  All rights reserved.
37ca915d33Sroot  *
38ca915d33Sroot  * Redistribution and use in source and binary forms, with or without
39ca915d33Sroot  * modification, are permitted provided that the following conditions
40ca915d33Sroot  * are met:
41ca915d33Sroot  * 1. Redistributions of source code must retain the above copyright
42ca915d33Sroot  *    notice, this list of conditions and the following disclaimer.
43ca915d33Sroot  * 2. Redistributions in binary form must reproduce the above copyright
44ca915d33Sroot  *    notice, this list of conditions and the following disclaimer in the
45ca915d33Sroot  *    documentation and/or other materials provided with the distribution.
46*d4a07e70Sfengbojiang  * 3. Neither the name of the University nor the names of its contributors
47ca915d33Sroot  *    may be used to endorse or promote products derived from this software
48ca915d33Sroot  *    without specific prior written permission.
49ca915d33Sroot  *
50ca915d33Sroot  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
51ca915d33Sroot  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
52ca915d33Sroot  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
53ca915d33Sroot  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
54ca915d33Sroot  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
55ca915d33Sroot  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
56ca915d33Sroot  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57ca915d33Sroot  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
58ca915d33Sroot  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
59ca915d33Sroot  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60ca915d33Sroot  * SUCH DAMAGE.
61ca915d33Sroot  *
62ca915d33Sroot  *	@(#)ip_var.h	8.1 (Berkeley) 6/10/93
63ca915d33Sroot  * $FreeBSD$
64ca915d33Sroot  */
65ca915d33Sroot 
66ca915d33Sroot #ifndef _NETINET6_IP6_VAR_H_
67ca915d33Sroot #define _NETINET6_IP6_VAR_H_
68ca915d33Sroot 
69*d4a07e70Sfengbojiang #include <sys/epoch.h>
70*d4a07e70Sfengbojiang 
71*d4a07e70Sfengbojiang #ifdef _KERNEL
72*d4a07e70Sfengbojiang struct ip6asfrag;		/* frag6.c */
73*d4a07e70Sfengbojiang TAILQ_HEAD(ip6fraghead, ip6asfrag);
74*d4a07e70Sfengbojiang 
75ca915d33Sroot /*
76ca915d33Sroot  * IP6 reassembly queue structure.  Each fragment
77ca915d33Sroot  * being reassembled is attached to one of these structures.
78ca915d33Sroot  */
79ca915d33Sroot struct	ip6q {
80*d4a07e70Sfengbojiang 	struct ip6fraghead ip6q_frags;
81ca915d33Sroot 	u_int32_t	ip6q_ident;
82ca915d33Sroot 	u_int8_t	ip6q_nxt;
83ca915d33Sroot 	u_int8_t	ip6q_ecn;
84ca915d33Sroot 	u_int8_t	ip6q_ttl;
85ca915d33Sroot 	struct in6_addr ip6q_src, ip6q_dst;
86*d4a07e70Sfengbojiang 	TAILQ_ENTRY(ip6q) ip6q_tq;
87ca915d33Sroot 	int		ip6q_unfrglen;	/* len of unfragmentable part */
88ca915d33Sroot 	int		ip6q_nfrag;	/* # of fragments */
89ca915d33Sroot 	struct label	*ip6q_label;
90ca915d33Sroot };
91*d4a07e70Sfengbojiang #endif /* _KERNEL */
92ca915d33Sroot 
93ca915d33Sroot /*
94ca915d33Sroot  * IP6 reinjecting structure.
95ca915d33Sroot  */
96ca915d33Sroot struct ip6_direct_ctx {
97ca915d33Sroot 	uint32_t	ip6dc_nxt;	/* next header to process */
98ca915d33Sroot 	uint32_t	ip6dc_off;	/* offset to next header */
99ca915d33Sroot };
100ca915d33Sroot 
101*d4a07e70Sfengbojiang #if defined(_NETINET6_IN6_VAR_H_) && defined(_KERNEL)
102ca915d33Sroot /*
103ca915d33Sroot  * Structure attached to inpcb.in6p_moptions and
104ca915d33Sroot  * passed to ip6_output when IPv6 multicast options are in use.
105ca915d33Sroot  * This structure is lazy-allocated.
106ca915d33Sroot  */
107ca915d33Sroot struct ip6_moptions {
108ca915d33Sroot 	struct	ifnet *im6o_multicast_ifp; /* ifp for outgoing multicasts */
109ca915d33Sroot 	u_char	im6o_multicast_hlim;	/* hoplimit for outgoing multicasts */
110ca915d33Sroot 	u_char	im6o_multicast_loop;	/* 1 >= hear sends if a member */
111*d4a07e70Sfengbojiang 	struct ip6_mfilter_head im6o_head; /* group membership list */
112ca915d33Sroot };
113*d4a07e70Sfengbojiang #else
114*d4a07e70Sfengbojiang struct ip6_moptions;
115*d4a07e70Sfengbojiang #endif
116ca915d33Sroot /*
117ca915d33Sroot  * Control options for outgoing packets
118ca915d33Sroot  */
119ca915d33Sroot 
120ca915d33Sroot /* Routing header related info */
121ca915d33Sroot struct	ip6po_rhinfo {
122ca915d33Sroot 	struct	ip6_rthdr *ip6po_rhi_rthdr; /* Routing header */
123ca915d33Sroot 	struct	route_in6 ip6po_rhi_route; /* Route to the 1st hop */
124ca915d33Sroot };
125ca915d33Sroot #define ip6po_rthdr	ip6po_rhinfo.ip6po_rhi_rthdr
126ca915d33Sroot #define ip6po_route	ip6po_rhinfo.ip6po_rhi_route
127ca915d33Sroot 
128ca915d33Sroot /* Nexthop related info */
129ca915d33Sroot struct	ip6po_nhinfo {
130ca915d33Sroot 	struct	sockaddr *ip6po_nhi_nexthop;
131ca915d33Sroot 	struct	route_in6 ip6po_nhi_route; /* Route to the nexthop */
132ca915d33Sroot };
133ca915d33Sroot #define ip6po_nexthop	ip6po_nhinfo.ip6po_nhi_nexthop
134ca915d33Sroot #define ip6po_nextroute	ip6po_nhinfo.ip6po_nhi_route
135ca915d33Sroot 
136ca915d33Sroot struct	ip6_pktopts {
137ca915d33Sroot 	struct	mbuf *ip6po_m;	/* Pointer to mbuf storing the data */
138ca915d33Sroot 	int	ip6po_hlim;	/* Hoplimit for outgoing packets */
139ca915d33Sroot 
140ca915d33Sroot 	/* Outgoing IF/address information */
141ca915d33Sroot 	struct	in6_pktinfo *ip6po_pktinfo;
142ca915d33Sroot 
143ca915d33Sroot 	/* Next-hop address information */
144ca915d33Sroot 	struct	ip6po_nhinfo ip6po_nhinfo;
145ca915d33Sroot 
146ca915d33Sroot 	struct	ip6_hbh *ip6po_hbh; /* Hop-by-Hop options header */
147ca915d33Sroot 
148ca915d33Sroot 	/* Destination options header (before a routing header) */
149ca915d33Sroot 	struct	ip6_dest *ip6po_dest1;
150ca915d33Sroot 
151ca915d33Sroot 	/* Routing header related info. */
152ca915d33Sroot 	struct	ip6po_rhinfo ip6po_rhinfo;
153ca915d33Sroot 
154ca915d33Sroot 	/* Destination options header (after a routing header) */
155ca915d33Sroot 	struct	ip6_dest *ip6po_dest2;
156ca915d33Sroot 
157ca915d33Sroot 	int	ip6po_tclass;	/* traffic class */
158ca915d33Sroot 
159ca915d33Sroot 	int	ip6po_minmtu;  /* fragment vs PMTU discovery policy */
160ca915d33Sroot #define IP6PO_MINMTU_MCASTONLY	-1 /* default; send at min MTU for multicast*/
161ca915d33Sroot #define IP6PO_MINMTU_DISABLE	 0 /* always perform pmtu disc */
162ca915d33Sroot #define IP6PO_MINMTU_ALL	 1 /* always send at min MTU */
163ca915d33Sroot 
164ca915d33Sroot 	int	ip6po_prefer_tempaddr;  /* whether temporary addresses are
165ca915d33Sroot 					   preferred as source address */
166ca915d33Sroot #define IP6PO_TEMPADDR_SYSTEM	-1 /* follow the system default */
167ca915d33Sroot #define IP6PO_TEMPADDR_NOTPREFER 0 /* not prefer temporary address */
168ca915d33Sroot #define IP6PO_TEMPADDR_PREFER	 1 /* prefer temporary address */
169ca915d33Sroot 
170ca915d33Sroot 	int ip6po_flags;
171ca915d33Sroot #if 0	/* parameters in this block is obsolete. do not reuse the values. */
172ca915d33Sroot #define IP6PO_REACHCONF	0x01	/* upper-layer reachability confirmation. */
173ca915d33Sroot #define IP6PO_MINMTU	0x02	/* use minimum MTU (IPV6_USE_MIN_MTU) */
174ca915d33Sroot #endif
175ca915d33Sroot #define IP6PO_DONTFRAG	0x04	/* disable fragmentation (IPV6_DONTFRAG) */
176ca915d33Sroot #define IP6PO_USECOA	0x08	/* use care of address */
177ca915d33Sroot };
178ca915d33Sroot 
179ca915d33Sroot /*
180ca915d33Sroot  * Control options for incoming packets
181ca915d33Sroot  */
182ca915d33Sroot 
183ca915d33Sroot struct	ip6stat {
184ca915d33Sroot 	uint64_t ip6s_total;		/* total packets received */
185ca915d33Sroot 	uint64_t ip6s_tooshort;		/* packet too short */
186ca915d33Sroot 	uint64_t ip6s_toosmall;		/* not enough data */
187ca915d33Sroot 	uint64_t ip6s_fragments;	/* fragments received */
188ca915d33Sroot 	uint64_t ip6s_fragdropped;	/* frags dropped(dups, out of space) */
189ca915d33Sroot 	uint64_t ip6s_fragtimeout;	/* fragments timed out */
190ca915d33Sroot 	uint64_t ip6s_fragoverflow;	/* fragments that exceeded limit */
191ca915d33Sroot 	uint64_t ip6s_forward;		/* packets forwarded */
192ca915d33Sroot 	uint64_t ip6s_cantforward;	/* packets rcvd for unreachable dest */
193ca915d33Sroot 	uint64_t ip6s_redirectsent;	/* packets forwarded on same net */
194ca915d33Sroot 	uint64_t ip6s_delivered;	/* datagrams delivered to upper level*/
195ca915d33Sroot 	uint64_t ip6s_localout;		/* total ip packets generated here */
196ca915d33Sroot 	uint64_t ip6s_odropped;		/* lost packets due to nobufs, etc. */
197ca915d33Sroot 	uint64_t ip6s_reassembled;	/* total packets reassembled ok */
198*d4a07e70Sfengbojiang 	uint64_t ip6s_atomicfrags;	/* atomic fragments */
199ca915d33Sroot 	uint64_t ip6s_fragmented;	/* datagrams successfully fragmented */
200ca915d33Sroot 	uint64_t ip6s_ofragments;	/* output fragments created */
201ca915d33Sroot 	uint64_t ip6s_cantfrag;		/* don't fragment flag was set, etc. */
202ca915d33Sroot 	uint64_t ip6s_badoptions;	/* error in option processing */
203ca915d33Sroot 	uint64_t ip6s_noroute;		/* packets discarded due to no route */
204ca915d33Sroot 	uint64_t ip6s_badvers;		/* ip6 version != 6 */
205ca915d33Sroot 	uint64_t ip6s_rawout;		/* total raw ip packets generated */
206ca915d33Sroot 	uint64_t ip6s_badscope;		/* scope error */
207ca915d33Sroot 	uint64_t ip6s_notmember;	/* don't join this multicast group */
208ca915d33Sroot #define	IP6S_HDRCNT		256	/* headers count */
209ca915d33Sroot 	uint64_t ip6s_nxthist[IP6S_HDRCNT]; /* next header history */
210ca915d33Sroot 	uint64_t ip6s_m1;		/* one mbuf */
211ca915d33Sroot #define	IP6S_M2MMAX		32
212ca915d33Sroot 	uint64_t ip6s_m2m[IP6S_M2MMAX];	/* two or more mbuf */
213ca915d33Sroot 	uint64_t ip6s_mext1;		/* one ext mbuf */
214ca915d33Sroot 	uint64_t ip6s_mext2m;		/* two or more ext mbuf */
215ca915d33Sroot 	uint64_t ip6s_exthdrtoolong;	/* ext hdr are not contiguous */
216ca915d33Sroot 	uint64_t ip6s_nogif;		/* no match gif found */
217ca915d33Sroot 	uint64_t ip6s_toomanyhdr;	/* discarded due to too many headers */
218ca915d33Sroot 
219ca915d33Sroot 	/*
220ca915d33Sroot 	 * statistics for improvement of the source address selection
221ca915d33Sroot 	 * algorithm:
222ca915d33Sroot 	 * XXX: hardcoded 16 = # of ip6 multicast scope types + 1
223ca915d33Sroot 	 */
224ca915d33Sroot #define	IP6S_RULESMAX		16
225ca915d33Sroot #define	IP6S_SCOPECNT		16
226ca915d33Sroot 	/* number of times that address selection fails */
227ca915d33Sroot 	uint64_t ip6s_sources_none;
228ca915d33Sroot 	/* number of times that an address on the outgoing I/F is chosen */
229ca915d33Sroot 	uint64_t ip6s_sources_sameif[IP6S_SCOPECNT];
230ca915d33Sroot 	/* number of times that an address on a non-outgoing I/F is chosen */
231ca915d33Sroot 	uint64_t ip6s_sources_otherif[IP6S_SCOPECNT];
232ca915d33Sroot 	/*
233ca915d33Sroot 	 * number of times that an address that has the same scope
234ca915d33Sroot 	 * from the destination is chosen.
235ca915d33Sroot 	 */
236ca915d33Sroot 	uint64_t ip6s_sources_samescope[IP6S_SCOPECNT];
237ca915d33Sroot 	/*
238ca915d33Sroot 	 * number of times that an address that has a different scope
239ca915d33Sroot 	 * from the destination is chosen.
240ca915d33Sroot 	 */
241ca915d33Sroot 	uint64_t ip6s_sources_otherscope[IP6S_SCOPECNT];
242ca915d33Sroot 	/* number of times that a deprecated address is chosen */
243ca915d33Sroot 	uint64_t ip6s_sources_deprecated[IP6S_SCOPECNT];
244ca915d33Sroot 
245ca915d33Sroot 	/* number of times that each rule of source selection is applied. */
246ca915d33Sroot 	uint64_t ip6s_sources_rule[IP6S_RULESMAX];
247ca915d33Sroot };
248ca915d33Sroot 
249ca915d33Sroot #ifdef _KERNEL
250ca915d33Sroot #include <sys/counter.h>
251ca915d33Sroot 
252ca915d33Sroot VNET_PCPUSTAT_DECLARE(struct ip6stat, ip6stat);
253ca915d33Sroot #define	IP6STAT_ADD(name, val)	\
254ca915d33Sroot     VNET_PCPUSTAT_ADD(struct ip6stat, ip6stat, name, (val))
255ca915d33Sroot #define	IP6STAT_SUB(name, val)	IP6STAT_ADD(name, -(val))
256ca915d33Sroot #define	IP6STAT_INC(name)	IP6STAT_ADD(name, 1)
257ca915d33Sroot #define	IP6STAT_DEC(name)	IP6STAT_SUB(name, 1)
258ca915d33Sroot #endif
259ca915d33Sroot 
260ca915d33Sroot #ifdef _KERNEL
261ca915d33Sroot /* flags passed to ip6_output as last parameter */
262ca915d33Sroot #define	IPV6_UNSPECSRC		0x01	/* allow :: as the source address */
263ca915d33Sroot #define	IPV6_FORWARDING		0x02	/* most of IPv6 header exists */
264ca915d33Sroot #define	IPV6_MINMTU		0x04	/* use minimum MTU (IPV6_USE_MIN_MTU) */
265ca915d33Sroot 
266ca915d33Sroot #ifdef __NO_STRICT_ALIGNMENT
267ca915d33Sroot #define IP6_HDR_ALIGNED_P(ip)	1
268ca915d33Sroot #else
269ca915d33Sroot #define IP6_HDR_ALIGNED_P(ip)	((((intptr_t) (ip)) & 3) == 0)
270ca915d33Sroot #endif
271ca915d33Sroot 
272ca915d33Sroot VNET_DECLARE(int, ip6_defhlim);		/* default hop limit */
273ca915d33Sroot VNET_DECLARE(int, ip6_defmcasthlim);	/* default multicast hop limit */
274ca915d33Sroot VNET_DECLARE(int, ip6_forwarding);	/* act as router? */
275ca915d33Sroot VNET_DECLARE(int, ip6_use_deprecated);	/* allow deprecated addr as source */
276ca915d33Sroot VNET_DECLARE(int, ip6_rr_prune);	/* router renumbering prefix
277ca915d33Sroot 					 * walk list every 5 sec.    */
278ca915d33Sroot VNET_DECLARE(int, ip6_mcast_pmtu);	/* enable pMTU discovery for multicast? */
279ca915d33Sroot VNET_DECLARE(int, ip6_v6only);
280ca915d33Sroot #define	V_ip6_defhlim			VNET(ip6_defhlim)
281ca915d33Sroot #define	V_ip6_defmcasthlim		VNET(ip6_defmcasthlim)
282ca915d33Sroot #define	V_ip6_forwarding		VNET(ip6_forwarding)
283ca915d33Sroot #define	V_ip6_use_deprecated		VNET(ip6_use_deprecated)
284ca915d33Sroot #define	V_ip6_rr_prune			VNET(ip6_rr_prune)
285ca915d33Sroot #define	V_ip6_mcast_pmtu		VNET(ip6_mcast_pmtu)
286ca915d33Sroot #define	V_ip6_v6only			VNET(ip6_v6only)
287ca915d33Sroot 
288ca915d33Sroot VNET_DECLARE(struct socket *, ip6_mrouter);	/* multicast routing daemon */
289ca915d33Sroot VNET_DECLARE(int, ip6_sendredirects);	/* send IP redirects when forwarding? */
290ca915d33Sroot VNET_DECLARE(int, ip6_accept_rtadv);	/* Acts as a host not a router */
291ca915d33Sroot VNET_DECLARE(int, ip6_no_radr);		/* No defroute from RA */
292ca915d33Sroot VNET_DECLARE(int, ip6_norbit_raif);	/* Disable R-bit in NA on RA
293ca915d33Sroot 					 * receiving IF. */
294ca915d33Sroot VNET_DECLARE(int, ip6_rfc6204w3);	/* Accept defroute from RA even when
295ca915d33Sroot 					   forwarding enabled */
296ca915d33Sroot VNET_DECLARE(int, ip6_log_interval);
297ca915d33Sroot VNET_DECLARE(time_t, ip6_log_time);
298ca915d33Sroot VNET_DECLARE(int, ip6_hdrnestlimit);	/* upper limit of # of extension
299ca915d33Sroot 					 * headers */
300ca915d33Sroot VNET_DECLARE(int, ip6_dad_count);	/* DupAddrDetectionTransmits */
301ca915d33Sroot #define	V_ip6_mrouter			VNET(ip6_mrouter)
302ca915d33Sroot #define	V_ip6_sendredirects		VNET(ip6_sendredirects)
303ca915d33Sroot #define	V_ip6_accept_rtadv		VNET(ip6_accept_rtadv)
304ca915d33Sroot #define	V_ip6_no_radr			VNET(ip6_no_radr)
305ca915d33Sroot #define	V_ip6_norbit_raif		VNET(ip6_norbit_raif)
306ca915d33Sroot #define	V_ip6_rfc6204w3			VNET(ip6_rfc6204w3)
307ca915d33Sroot #define	V_ip6_log_interval		VNET(ip6_log_interval)
308ca915d33Sroot #define	V_ip6_log_time			VNET(ip6_log_time)
309ca915d33Sroot #define	V_ip6_hdrnestlimit		VNET(ip6_hdrnestlimit)
310ca915d33Sroot #define	V_ip6_dad_count			VNET(ip6_dad_count)
311ca915d33Sroot 
312ca915d33Sroot VNET_DECLARE(int, ip6_auto_flowlabel);
313ca915d33Sroot VNET_DECLARE(int, ip6_auto_linklocal);
314ca915d33Sroot #define	V_ip6_auto_flowlabel		VNET(ip6_auto_flowlabel)
315ca915d33Sroot #define	V_ip6_auto_linklocal		VNET(ip6_auto_linklocal)
316ca915d33Sroot 
317ca915d33Sroot VNET_DECLARE(int, ip6_use_tempaddr);	/* Whether to use temporary addresses */
318ca915d33Sroot VNET_DECLARE(int, ip6_prefer_tempaddr);	/* Whether to prefer temporary
319ca915d33Sroot 					 * addresses in the source address
320ca915d33Sroot 					 * selection */
321ca915d33Sroot #define	V_ip6_use_tempaddr		VNET(ip6_use_tempaddr)
322ca915d33Sroot #define	V_ip6_prefer_tempaddr		VNET(ip6_prefer_tempaddr)
323ca915d33Sroot 
324ca915d33Sroot VNET_DECLARE(int, ip6_use_defzone);	/* Whether to use the default scope
325ca915d33Sroot 					 * zone when unspecified */
326ca915d33Sroot #define	V_ip6_use_defzone		VNET(ip6_use_defzone)
327ca915d33Sroot 
328*d4a07e70Sfengbojiang VNET_DECLARE(struct pfil_head *, inet6_pfil_head);
329*d4a07e70Sfengbojiang #define	V_inet6_pfil_head	VNET(inet6_pfil_head)
330*d4a07e70Sfengbojiang #define	PFIL_INET6_NAME		"inet6"
331*d4a07e70Sfengbojiang 
332ca915d33Sroot #ifdef IPSTEALTH
333ca915d33Sroot VNET_DECLARE(int, ip6stealth);
334ca915d33Sroot #define	V_ip6stealth			VNET(ip6stealth)
335ca915d33Sroot #endif
336ca915d33Sroot 
337*d4a07e70Sfengbojiang #ifdef EXPERIMENTAL
338*d4a07e70Sfengbojiang VNET_DECLARE(int, nd6_ignore_ipv6_only_ra);
339*d4a07e70Sfengbojiang #define	V_nd6_ignore_ipv6_only_ra	VNET(nd6_ignore_ipv6_only_ra)
340*d4a07e70Sfengbojiang #endif
341*d4a07e70Sfengbojiang 
342ca915d33Sroot extern struct	pr_usrreqs rip6_usrreqs;
343ca915d33Sroot struct sockopt;
344ca915d33Sroot 
345ca915d33Sroot struct inpcb;
346ca915d33Sroot 
347ca915d33Sroot int	icmp6_ctloutput(struct socket *, struct sockopt *sopt);
348ca915d33Sroot 
349ca915d33Sroot struct in6_ifaddr;
350ca915d33Sroot void	ip6_init(void);
351ca915d33Sroot int	ip6proto_register(short);
352ca915d33Sroot int	ip6proto_unregister(short);
353ca915d33Sroot 
354ca915d33Sroot void	ip6_input(struct mbuf *);
355ca915d33Sroot void	ip6_direct_input(struct mbuf *);
356ca915d33Sroot void	ip6_freepcbopts(struct ip6_pktopts *);
357ca915d33Sroot 
358ca915d33Sroot int	ip6_unknown_opt(u_int8_t *, struct mbuf *, int);
359*d4a07e70Sfengbojiang int	ip6_get_prevhdr(const struct mbuf *, int);
360ca915d33Sroot int	ip6_nexthdr(const struct mbuf *, int, int, int *);
361ca915d33Sroot int	ip6_lasthdr(const struct mbuf *, int, int, int *);
362ca915d33Sroot 
363ca915d33Sroot extern int	(*ip6_mforward)(struct ip6_hdr *, struct ifnet *,
364ca915d33Sroot     struct mbuf *);
365ca915d33Sroot 
366ca915d33Sroot int	ip6_process_hopopts(struct mbuf *, u_int8_t *, int, u_int32_t *,
367ca915d33Sroot 				 u_int32_t *);
368ca915d33Sroot struct mbuf	**ip6_savecontrol_v4(struct inpcb *, struct mbuf *,
369ca915d33Sroot 	    struct mbuf **, int *);
370ca915d33Sroot void	ip6_savecontrol(struct inpcb *, struct mbuf *, struct mbuf **);
371ca915d33Sroot void	ip6_notify_pmtu(struct inpcb *, struct sockaddr_in6 *, u_int32_t);
372ca915d33Sroot int	ip6_sysctl(int *, u_int, void *, size_t *, void *, size_t);
373ca915d33Sroot 
374ca915d33Sroot void	ip6_forward(struct mbuf *, int);
375ca915d33Sroot 
376ca915d33Sroot void	ip6_mloopback(struct ifnet *, struct mbuf *);
377ca915d33Sroot int	ip6_output(struct mbuf *, struct ip6_pktopts *,
378ca915d33Sroot 			struct route_in6 *,
379ca915d33Sroot 			int,
380ca915d33Sroot 			struct ip6_moptions *, struct ifnet **,
381ca915d33Sroot 			struct inpcb *);
382ca915d33Sroot int	ip6_ctloutput(struct socket *, struct sockopt *);
383ca915d33Sroot int	ip6_raw_ctloutput(struct socket *, struct sockopt *);
384ca915d33Sroot void	ip6_initpktopts(struct ip6_pktopts *);
385ca915d33Sroot int	ip6_setpktopts(struct mbuf *, struct ip6_pktopts *,
386ca915d33Sroot 	struct ip6_pktopts *, struct ucred *, int);
387ca915d33Sroot void	ip6_clearpktopts(struct ip6_pktopts *, int);
388ca915d33Sroot struct ip6_pktopts *ip6_copypktopts(struct ip6_pktopts *, int);
389ca915d33Sroot int	ip6_optlen(struct inpcb *);
390ca915d33Sroot int	ip6_deletefraghdr(struct mbuf *, int, int);
391ca915d33Sroot int	ip6_fragment(struct ifnet *, struct mbuf *, int, u_char, int,
392ca915d33Sroot 			uint32_t);
393ca915d33Sroot 
394ca915d33Sroot int	route6_input(struct mbuf **, int *, int);
395ca915d33Sroot 
396ca915d33Sroot void	frag6_init(void);
397*d4a07e70Sfengbojiang void	frag6_destroy(void);
398ca915d33Sroot int	frag6_input(struct mbuf **, int *, int);
399ca915d33Sroot void	frag6_slowtimo(void);
400ca915d33Sroot void	frag6_drain(void);
401ca915d33Sroot 
402ca915d33Sroot void	rip6_init(void);
403ca915d33Sroot int	rip6_input(struct mbuf **, int *, int);
404ca915d33Sroot void	rip6_ctlinput(int, struct sockaddr *, void *);
405ca915d33Sroot int	rip6_ctloutput(struct socket *, struct sockopt *);
406ca915d33Sroot int	rip6_output(struct mbuf *, struct socket *, ...);
407ca915d33Sroot int	rip6_usrreq(struct socket *,
408ca915d33Sroot 	    int, struct mbuf *, struct mbuf *, struct mbuf *, struct thread *);
409ca915d33Sroot 
410ca915d33Sroot int	dest6_input(struct mbuf **, int *, int);
411ca915d33Sroot int	none_input(struct mbuf **, int *, int);
412ca915d33Sroot 
413ca915d33Sroot int	in6_selectsrc_socket(struct sockaddr_in6 *, struct ip6_pktopts *,
414ca915d33Sroot     struct inpcb *, struct ucred *, int, struct in6_addr *, int *);
415ca915d33Sroot int	in6_selectsrc_addr(uint32_t, const struct in6_addr *,
416ca915d33Sroot     uint32_t, struct ifnet *, struct in6_addr *, int *);
417ca915d33Sroot int in6_selectroute(struct sockaddr_in6 *, struct ip6_pktopts *,
418ca915d33Sroot 	struct ip6_moptions *, struct route_in6 *, struct ifnet **,
419*d4a07e70Sfengbojiang 	struct nhop_object **, u_int, uint32_t);
420ca915d33Sroot u_int32_t ip6_randomid(void);
421ca915d33Sroot u_int32_t ip6_randomflowlabel(void);
422ca915d33Sroot void in6_delayed_cksum(struct mbuf *m, uint32_t plen, u_short offset);
423ca915d33Sroot #endif /* _KERNEL */
424ca915d33Sroot 
425ca915d33Sroot #endif /* !_NETINET6_IP6_VAR_H_ */
426