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=6f4aeb13ee6ac54bada0c64b466cc5ba54fa7c40;hp=e9ab6c93d7d5aea7ba0d440fa455ece7b401dafc;hb=7c765875884d6866c53b63757731b079bace2e9b;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..6f4aeb13e 100644 --- a/modules/admin-full/luasrc/model/cbi/admin_network/dhcp.lua +++ b/modules/admin-full/luasrc/model/cbi/admin_network/dhcp.lua @@ -11,8 +11,9 @@ 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") @@ -20,45 +21,52 @@ 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, "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 +s:option(Value, "name", translate("Name")).optional = true -s:option(Flag, "ignore").optional = true +ignore = s:option(Flag, "ignore") +ignore.optional = true -s:option(Value, "netmask", translate("netmask")).optional = true +s:option(Value, "netmask", translate("IPv4-Netmask")).optional = true s:option(Flag, "force").optional = true -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 +s:option(DynamicList, "dhcp_option").optional = true -m2 = Map("luci_ethers", translate("luci_ethers")) -s = m2:section(TypedSection, "static_lease", "") -s.addremove = true -s.anonymous = true -s.template = "cbi/tblsection" - -s:option(Value, "macaddr", translate("macaddress")) -s:option(Value, "ipaddr", translate("ipaddress")) +for i, n in ipairs(s.children) do + if n ~= iface and n ~= ignore then + n:depends("ignore", "") + end +end - -return m, m2 \ No newline at end of file +return m