hostapd: use new udebug ubus api to make debug rings configurable
[openwrt/staging/jow.git] / package / network / services / hostapd / files / wpa_supplicant.uc
index cb5f41b1af3ac0f18e2028ff83ff9257806d9888..1709bb019e310785ac4083feef7fbc23cb71235d 100644 (file)
@@ -1,6 +1,6 @@
 let libubus = require("ubus");
 import { open, readfile } from "fs";
-import { wdev_create, wdev_remove, is_equal, vlist_new, phy_open } from "common";
+import { wdev_create, wdev_set_mesh_params, wdev_remove, is_equal, wdev_set_up, vlist_new, phy_open } from "common";
 
 let ubus = libubus.connect();
 
@@ -40,6 +40,7 @@ function iface_start(phydev, iface, macaddr_list)
        let ret = wdev_create(phy, ifname, wdev_config);
        if (ret)
                wpas.printf(`Failed to create device ${ifname}: ${ret}`);
+       wdev_set_up(ifname, true);
        wpas.add_iface(iface.config);
        iface.running = true;
 }
@@ -245,6 +246,7 @@ let main_obj = {
 
 wpas.data.ubus = ubus;
 wpas.data.obj = ubus.publish("wpa_supplicant", main_obj);
+wpas.udebug_set("wpa_supplicant", wpas.data.ubus);
 
 function iface_event(type, name, data) {
        let ubus = wpas.data.ubus;
@@ -316,6 +318,23 @@ return {
                }
 
                iface_hostapd_notify(phy, ifname, iface, state);
+
+               if (state != "COMPLETED")
+                       return;
+
+               let phy_data = wpas.data.config[phy];
+               if (!phy_data)
+                       return;
+
+               let iface_data = phy_data.data[ifname];
+               if (!iface_data)
+                       return;
+
+               let wdev_config = iface_data.config;
+               if (!wdev_config || wdev_config.mode != "mesh")
+                       return;
+
+               wdev_set_mesh_params(ifname, wdev_config);
        },
        event: function(ifname, iface, ev, info) {
                let phy = wpas.data.iface_phy[ifname];