2 * Copyright (c) 2008 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 /* $FreeBSD: src/sys/netinet6/ip6_var.h,v 1.2.2.2 2001/07/03 11:01:54 ume Exp $ */
30 /* $KAME: ip6_var.h,v 1.62 2001/05/03 14:51:48 itojun Exp $ */
33 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
34 * 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. Neither the name of the project nor the names of its contributors
45 * may be used to endorse or promote products derived from this software
46 * without specific prior written permission.
48 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
49 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
62 * Copyright (c) 1982, 1986, 1993
63 * The Regents of the University of California. All rights reserved.
65 * Redistribution and use in source and binary forms, with or without
66 * modification, are permitted provided that the following conditions
68 * 1. Redistributions of source code must retain the above copyright
69 * notice, this list of conditions and the following disclaimer.
70 * 2. Redistributions in binary form must reproduce the above copyright
71 * notice, this list of conditions and the following disclaimer in the
72 * documentation and/or other materials provided with the distribution.
73 * 3. All advertising materials mentioning features or use of this software
74 * must display the following acknowledgement:
75 * This product includes software developed by the University of
76 * California, Berkeley and its contributors.
77 * 4. Neither the name of the University nor the names of its contributors
78 * may be used to endorse or promote products derived from this software
79 * without specific prior written permission.
81 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
82 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
83 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
84 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
85 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
86 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
87 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
88 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
89 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
90 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
93 * @(#)ip_var.h 8.1 (Berkeley) 6/10/93
96 #ifndef _NETINET6_IP6_VAR_H_
97 #define _NETINET6_IP6_VAR_H_
98 #include <sys/appleapiopts.h>
100 #ifdef KERNEL_PRIVATE
102 * IP6 reassembly queue structure. Each fragment
103 * being reassembled is attached to one of these structures.
108 u_int8_t ip6q_nxt
; /* ip6f_nxt in first fragment */
110 struct ip6asfrag
*ip6q_down
;
111 struct ip6asfrag
*ip6q_up
;
112 u_int32_t ip6q_ident
;
113 u_int8_t ip6q_arrive
;
115 struct in6_addr ip6q_src
, ip6q_dst
;
116 struct ip6q
*ip6q_next
;
117 struct ip6q
*ip6q_prev
;
118 int ip6q_unfrglen
; /* len of unfragmentable part */
122 int ip6q_nfrag
; /* number of fragments */
126 u_int32_t ip6af_head
;
130 /* must not override the above members during reassembling */
131 struct ip6asfrag
*ip6af_down
;
132 struct ip6asfrag
*ip6af_up
;
133 struct mbuf
*ip6af_m
;
134 int ip6af_offset
; /* offset in ip6af_m to next header */
135 int ip6af_frglen
; /* fragmentable part length */
136 int ip6af_off
; /* fragment offset */
137 u_int16_t ip6af_mff
; /* more fragment bit in frag off */
140 #define IP6_REASS_MBUF(ip6af) (*(struct mbuf **)&((ip6af)->ip6af_m))
142 struct ip6_moptions
{
143 struct ifnet
*im6o_multicast_ifp
; /* ifp for outgoing multicasts */
144 u_char im6o_multicast_hlim
; /* hoplimit for outgoing multicasts */
145 u_char im6o_multicast_loop
; /* 1 >= hear sends if a member */
146 LIST_HEAD(, in6_multi_mship
) im6o_memberships
;
150 * Control options for outgoing packets
153 /* Routing header related info */
154 struct ip6po_rhinfo
{
155 struct ip6_rthdr
*ip6po_rhi_rthdr
; /* Routing header */
156 struct route_in6 ip6po_rhi_route
; /* Route to the 1st hop */
158 #define ip6po_rthdr ip6po_rhinfo.ip6po_rhi_rthdr
159 #define ip6po_route ip6po_rhinfo.ip6po_rhi_route
162 struct mbuf
*ip6po_m
; /* Pointer to mbuf storing the data */
163 int ip6po_hlim
; /* Hoplimit for outgoing packets */
165 /* Outgoing IF/address information */
166 struct in6_pktinfo
*ip6po_pktinfo
;
168 struct sockaddr
*ip6po_nexthop
; /* Next-hop address */
170 struct ip6_hbh
*ip6po_hbh
; /* Hop-by-Hop options header */
172 /* Destination options header (before a routing header) */
173 struct ip6_dest
*ip6po_dest1
;
175 /* Routing header related info. */
176 struct ip6po_rhinfo ip6po_rhinfo
;
178 /* Destination options header (after a routing header) */
179 struct ip6_dest
*ip6po_dest2
;
181 int ip6po_tclass
; /* traffic class */
185 * Control options for incoming packets
187 #endif /* KERNEL_PRIVATE */
190 u_quad_t ip6s_total
; /* total packets received */
191 u_quad_t ip6s_tooshort
; /* packet too short */
192 u_quad_t ip6s_toosmall
; /* not enough data */
193 u_quad_t ip6s_fragments
; /* fragments received */
194 u_quad_t ip6s_fragdropped
; /* frags dropped(dups, out of space) */
195 u_quad_t ip6s_fragtimeout
; /* fragments timed out */
196 u_quad_t ip6s_fragoverflow
; /* fragments that exceeded limit */
197 u_quad_t ip6s_forward
; /* packets forwarded */
198 u_quad_t ip6s_cantforward
; /* packets rcvd for unreachable dest */
199 u_quad_t ip6s_redirectsent
; /* packets forwarded on same net */
200 u_quad_t ip6s_delivered
; /* datagrams delivered to upper level*/
201 u_quad_t ip6s_localout
; /* total ip packets generated here */
202 u_quad_t ip6s_odropped
; /* lost packets due to nobufs, etc. */
203 u_quad_t ip6s_reassembled
; /* total packets reassembled ok */
204 u_quad_t ip6s_fragmented
; /* datagrams sucessfully fragmented */
205 u_quad_t ip6s_ofragments
; /* output fragments created */
206 u_quad_t ip6s_cantfrag
; /* don't fragment flag was set, etc. */
207 u_quad_t ip6s_badoptions
; /* error in option processing */
208 u_quad_t ip6s_noroute
; /* packets discarded due to no route */
209 u_quad_t ip6s_badvers
; /* ip6 version != 6 */
210 u_quad_t ip6s_rawout
; /* total raw ip packets generated */
211 u_quad_t ip6s_badscope
; /* scope error */
212 u_quad_t ip6s_notmember
; /* don't join this multicast group */
213 u_quad_t ip6s_nxthist
[256]; /* next header history */
214 u_quad_t ip6s_m1
; /* one mbuf */
215 u_quad_t ip6s_m2m
[32]; /* two or more mbuf */
216 u_quad_t ip6s_mext1
; /* one ext mbuf */
217 u_quad_t ip6s_mext2m
; /* two or more ext mbuf */
218 u_quad_t ip6s_exthdrtoolong
; /* ext hdr are not continuous */
219 u_quad_t ip6s_nogif
; /* no match gif found */
220 u_quad_t ip6s_toomanyhdr
; /* discarded due to too many headers */
223 * statistics for improvement of the source address selection
225 * XXX: hardcoded 16 = # of ip6 multicast scope types + 1
227 /* number of times that address selection fails */
228 u_quad_t ip6s_sources_none
;
229 /* number of times that an address on the outgoing I/F is chosen */
230 u_quad_t ip6s_sources_sameif
[16];
231 /* number of times that an address on a non-outgoing I/F is chosen */
232 u_quad_t ip6s_sources_otherif
[16];
234 * number of times that an address that has the same scope
235 * from the destination is chosen.
237 u_quad_t ip6s_sources_samescope
[16];
239 * number of times that an address that has a different scope
240 * from the destination is chosen.
242 u_quad_t ip6s_sources_otherscope
[16];
243 /* number of times that an deprecated address is chosen */
244 u_quad_t ip6s_sources_deprecated
[16];
246 u_quad_t ip6s_forward_cachehit
;
247 u_quad_t ip6s_forward_cachemiss
;
250 #ifdef KERNEL_PRIVATE
253 * IPv6 onion peeling state.
254 * it will be initialized when we come into ip6_input().
255 * XXX do not make it a kitchen sink!
258 u_int32_t ip6a_flags
;
259 #define IP6A_SWAP 0x01 /* swapped home/care-of on packet */
260 #define IP6A_HASEEN 0x02 /* HA was present */
261 #define IP6A_BRUID 0x04 /* BR Unique Identifier was present */
262 #define IP6A_RTALERTSEEN 0x08 /* rtalert present */
265 struct in6_addr ip6a_careof
; /* care-of address of the peer */
266 struct in6_addr ip6a_home
; /* home address of the peer */
267 u_int16_t ip6a_bruid
; /* BR unique identifier */
270 struct in6_ifaddr
*ip6a_dstia6
; /* my ifaddr that matches ip6_dst */
273 u_int16_t ip6a_rtalert
; /* rtalert option value */
276 * decapsulation history will be here.
277 * with IPsec it may not be accurate.
281 /* flags passed to ip6_output as last parameter */
282 #define IPV6_DADOUTPUT 0x01 /* DAD */
283 #define IPV6_FORWARDING 0x02 /* most of IPv6 header exists */
284 #define IPV6_MINMTU 0x04 /* use minimum MTU (IPV6_USE_MIN_MTU) */
286 extern struct ip6stat ip6stat
; /* statistics */
287 extern u_int32_t ip6_id
; /* fragment identifier */
288 extern int ip6_defhlim
; /* default hop limit */
289 extern int ip6_defmcasthlim
; /* default multicast hop limit */
290 extern int ip6_forwarding
; /* act as router? */
291 extern int ip6_forward_srcrt
; /* forward src-routed? */
292 extern int ip6_gif_hlim
; /* Hop limit for gif encap packet */
293 extern int ip6_use_deprecated
; /* allow deprecated addr as source */
294 extern int ip6_rr_prune
; /* router renumbering prefix
295 * walk list every 5 sec. */
296 #define ip6_mapped_addr_on (!ip6_v6only)
297 extern int ip6_v6only
;
299 extern int ip6_neighborgcthresh
; /* Threshold # of NDP entries for GC */
300 extern int ip6_maxifprefixes
; /* Max acceptable prefixes via RA per IF */
301 extern int ip6_maxifdefrouters
; /* Max acceptable def routers via RA */
302 extern int ip6_maxdynroutes
; /* Max # of routes created via redirect */
304 extern struct socket
*ip6_mrouter
; /* multicast routing daemon */
305 extern int ip6_sendredirects
; /* send IP redirects when forwarding? */
306 extern int ip6_maxfragpackets
; /* Maximum packets in reassembly queue */
307 extern int ip6_maxfrags
; /* Maximum fragments in reassembly queue */
308 extern int ip6_sourcecheck
; /* Verify source interface */
309 extern int ip6_sourcecheck_interval
; /* Interval between log messages */
310 extern int ip6_accept_rtadv
; /* Acts as a host not a router */
311 extern int ip6_keepfaith
; /* Firewall Aided Internet Translator */
312 extern int ip6_log_interval
;
313 extern time_t ip6_log_time
;
314 extern int ip6_hdrnestlimit
; /* upper limit of # of extension headers */
315 extern int ip6_dad_count
; /* DupAddrDetectionTransmits */
317 extern u_int32_t ip6_flow_seq
;
318 extern int ip6_auto_flowlabel
;
319 extern int ip6_auto_linklocal
;
321 extern int ip6_anonportmin
; /* minimum ephemeral port */
322 extern int ip6_anonportmax
; /* maximum ephemeral port */
323 extern int ip6_lowportmin
; /* minimum reserved port */
324 extern int ip6_lowportmax
; /* maximum reserved port */
326 extern int ip6_use_tempaddr
; /* whether to use temporary addresses. */
328 extern struct pr_usrreqs rip6_usrreqs
;
329 extern struct pr_usrreqs icmp6_dgram_usrreqs
;
334 int icmp6_ctloutput(struct socket
*, struct sockopt
*);
335 int icmp6_dgram_ctloutput(struct socket
*, struct sockopt
*);
336 int icmp6_dgram_send(struct socket
*, int , struct mbuf
*, struct sockaddr
*, struct mbuf
*, struct proc
*);
337 int icmp6_dgram_attach(struct socket
*, int , struct proc
*);
342 void ip6_input(struct mbuf
*);
343 struct in6_ifaddr
*ip6_getdstifaddr(struct mbuf
*);
344 void ip6_freepcbopts(struct ip6_pktopts
*);
345 void ip6_freemoptions(struct ip6_moptions
*);
346 int ip6_unknown_opt(u_int8_t
*, struct mbuf
*, int, int);
347 char * ip6_get_prevhdr(struct mbuf
*, int);
348 int ip6_nexthdr(struct mbuf
*, int, int, int *);
349 int ip6_lasthdr(struct mbuf
*, int, int, int *);
351 struct ip6aux
*ip6_addaux(struct mbuf
*);
352 struct ip6aux
*ip6_findaux(struct mbuf
*);
353 void ip6_delaux(struct mbuf
*);
355 int ip6_mforward(struct ip6_hdr
*, struct ifnet
*, struct mbuf
*);
356 int ip6_process_hopopts(struct mbuf
*, u_int8_t
*, int, u_int32_t
*,
358 void ip6_savecontrol(struct inpcb
*, struct mbuf
**, struct ip6_hdr
*,
360 void ip6_forward(struct mbuf
*, struct route_in6
*, int, int);
362 void ip6_mloopback(struct ifnet
*, struct mbuf
*, struct sockaddr_in6
*);
363 int ip6_output(struct mbuf
*, struct ip6_pktopts
*,
366 struct ip6_moptions
*, struct ifnet
**, int locked
);
367 int ip6_ctloutput(struct socket
*, struct sockopt
*sopt
);
368 void ip6_initpktopts(struct ip6_pktopts
*);
369 int ip6_setpktoptions(struct mbuf
*, struct ip6_pktopts
*, int, int);
370 void ip6_clearpktopts(struct ip6_pktopts
*, int, int);
371 struct ip6_pktopts
*ip6_copypktopts(struct ip6_pktopts
*, int);
372 int ip6_optlen(struct inpcb
*);
374 int route6_input(struct mbuf
**, int *);
376 void frag6_init(void);
377 int frag6_input(struct mbuf
**, int *);
378 void frag6_slowtimo(void);
379 void frag6_drain(void);
381 int rip6_input(struct mbuf
**mp
, int *offset
);
382 void rip6_ctlinput(int, struct sockaddr
*, void *);
383 int rip6_ctloutput(struct socket
*so
, struct sockopt
*sopt
);
384 int rip6_output(struct mbuf
*, struct socket
*, struct sockaddr_in6
*, struct mbuf
*);
386 int dest6_input(struct mbuf
**, int *);
388 #endif /* KERNEL_PRIVATE */
390 #endif /* !_NETINET6_IP6_VAR_H_ */