Patchwork [2/5] wpa_supplicant/hostapd: Add awareness of CSA support

login
register
mail settings
Submitter Ilan Peer
Date Jan. 1, 2014, 1:32 p.m.
Message ID <1388583133-14842-3-git-send-email-ilan.peer@intel.com>
Download mbox | patch
Permalink /patch/305962/
State New
Headers show

Comments

Ilan Peer - Jan. 1, 2014, 1:32 p.m.
From: Andrei Otcheretianski <andrei.otcheretianski@intel.com>

Store csa_supported flag in wpa_supplicant and hostapd_iface.
Don't start CSA flow when CSA is not supported.

Signed-hostap: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
---
 hostapd/main.c                    |    1 +
 src/ap/hostapd.c                  |    8 ++++++++
 src/ap/hostapd.h                  |    1 +
 wpa_supplicant/ap.c               |    1 +
 wpa_supplicant/wpa_supplicant.c   |    1 +
 wpa_supplicant/wpa_supplicant_i.h |    2 ++
 6 files changed, 14 insertions(+)

Patch

diff --git a/hostapd/main.c b/hostapd/main.c
index 4e9fe40..eff99ea 100644
--- a/hostapd/main.c
+++ b/hostapd/main.c
@@ -223,6 +223,7 @@  static int hostapd_driver_init(struct hostapd_iface *iface)
 		iface->extended_capa_mask = capa.extended_capa_mask;
 		iface->extended_capa_len = capa.extended_capa_len;
 		iface->drv_max_acl_mac_addrs = capa.max_acl_mac_addrs;
+		iface->csa_supported = !!(capa.flags & WPA_DRIVER_FLAGS_AP_CSA);
 	}
 
 	return 0;
diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c
index 69459f7..3d88c59 100644
--- a/src/ap/hostapd.c
+++ b/src/ap/hostapd.c
@@ -2232,6 +2232,14 @@  int hostapd_switch_channel(struct hostapd_data *hapd,
 			   struct csa_settings *settings)
 {
 	int ret;
+	if (!hapd->iface)
+		return -1;
+
+	if (!hapd->iface->csa_supported) {
+		wpa_printf(MSG_ERROR, "CSA is not supported");
+		return -1;
+	}
+
 	ret = hostapd_fill_csa_settings(hapd->iface, settings);
 	if (ret)
 		return ret;
diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h
index 489ab16..e3ce3d2 100644
--- a/src/ap/hostapd.h
+++ b/src/ap/hostapd.h
@@ -344,6 +344,7 @@  struct hostapd_iface {
 	unsigned int cs_c_off_beacon;
 	unsigned int cs_c_off_proberesp;
 	int csa_in_progress;
+	unsigned int csa_supported:1;
 
 #ifdef CONFIG_ACS
 	unsigned int acs_num_completed_scans;
diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c
index 08a8855..86b8420 100644
--- a/wpa_supplicant/ap.c
+++ b/wpa_supplicant/ap.c
@@ -551,6 +551,7 @@  int wpa_supplicant_create_ap(struct wpa_supplicant *wpa_s,
 	hapd_iface->extended_capa = wpa_s->extended_capa;
 	hapd_iface->extended_capa_mask = wpa_s->extended_capa_mask;
 	hapd_iface->extended_capa_len = wpa_s->extended_capa_len;
+	hapd_iface->csa_supported = wpa_s->csa_supported;
 
 	wpa_s->ap_iface->conf = conf = hostapd_config_defaults();
 	if (conf == NULL) {
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index 50436cb..add71eb 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -3160,6 +3160,7 @@  static int wpa_supplicant_init_iface(struct wpa_supplicant *wpa_s,
 		wpa_s->extended_capa_len = capa.extended_capa_len;
 		wpa_s->num_multichan_concurrent =
 			capa.num_multichan_concurrent;
+		wpa_s->csa_supported = !!(capa.flags & WPA_DRIVER_FLAGS_AP_CSA);
 	}
 	if (wpa_s->max_remain_on_chan == 0)
 		wpa_s->max_remain_on_chan = 1000;
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
index 9dbf523..20dcb54 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -746,6 +746,8 @@  struct wpa_supplicant {
 #endif /* CONFIG_TESTING_GET_GTK */
 
 	unsigned int num_multichan_concurrent;
+
+	unsigned int csa_supported:1;
 };