Skip to content

Commit 271a930

Browse files
committed
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>
1 parent 6d8a33c commit 271a930

1 file changed

Lines changed: 30 additions & 13 deletions

File tree

core/shared/platform/zephyr/zephyr_socket.c

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -698,21 +698,18 @@ os_socket_get_linger(bh_socket_t socket, bool *is_enabled, int *linger_s)
698698
return BHT_ERROR;
699699
}
700700

701-
// TCP_NODELAY Disable TCP buffering (ignored, for compatibility)
702701
int
703702
os_socket_set_tcp_no_delay(bh_socket_t socket, bool is_enabled)
704703
{
705-
errno = ENOSYS;
706-
707-
return BHT_ERROR;
704+
return os_socket_setbooloption(socket, IPPROTO_TCP, TCP_NODELAY,
705+
is_enabled);
708706
}
709707

710708
int
711709
os_socket_get_tcp_no_delay(bh_socket_t socket, bool *is_enabled)
712710
{
713-
errno = ENOSYS;
714-
715-
return BHT_ERROR;
711+
return os_socket_getbooloption(socket, IPPROTO_TCP, TCP_NODELAY,
712+
is_enabled);
716713
}
717714

718715
int
@@ -861,17 +858,37 @@ os_socket_get_tcp_fastopen_connect(bh_socket_t socket, bool *is_enabled)
861858
int
862859
os_socket_set_ip_multicast_loop(bh_socket_t socket, bool ipv6, bool is_enabled)
863860
{
864-
errno = ENOSYS;
865-
866-
return BHT_ERROR;
861+
if (ipv6) {
862+
#ifdef IPPROTO_IPV6
863+
return os_socket_setbooloption(socket, IPPROTO_IPV6,
864+
IPV6_MULTICAST_LOOP, is_enabled);
865+
#else
866+
errno = EAFNOSUPPORT;
867+
return BHT_ERROR;
868+
#endif
869+
}
870+
else {
871+
return os_socket_setbooloption(socket, IPPROTO_IP, IP_MULTICAST_LOOP,
872+
is_enabled);
873+
}
867874
}
868875

869876
int
870877
os_socket_get_ip_multicast_loop(bh_socket_t socket, bool ipv6, bool *is_enabled)
871878
{
872-
errno = ENOSYS;
873-
874-
return BHT_ERROR;
879+
if (ipv6) {
880+
#ifdef IPPROTO_IPV6
881+
return os_socket_getbooloption(socket, IPPROTO_IPV6,
882+
IPV6_MULTICAST_LOOP, is_enabled);
883+
#else
884+
errno = EAFNOSUPPORT;
885+
return BHT_ERROR;
886+
#endif
887+
}
888+
else {
889+
return os_socket_getbooloption(socket, IPPROTO_IP, IP_MULTICAST_LOOP,
890+
is_enabled);
891+
}
875892
}
876893

877894
int

0 commit comments

Comments
 (0)