]> git.saurik.com Git - apple/xnu.git/blame - bsd/netinet6/ip6_var.h
xnu-201.42.3.tar.gz
[apple/xnu.git] / bsd / netinet6 / ip6_var.h
CommitLineData
1c79356b
A
1/* $KAME: ip6_var.h,v 1.31 2000/04/04 08:48:26 itojun Exp $ */
2
3/*
4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
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.
18 *
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
29 * SUCH DAMAGE.
30 */
31
32/*
33 * Copyright (c) 1982, 1986, 1993
34 * The Regents of the University of California. All rights reserved.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
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.
51 *
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
62 * SUCH DAMAGE.
63 *
64 * @(#)ip_var.h 8.1 (Berkeley) 6/10/93
65 */
66
67#ifndef _NETINET6_IP6_VAR_H_
68#define _NETINET6_IP6_VAR_H_
69
70/*
71 * IP6 reassembly queue structure. Each fragment
72 * being reassembled is attached to one of these structures.
73 */
74struct ip6q {
75 u_int32_t ip6q_head;
76 u_int16_t ip6q_len;
77 u_int8_t ip6q_nxt; /* ip6f_nxt in first fragment */
78 u_int8_t ip6q_hlim;
79 struct ip6asfrag *ip6q_down;
80 struct ip6asfrag *ip6q_up;
81 u_int32_t ip6q_ident;
82 u_int8_t ip6q_arrive;
83 u_int8_t ip6q_ttl;
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 */
88#if notyet
89 u_char *ip6q_nxtp;
90#endif
91};
92
93struct ip6asfrag {
94 u_int32_t ip6af_head;
95 u_int16_t ip6af_len;
96 u_int8_t ip6af_nxt;
97 u_int8_t ip6af_hlim;
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 */
106};
107
108#define IP6_REASS_MBUF(ip6af) (*(struct mbuf **)&((ip6af)->ip6af_m))
109
110struct 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;
115};
116
117/*
118 * Control options for outgoing packets
119 */
120
121/* Routing header related info */
122struct ip6po_rhinfo {
123 struct ip6_rthdr *ip6po_rhi_rthdr; /* Routing header */
124 struct route_in6 ip6po_rhi_route; /* Route to the 1st hop */
125};
126#define ip6po_rthdr ip6po_rhinfo.ip6po_rhi_rthdr
127#define ip6po_route ip6po_rhinfo.ip6po_rhi_route
128
129struct ip6_pktopts {
130 int ip6po_hlim; /* Hoplimit for outgoing packets */
131
132 /* Outgoing IF/address information */
133 struct in6_pktinfo *ip6po_pktinfo;
134
135 struct sockaddr *ip6po_nexthop; /* Next-hop address */
136
137 struct ip6_hbh *ip6po_hbh; /* Hop-by-Hop options header */
138
139 /* Destination options header (before a routing header) */
140 struct ip6_dest *ip6po_dest1;
141
142 /* Routing header related info. */
143 struct ip6po_rhinfo ip6po_rhinfo;
144
145 /* Destination options header (after a routing header) */
146 struct ip6_dest *ip6po_dest2;
147
148 int ip6po_flags;
149#define IP6PO_REACHCONF 0x01 /* upper-layer reachability confirmation */
150#define IP6PO_MINMTU 0x02 /* use minimum MTU (IPV6_USE_MIN_MTU) */
151};
152
153/*
154 * Control options for incoming packets
155 */
156
157struct ip6_recvpktopts {
158 struct mbuf *head; /* mbuf chain of data passed to a user */
159
160#ifdef SO_TIMESTAMP
161 struct mbuf *timestamp; /* timestamp */
162#endif
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 */
169};
170
171struct ip6stat {
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 */
217
218 /*
219 * statistics for improvement of the source address selection
220 * algorithm:
221 * XXX: hardcoded 16 = # of ip6 multicast scope types + 1
222 */
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];
229 /*
230 * number of times that an address that has the same scope
231 * from the destination is chosen.
232 */
233 u_quad_t ip6s_sources_samescope[16];
234 /*
235 * number of times that an address that has a different scope
236 * from the destination is chosen.
237 */
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];
241};
242
243#if KERNEL
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) */
248
249extern struct ip6stat ip6stat; /* statistics */
250extern u_int32_t ip6_id; /* fragment identifier */
251extern int ip6_defhlim; /* default hop limit */
252extern int ip6_defmcasthlim; /* default multicast hop limit */
253extern int ip6_forwarding; /* act as router? */
254extern int ip6_forward_srcrt; /* forward src-routed? */
255extern int ip6_gif_hlim; /* Hop limit for gif encap packet */
256extern int ip6_use_deprecated; /* allow deprecated addr as source */
257extern int ip6_rr_prune; /* router renumbering prefix
258 * walk list every 5 sec. */
259#if INET6
260extern int ip6_mapped_addr_on;
261#endif
262#if defined(__NetBSD__) && !defined(INET6_BINDV6ONLY)
263extern int ip6_bindv6only;
264#endif
265
266extern struct socket *ip6_mrouter; /* multicast routing daemon */
267extern int ip6_sendredirects; /* send IP redirects when forwarding? */
268extern int ip6_maxfragpackets; /* Maximum packets in reassembly queue */
269extern int ip6_sourcecheck; /* Verify source interface */
270extern int ip6_sourcecheck_interval; /* Interval between log messages */
271extern int ip6_accept_rtadv; /* Acts as a host not a router */
272extern int ip6_keepfaith; /* Firewall Aided Internet Translator */
273extern int ip6_log_interval;
274extern time_t ip6_log_time;
275extern int ip6_hdrnestlimit; /* upper limit of # of extension headers */
276extern int ip6_dad_count; /* DupAddrDetectionTransmits */
277
278extern u_int32_t ip6_flow_seq;
279extern int ip6_auto_flowlabel;
280
281#if !defined(__APPLE__)
282//#if !defined(__FreeBSD__) || __FreeBSD__ < 3
283struct in6pcb;
284#endif
285#if defined(__FreeBSD__) && __FreeBSD__ >= 3 || defined (__APPLE__)
286extern struct pr_usrreqs rip6_usrreqs;
287
288struct inpcb;
289struct sockopt;
290#endif
291
292#if (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined (__APPLE__)
293int icmp6_ctloutput __P((struct socket *, struct sockopt *sopt));
294#else
295int icmp6_ctloutput __P((int, struct socket *, int, int, struct mbuf **));
296#endif
297
298void ip6_init __P((void));
299void ip6intr __P((void));
300void ip6_input __P((struct mbuf *));
301void ip6_freepcbopts __P((struct ip6_pktopts *));
302void ip6_freemoptions __P((struct ip6_moptions *));
303int ip6_unknown_opt __P((u_int8_t *, struct mbuf *, int));
304char * ip6_get_prevhdr __P((struct mbuf *, int));
305int ip6_nexthdr __P((struct mbuf *, int, int, int *));
306int ip6_lasthdr __P((struct mbuf *, int, int, int *));
307int ip6_mforward __P((struct ip6_hdr *, struct ifnet *, struct mbuf *));
308int ip6_process_hopopts __P((struct mbuf *, u_int8_t *, int, u_int32_t *,
309 u_int32_t *));
310#if defined(__FreeBSD__) && __FreeBSD__ >= 3 || defined (__APPLE__)
311void ip6_savecontrol __P((struct inpcb *, struct ip6_hdr *, struct mbuf *,
312 struct ip6_recvpktopts *,
313 struct ip6_recvpktopts **));
314#else
315void ip6_savecontrol __P((struct in6pcb *, struct ip6_hdr *, struct mbuf *,
316 struct ip6_recvpktopts *,
317 struct ip6_recvpktopts **));
318#endif
319void ip6_update_recvpcbopt __P((struct ip6_recvpktopts *,
320 struct ip6_recvpktopts *));
321void ip6_reset_rcvopt __P((struct ip6_recvpktopts *, int));
322int ip6_sysctl __P((int *, u_int, void *, size_t *, void *, size_t));
323
324void ip6_forward __P((struct mbuf *, int));
325
326void ip6_mloopback __P((struct ifnet *, struct mbuf *, struct sockaddr_in6 *));
327int 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__)
331int ip6_ctloutput __P((struct socket *, struct sockopt *sopt));
332#else
333int ip6_ctloutput __P((int, struct socket *, int, int, struct mbuf **));
334#endif
335int ip6_setpktoptions __P((struct mbuf *, struct ip6_pktopts *, int, int));
336void ip6_clearpktopts __P((struct ip6_pktopts *, int, int));
337struct ip6_pktopts *ip6_copypktopts __P((struct ip6_pktopts *, int));
338#if defined(__FreeBSD__) && __FreeBSD__ >= 3 || defined (__APPLE__)
339int ip6_optlen __P((struct inpcb *));
340#else
341int ip6_optlen __P((struct in6pcb *));
342#endif
343
344int route6_input __P((struct mbuf **, int *, int));
345
346void frag6_init __P((void));
347int frag6_input __P((struct mbuf **, int *, int));
348void frag6_slowtimo __P((void));
349void frag6_drain __P((void));
350
351void rip6_init __P((void));
352int rip6_input __P((struct mbuf **mp, int *offp, int proto));
353void rip6_ctlinput __P((int, struct sockaddr *, void *));
354#if defined(__FreeBSD__) && __FreeBSD__ >= 3 || defined (__APPLE__)
355int rip6_ctloutput __P((struct socket *so, struct sockopt *sopt));
356#else
357int rip6_ctloutput __P((int, struct socket *, int, int, struct mbuf **));
358#endif
359int rip6_output __P((struct mbuf *, struct socket *, struct sockaddr_in6 *,
360 struct mbuf *));
361int rip6_usrreq __P((struct socket *,
362 int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *));
363
364int dest6_input __P((struct mbuf **, int *, int));
365int none_input __P((struct mbuf **, int *, int));
366#endif /* _KERNEL */
367
368#endif /* !_NETINET6_IP6_VAR_H_ */