diff --git a/feeds/ucentral/spotfilter/src/client.c b/feeds/ucentral/spotfilter/src/client.c index 7c2b084d3..7974c0357 100644 --- a/feeds/ucentral/spotfilter/src/client.c +++ b/feeds/ucentral/spotfilter/src/client.c @@ -65,6 +65,7 @@ static void __client_free(struct interface *iface, struct client *cl) avl_delete(&iface->client_ids, &cl->id_node); avl_delete(&iface->clients, &cl->node); kvlist_free(&cl->kvdata); + free(cl->device); spotfilter_bpf_set_client(iface, &cl->key, NULL); free(cl); } @@ -143,8 +144,10 @@ int client_set(struct interface *iface, const void *addr, const char *id, kvlist_set(&cl->kvdata, blobmsg_name(cur), cur); } - if (device) - cl->device = device; + if (device) { + free(cl->device); + cl->device = strdup(device); + } if (state >= 0) cl->data.cur_class = state; if (dns_state >= 0) diff --git a/feeds/ucentral/spotfilter/src/client.h b/feeds/ucentral/spotfilter/src/client.h index 0e45cf2d4..f9e6cc6f9 100644 --- a/feeds/ucentral/spotfilter/src/client.h +++ b/feeds/ucentral/spotfilter/src/client.h @@ -17,7 +17,7 @@ struct client { struct spotfilter_client_key key; struct spotfilter_client_data data; - const char *device; + char *device; }; int client_set(struct interface *iface, const void *addr, const char *id, diff --git a/feeds/ucentral/uspot/files/usr/share/uspot/accounting.uc b/feeds/ucentral/uspot/files/usr/share/uspot/accounting.uc index cf1007c19..e200700a9 100755 --- a/feeds/ucentral/uspot/files/usr/share/uspot/accounting.uc +++ b/feeds/ucentral/uspot/files/usr/share/uspot/accounting.uc @@ -32,11 +32,15 @@ function get_idle_timeout(mac) { } function get_session_timeout(mac) { - if (clients[mac]?.session_timeout) - return clients[mac].session_timeout; + if (clients[mac]?.session) + return clients[mac].session; return session_timeout; } +function radius_available(mac) { + return !!clients[mac]?.radius; +} + function radius_init(mac, payload) { for (let key in [ 'server', 'acct_server', 'acct_session', 'client_ip', 'called_station', 'calling_station', 'nas_ip', 'nas_id', 'username' ]) if (clients[mac].radius[key]) @@ -53,6 +57,8 @@ function radius_call(mac, payload) { } function radius_stop(mac) { + if (!radius_available(mac)) + return; debug(mac, 'stopping accounting'); let payload = { @@ -88,6 +94,8 @@ function radius_acct(mac, payload) { } function radius_idle_time(mac) { + if (!radius_available(mac)) + return; let payload = { acct_type: 2, terminate_cause: 4, @@ -96,6 +104,8 @@ function radius_idle_time(mac) { } function radius_session_time(mac) { + if (!radius_available(mac)) + return; let payload = { acct_type: 2, terminate_cause: 5, @@ -104,6 +114,8 @@ function radius_session_time(mac) { } function radius_disconnect(mac) { + if (!radius_available(mac)) + return; let payload = { acct_type: 2, terminate_cause: 1, @@ -112,6 +124,8 @@ function radius_disconnect(mac) { } function radius_interim(mac) { + if (!radius_available(mac)) + return; let payload = { acct_type: 3, }; @@ -126,17 +140,25 @@ function client_add(mac, state) { if (state.state != 1) return; - let interval = (state.data?.radius?.reply['Acct-Interim-Interval'] || acct_interval) * 1000; - let idle = (state.data?.radius?.reply['Idle-Timeout'] || idle_timeout); - let session = (state.data?.radius?.reply['Session-Timeout'] || session_timeout); + let interval = acct_interval * 1000; + let idle = idle_timeout; + let session = session_timeout; let accounting = (config.radius?.acct_server && config.radius?.acct_secret); + if (state.data?.radius?.reply) { + interval = (state.data?.radius?.reply['Acct-Interim-Interval'] || acct_interval) * 1000; + idle = (state.data?.radius?.reply['Idle-Timeout'] || idle_timeout); + session = (state.data?.radius?.reply['Session-Timeout'] || session_timeout); + } + clients[mac] = { accounting, - radius: state.data.radius.request, interval, + session, idle, }; + if (state.data?.radius?.request) + clients[mac].radius= state.data.radius.request; syslog(mac, 'adding client'); if (accounting) clients[mac].timeout = uloop.timer(interval, () => radius_interim(mac)); @@ -167,6 +189,7 @@ function client_timeout(mac) { ubus.call('spotfilter', 'client_set', { interface: "hotspot", state: 0, + dns_state: 1, address: mac, accounting: [], flush: true, diff --git a/feeds/ucentral/uspot/files/usr/share/uspot/common.uc b/feeds/ucentral/uspot/files/usr/share/uspot/common.uc index 9b4c64dbd..a289a295c 100644 --- a/feeds/ucentral/uspot/files/usr/share/uspot/common.uc +++ b/feeds/ucentral/uspot/files/usr/share/uspot/common.uc @@ -46,7 +46,6 @@ return { case 'aa-bb-cc-dd-ee-ff': case 'AA-BB-CC-DD-EE-FF': mac = replace(mac, ':', '-'); - warn('uspot: ' + ctx.env.REMOTE_ADDR + ' - ' + msg + '\n'); break; } @@ -140,7 +139,7 @@ return { acct_server: sprintf('%s:%s:%s', this.config.radius.acct_server, this.config.radius.acct_port, this.config.radius.acct_secret), acct_session, client_ip: ctx.env.REMOTE_ADDR, - called_station: this.config.uam.nasmac, + called_station: this.config.uam.nasmac + ':' + ctx.ssid, calling_station: this.format_mac(ctx.mac), nas_ip: ctx.env.SERVER_ADDR, nas_id: this.config.uam.nasid diff --git a/feeds/wifi-ax/hostapd/patches/750-wispr.patch b/feeds/wifi-ax/hostapd/patches/750-wispr.patch index f2f4a933d..d5772a4c0 100644 --- a/feeds/wifi-ax/hostapd/patches/750-wispr.patch +++ b/feeds/wifi-ax/hostapd/patches/750-wispr.patch @@ -120,7 +120,7 @@ Index: hostapd-2021-02-20-59e9794c/src/ap/sta_info.c else #endif /* CONFIG_P2P */ - os_snprintf(buf, sizeof(buf), MACSTR, MAC2STR(sta->addr)); -+ os_snprintf(buf, sizeof(buf), MACSTR " %d %d", MAC2STR(sta->addr), sta->bandwidth[0] / 1000, sta->bandwidth[1] / 1000); ++ os_snprintf(buf, sizeof(buf), MACSTR " %d %d", MAC2STR(sta->addr), sta->bandwidth[0] / 1000000, sta->bandwidth[1] / 1000000); if (hapd->sta_authorized_cb) hapd->sta_authorized_cb(hapd->sta_authorized_cb_ctx, diff --git a/patches/wifi/0005-hostapd-add-wispr-bandwidth-patch.patch b/patches/wifi/0005-hostapd-add-wispr-bandwidth-patch.patch index 468762b10..8b8a8e289 100644 --- a/patches/wifi/0005-hostapd-add-wispr-bandwidth-patch.patch +++ b/patches/wifi/0005-hostapd-add-wispr-bandwidth-patch.patch @@ -137,7 +137,7 @@ index 0000000000..f2f4a933d7 + else + #endif /* CONFIG_P2P */ +- os_snprintf(buf, sizeof(buf), MACSTR, MAC2STR(sta->addr)); -++ os_snprintf(buf, sizeof(buf), MACSTR " %d %d", MAC2STR(sta->addr), sta->bandwidth[0] / 1000, sta->bandwidth[1] / 1000); +++ os_snprintf(buf, sizeof(buf), MACSTR " %d %d", MAC2STR(sta->addr), sta->bandwidth[0] / 1000000, sta->bandwidth[1] / 1000000); + + if (hapd->sta_authorized_cb) + hapd->sta_authorized_cb(hapd->sta_authorized_cb_ctx,