P2P: fix freq conflict resolution in case of P2P and STA

The conflict resolution code doesn't run in case wpa_s SME is used
so moved it up wpa_supplicant_associate.
wpas_p2p_handle_frequency_conflicts assumes use of a different interface
created for p2p group (p2p_group_interface != 0) but that's not
necessarily the case with all drivers. Switch to detect if an iface
is used for P2P_GO by looking at current_ssid->mode.

[Arik - fix the separate interface case, was broken by the original
patch]

Signed-off-by: Eyal Shapira <eyal@wizery.com>
Signed-off-by: Arik Nemtsov <arik@wizery.com>
nl80211: fix extending shared_freq detection to AP/GO (BRCM)

Commit d3bd0f "nl80211: Extend shared_freq to handle AP/GO mode interfaces"
still discards AP/GO interfaces so effectively shared_freq
won't work on AP/GO interaces like intended.

Signed-off-by: Eyal Shapira <eyal@wizery.com>
nl80211: add parameter to force multi channel concurrency (BRCM)

Add a parameter which can be set from wpa_s commandline
or conf file to force real multi channel.

Signed-off-by: Eyal Shapira <eyal@wizery.com>
P2P: Decrease peer expiry time (BRCM)

Changed from 5 min to 30 secs probably in order
to avoid stale peers appearing in the Android UI.

Signed-off-by: Eyal Shapira <eyal@wizery.com>
P2P: Defer p2p scan if scanning on other interfaces (BRCM)

The current defer p2p scan until scan complete works
only when the scanning is done on the same interface.
However in Android case there are scans in progress on the STA
interface so these would fail the p2p_scan and consequently
the p2p find.

Signed-off-by: Eyal Shapira <eyal@wizery.com>
P2P: Start blocked p2p find even if scan was on another interface (BRCM)

p2p find can now defer starting the p2p scan due to an ongoing
scan on a different interface. Relying on p2p_cb_on_scan_complete
which is a per interface flag is wrong here and we won't resume
the p2p find in case the scan wasn't on the same interface (which is
the case in Android JB).
Fix this by relying on the global p2p state instead.

(This description is based on analysis of the code as the original
BRCM commit doesn't contain any useful information)

Signed-off-by: Eyal Shapira <eyal@wizery.com>
P2P: Improve scan results handling (BRCM)

Avoid reporting scan results to the application in case a P2P search
is in progress as there will be many events but the scan is only
done on channels 1,6,11. This may cause APs on other channels to "disappear"
from the scan results.
Also avoid updating P2P interfaces with STA interfaces scan results
in order to avoid having results which are not on the social channels.

Signed-off-by: Eyal Shapira <eyal@wizery.com>
P2P: Avoid peer expiration while connection in progress (BRCM)

(This seems to be a bug fix squashed in one of the BRCM patches.
Could be that the probability of this occuring once the expiration
time was reduced to 30s is higher)

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>
Handle new interface parameter in ctrl commands (BRCM)

Some commands sent to wpa_s by the framework in JB include
a new interface parameter. Handle it and dispatch the the
command on the correct interface.

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>
HACK: Force go_intent=14 in p2p connect

The current TI solution supports STA+P2P_GO but
not concurrent STA+P2P_CLI. Therefore we force
go_intent to be 14 in order to increase the chance
of us chosen as GO. The reason for not forcing 15
is to enable TI vs. TI to work as one side has to
be P2P_CLI and one P2P_GO.

Signed-off-by: Eyal Shapira <eyal@wizery.com>
Initialize P2P on p2p0 and not wlan0 (JB)

P2P is being initialized using a global struct
which points to the first initialized interface wpa_s
struct. That's causing P2P commands sent on the control
socket matching p2p0 to generate scan and ROC on the
wrong interface (wlan0) as well as events like PEER_DEVICE_FOUND
are sent on the wrong control socket to the Android framework.
This caused the framework to ignore these and prevent
displaying the P2P peer in the UI.

Solve it by an ugly hack for now to enable P2P only when the
interface p2p0 is being initialized.

This probably should be fixed upstream as well by marking
somehow on which interface you can do p2p or enable p2p per
interface.

Signed-off-by: Eyal Shapira <eyal@wizery.com>
Revert "P2P: Assume GO Negotiation failed if GO Neg Conf wait times out"

Galaxy Nexus takes time to send the GO Neg Confirm (~200ms) and this
commit caused the GO Neg to fail because of this.

This reverts commit 579a80982ad07619373876c09cdd60e2afcba5b5.