]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Allocate sta->ht_capabilities dynamically
authorJouni Malinen <j@w1.fi>
Sun, 29 Nov 2009 19:07:52 +0000 (21:07 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 29 Nov 2009 19:07:52 +0000 (21:07 +0200)
This avoids need for conditional inclusion of header file into
sta_info.h and cleans up the code a bit.

hostapd/config.c
hostapd/ieee802_11.c
hostapd/sta_info.c
hostapd/sta_info.h

index f92bbdebd968647283448ba73a782ad1644b53fc..a13adaf446d91031a682b4aeac518e92df268a6d 100644 (file)
@@ -24,6 +24,7 @@
 #include "sha1.h"
 #include "eap_server/eap.h"
 #include "radius/radius_client.h"
+#include "common/ieee802_11_defs.h"
 #include "common/wpa_common.h"
 #include "wpa.h"
 #include "uuid.h"
index 87775c37cb3fd924b385954224e60f931d0aaf2f..0522b88fb7cd62885319d645bbf599fd5a2761d1 100644 (file)
@@ -855,15 +855,28 @@ static void handle_assoc(struct hostapd_data *hapd,
 
 #ifdef CONFIG_IEEE80211N
        /* save HT capabilities in the sta object */
-       os_memset(&sta->ht_capabilities, 0, sizeof(sta->ht_capabilities));
        if (elems.ht_capabilities &&
            elems.ht_capabilities_len >=
            sizeof(struct ieee80211_ht_capabilities)) {
+               if (sta->ht_capabilities) {
+                       os_memset(sta->ht_capabilities, 0,
+                                 sizeof(*sta->ht_capabilities));
+               } else {
+                       sta->ht_capabilities =
+                               os_zalloc(sizeof(*sta->ht_capabilities));
+                       if (sta->ht_capabilities == NULL) {
+                               resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
+                               goto fail;
+                       }
+               }
                sta->flags |= WLAN_STA_HT;
-               os_memcpy(&sta->ht_capabilities, elems.ht_capabilities,
+               os_memcpy(sta->ht_capabilities, elems.ht_capabilities,
                          sizeof(struct ieee80211_ht_capabilities));
-       } else
+       } else {
                sta->flags &= ~WLAN_STA_HT;
+               os_free(sta->ht_capabilities);
+               sta->ht_capabilities = NULL;
+       }
 #endif /* CONFIG_IEEE80211N */
 
        if ((hapd->conf->wpa & WPA_PROTO_RSN) && elems.rsn_ie) {
@@ -1033,9 +1046,9 @@ static void handle_assoc(struct hostapd_data *hapd,
        }
 
 #ifdef CONFIG_IEEE80211N
-       if (sta->flags & WLAN_STA_HT) {
+       if ((sta->flags & WLAN_STA_HT) && sta->ht_capabilities) {
                u16 ht_capab = le_to_host16(
-                       sta->ht_capabilities.ht_capabilities_info);
+                       sta->ht_capabilities->ht_capabilities_info);
                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) {
@@ -1586,6 +1599,8 @@ hostapd_get_ht_capab(struct hostapd_data *hapd,
 {
        u16 cap;
 
+       if (ht_cap == NULL)
+               return;
        os_memcpy(neg_ht_cap, ht_cap, sizeof(*neg_ht_cap));
        cap = le_to_host16(neg_ht_cap->ht_capabilities_info);
        cap &= hapd->iconf->ht_capab;
@@ -1667,7 +1682,7 @@ static void handle_assoc_cb(struct hostapd_data *hapd,
 #ifdef CONFIG_IEEE80211N
        if (sta->flags & WLAN_STA_HT) {
                ht_cap_ptr = &ht_cap;
-               hostapd_get_ht_capab(hapd, &sta->ht_capabilities, ht_cap_ptr);
+               hostapd_get_ht_capab(hapd, sta->ht_capabilities, ht_cap_ptr);
        }
 #endif /* CONFIG_IEEE80211N */
 
index ee8187715fa5a38f0f7a22b294f511e7d3909857..9f74e6bd8e5ca572f40ee44e43e1cc41e6d51c4a 100644 (file)
@@ -200,6 +200,8 @@ void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta)
 
        wpabuf_free(sta->wps_ie);
 
+       os_free(sta->ht_capabilities);
+
        os_free(sta);
 }
 
index a12808245f53f34b2eac35ce314f0c83c7aa6e14..bd4b3e46e3f889ebbc5d898fba8b14d8e79c770e 100644 (file)
 #ifndef STA_INFO_H
 #define STA_INFO_H
 
-#ifdef CONFIG_IEEE80211N
-#include "common/ieee802_11_defs.h"
-#endif /* CONFIG_IEEE80211N */
-
 /* Maximum number of supported rates (from both Supported Rates and Extended
  * Supported Rates IEs). */
 #define WLAN_SUPP_RATES_MAX 32
@@ -77,9 +73,7 @@ struct sta_info {
 
        int vlan_id;
 
-#ifdef CONFIG_IEEE80211N
-       struct ieee80211_ht_capabilities ht_capabilities;
-#endif /* CONFIG_IEEE80211N */
+       struct ieee80211_ht_capabilities *ht_capabilities;
 
 #ifdef CONFIG_IEEE80211W
        int sa_query_count; /* number of pending SA Query requests;