mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-10-29 17:42:41 +00:00
uspot: add CoA support
Fixes: WIFI-12103 Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
@@ -4,10 +4,10 @@ PKG_NAME:=ucentral-schema
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_URL=https://github.com/Telecominfraproject/wlan-ucentral-schema.git
|
||||
PKG_MIRROR_HASH:=13ac49c727ad9bbceb02f8742e68f95b97ff907ea9120425656cf0d4d6f681be
|
||||
PKG_MIRROR_HASH:=f85296fa27a52d494f9787a5e4bde135653121608ad36a54252ca5c6dd46baf5
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_DATE:=2022-05-29
|
||||
PKG_SOURCE_VERSION:=aa79c72358293314581953226f11092eb2313bca
|
||||
PKG_SOURCE_VERSION:=19c5923382f5bb7407bec46b285ef4c63d2f31e0
|
||||
PKG_MAINTAINER:=John Crispin <john@phrozen.org>
|
||||
PKG_LICENSE:=BSD-3-Clause
|
||||
|
||||
|
||||
@@ -48,6 +48,13 @@
|
||||
"proto": "psk2",
|
||||
"key": "OpenWifi",
|
||||
"ieee80211w": "optional"
|
||||
},
|
||||
"radius": {
|
||||
"dynamic-authorization": {
|
||||
"host": "0.0.0.0",
|
||||
"port": 3333,
|
||||
"secret": "secret"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -7,6 +7,7 @@ let uloop = require('uloop');
|
||||
let ubus = require('ubus').connect();
|
||||
let uci = require('uci').cursor();
|
||||
let interfaces = {};
|
||||
let hapd_subscriber;
|
||||
|
||||
let uciload = uci.foreach('uspot', 'uspot', (d) => {
|
||||
if (!d[".anonymous"]) {
|
||||
@@ -119,6 +120,13 @@ const radtc_idleto = 4; // Idle Timeout
|
||||
const radtc_sessionto = 5; // Session Timeout
|
||||
const radtc_adminreset = 6; // Admin Reset
|
||||
|
||||
function interface_find(mac) {
|
||||
for (let k, v in interfaces)
|
||||
if (v.clients[mac])
|
||||
return k;
|
||||
return null;
|
||||
}
|
||||
|
||||
function radius_terminate(interface, mac, cause) {
|
||||
if (!interfaces[interface].clients[mac].radius)
|
||||
return;
|
||||
@@ -350,6 +358,34 @@ function accounting(interface) {
|
||||
}
|
||||
}
|
||||
|
||||
function hapd_subscriber_notify_cb(notify) {
|
||||
if (notify.type != 'coa')
|
||||
return 0;
|
||||
notify.data.address = uc(notify.data.address);
|
||||
let iface = interface_find(notify.data.address);
|
||||
if (!iface)
|
||||
return 0;
|
||||
client_kick(iface, notify.data.address, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
function hapd_subscriber_remove_cb(remove) {
|
||||
printf('remove: %.J\n', remove);
|
||||
}
|
||||
|
||||
function listener_cb(event, payload) {
|
||||
unsub_object(event == 'ubus.object.add', payload.id, payload.path);
|
||||
}
|
||||
|
||||
function unsub_object(add, id, path) {
|
||||
let object = split(path, '.');
|
||||
|
||||
if (object[0] == 'hostapd' && object[1] && add) {
|
||||
printf('adding %s\n', path);
|
||||
hapd_subscriber.subscribe(path);
|
||||
}
|
||||
}
|
||||
|
||||
function start()
|
||||
{
|
||||
let seen = {};
|
||||
@@ -367,6 +403,14 @@ function start()
|
||||
seen[server][nasid] = 1;
|
||||
radius_accton(interface);
|
||||
}
|
||||
hapd_subscriber = ubus.subscriber(hapd_subscriber_notify_cb, hapd_subscriber_remove_cb);
|
||||
|
||||
let list = ubus.list();
|
||||
for (let k, path in list)
|
||||
unsub_object(true, 0, path);
|
||||
|
||||
ubus.listener('ubus.object.add', listener_cb);
|
||||
ubus.listener('ubus.object.remove', listener_cb);
|
||||
}
|
||||
|
||||
function stop()
|
||||
|
||||
Reference in New Issue
Block a user