summaryrefslogtreecommitdiff
path: root/in_cksum.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2002-07-21 20:31:21 +0000
committerGuy Harris <guy@alum.mit.edu>2002-07-21 20:31:21 +0000
commit6c289aebb9aee29472a1f0f11a286e96a604dbf9 (patch)
tree07c580022da3a5a0a1b9b4c5d550363d32b5e77d /in_cksum.c
parent1dd6c308ce35bd65d6b93e6ee7badac6f2f5c81a (diff)
downloadwireshark-6c289aebb9aee29472a1f0f11a286e96a604dbf9.tar.gz
Fix up some comments.
Fix up a call to use the right byte-ordering routine (both routines have the same effect, but we want to use the right one to make it clearer what we're doing). svn path=/trunk/; revision=5901
Diffstat (limited to 'in_cksum.c')
-rw-r--r--in_cksum.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/in_cksum.c b/in_cksum.c
index 62b729875e..ff07a0ad2c 100644
--- a/in_cksum.c
+++ b/in_cksum.c
@@ -2,7 +2,7 @@
* 4.4-Lite-2 Internet checksum routine, modified to take a vector of
* pointers/lengths giving the pieces to be checksummed.
*
- * $Id: in_cksum.c,v 1.5 2002/06/23 10:32:14 guy Exp $
+ * $Id: in_cksum.c,v 1.6 2002/07/21 20:31:21 guy Exp $
*/
/*
@@ -166,9 +166,9 @@ in_cksum(const vec_t *vec, int veclen)
/*
* Given the host-byte-order value of the checksum field in a packet
- * header, and the one's complement negation of the host-byte-order
- * checksum of the packet, compute what the checksum field *should*
- * have been.
+ * header, and the network-byte-order computed checksum of the data
+ * that the checksum covers (including the checksum itself), compute
+ * what the checksum field *should* have been.
*/
guint16
in_cksum_shouldbe(guint16 sum, guint16 computed_sum)
@@ -204,14 +204,13 @@ in_cksum_shouldbe(guint16 sum, guint16 computed_sum)
* byte-swapped before being stuffed into a big-endian checksum
* field.
*
- * "computed_sum" is a host-byte-order value, so we must put
- * it in network byte order before subtracting it from the
- * network-byte-order value from the header; the adjusted
- * checksum will be in network byte order, which is what
- * we'll return.
+ * "computed_sum" is a network-byte-order value, so we must put
+ * it in host byte order before subtracting it from the
+ * host-byte-order value from the header; the adjusted checksum
+ * will be in host byte order, which is what we'll return.
*/
shouldbe = sum;
- shouldbe += htons(computed_sum);
+ shouldbe += ntohs(computed_sum);
shouldbe = (shouldbe & 0xFFFF) + (shouldbe >> 16);
shouldbe = (shouldbe & 0xFFFF) + (shouldbe >> 16);
return shouldbe;