Fixed non-HT (and GF, 20 MHz) counting
authorJouni Malinen <jouni.malinen@atheros.com>
Tue, 2 Dec 2008 12:32:05 +0000 (14:32 +0200)
committerJouni Malinen <j@w1.fi>
Tue, 2 Dec 2008 12:32:05 +0000 (14:32 +0200)
Must not count the same STA multiple times if it reassociates back to
the same AP without the old STA entry being removed.

hostapd/ap.h
hostapd/ieee802_11.c
hostapd/sta_info.c

index 380b786..b73bda1 100644 (file)
@@ -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];
index 7a233a2..e85e5e0 100644 (file)
@@ -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",
index 6fc1e04..1128f10 100644 (file)
@@ -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++;