version 1.3.4.1, 1993/09/24 08:55:04 |
version 1.28, 1996/03/16 23:54:03 |
|
|
|
/* $NetBSD$ */ |
|
|
/* |
/* |
* Copyright (c) 1982, 1986, 1988, 1990 Regents of the University of California. |
* Copyright (c) 1982, 1986, 1988, 1990, 1993 |
* All rights reserved. |
* The Regents of the University of California. All rights reserved. |
* |
* |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* modification, are permitted provided that the following conditions |
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
* |
* |
* from: @(#)udp_usrreq.c 7.20 (Berkeley) 4/20/91 |
* @(#)udp_usrreq.c 8.4 (Berkeley) 1/21/94 |
* $Id$ |
|
*/ |
*/ |
|
|
#include "param.h" |
#include <sys/param.h> |
#include "malloc.h" |
#include <sys/malloc.h> |
#include "mbuf.h" |
#include <sys/mbuf.h> |
#include "protosw.h" |
#include <sys/protosw.h> |
#include "socket.h" |
#include <sys/socket.h> |
#include "socketvar.h" |
#include <sys/socketvar.h> |
#include "stat.h" |
#include <sys/errno.h> |
|
#include <sys/stat.h> |
#include "machine/cpu.h" |
#include <sys/systm.h> |
|
#include <sys/proc.h> |
#include "../net/if.h" |
|
#include "../net/route.h" |
#include <vm/vm.h> |
|
#include <sys/sysctl.h> |
#include "in.h" |
|
#include "in_systm.h" |
#include <net/if.h> |
#include "ip.h" |
#include <net/route.h> |
#include "in_pcb.h" |
|
#include "ip_var.h" |
#include <netinet/in.h> |
#include "ip_icmp.h" |
#include <netinet/in_systm.h> |
#include "udp.h" |
#include <netinet/in_var.h> |
#include "udp_var.h" |
#include <netinet/ip.h> |
|
#include <netinet/in_pcb.h> |
|
#include <netinet/ip_var.h> |
|
#include <netinet/ip_icmp.h> |
|
#include <netinet/udp.h> |
|
#include <netinet/udp_var.h> |
|
|
struct inpcb *udp_last_inpcb = &udb; |
#include <machine/stdarg.h> |
|
|
/* |
/* |
* UDP protocol implementation. |
* UDP protocol implementation. |
* Per RFC 768, August, 1980. |
* Per RFC 768, August, 1980. |
*/ |
*/ |
udp_init() |
|
{ |
|
|
|
udb.inp_next = udb.inp_prev = &udb; |
|
} |
|
|
|
#ifndef COMPAT_42 |
#ifndef COMPAT_42 |
int udpcksum = 1; |
int udpcksum = 1; |
#else |
#else |
int udpcksum = 0; /* XXX */ |
int udpcksum = 0; /* XXX */ |
#endif |
#endif |
int udp_ttl = UDP_TTL; |
|
|
|
struct sockaddr_in udp_in = { sizeof(udp_in), AF_INET }; |
struct sockaddr_in udp_in = { sizeof(udp_in), AF_INET }; |
|
|
udp_input(m, iphlen) |
static void udp_detach __P((struct inpcb *)); |
register struct mbuf *m; |
static void udp_notify __P((struct inpcb *, int)); |
int iphlen; |
static struct mbuf *udp_saveopt __P((caddr_t, int, int)); |
|
|
|
#ifndef UDBHASHSIZE |
|
#define UDBHASHSIZE 128 |
|
#endif |
|
int udbhashsize = UDBHASHSIZE; |
|
|
|
void |
|
udp_init() |
|
{ |
|
|
|
in_pcbinit(&udbtable, udbhashsize); |
|
} |
|
|
|
void |
|
#if __STDC__ |
|
udp_input(struct mbuf *m, ...) |
|
#else |
|
udp_input(m, va_alist) |
|
struct mbuf *m; |
|
va_dcl |
|
#endif |
{ |
{ |
register struct ip *ip; |
register struct ip *ip; |
register struct udphdr *uh; |
register struct udphdr *uh; |
Line 87 udp_input(m, iphlen) |
|
Line 107 udp_input(m, iphlen) |
|
struct mbuf *opts = 0; |
struct mbuf *opts = 0; |
int len; |
int len; |
struct ip save_ip; |
struct ip save_ip; |
|
int iphlen; |
|
va_list ap; |
|
|
|
va_start(ap, m); |
|
iphlen = va_arg(ap, int); |
|
va_end(ap); |
|
|
udpstat.udps_ipackets++; |
udpstat.udps_ipackets++; |
|
|
Line 118 udp_input(m, iphlen) |
|
Line 144 udp_input(m, iphlen) |
|
* Make mbuf data length reflect UDP length. |
* Make mbuf data length reflect UDP length. |
* If not enough data to reflect UDP length, drop. |
* If not enough data to reflect UDP length, drop. |
*/ |
*/ |
len = ntohs((u_short)uh->uh_ulen); |
len = ntohs((u_int16_t)uh->uh_ulen); |
if (ip->ip_len != len) { |
if (ip->ip_len != len) { |
if (len > ip->ip_len) { |
if (len > ip->ip_len) { |
udpstat.udps_badlen++; |
udpstat.udps_badlen++; |
Line 137 udp_input(m, iphlen) |
|
Line 163 udp_input(m, iphlen) |
|
* Checksum extended UDP header and data. |
* Checksum extended UDP header and data. |
*/ |
*/ |
if (udpcksum && uh->uh_sum) { |
if (udpcksum && uh->uh_sum) { |
((struct ipovly *)ip)->ih_next = 0; |
bzero(((struct ipovly *)ip)->ih_x1, |
((struct ipovly *)ip)->ih_prev = 0; |
sizeof ((struct ipovly *)ip)->ih_x1); |
((struct ipovly *)ip)->ih_x1 = 0; |
|
((struct ipovly *)ip)->ih_len = uh->uh_ulen; |
((struct ipovly *)ip)->ih_len = uh->uh_ulen; |
if (uh->uh_sum = in_cksum(m, len + sizeof (struct ip))) { |
if ((uh->uh_sum = in_cksum(m, len + sizeof (struct ip))) != 0) { |
udpstat.udps_badsum++; |
udpstat.udps_badsum++; |
m_freem(m); |
m_freem(m); |
return; |
return; |
} |
} |
} |
} |
|
|
|
if (IN_MULTICAST(ip->ip_dst.s_addr) || |
|
in_broadcast(ip->ip_dst, m->m_pkthdr.rcvif)) { |
|
struct socket *last; |
|
/* |
|
* Deliver a multicast or broadcast datagram to *all* sockets |
|
* for which the local and remote addresses and ports match |
|
* those of the incoming datagram. This allows more than |
|
* one process to receive multi/broadcasts on the same port. |
|
* (This really ought to be done for unicast datagrams as |
|
* well, but that would cause problems with existing |
|
* applications that open both address-specific sockets and |
|
* a wildcard socket listening to the same port -- they would |
|
* end up receiving duplicates of every unicast datagram. |
|
* Those applications open the multiple sockets to overcome an |
|
* inadequacy of the UDP socket interface, but for backwards |
|
* compatibility we avoid the problem here rather than |
|
* fixing the interface. Maybe 4.5BSD will remedy this?) |
|
*/ |
|
|
|
/* |
|
* Construct sockaddr format source address. |
|
*/ |
|
udp_in.sin_port = uh->uh_sport; |
|
udp_in.sin_addr = ip->ip_src; |
|
m->m_len -= sizeof (struct udpiphdr); |
|
m->m_data += sizeof (struct udpiphdr); |
|
/* |
|
* Locate pcb(s) for datagram. |
|
* (Algorithm copied from raw_intr().) |
|
*/ |
|
last = NULL; |
|
for (inp = udbtable.inpt_queue.cqh_first; |
|
inp != (struct inpcb *)&udbtable.inpt_queue; |
|
inp = inp->inp_queue.cqe_next) { |
|
if (inp->inp_lport != uh->uh_dport) |
|
continue; |
|
if (inp->inp_laddr.s_addr != INADDR_ANY) { |
|
if (inp->inp_laddr.s_addr != |
|
ip->ip_dst.s_addr) |
|
continue; |
|
} |
|
if (inp->inp_faddr.s_addr != INADDR_ANY) { |
|
if (inp->inp_faddr.s_addr != |
|
ip->ip_src.s_addr || |
|
inp->inp_fport != uh->uh_sport) |
|
continue; |
|
} |
|
|
|
if (last != NULL) { |
|
struct mbuf *n; |
|
|
|
if ((n = m_copy(m, 0, M_COPYALL)) != NULL) { |
|
if (sbappendaddr(&last->so_rcv, |
|
sintosa(&udp_in), n, |
|
(struct mbuf *)0) == 0) { |
|
m_freem(n); |
|
udpstat.udps_fullsock++; |
|
} else |
|
sorwakeup(last); |
|
} |
|
} |
|
last = inp->inp_socket; |
|
/* |
|
* Don't look for additional matches if this one does |
|
* not have either the SO_REUSEPORT or SO_REUSEADDR |
|
* socket options set. This heuristic avoids searching |
|
* through all pcbs in the common case of a non-shared |
|
* port. It * assumes that an application will never |
|
* clear these options after setting them. |
|
*/ |
|
if ((last->so_options&(SO_REUSEPORT|SO_REUSEADDR)) == 0) |
|
break; |
|
} |
|
|
|
if (last == NULL) { |
|
/* |
|
* No matching pcb found; discard datagram. |
|
* (No need to send an ICMP Port Unreachable |
|
* for a broadcast or multicast datgram.) |
|
*/ |
|
udpstat.udps_noportbcast++; |
|
goto bad; |
|
} |
|
if (sbappendaddr(&last->so_rcv, sintosa(&udp_in), m, |
|
(struct mbuf *)0) == 0) { |
|
udpstat.udps_fullsock++; |
|
goto bad; |
|
} |
|
sorwakeup(last); |
|
return; |
|
} |
/* |
/* |
* Locate pcb for datagram. |
* Locate pcb for datagram. |
*/ |
*/ |
inp = udp_last_inpcb; |
inp = in_pcbhashlookup(&udbtable, ip->ip_src, uh->uh_sport, |
if (inp->inp_lport != uh->uh_dport || |
ip->ip_dst, uh->uh_dport); |
inp->inp_fport != uh->uh_sport || |
|
inp->inp_faddr.s_addr != ip->ip_src.s_addr || |
|
inp->inp_laddr.s_addr != ip->ip_dst.s_addr) { |
|
inp = in_pcblookup(&udb, ip->ip_src, uh->uh_sport, |
|
ip->ip_dst, uh->uh_dport, INPLOOKUP_WILDCARD); |
|
if (inp) |
|
udp_last_inpcb = inp; |
|
udpstat.udpps_pcbcachemiss++; |
|
} |
|
if (inp == 0) { |
if (inp == 0) { |
/* don't send ICMP response for broadcast packet */ |
++udpstat.udps_pcbhashmiss; |
udpstat.udps_noport++; |
inp = in_pcblookup(&udbtable, ip->ip_src, uh->uh_sport, |
if (m->m_flags & M_BCAST) { |
ip->ip_dst, uh->uh_dport, INPLOOKUP_WILDCARD); |
udpstat.udps_noportbcast++; |
if (inp == 0) { |
goto bad; |
udpstat.udps_noport++; |
|
if (m->m_flags & (M_BCAST | M_MCAST)) { |
|
udpstat.udps_noportbcast++; |
|
goto bad; |
|
} |
|
*ip = save_ip; |
|
ip->ip_len += iphlen; |
|
icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_PORT, 0, 0); |
|
return; |
} |
} |
*ip = save_ip; |
|
ip->ip_len += iphlen; |
|
icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_PORT); |
|
return; |
|
} |
} |
|
|
/* |
/* |
Line 183 udp_input(m, iphlen) |
|
Line 294 udp_input(m, iphlen) |
|
udp_in.sin_addr = ip->ip_src; |
udp_in.sin_addr = ip->ip_src; |
if (inp->inp_flags & INP_CONTROLOPTS) { |
if (inp->inp_flags & INP_CONTROLOPTS) { |
struct mbuf **mp = &opts; |
struct mbuf **mp = &opts; |
struct mbuf *udp_saveopt(); |
|
|
|
if (inp->inp_flags & INP_RECVDSTADDR) { |
if (inp->inp_flags & INP_RECVDSTADDR) { |
*mp = udp_saveopt((caddr_t) &ip->ip_dst, |
*mp = udp_saveopt((caddr_t) &ip->ip_dst, |
Line 212 udp_input(m, iphlen) |
|
Line 322 udp_input(m, iphlen) |
|
m->m_len -= iphlen; |
m->m_len -= iphlen; |
m->m_pkthdr.len -= iphlen; |
m->m_pkthdr.len -= iphlen; |
m->m_data += iphlen; |
m->m_data += iphlen; |
if (sbappendaddr(&inp->inp_socket->so_rcv, (struct sockaddr *)&udp_in, |
if (sbappendaddr(&inp->inp_socket->so_rcv, sintosa(&udp_in), m, |
m, opts) == 0) { |
opts) == 0) { |
udpstat.udps_fullsock++; |
udpstat.udps_fullsock++; |
goto bad; |
goto bad; |
} |
} |
Line 241 udp_saveopt(p, size, type) |
|
Line 351 udp_saveopt(p, size, type) |
|
if ((m = m_get(M_DONTWAIT, MT_CONTROL)) == NULL) |
if ((m = m_get(M_DONTWAIT, MT_CONTROL)) == NULL) |
return ((struct mbuf *) NULL); |
return ((struct mbuf *) NULL); |
cp = (struct cmsghdr *) mtod(m, struct cmsghdr *); |
cp = (struct cmsghdr *) mtod(m, struct cmsghdr *); |
bcopy(p, (caddr_t)(cp + 1), size); |
bcopy(p, CMSG_DATA(cp), size); |
size += sizeof(*cp); |
size += sizeof(*cp); |
m->m_len = size; |
m->m_len = size; |
cp->cmsg_len = size; |
cp->cmsg_len = size; |
Line 254 udp_saveopt(p, size, type) |
|
Line 364 udp_saveopt(p, size, type) |
|
* Notify a udp user of an asynchronous error; |
* Notify a udp user of an asynchronous error; |
* just wake up so that he can collect error status. |
* just wake up so that he can collect error status. |
*/ |
*/ |
|
static void |
udp_notify(inp, errno) |
udp_notify(inp, errno) |
register struct inpcb *inp; |
register struct inpcb *inp; |
|
int errno; |
{ |
{ |
|
|
inp->inp_socket->so_error = errno; |
inp->inp_socket->so_error = errno; |
sorwakeup(inp->inp_socket); |
sorwakeup(inp->inp_socket); |
sowwakeup(inp->inp_socket); |
sowwakeup(inp->inp_socket); |
} |
} |
|
|
udp_ctlinput(cmd, sa, ip) |
void * |
|
udp_ctlinput(cmd, sa, v) |
int cmd; |
int cmd; |
struct sockaddr *sa; |
struct sockaddr *sa; |
register struct ip *ip; |
void *v; |
{ |
{ |
|
register struct ip *ip = v; |
register struct udphdr *uh; |
register struct udphdr *uh; |
extern struct in_addr zeroin_addr; |
extern int inetctlerrmap[]; |
extern u_char inetctlerrmap[]; |
void (*notify) __P((struct inpcb *, int)) = udp_notify; |
|
int errno; |
if ((unsigned)cmd > PRC_NCMDS || inetctlerrmap[cmd] == 0) |
|
return; |
if ((unsigned)cmd >= PRC_NCMDS) |
|
return NULL; |
|
errno = inetctlerrmap[cmd]; |
|
if (PRC_IS_REDIRECT(cmd)) |
|
notify = in_rtchange, ip = 0; |
|
else if (cmd == PRC_HOSTDEAD) |
|
ip = 0; |
|
else if (errno == 0) |
|
return NULL; |
if (ip) { |
if (ip) { |
uh = (struct udphdr *)((caddr_t)ip + (ip->ip_hl << 2)); |
uh = (struct udphdr *)((caddr_t)ip + (ip->ip_hl << 2)); |
in_pcbnotify(&udb, sa, uh->uh_dport, ip->ip_src, uh->uh_sport, |
in_pcbnotify(&udbtable, sa, uh->uh_dport, ip->ip_src, |
cmd, udp_notify); |
uh->uh_sport, errno, notify); |
} else |
} else |
in_pcbnotify(&udb, sa, 0, zeroin_addr, 0, cmd, udp_notify); |
in_pcbnotifyall(&udbtable, sa, errno, notify); |
|
return NULL; |
} |
} |
|
|
udp_output(inp, m, addr, control) |
int |
|
#if __STDC__ |
|
udp_output(struct mbuf *m, ...) |
|
#else |
|
udp_output(m, va_alist) |
|
struct mbuf *m; |
|
va_dcl |
|
#endif |
|
{ |
register struct inpcb *inp; |
register struct inpcb *inp; |
register struct mbuf *m; |
|
struct mbuf *addr, *control; |
struct mbuf *addr, *control; |
{ |
|
register struct udpiphdr *ui; |
register struct udpiphdr *ui; |
register int len = m->m_pkthdr.len; |
register int len = m->m_pkthdr.len; |
struct in_addr laddr; |
struct in_addr laddr; |
int s, error = 0; |
int s = 0, error = 0; |
|
va_list ap; |
|
|
|
va_start(ap, m); |
|
inp = va_arg(ap, struct inpcb *); |
|
addr = va_arg(ap, struct mbuf *); |
|
control = va_arg(ap, struct mbuf *); |
|
va_end(ap); |
|
|
if (control) |
if (control) |
m_freem(control); /* XXX */ |
m_freem(control); /* XXX */ |
Line 304 udp_output(inp, m, addr, control) |
|
Line 439 udp_output(inp, m, addr, control) |
|
/* |
/* |
* Must block input while temporarily connected. |
* Must block input while temporarily connected. |
*/ |
*/ |
s = splnet(); |
s = splsoftnet(); |
error = in_pcbconnect(inp, addr); |
error = in_pcbconnect(inp, addr); |
if (error) { |
if (error) { |
splx(s); |
splx(s); |
Line 320 udp_output(inp, m, addr, control) |
|
Line 455 udp_output(inp, m, addr, control) |
|
* Calculate data length and get a mbuf |
* Calculate data length and get a mbuf |
* for UDP and IP headers. |
* for UDP and IP headers. |
*/ |
*/ |
M_PREPEND(m, sizeof(struct udpiphdr), M_WAIT); |
M_PREPEND(m, sizeof(struct udpiphdr), M_DONTWAIT); |
|
if (m == 0) { |
|
error = ENOBUFS; |
|
goto release; |
|
} |
|
|
/* |
/* |
* Fill in mbuf with extended UDP header |
* Fill in mbuf with extended UDP header |
* and addresses and length put into network format. |
* and addresses and length put into network format. |
*/ |
*/ |
ui = mtod(m, struct udpiphdr *); |
ui = mtod(m, struct udpiphdr *); |
ui->ui_next = ui->ui_prev = 0; |
bzero(ui->ui_x1, sizeof ui->ui_x1); |
ui->ui_x1 = 0; |
|
ui->ui_pr = IPPROTO_UDP; |
ui->ui_pr = IPPROTO_UDP; |
ui->ui_len = htons((u_short)len + sizeof (struct udphdr)); |
ui->ui_len = htons((u_int16_t)len + sizeof (struct udphdr)); |
ui->ui_src = inp->inp_laddr; |
ui->ui_src = inp->inp_laddr; |
ui->ui_dst = inp->inp_faddr; |
ui->ui_dst = inp->inp_faddr; |
ui->ui_sport = inp->inp_lport; |
ui->ui_sport = inp->inp_lport; |
Line 350 udp_output(inp, m, addr, control) |
|
Line 488 udp_output(inp, m, addr, control) |
|
((struct ip *)ui)->ip_tos = inp->inp_ip.ip_tos; /* XXX */ |
((struct ip *)ui)->ip_tos = inp->inp_ip.ip_tos; /* XXX */ |
udpstat.udps_opackets++; |
udpstat.udps_opackets++; |
error = ip_output(m, inp->inp_options, &inp->inp_route, |
error = ip_output(m, inp->inp_options, &inp->inp_route, |
inp->inp_socket->so_options & (SO_DONTROUTE | SO_BROADCAST)); |
inp->inp_socket->so_options & (SO_DONTROUTE | SO_BROADCAST), |
|
inp->inp_moptions); |
|
|
if (addr) { |
if (addr) { |
in_pcbdisconnect(inp); |
in_pcbdisconnect(inp); |
Line 369 u_long udp_recvspace = 40 * (1024 + size |
|
Line 508 u_long udp_recvspace = 40 * (1024 + size |
|
/* 40 1K datagrams */ |
/* 40 1K datagrams */ |
|
|
/*ARGSUSED*/ |
/*ARGSUSED*/ |
|
int |
udp_usrreq(so, req, m, addr, control) |
udp_usrreq(so, req, m, addr, control) |
struct socket *so; |
struct socket *so; |
int req; |
int req; |
Line 379 udp_usrreq(so, req, m, addr, control) |
|
Line 519 udp_usrreq(so, req, m, addr, control) |
|
int s; |
int s; |
|
|
if (req == PRU_CONTROL) |
if (req == PRU_CONTROL) |
return (in_control(so, (int)m, (caddr_t)addr, |
return (in_control(so, (long)m, (caddr_t)addr, |
(struct ifnet *)control)); |
(struct ifnet *)control)); |
if (inp == NULL && req != PRU_ATTACH) { |
if (inp == NULL && req != PRU_ATTACH) { |
error = EINVAL; |
error = EINVAL; |
Line 396 udp_usrreq(so, req, m, addr, control) |
|
Line 536 udp_usrreq(so, req, m, addr, control) |
|
error = EINVAL; |
error = EINVAL; |
break; |
break; |
} |
} |
s = splnet(); |
s = splsoftnet(); |
error = in_pcballoc(so, &udb); |
error = in_pcballoc(so, &udbtable); |
splx(s); |
splx(s); |
if (error) |
if (error) |
break; |
break; |
error = soreserve(so, udp_sendspace, udp_recvspace); |
error = soreserve(so, udp_sendspace, udp_recvspace); |
if (error) |
if (error) |
break; |
break; |
((struct inpcb *) so->so_pcb)->inp_ip.ip_ttl = udp_ttl; |
((struct inpcb *) so->so_pcb)->inp_ip.ip_ttl = ip_defttl; |
break; |
break; |
|
|
case PRU_DETACH: |
case PRU_DETACH: |
Line 412 udp_usrreq(so, req, m, addr, control) |
|
Line 552 udp_usrreq(so, req, m, addr, control) |
|
break; |
break; |
|
|
case PRU_BIND: |
case PRU_BIND: |
s = splnet(); |
s = splsoftnet(); |
error = in_pcbbind(inp, addr); |
error = in_pcbbind(inp, addr); |
splx(s); |
splx(s); |
break; |
break; |
Line 426 udp_usrreq(so, req, m, addr, control) |
|
Line 566 udp_usrreq(so, req, m, addr, control) |
|
error = EISCONN; |
error = EISCONN; |
break; |
break; |
} |
} |
s = splnet(); |
s = splsoftnet(); |
error = in_pcbconnect(inp, addr); |
error = in_pcbconnect(inp, addr); |
splx(s); |
splx(s); |
if (error == 0) |
if (error == 0) |
Line 446 udp_usrreq(so, req, m, addr, control) |
|
Line 586 udp_usrreq(so, req, m, addr, control) |
|
error = ENOTCONN; |
error = ENOTCONN; |
break; |
break; |
} |
} |
s = splnet(); |
s = splsoftnet(); |
in_pcbdisconnect(inp); |
in_pcbdisconnect(inp); |
inp->inp_laddr.s_addr = INADDR_ANY; |
inp->inp_laddr.s_addr = INADDR_ANY; |
splx(s); |
splx(s); |
Line 458 udp_usrreq(so, req, m, addr, control) |
|
Line 598 udp_usrreq(so, req, m, addr, control) |
|
break; |
break; |
|
|
case PRU_SEND: |
case PRU_SEND: |
return (udp_output(inp, m, addr, control)); |
return (udp_output(m, inp, addr, control)); |
|
|
case PRU_ABORT: |
case PRU_ABORT: |
soisdisconnected(so); |
soisdisconnected(so); |
|
|
return (error); |
return (error); |
} |
} |
|
|
|
static void |
udp_detach(inp) |
udp_detach(inp) |
struct inpcb *inp; |
struct inpcb *inp; |
{ |
{ |
int s = splnet(); |
int s = splsoftnet(); |
|
|
if (inp == udp_last_inpcb) |
|
udp_last_inpcb = &udb; |
|
in_pcbdetach(inp); |
in_pcbdetach(inp); |
splx(s); |
splx(s); |
} |
} |
|
|
|
/* |
|
* Sysctl for udp variables. |
|
*/ |
|
int |
|
udp_sysctl(name, namelen, oldp, oldlenp, newp, newlen) |
|
int *name; |
|
u_int namelen; |
|
void *oldp; |
|
size_t *oldlenp; |
|
void *newp; |
|
size_t newlen; |
|
{ |
|
/* All sysctl names at this level are terminal. */ |
|
if (namelen != 1) |
|
return (ENOTDIR); |
|
|
|
switch (name[0]) { |
|
case UDPCTL_CHECKSUM: |
|
return (sysctl_int(oldp, oldlenp, newp, newlen, &udpcksum)); |
|
default: |
|
return (ENOPROTOOPT); |
|
} |
|
/* NOTREACHED */ |
|
} |