/[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.12 by likewise, Thu May 1 08:29:54 2003 UTC revision 1.13 by likewise, Thu May 1 13:24:01 2003 UTC
# Line 74  icmp_input(struct pbuf *p, struct netif Line 74  icmp_input(struct pbuf *p, struct netif
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
# Line 87  icmp_input(struct pbuf *p, struct netif Line 87  icmp_input(struct pbuf *p, struct netif
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
# Line 98  icmp_input(struct pbuf *p, struct netif Line 98  icmp_input(struct pbuf *p, struct netif
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
# Line 112  icmp_input(struct pbuf *p, struct netif Line 112  icmp_input(struct pbuf *p, struct netif
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);
# Line 126  icmp_input(struct pbuf *p, struct netif Line 126  icmp_input(struct pbuf *p, struct netif
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:

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

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