svn commit: r206049 - head/sys/netgraph

Alexander Motin mav at FreeBSD.org
Thu Apr 1 16:18:16 UTC 2010


Author: mav
Date: Thu Apr  1 16:18:16 2010
New Revision: 206049
URL: http://svn.freebsd.org/changeset/base/206049

Log:
  Remove alignment constraints.

Modified:
  head/sys/netgraph/ng_deflate.c

Modified: head/sys/netgraph/ng_deflate.c
==============================================================================
--- head/sys/netgraph/ng_deflate.c	Thu Apr  1 15:37:38 2010	(r206048)
+++ head/sys/netgraph/ng_deflate.c	Thu Apr  1 16:18:16 2010	(r206049)
@@ -36,6 +36,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>
 
@@ -505,8 +506,8 @@ ng_deflate_compress(node_p node, struct 
 		priv->stats.OutOctets+=inlen;
 	} else {
 		/* Install header. */
-		((u_int16_t *)priv->outbuf)[0] = htons(PROT_COMPD);
-		((u_int16_t *)priv->outbuf)[1] = htons(priv->seqnum);
+		be16enc(priv->outbuf, PROT_COMPD);
+		be16enc(priv->outbuf + 2, priv->seqnum);
 
 		/* Return packet in an mbuf. */
 		m_copyback(m, 0, outlen, (caddr_t)priv->outbuf);
@@ -568,7 +569,7 @@ ng_deflate_decompress(node_p node, struc
 		proto = priv->inbuf[0];
 		offset = 1;
 	} else {
-		proto = ntohs(((uint16_t *)priv->inbuf)[0]);
+		proto = be16dec(priv->inbuf);
 		offset = 2;
 	}
 
@@ -579,7 +580,7 @@ ng_deflate_decompress(node_p node, struc
 		priv->stats.FramesComp++;
 
 		/* Check sequence number. */
-		rseqnum = ntohs(((uint16_t *)(priv->inbuf + offset))[0]);
+		rseqnum = be16dec(priv->inbuf + offset);
 		offset += 2;
 		if (rseqnum != priv->seqnum) {
 			priv->stats.Errors++;


More information about the svn-src-head mailing list