gluon-mesh-batman-adv-core: Announce client count by frequency
This commit is contained in:
parent
4405f39869
commit
89a9d8138c
@ -1,20 +1,55 @@
|
|||||||
local list = io.lines("/sys/kernel/debug/batman_adv/bat0/transtable_local")
|
local iwinfo = require 'iwinfo'
|
||||||
|
|
||||||
local count = 0
|
local counts = { total = 0
|
||||||
local wifi = 0
|
, wifi = 0
|
||||||
|
, wifi24 = 0
|
||||||
|
, wifi5 = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
local list = io.lines("/sys/kernel/debug/batman_adv/bat0/transtable_local")
|
||||||
|
local clients = {}
|
||||||
for line in list do
|
for line in list do
|
||||||
local mac, _, flags, lastseen = line:match("^ %* ([0-9a-f:]+) *(.- )%[(.-)%] +(%d+%.%d+)")
|
local mac, _, flags, lastseen = line:match("^ %* ([0-9a-f:]+) *(.- )%[(.-)%] +(%d+%.%d+)")
|
||||||
if mac then
|
if mac then
|
||||||
if not flags:match('P') then
|
if not flags:match('P') then
|
||||||
count = count + 1
|
counts.total = counts.total + 1
|
||||||
|
clients[mac:lower()] = true
|
||||||
|
|
||||||
if flags:match('W') then
|
if flags:match('W') then
|
||||||
wifi = wifi +1
|
counts.wifi = counts.wifi +1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return { total = count
|
function count_iface_stations(iface)
|
||||||
, wifi = wifi
|
local wifitype = iwinfo.type(iface)
|
||||||
}
|
if wifitype == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local freq = iwinfo[wifitype].frequency(iface)
|
||||||
|
local key
|
||||||
|
if freq >= 2400 and freq < 2500 then
|
||||||
|
key = "wifi24"
|
||||||
|
elseif freq >= 5000 and freq < 6000 then
|
||||||
|
key = "wifi5"
|
||||||
|
else
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
for k, v in pairs(iwinfo[wifitype].assoclist(iface)) do
|
||||||
|
if clients[k:lower()] then
|
||||||
|
counts[key] = counts[key] + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local ifaces = {}
|
||||||
|
uci:foreach("wireless", "wifi-iface", function(s)
|
||||||
|
if s.network == "client" and s.mode == "ap" then
|
||||||
|
count_iface_stations(s.ifname)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
return counts
|
||||||
|
Loading…
Reference in New Issue
Block a user