mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-01 04:12:07 +00:00
api_msg.c: Fix bug #22530 "api_msg.c's recv_raw() does not consume data".
This commit is contained in:
parent
a48370d5e9
commit
552106e2a4
@ -600,6 +600,12 @@ HISTORY
|
|||||||
|
|
||||||
++ Bug fixes:
|
++ Bug fixes:
|
||||||
|
|
||||||
|
2008-03-12 Frédéric Bernon, Jonathan Larmour
|
||||||
|
* api_msg.c, contrib/apps/ping.c: Fix bug #22530 "api_msg.c's
|
||||||
|
recv_raw() does not consume data", and the ping sample (with
|
||||||
|
LWIP_SOCKET=1, the code did the wrong supposition that lwip_recvfrom
|
||||||
|
returned the IP payload, without the IP header).
|
||||||
|
|
||||||
2008-03-04 Jonathan Larmour
|
2008-03-04 Jonathan Larmour
|
||||||
* mem.c, stats.c, mem.h: apply patch #6414 to avoid compiler errors
|
* mem.c, stats.c, mem.h: apply patch #6414 to avoid compiler errors
|
||||||
and/or warnings on some systems where mem_size_t and size_t differ.
|
and/or warnings on some systems where mem_size_t and size_t differ.
|
||||||
|
@ -70,6 +70,7 @@ static u8_t
|
|||||||
recv_raw(void *arg, struct raw_pcb *pcb, struct pbuf *p,
|
recv_raw(void *arg, struct raw_pcb *pcb, struct pbuf *p,
|
||||||
struct ip_addr *addr)
|
struct ip_addr *addr)
|
||||||
{
|
{
|
||||||
|
struct pbuf *q;
|
||||||
struct netbuf *buf;
|
struct netbuf *buf;
|
||||||
struct netconn *conn;
|
struct netconn *conn;
|
||||||
#if LWIP_SO_RCVBUF
|
#if LWIP_SO_RCVBUF
|
||||||
@ -85,21 +86,33 @@ recv_raw(void *arg, struct raw_pcb *pcb, struct pbuf *p,
|
|||||||
#else /* LWIP_SO_RCVBUF */
|
#else /* LWIP_SO_RCVBUF */
|
||||||
if ((conn != NULL) && (conn->recvmbox != SYS_MBOX_NULL)) {
|
if ((conn != NULL) && (conn->recvmbox != SYS_MBOX_NULL)) {
|
||||||
#endif /* LWIP_SO_RCVBUF */
|
#endif /* LWIP_SO_RCVBUF */
|
||||||
buf = memp_malloc(MEMP_NETBUF);
|
/* copy the whole packet into new pbufs */
|
||||||
if (buf == NULL) {
|
q = pbuf_alloc(PBUF_RAW, p->tot_len, PBUF_RAM);
|
||||||
return 0;
|
if(q != NULL) {
|
||||||
|
if (pbuf_copy(q, p) != ERR_OK) {
|
||||||
|
pbuf_free(q);
|
||||||
|
q = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pbuf_ref(p);
|
|
||||||
buf->p = p;
|
|
||||||
buf->ptr = p;
|
|
||||||
buf->addr = addr;
|
|
||||||
buf->port = pcb->protocol;
|
|
||||||
|
|
||||||
SYS_ARCH_INC(conn->recv_avail, p->tot_len);
|
if(q != NULL) {
|
||||||
/* Register event with callback */
|
buf = memp_malloc(MEMP_NETBUF);
|
||||||
API_EVENT(conn, NETCONN_EVT_RCVPLUS, p->tot_len);
|
if (buf == NULL) {
|
||||||
if (sys_mbox_trypost(conn->recvmbox, buf) != ERR_OK) {
|
pbuf_free(q);
|
||||||
netbuf_delete(buf);
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
buf->p = q;
|
||||||
|
buf->ptr = q;
|
||||||
|
buf->addr = addr;
|
||||||
|
buf->port = pcb->protocol;
|
||||||
|
|
||||||
|
SYS_ARCH_INC(conn->recv_avail, q->tot_len);
|
||||||
|
/* Register event with callback */
|
||||||
|
API_EVENT(conn, NETCONN_EVT_RCVPLUS, q->tot_len);
|
||||||
|
if (sys_mbox_trypost(conn->recvmbox, buf) != ERR_OK) {
|
||||||
|
netbuf_delete(buf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1182,4 +1195,3 @@ do_gethostbyname(void *arg)
|
|||||||
#endif /* LWIP_DNS */
|
#endif /* LWIP_DNS */
|
||||||
|
|
||||||
#endif /* LWIP_NETCONN */
|
#endif /* LWIP_NETCONN */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user