modules/admin-full: Added support for interface aliases
[project/luci.git] / modules / admin-full / luasrc / model / cbi / admin_network / dhcp.lua
index e9ab6c9..b50b05c 100644 (file)
@@ -13,6 +13,7 @@ $Id$
 ]]--
 require("luci.model.uci")
 require("luci.sys")
+require("luci.util")
 
 m = Map("dhcp", "DHCP")
 
@@ -24,11 +25,18 @@ iface = s:option(ListValue, "interface", translate("interface"))
 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
@@ -45,7 +53,7 @@ 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
@@ -57,8 +65,13 @@ s.addremove = true
 s.anonymous = true
 s.template = "cbi/tblsection"
 
-s:option(Value, "macaddr", translate("macaddress"))
-s:option(Value, "ipaddr", translate("ipaddress"))
+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"] .. ")")
+end
 
        
-return m, m2
\ No newline at end of file
+return m, m2