74 |
|
|
75 |
type = *((u8_t *)p->payload); |
type = *((u8_t *)p->payload); |
76 |
code = *(((u8_t *)p->payload)+1); |
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) || |
80 |
ip_addr_ismulticast(&iphdr->dest)) { |
ip_addr_ismulticast(&iphdr->dest)) { |
81 |
DEBUGF(ICMP_DEBUG, ("Smurf.\n")); |
DEBUGF(ICMP_DEBUG, ("Smurf.\n")); |
82 |
#ifdef ICMP_STATS |
#ifdef ICMP_STATS |
87 |
} |
} |
88 |
DEBUGF(ICMP_DEBUG, ("icmp_input: ping\n")); |
DEBUGF(ICMP_DEBUG, ("icmp_input: ping\n")); |
89 |
DEBUGF(DEMO_DEBUG, ("Pong!\n")); |
DEBUGF(DEMO_DEBUG, ("Pong!\n")); |
90 |
if(p->tot_len < sizeof(struct icmp_echo_hdr)) { |
if (p->tot_len < sizeof(struct icmp_echo_hdr)) { |
91 |
DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP echo received\n")); |
DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP echo received\n")); |
92 |
pbuf_free(p); |
pbuf_free(p); |
93 |
#ifdef ICMP_STATS |
#ifdef ICMP_STATS |
98 |
return; |
return; |
99 |
} |
} |
100 |
iecho = p->payload; |
iecho = p->payload; |
101 |
if(inet_chksum_pbuf(p) != 0) { |
if (inet_chksum_pbuf(p) != 0) { |
102 |
DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo\n")); |
DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo\n")); |
103 |
pbuf_free(p); |
pbuf_free(p); |
104 |
#ifdef ICMP_STATS |
#ifdef ICMP_STATS |
112 |
iphdr->dest.addr = tmpaddr.addr; |
iphdr->dest.addr = tmpaddr.addr; |
113 |
ICMPH_TYPE_SET(iecho, ICMP_ER); |
ICMPH_TYPE_SET(iecho, ICMP_ER); |
114 |
/* adjust the checksum */ |
/* adjust the checksum */ |
115 |
if(iecho->chksum >= htons(0xffff - (ICMP_ECHO << 8))) { |
if (iecho->chksum >= htons(0xffff - (ICMP_ECHO << 8))) { |
116 |
iecho->chksum += htons(ICMP_ECHO << 8) + 1; |
iecho->chksum += htons(ICMP_ECHO << 8) + 1; |
117 |
} else { |
} else { |
118 |
iecho->chksum += htons(ICMP_ECHO << 8); |
iecho->chksum += htons(ICMP_ECHO << 8); |
126 |
snmp_inc_icmpoutechoreps(); |
snmp_inc_icmpoutechoreps(); |
127 |
|
|
128 |
pbuf_header(p, hlen); |
pbuf_header(p, hlen); |
129 |
ip_output_if(p, &(iphdr->src), IP_HDRINCL, |
ip_output_if (p, &(iphdr->src), IP_HDRINCL, |
130 |
IPH_TTL(iphdr), IP_PROTO_ICMP, inp); |
IPH_TTL(iphdr), IP_PROTO_ICMP, inp); |
131 |
break; |
break; |
132 |
default: |
default: |