From 213595ce858c53189b9f585f0d0453aeae63c8d0 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Thu, 22 Jan 2015 18:45:28 +0100 Subject: luci-mod-admin-full: convert luci.sys.net.arptable() to luci.ip.neighbors() Signed-off-by: Jo-Philipp Wich --- .../luasrc/model/cbi/admin_network/dhcp.lua | 13 ++++++------- .../luasrc/model/cbi/admin_network/hosts.lua | 18 ++++++++---------- 2 files changed, 14 insertions(+), 17 deletions(-) (limited to 'modules/luci-mod-admin-full/luasrc/model') diff --git a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/dhcp.lua b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/dhcp.lua index 88e81bb18c..997a9274d2 100644 --- a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/dhcp.lua +++ b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/dhcp.lua @@ -1,7 +1,7 @@ -- Copyright 2008 Steven Barth -- Licensed to the public under the Apache License 2.0. -local sys = require "luci.sys" +local ipc = require "luci.ip" m = Map("dhcp", translate("DHCP and DNS"), translate("Dnsmasq is a combined IPv6-Suffix (hex)")) -sys.net.arptable(function(entry) - ip:value(entry["IP address"]) - mac:value( - entry["HW address"], - entry["HW address"] .. " (" .. entry["IP address"] .. ")" - ) +ipc.neighbors({ family = 4 }, function(n) + if n.mac and n.dest then + ip:value(n.dest:string()) + mac:value(n.mac, "%s (%s)" %{ n.mac, n.dest:string() }) + end end) function ip.validate(self, value, section) diff --git a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/hosts.lua b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/hosts.lua index da7c1181f7..fafacf35c5 100644 --- a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/hosts.lua +++ b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/hosts.lua @@ -1,9 +1,9 @@ -- Copyright 2008 Steven Barth --- Copyright 2010 Jo-Philipp Wich +-- Copyright 2010-2015 Jo-Philipp Wich -- Licensed to the public under the Apache License 2.0. -require("luci.sys") -require("luci.util") +local ipc = require "luci.ip" + m = Map("dhcp", translate("Hostnames")) s = m:section(TypedSection, "domain", translate("Host entries")) @@ -19,12 +19,10 @@ ip = s:option(Value, "ip", translate("IP address")) ip.datatype = "ipaddr" ip.rmempty = true -local arptable = luci.sys.net.arptable() or {} -for i, dataset in ipairs(arptable) do - ip:value( - dataset["IP address"], - "%s (%s)" %{ dataset["IP address"], dataset["HW address"] } - ) -end +ipc.neighbors({ }, function(n) + if n.mac and n.dest and not n.dest:is6linklocal() then + ip:value(n.dest:string(), "%s (%s)" %{ n.dest:string(), n.mac }) + end +end) return m -- cgit v1.2.3