Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/udp_usrreq.c
Show First 20 Lines • Show All 1,616 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
#ifdef INET | #ifdef INET | ||||
static int | static int | ||||
udp_bind(struct socket *so, struct sockaddr *nam, struct thread *td) | udp_bind(struct socket *so, struct sockaddr *nam, struct thread *td) | ||||
{ | { | ||||
struct inpcb *inp; | struct inpcb *inp; | ||||
struct inpcbinfo *pcbinfo; | struct inpcbinfo *pcbinfo; | ||||
struct sockaddr_in *sinp; | |||||
int error; | int error; | ||||
pcbinfo = udp_get_inpcbinfo(so->so_proto->pr_protocol); | pcbinfo = udp_get_inpcbinfo(so->so_proto->pr_protocol); | ||||
inp = sotoinpcb(so); | inp = sotoinpcb(so); | ||||
KASSERT(inp != NULL, ("udp_bind: inp == NULL")); | KASSERT(inp != NULL, ("udp_bind: inp == NULL")); | ||||
if (nam->sa_family != AF_INET) | sinp = (struct sockaddr_in *)nam; | ||||
if (nam->sa_family != AF_INET) { | |||||
/* | |||||
* Preserve compatibility with old programs. | |||||
*/ | |||||
if (nam->sa_family != AF_UNSPEC || | |||||
sinp->sin_addr.s_addr != INADDR_ANY) | |||||
return (EAFNOSUPPORT); | return (EAFNOSUPPORT); | ||||
nam->sa_family = AF_INET; | |||||
} | |||||
if (nam->sa_len != sizeof(struct sockaddr_in)) | if (nam->sa_len != sizeof(struct sockaddr_in)) | ||||
return (EINVAL); | return (EINVAL); | ||||
INP_WLOCK(inp); | INP_WLOCK(inp); | ||||
INP_HASH_WLOCK(pcbinfo); | INP_HASH_WLOCK(pcbinfo); | ||||
error = in_pcbbind(inp, nam, td->td_ucred); | error = in_pcbbind(inp, nam, td->td_ucred); | ||||
INP_HASH_WUNLOCK(pcbinfo); | INP_HASH_WUNLOCK(pcbinfo); | ||||
INP_WUNLOCK(inp); | INP_WUNLOCK(inp); | ||||
▲ Show 20 Lines • Show All 169 Lines • Show Last 20 Lines |