From 4abab5ad6c8465a7528ccdd5f49367da05f78bbd Mon Sep 17 00:00:00 2001 From: Vladimir Azarov Date: Tue, 1 Oct 2024 15:47:05 +0200 Subject: Initial version --- src/network/sendmmsg.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/network/sendmmsg.c (limited to 'src/network/sendmmsg.c') diff --git a/src/network/sendmmsg.c b/src/network/sendmmsg.c new file mode 100644 index 0000000..eeae1d0 --- /dev/null +++ b/src/network/sendmmsg.c @@ -0,0 +1,30 @@ +#define _GNU_SOURCE +#include +#include +#include +#include "syscall.h" + +int sendmmsg(int fd, struct mmsghdr *msgvec, unsigned int vlen, unsigned int flags) +{ +#if LONG_MAX > INT_MAX + /* Can't use the syscall directly because the kernel has the wrong + * idea for the types of msg_iovlen, msg_controllen, and cmsg_len, + * and the cmsg blocks cannot be modified in-place. */ + int i; + if (vlen > IOV_MAX) vlen = IOV_MAX; /* This matches the kernel. */ + if (!vlen) return 0; + for (i=0; i