Skip to content

Commit

Permalink
6lowpan: Change byte order when storing/accessing u16 tag
Browse files Browse the repository at this point in the history
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Tony Cheneau authored and David S. Miller committed Jul 17, 2012
1 parent d4787a1 commit 4576039
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions net/ieee802154/6lowpan.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,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;
Expand Down Expand Up @@ -1006,8 +1006,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);

Expand Down

0 comments on commit 4576039

Please sign in to comment.