--- a/src/ap/ieee802_11.c +++ b/src/ap/ieee802_11.c @@ -57,6 +57,15 @@ #include "gas_query_ap.h" +static int +ewma(int new, int old) +{ + #define ALPHA 10 + if (new >= 0) + return old; + return ((ALPHA * new) + ((100 - ALPHA) * old)) / 100; +} + #ifdef CONFIG_FILS static struct wpabuf * prepare_auth_resp_fils(struct hostapd_data *hapd, @@ -5873,7 +5882,7 @@ static int robust_action_frame(u8 catego static int handle_action(struct hostapd_data *hapd, const struct ieee80211_mgmt *mgmt, size_t len, - unsigned int freq) + unsigned int freq, int ssi_signal) { struct sta_info *sta; u8 *action __maybe_unused; @@ -5930,6 +5939,7 @@ static int handle_action(struct hostapd_ sta->last_seq_ctrl = seq_ctrl; sta->last_subtype = WLAN_FC_STYPE_ACTION; + sta->signal_mgmt = ewma(ssi_signal, sta->signal_mgmt);; } switch (mgmt->u.action.category) { @@ -6109,6 +6119,8 @@ int ieee802_11_mgmt(struct hostapd_data unsigned int freq; int ssi_signal = fi ? fi->ssi_signal : 0; + hapd->signal_mgmt = ewma(ssi_signal, hapd->signal_mgmt);; + if (len < 24) return 0; @@ -6208,7 +6220,7 @@ int ieee802_11_mgmt(struct hostapd_data break; case WLAN_FC_STYPE_ACTION: wpa_printf(MSG_DEBUG, "mgmt::action"); - ret = handle_action(hapd, mgmt, len, freq); + ret = handle_action(hapd, mgmt, len, freq, ssi_signal); break; default: hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211, --- a/src/ap/sta_info.h +++ b/src/ap/sta_info.h @@ -331,6 +331,7 @@ struct sta_info { #ifdef CONFIG_PASN struct pasn_data *pasn; #endif /* CONFIG_PASN */ + int signal_mgmt; }; --- a/src/ap/ubus.c +++ b/src/ap/ubus.c @@ -336,6 +336,9 @@ hostapd_bss_get_clients(struct ubus_cont blobmsg_add_u32(&b, "tx", sta_driver_data.tx_mcs); } blobmsg_close_table(&b, r); + + if (sta->signal_mgmt) + blobmsg_add_u32(&b, "signal_mgmt", sta->signal_mgmt); } hostapd_parse_capab_blobmsg(sta); @@ -457,6 +460,9 @@ hostapd_bss_get_status(struct ubus_conte if (hapd->conf->uci_section) blobmsg_add_string(&b, "uci_section", hapd->conf->uci_section); + if (hapd->signal_mgmt) + blobmsg_add_u32(&b, "signal_mgmt", hapd->signal_mgmt); + ubus_send_reply(ctx, req, b.head); return 0; --- a/src/ap/hostapd.h +++ b/src/ap/hostapd.h @@ -451,6 +451,7 @@ struct hostapd_data { #ifdef CONFIG_CTRL_IFACE_UDP unsigned char ctrl_iface_cookie[CTRL_IFACE_COOKIE_LEN]; #endif /* CONFIG_CTRL_IFACE_UDP */ + int signal_mgmt; };