nl802154.c (7fe9a3882bb37195c41ab125a0f2852398d2646a) nl802154.c (ba2a9506a76450568cbc0d51626d94cf8528c0c7)
1/* This program is free software; you can redistribute it and/or modify
2 * it under the terms of the GNU General Public License version 2
3 * as published by the Free Software Foundation.
4 *
5 * This program is distributed in the hope that it will be useful,
6 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8 * GNU General Public License for more details.

--- 195 unchanged lines hidden (view full) ---

204
205 [NL802154_ATTR_WPAN_DEV] = { .type = NLA_U64 },
206
207 [NL802154_ATTR_PAGE] = { .type = NLA_U8, },
208 [NL802154_ATTR_CHANNEL] = { .type = NLA_U8, },
209
210 [NL802154_ATTR_TX_POWER] = { .type = NLA_S8, },
211
1/* This program is free software; you can redistribute it and/or modify
2 * it under the terms of the GNU General Public License version 2
3 * as published by the Free Software Foundation.
4 *
5 * This program is distributed in the hope that it will be useful,
6 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8 * GNU General Public License for more details.

--- 195 unchanged lines hidden (view full) ---

204
205 [NL802154_ATTR_WPAN_DEV] = { .type = NLA_U64 },
206
207 [NL802154_ATTR_PAGE] = { .type = NLA_U8, },
208 [NL802154_ATTR_CHANNEL] = { .type = NLA_U8, },
209
210 [NL802154_ATTR_TX_POWER] = { .type = NLA_S8, },
211
212 [NL802154_ATTR_CCA_MODE] = { .type = NLA_U8, },
212 [NL802154_ATTR_CCA_MODE] = { .type = NLA_U32, },
213 [NL802154_ATTR_CCA_OPT] = { .type = NLA_U32, },
213
214 [NL802154_ATTR_SUPPORTED_CHANNEL] = { .type = NLA_U32, },
215
216 [NL802154_ATTR_PAN_ID] = { .type = NLA_U16, },
217 [NL802154_ATTR_EXTENDED_ADDR] = { .type = NLA_U64 },
218 [NL802154_ATTR_SHORT_ADDR] = { .type = NLA_U16, },
219
220 [NL802154_ATTR_MIN_BE] = { .type = NLA_U8, },

--- 64 unchanged lines hidden (view full) ---

285 rdev->wpan_phy.current_channel))
286 goto nla_put_failure;
287
288 /* supported channels array */
289 if (nl802154_send_wpan_phy_channels(rdev, msg))
290 goto nla_put_failure;
291
292 /* cca mode */
214
215 [NL802154_ATTR_SUPPORTED_CHANNEL] = { .type = NLA_U32, },
216
217 [NL802154_ATTR_PAN_ID] = { .type = NLA_U16, },
218 [NL802154_ATTR_EXTENDED_ADDR] = { .type = NLA_U64 },
219 [NL802154_ATTR_SHORT_ADDR] = { .type = NLA_U16, },
220
221 [NL802154_ATTR_MIN_BE] = { .type = NLA_U8, },

--- 64 unchanged lines hidden (view full) ---

286 rdev->wpan_phy.current_channel))
287 goto nla_put_failure;
288
289 /* supported channels array */
290 if (nl802154_send_wpan_phy_channels(rdev, msg))
291 goto nla_put_failure;
292
293 /* cca mode */
293 if (nla_put_u8(msg, NL802154_ATTR_CCA_MODE,
294 rdev->wpan_phy.cca.mode))
294 if (nla_put_u32(msg, NL802154_ATTR_CCA_MODE,
295 rdev->wpan_phy.cca.mode))
295 goto nla_put_failure;
296
296 goto nla_put_failure;
297
298 if (rdev->wpan_phy.cca.mode == NL802154_CCA_ENERGY_CARRIER) {
299 if (nla_put_u32(msg, NL802154_ATTR_CCA_OPT,
300 rdev->wpan_phy.cca.opt))
301 goto nla_put_failure;
302 }
303
297 if (nla_put_s8(msg, NL802154_ATTR_TX_POWER,
298 rdev->wpan_phy.transmit_power))
299 goto nla_put_failure;
300
301finish:
302 return genlmsg_end(msg, hdr);
303
304nla_put_failure:

--- 312 unchanged lines hidden (view full) ---

