modules/admin-{mini,full}: rename "mode" to "hwmode"
[project/luci.git] / modules / admin-full / luasrc / model / cbi / admin_network / dhcp.lua
index af018eaa8510b55bfc12137b10e2058a711b4125..872e6444d139e3a6d20036f9a76b6b604250a892 100644 (file)
@@ -24,7 +24,8 @@ s.anonymous = true
 iface = s:option(ListValue, "interface", translate("interface"))
 luci.tools.webadmin.cbi_add_networks(iface)
 
-luci.model.uci.foreach("network", "interface",
+local uci = luci.model.uci.cursor()
+uci:foreach("network", "interface",
        function (section)
                if section[".name"] ~= "loopback" then
                        iface.default = iface.default or section[".name"]
@@ -32,7 +33,7 @@ luci.model.uci.foreach("network", "interface",
                end
        end)
 
-luci.model.uci.foreach("network", "alias",
+uci:foreach("network", "alias",
        function (section)
                iface:value(section[".name"])
                s:depends("interface", section[".name"])
@@ -44,7 +45,11 @@ s:option(Value, "limit", translate("limit")).rmempty = true
 
 s:option(Value, "leasetime").rmempty = true
 
-s:option(Flag, "dynamicdhcp").rmempty = true
+local dd = s:option(Flag, "dynamicdhcp")
+dd.rmempty = false
+function dd.cfgvalue(self, section)
+       return Flag.cfgvalue(self, section) or "1"
+end
 
 s:option(Value, "name", translate("name")).optional = true
 
@@ -55,10 +60,7 @@ s:option(Value, "netmask", translate("netmask")).optional = true
 
 s:option(Flag, "force").optional = true
 
-for i, line in pairs(luci.util.execl("dnsmasq --help dhcp")) do
-       k, v = line:match("([^ ]+) +([^ ]+)")
-       s:option(Value, "dhcp"..k, v).optional = true
-end
+s:option(DynamicList, "dhcp_option").optional = true
 
 
 for i, n in ipairs(s.children) do
@@ -67,4 +69,4 @@ for i, n in ipairs(s.children) do
        end
 end
 
-return m
\ No newline at end of file
+return m