P2P: Deinitialize global P2P context on P2P mgmt interface removal

The P2P implementation assumes that the first wpa_s interface instance
is used to manage P2P operations and the P2P module maintains a pointer
to this interface in msg_ctx. This can result in issues (e.g., use of
freed memory) when the management interface is removed. Fix this by
deinitializing global P2P data if the interface that created it is
removed. This will disable P2P until the next interface is added.

Signed-hostap: Jouni Malinen <j@w1.fi>
intended-for: hostap-1
wpa_supplicant: Fix overlapping memcpy on WPS interface addition

I think this should fix the following valgrind complaint:

==1972== Source and destination overlap in memcpy(0x5181708, 0x5181708, 16)
==1972==    at 0x4A073BA: memcpy (mc_replace_strmem.c:602)
==1972==    by 0x45872B: wpas_wps_set_uuid (wps_supplicant.c:1116)
==1972==    by 0x4599EC: wpas_wps_update_config (wps_supplicant.c:1747)
==1972==    by 0x4C8DB0: wpa_supplicant_update_config (wpa_supplicant.c:3090)
==1972==    by 0x4C3E5E: wpa_supplicant_reload_configuration (wpa_supplicant.c:746)
==1972==    by 0x4B8B37: wpa_supplicant_ctrl_iface_process (ctrl_iface.c:4082)
==1972==    by 0x4BA39C: wpa_supplicant_ctrl_iface_receive (ctrl_iface_unix.c:168)
==1972==    by 0x4114D4: eloop_sock_table_dispatch_table (eloop.c:335)
==1972==    by 0x411541: eloop_sock_table_dispatch (eloop.c:352)
==1972==    by 0x41200D: eloop_run (eloop.c:766)
==1972==    by 0x4C8B43: wpa_supplicant_run (wpa_supplicant.c:3010)
==1972==    by 0x4D44AD: main (main.c:286)

Signed-hostap: Ben Greear <greearb@candelatech.com>
intended-for: hostap-1
Validate WEP key lengths based on driver capabilities

The nl80211 driver interface does not allow 128-bit WEP to be used
without a vendor specific cipher suite and no such suite is defined for
this purpose. Do not accept WEP key length 16 for nl80211 driver
interface forn ow. wext-interface can still try to use these for
backwards compatibility.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
Add ChangeLog entries from v1.0 release

Signed-hostap: Jouni Malinen <j@w1.fi>
WPS: Fix BSSID filter handling

If WPS commands are used with a specific BSSID instead of wildcard,
the BSSID that was supposed to be used only for the provisioning step
may end up getting copied to the network block that gets provisioned
based on the WPS credentials. Fix this by clearing ssid->bssid_set
when creating the network block by replacing the block used for WPS
provisioning.

This issue could show up with the provisioned network not getting
selected properly with APs that have multiple radios. Depending on
the driver, this could result in only a single one of the available
BSSes being available or the connection failing completely.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
intended-for: hostap-1
Fix BSSID enforcement with driver-based BSS selection

Previously, wpa_supplicant did not specify BSSID to any connection
request if the driver indicated that it will take care of BSS selection.
This is fine for most use cases, but can result to issues if the network
block has an explicit bssid parameter to select which BSS is to be used.
Fix this by setting BSSID and channel when the network block includes the
bssid parameter even if the driver indicates support for BSS selection.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
intended-for: hostap-1
Add debug prints of scan result IEs

Excessive debug level can now be used to dump the IEs received in scan
results from both Beacon and Probe Response frames. This makes it easier
to debug issues where the driver (or well, more likely cfg80211) does
not update the IEs based on Beacon frames if even a single Probe
Response frame has been received.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
P2P: Add option for Provision Discovery before GO Negotiation

This is a workaround for interoperability issues with some deployed P2P
implementations that require a Provision Discovery exchange to be used
before GO Negotiation. The new provdisc parameter for the p2p_connect
command can be used to request this behavior without having to run a
separate p2p_prov_disc command.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
nl80211: Add more debug info on NL80211_CMD_FRAME uses

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
nl80211: Use wait_time with AP mode driver SME for offchannel

When sending an offchannel frame (mainly, P2P Invitation Request), the
wait_time parameter was hardcoded to 0 for drivers that implement AP
mode SME. This is not correct and can cause problems for drivers that
support offloading of off-channel operations with driver/firmware based
AP SME.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
supplicant: Make unix socket non-blocking.

This keeps wpa_cli from hanging forever if the other end of the
socket dies.

Signed-hostap: Ben Greear <greearb@candelatech.com>
wpa_supplicant: Support minimum interval between scan attempts.

When running lots of vifs, they can all end up wanting to
scan right after the other.  This leaves too little time for
useful work to happen.  Allow users to configure a minimum
timer interval (in seconds) between scans.  Default is zero,
which is current behaviour.

Signed-off-by: Ben Greear <greearb@candelatech.com>
supplicant:  Allow limiting number of concurrent associations.

When using lots of virtual clients, it may be useful to
limit the number that attempt to connect to the AP at
once.  Limitting the associations per scan response is
an easy way to do this.

Signed-hostap: Ben Greear <greearb@candelatech.com>
Increase EAPOL timers.

This allows 128 stations to associate & authenticate
all at once.  Without this, 4-way handshake doesn't
work right.

From: Bjorn Smedman <bjorn.smedman@venatech.se>

NOTE:  This should probably not be applied upstream as is..but
should be a configuration option in the hostapd.conf file.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Support can-scan-one using -1 for freq.

Signed-off-by: Ben Greear <greearb@candelatech.com>
nl80211: Add identifier to structs

This helps one figure out what type of struct the object is, since they
are usually passed around as void* ctx pointers. Can be used in gdb
currently, but run-time checks could be added later if needed.

Signed-off-by: Ben Greear <greearb@candelatech.com>
wpa-config:  Add some debug info for config file error cases.

It didn't alway spit out useful stuff when reading config failed.

Signed-off-by: Ben Greear <greearb@candelatech.com>
nl80211:  Remove MLME retry code that causes trouble.

When testing 130+ virtual stations, using no encryption
(no WPA, etc), some number of them will get into endless
loops of authenticating and de-authenticating.  It appears
that the code that is supposed to ignore the spurious de-auth
event created by this retry logic does not work in all cases.

Removing the retry code as this patch does fixes the problem
for me.

Maybe the entire patch (6d6f4bb8) should be reverted?

Signed-hostap: Ben Greear <greearb@candelatech.com>
eloop/poll:  Handle POLLER | POLLHUP in read logic.

Without this, we can get into a tight loop because the
code in general doesn't add eloop exception handlers,
so socket reporting the POLLERR would never be read.

With this change, any socket with POLLERR or POLLHUP
asserted will be handled by the read logic.

Signed-off-by: Ben Greear <greearb@candelatech.com>
hostap:  Ensure netlink recv buf size is large enough.

I was getting this error on wpa_supplicant startup when configured
for 200+ stations:

1333514002.074458: netlink: recvfrom failed: No buffer space available

So, increase rcv buffer size to 1MB so we don't drop netlink
packets.

Signed-hostap: Ben Greear <greearb@candelatech.com>