Home | History | Annotate | Line # | Download | only in netinet6
udp6_usrreq.c revision 1.44.2.2
      1  1.44.2.2  thorpej /*	$NetBSD: udp6_usrreq.c,v 1.44.2.2 2002/01/10 20:03:33 thorpej Exp $	*/
      2      1.43   itojun /*	$KAME: udp6_usrreq.c,v 1.86 2001/05/27 17:33:00 itojun Exp $	*/
      3       1.3  thorpej 
      4       1.2   itojun /*
      5       1.2   itojun  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
      6       1.2   itojun  * All rights reserved.
      7      1.27   itojun  *
      8       1.2   itojun  * Redistribution and use in source and binary forms, with or without
      9       1.2   itojun  * modification, are permitted provided that the following conditions
     10       1.2   itojun  * are met:
     11       1.2   itojun  * 1. Redistributions of source code must retain the above copyright
     12       1.2   itojun  *    notice, this list of conditions and the following disclaimer.
     13       1.2   itojun  * 2. Redistributions in binary form must reproduce the above copyright
     14       1.2   itojun  *    notice, this list of conditions and the following disclaimer in the
     15       1.2   itojun  *    documentation and/or other materials provided with the distribution.
     16       1.2   itojun  * 3. Neither the name of the project nor the names of its contributors
     17       1.2   itojun  *    may be used to endorse or promote products derived from this software
     18       1.2   itojun  *    without specific prior written permission.
     19      1.27   itojun  *
     20       1.2   itojun  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
     21       1.2   itojun  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     22       1.2   itojun  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     23       1.2   itojun  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
     24       1.2   itojun  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     25       1.2   itojun  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     26       1.2   itojun  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     27       1.2   itojun  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     28       1.2   itojun  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     29       1.2   itojun  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     30       1.2   itojun  * SUCH DAMAGE.
     31       1.2   itojun  */
     32       1.2   itojun 
     33       1.2   itojun /*
     34       1.2   itojun  * Copyright (c) 1982, 1986, 1989, 1993
     35       1.2   itojun  *	The Regents of the University of California.  All rights reserved.
     36       1.2   itojun  *
     37       1.2   itojun  * Redistribution and use in source and binary forms, with or without
     38       1.2   itojun  * modification, are permitted provided that the following conditions
     39       1.2   itojun  * are met:
     40       1.2   itojun  * 1. Redistributions of source code must retain the above copyright
     41       1.2   itojun  *    notice, this list of conditions and the following disclaimer.
     42       1.2   itojun  * 2. Redistributions in binary form must reproduce the above copyright
     43       1.2   itojun  *    notice, this list of conditions and the following disclaimer in the
     44       1.2   itojun  *    documentation and/or other materials provided with the distribution.
     45       1.2   itojun  * 3. All advertising materials mentioning features or use of this software
     46       1.2   itojun  *    must display the following acknowledgement:
     47       1.2   itojun  *	This product includes software developed by the University of
     48       1.2   itojun  *	California, Berkeley and its contributors.
     49       1.2   itojun  * 4. Neither the name of the University nor the names of its contributors
     50       1.2   itojun  *    may be used to endorse or promote products derived from this software
     51       1.2   itojun  *    without specific prior written permission.
     52       1.2   itojun  *
     53       1.2   itojun  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     54       1.2   itojun  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     55       1.2   itojun  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     56       1.2   itojun  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     57       1.2   itojun  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     58       1.2   itojun  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     59       1.2   itojun  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     60       1.2   itojun  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     61       1.2   itojun  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     62       1.2   itojun  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     63       1.2   itojun  * SUCH DAMAGE.
     64       1.2   itojun  *
     65       1.2   itojun  *	@(#)udp_var.h	8.1 (Berkeley) 6/10/93
     66       1.2   itojun  */
     67       1.5  thorpej 
     68  1.44.2.2  thorpej #include <sys/cdefs.h>
     69  1.44.2.2  thorpej __KERNEL_RCSID(0, "$NetBSD: udp6_usrreq.c,v 1.44.2.2 2002/01/10 20:03:33 thorpej Exp $");
     70  1.44.2.2  thorpej 
     71       1.5  thorpej #include "opt_ipsec.h"
     72       1.2   itojun 
     73       1.2   itojun #include <sys/param.h>
     74       1.2   itojun #include <sys/malloc.h>
     75       1.2   itojun #include <sys/mbuf.h>
     76       1.2   itojun #include <sys/protosw.h>
     77       1.2   itojun #include <sys/socket.h>
     78       1.2   itojun #include <sys/socketvar.h>
     79       1.2   itojun #include <sys/errno.h>
     80       1.2   itojun #include <sys/stat.h>
     81       1.2   itojun #include <sys/systm.h>
     82       1.2   itojun #include <sys/proc.h>
     83       1.8   itojun #include <sys/syslog.h>
     84  1.44.2.2  thorpej #include <sys/sysctl.h>
     85       1.2   itojun 
     86       1.2   itojun #include <net/if.h>
     87       1.2   itojun #include <net/route.h>
     88       1.2   itojun #include <net/if_types.h>
     89       1.2   itojun 
     90       1.2   itojun #include <netinet/in.h>
     91       1.2   itojun #include <netinet/in_var.h>
     92      1.14   itojun #include <netinet/in_systm.h>
     93      1.14   itojun #include <netinet/ip.h>
     94      1.14   itojun #include <netinet/ip_var.h>
     95      1.14   itojun #include <netinet/in_pcb.h>
     96      1.14   itojun #include <netinet/udp.h>
     97      1.14   itojun #include <netinet/udp_var.h>
     98      1.23   itojun #include <netinet/ip6.h>
     99      1.27   itojun #include <netinet6/ip6_var.h>
    100       1.2   itojun #include <netinet6/in6_pcb.h>
    101      1.23   itojun #include <netinet/icmp6.h>
    102       1.2   itojun #include <netinet6/udp6_var.h>
    103      1.14   itojun #include <netinet6/ip6protosw.h>
    104       1.2   itojun 
    105       1.2   itojun #ifdef IPSEC
    106       1.2   itojun #include <netinet6/ipsec.h>
    107  1.44.2.2  thorpej #endif /* IPSEC */
    108       1.2   itojun 
    109       1.2   itojun #include "faith.h"
    110      1.41   itojun #if defined(NFAITH) && NFAITH > 0
    111      1.41   itojun #include <net/if_faith.h>
    112      1.41   itojun #endif
    113       1.2   itojun 
    114       1.2   itojun /*
    115       1.2   itojun  * UDP protocol inplementation.
    116       1.2   itojun  * Per RFC 768, August, 1980.
    117       1.2   itojun  */
    118       1.2   itojun 
    119       1.2   itojun struct	in6pcb *udp6_last_in6pcb = &udb6;
    120       1.2   itojun 
    121       1.2   itojun static	void udp6_detach __P((struct in6pcb *));
    122       1.2   itojun static	void udp6_notify __P((struct in6pcb *, int));
    123       1.2   itojun 
    124       1.2   itojun void
    125       1.2   itojun udp6_init()
    126       1.2   itojun {
    127       1.2   itojun 	udb6.in6p_next = udb6.in6p_prev = &udb6;
    128       1.2   itojun }
    129       1.2   itojun 
    130       1.2   itojun /*
    131       1.2   itojun  * Notify a udp user of an asynchronous error;
    132      1.27   itojun  * just wake up so that he can collect error status.
    133       1.2   itojun  */
    134       1.2   itojun static	void
    135       1.2   itojun udp6_notify(in6p, errno)
    136      1.39   itojun 	struct in6pcb *in6p;
    137       1.2   itojun 	int errno;
    138       1.2   itojun {
    139       1.2   itojun 	in6p->in6p_socket->so_error = errno;
    140       1.2   itojun 	sorwakeup(in6p->in6p_socket);
    141       1.2   itojun 	sowwakeup(in6p->in6p_socket);
    142       1.2   itojun }
    143       1.2   itojun 
    144       1.2   itojun void
    145      1.14   itojun udp6_ctlinput(cmd, sa, d)
    146       1.2   itojun 	int cmd;
    147       1.2   itojun 	struct sockaddr *sa;
    148      1.14   itojun 	void *d;
    149       1.2   itojun {
    150       1.2   itojun 	struct udphdr uh;
    151      1.39   itojun 	struct ip6_hdr *ip6;
    152      1.40   itojun 	struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)sa;
    153      1.14   itojun 	struct mbuf *m;
    154      1.14   itojun 	int off;
    155      1.40   itojun 	void *cmdarg;
    156      1.40   itojun 	struct ip6ctlparam *ip6cp = NULL;
    157      1.40   itojun 	const struct sockaddr_in6 *sa6_src = NULL;
    158      1.25   itojun 	void (*notify) __P((struct in6pcb *, int)) = udp6_notify;
    159      1.40   itojun 	struct udp_portonly {
    160      1.40   itojun 		u_int16_t uh_sport;
    161      1.40   itojun 		u_int16_t uh_dport;
    162      1.40   itojun 	} *uhp;
    163       1.2   itojun 
    164      1.10   itojun 	if (sa->sa_family != AF_INET6 ||
    165      1.10   itojun 	    sa->sa_len != sizeof(struct sockaddr_in6))
    166      1.10   itojun 		return;
    167      1.14   itojun 
    168      1.25   itojun 	if ((unsigned)cmd >= PRC_NCMDS)
    169      1.25   itojun 		return;
    170      1.25   itojun 	if (PRC_IS_REDIRECT(cmd))
    171      1.25   itojun 		notify = in6_rtchange, d = NULL;
    172      1.25   itojun 	else if (cmd == PRC_HOSTDEAD)
    173      1.25   itojun 		d = NULL;
    174  1.44.2.2  thorpej 	else if (cmd == PRC_MSGSIZE) {
    175  1.44.2.2  thorpej 		/* special code is present, see below */
    176  1.44.2.2  thorpej 		notify = in6_rtchange;
    177  1.44.2.2  thorpej 	}
    178      1.25   itojun 	else if (inet6ctlerrmap[cmd] == 0)
    179       1.2   itojun 		return;
    180       1.7   itojun 
    181      1.14   itojun 	/* if the parameter is from icmp6, decode it. */
    182      1.14   itojun 	if (d != NULL) {
    183      1.40   itojun 		ip6cp = (struct ip6ctlparam *)d;
    184      1.14   itojun 		m = ip6cp->ip6c_m;
    185      1.14   itojun 		ip6 = ip6cp->ip6c_ip6;
    186      1.14   itojun 		off = ip6cp->ip6c_off;
    187      1.40   itojun 		cmdarg = ip6cp->ip6c_cmdarg;
    188      1.40   itojun 		sa6_src = ip6cp->ip6c_src;
    189      1.14   itojun 	} else {
    190      1.14   itojun 		m = NULL;
    191      1.14   itojun 		ip6 = NULL;
    192      1.40   itojun 		cmdarg = NULL;
    193      1.40   itojun 		sa6_src = &sa6_any;
    194      1.14   itojun 	}
    195      1.14   itojun 
    196       1.2   itojun 	if (ip6) {
    197       1.2   itojun 		/*
    198       1.2   itojun 		 * XXX: We assume that when IPV6 is non NULL,
    199       1.2   itojun 		 * M and OFF are valid.
    200       1.2   itojun 		 */
    201      1.33   itojun 
    202      1.33   itojun 		/* check if we can safely examine src and dst ports */
    203      1.42   itojun 		if (m->m_pkthdr.len < off + sizeof(*uhp)) {
    204      1.42   itojun 			if (cmd == PRC_MSGSIZE)
    205      1.42   itojun 				icmp6_mtudisc_update((struct ip6ctlparam *)d, 0);
    206      1.33   itojun 			return;
    207      1.42   itojun 		}
    208       1.7   itojun 
    209      1.40   itojun 		bzero(&uh, sizeof(uh));
    210      1.40   itojun 		m_copydata(m, off, sizeof(*uhp), (caddr_t)&uh);
    211      1.34   itojun 
    212      1.34   itojun 		if (cmd == PRC_MSGSIZE) {
    213      1.36   itojun 			int valid = 0;
    214      1.40   itojun 
    215      1.34   itojun 			/*
    216      1.34   itojun 			 * Check to see if we have a valid UDP socket
    217      1.34   itojun 			 * corresponding to the address in the ICMPv6 message
    218      1.34   itojun 			 * payload.
    219      1.34   itojun 			 */
    220      1.40   itojun 			if (in6_pcblookup_connect(&udb6, &sa6->sin6_addr,
    221      1.40   itojun 			    uh.uh_dport, (struct in6_addr *)&sa6_src->sin6_addr,
    222      1.40   itojun 			    uh.uh_sport, 0))
    223      1.36   itojun 				valid++;
    224      1.34   itojun #if 0
    225      1.34   itojun 			/*
    226      1.34   itojun 			 * As the use of sendto(2) is fairly popular,
    227      1.34   itojun 			 * we may want to allow non-connected pcb too.
    228      1.34   itojun 			 * But it could be too weak against attacks...
    229      1.34   itojun 			 * We should at least check if the local address (= s)
    230      1.34   itojun 			 * is really ours.
    231      1.34   itojun 			 */
    232      1.40   itojun 			else if (in6_pcblookup_bind(&udb6, &sa6->sin6_addr,
    233      1.40   itojun 						    uh.uh_dport, 0))
    234      1.36   itojun 				valid++;
    235      1.34   itojun #endif
    236      1.34   itojun 
    237      1.34   itojun 			/*
    238      1.40   itojun 			 * Depending on the value of "valid" and routing table
    239      1.40   itojun 			 * size (mtudisc_{hi,lo}wat), we will:
    240  1.44.2.2  thorpej 			 * - recalculate the new MTU and create the
    241      1.40   itojun 			 *   corresponding routing entry, or
    242      1.40   itojun 			 * - ignore the MTU change notification.
    243      1.34   itojun 			 */
    244      1.36   itojun 			icmp6_mtudisc_update((struct ip6ctlparam *)d, valid);
    245      1.34   itojun 
    246      1.40   itojun 			/*
    247      1.40   itojun 			 * regardless of if we called icmp6_mtudisc_update(),
    248      1.40   itojun 			 * we need to call in6_pcbnotify(), to notify path
    249      1.40   itojun 			 * MTU change to the userland (2292bis-02), because
    250      1.40   itojun 			 * some unconnected sockets may share the same
    251      1.40   itojun 			 * destination and want to know the path MTU.
    252      1.40   itojun 			 */
    253      1.34   itojun 		}
    254      1.34   itojun 
    255      1.40   itojun 		(void) in6_pcbnotify(&udb6, sa, uh.uh_dport,
    256      1.40   itojun 		    (struct sockaddr *)sa6_src, uh.uh_sport, cmd, cmdarg,
    257      1.40   itojun 		    notify);
    258       1.2   itojun 	} else {
    259      1.40   itojun 		(void) in6_pcbnotify(&udb6, sa, 0, (struct sockaddr *)sa6_src,
    260      1.40   itojun 		    0, cmd, cmdarg, notify);
    261       1.2   itojun 	}
    262       1.2   itojun }
    263       1.2   itojun 
    264       1.2   itojun extern	int udp6_sendspace;
    265       1.2   itojun extern	int udp6_recvspace;
    266       1.2   itojun 
    267       1.2   itojun int
    268       1.2   itojun udp6_usrreq(so, req, m, addr6, control, p)
    269       1.2   itojun 	struct socket *so;
    270       1.2   itojun 	int req;
    271       1.2   itojun 	struct mbuf *m, *addr6, *control;
    272       1.2   itojun 	struct proc *p;
    273       1.2   itojun {
    274       1.2   itojun 	struct	in6pcb *in6p = sotoin6pcb(so);
    275       1.2   itojun 	int	error = 0;
    276       1.2   itojun 	int	s;
    277       1.2   itojun 
    278      1.27   itojun 	/*
    279       1.2   itojun 	 * MAPPED_ADDR implementation info:
    280       1.2   itojun 	 *  Mapped addr support for PRU_CONTROL is not necessary.
    281       1.2   itojun 	 *  Because typical user of PRU_CONTROL is such as ifconfig,
    282       1.2   itojun 	 *  and they don't associate any addr to their socket.  Then
    283       1.2   itojun 	 *  socket family is only hint about the PRU_CONTROL'ed address
    284       1.2   itojun 	 *  family, especially when getting addrs from kernel.
    285       1.2   itojun 	 *  So AF_INET socket need to be used to control AF_INET addrs,
    286       1.2   itojun 	 *  and AF_INET6 socket for AF_INET6 addrs.
    287       1.2   itojun 	 */
    288       1.2   itojun 	if (req == PRU_CONTROL)
    289       1.2   itojun 		return(in6_control(so, (u_long)m, (caddr_t)addr6,
    290       1.2   itojun 				   (struct ifnet *)control, p));
    291      1.20  thorpej 
    292      1.21  thorpej 	if (req == PRU_PURGEIF) {
    293      1.44   itojun 		in6_pcbpurgeif0(&udb6, (struct ifnet *)control);
    294      1.21  thorpej 		in6_purgeif((struct ifnet *)control);
    295      1.21  thorpej 		in6_pcbpurgeif(&udb6, (struct ifnet *)control);
    296      1.20  thorpej 		return (0);
    297      1.20  thorpej 	}
    298       1.2   itojun 
    299       1.2   itojun 	if (in6p == NULL && req != PRU_ATTACH) {
    300       1.2   itojun 		error = EINVAL;
    301       1.2   itojun 		goto release;
    302       1.2   itojun 	}
    303       1.2   itojun 
    304       1.2   itojun 	switch (req) {
    305       1.2   itojun 	case PRU_ATTACH:
    306       1.2   itojun 		/*
    307       1.2   itojun 		 * MAPPED_ADDR implementation spec:
    308      1.27   itojun 		 *  Always attach for IPv6,
    309       1.2   itojun 		 *  and only when necessary for IPv4.
    310       1.2   itojun 		 */
    311       1.2   itojun 		if (in6p != NULL) {
    312       1.2   itojun 			error = EINVAL;
    313       1.2   itojun 			break;
    314       1.2   itojun 		}
    315       1.4   itojun 		s = splsoftnet();
    316       1.2   itojun 		error = in6_pcballoc(so, &udb6);
    317       1.2   itojun 		splx(s);
    318       1.2   itojun 		if (error)
    319       1.2   itojun 			break;
    320       1.2   itojun 		error = soreserve(so, udp6_sendspace, udp6_recvspace);
    321       1.2   itojun 		if (error)
    322       1.2   itojun 			break;
    323       1.2   itojun 		in6p = sotoin6pcb(so);
    324       1.2   itojun 		in6p->in6p_cksum = -1;	/* just to be sure */
    325       1.2   itojun 		break;
    326       1.2   itojun 
    327       1.2   itojun 	case PRU_DETACH:
    328       1.2   itojun 		udp6_detach(in6p);
    329       1.2   itojun 		break;
    330       1.2   itojun 
    331       1.2   itojun 	case PRU_BIND:
    332       1.4   itojun 		s = splsoftnet();
    333      1.29   itojun 		error = in6_pcbbind(in6p, addr6, p);
    334       1.2   itojun 		splx(s);
    335       1.2   itojun 		break;
    336       1.2   itojun 
    337       1.2   itojun 	case PRU_LISTEN:
    338       1.2   itojun 		error = EOPNOTSUPP;
    339       1.2   itojun 		break;
    340       1.2   itojun 
    341       1.2   itojun 	case PRU_CONNECT:
    342      1.14   itojun 		if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr)) {
    343       1.2   itojun 			error = EISCONN;
    344       1.2   itojun 			break;
    345       1.2   itojun 		}
    346       1.4   itojun 		s = splsoftnet();
    347       1.2   itojun 		error = in6_pcbconnect(in6p, addr6);
    348       1.2   itojun 		if (ip6_auto_flowlabel) {
    349       1.2   itojun 			in6p->in6p_flowinfo &= ~IPV6_FLOWLABEL_MASK;
    350      1.27   itojun 			in6p->in6p_flowinfo |=
    351       1.2   itojun 				(htonl(ip6_flow_seq++) & IPV6_FLOWLABEL_MASK);
    352       1.2   itojun 		}
    353       1.2   itojun 		splx(s);
    354       1.2   itojun 		if (error == 0)
    355       1.2   itojun 			soisconnected(so);
    356       1.2   itojun 		break;
    357       1.2   itojun 
    358       1.2   itojun 	case PRU_CONNECT2:
    359       1.2   itojun 		error = EOPNOTSUPP;
    360       1.2   itojun 		break;
    361       1.2   itojun 
    362       1.2   itojun 	case PRU_ACCEPT:
    363       1.2   itojun 		error = EOPNOTSUPP;
    364       1.2   itojun 		break;
    365       1.2   itojun 
    366       1.2   itojun 	case PRU_DISCONNECT:
    367       1.2   itojun 		if (IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr)) {
    368       1.2   itojun 			error = ENOTCONN;
    369       1.2   itojun 			break;
    370       1.2   itojun 		}
    371       1.4   itojun 		s = splsoftnet();
    372       1.2   itojun 		in6_pcbdisconnect(in6p);
    373       1.2   itojun 		bzero((caddr_t)&in6p->in6p_laddr, sizeof(in6p->in6p_laddr));
    374       1.2   itojun 		splx(s);
    375       1.2   itojun 		so->so_state &= ~SS_ISCONNECTED;		/* XXX */
    376       1.2   itojun 		break;
    377       1.2   itojun 
    378       1.2   itojun 	case PRU_SHUTDOWN:
    379       1.2   itojun 		socantsendmore(so);
    380       1.2   itojun 		break;
    381       1.2   itojun 
    382       1.2   itojun 	case PRU_SEND:
    383      1.29   itojun 		return(udp6_output(in6p, m, addr6, control, p));
    384       1.2   itojun 
    385       1.2   itojun 	case PRU_ABORT:
    386       1.2   itojun 		soisdisconnected(so);
    387       1.2   itojun 		udp6_detach(in6p);
    388       1.2   itojun 		break;
    389       1.2   itojun 
    390       1.2   itojun 	case PRU_SOCKADDR:
    391       1.2   itojun 		in6_setsockaddr(in6p, addr6);
    392       1.2   itojun 		break;
    393       1.2   itojun 
    394       1.2   itojun 	case PRU_PEERADDR:
    395       1.2   itojun 		in6_setpeeraddr(in6p, addr6);
    396       1.2   itojun 		break;
    397       1.2   itojun 
    398       1.2   itojun 	case PRU_SENSE:
    399       1.2   itojun 		/*
    400       1.2   itojun 		 * stat: don't bother with a blocksize
    401       1.2   itojun 		 */
    402       1.2   itojun 		return(0);
    403       1.2   itojun 
    404       1.2   itojun 	case PRU_SENDOOB:
    405       1.2   itojun 	case PRU_FASTTIMO:
    406       1.2   itojun 	case PRU_SLOWTIMO:
    407       1.2   itojun 	case PRU_PROTORCV:
    408       1.2   itojun 	case PRU_PROTOSEND:
    409       1.2   itojun 		error = EOPNOTSUPP;
    410       1.2   itojun 		break;
    411       1.2   itojun 
    412       1.2   itojun 	case PRU_RCVD:
    413       1.2   itojun 	case PRU_RCVOOB:
    414       1.2   itojun 		return(EOPNOTSUPP);	/* do not free mbuf's */
    415       1.2   itojun 
    416       1.2   itojun 	default:
    417       1.2   itojun 		panic("udp6_usrreq");
    418       1.2   itojun 	}
    419       1.2   itojun 
    420       1.2   itojun release:
    421      1.43   itojun 	if (control)
    422       1.2   itojun 		m_freem(control);
    423       1.2   itojun 	if (m)
    424       1.2   itojun 		m_freem(m);
    425       1.2   itojun 	return(error);
    426       1.2   itojun }
    427       1.2   itojun 
    428       1.2   itojun static void
    429       1.2   itojun udp6_detach(in6p)
    430       1.2   itojun 	struct in6pcb *in6p;
    431       1.2   itojun {
    432      1.27   itojun 	int s = splsoftnet();
    433       1.2   itojun 
    434       1.2   itojun 	if (in6p == udp6_last_in6pcb)
    435       1.2   itojun 		udp6_last_in6pcb = &udb6;
    436       1.2   itojun 	in6_pcbdetach(in6p);
    437       1.2   itojun 	splx(s);
    438       1.2   itojun }
    439       1.2   itojun 
    440       1.2   itojun int
    441       1.2   itojun udp6_sysctl(name, namelen, oldp, oldlenp, newp, newlen)
    442       1.2   itojun 	int *name;
    443       1.2   itojun 	u_int namelen;
    444       1.2   itojun 	void *oldp;
    445       1.2   itojun 	size_t *oldlenp;
    446       1.2   itojun 	void *newp;
    447       1.2   itojun 	size_t newlen;
    448       1.2   itojun {
    449       1.2   itojun 	/* All sysctl names at this level are terminal. */
    450       1.2   itojun 	if (namelen != 1)
    451       1.2   itojun 		return ENOTDIR;
    452       1.2   itojun 
    453       1.2   itojun 	switch (name[0]) {
    454       1.2   itojun 
    455      1.28   itojun 	case UDP6CTL_SENDSPACE:
    456       1.2   itojun 		return sysctl_int(oldp, oldlenp, newp, newlen,
    457       1.2   itojun 		    &udp6_sendspace);
    458       1.2   itojun 	case UDP6CTL_RECVSPACE:
    459      1.27   itojun 		return sysctl_int(oldp, oldlenp, newp, newlen,
    460       1.2   itojun 		    &udp6_recvspace);
    461       1.2   itojun 	default:
    462       1.2   itojun 		return ENOPROTOOPT;
    463       1.2   itojun 	}
    464       1.2   itojun 	/* NOTREACHED */
    465       1.2   itojun }
    466