/[lwip]/lwip/src/core/ipv4/icmp.c
ViewVC logotype

Diff of /lwip/src/core/ipv4/icmp.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.11 by likewise, Sun Mar 16 22:39:15 2003 UTC revision 1.11.2.1 by likewise, Wed May 14 14:38:28 2003 UTC
# Line 65  icmp_input(struct pbuf *p, struct netif Line 65  icmp_input(struct pbuf *p, struct netif
65    
66    type = *((u8_t *)p->payload);    type = *((u8_t *)p->payload);
67    
68    switch(type) {    switch (type) {
69    case ICMP_ECHO:    case ICMP_ECHO:
70      if(ip_addr_isbroadcast(&iphdr->dest, &inp->netmask) ||      if (ip_addr_isbroadcast(&iphdr->dest, &inp->netmask) ||
71         ip_addr_ismulticast(&iphdr->dest)) {         ip_addr_ismulticast(&iphdr->dest)) {
72        DEBUGF(ICMP_DEBUG, ("Smurf.\n"));        DEBUGF(ICMP_DEBUG, ("Smurf.\n"));
73  #ifdef ICMP_STATS  #ifdef ICMP_STATS
# Line 78  icmp_input(struct pbuf *p, struct netif Line 78  icmp_input(struct pbuf *p, struct netif
78      }      }
79      DEBUGF(ICMP_DEBUG, ("icmp_input: ping\n"));      DEBUGF(ICMP_DEBUG, ("icmp_input: ping\n"));
80      DEBUGF(DEMO_DEBUG, ("Pong!\n"));      DEBUGF(DEMO_DEBUG, ("Pong!\n"));
81      if(p->tot_len < sizeof(struct icmp_echo_hdr)) {      if (p->tot_len < sizeof(struct icmp_echo_hdr)) {
82        DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP echo received\n"));        DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP echo received\n"));
83        pbuf_free(p);        pbuf_free(p);
84  #ifdef ICMP_STATS  #ifdef ICMP_STATS
# Line 89  icmp_input(struct pbuf *p, struct netif Line 89  icmp_input(struct pbuf *p, struct netif
89        return;              return;      
90      }      }
91      iecho = p->payload;          iecho = p->payload;    
92      if(inet_chksum_pbuf(p) != 0) {      if (inet_chksum_pbuf(p) != 0) {
93        DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo\n"));        DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo\n"));
94        pbuf_free(p);        pbuf_free(p);
95  #ifdef ICMP_STATS  #ifdef ICMP_STATS
# Line 103  icmp_input(struct pbuf *p, struct netif Line 103  icmp_input(struct pbuf *p, struct netif
103      iphdr->dest.addr = tmpaddr.addr;      iphdr->dest.addr = tmpaddr.addr;
104      ICMPH_TYPE_SET(iecho, ICMP_ER);      ICMPH_TYPE_SET(iecho, ICMP_ER);
105      /* adjust the checksum */      /* adjust the checksum */
106      if(iecho->chksum >= htons(0xffff - (ICMP_ECHO << 8))) {      if (iecho->chksum >= htons(0xffff - (ICMP_ECHO << 8))) {
107        iecho->chksum += htons(ICMP_ECHO << 8) + 1;        iecho->chksum += htons(ICMP_ECHO << 8) + 1;
108      } else {      } else {
109        iecho->chksum += htons(ICMP_ECHO << 8);        iecho->chksum += htons(ICMP_ECHO << 8);
# Line 117  icmp_input(struct pbuf *p, struct netif Line 117  icmp_input(struct pbuf *p, struct netif
117      snmp_inc_icmpoutechoreps();      snmp_inc_icmpoutechoreps();
118    
119      pbuf_header(p, hlen);      pbuf_header(p, hlen);
120      ip_output_if(p, &(iphdr->src), IP_HDRINCL,      ip_output_if (p, &(iphdr->src), IP_HDRINCL,
121                   IPH_TTL(iphdr), IP_PROTO_ICMP, inp);                   IPH_TTL(iphdr), IP_PROTO_ICMP, inp);
122      break;      break;
123    default:    default:

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.11.2.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26