Skip to content

Commit a6731e6

Browse files
committed
luci-mod-network: fill ieee-oui.txt from ufp-neigh
With ufp-neigh it is possible to get the vendor of a MAC address. Because arp-scan allows us to specify a txt file for lookup, it is suitable to use ufp-neigh to create a txt file on the spot and populate it with vendors of connected devices. This is only used if ufp is running as service. Signed-off-by: Christian Korber <ckorber@tdt.de>
1 parent e0d557f commit a6731e6

2 files changed

Lines changed: 36 additions & 3 deletions

File tree

modules/luci-mod-network/htdocs/luci-static/resources/view/network/diagnostics.js

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,25 @@
44
'require fs';
55
'require ui';
66
'require uci';
7+
'require rpc';
78
'require network';
89

10+
const callFingerprint = rpc.declare({
11+
object: 'fingerprint',
12+
method: 'fingerprint',
13+
params: [ 'export' ],
14+
expect: { '': {} }
15+
});
16+
17+
const callServiceList = rpc.declare({
18+
object: 'service',
19+
method: 'list',
20+
params: [ 'name' ],
21+
expect: { ufp: {} }
22+
});
23+
24+
let has_ufp;
25+
926
return view.extend({
1027
handleCommand(exec, args) {
1128
const buttons = document.querySelectorAll('.diag-action > .cbi-button');
@@ -50,8 +67,11 @@ return view.extend({
5067

5168
handleArpScan(ev, cmd) {
5269
const addr = ev.currentTarget.parentNode.previousSibling.value;
70+
const ieee_file = '/tmp/arp-scan/ieee-oui.txt';
5371

54-
return this.handleCommand('arp-scan', [ '-l', '-I', addr ]);
72+
if (!has_ufp)
73+
return this.handleCommand('arp-scan', [ '-l', '-I', addr ]);
74+
return this.handleCommand('arp-scan', [ '-l', '-I', addr, '-O', ieee_file ]);
5575
},
5676

5777
load() {
@@ -60,14 +80,25 @@ return view.extend({
6080
L.resolveDefault(fs.stat('/bin/traceroute6') || fs.stat('/usr/bin/traceroute6'), false),
6181
L.resolveDefault(fs.stat('/usr/bin/arp-scan'), false),
6282
network.getDevices(),
83+
callServiceList('ufp').then((res) => {
84+
let instances = res.instances;
85+
86+
for (let i in instances) {
87+
if (instances[i].running)
88+
return callFingerprint(true);
89+
}
90+
91+
return null;
92+
}),
6393
uci.load('luci')
6494
]);
6595
},
6696

67-
render([has_ping6, has_traceroute6, has_arpscan, devices]) {
97+
render([has_ping6, has_traceroute6, has_arpscan, devices, ufp]) {
6898
const dns_host = uci.get('luci', 'diag', 'dns') || 'openwrt.org';
6999
const ping_host = uci.get('luci', 'diag', 'ping') || 'openwrt.org';
70100
const route_host = uci.get('luci', 'diag', 'route') || 'openwrt.org';
101+
has_ufp = ufp != null ? true : false;
71102

72103
const table = E('table', { 'class': 'table' }, [
73104
E('tr', { 'class': 'tr' }, [

modules/luci-mod-network/root/usr/share/rpcd/acl.d/luci-mod-network.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@
7878
"/usr/bin/arp-scan": [ "exec", "list" ]
7979
},
8080
"ubus": {
81-
"file": [ "exec", "stat" ]
81+
"file": [ "exec", "stat" ],
82+
"fingerprint": [ "fingerprint" ],
83+
"service": [ "list" ]
8284
},
8385
"uci": [ "luci" ]
8486
}

0 commit comments

Comments
 (0)