[PATCH v2 06/11] wifi_stats: Use WBA Connect-Info format in RADIUS attributes

Iegor Sergieienkov iegor at nova-labs.com
Mon Nov 23 04:50:26 PST 2026


Use the format defined in draft-ietf-radext-connectinfo-02 for the
RADIUS Connect-Info attribute added in add_common_radius_sta_attr(),
i.e., in Access-Request and Accounting-Request messages for a station,
while station statistics are being collected (wifi_stats_wba_enabled=1).
The existing "CONNECT <rate>Mbps <mode>" format remains in use
otherwise. The buffer is extended to hold the 253 octets a RADIUS
attribute can carry.

Mark the statistics of a station as reported once an Accounting-Request
(Start, Interim-Update, or Stop) has been passed to the RADIUS client.
With wifi_stats_span=report this starts a new accumulation period, so
that each report covers the time since the previous one, as described in
Section 4.2 of the draft. With the default window span this has no
effect.

The Connect-Info attribute of RSN pre-authentication, of the
Access-Request messages for RADIUS-based MAC ACL and PSK, and one set
with radius_auth_req_attr or radius_acct_req_attr are not changed.

Signed-off-by: Iegor Sergieienkov <iegor at nova-labs.com>
---
 src/ap/accounting.c | 13 ++++++++++---
 src/ap/ieee802_1x.c |  5 +++--
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/src/ap/accounting.c b/src/ap/accounting.c
index 9fc1886a2..b1d572e9d 100644
--- a/src/ap/accounting.c
+++ b/src/ap/accounting.c
@@ -20,6 +20,7 @@
 #include "sta_info.h"
 #include "ap_drv_ops.h"
 #include "accounting.h"
+#include "wifi_stats.h"
 
 
 /* Default interval in seconds for polling TX/RX octets from the driver if
@@ -254,9 +255,13 @@ 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
+			wifi_stats_mark_signalled(hapd, sta);
+	}
 
 	sta->acct_session_started = 1;
 }
@@ -353,6 +358,8 @@ static void accounting_sta_report(struct hostapd_data *hapd,
 			       stop ? RADIUS_ACCT : RADIUS_ACCT_INTERIM,
 			       sta->addr) < 0)
 		goto fail;
+
+	wifi_stats_mark_signalled(hapd, sta);
 	return;
 
  fail:
diff --git a/src/ap/ieee802_1x.c b/src/ap/ieee802_1x.c
index cf5fdf31d..a99c38555 100644
--- a/src/ap/ieee802_1x.c
+++ b/src/ap/ieee802_1x.c
@@ -38,6 +38,7 @@
 #include "ieee802_11.h"
 #include "ieee802_1x.h"
 #include "wpa_auth_kay.h"
+#include "wifi_stats.h"
 
 
 #ifdef CONFIG_HS20
@@ -500,7 +501,7 @@ static int add_common_radius_sta_attr(struct hostapd_data *hapd,
 				      struct sta_info *sta,
 				      struct radius_msg *msg)
 {
-	char buf[128];
+	char buf[WIFI_STATS_MAX_CONNECT_INFO_LEN + 1];
 
 	if (!hostapd_config_get_radius_attr(req_attr,
 					    RADIUS_ATTR_SERVICE_TYPE) &&
@@ -530,7 +531,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 (wifi_stats_connect_info(hapd, sta, buf, sizeof(buf)) < 0) {
 		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