[PATCH] wpa_supplicant: handle enabling of one or all networks equ=

David Spinadel david.spinadel
Thu Oct 11 07:38:05 PDT 2012


ally

Moving enabling a network to a separate function.
Try to reconnect if there is no configured network.
Disable scheduled scan in any case of new scan.

Change-Id: I09fa93e7f2ae9a8451e74f83d452434d9fa96c00
Signed-off-by: David Spinadel <david.spinadel at intel.com>
---
 wpa_supplicant/wpa_supplicant.c |   63 +++++++++++++++++------------------=
---
 1 files changed, 28 insertions(+), 35 deletions(-)

diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplican=
t.c
index 1e6a93f..8bd3a0f 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -1791,6 +1791,22 @@ void wpa_supplicant_deauthenticate(struct wpa_suppli=
cant *wpa_s,
        wpa_supplicant_clear_connection(wpa_s, addr);
 }

+static void wpa_supplicant_enable_one_network(struct wpa_supplicant *wpa_s,
+                                            struct wpa_ssid *ssid)
+{
+       if (!ssid || !ssid->disabled || ssid->disabled =3D=3D 2)
+               return;
+
+       ssid->disabled =3D 0;
+       wpas_notify_network_enabled_changed(wpa_s, ssid);
+
+       /*
+        *Try to reassociate since there is no current configuration and a =
new
+        * network was made available, or the current network was just enab=
led.
+        */
+       if (!wpa_s->current_ssid)
+               wpa_s->reassociate =3D 1;
+}

 /**
  * wpa_supplicant_enable_network - Mark a configured network as enabled
@@ -1803,47 +1819,24 @@ void wpa_supplicant_enable_network(struct wpa_suppl=
icant *wpa_s,
                                   struct wpa_ssid *ssid)
 {
        struct wpa_ssid *other_ssid;
-       int was_disabled;

-       if (ssid =3D=3D NULL) {
+       if (ssid =3D=3D NULL)
                for (other_ssid =3D wpa_s->conf->ssid; other_ssid;
-                    other_ssid =3D other_ssid->next) {
-                       if (other_ssid->disabled =3D=3D 2)
-                               continue; /* do not change persistent P2P g=
roup
-                                          * data */
-                       if (other_ssid =3D=3D wpa_s->current_ssid &&
-                           other_ssid->disabled)
-                               wpa_s->reassociate =3D 1;
-
-                       was_disabled =3D other_ssid->disabled;
-
-                       other_ssid->disabled =3D 0;
-                       if (was_disabled)
-                               wpas_clear_temp_disabled(wpa_s, other_ssid,=
 0);
+                    other_ssid =3D other_ssid->next)
+                       wpa_supplicant_enable_one_network(wpa_s, other_ssid=
);
+       else
+               wpa_supplicant_enable_one_network(wpa_s, ssid);

-                       if (was_disabled !=3D other_ssid->disabled)
-                               wpas_notify_network_enabled_changed(
-                                       wpa_s, other_ssid);
+       if (wpa_s->reassociate) {
+               if (wpa_s->sched_scanning) {
+                       wpa_printf(MSG_DEBUG,
+                                  "Stop ongoing sched_scan to add new netw=
ork to scan filters");
+                       wpa_supplicant_cancel_sched_scan(wpa_s);
                }
-               if (wpa_s->reassociate)
-                       wpa_supplicant_req_scan(wpa_s, 0, 0);
-       } else if (ssid->disabled && ssid->disabled !=3D 2) {
-               if (wpa_s->current_ssid =3D=3D NULL) {
-                       /*
-                        * Try to reassociate since there is no current
-                        * configuration and a new network was made availab=
le.
-                        */
-                       wpa_s->reassociate =3D 1;
-                       wpa_supplicant_req_scan(wpa_s, 0, 0);
-               }
-
-               was_disabled =3D ssid->disabled;

-               ssid->disabled =3D 0;
                wpas_clear_temp_disabled(wpa_s, ssid, 1);

-               if (was_disabled !=3D ssid->disabled)
-                       wpas_notify_network_enabled_changed(wpa_s, ssid);
+               wpa_supplicant_req_scan(wpa_s, 0, 0);
        }
 }

