summaryrefslogtreecommitdiff
path: root/src/libstddjb/socket_recv46.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2023-12-11 09:13:16 +0000
committerLaurent Bercot <ska@appnovation.com>2023-12-11 09:13:16 +0000
commit370bdd3c5739aa8d94753e841aecf71fa04d9400 (patch)
tree93ec71b6a093971d91c16f61ea3e03147e94525e /src/libstddjb/socket_recv46.c
parent1fe597981c105bc3d1c9a38443e66ae6d61f2374 (diff)
downloadskalibs-370bdd3c5739aa8d94753e841aecf71fa04d9400.tar.xz
socket_recv46 was never working
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/libstddjb/socket_recv46.c')
-rw-r--r--src/libstddjb/socket_recv46.c24
1 files changed, 24 insertions, 0 deletions
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 <skalibs/socket.h>
+#include <skalibs/ip46.h>
+
+#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