luci/modules/admin-full/luasrc/model/cbi/admin_network/dhcp.lua

73 lines
1.7 KiB
Lua
Raw Normal View History

--[[
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$
]]--
require("luci.tools.webadmin")
require("luci.model.uci")
require("luci.util")
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
iface = s:option(ListValue, "interface", translate("Interface"))
luci.tools.webadmin.cbi_add_networks(iface)
2008-08-26 23:00:44 +00:00
local uci = luci.model.uci.cursor()
uci:foreach("network", "interface",
function (section)
if section[".name"] ~= "loopback" then
iface.default = iface.default or section[".name"]
s:depends("interface", section[".name"])
end
end)
2008-04-11 19:03:30 +00:00
2008-08-26 23:00:44 +00:00
uci:foreach("network", "alias",
function (section)
iface:value(section[".name"])
s:depends("interface", section[".name"])
end)
s:option(Value, "start", translate("Start")).rmempty = true
2008-04-11 19:03:30 +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
local dd = s:option(Flag, "dynamicdhcp")
dd.rmempty = false
function dd.cfgvalue(self, section)
return Flag.cfgvalue(self, section) or "1"
end
2008-04-11 19:03:30 +00:00
s:option(Value, "name", translate("Name")).optional = true
2008-04-11 19:03:30 +00:00
2008-08-14 11:50:44 +00:00
ignore = s:option(Flag, "ignore")
ignore.optional = true
2008-04-11 19:03:30 +00:00
s:option(Value, "netmask", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-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-09-07 23:50:58 +00:00
s:option(DynamicList, "dhcp_option").optional = true
2008-08-14 11:50:44 +00:00
for i, n in ipairs(s.children) do
if n ~= iface and n ~= ignore then
n:depends("ignore", "")
end
end
return m