diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-03-16 01:05:55 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-03-16 01:05:55 +0000 |
commit | e562180e6fc70e9f933b0bb081d5b69859d04327 (patch) | |
tree | 306206896a4fa9fd9b63c84e0366fa5e95b71865 /nuttx | |
parent | acaab5c7cb917271d8f1119b8f939b88c86b80fd (diff) | |
download | px4-nuttx-e562180e6fc70e9f933b0bb081d5b69859d04327.tar.gz px4-nuttx-e562180e6fc70e9f933b0bb081d5b69859d04327.tar.bz2 px4-nuttx-e562180e6fc70e9f933b0bb081d5b69859d04327.zip |
Better fix
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1618 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx')
-rw-r--r-- | nuttx/net/uip/uip_icmpinput.c | 17 |
1 files changed, 17 insertions, 0 deletions
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]); |