mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-11-01 10:57:47 +00:00
Merge pull request #484 from Telecominfraproject/2.7.1-fixes-from-next
2.7.1 fixes from next
This commit is contained in:
@@ -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->client_ids, &cl->id_node);
|
||||||
avl_delete(&iface->clients, &cl->node);
|
avl_delete(&iface->clients, &cl->node);
|
||||||
kvlist_free(&cl->kvdata);
|
kvlist_free(&cl->kvdata);
|
||||||
|
free(cl->device);
|
||||||
spotfilter_bpf_set_client(iface, &cl->key, NULL);
|
spotfilter_bpf_set_client(iface, &cl->key, NULL);
|
||||||
free(cl);
|
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);
|
kvlist_set(&cl->kvdata, blobmsg_name(cur), cur);
|
||||||
}
|
}
|
||||||
if (device)
|
if (device) {
|
||||||
cl->device = device;
|
free(cl->device);
|
||||||
|
cl->device = strdup(device);
|
||||||
|
}
|
||||||
if (state >= 0)
|
if (state >= 0)
|
||||||
cl->data.cur_class = state;
|
cl->data.cur_class = state;
|
||||||
if (dns_state >= 0)
|
if (dns_state >= 0)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ struct client {
|
|||||||
|
|
||||||
struct spotfilter_client_key key;
|
struct spotfilter_client_key key;
|
||||||
struct spotfilter_client_data data;
|
struct spotfilter_client_data data;
|
||||||
const char *device;
|
char *device;
|
||||||
};
|
};
|
||||||
|
|
||||||
int client_set(struct interface *iface, const void *addr, const char *id,
|
int client_set(struct interface *iface, const void *addr, const char *id,
|
||||||
|
|||||||
@@ -32,11 +32,15 @@ function get_idle_timeout(mac) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function get_session_timeout(mac) {
|
function get_session_timeout(mac) {
|
||||||
if (clients[mac]?.session_timeout)
|
if (clients[mac]?.session)
|
||||||
return clients[mac].session_timeout;
|
return clients[mac].session;
|
||||||
return session_timeout;
|
return session_timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function radius_available(mac) {
|
||||||
|
return !!clients[mac]?.radius;
|
||||||
|
}
|
||||||
|
|
||||||
function radius_init(mac, payload) {
|
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' ])
|
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])
|
if (clients[mac].radius[key])
|
||||||
@@ -53,6 +57,8 @@ function radius_call(mac, payload) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function radius_stop(mac) {
|
function radius_stop(mac) {
|
||||||
|
if (!radius_available(mac))
|
||||||
|
return;
|
||||||
debug(mac, 'stopping accounting');
|
debug(mac, 'stopping accounting');
|
||||||
|
|
||||||
let payload = {
|
let payload = {
|
||||||
@@ -88,6 +94,8 @@ function radius_acct(mac, payload) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function radius_idle_time(mac) {
|
function radius_idle_time(mac) {
|
||||||
|
if (!radius_available(mac))
|
||||||
|
return;
|
||||||
let payload = {
|
let payload = {
|
||||||
acct_type: 2,
|
acct_type: 2,
|
||||||
terminate_cause: 4,
|
terminate_cause: 4,
|
||||||
@@ -96,6 +104,8 @@ function radius_idle_time(mac) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function radius_session_time(mac) {
|
function radius_session_time(mac) {
|
||||||
|
if (!radius_available(mac))
|
||||||
|
return;
|
||||||
let payload = {
|
let payload = {
|
||||||
acct_type: 2,
|
acct_type: 2,
|
||||||
terminate_cause: 5,
|
terminate_cause: 5,
|
||||||
@@ -104,6 +114,8 @@ function radius_session_time(mac) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function radius_disconnect(mac) {
|
function radius_disconnect(mac) {
|
||||||
|
if (!radius_available(mac))
|
||||||
|
return;
|
||||||
let payload = {
|
let payload = {
|
||||||
acct_type: 2,
|
acct_type: 2,
|
||||||
terminate_cause: 1,
|
terminate_cause: 1,
|
||||||
@@ -112,6 +124,8 @@ function radius_disconnect(mac) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function radius_interim(mac) {
|
function radius_interim(mac) {
|
||||||
|
if (!radius_available(mac))
|
||||||
|
return;
|
||||||
let payload = {
|
let payload = {
|
||||||
acct_type: 3,
|
acct_type: 3,
|
||||||
};
|
};
|
||||||
@@ -126,17 +140,25 @@ function client_add(mac, state) {
|
|||||||
if (state.state != 1)
|
if (state.state != 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let interval = (state.data?.radius?.reply['Acct-Interim-Interval'] || acct_interval) * 1000;
|
let interval = acct_interval * 1000;
|
||||||
let idle = (state.data?.radius?.reply['Idle-Timeout'] || idle_timeout);
|
let idle = idle_timeout;
|
||||||
let session = (state.data?.radius?.reply['Session-Timeout'] || session_timeout);
|
let session = session_timeout;
|
||||||
let accounting = (config.radius?.acct_server && config.radius?.acct_secret);
|
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] = {
|
clients[mac] = {
|
||||||
accounting,
|
accounting,
|
||||||
radius: state.data.radius.request,
|
|
||||||
interval,
|
interval,
|
||||||
|
session,
|
||||||
idle,
|
idle,
|
||||||
};
|
};
|
||||||
|
if (state.data?.radius?.request)
|
||||||
|
clients[mac].radius= state.data.radius.request;
|
||||||
syslog(mac, 'adding client');
|
syslog(mac, 'adding client');
|
||||||
if (accounting)
|
if (accounting)
|
||||||
clients[mac].timeout = uloop.timer(interval, () => radius_interim(mac));
|
clients[mac].timeout = uloop.timer(interval, () => radius_interim(mac));
|
||||||
@@ -167,6 +189,7 @@ function client_timeout(mac) {
|
|||||||
ubus.call('spotfilter', 'client_set', {
|
ubus.call('spotfilter', 'client_set', {
|
||||||
interface: "hotspot",
|
interface: "hotspot",
|
||||||
state: 0,
|
state: 0,
|
||||||
|
dns_state: 1,
|
||||||
address: mac,
|
address: mac,
|
||||||
accounting: [],
|
accounting: [],
|
||||||
flush: true,
|
flush: true,
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ return {
|
|||||||
case 'aa-bb-cc-dd-ee-ff':
|
case 'aa-bb-cc-dd-ee-ff':
|
||||||
case 'AA-BB-CC-DD-EE-FF':
|
case 'AA-BB-CC-DD-EE-FF':
|
||||||
mac = replace(mac, ':', '-');
|
mac = replace(mac, ':', '-');
|
||||||
warn('uspot: ' + ctx.env.REMOTE_ADDR + ' - ' + msg + '\n');
|
|
||||||
break;
|
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_server: sprintf('%s:%s:%s', this.config.radius.acct_server, this.config.radius.acct_port, this.config.radius.acct_secret),
|
||||||
acct_session,
|
acct_session,
|
||||||
client_ip: ctx.env.REMOTE_ADDR,
|
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),
|
calling_station: this.format_mac(ctx.mac),
|
||||||
nas_ip: ctx.env.SERVER_ADDR,
|
nas_ip: ctx.env.SERVER_ADDR,
|
||||||
nas_id: this.config.uam.nasid
|
nas_id: this.config.uam.nasid
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ Index: hostapd-2021-02-20-59e9794c/src/ap/sta_info.c
|
|||||||
else
|
else
|
||||||
#endif /* CONFIG_P2P */
|
#endif /* CONFIG_P2P */
|
||||||
- os_snprintf(buf, sizeof(buf), MACSTR, MAC2STR(sta->addr));
|
- 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)
|
if (hapd->sta_authorized_cb)
|
||||||
hapd->sta_authorized_cb(hapd->sta_authorized_cb_ctx,
|
hapd->sta_authorized_cb(hapd->sta_authorized_cb_ctx,
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ index 0000000000..f2f4a933d7
|
|||||||
+ else
|
+ else
|
||||||
+ #endif /* CONFIG_P2P */
|
+ #endif /* CONFIG_P2P */
|
||||||
+- os_snprintf(buf, sizeof(buf), MACSTR, MAC2STR(sta->addr));
|
+- 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)
|
+ if (hapd->sta_authorized_cb)
|
||||||
+ hapd->sta_authorized_cb(hapd->sta_authorized_cb_ctx,
|
+ hapd->sta_authorized_cb(hapd->sta_authorized_cb_ctx,
|
||||||
|
|||||||
Reference in New Issue
Block a user