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
15 require("luci.tools.webadmin")
16 m2 = Map("luci_ethers", translate("dhcp_leases"))
18 local leasefn, leasefp, leases
19 luci.model.uci.foreach("dhcp", "dnsmasq",
21 leasefn = section.leasefile
24 local leasefp = leasefn and luci.fs.access(leasefn) and io.lines(leasefn)
27 for lease in leasefp do
28 table.insert(leases, luci.util.split(lease, " "))
33 v = m2:section(TypedSection, "_virtual", translate("dhcp_leases_active"))
36 v.template = "cbi/tblsection"
38 function v.cfgsections(self)
41 table.insert(sections, i)
46 ip = v:option(DummyValue, "ip", translate("ipaddress"))
47 function ip.cfgvalue(self, section)
48 return leases[section][3]
51 mac = v:option(DummyValue, "mac", translate("macaddress"))
52 function mac.cfgvalue(self, section)
53 return leases[section][2]
56 ltime = v:option(DummyValue, "time", translate("dhcp_timeremain"))
57 function ltime.cfgvalue(self, section)
58 return luci.tools.webadmin.date_format(
59 os.difftime(tonumber(leases[section][1]), os.time())
64 s = m2:section(TypedSection, "static_lease", translate("luci_ethers"))
67 s.template = "cbi/tblsection"
69 mac = s:option(Value, "macaddr", translate("macaddress"))
70 ip = s:option(Value, "ipaddr", translate("ipaddress"))
71 for i, dataset in ipairs(luci.sys.net.arptable()) do
72 ip:value(dataset["IP address"])
73 mac:value(dataset["HW address"],
74 dataset["HW address"] .. " (" .. dataset["IP address"] .. ")")