From a49148fd55c17da4bec69ea2b0d029b191019ebb Mon Sep 17 00:00:00 2001
From: Jouni Malinen <j@w1.fi>
Date: Sun, 29 Nov 2009 12:02:29 +0200
Subject: [PATCH] Rename HT Capabilities IE fields to match with IEEE Std
 802.11n-2009

---
 hostapd/beacon.c             |  6 +++---
 hostapd/ieee802_11.c         | 32 +++++++++++++++++++-------------
 hostapd/ieee802_11.h         |  2 +-
 src/common/ieee802_11_defs.h | 16 ++++++++--------
 4 files changed, 31 insertions(+), 25 deletions(-)

diff --git a/hostapd/beacon.c b/hostapd/beacon.c
index 52f1da104..425b51417 100644
--- a/hostapd/beacon.c
+++ b/hostapd/beacon.c
@@ -2,7 +2,7 @@
  * hostapd / IEEE 802.11 Management: Beacon and Probe Request/Response
  * Copyright (c) 2002-2004, Instant802 Networks, Inc.
  * Copyright (c) 2005-2006, Devicescape Software, Inc.
- * Copyright (c) 2008, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2008-2009, Jouni Malinen <j@w1.fi>
  * Copyright (c) 2007-2008, Intel Corporation
  *
  * This program is free software; you can redistribute it and/or modify
