aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Aring <alex.aring@gmail.com>2014-11-17 02:20:55 -0500
committerMarcel Holtmann <marcel@holtmann.org>2014-11-17 03:49:17 -0500
commitee7b9053bd69ff43cbc87a9bb987f4d92dc2c29f (patch)
treeeef6377b4bc5f6c76fffa547ee4d0872c58e8f3a
parentcb41c8dd01d74d091618f72e28f0282f064a9f0a (diff)
ieee802154: fix byteorder for short address and panid
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>
-rw-r--r--include/net/cfg802154.h4
-rw-r--r--net/ieee802154/nl802154.c8
-rw-r--r--net/ieee802154/rdev-ops.h4
-rw-r--r--net/mac802154/cfg.c14
4 files changed, 15 insertions, 15 deletions
diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h
index 228f1f7668f7..7f713acfa106 100644
--- a/include/net/cfg802154.h
+++ b/include/net/cfg802154.h
@@ -40,9 +40,9 @@ struct cfg802154_ops {
40 struct wpan_dev *wpan_dev); 40 struct wpan_dev *wpan_dev);
41 int (*set_channel)(struct wpan_phy *wpan_phy, u8 page, u8 channel); 41 int (*set_channel)(struct wpan_phy *wpan_phy, u8 page, u8 channel);
42 int (*set_pan_id)(struct wpan_phy *wpan_phy, 42 int (*set_pan_id)(struct wpan_phy *wpan_phy,
43 struct wpan_dev *wpan_dev, u16 pan_id); 43 struct wpan_dev *wpan_dev, __le16 pan_id);
44 int (*set_short_addr)(struct wpan_phy *wpan_phy, 44 int (*set_short_addr)(struct wpan_phy *wpan_phy,
45 struct wpan_dev *wpan_dev, u16 short_addr); 45 struct wpan_dev *wpan_dev, __le16 short_addr);
46 int (*set_backoff_exponent)(struct wpan_phy *wpan_phy, 46 int (*set_backoff_exponent)(struct wpan_phy *wpan_phy,
47 struct wpan_dev *wpan_dev, u8 min_be, 47 struct wpan_dev *wpan_dev, u8 min_be,
48 u8 max_be); 48 u8 max_be);
diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c
index b82b01669a67..889647744697 100644
--- a/net/ieee802154/nl802154.c
+++ b/net/ieee802154/nl802154.c
@@ -627,7 +627,7 @@ static int nl802154_set_pan_id(struct sk_buff *skb, struct genl_info *info)
627 struct cfg802154_registered_device *rdev = info->user_ptr[0]; 627 struct cfg802154_registered_device *rdev = info->user_ptr[0];
628 struct net_device *dev = info->user_ptr[1]; 628 struct net_device *dev = info->user_ptr[1];
629 struct wpan_dev *wpan_dev = dev->ieee802154_ptr; 629 struct wpan_dev *wpan_dev = dev->ieee802154_ptr;
630 u16 pan_id; 630 __le16 pan_id;
631 631
632 /* conflict here while tx/rx calls */ 632 /* conflict here while tx/rx calls */
633 if (netif_running(dev)) 633 if (netif_running(dev))
@@ -640,7 +640,7 @@ static int nl802154_set_pan_id(struct sk_buff *skb, struct genl_info *info)
640 if (!info->attrs[NL802154_ATTR_PAN_ID]) 640 if (!info->attrs[NL802154_ATTR_PAN_ID])
641 return -EINVAL; 641 return -EINVAL;
642 642
643 pan_id = nla_get_u16(info->attrs[NL802154_ATTR_PAN_ID]); 643 pan_id = nla_get_le16(info->attrs[NL802154_ATTR_PAN_ID]);
644 644
645 return rdev_set_pan_id(rdev, wpan_dev, pan_id); 645 return rdev_set_pan_id(rdev, wpan_dev, pan_id);
646} 646}
@@ -650,7 +650,7 @@ static int nl802154_set_short_addr(struct sk_buff *skb, struct genl_info *info)
650 struct cfg802154_registered_device *rdev = info->user_ptr[0]; 650 struct cfg802154_registered_device *rdev = info->user_ptr[0];
651 struct net_device *dev = info->user_ptr[1]; 651 struct net_device *dev = info->user_ptr[1];
652 struct wpan_dev *wpan_dev = dev->ieee802154_ptr; 652 struct wpan_dev *wpan_dev = dev->ieee802154_ptr;
653 u16 short_addr; 653 __le16 short_addr;
654 654
655 /* conflict here while tx/rx calls */ 655 /* conflict here while tx/rx calls */
656 if (netif_running(dev)) 656 if (netif_running(dev))
@@ -663,7 +663,7 @@ static int nl802154_set_short_addr(struct sk_buff *skb, struct genl_info *info)
663 if (!info->attrs[NL802154_ATTR_SHORT_ADDR]) 663 if (!info->attrs[NL802154_ATTR_SHORT_ADDR])
664 return -EINVAL; 664 return -EINVAL;
665 665
666 short_addr = nla_get_u16(info->attrs[NL802154_ATTR_SHORT_ADDR]); 666 short_addr = nla_get_le16(info->attrs[NL802154_ATTR_SHORT_ADDR]);
667 667
668 return rdev_set_short_addr(rdev, wpan_dev, short_addr); 668 return rdev_set_short_addr(rdev, wpan_dev, short_addr);
669} 669}
diff --git a/net/ieee802154/rdev-ops.h b/net/ieee802154/rdev-ops.h
index 40ffbc0d8b85..aff54fbd9264 100644
--- a/net/ieee802154/rdev-ops.h
+++ b/net/ieee802154/rdev-ops.h
@@ -43,14 +43,14 @@ rdev_set_channel(struct cfg802154_registered_device *rdev, u8 page, u8 channel)
43 43
44static inline int 44static inline int
45rdev_set_pan_id(struct cfg802154_registered_device *rdev, 45rdev_set_pan_id(struct cfg802154_registered_device *rdev,
46 struct wpan_dev *wpan_dev, u16 pan_id) 46 struct wpan_dev *wpan_dev, __le16 pan_id)
47{ 47{
48 return rdev->ops->set_pan_id(&rdev->wpan_phy, wpan_dev, pan_id); 48 return rdev->ops->set_pan_id(&rdev->wpan_phy, wpan_dev, pan_id);
49} 49}
50 50
51static inline int 51static inline int
52rdev_set_short_addr(struct cfg802154_registered_device *rdev, 52rdev_set_short_addr(struct cfg802154_registered_device *rdev,
53 struct wpan_dev *wpan_dev, u16 short_addr) 53 struct wpan_dev *wpan_dev, __le16 short_addr)
54{ 54{
55 return rdev->ops->set_short_addr(&rdev->wpan_phy, wpan_dev, short_addr); 55 return rdev->ops->set_short_addr(&rdev->wpan_phy, wpan_dev, short_addr);
56} 56}
diff --git a/net/mac802154/cfg.c b/net/mac802154/cfg.c
index 7def2625eaca..c035708ada16 100644
--- a/net/mac802154/cfg.c
+++ b/net/mac802154/cfg.c
@@ -88,7 +88,7 @@ ieee802154_set_channel(struct wpan_phy *wpan_phy, u8 page, u8 channel)
88 88
89static int 89static int
90ieee802154_set_pan_id(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev, 90ieee802154_set_pan_id(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
91 u16 pan_id) 91 __le16 pan_id)
92{ 92{
93 ASSERT_RTNL(); 93 ASSERT_RTNL();
94 94
@@ -99,10 +99,10 @@ ieee802154_set_pan_id(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
99 * 99 *
100 * This could useful to simple deassociate an device. 100 * This could useful to simple deassociate an device.
101 */ 101 */
102 if (pan_id == IEEE802154_PAN_ID_BROADCAST) 102 if (pan_id == cpu_to_le16(IEEE802154_PAN_ID_BROADCAST))
103 return -EINVAL; 103 return -EINVAL;
104 104
105 wpan_dev->pan_id = cpu_to_le16(pan_id); 105 wpan_dev->pan_id = pan_id;
106 return 0; 106 return 0;
107} 107}
108 108
@@ -125,7 +125,7 @@ ieee802154_set_backoff_exponent(struct wpan_phy *wpan_phy,
125 125
126static int 126static int
127ieee802154_set_short_addr(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev, 127ieee802154_set_short_addr(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
128 u16 short_addr) 128 __le16 short_addr)
129{ 129{
130 ASSERT_RTNL(); 130 ASSERT_RTNL();
131 131
@@ -140,11 +140,11 @@ ieee802154_set_short_addr(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
140 * I think we should allow to set these settings but 140 * I think we should allow to set these settings but
141 * don't allow to allow socket communication with it. 141 * don't allow to allow socket communication with it.
142 */ 142 */
143 if (short_addr == IEEE802154_ADDR_SHORT_UNSPEC || 143 if (short_addr == cpu_to_le16(IEEE802154_ADDR_SHORT_UNSPEC) ||
144 short_addr == IEEE802154_ADDR_SHORT_BROADCAST) 144 short_addr == cpu_to_le16(IEEE802154_ADDR_SHORT_BROADCAST))
145 return -EINVAL; 145 return -EINVAL;
146 146
147 wpan_dev->short_addr = cpu_to_le16(short_addr); 147 wpan_dev->short_addr = short_addr;
148 return 0; 148 return 0;
149} 149}
150 150