Skip to content

Commit

Permalink
ping: fix compiling in dual-stack mode
Browse files Browse the repository at this point in the history
  • Loading branch information
goldsimon committed Oct 10, 2023
1 parent 9e2fb28 commit 5ec4c1d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions contrib/apps/ping/ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,11 @@ ping_recv(void *arg, struct raw_pcb *pcb, struct pbuf *p, const ip_addr_t *addr)
LWIP_UNUSED_ARG(arg);
LWIP_UNUSED_ARG(pcb);
LWIP_UNUSED_ARG(addr);
LWIP_ASSERT("addr != NULL", addr != NULL);
LWIP_ASSERT("p != NULL", p != NULL);

if ((p->tot_len >= (PBUF_IP_HLEN + sizeof(struct icmp_echo_hdr))) &&
pbuf_remove_header(p, PBUF_IP_HLEN) == 0) {
if ((p->tot_len >= (IP_HLEN + sizeof(struct icmp_echo_hdr))) &&
pbuf_remove_header(p, IP_HLEN) == 0) {
iecho = (struct icmp_echo_hdr *)p->payload;

if ((iecho->id == PING_ID) && (iecho->seqno == lwip_htons(ping_seq_num))) {
Expand All @@ -315,7 +316,7 @@ ping_recv(void *arg, struct raw_pcb *pcb, struct pbuf *p, const ip_addr_t *addr)
return 1; /* eat the packet */
}
/* not eaten, restore original packet */
pbuf_add_header(p, PBUF_IP_HLEN);
pbuf_add_header(p, IP_HLEN);
}

return 0; /* don't eat the packet */
Expand Down

0 comments on commit 5ec4c1d

Please sign in to comment.