[PATCH RESEND] hostapd: add VHT tx power envelope IE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add VHT transmit power envelope element defined in IEEE std
802.11ac-2013 8.4.2.164 for VHT bandwidth channel switch.

Signed-off-by: Rajkumar Manoharan <rmanohar@xxxxxxxxxxxxxxxx>
---
 src/ap/beacon.c         |  3 ++-
 src/ap/ieee802_11.h     |  1 +
 src/ap/ieee802_11_vht.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 52 insertions(+), 1 deletion(-)

diff --git a/src/ap/beacon.c b/src/ap/beacon.c
index 5f1fc3e..9e40dc2 100644
--- a/src/ap/beacon.c
+++ b/src/ap/beacon.c
@@ -330,7 +330,6 @@ static u8 * hostapd_eid_ecsa(struct hostapd_data *hapd, u8 *eid)
 	return eid;
 }
 
-
 static u8 * hostapd_eid_supported_op_classes(struct hostapd_data *hapd, u8 *eid)
 {
 	u8 op_class, channel;
@@ -482,6 +481,7 @@ static u8 * hostapd_gen_probe_resp(struct hostapd_data *hapd,
 		pos = hostapd_eid_vht_capabilities(hapd, pos);
 		pos = hostapd_eid_vht_operation(hapd, pos);
 		pos = hostapd_eid_wb_chsw_wrapper(hapd, pos);
+		pos = hostapd_eid_vht_txpwr_env(hapd, pos);
 	}
 	if (hapd->conf->vendor_vht)
 		pos = hostapd_eid_vendor_vht(hapd, pos);
@@ -1086,6 +1086,7 @@ int ieee802_11_build_ap_params(struct hostapd_data *hapd,
 		tailpos = hostapd_eid_vht_capabilities(hapd, tailpos);
 		tailpos = hostapd_eid_vht_operation(hapd, tailpos);
 		tailpos = hostapd_eid_wb_chsw_wrapper(hapd, tailpos);
+		tailpos = hostapd_eid_vht_txpwr_env(hapd, tailpos);
 	}
 	if (hapd->conf->vendor_vht)
 		tailpos = hostapd_eid_vendor_vht(hapd, tailpos);
diff --git a/src/ap/ieee802_11.h b/src/ap/ieee802_11.h
index a2dd132..4788e6b 100644
--- a/src/ap/ieee802_11.h
+++ b/src/ap/ieee802_11.h
@@ -54,6 +54,7 @@ u8 * hostapd_eid_vht_capabilities(struct hostapd_data *hapd, u8 *eid);
 u8 * hostapd_eid_vht_operation(struct hostapd_data *hapd, u8 *eid);
 u8 * hostapd_eid_vendor_vht(struct hostapd_data *hapd, u8 *eid);
 u8 * hostapd_eid_wb_chsw_wrapper(struct hostapd_data *hapd, u8 *eid);
+u8 * hostapd_eid_vht_txpwr_env(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/ap/ieee802_11_vht.c b/src/ap/ieee802_11_vht.c
index 8d2c428..91c04c8 100644
--- a/src/ap/ieee802_11_vht.c
+++ b/src/ap/ieee802_11_vht.c
@@ -184,6 +184,55 @@ u8 * hostapd_eid_wb_chsw_wrapper(struct hostapd_data *hapd, u8 *eid)
 }
 
 
+u8 * hostapd_eid_vht_txpwr_env(struct hostapd_data *hapd, u8 *eid)
+{
+	struct hostapd_freq_params *params = &hapd->cs_freq_params;
+	struct hostapd_hw_modes *mode = hapd->iface->current_mode;
+	struct hostapd_channel_data *chan;
+	int i;
+	u8 channel, max_tx_power;
+
+	if (hapd->cs_freq_params.bandwidth > 80 ||
+	    !hapd->cs_freq_params.vht_enabled)
+		return eid;
+
+	if (!params->freq)
+		return eid;
+
+	if (ieee80211_freq_to_chan(params->freq, &channel) ==
+	    NUM_HOSTAPD_MODES)
+		return eid;
+
+	for (i = 0; i < mode->num_channels; i++) {
+		if (mode->channels[i].freq == params->freq)
+			break;
+	}
+	if (i == mode->num_channels)
+		return eid;
+
+	chan = &mode->channels[i];
+
+	*eid++ = WLAN_EID_VHT_TRANSMIT_POWER_ENVELOPE;
+	*eid++ = 4;
+	/*
+	 * Max Transmit Power count = 2( 20,40 and 80MHz) and
+	 * Max Transmit Power units = 0 (EIRP)
+	 */
+	*eid++ = 2;
+
+	/*
+	 * Local Maximum Transmit power is encoded as 2's complement
+	 * with a 0.5 dB step
+	 */
+	max_tx_power = ~(chan->max_tx_power * 2) + 1;
+	*eid++ = max_tx_power;
+	*eid++ = max_tx_power;
+	*eid++ = max_tx_power;
+
+	return eid;
+}
+
+
 u16 copy_sta_vht_capab(struct hostapd_data *hapd, struct sta_info *sta,
 		       const u8 *vht_capab)
 {
-- 
2.6.1


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux