| version 1.138.2.1, 2006/06/21 15:11:02 |
version 1.138.2.2, 2006/12/30 20:50:34 |
| Line 139 __KERNEL_RCSID(0, "$NetBSD$"); |
|
| Line 139 __KERNEL_RCSID(0, "$NetBSD$"); |
|
| * UDP protocol implementation. |
* UDP protocol implementation. |
| * Per RFC 768, August, 1980. |
* Per RFC 768, August, 1980. |
| */ |
*/ |
| #ifndef COMPAT_42 |
|
| int udpcksum = 1; |
int udpcksum = 1; |
| #else |
|
| int udpcksum = 0; /* XXX */ |
|
| #endif |
|
| int udp_do_loopback_cksum = 0; |
int udp_do_loopback_cksum = 0; |
| |
|
| struct inpcbtable udbtable; |
struct inpcbtable udbtable; |
| Line 177 static void udp_notify (struct inpcb *, |
|
| Line 173 static void udp_notify (struct inpcb *, |
|
| int udbhashsize = UDBHASHSIZE; |
int udbhashsize = UDBHASHSIZE; |
| |
|
| #ifdef MBUFTRACE |
#ifdef MBUFTRACE |
| struct mowner udp_mowner = { "udp" }; |
struct mowner udp_mowner = MOWNER_INIT("udp", ""); |
| struct mowner udp_rx_mowner = { "udp", "rx" }; |
struct mowner udp_rx_mowner = MOWNER_INIT("udp", "rx"); |
| struct mowner udp_tx_mowner = { "udp", "tx" }; |
struct mowner udp_tx_mowner = MOWNER_INIT("udp", "tx"); |
| #endif |
#endif |
| |
|
| #ifdef UDP_CSUM_COUNTERS |
#ifdef UDP_CSUM_COUNTERS |
| Line 999 udp_ctlinput(int cmd, struct sockaddr *s |
|
| Line 995 udp_ctlinput(int cmd, struct sockaddr *s |
|
| } |
} |
| |
|
| int |
int |
| udp_ctloutput(op, so, level, optname, mp) |
udp_ctloutput(int op, struct socket *so, int level, int optname, |
| int op; |
struct mbuf **mp) |
| struct socket *so; |
|
| int level, optname; |
|
| struct mbuf **mp; |
|
| { |
{ |
| int s; |
int s; |
| int error = 0; |
int error = 0; |
| Line 1034 udp_ctloutput(op, so, level, optname, mp |
|
| Line 1027 udp_ctloutput(op, so, level, optname, mp |
|
| default: |
default: |
| error = EAFNOSUPPORT; |
error = EAFNOSUPPORT; |
| goto end; |
goto end; |
| break; |
|
| } |
} |
| |
|
| |
|
| Line 1047 udp_ctloutput(op, so, level, optname, mp |
|
| Line 1039 udp_ctloutput(op, so, level, optname, mp |
|
| case UDP_ENCAP: |
case UDP_ENCAP: |
| if (m == NULL || m->m_len < sizeof (int)) { |
if (m == NULL || m->m_len < sizeof (int)) { |
| error = EINVAL; |
error = EINVAL; |
| goto end; |
break; |
| } |
} |
| |
|
| switch(*mtod(m, int *)) { |
switch(*mtod(m, int *)) { |
| Line 1068 udp_ctloutput(op, so, level, optname, mp |
|
| Line 1060 udp_ctloutput(op, so, level, optname, mp |
|
| #endif |
#endif |
| default: |
default: |
| error = EINVAL; |
error = EINVAL; |
| goto end; |
|
| break; |
break; |
| } |
} |
| break; |
break; |
| |
|
| default: |
default: |
| error = ENOPROTOOPT; |
error = ENOPROTOOPT; |
| goto end; |
|
| break; |
break; |
| } |
} |
| |
if (m != NULL) { |
| |
m_free(m); |
| |
} |
| break; |
break; |
| |
|
| default: |
default: |
| error = EINVAL; |
error = EINVAL; |
| goto end; |
|
| break; |
break; |
| } |
} |
| |
|
| Line 1179 udp_usrreq(struct socket *so, int req, s |
|
| Line 1171 udp_usrreq(struct socket *so, int req, s |
|
| struct mbuf *control, struct lwp *l) |
struct mbuf *control, struct lwp *l) |
| { |
{ |
| struct inpcb *inp; |
struct inpcb *inp; |
| struct proc *p; |
|
| int s; |
int s; |
| int error = 0; |
int error = 0; |
| |
|
| p = l ? l->l_proc : NULL; |
|
| if (req == PRU_CONTROL) |
if (req == PRU_CONTROL) |
| return (in_control(so, (long)m, (caddr_t)nam, |
return (in_control(so, (long)m, (caddr_t)nam, |
| (struct ifnet *)control, p)); |
(struct ifnet *)control, l)); |
| |
|
| |
s = splsoftnet(); |
| |
|
| if (req == PRU_PURGEIF) { |
if (req == PRU_PURGEIF) { |
| in_pcbpurgeif0(&udbtable, (struct ifnet *)control); |
in_pcbpurgeif0(&udbtable, (struct ifnet *)control); |
| in_purgeif((struct ifnet *)control); |
in_purgeif((struct ifnet *)control); |
| in_pcbpurgeif(&udbtable, (struct ifnet *)control); |
in_pcbpurgeif(&udbtable, (struct ifnet *)control); |
| |
splx(s); |
| return (0); |
return (0); |
| } |
} |
| |
|
| s = splsoftnet(); |
|
| inp = sotoinpcb(so); |
inp = sotoinpcb(so); |
| #ifdef DIAGNOSTIC |
#ifdef DIAGNOSTIC |
| if (req != PRU_SEND && req != PRU_SENDOOB && control) |
if (req != PRU_SEND && req != PRU_SENDOOB && control) |
| Line 1239 udp_usrreq(struct socket *so, int req, s |
|
| Line 1231 udp_usrreq(struct socket *so, int req, s |
|
| break; |
break; |
| |
|
| case PRU_BIND: |
case PRU_BIND: |
| error = in_pcbbind(inp, nam, p); |
error = in_pcbbind(inp, nam, l); |
| break; |
break; |
| |
|
| case PRU_LISTEN: |
case PRU_LISTEN: |
| Line 1247 udp_usrreq(struct socket *so, int req, s |
|
| Line 1239 udp_usrreq(struct socket *so, int req, s |
|
| break; |
break; |
| |
|
| case PRU_CONNECT: |
case PRU_CONNECT: |
| error = in_pcbconnect(inp, nam, p); |
error = in_pcbconnect(inp, nam, l); |
| if (error) |
if (error) |
| break; |
break; |
| soisconnected(so); |
soisconnected(so); |
| Line 1289 udp_usrreq(struct socket *so, int req, s |
|
| Line 1281 udp_usrreq(struct socket *so, int req, s |
|
| error = EISCONN; |
error = EISCONN; |
| goto die; |
goto die; |
| } |
} |
| error = in_pcbconnect(inp, nam, p); |
error = in_pcbconnect(inp, nam, l); |
| if (error) |
if (error) |
| goto die; |
goto die; |
| } else { |
} else { |
| Line 1421 SYSCTL_SETUP(sysctl_net_inet_udp_setup, |
|
| Line 1413 SYSCTL_SETUP(sysctl_net_inet_udp_setup, |
|
| * -1 if an error occurent and m was freed |
* -1 if an error occurent and m was freed |
| */ |
*/ |
| static int |
static int |
| udp4_espinudp(mp, off, src, so) |
udp4_espinudp(struct mbuf **mp, int off, struct sockaddr *src, |
| struct mbuf **mp; |
struct socket *so) |
| int off; |
|
| struct sockaddr *src; |
|
| struct socket *so; |
|
| { |
{ |
| size_t len; |
size_t len; |
| caddr_t data; |
caddr_t data; |