All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tony Cheneau <tony.cheneau@amnesiak.org>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org,
	Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
Subject: [PATCH net-next v3 2/3] 6lowpan: Change byte order when storing/accessing u16 tag
Date: Wed, 11 Jul 2012 12:51:15 -0400	[thread overview]
Message-ID: <1342025476-20949-3-git-send-email-tony.cheneau@amnesiak.org> (raw)
In-Reply-To: <1342025476-20949-1-git-send-email-tony.cheneau@amnesiak.org>

The tag field should be stored and accessed using big endian byte order (as
intended in the specs). Or else, when displayed with a trafic analyser, such a
Wireshark, the field not properly displayed (e.g. 0x01 00 instead of 0x00 01,
and so on).

Signed-off-by: Tony Cheneau <tony.cheneau@amnesiak.org>
---
 net/ieee802154/6lowpan.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
index 0c9f6d1..9de1ece 100644
--- a/net/ieee802154/6lowpan.c
+++ b/net/ieee802154/6lowpan.c
@@ -303,7 +303,7 @@ static inline int lowpan_fetch_skb_u16(struct sk_buff *skb, u16 *val)
 	if (unlikely(!pskb_may_pull(skb, 2)))
 		return -EINVAL;
 
-	*val = skb->data[0] | (skb->data[1] << 8);
+	*val = (skb->data[0] << 8) | skb->data[1];
 	skb_pull(skb, 2);
 
 	return 0;
@@ -1010,8 +1010,8 @@ lowpan_skb_fragmentation(struct sk_buff *skb)
 	/* first fragment header */
 	head[0] = LOWPAN_DISPATCH_FRAG1 | (payload_length & 0x7);
 	head[1] = (payload_length >> 3) & 0xff;
-	head[2] = tag & 0xff;
-	head[3] = tag >> 8;
+	head[2] = tag >> 8;
+	head[3] = tag & 0xff;
 
 	err = lowpan_fragment_xmit(skb, head, header_length, 0, 0);
 
-- 
1.7.3.4

  parent reply	other threads:[~2012-07-11 16:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-11 16:51 [PATCH net-next v3 0/3] 6lowpan: Various bug fixes Tony Cheneau
2012-07-11 16:51 ` [PATCH net-next v3 1/3] 6lowpan: Fix null pointer dereference in UDP uncompression function Tony Cheneau
2012-07-11 16:51 ` Tony Cheneau [this message]
2012-07-11 16:51 ` [PATCH net-next v3 3/3] 6lowpan: Change byte order when storing/accessing to len field Tony Cheneau
2012-07-17  5:52 ` [PATCH net-next v3 0/3] 6lowpan: Various bug fixes David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1342025476-20949-3-git-send-email-tony.cheneau@amnesiak.org \
    --to=tony.cheneau@amnesiak.org \
    --cc=alex.bluesman.smirnov@gmail.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.