Changeset View
Changeset View
Standalone View
Standalone View
head/sys/compat/linux/linux_socket.c
Show First 20 Lines • Show All 933 Lines • ▼ Show 20 Lines | linux_sendmsg_common(struct thread *td, l_int s, struct l_msghdr *msghdr, | ||||
struct mbuf *control; | struct mbuf *control; | ||||
struct msghdr msg; | struct msghdr msg; | ||||
struct l_cmsghdr linux_cmsg; | struct l_cmsghdr linux_cmsg; | ||||
struct l_cmsghdr *ptr_cmsg; | struct l_cmsghdr *ptr_cmsg; | ||||
struct l_msghdr linux_msg; | struct l_msghdr linux_msg; | ||||
struct iovec *iov; | struct iovec *iov; | ||||
socklen_t datalen; | socklen_t datalen; | ||||
struct sockaddr *sa; | struct sockaddr *sa; | ||||
struct socket *so; | |||||
sa_family_t sa_family; | sa_family_t sa_family; | ||||
struct file *fp; | |||||
void *data; | void *data; | ||||
l_size_t len; | l_size_t len; | ||||
l_size_t clen; | l_size_t clen; | ||||
int error; | int error, fflag; | ||||
error = copyin(msghdr, &linux_msg, sizeof(linux_msg)); | error = copyin(msghdr, &linux_msg, sizeof(linux_msg)); | ||||
if (error != 0) | if (error != 0) | ||||
return (error); | return (error); | ||||
/* | /* | ||||
* Some Linux applications (ping) define a non-NULL control data | * Some Linux applications (ping) define a non-NULL control data | ||||
* pointer, but a msg_controllen of 0, which is not allowed in the | * pointer, but a msg_controllen of 0, which is not allowed in the | ||||
Show All 14 Lines | |||||
#else | #else | ||||
error = copyiniov(msg.msg_iov, msg.msg_iovlen, &iov, EMSGSIZE); | error = copyiniov(msg.msg_iov, msg.msg_iovlen, &iov, EMSGSIZE); | ||||
#endif | #endif | ||||
if (error != 0) | if (error != 0) | ||||
return (error); | return (error); | ||||
control = NULL; | control = NULL; | ||||
if (linux_msg.msg_controllen >= sizeof(struct l_cmsghdr)) { | |||||
error = kern_getsockname(td, s, &sa, &datalen); | error = kern_getsockname(td, s, &sa, &datalen); | ||||
if (error != 0) | if (error != 0) | ||||
goto bad; | goto bad; | ||||
sa_family = sa->sa_family; | sa_family = sa->sa_family; | ||||
free(sa, M_SONAME); | free(sa, M_SONAME); | ||||
if (flags & LINUX_MSG_OOB) { | |||||
error = EOPNOTSUPP; | |||||
if (sa_family == AF_UNIX) | |||||
goto bad; | |||||
error = getsock_cap(td, s, &cap_send_rights, &fp, | |||||
&fflag, NULL); | |||||
if (error != 0) | |||||
goto bad; | |||||
so = fp->f_data; | |||||
if (so->so_type != SOCK_STREAM) | |||||
error = EOPNOTSUPP; | |||||
fdrop(fp, td); | |||||
if (error != 0) | |||||
goto bad; | |||||
} | |||||
if (linux_msg.msg_controllen >= sizeof(struct l_cmsghdr)) { | |||||
error = ENOBUFS; | error = ENOBUFS; | ||||
control = m_get(M_WAITOK, MT_CONTROL); | control = m_get(M_WAITOK, MT_CONTROL); | ||||
MCLGET(control, M_WAITOK); | MCLGET(control, M_WAITOK); | ||||
data = mtod(control, void *); | data = mtod(control, void *); | ||||
datalen = 0; | datalen = 0; | ||||
ptr_cmsg = PTRIN(linux_msg.msg_control); | ptr_cmsg = PTRIN(linux_msg.msg_control); | ||||
▲ Show 20 Lines • Show All 668 Lines • Show Last 20 Lines |