]> git.karo-electronics.de Git - karo-tx-redboot.git/blob - packages/net/bsd_tcpip/v2_0/src/sys/netinet6/in6_proto.c
unified MX27, MX25, MX37 trees
[karo-tx-redboot.git] / packages / net / bsd_tcpip / v2_0 / src / sys / netinet6 / in6_proto.c
1 //==========================================================================
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 #include <sys/sysctl.h>
95
96 #include <net/if.h>
97 #include <net/radix.h>
98 #ifdef RADIX_ART
99 #include <net/radix_art.h>
100 #elif defined(RADIX_MPATH)
101 #include <net/radix_mpath.h>
102 #endif
103 #include <net/route.h>
104
105 #include <netinet/in.h>
106 #include <netinet/in_systm.h>
107 #include <netinet/in_var.h>
108 #include <netinet/ip_encap.h>
109 #if (defined(__FreeBSD__) && __FreeBSD__ >= 3) || (defined(__NetBSD__) && !defined(TCP6)) || defined(__OpenBSD__) || (defined(__bsdi__) && _BSDI_VERSION >= 199802)
110 #include <netinet/ip.h>
111 #include <netinet/ip_var.h>
112 #endif
113 #if (defined(__NetBSD__) && !defined(TCP6)) || defined(__OpenBSD__) || (defined(__bsdi__) && _BSDI_VERSION >= 199802)
114 #include <netinet/in_pcb.h>
115 #endif
116 #include <netinet/ip6.h>
117 #include <netinet6/ip6_var.h>
118 #include <netinet/icmp6.h>
119 #if !(defined(__FreeBSD__) && __FreeBSD__ >= 3) && !defined(__OpenBSD__) && !(defined(__bsdi__) && _BSDI_VERSION >= 199802)
120 #include <netinet6/in6_pcb.h>
121 #endif
122
123 #if (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined(__OpenBSD__) || (defined(__bsdi__) && _BSDI_VERSION >= 199802)
124 #include <netinet/tcp.h>
125 #include <netinet/tcp_timer.h>
126 #include <netinet/tcp_var.h>
127 #include <netinet/udp.h>
128 #include <netinet/udp_var.h>
129 #if (defined(__FreeBSD__) && __FreeBSD__ >= 4)
130 #include <netinet6/tcp6_var.h>
131 #endif
132 #else
133 #if defined(__NetBSD__) && !defined(TCP6)
134 #include <netinet/tcp.h>
135 #include <netinet/tcp_fsm.h>
136 #include <netinet/tcp_seq.h>
137 #include <netinet/tcp_timer.h>
138 #include <netinet/tcp_var.h>
139 #include <netinet/tcpip.h>
140 #include <netinet/tcp_debug.h>
141 #else
142 #include <netinet6/tcp6.h>
143 #include <netinet6/tcp6_fsm.h>
144 #include <netinet6/tcp6_seq.h>
145 #include <netinet6/tcp6_timer.h>
146 #include <netinet6/tcp6_var.h>
147 #endif
148 #endif
149
150 #ifdef __FreeBSD__
151 #include <netinet6/raw_ip6.h>
152 #endif
153
154 #if !defined(__OpenBSD__) && !(defined(__bsdi__) && _BSDI_VERSION >= 199802)
155 #if !(defined(__FreeBSD__) && __FreeBSD__ >= 4)
156 #include <netinet6/udp6.h>
157 #endif
158 #include <netinet6/udp6_var.h>
159 #endif
160
161 #include <netinet6/pim6_var.h>
162
163 #include <netinet6/nd6.h>
164
165 #ifdef IPSEC
166 #ifdef __OpenBSD__
167 #include <netinet/ip_ipsp.h>
168 #include <netinet/ip_ah.h>
169 #include <netinet/ip_esp.h>
170 #include <netinet/ip_ipip.h>
171 #else
172 #include <netinet6/ipsec.h>
173 #include <netinet6/ah.h>
174 #ifdef IPSEC_ESP
175 #include <netinet6/esp.h>
176 #endif
177 #include <netinet6/ipcomp.h>
178 #endif
179 #endif /* IPSEC */
180
181 #include <netinet6/ip6protosw.h>
182
183 #ifdef MIP6
184 #include <netinet6/mip6.h>
185 #endif /* MIP6 */
186
187 #ifndef offsetof
188 #define offsetof(type, member)  ((size_t)(&((type *)0)->member))
189 #endif
190
191 /*
192  * TCP/IP protocol family: IP6, ICMP6, UDP, TCP.
193  */
194
195 extern  struct domain inet6domain;
196 #if defined(__FreeBSD__) && __FreeBSD__ >= 3
197 static struct pr_usrreqs nousrreqs;
198 #endif
199
200 #ifndef __NetBSD__
201 #define PR_LISTEN       0
202 #endif
203 #if !defined(__NetBSD__) && !defined(__OpenBSD__)
204 #define PR_ABRTACPTDIS  0
205 #endif
206 #ifdef __OpenBSD__
207 #define PR_LASTHDR      0
208 #endif
209
210 struct ip6protosw inet6sw[] = {
211 { 0,            &inet6domain,   IPPROTO_IPV6,   0,
212   0,            0,              0,              0,
213   0,
214   ip6_init,     0,              frag6_slowtimo, frag6_drain,
215 #ifndef __FreeBSD__
216   ip6_sysctl,
217 #else
218 # if __FreeBSD__ >= 3
219   &nousrreqs,
220 # endif
221 #endif
222 },
223 { SOCK_DGRAM,   &inet6domain,   IPPROTO_UDP,    PR_ATOMIC|PR_ADDR,
224   udp6_input,   0,              udp6_ctlinput,  ip6_ctloutput,
225 #if defined(__FreeBSD__) && __FreeBSD__ >= 3
226  0, 0,
227 #elif defined(HAVE_NRL_INPCB)
228  udp6_usrreq,   0,
229 #else
230  udp6_usrreq,   udp6_init,
231 #endif
232   0,            0,              0,
233 #ifndef __FreeBSD__
234 #ifdef HAVE_NRL_INPCB
235   udp_sysctl,
236 #else
237   udp6_sysctl,
238 #endif
239 #else
240 # if __FreeBSD__ >= 3
241   &udp6_usrreqs,
242 # endif
243 #endif
244 },
245 #ifdef TCP6
246 { SOCK_STREAM,  &inet6domain,   IPPROTO_TCP,    PR_CONNREQUIRED|PR_WANTRCVD|PR_LISTEN|PR_ABRTACPTDIS,
247   tcp6_input,   0,              tcp6_ctlinput,  tcp6_ctloutput,
248   tcp6_usrreq,
249   tcp6_init,    tcp6_fasttimo,  tcp6_slowtimo,  tcp6_drain,
250 #ifndef __FreeBSD__
251   tcp6_sysctl,
252 #else
253 # if __FreeBSD__ >= 3
254   &tcp6_usrreqs,
255 # endif
256 #endif
257 },
258 #else
259 { SOCK_STREAM,  &inet6domain,   IPPROTO_TCP,    PR_CONNREQUIRED|PR_WANTRCVD|PR_LISTEN,
260   tcp6_input,   0,              tcp6_ctlinput,  tcp_ctloutput,
261 #if defined(__FreeBSD__) && __FreeBSD__ >= 3
262   0,
263 #elif defined(HAVE_NRL_INPCB)
264   tcp6_usrreq,
265 #else
266   tcp_usrreq,
267 #endif
268 #ifdef INET     /* don't call initialization and timeout routines twice */
269   0,            0,              0,              tcp_drain,
270 #else
271   tcp_init,     tcp_fasttimo,   tcp_slowtimo,   tcp_drain,
272 #endif
273 #ifndef __FreeBSD__
274   tcp_sysctl,
275 #else
276 # if __FreeBSD__ >= 3
277   &tcp6_usrreqs,
278 # endif
279 #endif
280 },
281 #endif /* TCP6 */
282 { SOCK_RAW,     &inet6domain,   IPPROTO_RAW,    PR_ATOMIC|PR_ADDR,
283   rip6_input,   rip6_output,    rip6_ctlinput,  rip6_ctloutput,
284 #if defined(__FreeBSD__) && __FreeBSD__ >= 3
285   0,
286 #else
287   rip6_usrreq,
288 #endif
289   0,            0,              0,              0,
290 #if defined(__FreeBSD__) && __FreeBSD__ >= 3
291   &rip6_usrreqs
292 #endif
293 },
294 { SOCK_RAW,     &inet6domain,   IPPROTO_ICMPV6, PR_ATOMIC|PR_ADDR|PR_LASTHDR,
295   icmp6_input,  rip6_output,    rip6_ctlinput,  rip6_ctloutput,
296 #if defined(__FreeBSD__) && __FreeBSD__ >= 3
297   0,
298 #else
299   rip6_usrreq,
300 #endif
301   icmp6_init,   icmp6_fasttimo, 0,              0,
302 #ifndef __FreeBSD__
303   icmp6_sysctl,
304 #else
305 # if __FreeBSD__ >= 3
306   &rip6_usrreqs
307 # endif
308 #endif
309 },
310 { SOCK_RAW,     &inet6domain,   IPPROTO_DSTOPTS,PR_ATOMIC|PR_ADDR,
311   dest6_input,  0,              0,              0,
312   0,    
313   0,            0,              0,              0,
314 #if defined(__FreeBSD__) && __FreeBSD__ >= 3
315   &nousrreqs
316 #endif
317 },
318 { SOCK_RAW,     &inet6domain,   IPPROTO_ROUTING,PR_ATOMIC|PR_ADDR,
319   route6_input, 0,              0,              0,
320   0,    
321   0,            0,              0,              0,
322 #if defined(__FreeBSD__) && __FreeBSD__ >= 3
323   &nousrreqs
324 #endif
325 },
326 { SOCK_RAW,     &inet6domain,   IPPROTO_FRAGMENT,PR_ATOMIC|PR_ADDR,
327   frag6_input,  0,              0,              0,
328   0,    
329   0,            0,              0,              0,
330 #if defined(__FreeBSD__) && __FreeBSD__ >= 3
331   &nousrreqs
332 #endif
333 },
334 #ifdef IPSEC
335 { SOCK_RAW,     &inet6domain,   IPPROTO_AH,     PR_ATOMIC|PR_ADDR,
336   ah6_input,    0,
337 #ifdef __NetBSD__
338   ah6_ctlinput,
339 #else
340   0,
341 #endif
342   0,
343   0,    
344   0,            0,              0,              0,
345 #ifdef __OpenBSD__
346   ah_sysctl,
347 #elif !defined(__FreeBSD__)
348   ipsec6_sysctl,
349 #else
350 # if __FreeBSD__ >= 3
351   &nousrreqs,
352 # endif
353 #endif
354 },
355 #ifdef IPSEC_ESP
356 { SOCK_RAW,     &inet6domain,   IPPROTO_ESP,    PR_ATOMIC|PR_ADDR,
357   esp6_input,   0,
358   esp6_ctlinput,
359   0,
360   0,
361   0,            0,              0,              0,
362 #ifdef __OpenBSD__
363   esp_sysctl,
364 #elif !defined(__FreeBSD__)
365   ipsec6_sysctl,
366 #else
367 # if __FreeBSD__ >= 3
368   &nousrreqs,
369 # endif
370 #endif
371 },
372 #endif
373 #ifndef __OpenBSD__
374 { SOCK_RAW,     &inet6domain,   IPPROTO_IPCOMP, PR_ATOMIC|PR_ADDR,
375   ipcomp6_input, 0,             0,              0,
376   0,    
377   0,            0,              0,              0,
378 #ifndef __FreeBSD__
379   ipsec6_sysctl,
380 #else
381 # if __FreeBSD__ >= 3
382   &nousrreqs,
383 # endif
384 #endif
385 },
386 #endif /* !OpenBSD */
387 #endif /* IPSEC */
388 #ifdef INET
389 { SOCK_RAW,     &inet6domain,   IPPROTO_IPV4,   PR_ATOMIC|PR_ADDR|PR_LASTHDR,
390   encap6_input, rip6_output,    encap6_ctlinput, rip6_ctloutput,
391 #if defined(__FreeBSD__) && __FreeBSD__ >= 3
392   0,
393 #else
394   rip6_usrreq,
395 #endif
396   encap_init,   0,              0,              0,
397 #if defined(__FreeBSD__) && __FreeBSD__ >= 3
398   &rip6_usrreqs
399 #endif
400 },
401 #endif /* INET */
402 { SOCK_RAW,     &inet6domain,   IPPROTO_IPV6,   PR_ATOMIC|PR_ADDR|PR_LASTHDR,
403   encap6_input, rip6_output,    encap6_ctlinput, rip6_ctloutput,
404 #if defined(__FreeBSD__) && __FreeBSD__ >= 3
405   0,
406 #else
407   rip6_usrreq,
408 #endif
409   encap_init,   0,              0,              0,
410 #if defined(__FreeBSD__) && __FreeBSD__ >= 3
411   &rip6_usrreqs
412 #endif
413 },
414 #if defined(__NetBSD__) && defined(ISO)
415 { SOCK_RAW,     &inet6domain,   IPPROTO_EON,    PR_ATOMIC|PR_ADDR|PR_LASTHDR,
416   encap6_input, rip6_output,    encap6_ctlinput, rip6_ctloutput,
417   rip6_usrreq,  /* XXX */
418   encap_init,   0,              0,              0,
419 },
420 #endif
421 { SOCK_RAW,     &inet6domain,   IPPROTO_PIM,    PR_ATOMIC|PR_ADDR|PR_LASTHDR,
422   pim6_input,   rip6_output,    0,              rip6_ctloutput,
423 #if defined(__FreeBSD__) && __FreeBSD__ >= 3
424   0,
425 #else
426   rip6_usrreq,
427 #endif
428   0,            0,              0,              0,
429 #if defined(__FreeBSD__) && __FreeBSD__ >= 3
430   &rip6_usrreqs
431 # endif
432 },
433 /* raw wildcard */
434 { SOCK_RAW,     &inet6domain,   0,              PR_ATOMIC|PR_ADDR,
435   rip6_input,   rip6_output,    0,              rip6_ctloutput,
436 #if defined(__FreeBSD__) && __FreeBSD__ >= 3
437   0, 0,
438 #else
439   rip6_usrreq, rip6_init,
440 #endif
441   0,            0,              0,
442 #if defined(__FreeBSD__) && __FreeBSD__ >= 3
443   &rip6_usrreqs
444 #endif
445 },
446 };
447
448 #ifdef MIP6
449 struct ip6protosw mip6_tunnel_protosw =
450 { SOCK_RAW,     &inet6domain,   IPPROTO_IPV6,   PR_ATOMIC|PR_ADDR,
451   mip6_tunnel_input, rip6_output,       0,      rip6_ctloutput,
452 #if defined(__FreeBSD__) && __FreeBSD__ >= 3
453   0,
454 #else
455   rip6_usrreq,
456 #endif
457   0,            0,              0,              0,
458 #if defined(__FreeBSD__) && __FreeBSD__ >= 3
459   &rip6_usrreqs
460 #endif
461 };
462 #endif /* MIP6 */
463
464 #ifdef __FreeBSD__
465 extern int in6_inithead __P((void **, int));
466 #endif
467
468 struct domain inet6domain =
469     { AF_INET6, "internet6", 0, 0, 0,
470       (struct protosw *)inet6sw,
471       (struct protosw *)&inet6sw[sizeof(inet6sw)/sizeof(inet6sw[0])], 0,
472 #ifdef __FreeBSD__
473       in6_inithead,
474 #else
475 #ifdef RADIX_ART
476       rn_art_inithead,
477 #elif defined(RADIX_MPATH)
478       rn_mpath_inithead,
479 #else
480       rn_inithead,
481 #endif
482 #endif
483       offsetof(struct sockaddr_in6, sin6_addr) << 3,
484       sizeof(struct sockaddr_in6) };
485
486 #ifdef __FreeBSD__
487 DOMAIN_SET(inet6);
488 #endif
489
490 /*
491  * Internet configuration info
492  */
493 #ifndef IPV6FORWARDING
494 #ifdef GATEWAY6
495 #define IPV6FORWARDING  1       /* forward IP6 packets not for us */
496 #else
497 #define IPV6FORWARDING  0       /* don't forward IP6 packets not for us */
498 #endif /* GATEWAY6 */
499 #endif /* !IPV6FORWARDING */
500
501 #ifndef IPV6_SENDREDIRECTS
502 #define IPV6_SENDREDIRECTS      1
503 #endif
504
505 int     ip6_forwarding = IPV6FORWARDING;        /* act as router? */
506 int     ip6_sendredirects = IPV6_SENDREDIRECTS;
507 int     ip6_defhlim = IPV6_DEFHLIM;
508 int     ip6_defmcasthlim = IPV6_DEFAULT_MULTICAST_HOPS;
509 int     ip6_accept_rtadv = 1; // was 0; /* "IPV6FORWARDING ? 0 : 1" is dangerous */
510 #if defined(__FreeBSD__) && __FreeBSD__ >= 4
511 int     ip6_maxfragpackets;     /* initialized in frag6.c:frag6_init() */
512 #else
513 int     ip6_maxfragpackets = 200;
514 #endif
515 int     ip6_log_interval = 5;
516 int     ip6_hdrnestlimit = 50;  /* appropriate? */
517 int     ip6_dad_count = 1;      /* DupAddrDetectionTransmits */
518 u_int32_t ip6_flow_seq;
519 int     ip6_auto_flowlabel = 1;
520 int     ip6_use_deprecated = 1; /* allow deprecated addr (RFC2462 5.5.4) */
521 int     ip6_rr_prune = 5;       /* router renumbering prefix
522                                  * walk list every 5 sec. */
523 #if defined(__NetBSD__)
524 int     ip6_v6only = 1;
525 #elif defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD__ == 2) || (defined(__bsdi__) && _BSDI_VERSION < 199802) || defined(TCP6)
526 const int       ip6_v6only = 1;
527 #else
528 int     ip6_v6only = 0;
529 #endif
530
531 u_int32_t ip6_id = 0UL;
532 int     ip6_keepfaith = 0;
533 time_t  ip6_log_time = (time_t)0L;
534
535 /* icmp6 */
536 #ifndef __bsdi__
537 /*
538  * BSDI4 defines these variables in in_proto.c...
539  * XXX: what if we don't define INET? Should we define pmtu6_expire
540  * or so? (jinmei@kame.net 19990310)
541  */
542 int pmtu_expire = 60*10;
543 int pmtu_probe = 60*2;
544 #endif
545
546 /* raw IP6 parameters */
547 /*
548  * Nominal space allocated to a raw ip socket.
549  */
550 #define RIPV6SNDQ       8192
551 #define RIPV6RCVQ       8192
552
553 u_long  rip6_sendspace = RIPV6SNDQ;
554 u_long  rip6_recvspace = RIPV6RCVQ;
555
556 /* ICMPV6 parameters */
557 int     icmp6_rediraccept = 1;          /* accept and process redirects */
558 int     icmp6_redirtimeout = 10 * 60;   /* 10 minutes */
559 int     icmp6errppslim = 100;           /* 100pps */
560 int     icmp6_nodeinfo = 3;             /* enable/disable NI response */
561
562 #ifdef TCP6
563 /* TCP on IP6 parameters */
564 int     tcp6_sendspace = 1024 * 8;
565 int     tcp6_recvspace = 1024 * 8;
566 int     tcp6_mssdflt = TCP6_MSS;
567 int     tcp6_rttdflt = TCP6TV_SRTTDFLT / PR_SLOWHZ;
568 int     tcp6_do_rfc1323 = 1;
569 int     tcp6_conntimeo = TCP6TV_KEEP_INIT;      /* initial connection timeout */
570 int     tcp6_43maxseg = 0;
571 int     tcp6_pmtu = 0;
572
573 /*
574  * Parameters for keepalive option.
575  * Connections for which SO_KEEPALIVE is set will be probed
576  * after being idle for a time of tcp6_keepidle (in units of PR_SLOWHZ).
577  * Starting at that time, the connection is probed at intervals
578  * of tcp6_keepintvl (same units) until a response is received
579  * or until tcp6_keepcnt probes have been made, at which time
580  * the connection is dropped.  Note that a tcp6_keepidle value
581  * under 2 hours is nonconformant with RFC-1122, Internet Host Requirements.
582  */
583 int     tcp6_keepidle = TCP6TV_KEEP_IDLE;       /* time before probing idle */
584 int     tcp6_keepintvl = TCP6TV_KEEPINTVL;      /* interval betwn idle probes */
585 int     tcp6_keepcnt = TCP6TV_KEEPCNT;          /* max idle probes */
586 int     tcp6_maxpersistidle = TCP6TV_KEEP_IDLE; /* max idle time in persist */
587
588 #ifndef INET_SERVER
589 #define TCP6_LISTEN_HASH_SIZE   17
590 #define TCP6_CONN_HASH_SIZE     97
591 #define TCP6_SYN_HASH_SIZE      293
592 #define TCP6_SYN_BUCKET_SIZE    35
593 #else
594 #define TCP6_LISTEN_HASH_SIZE   97
595 #define TCP6_CONN_HASH_SIZE     9973
596 #define TCP6_SYN_HASH_SIZE      997
597 #define TCP6_SYN_BUCKET_SIZE    35
598 #endif
599 int     tcp6_listen_hash_size = TCP6_LISTEN_HASH_SIZE;
600 int     tcp6_conn_hash_size = TCP6_CONN_HASH_SIZE;
601 struct  tcp6_hash_list tcp6_listen_hash[TCP6_LISTEN_HASH_SIZE],
602         tcp6_conn_hash[TCP6_CONN_HASH_SIZE];
603
604 int     tcp6_syn_cache_size = TCP6_SYN_HASH_SIZE;
605 int     tcp6_syn_cache_limit = TCP6_SYN_HASH_SIZE*TCP6_SYN_BUCKET_SIZE;
606 int     tcp6_syn_bucket_limit = 3*TCP6_SYN_BUCKET_SIZE;
607 struct  syn_cache_head6 tcp6_syn_cache[TCP6_SYN_HASH_SIZE];
608 struct  syn_cache_head6 *tcp6_syn_cache_first;
609 int     tcp6_syn_cache_interval = 8;    /* runs timer every 4 seconds */
610 int     tcp6_syn_cache_timeo = TCP6TV_KEEP_INIT;
611
612 /*
613  * Parameters for computing a desirable data segment size
614  * given an upper bound (either interface MTU, or peer's MSS option)_.
615  * As applications tend to use a buffer size that is a multiple
616  * of kilobytes, try for something that divides evenly. However,
617  * do not round down too much.
618  *
619  * Round segment size down to a multiple of TCP6_ROUNDSIZE if this
620  * does not result in lowering by more than (size/TCP6_ROUNDFRAC).
621  * For example, round 536 to 512.  Older versions of the system
622  * effectively used MCLBYTES (1K or 2K) as TCP6_ROUNDSIZE, with
623  * a value of 1 for TCP6_ROUNDFRAC (eliminating its effect).
624  * We round to a multiple of 256 for SLIP.
625  */
626 #ifndef TCP6_ROUNDSIZE
627 #define TCP6_ROUNDSIZE  256     /* round to multiple of 256 */
628 #endif
629 #ifndef TCP6_ROUNDFRAC
630 #define TCP6_ROUNDFRAC  10      /* round down at most N/10, or 10% */
631 #endif
632
633 int     tcp6_roundsize = TCP6_ROUNDSIZE;
634 int     tcp6_roundfrac = TCP6_ROUNDFRAC;
635 #endif /* TCP6 */
636
637 /* UDP on IP6 parameters */
638 int     udp6_sendspace = 9216;          /* really max datagram size */
639 int     udp6_recvspace = 40 * (1024 + sizeof(struct sockaddr_in6));
640                                         /* 40 1K datagrams */
641 /*
642  * sysctl related items.
643  */
644 SYSCTL_NODE(_net,       PF_INET6,       inet6,  CTLFLAG_RW,     0,
645         "Internet6 Family");
646
647 /* net.inet6 */
648 SYSCTL_NODE(_net_inet6, IPPROTO_IPV6,   ip6,    CTLFLAG_RW, 0,  "IP6");
649 SYSCTL_NODE(_net_inet6, IPPROTO_ICMPV6, icmp6,  CTLFLAG_RW, 0,  "ICMP6");
650 SYSCTL_NODE(_net_inet6, IPPROTO_UDP,    udp6,   CTLFLAG_RW, 0,  "UDP6");
651 SYSCTL_NODE(_net_inet6, IPPROTO_TCP,    tcp6,   CTLFLAG_RW, 0,  "TCP6");
652 #ifdef IPSEC
653 SYSCTL_NODE(_net_inet6, IPPROTO_ESP,    ipsec6, CTLFLAG_RW, 0,  "IPSEC6");
654 #endif /* IPSEC */
655
656 #ifdef CYGPKG_NET_FREEBSD_SYSCTL
657 /* net.inet6.ip6 */
658 static int
659 sysctl_ip6_temppltime(SYSCTL_HANDLER_ARGS)
660 {
661         int error = 0;
662         int old;
663
664         error = SYSCTL_OUT(req, arg1, sizeof(int));
665         if (error || !req->newptr)
666                 return (error);
667         old = ip6_temp_preferred_lifetime;
668         error = SYSCTL_IN(req, arg1, sizeof(int));
669         if (ip6_temp_preferred_lifetime <
670             ip6_desync_factor + ip6_temp_regen_advance) {
671                 ip6_temp_preferred_lifetime = old;
672                 return(EINVAL);
673         }
674         return(error);
675 }
676
677 static int
678 sysctl_ip6_tempvltime(SYSCTL_HANDLER_ARGS)
679 {
680         int error = 0;
681         int old;
682
683         error = SYSCTL_OUT(req, arg1, sizeof(int));
684         if (error || !req->newptr)
685                 return (error);
686         old = ip6_temp_valid_lifetime;
687         error = SYSCTL_IN(req, arg1, sizeof(int));
688         if (ip6_temp_valid_lifetime < ip6_temp_preferred_lifetime) {
689                 ip6_temp_preferred_lifetime = old;
690                 return(EINVAL);
691         }
692         return(error);
693 }
694 #endif
695 SYSCTL_INT(_net_inet6_ip6, IPV6CTL_FORWARDING,
696         forwarding, CTLFLAG_RW,         &ip6_forwarding,        0, "");
697 SYSCTL_INT(_net_inet6_ip6, IPV6CTL_SENDREDIRECTS,
698         redirect, CTLFLAG_RW,           &ip6_sendredirects,     0, "");
699 SYSCTL_INT(_net_inet6_ip6, IPV6CTL_DEFHLIM,
700         hlim, CTLFLAG_RW,               &ip6_defhlim,   0, "");
701 SYSCTL_STRUCT(_net_inet6_ip6, IPV6CTL_STATS, stats, CTLFLAG_RD,
702         &ip6stat, ip6stat, "");
703 SYSCTL_INT(_net_inet6_ip6, IPV6CTL_MAXFRAGPACKETS,
704         maxfragpackets, CTLFLAG_RW,     &ip6_maxfragpackets,    0, "");
705 SYSCTL_INT(_net_inet6_ip6, IPV6CTL_ACCEPT_RTADV,
706         accept_rtadv, CTLFLAG_RW,       &ip6_accept_rtadv,      0, "");
707 SYSCTL_INT(_net_inet6_ip6, IPV6CTL_KEEPFAITH,
708         keepfaith, CTLFLAG_RW,          &ip6_keepfaith, 0, "");
709 SYSCTL_INT(_net_inet6_ip6, IPV6CTL_LOG_INTERVAL,
710         log_interval, CTLFLAG_RW,       &ip6_log_interval,      0, "");
711 SYSCTL_INT(_net_inet6_ip6, IPV6CTL_HDRNESTLIMIT,
712         hdrnestlimit, CTLFLAG_RW,       &ip6_hdrnestlimit,      0, "");
713 SYSCTL_INT(_net_inet6_ip6, IPV6CTL_DAD_COUNT,
714         dad_count, CTLFLAG_RW,  &ip6_dad_count, 0, "");
715 SYSCTL_INT(_net_inet6_ip6, IPV6CTL_AUTO_FLOWLABEL,
716         auto_flowlabel, CTLFLAG_RW,     &ip6_auto_flowlabel,    0, "");
717 SYSCTL_INT(_net_inet6_ip6, IPV6CTL_DEFMCASTHLIM,
718         defmcasthlim, CTLFLAG_RW,       &ip6_defmcasthlim,      0, "");
719 #ifndef __ECOS /* We don't support gif at the moment */
720 SYSCTL_INT(_net_inet6_ip6, IPV6CTL_GIF_HLIM,
721         gifhlim, CTLFLAG_RW,    &ip6_gif_hlim,                  0, "");
722 #endif
723 SYSCTL_STRING(_net_inet6_ip6, IPV6CTL_KAME_VERSION,
724         kame_version, CTLFLAG_RD,       __KAME_VERSION,         0, "");
725 SYSCTL_INT(_net_inet6_ip6, IPV6CTL_USE_DEPRECATED,
726         use_deprecated, CTLFLAG_RW,     &ip6_use_deprecated,    0, "");
727 SYSCTL_INT(_net_inet6_ip6, IPV6CTL_RR_PRUNE,
728         rr_prune, CTLFLAG_RW,   &ip6_rr_prune,                  0, "");
729 SYSCTL_INT(_net_inet6_ip6, IPV6CTL_USETEMPADDR,
730         use_tempaddr, CTLFLAG_RW, &ip6_use_tempaddr,            0, "");
731 SYSCTL_OID(_net_inet6_ip6, IPV6CTL_TEMPPLTIME, temppltime,
732            CTLTYPE_INT|CTLFLAG_RW, &ip6_temp_preferred_lifetime, 0,
733            sysctl_ip6_temppltime, "I", "");
734 SYSCTL_OID(_net_inet6_ip6, IPV6CTL_TEMPVLTIME, tempvltime,
735            CTLTYPE_INT|CTLFLAG_RW, &ip6_temp_valid_lifetime, 0,
736            sysctl_ip6_tempvltime, "I", "");
737 SYSCTL_INT(_net_inet6_ip6, IPV6CTL_V6ONLY,
738         v6only, CTLFLAG_RW,     &ip6_v6only,                    0, "");
739 SYSCTL_INT(_net_inet6_ip6, IPV6CTL_AUTO_LINKLOCAL,
740         auto_linklocal, CTLFLAG_RW, &ip6_auto_linklocal,        0, "");
741 SYSCTL_STRUCT(_net_inet6_ip6, IPV6CTL_RIP6STATS, rip6stats, CTLFLAG_RD,
742         &rip6stat, rip6stat, "");
743
744 /* net.inet6.icmp6 */
745 SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_REDIRACCEPT,
746         rediraccept, CTLFLAG_RW,        &icmp6_rediraccept,     0, "");
747 SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_REDIRTIMEOUT,
748         redirtimeout, CTLFLAG_RW,       &icmp6_redirtimeout,    0, "");
749 SYSCTL_STRUCT(_net_inet6_icmp6, ICMPV6CTL_STATS, stats, CTLFLAG_RD,
750         &icmp6stat, icmp6stat, "");
751 SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_PRUNE,
752         nd6_prune, CTLFLAG_RW,          &nd6_prune,     0, "");
753 SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_DELAY,
754         nd6_delay, CTLFLAG_RW,          &nd6_delay,     0, "");
755 SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_UMAXTRIES,
756         nd6_umaxtries, CTLFLAG_RW,      &nd6_umaxtries, 0, "");
757 SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_MMAXTRIES,
758         nd6_mmaxtries, CTLFLAG_RW,      &nd6_mmaxtries, 0, "");
759 SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_USELOOPBACK,
760         nd6_useloopback, CTLFLAG_RW,    &nd6_useloopback, 0, "");
761 SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_NODEINFO,
762         nodeinfo, CTLFLAG_RW,   &icmp6_nodeinfo,        0, "");
763 SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ERRPPSLIMIT,
764         errppslimit, CTLFLAG_RW,        &icmp6errppslim,        0, "");
765 SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_MAXNUDHINT,
766         nd6_maxnudhint, CTLFLAG_RW,     &nd6_maxnudhint, 0, "");
767 SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_DEBUG,
768         nd6_debug, CTLFLAG_RW,  &nd6_debug,             0, "");
769