1 /* $FreeBSD: src/sys/netinet6/ip6_var.h,v 1.2.2.4 2003/01/23 21:06:47 sam Exp $ */
2 /* $DragonFly: src/sys/netinet6/ip6_var.h,v 1.13 2008/09/04 09:08:22 hasso Exp $ */
3 /* $KAME: ip6_var.h,v 1.62 2001/05/03 14:51:48 itojun Exp $ */
6 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the project nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * Copyright (c) 1982, 1986, 1993
36 * The Regents of the University of California. All rights reserved.
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
41 * 1. Redistributions of source code must retain the above copyright
42 * notice, this list of conditions and the following disclaimer.
43 * 2. Redistributions in binary form must reproduce the above copyright
44 * notice, this list of conditions and the following disclaimer in the
45 * documentation and/or other materials provided with the distribution.
46 * 3. All advertising materials mentioning features or use of this software
47 * must display the following acknowledgement:
48 * This product includes software developed by the University of
49 * California, Berkeley and its contributors.
50 * 4. Neither the name of the University nor the names of its contributors
51 * may be used to endorse or promote products derived from this software
52 * without specific prior written permission.
54 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
55 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
56 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
57 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
58 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
59 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
60 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
61 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
62 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
66 * @(#)ip_var.h 8.1 (Berkeley) 6/10/93
69 #ifndef _NETINET6_IP6_VAR_H_
70 #define _NETINET6_IP6_VAR_H_
73 #include <sys/types.h>
76 #include <sys/queue.h>
78 #ifndef _NETINET_IN_H_
79 #include <netinet/in.h>
83 * IP6 reassembly queue structure. Each fragment
84 * being reassembled is attached to one of these structures.
89 u_int8_t ip6q_nxt
; /* ip6f_nxt in first fragment */
91 struct ip6asfrag
*ip6q_down
;
92 struct ip6asfrag
*ip6q_up
;
96 struct in6_addr ip6q_src
, ip6q_dst
;
97 struct ip6q
*ip6q_next
;
98 struct ip6q
*ip6q_prev
;
99 int ip6q_unfrglen
; /* len of unfragmentable part */
103 int ip6q_nfrag
; /* # of fragments */
107 u_int32_t ip6af_head
;
111 /* must not override the above members during reassembling */
112 struct ip6asfrag
*ip6af_down
;
113 struct ip6asfrag
*ip6af_up
;
114 struct mbuf
*ip6af_m
;
115 int ip6af_offset
; /* offset in ip6af_m to next header */
116 int ip6af_frglen
; /* fragmentable part length */
117 int ip6af_off
; /* fragment offset */
118 u_int16_t ip6af_mff
; /* more fragment bit in frag off */
121 #define IP6_REASS_MBUF(ip6af) (*(struct mbuf **)&((ip6af)->ip6af_m))
123 struct ip6_moptions
{
124 struct ifnet
*im6o_multicast_ifp
; /* ifp for outgoing multicasts */
125 u_char im6o_multicast_hlim
; /* hoplimit for outgoing multicasts */
126 u_char im6o_multicast_loop
; /* 1 >= hear sends if a member */
127 LIST_HEAD(, in6_multi_mship
) im6o_memberships
;
131 * Control options for outgoing packets
134 /* Routing header related info */
135 struct ip6po_rhinfo
{
136 struct ip6_rthdr
*ip6po_rhi_rthdr
; /* Routing header */
137 struct route_in6 ip6po_rhi_route
; /* Route to the 1st hop */
139 #define ip6po_rthdr ip6po_rhinfo.ip6po_rhi_rthdr
140 #define ip6po_route ip6po_rhinfo.ip6po_rhi_route
142 /* Nexthop related info */
143 struct ip6po_nhinfo
{
144 struct sockaddr
*ip6po_nhi_nexthop
;
145 struct route_in6 ip6po_nhi_route
; /* Route to the nexthop */
147 #define ip6po_nexthop ip6po_nhinfo.ip6po_nhi_nexthop
148 #define ip6po_nextroute ip6po_nhinfo.ip6po_nhi_route
151 struct mbuf
*ip6po_m
; /* Pointer to mbuf storing the data */
152 int ip6po_hlim
; /* Hoplimit for outgoing packets */
154 /* Outgoing IF/address information */
155 struct in6_pktinfo
*ip6po_pktinfo
;
157 /* Next-hop address information */
158 struct ip6po_nhinfo ip6po_nhinfo
;
160 struct ip6_hbh
*ip6po_hbh
; /* Hop-by-Hop options header */
162 /* Destination options header (before a routing header) */
163 struct ip6_dest
*ip6po_dest1
;
165 /* Routing header related info. */
166 struct ip6po_rhinfo ip6po_rhinfo
;
168 /* Destination options header (after a routing header) */
169 struct ip6_dest
*ip6po_dest2
;
171 * below fields are introduced in RFC3542
173 int ip6po_tclass
; /* traffic class */
174 int ip6po_minmtu
; /* fragment vs PMTU discovery policy */
175 #define IP6PO_MINMTU_MCASTONLY -1 /* default; send at min MTU for multicast*/
176 #define IP6PO_MINMTU_DISABLE 0 /* always perform pmtu disc */
177 #define IP6PO_MINMTU_ALL 1 /* always send at min MTU */
178 int ip6po_prefer_tempaddr
; /* whether temporary addresses are
179 preferred as source address */
180 #define IP6PO_TEMPADDR_SYSTEM -1 /* follow the system default */
181 #define IP6PO_TEMPADDR_NOTPREFER 0 /* not prefer temporary address */
182 #define IP6PO_TEMPADDR_PREFER 1 /* prefer temporary address */
185 #if 0 /* Parameters in this block are obsolete. Do not reuse the values. */
186 #define IP6PO_REACHCONF 0x01 /* upper-layer reachability confirmation. */
187 #define IP6PO_MINMTU 0x02 /* use minimum MTU (IPV6_USE_MIN_MTU) */
189 #define IP6PO_DONTFRAG 0x04 /* disable fragmentation (IPV6_DONTFRAG) */
190 #define IP6PO_USECOA 0x08 /* use care of address */
194 * Control options for incoming packets
197 u_quad_t ip6s_total
; /* total packets received */
198 u_quad_t ip6s_tooshort
; /* packet too short */
199 u_quad_t ip6s_toosmall
; /* not enough data */
200 u_quad_t ip6s_fragments
; /* fragments received */
201 u_quad_t ip6s_fragdropped
; /* frags dropped(dups, out of space) */
202 u_quad_t ip6s_fragtimeout
; /* fragments timed out */
203 u_quad_t ip6s_fragoverflow
; /* fragments that exceeded limit */
204 u_quad_t ip6s_forward
; /* packets forwarded */
205 u_quad_t ip6s_cantforward
; /* packets rcvd for unreachable dest */
206 u_quad_t ip6s_redirectsent
; /* packets forwarded on same net */
207 u_quad_t ip6s_delivered
; /* datagrams delivered to upper level*/
208 u_quad_t ip6s_localout
; /* total ip packets generated here */
209 u_quad_t ip6s_odropped
; /* lost packets due to nobufs, etc. */
210 u_quad_t ip6s_reassembled
; /* total packets reassembled ok */
211 u_quad_t ip6s_fragmented
; /* datagrams successfully fragmented */
212 u_quad_t ip6s_ofragments
; /* output fragments created */
213 u_quad_t ip6s_cantfrag
; /* don't fragment flag was set, etc. */
214 u_quad_t ip6s_badoptions
; /* error in option processing */
215 u_quad_t ip6s_noroute
; /* packets discarded due to no route */
216 u_quad_t ip6s_badvers
; /* ip6 version != 6 */
217 u_quad_t ip6s_rawout
; /* total raw ip packets generated */
218 u_quad_t ip6s_badscope
; /* scope error */
219 u_quad_t ip6s_notmember
; /* don't join this multicast group */
220 u_quad_t ip6s_nxthist
[256]; /* next header history */
221 u_quad_t ip6s_m1
; /* one mbuf */
222 u_quad_t ip6s_m2m
[32]; /* two or more mbuf */
223 u_quad_t ip6s_mext1
; /* one ext mbuf */
224 u_quad_t ip6s_mext2m
; /* two or more ext mbuf */
225 u_quad_t ip6s_exthdrtoolong
; /* ext hdr are not continuous */
226 u_quad_t ip6s_nogif
; /* no match gif found */
227 u_quad_t ip6s_toomanyhdr
; /* discarded due to too many headers */
230 * statistics for improvement of the source address selection
232 * XXX: hardcoded 16 = # of ip6 multicast scope types + 1
234 /* number of times that address selection fails */
235 u_quad_t ip6s_sources_none
;
236 /* number of times that an address on the outgoing I/F is chosen */
237 u_quad_t ip6s_sources_sameif
[16];
238 /* number of times that an address on a non-outgoing I/F is chosen */
239 u_quad_t ip6s_sources_otherif
[16];
241 * number of times that an address that has the same scope
242 * from the destination is chosen.
244 u_quad_t ip6s_sources_samescope
[16];
246 * number of times that an address that has a different scope
247 * from the destination is chosen.
249 u_quad_t ip6s_sources_otherscope
[16];
250 /* number of times that an deprecated address is chosen */
251 u_quad_t ip6s_sources_deprecated
[16];
253 u_quad_t ip6s_forward_cachehit
;
254 u_quad_t ip6s_forward_cachemiss
;
259 * IPv6 onion peeling state.
260 * it will be initialized when we come into ip6_input().
261 * XXX do not make it a kitchen sink!
264 u_int32_t ip6a_flags
;
265 #define IP6A_SWAP 0x01 /* swapped home/care-of on packet */
266 #define IP6A_HASEEN 0x02 /* HA was present */
267 #define IP6A_BRUID 0x04 /* BR Unique Identifier was present */
268 #define IP6A_RTALERTSEEN 0x08 /* rtalert present */
271 struct in6_addr ip6a_careof
; /* care-of address of the peer */
272 struct in6_addr ip6a_home
; /* home address of the peer */
273 u_int16_t ip6a_bruid
; /* BR unique identifier */
276 struct in6_ifaddr
*ip6a_dstia6
; /* my ifaddr that matches ip6_dst */
279 u_int16_t ip6a_rtalert
; /* rtalert option value */
282 * decapsulation history will be here.
283 * with IPsec it may not be accurate.
289 /* flags passed to ip6_output as last parameter */
290 #define IPV6_DADOUTPUT 0x01 /* DAD */
291 #define IPV6_FORWARDING 0x02 /* most of IPv6 header exists */
292 #define IPV6_MINMTU 0x04 /* use minimum MTU (IPV6_USE_MIN_MTU) */
294 /* direction passed to ip_hashfn as last parameter */
295 #define IP6_MPORT_IN 0 /* Find lwkt port for incoming packets */
296 #define IP6_MPORT_OUT 1 /* Find lwkt port for outgoing packets */
298 extern struct ip6stat ip6stat
; /* statistics */
299 extern u_int32_t ip6_id
; /* fragment identifier */
300 extern int ip6_minhlim
; /* minimum hop limit */
301 extern int ip6_defhlim
; /* default hop limit */
302 extern int ip6_defmcasthlim
; /* default multicast hop limit */
303 extern int ip6_forwarding
; /* act as router? */
304 extern int ip6_forward_srcrt
; /* forward src-routed? */
305 extern int ip6_gif_hlim
; /* Hop limit for gif encap packet */
306 extern int ip6_use_deprecated
; /* allow deprecated addr as source */
307 extern int ip6_rr_prune
; /* router renumbering prefix
308 * walk list every 5 sec. */
310 extern struct socket
*ip6_mrouter
; /* multicast routing daemon */
311 extern int ip6_sendredirects
; /* send IP redirects when forwarding? */
312 extern int ip6_maxfragpackets
; /* Maximum packets in reassembly queue */
313 extern int ip6_maxfrags
; /* Maximum fragments in reassembly queue */
314 extern int ip6_sourcecheck
; /* Verify source interface */
315 extern int ip6_sourcecheck_interval
; /* Interval between log messages */
316 extern int ip6_accept_rtadv
; /* Acts as a host not a router */
317 extern int ip6_keepfaith
; /* Firewall Aided Internet Translator */
318 extern int ip6_log_interval
;
319 extern time_t ip6_log_time
;
320 extern int ip6_hdrnestlimit
; /* upper limit of # of extension headers */
321 extern int ip6_dad_count
; /* DupAddrDetectionTransmits */
323 extern u_int32_t ip6_flow_seq
;
324 extern int ip6_auto_flowlabel
;
325 extern int ip6_auto_linklocal
;
327 extern int ip6_anonportmin
; /* minimum ephemeral port */
328 extern int ip6_anonportmax
; /* maximum ephemeral port */
329 extern int ip6_lowportmin
; /* minimum reserved port */
330 extern int ip6_lowportmax
; /* maximum reserved port */
332 extern int ip6_use_tempaddr
; /* whether to use temporary addresses. */
334 extern struct pfil_head inet6_pfil_hook
;
336 extern struct pr_usrreqs rip6_usrreqs
;
345 void icmp6_ctloutput (union netmsg
*);
347 void ip6_init (void);
349 struct in6_ifaddr
*ip6_getdstifaddr (struct mbuf
*);
350 void ip6_freepcbopts (struct ip6_pktopts
*);
351 void ip6_freemoptions (struct ip6_moptions
*);
352 int ip6_unknown_opt (u_int8_t
*, struct mbuf
*, int);
353 char * ip6_get_prevhdr (struct mbuf
*, int);
354 int ip6_nexthdr (struct mbuf
*, int, int, int *);
355 int ip6_lasthdr (struct mbuf
*, int, int, int *);
357 struct ip6aux
*ip6_addaux (struct mbuf
*);
358 struct ip6aux
*ip6_findaux (struct mbuf
*);
359 void ip6_delaux (struct mbuf
*);
361 int ip6_mforward (struct ip6_hdr
*, struct ifnet
*, struct mbuf
*);
362 int ip6_process_hopopts (struct mbuf
*, u_int8_t
*, int, u_int32_t
*,
364 void ip6_savecontrol (struct inpcb
*, struct mbuf
**, struct ip6_hdr
*,
366 void ip6_notify_pmtu (struct inpcb
*, struct sockaddr_in6
*,
368 int ip6_sysctl (int *, u_int
, void *, size_t *, void *, size_t);
370 void ip6_forward (struct mbuf
*, int);
372 void ip6_mloopback (struct ifnet
*, struct mbuf
*, struct sockaddr_in6
*);
373 int ip6_output (struct mbuf
*, struct ip6_pktopts
*,
376 struct ip6_moptions
*, struct ifnet
**,
378 void ip6_ctloutput_dispatch(netmsg_t msg
);
379 int ip6_ctloutput (struct socket
*, struct sockopt
*);
380 int ip6_raw_ctloutput (struct socket
*, struct sockopt
*);
381 void init_ip6pktopts (struct ip6_pktopts
*);
383 ip6_setpktoptions(struct mbuf
*, struct ip6_pktopts
*,
384 struct ip6_pktopts
*, int , int);
385 void ip6_clearpktopts (struct ip6_pktopts
*, int);
386 struct ip6_pktopts
*ip6_copypktopts (struct ip6_pktopts
*, int);
387 int ip6_optlen (struct inpcb
*);
389 int route6_input (struct mbuf
**, int *, int);
391 void frag6_init (void);
392 int frag6_input (struct mbuf
**, int *, int);
393 void frag6_slowtimo (void);
394 void frag6_drain (void);
396 void rip6_init (void);
397 int rip6_input (struct mbuf
**, int *, int);
398 void rip6_ctlinput (union netmsg
*);
399 void rip6_ctloutput (union netmsg
*);
400 int rip6_output (struct mbuf
*, struct socket
*, ...);
401 int rip6_usrreq (struct socket
*,
402 int, struct mbuf
*, struct mbuf
*, struct mbuf
*, struct proc
*);
404 int dest6_input (struct mbuf
**, int *, int);
405 int none_input (struct mbuf
**, int *, int);
408 #endif /* !_NETINET6_IP6_VAR_H_ */