Re: Passive Scanning not supported?

Thomas King <[email protected]>
Newsgroups gmane.linux.drivers.ipw2100.devel
Message-ID <[email protected]>
On Friday 28 July 2006 11:21, Zhu Yi wrote:
> > 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.
>
> Yup. Can you add a new parameter (indicating active or passive scan) to
> ipw_request_scan() so that we can avoid the code duplication?
I fixed this problem (see attachment). I created another patch against 
ipw2200-1.1.3. This patch contains one new function called 
ipw_request_scan_helper that does all the scanning stuff.

>
> > - 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.
>
> OK. We can use 320 and see how it work for most of people.
I set this value to 2000 as used in MONITOR mode. I have overseen this value 
in the first place.

>
> BTW, did you try whether you can still see probe request frames when
> passive scan is requested with your patch?
Of course, I have used another machine in MONITOR mode to figure out what is 
going on. If passive scanning is used no probe response frame is transmitted.

Any comments?

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

-------------------------------------------------------------------------
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_2.patch (text/x-diff, 7.6 KB)
--- ipw2200.c.old	2006-07-28 17:35:32.000000000 +0200
+++ ipw2200.c	2006-07-28 20:24:21.000000000 +0200
@@ -6277,10 +6277,15 @@
 	}
 }
 
