<%-
- require "luci.tools.webadmin"
-
- local wba = luci.tools.webadmin
- local uci = luci.model.uci.cursor_state()
+ local sys = require "luci.sys"
+ local wba = require "luci.tools.webadmin"
+ local uci = require "luci.model.uci".cursor_state()
+ local fs = require "nixio.fs"
local bridge_ifs = { }
local single_ifs = { }
local wifi_ifs = { }
- local devinfo = luci.sys.net.deviceinfo()
+ local devinfo = sys.net.deviceinfo()
uci:foreach("network", "interface",
function(s)
end
function get_vlan(i)
- return i:match("^%w+%.(%d+)$")
+ return i and i:match("^%w+%.(%d+)$")
end
function get_vlan_ports(i)
function get_switch_driver(i)
local n, d = i:match("([a-z]+)(%d+)%.%d+$")
- local hw = luci.fs.readfile("/proc/switch/%s%s/driver" %{ n, d })
- or luci.fs.readfile("/proc/switch/%s/driver" % d )
+ local hw = fs.readfile("/proc/switch/%s%s/driver" %{ n, d })
+ or fs.readfile("/proc/switch/%s/driver" % d )
return hw and hw:match("%S+")
end
function get_brinfo(s)
local b = { }
- for l in luci.util.execi("brctl show br-%s" % s['.name']) do
+ local m = false
+ for l in luci.util.execi("brctl show") do
if not l:match("STP") then
- local r = luci.util.split(l, "%s+", nil, true)
- if #r > 2 then
- b.name = r[1]
- b.id = r[2]
- b.stp = r[3] == "yes"
- b.ifnames = { r[4] }
- else
- b.ifnames[#b.ifnames+1] = r[2]
+ if m and l:match("^[a-z]") then
+ break
+ elseif m or l:match("^br%%-%s" % s['.name']) then
+ m = true
+ local r = luci.util.split(l, "%s+", nil, true)
+ if #r > 2 then
+ b.name = r[1]
+ b.id = r[2]
+ b.stp = r[3] == "yes"
+ b.ifnames = { r[4] }
+ else
+ b.ifnames[#b.ifnames+1] = r[2]
+ end
end
end
end
<% for _, i in ipairs(single_ifs) do
dev = get_ifname(i)
vlan = get_vlan(dev)
+
+ if dev and devinfo and devinfo[dev] then
%>
<h3><%:a_s_if_interface Interface%> <%=i['.name']%></h3>
<p style="font-size:90%;padding-left:1em">
<% end %>
<%- end -%>
<br /></p>
- <% end %>
+ <% end end %>
<% for _, b in ipairs(bridge_ifs) do
br = get_brinfo(b)
- dev = br.name
+ dev = br and br.name
+
+ if br and devinfo and devinfo[dev] then
%>
<h3><%:a_s_if_bridge Bridge%> <%=br.name%></h3>
<p style="font-size:90%;padding-left:1em">
<% end -%><br />
<% end %>
<br /></p>
- <% end %>
+ <% end end %>
</fieldset>
</div>
</form>