From 346d2f8c8a8c77ca30a6a71bcd660aba7a857741 Mon Sep 17 00:00:00 2001 From: Simon Goldschmidt Date: Fri, 11 Jan 2013 22:00:24 +0100 Subject: [PATCH] ping app: restore original packet if packet is not eaten --- apps/ping/ping.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/ping/ping.c b/apps/ping/ping.c index 595c2a1..20f16b0 100644 --- a/apps/ping/ping.c +++ b/apps/ping/ping.c @@ -237,7 +237,7 @@ ping_recv(void *arg, struct raw_pcb *pcb, struct pbuf *p, ip_addr_t *addr) LWIP_ASSERT("p != NULL", p != NULL); if ((p->tot_len >= (PBUF_IP_HLEN + sizeof(struct icmp_echo_hdr))) && - pbuf_header( p, -PBUF_IP_HLEN) == 0) { + pbuf_header(p, -PBUF_IP_HLEN) == 0) { iecho = (struct icmp_echo_hdr *)p->payload; if ((iecho->id == PING_ID) && (iecho->seqno == htons(ping_seq_num))) { @@ -250,6 +250,8 @@ ping_recv(void *arg, struct raw_pcb *pcb, struct pbuf *p, ip_addr_t *addr) pbuf_free(p); return 1; /* eat the packet */ } + /* not eaten, restore original packet */ + pbuf_header(p, PBUF_IP_HLEN); } return 0; /* don't eat the packet */