From e562180e6fc70e9f933b0bb081d5b69859d04327 Mon Sep 17 00:00:00 2001 From: patacongo Date: Mon, 16 Mar 2009 01:05:55 +0000 Subject: Better fix git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1618 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/net/uip/uip_icmpinput.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/nuttx/net/uip/uip_icmpinput.c b/nuttx/net/uip/uip_icmpinput.c index f2edcbcb5..e9b7a9367 100644 --- a/nuttx/net/uip/uip_icmpinput.c +++ b/nuttx/net/uip/uip_icmpinput.c @@ -142,12 +142,29 @@ void uip_icmpinput(struct uip_driver_s *dev) /* Recalculate the ICMP checksum */ +#if 0 + /* The slow way... sum over the ICMP message */ + picmp->icmpchksum = 0; picmp->icmpchksum = ~uip_icmpchksum(dev, (((uint16)picmp->len[0] << 8) | (uint16)picmp->len[1]) - UIP_IPH_LEN); if (picmp->icmpchksum == 0) { picmp->icmpchksum = 0xffff; } +#else + /* The quick way -- Since only the type has changed, just adjust the + * checksum for the change of type + */ + + if( picmp->icmpchksum >= HTONS(0xffff - (ICMP_ECHO_REQUEST << 8))) + { + picmp->icmpchksum += HTONS(ICMP_ECHO_REQUEST << 8) + 1; + } + else + { + picmp->icmpchksum += HTONS(ICMP_ECHO_REQUEST << 8); + } +#endif nvdbg("Outgoing ICMP packet length: %d (%d)\n", dev->d_len, (picmp->len[0] << 8) | picmp->len[1]); -- cgit v1.2.3