Added http downloader and multicast socket options (#1467)
Add a group of socket options used by cURL and rust stdlib, as well as some UDP multicast options.
This commit is contained in:
@ -1120,10 +1120,80 @@ wasi_sock_connect(wasm_exec_env_t exec_env, wasi_fd_t fd, wasi_addr_t *addr)
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_get_recv_buf_size(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
||||
wasi_size_t *size)
|
||||
wasi_sock_get_broadcast(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
||||
bool *is_enabled)
|
||||
{
|
||||
return __WASI_ENOSYS;
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
|
||||
struct fd_table *curfds = NULL;
|
||||
|
||||
if (!wasi_ctx)
|
||||
return __WASI_EACCES;
|
||||
|
||||
if (!validate_native_addr(is_enabled, sizeof(bool)))
|
||||
return __WASI_EINVAL;
|
||||
|
||||
curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
||||
|
||||
return wasmtime_ssp_sock_get_broadcast(curfds, fd, is_enabled);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_get_keep_alive(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
||||
bool *is_enabled)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
|
||||
struct fd_table *curfds = NULL;
|
||||
|
||||
if (!wasi_ctx)
|
||||
return __WASI_EACCES;
|
||||
|
||||
if (!validate_native_addr(is_enabled, sizeof(bool)))
|
||||
return __WASI_EINVAL;
|
||||
|
||||
curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
||||
|
||||
return wasmtime_ssp_sock_get_keep_alive(curfds, fd, is_enabled);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_get_linger(wasm_exec_env_t exec_env, wasi_fd_t fd, bool *is_enabled,
|
||||
int *linger_s)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
|
||||
struct fd_table *curfds = NULL;
|
||||
|
||||
if (!wasi_ctx)
|
||||
return __WASI_EACCES;
|
||||
|
||||
if (!validate_native_addr(is_enabled, sizeof(bool))
|
||||
|| !validate_native_addr(linger_s, sizeof(int)))
|
||||
return __WASI_EINVAL;
|
||||
|
||||
curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
||||
|
||||
return wasmtime_ssp_sock_get_linger(curfds, fd, is_enabled, linger_s);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_get_recv_buf_size(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
||||
size_t *size)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
|
||||
struct fd_table *curfds = NULL;
|
||||
|
||||
if (!wasi_ctx)
|
||||
return __WASI_EACCES;
|
||||
|
||||
if (!validate_native_addr(size, sizeof(wasi_size_t)))
|
||||
return __WASI_EINVAL;
|
||||
|
||||
curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
||||
|
||||
return wasmtime_ssp_sock_get_recv_buf_size(curfds, fd, size);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
@ -1146,22 +1216,60 @@ wasi_sock_get_recv_timeout(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_get_reuse_addr(wasm_exec_env_t exec_env, wasi_fd_t fd, uint8 *reuse)
|
||||
wasi_sock_get_reuse_addr(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
||||
bool *is_enabled)
|
||||
{
|
||||
return __WASI_ENOSYS;
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
|
||||
struct fd_table *curfds = NULL;
|
||||
|
||||
if (!wasi_ctx)
|
||||
return __WASI_EACCES;
|
||||
|
||||
if (!validate_native_addr(is_enabled, sizeof(bool)))
|
||||
return __WASI_EINVAL;
|
||||
|
||||
curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
||||
|
||||
return wasmtime_ssp_sock_get_reuse_addr(curfds, fd, is_enabled);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_get_reuse_port(wasm_exec_env_t exec_env, wasi_fd_t fd, uint8 *reuse)
|
||||
wasi_sock_get_reuse_port(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
||||
bool *is_enabled)
|
||||
{
|
||||
return __WASI_ENOSYS;
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
|
||||
struct fd_table *curfds = NULL;
|
||||
|
||||
if (!wasi_ctx)
|
||||
return __WASI_EACCES;
|
||||
|
||||
if (!validate_native_addr(is_enabled, sizeof(bool)))
|
||||
return __WASI_EINVAL;
|
||||
|
||||
curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
||||
|
||||
return wasmtime_ssp_sock_get_reuse_port(curfds, fd, is_enabled);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_get_send_buf_size(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
||||
wasi_size_t *size)
|
||||
size_t *size)
|
||||
{
|
||||
return __WASI_ENOSYS;
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
|
||||
struct fd_table *curfds = NULL;
|
||||
|
||||
if (!wasi_ctx)
|
||||
return __WASI_EACCES;
|
||||
|
||||
if (!validate_native_addr(size, sizeof(__wasi_size_t)))
|
||||
return __WASI_EINVAL;
|
||||
|
||||
curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
||||
|
||||
return wasmtime_ssp_sock_get_send_buf_size(curfds, fd, size);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
@ -1183,6 +1291,177 @@ wasi_sock_get_send_timeout(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
||||
return wasmtime_ssp_sock_get_send_timeout(curfds, fd, timeout_us);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_get_tcp_fastopen_connect(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
||||
bool *is_enabled)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
|
||||
struct fd_table *curfds = NULL;
|
||||
|
||||
if (!wasi_ctx)
|
||||
return __WASI_EACCES;
|
||||
|
||||
if (!validate_native_addr(is_enabled, sizeof(bool)))
|
||||
return __WASI_EINVAL;
|
||||
|
||||
curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
||||
|
||||
return wasmtime_ssp_sock_get_tcp_fastopen_connect(curfds, fd, is_enabled);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_get_tcp_no_delay(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
||||
bool *is_enabled)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
|
||||
struct fd_table *curfds = NULL;
|
||||
|
||||
if (!wasi_ctx)
|
||||
return __WASI_EACCES;
|
||||
|
||||
if (!validate_native_addr(is_enabled, sizeof(bool)))
|
||||
return __WASI_EINVAL;
|
||||
|
||||
curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
||||
|
||||
return wasmtime_ssp_sock_get_tcp_no_delay(curfds, fd, is_enabled);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_get_tcp_quick_ack(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
||||
bool *is_enabled)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
|
||||
struct fd_table *curfds = NULL;
|
||||
|
||||
if (!wasi_ctx)
|
||||
return __WASI_EACCES;
|
||||
|
||||
if (!validate_native_addr(is_enabled, sizeof(bool)))
|
||||
return __WASI_EINVAL;
|
||||
|
||||
curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
||||
|
||||
return wasmtime_ssp_sock_get_tcp_quick_ack(curfds, fd, is_enabled);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_get_tcp_keep_idle(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
||||
uint32_t *time_s)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
|
||||
struct fd_table *curfds = NULL;
|
||||
|
||||
if (!wasi_ctx)
|
||||
return __WASI_EACCES;
|
||||
|
||||
if (!validate_native_addr(time_s, sizeof(uint32_t)))
|
||||
return __WASI_EINVAL;
|
||||
|
||||
curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
||||
|
||||
return wasmtime_ssp_sock_get_tcp_keep_idle(curfds, fd, time_s);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_get_tcp_keep_intvl(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
||||
uint32_t *time_s)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
|
||||
struct fd_table *curfds = NULL;
|
||||
|
||||
if (!wasi_ctx)
|
||||
return __WASI_EACCES;
|
||||
|
||||
if (!validate_native_addr(time_s, sizeof(uint32_t)))
|
||||
return __WASI_EINVAL;
|
||||
|
||||
curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
||||
|
||||
return wasmtime_ssp_sock_get_tcp_keep_intvl(curfds, fd, time_s);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_get_ip_multicast_loop(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
||||
bool ipv6, bool *is_enabled)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
|
||||
struct fd_table *curfds = NULL;
|
||||
|
||||
if (!wasi_ctx)
|
||||
return __WASI_EACCES;
|
||||
|
||||
if (!validate_native_addr(is_enabled, sizeof(bool)))
|
||||
return __WASI_EINVAL;
|
||||
|
||||
curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
||||
|
||||
return wasmtime_ssp_sock_get_ip_multicast_loop(curfds, fd, ipv6,
|
||||
is_enabled);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_get_ip_ttl(wasm_exec_env_t exec_env, wasi_fd_t fd, uint8_t *ttl_s)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
|
||||
struct fd_table *curfds = NULL;
|
||||
|
||||
if (!wasi_ctx)
|
||||
return __WASI_EACCES;
|
||||
|
||||
if (!validate_native_addr(ttl_s, sizeof(uint8_t)))
|
||||
return __WASI_EINVAL;
|
||||
|
||||
curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
||||
|
||||
return wasmtime_ssp_sock_get_ip_ttl(curfds, fd, ttl_s);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_get_ip_multicast_ttl(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
||||
uint8_t *ttl_s)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
|
||||
struct fd_table *curfds = NULL;
|
||||
|
||||
if (!wasi_ctx)
|
||||
return __WASI_EACCES;
|
||||
|
||||
if (!validate_native_addr(ttl_s, sizeof(uint8_t)))
|
||||
return __WASI_EINVAL;
|
||||
|
||||
curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
||||
|
||||
return wasmtime_ssp_sock_get_ip_multicast_ttl(curfds, fd, ttl_s);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_get_ipv6_only(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
||||
bool *is_enabled)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
|
||||
struct fd_table *curfds = NULL;
|
||||
|
||||
if (!wasi_ctx)
|
||||
return __WASI_EACCES;
|
||||
|
||||
if (!validate_native_addr(is_enabled, sizeof(bool)))
|
||||
return __WASI_EINVAL;
|
||||
|
||||
curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
||||
|
||||
return wasmtime_ssp_sock_get_ipv6_only(curfds, fd, is_enabled);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_listen(wasm_exec_env_t exec_env, wasi_fd_t fd, uint32 backlog)
|
||||
{
|
||||
@ -1216,10 +1495,65 @@ wasi_sock_open(wasm_exec_env_t exec_env, wasi_fd_t poolfd,
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_set_recv_buf_size(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
||||
wasi_size_t size)
|
||||
wasi_sock_set_broadcast(wasm_exec_env_t exec_env, wasi_fd_t fd, bool is_enabled)
|
||||
{
|
||||
return __WASI_ENOSYS;
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
|
||||
struct fd_table *curfds = NULL;
|
||||
|
||||
if (!wasi_ctx)
|
||||
return __WASI_EACCES;
|
||||
|
||||
curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
||||
|
||||
return wasmtime_ssp_sock_set_broadcast(curfds, fd, is_enabled);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_set_keep_alive(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
||||
bool is_enabled)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
|
||||
struct fd_table *curfds = NULL;
|
||||
|
||||
if (!wasi_ctx)
|
||||
return __WASI_EACCES;
|
||||
|
||||
curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
||||
|
||||
return wasmtime_ssp_sock_set_keep_alive(curfds, fd, is_enabled);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_set_linger(wasm_exec_env_t exec_env, wasi_fd_t fd, bool is_enabled,
|
||||
int linger_s)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
|
||||
struct fd_table *curfds = NULL;
|
||||
|
||||
if (!wasi_ctx)
|
||||
return __WASI_EACCES;
|
||||
|
||||
curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
||||
|
||||
return wasmtime_ssp_sock_set_linger(curfds, fd, is_enabled, linger_s);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_set_recv_buf_size(wasm_exec_env_t exec_env, wasi_fd_t fd, size_t size)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
|
||||
struct fd_table *curfds = NULL;
|
||||
|
||||
if (!wasi_ctx)
|
||||
return __WASI_EACCES;
|
||||
|
||||
curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
||||
|
||||
return wasmtime_ssp_sock_set_recv_buf_size(curfds, fd, size);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
@ -1239,22 +1573,50 @@ wasi_sock_set_recv_timeout(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_set_reuse_addr(wasm_exec_env_t exec_env, wasi_fd_t fd, uint8 reuse)
|
||||
wasi_sock_set_reuse_addr(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
||||
bool is_enabled)
|
||||
{
|
||||
return __WASI_ENOSYS;
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
|
||||
struct fd_table *curfds = NULL;
|
||||
|
||||
if (!wasi_ctx)
|
||||
return __WASI_EACCES;
|
||||
|
||||
curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
||||
|
||||
return wasmtime_ssp_sock_set_reuse_addr(curfds, fd, is_enabled);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_set_reuse_port(wasm_exec_env_t exec_env, wasi_fd_t fd, uint8 reuse)
|
||||
wasi_sock_set_reuse_port(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
||||
bool is_enabled)
|
||||
{
|
||||
return __WASI_ENOSYS;
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
|
||||
struct fd_table *curfds = NULL;
|
||||
|
||||
if (!wasi_ctx)
|
||||
return __WASI_EACCES;
|
||||
|
||||
curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
||||
|
||||
return wasmtime_ssp_sock_set_reuse_port(curfds, fd, is_enabled);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_set_send_buf_size(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
||||
wasi_size_t size)
|
||||
wasi_sock_set_send_buf_size(wasm_exec_env_t exec_env, wasi_fd_t fd, size_t size)
|
||||
{
|
||||
return __WASI_ENOSYS;
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
|
||||
struct fd_table *curfds = NULL;
|
||||
|
||||
if (!wasi_ctx)
|
||||
return __WASI_EACCES;
|
||||
|
||||
curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
||||
|
||||
return wasmtime_ssp_sock_set_send_buf_size(curfds, fd, size);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
@ -1273,6 +1635,191 @@ wasi_sock_set_send_timeout(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
||||
return wasmtime_ssp_sock_set_send_timeout(curfds, fd, timeout_us);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_set_tcp_fastopen_connect(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
||||
bool is_enabled)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
|
||||
struct fd_table *curfds = NULL;
|
||||
|
||||
if (!wasi_ctx)
|
||||
return __WASI_EACCES;
|
||||
|
||||
curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
||||
|
||||
return wasmtime_ssp_sock_set_tcp_fastopen_connect(curfds, fd, is_enabled);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_set_tcp_no_delay(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
||||
bool is_enabled)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
|
||||
struct fd_table *curfds = NULL;
|
||||
|
||||
if (!wasi_ctx)
|
||||
return __WASI_EACCES;
|
||||
|
||||
curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
||||
|
||||
return wasmtime_ssp_sock_set_tcp_no_delay(curfds, fd, is_enabled);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_set_tcp_quick_ack(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
||||
bool is_enabled)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
|
||||
struct fd_table *curfds = NULL;
|
||||
|
||||
if (!wasi_ctx)
|
||||
return __WASI_EACCES;
|
||||
|
||||
curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
||||
|
||||
return wasmtime_ssp_sock_set_tcp_quick_ack(curfds, fd, is_enabled);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_set_tcp_keep_idle(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
||||
uint32_t time_s)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
|
||||
struct fd_table *curfds = NULL;
|
||||
|
||||
if (!wasi_ctx)
|
||||
return __WASI_EACCES;
|
||||
|
||||
curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
||||
|
||||
return wasmtime_ssp_sock_set_tcp_keep_idle(curfds, fd, time_s);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_set_tcp_keep_intvl(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
||||
uint32_t time_s)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
|
||||
struct fd_table *curfds = NULL;
|
||||
|
||||
if (!wasi_ctx)
|
||||
return __WASI_EACCES;
|
||||
|
||||
curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
||||
|
||||
return wasmtime_ssp_sock_set_tcp_keep_intvl(curfds, fd, time_s);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_set_ip_multicast_loop(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
||||
bool ipv6, bool is_enabled)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
|
||||
struct fd_table *curfds = NULL;
|
||||
|
||||
if (!wasi_ctx)
|
||||
return __WASI_EACCES;
|
||||
|
||||
curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
||||
|
||||
return wasmtime_ssp_sock_set_ip_multicast_loop(curfds, fd, ipv6,
|
||||
is_enabled);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_set_ip_add_membership(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
||||
__wasi_addr_ip_t *imr_multiaddr,
|
||||
uint32_t imr_interface)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
|
||||
struct fd_table *curfds = NULL;
|
||||
|
||||
if (!wasi_ctx)
|
||||
return __WASI_EACCES;
|
||||
|
||||
if (!validate_native_addr(imr_multiaddr, sizeof(__wasi_addr_ip_t)))
|
||||
return __WASI_EINVAL;
|
||||
|
||||
curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
||||
|
||||
return wasmtime_ssp_sock_set_ip_add_membership(curfds, fd, imr_multiaddr,
|
||||
imr_interface);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_set_ip_drop_membership(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
||||
__wasi_addr_ip_t *imr_multiaddr,
|
||||
uint32_t imr_interface)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
|
||||
struct fd_table *curfds = NULL;
|
||||
|
||||
if (!wasi_ctx)
|
||||
return __WASI_EACCES;
|
||||
|
||||
if (!validate_native_addr(imr_multiaddr, sizeof(__wasi_addr_ip_t)))
|
||||
return __WASI_EINVAL;
|
||||
|
||||
curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
||||
|
||||
return wasmtime_ssp_sock_set_ip_drop_membership(curfds, fd, imr_multiaddr,
|
||||
imr_interface);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_set_ip_ttl(wasm_exec_env_t exec_env, wasi_fd_t fd, uint8_t ttl_s)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
|
||||
struct fd_table *curfds = NULL;
|
||||
|
||||
if (!wasi_ctx)
|
||||
return __WASI_EACCES;
|
||||
|
||||
curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
||||
|
||||
return wasmtime_ssp_sock_set_ip_ttl(curfds, fd, ttl_s);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_set_ip_multicast_ttl(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
||||
uint8_t ttl_s)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
|
||||
struct fd_table *curfds = NULL;
|
||||
|
||||
if (!wasi_ctx)
|
||||
return __WASI_EACCES;
|
||||
|
||||
curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
||||
|
||||
return wasmtime_ssp_sock_set_ip_multicast_ttl(curfds, fd, ttl_s);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
wasi_sock_set_ipv6_only(wasm_exec_env_t exec_env, wasi_fd_t fd, bool is_enabled)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
|
||||
struct fd_table *curfds = NULL;
|
||||
|
||||
if (!wasi_ctx)
|
||||
return __WASI_EACCES;
|
||||
|
||||
curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
||||
|
||||
return wasmtime_ssp_sock_set_ipv6_only(curfds, fd, is_enabled);
|
||||
}
|
||||
|
||||
static wasi_errno_t
|
||||
allocate_iovec_app_buffer(wasm_module_inst_t module_inst,
|
||||
const iovec_app_t *data, uint32 data_len,
|
||||
@ -1589,24 +2136,50 @@ static NativeSymbol native_symbols_libc_wasi[] = {
|
||||
REG_NATIVE_FUNC(sock_bind, "(i*)i"),
|
||||
REG_NATIVE_FUNC(sock_close, "(i)i"),
|
||||
REG_NATIVE_FUNC(sock_connect, "(i*)i"),
|
||||
REG_NATIVE_FUNC(sock_get_broadcast, "(i*)i"),
|
||||
REG_NATIVE_FUNC(sock_get_keep_alive, "(i*)i"),
|
||||
REG_NATIVE_FUNC(sock_get_linger, "(i**)i"),
|
||||
REG_NATIVE_FUNC(sock_get_recv_buf_size, "(i*)i"),
|
||||
REG_NATIVE_FUNC(sock_get_recv_timeout, "(i*)i"),
|
||||
REG_NATIVE_FUNC(sock_get_reuse_addr, "(i*)i"),
|
||||
REG_NATIVE_FUNC(sock_get_reuse_port, "(i*)i"),
|
||||
REG_NATIVE_FUNC(sock_get_send_buf_size, "(i*)i"),
|
||||
REG_NATIVE_FUNC(sock_get_send_timeout, "(i*)i"),
|
||||
REG_NATIVE_FUNC(sock_get_tcp_fastopen_connect, "(i*)i"),
|
||||
REG_NATIVE_FUNC(sock_get_tcp_keep_idle, "(i*)i"),
|
||||
REG_NATIVE_FUNC(sock_get_tcp_keep_intvl, "(i*)i"),
|
||||
REG_NATIVE_FUNC(sock_get_tcp_no_delay, "(i*)i"),
|
||||
REG_NATIVE_FUNC(sock_get_tcp_quick_ack, "(i*)i"),
|
||||
REG_NATIVE_FUNC(sock_get_ip_multicast_loop, "(ii*)i"),
|
||||
REG_NATIVE_FUNC(sock_get_ip_multicast_ttl, "(i*)i"),
|
||||
REG_NATIVE_FUNC(sock_get_ip_ttl, "(i*)i"),
|
||||
REG_NATIVE_FUNC(sock_get_ipv6_only, "(i*)i"),
|
||||
REG_NATIVE_FUNC(sock_listen, "(ii)i"),
|
||||
REG_NATIVE_FUNC(sock_open, "(iii*)i"),
|
||||
REG_NATIVE_FUNC(sock_recv, "(i*ii**)i"),
|
||||
REG_NATIVE_FUNC(sock_recv_from, "(i*ii**)i"),
|
||||
REG_NATIVE_FUNC(sock_send, "(i*ii*)i"),
|
||||
REG_NATIVE_FUNC(sock_send_to, "(i*ii**)i"),
|
||||
REG_NATIVE_FUNC(sock_set_broadcast, "(ii)i"),
|
||||
REG_NATIVE_FUNC(sock_set_keep_alive, "(ii)i"),
|
||||
REG_NATIVE_FUNC(sock_set_linger, "(iii)i"),
|
||||
REG_NATIVE_FUNC(sock_set_recv_buf_size, "(ii)i"),
|
||||
REG_NATIVE_FUNC(sock_set_recv_timeout, "(iI)i"),
|
||||
REG_NATIVE_FUNC(sock_set_reuse_addr, "(ii)i"),
|
||||
REG_NATIVE_FUNC(sock_set_reuse_port, "(ii)i"),
|
||||
REG_NATIVE_FUNC(sock_set_send_buf_size, "(ii)i"),
|
||||
REG_NATIVE_FUNC(sock_set_send_timeout, "(iI)i"),
|
||||
REG_NATIVE_FUNC(sock_set_tcp_fastopen_connect, "(ii)i"),
|
||||
REG_NATIVE_FUNC(sock_set_tcp_keep_idle, "(ii)i"),
|
||||
REG_NATIVE_FUNC(sock_set_tcp_keep_intvl, "(ii)i"),
|
||||
REG_NATIVE_FUNC(sock_set_tcp_no_delay, "(ii)i"),
|
||||
REG_NATIVE_FUNC(sock_set_tcp_quick_ack, "(ii)i"),
|
||||
REG_NATIVE_FUNC(sock_set_ip_multicast_loop, "(iii)i"),
|
||||
REG_NATIVE_FUNC(sock_set_ip_multicast_ttl, "(ii)i"),
|
||||
REG_NATIVE_FUNC(sock_set_ip_add_membership, "(i*i)i"),
|
||||
REG_NATIVE_FUNC(sock_set_ip_drop_membership, "(i*i)i"),
|
||||
REG_NATIVE_FUNC(sock_set_ip_ttl, "(ii)i"),
|
||||
REG_NATIVE_FUNC(sock_set_ipv6_only, "(ii)i"),
|
||||
REG_NATIVE_FUNC(sock_shutdown, "(ii)i"),
|
||||
REG_NATIVE_FUNC(sched_yield, "()i"),
|
||||
};
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
#ifndef WASMTIME_SSP_H
|
||||
#define WASMTIME_SSP_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
@ -588,6 +589,14 @@ typedef struct __wasi_addr_ip6_port_t {
|
||||
__wasi_ip_port_t port;
|
||||
} __wasi_addr_ip6_port_t;
|
||||
|
||||
typedef struct __wasi_addr_ip_t {
|
||||
__wasi_addr_type_t kind;
|
||||
union {
|
||||
__wasi_addr_ip4_t ip4;
|
||||
__wasi_addr_ip6_t ip6;
|
||||
} addr;
|
||||
} __wasi_addr_ip_t;
|
||||
|
||||
typedef struct __wasi_addr_t {
|
||||
__wasi_addr_type_t kind;
|
||||
union {
|
||||
@ -1144,6 +1153,283 @@ __wasi_errno_t wasmtime_ssp_sock_get_send_timeout(
|
||||
uint64_t *timeout_us
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_get_send_timeout) __attribute__((__warn_unused_result__));
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sock_set_send_buf_size(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock,
|
||||
size_t bufsiz
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_set_send_buf_size) __attribute__((__warn_unused_result__));
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sock_get_send_buf_size(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock,
|
||||
size_t *bufsiz
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_get_send_buf_size) __attribute__((__warn_unused_result__));
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sock_set_recv_buf_size(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock,
|
||||
size_t bufsiz
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_set_recv_buf_size) __attribute__((__warn_unused_result__));
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sock_get_recv_buf_size(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock,
|
||||
size_t *bufsiz
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_get_recv_buf_size) __attribute__((__warn_unused_result__));
|
||||
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sock_set_keep_alive(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock,
|
||||
bool is_enabled
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_set_keep_alive) __attribute__((__warn_unused_result__));
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sock_get_keep_alive(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock,
|
||||
bool *is_enabled
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_get_keep_alive) __attribute__((__warn_unused_result__));
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sock_set_reuse_addr(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock,
|
||||
bool is_enabled
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_set_reuse_addr) __attribute__((__warn_unused_result__));
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sock_get_reuse_addr(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock,
|
||||
bool *is_enabled
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_get_reuse_addr) __attribute__((__warn_unused_result__));
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sock_set_reuse_port(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock,
|
||||
bool is_enabled
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_set_reuse_port) __attribute__((__warn_unused_result__));
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sock_get_reuse_port(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock,
|
||||
bool *is_enabled
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_get_reuse_port) __attribute__((__warn_unused_result__));
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sock_set_linger(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock,
|
||||
bool is_enabled,
|
||||
int linger_s
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_set_linger) __attribute__((__warn_unused_result__));
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sock_get_linger(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock, bool *is_enabled, int *linger_s
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_get_linger) __attribute__((__warn_unused_result__));
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sock_set_broadcast(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock,
|
||||
bool is_enabled
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_set_broadcast) __attribute__((__warn_unused_result__));
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sock_get_broadcast(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock,
|
||||
bool *is_enabled
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_get_broadcast) __attribute__((__warn_unused_result__));
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sock_set_tcp_no_delay(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock,
|
||||
bool is_enabled
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_set_tcp_no_delay) __attribute__((__warn_unused_result__));
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sock_get_tcp_no_delay(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock,
|
||||
bool *is_enabled
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_get_tcp_no_delay) __attribute__((__warn_unused_result__));
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sock_set_tcp_quick_ack(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock,
|
||||
bool is_enabled
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_set_tcp_quick_ack) __attribute__((__warn_unused_result__));
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sock_get_tcp_quick_ack(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock,
|
||||
bool *is_enabled
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_get_tcp_quick_ack) __attribute__((__warn_unused_result__));
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sock_set_tcp_keep_idle(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock,
|
||||
uint32_t time_s
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_set_tcp_keep_idle) __attribute__((__warn_unused_result__));
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sock_get_tcp_keep_idle(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock,
|
||||
uint32_t *time_s
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_get_tcp_keep_idle) __attribute__((__warn_unused_result__));
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sock_set_tcp_keep_intvl(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock,
|
||||
uint32_t time_s
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_set_tcp_keep_intvl) __attribute__((__warn_unused_result__));
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sock_get_tcp_keep_intvl(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock,
|
||||
uint32_t *time_s
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_get_tcp_keep_intvl) __attribute__((__warn_unused_result__));
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sock_set_tcp_fastopen_connect(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock,
|
||||
bool is_enabled
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_set_tcp_fastopen_connect) __attribute__((__warn_unused_result__));
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sock_get_tcp_fastopen_connect(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock,
|
||||
bool *is_enabled
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_get_tcp_fastopen_connect) __attribute__((__warn_unused_result__));
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sock_set_ip_multicast_loop(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock,
|
||||
bool ipv6,
|
||||
bool is_enabled
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_set_ip_multicast_loop) __attribute__((__warn_unused_result__));
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sock_get_ip_multicast_loop(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock,
|
||||
bool ipv6,
|
||||
bool *is_enabled
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_get_ip_multicast_loop) __attribute__((__warn_unused_result__));
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sock_set_ip_add_membership(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock,
|
||||
__wasi_addr_ip_t *imr_multiaddr,
|
||||
uint32_t imr_interface
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_set_ip_add_membership) __attribute__((__warn_unused_result__));
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sock_set_ip_drop_membership(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock,
|
||||
__wasi_addr_ip_t *imr_multiaddr,
|
||||
uint32_t imr_interface
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_set_ip_drop_membership) __attribute__((__warn_unused_result__));
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sock_set_ip_ttl(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock,
|
||||
uint8_t ttl_s
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_set_ip_ttl) __attribute__((__warn_unused_result__));
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sock_get_ip_ttl(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock,
|
||||
uint8_t *ttl_s
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_get_ip_ttl) __attribute__((__warn_unused_result__));
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sock_set_ip_multicast_ttl(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock,
|
||||
uint8_t ttl_s
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_set_ip_multicast_ttl) __attribute__((__warn_unused_result__));
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sock_get_ip_multicast_ttl(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock,
|
||||
uint8_t *ttl_s
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_get_ip_multicast_ttl) __attribute__((__warn_unused_result__));
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sock_set_ipv6_only(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock,
|
||||
bool is_enabled
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_set_ipv6_only) __attribute__((__warn_unused_result__));
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sock_get_ipv6_only(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock,
|
||||
bool *is_enabled
|
||||
) WASMTIME_SSP_SYSCALL_NAME(sock_get_ipv6_only) __attribute__((__warn_unused_result__));
|
||||
|
||||
__wasi_errno_t wasmtime_ssp_sched_yield(void)
|
||||
WASMTIME_SSP_SYSCALL_NAME(sched_yield) __attribute__((__warn_unused_result__));
|
||||
|
||||
|
||||
@ -250,6 +250,7 @@ wasi_addr_to_bh_sockaddr(const __wasi_addr_t *wasi_addr,
|
||||
}
|
||||
}
|
||||
|
||||
// Converts an IPv6 binary address object to WASI address object.
|
||||
static void
|
||||
bh_sockaddr_to_wasi_addr(const bh_sockaddr_t *sockaddr,
|
||||
__wasi_addr_t *wasi_addr)
|
||||
@ -279,6 +280,26 @@ bh_sockaddr_to_wasi_addr(const bh_sockaddr_t *sockaddr,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
wasi_addr_ip_to_bh_ip_addr_buffer(__wasi_addr_ip_t *addr,
|
||||
bh_ip_addr_buffer_t *out)
|
||||
{
|
||||
if (addr->kind == IPv4) {
|
||||
out->ipv4 = htonl((addr->addr.ip4.n0 << 24) | (addr->addr.ip4.n1 << 16)
|
||||
| (addr->addr.ip4.n2 << 8) | addr->addr.ip4.n3);
|
||||
}
|
||||
else {
|
||||
out->ipv6[0] = htons(addr->addr.ip6.n0);
|
||||
out->ipv6[1] = htons(addr->addr.ip6.n1);
|
||||
out->ipv6[2] = htons(addr->addr.ip6.n2);
|
||||
out->ipv6[3] = htons(addr->addr.ip6.n3);
|
||||
out->ipv6[4] = htons(addr->addr.ip6.h0);
|
||||
out->ipv6[5] = htons(addr->addr.ip6.h1);
|
||||
out->ipv6[6] = htons(addr->addr.ip6.h2);
|
||||
out->ipv6[7] = htons(addr->addr.ip6.h3);
|
||||
}
|
||||
}
|
||||
|
||||
__wasi_errno_t
|
||||
wasmtime_ssp_clock_res_get(__wasi_clockid_t clock_id,
|
||||
__wasi_timestamp_t *resolution)
|
||||
@ -3645,6 +3666,172 @@ WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(set_send_timeout, uint64)
|
||||
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(get_send_timeout, uint64 *)
|
||||
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(set_recv_timeout, uint64)
|
||||
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(get_recv_timeout, uint64 *)
|
||||
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(set_send_buf_size, size_t)
|
||||
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(get_send_buf_size, size_t *)
|
||||
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(set_recv_buf_size, size_t)
|
||||
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(get_recv_buf_size, size_t *)
|
||||
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(set_broadcast, bool)
|
||||
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(get_broadcast, bool *)
|
||||
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(set_keep_alive, bool)
|
||||
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(get_keep_alive, bool *)
|
||||
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(set_reuse_addr, bool)
|
||||
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(get_reuse_addr, bool *)
|
||||
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(set_reuse_port, bool)
|
||||
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(get_reuse_port, bool *)
|
||||
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(set_tcp_no_delay, bool)
|
||||
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(get_tcp_no_delay, bool *)
|
||||
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(set_tcp_quick_ack, bool)
|
||||
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(get_tcp_quick_ack, bool *)
|
||||
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(set_tcp_keep_idle, uint32)
|
||||
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(get_tcp_keep_idle, uint32 *)
|
||||
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(set_tcp_keep_intvl, uint32)
|
||||
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(get_tcp_keep_intvl, uint32 *)
|
||||
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(set_tcp_fastopen_connect, bool)
|
||||
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(get_tcp_fastopen_connect, bool *)
|
||||
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(set_ip_ttl, uint8_t)
|
||||
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(get_ip_ttl, uint8_t *)
|
||||
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(set_ip_multicast_ttl, uint8_t)
|
||||
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(get_ip_multicast_ttl, uint8_t *)
|
||||
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(set_ipv6_only, bool)
|
||||
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(get_ipv6_only, bool *)
|
||||
|
||||
#undef WASMTIME_SSP_PASSTHROUGH_FD_TABLE
|
||||
#undef WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION
|
||||
|
||||
__wasi_errno_t
|
||||
wasmtime_ssp_sock_set_linger(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock, bool is_enabled, int linger_s)
|
||||
{
|
||||
struct fd_object *fo;
|
||||
__wasi_errno_t error;
|
||||
int ret;
|
||||
error = fd_object_get(curfds, &fo, sock, 0, 0);
|
||||
if (error != 0)
|
||||
return error;
|
||||
|
||||
ret = os_socket_set_linger(fd_number(fo), is_enabled, linger_s);
|
||||
fd_object_release(fo);
|
||||
if (BHT_OK != ret)
|
||||
return convert_errno(errno);
|
||||
return __WASI_ESUCCESS;
|
||||
}
|
||||
|
||||
__wasi_errno_t
|
||||
wasmtime_ssp_sock_get_linger(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock, bool *is_enabled, int *linger_s)
|
||||
{
|
||||
struct fd_object *fo;
|
||||
__wasi_errno_t error;
|
||||
int ret;
|
||||
error = fd_object_get(curfds, &fo, sock, 0, 0);
|
||||
if (error != 0)
|
||||
return error;
|
||||
|
||||
ret = os_socket_get_linger(fd_number(fo), is_enabled, linger_s);
|
||||
fd_object_release(fo);
|
||||
if (BHT_OK != ret)
|
||||
return convert_errno(errno);
|
||||
|
||||
return __WASI_ESUCCESS;
|
||||
}
|
||||
|
||||
__wasi_errno_t
|
||||
wasmtime_ssp_sock_set_ip_add_membership(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock, __wasi_addr_ip_t *imr_multiaddr, uint32_t imr_interface)
|
||||
{
|
||||
struct fd_object *fo;
|
||||
__wasi_errno_t error;
|
||||
int ret;
|
||||
bh_ip_addr_buffer_t addr_info;
|
||||
bool is_ipv6;
|
||||
error = fd_object_get(curfds, &fo, sock, 0, 0);
|
||||
if (error != 0)
|
||||
return error;
|
||||
|
||||
wasi_addr_ip_to_bh_ip_addr_buffer(imr_multiaddr, &addr_info);
|
||||
is_ipv6 = imr_multiaddr->kind == IPv6;
|
||||
ret = os_socket_set_ip_add_membership(fd_number(fo), &addr_info,
|
||||
imr_interface, is_ipv6);
|
||||
fd_object_release(fo);
|
||||
if (BHT_OK != ret)
|
||||
return convert_errno(errno);
|
||||
return __WASI_ESUCCESS;
|
||||
}
|
||||
|
||||
__wasi_errno_t
|
||||
wasmtime_ssp_sock_set_ip_drop_membership(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock, __wasi_addr_ip_t *imr_multiaddr, uint32_t imr_interface)
|
||||
{
|
||||
struct fd_object *fo;
|
||||
__wasi_errno_t error;
|
||||
int ret;
|
||||
bh_ip_addr_buffer_t addr_info;
|
||||
bool is_ipv6;
|
||||
error = fd_object_get(curfds, &fo, sock, 0, 0);
|
||||
if (error != 0)
|
||||
return error;
|
||||
|
||||
wasi_addr_ip_to_bh_ip_addr_buffer(imr_multiaddr, &addr_info);
|
||||
is_ipv6 = imr_multiaddr->kind == IPv6;
|
||||
ret = os_socket_set_ip_drop_membership(fd_number(fo), &addr_info,
|
||||
imr_interface, is_ipv6);
|
||||
fd_object_release(fo);
|
||||
if (BHT_OK != ret)
|
||||
return convert_errno(errno);
|
||||
return __WASI_ESUCCESS;
|
||||
}
|
||||
|
||||
__wasi_errno_t
|
||||
wasmtime_ssp_sock_set_ip_multicast_loop(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock, bool ipv6, bool is_enabled)
|
||||
{
|
||||
struct fd_object *fo;
|
||||
__wasi_errno_t error;
|
||||
int ret;
|
||||
error = fd_object_get(curfds, &fo, sock, 0, 0);
|
||||
if (error != 0)
|
||||
return error;
|
||||
|
||||
ret = os_socket_set_ip_multicast_loop(fd_number(fo), ipv6, is_enabled);
|
||||
fd_object_release(fo);
|
||||
if (BHT_OK != ret)
|
||||
return convert_errno(errno);
|
||||
return __WASI_ESUCCESS;
|
||||
}
|
||||
|
||||
__wasi_errno_t
|
||||
wasmtime_ssp_sock_get_ip_multicast_loop(
|
||||
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
|
||||
struct fd_table *curfds,
|
||||
#endif
|
||||
__wasi_fd_t sock, bool ipv6, bool *is_enabled)
|
||||
{
|
||||
struct fd_object *fo;
|
||||
__wasi_errno_t error;
|
||||
int ret;
|
||||
error = fd_object_get(curfds, &fo, sock, 0, 0);
|
||||
if (error != 0)
|
||||
return error;
|
||||
|
||||
ret = os_socket_get_ip_multicast_loop(fd_number(fo), ipv6, is_enabled);
|
||||
fd_object_release(fo);
|
||||
if (BHT_OK != ret)
|
||||
return convert_errno(errno);
|
||||
|
||||
return __WASI_ESUCCESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user