aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Aring <alex.aring@gmail.com>2015-05-17 15:44:38 -0400
committerMarcel Holtmann <marcel@holtmann.org>2015-05-19 05:44:41 -0400
commit673692faf3fb42ec73ef7210238b5869d6e2873d (patch)
tree9de5b9e4408ec6de1b29bea56728adb4d9a6bbc5
parent0cf0879acdbeff695963d78940b89497803ae55c (diff)
ieee802154: move validation check out of softmac
This patch moves the value validation out of softmac layer. We need to be sure now that this value is accepted by the transceiver/mac802154 or "possible" hardmac drivers before calling rdev-ops. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
-rw-r--r--net/ieee802154/nl802154.c28
-rw-r--r--net/mac802154/cfg.c29
2 files changed, 27 insertions, 30 deletions
diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c
index c01f4bbe7c7c..d750d9778ba7 100644
--- a/net/ieee802154/nl802154.c
+++ b/net/ieee802154/nl802154.c
@@ -625,7 +625,8 @@ static int nl802154_set_channel(struct sk_buff *skb, struct genl_info *info)
625 channel = nla_get_u8(info->attrs[NL802154_ATTR_CHANNEL]); 625 channel = nla_get_u8(info->attrs[NL802154_ATTR_CHANNEL]);
626 626
627 /* check 802.15.4 constraints */ 627 /* check 802.15.4 constraints */
628 if (page > IEEE802154_MAX_PAGE || channel > IEEE802154_MAX_CHANNEL) 628 if (page > IEEE802154_MAX_PAGE || channel > IEEE802154_MAX_CHANNEL ||
629 !(rdev->wpan_phy.channels_supported[page] & BIT(channel)))
629 return -EINVAL; 630 return -EINVAL;
630 631
631 return rdev_set_channel(rdev, page, channel); 632 return rdev_set_channel(rdev, page, channel);
@@ -674,6 +675,16 @@ static int nl802154_set_pan_id(struct sk_buff *skb, struct genl_info *info)
674 675
675 pan_id = nla_get_le16(info->attrs[NL802154_ATTR_PAN_ID]); 676 pan_id = nla_get_le16(info->attrs[NL802154_ATTR_PAN_ID]);
676 677
678 /* TODO
679 * I am not sure about to check here on broadcast pan_id.
680 * Broadcast is a valid setting, comment from 802.15.4:
681 * If this value is 0xffff, the device is not associated.
682 *
683 * This could useful to simple deassociate an device.
684 */
685 if (pan_id == cpu_to_le16(IEEE802154_PAN_ID_BROADCAST))
686 return -EINVAL;
687
677 return rdev_set_pan_id(rdev, wpan_dev, pan_id); 688 return rdev_set_pan_id(rdev, wpan_dev, pan_id);
678} 689}
679 690
@@ -695,6 +706,21 @@ static int nl802154_set_short_addr(struct sk_buff *skb, struct genl_info *info)
695 706
696 short_addr = nla_get_le16(info->attrs[NL802154_ATTR_SHORT_ADDR]); 707 short_addr = nla_get_le16(info->attrs[NL802154_ATTR_SHORT_ADDR]);
697 708
709 /* TODO
710 * I am not sure about to check here on broadcast short_addr.
711 * Broadcast is a valid setting, comment from 802.15.4:
712 * A value of 0xfffe indicates that the device has
713 * associated but has not been allocated an address. A
714 * value of 0xffff indicates that the device does not
715 * have a short address.
716 *
717 * I think we should allow to set these settings but
718 * don't allow to allow socket communication with it.
719 */
720 if (short_addr == cpu_to_le16(IEEE802154_ADDR_SHORT_UNSPEC) ||
721 short_addr == cpu_to_le16(IEEE802154_ADDR_SHORT_BROADCAST))
722 return -EINVAL;
723
698 return rdev_set_short_addr(rdev, wpan_dev, short_addr); 724 return rdev_set_short_addr(rdev, wpan_dev, short_addr);
699} 725}
700 726
diff --git a/net/mac802154/cfg.c b/net/mac802154/cfg.c
index 70be9c799f8a..c63601582c71 100644
--- a/net/mac802154/cfg.c
+++ b/net/mac802154/cfg.c
@@ -73,10 +73,6 @@ ieee802154_set_channel(struct wpan_phy *wpan_phy, u8 page, u8 channel)
73 73
74 ASSERT_RTNL(); 74 ASSERT_RTNL();
75 75
76 /* check if phy support this setting */
77 if (!(wpan_phy->channels_supported[page] & BIT(channel)))
78 return -EINVAL;
79
80 ret = drv_set_channel(local, page, channel); 76 ret = drv_set_channel(local, page, channel);
81 if (!ret) { 77 if (!ret) {
82 wpan_phy->current_page = page; 78 wpan_phy->current_page = page;
@@ -112,16 +108,6 @@ ieee802154_set_pan_id(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
112{ 108{
113 ASSERT_RTNL(); 109 ASSERT_RTNL();
114 110
115 /* TODO
116 * I am not sure about to check here on broadcast pan_id.
117 * Broadcast is a valid setting, comment from 802.15.4:
118 * If this value is 0xffff, the device is not associated.
119 *
120 * This could useful to simple deassociate an device.
121 */
122 if (pan_id == cpu_to_le16(IEEE802154_PAN_ID_BROADCAST))
123 return -EINVAL;
124
125 wpan_dev->pan_id = pan_id; 111 wpan_dev->pan_id = pan_id;
126 return 0; 112 return 0;
127} 113}
@@ -149,21 +135,6 @@ ieee802154_set_short_addr(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
149{ 135{
150 ASSERT_RTNL(); 136 ASSERT_RTNL();
151 137
152 /* TODO
153 * I am not sure about to check here on broadcast short_addr.
154 * Broadcast is a valid setting, comment from 802.15.4:
155 * A value of 0xfffe indicates that the device has
156 * associated but has not been allocated an address. A
157 * value of 0xffff indicates that the device does not
158 * have a short address.
159 *
160 * I think we should allow to set these settings but
161 * don't allow to allow socket communication with it.
162 */
163 if (short_addr == cpu_to_le16(IEEE802154_ADDR_SHORT_UNSPEC) ||
164 short_addr == cpu_to_le16(IEEE802154_ADDR_SHORT_BROADCAST))
165 return -EINVAL;
166
167 wpan_dev->short_addr = short_addr; 138 wpan_dev->short_addr = short_addr;
168 return 0; 139 return 0;
169} 140}