diff mbox

wpa_supplicant: handle enabling of one or all networks equally

Message ID F781B6216F70FE49AB7B89F25E2F80C0BB5329@HASMSX105.ger.corp.intel.com
State Superseded
Headers show

Commit Message

Spinadel, David Oct. 25, 2012, 8:53 a.m. UTC
From b1fe43755f32d4b798b7f90b458c0a0010b521b8 Mon Sep 17 00:00:00 2001
From: David Spinadel <david.spinadel@intel.com>
Date: Thu, 11 Oct 2012 16:38:05 +0200
Subject: [PATCH] wpa_supplicant: handle enabling of one or all networks equally

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@intel.com>
---
 wpa_supplicant/wpa_supplicant.c |   63 +++++++++++++++++---------------------
 1 files changed, 28 insertions(+), 35 deletions(-)

--
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.

Comments

Jouni Malinen Oct. 28, 2012, 6:54 p.m. UTC | #1
On Thu, Oct 25, 2012 at 08:53:00AM +0000, Spinadel, David wrote:
> 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.

This does not seem to apply (whitespace damage). In addition, it is
quite difficult to understand the exact changes in this form. Could you
please split this into two commits with the first one adding the new
shared wpa_supplicant_enable_one_network() function without any changes
to functionality and another commit doing whatever changes there are in
this?
diff mbox

Patch

diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.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_supplicant *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 == 2)
+               return;
+
+       ssid->disabled = 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 enabled.
+        */
+       if (!wpa_s->current_ssid)
+               wpa_s->reassociate = 1;
+}

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

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

-                       if (was_disabled != 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 network 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 != 2) {
-               if (wpa_s->current_ssid == NULL) {
-                       /*
-                        * Try to reassociate since there is no current
-                        * configuration and a new network was made available.
-                        */
-                       wpa_s->reassociate = 1;
-                       wpa_supplicant_req_scan(wpa_s, 0, 0);
-               }
-
-               was_disabled = ssid->disabled;

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

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