From 370bdd3c5739aa8d94753e841aecf71fa04d9400 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Mon, 11 Dec 2023 09:13:16 +0000 Subject: socket_recv46 was never working Signed-off-by: Laurent Bercot --- src/libstddjb/socket_recv46.c | 24 ++++++++++++++++++++++++ src/libstddjb/socket_recvnb46.c | 24 ++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 src/libstddjb/socket_recv46.c create mode 100644 src/libstddjb/socket_recvnb46.c (limited to 'src/libstddjb') diff --git a/src/libstddjb/socket_recv46.c b/src/libstddjb/socket_recv46.c new file mode 100644 index 0000000..9c1319e --- /dev/null +++ b/src/libstddjb/socket_recv46.c @@ -0,0 +1,24 @@ +/* ISC license. */ + +#include +#include + +#ifdef SKALIBS_IPV6_ENABLED + +ssize_t socket_recv46 (int s, char *buf, size_t len, ip46 *ip, uint16_t *port, int h) +{ + ssize_t r = h ? socket_recv6(s, buf, len, ip->ip, port) : socket_recv4(s, buf, len, ip->ip, port) ; + if (r == -1) return -1 ; + ip->is6 = !!h ; + return r ; +} + +#else + +ssize_t socket_recv46 (int s, char *buf, size_t len, ip46 *ip, uint16_t *port, int h) +{ + (void)h ; + return socket_recv4(s, buf, len, ip->ip, port) ; +} + +#endif diff --git a/src/libstddjb/socket_recvnb46.c b/src/libstddjb/socket_recvnb46.c new file mode 100644 index 0000000..db63357 --- /dev/null +++ b/src/libstddjb/socket_recvnb46.c @@ -0,0 +1,24 @@ +/* ISC license. */ + +#include +#include + +#ifdef SKALIBS_IPV6_ENABLED + +ssize_t socket_recvnb46 (int s, char *buf, size_t len, ip46 *ip, uint16_t *port, int h, tain const *deadline, tain *stamp) +{ + ssize_t r = h ? socket_recvnb6(s, buf, len, ip->ip, port, deadline, stamp) : socket_recvnb4(s, buf, len, ip->ip, port, deadline, stamp) ; + if (r == -1) return -1 ; + ip->is6 = !!h ; + return r ; +} + +#else + +ssize_t socket_recvnb46 (int s, char *buf, size_t len, ip46 *ip, uint16_t *port, int h, tain const *deadline, tain *stamp) +{ + (void)h ; + return socket_recvnb4(s, buf, len, ip->ip, port, deadline, stamp) ; +} + +#endif -- cgit v1.2.3