1 |
27 |
unneback |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// src/sys/netinet6/in6_proto.c
|
4 |
|
|
//
|
5 |
|
|
//==========================================================================
|
6 |
|
|
//####BSDCOPYRIGHTBEGIN####
|
7 |
|
|
//
|
8 |
|
|
// -------------------------------------------
|
9 |
|
|
//
|
10 |
|
|
// Portions of this software may have been derived from OpenBSD,
|
11 |
|
|
// FreeBSD or other sources, and are covered by the appropriate
|
12 |
|
|
// copyright disclaimers included herein.
|
13 |
|
|
//
|
14 |
|
|
// Portions created by Red Hat are
|
15 |
|
|
// Copyright (C) 2002 Red Hat, Inc. All Rights Reserved.
|
16 |
|
|
//
|
17 |
|
|
// -------------------------------------------
|
18 |
|
|
//
|
19 |
|
|
//####BSDCOPYRIGHTEND####
|
20 |
|
|
//==========================================================================
|
21 |
|
|
|
22 |
|
|
/* $KAME: in6_proto.c,v 1.111 2001/12/21 03:32:34 itojun Exp $ */
|
23 |
|
|
|
24 |
|
|
/*
|
25 |
|
|
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
26 |
|
|
* All rights reserved.
|
27 |
|
|
*
|
28 |
|
|
* Redistribution and use in source and binary forms, with or without
|
29 |
|
|
* modification, are permitted provided that the following conditions
|
30 |
|
|
* are met:
|
31 |
|
|
* 1. Redistributions of source code must retain the above copyright
|
32 |
|
|
* notice, this list of conditions and the following disclaimer.
|
33 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
34 |
|
|
* notice, this list of conditions and the following disclaimer in the
|
35 |
|
|
* documentation and/or other materials provided with the distribution.
|
36 |
|
|
* 3. Neither the name of the project nor the names of its contributors
|
37 |
|
|
* may be used to endorse or promote products derived from this software
|
38 |
|
|
* without specific prior written permission.
|
39 |
|
|
*
|
40 |
|
|
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
41 |
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
42 |
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
43 |
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
44 |
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
45 |
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
46 |
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
47 |
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
48 |
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
49 |
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
50 |
|
|
* SUCH DAMAGE.
|
51 |
|
|
*/
|
52 |
|
|
|
53 |
|
|
/*
|
54 |
|
|
* Copyright (c) 1982, 1986, 1993
|
55 |
|
|
* The Regents of the University of California. All rights reserved.
|
56 |
|
|
*
|
57 |
|
|
* Redistribution and use in source and binary forms, with or without
|
58 |
|
|
* modification, are permitted provided that the following conditions
|
59 |
|
|
* are met:
|
60 |
|
|
* 1. Redistributions of source code must retain the above copyright
|
61 |
|
|
* notice, this list of conditions and the following disclaimer.
|
62 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
63 |
|
|
* notice, this list of conditions and the following disclaimer in the
|
64 |
|
|
* documentation and/or other materials provided with the distribution.
|
65 |
|
|
* 3. All advertising materials mentioning features or use of this software
|
66 |
|
|
* must display the following acknowledgement:
|
67 |
|
|
* This product includes software developed by the University of
|
68 |
|
|
* California, Berkeley and its contributors.
|
69 |
|
|
* 4. Neither the name of the University nor the names of its contributors
|
70 |
|
|
* may be used to endorse or promote products derived from this software
|
71 |
|
|
* without specific prior written permission.
|
72 |
|
|
*
|
73 |
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
74 |
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
75 |
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
76 |
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
77 |
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
78 |
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
79 |
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
80 |
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
81 |
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
82 |
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
83 |
|
|
* SUCH DAMAGE.
|
84 |
|
|
*
|
85 |
|
|
* @(#)in_proto.c 8.1 (Berkeley) 6/10/93
|
86 |
|
|
*/
|
87 |
|
|
|
88 |
|
|
#include <sys/param.h>
|
89 |
|
|
#include <sys/socket.h>
|
90 |
|
|
#include <sys/socketvar.h>
|
91 |
|
|
#include <sys/protosw.h>
|
92 |
|
|
#include <sys/domain.h>
|
93 |
|
|
#include <sys/mbuf.h>
|
94 |
|
|
|
95 |
|
|
#include <net/if.h>
|
96 |
|
|
#include <net/radix.h>
|
97 |
|
|
#ifdef RADIX_ART
|
98 |
|
|
#include <net/radix_art.h>
|
99 |
|
|
#elif defined(RADIX_MPATH)
|
100 |
|
|
#include <net/radix_mpath.h>
|
101 |
|
|
#endif
|
102 |
|
|
#include <net/route.h>
|
103 |
|
|
|
104 |
|
|
#include <netinet/in.h>
|
105 |
|
|
#include <netinet/in_systm.h>
|
106 |
|
|
#include <netinet/in_var.h>
|
107 |
|
|
#include <netinet/ip_encap.h>
|
108 |
|
|
#if (defined(__FreeBSD__) && __FreeBSD__ >= 3) || (defined(__NetBSD__) && !defined(TCP6)) || defined(__OpenBSD__) || (defined(__bsdi__) && _BSDI_VERSION >= 199802)
|
109 |
|
|
#include <netinet/ip.h>
|
110 |
|
|
#include <netinet/ip_var.h>
|
111 |
|
|
#endif
|
112 |
|
|
#if (defined(__NetBSD__) && !defined(TCP6)) || defined(__OpenBSD__) || (defined(__bsdi__) && _BSDI_VERSION >= 199802)
|
113 |
|
|
#include <netinet/in_pcb.h>
|
114 |
|
|
#endif
|
115 |
|
|
#include <netinet/ip6.h>
|
116 |
|
|
#include <netinet6/ip6_var.h>
|
117 |
|
|
#include <netinet/icmp6.h>
|
118 |
|
|
#if !(defined(__FreeBSD__) && __FreeBSD__ >= 3) && !defined(__OpenBSD__) && !(defined(__bsdi__) && _BSDI_VERSION >= 199802)
|
119 |
|
|
#include <netinet6/in6_pcb.h>
|
120 |
|
|
#endif
|
121 |
|
|
|
122 |
|
|
#if (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined(__OpenBSD__) || (defined(__bsdi__) && _BSDI_VERSION >= 199802)
|
123 |
|
|
#include <netinet/tcp.h>
|
124 |
|
|
#include <netinet/tcp_timer.h>
|
125 |
|
|
#include <netinet/tcp_var.h>
|
126 |
|
|
#include <netinet/udp.h>
|
127 |
|
|
#include <netinet/udp_var.h>
|
128 |
|
|
#if (defined(__FreeBSD__) && __FreeBSD__ >= 4)
|
129 |
|
|
#include <netinet6/tcp6_var.h>
|
130 |
|
|
#endif
|
131 |
|
|
#else
|
132 |
|
|
#if defined(__NetBSD__) && !defined(TCP6)
|
133 |
|
|
#include <netinet/tcp.h>
|
134 |
|
|
#include <netinet/tcp_fsm.h>
|
135 |
|
|
#include <netinet/tcp_seq.h>
|
136 |
|
|
#include <netinet/tcp_timer.h>
|
137 |
|
|
#include <netinet/tcp_var.h>
|
138 |
|
|
#include <netinet/tcpip.h>
|
139 |
|
|
#include <netinet/tcp_debug.h>
|
140 |
|
|
#else
|
141 |
|
|
#include <netinet6/tcp6.h>
|
142 |
|
|
#include <netinet6/tcp6_fsm.h>
|
143 |
|
|
#include <netinet6/tcp6_seq.h>
|
144 |
|
|
#include <netinet6/tcp6_timer.h>
|
145 |
|
|
#include <netinet6/tcp6_var.h>
|
146 |
|
|
#endif
|
147 |
|
|
#endif
|
148 |
|
|
|
149 |
|
|
#ifdef __FreeBSD__
|
150 |
|
|
#include <netinet6/raw_ip6.h>
|
151 |
|
|
#endif
|
152 |
|
|
|
153 |
|
|
#if !defined(__OpenBSD__) && !(defined(__bsdi__) && _BSDI_VERSION >= 199802)
|
154 |
|
|
#if !(defined(__FreeBSD__) && __FreeBSD__ >= 4)
|
155 |
|
|
#include <netinet6/udp6.h>
|
156 |
|
|
#endif
|
157 |
|
|
#include <netinet6/udp6_var.h>
|
158 |
|
|
#endif
|
159 |
|
|
|
160 |
|
|
#include <netinet6/pim6_var.h>
|
161 |
|
|
|
162 |
|
|
#include <netinet6/nd6.h>
|
163 |
|
|
|
164 |
|
|
#ifdef IPSEC
|
165 |
|
|
#ifdef __OpenBSD__
|
166 |
|
|
#include <netinet/ip_ipsp.h>
|
167 |
|
|
#include <netinet/ip_ah.h>
|
168 |
|
|
#include <netinet/ip_esp.h>
|
169 |
|
|
#include <netinet/ip_ipip.h>
|
170 |
|
|
#else
|
171 |
|
|
#include <netinet6/ipsec.h>
|
172 |
|
|
#include <netinet6/ah.h>
|
173 |
|
|
#ifdef IPSEC_ESP
|
174 |
|
|
#include <netinet6/esp.h>
|
175 |
|
|
#endif
|
176 |
|
|
#include <netinet6/ipcomp.h>
|
177 |
|
|
#endif
|
178 |
|
|
#endif /* IPSEC */
|
179 |
|
|
|
180 |
|
|
#include <netinet6/ip6protosw.h>
|
181 |
|
|
|
182 |
|
|
#ifdef MIP6
|
183 |
|
|
#include <netinet6/mip6.h>
|
184 |
|
|
#endif /* MIP6 */
|
185 |
|
|
|
186 |
|
|
#ifndef offsetof
|
187 |
|
|
#define offsetof(type, member) ((size_t)(&((type *)0)->member))
|
188 |
|
|
#endif
|
189 |
|
|
|
190 |
|
|
/*
|
191 |
|
|
* TCP/IP protocol family: IP6, ICMP6, UDP, TCP.
|
192 |
|
|
*/
|
193 |
|
|
|
194 |
|
|
extern struct domain inet6domain;
|
195 |
|
|
#if defined(__FreeBSD__) && __FreeBSD__ >= 3
|
196 |
|
|
static struct pr_usrreqs nousrreqs;
|
197 |
|
|
#endif
|
198 |
|
|
|
199 |
|
|
#ifndef __NetBSD__
|
200 |
|
|
#define PR_LISTEN 0
|
201 |
|
|
#endif
|
202 |
|
|
#if !defined(__NetBSD__) && !defined(__OpenBSD__)
|
203 |
|
|
#define PR_ABRTACPTDIS 0
|
204 |
|
|
#endif
|
205 |
|
|
#ifdef __OpenBSD__
|
206 |
|
|
#define PR_LASTHDR 0
|
207 |
|
|
#endif
|
208 |
|
|
|
209 |
|
|
struct ip6protosw inet6sw[] = {
|
210 |
|
|
{ 0, &inet6domain, IPPROTO_IPV6, 0,
|
211 |
|
|
0, 0, 0, 0,
|
212 |
|
|
0,
|
213 |
|
|
ip6_init, 0, frag6_slowtimo, frag6_drain,
|
214 |
|
|
#ifndef __FreeBSD__
|
215 |
|
|
ip6_sysctl,
|
216 |
|
|
#else
|
217 |
|
|
# if __FreeBSD__ >= 3
|
218 |
|
|
&nousrreqs,
|
219 |
|
|
# endif
|
220 |
|
|
#endif
|
221 |
|
|
},
|
222 |
|
|
{ SOCK_DGRAM, &inet6domain, IPPROTO_UDP, PR_ATOMIC|PR_ADDR,
|
223 |
|
|
udp6_input, 0, udp6_ctlinput, ip6_ctloutput,
|
224 |
|
|
#if defined(__FreeBSD__) && __FreeBSD__ >= 3
|
225 |
|
|
0, 0,
|
226 |
|
|
#elif defined(HAVE_NRL_INPCB)
|
227 |
|
|
udp6_usrreq, 0,
|
228 |
|
|
#else
|
229 |
|
|
udp6_usrreq, udp6_init,
|
230 |
|
|
#endif
|
231 |
|
|
0, 0, 0,
|
232 |
|
|
#ifndef __FreeBSD__
|
233 |
|
|
#ifdef HAVE_NRL_INPCB
|
234 |
|
|
udp_sysctl,
|
235 |
|
|
#else
|
236 |
|
|
udp6_sysctl,
|
237 |
|
|
#endif
|
238 |
|
|
#else
|
239 |
|
|
# if __FreeBSD__ >= 3
|
240 |
|
|
&udp6_usrreqs,
|
241 |
|
|
# endif
|
242 |
|
|
#endif
|
243 |
|
|
},
|
244 |
|
|
#ifdef TCP6
|
245 |
|
|
{ SOCK_STREAM, &inet6domain, IPPROTO_TCP, PR_CONNREQUIRED|PR_WANTRCVD|PR_LISTEN|PR_ABRTACPTDIS,
|
246 |
|
|
tcp6_input, 0, tcp6_ctlinput, tcp6_ctloutput,
|
247 |
|
|
tcp6_usrreq,
|
248 |
|
|
tcp6_init, tcp6_fasttimo, tcp6_slowtimo, tcp6_drain,
|
249 |
|
|
#ifndef __FreeBSD__
|
250 |
|
|
tcp6_sysctl,
|
251 |
|
|
#else
|
252 |
|
|
# if __FreeBSD__ >= 3
|
253 |
|
|
&tcp6_usrreqs,
|
254 |
|
|
# endif
|
255 |
|
|
#endif
|
256 |
|
|
},
|
257 |
|
|
#else
|
258 |
|
|
{ SOCK_STREAM, &inet6domain, IPPROTO_TCP, PR_CONNREQUIRED|PR_WANTRCVD|PR_LISTEN,
|
259 |
|
|
tcp6_input, 0, tcp6_ctlinput, tcp_ctloutput,
|
260 |
|
|
#if defined(__FreeBSD__) && __FreeBSD__ >= 3
|
261 |
|
|
0,
|
262 |
|
|
#elif defined(HAVE_NRL_INPCB)
|
263 |
|
|
tcp6_usrreq,
|
264 |
|
|
#else
|
265 |
|
|
tcp_usrreq,
|
266 |
|
|
#endif
|
267 |
|
|
#ifdef INET /* don't call initialization and timeout routines twice */
|
268 |
|
|
0, 0, 0, tcp_drain,
|
269 |
|
|
#else
|
270 |
|
|
tcp_init, tcp_fasttimo, tcp_slowtimo, tcp_drain,
|
271 |
|
|
#endif
|
272 |
|
|
#ifndef __FreeBSD__
|
273 |
|
|
tcp_sysctl,
|
274 |
|
|
#else
|
275 |
|
|
# if __FreeBSD__ >= 3
|
276 |
|
|
&tcp6_usrreqs,
|
277 |
|
|
# endif
|
278 |
|
|
#endif
|
279 |
|
|
},
|
280 |
|
|
#endif /* TCP6 */
|
281 |
|
|
{ SOCK_RAW, &inet6domain, IPPROTO_RAW, PR_ATOMIC|PR_ADDR,
|
282 |
|
|
rip6_input, rip6_output, rip6_ctlinput, rip6_ctloutput,
|
283 |
|
|
#if defined(__FreeBSD__) && __FreeBSD__ >= 3
|
284 |
|
|
0,
|
285 |
|
|
#else
|
286 |
|
|
rip6_usrreq,
|
287 |
|
|
#endif
|
288 |
|
|
0, 0, 0, 0,
|
289 |
|
|
#if defined(__FreeBSD__) && __FreeBSD__ >= 3
|
290 |
|
|
&rip6_usrreqs
|
291 |
|
|
#endif
|
292 |
|
|
},
|
293 |
|
|
{ SOCK_RAW, &inet6domain, IPPROTO_ICMPV6, PR_ATOMIC|PR_ADDR|PR_LASTHDR,
|
294 |
|
|
icmp6_input, rip6_output, rip6_ctlinput, rip6_ctloutput,
|
295 |
|
|
#if defined(__FreeBSD__) && __FreeBSD__ >= 3
|
296 |
|
|
0,
|
297 |
|
|
#else
|
298 |
|
|
rip6_usrreq,
|
299 |
|
|
#endif
|
300 |
|
|
icmp6_init, icmp6_fasttimo, 0, 0,
|
301 |
|
|
#ifndef __FreeBSD__
|
302 |
|
|
icmp6_sysctl,
|
303 |
|
|
#else
|
304 |
|
|
# if __FreeBSD__ >= 3
|
305 |
|
|
&rip6_usrreqs
|
306 |
|
|
# endif
|
307 |
|
|
#endif
|
308 |
|
|
},
|
309 |
|
|
{ SOCK_RAW, &inet6domain, IPPROTO_DSTOPTS,PR_ATOMIC|PR_ADDR,
|
310 |
|
|
dest6_input, 0, 0, 0,
|
311 |
|
|
0,
|
312 |
|
|
0, 0, 0, 0,
|
313 |
|
|
#if defined(__FreeBSD__) && __FreeBSD__ >= 3
|
314 |
|
|
&nousrreqs
|
315 |
|
|
#endif
|
316 |
|
|
},
|
317 |
|
|
{ SOCK_RAW, &inet6domain, IPPROTO_ROUTING,PR_ATOMIC|PR_ADDR,
|
318 |
|
|
route6_input, 0, 0, 0,
|
319 |
|
|
0,
|
320 |
|
|
0, 0, 0, 0,
|
321 |
|
|
#if defined(__FreeBSD__) && __FreeBSD__ >= 3
|
322 |
|
|
&nousrreqs
|
323 |
|
|
#endif
|
324 |
|
|
},
|
325 |
|
|
{ SOCK_RAW, &inet6domain, IPPROTO_FRAGMENT,PR_ATOMIC|PR_ADDR,
|
326 |
|
|
frag6_input, 0, 0, 0,
|
327 |
|
|
0,
|
328 |
|
|
0, 0, 0, 0,
|
329 |
|
|
#if defined(__FreeBSD__) && __FreeBSD__ >= 3
|
330 |
|
|
&nousrreqs
|
331 |
|
|
#endif
|
332 |
|
|
},
|
333 |
|
|
#ifdef IPSEC
|
334 |
|
|
{ SOCK_RAW, &inet6domain, IPPROTO_AH, PR_ATOMIC|PR_ADDR,
|
335 |
|
|
ah6_input, 0,
|
336 |
|
|
#ifdef __NetBSD__
|
337 |
|
|
ah6_ctlinput,
|
338 |
|
|
#else
|
339 |
|
|
0,
|
340 |
|
|
#endif
|
341 |
|
|
0,
|
342 |
|
|
0,
|
343 |
|
|
0, 0, 0, 0,
|
344 |
|
|
#ifdef __OpenBSD__
|
345 |
|
|
ah_sysctl,
|
346 |
|
|
#elif !defined(__FreeBSD__)
|
347 |
|
|
ipsec6_sysctl,
|
348 |
|
|
#else
|
349 |
|
|
# if __FreeBSD__ >= 3
|
350 |
|
|
&nousrreqs,
|
351 |
|
|
# endif
|
352 |
|
|
#endif
|
353 |
|
|
},
|
354 |
|
|
#ifdef IPSEC_ESP
|
355 |
|
|
{ SOCK_RAW, &inet6domain, IPPROTO_ESP, PR_ATOMIC|PR_ADDR,
|
356 |
|
|
esp6_input, 0,
|
357 |
|
|
esp6_ctlinput,
|
358 |
|
|
0,
|
359 |
|
|
0,
|
360 |
|
|
0, 0, 0, 0,
|
361 |
|
|
#ifdef __OpenBSD__
|
362 |
|
|
esp_sysctl,
|
363 |
|
|
#elif !defined(__FreeBSD__)
|
364 |
|
|
ipsec6_sysctl,
|
365 |
|
|
#else
|
366 |
|
|
# if __FreeBSD__ >= 3
|
367 |
|
|
&nousrreqs,
|
368 |
|
|
# endif
|
369 |
|
|
#endif
|
370 |
|
|
},
|
371 |
|
|
#endif
|
372 |
|
|
#ifndef __OpenBSD__
|
373 |
|
|
{ SOCK_RAW, &inet6domain, IPPROTO_IPCOMP, PR_ATOMIC|PR_ADDR,
|
374 |
|
|
ipcomp6_input, 0, 0, 0,
|
375 |
|
|
0,
|
376 |
|
|
0, 0, 0, 0,
|
377 |
|
|
#ifndef __FreeBSD__
|
378 |
|
|
ipsec6_sysctl,
|
379 |
|
|
#else
|
380 |
|
|
# if __FreeBSD__ >= 3
|
381 |
|
|
&nousrreqs,
|
382 |
|
|
# endif
|
383 |
|
|
#endif
|
384 |
|
|
},
|
385 |
|
|
#endif /* !OpenBSD */
|
386 |
|
|
#endif /* IPSEC */
|
387 |
|
|
#ifdef INET
|
388 |
|
|
{ SOCK_RAW, &inet6domain, IPPROTO_IPV4, PR_ATOMIC|PR_ADDR|PR_LASTHDR,
|
389 |
|
|
encap6_input, rip6_output, encap6_ctlinput, rip6_ctloutput,
|
390 |
|
|
#if defined(__FreeBSD__) && __FreeBSD__ >= 3
|
391 |
|
|
0,
|
392 |
|
|
#else
|
393 |
|
|
rip6_usrreq,
|
394 |
|
|
#endif
|
395 |
|
|
encap_init, 0, 0, 0,
|
396 |
|
|
#if defined(__FreeBSD__) && __FreeBSD__ >= 3
|
397 |
|
|
&rip6_usrreqs
|
398 |
|
|
#endif
|
399 |
|
|
},
|
400 |
|
|
#endif /* INET */
|
401 |
|
|
{ SOCK_RAW, &inet6domain, IPPROTO_IPV6, PR_ATOMIC|PR_ADDR|PR_LASTHDR,
|
402 |
|
|
encap6_input, rip6_output, encap6_ctlinput, rip6_ctloutput,
|
403 |
|
|
#if defined(__FreeBSD__) && __FreeBSD__ >= 3
|
404 |
|
|
0,
|
405 |
|
|
#else
|
406 |
|
|
rip6_usrreq,
|
407 |
|
|
#endif
|
408 |
|
|
encap_init, 0, 0, 0,
|
409 |
|
|
#if defined(__FreeBSD__) && __FreeBSD__ >= 3
|
410 |
|
|
&rip6_usrreqs
|
411 |
|
|
#endif
|
412 |
|
|
},
|
413 |
|
|
#if defined(__NetBSD__) && defined(ISO)
|
414 |
|
|
{ SOCK_RAW, &inet6domain, IPPROTO_EON, PR_ATOMIC|PR_ADDR|PR_LASTHDR,
|
415 |
|
|
encap6_input, rip6_output, encap6_ctlinput, rip6_ctloutput,
|
416 |
|
|
rip6_usrreq, /* XXX */
|
417 |
|
|
encap_init, 0, 0, 0,
|
418 |
|
|
},
|
419 |
|
|
#endif
|
420 |
|
|
{ SOCK_RAW, &inet6domain, IPPROTO_PIM, PR_ATOMIC|PR_ADDR|PR_LASTHDR,
|
421 |
|
|
pim6_input, rip6_output, 0, rip6_ctloutput,
|
422 |
|
|
#if defined(__FreeBSD__) && __FreeBSD__ >= 3
|
423 |
|
|
0,
|
424 |
|
|
#else
|
425 |
|
|
rip6_usrreq,
|
426 |
|
|
#endif
|
427 |
|
|
0, 0, 0, 0,
|
428 |
|
|
#if defined(__FreeBSD__) && __FreeBSD__ >= 3
|
429 |
|
|
&rip6_usrreqs
|
430 |
|
|
# endif
|
431 |
|
|
},
|
432 |
|
|
/* raw wildcard */
|
433 |
|
|
{ SOCK_RAW, &inet6domain, 0, PR_ATOMIC|PR_ADDR,
|
434 |
|
|
rip6_input, rip6_output, 0, rip6_ctloutput,
|
435 |
|
|
#if defined(__FreeBSD__) && __FreeBSD__ >= 3
|
436 |
|
|
0, 0,
|
437 |
|
|
#else
|
438 |
|
|
rip6_usrreq, rip6_init,
|
439 |
|
|
#endif
|
440 |
|
|
0, 0, 0,
|
441 |
|
|
#if defined(__FreeBSD__) && __FreeBSD__ >= 3
|
442 |
|
|
&rip6_usrreqs
|
443 |
|
|
#endif
|
444 |
|
|
},
|
445 |
|
|
};
|
446 |
|
|
|
447 |
|
|
#ifdef MIP6
|
448 |
|
|
struct ip6protosw mip6_tunnel_protosw =
|
449 |
|
|
{ SOCK_RAW, &inet6domain, IPPROTO_IPV6, PR_ATOMIC|PR_ADDR,
|
450 |
|
|
mip6_tunnel_input, rip6_output, 0, rip6_ctloutput,
|
451 |
|
|
#if defined(__FreeBSD__) && __FreeBSD__ >= 3
|
452 |
|
|
0,
|
453 |
|
|
#else
|
454 |
|
|
rip6_usrreq,
|
455 |
|
|
#endif
|
456 |
|
|
0, 0, 0, 0,
|
457 |
|
|
#if defined(__FreeBSD__) && __FreeBSD__ >= 3
|
458 |
|
|
&rip6_usrreqs
|
459 |
|
|
#endif
|
460 |
|
|
};
|
461 |
|
|
#endif /* MIP6 */
|
462 |
|
|
|
463 |
|
|
#ifdef __FreeBSD__
|
464 |
|
|
extern int in6_inithead __P((void **, int));
|
465 |
|
|
#endif
|
466 |
|
|
|
467 |
|
|
struct domain inet6domain =
|
468 |
|
|
{ AF_INET6, "internet6", 0, 0, 0,
|
469 |
|
|
(struct protosw *)inet6sw,
|
470 |
|
|
(struct protosw *)&inet6sw[sizeof(inet6sw)/sizeof(inet6sw[0])], 0,
|
471 |
|
|
#ifdef __FreeBSD__
|
472 |
|
|
in6_inithead,
|
473 |
|
|
#else
|
474 |
|
|
#ifdef RADIX_ART
|
475 |
|
|
rn_art_inithead,
|
476 |
|
|
#elif defined(RADIX_MPATH)
|
477 |
|
|
rn_mpath_inithead,
|
478 |
|
|
#else
|
479 |
|
|
rn_inithead,
|
480 |
|
|
#endif
|
481 |
|
|
#endif
|
482 |
|
|
offsetof(struct sockaddr_in6, sin6_addr) << 3,
|
483 |
|
|
sizeof(struct sockaddr_in6) };
|
484 |
|
|
|
485 |
|
|
#ifdef __FreeBSD__
|
486 |
|
|
DOMAIN_SET(inet6);
|
487 |
|
|
#endif
|
488 |
|
|
|
489 |
|
|
/*
|
490 |
|
|
* Internet configuration info
|
491 |
|
|
*/
|
492 |
|
|
#ifndef IPV6FORWARDING
|
493 |
|
|
#ifdef GATEWAY6
|
494 |
|
|
#define IPV6FORWARDING 1 /* forward IP6 packets not for us */
|
495 |
|
|
#else
|
496 |
|
|
#define IPV6FORWARDING 0 /* don't forward IP6 packets not for us */
|
497 |
|
|
#endif /* GATEWAY6 */
|
498 |
|
|
#endif /* !IPV6FORWARDING */
|
499 |
|
|
|
500 |
|
|
#ifndef IPV6_SENDREDIRECTS
|
501 |
|
|
#define IPV6_SENDREDIRECTS 1
|
502 |
|
|
#endif
|
503 |
|
|
|
504 |
|
|
int ip6_forwarding = IPV6FORWARDING; /* act as router? */
|
505 |
|
|
int ip6_sendredirects = IPV6_SENDREDIRECTS;
|
506 |
|
|
int ip6_defhlim = IPV6_DEFHLIM;
|
507 |
|
|
int ip6_defmcasthlim = IPV6_DEFAULT_MULTICAST_HOPS;
|
508 |
|
|
int ip6_accept_rtadv = 1; // was 0; /* "IPV6FORWARDING ? 0 : 1" is dangerous */
|
509 |
|
|
#if defined(__FreeBSD__) && __FreeBSD__ >= 4
|
510 |
|
|
int ip6_maxfragpackets; /* initialized in frag6.c:frag6_init() */
|
511 |
|
|
#else
|
512 |
|
|
int ip6_maxfragpackets = 200;
|
513 |
|
|
#endif
|
514 |
|
|
int ip6_log_interval = 5;
|
515 |
|
|
int ip6_hdrnestlimit = 50; /* appropriate? */
|
516 |
|
|
int ip6_dad_count = 1; /* DupAddrDetectionTransmits */
|
517 |
|
|
u_int32_t ip6_flow_seq;
|
518 |
|
|
int ip6_auto_flowlabel = 1;
|
519 |
|
|
int ip6_use_deprecated = 1; /* allow deprecated addr (RFC2462 5.5.4) */
|
520 |
|
|
int ip6_rr_prune = 5; /* router renumbering prefix
|
521 |
|
|
* walk list every 5 sec. */
|
522 |
|
|
#if defined(__NetBSD__)
|
523 |
|
|
int ip6_v6only = 1;
|
524 |
|
|
#elif defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD__ == 2) || (defined(__bsdi__) && _BSDI_VERSION < 199802) || defined(TCP6)
|
525 |
|
|
const int ip6_v6only = 1;
|
526 |
|
|
#else
|
527 |
|
|
int ip6_v6only = 0;
|
528 |
|
|
#endif
|
529 |
|
|
|
530 |
|
|
u_int32_t ip6_id = 0UL;
|
531 |
|
|
int ip6_keepfaith = 0;
|
532 |
|
|
time_t ip6_log_time = (time_t)0L;
|
533 |
|
|
|
534 |
|
|
/* icmp6 */
|
535 |
|
|
#ifndef __bsdi__
|
536 |
|
|
/*
|
537 |
|
|
* BSDI4 defines these variables in in_proto.c...
|
538 |
|
|
* XXX: what if we don't define INET? Should we define pmtu6_expire
|
539 |
|
|
* or so? (jinmei@kame.net 19990310)
|
540 |
|
|
*/
|
541 |
|
|
int pmtu_expire = 60*10;
|
542 |
|
|
int pmtu_probe = 60*2;
|
543 |
|
|
#endif
|
544 |
|
|
|
545 |
|
|
/* raw IP6 parameters */
|
546 |
|
|
/*
|
547 |
|
|
* Nominal space allocated to a raw ip socket.
|
548 |
|
|
*/
|
549 |
|
|
#define RIPV6SNDQ 8192
|
550 |
|
|
#define RIPV6RCVQ 8192
|
551 |
|
|
|
552 |
|
|
u_long rip6_sendspace = RIPV6SNDQ;
|
553 |
|
|
u_long rip6_recvspace = RIPV6RCVQ;
|
554 |
|
|
|
555 |
|
|
/* ICMPV6 parameters */
|
556 |
|
|
int icmp6_rediraccept = 1; /* accept and process redirects */
|
557 |
|
|
int icmp6_redirtimeout = 10 * 60; /* 10 minutes */
|
558 |
|
|
int icmp6errppslim = 100; /* 100pps */
|
559 |
|
|
int icmp6_nodeinfo = 3; /* enable/disable NI response */
|
560 |
|
|
|
561 |
|
|
#ifdef TCP6
|
562 |
|
|
/* TCP on IP6 parameters */
|
563 |
|
|
int tcp6_sendspace = 1024 * 8;
|
564 |
|
|
int tcp6_recvspace = 1024 * 8;
|
565 |
|
|
int tcp6_mssdflt = TCP6_MSS;
|
566 |
|
|
int tcp6_rttdflt = TCP6TV_SRTTDFLT / PR_SLOWHZ;
|
567 |
|
|
int tcp6_do_rfc1323 = 1;
|
568 |
|
|
int tcp6_conntimeo = TCP6TV_KEEP_INIT; /* initial connection timeout */
|
569 |
|
|
int tcp6_43maxseg = 0;
|
570 |
|
|
int tcp6_pmtu = 0;
|
571 |
|
|
|
572 |
|
|
/*
|
573 |
|
|
* Parameters for keepalive option.
|
574 |
|
|
* Connections for which SO_KEEPALIVE is set will be probed
|
575 |
|
|
* after being idle for a time of tcp6_keepidle (in units of PR_SLOWHZ).
|
576 |
|
|
* Starting at that time, the connection is probed at intervals
|
577 |
|
|
* of tcp6_keepintvl (same units) until a response is received
|
578 |
|
|
* or until tcp6_keepcnt probes have been made, at which time
|
579 |
|
|
* the connection is dropped. Note that a tcp6_keepidle value
|
580 |
|
|
* under 2 hours is nonconformant with RFC-1122, Internet Host Requirements.
|
581 |
|
|
*/
|
582 |
|
|
int tcp6_keepidle = TCP6TV_KEEP_IDLE; /* time before probing idle */
|
583 |
|
|
int tcp6_keepintvl = TCP6TV_KEEPINTVL; /* interval betwn idle probes */
|
584 |
|
|
int tcp6_keepcnt = TCP6TV_KEEPCNT; /* max idle probes */
|
585 |
|
|
int tcp6_maxpersistidle = TCP6TV_KEEP_IDLE; /* max idle time in persist */
|
586 |
|
|
|
587 |
|
|
#ifndef INET_SERVER
|
588 |
|
|
#define TCP6_LISTEN_HASH_SIZE 17
|
589 |
|
|
#define TCP6_CONN_HASH_SIZE 97
|
590 |
|
|
#define TCP6_SYN_HASH_SIZE 293
|
591 |
|
|
#define TCP6_SYN_BUCKET_SIZE 35
|
592 |
|
|
#else
|
593 |
|
|
#define TCP6_LISTEN_HASH_SIZE 97
|
594 |
|
|
#define TCP6_CONN_HASH_SIZE 9973
|
595 |
|
|
#define TCP6_SYN_HASH_SIZE 997
|
596 |
|
|
#define TCP6_SYN_BUCKET_SIZE 35
|
597 |
|
|
#endif
|
598 |
|
|
int tcp6_listen_hash_size = TCP6_LISTEN_HASH_SIZE;
|
599 |
|
|
int tcp6_conn_hash_size = TCP6_CONN_HASH_SIZE;
|
600 |
|
|
struct tcp6_hash_list tcp6_listen_hash[TCP6_LISTEN_HASH_SIZE],
|
601 |
|
|
tcp6_conn_hash[TCP6_CONN_HASH_SIZE];
|
602 |
|
|
|
603 |
|
|
int tcp6_syn_cache_size = TCP6_SYN_HASH_SIZE;
|
604 |
|
|
int tcp6_syn_cache_limit = TCP6_SYN_HASH_SIZE*TCP6_SYN_BUCKET_SIZE;
|
605 |
|
|
int tcp6_syn_bucket_limit = 3*TCP6_SYN_BUCKET_SIZE;
|
606 |
|
|
struct syn_cache_head6 tcp6_syn_cache[TCP6_SYN_HASH_SIZE];
|
607 |
|
|
struct syn_cache_head6 *tcp6_syn_cache_first;
|
608 |
|
|
int tcp6_syn_cache_interval = 8; /* runs timer every 4 seconds */
|
609 |
|
|
int tcp6_syn_cache_timeo = TCP6TV_KEEP_INIT;
|
610 |
|
|
|
611 |
|
|
/*
|
612 |
|
|
* Parameters for computing a desirable data segment size
|
613 |
|
|
* given an upper bound (either interface MTU, or peer's MSS option)_.
|
614 |
|
|
* As applications tend to use a buffer size that is a multiple
|
615 |
|
|
* of kilobytes, try for something that divides evenly. However,
|
616 |
|
|
* do not round down too much.
|
617 |
|
|
*
|
618 |
|
|
* Round segment size down to a multiple of TCP6_ROUNDSIZE if this
|
619 |
|
|
* does not result in lowering by more than (size/TCP6_ROUNDFRAC).
|
620 |
|
|
* For example, round 536 to 512. Older versions of the system
|
621 |
|
|
* effectively used MCLBYTES (1K or 2K) as TCP6_ROUNDSIZE, with
|
622 |
|
|
* a value of 1 for TCP6_ROUNDFRAC (eliminating its effect).
|
623 |
|
|
* We round to a multiple of 256 for SLIP.
|
624 |
|
|
*/
|
625 |
|
|
#ifndef TCP6_ROUNDSIZE
|
626 |
|
|
#define TCP6_ROUNDSIZE 256 /* round to multiple of 256 */
|
627 |
|
|
#endif
|
628 |
|
|
#ifndef TCP6_ROUNDFRAC
|
629 |
|
|
#define TCP6_ROUNDFRAC 10 /* round down at most N/10, or 10% */
|
630 |
|
|
#endif
|
631 |
|
|
|
632 |
|
|
int tcp6_roundsize = TCP6_ROUNDSIZE;
|
633 |
|
|
int tcp6_roundfrac = TCP6_ROUNDFRAC;
|
634 |
|
|
#endif /* TCP6 */
|
635 |
|
|
|
636 |
|
|
/* UDP on IP6 parameters */
|
637 |
|
|
int udp6_sendspace = 9216; /* really max datagram size */
|
638 |
|
|
int udp6_recvspace = 40 * (1024 + sizeof(struct sockaddr_in6));
|
639 |
|
|
/* 40 1K datagrams */
|