|
@@ -1126,6 +1126,25 @@ wasi_sock_get_recv_buf_size(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
return __WASI_ENOSYS;
|
|
return __WASI_ENOSYS;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+static wasi_errno_t
|
|
|
|
|
+wasi_sock_get_recv_timeout(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
|
|
+ uint64_t *timeout_us)
|
|
|
|
|
+{
|
|
|
|
|
+ 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(timeout_us, sizeof(uint64_t)))
|
|
|
|
|
+ return __WASI_EINVAL;
|
|
|
|
|
+
|
|
|
|
|
+ curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
|
|
|
|
+
|
|
|
|
|
+ return wasmtime_ssp_sock_get_recv_timeout(curfds, fd, timeout_us);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
static wasi_errno_t
|
|
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, uint8 *reuse)
|
|
|
{
|
|
{
|
|
@@ -1145,6 +1164,25 @@ wasi_sock_get_send_buf_size(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
return __WASI_ENOSYS;
|
|
return __WASI_ENOSYS;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+static wasi_errno_t
|
|
|
|
|
+wasi_sock_get_send_timeout(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
|
|
+ uint64_t *timeout_us)
|
|
|
|
|
+{
|
|
|
|
|
+ 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(timeout_us, sizeof(uint64_t)))
|
|
|
|
|
+ return __WASI_EINVAL;
|
|
|
|
|
+
|
|
|
|
|
+ curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx);
|
|
|
|
|
+
|
|
|
|
|
+ return wasmtime_ssp_sock_get_send_timeout(curfds, fd, timeout_us);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
static wasi_errno_t
|
|
static wasi_errno_t
|
|
|
wasi_sock_listen(wasm_exec_env_t exec_env, wasi_fd_t fd, uint32 backlog)
|
|
wasi_sock_listen(wasm_exec_env_t exec_env, wasi_fd_t fd, uint32 backlog)
|
|
|
{
|
|
{
|
|
@@ -1184,6 +1222,22 @@ wasi_sock_set_recv_buf_size(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
return __WASI_ENOSYS;
|
|
return __WASI_ENOSYS;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+static wasi_errno_t
|
|
|
|
|
+wasi_sock_set_recv_timeout(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
|
|
+ uint64_t timeout_us)
|
|
|
|
|
+{
|
|
|
|
|
+ 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_timeout(curfds, fd, timeout_us);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
static wasi_errno_t
|
|
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, uint8 reuse)
|
|
|
{
|
|
{
|
|
@@ -1203,6 +1257,22 @@ wasi_sock_set_send_buf_size(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
return __WASI_ENOSYS;
|
|
return __WASI_ENOSYS;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+static wasi_errno_t
|
|
|
|
|
+wasi_sock_set_send_timeout(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
|
|
+ uint64_t timeout_us)
|
|
|
|
|
+{
|
|
|
|
|
+ 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_timeout(curfds, fd, timeout_us);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
static wasi_errno_t
|
|
static wasi_errno_t
|
|
|
wasi_sock_recv(wasm_exec_env_t exec_env, wasi_fd_t sock, iovec_app_t *ri_data,
|
|
wasi_sock_recv(wasm_exec_env_t exec_env, wasi_fd_t sock, iovec_app_t *ri_data,
|
|
|
uint32 ri_data_len, wasi_riflags_t ri_flags, uint32 *ro_data_len,
|
|
uint32 ri_data_len, wasi_riflags_t ri_flags, uint32 *ro_data_len,
|
|
@@ -1427,17 +1497,21 @@ static NativeSymbol native_symbols_libc_wasi[] = {
|
|
|
REG_NATIVE_FUNC(sock_close, "(i)i"),
|
|
REG_NATIVE_FUNC(sock_close, "(i)i"),
|
|
|
REG_NATIVE_FUNC(sock_connect, "(i*)i"),
|
|
REG_NATIVE_FUNC(sock_connect, "(i*)i"),
|
|
|
REG_NATIVE_FUNC(sock_get_recv_buf_size, "(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_addr, "(i*)i"),
|
|
|
REG_NATIVE_FUNC(sock_get_reuse_port, "(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_buf_size, "(i*)i"),
|
|
|
|
|
+ REG_NATIVE_FUNC(sock_get_send_timeout, "(i*)i"),
|
|
|
REG_NATIVE_FUNC(sock_listen, "(ii)i"),
|
|
REG_NATIVE_FUNC(sock_listen, "(ii)i"),
|
|
|
REG_NATIVE_FUNC(sock_open, "(iii*)i"),
|
|
REG_NATIVE_FUNC(sock_open, "(iii*)i"),
|
|
|
REG_NATIVE_FUNC(sock_recv, "(i*ii**)i"),
|
|
REG_NATIVE_FUNC(sock_recv, "(i*ii**)i"),
|
|
|
REG_NATIVE_FUNC(sock_send, "(i*ii*)i"),
|
|
REG_NATIVE_FUNC(sock_send, "(i*ii*)i"),
|
|
|
REG_NATIVE_FUNC(sock_set_recv_buf_size, "(ii)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_addr, "(ii)i"),
|
|
|
REG_NATIVE_FUNC(sock_set_reuse_port, "(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_buf_size, "(ii)i"),
|
|
|
|
|
+ REG_NATIVE_FUNC(sock_set_send_timeout, "(iI)i"),
|
|
|
REG_NATIVE_FUNC(sock_shutdown, "(ii)i"),
|
|
REG_NATIVE_FUNC(sock_shutdown, "(ii)i"),
|
|
|
REG_NATIVE_FUNC(sched_yield, "()i"),
|
|
REG_NATIVE_FUNC(sched_yield, "()i"),
|
|
|
};
|
|
};
|