From 271a930e80ff4da80dcfd64530052fd6cd5c4565 Mon Sep 17 00:00:00 2001 From: Krisztian Szilvasi <34309983+kr-t@users.noreply.github.com> Date: Tue, 17 Feb 2026 13:10:34 +0100 Subject: [PATCH] feat: zephyr sockets: implement missing networking functions Some of the optvals are implemented by zephyr, some are missing. Call the appropriate function and let set the retval based on that. Signed-off-by: Krisztian Szilvasi <34309983+kr-t@users.noreply.github.com> --- core/shared/platform/zephyr/zephyr_socket.c | 43 ++++++++++++++------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/core/shared/platform/zephyr/zephyr_socket.c b/core/shared/platform/zephyr/zephyr_socket.c index 52dc5e619..56f37fc8e 100644 --- a/core/shared/platform/zephyr/zephyr_socket.c +++ b/core/shared/platform/zephyr/zephyr_socket.c @@ -698,21 +698,18 @@ os_socket_get_linger(bh_socket_t socket, bool *is_enabled, int *linger_s) return BHT_ERROR; } -// TCP_NODELAY Disable TCP buffering (ignored, for compatibility) int os_socket_set_tcp_no_delay(bh_socket_t socket, bool is_enabled) { - errno = ENOSYS; - - return BHT_ERROR; + return os_socket_setbooloption(socket, IPPROTO_TCP, TCP_NODELAY, + is_enabled); } int os_socket_get_tcp_no_delay(bh_socket_t socket, bool *is_enabled) { - errno = ENOSYS; - - return BHT_ERROR; + return os_socket_getbooloption(socket, IPPROTO_TCP, TCP_NODELAY, + is_enabled); } int @@ -861,17 +858,37 @@ os_socket_get_tcp_fastopen_connect(bh_socket_t socket, bool *is_enabled) int os_socket_set_ip_multicast_loop(bh_socket_t socket, bool ipv6, bool is_enabled) { - errno = ENOSYS; - - return BHT_ERROR; + if (ipv6) { +#ifdef IPPROTO_IPV6 + return os_socket_setbooloption(socket, IPPROTO_IPV6, + IPV6_MULTICAST_LOOP, is_enabled); +#else + errno = EAFNOSUPPORT; + return BHT_ERROR; +#endif + } + else { + return os_socket_setbooloption(socket, IPPROTO_IP, IP_MULTICAST_LOOP, + is_enabled); + } } int os_socket_get_ip_multicast_loop(bh_socket_t socket, bool ipv6, bool *is_enabled) { - errno = ENOSYS; - - return BHT_ERROR; + if (ipv6) { +#ifdef IPPROTO_IPV6 + return os_socket_getbooloption(socket, IPPROTO_IPV6, + IPV6_MULTICAST_LOOP, is_enabled); +#else + errno = EAFNOSUPPORT; + return BHT_ERROR; +#endif + } + else { + return os_socket_getbooloption(socket, IPPROTO_IP, IP_MULTICAST_LOOP, + is_enabled); + } } int