2 * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * @(#)udp_usrreq.c 8.6 (Berkeley) 5/23/95
34 * $FreeBSD: src/sys/netinet/udp_usrreq.c,v 1.64.2.18 2003/01/24 05:11:34 sam Exp $
37 #include "opt_ipsec.h"
38 #include "opt_inet6.h"
40 #include <sys/param.h>
41 #include <sys/systm.h>
42 #include <sys/kernel.h>
43 #include <sys/malloc.h>
45 #include <sys/domain.h>
47 #include <sys/protosw.h>
48 #include <sys/socket.h>
49 #include <sys/socketvar.h>
50 #include <sys/sysctl.h>
51 #include <sys/syslog.h>
53 #include <vm/vm_zone.h>
56 #include <net/route.h>
58 #include <netinet/in.h>
59 #include <netinet/in_systm.h>
60 #include <netinet/ip.h>
62 #include <netinet/ip6.h>
64 #include <netinet/in_pcb.h>
65 #include <netinet/in_var.h>
66 #include <netinet/ip_var.h>
68 #include <netinet6/ip6_var.h>
70 #include <netinet/ip_icmp.h>
71 #include <netinet/icmp_var.h>
72 #include <netinet/udp.h>
73 #include <netinet/udp_var.h>
76 #include <netipsec/ipsec.h>
80 #include <netinet6/ipsec.h>
83 #include <machine/in_cksum.h>
86 * UDP protocol implementation.
87 * Per RFC 768, August, 1980.
90 static int udpcksum = 1;
92 static int udpcksum = 0; /* XXX */
94 SYSCTL_INT(_net_inet_udp, UDPCTL_CHECKSUM, checksum, CTLFLAG_RW,
98 SYSCTL_INT(_net_inet_udp, OID_AUTO, log_in_vain, CTLFLAG_RW,
99 &log_in_vain, 0, "Log all incoming UDP packets");
101 static int blackhole = 0;
102 SYSCTL_INT(_net_inet_udp, OID_AUTO, blackhole, CTLFLAG_RW,
103 &blackhole, 0, "Do not send port unreachables for refused connects");
105 struct inpcbhead udb; /* from udp_var.h */
106 #define udb6 udb /* for KAME src sync over BSD*'s */
107 struct inpcbinfo udbinfo;
110 #define UDBHASHSIZE 16
113 struct udpstat udpstat; /* from udp_var.h */
114 SYSCTL_STRUCT(_net_inet_udp, UDPCTL_STATS, stats, CTLFLAG_RW,
115 &udpstat, udpstat, "UDP statistics (struct udpstat, netinet/udp_var.h)");
117 static struct sockaddr_in udp_in = { sizeof(udp_in), AF_INET };
120 struct sockaddr_in6 uin6_sin;
121 u_char uin6_init_done : 1;
123 { sizeof(udp_in6.uin6_sin), AF_INET6 },
127 struct ip6_hdr uip6_ip6;
128 u_char uip6_init_done : 1;
132 static void udp_append __P((struct inpcb *last, struct ip *ip,
133 struct mbuf *n, int off));
135 static void ip_2_ip6_hdr __P((struct ip6_hdr *ip6, struct ip *ip));
138 static int udp_detach __P((struct socket *so));
139 static int udp_output __P((struct inpcb *, struct mbuf *, struct sockaddr *,
140 struct mbuf *, struct proc *));
146 udbinfo.listhead = &udb;
147 udbinfo.hashbase = hashinit(UDBHASHSIZE, M_PCB, &udbinfo.hashmask);
148 udbinfo.porthashbase = hashinit(UDBHASHSIZE, M_PCB,
149 &udbinfo.porthashmask);
150 udbinfo.ipi_zone = zinit("udpcb", sizeof(struct inpcb), maxsockets,
155 udp_input(m, off, proto)
156 register struct mbuf *m;
160 register struct ip *ip;
161 register struct udphdr *uh;
162 register struct inpcb *inp;
163 struct mbuf *opts = 0;
166 struct sockaddr *append_sa;
168 udpstat.udps_ipackets++;
171 * Strip IP options, if any; should skip this,
172 * make available to user, and use on returned packets,
173 * but we don't yet have a way to check the checksum
174 * with options still present.
176 if (iphlen > sizeof (struct ip)) {
177 ip_stripoptions(m, (struct mbuf *)0);
178 iphlen = sizeof(struct ip);
182 * Get IP and UDP header together in first mbuf.
184 ip = mtod(m, struct ip *);
185 if (m->m_len < iphlen + sizeof(struct udphdr)) {
186 if ((m = m_pullup(m, iphlen + sizeof(struct udphdr))) == 0) {
187 udpstat.udps_hdrops++;
190 ip = mtod(m, struct ip *);
192 uh = (struct udphdr *)((caddr_t)ip + iphlen);
194 /* destination port of 0 is illegal, based on RFC768. */
195 if (uh->uh_dport == 0)
199 * Make mbuf data length reflect UDP length.
200 * If not enough data to reflect UDP length, drop.
202 len = ntohs((u_short)uh->uh_ulen);
203 if (ip->ip_len != len) {
204 if (len > ip->ip_len || len < sizeof(struct udphdr)) {
205 udpstat.udps_badlen++;
208 m_adj(m, len - ip->ip_len);
209 /* ip->ip_len = len; */
212 * Save a copy of the IP header in case we want restore it
213 * for sending an ICMP error message in response.
218 * Checksum extended UDP header and data.
221 if (m->m_pkthdr.csum_flags & CSUM_DATA_VALID) {
222 if (m->m_pkthdr.csum_flags & CSUM_PSEUDO_HDR)
223 uh->uh_sum = m->m_pkthdr.csum_data;
225 uh->uh_sum = in_pseudo(ip->ip_src.s_addr,
226 ip->ip_dst.s_addr, htonl((u_short)len +
227 m->m_pkthdr.csum_data + IPPROTO_UDP));
228 uh->uh_sum ^= 0xffff;
231 bcopy(((struct ipovly *)ip)->ih_x1, b, 9);
232 bzero(((struct ipovly *)ip)->ih_x1, 9);
233 ((struct ipovly *)ip)->ih_len = uh->uh_ulen;
234 uh->uh_sum = in_cksum(m, len + sizeof (struct ip));
235 bcopy(b, ((struct ipovly *)ip)->ih_x1, 9);
238 udpstat.udps_badsum++;
243 udpstat.udps_nosum++;
245 if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) ||
246 in_broadcast(ip->ip_dst, m->m_pkthdr.rcvif)) {
249 * Deliver a multicast or broadcast datagram to *all* sockets
250 * for which the local and remote addresses and ports match
251 * those of the incoming datagram. This allows more than
252 * one process to receive multi/broadcasts on the same port.
253 * (This really ought to be done for unicast datagrams as
254 * well, but that would cause problems with existing
255 * applications that open both address-specific sockets and
256 * a wildcard socket listening to the same port -- they would
257 * end up receiving duplicates of every unicast datagram.
258 * Those applications open the multiple sockets to overcome an
259 * inadequacy of the UDP socket interface, but for backwards
260 * compatibility we avoid the problem here rather than
261 * fixing the interface. Maybe 4.5BSD will remedy this?)
265 * Construct sockaddr format source address.
267 udp_in.sin_port = uh->uh_sport;
268 udp_in.sin_addr = ip->ip_src;
270 * Locate pcb(s) for datagram.
271 * (Algorithm copied from raw_intr().)
275 udp_in6.uin6_init_done = udp_ip6.uip6_init_done = 0;
277 LIST_FOREACH(inp, &udb, inp_list) {
279 if ((inp->inp_vflag & INP_IPV4) == 0)
282 if (inp->inp_lport != uh->uh_dport)
284 if (inp->inp_laddr.s_addr != INADDR_ANY) {
285 if (inp->inp_laddr.s_addr !=
289 if (inp->inp_faddr.s_addr != INADDR_ANY) {
290 if (inp->inp_faddr.s_addr !=
292 inp->inp_fport != uh->uh_sport)
300 /* check AH/ESP integrity. */
301 if (ipsec4_in_reject_so(m, last->inp_socket))
302 ipsecstat.in_polvio++;
303 /* do not inject data to pcb */
307 /* check AH/ESP integrity. */
308 if (ipsec4_in_reject(m, last))
311 #endif /*FAST_IPSEC*/
312 if ((n = m_copy(m, 0, M_COPYALL)) != NULL)
313 udp_append(last, ip, n,
315 sizeof(struct udphdr));
319 * Don't look for additional matches if this one does
320 * not have either the SO_REUSEPORT or SO_REUSEADDR
321 * socket options set. This heuristic avoids searching
322 * through all pcbs in the common case of a non-shared
323 * port. It * assumes that an application will never
324 * clear these options after setting them.
326 if ((last->inp_socket->so_options&(SO_REUSEPORT|SO_REUSEADDR)) == 0)
332 * No matching pcb found; discard datagram.
333 * (No need to send an ICMP Port Unreachable
334 * for a broadcast or multicast datgram.)
336 udpstat.udps_noportbcast++;
340 /* check AH/ESP integrity. */
341 if (ipsec4_in_reject_so(m, last->inp_socket)) {
342 ipsecstat.in_polvio++;
347 /* check AH/ESP integrity. */
348 if (ipsec4_in_reject(m, last))
350 #endif /*FAST_IPSEC*/
351 udp_append(last, ip, m, iphlen + sizeof(struct udphdr));
355 * Locate pcb for datagram.
357 inp = in_pcblookup_hash(&udbinfo, ip->ip_src, uh->uh_sport,
358 ip->ip_dst, uh->uh_dport, 1, m->m_pkthdr.rcvif);
361 char buf[4*sizeof "123"];
363 strcpy(buf, inet_ntoa(ip->ip_dst));
365 "Connection attempt to UDP %s:%d from %s:%d\n",
366 buf, ntohs(uh->uh_dport), inet_ntoa(ip->ip_src),
367 ntohs(uh->uh_sport));
369 udpstat.udps_noport++;
370 if (m->m_flags & (M_BCAST | M_MCAST)) {
371 udpstat.udps_noportbcast++;
377 if (badport_bandlim(BANDLIM_ICMP_UNREACH) < 0)
381 ip->ip_len += iphlen;
382 icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_PORT, 0, 0);
386 if (ipsec4_in_reject_so(m, inp->inp_socket)) {
387 ipsecstat.in_polvio++;
392 if (ipsec4_in_reject(m, inp))
394 #endif /*FAST_IPSEC*/
397 * Construct sockaddr format source address.
398 * Stuff source address and datagram in user buffer.
400 udp_in.sin_port = uh->uh_sport;
401 udp_in.sin_addr = ip->ip_src;
402 if (inp->inp_flags & INP_CONTROLOPTS
403 || inp->inp_socket->so_options & SO_TIMESTAMP) {
405 if (inp->inp_vflag & INP_IPV6) {
408 ip_2_ip6_hdr(&udp_ip6.uip6_ip6, ip);
409 savedflags = inp->inp_flags;
410 inp->inp_flags &= ~INP_UNMAPPABLEOPTS;
411 ip6_savecontrol(inp, &opts, &udp_ip6.uip6_ip6, m);
412 inp->inp_flags = savedflags;
415 ip_savecontrol(inp, &opts, ip, m);
417 m_adj(m, iphlen + sizeof(struct udphdr));
419 if (inp->inp_vflag & INP_IPV6) {
420 in6_sin_2_v4mapsin6(&udp_in, &udp_in6.uin6_sin);
421 append_sa = (struct sockaddr *)&udp_in6;
424 append_sa = (struct sockaddr *)&udp_in;
425 if (sbappendaddr(&inp->inp_socket->so_rcv, append_sa, m, opts) == 0) {
426 udpstat.udps_fullsock++;
429 sorwakeup(inp->inp_socket);
440 ip_2_ip6_hdr(ip6, ip)
444 bzero(ip6, sizeof(*ip6));
446 ip6->ip6_vfc = IPV6_VERSION;
447 ip6->ip6_plen = ip->ip_len;
448 ip6->ip6_nxt = ip->ip_p;
449 ip6->ip6_hlim = ip->ip_ttl;
450 ip6->ip6_src.s6_addr32[2] = ip6->ip6_dst.s6_addr32[2] =
452 ip6->ip6_src.s6_addr32[3] = ip->ip_src.s_addr;
453 ip6->ip6_dst.s6_addr32[3] = ip->ip_dst.s_addr;
458 * subroutine of udp_input(), mainly for source code readability.
459 * caller must properly init udp_ip6 and udp_in6 beforehand.
462 udp_append(last, ip, n, off)
468 struct sockaddr *append_sa;
469 struct mbuf *opts = 0;
471 if (last->inp_flags & INP_CONTROLOPTS ||
472 last->inp_socket->so_options & SO_TIMESTAMP) {
474 if (last->inp_vflag & INP_IPV6) {
477 if (udp_ip6.uip6_init_done == 0) {
478 ip_2_ip6_hdr(&udp_ip6.uip6_ip6, ip);
479 udp_ip6.uip6_init_done = 1;
481 savedflags = last->inp_flags;
482 last->inp_flags &= ~INP_UNMAPPABLEOPTS;
483 ip6_savecontrol(last, &opts, &udp_ip6.uip6_ip6, n);
484 last->inp_flags = savedflags;
487 ip_savecontrol(last, &opts, ip, n);
490 if (last->inp_vflag & INP_IPV6) {
491 if (udp_in6.uin6_init_done == 0) {
492 in6_sin_2_v4mapsin6(&udp_in, &udp_in6.uin6_sin);
493 udp_in6.uin6_init_done = 1;
495 append_sa = (struct sockaddr *)&udp_in6.uin6_sin;
498 append_sa = (struct sockaddr *)&udp_in;
500 if (sbappendaddr(&last->inp_socket->so_rcv, append_sa, n, opts) == 0) {
504 udpstat.udps_fullsock++;
506 sorwakeup(last->inp_socket);
510 * Notify a udp user of an asynchronous error;
511 * just wake up so that he can collect error status.
514 udp_notify(inp, errno)
515 register struct inpcb *inp;
518 inp->inp_socket->so_error = errno;
519 sorwakeup(inp->inp_socket);
520 sowwakeup(inp->inp_socket);
524 udp_ctlinput(cmd, sa, vip)
531 void (*notify) __P((struct inpcb *, int)) = udp_notify;
532 struct in_addr faddr;
536 faddr = ((struct sockaddr_in *)sa)->sin_addr;
537 if (sa->sa_family != AF_INET || faddr.s_addr == INADDR_ANY)
540 if (PRC_IS_REDIRECT(cmd)) {
542 notify = in_rtchange;
543 } else if (cmd == PRC_HOSTDEAD)
545 else if ((unsigned)cmd >= PRC_NCMDS || inetctlerrmap[cmd] == 0)
549 uh = (struct udphdr *)((caddr_t)ip + (ip->ip_hl << 2));
550 inp = in_pcblookup_hash(&udbinfo, faddr, uh->uh_dport,
551 ip->ip_src, uh->uh_sport, 0, NULL);
552 if (inp != NULL && inp->inp_socket != NULL)
553 (*notify)(inp, inetctlerrmap[cmd]);
556 in_pcbnotifyall(&udb, faddr, inetctlerrmap[cmd], notify);
560 udp_pcblist(SYSCTL_HANDLER_ARGS)
563 struct inpcb *inp, **inp_list;
568 * The process of preparing the TCB list is too time-consuming and
569 * resource-intensive to repeat twice on every request.
571 if (req->oldptr == 0) {
572 n = udbinfo.ipi_count;
573 req->oldidx = 2 * (sizeof xig)
574 + (n + n/8) * sizeof(struct xinpcb);
578 if (req->newptr != 0)
582 * OK, now we're committed to doing something.
585 gencnt = udbinfo.ipi_gencnt;
586 n = udbinfo.ipi_count;
589 xig.xig_len = sizeof xig;
591 xig.xig_gen = gencnt;
592 xig.xig_sogen = so_gencnt;
593 error = SYSCTL_OUT(req, &xig, sizeof xig);
597 inp_list = malloc(n * sizeof *inp_list, M_TEMP, M_WAITOK);
602 for (inp = LIST_FIRST(udbinfo.listhead), i = 0; inp && i < n;
603 inp = LIST_NEXT(inp, inp_list)) {
604 if (inp->inp_gencnt <= gencnt && !prison_xinpcb(req->p, inp))
611 for (i = 0; i < n; i++) {
613 if (inp->inp_gencnt <= gencnt) {
615 xi.xi_len = sizeof xi;
616 /* XXX should avoid extra copy */
617 bcopy(inp, &xi.xi_inp, sizeof *inp);
619 sotoxsocket(inp->inp_socket, &xi.xi_socket);
620 error = SYSCTL_OUT(req, &xi, sizeof xi);
625 * Give the user an updated idea of our state.
626 * If the generation differs from what we told
627 * her before, she knows that something happened
628 * while we were processing this request, and it
629 * might be necessary to retry.
632 xig.xig_gen = udbinfo.ipi_gencnt;
633 xig.xig_sogen = so_gencnt;
634 xig.xig_count = udbinfo.ipi_count;
636 error = SYSCTL_OUT(req, &xig, sizeof xig);
638 free(inp_list, M_TEMP);
642 SYSCTL_PROC(_net_inet_udp, UDPCTL_PCBLIST, pcblist, CTLFLAG_RD, 0, 0,
643 udp_pcblist, "S,xinpcb", "List of active UDP sockets");
646 udp_getcred(SYSCTL_HANDLER_ARGS)
648 struct sockaddr_in addrs[2];
652 error = suser(req->p);
655 error = SYSCTL_IN(req, addrs, sizeof(addrs));
659 inp = in_pcblookup_hash(&udbinfo, addrs[1].sin_addr, addrs[1].sin_port,
660 addrs[0].sin_addr, addrs[0].sin_port, 1, NULL);
661 if (inp == NULL || inp->inp_socket == NULL) {
665 error = SYSCTL_OUT(req, inp->inp_socket->so_cred, sizeof(struct ucred));
671 SYSCTL_PROC(_net_inet_udp, OID_AUTO, getcred, CTLTYPE_OPAQUE|CTLFLAG_RW,
672 0, 0, udp_getcred, "S,ucred", "Get the ucred of a UDP connection");
675 udp_output(inp, m, addr, control, p)
676 register struct inpcb *inp;
678 struct sockaddr *addr;
679 struct mbuf *control;
682 register struct udpiphdr *ui;
683 register int len = m->m_pkthdr.len;
684 struct in_addr laddr;
685 struct sockaddr_in *sin;
686 int s = 0, error = 0;
689 m_freem(control); /* XXX */
691 if (len + sizeof(struct udpiphdr) > IP_MAXPACKET) {
697 sin = (struct sockaddr_in *)addr;
698 prison_remote_ip(p, 0, &sin->sin_addr.s_addr);
699 laddr = inp->inp_laddr;
700 if (inp->inp_faddr.s_addr != INADDR_ANY) {
705 * Must block input while temporarily connected.
708 error = in_pcbconnect(inp, addr, p);
714 if (inp->inp_faddr.s_addr == INADDR_ANY) {
720 * Calculate data length and get a mbuf
721 * for UDP and IP headers.
723 M_PREPEND(m, sizeof(struct udpiphdr), M_DONTWAIT);
732 * Fill in mbuf with extended UDP header
733 * and addresses and length put into network format.
735 ui = mtod(m, struct udpiphdr *);
736 bzero(ui->ui_x1, sizeof(ui->ui_x1)); /* XXX still needed? */
737 ui->ui_pr = IPPROTO_UDP;
738 ui->ui_src = inp->inp_laddr;
739 ui->ui_dst = inp->inp_faddr;
740 ui->ui_sport = inp->inp_lport;
741 ui->ui_dport = inp->inp_fport;
742 ui->ui_ulen = htons((u_short)len + sizeof(struct udphdr));
745 * Set up checksum and output datagram.
748 ui->ui_sum = in_pseudo(ui->ui_src.s_addr, ui->ui_dst.s_addr,
749 htons((u_short)len + sizeof(struct udphdr) + IPPROTO_UDP));
750 m->m_pkthdr.csum_flags = CSUM_UDP;
751 m->m_pkthdr.csum_data = offsetof(struct udphdr, uh_sum);
755 ((struct ip *)ui)->ip_len = sizeof (struct udpiphdr) + len;
756 ((struct ip *)ui)->ip_ttl = inp->inp_ip_ttl; /* XXX */
757 ((struct ip *)ui)->ip_tos = inp->inp_ip_tos; /* XXX */
758 udpstat.udps_opackets++;
760 error = ip_output(m, inp->inp_options, &inp->inp_route,
761 (inp->inp_socket->so_options & (SO_DONTROUTE | SO_BROADCAST)),
762 inp->inp_moptions, inp);
765 in_pcbdisconnect(inp);
766 inp->inp_laddr = laddr; /* XXX rehash? */
776 u_long udp_sendspace = 9216; /* really max datagram size */
777 /* 40 1K datagrams */
778 SYSCTL_INT(_net_inet_udp, UDPCTL_MAXDGRAM, maxdgram, CTLFLAG_RW,
779 &udp_sendspace, 0, "Maximum outgoing UDP datagram size");
781 u_long udp_recvspace = 40 * (1024 +
783 sizeof(struct sockaddr_in6)
785 sizeof(struct sockaddr_in)
788 SYSCTL_INT(_net_inet_udp, UDPCTL_RECVSPACE, recvspace, CTLFLAG_RW,
789 &udp_recvspace, 0, "Maximum incoming UDP datagram size");
792 udp_abort(struct socket *so)
799 return EINVAL; /* ??? possible? panic instead? */
800 soisdisconnected(so);
808 udp_attach(struct socket *so, int proto, struct proc *p)
817 error = soreserve(so, udp_sendspace, udp_recvspace);
821 error = in_pcballoc(so, &udbinfo, p);
826 inp = (struct inpcb *)so->so_pcb;
827 inp->inp_vflag |= INP_IPV4;
828 inp->inp_ip_ttl = ip_defttl;
833 udp_bind(struct socket *so, struct sockaddr *nam, struct proc *p)
842 error = in_pcbbind(inp, nam, p);
848 udp_connect(struct socket *so, struct sockaddr *nam, struct proc *p)
852 struct sockaddr_in *sin;
857 if (inp->inp_faddr.s_addr != INADDR_ANY)
861 if (inp->inp_laddr.s_addr == INADDR_ANY && p->p_prison != NULL)
862 error = in_pcbbind(inp, NULL, p);
864 sin = (struct sockaddr_in *)nam;
865 prison_remote_ip(p, 0, &sin->sin_addr.s_addr);
866 error = in_pcbconnect(inp, nam, p);
875 udp_detach(struct socket *so)
890 udp_disconnect(struct socket *so)
898 if (inp->inp_faddr.s_addr == INADDR_ANY)
902 in_pcbdisconnect(inp);
903 inp->inp_laddr.s_addr = INADDR_ANY;
905 so->so_state &= ~SS_ISCONNECTED; /* XXX */
910 udp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
911 struct mbuf *control, struct proc *p)
920 return udp_output(inp, m, addr, control, p);
924 udp_shutdown(struct socket *so)
935 struct pr_usrreqs udp_usrreqs = {
936 udp_abort, pru_accept_notsupp, udp_attach, udp_bind, udp_connect,
937 pru_connect2_notsupp, in_control, udp_detach, udp_disconnect,
938 pru_listen_notsupp, in_setpeeraddr, pru_rcvd_notsupp,
939 pru_rcvoob_notsupp, udp_send, pru_sense_null, udp_shutdown,
940 in_setsockaddr, sosend, soreceive, sopoll