summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2010-03-31 22:47:55 +0000
committermav <mav@FreeBSD.org>2010-03-31 22:47:55 +0000
commit636a35a886cdc058e44b0e076917e3b4eda62947 (patch)
tree81dd1e512f5f22836a9a4b6bcaee4f19c46c672e
parent4cf5e5ba4b623f3d41661d7252d884bd65f329cf (diff)
downloadFreeBSD-src-636a35a886cdc058e44b0e076917e3b4eda62947.zip
FreeBSD-src-636a35a886cdc058e44b0e076917e3b4eda62947.tar.gz
Remove some more alignment constraints.
-rw-r--r--sys/netgraph/ng_mppc.c6
-rw-r--r--sys/netgraph/ng_ppp.c9
2 files changed, 8 insertions, 7 deletions
diff --git a/sys/netgraph/ng_mppc.c b/sys/netgraph/ng_mppc.c
index e934481..074c018 100644
--- a/sys/netgraph/ng_mppc.c
+++ b/sys/netgraph/ng_mppc.c
@@ -53,6 +53,7 @@
#include <sys/kernel.h>
#include <sys/mbuf.h>
#include <sys/malloc.h>
+#include <sys/endian.h>
#include <sys/errno.h>
#include <sys/syslog.h>
@@ -601,7 +602,7 @@ err1:
/* Install header */
M_PREPEND(m, MPPC_HDRLEN, M_DONTWAIT);
if (m != NULL)
- *(mtod(m, uint16_t *)) = htons(header);
+ be16enc(mtod(m, void *), header);
*datap = m;
return (*datap == NULL ? ENOBUFS : 0);
@@ -630,8 +631,7 @@ ng_mppc_decompress(node_p node, struct mbuf **datap)
m_freem(m);
return (EINVAL);
}
- m_copydata(m, 0, MPPC_HDRLEN, (caddr_t)&header);
- header = ntohs(header);
+ header = be16dec(mtod(m, void *));
cc = (header & MPPC_CCOUNT_MASK);
m_adj(m, MPPC_HDRLEN);
diff --git a/sys/netgraph/ng_ppp.c b/sys/netgraph/ng_ppp.c
index ec3ed82..e5897f3 100644
--- a/sys/netgraph/ng_ppp.c
+++ b/sys/netgraph/ng_ppp.c
@@ -97,6 +97,7 @@
#include <sys/time.h>
#include <sys/mbuf.h>
#include <sys/malloc.h>
+#include <sys/endian.h>
#include <sys/errno.h>
#include <sys/ctype.h>
@@ -860,8 +861,8 @@ ng_ppp_rcvdata_bypass(hook_p hook, item_p item)
NG_FREE_ITEM(item);
return (ENOBUFS);
}
- linkNum = ntohs(mtod(m, uint16_t *)[0]);
- proto = ntohs(mtod(m, uint16_t *)[1]);
+ linkNum = be16dec(mtod(m, uint8_t *));
+ proto = be16dec(mtod(m, uint8_t *) + 2);
m_adj(m, 4);
NGI_M(item) = m;
@@ -1544,7 +1545,7 @@ ng_ppp_mp_recv(node_p node, item_p item, uint16_t proto, uint16_t linkNum)
if (m->m_len < 2 && (m = m_pullup(m, 2)) == NULL)
ERROUT(ENOBUFS);
- shdr = ntohs(*mtod(m, uint16_t *));
+ shdr = be16dec(mtod(m, void *));
frag->seq = MP_SHORT_EXTEND(shdr);
frag->first = (shdr & MP_SHORT_FIRST_FLAG) != 0;
frag->last = (shdr & MP_SHORT_LAST_FLAG) != 0;
@@ -1561,7 +1562,7 @@ ng_ppp_mp_recv(node_p node, item_p item, uint16_t proto, uint16_t linkNum)
if (m->m_len < 4 && (m = m_pullup(m, 4)) == NULL)
ERROUT(ENOBUFS);
- lhdr = ntohl(*mtod(m, uint32_t *));
+ lhdr = be32dec(mtod(m, void *));
frag->seq = MP_LONG_EXTEND(lhdr);
frag->first = (lhdr & MP_LONG_FIRST_FLAG) != 0;
frag->last = (lhdr & MP_LONG_LAST_FLAG) != 0;
OpenPOWER on IntegriCloud