+function iface_shutdown()
+ local path = luci.dispatcher.context.requestpath
+ local iface = path[#path]
+ local netmd = require "luci.model.network".init()
+
+ local net = netmd:get_network(iface)
+ if net then
+ luci.sys.call("env -i /sbin/ifdown %q >/dev/null 2>/dev/null" % iface)
+ luci.http.status(200, "Shutdown")
+ return
+ end
+
+ luci.http.status(404, "No such interface")
+end
+
+function iface_delete()
+ local path = luci.dispatcher.context.requestpath
+ local iface = path[#path]
+ local netmd = require "luci.model.network".init()
+
+ local net = netmd:del_network(iface)
+ if net then
+ luci.sys.call("env -i /sbin/ifdown %q >/dev/null 2>/dev/null" % iface)
+ luci.http.redirect(luci.dispatcher.build_url("admin/network/network"))
+ netmd:commit("network")
+ netmd:commit("wireless")
+ return
+ end
+
+ luci.http.status(404, "No such interface")
+end
+
+function wifi_status()
+ local netm = require "luci.model.network".init()
+ local path = luci.dispatcher.context.requestpath
+ local rv = { }
+
+ local dev
+ for dev in path[#path]:gmatch("[%w%.%-]+") do
+ local j = { id = dev }
+ local wn = netm:get_wifinet(dev)
+ local iw = wn and wn.iwinfo
+ if iw then
+ local f
+ for _, f in ipairs({
+ "channel", "frequency", "txpower", "bitrate", "signal", "noise",
+ "quality", "quality_max", "bssid", "country",
+ "encryption", "ifname", "assoclist"
+ }) do
+ j[f] = iw[f]