Q: wpa_supplicant/scan.c: num_ssids+

Holger Schurig hs4233 at mail.mn-solutions.de
Wed Sep 9 09:35:46 EDT 2009


Hi !

I have a bit of trouble understanding source code parts in scan.c.


Suppose I have only one network section in wpa_supplicant.conf,
e.g. something like this:

   network={
       ssid="TEST"
       key_mgmt=NONE
       wep_key0="9999"
       scan_ssid=1
       scan_freq=2412 2437 2462
    }

And now wpa_supplicants scans. Then the following code block
get's executed:

   ssid = wpa_s->conf->ssid;
   ...
   while (ssid) {
           if (!ssid->disabled && ssid->scan_ssid) {
                   wpa_hexdump_ascii(MSG_DEBUG, "Scan SSID",
                                     ssid->ssid, ssid->ssid_len);
                   params.ssids[params.num_ssids].ssid = ssid->ssid;
                   params.ssids[params.num_ssids].ssid_len = ssid->ssid_len;
                   params.num_ssids++;
                   if (params.num_ssids + 1 >= max_ssids)
                           break;
            }
            ssid = ssid->next;
            ...
   }

That means: "ssid" is set to the first SSID in the configuration.
Then the while loop runs until ssid->next is NULL. So at the end
of this while loop "ssid" is NULL. And params.num_ssids is 1.
Fine with me.


Now, some lines below we have this code block:

   if (ssid) {
           wpa_s->prev_scan_ssid = ssid;
           if (max_ssids > 1) {
                   wpa_printf(MSG_DEBUG, "Include wildcard SSID in the "
                              "scan request");
                   params.num_ssids++;
           }
           wpa_printf(MSG_DEBUG, "Starting AP scan for specific SSID(s)");
   } else {
           wpa_s->prev_scan_ssid = WILDCARD_SSID_SCAN;
           params.num_ssids++;
           wpa_printf(MSG_DEBUG, "Starting AP scan for wildcard SSID");
   }

And here are my understanding problems:

1. Is the debug text simply misleading?  In my case, ssid is NULL, so
   the else-part is taken. Here it babbles something about a wildcard
   SSID scan, which is wrong.

2. Why is params.num_ssids++ in both cases incremented?  In the else-
   case, it seems to be simply wrong.

3. Why force a wild-card SSID scan at all?

4. Currently, driver_wext.c says "max_ssids = 1", so isn't forcing
   a wild-card SSID scan via manipulating params.num_ssids bogus
   in the first place?

-- 
http://www.holgerschurig.de


More information about the HostAP mailing list