diff --git a/hostapd/ap.h b/hostapd/ap.h index 380b7863e..b73bda104 100644 --- a/hostapd/ap.h +++ b/hostapd/ap.h @@ -56,6 +56,9 @@ struct sta_info { unsigned int nonerp_set:1; unsigned int no_short_slot_time_set:1; unsigned int no_short_preamble_set:1; + unsigned int no_ht_gf_set:1; + unsigned int no_ht_set:1; + unsigned int ht_20mhz_set:1; u16 auth_alg; u8 previous_ap[6]; diff --git a/hostapd/ieee802_11.c b/hostapd/ieee802_11.c index 7a233a259..e85e5e015 100644 --- a/hostapd/ieee802_11.c +++ b/hostapd/ieee802_11.c @@ -980,21 +980,30 @@ static void handle_assoc(struct hostapd_data *hapd, wpa_printf(MSG_DEBUG, "HT: STA " MACSTR " HT Capabilities " "Info: 0x%04x", MAC2STR(sta->addr), ht_capab); if ((ht_capab & HT_CAP_INFO_GREEN_FIELD) == 0) { - hapd->iface->num_sta_ht_no_gf++; + if (!sta->no_ht_gf_set) { + sta->no_ht_gf_set = 1; + hapd->iface->num_sta_ht_no_gf++; + } wpa_printf(MSG_DEBUG, "%s STA " MACSTR " - no " "greenfield, num of non-gf stations %d", __func__, MAC2STR(sta->addr), hapd->iface->num_sta_ht_no_gf); } if ((ht_capab & HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET) == 0) { - hapd->iface->num_sta_ht_20mhz++; + if (!sta->ht_20mhz_set) { + sta->ht_20mhz_set = 1; + hapd->iface->num_sta_ht_20mhz++; + } wpa_printf(MSG_DEBUG, "%s STA " MACSTR " - 20 MHz HT, " "num of 20MHz HT STAs %d", __func__, MAC2STR(sta->addr), hapd->iface->num_sta_ht_20mhz); } } else { - hapd->iface->num_sta_no_ht++; + if (!sta->no_ht_set) { + sta->no_ht_set = 1; + hapd->iface->num_sta_no_ht++; + } if (hapd->iconf->ieee80211n) { wpa_printf(MSG_DEBUG, "%s STA " MACSTR " - no HT, num of non-HT stations %d", diff --git a/hostapd/sta_info.c b/hostapd/sta_info.c index 6fc1e0435..1128f1064 100644 --- a/hostapd/sta_info.c +++ b/hostapd/sta_info.c @@ -155,15 +155,20 @@ void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta) } #ifdef CONFIG_IEEE80211N - if (sta->flags & WLAN_STA_HT) { - u16 ht_capab = le_to_host16( - sta->ht_capabilities.data.capabilities_info); - if ((ht_capab & HT_CAP_INFO_GREEN_FIELD) == 0) - hapd->iface->num_sta_ht_no_gf--; - if ((ht_capab & HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET) == 0) - hapd->iface->num_sta_ht_20mhz--; - } else + if (sta->no_ht_gf_set) { + sta->no_ht_gf_set = 0; + hapd->iface->num_sta_ht_no_gf--; + } + + if (sta->no_ht_set) { + sta->no_ht_set = 0; hapd->iface->num_sta_no_ht--; + } + + if (sta->ht_20mhz_set) { + sta->ht_20mhz_set = 0; + hapd->iface->num_sta_ht_20mhz--; + } if (hostapd_ht_operation_update(hapd->iface) > 0) set_beacon++;