--
1.7.1

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

--_000_F781B6216F70FE49AB7B89F25E2F80C0BB5329HASMSX105gercorpi_
Content-Type: text/html; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii">
<meta name=3D"Generator" content=3D"Microsoft Exchange Server">
<!-- converted from rtf -->
<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left:=
 #800000 2px solid; } --></style>
</head>
<body>
<font face=3D"Calibri" size=3D"2"><span style=3D"font-size:11pt;">
<div>From b1fe43755f32d4b798b7f90b458c0a0010b521b8 Mon Sep 17 00:00:00 2001=
</div>
<div>From: David Spinadel <david.spinadel at intel.com></div>
<div>Date: Thu, 11 Oct 2012 16:38:05 +0200</div>
<div>Subject: [PATCH] wpa_supplicant: handle enabling of one or all network=
s equally</div>
<div> </div>
<div>Moving enabling a network to a separate function.</div>
<div>Try to reconnect if there is no configured network.</div>
<div>Disable scheduled scan in any case of new scan.</div>
<div> </div>
<div>Change-Id: I09fa93e7f2ae9a8451e74f83d452434d9fa96c00</div>
<div>Signed-off-by: David Spinadel <david.spinadel at intel.com></div>
<div>---</div>
<div> wpa_supplicant/wpa_supplicant.c |   63 ++++=
+++++++++++++----------=
-----------</div>
<div> 1 files changed, 28 insertions(+), 35 deletions(-)</div>
<div> </div>
<div>diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supp=
licant.c</div>
<div>index 1e6a93f..8bd3a0f 100644</div>
<div>--- a/wpa_supplicant/wpa_supplicant.c</div>
<div>+++ b/wpa_supplicant/wpa_supplicant.c</div>
<div>@@ -1791,6 +1791,22 @@ void wpa_supplicant_deauthenticate(struct w=
pa_supplicant *wpa_s,</div>
<div>         wpa_supplicant_clear_=
connection(wpa_s, addr);</div>
<div> }</div>
<div> </div>
<div>+static void wpa_supplicant_enable_one_network(struct wpa_supplica=
nt *wpa_s,</div>
<div>+          &nbsp=
;            &n=
bsp;           &nbsp=
;        struct wpa_ssid *ssid)</div>
<div>+{</div>
<div>+       if (!ssid || !ssid->disab=
led || ssid->disabled =3D=3D 2)</div>
<div>+          &nbsp=
;    return;</div>
<div>+</div>
<div>+       ssid->disabled =3D 0;</di=
v>
<div>+       wpas_notify_network_enabled_=
changed(wpa_s, ssid);</div>
<div>+</div>
<div>+       /*</div>
<div>+        *Try to reassociate si=
nce there is no current configuration and a new</div>
<div>+        * network was made ava=
ilable, or the current network was just enabled.</div>
<div>+        */</div>
<div>+       if (!wpa_s->current_ssid)=
</div>
<div>+          &nbsp=
;    wpa_s->reassociate =3D 1;</div>
<div>+}</div>
<div> </div>
<div> /**</div>
<div>  * wpa_supplicant_enable_network - Mark a configured network as =
enabled</div>
<div>@@ -1803,47 +1819,24 @@ void wpa_supplicant_enable_network(struct =
wpa_supplicant *wpa_s,</div>
<div>           &nbs=
p;            &=
nbsp;           struct wp=
a_ssid *ssid)</div>
<div> {</div>
<div>         struct wpa_ssid *othe=
r_ssid;</div>
<div>-       int was_disabled;</div>
<div> </div>
<div>-       if (ssid =3D=3D NULL) {</div>
<div>+       if (ssid =3D=3D NULL)</div>
<div>           &nbs=
p;     for (other_ssid =3D wpa_s->conf->ssid; oth=
er_ssid;</div>
<div>-           &nb=
sp;        other_ssid =3D other_ssid-&gt=
;next) {</div>
<div>-           &nb=
sp;           if (other_s=
sid->disabled =3D=3D 2)</div>
<div>-           &nb=
sp;            =
       continue; /* do not change persistent =
P2P group</div>
<div>-           &nb=
sp;            =
            &nb=
sp;     * data */</div>
<div>-           &nb=
sp;           if (other_s=
sid =3D=3D wpa_s->current_ssid &&</div>
<div>-           &nb=
sp;            =
   other_ssid->disabled)</div>
