X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=modules%2Fadmin-full%2Fluasrc%2Fmodel%2Fcbi%2Fadmin_network%2Fdhcp.lua;h=13a00ab82e9ef39544b3bb0a9e672009cb9f147b;hp=e9ab6c93d7d5aea7ba0d440fa455ece7b401dafc;hb=603ea189d7748ff4edd6b3e03e3de11e6b22e5ac;hpb=8bb8b7c09cee818246312a637d846be491e171d3
diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/dhcp.lua b/modules/admin-full/luasrc/model/cbi/admin_network/dhcp.lua
index e9ab6c93d..13a00ab82 100644
--- a/modules/admin-full/luasrc/model/cbi/admin_network/dhcp.lua
+++ b/modules/admin-full/luasrc/model/cbi/admin_network/dhcp.lua
@@ -11,54 +11,73 @@ You may obtain a copy of the License at
$Id$
]]--
+require("luci.tools.webadmin")
require("luci.model.uci")
-require("luci.sys")
+require("luci.util")
-m = Map("dhcp", "DHCP")
+m = Map("dhcp",
+ translate("DHCP"),
+ translate("With DHCP network " ..
+ "members can automatically receive their network settings (IP-address, netmask, DNS-server, ...)."))
s = m:section(TypedSection, "dhcp", "")
s.addremove = true
s.anonymous = true
-iface = s:option(ListValue, "interface", translate("interface"))
-luci.model.uci.foreach("network", "interface",
+iface = s:option(ListValue, "interface", translate("Interface"))
+luci.tools.webadmin.cbi_add_networks(iface)
+
+local uci = luci.model.uci.cursor()
+uci:foreach("network", "interface",
function (section)
if section[".name"] ~= "loopback" then
- iface:value(section[".name"])
+ iface.default = iface.default or section[".name"]
s:depends("interface", section[".name"])
end
end)
-s:option(Value, "start", translate("start")).rmempty = true
+uci:foreach("network", "alias",
+ function (section)
+ iface:value(section[".name"])
+ s:depends("interface", section[".name"])
+ end)
-s:option(Value, "limit", translate("limit")).rmempty = true
+s:option(Value, "start", translate("Start")).rmempty = true
-s:option(Value, "leasetime").rmempty = true
+s:option(Value, "limit", translate("Limit")).rmempty = true
-s:option(Flag, "dynamicdhcp").rmempty = true
+s:option(Value, "leasetime", translate("Leasetime")).rmempty = true
-s:option(Value, "name", translate("name")).optional = true
+local dd = s:option(Flag, "dynamicdhcp",
+ translate("Dynamic DHCP"))
-s:option(Flag, "ignore").optional = true
+dd.rmempty = false
+function dd.cfgvalue(self, section)
+ return Flag.cfgvalue(self, section) or "1"
+end
-s:option(Value, "netmask", translate("netmask")).optional = true
+s:option(Value, "name", translate("Name")).optional = true
-s:option(Flag, "force").optional = true
+ignore = s:option(Flag, "ignore",
+ translate("Ignore interface"),
+ translate("disable DHCP for " ..
+ "this interface"))
-for i, line in pairs(luci.sys.execl("dnsmasq --help dhcp")) do
- k, v = line:match("([^ ]+) +([^ ]+)")
- s:option(Value, "dhcp"..k, v).optional = true
-end
+ignore.optional = true
-m2 = Map("luci_ethers", translate("luci_ethers"))
+s:option(Value, "netmask", translate("IPv4-Netmask")).optional = true
-s = m2:section(TypedSection, "static_lease", "")
-s.addremove = true
-s.anonymous = true
-s.template = "cbi/tblsection"
+s:option(Flag, "force", translate("Force")).optional = true
+
+s:option(DynamicList, "dhcp_option", translate("DHCP-Options")).optional = true
-s:option(Value, "macaddr", translate("macaddress"))
-s:option(Value, "ipaddr", translate("ipaddress"))
-
-return m, m2
\ No newline at end of file
+for i, n in ipairs(s.children) do
+ if n ~= iface and n ~= ignore then
+ n:depends("ignore", "")
+ end
+end
+
+return m