Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet6/raw_ip6.c
Show First 20 Lines • Show All 754 Lines • ▼ Show 20 Lines | rip6_bind(struct socket *so, struct sockaddr *nam, struct thread *td) | ||||
struct inpcb *inp; | struct inpcb *inp; | ||||
struct sockaddr_in6 *addr = (struct sockaddr_in6 *)nam; | struct sockaddr_in6 *addr = (struct sockaddr_in6 *)nam; | ||||
struct ifaddr *ifa = NULL; | struct ifaddr *ifa = NULL; | ||||
int error = 0; | int error = 0; | ||||
inp = sotoinpcb(so); | inp = sotoinpcb(so); | ||||
KASSERT(inp != NULL, ("rip6_bind: inp == NULL")); | KASSERT(inp != NULL, ("rip6_bind: inp == NULL")); | ||||
if (nam->sa_family != AF_INET6) | |||||
return (EAFNOSUPPORT); | |||||
if (nam->sa_len != sizeof(*addr)) | if (nam->sa_len != sizeof(*addr)) | ||||
return (EINVAL); | return (EINVAL); | ||||
if ((error = prison_check_ip6(td->td_ucred, &addr->sin6_addr)) != 0) | if ((error = prison_check_ip6(td->td_ucred, &addr->sin6_addr)) != 0) | ||||
return (error); | return (error); | ||||
if (CK_STAILQ_EMPTY(&V_ifnet) || addr->sin6_family != AF_INET6) | if (CK_STAILQ_EMPTY(&V_ifnet) || addr->sin6_family != AF_INET6) | ||||
return (EADDRNOTAVAIL); | return (EADDRNOTAVAIL); | ||||
if ((error = sa6_embedscope(addr, V_ip6_use_defzone)) != 0) | if ((error = sa6_embedscope(addr, V_ip6_use_defzone)) != 0) | ||||
return (error); | return (error); | ||||
▲ Show 20 Lines • Show All 114 Lines • ▼ Show 20 Lines | if (so->so_state & SS_ISCONNECTED) { | ||||
bcopy(&inp->in6p_faddr, &tmp.sin6_addr, | bcopy(&inp->in6p_faddr, &tmp.sin6_addr, | ||||
sizeof(struct in6_addr)); | sizeof(struct in6_addr)); | ||||
INP_RUNLOCK(inp); | INP_RUNLOCK(inp); | ||||
dst = &tmp; | dst = &tmp; | ||||
} else { | } else { | ||||
if (nam == NULL) { | if (nam == NULL) { | ||||
m_freem(m); | m_freem(m); | ||||
return (ENOTCONN); | return (ENOTCONN); | ||||
} | |||||
if (nam->sa_family != AF_INET6) { | |||||
m_freem(m); | |||||
return (EAFNOSUPPORT); | |||||
} | } | ||||
if (nam->sa_len != sizeof(struct sockaddr_in6)) { | if (nam->sa_len != sizeof(struct sockaddr_in6)) { | ||||
m_freem(m); | m_freem(m); | ||||
return (EINVAL); | return (EINVAL); | ||||
} | } | ||||
tmp = *(struct sockaddr_in6 *)nam; | tmp = *(struct sockaddr_in6 *)nam; | ||||
dst = &tmp; | dst = &tmp; | ||||
Show All 32 Lines |