mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-01-01 12:00:53 +00:00
sockets.h, sockets.c: Implement MSG_PEEK flag for recv/recvfrom functions.
This commit is contained in:
parent
c91caa06d3
commit
b6750de9e8
@ -19,6 +19,9 @@ HISTORY
|
|||||||
|
|
||||||
++ New features:
|
++ New features:
|
||||||
|
|
||||||
|
2007-06-30 Frédéric Bernon
|
||||||
|
* sockets.h, sockets.c: Implement MSG_PEEK flag for recv/recvfrom functions.
|
||||||
|
|
||||||
2007-06-21 Simon Goldschmidt
|
2007-06-21 Simon Goldschmidt
|
||||||
* etharp.h, etharp.c: Combined etharp_request with etharp_raw for both
|
* etharp.h, etharp.c: Combined etharp_request with etharp_raw for both
|
||||||
LWIP_AUTOIP =0 and =1 to remove redundant code.
|
LWIP_AUTOIP =0 and =1 to remove redundant code.
|
||||||
|
@ -381,7 +381,6 @@ lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
|
|||||||
struct ip_addr *addr;
|
struct ip_addr *addr;
|
||||||
u16_t port;
|
u16_t port;
|
||||||
|
|
||||||
|
|
||||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d, %p, %d, 0x%x, ..)\n", s, mem, len, flags));
|
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d, %p, %d, 0x%x, ..)\n", s, mem, len, flags));
|
||||||
sock = get_socket(s);
|
sock = get_socket(s);
|
||||||
if (!sock)
|
if (!sock)
|
||||||
@ -400,7 +399,7 @@ lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
|
|||||||
|
|
||||||
/* No data was left from the previous operation, so we try to get
|
/* No data was left from the previous operation, so we try to get
|
||||||
some from the network. */
|
some from the network. */
|
||||||
buf = netconn_recv(sock->conn);
|
sock->lastdata = buf = netconn_recv(sock->conn);
|
||||||
|
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
/* We should really do some error checking here. */
|
/* We should really do some error checking here. */
|
||||||
@ -454,19 +453,21 @@ lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
|
|||||||
ip_addr_debug_print(SOCKETS_DEBUG, addr);
|
ip_addr_debug_print(SOCKETS_DEBUG, addr);
|
||||||
LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u len=%u\n", port, copylen));
|
LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u len=%u\n", port, copylen));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If this is a TCP socket, check if there is data left in the
|
/* If we don't peek the incoming message... */
|
||||||
buffer. If so, it should be saved in the sock structure for next
|
if ((flags & MSG_PEEK)==0) {
|
||||||
time around. */
|
/* If this is a TCP socket, check if there is data left in the
|
||||||
if ((sock->conn->type == NETCONN_TCP) && (buflen - copylen > 0)) {
|
buffer. If so, it should be saved in the sock structure for next
|
||||||
sock->lastdata = buf;
|
time around. */
|
||||||
sock->lastoffset += copylen;
|
if ((sock->conn->type == NETCONN_TCP) && (buflen - copylen > 0)) {
|
||||||
} else {
|
sock->lastdata = buf;
|
||||||
sock->lastdata = NULL;
|
sock->lastoffset += copylen;
|
||||||
sock->lastoffset = 0;
|
} else {
|
||||||
netbuf_delete(buf);
|
sock->lastdata = NULL;
|
||||||
|
sock->lastoffset = 0;
|
||||||
|
netbuf_delete(buf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sock_set_errno(sock, 0);
|
sock_set_errno(sock, 0);
|
||||||
|
@ -121,11 +121,14 @@ struct linger {
|
|||||||
#define IPPROTO_UDP 17
|
#define IPPROTO_UDP 17
|
||||||
#define IPPROTO_UDPLITE 136
|
#define IPPROTO_UDPLITE 136
|
||||||
|
|
||||||
#define INADDR_ANY 0
|
#define INADDR_ANY 0
|
||||||
#define INADDR_BROADCAST 0xffffffff
|
#define INADDR_BROADCAST 0xffffffff
|
||||||
|
|
||||||
/* Flags we can use with send and recv. */
|
/* Flags we can use with send and recv. */
|
||||||
#define MSG_DONTWAIT 0x40 /* Nonblocking i/o for this operation only */
|
#define MSG_PEEK 0x01 /* Peeks at an incoming message */
|
||||||
|
#define MSG_WAITALL 0x02 /* Requests that the function block until the full amount of data requested can be returned */
|
||||||
|
#define MSG_OOB 0x04 /* Requests out-of-band data. The significance and semantics of out-of-band data are protocol-specific */
|
||||||
|
#define MSG_DONTWAIT 0x08 /* Nonblocking i/o for this operation only */
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -140,7 +143,7 @@ struct linger {
|
|||||||
*/
|
*/
|
||||||
#define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */
|
#define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */
|
||||||
#define TCP_KEEPALIVE 0x02 /* send KEEPALIVE probes when idle for pcb->keep_idle milliseconds */
|
#define TCP_KEEPALIVE 0x02 /* send KEEPALIVE probes when idle for pcb->keep_idle milliseconds */
|
||||||
#define TCP_KEEPIDLE 0x03 /* set pcb->keep_idle - Same as TCP_KEEPALIVE, but use seconds for get/setsockopt*/
|
#define TCP_KEEPIDLE 0x03 /* set pcb->keep_idle - Same as TCP_KEEPALIVE, but use seconds for get/setsockopt */
|
||||||
#define TCP_KEEPINTVL 0x04 /* set pcb->keep_intvl - Use seconds for get/setsockopt */
|
#define TCP_KEEPINTVL 0x04 /* set pcb->keep_intvl - Use seconds for get/setsockopt */
|
||||||
#define TCP_KEEPCNT 0x05 /* set pcb->keep_cnt - Use number of probes sent for get/setsockopt */
|
#define TCP_KEEPCNT 0x05 /* set pcb->keep_cnt - Use number of probes sent for get/setsockopt */
|
||||||
#endif /* LWIP_TCP */
|
#endif /* LWIP_TCP */
|
||||||
|
Loading…
Reference in New Issue
Block a user