Search Linux Wireless

[PATCH v3 3/7] hostapd: add dfs events

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add EVENT_RADAR_DETECTED and EVENT_AP_CH_SWITCH_COMPLETE
events.

EVENT_RADAR_DETECTED indicates that radar was detected on
operational channel. EVENT_AP_CH_SWITCH_COMPLETE indicates
that device has finished the channel switch process.

Signed-hostap: Boris Presman <boris.presman@xxxxxx>
Signed-hostap: Victor Goldenshtein <victorg@xxxxxx>
---
 src/ap/drv_callbacks.c      |   45 +++++++++++++++++++++++++++++++++++++++++++
 src/drivers/driver.h        |   20 ++++++++++++++++++-
 src/drivers/driver_common.c |    2 +
 3 files changed, 66 insertions(+), 1 deletions(-)

diff --git a/src/ap/drv_callbacks.c b/src/ap/drv_callbacks.c
index c793c6a..d7148b0 100644
--- a/src/ap/drv_callbacks.c
+++ b/src/ap/drv_callbacks.c
@@ -684,6 +684,34 @@ static void hostapd_event_eapol_rx(struct hostapd_data *hapd, const u8 *src,
 	ieee802_1x_receive(hapd, src, data, data_len);
 }
 
+static void hostapd_event_radar_detected(struct hostapd_data *hapd,
+					 struct radar_detected *radar)
+{
+	if (!hapd->iconf->ieee80211h)
+		return;
+
+	if ((!(hapd->iface->dfs_state & DFS_INIT_PHASE_CAC)) &&
+	    (hapd->iface->freq != radar->freq)) {
+		wpa_printf(MSG_WARNING, "False radar detection, op_freq(%d) != "
+			   "radar_freq(%d)", hapd->iface->freq, radar->freq);
+		return;
+	}
+
+	if (ieee802_11_radar_detected(hapd))
+		ieee802_11_start_channel_switch(hapd, TRUE);
+	else
+		wpa_printf(MSG_DEBUG, "False radar detection");
+}
+
+static void hostapd_event_ap_ch_switch(struct hostapd_data *hapd, int freq)
+{
+	if (hapd->next_channel->freq != freq)
+		wpa_printf(MSG_WARNING, "Switched to wrong freq, next_freq(%d) "
+			   "!= ch_switch_freq(%d)", hapd->next_channel->freq,
+			   freq);
+
+	ieee802_11_complete_channel_switch(hapd);
+}
 
 void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
 			  union wpa_event_data *data)
@@ -707,6 +735,13 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
 		event_to_string(event), event);
 #endif /* CONFIG_NO_STDOUT_DEBUG */
 
+	if ((hapd->iface->dfs_state & DFS_INIT_PHASE_CAC) &&
+	    (event != EVENT_RADAR_DETECTED)) {
+		wpa_dbg(hapd->msg_ctx, level, "Irrelevant event "
+			"during DFS init phase");
+		return;
+	}
+
 	switch (event) {
 	case EVENT_MICHAEL_MIC_FAILURE:
 		michael_mic_failure(hapd, data->michael_mic_failure.src, 1);
@@ -816,6 +851,16 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
 					data->ch_switch.ht_enabled,
 					data->ch_switch.ch_offset);
 		break;
+	case EVENT_AP_CH_SWITCH_COMPLETE:
+		if (!data)
+			break;
+		hostapd_event_ap_ch_switch(hapd, data->ch_switch.freq);
+		break;
+	case EVENT_RADAR_DETECTED:
+		if (!data)
+			break;
+		hostapd_event_radar_detected(hapd, &data->radar_detected);
+		break;
 	default:
 		wpa_printf(MSG_DEBUG, "Unknown event %d", event);
 		break;
diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index 047a5aa..5b031a8 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -3111,7 +3111,17 @@ enum wpa_event_type {
 	 *
 	 * This event can be used to request a WNM operation to be performed.
 	 */
-	EVENT_WNM
+	EVENT_WNM,
+
+	/**
+	 * EVENT_AP_CH_SWITCH_COMPLETE - notify of channel switch complete
+	 */
+	EVENT_AP_CH_SWITCH_COMPLETE,
+
+	/**
+	 * EVENT_RADAR_DETECTED - notify of radar detection
+	 */
+	EVENT_RADAR_DETECTED
 };
 
 
@@ -3736,6 +3746,14 @@ union wpa_event_data {
 		int ht_enabled;
 		int ch_offset;
 	} ch_switch;
+
+	/**
+	 * struct radar_detected
+	 * @freq: Frequency of new channel in MHz
+	 */
+	struct radar_detected {
+		int freq;
+	} radar_detected;
 };
 
 /**
diff --git a/src/drivers/driver_common.c b/src/drivers/driver_common.c
index 418cf1a..2232ade 100644
--- a/src/drivers/driver_common.c
+++ b/src/drivers/driver_common.c
@@ -79,6 +79,8 @@ const char * event_to_string(enum wpa_event_type event)
 	E2S(EAPOL_TX_STATUS);
 	E2S(CH_SWITCH);
 	E2S(WNM);
+	E2S(AP_CH_SWITCH_COMPLETE);
+	E2S(RADAR_DETECTED);
 	}
 
 	return "UNKNOWN";
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux