Allocate sta->ht_capabilities dynamically

This avoids need for conditional inclusion of header file into
sta_info.h and cleans up the code a bit.
This commit is contained in:
Jouni Malinen 2009-11-29 21:07:52 +02:00
parent 99d845a7ec
commit df84268ae7
4 changed files with 25 additions and 13 deletions

View 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"

View 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 */

View 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);
}

View file

@ -15,10 +15,6 @@
#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;