root/luci/branches/luci-0.8/modules/admin-full/luasrc/model/cbi/admin_network/dhcp.lua @ 3796

Revision 3796, 1.7 KB (checked in by Cyrus, 5 years ago)

Fix behaviour of dynamicdhcp field (thanks to Fabio Mercuri)

  • Property svn:keywords set to Id
Line 
1--[[
2LuCI - Lua Configuration Interface
3
4Copyright 2008 Steven Barth <steven@midlink.org>
5
6Licensed under the Apache License, Version 2.0 (the "License");
7you may not use this file except in compliance with the License.
8You may obtain a copy of the License at
9
10    http://www.apache.org/licenses/LICENSE-2.0
11
12$Id$
13]]--
14require("luci.tools.webadmin")
15require("luci.model.uci")
16require("luci.util")
17
18m = Map("dhcp", "DHCP")
19
20s = m:section(TypedSection, "dhcp", "")
21s.addremove = true
22s.anonymous = true
23
24iface = s:option(ListValue, "interface", translate("interface"))
25luci.tools.webadmin.cbi_add_networks(iface)
26
27local uci = luci.model.uci.cursor()
28uci:foreach("network", "interface",
29    function (section)
30        if section[".name"] ~= "loopback" then
31            iface.default = iface.default or section[".name"]
32            s:depends("interface", section[".name"])
33        end
34    end)
35
36uci:foreach("network", "alias",
37    function (section)
38        iface:value(section[".name"])
39        s:depends("interface", section[".name"])
40    end)
41
42s:option(Value, "start", translate("start")).rmempty = true
43
44s:option(Value, "limit", translate("limit")).rmempty = true
45
46s:option(Value, "leasetime").rmempty = true
47
48local dd = s:option(Flag, "dynamicdhcp")
49dd.rmempty = false
50function dd.cfgvalue(self, section)
51    return Flag.cfgvalue(self, section) or "1"
52end
53
54s:option(Value, "name", translate("name")).optional = true
55
56ignore = s:option(Flag, "ignore")
57ignore.optional = true
58
59s:option(Value, "netmask", translate("netmask")).optional = true
60
61s:option(Flag, "force").optional = true
62
63s:option(DynamicList, "dhcp_option").optional = true
64
65
66for i, n in ipairs(s.children) do
67    if n ~= iface and n ~= ignore then
68        n:depends("ignore", "")
69    end
70end
71
72return m
Note: See TracBrowser for help on using the browser.