bgscan_learn: scan all freq only if there are no candidates (INTERNAL)

change to patch 19958a54733009e7ef07dc10d98c8b04fa94b882

The original fix to bgscan_learn performs a scan on
all frequencies if bss candidates were not seen on other
channels.
This patch changes it so that if a candidate bss was
seen on the channel of the current AP do not scan
all frequencies.

Signed-off-by: Yoni Divinsky <yoni.divinsky@ti.com>
ctrl_iface: check for ongoing sched_scan on SCAN command

The first "if" in the SCAN command handling didn't
check properly for sched_scan, causing the sched_scan
and scan to run concurrently, instead of cancelling
the ongoing sched scan (which is handled by the
"else if" later).

Signed-off-by: Eliad Peller <eliad@wizery.com>
Android.mk: Define ANDROID_P2P

Changes within #ifdef ANDROID_P2P are BRCM additions
which are non BRCM specific and there should be included.
That's in contrast of ANDROID_BRCM_P2P_PATCH which mark
parts that are BRCM implementation specific (like device_ap_sme)
and therefore would be compiled in only when compiling with BRCM
driver.

Change-Id: I031f0908055756b6e85b64c5151c18b8a73b9841
Signed-off-by: Eyal Shapira <eyal@wizery.com>
Fix p2p service discovery

- Fix listen timing to improve SD reliability
- Fix SD packet scheduling

Signed-off-by: Eyal Shapira <eyal@wizery.com>
Fix a crash in WPS PBC overlap (BRCM)

Supposedly fixed a crash which occurs during actual PBC overlap
according to BRCM commit log.

(Not quite sure what's the exact cause of the crash here. However
this looks like a non BRCM specific change so take it).
p2p_dev_addr can be NULL in some of the calls. Might cause a problem ?)

Signed-off-by: Eyal Shapira <eyal@wizery.com>
Increase P2P_MAX_CLIENT_IDLE to 20 secs (BRCM)

This is from Jithu Jance submission to hostap ML:

Consider the disconnect event generated due to EAP-FAILURE(after WPS handshake)
during the P2P connection.

In this disconnect context, the group idle timer will be set to 10 and assoc retry starts.
If the connection doesn't go through in the first attempt the group will be removed.
This is because the authentication timeout happens at 10secs and the assoc will be retried only after that.

Signed-off-by: Eyal Shapira <eyal@wizery.com>
WPS: Update dev.config_methods in wps_update_config

dev.config_methods was not updated when wps_update_config was called.
This could lead to mismatching config methods between Probe Request and
M1 packets. Add missing part for it.
SME: Fix handle Netgear APs WEP shared quirks (UPSTREAM-SQ)

If the network entry is created with both WPA_AUTH_ALG_OPEN and
WPA_AUTH_ALG_SHARED set in wpa_s->current_ssid->auth_alg, the
existing logic will end up picking WPA_AUTH_ALG_LEAP instead of
shared when open authentication fails.

Fix this by using a bitwise-and to check for WPA_AUTH_ALG_OPEN instead.

(Should be squashed into commit
2e35a02 SME: Handle Netgear APs WEP shared quirks)

Signed-Off-By: William List <wlist@ti.com>
Signed-Off-By: Eyal Shapira <eyal@wizery.com>
P2P: Increase GO Negotiation timeouts

p2p_set_timeout() calls in GO Neg Req/Resp TX callbacks used timeout of
100 ms which is the value given in the P2P specification for GO
Negotiation, but this was actually shorter than the
wait-for-offchannel-TX value (200 ms) used for the driver call. In
addition, it looks like some devices (e.g., Galaxy Nexus with JB image)
can take longer time to reply to GO Negotiation Response (somewhere
between 200 and 250 ms has been observed).

Increase the wait-for-GO-Neg-Resp timeout from 100 ms to 200 ms if GO
Negotiation Request frame was acknowledged (this matches with the
offchannel wait timeout that used previously). The no-ack case is left
at 100 ms since we use GO Negotiation Request frame also to discover
whether the peer is on its Listen channel.

Increase the wait-for-GO-Neg-Conf timeout from 100 ms to 250 ms (and
increase the offchannel wait timeout to matching 250 ms) as a workaround
for devices that take over 200 ms to reply to GO Negotiation Response.

Signed-hostap: Jouni Malinen <j@w1.fi>
WPS: fix nonce comparisons (UPSTREAM)

Multiple memcmps of nonces were actually comparing
only the first byte instead of all 16 bytes.

Signed-off-by: Eyal Shapira <eyal@wizery.com>
Remove default ACM=1 from AC_VO and AC_VI

There is no need to mandate admission control (ACM=1) by default, so
clear that flag in the case the configuration file does not specify
wmm_ac_{vo,vi}_acm value. This gets closer to the values mentioned
in the sample hostapd.conf file and reduces the need to specify WMM
parameters in the configuration file for most common use cases.

Signed-hostap: Jouni Malinen <j@w1.fi>
P2P: always re-select oper channel if not hard coded

Since the operating channel is randomly set to 1/6/11 on init, which is
always in the channel intersection, we were effectively ignoring the set
of p2p preferred channels.
Fix this by trying to get the best channel we can, unless the user hard
coded the operating channel in the configuration file. Fall back to the
initial randomly selected channel if a better one cannot be chosen.

Signed-hostap: Arik Nemtsov <arik@wizery.com>
Fix a couple memory leaks

Found using valgrind.
wpa_s: don't reschedule the sched scan on each scan complete event

wpa_supplicant doesn't distinguish between NL80211_CMD_SCHED_SCAN_RESULTS
and NL80211_CMD_NEW_SCAN_RESULTS, this causing unnecessary rescheduling
of the sched scan on each scan complete event.

Reschedule the sched scan (stop + start) only if the scan results are from
the sched scan.
Fix wpa_s crash and kickstart sched scan (INTERNAL-SQ)

data may be NULL and should be checked before dereferencing it.
This can happen when scan times out for example.
Another bug fixed is that sched scan wouldn't be kick started
from anywhere. Previously it was started following a normal scan
which didn't find any results. Fix it by start it if it's not running.

(These issues were introduced by commit
a523a28 wpa_s: don't reschedule the sched scan on each scan complete event
and the fix should be squashed into it)
android: wpa_s template: set p2p_go_max_inactivity (ANDROID)

Set p2p_go_max_inactivity to 30 secs (instead of the default
of 300 secs) to avoid creating a user of experience of a
WiFi Direct connection which doesn't disconnect. This may
happen if the P2P GO interface misses a deauth/disassoc frame
and keeps on thinking the client is connected. Limit this
time to 30 secs which creates a better user experience.
ap: add missing WLAN_STA_ASSOC_REQ_OK flag cleanups

cleanup of WLAN_STA_ASSOC_REQ_OK flag is missing in some
places (e.g. when deauth a sta).

(This in turn caused problems when working as GO, as our
internal commit (a3e0a16 "Fix deauth with reason 7 due to
multiple assoc_req received") caused reassociations
(after WPS) to get dropped.
Revert "WPS: Update dev.config_methods in wps_update_config"

This reverts commit f654966fb2b0e48561c34dcef6430cc916859469.