summaryrefslogtreecommitdiff
path: root/src
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
parent1fe597981c105bc3d1c9a38443e66ae6d61f2374 (diff)
downloadskalibs-370bdd3c5739aa8d94753e841aecf71fa04d9400.tar.xz
socket_recv46 was never working
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src')
-rw-r--r--src/headers/ip46-footer5
-rw-r--r--src/headers/ip46-header2
-rw-r--r--src/headers/ip46-with4
-rw-r--r--src/headers/ip46-without4
-rw-r--r--src/libstddjb/socket_recv46.c24
-rw-r--r--src/libstddjb/socket_recvnb46.c24
6 files changed, 53 insertions, 10 deletions
diff --git a/src/headers/ip46-footer b/src/headers/ip46-footer
index a1062bf..5343c54 100644
--- a/src/headers/ip46-footer
+++ b/src/headers/ip46-footer
@@ -1,7 +1,10 @@
#define ip46_from_ip(i, s, h) ((h) ? ip46_from_ip6(i, s) : ip46_from_ip4(i, s))
-#define socket_recvnb46_g(fd, buf, len, i, port, deadline) socket_recvnb46(fd, buf, len, i, port, (deadline), &STAMP)
+extern ssize_t socket_recv46 (int, char *, size_t, ip46 *, uint16_t *, int) ;
+extern ssize_t socket_recvnb46 (int, char *, size_t, ip46 *, uint16_t *, int, tain const *, tain *) ;
+
+#define socket_recvnb46_g(fd, buf, len, i, port, h, deadline) socket_recvnb46(fd, buf, len, i, port, h, (deadline), &STAMP)
#define socket_sendnb46_g(fd, buf, len, i, port, deadline) socket_sendnb46(fd, buf, len, i, port, (deadline), &STAMP)
extern int socket_deadlineconnstamp46 (int, ip46 const *, uint16_t, tain const *, tain *) ;
diff --git a/src/headers/ip46-header b/src/headers/ip46-header
index 49936a7..fd0be49 100644
--- a/src/headers/ip46-header
+++ b/src/headers/ip46-header
@@ -3,7 +3,7 @@
#ifndef SKALIBS_IP46_H
#define SKALIBS_IP46_H
-#include <string.h>
+#include <sys/types.h>
#include <stdint.h>
#include <errno.h>
diff --git a/src/headers/ip46-with b/src/headers/ip46-with
index 5eec291..f6e0ed1 100644
--- a/src/headers/ip46-with
+++ b/src/headers/ip46-with
@@ -28,12 +28,8 @@ typedef ip46full ip46, *ip46_ref ;
#define socket_udp46_nbcoe(h) ((h) ? socket_udp6_nbcoe() : socket_udp4_nbcoe())
#define socket_udp46_internal(h, flags) ((h) ? socket_udp6_internal(flags) : socket_udp4_internal(flags))
-#define socket_recv46(fd, s, len, i, port) ((i)->is6 ? socket_recv6(fd, s, len, (i)->ip, port) : socket_recv4(fd, s, len, (i)->ip, port))
#define socket_send46(fd, s, len, i, port) ((i)->is6 ? socket_send6(fd, s, len, (i)->ip, port) : socket_send4(fd, s, len, (i)->ip, port))
extern int socket_local46 (int, ip46 *, uint16_t *) ;
extern int socket_remote46 (int, ip46 *, uint16_t *) ;
-#define socket_recvnb46(fd, buf, len, i, port, deadline, stamp) ((i)->is6 ? socket_recvnb6(fd, buf, len, (i)->ip, port, deadline, stamp) : socket_recvnb4(fd, buf, len, (i)->ip, port, deadline, stamp))
-#define socket_recvnb46_g(fd, buf, len, i, port, deadline) socket_recvnb46(fd, buf, len, i, port, (deadline), &STAMP)
#define socket_sendnb46(fd, buf, len, i, port, deadline, stamp) ((i)->is6 ? socket_sendnb6(fd, buf, len, (i)->ip, port, deadline, stamp) : socket_sendnb4(fd, buf, len, (i)->ip, port, deadline, stamp))
-#define socket_sendnb46_g(fd, buf, len, i, port, deadline) socket_sendnb46(fd, buf, len, i, port, (deadline), &STAMP)
diff --git a/src/headers/ip46-without b/src/headers/ip46-without
index 5f332db..58fe022 100644
--- a/src/headers/ip46-without
+++ b/src/headers/ip46-without
@@ -32,12 +32,8 @@ struct ip46_s
#define socket_udp46_nbcoe(h) socket_udp4_nbcoe()
#define socket_udp46_internal(h, flags) socket_udp4_internal(flags)
-#define socket_recv46(fd, s, len, i, port) socket_recv4(fd, s, len, (i)->ip, port)
#define socket_send46(fd, s, len, i, port) socket_send4(fd, s, len, (i)->ip, port)
#define socket_local46(fd, i, port) socket_local4(fd, (i)->ip, port)
#define socket_remote46(fd, i, port) socket_remote4(fd, (i)->ip, port)
-#define socket_recvnb46(fd, buf, len, i, port, deadline, stamp) socket_recvnb4(fd, buf, len, (i)->ip, port, deadline, stamp)
-#define socket_recvnb46_g(fd, buf, len, i, port, deadline) socket_recvnb46(fd, buf, len, i, port, (deadline), &STAMP)
#define socket_sendnb46(fd, buf, len, i, port, deadline, stamp) socket_sendnb4(fd, buf, len, (i)->ip, port, deadline, stamp)
-#define socket_sendnb46_g(fd, buf, len, i, port, deadline, stamp) socket_sendnb46(fd, buf, len, i, port, (deadline), &STAMP)
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
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 <skalibs/socket.h>
+#include <skalibs/ip46.h>
+
+#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