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 local uci = require "luci.model.uci".cursor()
16 local sys = require "luci.sys"
17 local wa = require "luci.tools.webadmin"
18 local fs = require "nixio.fs"
20 m2 = Map("luci_ethers", translate("dhcp_leases"))
22 local leasefn, leasefp, leases
23 uci:foreach("dhcp", "dnsmasq",
25 leasefn = section.leasefile
28 local leasefp = leasefn and fs.access(leasefn) and io.lines(leasefn)
31 for lease in leasefp do
32 table.insert(leases, luci.util.split(lease, " "))
37 v = m2:section(Table, leases, translate("dhcp_leases_active"))
38 ip = v:option(DummyValue, 3, translate("ipaddress"))
40 mac = v:option(DummyValue, 2, translate("macaddress"))
42 ltime = v:option(DummyValue, 1, translate("dhcp_timeremain"))
43 function ltime.cfgvalue(self, ...)
44 local value = DummyValue.cfgvalue(self, ...)
45 return wa.date_format(os.difftime(tonumber(value), os.time()))
49 s = m2:section(TypedSection, "static_lease", translate("luci_ethers"))
52 s.template = "cbi/tblsection"
54 mac = s:option(Value, "macaddr", translate("macaddress"))
55 ip = s:option(Value, "ipaddr", translate("ipaddress"))
56 sys.net.arptable(function(entry)
57 ip:value(entry["IP address"])
60 entry["HW address"] .. " (" .. entry["IP address"] .. ")"