modules/admin-core: Added several cross-references to relevant configuration pages
[project/luci.git] / modules / admin-full / luasrc / model / cbi / admin_network / dhcp.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2008 Steven Barth <steven@midlink.org>
5
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
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 $Id$
13 ]]--
14 require("luci.tools.webadmin")
15 require("luci.model.uci")
16 require("luci.sys")
17 require("luci.util")
18
19 m = Map("dhcp", "DHCP")
20
21 s = m:section(TypedSection, "dhcp", "")
22 s.addremove = true
23 s.anonymous = true
24
25 iface = s:option(ListValue, "interface", translate("interface"))
26 luci.tools.webadmin.cbi_add_networks(iface)
27
28 luci.model.uci.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
36 luci.model.uci.foreach("network", "alias",
37 function (section)
38 iface:value(section[".name"])
39 s:depends("interface", section[".name"])
40 end)
41
42 s:option(Value, "start", translate("start")).rmempty = true
43
44 s:option(Value, "limit", translate("limit")).rmempty = true
45
46 s:option(Value, "leasetime").rmempty = true
47
48 s:option(Flag, "dynamicdhcp").rmempty = true
49
50 s:option(Value, "name", translate("name")).optional = true
51
52 ignore = s:option(Flag, "ignore")
53 ignore.optional = true
54
55 s:option(Value, "netmask", translate("netmask")).optional = true
56
57 s:option(Flag, "force").optional = true
58
59 for i, line in pairs(luci.util.execl("dnsmasq --help dhcp")) do
60 k, v = line:match("([^ ]+) +([^ ]+)")
61 s:option(Value, "dhcp"..k, v).optional = true
62 end
63
64
65 for i, n in ipairs(s.children) do
66 if n ~= iface and n ~= ignore then
67 n:depends("ignore", "")
68 end
69 end
70
71
72 m2 = Map("luci_ethers", translate("luci_ethers"))
73
74 s = m2:section(TypedSection, "static_lease", "")
75 s.addremove = true
76 s.anonymous = true
77 s.template = "cbi/tblsection"
78
79 mac = s:option(Value, "macaddr", translate("macaddress"))
80 ip = s:option(Value, "ipaddr", translate("ipaddress"))
81 for i, dataset in ipairs(luci.sys.net.arptable()) do
82 ip:value(dataset["IP address"])
83 mac:value(dataset["HW address"],
84 dataset["HW address"] .. " (" .. dataset["IP address"] .. ")")
85 end
86
87
88 return m, m2