Moved luci.sys.exec, luci.sys.execl and luci.sys.bigendian to luci.util
[project/luci.git] / modules / admin-full / luasrc / model / cbi / admin_network / dhcp.lua
index e9ab6c93d7d5aea7ba0d440fa455ece7b401dafc..f85eb5219825f02f7856db3ebcd1cf7bfb826c7c 100644 (file)
@@ -13,6 +13,7 @@ $Id$
 ]]--
 require("luci.model.uci")
 require("luci.sys")
 ]]--
 require("luci.model.uci")
 require("luci.sys")
+require("luci.util")
 
 m = Map("dhcp", "DHCP")
 
 
 m = Map("dhcp", "DHCP")
 
@@ -24,6 +25,7 @@ iface = s:option(ListValue, "interface", translate("interface"))
 luci.model.uci.foreach("network", "interface",
        function (section)
                if section[".name"] ~= "loopback" then
 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
                        iface:value(section[".name"])
                        s:depends("interface", section[".name"])
                end
@@ -45,7 +47,7 @@ s:option(Value, "netmask", translate("netmask")).optional = true
 
 s:option(Flag, "force").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
        k, v = line:match("([^ ]+) +([^ ]+)")
        s:option(Value, "dhcp"..k, v).optional = true
 end
@@ -57,8 +59,13 @@ s.addremove = true
 s.anonymous = true
 s.template = "cbi/tblsection"
 
 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