mirror of https://github.com/openwrt/luci.git
luci-mod-admin-full: convert luci.sys.net.arptable() to luci.ip.neighbors()
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>pull/308/head
parent
577b772824
commit
213595ce85
|
@ -1,7 +1,7 @@
|
|||
-- Copyright 2008 Steven Barth <steven@midlink.org>
|
||||
-- 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 <abbr title=\"Dynamic Host Configuration Protocol" ..
|
||||
|
@ -232,12 +232,11 @@ ip.datatype = "or(ip4addr,'ignore')"
|
|||
|
||||
hostid = s:option(Value, "hostid", translate("<abbr title=\"Internet Protocol Version 6\">IPv6</abbr>-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)
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
-- Copyright 2008 Steven Barth <steven@midlink.org>
|
||||
-- Copyright 2010 Jo-Philipp Wich <jow@openwrt.org>
|
||||
-- Copyright 2010-2015 Jo-Philipp Wich <jow@openwrt.org>
|
||||
-- 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
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<%#
|
||||
Copyright 2008-2009 Steven Barth <steven@midlink.org>
|
||||
Copyright 2008-2013 Jo-Philipp Wich <jow@openwrt.org>
|
||||
Copyright 2008-2015 Jo-Philipp Wich <jow@openwrt.org>
|
||||
Licensed to the public under the Apache License 2.0.
|
||||
-%>
|
||||
|
||||
<%-
|
||||
|
||||
local sys = require "luci.sys"
|
||||
local ip = require "luci.ip"
|
||||
local fs = require "nixio.fs"
|
||||
local utl = require "luci.util"
|
||||
local uci = require "luci.model.uci".cursor()
|
||||
|
@ -90,7 +90,9 @@
|
|||
|
||||
local devices = ntm:get_wifidevs()
|
||||
local arpcache = { }
|
||||
sys.net.arptable(function(e) arpcache[e["HW address"]:upper()] = e["IP address"] end)
|
||||
ip.neighbors({ family = 4 }, function(n)
|
||||
if n.mac and n.dest then arpcache[n.mac:upper()] = n.dest:string() end
|
||||
end)
|
||||
|
||||
local netlist = { }
|
||||
local netdevs = { }
|
||||
|
|
Loading…
Reference in New Issue