mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2025-08-03 21:14:40 +08:00
Use ICMP_STATS_INC instead of #if ICMP_STATS...
This commit is contained in:
parent
4211da00b3
commit
4a01122fb7
@ -51,9 +51,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
|
|||||||
struct ip_hdr *iphdr;
|
struct ip_hdr *iphdr;
|
||||||
struct ip_addr tmpaddr;
|
struct ip_addr tmpaddr;
|
||||||
|
|
||||||
#if ICMP_STATS
|
ICMP_STATS_INC(icmp.recv);
|
||||||
++lwip_stats.icmp.recv;
|
|
||||||
#endif /* ICMP_STATS */
|
|
||||||
|
|
||||||
/* TODO: check length before accessing payload! */
|
/* TODO: check length before accessing payload! */
|
||||||
|
|
||||||
@ -67,20 +65,14 @@ icmp_input(struct pbuf *p, struct netif *inp)
|
|||||||
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP echo received\n"));
|
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP echo received\n"));
|
||||||
|
|
||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
#if ICMP_STATS
|
ICMP_STATS_INC(icmp.lenerr);
|
||||||
++lwip_stats.icmp.lenerr;
|
|
||||||
#endif /* ICMP_STATS */
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
iecho = p->payload;
|
iecho = p->payload;
|
||||||
iphdr = (struct ip_hdr *)((u8_t *)p->payload - IP_HLEN);
|
iphdr = (struct ip_hdr *)((u8_t *)p->payload - IP_HLEN);
|
||||||
if (inet_chksum_pbuf(p) != 0) {
|
if (inet_chksum_pbuf(p) != 0) {
|
||||||
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo (%"X16_F")\n", inet_chksum_pseudo(p, &(iphdr->src), &(iphdr->dest), IP_PROTO_ICMP, p->tot_len)));
|
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo (%"X16_F")\n", inet_chksum_pseudo(p, &(iphdr->src), &(iphdr->dest), IP_PROTO_ICMP, p->tot_len)));
|
||||||
|
ICMP_STATS_INC(icmp.chkerr);
|
||||||
#if ICMP_STATS
|
|
||||||
++lwip_stats.icmp.chkerr;
|
|
||||||
#endif /* ICMP_STATS */
|
|
||||||
/* return;*/
|
/* return;*/
|
||||||
}
|
}
|
||||||
LWIP_DEBUGF(ICMP_DEBUG, ("icmp: p->len %"S16_F" p->tot_len %"S16_F"\n", p->len, p->tot_len));
|
LWIP_DEBUGF(ICMP_DEBUG, ("icmp: p->len %"S16_F" p->tot_len %"S16_F"\n", p->len, p->tot_len));
|
||||||
@ -95,9 +87,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
|
|||||||
iecho->chksum += htons(ICMP6_ECHO << 8);
|
iecho->chksum += htons(ICMP6_ECHO << 8);
|
||||||
}
|
}
|
||||||
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo (%"X16_F")\n", inet_chksum_pseudo(p, &(iphdr->src), &(iphdr->dest), IP_PROTO_ICMP, p->tot_len)));
|
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo (%"X16_F")\n", inet_chksum_pseudo(p, &(iphdr->src), &(iphdr->dest), IP_PROTO_ICMP, p->tot_len)));
|
||||||
#if ICMP_STATS
|
ICMP_STATS_INC(icmp.xmit);
|
||||||
++lwip_stats.icmp.xmit;
|
|
||||||
#endif /* ICMP_STATS */
|
|
||||||
|
|
||||||
/* LWIP_DEBUGF("icmp: p->len %"U16_F" p->tot_len %"U16_F"\n", p->len, p->tot_len);*/
|
/* LWIP_DEBUGF("icmp: p->len %"U16_F" p->tot_len %"U16_F"\n", p->len, p->tot_len);*/
|
||||||
ip_output_if (p, &(iphdr->src), IP_HDRINCL,
|
ip_output_if (p, &(iphdr->src), IP_HDRINCL,
|
||||||
@ -105,10 +95,8 @@ icmp_input(struct pbuf *p, struct netif *inp)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type %"S16_F" not supported.\n", (s16_t)type));
|
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type %"S16_F" not supported.\n", (s16_t)type));
|
||||||
#if ICMP_STATS
|
ICMP_STATS_INC(icmp.proterr);
|
||||||
++lwip_stats.icmp.proterr;
|
ICMP_STATS_INC(icmp.drop);
|
||||||
++lwip_stats.icmp.drop;
|
|
||||||
#endif /* ICMP_STATS */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
@ -143,9 +131,7 @@ icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t)
|
|||||||
/* calculate checksum */
|
/* calculate checksum */
|
||||||
idur->chksum = 0;
|
idur->chksum = 0;
|
||||||
idur->chksum = inet_chksum(idur, q->len);
|
idur->chksum = inet_chksum(idur, q->len);
|
||||||
#if ICMP_STATS
|
ICMP_STATS_INC(icmp.xmit);
|
||||||
++lwip_stats.icmp.xmit;
|
|
||||||
#endif /* ICMP_STATS */
|
|
||||||
|
|
||||||
ip_output(q, NULL,
|
ip_output(q, NULL,
|
||||||
(struct ip_addr *)&(iphdr->src), ICMP_TTL, IP_PROTO_ICMP);
|
(struct ip_addr *)&(iphdr->src), ICMP_TTL, IP_PROTO_ICMP);
|
||||||
@ -184,9 +170,7 @@ icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t)
|
|||||||
/* calculate checksum */
|
/* calculate checksum */
|
||||||
tehdr->chksum = 0;
|
tehdr->chksum = 0;
|
||||||
tehdr->chksum = inet_chksum(tehdr, q->len);
|
tehdr->chksum = inet_chksum(tehdr, q->len);
|
||||||
#if ICMP_STATS
|
ICMP_STATS_INC(icmp.xmit);
|
||||||
++lwip_stats.icmp.xmit;
|
|
||||||
#endif /* ICMP_STATS */
|
|
||||||
ip_output(q, NULL,
|
ip_output(q, NULL,
|
||||||
(struct ip_addr *)&(iphdr->src), ICMP_TTL, IP_PROTO_ICMP);
|
(struct ip_addr *)&(iphdr->src), ICMP_TTL, IP_PROTO_ICMP);
|
||||||
pbuf_free(q);
|
pbuf_free(q);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user