SCCS-vsn: sys/netns/ns_cksum.c 7.7
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)ns_cksum.c 7.6 (Berkeley) %G%
+ * @(#)ns_cksum.c 7.7 (Berkeley) %G%
*/
#include "sys/param.h"
*/
#include "sys/param.h"
* There is a byte left from the last segment;
* ones-complement add it into the checksum.
*/
* There is a byte left from the last segment;
* ones-complement add it into the checksum.
*/
- sum += *(u_char *)w; /* Big-Endian, else << 8 */
+#if BYTE_ORDER == BIG_ENDIAN
+ sum += *(u_char *)w;
+#else
+ sum += *(u_char *)w << 8;
+#endif
sum += sum;
w = (u_short *)(1 + (char *)w);
mlen = m->m_len - 1;
sum += sum;
w = (u_short *)(1 + (char *)w);
mlen = m->m_len - 1;
}
goto commoncase;
uuuuglyy:
}
goto commoncase;
uuuuglyy:
-/* Big-Endian; else reverse ww and vv */
+#if BYTE_ORDER == BIG_ENDIAN
#define ww(n) (((u_char *)w)[n + n + 1])
#define vv(n) (((u_char *)w)[n + n])
#define ww(n) (((u_char *)w)[n + n + 1])
#define vv(n) (((u_char *)w)[n + n])
+#else
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define vv(n) (((u_char *)w)[n + n + 1])
+#define ww(n) (((u_char *)w)[n + n])
+#endif
+#endif
sum2 = 0;
#ifndef TINY
while ((mlen -= 32) >= 0) {
sum2 = 0;
#ifndef TINY
while ((mlen -= 32) >= 0) {
sum += (sum2 << 8);
commoncase:
if (mlen == -1) {
sum += (sum2 << 8);
commoncase:
if (mlen == -1) {
- sum += *(u_char *)w << 8; /* Big-Endian, else no << 8 */
+#if BYTE_ORDER == BIG_ENDIAN
+ sum += *(u_char *)w << 8;
+#else
+ sum += *(u_char *)w;
+#endif