mirror of
				https://github.com/Telecominfraproject/wlan-ap.git
				synced 2025-10-30 18:07:52 +00:00 
			
		
		
		
	ucentral-event: add dhcp-relay support
Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
		| @@ -24,6 +24,7 @@ let uci = libuci.cursor(); | |||||||
| let hostapd = {}; | let hostapd = {}; | ||||||
| let hapd_subscriber; | let hapd_subscriber; | ||||||
| let dhcp_subscriber; | let dhcp_subscriber; | ||||||
|  | let dhcp_relay_subscriber; | ||||||
| let log_subscriber; | let log_subscriber; | ||||||
| let ratelimit = false; | let ratelimit = false; | ||||||
| let config; | let config; | ||||||
| @@ -32,6 +33,8 @@ let carrier = {}; | |||||||
| let boot_file = "/tmp/booted"; | let boot_file = "/tmp/booted"; | ||||||
| let ucentral_running = false; | let ucentral_running = false; | ||||||
| let pending_events = []; | let pending_events = []; | ||||||
|  | let relay = {}; | ||||||
|  |  | ||||||
|  |  | ||||||
| function config_load() { | function config_load() { | ||||||
| 	uci.load('event'); | 	uci.load('event'); | ||||||
| @@ -227,6 +230,20 @@ function dhcp_subscriber_remove_cb(remove) { | |||||||
| 	printf('dhcp remove: %.J\n', 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) { | function log_subscriber_notify_cb(notify) { | ||||||
| 	let msg = split(notify.data.msg, ': ', 2); | 	let msg = split(notify.data.msg, ': ', 2); | ||||||
| 	let daemon = split(msg[0], '[')[0]; | 	let daemon = split(msg[0], '[')[0]; | ||||||
| @@ -259,6 +276,12 @@ function unsub_object(add, id, path) { | |||||||
| 		printf('adding %s\n', path); | 		printf('adding %s\n', path); | ||||||
| 		dhcp_subscriber.subscribe(path); | 		dhcp_subscriber.subscribe(path); | ||||||
| 		break; | 		break; | ||||||
|  | 	case 'dhcprelay': | ||||||
|  | 		printf('adding %s\n', path); | ||||||
|  | 		uci.load('dhcprelay'); | ||||||
|  | 		relay = uci.get_all('dhcprelay'); | ||||||
|  | 		dhcp_relay_subscriber.subscribe(path); | ||||||
|  | 		break; | ||||||
| 	case 'log': | 	case 'log': | ||||||
| 		printf('adding %s\n', path); | 		printf('adding %s\n', path); | ||||||
| 		log_subscriber.subscribe(path); | 		log_subscriber.subscribe(path); | ||||||
| @@ -362,6 +385,7 @@ config_load(); | |||||||
| hapd_subscriber = ubus.subscriber(hapd_subscriber_notify_cb, hapd_subscriber_remove_cb); | hapd_subscriber = ubus.subscriber(hapd_subscriber_notify_cb, hapd_subscriber_remove_cb); | ||||||
| dhcp_subscriber = ubus.subscriber(dhcp_subscriber_notify_cb, dhcp_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); | 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(); | let list = ubus.list(); | ||||||
| for (let k, path in list) | for (let k, path in list) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 John Crispin
					John Crispin