diff options
| author | Alexander Aring <alex.aring@gmail.com> | 2014-11-17 02:20:51 -0500 |
|---|---|---|
| committer | Marcel Holtmann <marcel@holtmann.org> | 2014-11-17 03:49:16 -0500 |
| commit | f3ea5e44231a88eaea69a13410d1b80c19cfa1df (patch) | |
| tree | 6cc6980d8ccbb0ef4b91d833d73dbbcc91ee7404 /net/ieee802154 | |
| parent | 133d3f31729a62908ab98d0b6562cc1a35d3dc39 (diff) | |
ieee802154: add new interface command
This patch adds a new nl802154 command for adding a new interface
according to a wpan phy via nl802154.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/ieee802154')
| -rw-r--r-- | net/ieee802154/nl802154.c | 34 | ||||
| -rw-r--r-- | net/ieee802154/rdev-ops.h | 7 |
2 files changed, 41 insertions, 0 deletions
diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c index ccdf33ecee0b..e7224f3c1584 100644 --- a/net/ieee802154/nl802154.c +++ b/net/ieee802154/nl802154.c | |||
| @@ -551,6 +551,32 @@ static int nl802154_get_interface(struct sk_buff *skb, struct genl_info *info) | |||
| 551 | return genlmsg_reply(msg, info); | 551 | return genlmsg_reply(msg, info); |
| 552 | } | 552 | } |
| 553 | 553 | ||
| 554 | static int nl802154_new_interface(struct sk_buff *skb, struct genl_info *info) | ||
| 555 | { | ||
| 556 | struct cfg802154_registered_device *rdev = info->user_ptr[0]; | ||
| 557 | enum nl802154_iftype type = NL802154_IFTYPE_UNSPEC; | ||
| 558 | |||
| 559 | /* TODO avoid failing a new interface | ||
| 560 | * creation due to pending removal? | ||
| 561 | */ | ||
| 562 | |||
| 563 | if (!info->attrs[NL802154_ATTR_IFNAME]) | ||
| 564 | return -EINVAL; | ||
| 565 | |||
| 566 | if (info->attrs[NL802154_ATTR_IFTYPE]) { | ||
| 567 | type = nla_get_u32(info->attrs[NL802154_ATTR_IFTYPE]); | ||
| 568 | if (type > NL802154_IFTYPE_MAX) | ||
| 569 | return -EINVAL; | ||
| 570 | } | ||
| 571 | |||
| 572 | if (!rdev->ops->add_virtual_intf) | ||
| 573 | return -EOPNOTSUPP; | ||
| 574 | |||
| 575 | return rdev_add_virtual_intf(rdev, | ||
| 576 | nla_data(info->attrs[NL802154_ATTR_IFNAME]), | ||
| 577 | type); | ||
| 578 | } | ||
| 579 | |||
| 554 | static int nl802154_set_channel(struct sk_buff *skb, struct genl_info *info) | 580 | static int nl802154_set_channel(struct sk_buff *skb, struct genl_info *info) |
| 555 | { | 581 | { |
| 556 | struct cfg802154_registered_device *rdev = info->user_ptr[0]; | 582 | struct cfg802154_registered_device *rdev = info->user_ptr[0]; |
| @@ -819,6 +845,14 @@ static const struct genl_ops nl802154_ops[] = { | |||
| 819 | NL802154_FLAG_NEED_RTNL, | 845 | NL802154_FLAG_NEED_RTNL, |
| 820 | }, | 846 | }, |
| 821 | { | 847 | { |
| 848 | .cmd = NL802154_CMD_NEW_INTERFACE, | ||
| 849 | .doit = nl802154_new_interface, | ||
| 850 | .policy = nl802154_policy, | ||
| 851 | .flags = GENL_ADMIN_PERM, | ||
| 852 | .internal_flags = NL802154_FLAG_NEED_WPAN_PHY | | ||
| 853 | NL802154_FLAG_NEED_RTNL, | ||
| 854 | }, | ||
| 855 | { | ||
| 822 | .cmd = NL802154_CMD_SET_CHANNEL, | 856 | .cmd = NL802154_CMD_SET_CHANNEL, |
| 823 | .doit = nl802154_set_channel, | 857 | .doit = nl802154_set_channel, |
| 824 | .policy = nl802154_policy, | 858 | .policy = nl802154_policy, |
diff --git a/net/ieee802154/rdev-ops.h b/net/ieee802154/rdev-ops.h index 578bc41e92d3..d3a4f94c5fdc 100644 --- a/net/ieee802154/rdev-ops.h +++ b/net/ieee802154/rdev-ops.h | |||
| @@ -21,6 +21,13 @@ rdev_del_virtual_intf_deprecated(struct cfg802154_registered_device *rdev, | |||
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | static inline int | 23 | static inline int |
| 24 | rdev_add_virtual_intf(struct cfg802154_registered_device *rdev, char *name, | ||
| 25 | enum nl802154_iftype type) | ||
| 26 | { | ||
| 27 | return rdev->ops->add_virtual_intf(&rdev->wpan_phy, name, type); | ||
| 28 | } | ||
| 29 | |||
| 30 | static inline int | ||
| 24 | rdev_set_channel(struct cfg802154_registered_device *rdev, u8 page, u8 channel) | 31 | rdev_set_channel(struct cfg802154_registered_device *rdev, u8 page, u8 channel) |
| 25 | { | 32 | { |
| 26 | return rdev->ops->set_channel(&rdev->wpan_phy, page, channel); | 33 | return rdev->ops->set_channel(&rdev->wpan_phy, page, channel); |
