wireless: add back support for multiple networks per interface
authorFelix Fietkau <nbd@openwrt.org>
Sun, 8 Dec 2013 17:57:40 +0000 (18:57 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Sun, 8 Dec 2013 17:57:40 +0000 (18:57 +0100)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
wireless.c
wireless.h

index 508d35e4e7b9def434b4b0dc2c820a33ec87a2cc..1f7fc5d6c56d3bc3d1654147d435f8e34f5a1064 100644 (file)
@@ -40,7 +40,7 @@ enum {
 
 static const struct blobmsg_policy vif_policy[__VIF_ATTR_MAX] = {
        [VIF_ATTR_DISABLED] = { .name = "disabled", .type = BLOBMSG_TYPE_BOOL },
-       [VIF_ATTR_NETWORK] = { .name = "network", .type = BLOBMSG_TYPE_STRING },
+       [VIF_ATTR_NETWORK] = { .name = "network", .type = BLOBMSG_TYPE_ARRAY },
 };
 
 static const struct uci_blob_param_list vif_param = {
@@ -57,23 +57,33 @@ put_container(struct blob_buf *buf, struct blob_attr *attr, const char *name)
 }
 
 static void
-vif_config_add_bridge(struct blob_buf *buf, const char *network, bool prepare)
+vif_config_add_bridge(struct blob_buf *buf, struct blob_attr *networks, bool prepare)
 {
        struct interface *iface;
-       struct device *dev;
+       struct device *dev = NULL;
+       struct blob_attr *cur;
+       const char *network;
+       int rem;
 
-       if (!network)
+       if (!networks)
                return;
 
-       iface = vlist_find(&interfaces, network, iface, node);
-       if (!iface)
-               return;
+       blobmsg_for_each_attr(cur, networks, rem) {
+               network = blobmsg_data(cur);
 
-       dev = iface->main_dev.dev;
-       if (!dev)
-               return;
+               iface = vlist_find(&interfaces, network, iface, node);
+               if (!iface)
+                       continue;
+
+               dev = iface->main_dev.dev;
+               if (!dev)
+                       return;
+
+               if (dev->type != &bridge_device_type)
+                       return;
+       }
 
-       if (dev->type != &bridge_device_type)
+       if (!dev)
                return;
 
        if (dev->hotplug_ops && dev->hotplug_ops->prepare)
@@ -184,15 +194,22 @@ wireless_device_free_state(struct wireless_device *wdev)
 static void wireless_interface_handle_link(struct wireless_interface *vif, bool up)
 {
        struct interface *iface;
+       struct blob_attr *cur;
+       const char *network;
+       int rem;
 
        if (!vif->network || !vif->ifname)
                return;
 
-       iface = vlist_find(&interfaces, vif->network, iface, node);
-       if (!iface)
-               return;
+       blobmsg_for_each_attr(cur, vif->network, rem) {
+               network = blobmsg_data(cur);
+
+               iface = vlist_find(&interfaces, network, iface, node);
+               if (!iface)
+                       continue;
 
-       interface_handle_link(iface, vif->ifname, up);
+               interface_handle_link(iface, vif->ifname, up);
+       }
 }
 
 static void
@@ -494,7 +511,7 @@ wireless_interface_init_config(struct wireless_interface *vif)
        blobmsg_parse(vif_policy, __VIF_ATTR_MAX, tb, blob_data(vif->config), blob_len(vif->config));
 
        if ((cur = tb[VIF_ATTR_NETWORK]))
-               vif->network = blobmsg_data(cur);
+               vif->network = cur;
 }
 
 static void
index 4a98c7774aea313c9763c6c18d0fe80ef159dd3b..a3eadc15c605570cf33a8b416992e22cb7d31d5a 100644 (file)
@@ -74,7 +74,7 @@ struct wireless_interface {
        struct blob_attr *data;
 
        const char *ifname;
-       const char *network;
+       struct blob_attr *network;
 };
 
 struct wireless_process {