modules/admin-full: Display wifi devices as enabled if user removes the disabled...
[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.model.uci")
15 require("luci.sys")
16
17 m = Map("dhcp", "DHCP")
18
19 s = m:section(TypedSection, "dhcp", "")
20 s.addremove = true
21 s.anonymous = true
22
23 iface = s:option(ListValue, "interface", translate("interface"))
24 luci.model.uci.foreach("network", "interface",
25         function (section)
26                 if section[".name"] ~= "loopback" then
27                         iface.default = iface.default or section[".name"]
28                         iface:value(section[".name"])
29                         s:depends("interface", section[".name"])
30                 end
31         end)
32
33 s:option(Value, "start", translate("start")).rmempty = true
34
35 s:option(Value, "limit", translate("limit")).rmempty = true
36
37 s:option(Value, "leasetime").rmempty = true
38
39 s:option(Flag, "dynamicdhcp").rmempty = true
40
41 s:option(Value, "name", translate("name")).optional = true
42
43 s:option(Flag, "ignore").optional = true
44
45 s:option(Value, "netmask", translate("netmask")).optional = true
46
47 s:option(Flag, "force").optional = true
48
49 for i, line in pairs(luci.sys.execl("dnsmasq --help dhcp")) do
50         k, v = line:match("([^ ]+) +([^ ]+)")
51         s:option(Value, "dhcp"..k, v).optional = true
52 end
53
54 m2 = Map("luci_ethers", translate("luci_ethers"))
55
56 s = m2:section(TypedSection, "static_lease", "")
57 s.addremove = true
58 s.anonymous = true
59 s.template = "cbi/tblsection"
60
61 mac = s:option(Value, "macaddr", translate("macaddress"))
62 ip = s:option(Value, "ipaddr", translate("ipaddress"))
63 for i, dataset in ipairs(luci.sys.net.arptable()) do
64         ip:value(dataset["IP address"])
65         mac:value(dataset["HW address"],
66          dataset["HW address"] .. " (" .. dataset["IP address"] .. ")")
67 end
68
69         
70 return m, m2