[PATCH 09/24] wpa_supplicant/hostapd: Add awareness of CSA support

Ilan Peer ilan.peer at intel.com
Mon May 19 03:06:06 EDT 2014


From: Andrei Otcheretianski <andrei.otcheretianski at intel.com>

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

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski at 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(+)

diff --git a/hostapd/main.c b/hostapd/main.c
index a9d7da5..e4e3f27 100644
--- a/hostapd/main.c
+++ b/hostapd/main.c
@@ -217,6 +217,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 391d774..147635f 100644
--- a/src/ap/hostapd.c
+++ b/src/ap/hostapd.c
@@ -2333,6 +2333,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 bd85c54..25c2d4f 100644
--- a/src/ap/hostapd.h
+++ b/src/ap/hostapd.h
@@ -350,6 +350,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;
 
 	unsigned int dfs_cac_ms;
 	struct os_reltime dfs_cac_start;
diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c
index b02c424..945dc67 100644
--- a/wpa_supplicant/ap.c
+++ b/wpa_supplicant/ap.c
@@ -569,6 +569,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 2e60950..bf455ed 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -3664,6 +3664,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 526b795..2a2935c 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -860,6 +860,8 @@ struct wpa_supplicant {
 	struct wpa_radio_work *connect_work;
 
 	unsigned int ext_work_id;
+
+	unsigned int csa_supported:1;
 };
 
 
-- 
1.7.10.4



More information about the HostAP mailing list