From 80a505accfd177de92259660b3e619822664263f Mon Sep 17 00:00:00 2001 From: Eyal Shapira Date: Wed, 24 Oct 2012 17:47:30 +0200 Subject: Don't disable and select new network if SETBAND didn't change (ANDROID) Current SETBAND would trigger network selection and as part of this a scan attempt. This is not required in case SETBAND didn't change the existing setting. In Android which sends SETBAND immediately after WiFi startup this would trigger needless scan attempts which would usually fail with -EBUSY as another framework triggers scan was already going on. The retry mechanism would then attempt further scans every 1 sec. Signed-off-by: Eyal Shapira --- wpa_supplicant/ctrl_iface.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 0f5f431..4f0aa33 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -4193,6 +4193,7 @@ static int wpa_supplicant_driver_cmd(struct wpa_supplicant *wpa_s, char *cmd, ret = pno_stop(wpa_s); else if (os_strncasecmp(cmd, "SETBAND ", 8) == 0) { int val = atoi(cmd + 8); + uint setband = 0; /* * Use driver_cmd for drivers that support it, but ignore the * return value since scan requests from wpa_supplicant will @@ -4203,20 +4204,29 @@ static int wpa_supplicant_driver_cmd(struct wpa_supplicant *wpa_s, char *cmd, wpa_drv_driver_cmd(wpa_s, cmd, buf, buflen); ret = 0; if (val == 0) - wpa_s->setband = WPA_SETBAND_AUTO; + setband = WPA_SETBAND_AUTO; else if (val == 1) - wpa_s->setband = WPA_SETBAND_5G; + setband = WPA_SETBAND_5G; else if (val == 2) - wpa_s->setband = WPA_SETBAND_2G; - else + setband = WPA_SETBAND_2G; + else { ret = -1; + goto out; + } + + if (wpa_s->setband == setband) { + wpa_printf(MSG_DEBUG, "Same setband as before"); + goto out; + } + wpa_s->setband = setband; if (wpa_s->current_bss && !wpa_bss_in_current_band(wpa_s, wpa_s->current_bss)) wpa_supplicant_disable_network(wpa_s, wpa_s->current_ssid); wpa_supplicant_select_network(wpa_s, NULL); } else ret = wpa_drv_driver_cmd(wpa_s, cmd, buf, buflen); +out: if (ret == 0) ret = sprintf(buf, "%s\n", "OK"); return ret; -- cgit v1.1