summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-08-13 22:54:38 +0000
committerSteven Barth <steven@midlink.org>2008-08-13 22:54:38 +0000
commit58f183a28269ded9f41eb980b63a607421689f63 (patch)
tree5cd1a4e51a2a8c5d8e90703ef232f7c064194fe4
parent741e0c89a4e4e9821731a28d4117cdac27539a19 (diff)
Completed rewrite of network interface configuration page
-rw-r--r--i18n/english/luasrc/i18n/admin-core.en.lua13
-rw-r--r--i18n/english/luasrc/i18n/default.en.lua1
-rw-r--r--i18n/german/luasrc/i18n/admin-core.de.lua13
-rw-r--r--i18n/german/luasrc/i18n/default.de.lua1
-rw-r--r--libs/cbi/luasrc/view/cbi/tblsection.htm2
-rw-r--r--libs/uci/luasrc/model/uci.lua1
-rw-r--r--modules/admin-core/luasrc/tools/webadmin.lua73
-rw-r--r--modules/admin-full/luasrc/controller/admin/network.lua4
-rw-r--r--modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua57
-rw-r--r--modules/admin-full/luasrc/model/cbi/admin_network/network.lua20
10 files changed, 163 insertions, 22 deletions
diff --git a/i18n/english/luasrc/i18n/admin-core.en.lua b/i18n/english/luasrc/i18n/admin-core.en.lua
index 348c8065e..762fc5017 100644
--- a/i18n/english/luasrc/i18n/admin-core.en.lua
+++ b/i18n/english/luasrc/i18n/admin-core.en.lua
@@ -309,4 +309,15 @@ system_led_dev = "Device"
system_led_mode = "Trigger Mode"
system_led_mode_link = "Link On"
system_led_mode_tx = "Transmit"
-system_led_mode_rx = "Receive" \ No newline at end of file
+system_led_mode_rx = "Receive"
+
+network_interface_up = "Active"
+network_interface_hwaddr = "MAC-Address"
+network_interface_hwaddr_desc = "Hardware Address"
+network_interface_txrx = "Traffic"
+network_interface_txrx_desc = "transmitted / received"
+network_interface_err = "Errors"
+network_interface_err_desc = "TX / RX"
+
+network_interface_fwzone = "Create / Assign firewall-zone"
+network_interface_fwzone_desc = "This interface does not belong to any firewall zone yet." \ No newline at end of file
diff --git a/i18n/english/luasrc/i18n/default.en.lua b/i18n/english/luasrc/i18n/default.en.lua
index faa7b8770..6666864cd 100644
--- a/i18n/english/luasrc/i18n/default.en.lua
+++ b/i18n/english/luasrc/i18n/default.en.lua
@@ -67,6 +67,7 @@ name = "Name"
netmask = "IPv4-Netmask"
network = "Network"
networks = "Networks"
+none = "none"
notinstalled = "not installed"
ok = "OK"
diff --git a/i18n/german/luasrc/i18n/admin-core.de.lua b/i18n/german/luasrc/i18n/admin-core.de.lua
index 128deda5c..a1ea18308 100644
--- a/i18n/german/luasrc/i18n/admin-core.de.lua
+++ b/i18n/german/luasrc/i18n/admin-core.de.lua
@@ -314,4 +314,15 @@ system_led_dev = "Schnittstelle"
system_led_mode = "Auslösemodus"
system_led_mode_link = "Verbindung hergestellt"
system_led_mode_tx = "Senden"
-system_led_mode_rx = "Empfangen" \ No newline at end of file
+system_led_mode_rx = "Empfangen"
+
+network_interface_up = "Aktiv"
+network_interface_hwaddr = "MAC-Adresse"
+network_interface_hwaddr_desc = "Hardware Adresse"
+network_interface_txrx = "Traffic"
+network_interface_txrx_desc = "gesendet / empfangen"
+network_interface_err = "Fehler"
+network_interface_err_desc = "TX / RX"
+
+network_interface_fwzone = "Firewallzone anlegen / zuweisen"
+network_interface_fwzone_desc = "Diese Schnittstelle gehört bis jetzt zu keiner Firewallzone." \ No newline at end of file
diff --git a/i18n/german/luasrc/i18n/default.de.lua b/i18n/german/luasrc/i18n/default.de.lua
index 64633e60e..a58977384 100644
--- a/i18n/german/luasrc/i18n/default.de.lua
+++ b/i18n/german/luasrc/i18n/default.de.lua
@@ -68,6 +68,7 @@ name = "Name"
netmask = "IPv4-Netzmaske"
network = "Netzwerk"
networks = "Netzwerke"
+none = "keine"
notinstalled = "nicht installiert"
ok = "OK"
diff --git a/libs/cbi/luasrc/view/cbi/tblsection.htm b/libs/cbi/luasrc/view/cbi/tblsection.htm
index 979a135b5..d4effef49 100644
--- a/libs/cbi/luasrc/view/cbi/tblsection.htm
+++ b/libs/cbi/luasrc/view/cbi/tblsection.htm
@@ -70,7 +70,7 @@ end
<%- if self.extedit or self.addremove then -%>
<td class="cbi-section-table-cell">
<%- if self.extedit then -%>
- <a href="<%=self.extedit:format(section)%>"><img style="border: none" src="<%=resource%>/cbi/edit.gif" alt="<%:edit%>" /></a>
+ <a href="<%=self.extedit:format(section)%>" title="<%:edit%>"><img style="border: none" src="<%=resource%>/cbi/edit.gif" alt="<%:edit%>" /></a>
<%- end; if self.addremove then %>
<input type="image" value="<%:cbi_del%>" name="cbi.rts.<%=self.config%>.<%=k%>" alt="<%:cbi_del%>" title="<%:cbi_del%>" src="<%=resource%>/cbi/remove.gif" />
<%- end -%>
diff --git a/libs/uci/luasrc/model/uci.lua b/libs/uci/luasrc/model/uci.lua
index 02bcbe99c..665866e68 100644
--- a/libs/uci/luasrc/model/uci.lua
+++ b/libs/uci/luasrc/model/uci.lua
@@ -101,6 +101,7 @@ function tset(config, section, values)
stat = stat and set(config, section, k, v)
end
end
+ return stat
end
diff --git a/modules/admin-core/luasrc/tools/webadmin.lua b/modules/admin-core/luasrc/tools/webadmin.lua
index 3664997a5..ac11845d4 100644
--- a/modules/admin-core/luasrc/tools/webadmin.lua
+++ b/modules/admin-core/luasrc/tools/webadmin.lua
@@ -16,6 +16,7 @@ $Id$
module("luci.tools.webadmin", package.seeall)
require("luci.model.uci")
require("luci.sys")
+require("luci.ip")
function byte_format(byte)
local suff = {"B", "KB", "MB", "GB", "TB"}
@@ -28,6 +29,45 @@ function byte_format(byte)
end
end
+function network_get_addresses(net)
+ local addr = {}
+ local ipv4 = luci.model.uci.get_statevalue("network", net, "ipaddr")
+ local mav4 = luci.model.uci.get_statevalue("network", net, "netmask")
+ local ipv6 = luci.model.uci.get_statevalue("network", net, "ip6addr")
+
+ if ipv4 and mav4 then
+ ipv4 = luci.ip.IPv4(ipv4, mav4)
+
+ if ipv4 then
+ table.insert(addr, ipv4:string())
+ end
+ end
+
+ if ipv6 then
+ table.insert(addr, ipv6)
+ end
+
+ luci.model.uci.foreach("network", "alias",
+ function (section)
+ if section.interface == net then
+ if section.ipaddr and section.netmask then
+ local ipv4 = luci.ip.IPv4(section.ipaddr, section.netmask)
+
+ if ipv4 then
+ table.insert(addr, ipv4:string())
+ end
+ end
+
+ if section.ip6addr then
+ table.insert(addr, section.ip6addr)
+ end
+ end
+ end
+ )
+
+ return addr
+end
+
function cbi_add_networks(field)
luci.model.uci.foreach("network", "interface",
function (section)
@@ -42,4 +82,37 @@ function cbi_add_knownips(field)
for i, dataset in ipairs(luci.sys.net.arptable()) do
field:value(dataset["IP address"])
end
+end
+
+function network_get_zones(net)
+ if not luci.model.uci.load("firewall") then
+ return nil
+ end
+
+ local zones = {}
+
+ luci.model.uci.foreach("firewall", "zone",
+ function (section)
+ local znet = section.network or section.name
+ if luci.util.contains(luci.util.split(znet, " "), net) then
+ table.insert(zones, section.name)
+ end
+ end
+ )
+
+ return zones
+end
+
+function firewall_find_zone(name)
+ local find
+
+ luci.model.uci.foreach("firewall", "zone",
+ function (section)
+ if section.name == name then
+ find = section[".name"]
+ end
+ end
+ )
+
+ return find
end \ No newline at end of file
diff --git a/modules/admin-full/luasrc/controller/admin/network.lua b/modules/admin-full/luasrc/controller/admin/network.lua
index fa7a8c719..cc79e57a5 100644
--- a/modules/admin-full/luasrc/controller/admin/network.lua
+++ b/modules/admin-full/luasrc/controller/admin/network.lua
@@ -26,12 +26,12 @@ function index()
local page = node("admin", "network", "vlan")
page.target = cbi("admin_network/vlan")
page.title = i18n("a_n_switch", "Switch")
- page.order = 10
+ page.order = 20
local page = node("admin", "network", "network")
page.target = cbi("admin_network/network")
page.title = i18n("interfaces", "Schnittstellen")
- page.order = 20
+ page.order = 10
luci.model.uci.foreach("network", "interface",
function (section)
local ifc = section[".name"]
diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua b/modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua
index 681bfcd6d..ae5f2aeab 100644
--- a/modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua
+++ b/modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua
@@ -12,6 +12,7 @@ You may obtain a copy of the License at
$Id$
]]--
+require("luci.tools.webadmin")
arg[1] = arg[1] or ""
m = Map("network", translate("interfaces"), translate("a_n_ifaces1"))
@@ -37,6 +38,42 @@ for i,d in ipairs(luci.sys.net.devices()) do
end
end
+local zones = luci.tools.webadmin.network_get_zones(arg[1])
+if zones and #zones == 0 then
+ m:chain("firewall")
+
+ fwzone = s:option(Value, "_fwzone",
+ translate("network_interface_fwzone"),
+ translate("network_interface_fwzone_desc"))
+ fwzone.rmempty = true
+ fwzone:value("", "- " .. translate("none") .. " -")
+ fwzone:value(arg[1])
+ luci.model.uci.foreach("firewall", "zone",
+ function (section)
+ fwzone:value(section.name)
+ end
+ )
+
+ function fwzone.write(self, section, value)
+ local zone = luci.tools.webadmin.firewall_find_zone(value)
+ local stat
+
+ if not zone then
+ stat = luci.model.uci.section("firewall", "zone", nil, {
+ name = value,
+ network = section
+ })
+ else
+ local net = luci.model.uci.get("firewall", zone, "network")
+ net = (net or value) .. " " .. section
+ stat = luci.model.uci.set("firewall", zone, "network", net)
+ end
+
+ if stat then
+ self.render = function() end
+ end
+ end
+end
ipaddr = s:option(Value, "ipaddr", translate("ipaddress"))
ipaddr.rmempty = true
@@ -79,24 +116,30 @@ mac.optional = true
user = s:option(Value, "username", translate("username"))
user.rmempty = true
user:depends("proto", "pptp")
-user:depends("proto", "ppoe")
+user:depends("proto", "pppoe")
pass = s:option(Value, "password", translate("password"))
pass.rmempty = true
pass:depends("proto", "pptp")
-pass:depends("proto", "ppoe")
+pass:depends("proto", "pppoe")
-ka = s:option(Value, "keepalive")
+ka = s:option(Value, "keepalive",
+ translate("network_interface_keepalive"),
+ translate("network_interface_keepalive_desc")
+)
ka.rmempty = true
ka:depends("proto", "pptp")
-ka:depends("proto", "ppoe")
+ka:depends("proto", "pppoe")
-demand = s:option(Value, "demand")
+demand = s:option(Value, "demand",
+ translate("network_interface_demand"),
+ translate("network_interface_demand_desc")
+)
demand.rmempty = true
demand:depends("proto", "pptp")
-demand:depends("proto", "ppoe")
+demand:depends("proto", "pppoe")
-srv = s:option(Value, "server")
+srv = s:option(Value, "server", translate("network_interface_server"))
srv:depends("proto", "pptp")
srv.rmempty = true
diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/network.lua b/modules/admin-full/luasrc/model/cbi/admin_network/network.lua
index 00c001e50..0fffd32b6 100644
--- a/modules/admin-full/luasrc/model/cbi/admin_network/network.lua
+++ b/modules/admin-full/luasrc/model/cbi/admin_network/network.lua
@@ -16,12 +16,12 @@ require("luci.sys")
require("luci.tools.webadmin")
-m = Map("network", translate("interfaces"), translate("a_n_ifaces1"))
+m = Map("network", translate("interfaces"))
local created
local netstat = luci.sys.net.deviceinfo()
-s = m:section(TypedSection, "interface", translate("interfaces"))
+s = m:section(TypedSection, "interface", "")
s.addremove = true
s.extedit = luci.http.getenv("REQUEST_URI") .. "/%s"
s.template = "cbi/tblsection"
@@ -50,6 +50,9 @@ function up.write(self, section, value)
os.execute(call .. " " .. section)
end
+ifname = s:option(DummyValue, "ifname", translate("device"))
+ifname.stateful = true
+
hwaddr = s:option(DummyValue, "_hwaddr")
function hwaddr.cfgvalue(self, section)
local ix = self.map:stateget(section, "ifname") or ""
@@ -57,17 +60,14 @@ function hwaddr.cfgvalue(self, section)
end
-ipaddr = s:option(DummyValue, "ipaddr")
+ipaddr = s:option(DummyValue, "ipaddr", translate("addresses"))
function ipaddr.cfgvalue(self, section)
- local ip = self.map:stateget(section, "ipaddr")
- local nm = self.map:stateget(section, "netmask")
-
- local parsed = ip and luci.ip.IPv4(ip, nm)
- return parsed and parsed:string() or ""
+ local addr = luci.tools.webadmin.network_get_addresses(section)
+ return table.concat(addr, ", ")
end
-txrx = s:option(DummyValue, "_rx", "TX / RX")
+txrx = s:option(DummyValue, "_txrx")
function txrx.cfgvalue(self, section)
local ix = self.map:stateget(section, "ifname")
@@ -81,7 +81,7 @@ function txrx.cfgvalue(self, section)
return string.format("%s / %s", tx, rx)
end
-errors = s:option(DummyValue, "_err", "Errors", "TX / RX")
+errors = s:option(DummyValue, "_err")
function errors.cfgvalue(self, section)
local ix = self.map:stateget(section, "ifname")