2 LuCI - Lua Configuration Interface
4 Copyright 2008 Steven Barth <steven@midlink.org>
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
14 require("luci.tools.webadmin")
15 require("luci.model.uci")
18 m = Map("dhcp", "DHCP")
20 s = m:section(TypedSection, "dhcp", "")
24 iface = s:option(ListValue, "interface", translate("Interface"))
25 luci.tools.webadmin.cbi_add_networks(iface)
27 local uci = luci.model.uci.cursor()
28 uci:foreach("network", "interface",
30 if section[".name"] ~= "loopback" then
31 iface.default = iface.default or section[".name"]
32 s:depends("interface", section[".name"])
36 uci:foreach("network", "alias",
38 iface:value(section[".name"])
39 s:depends("interface", section[".name"])
42 s:option(Value, "start", translate("Start")).rmempty = true
44 s:option(Value, "limit", translate("Limit")).rmempty = true
46 s:option(Value, "leasetime").rmempty = true
48 local dd = s:option(Flag, "dynamicdhcp")
50 function dd.cfgvalue(self, section)
51 return Flag.cfgvalue(self, section) or "1"
54 s:option(Value, "name", translate("Name")).optional = true
56 ignore = s:option(Flag, "ignore")
57 ignore.optional = true
59 s:option(Value, "netmask", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Netmask")).optional = true
61 s:option(Flag, "force").optional = true
63 s:option(DynamicList, "dhcp_option").optional = true
66 for i, n in ipairs(s.children) do
67 if n ~= iface and n ~= ignore then
68 n:depends("ignore", "")