Annotation of src/sys/netinet6/ip6_input.c, Revision 1.12
1.12 ! itojun 1: /* $NetBSD: ip6_input.c,v 1.11 2000/01/06 06:41:19 itojun Exp $ */
1.3 thorpej 2:
1.2 itojun 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, 1988, 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_input.c 8.2 (Berkeley) 1/4/94
65: */
66:
67: #include "opt_inet.h"
1.4 thorpej 68: #include "opt_ipsec.h"
1.2 itojun 69:
70: #include <sys/param.h>
71: #include <sys/systm.h>
72: #include <sys/malloc.h>
73: #include <sys/mbuf.h>
74: #include <sys/domain.h>
75: #include <sys/protosw.h>
76: #include <sys/socket.h>
77: #include <sys/socketvar.h>
78: #include <sys/errno.h>
79: #include <sys/time.h>
80: #include <sys/kernel.h>
81: #include <sys/syslog.h>
82: #include <sys/proc.h>
83:
84: #include <net/if.h>
85: #include <net/if_types.h>
86: #include <net/if_dl.h>
87: #include <net/route.h>
88: #include <net/netisr.h>
89:
90: #include <netinet/in.h>
1.9 itojun 91: #include <netinet/in_systm.h>
92: #ifdef INET
93: #include <netinet/ip.h>
94: #include <netinet/ip_icmp.h>
95: #endif /*INET*/
1.11 itojun 96: #include <netinet6/ip6.h>
1.2 itojun 97: #include <netinet6/in6_var.h>
1.11 itojun 98: #include <netinet6/ip6_var.h>
1.2 itojun 99: #include <netinet6/in6_pcb.h>
100: #include <netinet6/icmp6.h>
101: #include <netinet6/in6_ifattach.h>
102: #include <netinet6/nd6.h>
1.9 itojun 103: #include <netinet6/in6_prefix.h>
1.2 itojun 104:
1.9 itojun 105: #ifdef IPV6FIREWALL
106: #include <netinet6/ip6_fw.h>
107: #endif
1.2 itojun 108:
109: #include <netinet6/ip6protosw.h>
110:
111: /* we need it for NLOOP. */
112: #include "loop.h"
113: #include "faith.h"
114:
115: #include "gif.h"
116: #include "bpfilter.h"
117:
1.9 itojun 118: #include <net/net_osdep.h>
119:
1.2 itojun 120: extern struct domain inet6domain;
121: extern struct ip6protosw inet6sw[];
122:
123: u_char ip6_protox[IPPROTO_MAX];
124: static int ip6qmaxlen = IFQ_MAXLEN;
125: struct in6_ifaddr *in6_ifaddr;
126: struct ifqueue ip6intrq;
127:
128: extern struct ifnet loif[NLOOP];
129: int ip6_forward_srcrt; /* XXX */
130: int ip6_sourcecheck; /* XXX */
131: int ip6_sourcecheck_interval; /* XXX */
1.9 itojun 132:
133: #ifdef IPV6FIREWALL
134: /* firewall hooks */
135: ip6_fw_chk_t *ip6_fw_chk_ptr;
136: ip6_fw_ctl_t *ip6_fw_ctl_ptr;
1.2 itojun 137: #endif
138:
139: struct ip6stat ip6stat;
140:
141: static void ip6_init2 __P((void *));
142:
1.5 itojun 143: static int ip6_hopopts_input __P((u_int32_t *, u_int32_t *, struct mbuf **, int *));
1.2 itojun 144:
1.12 ! itojun 145: #ifdef PTR
1.9 itojun 146: extern int ip6_protocol_tr;
147:
148: int ptr_in6 __P((struct mbuf *, struct mbuf **));
149: extern void ip_forward __P((struct mbuf *, int));
150: #endif
151:
1.2 itojun 152: /*
153: * IP6 initialization: fill in IP6 protocol switch table.
154: * All protocols not implemented in kernel go to raw IP6 protocol handler.
155: */
156: void
157: ip6_init()
158: {
159: register struct ip6protosw *pr;
160: register int i;
161: struct timeval tv;
162:
163: pr = (struct ip6protosw *)pffindproto(PF_INET6, IPPROTO_RAW, SOCK_RAW);
164: if (pr == 0)
165: panic("ip6_init");
166: for (i = 0; i < IPPROTO_MAX; i++)
167: ip6_protox[i] = pr - inet6sw;
168: for (pr = (struct ip6protosw *)inet6domain.dom_protosw;
169: pr < (struct ip6protosw *)inet6domain.dom_protoswNPROTOSW; pr++)
170: if (pr->pr_domain->dom_family == PF_INET6 &&
171: pr->pr_protocol && pr->pr_protocol != IPPROTO_RAW)
172: ip6_protox[pr->pr_protocol] = pr - inet6sw;
173: ip6intrq.ifq_maxlen = ip6qmaxlen;
174: nd6_init();
175: frag6_init();
1.9 itojun 176: #ifdef IPV6FIREWALL
177: ip6_fw_init();
178: #endif
1.2 itojun 179: /*
180: * in many cases, random() here does NOT return random number
181: * as initialization during bootstrap time occur in fixed order.
182: */
183: microtime(&tv);
184: ip6_flow_seq = random() ^ tv.tv_usec;
185:
186: ip6_init2((void *)0);
187: }
188:
189: static void
190: ip6_init2(dummy)
191: void *dummy;
192: {
1.9 itojun 193: int ret;
194:
195: /* get EUI64 from somewhere */
196: ret = in6_ifattach_getifid(NULL);
1.2 itojun 197:
198: /*
199: * to route local address of p2p link to loopback,
200: * assign loopback address first.
201: */
1.9 itojun 202: in6_ifattach(&loif[0], IN6_IFT_LOOP, NULL, 0);
1.2 itojun 203:
204: /* nd6_timer_init */
205: timeout(nd6_timer, (caddr_t)0, hz);
1.9 itojun 206: /* router renumbering prefix list maintenance */
207: timeout(in6_rr_timer, (caddr_t)0, hz);
1.2 itojun 208: }
209:
210: /*
211: * IP6 input interrupt handling. Just pass the packet to ip6_input.
212: */
213: void
214: ip6intr()
215: {
216: int s;
217: struct mbuf *m;
218:
219: for (;;) {
220: s = splimp();
221: IF_DEQUEUE(&ip6intrq, m);
222: splx(s);
223: if (m == 0)
224: return;
225: ip6_input(m);
226: }
227: }
228:
229: extern struct route_in6 ip6_forward_rt;
230:
231: void
232: ip6_input(m)
233: struct mbuf *m;
234: {
1.9 itojun 235: struct ip6_hdr *ip6;
1.2 itojun 236: int off = sizeof(struct ip6_hdr), nest;
237: u_int32_t plen;
1.5 itojun 238: u_int32_t rtalert = ~0;
1.2 itojun 239: int nxt, ours = 0;
1.9 itojun 240: struct ifnet *deliverifp = NULL;
1.2 itojun 241:
242: #ifdef IPSEC
243: /*
244: * should the inner packet be considered authentic?
245: * see comment in ah4_input().
246: */
247: if (m) {
248: m->m_flags &= ~M_AUTHIPHDR;
249: m->m_flags &= ~M_AUTHIPDGM;
250: }
251: #endif
1.9 itojun 252:
1.2 itojun 253: /*
254: * mbuf statistics by kazu
255: */
256: if (m->m_flags & M_EXT) {
257: if (m->m_next)
258: ip6stat.ip6s_mext2m++;
259: else
260: ip6stat.ip6s_mext1++;
261: } else {
262: if (m->m_next) {
1.9 itojun 263: if (m->m_flags & M_LOOP) {
1.2 itojun 264: ip6stat.ip6s_m2m[loif[0].if_index]++; /*XXX*/
1.9 itojun 265: }
1.2 itojun 266: else if (m->m_pkthdr.rcvif->if_index <= 31)
267: ip6stat.ip6s_m2m[m->m_pkthdr.rcvif->if_index]++;
268: else
269: ip6stat.ip6s_m2m[0]++;
270: } else
271: ip6stat.ip6s_m1++;
272: }
273:
1.9 itojun 274: in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_receive);
275: ip6stat.ip6s_total++;
276:
277: #ifndef PULLDOWN_TEST
278: /* XXX is the line really necessary? */
1.2 itojun 279: IP6_EXTHDR_CHECK(m, 0, sizeof(struct ip6_hdr), /*nothing*/);
1.9 itojun 280: #endif
1.2 itojun 281:
1.9 itojun 282: if (m->m_len < sizeof(struct ip6_hdr)) {
283: struct ifnet *inifp;
284: inifp = m->m_pkthdr.rcvif;
285: if ((m = m_pullup(m, sizeof(struct ip6_hdr))) == 0) {
286: ip6stat.ip6s_toosmall++;
287: in6_ifstat_inc(inifp, ifs6_in_hdrerr);
288: return;
289: }
1.2 itojun 290: }
291:
292: ip6 = mtod(m, struct ip6_hdr *);
293:
294: if ((ip6->ip6_vfc & IPV6_VERSION_MASK) != IPV6_VERSION) {
295: ip6stat.ip6s_badvers++;
1.9 itojun 296: in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_hdrerr);
1.2 itojun 297: goto bad;
298: }
299:
300: ip6stat.ip6s_nxthist[ip6->ip6_nxt]++;
301:
1.9 itojun 302: #ifdef IPV6FIREWALL
303: /*
304: * Check with the firewall...
305: */
306: if (ip6_fw_chk_ptr) {
307: u_short port = 0;
308: /* If ipfw says divert, we have to just drop packet */
309: /* use port as a dummy argument */
310: if ((*ip6_fw_chk_ptr)(&ip6, NULL, &port, &m)) {
311: m_freem(m);
312: m = NULL;
313: }
314: if (!m)
315: return;
316: }
317: #endif
318:
1.2 itojun 319: /*
320: * Scope check
321: */
322: if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_src) ||
323: IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_dst)) {
324: ip6stat.ip6s_badscope++;
1.9 itojun 325: in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_addrerr);
1.2 itojun 326: goto bad;
327: }
328: if (IN6_IS_ADDR_LOOPBACK(&ip6->ip6_src) ||
329: IN6_IS_ADDR_LOOPBACK(&ip6->ip6_dst)) {
330: if (m->m_pkthdr.rcvif->if_flags & IFF_LOOPBACK) {
331: ours = 1;
1.9 itojun 332: deliverifp = m->m_pkthdr.rcvif;
1.2 itojun 333: goto hbhcheck;
334: } else {
335: ip6stat.ip6s_badscope++;
1.9 itojun 336: in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_addrerr);
1.2 itojun 337: goto bad;
338: }
339: }
340:
341: if (m->m_pkthdr.rcvif->if_flags & IFF_LOOPBACK) {
342: if (IN6_IS_ADDR_LINKLOCAL(&ip6->ip6_dst)) {
343: ours = 1;
1.9 itojun 344: deliverifp = m->m_pkthdr.rcvif;
1.2 itojun 345: goto hbhcheck;
346: }
347: } else {
348: if (IN6_IS_SCOPE_LINKLOCAL(&ip6->ip6_src))
349: ip6->ip6_src.s6_addr16[1]
350: = htons(m->m_pkthdr.rcvif->if_index);
351: if (IN6_IS_SCOPE_LINKLOCAL(&ip6->ip6_dst))
352: ip6->ip6_dst.s6_addr16[1]
353: = htons(m->m_pkthdr.rcvif->if_index);
354: }
355:
1.12 ! itojun 356: #ifdef PTR
1.9 itojun 357: /*
358: *
359: */
360: if (ip6_protocol_tr)
361: {
362: struct mbuf *m1 = NULL;
363:
364: switch (ptr_in6(m, &m1))
365: {
366: case IPPROTO_IP: goto mcastcheck;
367: case IPPROTO_IPV4: ip_forward(m1, 0); break;
368: case IPPROTO_IPV6: ip6_forward(m1, 0); break;
369: case IPPROTO_MAX: /* discard this packet */
370: default:
371: }
372:
373: if (m != m1)
374: m_freem(m);
375:
376: return;
377: }
378:
379: mcastcheck:
380: #endif
381:
1.2 itojun 382: /*
383: * Multicast check
384: */
385: if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) {
386: struct in6_multi *in6m = 0;
1.9 itojun 387:
388: in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_mcast);
1.2 itojun 389: /*
390: * See if we belong to the destination multicast group on the
391: * arrival interface.
392: */
393: IN6_LOOKUP_MULTI(ip6->ip6_dst, m->m_pkthdr.rcvif, in6m);
394: if (in6m)
395: ours = 1;
396: else if (!ip6_mrouter) {
397: ip6stat.ip6s_notmember++;
398: ip6stat.ip6s_cantforward++;
1.9 itojun 399: in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_discard);
1.2 itojun 400: goto bad;
401: }
1.9 itojun 402: deliverifp = m->m_pkthdr.rcvif;
1.2 itojun 403: goto hbhcheck;
404: }
405:
406: /*
407: * Unicast check
408: */
409: if (ip6_forward_rt.ro_rt == 0 ||
410: !IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst,
411: &ip6_forward_rt.ro_dst.sin6_addr)) {
412: if (ip6_forward_rt.ro_rt) {
413: RTFREE(ip6_forward_rt.ro_rt);
414: ip6_forward_rt.ro_rt = 0;
415: }
416: bzero(&ip6_forward_rt.ro_dst, sizeof(struct sockaddr_in6));
417: ip6_forward_rt.ro_dst.sin6_len = sizeof(struct sockaddr_in6);
418: ip6_forward_rt.ro_dst.sin6_family = AF_INET6;
419: ip6_forward_rt.ro_dst.sin6_addr = ip6->ip6_dst;
420:
1.9 itojun 421: rtalloc((struct route *)&ip6_forward_rt);
1.2 itojun 422: }
423:
424: #define rt6_key(r) ((struct sockaddr_in6 *)((r)->rt_nodes->rn_key))
425:
426: /*
427: * Accept the packet if the forwarding interface to the destination
428: * according to the routing table is the loopback interface,
429: * unless the associated route has a gateway.
430: * Note that this approach causes to accept a packet if there is a
431: * route to the loopback interface for the destination of the packet.
432: * But we think it's even useful in some situations, e.g. when using
433: * a special daemon which wants to intercept the packet.
434: */
435: if (ip6_forward_rt.ro_rt &&
436: (ip6_forward_rt.ro_rt->rt_flags &
437: (RTF_HOST|RTF_GATEWAY)) == RTF_HOST &&
438: #if 0
439: /*
440: * The check below is redundant since the comparison of
441: * the destination and the key of the rtentry has
442: * already done through looking up the routing table.
443: */
444: IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst,
445: &rt6_key(ip6_forward_rt.ro_rt)->sin6_addr) &&
446: #endif
1.9 itojun 447: ip6_forward_rt.ro_rt->rt_ifp->if_type == IFT_LOOP) {
1.2 itojun 448: struct in6_ifaddr *ia6 =
449: (struct in6_ifaddr *)ip6_forward_rt.ro_rt->rt_ifa;
450: /* packet to tentative address must not be received */
451: if (ia6->ia6_flags & IN6_IFF_ANYCAST)
452: m->m_flags |= M_ANYCAST6;
453: if (!(ia6->ia6_flags & IN6_IFF_NOTREADY)) {
454: /* this interface is ready */
455: ours = 1;
1.9 itojun 456: deliverifp = ia6->ia_ifp; /* correct? */
1.2 itojun 457: goto hbhcheck;
458: } else {
459: /* this interface is not ready, fall through */
460: }
461: }
462:
463: /*
464: * FAITH(Firewall Aided Internet Translator)
465: */
466: #if defined(NFAITH) && 0 < NFAITH
467: if (ip6_keepfaith) {
468: if (ip6_forward_rt.ro_rt && ip6_forward_rt.ro_rt->rt_ifp
469: && ip6_forward_rt.ro_rt->rt_ifp->if_type == IFT_FAITH) {
470: /* XXX do we need more sanity checks? */
471: ours = 1;
1.9 itojun 472: deliverifp = ip6_forward_rt.ro_rt->rt_ifp; /*faith*/
473: goto hbhcheck;
474: }
475: }
476: #endif
477:
478: #if 0
479: {
480: /*
481: * Last resort: check in6_ifaddr for incoming interface.
482: * The code is here until I update the "goto ours hack" code above
483: * working right.
484: */
485: struct ifaddr *ifa;
486: for (ifa = m->m_pkthdr.rcvif->if_addrlist.tqh_first;
487: ifa;
488: ifa = ifa->ifa_list.tqe_next) {
489: if (ifa->ifa_addr == NULL)
490: continue; /* just for safety */
491: if (ifa->ifa_addr->sa_family != AF_INET6)
492: continue;
493: if (IN6_ARE_ADDR_EQUAL(IFA_IN6(ifa), &ip6->ip6_dst)) {
494: ours = 1;
495: deliverifp = ifa->ifa_ifp;
1.2 itojun 496: goto hbhcheck;
497: }
498: }
1.9 itojun 499: }
1.2 itojun 500: #endif
501:
502: /*
503: * Now there is no reason to process the packet if it's not our own
504: * and we're not a router.
505: */
506: if (!ip6_forwarding) {
507: ip6stat.ip6s_cantforward++;
1.9 itojun 508: in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_discard);
1.2 itojun 509: goto bad;
510: }
511:
512: hbhcheck:
513: /*
514: * Process Hop-by-Hop options header if it's contained.
515: * m may be modified in ip6_hopopts_input().
516: * If a JumboPayload option is included, plen will also be modified.
517: */
518: plen = (u_int32_t)ntohs(ip6->ip6_plen);
519: if (ip6->ip6_nxt == IPPROTO_HOPOPTS) {
1.9 itojun 520: struct ip6_hbh *hbh;
521:
522: if (ip6_hopopts_input(&plen, &rtalert, &m, &off)) {
523: #if 0 /*touches NULL pointer*/
524: in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_discard);
525: #endif
1.2 itojun 526: return; /* m have already been freed */
1.9 itojun 527: }
1.2 itojun 528: /* adjust pointer */
529: ip6 = mtod(m, struct ip6_hdr *);
1.9 itojun 530: #ifndef PULLDOWN_TEST
531: /* ip6_hopopts_input() ensures that mbuf is contiguous */
532: hbh = (struct ip6_hbh *)(ip6 + 1);
533: #else
534: IP6_EXTHDR_GET(hbh, struct ip6_hbh *, m, sizeof(struct ip6_hdr),
535: sizeof(struct ip6_hbh));
536: if (hbh == NULL) {
537: ip6stat.ip6s_tooshort++;
538: return;
539: }
540: #endif
541: nxt = hbh->ip6h_nxt;
1.2 itojun 542:
543: /*
544: * accept the packet if a router alert option is included
545: * and we act as an IPv6 router.
546: */
1.5 itojun 547: if (rtalert != ~0 && ip6_forwarding)
1.2 itojun 548: ours = 1;
549: } else
550: nxt = ip6->ip6_nxt;
551:
552: /*
553: * Check that the amount of data in the buffers
554: * is as at least much as the IPv6 header would have us expect.
555: * Trim mbufs if longer than we expect.
556: * Drop packet if shorter than we expect.
557: */
558: if (m->m_pkthdr.len - sizeof(struct ip6_hdr) < plen) {
559: ip6stat.ip6s_tooshort++;
1.9 itojun 560: in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_truncated);
1.2 itojun 561: goto bad;
562: }
563: if (m->m_pkthdr.len > sizeof(struct ip6_hdr) + plen) {
564: if (m->m_len == m->m_pkthdr.len) {
565: m->m_len = sizeof(struct ip6_hdr) + plen;
566: m->m_pkthdr.len = sizeof(struct ip6_hdr) + plen;
567: } else
568: m_adj(m, sizeof(struct ip6_hdr) + plen - m->m_pkthdr.len);
569: }
570:
571: /*
572: * Forward if desirable.
573: */
574: if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) {
575: /*
576: * If we are acting as a multicast router, all
577: * incoming multicast packets are passed to the
578: * kernel-level multicast forwarding function.
579: * The packet is returned (relatively) intact; if
580: * ip6_mforward() returns a non-zero value, the packet
581: * must be discarded, else it may be accepted below.
582: */
583: if (ip6_mrouter && ip6_mforward(ip6, m->m_pkthdr.rcvif, m)) {
584: ip6stat.ip6s_cantforward++;
585: m_freem(m);
586: return;
587: }
588: if (!ours) {
589: m_freem(m);
590: return;
591: }
592: }
593: else if (!ours) {
594: ip6_forward(m, 0);
595: return;
596: }
597:
598: /*
599: * Tell launch routine the next header
600: */
1.12 ! itojun 601: #ifdef IFA_STATS
1.9 itojun 602: if (IFA_STATS && deliverifp != NULL) {
603: struct in6_ifaddr *ia6;
604: ip6 = mtod(m, struct ip6_hdr *);
605: ia6 = in6_ifawithifp(deliverifp, &ip6->ip6_dst);
606: if (ia6)
607: ia6->ia_ifa.ifa_data.ifad_inbytes += m->m_pkthdr.len;
608: }
609: #endif
1.2 itojun 610: ip6stat.ip6s_delivered++;
1.9 itojun 611: in6_ifstat_inc(deliverifp, ifs6_in_deliver);
1.2 itojun 612: nest = 0;
613: while (nxt != IPPROTO_DONE) {
614: if (ip6_hdrnestlimit && (++nest > ip6_hdrnestlimit)) {
615: ip6stat.ip6s_toomanyhdr++;
616: goto bad;
617: }
1.8 itojun 618:
619: /*
620: * protection against faulty packet - there should be
621: * more sanity checks in header chain processing.
622: */
623: if (m->m_pkthdr.len < off) {
624: ip6stat.ip6s_tooshort++;
1.9 itojun 625: in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_truncated);
1.8 itojun 626: goto bad;
627: }
628:
1.2 itojun 629: nxt = (*inet6sw[ip6_protox[nxt]].pr_input)(&m, &off, nxt);
630: }
631: return;
632: bad:
633: m_freem(m);
634: }
635:
636: /*
637: * Hop-by-Hop options header processing. If a valid jumbo payload option is
638: * included, the real payload length will be stored in plenp.
639: */
640: static int
641: ip6_hopopts_input(plenp, rtalertp, mp, offp)
642: u_int32_t *plenp;
1.5 itojun 643: u_int32_t *rtalertp; /* XXX: should be stored more smart way */
1.2 itojun 644: struct mbuf **mp;
645: int *offp;
646: {
647: register struct mbuf *m = *mp;
648: int off = *offp, hbhlen;
649: struct ip6_hbh *hbh;
650: u_int8_t *opt;
651:
652: /* validation of the length of the header */
1.9 itojun 653: #ifndef PULLDOWN_TEST
1.2 itojun 654: IP6_EXTHDR_CHECK(m, off, sizeof(*hbh), -1);
655: hbh = (struct ip6_hbh *)(mtod(m, caddr_t) + off);
656: hbhlen = (hbh->ip6h_len + 1) << 3;
657:
658: IP6_EXTHDR_CHECK(m, off, hbhlen, -1);
659: hbh = (struct ip6_hbh *)(mtod(m, caddr_t) + off);
1.9 itojun 660: #else
661: IP6_EXTHDR_GET(hbh, struct ip6_hbh *, m,
662: sizeof(struct ip6_hdr), sizeof(struct ip6_hbh));
663: if (hbh == NULL) {
664: ip6stat.ip6s_tooshort++;
665: return -1;
666: }
667: hbhlen = (hbh->ip6h_len + 1) << 3;
668: IP6_EXTHDR_GET(hbh, struct ip6_hbh *, m, sizeof(struct ip6_hdr),
669: hbhlen);
670: if (hbh == NULL) {
671: ip6stat.ip6s_tooshort++;
672: return -1;
673: }
674: #endif
1.2 itojun 675: off += hbhlen;
676: hbhlen -= sizeof(struct ip6_hbh);
677: opt = (u_int8_t *)hbh + sizeof(struct ip6_hbh);
678:
679: if (ip6_process_hopopts(m, (u_int8_t *)hbh + sizeof(struct ip6_hbh),
680: hbhlen, rtalertp, plenp) < 0)
681: return(-1);
682:
683: *offp = off;
684: *mp = m;
685: return(0);
686: }
687:
688: /*
689: * Search header for all Hop-by-hop options and process each option.
690: * This function is separate from ip6_hopopts_input() in order to
691: * handle a case where the sending node itself process its hop-by-hop
692: * options header. In such a case, the function is called from ip6_output().
693: */
694: int
695: ip6_process_hopopts(m, opthead, hbhlen, rtalertp, plenp)
696: struct mbuf *m;
697: u_int8_t *opthead;
698: int hbhlen;
1.5 itojun 699: u_int32_t *rtalertp;
1.2 itojun 700: u_int32_t *plenp;
701: {
702: struct ip6_hdr *ip6;
703: int optlen = 0;
704: u_int8_t *opt = opthead;
705: u_int16_t rtalert_val;
706:
707: for (; hbhlen > 0; hbhlen -= optlen, opt += optlen) {
708: switch(*opt) {
709: case IP6OPT_PAD1:
710: optlen = 1;
711: break;
712: case IP6OPT_PADN:
713: if (hbhlen < IP6OPT_MINLEN) {
714: ip6stat.ip6s_toosmall++;
715: goto bad;
716: }
717: optlen = *(opt + 1) + 2;
718: break;
719: case IP6OPT_RTALERT:
1.8 itojun 720: /* XXX may need check for alignment */
1.2 itojun 721: if (hbhlen < IP6OPT_RTALERT_LEN) {
722: ip6stat.ip6s_toosmall++;
723: goto bad;
724: }
725: if (*(opt + 1) != IP6OPT_RTALERT_LEN - 2)
726: /* XXX: should we discard the packet? */
727: log(LOG_ERR, "length of router alert opt is inconsitent(%d)",
728: *(opt + 1));
729: optlen = IP6OPT_RTALERT_LEN;
730: bcopy((caddr_t)(opt + 2), (caddr_t)&rtalert_val, 2);
731: *rtalertp = ntohs(rtalert_val);
732: break;
733: case IP6OPT_JUMBO:
1.8 itojun 734: /* XXX may need check for alignment */
1.2 itojun 735: if (hbhlen < IP6OPT_JUMBO_LEN) {
736: ip6stat.ip6s_toosmall++;
737: goto bad;
738: }
739: if (*(opt + 1) != IP6OPT_JUMBO_LEN - 2)
740: /* XXX: should we discard the packet? */
741: log(LOG_ERR, "length of jumbopayload opt "
742: "is inconsistent(%d)",
743: *(opt + 1));
744: optlen = IP6OPT_JUMBO_LEN;
745:
746: /*
747: * We can simply cast because of the alignment
748: * requirement of the jumbo payload option.
749: */
1.8 itojun 750: #if 0
1.2 itojun 751: *plenp = ntohl(*(u_int32_t *)(opt + 2));
1.8 itojun 752: #else
753: bcopy(opt + 2, plenp, sizeof(*plenp));
754: *plenp = htonl(*plenp);
755: #endif
1.2 itojun 756: if (*plenp <= IPV6_MAXPACKET) {
757: /*
758: * jumbo payload length must be larger
759: * than 65535
760: */
761: ip6stat.ip6s_badoptions++;
762: icmp6_error(m, ICMP6_PARAM_PROB,
763: ICMP6_PARAMPROB_HEADER,
764: sizeof(struct ip6_hdr) +
765: sizeof(struct ip6_hbh) +
766: opt + 2 - opthead);
767: return(-1);
768: }
769:
770: ip6 = mtod(m, struct ip6_hdr *);
771: if (ip6->ip6_plen) {
772: /*
773: * IPv6 packets that have non 0 payload length
774: * must not contain a jumbo paylod option.
775: */
776: ip6stat.ip6s_badoptions++;
777: icmp6_error(m, ICMP6_PARAM_PROB,
778: ICMP6_PARAMPROB_HEADER,
779: sizeof(struct ip6_hdr) +
780: sizeof(struct ip6_hbh) +
781: opt - opthead);
782: return(-1);
783: }
784: break;
785: default: /* unknown option */
786: if (hbhlen < IP6OPT_MINLEN) {
787: ip6stat.ip6s_toosmall++;
788: goto bad;
789: }
790: if ((optlen = ip6_unknown_opt(opt, m,
791: sizeof(struct ip6_hdr) +
792: sizeof(struct ip6_hbh) +
793: opt - opthead)) == -1)
794: return(-1);
795: optlen += 2;
796: break;
797: }
798: }
799:
800: return(0);
801:
802: bad:
803: m_freem(m);
804: return(-1);
805: }
806:
807: /*
808: * Unknown option processing.
809: * The third argument `off' is the offset from the IPv6 header to the option,
810: * which is necessary if the IPv6 header the and option header and IPv6 header
811: * is not continuous in order to return an ICMPv6 error.
812: */
813: int
814: ip6_unknown_opt(optp, m, off)
815: u_int8_t *optp;
816: struct mbuf *m;
817: int off;
818: {
819: struct ip6_hdr *ip6;
820:
821: switch(IP6OPT_TYPE(*optp)) {
822: case IP6OPT_TYPE_SKIP: /* ignore the option */
823: return((int)*(optp + 1));
824: case IP6OPT_TYPE_DISCARD: /* silently discard */
825: m_freem(m);
826: return(-1);
827: case IP6OPT_TYPE_FORCEICMP: /* send ICMP even if multicasted */
828: ip6stat.ip6s_badoptions++;
829: icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_OPTION, off);
830: return(-1);
831: case IP6OPT_TYPE_ICMP: /* send ICMP if not multicasted */
832: ip6stat.ip6s_badoptions++;
833: ip6 = mtod(m, struct ip6_hdr *);
834: if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst) ||
835: (m->m_flags & (M_BCAST|M_MCAST)))
836: m_freem(m);
837: else
838: icmp6_error(m, ICMP6_PARAM_PROB,
839: ICMP6_PARAMPROB_OPTION, off);
840: return(-1);
841: }
842:
843: m_freem(m); /* XXX: NOTREACHED */
844: return(-1);
845: }
846:
847: /*
1.9 itojun 848: * Create the "control" list for this pcb.
849: *
850: * The routine will be called from upper layer handlers like tcp6_input().
851: * Thus the routine assumes that the caller (tcp6_input) have already
852: * called IP6_EXTHDR_CHECK() and all the extension headers are located in the
853: * very first mbuf on the mbuf chain.
854: * We may want to add some infinite loop prevention or sanity checks for safety.
855: * (This applies only when you are using KAME mbuf chain restriction, i.e.
856: * you are using IP6_EXTHDR_CHECK() not m_pulldown())
1.2 itojun 857: */
858: void
859: ip6_savecontrol(in6p, mp, ip6, m)
860: register struct in6pcb *in6p;
861: register struct mbuf **mp;
862: register struct ip6_hdr *ip6;
863: register struct mbuf *m;
864: {
865: struct proc *p = curproc; /* XXX */
1.9 itojun 866: int privileged;
1.2 itojun 867:
1.9 itojun 868: privileged = 0;
869: if (p && !suser(p->p_ucred, &p->p_acflag))
870: privileged++;
871:
872: #ifdef SO_TIMESTAMP
1.2 itojun 873: if (in6p->in6p_socket->so_options & SO_TIMESTAMP) {
874: struct timeval tv;
875:
876: microtime(&tv);
877: *mp = sbcreatecontrol((caddr_t) &tv, sizeof(tv),
878: SCM_TIMESTAMP, SOL_SOCKET);
879: if (*mp)
880: mp = &(*mp)->m_next;
881: }
1.9 itojun 882: #endif
1.2 itojun 883: if (in6p->in6p_flags & IN6P_RECVDSTADDR) {
884: *mp = sbcreatecontrol((caddr_t) &ip6->ip6_dst,
885: sizeof(struct in6_addr), IPV6_RECVDSTADDR,
886: IPPROTO_IPV6);
887: if (*mp)
888: mp = &(*mp)->m_next;
889: }
890:
891: #ifdef noyet
892: /* options were tossed above */
893: if (in6p->in6p_flags & IN6P_RECVOPTS)
894: /* broken */
895: /* ip6_srcroute doesn't do what we want here, need to fix */
896: if (in6p->in6p_flags & IPV6P_RECVRETOPTS)
897: /* broken */
898: #endif
899:
900: /* RFC 2292 sec. 5 */
901: if (in6p->in6p_flags & IN6P_PKTINFO) {
902: struct in6_pktinfo pi6;
903: bcopy(&ip6->ip6_dst, &pi6.ipi6_addr, sizeof(struct in6_addr));
904: if (IN6_IS_SCOPE_LINKLOCAL(&pi6.ipi6_addr))
905: pi6.ipi6_addr.s6_addr16[1] = 0;
906: pi6.ipi6_ifindex = (m && m->m_pkthdr.rcvif)
907: ? m->m_pkthdr.rcvif->if_index
908: : 0;
909: *mp = sbcreatecontrol((caddr_t) &pi6,
910: sizeof(struct in6_pktinfo), IPV6_PKTINFO,
911: IPPROTO_IPV6);
912: if (*mp)
913: mp = &(*mp)->m_next;
914: }
915: if (in6p->in6p_flags & IN6P_HOPLIMIT) {
916: int hlim = ip6->ip6_hlim & 0xff;
917: *mp = sbcreatecontrol((caddr_t) &hlim,
918: sizeof(int), IPV6_HOPLIMIT, IPPROTO_IPV6);
919: if (*mp)
920: mp = &(*mp)->m_next;
921: }
922: /* IN6P_NEXTHOP - for outgoing packet only */
923:
924: /*
925: * IPV6_HOPOPTS socket option. We require super-user privilege
926: * for the option, but it might be too strict, since there might
927: * be some hop-by-hop options which can be returned to normal user.
928: * See RFC 2292 section 6.
929: */
1.9 itojun 930: if ((in6p->in6p_flags & IN6P_HOPOPTS) && privileged) {
1.2 itojun 931: /*
932: * Check if a hop-by-hop options header is contatined in the
933: * received packet, and if so, store the options as ancillary
934: * data. Note that a hop-by-hop options header must be
935: * just after the IPv6 header, which fact is assured through
936: * the IPv6 input processing.
937: */
938: struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
939: if (ip6->ip6_nxt == IPPROTO_HOPOPTS) {
1.9 itojun 940: struct ip6_hbh *hbh;
941: int hbhlen;
942:
943: #ifndef PULLDOWN_TEST
944: hbh = (struct ip6_hbh *)(ip6 + 1);
945: hbhlen = (hbh->ip6h_len + 1) << 3;
946: #else
947: IP6_EXTHDR_GET(hbh, struct ip6_hbh *, m,
948: sizeof(struct ip6_hdr), sizeof(struct ip6_hbh));
949: if (hbh == NULL) {
950: ip6stat.ip6s_tooshort++;
951: return;
952: }
953: hbhlen = (hbh->ip6h_len + 1) << 3;
954: IP6_EXTHDR_GET(hbh, struct ip6_hbh *, m,
955: sizeof(struct ip6_hdr), hbhlen);
956: if (hbh == NULL) {
957: ip6stat.ip6s_tooshort++;
958: return;
959: }
960: #endif
1.2 itojun 961:
962: /*
963: * XXX: We copy whole the header even if a jumbo
964: * payload option is included, which option is to
965: * be removed before returning in the RFC 2292.
966: * But it's too painful operation...
967: */
1.9 itojun 968: *mp = sbcreatecontrol((caddr_t)hbh, hbhlen,
1.2 itojun 969: IPV6_HOPOPTS, IPPROTO_IPV6);
970: if (*mp)
971: mp = &(*mp)->m_next;
972: }
973: }
974:
975: /* IPV6_DSTOPTS and IPV6_RTHDR socket options */
976: if (in6p->in6p_flags & (IN6P_DSTOPTS | IN6P_RTHDR)) {
977: struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
978: int nxt = ip6->ip6_nxt, off = sizeof(struct ip6_hdr);;
979:
980: /*
981: * Search for destination options headers or routing
982: * header(s) through the header chain, and stores each
983: * header as ancillary data.
984: * Note that the order of the headers remains in
985: * the chain of ancillary data.
986: */
987: while(1) { /* is explicit loop prevention necessary? */
1.9 itojun 988: struct ip6_ext *ip6e;
989: int elen;
990:
991: #ifndef PULLDOWN_TEST
992: ip6e = (struct ip6_ext *)(mtod(m, caddr_t) + off);
993: if (nxt == IPPROTO_AH)
994: elen = (ip6e->ip6e_len + 2) << 2;
995: else
996: elen = (ip6e->ip6e_len + 1) << 3;
997: #else
998: IP6_EXTHDR_GET(ip6e, struct ip6_ext *, m, off,
999: sizeof(struct ip6_ext));
1000: if (ip6e == NULL) {
1001: ip6stat.ip6s_tooshort++;
1002: return;
1003: }
1004: if (nxt == IPPROTO_AH)
1005: elen = (ip6e->ip6e_len + 2) << 2;
1006: else
1007: elen = (ip6e->ip6e_len + 1) << 3;
1008: IP6_EXTHDR_GET(ip6e, struct ip6_ext *, m, off, elen);
1009: if (ip6e == NULL) {
1010: ip6stat.ip6s_tooshort++;
1011: return;
1012: }
1013: #endif
1.2 itojun 1014:
1015: switch(nxt) {
1016: case IPPROTO_DSTOPTS:
1017: if (!in6p->in6p_flags & IN6P_DSTOPTS)
1018: break;
1019:
1020: /*
1021: * We also require super-user privilege for
1022: * the option.
1023: * See the comments on IN6_HOPOPTS.
1024: */
1.9 itojun 1025: if (!privileged)
1.2 itojun 1026: break;
1027:
1.9 itojun 1028: *mp = sbcreatecontrol((caddr_t)ip6e, elen,
1.2 itojun 1029: IPV6_DSTOPTS,
1030: IPPROTO_IPV6);
1031: if (*mp)
1032: mp = &(*mp)->m_next;
1033: break;
1034:
1035: case IPPROTO_ROUTING:
1036: if (!in6p->in6p_flags & IN6P_RTHDR)
1037: break;
1038:
1.9 itojun 1039: *mp = sbcreatecontrol((caddr_t)ip6e, elen,
1.2 itojun 1040: IPV6_RTHDR,
1041: IPPROTO_IPV6);
1042: if (*mp)
1043: mp = &(*mp)->m_next;
1044: break;
1045:
1046: case IPPROTO_UDP:
1047: case IPPROTO_TCP:
1048: case IPPROTO_ICMPV6:
1049: default:
1050: /*
1051: * stop search if we encounter an upper
1052: * layer protocol headers.
1053: */
1054: goto loopend;
1055:
1056: case IPPROTO_HOPOPTS:
1057: case IPPROTO_AH: /* is it possible? */
1058: break;
1059: }
1060:
1061: /* proceed with the next header. */
1.9 itojun 1062: off += elen;
1.2 itojun 1063: nxt = ip6e->ip6e_nxt;
1064: }
1065: loopend:
1066: }
1.9 itojun 1067: if ((in6p->in6p_flags & IN6P_HOPOPTS) && privileged) {
1.2 itojun 1068: /* to be done */
1069: }
1.9 itojun 1070: if ((in6p->in6p_flags & IN6P_DSTOPTS) && privileged) {
1.2 itojun 1071: /* to be done */
1072: }
1073: /* IN6P_RTHDR - to be done */
1074:
1075: }
1076:
1077: /*
1078: * Get pointer to the previous header followed by the header
1079: * currently processed.
1080: * XXX: This function supposes that
1081: * M includes all headers,
1082: * the next header field and the header length field of each header
1083: * are valid, and
1084: * the sum of each header length equals to OFF.
1085: * Because of these assumptions, this function must be called very
1086: * carefully. Moreover, it will not be used in the near future when
1087: * we develop `neater' mechanism to process extension headers.
1088: */
1089: char *
1090: ip6_get_prevhdr(m, off)
1091: struct mbuf *m;
1092: int off;
1093: {
1094: struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
1095:
1096: if (off == sizeof(struct ip6_hdr))
1097: return(&ip6->ip6_nxt);
1098: else {
1099: int len, nxt;
1100: struct ip6_ext *ip6e = NULL;
1101:
1102: nxt = ip6->ip6_nxt;
1103: len = sizeof(struct ip6_hdr);
1104: while (len < off) {
1105: ip6e = (struct ip6_ext *)(mtod(m, caddr_t) + len);
1106:
1107: switch(nxt) {
1108: case IPPROTO_FRAGMENT:
1109: len += sizeof(struct ip6_frag);
1110: break;
1111: case IPPROTO_AH:
1112: len += (ip6e->ip6e_len + 2) << 2;
1113: break;
1114: default:
1115: len += (ip6e->ip6e_len + 1) << 3;
1116: break;
1117: }
1118: nxt = ip6e->ip6e_nxt;
1119: }
1120: if (ip6e)
1121: return(&ip6e->ip6e_nxt);
1122: else
1123: return NULL;
1124: }
1125: }
1126:
1127: /*
1128: * System control for IP6
1129: */
1130:
1131: u_char inet6ctlerrmap[PRC_NCMDS] = {
1132: 0, 0, 0, 0,
1133: 0, EMSGSIZE, EHOSTDOWN, EHOSTUNREACH,
1134: EHOSTUNREACH, EHOSTUNREACH, ECONNREFUSED, ECONNREFUSED,
1135: EMSGSIZE, EHOSTUNREACH, 0, 0,
1136: 0, 0, 0, 0,
1137: ENOPROTOOPT
1138: };
1139:
1140: #include <vm/vm.h>
1141: #include <sys/sysctl.h>
1142:
1143: int
1144: ip6_sysctl(name, namelen, oldp, oldlenp, newp, newlen)
1145: int *name;
1146: u_int namelen;
1147: void *oldp;
1148: size_t *oldlenp;
1149: void *newp;
1150: size_t newlen;
1151: {
1152: /* All sysctl names at this level are terminal. */
1153: if (namelen != 1)
1154: return ENOTDIR;
1155:
1156: switch (name[0]) {
1157:
1158: case IPV6CTL_FORWARDING:
1159: return sysctl_int(oldp, oldlenp, newp, newlen,
1160: &ip6_forwarding);
1161: case IPV6CTL_SENDREDIRECTS:
1162: return sysctl_int(oldp, oldlenp, newp, newlen,
1163: &ip6_sendredirects);
1164: case IPV6CTL_DEFHLIM:
1165: return sysctl_int(oldp, oldlenp, newp, newlen, &ip6_defhlim);
1166: case IPV6CTL_MAXFRAGPACKETS:
1167: return sysctl_int(oldp, oldlenp, newp, newlen,
1168: &ip6_maxfragpackets);
1169: case IPV6CTL_ACCEPT_RTADV:
1170: return sysctl_int(oldp, oldlenp, newp, newlen,
1171: &ip6_accept_rtadv);
1172: case IPV6CTL_KEEPFAITH:
1173: return sysctl_int(oldp, oldlenp, newp, newlen, &ip6_keepfaith);
1174: case IPV6CTL_LOG_INTERVAL:
1175: return sysctl_int(oldp, oldlenp, newp, newlen,
1176: &ip6_log_interval);
1177: case IPV6CTL_HDRNESTLIMIT:
1178: return sysctl_int(oldp, oldlenp, newp, newlen,
1179: &ip6_hdrnestlimit);
1180: case IPV6CTL_DAD_COUNT:
1181: return sysctl_int(oldp, oldlenp, newp, newlen, &ip6_dad_count);
1182: case IPV6CTL_AUTO_FLOWLABEL:
1183: return sysctl_int(oldp, oldlenp, newp, newlen,
1184: &ip6_auto_flowlabel);
1185: case IPV6CTL_DEFMCASTHLIM:
1186: return sysctl_int(oldp, oldlenp, newp, newlen,
1187: &ip6_defmcasthlim);
1188: case IPV6CTL_GIF_HLIM:
1189: return sysctl_int(oldp, oldlenp, newp, newlen,
1190: &ip6_gif_hlim);
1191: case IPV6CTL_KAME_VERSION:
1192: return sysctl_rdstring(oldp, oldlenp, newp, __KAME_VERSION);
1.9 itojun 1193: case IPV6CTL_USE_DEPRECATED:
1194: return sysctl_int(oldp, oldlenp, newp, newlen,
1195: &ip6_use_deprecated);
1.10 itojun 1196: case IPV6CTL_RR_PRUNE:
1197: return sysctl_int(oldp, oldlenp, newp, newlen, &ip6_rr_prune);
1.12 ! itojun 1198: #ifndef INET6_BINDV6ONLY
1.11 itojun 1199: case IPV6CTL_BINDV6ONLY:
1200: return sysctl_int(oldp, oldlenp, newp, newlen,
1201: &ip6_bindv6only);
1202: #endif
1.2 itojun 1203: default:
1204: return EOPNOTSUPP;
1205: }
1206: /* NOTREACHED */
1207: }
CVSweb <webmaster@jp.NetBSD.org>