<div>-           &nb=
sp;            =
       wpa_s->reassociate =3D 1;</div>
<div>-</div>
<div>-           &nb=
sp;           was_disable=
d =3D other_ssid->disabled;</div>
<div>-</div>
<div>-           &nb=
sp;           other_ssid-=
>disabled =3D 0;</div>
<div>-           &nb=
sp;           if (was_dis=
abled)</div>
<div>-           &nb=
sp;            =
       wpas_clear_temp_disabled(wpa_s, other_=
ssid, 0);</div>
<div>+          &nbsp=
;         other_ssid =3D other_ssid=
->next)</div>
<div>+          &nbsp=
;            wpa_sup=
plicant_enable_one_network(wpa_s, other_ssid);</div>
<div>+       else</div>
<div>+          &nbsp=
;    wpa_supplicant_enable_one_network(wpa_s, ssid);</div>
<div> </div>
<div>-           &nb=
sp;           if (was_dis=
abled !=3D other_ssid->disabled)</div>
<div>-           &nb=
sp;            =
       wpas_notify_network_enabled_changed(</=
div>
<div>-           &nb=
sp;            =
            &nb=
sp;  wpa_s, other_ssid);</div>
<div>+       if (wpa_s->reassociate) {=
</div>
<div>+          &nbsp=
;    if (wpa_s->sched_scanning) {</div>
<div>+          &nbsp=
;            wpa_pri=
ntf(MSG_DEBUG,</div>
<div>+          &nbsp=
;            &n=
bsp;          "Stop ongoi=
ng sched_scan to add new network to scan filters");</div>
<div>+          &nbsp=
;            wpa_sup=
plicant_cancel_sched_scan(wpa_s);</div>
<div>           &nbs=
p;     }</div>
<div>-           &nb=
sp;   if (wpa_s->reassociate)</div>
<div>-           &nb=
sp;           wpa_supplic=
ant_req_scan(wpa_s, 0, 0);</div>
<div>-       } else if (ssid->disabled &am=
p;& ssid->disabled !=3D 2) {</div>
<div>-           &nb=
sp;   if (wpa_s->current_ssid =3D=3D NULL) {</div>
<div>-           &nb=
sp;           /*</div>
<div>-           &nb=
sp;            * Try=
 to reassociate since there is no current</div>
<div>-           &nb=
sp;            * con=
figuration and a new network was made available.</div>
<div>-           &nb=
sp;            */</d=
iv>
<div>-           &nb=
sp;           wpa_s->r=
eassociate =3D 1;</div>
<div>-           &nb=
sp;           wpa_supplic=
ant_req_scan(wpa_s, 0, 0);</div>
<div>-           &nb=
sp;   }</div>
<div>-</div>
<div>-           &nb=
sp;   was_disabled =3D ssid->disabled;</div>
<div> </div>
<div>-           &nb=
sp;   ssid->disabled =3D 0;</div>
<div>           &nbs=
p;     wpas_clear_temp_disabled(wpa_s, ssid, 1);</div>
<div> </div>
<div>-           &nb=
sp;   if (was_disabled !=3D ssid->disabled)</div>
<div>-           &nb=
sp;           wpas_notify=
_network_enabled_changed(wpa_s, ssid);</div>
<div>+          &nbsp=
;    wpa_supplicant_req_scan(wpa_s, 0, 0);</div>
<div>         }</div>
<div> }</div>
<div> </div>
<div>-- </div>
<div>1.7.1</div>
<div> </div>
</span></font>
<p>---------------------------------------------------------------------<br>
Intel Israel (74) Limited</p>

<p>This e-mail and any attachments may contain confidential material for<br>
the sole use of the intended recipient(s). Any review or distribution<br>
by others is strictly prohibited. If you are not the intended<br>
recipient, please contact the sender and delete all copies.</p></body>
</html>

--_000_F781B6216F70FE49AB7B89F25E2F80C0BB5329HASMSX105gercorpi_--




More information about the Hostap mailing list