summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/luasrc/model/network.lua
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2018-01-02 00:30:53 +0100
committerJo-Philipp Wich <jo@mein.io>2018-01-02 00:30:53 +0100
commitc8b48f95246c30ca486567b3a1d96df16e0c2d8c (patch)
treebb160b207047154a2a90375c5193db8530f3f514 /modules/luci-base/luasrc/model/network.lua
parentf9b8d7ff7bbd3c82f9889b65af07a28d94d9fed7 (diff)
luci-base: reorder private functions
The _wifi_sid_by_ifname() function depends on _wifi_state_by_ifname() so reorder the private helper functions accordingly to avoid nil value call attempts. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base/luasrc/model/network.lua')
-rw-r--r--modules/luci-base/luasrc/model/network.lua90
1 files changed, 45 insertions, 45 deletions
diff --git a/modules/luci-base/luasrc/model/network.lua b/modules/luci-base/luasrc/model/network.lua
index 48a03393e..6f405a131 100644
--- a/modules/luci-base/luasrc/model/network.lua
+++ b/modules/luci-base/luasrc/model/network.lua
@@ -113,6 +113,51 @@ local function _wifi_state()
return _ubuswificache
end
+local function _wifi_state_by_sid(sid)
+ local t1, n1 = _uci:get("wireless", sid)
+ if t1 == "wifi-iface" and n1 ~= nil then
+ local radioname, radiostate
+ for radioname, radiostate in pairs(_wifi_state()) do
+ if type(radiostate) == "table" and
+ type(radiostate.interfaces) == "table"
+ then
+ local netidx, netstate
+ for netidx, netstate in ipairs(radiostate.interfaces) do
+ if type(netstate) == "table" and
+ type(netstate.section) == "string"
+ then
+ local t2, n2 = _uci:get("wireless", netstate.section)
+ if t1 == t2 and n1 == n2 then
+ return radioname, radiostate, netstate
+ end
+ end
+ end
+ end
+ end
+ end
+end
+
+local function _wifi_state_by_ifname(ifname)
+ if type(ifname) == "string" then
+ local radioname, radiostate
+ for radioname, radiostate in pairs(_wifi_state()) do
+ if type(radiostate) == "table" and
+ type(radiostate.interfaces) == "table"
+ then
+ local netidx, netstate
+ for netidx, netstate in ipairs(radiostate.interfaces) do
+ if type(netstate) == "table" and
+ type(netstate.ifname) == "string" and
+ netstate.ifname == ifname
+ then
+ return radioname, radiostate, netstate
+ end
+ end
+ end
+ end
+ end
+end
+
function _wifi_iface(x)
local _, p
for _, p in ipairs(IFACE_PATTERNS_WIRELESS) do
@@ -230,51 +275,6 @@ local function _wifi_netid_by_netname(name)
return netid
end
-local function _wifi_state_by_sid(sid)
- local t1, n1 = _uci:get("wireless", sid)
- if t1 == "wifi-iface" and n1 ~= nil then
- local radioname, radiostate
- for radioname, radiostate in pairs(_wifi_state()) do
- if type(radiostate) == "table" and
- type(radiostate.interfaces) == "table"
- then
- local netidx, netstate
- for netidx, netstate in ipairs(radiostate.interfaces) do
- if type(netstate) == "table" and
- type(netstate.section) == "string"
- then
- local t2, n2 = _uci:get("wireless", netstate.section)
- if t1 == t2 and n1 == n2 then
- return radioname, radiostate, netstate
- end
- end
- end
- end
- end
- end
-end
-
-local function _wifi_state_by_ifname(ifname)
- if type(ifname) == "string" then
- local radioname, radiostate
- for radioname, radiostate in pairs(_wifi_state()) do
- if type(radiostate) == "table" and
- type(radiostate.interfaces) == "table"
- then
- local netidx, netstate
- for netidx, netstate in ipairs(radiostate.interfaces) do
- if type(netstate) == "table" and
- type(netstate.ifname) == "string" and
- netstate.ifname == ifname
- then
- return radioname, radiostate, netstate
- end
- end
- end
- end
- end
-end
-
function _iface_virtual(x)
local _, p
for _, p in ipairs(IFACE_PATTERNS_VIRTUAL) do