617
618 /* check 802.15.4 constraints */
619 if (page > IEEE802154_MAX_PAGE || channel > IEEE802154_MAX_CHANNEL)
620 return -EINVAL;
621
622 return rdev_set_channel(rdev, page, channel);
623}
624
304 if (nla_put_s8(msg, NL802154_ATTR_TX_POWER,
305 rdev->wpan_phy.transmit_power))
306 goto nla_put_failure;
307
308finish:
309 return genlmsg_end(msg, hdr);
310
311nla_put_failure:

--- 312 unchanged lines hidden (view full) ---

624
625 /* check 802.15.4 constraints */
626 if (page > IEEE802154_MAX_PAGE || channel > IEEE802154_MAX_CHANNEL)
627 return -EINVAL;
628
629 return rdev_set_channel(rdev, page, channel);
630}
631
632static int nl802154_set_cca_mode(struct sk_buff *skb, struct genl_info *info)
633{
634 struct cfg802154_registered_device *rdev = info->user_ptr[0];
635 struct wpan_phy_cca cca;
636
637 if (!info->attrs[NL802154_ATTR_CCA_MODE])
638 return -EINVAL;
639
640 cca.mode = nla_get_u32(info->attrs[NL802154_ATTR_CCA_MODE]);
641 /* checking 802.15.4 constraints */
642 if (cca.mode < NL802154_CCA_ENERGY || cca.mode > NL802154_CCA_ATTR_MAX)
643 return -EINVAL;
644
645 if (cca.mode == NL802154_CCA_ENERGY_CARRIER) {
646 if (!info->attrs[NL802154_ATTR_CCA_OPT])
647 return -EINVAL;
648
649 cca.opt = nla_get_u32(info->attrs[NL802154_ATTR_CCA_OPT]);
650 if (cca.opt > NL802154_CCA_OPT_ATTR_MAX)
651 return -EINVAL;
652 }
653
654 return rdev_set_cca_mode(rdev, &cca);
655}
656
625static int nl802154_set_pan_id(struct sk_buff *skb, struct genl_info *info)
626{
627 struct cfg802154_registered_device *rdev = info->user_ptr[0];
628 struct net_device *dev = info->user_ptr[1];
629 struct wpan_dev *wpan_dev = dev->ieee802154_ptr;
630 __le16 pan_id;
631
632 /* conflict here while tx/rx calls */

--- 257 unchanged lines hidden (view full) ---

890 .cmd = NL802154_CMD_SET_CHANNEL,
891 .doit = nl802154_set_channel,
892 .policy = nl802154_policy,
893 .flags = GENL_ADMIN_PERM,
894 .internal_flags = NL802154_FLAG_NEED_WPAN_PHY |
895 NL802154_FLAG_NEED_RTNL,
896 },
897 {
657static int nl802154_set_pan_id(struct sk_buff *skb, struct genl_info *info)
658{
659 struct cfg802154_registered_device *rdev = info->user_ptr[0];
660 struct net_device *dev = info->user_ptr[1];
661 struct wpan_dev *wpan_dev = dev->ieee802154_ptr;
662 __le16 pan_id;
663
664 /* conflict here while tx/rx calls */

--- 257 unchanged lines hidden (view full) ---

922 .cmd = NL802154_CMD_SET_CHANNEL,
923 .doit = nl802154_set_channel,
924 .policy = nl802154_policy,
925 .flags = GENL_ADMIN_PERM,
926 .internal_flags = NL802154_FLAG_NEED_WPAN_PHY |
927 NL802154_FLAG_NEED_RTNL,
928 },
929 {
930 .cmd = NL802154_CMD_SET_CCA_MODE,
931 .doit = nl802154_set_cca_mode,
932 .policy = nl802154_policy,
933 .flags = GENL_ADMIN_PERM,
934 .internal_flags = NL802154_FLAG_NEED_WPAN_PHY |
935 NL802154_FLAG_NEED_RTNL,
936 },
937 {
898 .cmd = NL802154_CMD_SET_PAN_ID,
899 .doit = nl802154_set_pan_id,
900 .policy = nl802154_policy,
901 .flags = GENL_ADMIN_PERM,
902 .internal_flags = NL802154_FLAG_NEED_NETDEV |
903 NL802154_FLAG_NEED_RTNL,
904 },
905 {

--- 52 unchanged lines hidden ---
938 .cmd = NL802154_CMD_SET_PAN_ID,
939 .doit = nl802154_set_pan_id,
940 .policy = nl802154_policy,
941 .flags = GENL_ADMIN_PERM,
942 .internal_flags = NL802154_FLAG_NEED_NETDEV |
943 NL802154_FLAG_NEED_RTNL,
944 },
945 {

--- 52 unchanged lines hidden ---