let ubus = libubus.connect(null, 60);
+function ex_handler(e)
+{
+ e = split(`${e}\n${e.stacktrace[0].context}`, '\n');
+ for (let line in e)
+ hostapd.printf(line);
+ return libubus.STATUS_UNKNOWN_ERROR;
+}
+libubus.guard(ex_handler);
+
hostapd.data.config = {};
hostapd.data.pending_config = {};
return config;
}
-function ex_wrap(func) {
- return (req) => {
- try {
- let ret = func(req);
- return ret;
- } catch(e) {
- hostapd.printf(`Exception in ubus function: ${e}\n${e.stacktrace[0].context}`);
- }
- return libubus.STATUS_UNKNOWN_ERROR;
- };
-}
-
function phy_name(phy, radio)
{
if (!phy)
phy: "",
radio: 0,
},
- call: ex_wrap(function(req) {
+ call: function(req) {
let phy_list = req.args.phy ? [ phy_name(req.args.phy, req.args.radio) ] : keys(hostapd.data.config);
for (let phy_name in phy_list) {
let phy = hostapd.data.config[phy_name];
}
return 0;
- })
+ }
},
apsta_state: {
args: {
csa: true,
csa_count: 0,
},
- call: ex_wrap(function(req) {
+ call: function(req) {
let phy = phy_name(req.args.phy, req.args.radio);
if (req.args.up == null || !phy)
return libubus.STATUS_INVALID_ARGUMENT;
return libubus.STATUS_UNKNOWN_ERROR;
return 0;
- })
+ }
},
config_get_macaddr_list: {
args: {
phy: "",
radio: 0,
},
- call: ex_wrap(function(req) {
+ call: function(req) {
let phy = phy_name(req.args.phy, req.args.radio);
if (!phy)
return libubus.STATUS_INVALID_ARGUMENT;
ret.macaddr = map(config.bss, (bss) => bss.bssid);
return ret;
- })
+ }
},
mld_set: {
args: {
config: {}
},
- call: ex_wrap(function(req) {
+ call: function(req) {
if (!req.args.config)
return libubus.STATUS_INVALID_ARGUMENT;
return {
pid: hostapd.getpid()
};
- })
+ }
},
config_reset: {
args: {
},
- call: ex_wrap(function(req) {
+ call: function(req) {
for (let name in hostapd.data.config)
iface_set_config(name);
mld_set_config({});
return 0;
- })
+ }
},
config_set: {
args: {
config: "",
prev_config: "",
},
- call: ex_wrap(function(req) {
+ call: function(req) {
let phy = req.args.phy;
let radio = req.args.radio;
let name = phy_name(phy, radio);
return {
pid: hostapd.getpid()
};
- })
+ }
},
config_add: {
args: {
iface: "",
config: "",
},
- call: ex_wrap(function(req) {
+ call: function(req) {
if (!req.args.iface || !req.args.config)
return libubus.STATUS_INVALID_ARGUMENT;
return {
pid: hostapd.getpid()
};
- })
+ }
},
config_remove: {
args: {
iface: ""
},
- call: ex_wrap(function(req) {
+ call: function(req) {
if (!req.args.iface)
return libubus.STATUS_INVALID_ARGUMENT;
hostapd.remove_iface(req.args.iface);
return 0;
- })
+ }
},
bss_info: {
args: {
iface: ""
},
- call: ex_wrap(function(req) {
+ call: function(req) {
if (!req.args.iface)
return libubus.STATUS_INVALID_ARGUMENT;
}
return ret;
- })
+ }
},
};