sockets: add readv() implementation (task #14610)

Adds an implementation of readv() that calls recvmsg()

See http://pubs.opengroup.org/onlinepubs/009695399/functions/readv.html
This commit is contained in:
Joel Cunningham
2017-09-10 22:37:40 -05:00
parent 558480a5b9
commit 445eef2b0e
3 changed files with 24 additions and 0 deletions

View File

@@ -1204,6 +1204,23 @@ lwip_read(int s, void *mem, size_t len)
return lwip_recvfrom(s, mem, len, 0, NULL, NULL);
}
ssize_t
lwip_readv(int s, const struct iovec *iov, int iovcnt)
{
struct msghdr msg;
msg.msg_name = NULL;
msg.msg_namelen = 0;
/* Hack: we have to cast via number to cast from 'const' pointer to non-const.
Blame the opengroup standard for this inconsistency. */
msg.msg_iov = LWIP_CONST_CAST(struct iovec *, iov);
msg.msg_iovlen = iovcnt;
msg.msg_control = NULL;
msg.msg_controllen = 0;
msg.msg_flags = 0;
return lwip_recvmsg(s, &msg, 0);
}
ssize_t
lwip_recv(int s, void *mem, size_t len, int flags)
{