Skip to content

Commit

Permalink
ieee802154: fix byteorder for short address and panid
Browse files Browse the repository at this point in the history
This patch changes the byteorder handling for short and panid handling.
We now except to get little endian in nl802154 for these attributes.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
  • Loading branch information
Alexander Aring authored and Marcel Holtmann committed Nov 17, 2014
1 parent cb41c8d commit ee7b905
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions include/net/cfg802154.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ struct cfg802154_ops {
struct wpan_dev *wpan_dev);
int (*set_channel)(struct wpan_phy *wpan_phy, u8 page, u8 channel);
int (*set_pan_id)(struct wpan_phy *wpan_phy,
struct wpan_dev *wpan_dev, u16 pan_id);
struct wpan_dev *wpan_dev, __le16 pan_id);
int (*set_short_addr)(struct wpan_phy *wpan_phy,
struct wpan_dev *wpan_dev, u16 short_addr);
struct wpan_dev *wpan_dev, __le16 short_addr);
int (*set_backoff_exponent)(struct wpan_phy *wpan_phy,
struct wpan_dev *wpan_dev, u8 min_be,
u8 max_be);
Expand Down
8 changes: 4 additions & 4 deletions net/ieee802154/nl802154.c
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ static int nl802154_set_pan_id(struct sk_buff *skb, struct genl_info *info)
struct cfg802154_registered_device *rdev = info->user_ptr[0];
struct net_device *dev = info->user_ptr[1];
struct wpan_dev *wpan_dev = dev->ieee802154_ptr;
u16 pan_id;
__le16 pan_id;

/* conflict here while tx/rx calls */
if (netif_running(dev))
Expand All @@ -640,7 +640,7 @@ static int nl802154_set_pan_id(struct sk_buff *skb, struct genl_info *info)
if (!info->attrs[NL802154_ATTR_PAN_ID])
return -EINVAL;

pan_id = nla_get_u16(info->attrs[NL802154_ATTR_PAN_ID]);
pan_id = nla_get_le16(info->attrs[NL802154_ATTR_PAN_ID]);

return rdev_set_pan_id(rdev, wpan_dev, pan_id);
}
Expand All @@ -650,7 +650,7 @@ static int nl802154_set_short_addr(struct sk_buff *skb, struct genl_info *info)
struct cfg802154_registered_device *rdev = info->user_ptr[0];
struct net_device *dev = info->user_ptr[1];
struct wpan_dev *wpan_dev = dev->ieee802154_ptr;
u16 short_addr;
__le16 short_addr;

/* conflict here while tx/rx calls */
if (netif_running(dev))
Expand All @@ -663,7 +663,7 @@ static int nl802154_set_short_addr(struct sk_buff *skb, struct genl_info *info)
if (!info->attrs[NL802154_ATTR_SHORT_ADDR])
return -EINVAL;

short_addr = nla_get_u16(info->attrs[NL802154_ATTR_SHORT_ADDR]);
short_addr = nla_get_le16(info->attrs[NL802154_ATTR_SHORT_ADDR]);

return rdev_set_short_addr(rdev, wpan_dev, short_addr);
}
Expand Down
4 changes: 2 additions & 2 deletions net/ieee802154/rdev-ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ rdev_set_channel(struct cfg802154_registered_device *rdev, u8 page, u8 channel)

static inline int
rdev_set_pan_id(struct cfg802154_registered_device *rdev,
struct wpan_dev *wpan_dev, u16 pan_id)
struct wpan_dev *wpan_dev, __le16 pan_id)
{
return rdev->ops->set_pan_id(&rdev->wpan_phy, wpan_dev, pan_id);
}

static inline int
rdev_set_short_addr(struct cfg802154_registered_device *rdev,
struct wpan_dev *wpan_dev, u16 short_addr)
struct wpan_dev *wpan_dev, __le16 short_addr)
{
return rdev->ops->set_short_addr(&rdev->wpan_phy, wpan_dev, short_addr);
}
Expand Down
14 changes: 7 additions & 7 deletions net/mac802154/cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ ieee802154_set_channel(struct wpan_phy *wpan_phy, u8 page, u8 channel)

static int
ieee802154_set_pan_id(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
u16 pan_id)
__le16 pan_id)
{
ASSERT_RTNL();

Expand All @@ -99,10 +99,10 @@ ieee802154_set_pan_id(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
*
* This could useful to simple deassociate an device.
*/
if (pan_id == IEEE802154_PAN_ID_BROADCAST)
if (pan_id == cpu_to_le16(IEEE802154_PAN_ID_BROADCAST))
return -EINVAL;

wpan_dev->pan_id = cpu_to_le16(pan_id);
wpan_dev->pan_id = pan_id;
return 0;
}

Expand All @@ -125,7 +125,7 @@ ieee802154_set_backoff_exponent(struct wpan_phy *wpan_phy,

static int
ieee802154_set_short_addr(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
u16 short_addr)
__le16 short_addr)
{
ASSERT_RTNL();

Expand All @@ -140,11 +140,11 @@ ieee802154_set_short_addr(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
* I think we should allow to set these settings but
* don't allow to allow socket communication with it.
*/
if (short_addr == IEEE802154_ADDR_SHORT_UNSPEC ||
short_addr == IEEE802154_ADDR_SHORT_BROADCAST)
if (short_addr == cpu_to_le16(IEEE802154_ADDR_SHORT_UNSPEC) ||
short_addr == cpu_to_le16(IEEE802154_ADDR_SHORT_BROADCAST))
return -EINVAL;

wpan_dev->short_addr = cpu_to_le16(short_addr);
wpan_dev->short_addr = short_addr;
return 0;
}

Expand Down

0 comments on commit ee7b905

Please sign in to comment.