raw_ip6.c revision 1.11.8.1 1 /* $NetBSD: raw_ip6.c,v 1.11.8.1 1999/12/27 18:36:28 wrstuden Exp $ */
2
3 /*
4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the project nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32 /*
33 * Copyright (c) 1982, 1986, 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 * @(#)raw_ip.c 8.2 (Berkeley) 1/4/94
65 */
66
67 #ifdef __NetBSD__ /*XXX*/
68 #include "opt_ipsec.h"
69 #endif
70
71 #include <sys/param.h>
72 #include <sys/malloc.h>
73 #include <sys/mbuf.h>
74 #include <sys/socket.h>
75 #include <sys/protosw.h>
76 #include <sys/socketvar.h>
77 #include <sys/errno.h>
78 #include <sys/systm.h>
79 #ifdef __NetBSD__
80 #include <sys/proc.h>
81 #endif
82
83 #include <net/if.h>
84 #include <net/route.h>
85 #include <net/if_types.h>
86
87 #include <netinet/in.h>
88 #include <netinet/in_var.h>
89 #include <netinet6/ip6.h>
90 #include <netinet6/ip6_var.h>
91 #include <netinet6/ip6_mroute.h>
92 #include <netinet6/icmp6.h>
93 #include <netinet6/in6_pcb.h>
94 #include <netinet6/nd6.h>
95
96 #ifdef IPSEC
97 #include <netinet6/ipsec.h>
98 #endif /*IPSEC*/
99
100 #include <machine/stdarg.h>
101
102 #include "faith.h"
103
104 struct in6pcb rawin6pcb;
105 #define ifatoia6(ifa) ((struct in6_ifaddr *)(ifa))
106
107 /*
108 * Raw interface to IP6 protocol.
109 */
110
111 /*
112 * Initialize raw connection block queue.
113 */
114 void
115 rip6_init()
116 {
117 rawin6pcb.in6p_next = rawin6pcb.in6p_prev = &rawin6pcb;
118 }
119
120 /*
121 * Setup generic address and protocol structures
122 * for raw_input routine, then pass them along with
123 * mbuf chain.
124 */
125 int
126 rip6_input(mp, offp, proto)
127 struct mbuf **mp;
128 int *offp, proto;
129 {
130 struct mbuf *m = *mp;
131 register struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
132 register struct in6pcb *in6p;
133 struct in6pcb *last = NULL;
134 struct sockaddr_in6 rip6src;
135 struct mbuf *opts = NULL;
136
137 #if defined(NFAITH) && 0 < NFAITH
138 if (m->m_pkthdr.rcvif) {
139 if (m->m_pkthdr.rcvif->if_type == IFT_FAITH) {
140 /* send icmp6 host unreach? */
141 m_freem(m);
142 return IPPROTO_DONE;
143 }
144 }
145 #endif
146 bzero(&rip6src, sizeof(rip6src));
147 rip6src.sin6_len = sizeof(struct sockaddr_in6);
148 rip6src.sin6_family = AF_INET6;
149 rip6src.sin6_addr = ip6->ip6_src;
150 if (IN6_IS_SCOPE_LINKLOCAL(&rip6src.sin6_addr))
151 rip6src.sin6_addr.s6_addr16[1] = 0;
152 if (m->m_pkthdr.rcvif) {
153 if (IN6_IS_SCOPE_LINKLOCAL(&rip6src.sin6_addr))
154 rip6src.sin6_scope_id = m->m_pkthdr.rcvif->if_index;
155 else
156 rip6src.sin6_scope_id = 0;
157 } else
158 rip6src.sin6_scope_id = 0;
159
160 for (in6p = rawin6pcb.in6p_next;
161 in6p != &rawin6pcb; in6p = in6p->in6p_next) {
162 if (in6p->in6p_ip6.ip6_nxt &&
163 in6p->in6p_ip6.ip6_nxt != proto)
164 continue;
165 if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_laddr) &&
166 !IN6_ARE_ADDR_EQUAL(&in6p->in6p_laddr, &ip6->ip6_dst))
167 continue;
168 if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr) &&
169 !IN6_ARE_ADDR_EQUAL(&in6p->in6p_faddr, &ip6->ip6_src))
170 continue;
171 if (in6p->in6p_cksum != -1
172 && in6_cksum(m, ip6->ip6_nxt, *offp, m->m_pkthdr.len - *offp))
173 {
174 /* XXX bark something */
175 continue;
176 }
177 if (last) {
178 struct mbuf *n;
179 if ((n = m_copy(m, 0, (int)M_COPYALL)) != NULL) {
180 if (last->in6p_flags & IN6P_CONTROLOPTS)
181 ip6_savecontrol(last, &opts, ip6, n);
182 /* strip intermediate headers */
183 m_adj(n, *offp);
184 if (sbappendaddr(&last->in6p_socket->so_rcv,
185 (struct sockaddr *)&rip6src,
186 n, opts) == 0) {
187 /* should notify about lost packet */
188 m_freem(n);
189 if (opts)
190 m_freem(opts);
191 } else
192 sorwakeup(last->in6p_socket);
193 opts = NULL;
194 }
195 }
196 last = in6p;
197 }
198 if (last) {
199 if (last->in6p_flags & IN6P_CONTROLOPTS)
200 ip6_savecontrol(last, &opts, ip6, m);
201 /* strip intermediate headers */
202 m_adj(m, *offp);
203 if (sbappendaddr(&last->in6p_socket->so_rcv,
204 (struct sockaddr *)&rip6src, m, opts) == 0) {
205 m_freem(m);
206 if (opts)
207 m_freem(opts);
208 } else
209 sorwakeup(last->in6p_socket);
210 } else {
211 if (proto == IPPROTO_NONE)
212 m_freem(m);
213 else {
214 char *prvnxtp = ip6_get_prevhdr(m, *offp); /* XXX */
215 icmp6_error(m, ICMP6_PARAM_PROB,
216 ICMP6_PARAMPROB_NEXTHEADER,
217 prvnxtp - mtod(m, char *));
218 }
219 ip6stat.ip6s_delivered--;
220 }
221 return IPPROTO_DONE;
222 }
223
224 /*
225 * Generate IPv6 header and pass packet to ip6_output.
226 * Tack on options user may have setup with control call.
227 */
228 int
229 #if __STDC__
230 rip6_output(struct mbuf *m, ...)
231 #else
232 rip6_output(m, va_alist)
233 struct mbuf *m;
234 va_dcl
235 #endif
236 {
237 struct socket *so;
238 struct sockaddr_in6 *dstsock;
239 struct mbuf *control;
240 struct in6_addr *dst;
241 struct ip6_hdr *ip6;
242 struct in6pcb *in6p;
243 u_int plen = m->m_pkthdr.len;
244 int error = 0;
245 struct ip6_pktopts opt, *optp = NULL;
246 struct ifnet *oifp = NULL;
247 int type, code; /* for ICMPv6 output statistics only */
248 int priv;
249 va_list ap;
250
251 va_start(ap, m);
252 so = va_arg(ap, struct socket *);
253 dstsock = va_arg(ap, struct sockaddr_in6 *);
254 control = va_arg(ap, struct mbuf *);
255 va_end(ap);
256
257 in6p = sotoin6pcb(so);
258
259 priv = 0;
260 {
261 struct proc *p = curproc; /* XXX */
262
263 if (p && !suser(p->p_ucred, &p->p_acflag))
264 priv = 1;
265 }
266 dst = &dstsock->sin6_addr;
267 if (control) {
268 if ((error = ip6_setpktoptions(control, &opt, priv)) != 0)
269 goto bad;
270 optp = &opt;
271 } else
272 optp = in6p->in6p_outputopts;
273
274 /*
275 * For an ICMPv6 packet, we should know its type and code
276 * to update statistics.
277 */
278 if (so->so_proto->pr_protocol == IPPROTO_ICMPV6) {
279 struct icmp6_hdr *icmp6;
280 if (m->m_len < sizeof(struct icmp6_hdr) &&
281 (m = m_pullup(m, sizeof(struct icmp6_hdr))) == NULL) {
282 error = ENOBUFS;
283 goto bad;
284 }
285 icmp6 = mtod(m, struct icmp6_hdr *);
286 type = icmp6->icmp6_type;
287 code = icmp6->icmp6_code;
288 }
289
290 M_PREPEND(m, sizeof(*ip6), M_WAIT);
291 ip6 = mtod(m, struct ip6_hdr *);
292
293 /*
294 * Next header might not be ICMP6 but use its pseudo header anyway.
295 */
296 ip6->ip6_dst = *dst;
297
298 /*
299 * If the scope of the destination is link-local, embed the interface
300 * index in the address.
301 *
302 * XXX advanced-api value overrides sin6_scope_id
303 */
304 if (IN6_IS_ADDR_LINKLOCAL(&ip6->ip6_dst) ||
305 IN6_IS_ADDR_MC_LINKLOCAL(&ip6->ip6_dst)) {
306 struct in6_pktinfo *pi;
307
308 /*
309 * XXX Boundary check is assumed to be already done in
310 * ip6_setpktoptions().
311 */
312 if (optp && (pi = optp->ip6po_pktinfo) && pi->ipi6_ifindex) {
313 ip6->ip6_dst.s6_addr16[1] = htons(pi->ipi6_ifindex);
314 oifp = ifindex2ifnet[pi->ipi6_ifindex];
315 }
316 else if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst) &&
317 in6p->in6p_moptions &&
318 in6p->in6p_moptions->im6o_multicast_ifp) {
319 oifp = in6p->in6p_moptions->im6o_multicast_ifp;
320 ip6->ip6_dst.s6_addr16[1] = htons(oifp->if_index);
321 } else if (dstsock->sin6_scope_id) {
322 /* boundary check */
323 if (dstsock->sin6_scope_id < 0
324 || if_index < dstsock->sin6_scope_id) {
325 error = ENXIO; /* XXX EINVAL? */
326 goto bad;
327 }
328 ip6->ip6_dst.s6_addr16[1]
329 = htons(dstsock->sin6_scope_id & 0xffff);/*XXX*/
330 }
331 }
332
333 /*
334 * Source address selection.
335 */
336 {
337 struct in6_addr *in6a;
338
339 if ((in6a = in6_selectsrc(dstsock, optp,
340 in6p->in6p_moptions,
341 &in6p->in6p_route,
342 &in6p->in6p_laddr,
343 &error)) == 0) {
344 if (error == 0)
345 error = EADDRNOTAVAIL;
346 goto bad;
347 }
348 ip6->ip6_src = *in6a;
349 if (in6p->in6p_route.ro_rt)
350 oifp = ifindex2ifnet[in6p->in6p_route.ro_rt->rt_ifp->if_index];
351 }
352
353 ip6->ip6_flow = in6p->in6p_flowinfo & IPV6_FLOWINFO_MASK;
354 ip6->ip6_vfc &= ~IPV6_VERSION_MASK;
355 ip6->ip6_vfc |= IPV6_VERSION;
356 #if 0 /* ip6_plen will be filled in ip6_output. */
357 ip6->ip6_plen = htons((u_short)plen);
358 #endif
359 ip6->ip6_nxt = in6p->in6p_ip6.ip6_nxt;
360 ip6->ip6_hlim = in6_selecthlim(in6p, oifp);
361
362 if (so->so_proto->pr_protocol == IPPROTO_ICMPV6 ||
363 in6p->in6p_cksum != -1) {
364 struct mbuf *n;
365 int off;
366 u_int16_t *p;
367
368 #define offsetof(type, member) ((size_t)(&((type *)0)->member)) /* XXX */
369
370 /* compute checksum */
371 if (so->so_proto->pr_protocol == IPPROTO_ICMPV6)
372 off = offsetof(struct icmp6_hdr, icmp6_cksum);
373 else
374 off = in6p->in6p_cksum;
375 if (plen < off + 1) {
376 error = EINVAL;
377 goto bad;
378 }
379 off += sizeof(struct ip6_hdr);
380
381 n = m;
382 while (n && n->m_len <= off) {
383 off -= n->m_len;
384 n = n->m_next;
385 }
386 if (!n)
387 goto bad;
388 p = (u_int16_t *)(mtod(n, caddr_t) + off);
389 *p = 0;
390 *p = in6_cksum(m, ip6->ip6_nxt, sizeof(*ip6), plen);
391 }
392
393 #ifdef IPSEC
394 m->m_pkthdr.rcvif = (struct ifnet *)so;
395 #endif /*IPSEC*/
396
397 error = ip6_output(m, optp, &in6p->in6p_route, 0, in6p->in6p_moptions,
398 &oifp);
399 if (so->so_proto->pr_protocol == IPPROTO_ICMPV6) {
400 if (oifp)
401 icmp6_ifoutstat_inc(oifp, type, code);
402 icmp6stat.icp6s_outhist[type]++;
403 }
404
405 goto freectl;
406
407 bad:
408 if (m)
409 m_freem(m);
410
411 freectl:
412 if (optp == &opt && optp->ip6po_rthdr && optp->ip6po_route.ro_rt)
413 RTFREE(optp->ip6po_route.ro_rt);
414 if (control)
415 m_freem(control);
416 return(error);
417 }
418
419 /*
420 * Raw IPv6 socket option processing.
421 */
422 int
423 rip6_ctloutput(op, so, level, optname, m)
424 int op;
425 struct socket *so;
426 int level, optname;
427 struct mbuf **m;
428 {
429 int error = 0;
430
431 switch(level) {
432 case IPPROTO_IPV6:
433 switch(optname) {
434 case MRT6_INIT:
435 case MRT6_DONE:
436 case MRT6_ADD_MIF:
437 case MRT6_DEL_MIF:
438 case MRT6_ADD_MFC:
439 case MRT6_DEL_MFC:
440 case MRT6_PIM:
441 if (op == PRCO_SETOPT) {
442 error = ip6_mrouter_set(optname, so, *m);
443 if (*m)
444 (void)m_free(*m);
445 } else if (op == PRCO_GETOPT) {
446 error = ip6_mrouter_get(optname, so, m);
447 } else
448 error = EINVAL;
449 return (error);
450 }
451 return (ip6_ctloutput(op, so, level, optname, m));
452 /* NOTREACHED */
453
454 case IPPROTO_ICMPV6:
455 /*
456 * XXX: is it better to call icmp6_ctloutput() directly
457 * from protosw?
458 */
459 return(icmp6_ctloutput(op, so, level, optname, m));
460
461 default:
462 if (op == PRCO_SETOPT && *m)
463 (void)m_free(*m);
464 return(EINVAL);
465 }
466 }
467
468 extern u_long rip6_sendspace;
469 extern u_long rip6_recvspace;
470
471 int
472 rip6_usrreq(so, req, m, nam, control, p)
473 register struct socket *so;
474 int req;
475 struct mbuf *m, *nam, *control;
476 struct proc *p;
477 {
478 register struct in6pcb *in6p = sotoin6pcb(so);
479 int s;
480 int error = 0;
481 /* extern struct socket *ip6_mrouter; */ /* xxx */
482 int priv;
483
484 priv = 0;
485 if (p && !suser(p->p_ucred, &p->p_acflag))
486 priv++;
487
488 if (req == PRU_CONTROL)
489 return (in6_control(so, (u_long)m, (caddr_t)nam,
490 (struct ifnet *)control, p));
491
492 switch (req) {
493 case PRU_ATTACH:
494 if (in6p)
495 panic("rip6_attach");
496 if (!priv) {
497 error = EACCES;
498 break;
499 }
500 s = splsoftnet();
501 if ((error = soreserve(so, rip6_sendspace, rip6_recvspace)) ||
502 (error = in6_pcballoc(so, &rawin6pcb))) {
503 splx(s);
504 break;
505 }
506 splx(s);
507 in6p = sotoin6pcb(so);
508 in6p->in6p_ip6.ip6_nxt = (long)nam;
509 in6p->in6p_cksum = -1;
510 #ifdef IPSEC
511 error = ipsec_init_policy(&in6p->in6p_sp);
512 if (error != 0) {
513 in6_pcbdetach(in6p);
514 break;
515 }
516 #endif /*IPSEC*/
517
518 MALLOC(in6p->in6p_icmp6filt, struct icmp6_filter *,
519 sizeof(struct icmp6_filter), M_PCB, M_NOWAIT);
520 if (in6p->in6p_icmp6filt == NULL) {
521 in6_pcbdetach(in6p);
522 error = ENOMEM;
523 break;
524 }
525 ICMP6_FILTER_SETPASSALL(in6p->in6p_icmp6filt);
526 break;
527
528 case PRU_DISCONNECT:
529 if ((so->so_state & SS_ISCONNECTED) == 0) {
530 error = ENOTCONN;
531 break;
532 }
533 in6p->in6p_faddr = in6addr_any;
534 so->so_state &= ~SS_ISCONNECTED; /* XXX */
535 break;
536
537 case PRU_ABORT:
538 soisdisconnected(so);
539 /* Fallthrough */
540 case PRU_DETACH:
541 if (in6p == 0)
542 panic("rip6_detach");
543 if (so == ip6_mrouter)
544 ip6_mrouter_done();
545 /* xxx: RSVP */
546 if (in6p->in6p_icmp6filt) {
547 FREE(in6p->in6p_icmp6filt, M_PCB);
548 in6p->in6p_icmp6filt = NULL;
549 }
550 in6_pcbdetach(in6p);
551 break;
552
553 case PRU_BIND:
554 {
555 struct sockaddr_in6 *addr = mtod(nam, struct sockaddr_in6 *);
556 struct ifaddr *ia = NULL;
557
558 if (nam->m_len != sizeof(*addr)) {
559 error = EINVAL;
560 break;
561 }
562 if ((ifnet.tqh_first == 0) ||
563 (addr->sin6_family != AF_INET6) ||
564 (!IN6_IS_ADDR_UNSPECIFIED(&addr->sin6_addr) &&
565 (ia = ifa_ifwithaddr((struct sockaddr *)addr)) == 0)) {
566 error = EADDRNOTAVAIL;
567 break;
568 }
569 if (ia &&
570 ((struct in6_ifaddr *)ia)->ia6_flags &
571 (IN6_IFF_ANYCAST|IN6_IFF_NOTREADY|
572 IN6_IFF_DETACHED|IN6_IFF_DEPRECATED)) {
573 error = EADDRNOTAVAIL;
574 break;
575 }
576 in6p->in6p_laddr = addr->sin6_addr;
577 break;
578 }
579
580 case PRU_CONNECT:
581 {
582 struct sockaddr_in6 *addr = mtod(nam, struct sockaddr_in6 *);
583 struct in6_addr *in6a = NULL;
584
585 if (nam->m_len != sizeof(*addr)) {
586 error = EINVAL;
587 break;
588 }
589 if (ifnet.tqh_first == 0) {
590 error = EADDRNOTAVAIL;
591 break;
592 }
593 if (addr->sin6_family != AF_INET6) {
594 error = EAFNOSUPPORT;
595 break;
596 }
597
598 /* Source address selection. XXX: need pcblookup? */
599 in6a = in6_selectsrc(addr, in6p->in6p_outputopts,
600 in6p->in6p_moptions,
601 &in6p->in6p_route,
602 &in6p->in6p_laddr,
603 &error);
604 if (in6a == NULL) {
605 if (error == 0)
606 error = EADDRNOTAVAIL;
607 break;
608 }
609 in6p->in6p_laddr = *in6a;
610 in6p->in6p_faddr = addr->sin6_addr;
611 soisconnected(so);
612 break;
613 }
614
615 case PRU_CONNECT2:
616 error = EOPNOTSUPP;
617 break;
618
619 /*
620 * Mark the connection as being incapable of futther input.
621 */
622 case PRU_SHUTDOWN:
623 socantsendmore(so);
624 break;
625 /*
626 * Ship a packet out. The appropriate raw output
627 * routine handles any messaging necessary.
628 */
629 case PRU_SEND:
630 {
631 struct sockaddr_in6 tmp;
632 struct sockaddr_in6 *dst;
633
634 if (so->so_state & SS_ISCONNECTED) {
635 if (nam) {
636 error = EISCONN;
637 break;
638 }
639 /* XXX */
640 bzero(&tmp, sizeof(tmp));
641 tmp.sin6_family = AF_INET6;
642 tmp.sin6_len = sizeof(struct sockaddr_in6);
643 bcopy(&in6p->in6p_faddr, &tmp.sin6_addr,
644 sizeof(struct in6_addr));
645 dst = &tmp;
646 } else {
647 if (nam == NULL) {
648 error = ENOTCONN;
649 break;
650 }
651 dst = mtod(nam, struct sockaddr_in6 *);
652 }
653 error = rip6_output(m, so, dst, control);
654 m = NULL;
655 break;
656 }
657
658 case PRU_SENSE:
659 /*
660 * stat: don't bother with a blocksize
661 */
662 return(0);
663 /*
664 * Not supported.
665 */
666 case PRU_RCVOOB:
667 case PRU_RCVD:
668 case PRU_LISTEN:
669 case PRU_ACCEPT:
670 case PRU_SENDOOB:
671 error = EOPNOTSUPP;
672 break;
673
674 case PRU_SOCKADDR:
675 in6_setsockaddr(in6p, nam);
676 break;
677
678 case PRU_PEERADDR:
679 in6_setpeeraddr(in6p, nam);
680 break;
681
682 default:
683 panic("rip6_usrreq");
684 }
685 if (m != NULL)
686 m_freem(m);
687 return(error);
688 }
689