2 LuCI - Lua Configuration Interface
4 Copyright 2008 Steven Barth <steven@midlink.org>
5 Copyright 2010 Jo-Philipp Wich <xm@subsignal.org>
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-2.0
16 local uci = require "luci.model.uci".cursor()
17 local sys = require "luci.sys"
18 local wa = require "luci.tools.webadmin"
19 local fs = require "nixio.fs"
21 m2 = Map("dhcp", translate("dhcp_leases"))
23 local leasefn, leasefp, leases
24 uci:foreach("dhcp", "dnsmasq",
26 leasefn = section.leasefile
29 local leasefp = leasefn and fs.access(leasefn) and io.lines(leasefn)
32 for lease in leasefp do
33 table.insert(leases, luci.util.split(lease, " "))
38 v = m2:section(Table, leases, translate("dhcp_leases_active"))
39 ip = v:option(DummyValue, 3, translate("ipaddress"))
41 mac = v:option(DummyValue, 2, translate("macaddress"))
43 ltime = v:option(DummyValue, 1, translate("dhcp_timeremain"))
44 function ltime.cfgvalue(self, ...)
45 local value = DummyValue.cfgvalue(self, ...)
46 return wa.date_format(os.difftime(tonumber(value), os.time()))
50 s = m2:section(TypedSection, "host", translate("luci_ethers"))
53 s.template = "cbi/tblsection"
55 name = s:option(Value, "name", translate("hostname"))
56 mac = s:option(Value, "mac", translate("macaddress"))
57 ip = s:option(Value, "ip", translate("ipaddress"))
58 sys.net.arptable(function(entry)
59 ip:value(entry["IP address"])
62 entry["HW address"] .. " (" .. entry["IP address"] .. ")"