From: David Bauer Date: Wed, 17 Aug 2022 00:17:40 +0000 (+0200) Subject: usteer: add connected-since X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=837f144f6cd8c5fb55cf61181d8cf434f40dd6a0;p=project%2Fusteer.git usteer: add connected-since Fetch the age of the association for STAs in order to implement minimum intervals after which a STA is considered kickable. Signed-off-by: David Bauer --- diff --git a/nl80211.c b/nl80211.c index f0ac137..a232505 100644 --- a/nl80211.c +++ b/nl80211.c @@ -269,6 +269,9 @@ static void nl80211_update_sta(struct usteer_node *node, struct sta_info *si) if (tb_sta[NL80211_STA_INFO_SIGNAL_AVG]) signal = (int8_t) nla_get_u8(tb_sta[NL80211_STA_INFO_SIGNAL_AVG]); + + if (tb_sta[NL80211_STA_INFO_CONNECTED_TIME]) + si->connected_since = current_time - (nla_get_u32(tb_sta[NL80211_STA_INFO_CONNECTED_TIME]) * 1000); usteer_sta_info_update(si, signal, true); diff --git a/sta.c b/sta.c index 740463d..ed7e40e 100644 --- a/sta.c +++ b/sta.c @@ -150,6 +150,7 @@ void usteer_sta_disconnected(struct sta_info *si) { si->connected = STA_NOT_CONNECTED; si->kick_time = 0; + si->connected_since = 0; usteer_sta_info_update_timeout(si, config.local_sta_timeout); } diff --git a/ubus.c b/ubus.c index c385870..8aaf5f1 100644 --- a/ubus.c +++ b/ubus.c @@ -403,6 +403,7 @@ usteer_ubus_get_connected_clients(struct ubus_context *ctx, struct ubus_object * blobmsg_add_u32(&b, "signal", si->signal); blobmsg_add_u64(&b, "created", si->created); blobmsg_add_u64(&b, "seen", si->seen); + blobmsg_add_u64(&b, "connected_since", si->connected_since); blobmsg_add_u64(&b, "last_connected", si->last_connected); t = blobmsg_open_table(&b, "snr-kick"); diff --git a/usteer.h b/usteer.h index bbb7ff1..4f5aa1b 100644 --- a/usteer.h +++ b/usteer.h @@ -241,7 +241,10 @@ struct sta_info { struct sta_info_stats stats[__EVENT_TYPE_MAX]; uint64_t created; uint64_t seen; + + uint64_t connected_since; uint64_t last_connected; + int signal; uint8_t rrm;