|
@@ -570,6 +570,29 @@ static int nl802154_set_channel(struct sk_buff *skb, struct genl_info *info)
|
|
|
return rdev_set_channel(rdev, page, channel);
|
|
|
}
|
|
|
|
|
|
+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;
|
|
|
+
|
|
|
+ /* conflict here while tx/rx calls */
|
|
|
+ if (netif_running(dev))
|
|
|
+ return -EBUSY;
|
|
|
+
|
|
|
+ /* don't change address fields on monitor */
|
|
|
+ if (wpan_dev->iftype == NL802154_IFTYPE_MONITOR)
|
|
|
+ return -EINVAL;
|
|
|
+
|
|
|
+ if (!info->attrs[NL802154_ATTR_PAN_ID])
|
|
|
+ return -EINVAL;
|
|
|
+
|
|
|
+ pan_id = nla_get_u16(info->attrs[NL802154_ATTR_PAN_ID]);
|
|
|
+
|
|
|
+ return rdev_set_pan_id(rdev, wpan_dev, pan_id);
|
|
|
+}
|
|
|
+
|
|
|
#define NL802154_FLAG_NEED_WPAN_PHY 0x01
|
|
|
#define NL802154_FLAG_NEED_NETDEV 0x02
|
|
|
#define NL802154_FLAG_NEED_RTNL 0x04
|
|
@@ -688,6 +711,14 @@ static const struct genl_ops nl802154_ops[] = {
|
|
|
.internal_flags = NL802154_FLAG_NEED_WPAN_PHY |
|
|
|
NL802154_FLAG_NEED_RTNL,
|
|
|
},
|
|
|
+ {
|
|
|
+ .cmd = NL802154_CMD_SET_PAN_ID,
|
|
|
+ .doit = nl802154_set_pan_id,
|
|
|
+ .policy = nl802154_policy,
|
|
|
+ .flags = GENL_ADMIN_PERM,
|
|
|
+ .internal_flags = NL802154_FLAG_NEED_NETDEV |
|
|
|
+ NL802154_FLAG_NEED_RTNL,
|
|
|
+ },
|
|
|
};
|
|
|
|
|
|
/* initialisation/exit functions */
|