summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2009-02-08 20:11:09 +0000
committerJo-Philipp Wich <jow@openwrt.org>2009-02-08 20:11:09 +0000
commit2c73c9505540c543c4f7026aeca54bef72f3d6ab (patch)
tree456cba58b67b7bada4119fc333ad009da35d9d35
parent56d142a1a1b0286b8611040ea47ddf3a9844bb91 (diff)
modules/admin-full: implement interface status page
i18n/english: add required strings for interface status
-rw-r--r--i18n/english/luasrc/i18n/admin-core.en.lua36
-rw-r--r--i18n/english/luasrc/i18n/admin-core.en.xml36
-rw-r--r--modules/admin-full/luasrc/controller/admin/status.lua8
-rw-r--r--modules/admin-full/luasrc/view/admin_status/interfaces.htm302
4 files changed, 379 insertions, 3 deletions
diff --git a/i18n/english/luasrc/i18n/admin-core.en.lua b/i18n/english/luasrc/i18n/admin-core.en.lua
index 6b7195c64..f0d5d48cf 100644
--- a/i18n/english/luasrc/i18n/admin-core.en.lua
+++ b/i18n/english/luasrc/i18n/admin-core.en.lua
@@ -41,6 +41,42 @@ a_s_flash = 'Flash Firmware'
a_s_i_system1 = 'Change settings related to the system itself, its identification, installed hard- and software, authentication or mount points.'
a_s_i_system2 = 'These settings define the base of your system.'
a_s_i_system3 = 'Pay attention as any misconfiguration here may prevent your device from booting or may lock yourself out of it.'
+a_s_if = 'Interfaces'
+a_s_if_bridge = 'Bridge'
+a_s_if_bridge_id = 'ID'
+a_s_if_bridge_port = 'Bridge Port'
+a_s_if_bridge_stp = 'STP'
+a_s_if_device = 'Device'
+a_s_if_ethbridge = 'Ethernet Bridge'
+a_s_if_ethdev = 'Ethernet Adapter'
+a_s_if_ethswitch = 'Ethernet Switch'
+a_s_if_interface = 'Interface'
+a_s_if_ipconfig = 'IP Configuration'
+a_s_if_ipconfig_alias = 'Alias'
+a_s_if_ipconfig_dhcp = 'DHCP assigned'
+a_s_if_ipconfig_ipv6 = 'IPv6'
+a_s_if_ipconfig_none = 'Not configured'
+a_s_if_ipconfig_primary = 'Primary'
+a_s_if_iwchannel = 'Channel'
+a_s_if_iwmode = 'Mode'
+a_s_if_iwmode_adhoc = 'Ad-Hoc'
+a_s_if_iwmode_ahdemo = 'Pseudo Ad-Hoc'
+a_s_if_iwmode_ap = 'Master'
+a_s_if_iwmode_apwds = 'Master + WDS'
+a_s_if_iwmode_sta = 'Client'
+a_s_if_iwmode_stawds = 'Client + WDS'
+a_s_if_iwmode_wds = 'WDS'
+a_s_if_iwssid = 'SSID'
+a_s_if_mac = 'MAC'
+a_s_if_pkts = 'Pkts.'
+a_s_if_status = 'Interface Status'
+a_s_if_transfer = 'Transfer'
+a_s_if_transfer_rx = 'RX'
+a_s_if_transfer_tx = 'TX'
+a_s_if_type = 'Type'
+a_s_if_vlan = 'VLAN'
+a_s_if_vlanports = 'Ports'
+a_s_if_wifidev = 'Wireless Adapter'
a_s_ipt = 'Firewall'
a_s_ipt_actions = 'Actions'
a_s_ipt_bytes = 'Traffic'
diff --git a/i18n/english/luasrc/i18n/admin-core.en.xml b/i18n/english/luasrc/i18n/admin-core.en.xml
index 4c11c8b5c..39fe5874a 100644
--- a/i18n/english/luasrc/i18n/admin-core.en.xml
+++ b/i18n/english/luasrc/i18n/admin-core.en.xml
@@ -45,6 +45,42 @@
<i18n:msg xml:id="a_s_i_system1">Change settings related to the system itself, its identification, installed hard- and software, authentication or mount points.</i18n:msg>
<i18n:msg xml:id="a_s_i_system2">These settings define the base of your system.</i18n:msg>
<i18n:msg xml:id="a_s_i_system3">Pay attention as any misconfiguration here may prevent your device from booting or may lock yourself out of it.</i18n:msg>
+<i18n:msg xml:id="a_s_if">Interfaces</i18n:msg>
+<i18n:msg xml:id="a_s_if_bridge">Bridge</i18n:msg>
+<i18n:msg xml:id="a_s_if_bridge_id">ID</i18n:msg>
+<i18n:msg xml:id="a_s_if_bridge_port">Bridge Port</i18n:msg>
+<i18n:msg xml:id="a_s_if_bridge_stp">STP</i18n:msg>
+<i18n:msg xml:id="a_s_if_device">Device</i18n:msg>
+<i18n:msg xml:id="a_s_if_ethbridge">Ethernet Bridge</i18n:msg>
+<i18n:msg xml:id="a_s_if_ethdev">Ethernet Adapter</i18n:msg>
+<i18n:msg xml:id="a_s_if_ethswitch">Ethernet Switch</i18n:msg>
+<i18n:msg xml:id="a_s_if_interface">Interface</i18n:msg>
+<i18n:msg xml:id="a_s_if_ipconfig">IP Configuration</i18n:msg>
+<i18n:msg xml:id="a_s_if_ipconfig_alias">Alias</i18n:msg>
+<i18n:msg xml:id="a_s_if_ipconfig_dhcp">DHCP assigned</i18n:msg>
+<i18n:msg xml:id="a_s_if_ipconfig_ipv6">IPv6</i18n:msg>
+<i18n:msg xml:id="a_s_if_ipconfig_none">Not configured</i18n:msg>
+<i18n:msg xml:id="a_s_if_ipconfig_primary">Primary</i18n:msg>
+<i18n:msg xml:id="a_s_if_iwchannel">Channel</i18n:msg>
+<i18n:msg xml:id="a_s_if_iwmode">Mode</i18n:msg>
+<i18n:msg xml:id="a_s_if_iwmode_adhoc">Ad-Hoc</i18n:msg>
+<i18n:msg xml:id="a_s_if_iwmode_ahdemo">Pseudo Ad-Hoc</i18n:msg>
+<i18n:msg xml:id="a_s_if_iwmode_ap">Master</i18n:msg>
+<i18n:msg xml:id="a_s_if_iwmode_apwds">Master + WDS</i18n:msg>
+<i18n:msg xml:id="a_s_if_iwmode_sta">Client</i18n:msg>
+<i18n:msg xml:id="a_s_if_iwmode_stawds">Client + WDS</i18n:msg>
+<i18n:msg xml:id="a_s_if_iwmode_wds">WDS</i18n:msg>
+<i18n:msg xml:id="a_s_if_iwssid">SSID</i18n:msg>
+<i18n:msg xml:id="a_s_if_mac">MAC</i18n:msg>
+<i18n:msg xml:id="a_s_if_pkts">Pkts.</i18n:msg>
+<i18n:msg xml:id="a_s_if_status">Interface Status</i18n:msg>
+<i18n:msg xml:id="a_s_if_transfer">Transfer</i18n:msg>
+<i18n:msg xml:id="a_s_if_transfer_rx">RX</i18n:msg>
+<i18n:msg xml:id="a_s_if_transfer_tx">TX</i18n:msg>
+<i18n:msg xml:id="a_s_if_type">Type</i18n:msg>
+<i18n:msg xml:id="a_s_if_vlan">VLAN</i18n:msg>
+<i18n:msg xml:id="a_s_if_vlanports">Ports</i18n:msg>
+<i18n:msg xml:id="a_s_if_wifidev">Wireless Adapter</i18n:msg>
<i18n:msg xml:id="a_s_ipt">Firewall</i18n:msg>
<i18n:msg xml:id="a_s_ipt_actions">Actions</i18n:msg>
<i18n:msg xml:id="a_s_ipt_bytes">Traffic</i18n:msg>
diff --git a/modules/admin-full/luasrc/controller/admin/status.lua b/modules/admin-full/luasrc/controller/admin/status.lua
index fd61459e9..abfc9d69c 100644
--- a/modules/admin-full/luasrc/controller/admin/status.lua
+++ b/modules/admin-full/luasrc/controller/admin/status.lua
@@ -18,9 +18,11 @@ function index()
local i18n = luci.i18n.translate
entry({"admin", "status"}, template("admin_status/index"), i18n("status", "Status"), 20).index = true
- entry({"admin", "status", "syslog"}, call("action_syslog"), i18n("syslog", "Systemprotokoll"), 1)
- entry({"admin", "status", "dmesg"}, call("action_dmesg"), i18n("dmesg", "Kernelprotokoll"), 2)
- entry({"admin", "status", "iptables"}, call("action_iptables"), i18n("a_s_ipt", "Firewall"), 3)
+ entry({"admin", "status", "interfaces"}, template("admin_status/interfaces"), i18n("interfaces", "Interfaces"), 1)
+ entry({"admin", "status", "iptables"}, call("action_iptables"), i18n("a_s_ipt", "Firewall"), 2)
+ entry({"admin", "status", "syslog"}, call("action_syslog"), i18n("syslog", "Systemprotokoll"), 3)
+ entry({"admin", "status", "dmesg"}, call("action_dmesg"), i18n("dmesg", "Kernelprotokoll"), 4)
+
end
function action_syslog()
diff --git a/modules/admin-full/luasrc/view/admin_status/interfaces.htm b/modules/admin-full/luasrc/view/admin_status/interfaces.htm
new file mode 100644
index 000000000..562b1e675
--- /dev/null
+++ b/modules/admin-full/luasrc/view/admin_status/interfaces.htm
@@ -0,0 +1,302 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+
+<%-
+
+ require "luci.tools.webadmin"
+
+ local wba = luci.tools.webadmin
+ local uci = luci.model.uci.cursor_state()
+
+ local bridge_ifs = { }
+ local single_ifs = { }
+ local wifi_ifs = { }
+ local devinfo = luci.sys.net.deviceinfo()
+
+ uci:foreach("network", "interface",
+ function(s)
+ if s['.name'] ~= "loopback" then
+ if s.type == "bridge" then
+ bridge_ifs[#bridge_ifs+1] = s
+ else
+ single_ifs[#single_ifs+1] = s
+ end
+ end
+ end)
+
+ uci:foreach("wireless", "wifi-iface",
+ function(s)
+ wifi_ifs[s.network or s.device] = true
+ end)
+
+ function is_wifi(i)
+ return wifi_ifs[i]
+ or i:match("^wl%d+")
+ or i:match("^ath%d+")
+ or i:match("^wlan%d+")
+ end
+
+ function get_ifname(s)
+ return s.ifname and s.ifname:match("%S+")
+ end
+
+ function get_ifnames(s)
+ local l = { }
+ if s.ifname then
+ for n in s.ifname:gmatch("%S+") do
+ l[#l+1] = n
+ end
+ end
+ return l
+ end
+
+ function get_vlan(i)
+ return i:match("^%w+%.(%d+)$")
+ end
+
+ function get_vlan_ports(i)
+ local x = get_vlan(i)
+ local d = i:match("(%d+)%.%d+$")
+ local p = { }
+
+ uci:foreach("network", "switch",
+ function(s)
+ local d2 = s['.name']:match("%d+$")
+ if d2 == d and s["vlan"..x] then
+ for pt in s["vlan"..x]:gmatch("%S+") do
+ p[#p+1] = pt
+ end
+ end
+ end)
+
+ return p
+ end
+
+ 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 )
+
+ return hw and hw:match("%S+")
+ end
+
+ function get_mac(i)
+ for l in luci.util.execi("ifconfig %q" % i) do
+ if l:find("HWaddr ") then
+ return l:match("HWaddr (%S+)")
+ end
+ end
+ return "00:00:00:00:00:00"
+ end
+
+ function get_aliases(s)
+ local a = { }
+ uci:foreach("network", "alias",
+ function(s2)
+ if s2.interface == s['.name'] then
+ a[#a+1] = s2
+ end
+ end)
+ return a
+ end
+
+ function get_iwinfo(i)
+ local w = { }
+ uci:foreach("wireless", "wifi-iface",
+ function(s)
+ if s.ifname == i then
+ w.type = uci:get("wireless", s.device, "type")
+ w.channel = uci:get("wireless", s.device, "channel")
+ w.mode = ( s.wds == "1" ) and s.mode .. "wds" or s.mode
+ w.ssid = s.ssid
+ w.type = w.type and w.type:gsub("^([a-z])", string.upper)
+ end
+ end)
+ return w
+ end
+
+ function get_iwmode(w)
+ local m = {
+ ap = translate("a_s_if_iwmode_ap", "Master"),
+ sta = translate("a_s_if_iwmode_sta", "Client"),
+ wds = translate("a_s_if_iwmode_wds", "WDS"),
+ stawds = translate("a_s_if_iwmode_stawds", "Client + WDS"),
+ apwds = translate("a_s_if_iwmode_apwds", "Master + WDS"),
+ adhoc = translate("a_s_if_iwmode_adhoc", "Ad-Hoc"),
+ ahdemo = translate("a_s_if_iwmode_ahdemo", "Pseudo Ad-Hoc")
+ }
+
+ return m[w.mode] or w.mode
+ end
+
+ function get_brinfo(s)
+ local b = { }
+ for l in luci.util.execi("brctl show br-%s" % s['.name']) 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]
+ end
+ end
+ end
+ return b
+ end
+
+-%>
+
+<%+header%>
+
+<h2><a id="content" name="content"><%:a_s_if_status Interface Status%></a></h2>
+
+<form method="post" action="<%=REQUEST_URI%>">
+ <div class="cbi-map">
+ <fieldset class="cbi-section">
+ <% for _, i in ipairs(single_ifs) do
+ dev = get_ifname(i)
+ vlan = get_vlan(dev)
+ %>
+ <h3><%:a_s_if_interface Interface%> <%=i['.name']%></h3>
+ <p style="font-size:90%;padding-left:1em">
+
+ <strong><%:a_s_if_device Device%>:</strong>
+ <%=dev%> (<%:a_s_if_mac MAC%> <%=get_mac(dev)%>)<br />
+
+ <strong><%:a_s_if_type Type%>:</strong>
+ <% if is_wifi(dev) then iw = get_iwinfo(dev) -%>
+ <%:a_s_if_wifidev Wireless Adapter%> (<%=iw.type%>)<br />
+ <% if iw then %>
+ &nbsp; &#x2514; <strong><%:a_s_if_iwmode Mode%>:</strong> <%=get_iwmode(iw)%><br />
+ &nbsp; &#x2514; <strong><%:a_s_if_iwssid SSID%>:</strong> <%=iw.ssid%><br />
+ &nbsp; &#x2514; <strong><%:a_s_if_iwchannel Channel%>:</strong> <%=iw.channel%>
+ <% end %>
+ <% else -%>
+ <% if vlan then %>
+ <%:a_s_if_ethswitch Ethernet Switch%> (<%=get_switch_driver(dev)%>)<br />
+ &nbsp; &#x2514; <strong><%:a_s_if_vlan VLAN%>:</strong> <%=get_vlan(dev)%> (<%:a_s_if_vlanports Ports%> <%=table.concat(get_vlan_ports(dev), ", ")%>)
+ <% else %>
+ <%:a_s_if_ethdev Ethernet Adapter%>
+ <% end %>
+ <% end -%><br />
+
+ <strong><%:a_s_if_transfer Transfer%></strong><br />
+ &nbsp; &#x2514; <strong><%:a_s_if_transfer_rx RX%>:</strong> <%=devinfo[dev][2]%> <%:a_s_if_pkts Pkts.%> (<%=wba.byte_format(tonumber(devinfo[dev][1]))%>)<br />
+ &nbsp; &#x2514; <strong><%:a_s_if_transfer_tx TX%>:</strong> <%=devinfo[dev][10]%> <%:a_s_if_pkts Pkts.%> (<%=wba.byte_format(tonumber(devinfo[dev][9]))%>)<br />
+
+ <%- if ( i.ipaddr and #i.ipaddr > 0 ) or ( i.ip6addr and #i.ip6addr > 0 ) then -%>
+ <strong><%:a_s_if_ipconfig IP Configuration%></strong><br />
+ &nbsp; &#x2514; <strong><%:a_s_if_ipconfig_primary Primary%>:</strong>
+ <% if i.ipaddr and #i.ipaddr > 0 then %>
+ <%=i.ipaddr%>/<%=i.netmask%>
+ <% if i.proto == "dhcp" then -%>
+ (<%:a_s_if_ipconfig_dhcp DHCP assigned%>)
+ <%- end %>
+ <% else %>
+ <em><%:a_s_if_ipconfig_none Not configured%></em>
+ <% end %><br />
+
+ <% for i, a in ipairs(get_aliases(i)) do %>
+ &nbsp; &#x2514; <strong><%:a_s_if_ipconfig_alias Alias%> #<%=i%>:</strong>
+ <%=a.ipaddr%>/<%=a.netmask%> (<%:a_s_if_device Device%> <%=dev%>:<%=i%>) <br />
+ <% end %>
+
+ <% if i.ip6addr and #i.ip6addr > 0 then %>
+ &nbsp; &#x2514; <strong><%:a_s_if_ipconfig_ipv6 IPv6%>:</strong> <%=i.ip6addr%><br />
+ <% end %>
+ <%- end -%>
+ <br /></p>
+ <% end %>
+
+
+ <% for _, b in ipairs(bridge_ifs) do
+ br = get_brinfo(b)
+ dev = br.name
+ %>
+ <h3><%:a_s_if_bridge Bridge%> <%=br.name%></h3>
+ <p style="font-size:90%;padding-left:1em">
+
+ <strong><%:a_s_if_device Device%>:</strong>
+ <%=dev%> (<%:a_s_if_mac MAC%> <%=get_mac(dev)%>)<br />
+
+ <strong><%:a_s_if_type Type%>:</strong>
+ <%:a_s_if_ethbridge Ethernet Bridge%><br />
+
+ &nbsp; &#x2514; <strong><%:a_s_if_bridge_id ID%>:</strong> <%=br.id%><br />
+ &nbsp; &#x2514; <strong><%:a_s_if_bridge_stp STP%>:</strong> <%=br.stp and "enabled" or "disabled"%><br />
+
+ <strong><%:a_s_if_transfer Transfer%></strong><br />
+ &nbsp; &#x2514; <strong><%:a_s_if_transfer_rx RX%>:</strong> <%=devinfo[dev][2]%> Pkts. (<%=wba.byte_format(tonumber(devinfo[dev][1]))%>)<br />
+ &nbsp; &#x2514; <strong><%:a_s_if_transfer_tx TX%>:</strong> <%=devinfo[dev][10]%> Pkts. (<%=wba.byte_format(tonumber(devinfo[dev][9]))%>)<br />
+
+ <%- if ( b.ipaddr and #b.ipaddr > 0 ) or ( b.ip6addr and #b.ip6addr > 0 ) then -%>
+ <strong><%:a_s_if_ipconfig IP Configuration%></strong><br />
+ &nbsp; &#x2514; <strong><%:a_s_if_ipconfig_primary Primary%>:</strong>
+ <% if b.ipaddr and #b.ipaddr > 0 then %>
+ <%=b.ipaddr%>/<%=b.netmask%>
+ <% if b.proto == "dhcp" then -%>
+ (<%:a_s_if_ipconfig_dhcp DHCP assigned%>)
+ <%- end %>
+ <% else %>
+ <em><%:a_s_if_ipconfig_none Not configured%></em>
+ <% end %><br />
+
+ <% for i, a in ipairs(get_aliases(b)) do %>
+ &nbsp; &#x2514; <strong><%:a_s_if_ipconfig_alias Alias%> #<%=i%>:</strong>
+ <%=a.ipaddr%>/<%=a.netmask%> (<%:a_s_if_device Device%> <%=dev%>:<%=i%>) <br />
+ <% end %>
+
+ <% if b.ip6addr and #b.ip6addr > 0 then %>
+ &nbsp; &#x2514; <strong><%:a_s_if_ipconfig_ipv6 IPv6%>:</strong> <%=b.ip6addr%><br />
+ <% end %>
+ <%- end -%>
+
+ <% for n, i in ipairs(br.ifnames) do
+ dev = i
+ vlan = get_vlan(dev)
+ %>
+ <strong><%:a_s_if_bridge_port Bridge Port%> <%=n%></strong><br />
+
+ &nbsp; &#x2514; <strong><%:a_s_if_device Device%>:</strong>
+ <%=dev%> (<%:a_s_if_mac MAC%> <%=get_mac(dev)%>)<br />
+
+ &nbsp; &#x2514; <strong><%:a_s_if_type Type%>:</strong>
+ <% if is_wifi(dev) then iw = get_iwinfo(dev) -%>
+ <%:a_s_if_wifidev Wireless Adapter%> (<%=iw.type%>)<br />
+ <% if iw then %>
+ &nbsp; &nbsp; &nbsp; &#x2514; <strong><%:a_s_if_iwmode Mode%>:</strong> <%=get_iwmode(iw)%><br />
+ &nbsp; &nbsp; &nbsp; &#x2514; <strong><%:a_s_if_iwssid SSID%>:</strong> <%=iw.ssid%><br />
+ &nbsp; &nbsp; &nbsp; &#x2514; <strong><%:a_s_if_iwchannel Channel%>:</strong> <%=iw.channel%>
+ <% end %>
+ <% else -%>
+ <% if vlan then %>
+ <%:a_s_if_ethswitch Ethernet Switch%> (<%=get_switch_driver(dev)%>)<br />
+ &nbsp; &nbsp; &nbsp; &#x2514; <strong><%:a_s_if_vlan VLAN%>:</strong>
+ <%=get_vlan(dev)%> (<%:a_s_if_vlan_ports Ports%> <%=table.concat(get_vlan_ports(dev), ", ")%>)
+ <% else %>
+ <%:a_s_if_ethdev Ethernet Adapter%>
+ <% end %>
+ <% end -%><br />
+ <% end %>
+ <br /></p>
+ <% end %>
+ </fieldset>
+ </div>
+</form>
+
+<%+footer%>