blob: a01a7fcc8422455b82ff3e9f81dca8ab0d43cfb5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
import * as rtnl from 'rtnl';
let global;
function get_arp_cache() {
let ret = {};
let cache = rtnl.request(rtnl.const.RTM_GETNEIGH, rtnl.const.NLM_F_DUMP, {});
for (let data in cache)
if (data.lladdr && data.dst)
ret[data.dst] = data.lladdr;
return ret;
}
function refresh() {
let cache = get_arp_cache();
for (let entry in cache) {
let mac = cache[entry];
if (!match(mac, /00:00:00.*/) &&
!match(mac, /^33:33.*/) &&
!match(mac, /^01:00:5e.*/) &&
!match(mac, /^ff:ff:ff.*/)) {
global.device_add_data(mac, "");
global.device_refresh(mac);
}
}
}
function init(gl) {
global = gl;
}
return { init, refresh };
|