Changeset View
Changeset View
Standalone View
Standalone View
sys/compat/linux/linux_socket.c
Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | |||||
#endif | #endif | ||||
#include <compat/linux/linux_common.h> | #include <compat/linux/linux_common.h> | ||||
#include <compat/linux/linux_file.h> | #include <compat/linux/linux_file.h> | ||||
#include <compat/linux/linux_mib.h> | #include <compat/linux/linux_mib.h> | ||||
#include <compat/linux/linux_socket.h> | #include <compat/linux/linux_socket.h> | ||||
#include <compat/linux/linux_timer.h> | #include <compat/linux/linux_timer.h> | ||||
#include <compat/linux/linux_util.h> | #include <compat/linux/linux_util.h> | ||||
#define SECURITY_CONTEXT_STRING "unconfined" | |||||
static int linux_sendmsg_common(struct thread *, l_int, struct l_msghdr *, | static int linux_sendmsg_common(struct thread *, l_int, struct l_msghdr *, | ||||
l_uint); | l_uint); | ||||
static int linux_recvmsg_common(struct thread *, l_int, struct l_msghdr *, | static int linux_recvmsg_common(struct thread *, l_int, struct l_msghdr *, | ||||
l_uint, struct msghdr *); | l_uint, struct msghdr *); | ||||
static int linux_set_socket_flags(int, int *); | static int linux_set_socket_flags(int, int *); | ||||
static int | static int | ||||
linux_to_bsd_sockopt_level(int level) | linux_to_bsd_sockopt_level(int level) | ||||
▲ Show 20 Lines • Show All 1,763 Lines • ▼ Show 20 Lines | linux_setsockopt(struct thread *td, struct linux_setsockopt_args *args) | ||||
} else { | } else { | ||||
error = kern_setsockopt(td, args->s, level, | error = kern_setsockopt(td, args->s, level, | ||||
name, PTRIN(args->optval), UIO_USERSPACE, args->optlen); | name, PTRIN(args->optval), UIO_USERSPACE, args->optlen); | ||||
} | } | ||||
return (error); | return (error); | ||||
} | } | ||||
static int | |||||
linux_getsockopt_so_peersec(struct thread *td, | |||||
struct linux_getsockopt_args *args) | |||||
{ | |||||
socklen_t len; | |||||
int error; | |||||
len = sizeof(SECURITY_CONTEXT_STRING); | |||||
if (args->optlen < len) { | |||||
error = copyout(&len, PTRIN(args->optlen), sizeof(len)); | |||||
if (error == 0) | |||||
error = ERANGE; | |||||
return (error); | |||||
} | |||||
error = copyout(SECURITY_CONTEXT_STRING, | |||||
PTRIN(args->optval), sizeof(SECURITY_CONTEXT_STRING)); | |||||
if (error == 0) | |||||
error = copyout(&len, PTRIN(args->optlen), sizeof(len)); | |||||
return (error); | |||||
} | |||||
int | int | ||||
linux_getsockopt(struct thread *td, struct linux_getsockopt_args *args) | linux_getsockopt(struct thread *td, struct linux_getsockopt_args *args) | ||||
{ | { | ||||
l_timeval linux_tv; | l_timeval linux_tv; | ||||
struct timeval tv; | struct timeval tv; | ||||
socklen_t tv_len, xulen, len; | socklen_t tv_len, xulen, len; | ||||
struct sockaddr *sa; | struct sockaddr *sa; | ||||
struct xucred xu; | struct xucred xu; | ||||
struct l_ucred lxu; | struct l_ucred lxu; | ||||
int error, level, name, newval; | int error, level, name, newval; | ||||
level = linux_to_bsd_sockopt_level(args->level); | level = linux_to_bsd_sockopt_level(args->level); | ||||
switch (level) { | switch (level) { | ||||
case SOL_SOCKET: | case SOL_SOCKET: | ||||
if (args->optname == LINUX_SO_PEERSEC) | |||||
return (linux_getsockopt_so_peersec(td, args)); | |||||
name = linux_to_bsd_so_sockopt(args->optname); | name = linux_to_bsd_so_sockopt(args->optname); | ||||
switch (name) { | switch (name) { | ||||
case LOCAL_CREDS_PERSISTENT: | case LOCAL_CREDS_PERSISTENT: | ||||
level = SOL_LOCAL; | level = SOL_LOCAL; | ||||
break; | break; | ||||
case SO_RCVTIMEO: | case SO_RCVTIMEO: | ||||
/* FALLTHROUGH */ | /* FALLTHROUGH */ | ||||
case SO_SNDTIMEO: | case SO_SNDTIMEO: | ||||
▲ Show 20 Lines • Show All 313 Lines • Show Last 20 Lines |