From fee0e5de33cee1a40890e3778e5242093463fb8d Mon Sep 17 00:00:00 2001 From: Gokul Sivakumar Date: Wed, 6 Aug 2025 14:46:25 +0530 Subject: [PATCH] netdev: parse INACTIVE_TIME and CONNECTED_TIME in netdev_get_station These two newly parsed station info params "inactive time" and the "connected time" would be helpful to track the duration (in ms) for which the station was last inactive and the total duration (in s) for which the station is currently connected to the AP. When the wlan device is in STA mode, these fields represent the info of this station device. And when wlan device is in AP mode, then these fields repesents the stations that are connected to this AP device. --- client/diagnostic.c | 2 ++ src/diagnostic.c | 8 ++++++++ src/diagnostic.h | 5 +++++ src/netdev.c | 17 ++++++++++++++++- 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/client/diagnostic.c b/client/diagnostic.c index 92a6126a..2be8b724 100644 --- a/client/diagnostic.c +++ b/client/diagnostic.c @@ -95,6 +95,8 @@ static const struct diagnostic_dict_mapping diagnostic_mapping[] = { { "Frequency", 'u' }, { "Channel", 'q' }, { "Security", 's' }, + { "InactiveTime", 'u', "ms" }, + { "ConnectedTime", 'u', "s" }, { NULL } }; diff --git a/src/diagnostic.c b/src/diagnostic.c index b928c2c1..9dc61deb 100644 --- a/src/diagnostic.c +++ b/src/diagnostic.c @@ -110,6 +110,14 @@ bool diagnostic_info_to_dict(const struct diagnostic_station_info *info, dbus_append_dict_basic(builder, "ExpectedThroughput", 'u', &info->expected_throughput); + if (info->have_inactive_time) + dbus_append_dict_basic(builder, "InactiveTime", 'u', + &info->inactive_time); + + if (info->have_connected_time) + dbus_append_dict_basic(builder, "ConnectedTime", 'u', + &info->connected_time); + return true; } diff --git a/src/diagnostic.h b/src/diagnostic.h index fd965839..3a3b65de 100644 --- a/src/diagnostic.h +++ b/src/diagnostic.h @@ -43,6 +43,9 @@ struct diagnostic_station_info { uint32_t expected_throughput; + uint32_t inactive_time; + uint32_t connected_time; + bool have_cur_rssi : 1; bool have_avg_rssi : 1; bool have_rx_mcs : 1; @@ -50,6 +53,8 @@ struct diagnostic_station_info { bool have_rx_bitrate : 1; bool have_tx_bitrate : 1; bool have_expected_throughput : 1; + bool have_inactive_time : 1; + bool have_connected_time : 1; }; bool diagnostic_info_to_dict(const struct diagnostic_station_info *info, diff --git a/src/netdev.c b/src/netdev.c index 3bdc3e69..c5ab9105 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -637,7 +637,6 @@ static bool netdev_parse_sta_info(struct l_genl_attr *attr, info->have_tx_mcs = true; break; - case NL80211_STA_INFO_EXPECTED_THROUGHPUT: if (len != 4) return false; @@ -645,6 +644,22 @@ static bool netdev_parse_sta_info(struct l_genl_attr *attr, info->expected_throughput = l_get_u32(data); info->have_expected_throughput = true; + break; + case NL80211_STA_INFO_INACTIVE_TIME: + if (len != 4) + return false; + + info->inactive_time = l_get_u32(data); + info->have_inactive_time = true; + + break; + case NL80211_STA_INFO_CONNECTED_TIME: + if (len != 4) + return false; + + info->connected_time = l_get_u32(data); + info->have_connected_time = true; + break; } }