Make standalone in_cksum work on little-endian machines, too, courtesy of
Jeff Smith, <jeffs@geocast.com>.
This commit is contained in:
parent
fe43e9f08f
commit
5e29a96b48
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: in_cksum.c,v 1.5 2000/03/30 12:19:48 augustss Exp $ */
|
||||
/* $NetBSD: in_cksum.c,v 1.6 2000/03/31 19:55:09 castor Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992 Regents of the University of California.
|
||||
|
@ -52,6 +52,8 @@
|
|||
#include <netinet/udp.h>
|
||||
#include <netinet/udp_var.h>
|
||||
|
||||
#include <machine/endian.h>
|
||||
|
||||
#include "stand.h"
|
||||
#include "net.h"
|
||||
|
||||
|
@ -82,12 +84,21 @@ in_cksum(p, len)
|
|||
}
|
||||
} else {
|
||||
while ((len -= 2) >= 0) {
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
sum += *cp++ << 8;
|
||||
sum += *cp++;
|
||||
#else
|
||||
sum += *cp++;
|
||||
sum += *cp++ << 8;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if ((oddbyte = len & 1) != 0)
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
v = *cp << 8;
|
||||
#else
|
||||
v = *cp;
|
||||
#endif
|
||||
}
|
||||
if (oddbyte)
|
||||
sum += v;
|
||||
|
|
Loading…
Reference in New Issue