Added callback for local hosts

This commit is contained in:
Luca Deri 2018-03-27 23:38:16 +02:00
parent 0751147ff8
commit 945a9f9789

View file

@ -167,6 +167,31 @@ function callback_utils.foreachHost(ifname, deadline, callback)
return true
end
-- ########################################################
-- Iterates each active host on the ifname interface.
-- Each host is passed to the callback with some more information.
function callback_utils.foreachLocalHost(ifname, deadline, callback)
local hostbase
interface.select(ifname)
local iterator = callback_utils.getLocalHostsIterator(false --[[ no details ]])
for hostname, hoststats in iterator do
if ((deadline ~= nil) and (os.time() >= deadline)) then
-- Out of time
return false
end
if callback(hostname, hoststats) == false then
return false
end
end
return true
end
-- Iterates each device on the ifname interface.
-- Each device is passed to the callback with some more information.
function callback_utils.foreachDevice(ifname, deadline, callback)