svn commit: r206021 - head/sys/netgraph
Alexander Motin
mav at FreeBSD.org
Wed Mar 31 22:47:56 UTC 2010
Author: mav
Date: Wed Mar 31 22:47:55 2010
New Revision: 206021
URL: http://svn.freebsd.org/changeset/base/206021
Log:
Remove some more alignment constraints.
Modified:
head/sys/netgraph/ng_mppc.c
head/sys/netgraph/ng_ppp.c
Modified: head/sys/netgraph/ng_mppc.c
==============================================================================
--- head/sys/netgraph/ng_mppc.c Wed Mar 31 22:32:56 2010 (r206020)
+++ head/sys/netgraph/ng_mppc.c Wed Mar 31 22:47:55 2010 (r206021)
@@ -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 m
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);
Modified: head/sys/netgraph/ng_ppp.c
==============================================================================
--- head/sys/netgraph/ng_ppp.c Wed Mar 31 22:32:56 2010 (r206020)
+++ head/sys/netgraph/ng_ppp.c Wed Mar 31 22:47:55 2010 (r206021)
@@ -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_
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,
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,
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;
More information about the svn-src-all
mailing list