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

Janusz Dziedzic janusz.dziedzic
Thu Oct 24 08:40:28 PDT 2013


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 at 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(-)

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;
-- 
1.7.9.5




More information about the Hostap mailing list