Changeset View
Changeset View
Standalone View
Standalone View
head/sys/netinet/udp_usrreq.c
Show First 20 Lines • Show All 786 Lines • ▼ Show 20 Lines | if (ip != NULL) { | ||||
inp = in_pcblookup(pcbinfo, faddr, uh->uh_dport, | inp = in_pcblookup(pcbinfo, faddr, uh->uh_dport, | ||||
ip->ip_src, uh->uh_sport, INPLOOKUP_RLOCKPCB, NULL); | ip->ip_src, uh->uh_sport, INPLOOKUP_RLOCKPCB, NULL); | ||||
if (inp != NULL) { | if (inp != NULL) { | ||||
INP_RLOCK_ASSERT(inp); | INP_RLOCK_ASSERT(inp); | ||||
if (inp->inp_socket != NULL) { | if (inp->inp_socket != NULL) { | ||||
udp_notify(inp, inetctlerrmap[cmd]); | udp_notify(inp, inetctlerrmap[cmd]); | ||||
} | } | ||||
INP_RUNLOCK(inp); | INP_RUNLOCK(inp); | ||||
} else { | |||||
inp = in_pcblookup(pcbinfo, faddr, uh->uh_dport, | |||||
ip->ip_src, uh->uh_sport, | |||||
INPLOOKUP_WILDCARD | INPLOOKUP_RLOCKPCB, NULL); | |||||
if (inp != NULL) { | |||||
struct udpcb *up; | |||||
up = intoudpcb(inp); | |||||
if (up->u_icmp_func != NULL) { | |||||
INP_RUNLOCK(inp); | |||||
(*up->u_icmp_func)(cmd, sa, vip, up->u_tun_ctx); | |||||
} else { | |||||
INP_RUNLOCK(inp); | |||||
} | } | ||||
} | |||||
} | |||||
} else | } else | ||||
in_pcbnotifyall(pcbinfo, faddr, inetctlerrmap[cmd], | in_pcbnotifyall(pcbinfo, faddr, inetctlerrmap[cmd], | ||||
udp_notify); | udp_notify); | ||||
} | } | ||||
void | void | ||||
udp_ctlinput(int cmd, struct sockaddr *sa, void *vip) | udp_ctlinput(int cmd, struct sockaddr *sa, void *vip) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 939 Lines • ▼ Show 20 Lines | udp_attach(struct socket *so, int proto, struct thread *td) | ||||
INP_WUNLOCK(inp); | INP_WUNLOCK(inp); | ||||
INP_INFO_WUNLOCK(pcbinfo); | INP_INFO_WUNLOCK(pcbinfo); | ||||
return (0); | return (0); | ||||
} | } | ||||
#endif /* INET */ | #endif /* INET */ | ||||
int | int | ||||
udp_set_kernel_tunneling(struct socket *so, udp_tun_func_t f, void *ctx) | udp_set_kernel_tunneling(struct socket *so, udp_tun_func_t f, udp_tun_icmp_t i, void *ctx) | ||||
{ | { | ||||
struct inpcb *inp; | struct inpcb *inp; | ||||
struct udpcb *up; | struct udpcb *up; | ||||
KASSERT(so->so_type == SOCK_DGRAM, | KASSERT(so->so_type == SOCK_DGRAM, | ||||
("udp_set_kernel_tunneling: !dgram")); | ("udp_set_kernel_tunneling: !dgram")); | ||||
inp = sotoinpcb(so); | inp = sotoinpcb(so); | ||||
KASSERT(inp != NULL, ("udp_set_kernel_tunneling: inp == NULL")); | KASSERT(inp != NULL, ("udp_set_kernel_tunneling: inp == NULL")); | ||||
INP_WLOCK(inp); | INP_WLOCK(inp); | ||||
up = intoudpcb(inp); | up = intoudpcb(inp); | ||||
if (up->u_tun_func != NULL) { | if ((up->u_tun_func != NULL) || | ||||
(up->u_icmp_func != NULL)) { | |||||
INP_WUNLOCK(inp); | INP_WUNLOCK(inp); | ||||
return (EBUSY); | return (EBUSY); | ||||
} | } | ||||
up->u_tun_func = f; | up->u_tun_func = f; | ||||
up->u_icmp_func = i; | |||||
up->u_tun_ctx = ctx; | up->u_tun_ctx = ctx; | ||||
INP_WUNLOCK(inp); | INP_WUNLOCK(inp); | ||||
return (0); | return (0); | ||||
} | } | ||||
#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) | ||||
▲ Show 20 Lines • Show All 159 Lines • Show Last 20 Lines |