@@ -301,7 +301,7 @@ void handle_probe_req(struct hostapd_data *hapd, struct ieee80211_mgmt *mgmt,
 	/* Wi-Fi Alliance WMM */
 	pos = hostapd_eid_wmm(hapd, pos);
 
-	pos = hostapd_eid_ht_capabilities_info(hapd, pos);
+	pos = hostapd_eid_ht_capabilities(hapd, pos);
 	pos = hostapd_eid_ht_operation(hapd, pos);
 
 #ifdef CONFIG_WPS
@@ -402,7 +402,7 @@ void ieee802_11_set_beacon(struct hostapd_data *hapd)
 	if (hapd->iconf->ieee80211n) {
 		u8 *ht_capab, *ht_oper;
 		ht_capab = tailpos;
-		tailpos = hostapd_eid_ht_capabilities_info(hapd, tailpos);
+		tailpos = hostapd_eid_ht_capabilities(hapd, tailpos);
 
 		ht_oper = tailpos;
 		tailpos = hostapd_eid_ht_operation(hapd, tailpos);
diff --git a/hostapd/ieee802_11.c b/hostapd/ieee802_11.c
index 75bf62c71..acd052eec 100644
--- a/hostapd/ieee802_11.c
+++ b/hostapd/ieee802_11.c
@@ -1,6 +1,6 @@
 /*
  * hostapd / IEEE 802.11 Management
- * Copyright (c) 2002-2008, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
  * Copyright (c) 2007-2008, Intel Corporation
  *
  * This program is free software; you can redistribute it and/or modify
@@ -101,10 +101,10 @@ u8 * hostapd_eid_ext_supp_rates(struct hostapd_data *hapd, u8 *eid)
 }
 
 
-u8 * hostapd_eid_ht_capabilities_info(struct hostapd_data *hapd, u8 *eid)
+u8 * hostapd_eid_ht_capabilities(struct hostapd_data *hapd, u8 *eid)
 {
 #ifdef CONFIG_IEEE80211N
-	struct ieee80211_ht_capability *cap;
+	struct ieee80211_ht_capabilities *cap;
 	u8 *pos = eid;
 
 	if (!hapd->iconf->ieee80211n)
@@ -113,16 +113,22 @@ u8 * hostapd_eid_ht_capabilities_info(struct hostapd_data *hapd, u8 *eid)
 	*pos++ = WLAN_EID_HT_CAP;
 	*pos++ = sizeof(*cap);
 
-	cap = (struct ieee80211_ht_capability *) pos;
+	cap = (struct ieee80211_ht_capabilities *) pos;
 	os_memset(cap, 0, sizeof(*cap));
-	SET_2BIT_U8(&cap->mac_ht_params_info,
+	cap->ht_capabilities_info = host_to_le16(hapd->iconf->ht_capab);
+
+	/* FIX: from driver */
+	SET_2BIT_U8(&cap->a_mpdu_params,
 		    MAC_HT_PARAM_INFO_MAX_RX_AMPDU_FACTOR_OFFSET,
 		    MAX_RX_AMPDU_FACTOR_64KB);
 
-	cap->capabilities_info = host_to_le16(hapd->iconf->ht_capab);
 	os_memcpy(cap->supported_mcs_set, hapd->iface->current_mode->mcs_set,
 		  16);
 
+	/* TODO: ht_extended_capabilities (now fully disabled) */
+	/* TODO: tx_bf_capability_info (now fully disabled) */
+	/* TODO: asel_capabilities (now fully disabled) */
+
  	pos += sizeof(*cap);
 
 	return pos;
@@ -855,14 +861,14 @@ static void handle_assoc(struct hostapd_data *hapd,
 	os_memset(&sta->ht_capabilities, 0, sizeof(sta->ht_capabilities));
 	if (elems.ht_capabilities &&
 	    elems.ht_capabilities_len >=
-	    sizeof(struct ieee80211_ht_capability)) {
+	    sizeof(struct ieee80211_ht_capabilities)) {
 		sta->flags |= WLAN_STA_HT;
 		sta->ht_capabilities.id = WLAN_EID_HT_CAP;
 		sta->ht_capabilities.length =
-			sizeof(struct ieee80211_ht_capability);
+			sizeof(struct ieee80211_ht_capabilities);
 		os_memcpy(&sta->ht_capabilities.data,
 			  elems.ht_capabilities,
-			  sizeof(struct ieee80211_ht_capability));
+			  sizeof(struct ieee80211_ht_capabilities));
 	} else
 		sta->flags &= ~WLAN_STA_HT;
 #endif /* CONFIG_IEEE80211N */
@@ -1036,7 +1042,7 @@ static void handle_assoc(struct hostapd_data *hapd,
 #ifdef CONFIG_IEEE80211N
 	if (sta->flags & WLAN_STA_HT) {
 		u16 ht_capab = le_to_host16(
-			sta->ht_capabilities.data.capabilities_info);
+			sta->ht_capabilities.data.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) {
@@ -1147,7 +1153,7 @@ static void handle_assoc(struct hostapd_data *hapd,
 		if (sta->flags & WLAN_STA_WMM)
 			p = hostapd_eid_wmm(hapd, p);
 
-		p = hostapd_eid_ht_capabilities_info(hapd, p);
+		p = hostapd_eid_ht_capabilities(hapd, p);
 		p = hostapd_eid_ht_operation(hapd, p);
 
 #ifdef CONFIG_IEEE80211R
@@ -1588,13 +1594,13 @@ hostapd_get_ht_capab(struct hostapd_data *hapd,
 	u16 cap;
 
 	os_memcpy(neg_ht_cap_ie, ht_cap_ie, sizeof(struct ht_cap_ie));
-	cap = le_to_host16(neg_ht_cap_ie->data.capabilities_info);
+	cap = le_to_host16(neg_ht_cap_ie->data.ht_capabilities_info);
 	cap &= hapd->iconf->ht_capab;
 	cap |= (hapd->iconf->ht_capab & HT_CAP_INFO_SMPS_DISABLED);
 
 	/* FIXME: Rx STBC needs to be handled specially */
 	cap |= (hapd->iconf->ht_capab & HT_CAP_INFO_RX_STBC_MASK);
-	neg_ht_cap_ie->data.capabilities_info = host_to_le16(cap);
+	neg_ht_cap_ie->data.ht_capabilities_info = host_to_le16(cap);
 }
 #endif /* CONFIG_IEEE80211N */
 
diff --git a/hostapd/ieee802_11.h b/hostapd/ieee802_11.h
index ca56c2071..68ed983e7 100644
--- a/hostapd/ieee802_11.h
+++ b/hostapd/ieee802_11.h
@@ -52,7 +52,7 @@ u16 hostapd_own_capab_info(struct hostapd_data *hapd, struct sta_info *sta,
 			   int probe);
 u8 * hostapd_eid_supp_rates(struct hostapd_data *hapd, u8 *eid);
 u8 * hostapd_eid_ext_supp_rates(struct hostapd_data *hapd, u8 *eid);
-u8 * hostapd_eid_ht_capabilities_info(struct hostapd_data *hapd, u8 *eid);
+u8 * hostapd_eid_ht_capabilities(struct hostapd_data *hapd, u8 *eid);
 u8 * hostapd_eid_ht_operation(struct hostapd_data *hapd, u8 *eid);
 int hostapd_ht_operation_update(struct hostapd_iface *iface);
 void ieee802_11_send_sa_query_req(struct hostapd_data *hapd,
diff --git a/src/common/ieee802_11_defs.h b/src/common/ieee802_11_defs.h
index 88eb48ebe..d78a040f9 100644
--- a/src/common/ieee802_11_defs.h
+++ b/src/common/ieee802_11_defs.h
@@ -1,6 +1,6 @@
 /*
  * IEEE 802.11 Frame type definitions
- * Copyright (c) 2002-2007, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
  * Copyright (c) 2007-2008 Intel Corporation
  *
  * This program is free software; you can redistribute it and/or modify
@@ -392,13 +392,13 @@ enum {
 };
 
 
-struct ieee80211_ht_capability {
-	le16 capabilities_info;
-	u8 mac_ht_params_info;
+struct ieee80211_ht_capabilities {
+	le16 ht_capabilities_info;
+	u8 a_mpdu_params;
 	u8 supported_mcs_set[16];
-	le16 extended_ht_capability_info;
-	le32 tx_BF_capability_info;
-	u8 antenna_selection_info;
+	le16 ht_extended_capabilities;
+	le32 tx_bf_capability_info;
+	u8 asel_capabilities;
 } STRUCT_PACKED;
 
 
@@ -517,7 +517,7 @@ struct ieee80211_ht_operation {
 struct ht_cap_ie {
 	u8 id;
 	u8 length;
-	struct ieee80211_ht_capability data;
+	struct ieee80211_ht_capabilities data;
 } STRUCT_PACKED;