aboutsummaryrefslogtreecommitdiffstats
path: root/in_cksum.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2001-06-09 01:02:29 +0000
committerGuy Harris <guy@alum.mit.edu>2001-06-09 01:02:29 +0000
commit58304dd1f761ea86735101bb2db266cc2a56cf37 (patch)
tree0638bea5d8e5425c5e05c0302975da6da221d328 /in_cksum.c
parente52dd802c419072535154586d3a65e763bd62dd4 (diff)
"long" does not necessarily mean "32-bit integral data type"; the union
used to treat a 32-bit quantity either as 2 16-bit quantities or a 32-bit quantity should use "guint32", not "long", for the latter. We should also use "guint8" for the two 8-bit quantities in "s_util", although that shouldn't make a difference in practice (we store into them, but fetch only the 16-bit overlapping quantity, which is already unsigned). svn path=/trunk/; revision=3533
Diffstat (limited to 'in_cksum.c')
-rw-r--r--in_cksum.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/in_cksum.c b/in_cksum.c
index ee047a8c2c..2ab7dd36f8 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.3 2001/01/10 23:34:06 guy Exp $
+ * $Id: in_cksum.c,v 1.4 2001/06/09 01:02:29 guy Exp $
*/
/*
@@ -79,12 +79,12 @@ in_cksum(const vec_t *vec, int veclen)
int byte_swapped = 0;
union {
- char c[2];
+ guint8 c[2];
guint16 s;
} s_util;
union {
guint16 s[2];
- long l;
+ guint32 l;
} l_util;
for (; veclen != 0; vec++, veclen--) {
@@ -100,7 +100,7 @@ in_cksum(const vec_t *vec, int veclen)
* s_util.c[0] is already saved when scanning previous
* chunk.
*/
- s_util.c[1] = *(char *)w;
+ s_util.c[1] = *(const guint8 *)w;
sum += s_util.s;
w = (const guint16 *)((const guint8 *)w + 1);
mlen = vec->len - 1;
@@ -145,13 +145,13 @@ in_cksum(const vec_t *vec, int veclen)
sum <<= 8;
byte_swapped = 0;
if (mlen == -1) {
- s_util.c[1] = *(char *)w;
+ s_util.c[1] = *(const guint8 *)w;
sum += s_util.s;
mlen = 0;
} else
mlen = -1;
} else if (mlen == -1)
- s_util.c[0] = *(char *)w;
+ s_util.c[0] = *(const guint8 *)w;
}
if (mlen == -1) {
/* The last mbuf has odd # of bytes. Follow the