usteer: add connected-since
authorDavid Bauer <mail@david-bauer.net>
Wed, 17 Aug 2022 00:17:40 +0000 (02:17 +0200)
committerDavid Bauer <mail@david-bauer.net>
Wed, 17 Aug 2022 20:07:53 +0000 (22:07 +0200)
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 <mail@david-bauer.net>
nl80211.c
sta.c
ubus.c
usteer.h

index f0ac137b9083d19cccaa9b3379e898ceee1285bd..a2325051851ac790b2d2dea2f38f2f16cad29fb1 100644 (file)
--- 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 740463dd2efe6c04f7874300ea1aed33967dfc18..ed7e40ecb032224828378f42b262812eeceb6f7b 100644 (file)
--- 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 c385870be0a73d42d190395df46e6cbc253d520f..8aaf5f1e0d6995904e7548d454cddc699a976a28 100644 (file)
--- 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");
index bbb7ff14f58a611e6d5b82eb5c74902a9a48bd92..4f5aa1b294439fb0357b21400cf8e6d973911a18 100644 (file)
--- 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;