mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-11-04 23:29:25 +00:00
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:
parent
558480a5b9
commit
445eef2b0e
@ -6,6 +6,9 @@ HISTORY
|
|||||||
|
|
||||||
++ New features:
|
++ New features:
|
||||||
|
|
||||||
|
2017-09-10: Joel Cunningham
|
||||||
|
* sockets: add readv() implementation (task #14610)
|
||||||
|
|
||||||
2017-08-04: Simon Goldschmidt
|
2017-08-04: Simon Goldschmidt
|
||||||
* Clean up DHCP a bit: no need keep msg_out and msg_in as members in struct
|
* Clean up DHCP a bit: no need keep msg_out and msg_in as members in struct
|
||||||
dhcp - they are used in a call stack only (p_out and options_out_len as well)
|
dhcp - they are used in a call stack only (p_out and options_out_len as well)
|
||||||
|
@ -1204,6 +1204,23 @@ lwip_read(int s, void *mem, size_t len)
|
|||||||
return lwip_recvfrom(s, mem, len, 0, NULL, NULL);
|
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
|
ssize_t
|
||||||
lwip_recv(int s, void *mem, size_t len, int flags)
|
lwip_recv(int s, void *mem, size_t len, int flags)
|
||||||
{
|
{
|
||||||
|
@ -529,6 +529,7 @@ void lwip_socket_thread_cleanup(void); /* LWIP_NETCONN_SEM_PER_THREAD==1: destro
|
|||||||
|
|
||||||
#if LWIP_POSIX_SOCKETS_IO_NAMES
|
#if LWIP_POSIX_SOCKETS_IO_NAMES
|
||||||
#define lwip_read read
|
#define lwip_read read
|
||||||
|
#define lwip_readv readv
|
||||||
#define lwip_write write
|
#define lwip_write write
|
||||||
#define lwip_writev writev
|
#define lwip_writev writev
|
||||||
#undef lwip_close
|
#undef lwip_close
|
||||||
@ -551,6 +552,7 @@ int lwip_connect(int s, const struct sockaddr *name, socklen_t namelen);
|
|||||||
int lwip_listen(int s, int backlog);
|
int lwip_listen(int s, int backlog);
|
||||||
ssize_t lwip_recv(int s, void *mem, size_t len, int flags);
|
ssize_t lwip_recv(int s, void *mem, size_t len, int flags);
|
||||||
ssize_t lwip_read(int s, void *mem, size_t len);
|
ssize_t lwip_read(int s, void *mem, size_t len);
|
||||||
|
ssize_t lwip_readv(int s, const struct iovec *iov, int iovcnt);
|
||||||
ssize_t lwip_recvfrom(int s, void *mem, size_t len, int flags,
|
ssize_t lwip_recvfrom(int s, void *mem, size_t len, int flags,
|
||||||
struct sockaddr *from, socklen_t *fromlen);
|
struct sockaddr *from, socklen_t *fromlen);
|
||||||
ssize_t lwip_recvmsg(int s, struct msghdr *message, int flags);
|
ssize_t lwip_recvmsg(int s, struct msghdr *message, int flags);
|
||||||
@ -619,6 +621,8 @@ int lwip_inet_pton(int af, const char *src, void *dst);
|
|||||||
/** @ingroup socket */
|
/** @ingroup socket */
|
||||||
#define read(s,mem,len) lwip_read(s,mem,len)
|
#define read(s,mem,len) lwip_read(s,mem,len)
|
||||||
/** @ingroup socket */
|
/** @ingroup socket */
|
||||||
|
#define readv(s,iov,iovcnt) lwip_readv(s,iov,iovcnt)
|
||||||
|
/** @ingroup socket */
|
||||||
#define write(s,dataptr,len) lwip_write(s,dataptr,len)
|
#define write(s,dataptr,len) lwip_write(s,dataptr,len)
|
||||||
/** @ingroup socket */
|
/** @ingroup socket */
|
||||||
#define writev(s,iov,iovcnt) lwip_writev(s,iov,iovcnt)
|
#define writev(s,iov,iovcnt) lwip_writev(s,iov,iovcnt)
|
||||||
|
Loading…
Reference in New Issue
Block a user