|
|
@@ -1119,11 +1119,81 @@ wasi_sock_connect(wasm_exec_env_t exec_env, wasi_fd_t fd, wasi_addr_t *addr)
|
|
|
return wasi_ssp_sock_connect(curfds, addr_pool, fd, addr);
|
|
|
}
|
|
|
|
|
|
+static wasi_errno_t
|
|
|
+wasi_sock_get_broadcast(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_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,
|
|
|
- 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_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"),
|
|
|
};
|