summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2000-09-09 16:13:35 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2000-09-09 16:13:35 +0000
commitcd7e063a0cd4409a6456efdc9dd3d7b8e63bc0f5 (patch)
tree26a75fc6f80cb989335ece5ea83d9728ff510e08
parent0399a73d5b66cf85dd628d729ebeae8fdfb4a16f (diff)
add attribute(packed) for alignment constraint on a union.
get rid of file static variable, make it an auto variable. (sync with kame)
-rw-r--r--sys/netinet6/in6_cksum.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/sys/netinet6/in6_cksum.c b/sys/netinet6/in6_cksum.c
index 4ff14efda5c..81bfe828f63 100644
--- a/sys/netinet6/in6_cksum.c
+++ b/sys/netinet6/in6_cksum.c
@@ -1,9 +1,10 @@
-/* $OpenBSD: in6_cksum.c,v 1.5 2000/02/28 11:55:22 itojun Exp $ */
+/* $OpenBSD: in6_cksum.c,v 1.6 2000/09/09 16:13:34 itojun Exp $ */
+/* $KAME: in6_cksum.c,v 1.9 2000/09/09 15:33:31 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -15,7 +16,7 @@
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -82,15 +83,6 @@
#define ADDCARRY(x) (x > 65535 ? x -= 65535 : x)
#define REDUCE {l_util.l = sum; sum = l_util.s[0] + l_util.s[1]; ADDCARRY(sum);}
-static union {
- u_int16_t phs[4];
- struct {
- u_int32_t ph_len;
- u_int8_t ph_zero[3];
- u_int8_t ph_nxt;
- } ph;
-} uph;
-
/*
* m MUST contain a continuous IP6 header.
* off is a offset where TCP/UDP/ICMP6 header starts.
@@ -112,7 +104,14 @@ in6_cksum(m, nxt, off, len)
int srcifid = 0, dstifid = 0;
#endif
struct ip6_hdr *ip6;
-
+ union {
+ u_int16_t phs[4];
+ struct {
+ u_int32_t ph_len;
+ u_int8_t ph_zero[3];
+ u_int8_t ph_nxt;
+ } ph __attribute__((__packed__));
+ } uph;
union {
u_int8_t c[2];
u_int16_t s;
@@ -128,6 +127,8 @@ in6_cksum(m, nxt, off, len)
m->m_pkthdr.len, off, len);
}
+ bzero(&uph, sizeof(uph));
+
/*
* First create IP6 pseudo header and calculate a summary.
*/
@@ -150,7 +151,7 @@ in6_cksum(m, nxt, off, len)
sum += w[0];
if (!IN6_IS_SCOPE_LINKLOCAL(&ip6->ip6_src))
sum += w[1];
- sum += w[2]; sum += w[3]; sum += w[4]; sum += w[5];
+ sum += w[2]; sum += w[3]; sum += w[4]; sum += w[5];
sum += w[6]; sum += w[7];
/* IPv6 destination address */
sum += w[8];
@@ -246,7 +247,7 @@ in6_cksum(m, nxt, off, len)
* of a word spanning between this mbuf and the
* last mbuf.
*
- * s_util.c[0] is already saved when scanning previous
+ * s_util.c[0] is already saved when scanning previous
* mbuf.
*/
s_util.c[1] = *(char *)w;