[PATCH 23/26] hostapd: set channel and operating class in hostapd_fill_csa_settings()

Ilan Peer ilan.peer
Tue Sep 8 02:46:30 PDT 2015


From: Luciano Coelho <luciano.coelho at intel.com>

The CSA channel and operating class values need to be set for all
types of channel switch (ie. either if it's triggered by the control
interfaces or due to the GO-follows-STA flow).  To do so, move the
code that sets them from the GO-follows-STA flow to the more generic
hostapd_fill_csa_settings() function.

Signed-off-by: Luciano Coelho <luciano.coelho at intel.com>
---
 src/ap/hostapd.c                | 17 +++++++++++++++++
 wpa_supplicant/p2p_supplicant.c | 30 +++++++++++++-----------------
 2 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c
index 3b879a5..0dbd753 100644
--- a/src/ap/hostapd.c
+++ b/src/ap/hostapd.c
@@ -2828,11 +2828,28 @@ static int hostapd_fill_csa_settings(struct hostapd_data *hapd,
 	struct hostapd_iface *iface = hapd->iface;
 	struct hostapd_freq_params old_freq;
 	int ret;
+	u8 chan;
 
 	os_memset(&old_freq, 0, sizeof(old_freq));
 	if (!iface || !iface->freq || hapd->csa_in_progress)
 		return -1;
 
+	if (ieee80211_freq_to_channel_ext(
+		    settings->freq_params.freq,
+		    settings->freq_params.sec_channel_offset,
+		    settings->freq_params.vht_enabled,
+		    &hapd->iface->cs_oper_class,
+		    &chan) == NUM_HOSTAPD_MODES) {
+		wpa_printf(MSG_DEBUG,
+			   "invalid frequency for channel switch (freq = %d, sec_channel_offset = %d, vht_enabled = %d\n",
+			   settings->freq_params.freq,
+			   settings->freq_params.sec_channel_offset,
+			   settings->freq_params.vht_enabled);
+		return -1;
+	}
+
+	settings->freq_params.channel = chan;
+
 	ret = hostapd_change_config_freq(iface->bss[0], iface->conf,
 					 &settings->freq_params,
 					 &old_freq);
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index a2e32cb..a19253d 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -8527,7 +8527,6 @@ static int wpas_p2p_move_go_csa(struct wpa_supplicant *wpa_s)
 	struct wpa_ssid *current_ssid = wpa_s->current_ssid;
 	int old_freq = current_ssid->frequency;
 	int ret;
-	u8 chan;
 
 	if (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_AP_CSA)) {
 		wpa_dbg(wpa_s, MSG_DEBUG, "CSA is not enabled");
@@ -8576,35 +8575,32 @@ static int wpas_p2p_move_go_csa(struct wpa_supplicant *wpa_s)
 	csa_settings.cs_count = P2P_GO_CSA_COUNT;
 	csa_settings.block_tx = P2P_GO_CSA_BLOCK_TX;
 	csa_settings.freq_params.freq = params.freq;
-
-	if (ieee80211_freq_to_channel_ext(params.freq,
-					  conf->secondary_channel,
-					  conf->ieee80211ac,
-					  &wpa_s->ap_iface->cs_oper_class,
-					  &chan) ==
-	    NUM_HOSTAPD_MODES) {
-		wpa_dbg(wpa_s, MSG_DEBUG,
-			"P2P CSA: Selected invalid frequency");
-		ret = -1;
-		goto out;
-	}
-
-	csa_settings.freq_params.channel = chan;
 	csa_settings.freq_params.sec_channel_offset = conf->secondary_channel;
 	csa_settings.freq_params.ht_enabled = conf->ieee80211n;
 	csa_settings.freq_params.bandwidth = conf->secondary_channel ? 40 : 20;
 
 	if (conf->ieee80211ac) {
 		int freq1 = 0, freq2 = 0;
+		u8 chan, op_class;
+
+		if (ieee80211_freq_to_channel_ext(params.freq,
+						  conf->secondary_channel,
+						  conf->vht_oper_chwidth,
+						  &op_class, &chan) ==
+		    NUM_HOSTAPD_MODES) {
+			wpa_printf(MSG_ERROR, "P2P CSA: Bad freq");
+			ret = -1;
+			goto out;
+		}
 
 		if (conf->vht_oper_centr_freq_seg0_idx)
 			freq1 = ieee80211_chan_to_freq(NULL,
-						       wpa_s->ap_iface->cs_oper_class,
+						       op_class,
 						       conf->vht_oper_centr_freq_seg0_idx);
 
 		if (conf->vht_oper_centr_freq_seg1_idx)
 			freq2 = ieee80211_chan_to_freq(NULL,
-						       wpa_s->ap_iface->cs_oper_class,
+						       op_class,
 						       conf->vht_oper_centr_freq_seg1_idx);
 
 		if (freq1 < 0 || freq2 < 0) {
-- 
1.9.1




More information about the Hostap mailing list