Re: Passive Scanning not supported?

Thomas King <[email protected]>
Newsgroups gmane.linux.drivers.ipw2100.devel
Message-ID <[email protected]>
On Wednesday 26 July 2006 07:43, Zhu Yi wrote:
>
> ipw_request_scan() performs the scan request to the firmware. Currently
> if STA is not in monitor mode or roaming, it will do an active broadcast
> scan. While from your description, if IW_SCAN_TYPE_PASSIVE is given, we
> should actually do a passive scan (IPW_SCAN_PASSIVE_FULL_DWELL_SCAN).
>
> Would you like to provide a patch to fix that? And try to see if the
> probe request frames are not actually sent out by the card.
So, here is my patch that enables the ipw2200 driver to support
passive scanning as offered by the wireless extensions. For this, I
enhanced the ipw_wx_set_scan function in such a way that it
differentiates between a passive and an active scan
request. Additionally, I added a new function called
ipw_request_passive_scan that is similiar to the ipw_request_scan
function to perform passive scans. Last but not least, I added a field
(in fact it is a work_struct struct) called request_passive_scan to
the ipw_priv struct. Of course, I release this patch under the terms of
the GPL and the Copyright by Thomas King <[email protected]>
(that is me :-)).

Some notes:
- The ipw_request_scan and ipw_request_passive_scan contain a few
  identical lines of code. I think this should be fixed soon because
  we all know that redundant code is a bad thing.
- I set the IPW_SCAN_PASSIVE_FULL_DWELL_SCAN value inside the
  ipw_request_scan function to 320 because I collected more access points
  with such a high value as with a value of 120. However, I not sure about
  the side effects of such an high value.


What do you think about this patch?

Greetings,
Thomas

>
> Thanks,
> -yi

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
ipw2100-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ipw2100-devel
passive_scanning.patch (text/x-diff, 3.8 KB)
--- ipw2200.c.old	2006-07-27 13:54:19.000000000 +0200
+++ ipw2200.c	2006-07-27 14:00:38.000000000 +0200
@@ -6277,11 +6277,78 @@
 	}
 }
 
+static int ipw_request_passive_scan(struct ipw_priv *priv) {
+	struct ipw_scan_request_ext scan;
+	int err = 0, scan_type;
+
+	IPW_DEBUG_WX("use passive scanning\n");
+	
+	if (!(priv->status & STATUS_INIT) ||
+	    (priv->status & STATUS_EXIT_PENDING))
+		return 0;
+
+	mutex_lock(&priv->mutex);
+
+	if (priv->status & STATUS_SCANNING) {
+		IPW_DEBUG_HC("Concurrent scan requested.  Ignoring.\n");
+		priv->status |= STATUS_SCAN_PENDING;
+		goto done;
+	}
+
+	if (!(priv->status & STATUS_SCAN_FORCED) &&
+	    priv->status & STATUS_SCAN_ABORTING) {
+		IPW_DEBUG_HC("Scan request while abort pending.  Queuing.\n");
+		priv->status |= STATUS_SCAN_PENDING;
+		goto done;
+	}
+
+	if (priv->status & STATUS_RF_KILL_MASK) {
+		IPW_DEBUG_HC("Aborting scan due to RF Kill activation\n");
+		priv->status |= STATUS_SCAN_PENDING;
+		goto done;
+	}
+
+	memset(&scan, 0, sizeof(scan));
+
+	if (priv->config & CFG_SPEED_SCAN)
+		scan.dwell_time[IPW_SCAN_ACTIVE_BROADCAST_SCAN] =
+		    cpu_to_le16(30);
+	else
+		scan.dwell_time[IPW_SCAN_ACTIVE_BROADCAST_SCAN] =
+		    cpu_to_le16(20);
+
+	scan.dwell_time[IPW_SCAN_ACTIVE_BROADCAST_AND_DIRECT_SCAN] =
+	    cpu_to_le16(20);
+	scan.dwell_time[IPW_SCAN_PASSIVE_FULL_DWELL_SCAN] = cpu_to_le16(320);
+
+	scan.full_scan_index = cpu_to_le32(ieee80211_get_scans(priv->ieee));
+
+	scan_type = IPW_SCAN_PASSIVE_FULL_DWELL_SCAN;
+	
+	ipw_add_scan_channels(priv, &scan, scan_type);
+	
+	err = ipw_send_scan_request_ext(priv, &scan);
+	if (err) {
+	  	IPW_DEBUG_HC("Sending scan command failed: %08X\n", err);
+	  	goto done;
+	}
+
+	priv->status |= STATUS_SCANNING;
+	priv->status &= ~STATUS_SCAN_PENDING;
+	queue_delayed_work(priv->workqueue, &priv->scan_check,
+			   IPW_SCAN_CHECK_WATCHDOG);
+      done:
+	mutex_unlock(&priv->mutex);
+	return err;
+}
+
 static int ipw_request_scan(struct ipw_priv *priv)
 {
 	struct ipw_scan_request_ext scan;
 	int err = 0, scan_type;
 
+	IPW_DEBUG_WX("use active scanning\n");
+	
 	if (!(priv->status & STATUS_INIT) ||
 	    (priv->status & STATUS_EXIT_PENDING))
 		return 0;
@@ -9991,8 +10058,9 @@
 			   union iwreq_data *wrqu, char *extra)
 {
 	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct iw_scan_req* req = NULL;
 #if WIRELESS_EXT > 17
-	struct iw_scan_req *req = NULL;
+	//struct iw_scan_req *req = NULL;
 	if (wrqu->data.length
 	    && wrqu->data.length == sizeof(struct iw_scan_req)) {
 		req = (struct iw_scan_req *)extra;
@@ -10004,9 +10072,16 @@
 	}
 #endif
 	IPW_DEBUG_WX("Start scan\n");
-
-	queue_work(priv->workqueue, &priv->request_scan);
-
+	if (wrqu->data.length == sizeof(struct iw_scan_req)) {
+	  	req = (struct iw_scan_req*) extra;
+	  	if (req->scan_type == IW_SCAN_TYPE_PASSIVE) {
+		  	queue_work(priv->workqueue, &priv->request_passive_scan);
+	  	} else { /* it must be IW_SCAN_TYPE_ACTIVE */
+	    		queue_work(priv->workqueue, &priv->request_scan);
+	  	}
+	} else {  /* no scan type is set -> default scan type */
+	  	queue_work(priv->workqueue, &priv->request_scan);
+	}
 	return 0;
 }
 
@@ -11241,6 +11316,8 @@
 	INIT_WORK(&priv->down, (void (*)(void *))ipw_bg_down, priv);
 	INIT_WORK(&priv->request_scan,
 		  (void (*)(void *))ipw_request_scan, priv);
+	INIT_WORK(&priv->request_passive_scan,
+		  (void (*)(void *))ipw_request_passive_scan, priv);
 	INIT_WORK(&priv->gather_stats,
 		  (void (*)(void *))ipw_bg_gather_stats, priv);
 	INIT_WORK(&priv->abort_scan, (void (*)(void *))ipw_bg_abort_scan, priv);
--- ipw2200.h.old	2006-07-27 13:54:35.000000000 +0200
+++ ipw2200.h	2006-07-27 13:22:28.000000000 +0200
@@ -1316,6 +1316,7 @@
 	struct work_struct system_config;
 	struct work_struct rx_replenish;
 	struct work_struct request_scan;
+  	struct work_struct request_passive_scan;
 	struct work_struct adapter_restart;
 	struct work_struct rf_kill;
 	struct work_struct up;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.