summaryrefslogtreecommitdiffstats
path: root/modules/admin-full/luasrc/model/cbi/admin_network/dhcp.lua
blob: 872e6444d139e3a6d20036f9a76b6b604250a892 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
--[[
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")

m = Map("dhcp", "DHCP")

s = m:section(TypedSection, "dhcp", "")
s.addremove = true
s.anonymous = true

iface = s:option(ListValue, "interface", translate("interface"))
luci.tools.webadmin.cbi_add_networks(iface)

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)

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

s:option(Value, "leasetime").rmempty = true

local dd = s:option(Flag, "dynamicdhcp")
dd.rmempty = false
function dd.cfgvalue(self, section)
	return Flag.cfgvalue(self, section) or "1"
end

s:option(Value, "name", translate("name")).optional = true

ignore = s:option(Flag, "ignore")
ignore.optional = true

s:option(Value, "netmask", translate("netmask")).optional = true

s:option(Flag, "force").optional = true

s:option(DynamicList, "dhcp_option").optional = true


for i, n in ipairs(s.children) do
	if n ~= iface and n ~= ignore then
		n:depends("ignore", "")
	end
end

return m