summaryrefslogtreecommitdiffhomepage
path: root/modules/admin-core
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2012-08-17 15:06:46 +0000
committerJo-Philipp Wich <jow@openwrt.org>2012-08-17 15:06:46 +0000
commitdce04bbcb2b2b41898281ed5de0622705bf17b1e (patch)
treeb8428d52f69ac79dc4a7c6ae4fd8cf0741411477 /modules/admin-core
parent044b011051086b9cb845e497c0a620cdecd038a6 (diff)
modules/admin-core, modules/admin-full: implement display support for dnsmasq dhcpv6 leases
Diffstat (limited to 'modules/admin-core')
-rw-r--r--modules/admin-core/luasrc/tools/status.lua39
1 files changed, 30 insertions, 9 deletions
diff --git a/modules/admin-core/luasrc/tools/status.lua b/modules/admin-core/luasrc/tools/status.lua
index 2eef3e0e1c..cd543f71e8 100644
--- a/modules/admin-core/luasrc/tools/status.lua
+++ b/modules/admin-core/luasrc/tools/status.lua
@@ -16,7 +16,7 @@ module("luci.tools.status", package.seeall)
local uci = require "luci.model.uci".cursor()
-function dhcp_leases()
+local function dhcp_leases_common(family)
local rv = { }
local nfs = require "nixio.fs"
local leasefile = "/var/dhcp.leases"
@@ -36,14 +36,23 @@ function dhcp_leases()
if not ln then
break
else
- local ts, mac, ip, name = ln:match("^(%d+) (%S+) (%S+) (%S+)")
- if ts and mac and ip and name then
- rv[#rv+1] = {
- expires = os.difftime(tonumber(ts) or 0, os.time()),
- macaddr = mac,
- ipaddr = ip,
- hostname = (name ~= "*") and name
- }
+ local ts, mac, ip, name, duid = ln:match("^(%d+) (%S+) (%S+) (%S+) (%S+)")
+ if ts and mac and ip and name and duid then
+ if family == 4 and not ip:match(":") then
+ rv[#rv+1] = {
+ expires = os.difftime(tonumber(ts) or 0, os.time()),
+ macaddr = mac,
+ ipaddr = ip,
+ hostname = (name ~= "*") and name
+ }
+ elseif family == 6 and ip:match(":") then
+ rv[#rv+1] = {
+ expires = os.difftime(tonumber(ts) or 0, os.time()),
+ ip6addr = ip,
+ duid = (duid ~= "*") and duid,
+ hostname = (name ~= "*") and name
+ }
+ end
end
end
end
@@ -53,6 +62,18 @@ function dhcp_leases()
return rv
end
+function dhcp_leases()
+ return dhcp_leases_common(4)
+end
+
+function dhcp6_leases()
+ if luci.sys.call("dnsmasq --version 2>/dev/null | grep -q ' DHCPv6 '") == 0 then
+ return dhcp_leases_common(6)
+ else
+ return nil
+ end
+end
+
function wifi_networks()
local rv = { }
local ntm = require "luci.model.network".init()