/[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.23 by likewise, Mon Jan 24 21:05:47 2005 UTC revision 1.24 by christiaans, Fri Nov 25 12:03:38 2005 UTC
# Line 46  Line 46 
46  void  void
47  icmp_input(struct pbuf *p, struct netif *inp)  icmp_input(struct pbuf *p, struct netif *inp)
48  {  {
49    unsigned char type;    u8_t type;
50    unsigned char code;    u8_t code;
51    struct icmp_echo_hdr *iecho;    struct icmp_echo_hdr *iecho;
52    struct ip_hdr *iphdr;    struct ip_hdr *iphdr;
53    struct ip_addr tmpaddr;    struct ip_addr tmpaddr;
# Line 60  icmp_input(struct pbuf *p, struct netif Line 60  icmp_input(struct pbuf *p, struct netif
60    iphdr = p->payload;    iphdr = p->payload;
61    hlen = IPH_HL(iphdr) * 4;    hlen = IPH_HL(iphdr) * 4;
62    if (pbuf_header(p, -((s16_t)hlen)) || (p->tot_len < sizeof(u16_t)*2)) {    if (pbuf_header(p, -((s16_t)hlen)) || (p->tot_len < sizeof(u16_t)*2)) {
63      LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: short ICMP (%u bytes) received\n", p->tot_len));      LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: short ICMP (%"U16_F" bytes) received\n", p->tot_len));
64      pbuf_free(p);      pbuf_free(p);
65      ICMP_STATS_INC(icmp.lenerr);      ICMP_STATS_INC(icmp.lenerr);
66      snmp_inc_icmpinerrors();      snmp_inc_icmpinerrors();
# Line 116  icmp_input(struct pbuf *p, struct netif Line 116  icmp_input(struct pbuf *p, struct netif
116                   IPH_TTL(iphdr), 0, IP_PROTO_ICMP, inp);                   IPH_TTL(iphdr), 0, IP_PROTO_ICMP, inp);
117      break;      break;
118    default:    default:
119    LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type %d code %d not supported.\n", (int)type, (int)code));    LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type %"S16_F" code %"S16_F" not supported.\n", (s16_t)type, (s16_t)code));
120      ICMP_STATS_INC(icmp.proterr);      ICMP_STATS_INC(icmp.proterr);
121      ICMP_STATS_INC(icmp.drop);      ICMP_STATS_INC(icmp.drop);
122    }    }
# Line 139  icmp_dest_unreach(struct pbuf *p, enum i Line 139  icmp_dest_unreach(struct pbuf *p, enum i
139    ICMPH_TYPE_SET(idur, ICMP_DUR);    ICMPH_TYPE_SET(idur, ICMP_DUR);
140    ICMPH_CODE_SET(idur, t);    ICMPH_CODE_SET(idur, t);
141    
142    memcpy((char *)q->payload + 8, p->payload, IP_HLEN + 8);    memcpy((u8_t *)q->payload + 8, p->payload, IP_HLEN + 8);
143    
144    /* calculate checksum */    /* calculate checksum */
145    idur->chksum = 0;    idur->chksum = 0;
# Line 177  icmp_time_exceeded(struct pbuf *p, enum Line 177  icmp_time_exceeded(struct pbuf *p, enum
177    ICMPH_CODE_SET(tehdr, t);    ICMPH_CODE_SET(tehdr, t);
178    
179    /* copy fields from original packet */    /* copy fields from original packet */
180    memcpy((char *)q->payload + 8, (char *)p->payload, IP_HLEN + 8);    memcpy((u8_t *)q->payload + 8, (u8_t *)p->payload, IP_HLEN + 8);
181    
182    /* calculate checksum */    /* calculate checksum */
183    tehdr->chksum = 0;    tehdr->chksum = 0;

Legend:
Removed from v.1.23  
changed lines
  Added in v.1.24

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