Skip to content

Commit

Permalink
mac802154: iface: assume big endian for af_packet
Browse files Browse the repository at this point in the history
The callback "create" and "parse" from header_ops are called from
netdev core upper-layer functionality, like af_packet. These callbacks
assumes big endian for addresses and we should not introduce a special
byteordering handling for ieee802154 over af_packet in userspace.

We have an identical issue with setting the mac address which also
assumes big endian byteordering.

Signed-off-by: Alexander Aring <[email protected]>
Signed-off-by: Marcel Holtmann <[email protected]>
  • Loading branch information
alexaring authored and holtmann committed Sep 24, 2015
1 parent f856f21 commit c2d5ecf
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions net/mac802154/iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,16 +461,15 @@ static int mac802154_header_create(struct sk_buff *skb,

hdr.dest.pan_id = wpan_dev->pan_id;
hdr.dest.mode = IEEE802154_ADDR_LONG;
memcpy(&hdr.dest.extended_addr, daddr, IEEE802154_EXTENDED_ADDR_LEN);
ieee802154_be64_to_le64(&hdr.dest.extended_addr, daddr);

hdr.source.pan_id = hdr.dest.pan_id;
hdr.source.mode = IEEE802154_ADDR_LONG;

if (!saddr)
hdr.source.extended_addr = wpan_dev->extended_addr;
else
memcpy(&hdr.source.extended_addr, saddr,
IEEE802154_EXTENDED_ADDR_LEN);
ieee802154_be64_to_le64(&hdr.source.extended_addr, saddr);

hlen = ieee802154_hdr_push(skb, &hdr);
if (hlen < 0)
Expand All @@ -496,8 +495,7 @@ mac802154_header_parse(const struct sk_buff *skb, unsigned char *haddr)
}

if (hdr.source.mode == IEEE802154_ADDR_LONG) {
memcpy(haddr, &hdr.source.extended_addr,
IEEE802154_EXTENDED_ADDR_LEN);
ieee802154_le64_to_be64(haddr, &hdr.source.extended_addr);
return IEEE802154_EXTENDED_ADDR_LEN;
}

Expand Down

0 comments on commit c2d5ecf

Please sign in to comment.