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("dhcp", "Address Assignment")
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("Active Leases"))
38 ip = v:option(DummyValue, 3, translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Address"))
40 mac = v:option(DummyValue, 2, translate("<abbr title=\"Media Access Control\">MAC</abbr>-Address"))
42 ltime = v:option(DummyValue, 1, translate("Leasetime remaining"))
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, "host")
52 s.template = "cbi/tblsection"
54 hn = s:option(Value, "name", translate("Hostname"))
55 mac = s:option(Value, "mac", translate("<abbr title=\"Media Access Control\">MAC</abbr>-Address"))
56 ip = s:option(Value, "ip", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Address"))
57 sys.net.arptable(function(entry)
58 ip:value(entry["IP address"])
61 entry["HW address"] .. " (" .. entry["IP address"] .. ")"