Patch for wpa_supplicant multiple networks when ap_scan = 2

Brian Hill brian
Thu May 19 03:11:31 PDT 2005


Hi,

I'm' not sure if this will be useful to anyone besides myself, but I'm
using the ipw2200 adapter, and have had trouble getting a single
wpa_supplicant configuration file that would get me connected with no
manual intervention to my home WLAN (using simple, static WEP) and my
work WLAN (using IEEE 8021X key management and EAP-PEAP-GTC
authentication).

I made a very crude patch to wpa_supplicant.c that will let the
supplicant scan through multiple networks in priority order, even when
ap_scan = 2.  It's not well done, it's what I could do in just a few
minutes to make it work for me.  I'd certainly appreciate any feedback
if someone finds this useful / badly broken / stupid / funny.

--- wpa_supplicant-0.4.0/wpa_supplicant.c       2005-04-25
22:29:31.000000000 -0400
+++ wpa_supplicant-0.4.0-brian/wpa_supplicant.c 2005-05-18
22:13:07.000000000 -0400
@@ -122,6 +122,8 @@
 extern int wpa_debug_show_keys;
 extern int wpa_debug_timestamp;

+static int last_prio_scan = -1;
+

 void wpa_msg(struct wpa_supplicant *wpa_s, int level, char *fmt, ...)
 {
@@ -1138,6 +1140,7 @@
 {
       struct wpa_supplicant *wpa_s = eloop_ctx;
       struct wpa_ssid *ssid;
+       int prio;

       if (wpa_s->conf->ap_scan == 0) {
               wpa_supplicant_gen_assoc_event(wpa_s);
@@ -1145,7 +1148,13 @@
       }

       if (wpa_s->conf->ap_scan == 2) {
-               ssid = wpa_s->conf->ssid;
+               if(last_prio_scan == wpa_s->conf->num_prio) {
+                       last_prio_scan = -1;
+               }
+               prio = last_prio_scan + 1;
+               last_prio_scan++;
+               ssid = wpa_s->conf->pssid[prio];
+               wpa_printf(MSG_INFO, "Now scanning ssid (%d) %s",
last_prio_scan, ssid->ssid);
               if (ssid == NULL)
                       return;
               wpa_supplicant_associate(wpa_s, NULL, ssid);


--
Brian Hill
brian at the-hills.org




More information about the Hostap mailing list