Search Linux Wireless

[PATCH 3/7] hostapd: add dfs events

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

 



Add EVENT_RADAR_DETECTED and EVENT_CHANNEL_SWITCH_COMPLETE
events.

EVENT_RADAR_DETECTED indicates that radar was detected on
operational channel. EVENT_CHANNEL_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      |   47 +++++++++++++++++++++++++++++++++++++++++++
 src/drivers/driver.h        |   22 +++++++++++++++++++-
 src/drivers/driver_common.c |    2 +
 3 files changed, 70 insertions(+), 1 deletions(-)

diff --git a/src/ap/drv_callbacks.c b/src/ap/drv_callbacks.c
index 4c0d0ab..603820f 100644
--- a/src/ap/drv_callbacks.c
+++ b/src/ap/drv_callbacks.c
@@ -469,6 +469,37 @@ 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_complete_channel_switch(struct hostapd_data *hapd,
+		struct channel_switch_complete *channel_switch)
+{
+	if (hapd->next_channel->freq != channel_switch->freq) {
+		wpa_printf(MSG_WARNING, "Switched to wrong freq, next_freq(%d) "
+			   "!= ch_switch_freq(%d)", hapd->next_channel->freq,
+			   channel_switch->freq);
+	}
+
+	if (channel_switch->status)
+		ieee802_11_complete_channel_switch(hapd);
+}
 
 void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
 			  union wpa_event_data *data)
@@ -492,6 +523,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);
@@ -582,6 +620,15 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
 			break;
 		hostapd_event_sta_low_ack(hapd, data->low_ack.addr);
 		break;
+	case EVENT_RADAR_DETECTED:
+		if (data)
+			hostapd_event_radar_detected(hapd, &data->radar_detected);
+		break;
+	case EVENT_CHANNEL_SWITCH_COMPLETE:
+		if (data)
+			hostapd_event_complete_channel_switch(hapd,
+				&data->channel_switch_complete);
+		break;
 #ifdef NEED_AP_MLME
 	case EVENT_RX_ACTION:
 		if (data->rx_action.da == NULL || data->rx_action.sa == NULL ||
diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index 780fac8..44f6af0 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -3042,7 +3042,17 @@ enum wpa_event_type {
 	/**
 	 * EVENT_EAPOL_TX_STATUS - notify of EAPOL TX status
 	 */
-	EVENT_EAPOL_TX_STATUS
+	EVENT_EAPOL_TX_STATUS,
+
+	/**
+	 * EVENT_RADAR_DETECTED - notify of radar detection
+	 */
+	EVENT_RADAR_DETECTED,
+
+	/**
+	 * EVENT_CHANNEL_SWITCH_COMPLETE - notify of channel switch complete
+	 */
+	EVENT_CHANNEL_SWITCH_COMPLETE
 };
 
 
@@ -3637,6 +3647,16 @@ union wpa_event_data {
 		int data_len;
 		int ack;
 	} eapol_tx_status;
+
+	struct radar_detected {
+		int status;
+		int freq;
+	} radar_detected;
+
+	struct channel_switch_complete {
+		int status;
+		int freq;
+	} channel_switch_complete;
 };
 
 /**
diff --git a/src/drivers/driver_common.c b/src/drivers/driver_common.c
index 345e851..321b057 100644
--- a/src/drivers/driver_common.c
+++ b/src/drivers/driver_common.c
@@ -77,6 +77,8 @@ const char * event_to_string(enum wpa_event_type event)
 	E2S(SCHED_SCAN_STOPPED);
 	E2S(DRIVER_CLIENT_POLL_OK);
 	E2S(EAPOL_TX_STATUS);
+	E2S(RADAR_DETECTED);
+	E2S(CHANNEL_SWITCH_COMPLETE);
 	}
 
 	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