modules/admin-full: Reworked DHCP configuration
[project/luci.git] / modules / admin-full / luasrc / model / cbi / admin_network / dhcp.lua
index 20adcdf..af018ea 100644 (file)
@@ -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")
 
@@ -21,15 +22,22 @@ s.addremove = true
 s.anonymous = true
 
 iface = s:option(ListValue, "interface", translate("interface"))
+luci.tools.webadmin.cbi_add_networks(iface)
+
 luci.model.uci.foreach("network", "interface",
        function (section)
                if section[".name"] ~= "loopback" then
                        iface.default = iface.default or section[".name"]
-                       iface:value(section[".name"])
                        s:depends("interface", section[".name"])
                end
        end)
 
+luci.model.uci.foreach("network", "alias",
+       function (section)
+               iface:value(section[".name"])
+               s:depends("interface", section[".name"])
+       end)
+
 s:option(Value, "start", translate("start")).rmempty = true
 
 s:option(Value, "limit", translate("limit")).rmempty = true
@@ -40,31 +48,23 @@ s:option(Flag, "dynamicdhcp").rmempty = 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(Flag, "force").optional = true
 
-for i, line in pairs(luci.sys.execl("dnsmasq --help dhcp")) do
+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
 
-m2 = Map("luci_ethers", translate("luci_ethers"))
 
-s = m2:section(TypedSection, "static_lease", "")
-s.addremove = true
-s.anonymous = true
-s.template = "cbi/tblsection"
-
-mac = s:option(Value, "macaddr", translate("macaddress"))
-ip = s:option(Value, "ipaddr", translate("ipaddress"))
-for i, dataset in ipairs(luci.sys.net.arptable()) do
-       ip:value(dataset["IP address"])
-       mac:value(dataset["HW address"],
-        dataset["HW address"] .. " (" .. dataset["IP address"] .. ")")
+for i, n in ipairs(s.children) do
+       if n ~= iface and n ~= ignore then
+               n:depends("ignore", "")
+       end
 end
 
-       
-return m, m2
+return m
\ No newline at end of file