Skip to content
Snippets Groups Projects
Commit a567197b authored by Jeremy Soller's avatar Jeremy Soller
Browse files

enable getsockopt and setsockopt

parent 9dbf49fd
No related branches found
No related tags found
No related merge requests found
...@@ -92,17 +92,25 @@ pub unsafe extern "C" fn getsockname( ...@@ -92,17 +92,25 @@ pub unsafe extern "C" fn getsockname(
) )
} }
// #[no_mangle] #[no_mangle]
// pub unsafe extern "C" fn getsockopt( pub unsafe extern "C" fn getsockopt(
// socket: c_int, socket: c_int,
// level: c_int, level: c_int,
// option_name: c_int, option_name: c_int,
// option_value: *mut c_void, option_value: *mut c_void,
// option_len: *mut socklen_t, option_len: *mut socklen_t,
// ) -> c_int { ) -> c_int {
// Sys::getsockopt(socket, level, option_name, option_value, option_len) trace_expr!(
// } Sys::getsockopt(socket, level, option_name, option_value, option_len),
// "getsockopt({}, {}, {}, {:p}, {:p})",
socket,
level,
option_name,
option_value,
option_len
)
}
// #[no_mangle] // #[no_mangle]
// pub unsafe extern "C" fn listen(socket: c_int, backlog: c_int) -> c_int { // pub unsafe extern "C" fn listen(socket: c_int, backlog: c_int) -> c_int {
// Sys::listen(socket, backlog) // Sys::listen(socket, backlog)
...@@ -177,16 +185,24 @@ pub unsafe extern "C" fn sendto( ...@@ -177,16 +185,24 @@ pub unsafe extern "C" fn sendto(
) )
} }
// #[no_mangle] #[no_mangle]
// pub unsafe extern "C" fn setsockopt( pub unsafe extern "C" fn setsockopt(
// socket: c_int, socket: c_int,
// level: c_int, level: c_int,
// option_name: c_int, option_name: c_int,
// option_value: *const c_void, option_value: *const c_void,
// option_len: socklen_t, option_len: socklen_t,
// ) -> c_int { ) -> c_int {
// Sys::setsockopt(socket, level, option_name, option_value, option_len) trace_expr!(
// } Sys::setsockopt(socket, level, option_name, option_value, option_len),
"setsockopt({}, {}, {}, {:p}, {})",
socket,
level,
option_name,
option_value,
option_len
)
}
// #[no_mangle] // #[no_mangle]
// pub unsafe extern "C" fn shutdown(socket: c_int, how: c_int) -> c_int { // pub unsafe extern "C" fn shutdown(socket: c_int, how: c_int) -> c_int {
......
...@@ -4,48 +4,10 @@ use super::{e, Sys}; ...@@ -4,48 +4,10 @@ use super::{e, Sys};
use header::sys_socket::{sockaddr, socklen_t}; use header::sys_socket::{sockaddr, socklen_t};
impl Sys { impl Sys {
fn getsockopt(
socket: c_int,
level: c_int,
option_name: c_int,
option_value: *mut c_void,
option_len: *mut socklen_t,
) -> c_int {
e(unsafe {
syscall!(
GETSOCKOPT,
socket,
level,
option_name,
option_value,
option_len
)
}) as c_int
}
fn listen(socket: c_int, backlog: c_int) -> c_int { fn listen(socket: c_int, backlog: c_int) -> c_int {
e(unsafe { syscall!(LISTEN, socket, backlog) }) as c_int e(unsafe { syscall!(LISTEN, socket, backlog) }) as c_int
} }
fn setsockopt(
socket: c_int,
level: c_int,
option_name: c_int,
option_value: *const c_void,
option_len: socklen_t,
) -> c_int {
e(unsafe {
syscall!(
SETSOCKOPT,
socket,
level,
option_name,
option_value,
option_len
)
}) as c_int
}
fn shutdown(socket: c_int, how: c_int) -> c_int { fn shutdown(socket: c_int, how: c_int) -> c_int {
e(unsafe { syscall!(SHUTDOWN, socket, how) }) as c_int e(unsafe { syscall!(SHUTDOWN, socket, how) }) as c_int
} }
...@@ -84,6 +46,25 @@ impl PalSocket for Sys { ...@@ -84,6 +46,25 @@ impl PalSocket for Sys {
e(syscall!(GETSOCKNAME, socket, address, address_len)) as c_int e(syscall!(GETSOCKNAME, socket, address, address_len)) as c_int
} }
fn getsockopt(
socket: c_int,
level: c_int,
option_name: c_int,
option_value: *mut c_void,
option_len: *mut socklen_t,
) -> c_int {
e(unsafe {
syscall!(
GETSOCKOPT,
socket,
level,
option_name,
option_value,
option_len
)
}) as c_int
}
unsafe fn recvfrom( unsafe fn recvfrom(
socket: c_int, socket: c_int,
buf: *mut c_void, buf: *mut c_void,
...@@ -116,6 +97,25 @@ impl PalSocket for Sys { ...@@ -116,6 +97,25 @@ impl PalSocket for Sys {
)) as ssize_t )) as ssize_t
} }
fn setsockopt(
socket: c_int,
level: c_int,
option_name: c_int,
option_value: *const c_void,
option_len: socklen_t,
) -> c_int {
e(unsafe {
syscall!(
SETSOCKOPT,
socket,
level,
option_name,
option_value,
option_len
)
}) as c_int
}
unsafe fn socket(domain: c_int, kind: c_int, protocol: c_int) -> c_int { unsafe fn socket(domain: c_int, kind: c_int, protocol: c_int) -> c_int {
e(syscall!(SOCKET, domain, kind, protocol)) as c_int e(syscall!(SOCKET, domain, kind, protocol)) as c_int
} }
......
...@@ -21,6 +21,14 @@ pub trait PalSocket: Pal { ...@@ -21,6 +21,14 @@ pub trait PalSocket: Pal {
address_len: *mut socklen_t, address_len: *mut socklen_t,
) -> c_int; ) -> c_int;
fn getsockopt(
socket: c_int,
level: c_int,
option_name: c_int,
option_value: *mut c_void,
option_len: *mut socklen_t,
) -> c_int;
unsafe fn recvfrom( unsafe fn recvfrom(
socket: c_int, socket: c_int,
buf: *mut c_void, buf: *mut c_void,
...@@ -39,5 +47,13 @@ pub trait PalSocket: Pal { ...@@ -39,5 +47,13 @@ pub trait PalSocket: Pal {
dest_len: socklen_t, dest_len: socklen_t,
) -> ssize_t; ) -> ssize_t;
fn setsockopt(
socket: c_int,
level: c_int,
option_name: c_int,
option_value: *const c_void,
option_len: socklen_t,
) -> c_int;
unsafe fn socket(domain: c_int, kind: c_int, protocol: c_int) -> c_int; unsafe fn socket(domain: c_int, kind: c_int, protocol: c_int) -> c_int;
} }
...@@ -134,6 +134,16 @@ impl PalSocket for Sys { ...@@ -134,6 +134,16 @@ impl PalSocket for Sys {
e(inner_get_name(true, socket, address, address_len)) as c_int e(inner_get_name(true, socket, address, address_len)) as c_int
} }
fn getsockopt(
socket: c_int,
level: c_int,
option_name: c_int,
option_value: *mut c_void,
option_len: *mut socklen_t,
) -> c_int {
e(Err(syscall::Error::new(syscall::ENOSYS))) as c_int
}
unsafe fn recvfrom( unsafe fn recvfrom(
socket: c_int, socket: c_int,
buf: *mut c_void, buf: *mut c_void,
...@@ -186,6 +196,16 @@ impl PalSocket for Sys { ...@@ -186,6 +196,16 @@ impl PalSocket for Sys {
} }
} }
fn setsockopt(
socket: c_int,
level: c_int,
option_name: c_int,
option_value: *const c_void,
option_len: socklen_t,
) -> c_int {
e(Err(syscall::Error::new(syscall::ENOSYS))) as c_int
}
unsafe fn socket(domain: c_int, mut kind: c_int, protocol: c_int) -> c_int { unsafe fn socket(domain: c_int, mut kind: c_int, protocol: c_int) -> c_int {
if domain != AF_INET { if domain != AF_INET {
errno = syscall::EAFNOSUPPORT; errno = syscall::EAFNOSUPPORT;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment