2008-06-08 08:14:31 +00:00
|
|
|
--[[
|
|
|
|
LuCI - Lua Configuration Interface
|
|
|
|
|
|
|
|
Copyright 2008 Steven Barth <steven@midlink.org>
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
$Id$
|
|
|
|
]]--
|
2008-05-25 17:00:30 +00:00
|
|
|
require("luci.model.uci")
|
|
|
|
require("luci.sys")
|
2008-04-11 19:03:30 +00:00
|
|
|
|
2008-06-08 13:03:55 +00:00
|
|
|
m = Map("dhcp", "DHCP")
|
2008-04-11 19:03:30 +00:00
|
|
|
|
2008-06-06 18:27:59 +00:00
|
|
|
s = m:section(TypedSection, "dhcp", "")
|
2008-04-11 19:03:30 +00:00
|
|
|
s.addremove = true
|
|
|
|
s.anonymous = true
|
|
|
|
|
2008-06-09 10:10:29 +00:00
|
|
|
iface = s:option(ListValue, "interface", translate("interface"))
|
2008-06-05 19:16:38 +00:00
|
|
|
luci.model.uci.foreach("network", "interface",
|
|
|
|
function (section)
|
|
|
|
if section[".name"] ~= "loopback" then
|
2008-08-04 23:12:14 +00:00
|
|
|
iface.default = iface.default or section[".name"]
|
2008-06-05 19:16:38 +00:00
|
|
|
iface:value(section[".name"])
|
|
|
|
s:depends("interface", section[".name"])
|
|
|
|
end
|
|
|
|
end)
|
2008-04-11 19:03:30 +00:00
|
|
|
|
2008-06-09 10:10:29 +00:00
|
|
|
s:option(Value, "start", translate("start")).rmempty = true
|
2008-04-11 19:03:30 +00:00
|
|
|
|
2008-06-09 10:10:29 +00:00
|
|
|
s:option(Value, "limit", translate("limit")).rmempty = true
|
2008-04-27 22:57:29 +00:00
|
|
|
|
2008-06-08 13:03:55 +00:00
|
|
|
s:option(Value, "leasetime").rmempty = true
|
2008-04-11 19:03:30 +00:00
|
|
|
|
2008-06-08 13:03:55 +00:00
|
|
|
s:option(Flag, "dynamicdhcp").rmempty = true
|
2008-04-11 19:03:30 +00:00
|
|
|
|
2008-06-09 10:10:29 +00:00
|
|
|
s:option(Value, "name", translate("name")).optional = true
|
2008-04-11 19:03:30 +00:00
|
|
|
|
2008-06-08 13:03:55 +00:00
|
|
|
s:option(Flag, "ignore").optional = true
|
2008-04-11 19:03:30 +00:00
|
|
|
|
2008-06-09 10:10:29 +00:00
|
|
|
s:option(Value, "netmask", translate("netmask")).optional = true
|
2008-04-11 19:03:30 +00:00
|
|
|
|
2008-06-08 13:03:55 +00:00
|
|
|
s:option(Flag, "force").optional = true
|
2008-04-11 19:03:30 +00:00
|
|
|
|
2008-05-25 17:00:30 +00:00
|
|
|
for i, line in pairs(luci.sys.execl("dnsmasq --help dhcp")) do
|
2008-04-11 19:03:30 +00:00
|
|
|
k, v = line:match("([^ ]+) +([^ ]+)")
|
|
|
|
s:option(Value, "dhcp"..k, v).optional = true
|
|
|
|
end
|
2008-07-15 16:28:29 +00:00
|
|
|
|
|
|
|
m2 = Map("luci_ethers", translate("luci_ethers"))
|
|
|
|
|
|
|
|
s = m2:section(TypedSection, "static_lease", "")
|
|
|
|
s.addremove = true
|
|
|
|
s.anonymous = true
|
|
|
|
s.template = "cbi/tblsection"
|
|
|
|
|
2008-08-04 23:48:41 +00:00
|
|
|
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
|
2008-07-15 16:28:29 +00:00
|
|
|
|
2008-04-11 19:03:30 +00:00
|
|
|
|
2008-08-04 23:12:14 +00:00
|
|
|
return m, m2
|