ieee802154: interface type to be added
authoralex.bluesman.smirnov@gmail.com <alex.bluesman.smirnov@gmail.com>
Tue, 15 May 2012 20:50:27 +0000 (20:50 +0000)
committerDavid S. Miller <davem@davemloft.net>
Wed, 16 May 2012 19:17:08 +0000 (15:17 -0400)
This stack implementation distinguishes several types of slave
interfaces. Another parameter to 'add_iface_' function is added
to clarify the interface type is going to be registered.

Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/nl802154.h
include/net/wpan-phy.h
net/ieee802154/nl-phy.c

index 33d9f5175109558d4934de7893003e0a1608759d..2015ad24810193013f53f9d4660e53f57c84656b 100644 (file)
@@ -68,6 +68,7 @@ enum {
        IEEE802154_ATTR_CHANNEL_PAGE_LIST,
 
        IEEE802154_ATTR_PHY_NAME,
+       IEEE802154_ATTR_DEV_TYPE,
 
        __IEEE802154_ATTR_MAX,
 };
@@ -126,4 +127,9 @@ enum {
 
 #define IEEE802154_CMD_MAX (__IEEE802154_CMD_MAX - 1)
 
+enum {
+       __IEEE802154_DEV_INVALID = -1,
+       __IEEE802154_DEV_MAX,
+};
+
 #endif
index ff27f1b078d119173bd86b663df5fe770b4da7c7..efd6749e392b399117399afed88cd38f656c4135 100644 (file)
@@ -43,7 +43,7 @@ struct wpan_phy {
        int idx;
 
        struct net_device *(*add_iface)(struct wpan_phy *phy,
-                       const char *name);
+                                       const char *name, int type);
        void (*del_iface)(struct wpan_phy *phy, struct net_device *dev);
 
        char priv[0] __attribute__((__aligned__(NETDEV_ALIGN)));
index 3bdc4303c339ea6cd6ebc0995f014382ae43d8d2..eed291626da6a2a229d00b4304b9695a1195c2ae 100644 (file)
@@ -179,6 +179,7 @@ static int ieee802154_add_iface(struct sk_buff *skb,
        const char *devname;
        int rc = -ENOBUFS;
        struct net_device *dev;
+       int type = __IEEE802154_DEV_INVALID;
 
        pr_debug("%s\n", __func__);
 
@@ -221,7 +222,13 @@ static int ieee802154_add_iface(struct sk_buff *skb,
                goto nla_put_failure;
        }
 
-       dev = phy->add_iface(phy, devname);
+       if (info->attrs[IEEE802154_ATTR_DEV_TYPE]) {
+               type = nla_get_u8(info->attrs[IEEE802154_ATTR_DEV_TYPE]);
+               if (type >= __IEEE802154_DEV_MAX)
+                       return -EINVAL;
+       }
+
+       dev = phy->add_iface(phy, devname, type);
        if (IS_ERR(dev)) {
                rc = PTR_ERR(dev);
                goto nla_put_failure;