summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2011-09-22 01:40:26 +0000
committerJo-Philipp Wich <jow@openwrt.org>2011-09-22 01:40:26 +0000
commit59e95ddcadf5caac70d6f6228bf0c519297cc551 (patch)
tree6f85bcc0d243147fc21074f157c3954a8d2d78a6
parente2a1ffb59d689644e5fc7030838906f0ec9f30f6 (diff)
modules/admin-full, libs/web: various interface handling fixes in network settings
-rw-r--r--libs/web/luasrc/view/cbi/network_ifacelist.htm11
-rw-r--r--modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua34
2 files changed, 32 insertions, 13 deletions
diff --git a/libs/web/luasrc/view/cbi/network_ifacelist.htm b/libs/web/luasrc/view/cbi/network_ifacelist.htm
index 192bcac72..beca1599e 100644
--- a/libs/web/luasrc/view/cbi/network_ifacelist.htm
+++ b/libs/web/luasrc/view/cbi/network_ifacelist.htm
@@ -36,14 +36,16 @@
<ul style="margin:0; list-style-type:none">
<% for _, iface in ipairs(ifaces) do
local link = iface:adminlink()
- if (not self.nobridges or not iface:is_bridge()) and iface:name() ~= self.exclude then %>
+ if (not self.nobridges or not iface:is_bridge()) and
+ (not self.noinactive or iface:is_up()) and
+ iface:name() ~= self.exclude
+ then %>
<li>
<input class="cbi-input-<%=self.widget or "radio"%>" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%=
attr("type", self.widget or "radio") ..
attr("id", cbid .. "." .. iface:name()) ..
attr("name", cbid) .. attr("value", iface:name()) ..
- ifattr(checked[iface:name()], "checked", "checked") ..
- ifattr(iface:type() == "wifi" and not iface:is_up(), "disabled", "disabled")
+ ifattr(checked[iface:name()], "checked", "checked")
%> /> &#160;
<label<%=attr("for", cbid .. "." .. iface:name())%>>
<% if link then -%><a href="<%=link%>"><% end -%>
@@ -58,7 +60,8 @@
<input class="cbi-input-<%=self.widget or "radio"%>" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%=
attr("type", self.widget or "radio") ..
attr("id", cbid .. "_custom") ..
- attr("name", cbid)
+ attr("name", cbid) ..
+ attr("value", " ")
%> /> &#160;
<label<%=attr("for", cbid .. "_custom")%>>
<img title="<%:Custom Interface%>" style="width:16px; height:16px; vertical-align:middle" src="<%=resource%>/icons/ethernet_disabled.png" />
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 3aef9d71f..5b298ea12 100644
--- a/modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua
+++ b/modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua
@@ -72,7 +72,7 @@ if m:formvalue("cbid.dhcp._enable._enable") then
return
end
-local ifc = net:get_interfaces()[1]
+local ifc = net:get_interface()
s = m:section(NamedSection, arg[1], "interface", translate("Common Configuration"))
s.addremove = false
@@ -117,7 +117,7 @@ if not ( has_pppd and has_pppoe and has_pppoa and has_3g and has_pptp ) then
p.description = translate("You need to install \"comgt\" for UMTS/GPRS, \"ppp-mod-pppoe\" for PPPoE, \"ppp-mod-pppoa\" for PPPoA or \"pptp\" for PPtP support")
end
-auto = s:taboption("physical", Flag, "auto", translate("Bring up on boot"))
+auto = s:taboption("physical", Flag, "auto", translate("Bring up on boot"))
auto.default = (m.uci:get("network", arg[1], "proto") == "none") and auto.disabled or auto.enabled
br = s:taboption("physical", Flag, "type", translate("Bridge interfaces"), translate("creates a bridge over specified interface(s)"))
@@ -136,6 +136,7 @@ ifname_single = s:taboption("physical", Value, "ifname_single", translate("Inter
ifname_single.template = "cbi/network_ifacelist"
ifname_single.widget = "radio"
ifname_single.nobridges = true
+ifname_single.rmempty = false
ifname_single.network = arg[1]
ifname_single:depends({ type = "", proto = "static" })
ifname_single:depends({ type = "", proto = "dhcp" })
@@ -153,35 +154,49 @@ function ifname_single.write(self, s, val)
local n = nw:get_network(s)
if n then
local i
+ local new_ifs = { }
+ local old_ifs = { }
+
for _, i in ipairs(n:get_interfaces()) do
- n:del_interface(i)
+ old_ifs[#old_ifs+1] = i:name()
end
for i in ut.imatch(val) do
- n:add_interface(i)
+ new_ifs[#new_ifs+1] = i
-- if this is not a bridge, only assign first interface
if self.option == "ifname_single" then
break
end
end
- end
-end
-function ifname_single.remove(self, s)
- self:write(s, "")
+ table.sort(old_ifs)
+ table.sort(new_ifs)
+
+ for i = 1, math.max(#old_ifs, #new_ifs) do
+ if old_ifs[i] ~= new_ifs[i] then
+ for i = 1, #old_ifs do
+ n:del_interface(old_ifs[i])
+ end
+ for i = 1, #new_ifs do
+ n:add_interface(new_ifs[i])
+ end
+ break
+ end
+ end
+ end
end
ifname_multi = s:taboption("physical", Value, "ifname_multi", translate("Interface"))
ifname_multi.template = "cbi/network_ifacelist"
ifname_multi.nobridges = true
+ifname_multi.rmempty = false
ifname_multi.network = arg[1]
ifname_multi.widget = "checkbox"
ifname_multi:depends("type", "bridge")
ifname_multi.cfgvalue = ifname_single.cfgvalue
ifname_multi.write = ifname_single.write
-ifname_multi.remove = ifname_single.remove
if has_firewall then
@@ -235,6 +250,7 @@ gw = s:taboption("general", Value, "gateway", translate("<abbr title=\"Internet
gw.optional = true
gw.datatype = "ip4addr"
gw:depends("proto", "static")
+gw:depends("proto", "dhcp")
bcast = s:taboption("general", Value, "broadcast", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Broadcast"))
bcast.optional = true