From 9eada6166c7487a1a28fc81082d4c46be5e4d6c8 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Mon, 22 May 2023 09:56:35 +0200 Subject: [PATCH] ucentral-event: add dhcp-relay support Signed-off-by: John Crispin --- .../ucentral-event/files/ucentral-event | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/feeds/ucentral/ucentral-event/files/ucentral-event b/feeds/ucentral/ucentral-event/files/ucentral-event index 2cf36a463..c35fb536a 100755 --- a/feeds/ucentral/ucentral-event/files/ucentral-event +++ b/feeds/ucentral/ucentral-event/files/ucentral-event @@ -24,6 +24,7 @@ let uci = libuci.cursor(); let hostapd = {}; let hapd_subscriber; let dhcp_subscriber; +let dhcp_relay_subscriber; let log_subscriber; let ratelimit = false; let config; @@ -32,6 +33,8 @@ let carrier = {}; let boot_file = "/tmp/booted"; let ucentral_running = false; let pending_events = []; +let relay = {}; + function config_load() { uci.load('event'); @@ -227,6 +230,20 @@ function dhcp_subscriber_remove_cb(remove) { printf('dhcp remove: %.J\n', remove); } +function dhcp_relay_subscriber_notify_cb(notify) { + printf('%.J\n', notify.data); + return { + address: relay.config.server, + options: [ + [ 62, "hello, world" ] + ] + }; +} + +function dhcp_relay_subscriber_remove_cb(remove) { + printf('dhcp-relay remove: %.J\n', remove); +} + function log_subscriber_notify_cb(notify) { let msg = split(notify.data.msg, ': ', 2); let daemon = split(msg[0], '[')[0]; @@ -259,6 +276,12 @@ function unsub_object(add, id, path) { printf('adding %s\n', path); dhcp_subscriber.subscribe(path); break; + case 'dhcprelay': + printf('adding %s\n', path); + uci.load('dhcprelay'); + relay = uci.get_all('dhcprelay'); + dhcp_relay_subscriber.subscribe(path); + break; case 'log': printf('adding %s\n', path); log_subscriber.subscribe(path); @@ -362,6 +385,7 @@ config_load(); hapd_subscriber = ubus.subscriber(hapd_subscriber_notify_cb, hapd_subscriber_remove_cb); dhcp_subscriber = ubus.subscriber(dhcp_subscriber_notify_cb, dhcp_subscriber_remove_cb); log_subscriber = ubus.subscriber(log_subscriber_notify_cb, log_subscriber_remove_cb); +dhcp_relay_subscriber = ubus.subscriber(dhcp_relay_subscriber_notify_cb, dhcp_relay_subscriber_remove_cb); let list = ubus.list(); for (let k, path in list)