[PATCH 5/8] wifi_stats: Use WBA Connect-Info format in RADIUS attributes
Iegor Sergieienkov
iegor at nova-labs.com
Thu Aug 27 07:16:22 PDT 2026
Replace the contents of the RADIUS Connect-Info attribute with the WBA
format from draft-grayson-connectinfo-10 when wifi_stats_wba_enabled is
set and per-station statistics are available. The legacy
"CONNECT <rate> Mbps <mode>" format remains in use otherwise.
Sending an accounting message resets the per-station accumulation, so
that each report covers the period since the previous one, as described
in draft-grayson-connectinfo-10 Section 4.2.
Signed-off-by: Iegor Sergieienkov <iegor at nova-labs.com>
---
src/ap/accounting.c | 23 ++++++++++++++++++++---
src/ap/ieee802_1x.c | 32 ++++++++++++++++++++++++++++++--
2 files changed, 50 insertions(+), 5 deletions(-)
diff --git a/src/ap/accounting.c b/src/ap/accounting.c
index 9fc1886a2..e5ddc093c 100644
--- a/src/ap/accounting.c
+++ b/src/ap/accounting.c
@@ -20,6 +20,9 @@
#include "sta_info.h"
#include "ap_drv_ops.h"
#include "accounting.h"
+#ifdef CONFIG_WIFI_STATS
+#include "wifi_stats/wifi_stats.h"
+#endif /* CONFIG_WIFI_STATS */
/* Default interval in seconds for polling TX/RX octets from the driver if
@@ -254,9 +257,18 @@ void accounting_sta_start(struct hostapd_data *hapd, struct sta_info *sta)
hapd, sta);
msg = accounting_msg(hapd, sta, RADIUS_ACCT_STATUS_TYPE_START);
- if (msg &&
- radius_client_send(hapd->radius, msg, RADIUS_ACCT, sta->addr) < 0)
- radius_msg_free(msg);
+ if (msg) {
+ if (radius_client_send(hapd->radius, msg, RADIUS_ACCT,
+ sta->addr) < 0) {
+ radius_msg_free(msg);
+ } else {
+#ifdef CONFIG_WIFI_STATS
+ if (hapd->iface)
+ wifi_stats_mark_signalled(hapd->iface->wifi_stats,
+ sta->addr);
+#endif /* CONFIG_WIFI_STATS */
+ }
+ }
sta->acct_session_started = 1;
}
@@ -353,6 +365,11 @@ static void accounting_sta_report(struct hostapd_data *hapd,
stop ? RADIUS_ACCT : RADIUS_ACCT_INTERIM,
sta->addr) < 0)
goto fail;
+
+#ifdef CONFIG_WIFI_STATS
+ if (hapd->iface)
+ wifi_stats_mark_signalled(hapd->iface->wifi_stats, sta->addr);
+#endif /* CONFIG_WIFI_STATS */
return;
fail:
diff --git a/src/ap/ieee802_1x.c b/src/ap/ieee802_1x.c
index 7f47318b2..a40bf4353 100644
--- a/src/ap/ieee802_1x.c
+++ b/src/ap/ieee802_1x.c
@@ -38,6 +38,9 @@
#include "ieee802_11.h"
#include "ieee802_1x.h"
#include "wpa_auth_kay.h"
+#ifdef CONFIG_WIFI_STATS
+#include "wifi_stats/wifi_stats.h"
+#endif /* CONFIG_WIFI_STATS */
#ifdef CONFIG_HS20
@@ -495,12 +498,37 @@ static int add_common_radius_sta_attr_rsn(struct hostapd_data *hapd,
}
+#ifdef CONFIG_WIFI_STATS
+#define RADIUS_CONNECT_INFO_LEN (WIFI_STATS_MAX_CONN_INFO_LEN + 1)
+#else /* CONFIG_WIFI_STATS */
+#define RADIUS_CONNECT_INFO_LEN 128
+#endif /* CONFIG_WIFI_STATS */
+
+
+static bool add_wifi_stats_connect_info(struct hostapd_data *hapd,
+ struct sta_info *sta,
+ char *buf, size_t len)
+{
+#ifdef CONFIG_WIFI_STATS
+ if (!hapd->iface || !hapd->iface->wifi_stats ||
+ !hapd->iconf->wifi_stats_wba_enabled)
+ return false;
+
+ return wifi_stats_format_connection_info(hapd->iface->wifi_stats,
+ hapd, sta, sta->addr,
+ buf, len) >= 0;
+#else /* CONFIG_WIFI_STATS */
+ return false;
+#endif /* CONFIG_WIFI_STATS */
+}
+
+
static int add_common_radius_sta_attr(struct hostapd_data *hapd,
struct hostapd_radius_attr *req_attr,
struct sta_info *sta,
struct radius_msg *msg)
{
- char buf[128];
+ char buf[RADIUS_CONNECT_INFO_LEN];
if (!hostapd_config_get_radius_attr(req_attr,
RADIUS_ATTR_SERVICE_TYPE) &&
@@ -530,7 +558,7 @@ static int add_common_radius_sta_attr(struct hostapd_data *hapd,
if (sta->flags & WLAN_STA_PREAUTH) {
os_strlcpy(buf, "IEEE 802.11i Pre-Authentication",
sizeof(buf));
- } else {
+ } else if (!add_wifi_stats_connect_info(hapd, sta, buf, sizeof(buf))) {
os_snprintf(buf, sizeof(buf), "CONNECT %d%sMbps %s",
radius_sta_rate(hapd, sta) / 2,
(radius_sta_rate(hapd, sta) & 1) ? ".5" : "",
--
2.43.0
More information about the Hostap
mailing list