[RFC v2 3/4] nl80211: Add suport for chan_time scan parameter

Michal Kazior michal.kazior
Mon Jul 29 02:19:13 PDT 2013


This can be useful for future Automatic Channel
Selection.

Signed-off-by: Michal Kazior <michal.kazior at tieto.com>
---
 src/drivers/driver.h         |    7 +++++++
 src/drivers/driver_nl80211.c |   17 ++++++++++++++++-
 src/drivers/nl80211_copy.h   |    2 ++
 3 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index 661f427..34da469 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -318,6 +318,13 @@ struct wpa_driver_scan_params {
 	 * and not to transmit the frames at any of those rates.
 	 */
 	u8 p2p_probe;
+
+	/**
+	 * chan_time - How many msecs driver should stay on each channel
+	 *
+	 * This is intended for either long passive scans or ACS.
+	 */
+	u32 chan_time;
 };
 
 /**
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 034fe26..d56629e 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -4256,6 +4256,10 @@ nl80211_scan_common(struct wpa_driver_nl80211_data *drv, u8 cmd,
 		nla_nest_end(msg, freqs);
 	}
 
+	if (params->chan_time)
+		nla_put_u32(msg, NL80211_ATTR_SCAN_CHAN_TIME,
+			    params->chan_time);
+
 	os_free(drv->filter_ssids);
 	drv->filter_ssids = params->filter_ssids;
 	params->filter_ssids = NULL;
@@ -4280,7 +4284,7 @@ static int wpa_driver_nl80211_scan(struct i802_bss *bss,
 				   struct wpa_driver_scan_params *params)
 {
 	struct wpa_driver_nl80211_data *drv = bss->drv;
-	int ret = -1, timeout;
+	int ret = -1, timeout, n_freqs = 0, *freq;
 	struct nl_msg *msg = NULL;
 
 	wpa_dbg(drv->ctx, MSG_DEBUG, "nl80211: scan request");
@@ -4354,6 +4358,17 @@ static int wpa_driver_nl80211_scan(struct i802_bss *bss,
 		 */
 		timeout = 30;
 	}
+
+	if (params->chan_time && params->freqs) {
+		for (freq = params->freqs; *freq; freq++)
+			n_freqs++;
+
+		/* Give it twice the time each frequency is visited for
+		 * to provide enough grace period for channel
+		 * switching, etc. Also round up. */
+		timeout = ((params->chan_time * n_freqs) * 2 + 1) / 1000;
+	}
+
 	wpa_printf(MSG_DEBUG, "Scan requested (ret=%d) - scan timeout %d "
 		   "seconds", ret, timeout);
 	eloop_cancel_timeout(wpa_driver_nl80211_scan_timeout, drv, drv->ctx);
diff --git a/src/drivers/nl80211_copy.h b/src/drivers/nl80211_copy.h
index 32b060e..10e28e9 100644
--- a/src/drivers/nl80211_copy.h
+++ b/src/drivers/nl80211_copy.h
@@ -1736,6 +1736,8 @@ enum nl80211_attrs {
 
 	NL80211_ATTR_PEER_AID,
 
+	NL80211_ATTR_SCAN_CHAN_TIME,
+
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,
-- 
1.7.9.5




More information about the Hostap mailing list