-static int ipw_request_scan(struct ipw_priv *priv)
-{
+static int ipw_request_scan_helper(struct ipw_priv *priv,
+				   int active_or_passive) {
 	struct ipw_scan_request_ext scan;
-	int err = 0, scan_type;
+	int err = 0, scan_type = IPW_SCAN_ACTIVE_BROADCAST_SCAN;
+
+	if (active_or_passive == IW_SCAN_TYPE_ACTIVE)
+	  	IPW_DEBUG_WX("use active scanning\n");
+	if (active_or_passive == IW_SCAN_TYPE_PASSIVE)
+	  	IPW_DEBUG_WX("use passive scanning\n");
 
 	if (!(priv->status & STATUS_INIT) ||
 	    (priv->status & STATUS_EXIT_PENDING))
@@ -6309,79 +6314,99 @@
 
 	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(120);
+	if (active_or_passive == IW_SCAN_TYPE_ACTIVE) {
+	  	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(120);
+	}
+	if (active_or_passive == IW_SCAN_TYPE_PASSIVE)
+	  	scan.dwell_time[IPW_SCAN_PASSIVE_FULL_DWELL_SCAN] =
+		  	cpu_to_le16(200);
 
 	scan.full_scan_index = cpu_to_le32(ieee80211_get_scans(priv->ieee));
 
+	if (active_or_passive == IW_SCAN_TYPE_ACTIVE) {
 #ifdef CONFIG_IPW2200_MONITOR
-	if (priv->ieee->iw_mode == IW_MODE_MONITOR) {
-		u8 channel;
-		u8 band = 0;
-
-		switch (ipw_is_valid_channel(priv->ieee, priv->channel)) {
-		case IEEE80211_52GHZ_BAND:
-			band = (u8) (IPW_A_MODE << 6) | 1;
-			channel = priv->channel;
-			break;
+		if (priv->ieee->iw_mode == IW_MODE_MONITOR) {
+			u8 channel;
+			u8 band = 0;
+
+			switch (ipw_is_valid_channel(priv->ieee,
+						     priv->channel)) {
+			case IEEE80211_52GHZ_BAND:
+				band = (u8) (IPW_A_MODE << 6) | 1;
+				channel = priv->channel;
+				break;
 
-		case IEEE80211_24GHZ_BAND:
-			band = (u8) (IPW_B_MODE << 6) | 1;
-			channel = priv->channel;
-			break;
+			case IEEE80211_24GHZ_BAND:
+			  	band = (u8) (IPW_B_MODE << 6) | 1;
+				channel = priv->channel;
+				break;
 
-		default:
-			band = (u8) (IPW_B_MODE << 6) | 1;
-			channel = 9;
-			break;
-		}
+			default:
+				band = (u8) (IPW_B_MODE << 6) | 1;
+				channel = 9;
+				break;
+			}
 
-		scan.channels_list[0] = band;
-		scan.channels_list[1] = channel;
-		ipw_set_scan_type(&scan, 1, IPW_SCAN_PASSIVE_FULL_DWELL_SCAN);
-
-		/* NOTE:  The card will sit on this channel for this time
-		 * period.  Scan aborts are timing sensitive and frequently
-		 * result in firmware restarts.  As such, it is best to
-		 * set a small dwell_time here and just keep re-issuing
-		 * scans.  Otherwise fast channel hopping will not actually
-		 * hop channels.
-		 *
-		 * TODO: Move SPEED SCAN support to all modes and bands */
-		scan.dwell_time[IPW_SCAN_PASSIVE_FULL_DWELL_SCAN] =
-		    cpu_to_le16(2000);
-	} else {
+			scan.channels_list[0] = band;
+			scan.channels_list[1] = channel;
+			ipw_set_scan_type(&scan, 1,
+					  IPW_SCAN_PASSIVE_FULL_DWELL_SCAN);
+
+			/* NOTE: The card will sit on this channel for this
+			 * time period. Scan aborts are timing sensitive and
+			 * frequently result in firmware restarts. As such, it
+			 * is best to set a small dwell_time here and just keep
+			 * re-issuing scans. Otherwise fast channel hopping
+			 * will not actually hop channels.
+			 *
+			 * TODO: Move SPEED SCAN support to all modes and bands
+			 */
+			scan.dwell_time[IPW_SCAN_PASSIVE_FULL_DWELL_SCAN] =
+			  	cpu_to_le16(2000);
+		} else {
 #endif				/* CONFIG_IPW2200_MONITOR */
-		/* If we are roaming, then make this a directed scan for the
-		 * current network.  Otherwise, ensure that every other scan
-		 * is a fast channel hop scan */
-		if ((priv->status & STATUS_ROAMING)
-		    || (!(priv->status & STATUS_ASSOCIATED)
-			&& (priv->config & CFG_STATIC_ESSID)
-			&& (le32_to_cpu(scan.full_scan_index) % 2))) {
-			err = ipw_send_ssid(priv, priv->essid, priv->essid_len);
-			if (err) {
-				IPW_DEBUG_HC("Attempt to send SSID command "
-					     "failed.\n");
-				goto done;
-			}
+			/* If we are roaming, then make this a directed scan
+			 * for the current network.  Otherwise, ensure that
+			 * every other scan is a fast channel hop scan */
+		  	if ((priv->status & STATUS_ROAMING)
+		    	    	|| (!(priv->status & STATUS_ASSOCIATED)
+			    	&& (priv->config & CFG_STATIC_ESSID)
+				&& (le32_to_cpu(scan.full_scan_index) % 2))) {
+				err = ipw_send_ssid(priv, priv->essid,
+						    priv->essid_len);
+				if (err) {
+					IPW_DEBUG_HC("Attempt to send SSID "
+						     "command failed.\n");
+					goto done;
+				}
 
-			scan_type = IPW_SCAN_ACTIVE_BROADCAST_AND_DIRECT_SCAN;
-		} else
-			scan_type = IPW_SCAN_ACTIVE_BROADCAST_SCAN;
+				scan_type =
+				  IPW_SCAN_ACTIVE_BROADCAST_AND_DIRECT_SCAN;
+			} else
+				scan_type = IPW_SCAN_ACTIVE_BROADCAST_SCAN;
 
-		ipw_add_scan_channels(priv, &scan, scan_type);
 #ifdef CONFIG_IPW2200_MONITOR
-	}
+		}
 #endif
+	}
+
+	if (active_or_passive == IW_SCAN_TYPE_PASSIVE)
+	  	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) {
@@ -6398,6 +6423,14 @@
 	return err;
 }
 
+static int ipw_request_passive_scan(struct ipw_priv *priv) {
+  	return ipw_request_scan_helper(priv, IW_SCAN_TYPE_PASSIVE);
+}
+
+static int ipw_request_scan(struct ipw_priv *priv) {
+	return ipw_request_scan_helper(priv, IW_SCAN_TYPE_ACTIVE);
+}
+
 static void ipw_bg_abort_scan(void *data)
 {
 	struct ipw_priv *priv = data;
@@ -9991,8 +10024,8 @@
 			   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;
 	if (wrqu->data.length
 	    && wrqu->data.length == sizeof(struct iw_scan_req)) {
 		req = (struct iw_scan_req *)extra;
@@ -10004,9 +10037,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 +11281,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-28 17:35:41.000000000 +0200
+++ ipw2200.h	2006-07-28 20:15:07.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.