48 |
icmp_input(struct pbuf *p, struct netif *inp) |
icmp_input(struct pbuf *p, struct netif *inp) |
49 |
{ |
{ |
50 |
unsigned char type; |
unsigned char type; |
51 |
|
unsigned char code; |
52 |
struct icmp_echo_hdr *iecho; |
struct icmp_echo_hdr *iecho; |
53 |
struct ip_hdr *iphdr; |
struct ip_hdr *iphdr; |
54 |
struct ip_addr tmpaddr; |
struct ip_addr tmpaddr; |
62 |
|
|
63 |
iphdr = p->payload; |
iphdr = p->payload; |
64 |
hlen = IPH_HL(iphdr) * 4; |
hlen = IPH_HL(iphdr) * 4; |
65 |
pbuf_header(p, -((s16_t)hlen)); |
if (pbuf_header(p, -((s16_t)hlen)) || (p->tot_len < sizeof(u16_t)*2)) { |
66 |
|
DEBUGF(ICMP_DEBUG, ("icmp_input: short ICMP (%u bytes) received\n", p->tot_len)); |
67 |
|
pbuf_free(p); |
68 |
|
#ifdef ICMP_STATS |
69 |
|
++lwip_stats.icmp.lenerr; |
70 |
|
#endif /* ICMP_STATS */ |
71 |
|
snmp_inc_icmpinerrors(); |
72 |
|
return; |
73 |
|
} |
74 |
|
|
75 |
type = *((u8_t *)p->payload); |
type = *((u8_t *)p->payload); |
76 |
|
code = *(((u8_t *)p->payload)+1); |
77 |
switch(type) { |
switch(type) { |
78 |
case ICMP_ECHO: |
case ICMP_ECHO: |
79 |
if(ip_addr_isbroadcast(&iphdr->dest, &inp->netmask) || |
if(ip_addr_isbroadcast(&iphdr->dest, &inp->netmask) || |
130 |
IPH_TTL(iphdr), IP_PROTO_ICMP, inp); |
IPH_TTL(iphdr), IP_PROTO_ICMP, inp); |
131 |
break; |
break; |
132 |
default: |
default: |
133 |
DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type not supported.\n")); |
DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type %d code %d not supported.\n", (int)type, (int)code)); |
134 |
#ifdef ICMP_STATS |
#ifdef ICMP_STATS |
135 |
++lwip_stats.icmp.proterr; |
++lwip_stats.icmp.proterr; |
136 |
++lwip_stats.icmp.drop; |
++lwip_stats.icmp.drop; |