]>
Commit | Line | Data |
---|---|---|
b0d623f7 | 1 | /* |
39236c6e | 2 | * Copyright (c) 2008-2013 Apple Inc. All rights reserved. |
b0d623f7 A |
3 | * |
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ | |
39236c6e | 5 | * |
b0d623f7 A |
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. | |
39236c6e | 14 | * |
b0d623f7 A |
15 | * Please obtain a copy of the License at |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
39236c6e | 17 | * |
b0d623f7 A |
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. | |
39236c6e | 25 | * |
b0d623f7 A |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
27 | */ | |
28 | ||
1c79356b A |
29 | /* |
30 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. | |
31 | * All rights reserved. | |
32 | * | |
33 | * Redistribution and use in source and binary forms, with or without | |
34 | * modification, are permitted provided that the following conditions | |
35 | * are met: | |
36 | * 1. Redistributions of source code must retain the above copyright | |
37 | * notice, this list of conditions and the following disclaimer. | |
38 | * 2. Redistributions in binary form must reproduce the above copyright | |
39 | * notice, this list of conditions and the following disclaimer in the | |
40 | * documentation and/or other materials provided with the distribution. | |
41 | * 3. Neither the name of the project nor the names of its contributors | |
42 | * may be used to endorse or promote products derived from this software | |
43 | * without specific prior written permission. | |
44 | * | |
45 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND | |
46 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
47 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
48 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE | |
49 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
50 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
51 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
52 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
53 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
54 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
55 | * SUCH DAMAGE. | |
56 | */ | |
57 | ||
58 | /* | |
59 | * Copyright (c) 1982, 1986, 1993 | |
60 | * The Regents of the University of California. All rights reserved. | |
61 | * | |
62 | * Redistribution and use in source and binary forms, with or without | |
63 | * modification, are permitted provided that the following conditions | |
64 | * are met: | |
65 | * 1. Redistributions of source code must retain the above copyright | |
66 | * notice, this list of conditions and the following disclaimer. | |
67 | * 2. Redistributions in binary form must reproduce the above copyright | |
68 | * notice, this list of conditions and the following disclaimer in the | |
69 | * documentation and/or other materials provided with the distribution. | |
70 | * 3. All advertising materials mentioning features or use of this software | |
71 | * must display the following acknowledgement: | |
72 | * This product includes software developed by the University of | |
73 | * California, Berkeley and its contributors. | |
74 | * 4. Neither the name of the University nor the names of its contributors | |
75 | * may be used to endorse or promote products derived from this software | |
76 | * without specific prior written permission. | |
77 | * | |
78 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
79 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
80 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
81 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
82 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
83 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
84 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
85 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
86 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
87 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
88 | * SUCH DAMAGE. | |
89 | * | |
90 | * @(#)in_proto.c 8.1 (Berkeley) 6/10/93 | |
91 | */ | |
92 | ||
1c79356b A |
93 | |
94 | #include <sys/param.h> | |
95 | #include <sys/socket.h> | |
1c79356b | 96 | #include <sys/socketvar.h> |
1c79356b A |
97 | #include <sys/protosw.h> |
98 | #include <sys/kernel.h> | |
99 | #include <sys/domain.h> | |
100 | #include <sys/mbuf.h> | |
1c79356b A |
101 | #include <sys/systm.h> |
102 | #include <sys/sysctl.h> | |
1c79356b A |
103 | |
104 | #include <net/if.h> | |
105 | #include <net/radix.h> | |
106 | #include <net/route.h> | |
107 | ||
108 | #include <netinet/in.h> | |
109 | #include <netinet/in_systm.h> | |
110 | #include <netinet/in_var.h> | |
111 | #include <netinet/ip_encap.h> | |
1c79356b A |
112 | #include <netinet/ip.h> |
113 | #include <netinet/ip_var.h> | |
1c79356b A |
114 | #include <netinet/ip6.h> |
115 | #include <netinet6/ip6_var.h> | |
39236c6e | 116 | #include <netinet6/in6_var.h> |
1c79356b A |
117 | #include <netinet/icmp6.h> |
118 | ||
1c79356b A |
119 | #include <netinet/tcp.h> |
120 | #include <netinet/tcp_timer.h> | |
121 | #include <netinet/tcp_var.h> | |
122 | #include <netinet/udp.h> | |
123 | #include <netinet/udp_var.h> | |
1c79356b | 124 | #include <netinet6/tcp6_var.h> |
9bccf70c | 125 | #include <netinet6/raw_ip6.h> |
1c79356b | 126 | #include <netinet6/udp6_var.h> |
1c79356b | 127 | #include <netinet6/pim6_var.h> |
1c79356b | 128 | #include <netinet6/nd6.h> |
6d2010ae | 129 | #include <netinet6/mld6_var.h> |
1c79356b | 130 | |
91447636 A |
131 | #include <netinet6/ip6_mroute.h> |
132 | ||
1c79356b A |
133 | #if IPSEC |
134 | #include <netinet6/ipsec.h> | |
9bccf70c A |
135 | #if INET6 |
136 | #include <netinet6/ipsec6.h> | |
137 | #endif | |
1c79356b | 138 | #include <netinet6/ah.h> |
9bccf70c A |
139 | #if INET6 |
140 | #include <netinet6/ah6.h> | |
141 | #endif | |
1c79356b A |
142 | #if IPSEC_ESP |
143 | #include <netinet6/esp.h> | |
9bccf70c A |
144 | #if INET6 |
145 | #include <netinet6/esp6.h> | |
146 | #endif | |
1c79356b A |
147 | #endif |
148 | #include <netinet6/ipcomp.h> | |
9bccf70c A |
149 | #if INET6 |
150 | #include <netinet6/ipcomp6.h> | |
151 | #endif | |
1c79356b A |
152 | #endif /*IPSEC*/ |
153 | ||
154 | #include <netinet6/ip6protosw.h> | |
1c79356b A |
155 | |
156 | #include <net/net_osdep.h> | |
157 | ||
1c79356b A |
158 | /* |
159 | * TCP/IP protocol family: IP6, ICMP6, UDP, TCP. | |
160 | */ | |
161 | ||
39236c6e A |
162 | extern struct domain inet6domain_s; |
163 | struct domain *inet6domain = NULL; | |
164 | ||
1c79356b | 165 | static struct pr_usrreqs nousrreqs; |
91447636 | 166 | lck_mtx_t *inet6_domain_mutex; |
9bccf70c | 167 | |
39236c6e A |
168 | static void in6_dinit(struct domain *); |
169 | static int rip6_pr_output(struct mbuf *, struct socket *, | |
170 | struct sockaddr_in6 *, struct mbuf *); | |
55e303ae | 171 | |
1c79356b | 172 | struct ip6protosw inet6sw[] = { |
39236c6e A |
173 | { |
174 | .pr_type = 0, | |
175 | .pr_protocol = IPPROTO_IPV6, | |
176 | .pr_init = ip6_init, | |
177 | .pr_drain = ip6_drain, | |
178 | .pr_usrreqs = &nousrreqs, | |
1c79356b | 179 | }, |
39236c6e A |
180 | { |
181 | .pr_type = SOCK_DGRAM, | |
182 | .pr_protocol = IPPROTO_UDP, | |
183 | .pr_flags = PR_ATOMIC|PR_ADDR|PR_PROTOLOCK|PR_PCBLOCK| | |
184 | PR_EVCONNINFO, | |
185 | .pr_input = udp6_input, | |
186 | .pr_ctlinput = udp6_ctlinput, | |
187 | .pr_ctloutput = ip6_ctloutput, | |
188 | #if !INET /* don't call initialization twice */ | |
189 | .pr_init = udp_init, | |
190 | #endif /* !INET */ | |
191 | .pr_usrreqs = &udp6_usrreqs, | |
192 | .pr_lock = udp_lock, | |
193 | .pr_unlock = udp_unlock, | |
194 | .pr_getlock = udp_getlock, | |
1c79356b | 195 | }, |
39236c6e A |
196 | { |
197 | .pr_type = SOCK_STREAM, | |
198 | .pr_protocol = IPPROTO_TCP, | |
199 | .pr_flags = PR_CONNREQUIRED|PR_WANTRCVD|PR_PCBLOCK| | |
200 | PR_PROTOLOCK|PR_DISPOSE|PR_EVCONNINFO, | |
201 | .pr_input = tcp6_input, | |
202 | .pr_ctlinput = tcp6_ctlinput, | |
203 | .pr_ctloutput = tcp_ctloutput, | |
204 | #if !INET /* don't call initialization and timeout routines twice */ | |
205 | .pr_init = tcp_init, | |
206 | #endif /* !INET */ | |
207 | .pr_drain = tcp_drain, | |
208 | .pr_usrreqs = &tcp6_usrreqs, | |
209 | .pr_lock = tcp_lock, | |
210 | .pr_unlock = tcp_unlock, | |
211 | .pr_getlock = tcp_getlock, | |
1c79356b | 212 | }, |
39236c6e A |
213 | { |
214 | .pr_type = SOCK_RAW, | |
215 | .pr_protocol = IPPROTO_RAW, | |
216 | .pr_flags = PR_ATOMIC|PR_ADDR, | |
217 | .pr_input = rip6_input, | |
218 | .pr_output = rip6_pr_output, | |
219 | .pr_ctlinput = rip6_ctlinput, | |
220 | .pr_ctloutput = rip6_ctloutput, | |
221 | #if !INET /* don't call initialization and timeout routines twice */ | |
222 | .pr_init = rip_init, | |
223 | #endif /* !INET */ | |
224 | .pr_usrreqs = &rip6_usrreqs, | |
225 | .pr_unlock = rip_unlock, | |
1c79356b | 226 | }, |
39236c6e A |
227 | { |
228 | .pr_type = SOCK_RAW, | |
229 | .pr_protocol = IPPROTO_ICMPV6, | |
230 | .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR, | |
231 | .pr_input = icmp6_input, | |
232 | .pr_output = rip6_pr_output, | |
233 | .pr_ctlinput = rip6_ctlinput, | |
234 | .pr_ctloutput = rip6_ctloutput, | |
235 | .pr_init = icmp6_init, | |
236 | .pr_usrreqs = &rip6_usrreqs, | |
237 | .pr_unlock = rip_unlock, | |
2d21ac55 | 238 | }, |
39236c6e A |
239 | { |
240 | .pr_type = SOCK_DGRAM, | |
241 | .pr_protocol = IPPROTO_ICMPV6, | |
242 | .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR, | |
243 | .pr_input = icmp6_input, | |
244 | .pr_output = rip6_pr_output, | |
245 | .pr_ctlinput = rip6_ctlinput, | |
246 | .pr_ctloutput = icmp6_dgram_ctloutput, | |
247 | .pr_init = icmp6_init, | |
248 | .pr_usrreqs = &icmp6_dgram_usrreqs, | |
249 | .pr_unlock = rip_unlock, | |
1c79356b | 250 | }, |
39236c6e A |
251 | { |
252 | .pr_type = SOCK_RAW, | |
253 | .pr_protocol = IPPROTO_DSTOPTS, | |
254 | .pr_flags = PR_ATOMIC|PR_ADDR, | |
255 | .pr_input = dest6_input, | |
256 | .pr_usrreqs = &nousrreqs, | |
1c79356b | 257 | }, |
39236c6e A |
258 | { |
259 | .pr_type = SOCK_RAW, | |
260 | .pr_protocol = IPPROTO_ROUTING, | |
261 | .pr_flags = PR_ATOMIC|PR_ADDR, | |
262 | .pr_input = route6_input, | |
263 | .pr_usrreqs = &nousrreqs, | |
1c79356b | 264 | }, |
39236c6e A |
265 | { |
266 | .pr_type = SOCK_RAW, | |
267 | .pr_protocol = IPPROTO_FRAGMENT, | |
268 | .pr_flags = PR_ATOMIC|PR_ADDR|PR_PROTOLOCK, | |
269 | .pr_input = frag6_input, | |
270 | .pr_usrreqs = &nousrreqs, | |
1c79356b A |
271 | }, |
272 | #if IPSEC | |
39236c6e A |
273 | { |
274 | .pr_type = SOCK_RAW, | |
275 | .pr_protocol = IPPROTO_AH, | |
276 | .pr_flags = PR_ATOMIC|PR_ADDR|PR_PROTOLOCK, | |
277 | .pr_input = ah6_input, | |
278 | .pr_usrreqs = &nousrreqs, | |
1c79356b A |
279 | }, |
280 | #if IPSEC_ESP | |
39236c6e A |
281 | { |
282 | .pr_type = SOCK_RAW, | |
283 | .pr_protocol = IPPROTO_ESP, | |
284 | .pr_flags = PR_ATOMIC|PR_ADDR|PR_PROTOLOCK, | |
285 | .pr_input = esp6_input, | |
286 | .pr_ctlinput = esp6_ctlinput, | |
287 | .pr_usrreqs = &nousrreqs, | |
1c79356b | 288 | }, |
39236c6e A |
289 | #endif /* IPSEC_ESP */ |
290 | { | |
291 | .pr_type = SOCK_RAW, | |
292 | .pr_protocol = IPPROTO_IPCOMP, | |
293 | .pr_flags = PR_ATOMIC|PR_ADDR|PR_PROTOLOCK, | |
294 | .pr_input = ipcomp6_input, | |
295 | .pr_usrreqs = &nousrreqs, | |
1c79356b A |
296 | }, |
297 | #endif /* IPSEC */ | |
9bccf70c | 298 | #if INET |
39236c6e A |
299 | { |
300 | .pr_type = SOCK_RAW, | |
301 | .pr_protocol = IPPROTO_IPV4, | |
302 | .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR, | |
303 | .pr_input = encap6_input, | |
304 | .pr_output = rip6_pr_output, | |
305 | .pr_ctloutput = rip6_ctloutput, | |
306 | .pr_init = encap6_init, | |
307 | .pr_usrreqs = &rip6_usrreqs, | |
308 | .pr_unlock = rip_unlock, | |
1c79356b | 309 | }, |
9bccf70c | 310 | #endif /*INET*/ |
39236c6e A |
311 | { |
312 | .pr_type = SOCK_RAW, | |
313 | .pr_protocol = IPPROTO_IPV6, | |
314 | .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR, | |
315 | .pr_input = encap6_input, | |
316 | .pr_output = rip6_pr_output, | |
317 | .pr_ctloutput = rip6_ctloutput, | |
318 | .pr_init = encap6_init, | |
319 | .pr_usrreqs = &rip6_usrreqs, | |
320 | .pr_unlock = rip_unlock, | |
1c79356b | 321 | }, |
b7266188 | 322 | #if MROUTING |
39236c6e A |
323 | { |
324 | .pr_type = SOCK_RAW, | |
325 | .pr_protocol = IPPROTO_PIM, | |
326 | .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR, | |
327 | .pr_input = pim6_input, | |
328 | .pr_output = rip6_pr_output, | |
329 | .pr_ctloutput = rip6_ctloutput, | |
330 | .pr_usrreqs = &rip6_usrreqs, | |
331 | .pr_unlock = rip_unlock, | |
1c79356b | 332 | }, |
39236c6e | 333 | #endif /* MROUTING */ |
1c79356b | 334 | /* raw wildcard */ |
39236c6e A |
335 | { |
336 | .pr_type = SOCK_RAW, | |
337 | .pr_protocol = 0, | |
338 | .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR, | |
339 | .pr_input = rip6_input, | |
340 | .pr_output = rip6_pr_output, | |
341 | .pr_ctloutput = rip6_ctloutput, | |
342 | .pr_usrreqs = &rip6_usrreqs, | |
343 | .pr_unlock = rip_unlock, | |
1c79356b A |
344 | }, |
345 | }; | |
346 | ||
1c79356b | 347 | int in6_proto_count = (sizeof (inet6sw) / sizeof (struct ip6protosw)); |
1c79356b | 348 | |
39236c6e A |
349 | struct domain inet6domain_s = { |
350 | .dom_family = PF_INET6, | |
351 | .dom_flags = DOM_REENTRANT, | |
352 | .dom_name = "internet6", | |
353 | .dom_init = in6_dinit, | |
354 | .dom_rtattach = in6_inithead, | |
355 | .dom_rtoffset = offsetof(struct sockaddr_in6, sin6_addr) << 3, | |
356 | .dom_maxrtkey = sizeof (struct sockaddr_in6), | |
357 | .dom_protohdrlen = sizeof (struct sockaddr_in6), | |
358 | }; | |
1c79356b | 359 | |
9bccf70c A |
360 | /* Initialize the PF_INET6 domain, and add in the pre-defined protos */ |
361 | void | |
39236c6e | 362 | in6_dinit(struct domain *dp) |
9bccf70c | 363 | { |
39236c6e A |
364 | struct ip6protosw *pr; |
365 | int i; | |
366 | ||
367 | VERIFY(!(dp->dom_flags & DOM_INITIALIZED)); | |
368 | VERIFY(inet6domain == NULL); | |
369 | ||
370 | inet6domain = dp; | |
371 | ||
372 | _CASSERT(sizeof (struct protosw) == sizeof (struct ip6protosw)); | |
373 | _CASSERT(offsetof(struct ip6protosw, pr_entry) == | |
374 | offsetof(struct protosw, pr_entry)); | |
375 | _CASSERT(offsetof(struct ip6protosw, pr_domain) == | |
376 | offsetof(struct protosw, pr_domain)); | |
377 | _CASSERT(offsetof(struct ip6protosw, pr_protosw) == | |
378 | offsetof(struct protosw, pr_protosw)); | |
379 | _CASSERT(offsetof(struct ip6protosw, pr_type) == | |
380 | offsetof(struct protosw, pr_type)); | |
381 | _CASSERT(offsetof(struct ip6protosw, pr_protocol) == | |
382 | offsetof(struct protosw, pr_protocol)); | |
383 | _CASSERT(offsetof(struct ip6protosw, pr_flags) == | |
384 | offsetof(struct protosw, pr_flags)); | |
385 | _CASSERT(offsetof(struct ip6protosw, pr_input) == | |
386 | offsetof(struct protosw, pr_input)); | |
387 | _CASSERT(offsetof(struct ip6protosw, pr_output) == | |
388 | offsetof(struct protosw, pr_output)); | |
389 | _CASSERT(offsetof(struct ip6protosw, pr_ctlinput) == | |
390 | offsetof(struct protosw, pr_ctlinput)); | |
391 | _CASSERT(offsetof(struct ip6protosw, pr_ctloutput) == | |
392 | offsetof(struct protosw, pr_ctloutput)); | |
393 | _CASSERT(offsetof(struct ip6protosw, pr_usrreqs) == | |
394 | offsetof(struct protosw, pr_usrreqs)); | |
395 | _CASSERT(offsetof(struct ip6protosw, pr_init) == | |
396 | offsetof(struct protosw, pr_init)); | |
397 | _CASSERT(offsetof(struct ip6protosw, pr_drain) == | |
398 | offsetof(struct protosw, pr_drain)); | |
399 | _CASSERT(offsetof(struct ip6protosw, pr_sysctl) == | |
400 | offsetof(struct protosw, pr_sysctl)); | |
401 | _CASSERT(offsetof(struct ip6protosw, pr_lock) == | |
402 | offsetof(struct protosw, pr_lock)); | |
403 | _CASSERT(offsetof(struct ip6protosw, pr_unlock) == | |
404 | offsetof(struct protosw, pr_unlock)); | |
405 | _CASSERT(offsetof(struct ip6protosw, pr_getlock) == | |
406 | offsetof(struct protosw, pr_getlock)); | |
407 | _CASSERT(offsetof(struct ip6protosw, pr_filter_head) == | |
408 | offsetof(struct protosw, pr_filter_head)); | |
409 | _CASSERT(offsetof(struct ip6protosw, pr_old) == | |
410 | offsetof(struct protosw, pr_old)); | |
411 | ||
412 | /* | |
413 | * Attach first, then initialize. ip6_init() needs raw IP6 handler. | |
414 | */ | |
415 | for (i = 0, pr = &inet6sw[0]; i < in6_proto_count; i++, pr++) | |
416 | net_add_proto((struct protosw *)pr, dp, 0); | |
417 | for (i = 0, pr = &inet6sw[0]; i < in6_proto_count; i++, pr++) | |
418 | net_init_proto((struct protosw *)pr, dp); | |
419 | ||
420 | inet6_domain_mutex = dp->dom_mtx; | |
9bccf70c A |
421 | } |
422 | ||
39236c6e A |
423 | static int |
424 | rip6_pr_output(struct mbuf *m, struct socket *so, struct sockaddr_in6 *sin6, | |
425 | struct mbuf *m1) | |
55e303ae | 426 | { |
39236c6e A |
427 | #pragma unused(m, so, sin6, m1) |
428 | panic("%s\n", __func__); | |
429 | /* NOTREACHED */ | |
430 | return (0); | |
55e303ae | 431 | } |
9bccf70c | 432 | |
1c79356b A |
433 | /* |
434 | * Internet configuration info | |
435 | */ | |
436 | #ifndef IPV6FORWARDING | |
437 | #if GATEWAY6 | |
438 | #define IPV6FORWARDING 1 /* forward IP6 packets not for us */ | |
439 | #else | |
440 | #define IPV6FORWARDING 0 /* don't forward IP6 packets not for us */ | |
441 | #endif /* GATEWAY6 */ | |
442 | #endif /* !IPV6FORWARDING */ | |
443 | ||
444 | #ifndef IPV6_SENDREDIRECTS | |
445 | #define IPV6_SENDREDIRECTS 1 | |
446 | #endif | |
447 | ||
448 | int ip6_forwarding = IPV6FORWARDING; /* act as router? */ | |
449 | int ip6_sendredirects = IPV6_SENDREDIRECTS; | |
450 | int ip6_defhlim = IPV6_DEFHLIM; | |
451 | int ip6_defmcasthlim = IPV6_DEFAULT_MULTICAST_HOPS; | |
316670eb | 452 | int ip6_accept_rtadv = 1; /* deprecated */ |
1c79356b | 453 | int ip6_log_interval = 5; |
6d2010ae | 454 | int ip6_hdrnestlimit = 15; /* How many header options will we process? */ |
1c79356b | 455 | int ip6_dad_count = 1; /* DupAddrDetectionTransmits */ |
1c79356b | 456 | int ip6_auto_flowlabel = 1; |
1c79356b | 457 | int ip6_gif_hlim = 0; |
39236c6e | 458 | int ip6_use_deprecated = 1; /* allow deprecated addr [RFC 4862, 5.5.4] */ |
1c79356b A |
459 | int ip6_rr_prune = 5; /* router renumbering prefix |
460 | * walk list every 5 sec. */ | |
6d2010ae A |
461 | int ip6_mcast_pmtu = 0; /* enable pMTU discovery for multicast? */ |
462 | int ip6_v6only = 0; /* Mapped addresses off by default - Radar 3347718 -- REVISITING FOR 10.7 -- TESTING WITH MAPPED@ OFF */ | |
1c79356b | 463 | |
b0d623f7 | 464 | int ip6_neighborgcthresh = 1024; /* Threshold # of NDP entries for GC */ |
e2fac8b1 A |
465 | int ip6_maxifprefixes = 16; /* Max acceptable prefixes via RA per IF */ |
466 | int ip6_maxifdefrouters = 16; /* Max acceptable def routers via RA */ | |
b0d623f7 | 467 | int ip6_maxdynroutes = 1024; /* Max # of routes created via redirect */ |
6d2010ae | 468 | int ip6_only_allow_rfc4193_prefix = 0; /* Only allow RFC4193 style Unique Local IPv6 Unicast prefixes */ |
e2fac8b1 | 469 | |
316670eb | 470 | static int ip6_keepfaith = 0; |
39236c6e | 471 | uint64_t ip6_log_time = 0; |
6d2010ae | 472 | int nd6_onlink_ns_rfc4861 = 0; /* allow 'on-link' nd6 NS (as in RFC 4861) */ |
1c79356b A |
473 | |
474 | /* icmp6 */ | |
1c79356b A |
475 | /* |
476 | * BSDI4 defines these variables in in_proto.c... | |
477 | * XXX: what if we don't define INET? Should we define pmtu6_expire | |
478 | * or so? (jinmei@kame.net 19990310) | |
479 | */ | |
480 | int pmtu_expire = 60*10; | |
481 | int pmtu_probe = 60*2; | |
1c79356b A |
482 | |
483 | /* raw IP6 parameters */ | |
484 | /* | |
485 | * Nominal space allocated to a raw ip socket. | |
486 | */ | |
487 | #define RIPV6SNDQ 8192 | |
488 | #define RIPV6RCVQ 8192 | |
489 | ||
b0d623f7 A |
490 | u_int32_t rip6_sendspace = RIPV6SNDQ; |
491 | u_int32_t rip6_recvspace = RIPV6RCVQ; | |
1c79356b A |
492 | |
493 | /* ICMPV6 parameters */ | |
494 | int icmp6_rediraccept = 1; /* accept and process redirects */ | |
495 | int icmp6_redirtimeout = 10 * 60; /* 10 minutes */ | |
b0d623f7 | 496 | int icmp6errppslim = 500; /* 500 packets per second */ |
55e303ae | 497 | int icmp6_nodeinfo = 3; /* enable/disable NI response */ |
1c79356b | 498 | |
1c79356b A |
499 | /* UDP on IP6 parameters */ |
500 | int udp6_sendspace = 9216; /* really max datagram size */ | |
501 | int udp6_recvspace = 40 * (1024 + sizeof(struct sockaddr_in6)); | |
502 | /* 40 1K datagrams */ | |
503 | ||
1c79356b A |
504 | /* |
505 | * sysctl related items. | |
506 | */ | |
39236c6e A |
507 | SYSCTL_NODE(_net, PF_INET6, inet6, |
508 | CTLFLAG_RW | CTLFLAG_LOCKED, 0, "Internet6 Family"); | |
1c79356b A |
509 | |
510 | /* net.inet6 */ | |
39236c6e A |
511 | SYSCTL_NODE(_net_inet6, IPPROTO_IPV6, ip6, |
512 | CTLFLAG_RW|CTLFLAG_LOCKED, 0, "IP6"); | |
513 | SYSCTL_NODE(_net_inet6, IPPROTO_ICMPV6, icmp6, | |
514 | CTLFLAG_RW|CTLFLAG_LOCKED, 0, "ICMP6"); | |
515 | SYSCTL_NODE(_net_inet6, IPPROTO_UDP, udp6, | |
516 | CTLFLAG_RW|CTLFLAG_LOCKED, 0, "UDP6"); | |
517 | SYSCTL_NODE(_net_inet6, IPPROTO_TCP, tcp6, | |
518 | CTLFLAG_RW|CTLFLAG_LOCKED, 0, "TCP6"); | |
1c79356b | 519 | #if IPSEC |
39236c6e A |
520 | SYSCTL_NODE(_net_inet6, IPPROTO_ESP, ipsec6, |
521 | CTLFLAG_RW|CTLFLAG_LOCKED, 0, "IPSEC6"); | |
1c79356b A |
522 | #endif /* IPSEC */ |
523 | ||
524 | /* net.inet6.ip6 */ | |
525 | static int | |
9bccf70c | 526 | sysctl_ip6_temppltime SYSCTL_HANDLER_ARGS |
1c79356b | 527 | { |
b0d623f7 | 528 | #pragma unused(oidp, arg2) |
1c79356b | 529 | int error = 0; |
9bccf70c | 530 | int old; |
1c79356b A |
531 | |
532 | error = SYSCTL_OUT(req, arg1, sizeof(int)); | |
533 | if (error || !req->newptr) | |
534 | return (error); | |
9bccf70c | 535 | old = ip6_temp_preferred_lifetime; |
1c79356b | 536 | error = SYSCTL_IN(req, arg1, sizeof(int)); |
6d2010ae A |
537 | if (ip6_temp_preferred_lifetime > ND6_MAX_LIFETIME || |
538 | ip6_temp_preferred_lifetime < | |
9bccf70c A |
539 | ip6_desync_factor + ip6_temp_regen_advance) { |
540 | ip6_temp_preferred_lifetime = old; | |
39236c6e | 541 | return (EINVAL); |
1c79356b | 542 | } |
39236c6e | 543 | return (error); |
9bccf70c | 544 | } |
1c79356b | 545 | |
9bccf70c A |
546 | static int |
547 | sysctl_ip6_tempvltime SYSCTL_HANDLER_ARGS | |
548 | { | |
b0d623f7 | 549 | #pragma unused(oidp, arg2) |
9bccf70c A |
550 | int error = 0; |
551 | int old; | |
552 | ||
553 | error = SYSCTL_OUT(req, arg1, sizeof(int)); | |
554 | if (error || !req->newptr) | |
555 | return (error); | |
556 | old = ip6_temp_valid_lifetime; | |
557 | error = SYSCTL_IN(req, arg1, sizeof(int)); | |
6d2010ae A |
558 | if (ip6_temp_valid_lifetime > ND6_MAX_LIFETIME || |
559 | ip6_temp_valid_lifetime < ip6_temp_preferred_lifetime) { | |
39236c6e A |
560 | ip6_temp_valid_lifetime = old; |
561 | return (EINVAL); | |
9bccf70c | 562 | } |
39236c6e A |
563 | return (error); |
564 | } | |
565 | ||
566 | static int | |
567 | ip6_getstat SYSCTL_HANDLER_ARGS | |
568 | { | |
569 | #pragma unused(oidp, arg1, arg2) | |
570 | if (req->oldptr == USER_ADDR_NULL) | |
571 | req->oldlen = (size_t)sizeof (struct ip6stat); | |
572 | ||
573 | return (SYSCTL_OUT(req, &ip6stat, MIN(sizeof (ip6stat), req->oldlen))); | |
1c79356b A |
574 | } |
575 | ||
9bccf70c | 576 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_FORWARDING, |
6d2010ae | 577 | forwarding, CTLFLAG_RW | CTLFLAG_LOCKED, &ip6_forwarding, 0, ""); |
1c79356b | 578 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_SENDREDIRECTS, |
6d2010ae | 579 | redirect, CTLFLAG_RW | CTLFLAG_LOCKED, &ip6_sendredirects, 0, ""); |
1c79356b | 580 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_DEFHLIM, |
6d2010ae | 581 | hlim, CTLFLAG_RW | CTLFLAG_LOCKED, &ip6_defhlim, 0, ""); |
39236c6e A |
582 | SYSCTL_PROC(_net_inet6_ip6, IPV6CTL_STATS, stats, CTLFLAG_RD | CTLFLAG_LOCKED, |
583 | 0, 0, ip6_getstat, "S,ip6stat", ""); | |
1c79356b | 584 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_ACCEPT_RTADV, |
316670eb | 585 | accept_rtadv, CTLFLAG_RD | CTLFLAG_LOCKED, |
6d2010ae | 586 | &ip6_accept_rtadv, 0, ""); |
1c79356b | 587 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_KEEPFAITH, |
316670eb | 588 | keepfaith, CTLFLAG_RD | CTLFLAG_LOCKED, &ip6_keepfaith, 0, ""); |
1c79356b | 589 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_LOG_INTERVAL, |
6d2010ae | 590 | log_interval, CTLFLAG_RW | CTLFLAG_LOCKED, &ip6_log_interval, 0, ""); |
1c79356b | 591 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_HDRNESTLIMIT, |
6d2010ae | 592 | hdrnestlimit, CTLFLAG_RW | CTLFLAG_LOCKED, &ip6_hdrnestlimit, 0, ""); |
1c79356b | 593 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_DAD_COUNT, |
6d2010ae | 594 | dad_count, CTLFLAG_RW | CTLFLAG_LOCKED, &ip6_dad_count, 0, ""); |
1c79356b | 595 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_AUTO_FLOWLABEL, |
6d2010ae | 596 | auto_flowlabel, CTLFLAG_RW | CTLFLAG_LOCKED, &ip6_auto_flowlabel, 0, ""); |
1c79356b | 597 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_DEFMCASTHLIM, |
6d2010ae | 598 | defmcasthlim, CTLFLAG_RW | CTLFLAG_LOCKED, &ip6_defmcasthlim, 0, ""); |
1c79356b | 599 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_GIF_HLIM, |
6d2010ae | 600 | gifhlim, CTLFLAG_RW | CTLFLAG_LOCKED, &ip6_gif_hlim, 0, ""); |
1c79356b | 601 | SYSCTL_STRING(_net_inet6_ip6, IPV6CTL_KAME_VERSION, |
6d2010ae | 602 | kame_version, CTLFLAG_RD | CTLFLAG_LOCKED, (void *)((uintptr_t)(__KAME_VERSION)), 0, ""); |
1c79356b | 603 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_USE_DEPRECATED, |
6d2010ae | 604 | use_deprecated, CTLFLAG_RW | CTLFLAG_LOCKED, &ip6_use_deprecated, 0, ""); |
1c79356b | 605 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_RR_PRUNE, |
6d2010ae | 606 | rr_prune, CTLFLAG_RW | CTLFLAG_LOCKED, &ip6_rr_prune, 0, ""); |
9bccf70c | 607 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_USETEMPADDR, |
6d2010ae | 608 | use_tempaddr, CTLFLAG_RW | CTLFLAG_LOCKED, &ip6_use_tempaddr, 0, ""); |
9bccf70c | 609 | SYSCTL_OID(_net_inet6_ip6, IPV6CTL_TEMPPLTIME, temppltime, |
6d2010ae | 610 | CTLTYPE_INT|CTLFLAG_RW | CTLFLAG_LOCKED, &ip6_temp_preferred_lifetime, 0, |
9bccf70c A |
611 | sysctl_ip6_temppltime, "I", ""); |
612 | SYSCTL_OID(_net_inet6_ip6, IPV6CTL_TEMPVLTIME, tempvltime, | |
6d2010ae | 613 | CTLTYPE_INT|CTLFLAG_RW | CTLFLAG_LOCKED, &ip6_temp_valid_lifetime, 0, |
9bccf70c A |
614 | sysctl_ip6_tempvltime, "I", ""); |
615 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_V6ONLY, | |
6d2010ae | 616 | v6only, CTLFLAG_RW | CTLFLAG_LOCKED, &ip6_v6only, 0, ""); |
9bccf70c | 617 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_AUTO_LINKLOCAL, |
6d2010ae A |
618 | auto_linklocal, CTLFLAG_RW | CTLFLAG_LOCKED, &ip6_auto_linklocal, 0, ""); |
619 | SYSCTL_STRUCT(_net_inet6_ip6, IPV6CTL_RIP6STATS, rip6stats, CTLFLAG_RD | CTLFLAG_LOCKED, | |
9bccf70c | 620 | &rip6stat, rip6stat, ""); |
6d2010ae A |
621 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_PREFER_TEMPADDR, |
622 | prefer_tempaddr, CTLFLAG_RW | CTLFLAG_LOCKED, &ip6_prefer_tempaddr, 0, ""); | |
623 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_USE_DEFAULTZONE, | |
624 | use_defaultzone, CTLFLAG_RW | CTLFLAG_LOCKED, &ip6_use_defzone, 0,""); | |
625 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_MCAST_PMTU, | |
626 | mcast_pmtu, CTLFLAG_RW | CTLFLAG_LOCKED, &ip6_mcast_pmtu, 0, ""); | |
b7266188 | 627 | #if MROUTING |
6d2010ae | 628 | SYSCTL_STRUCT(_net_inet6_ip6, OID_AUTO, mrt6stat, CTLFLAG_RD | CTLFLAG_LOCKED, |
91447636 | 629 | &mrt6stat, mrt6stat, ""); |
b7266188 | 630 | #endif |
e2fac8b1 | 631 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_NEIGHBORGCTHRESH, |
6d2010ae | 632 | neighborgcthresh, CTLFLAG_RW | CTLFLAG_LOCKED, &ip6_neighborgcthresh, 0, ""); |
e2fac8b1 | 633 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_MAXIFPREFIXES, |
6d2010ae | 634 | maxifprefixes, CTLFLAG_RW | CTLFLAG_LOCKED, &ip6_maxifprefixes, 0, ""); |
e2fac8b1 | 635 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_MAXIFDEFROUTERS, |
6d2010ae | 636 | maxifdefrouters, CTLFLAG_RW | CTLFLAG_LOCKED, &ip6_maxifdefrouters, 0, ""); |
e2fac8b1 | 637 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_MAXDYNROUTES, |
6d2010ae A |
638 | maxdynroutes, CTLFLAG_RW | CTLFLAG_LOCKED, &ip6_maxdynroutes, 0, ""); |
639 | SYSCTL_INT(_net_inet6_ip6, OID_AUTO, | |
640 | only_allow_rfc4193_prefixes, CTLFLAG_RW | CTLFLAG_LOCKED, | |
641 | &ip6_only_allow_rfc4193_prefix, 0, ""); | |
1c79356b A |
642 | |
643 | /* net.inet6.icmp6 */ | |
644 | SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_REDIRACCEPT, | |
6d2010ae | 645 | rediraccept, CTLFLAG_RW | CTLFLAG_LOCKED, &icmp6_rediraccept, 0, ""); |
1c79356b | 646 | SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_REDIRTIMEOUT, |
6d2010ae A |
647 | redirtimeout, CTLFLAG_RW | CTLFLAG_LOCKED, &icmp6_redirtimeout, 0, ""); |
648 | SYSCTL_STRUCT(_net_inet6_icmp6, ICMPV6CTL_STATS, stats, CTLFLAG_RD | CTLFLAG_LOCKED, | |
1c79356b | 649 | &icmp6stat, icmp6stat, ""); |
1c79356b | 650 | SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_PRUNE, |
6d2010ae | 651 | nd6_prune, CTLFLAG_RW | CTLFLAG_LOCKED, &nd6_prune, 0, ""); |
39236c6e A |
652 | SYSCTL_INT(_net_inet6_icmp6, OID_AUTO, |
653 | nd6_prune_lazy, CTLFLAG_RW | CTLFLAG_LOCKED, &nd6_prune_lazy, 0, ""); | |
1c79356b | 654 | SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_DELAY, |
6d2010ae | 655 | nd6_delay, CTLFLAG_RW | CTLFLAG_LOCKED, &nd6_delay, 0, ""); |
1c79356b | 656 | SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_UMAXTRIES, |
6d2010ae | 657 | nd6_umaxtries, CTLFLAG_RW | CTLFLAG_LOCKED, &nd6_umaxtries, 0, ""); |
1c79356b | 658 | SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_MMAXTRIES, |
6d2010ae | 659 | nd6_mmaxtries, CTLFLAG_RW | CTLFLAG_LOCKED, &nd6_mmaxtries, 0, ""); |
1c79356b | 660 | SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_USELOOPBACK, |
6d2010ae A |
661 | nd6_useloopback, CTLFLAG_RW | CTLFLAG_LOCKED, &nd6_useloopback, 0, ""); |
662 | SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_ACCEPT_6TO4, | |
663 | nd6_accept_6to4, CTLFLAG_RW | CTLFLAG_LOCKED, &nd6_accept_6to4, 0, ""); | |
1c79356b | 664 | SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_NODEINFO, |
6d2010ae | 665 | nodeinfo, CTLFLAG_RW | CTLFLAG_LOCKED, &icmp6_nodeinfo, 0, ""); |
9bccf70c | 666 | SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ERRPPSLIMIT, |
6d2010ae | 667 | errppslimit, CTLFLAG_RW | CTLFLAG_LOCKED, &icmp6errppslim, 0, ""); |
9bccf70c | 668 | SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_DEBUG, |
6d2010ae A |
669 | nd6_debug, CTLFLAG_RW | CTLFLAG_LOCKED, &nd6_debug, 0, ""); |
670 | SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_ONLINKNSRFC4861, | |
671 | nd6_onlink_ns_rfc4861, CTLFLAG_RW | CTLFLAG_LOCKED, &nd6_onlink_ns_rfc4861, 0, | |
672 | "Accept 'on-link' nd6 NS in compliance with RFC 4861."); | |
316670eb A |
673 | SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_OPTIMISTIC_DAD, |
674 | nd6_optimistic_dad, CTLFLAG_RW | CTLFLAG_LOCKED, &nd6_optimistic_dad, 0, ""); |