Patchwork [4/4] hostapd: DFS handle radar event when CAC active correctly

login
register
mail settings
Submitter Janusz.Dziedzic@tieto.com
Date Oct. 24, 2013, 3:40 p.m.
Message ID <1382629228-8895-4-git-send-email-janusz.dziedzic@tieto.com>
Download mbox | patch
Permalink /patch/285955/
State Accepted
Commit 2e946249b1f603ea31cc5609800797829d17fdd7
Headers show

Comments

Janusz.Dziedzic@tieto.com - Oct. 24, 2013, 3:40 p.m.
When we have CAC active and will get radar event,
we should ignore CAC_ABORT event and handle channel
switch in radar event handler.

Signed-hostap: Janusz Dziedzic <janusz.dziedzic@tieto.com>
---
 src/ap/ap_drv_ops.c |    7 ++++++-
 src/ap/dfs.c        |   29 ++++++++---------------------
 src/ap/hostapd.h    |    3 +++
 3 files changed, 17 insertions(+), 22 deletions(-)

Patch

diff --git a/src/ap/ap_drv_ops.c b/src/ap/ap_drv_ops.c
index 9023eab..1109575 100644
--- a/src/ap/ap_drv_ops.c
+++ b/src/ap/ap_drv_ops.c
@@ -724,6 +724,7 @@  int hostapd_start_dfs_cac(struct hostapd_data *hapd, int mode, int freq,
 			  int center_segment0, int center_segment1)
 {
 	struct hostapd_freq_params data;
+	int res;
 
 	if (!hapd->driver || !hapd->driver->start_dfs_cac)
 		return 0;
@@ -740,7 +741,11 @@  int hostapd_start_dfs_cac(struct hostapd_data *hapd, int mode, int freq,
 				    center_segment1))
 		return -1;
 
-	return hapd->driver->start_dfs_cac(hapd->drv_priv, &data);
+	res = hapd->driver->start_dfs_cac(hapd->drv_priv, &data);
+	if (!res)
+		hapd->cac_started = 1;
+
+	return res;
 }
 
 
diff --git a/src/ap/dfs.c b/src/ap/dfs.c
index dffbea0..b65da33 100644
--- a/src/ap/dfs.c
+++ b/src/ap/dfs.c
@@ -540,29 +540,14 @@  int hostapd_dfs_complete_cac(struct hostapd_data *hapd, int success, int freq,
 			     int ht_enabled, int chan_offset, int chan_width,
 			     int cf1, int cf2)
 {
-	struct hostapd_channel_data *channel;
-	int err = 1;
 
 	if (success) {
 		/* Complete iface/ap configuration */
 		set_dfs_state(hapd, freq, ht_enabled, chan_offset,
 			      chan_width, cf1, cf2,
 			      HOSTAPD_CHAN_DFS_AVAILABLE);
+		hapd->cac_started = 0;
 		hostapd_setup_interface_complete(hapd->iface, 0);
-	} else {
-		/* Switch to new channel */
-		set_dfs_state(hapd, freq, ht_enabled, chan_offset,
-			      chan_width, cf1, cf2,
-			      HOSTAPD_CHAN_DFS_UNAVAILABLE);
-		channel = dfs_get_valid_channel(hapd);
-		if (channel) {
-			hapd->iconf->channel = channel->chan;
-			hapd->iface->freq = channel->freq;
-			err = 0;
-		} else
-			wpa_printf(MSG_ERROR, "No valid channel available");
-
-		hostapd_setup_interface_complete(hapd->iface, err);
 	}
 
 	return 0;
@@ -582,7 +567,13 @@  static int hostapd_dfs_start_channel_switch(struct hostapd_data *hapd)
 		err = 0;
 	}
 
-	hapd->driver->stop_ap(hapd->drv_priv);
+	if (!hapd->cac_started) {
+		wpa_printf(MSG_DEBUG, "DFS radar detected");
+		hapd->driver->stop_ap(hapd->drv_priv);
+	} else {
+		wpa_printf(MSG_DEBUG, "DFS radar detected during CAC");
+		hapd->cac_started = 0;
+	}
 
 	hostapd_setup_interface_complete(hapd->iface, err);
 	return 0;
@@ -608,10 +599,6 @@  int hostapd_dfs_radar_detected(struct hostapd_data *hapd, int freq,
 	if (!res)
 		return 0;
 
-	/* we are working on non-DFS channel - skip event */
-	if (res == 0)
-		return 0;
-
 	/* radar detected while operating, switch the channel. */
 	res = hostapd_dfs_start_channel_switch(hapd);
 
diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h
index dbf1b52..b4bbb21 100644
--- a/src/ap/hostapd.h
+++ b/src/ap/hostapd.h
@@ -152,6 +152,9 @@  struct hostapd_data {
 
 	int parameter_set_count;
 
+	/* DFS specyfic parameters */
+	int cac_started;
+
 	/* Time Advertisement */
 	u8 time_update_counter;
 	struct wpabuf *time_adv;