2 #include <sys/socket.h>
7 int sendmmsg(int fd
, struct mmsghdr
*msgvec
, unsigned int vlen
, unsigned int flags
)
10 /* Can't use the syscall directly because the kernel has the wrong
11 * idea for the types of msg_iovlen, msg_controllen, and cmsg_len,
12 * and the cmsg blocks cannot be modified in-place. */
14 if (vlen
> IOV_MAX
) vlen
= IOV_MAX
; /* This matches the kernel. */
16 for (i
=0; i
<vlen
; i
++) {
17 /* As an unfortunate inconsistency, the sendmmsg API uses
18 * unsigned int for the resulting msg_len, despite sendmsg
19 * returning ssize_t. However Linux limits the total bytes
20 * sent by sendmsg to INT_MAX, so the assignment is safe. */
21 ssize_t r
= sendmsg(fd
, &msgvec
[i
].msg_hdr
, flags
);
22 if (r
< 0) goto error
;
23 msgvec
[i
].msg_len
= r
;
28 return syscall_cp(SYS_sendmmsg
, fd
, msgvec
, vlen
, flags
);