version 1.26, 1996/01/31 03:49:38 |
version 1.27, 1996/02/13 23:44:32 |
|
|
#include <sys/socketvar.h> |
#include <sys/socketvar.h> |
#include <sys/errno.h> |
#include <sys/errno.h> |
#include <sys/stat.h> |
#include <sys/stat.h> |
|
#include <sys/systm.h> |
|
#include <sys/proc.h> |
|
|
|
#include <vm/vm.h> |
|
#include <sys/sysctl.h> |
|
|
#include <net/if.h> |
#include <net/if.h> |
#include <net/route.h> |
#include <net/route.h> |
|
|
#include <netinet/udp.h> |
#include <netinet/udp.h> |
#include <netinet/udp_var.h> |
#include <netinet/udp_var.h> |
|
|
|
#include <machine/stdarg.h> |
|
|
/* |
/* |
* UDP protocol implementation. |
* UDP protocol implementation. |
* Per RFC 768, August, 1980. |
* Per RFC 768, August, 1980. |
|
|
} |
} |
|
|
void |
void |
udp_input(m, iphlen) |
#if __STDC__ |
register struct mbuf *m; |
udp_input(struct mbuf *m, ...) |
int iphlen; |
#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 96 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 149 udp_input(m, iphlen) |
|
Line 166 udp_input(m, iphlen) |
|
bzero(((struct ipovly *)ip)->ih_x1, |
bzero(((struct ipovly *)ip)->ih_x1, |
sizeof ((struct ipovly *)ip)->ih_x1); |
sizeof ((struct ipovly *)ip)->ih_x1); |
((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; |
Line 357 udp_notify(inp, errno) |
|
Line 374 udp_notify(inp, errno) |
|
sowwakeup(inp->inp_socket); |
sowwakeup(inp->inp_socket); |
} |
} |
|
|
void |
void * |
udp_ctlinput(cmd, sa, ip) |
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 int inetctlerrmap[]; |
void (*notify) __P((struct inpcb *, int)) = udp_notify; |
void (*notify) __P((struct inpcb *, int)) = udp_notify; |
int errno; |
int errno; |
|
|
if ((unsigned)cmd >= PRC_NCMDS) |
if ((unsigned)cmd >= PRC_NCMDS) |
return; |
return NULL; |
errno = inetctlerrmap[cmd]; |
errno = inetctlerrmap[cmd]; |
if (PRC_IS_REDIRECT(cmd)) |
if (PRC_IS_REDIRECT(cmd)) |
notify = in_rtchange, ip = 0; |
notify = in_rtchange, ip = 0; |
else if (cmd == PRC_HOSTDEAD) |
else if (cmd == PRC_HOSTDEAD) |
ip = 0; |
ip = 0; |
else if (errno == 0) |
else if (errno == 0) |
return; |
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(&udbtable, sa, uh->uh_dport, ip->ip_src, |
in_pcbnotify(&udbtable, sa, uh->uh_dport, ip->ip_src, |
uh->uh_sport, errno, notify); |
uh->uh_sport, errno, notify); |
} else |
} else |
in_pcbnotifyall(&udbtable, sa, errno, notify); |
in_pcbnotifyall(&udbtable, sa, errno, notify); |
|
return NULL; |
} |
} |
|
|
int |
int |
udp_output(inp, m, addr, control) |
#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 568 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); |
|
|
/* |
/* |
* Sysctl for udp variables. |
* Sysctl for udp variables. |
*/ |
*/ |
|
int |
udp_sysctl(name, namelen, oldp, oldlenp, newp, newlen) |
udp_sysctl(name, namelen, oldp, oldlenp, newp, newlen) |
int *name; |
int *name; |
u_int namelen; |
u_int namelen; |