Skip to content

Commit 4576039

Browse files
tcheneaudavem330
authored andcommitted
6lowpan: Change byte order when storing/accessing u16 tag
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d4787a1 commit 4576039

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

net/ieee802154/6lowpan.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ static inline int lowpan_fetch_skb_u16(struct sk_buff *skb, u16 *val)
302302
if (unlikely(!pskb_may_pull(skb, 2)))
303303
return -EINVAL;
304304

305-
*val = skb->data[0] | (skb->data[1] << 8);
305+
*val = (skb->data[0] << 8) | skb->data[1];
306306
skb_pull(skb, 2);
307307

308308
return 0;
@@ -1006,8 +1006,8 @@ lowpan_skb_fragmentation(struct sk_buff *skb)
10061006
/* first fragment header */
10071007
head[0] = LOWPAN_DISPATCH_FRAG1 | (payload_length & 0x7);
10081008
head[1] = (payload_length >> 3) & 0xff;
1009-
head[2] = tag & 0xff;
1010-
head[3] = tag >> 8;
1009+
head[2] = tag >> 8;
1010+
head[3] = tag & 0xff;
10111011

10121012
err = lowpan_fragment_xmit(skb, head, header_length, 0, 0);
10131013

0 commit comments

Comments
 (0)