[ufp] ufp: write oui info to ieee-oui.txt

Christian Korber ckorber at tdt.de
Wed Apr 22 07:56:23 PDT 2026


This commit writes connected device's information (oui and vendor) to
ieee-oui.txt for arp-scan. This way there is no unneccessary big file on
the target.

Signed-off-by: Christian Korber <ckorber at tdt.de>
---
 .../0003-ufp-write-to-ieee-oui-txt.patch      | 64 +++++++++++++++++++
 1 file changed, 64 insertions(+)
 create mode 100644 utils/ufp/patches/0003-ufp-write-to-ieee-oui-txt.patch

diff --git a/utils/ufp/patches/0003-ufp-write-to-ieee-oui-txt.patch b/utils/ufp/patches/0003-ufp-write-to-ieee-oui-txt.patch
new file mode 100644
index 000000000..bacad6930
--- /dev/null
+++ b/utils/ufp/patches/0003-ufp-write-to-ieee-oui-txt.patch
@@ -0,0 +1,64 @@
+--- a/ufpd
++++ b/ufpd
+@@ -2,7 +2,7 @@
+ 'use strict';
+ import * as uloop from "uloop";
+ import * as libubus from "ubus";
+-import { readfile, glob, basename } from "fs";
++import { readfile, glob, basename, open, stat, mkdir } from "fs";
+ let uht = require("uht");
+ push(REQUIRE_SEARCH_PATH, "/usr/share/ufp/*.uc");
+ 
+@@ -380,6 +380,52 @@ global.ubus_object = {
+ 				}
+ 			}
+ 
++			/*
++			 * We want to populate ieee-oui.txt in order to
++			 * use it for arp-scan. This way we don't need a
++			 * large file too big in size, but rather rely on
++			 * found data via ubus call 'fingerprint'.
++			 * ieee-oui.txt will be updated on every call to:
++			 * `ubus call fingerprint fingerprint`.
++			 */
++
++			const tmp_dir = '/tmp/arp-scan';
++			const ieee_file = sprintf('%s/ieee-oui.txt', tmp_dir);
++			let ouis_added = [];
++
++			if (!stat(tmp_dir))
++				mkdir(tmp_dir);
++
++			const fd = open(ieee_file, 'a+');
++
++			/*
++			 * check for duplicate ouis
++			 */
++			for (let line = fd.read('line'); length(line); line = fd.read('line')) {
++				let oui = split(line, '\t')[0];
++				oui = uc(oui);
++
++				if (index(ouis_added, oui) < 0)
++					push(ouis_added, oui);
++			}
++
++			/*
++			 * write to ieee-oui.txt
++			 */
++			for (let entry in ret) {
++				let vendor = ret[entry].vendor;
++				let oui = split(entry, ':');
++				oui = join('', slice(oui, 0,3));
++				oui = uc(oui);
++
++				if (index(ouis_added, oui) < 0) {
++					let line = sprintf('%s\t%s\n', oui, vendor);
++					fd.write(line);
++				}
++			}
++
++			fd.close();
++
+ 			return req.args.macaddr ? ret[req.args.macaddr] : ret;
+ 		}
+ 	},
-- 
2.47.3
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 6005 bytes
Desc: not available
URL: <http://lists.openwrt.org/pipermail/openwrt-devel/attachments/20260422/7ceaa5ac/attachment-0001.bin>


More information about the openwrt-devel mailing list