Search Linux Wireless

[RFC 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-off-by: Boris Presman <boris.presman@xxxxxx>
Signed-off-by: Victor Goldenshtein <victorg@xxxxxx>
---
 src/ap/drv_callbacks.c      |   40 ++++++++++++++++++++++++++++++++++++++++
 src/drivers/driver.h        |   22 +++++++++++++++++++++-
 src/drivers/driver_common.c |    2 ++
 3 files changed, 63 insertions(+), 1 deletions(-)

diff --git a/src/ap/drv_callbacks.c b/src/ap/drv_callbacks.c
index b7febdc..d5079c4 100644
--- a/src/ap/drv_callbacks.c
+++ b/src/ap/drv_callbacks.c
@@ -464,6 +464,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)
@@ -576,6 +607,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 1f2e521..68bf2e7 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -2973,7 +2973,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
 };
 
 
@@ -3563,6 +3573,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 26ca8d6..8e0492a 100644
--- a/src/drivers/driver_common.c
+++ b/src/drivers/driver_common.c
@@ -83,6 +83,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 Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux