[PATCH 11/14] wpa_supplicant: Move HT and VHT CSA related IEs functions
Ilan Peer
ilan.peer
Mon May 19 00:07:13 PDT 2014
From: Andrei Otcheretianski <andrei.otcheretianski at intel.com>
Move secondary channel IE function and wide bandwidth channel switch wrapper IE
to ieee802_11_ht.c and ieee802_11_vht.c accordingly.
Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski at intel.com>
---
src/ap/beacon.c | 79 +++--------------------------------------------
src/ap/ieee802_11.h | 2 ++
src/ap/ieee802_11_ht.c | 22 +++++++++++++
src/ap/ieee802_11_vht.c | 55 +++++++++++++++++++++++++++++++++
4 files changed, 83 insertions(+), 75 deletions(-)
diff --git a/src/ap/beacon.c b/src/ap/beacon.c
index 7178862..1720f87 100644
--- a/src/ap/beacon.c
+++ b/src/ap/beacon.c
@@ -293,81 +293,6 @@ static u8 *hostapd_eid_ecsa(struct hostapd_data *hapd, u8 *eid)
return eid;
}
-static u8 *hostapd_eid_secondary_channel(struct hostapd_data *hapd, u8 *eid)
-{
- u8 sec_ch;
-
- if (!hapd->iface->cs_freq_params.sec_channel_offset)
- return eid;
-
- if (hapd->iface->cs_freq_params.sec_channel_offset == -1)
- sec_ch = HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW;
- else if (hapd->iface->cs_freq_params.sec_channel_offset == 1)
- sec_ch = HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE;
- else
- return eid;
-
- *eid++ = WLAN_EID_SECONDARY_CHANNEL_OFFSET;
- *eid++ = 1;
- *eid++ = sec_ch;
-
- return eid;
-}
-
-static u8 *hostapd_eid_wb_chsw_wrapper(struct hostapd_data *hapd, u8 *eid)
-{
- u8 bw, chan1, chan2 = 0;
- int freq1;
-
- if (!hapd->iface->cs_freq_params.vht_enabled)
- return eid;
-
- /* bandwidth: 0: 40, 1: 80, 2: 160, 3: 80+80 */
- switch (hapd->iface->cs_freq_params.bandwidth) {
- case 40:
- bw = 0;
- break;
- case 80:
- /* check if it's 80+80 */
- if (!hapd->iface->cs_freq_params.center_freq2)
- bw = 1;
- else
- bw = 3;
- break;
- case 160:
- bw = 2;
- break;
- default:
- /* not valid VHT bandwidth or not in csa */
- return eid;
- }
-
- freq1 = hapd->iface->cs_freq_params.center_freq1 ?
- hapd->iface->cs_freq_params.center_freq1 :
- hapd->iface->cs_freq_params.freq;
- if (ieee80211_freq_to_chan(freq1, &chan1) !=
- HOSTAPD_MODE_IEEE80211A)
- return eid;
-
- if (hapd->iface->cs_freq_params.center_freq2) {
- if (ieee80211_freq_to_chan(
- hapd->iface->cs_freq_params.center_freq2,
- &chan2) !=
- HOSTAPD_MODE_IEEE80211A)
- return eid;
- }
-
- *eid++ = WLAN_EID_VHT_CHANNEL_SWITCH_WRAPPER;
- *eid++ = 5; /* length of ch. sw. wrapper */
- *eid++ = WLAN_EID_VHT_WIDE_BW_CHSWITCH;
- *eid++ = 3;
- *eid++ = bw;
- *eid++ = chan1;
- *eid++ = chan2;
-
- return eid;
-}
-
static u8 *hostapd_add_csa_elems(struct hostapd_data *hapd, u8 *pos,
u8 *start, unsigned int *csa_counter_off,
unsigned int *ecsa_counter_off)
@@ -396,8 +321,12 @@ static u8 *hostapd_add_csa_elems(struct hostapd_data *hapd, u8 *pos,
/* at least one of ies is added */
if (pos != curr_pos) {
+#ifdef CONFIG_IEEE80211N
curr_pos = hostapd_eid_secondary_channel(hapd, curr_pos);
+#endif
+#ifdef CONFIG_IEEE80211AC
curr_pos = hostapd_eid_wb_chsw_wrapper(hapd, curr_pos);
+#endif
}
return curr_pos;
}
diff --git a/src/ap/ieee802_11.h b/src/ap/ieee802_11.h
index cf0d3f2..6376808 100644
--- a/src/ap/ieee802_11.h
+++ b/src/ap/ieee802_11.h
@@ -49,8 +49,10 @@ 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(struct hostapd_data *hapd, u8 *eid);
u8 * hostapd_eid_ht_operation(struct hostapd_data *hapd, u8 *eid);
+u8 *hostapd_eid_secondary_channel(struct hostapd_data *hapd, u8 *eid);
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_wb_chsw_wrapper(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,
const u8 *addr, const u8 *trans_id);
diff --git a/src/ap/ieee802_11_ht.c b/src/ap/ieee802_11_ht.c
index c0a7cd4..5ae8726 100644
--- a/src/ap/ieee802_11_ht.c
+++ b/src/ap/ieee802_11_ht.c
@@ -108,6 +108,28 @@ u8 * hostapd_eid_ht_operation(struct hostapd_data *hapd, u8 *eid)
}
+u8 *hostapd_eid_secondary_channel(struct hostapd_data *hapd, u8 *eid)
+{
+ u8 sec_ch;
+
+ if (!hapd->iface->cs_freq_params.sec_channel_offset)
+ return eid;
+
+ if (hapd->iface->cs_freq_params.sec_channel_offset == -1)
+ sec_ch = HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW;
+ else if (hapd->iface->cs_freq_params.sec_channel_offset == 1)
+ sec_ch = HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE;
+ else
+ return eid;
+
+ *eid++ = WLAN_EID_SECONDARY_CHANNEL_OFFSET;
+ *eid++ = 1;
+ *eid++ = sec_ch;
+
+ return eid;
+}
+
+
/*
op_mode
Set to 0 (HT pure) under the followign conditions
diff --git a/src/ap/ieee802_11_vht.c b/src/ap/ieee802_11_vht.c
index 221d9c2..c0d179c 100644
--- a/src/ap/ieee802_11_vht.c
+++ b/src/ap/ieee802_11_vht.c
@@ -81,6 +81,61 @@ u8 * hostapd_eid_vht_operation(struct hostapd_data *hapd, u8 *eid)
}
+u8 *hostapd_eid_wb_chsw_wrapper(struct hostapd_data *hapd, u8 *eid)
+{
+ u8 bw, chan1, chan2 = 0;
+ int freq1;
+
+ if (!hapd->iface->cs_freq_params.vht_enabled)
+ return eid;
+
+ /* bandwidth: 0: 40, 1: 80, 2: 160, 3: 80+80 */
+ switch (hapd->iface->cs_freq_params.bandwidth) {
+ case 40:
+ bw = 0;
+ break;
+ case 80:
+ /* check if it's 80+80 */
+ if (!hapd->iface->cs_freq_params.center_freq2)
+ bw = 1;
+ else
+ bw = 3;
+ break;
+ case 160:
+ bw = 2;
+ break;
+ default:
+ /* not valid VHT bandwidth or not in csa */
+ return eid;
+ }
+
+ freq1 = hapd->iface->cs_freq_params.center_freq1 ?
+ hapd->iface->cs_freq_params.center_freq1 :
+ hapd->iface->cs_freq_params.freq;
+ if (ieee80211_freq_to_chan(freq1, &chan1) !=
+ HOSTAPD_MODE_IEEE80211A)
+ return eid;
+
+ if (hapd->iface->cs_freq_params.center_freq2) {
+ if (ieee80211_freq_to_chan(
+ hapd->iface->cs_freq_params.center_freq2,
+ &chan2) !=
+ HOSTAPD_MODE_IEEE80211A)
+ return eid;
+ }
+
+ *eid++ = WLAN_EID_VHT_CHANNEL_SWITCH_WRAPPER;
+ *eid++ = 5; /* length of ch. sw. wrapper */
+ *eid++ = WLAN_EID_VHT_WIDE_BW_CHSWITCH;
+ *eid++ = 3;
+ *eid++ = bw;
+ *eid++ = chan1;
+ *eid++ = chan2;
+
+ return eid;
+}
+
+
u16 copy_sta_vht_capab(struct hostapd_data *hapd, struct sta_info *sta,
const u8 *vht_capab, size_t vht_capab_len)
{
--
1.7.10.4
More information about the Hostap
mailing list