1 /* $KAME: ip6_var.h,v 1.31 2000/04/04 08:48:26 itojun Exp $ */
4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the project nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * Copyright (c) 1982, 1986, 1993
34 * The Regents of the University of California. All rights reserved.
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
39 * 1. Redistributions of source code must retain the above copyright
40 * notice, this list of conditions and the following disclaimer.
41 * 2. Redistributions in binary form must reproduce the above copyright
42 * notice, this list of conditions and the following disclaimer in the
43 * documentation and/or other materials provided with the distribution.
44 * 3. All advertising materials mentioning features or use of this software
45 * must display the following acknowledgement:
46 * This product includes software developed by the University of
47 * California, Berkeley and its contributors.
48 * 4. Neither the name of the University nor the names of its contributors
49 * may be used to endorse or promote products derived from this software
50 * without specific prior written permission.
52 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
53 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
54 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
55 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
56 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
57 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
58 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
59 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
60 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
61 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64 * @(#)ip_var.h 8.1 (Berkeley) 6/10/93
67 #ifndef _NETINET6_IP6_VAR_H_
68 #define _NETINET6_IP6_VAR_H_
71 * IP6 reassembly queue structure. Each fragment
72 * being reassembled is attached to one of these structures.
77 u_int8_t ip6q_nxt
; /* ip6f_nxt in first fragment */
79 struct ip6asfrag
*ip6q_down
;
80 struct ip6asfrag
*ip6q_up
;
84 struct in6_addr ip6q_src
, ip6q_dst
;
85 struct ip6q
*ip6q_next
;
86 struct ip6q
*ip6q_prev
;
87 int ip6q_unfrglen
; /* len of unfragmentable part */
98 /* must not override the above members during reassembling */
99 struct ip6asfrag
*ip6af_down
;
100 struct ip6asfrag
*ip6af_up
;
101 struct mbuf
*ip6af_m
;
102 int ip6af_offset
; /* offset in ip6af_m to next header */
103 int ip6af_frglen
; /* fragmentable part length */
104 int ip6af_off
; /* fragment offset */
105 u_int16_t ip6af_mff
; /* more fragment bit in frag off */
108 #define IP6_REASS_MBUF(ip6af) (*(struct mbuf **)&((ip6af)->ip6af_m))
110 struct ip6_moptions
{
111 struct ifnet
*im6o_multicast_ifp
; /* ifp for outgoing multicasts */
112 u_char im6o_multicast_hlim
; /* hoplimit for outgoing multicasts */
113 u_char im6o_multicast_loop
; /* 1 >= hear sends if a member */
114 LIST_HEAD(, in6_multi_mship
) im6o_memberships
;
118 * Control options for outgoing packets
121 /* Routing header related info */
122 struct ip6po_rhinfo
{
123 struct ip6_rthdr
*ip6po_rhi_rthdr
; /* Routing header */
124 struct route_in6 ip6po_rhi_route
; /* Route to the 1st hop */
126 #define ip6po_rthdr ip6po_rhinfo.ip6po_rhi_rthdr
127 #define ip6po_route ip6po_rhinfo.ip6po_rhi_route
130 int ip6po_hlim
; /* Hoplimit for outgoing packets */
132 /* Outgoing IF/address information */
133 struct in6_pktinfo
*ip6po_pktinfo
;
135 struct sockaddr
*ip6po_nexthop
; /* Next-hop address */
137 struct ip6_hbh
*ip6po_hbh
; /* Hop-by-Hop options header */
139 /* Destination options header (before a routing header) */
140 struct ip6_dest
*ip6po_dest1
;
142 /* Routing header related info. */
143 struct ip6po_rhinfo ip6po_rhinfo
;
145 /* Destination options header (after a routing header) */
146 struct ip6_dest
*ip6po_dest2
;
149 #define IP6PO_REACHCONF 0x01 /* upper-layer reachability confirmation */
150 #define IP6PO_MINMTU 0x02 /* use minimum MTU (IPV6_USE_MIN_MTU) */
154 * Control options for incoming packets
157 struct ip6_recvpktopts
{
158 struct mbuf
*head
; /* mbuf chain of data passed to a user */
161 struct mbuf
*timestamp
; /* timestamp */
163 struct mbuf
*hlim
; /* received hop limit */
164 struct mbuf
*pktinfo
; /* packet information of rcv packet */
165 struct mbuf
*hbh
; /* HbH options header of rcv packet */
166 struct mbuf
*dest1
; /* Dest opt header of rcv packet */
167 struct mbuf
*dest2
; /* Dest opt header (after rthdr) of rcv packet */
168 struct mbuf
*rthdr
; /* Routing header of rcv packet */
172 u_quad_t ip6s_total
; /* total packets received */
173 u_quad_t ip6s_tooshort
; /* packet too short */
174 u_quad_t ip6s_toosmall
; /* not enough data */
175 u_quad_t ip6s_fragments
; /* fragments received */
176 u_quad_t ip6s_fragdropped
; /* frags dropped(dups, out of space) */
177 u_quad_t ip6s_fragtimeout
; /* fragments timed out */
178 u_quad_t ip6s_fragoverflow
; /* fragments that exceeded limit */
179 u_quad_t ip6s_forward
; /* packets forwarded */
180 u_quad_t ip6s_cantforward
; /* packets rcvd for unreachable dest */
181 u_quad_t ip6s_redirectsent
; /* packets forwarded on same net */
182 u_quad_t ip6s_delivered
; /* datagrams delivered to upper level*/
183 u_quad_t ip6s_localout
; /* total ip packets generated here */
184 u_quad_t ip6s_odropped
; /* lost packets due to nobufs, etc. */
185 u_quad_t ip6s_reassembled
; /* total packets reassembled ok */
186 u_quad_t ip6s_fragmented
; /* datagrams sucessfully fragmented */
187 u_quad_t ip6s_ofragments
; /* output fragments created */
188 u_quad_t ip6s_cantfrag
; /* don't fragment flag was set, etc. */
189 u_quad_t ip6s_badoptions
; /* error in option processing */
190 u_quad_t ip6s_noroute
; /* packets discarded due to no route */
191 u_quad_t ip6s_badvers
; /* ip6 version != 6 */
192 u_quad_t ip6s_rawout
; /* total raw ip packets generated */
193 u_quad_t ip6s_badscope
; /* scope error */
194 u_quad_t ip6s_notmember
; /* don't join this multicast group */
195 u_quad_t ip6s_nxthist
[256]; /* next header history */
196 u_quad_t ip6s_m1
; /* one mbuf */
197 u_quad_t ip6s_m2m
[32]; /* two or more mbuf */
198 u_quad_t ip6s_mext1
; /* one ext mbuf */
199 u_quad_t ip6s_mext2m
; /* two or more ext mbuf */
200 u_quad_t ip6s_exthdrtoolong
; /* ext hdr are not continuous */
201 u_quad_t ip6s_nogif
; /* no match gif found */
202 u_quad_t ip6s_toomanyhdr
; /* discarded due to too many headers */
203 /* XXX the following two items are not really AF_INET6 thing */
204 u_quad_t ip6s_exthdrget
; /* # of calls to IP6_EXTHDR_GET */
205 u_quad_t ip6s_exthdrget0
; /* # of calls to IP6_EXTHDR_GET0 */
206 u_quad_t ip6s_pulldown
; /* # of calls to m_pulldown */
207 u_quad_t ip6s_pulldown_copy
; /* # of mbuf copies in m_pulldown */
208 u_quad_t ip6s_pulldown_alloc
; /* # of mbuf allocs in m_pulldown */
209 u_quad_t ip6s_pullup
; /* # of calls to m_pullup */
210 u_quad_t ip6s_pullup_copy
; /* # of possible m_pullup copies */
211 u_quad_t ip6s_pullup_alloc
; /* # of possible m_pullup mallocs */
212 u_quad_t ip6s_pullup_fail
; /* # of possible m_pullup failures */
213 u_quad_t ip6s_pullup2
; /* # of calls to m_pullup2 */
214 u_quad_t ip6s_pullup2_copy
; /* # of possible m_pullup2 copies */
215 u_quad_t ip6s_pullup2_alloc
; /* # of possible m_pullup2 mallocs */
216 u_quad_t ip6s_pullup2_fail
; /* # of possible m_pullup2 failures */
219 * statistics for improvement of the source address selection
221 * XXX: hardcoded 16 = # of ip6 multicast scope types + 1
223 /* number of times that address selection fails */
224 u_quad_t ip6s_sources_none
;
225 /* number of times that an address on the outgoing I/F is chosen */
226 u_quad_t ip6s_sources_sameif
[16];
227 /* number of times that an address on a non-outgoing I/F is chosen */
228 u_quad_t ip6s_sources_otherif
[16];
230 * number of times that an address that has the same scope
231 * from the destination is chosen.
233 u_quad_t ip6s_sources_samescope
[16];
235 * number of times that an address that has a different scope
236 * from the destination is chosen.
238 u_quad_t ip6s_sources_otherscope
[16];
239 /* number of times that an deprecated address is chosen */
240 u_quad_t ip6s_sources_deprecated
[16];
244 /* flags passed to ip6_output as last parameter */
245 #define IPV6_DADOUTPUT 0x01 /* DAD */
246 #define IPV6_FORWARDING 0x02 /* most of IPv6 header exists */
247 #define IPV6_MINMTU 0x04 /* use minimum MTU (IPV6_USE_MIN_MTU) */
249 extern struct ip6stat ip6stat
; /* statistics */
250 extern u_int32_t ip6_id
; /* fragment identifier */
251 extern int ip6_defhlim
; /* default hop limit */
252 extern int ip6_defmcasthlim
; /* default multicast hop limit */
253 extern int ip6_forwarding
; /* act as router? */
254 extern int ip6_forward_srcrt
; /* forward src-routed? */
255 extern int ip6_gif_hlim
; /* Hop limit for gif encap packet */
256 extern int ip6_use_deprecated
; /* allow deprecated addr as source */
257 extern int ip6_rr_prune
; /* router renumbering prefix
258 * walk list every 5 sec. */
260 extern int ip6_mapped_addr_on
;
262 #if defined(__NetBSD__) && !defined(INET6_BINDV6ONLY)
263 extern int ip6_bindv6only
;
266 extern struct socket
*ip6_mrouter
; /* multicast routing daemon */
267 extern int ip6_sendredirects
; /* send IP redirects when forwarding? */
268 extern int ip6_maxfragpackets
; /* Maximum packets in reassembly queue */
269 extern int ip6_sourcecheck
; /* Verify source interface */
270 extern int ip6_sourcecheck_interval
; /* Interval between log messages */
271 extern int ip6_accept_rtadv
; /* Acts as a host not a router */
272 extern int ip6_keepfaith
; /* Firewall Aided Internet Translator */
273 extern int ip6_log_interval
;
274 extern time_t ip6_log_time
;
275 extern int ip6_hdrnestlimit
; /* upper limit of # of extension headers */
276 extern int ip6_dad_count
; /* DupAddrDetectionTransmits */
278 extern u_int32_t ip6_flow_seq
;
279 extern int ip6_auto_flowlabel
;
281 #if !defined(__APPLE__)
282 //#if !defined(__FreeBSD__) || __FreeBSD__ < 3
285 #if defined(__FreeBSD__) && __FreeBSD__ >= 3 || defined (__APPLE__)
286 extern struct pr_usrreqs rip6_usrreqs
;
292 #if (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined (__APPLE__)
293 int icmp6_ctloutput
__P((struct socket
*, struct sockopt
*sopt
));
295 int icmp6_ctloutput
__P((int, struct socket
*, int, int, struct mbuf
**));
298 void ip6_init
__P((void));
299 void ip6intr
__P((void));
300 void ip6_input
__P((struct mbuf
*));
301 void ip6_freepcbopts
__P((struct ip6_pktopts
*));
302 void ip6_freemoptions
__P((struct ip6_moptions
*));
303 int ip6_unknown_opt
__P((u_int8_t
*, struct mbuf
*, int));
304 char * ip6_get_prevhdr
__P((struct mbuf
*, int));
305 int ip6_nexthdr
__P((struct mbuf
*, int, int, int *));
306 int ip6_lasthdr
__P((struct mbuf
*, int, int, int *));
307 int ip6_mforward
__P((struct ip6_hdr
*, struct ifnet
*, struct mbuf
*));
308 int ip6_process_hopopts
__P((struct mbuf
*, u_int8_t
*, int, u_int32_t
*,
310 #if defined(__FreeBSD__) && __FreeBSD__ >= 3 || defined (__APPLE__)
311 void ip6_savecontrol
__P((struct inpcb
*, struct ip6_hdr
*, struct mbuf
*,
312 struct ip6_recvpktopts
*,
313 struct ip6_recvpktopts
**));
315 void ip6_savecontrol
__P((struct in6pcb
*, struct ip6_hdr
*, struct mbuf
*,
316 struct ip6_recvpktopts
*,
317 struct ip6_recvpktopts
**));
319 void ip6_update_recvpcbopt
__P((struct ip6_recvpktopts
*,
320 struct ip6_recvpktopts
*));
321 void ip6_reset_rcvopt
__P((struct ip6_recvpktopts
*, int));
322 int ip6_sysctl
__P((int *, u_int
, void *, size_t *, void *, size_t));
324 void ip6_forward
__P((struct mbuf
*, int));
326 void ip6_mloopback
__P((struct ifnet
*, struct mbuf
*, struct sockaddr_in6
*));
327 int ip6_output
__P((struct mbuf
*, struct ip6_pktopts
*,
328 struct route_in6
*, int,
329 struct ip6_moptions
*, struct ifnet
**));
330 #if defined(__FreeBSD__) && __FreeBSD__ >= 3 || defined (__APPLE__)
331 int ip6_ctloutput
__P((struct socket
*, struct sockopt
*sopt
));
333 int ip6_ctloutput
__P((int, struct socket
*, int, int, struct mbuf
**));
335 int ip6_setpktoptions
__P((struct mbuf
*, struct ip6_pktopts
*, int, int));
336 void ip6_clearpktopts
__P((struct ip6_pktopts
*, int, int));
337 struct ip6_pktopts
*ip6_copypktopts
__P((struct ip6_pktopts
*, int));
338 #if defined(__FreeBSD__) && __FreeBSD__ >= 3 || defined (__APPLE__)
339 int ip6_optlen
__P((struct inpcb
*));
341 int ip6_optlen
__P((struct in6pcb
*));
344 int route6_input
__P((struct mbuf
**, int *, int));
346 void frag6_init
__P((void));
347 int frag6_input
__P((struct mbuf
**, int *, int));
348 void frag6_slowtimo
__P((void));
349 void frag6_drain
__P((void));
351 void rip6_init
__P((void));
352 int rip6_input
__P((struct mbuf
**mp
, int *offp
, int proto
));
353 void rip6_ctlinput
__P((int, struct sockaddr
*, void *));
354 #if defined(__FreeBSD__) && __FreeBSD__ >= 3 || defined (__APPLE__)
355 int rip6_ctloutput
__P((struct socket
*so
, struct sockopt
*sopt
));
357 int rip6_ctloutput
__P((int, struct socket
*, int, int, struct mbuf
**));
359 int rip6_output
__P((struct mbuf
*, struct socket
*, struct sockaddr_in6
*,
361 int rip6_usrreq
__P((struct socket
*,
362 int, struct mbuf
*, struct mbuf
*, struct mbuf
*, struct proc
*));
364 int dest6_input
__P((struct mbuf
**, int *, int));
365 int none_input
__P((struct mbuf
**, int *, int));
368 #endif /* !_NETINET6_IP6_VAR_H_ */