mech_eap.git
10 years agoP2P: Fix crash when failed to create GO interface aosp-kk-from-upstream
Vinay Krishna Eranna [Tue, 3 Sep 2013 08:17:21 +0000 (11:17 +0300)]
P2P: Fix crash when failed to create GO interface

wpa_supplicant crashes if driver configuration for AP mode interface
configuration fails after group negotiation. This is because of a
regression from commit 1075b2957169d8f9d6dddd7679339c751dc9515b that
ends up freeing the wpa_s instance from within
wpa_supplicant_create_ap() without the caller knowing.

Fix this by using an eloop timeout to free remove the P2P group so that
wpa_supplicant_create_ap() and especially wpa_supplicant_associate()
callers do not need to know about interface getting possibly removed. In
addition, move the P2P specific code into p2p_supplicant.c where it
really belongs. This allows the already existing group formation timeout
to be used by reducing the timeout to zero.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

10 years agotests: Check wpa_supplicant connection after reset
Jouni Malinen [Tue, 3 Sep 2013 09:13:25 +0000 (12:13 +0300)]
tests: Check wpa_supplicant connection after reset

Some test runs have resulted in wpa_supplicant being unresponsive or
very slow on the control interface. Check for that type of issues as
part of the reset sequence that is done between each test case.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

10 years agoWPS NFC: Fix build without CONFIG_AP=y
Jouni Malinen [Tue, 3 Sep 2013 08:27:24 +0000 (11:27 +0300)]
WPS NFC: Fix build without CONFIG_AP=y

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

10 years agoSAE: Fix build without CONFIG_AP=y
Jouni Malinen [Tue, 3 Sep 2013 08:25:29 +0000 (11:25 +0300)]
SAE: Fix build without CONFIG_AP=y

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

10 years agoP2P: Remove group from timeout on PSK failure
Jouni Malinen [Mon, 2 Sep 2013 13:33:42 +0000 (16:33 +0300)]
P2P: Remove group from timeout on PSK failure

Avoid potential issues with removing a P2P group on PSK failure directly
from the wpa_supplicant_event() call since the caller (in driver_*.c)
may not be prepared for the interface disappearing at that point in
time.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

10 years agotests: Add a test case for invitation after client removal
Jouni Malinen [Sun, 1 Sep 2013 17:47:37 +0000 (20:47 +0300)]
tests: Add a test case for invitation after client removal

test_persistent_group_invite_removed_client verifies that a client
that is removed from a group can rejoin based on new invitation.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agotests: Use a helper function for waiting session termination
Jouni Malinen [Sun, 1 Sep 2013 16:30:08 +0000 (19:30 +0300)]
tests: Use a helper function for waiting session termination

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agotests: Add test cases for persistent P2P groups
Jouni Malinen [Sun, 1 Sep 2013 16:24:12 +0000 (19:24 +0300)]
tests: Add test cases for persistent P2P groups

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agotests: Extend test_autogo_2cli to test client removal
Jouni Malinen [Sun, 1 Sep 2013 14:58:17 +0000 (17:58 +0300)]
tests: Extend test_autogo_2cli to test client removal

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agotests: Add test cases for per-STA PSK in P2P group
Jouni Malinen [Sun, 1 Sep 2013 08:56:55 +0000 (11:56 +0300)]
tests: Add test cases for per-STA PSK in P2P group

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agoP2P: Add event messages for possible PSK failures on P2P groups
Jouni Malinen [Sun, 1 Sep 2013 18:28:16 +0000 (21:28 +0300)]
P2P: Add event messages for possible PSK failures on P2P groups

It is possible for the GO of a persistent group to change the PSK or
remove a client when per-client PSKs are used and this can happen
without the SSID changing (i.e., the group is still valid, but just not
for a specific client). If the client side of such persistent group ends
up trying to use an invalidated persistent group information, the
connection will fail in 4-way handshake. A new WPS provisioning step is
needed to recover from this.

Detect this type of case based on two 4-way handshake failures when
acting as a P2P client in a persistent group. A new
"P2P-PERSISTENT-PSK-FAIL id=<persistent group id>" event is used to
indicate when this happens. This makes it easier for upper layers to
remove the persistent group information with "REMOVE_NETWORK <persistent
group id>" if desired (e.g., based on user confirmation).

In addition to indicating the error cases for persistent groups, all
this type of PSK failures end up in the client removing the group with
the new reason=PSK_FAILURE information in the P2P-GROUP-REMOVED event.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agoP2P: Document per-client keys and p2p_remove_client
Jouni Malinen [Sun, 1 Sep 2013 14:54:10 +0000 (17:54 +0300)]
P2P: Document per-client keys and p2p_remove_client

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agoP2P: Do not store duplicate PSK entries for the same device
Jouni Malinen [Sun, 1 Sep 2013 14:47:05 +0000 (17:47 +0300)]
P2P: Do not store duplicate PSK entries for the same device

If a client joins a P2P group multiple times, replace the previous
per-client PSK entry instead of adding a new entry each time.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agoP2P: Add a command for removing a client from all groups
Jouni Malinen [Sun, 1 Sep 2013 14:37:22 +0000 (17:37 +0300)]
P2P: Add a command for removing a client from all groups

The new control interface command P2P_REMOVE_CLIENT <P2P Device
Address|iface=Address> can now be used to remove the specified client
from all groups (ongoing and persistent) in which the local device is a
GO. This will remove any per-client PSK entries and deauthenticate the
device.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agoP2P: Maintain list of per-client PSKs for persistent groups
Jouni Malinen [Sun, 1 Sep 2013 10:40:33 +0000 (13:40 +0300)]
P2P: Maintain list of per-client PSKs for persistent groups

Record all generated per-client PSKs in the persistent group network
block and configure these for the GO Authenticator whenever re-starting
the persistent group. This completes per-client PSK support for
persistent groups.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agoP2P: Select PSK based on Device Address instead of Interface Address
Jouni Malinen [Sun, 1 Sep 2013 08:30:26 +0000 (11:30 +0300)]
P2P: Select PSK based on Device Address instead of Interface Address

When using per-device PSKs, select the PSK based on the P2P Device
Address of the connecting client if that client is a P2P Device. This
allows the P2P Interface Address to be changed between P2P group
connections which may happen especially when using persistent groups.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agoP2P: Make peer's P2P Device Address available to authenticator
Jouni Malinen [Sun, 1 Sep 2013 08:05:19 +0000 (11:05 +0300)]
P2P: Make peer's P2P Device Address available to authenticator

This can be used to implement per-device PSK selection based on the
peer's P2P Device Address instead of P2P Interface Address.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agoP2P: Store P2P Device Address in per-device PSK records
Jouni Malinen [Sun, 1 Sep 2013 07:47:34 +0000 (10:47 +0300)]
P2P: Store P2P Device Address in per-device PSK records

This makes the P2P Device Address of the Enrollee available with the PSK
records to allow P2P Device Address instead of P2P Interface Address to
be used for finding the correct PSK.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agoP2P: Allow per-device PSK to be assigned
Jouni Malinen [Sun, 1 Sep 2013 07:08:30 +0000 (10:08 +0300)]
P2P: Allow per-device PSK to be assigned

"wpa_cli p2p_set per_sta_psk <0/1>" can now be used to disable/enable
use of per-device PSKs in P2P groups. This is disabled by default.
When enabled, a default passphrase is still generated by the GO for
legacy stations, but all P2P and non-P2P devices using WPS will get
a unique PSK.

This gives more protection for the P2P group by preventing clients from
being able to derive the unicast keys used by other clients. This is
also a step towards allowing specific clients to be removed from a group
reliably without having to tear down the full group to do so.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agowpa_cli: Add tab completion for p2p_set field values
Jouni Malinen [Sat, 31 Aug 2013 17:58:35 +0000 (20:58 +0300)]
wpa_cli: Add tab completion for p2p_set field values

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agoP2P: Stop listen state when listen-only duration is over
Syed Asifful Dayyan Rafiuddeen [Sat, 31 Aug 2013 15:09:15 +0000 (18:09 +0300)]
P2P: Stop listen state when listen-only duration is over

Even after listen duration is over, P2P module remained in
P2P_LISTEN_ONLY state, which is blocking station mode scans. Fix this by
stopping P2P listen explicitly to update p2p_state to IDLE when listen
duration expires.

Signed-hostap: Syed Asifful Dayyan <syedd@broadcom.com>

10 years agotests: Make test_autogo validate group removal event on client
Jouni Malinen [Sat, 31 Aug 2013 14:59:16 +0000 (17:59 +0300)]
tests: Make test_autogo validate group removal event on client

Use test_autogo to verify that P2P client is able to notice explicit
group session termination message from the GO. This would have caught
the regression in processing P2P deauthentication notifications.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agowpa_cli: Allow first DISCONNECTED event to be reported
Jouni Malinen [Sat, 31 Aug 2013 14:27:20 +0000 (17:27 +0300)]
wpa_cli: Allow first DISCONNECTED event to be reported

wpa_cli filters out extra DISCONNECTED events from action scripts. This
ended up filtering out the first real DISCONNECT event in case wpa_cli
was started when wpa_supplicant was in connected state. Change wpa_cli
to allow the first disconnection event to be reported to the action
script in such case.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agoDisallow WEP configuration in WPA network
Jouni Malinen [Sat, 31 Aug 2013 14:18:45 +0000 (17:18 +0300)]
Disallow WEP configuration in WPA network

Some drivers fail to work if WEP keys are configured in a WPA network.
To avoid potentially confusing error cases, reject hostapd configuration
that enables WPA and includes parameters that would imply that WEP keys
would be set.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agoD-Bus: Fix per-iface object unregistration on not existing objects
Jouni Malinen [Sat, 31 Aug 2013 13:46:24 +0000 (16:46 +0300)]
D-Bus: Fix per-iface object unregistration on not existing objects

If the private data for an object is not found, do not try to unregister
that object to avoid D-Bus errors.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agoD-Bus: Do not send network notification for all P2P groups
Jouni Malinen [Sat, 31 Aug 2013 13:44:42 +0000 (16:44 +0300)]
D-Bus: Do not send network notification for all P2P groups

Previously, network added event was skipping during group formation.
However, this did not necessarily catch all cases of temporary P2P
network blocks. Check ssid->p2p_group to make this behavior more
consistent by avoiding all P2P groups.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agoFix switching from EAP-SIM to EAP-AKA/AKA'
Masashi Honma [Sat, 31 Aug 2013 13:11:48 +0000 (16:11 +0300)]
Fix switching from EAP-SIM to EAP-AKA/AKA'

Switching EAP method from EAP-SIM to EAP-AKA fails.
wpa_cli commands are below.

------------------
sudo wpa_cli add_network
sudo wpa_cli set_network 0 ssid '"eap-sim"'
sudo wpa_cli set_network 0 key_mgmt WPA-EAP
sudo wpa_cli set_network 0 eap SIM
sudo wpa_cli set_network 0 pin '"1234"'
sudo wpa_cli set_network 0 pcsc '""'
sudo wpa_cli select_network 0

sudo wpa_cli disable_network 0
sudo wpa_cli disconnect
sudo wpa_cli remove_network 0

sudo wpa_cli add_network
sudo wpa_cli set_network 0 ssid '"eap-sim"'
sudo wpa_cli set_network 0 key_mgmt WPA-EAP
sudo wpa_cli set_network 0 eap AKA
sudo wpa_cli set_network 0 pin '"1234"'
sudo wpa_cli set_network 0 pcsc '""'
sudo wpa_cli select_network 0
------------------

Then EAP-AKA connection resulted in fail.
wpa_supplicant log is below.

------------------
wlan0: CTRL-EVENT-EAP-METHOD EAP vendor 0 method 23 (AKA) selected
SCARD: Non-USIM card - cannot do UMTS auth
EAP-AKA: UMTS authentication failed (AUTN)
wlan0: CTRL-EVENT-EAP-FAILURE EAP authentication failed
------------------

This occurs because on the first EAP-SIM authentication, the SIM/USIM
card in the device was recognized as SIM card even if it is USIM card.

So this patch changes it to recognize as USIM card even if EAP-SIM
authentication was required.

I have tested these switching cases.
EAP-SIM -> EAP-AKA
EAP-SIM -> EAP-AKA'
EAP-AKA -> EAP-SIM
EAP-AKA -> EAP-AKA'
EAP-AKA' -> EAP-SIM
EAP-AKA' -> EAP-AKA

Signed-hostap: Masashi Honma <masashi.honma@gmail.com>

10 years agoP2P: Allow P2P functionality to be disabled per interface
Sreenath Sharma [Sat, 31 Aug 2013 08:59:05 +0000 (11:59 +0300)]
P2P: Allow P2P functionality to be disabled per interface

By default, P2P is initialized for all driver interfaces and this makes
P2P getting initialized for non-P2P station interface if the supplicant
is started first on this interface. If an interface is dedicated for
non-P2P station mode, it is now possible to disable P2P initialization
by adding 'p2p_disabled=1' in the configuration file of non-P2P station
interface, irrespective of the order in which supplicant is started.

Signed-hostap: Sreenath Sharma <sreenats@broadcom.com>

10 years agotests: Use longer timeout in test_ap_wps_er_add_enrollee
Jouni Malinen [Sat, 31 Aug 2013 08:54:23 +0000 (11:54 +0300)]
tests: Use longer timeout in test_ap_wps_er_add_enrollee

This is another one of the test cases that can time out frequently
under valgrind during WPS exchange. Increase the timeout to make
false error reports less likely to occur.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agohostapd: Add Automatic Channel Selection (ACS) support
Michal Kazior [Sat, 31 Aug 2013 08:49:51 +0000 (11:49 +0300)]
hostapd: Add Automatic Channel Selection (ACS) support

This adds ACS support to hostapd. Currently only survey-based
algorithm is available.

To use ACS you need to enable CONFIG_ACS=y in .config and use
channel=0 (or channel=acs_survey) in hostapd.conf.

For more details see wiki page [1] or comments in src/ap/acs.c.

[1]: http://wireless.kernel.org/en/users/Documentation/acs

Signed-hostap: Michal Kazior <michal.kazior@tieto.com>

10 years agoP2P: Immediate group removal in GC in case of deauthentication
Sreenath Sharma [Sat, 31 Aug 2013 08:11:41 +0000 (11:11 +0300)]
P2P: Immediate group removal in GC in case of deauthentication

Right now in case of deauthentication from GO, immediate group removal will
happen in GC only if the deauthentication packet has a valid IE. However,
the IE in deauthentication packet is mandated only for managed P2P group.
So in normal P2P group the group removal is delayed and will happen later
only in group idle timeout.

This fixes a regression from commit
d7df0fa727a2a79d7b22df6c68961220349ab2e3 that changed the previous check
for data->deauth_info != NULL to data->deauth_info->ie != NULL.

Signed-hostap: Sreenath Sharma <sreenats@broadcom.com>

10 years agoFix MNC length for Swisscom SIM cards
Andrejs Cainikovs [Sat, 31 Aug 2013 07:58:23 +0000 (10:58 +0300)]
Fix MNC length for Swisscom SIM cards

Swisscom SIM cards do not include MNC length within EF_AD, and end up
using incorrect MNC length based on the 3-digit default. Hardcode MNC
length of 2 for Switzerland, in the same manner as it was done for
Finland.

Signed-hostap: Andrejs Cainikovs <andrejs.cainikovs@sonymobile.com>

10 years agotests: Increase WPS timeout to 30 seconds
Jouni Malinen [Sat, 31 Aug 2013 07:45:03 +0000 (10:45 +0300)]
tests: Increase WPS timeout to 30 seconds

Number of crypto operations seem to take very long time in the valgrind
tests (about five seconds for public key generation for M1 and M2 on a
virtual server) and this is enough to push the test runs to hit the
timeout frequently even when there is no real error. Make this less
frequent by increasing WPS test case timeout from 15 to 30 seconds to
avoid issues based on the test scripts.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agotests: Increase P2P group formation timeout to 20 seconds
Jouni Malinen [Sat, 31 Aug 2013 07:33:44 +0000 (10:33 +0300)]
tests: Increase P2P group formation timeout to 20 seconds

Number of crypto operations seem to take very long time in the valgrind
tests (about five seconds for passphrase to PSK mapping and for public
key generation for M1 and M2 on a virtual server) and this is enough to
push the test runs to hit the timeout frequently even when there is no
real error. Make this less frequent by increasing group formation
timeout from 15 to 20 seconds to avoid issues based on the test scripts
(15 + config time seconds timeout in the protocol may still kick in,
though).

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agoIBSS RSN: Add a timeout for Authentication frame exchange
Jouni Malinen [Tue, 27 Aug 2013 13:26:33 +0000 (16:26 +0300)]
IBSS RSN: Add a timeout for Authentication frame exchange

It is possible for the peer device not to support Authentication frame
exchange even though this would be required functionality in the
standard. Furthermore, either Authentication frame may be lost. To
recover from cases where Authentication frame sequence 2 is not
received, start EAPOL Authenticator from one second timeout.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agotests: Wait longer for program deinit
Jouni Malinen [Tue, 27 Aug 2013 13:02:15 +0000 (16:02 +0300)]
tests: Wait longer for program deinit

Wait a bit longer for wpa_supplicant/hostapd to exit and clear control
interface files separately if either any of the cleanup steps fail to do
so.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agotests: Wait for hostapd/wpa_supplicant to reply at start (concurrent)
Jouni Malinen [Tue, 27 Aug 2013 13:01:04 +0000 (16:01 +0300)]
tests: Wait for hostapd/wpa_supplicant to reply at start (concurrent)

Instead of waiting for a fixed duration, poll hostapd/wpa_supplicant
through the control interface until they are ready to reply in order to
avoid starting test case execution too early. This is like commit
b76579e0c09a1a763b70d63613377b407cbc405f but for the concurrent P2P test
cases that were forgotten from that commit.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agoP2P: Postpone concurrent scans when waiting for first client as GO
Jouni Malinen [Tue, 27 Aug 2013 09:23:10 +0000 (12:23 +0300)]
P2P: Postpone concurrent scans when waiting for first client as GO

Previously, concurrent station mode scans were postponed during an
ongoing P2P group formation up to the point of completed WPS
provisioning step. This would allow a scan to be started before the P2P
client has completed association for the data connection if a scan
request were timed to hit the window between the provisioning step and
the following association. Avoid this by extending P2P-in-progress state
to continue until the first data connection has been completed as part
of group formation. Use a ten second timeout for this to avoid leaving
scans disabled indefinitely if the client fails to connect completely.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

10 years agotests: Detect BSSID mismatch in test_ibss_rsn
Jouni Malinen [Tue, 27 Aug 2013 00:11:02 +0000 (03:11 +0300)]
tests: Detect BSSID mismatch in test_ibss_rsn

It looks like mac80211 does not always manage to join the same IBSS and
this can result in test_ibss_rsn failures. Detect this case and try to
get the IBSSes to merge by running a scan prior to continuing with the
test case.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agoIBSS RSN: Work around Data RX vs. Authentication RX race condition
Jouni Malinen [Mon, 26 Aug 2013 23:54:35 +0000 (02:54 +0300)]
IBSS RSN: Work around Data RX vs. Authentication RX race condition

It is possible for the driver to report EAPOL frame RX before
Authentication frame RX even if the frames arrived in the opposite
order. This can result in issues in cases where both IBSS peers initiate
Authentication frame exchange at about the same time and one of the
EAPOL sessions is started before processing Authentication frame seq=1
RX. Work around this by not re-initializing EAPOL state on
Authentication (SEQ=1) RX if own Authentication frame was transmitted
within last 500 ms.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agotests: Wait for all 4-way handshake pairs in test_ibss_rsn
Jouni Malinen [Mon, 26 Aug 2013 23:00:39 +0000 (02:00 +0300)]
tests: Wait for all 4-way handshake pairs in test_ibss_rsn

The handshake between STA2 and STA1 was not tracked previously. For
completeness, include that in the list of handshakes that are explicitly
waited for to complete prior to starting the connectivity tests. Since
all key setup should be done at this point, remove the extra wait before
the last connectivity test between STA1 and STA2.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agotests: Increase test_ap_wps_init connection timeout
Jouni Malinen [Mon, 26 Aug 2013 13:54:05 +0000 (16:54 +0300)]
tests: Increase test_ap_wps_init connection timeout

It looks like there may not be enough time to complete this test case in
15 seconds under valgrind on a virtual host every time, so increase the
timeout to 30 seconds to get more consistent test results.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agotests: Wait for hostapd/wpa_supplicant to reply at start
Jouni Malinen [Mon, 26 Aug 2013 13:47:15 +0000 (16:47 +0300)]
tests: Wait for hostapd/wpa_supplicant to reply at start

Instead of waiting for a fixed duration, poll hostapd/wpa_supplicant
through the control interface until they are ready to reply in order to
avoid starting test case execution too early.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agotests: Kill hostapd/wpa_supplicant more forcefully if needed
Jouni Malinen [Mon, 26 Aug 2013 13:38:13 +0000 (16:38 +0300)]
tests: Kill hostapd/wpa_supplicant more forcefully if needed

Try to make sure new testing can be started by forcing
hostapd/wpa_supplicant to be killed with SIGKILL if needed. In addition,
wait a bit longer when killing the processes to avoid issues with the
next test run starting before the old one has been fully terminated.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agoP2P: Update peer operating channel from GO Negotiation Confirm
Jouni Malinen [Mon, 26 Aug 2013 11:16:31 +0000 (14:16 +0300)]
P2P: Update peer operating channel from GO Negotiation Confirm

If the device that sends the GO Negotiation Confirm becomes the GO, it
may change its operating channel preference between GO Negotiation
Request and Confirm messages based on the channel list received from us.
Previously, the peer operating channel preference was not updated in
such a case and this could result in the initial scans after GO
Negotiation using incorrect operating channel and as such, extra delay
in the connection process. Fix this by updating the operating channel
information from GO Negotiation Confirm in cases where the peer becomes
the GO.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

10 years agoP2P: Use the first pref_chan entry as operating channel preference
Jouni Malinen [Mon, 26 Aug 2013 11:10:23 +0000 (14:10 +0300)]
P2P: Use the first pref_chan entry as operating channel preference

If there are no higher priority preference for the operating channel,
use the first pref_chan entry as the operating channel preference over
the pre-configured channel which is not really a good indication of
preference. This changes the behavior for GO Negotiation Request frame
operating channel preference value in cases where p2p_pref_chan list is
set.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

10 years agoP2P: Add more debug info on operating channel selection
Jouni Malinen [Mon, 26 Aug 2013 11:08:03 +0000 (14:08 +0300)]
P2P: Add more debug info on operating channel selection

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

10 years agoP2P: Add GO negotiation results into the P2P-GO-NEG-SUCCESS event
Jouni Malinen [Mon, 26 Aug 2013 10:35:44 +0000 (13:35 +0300)]
P2P: Add GO negotiation results into the P2P-GO-NEG-SUCCESS event

This provides status information about the negotiated group to
wpa_supplicant control interface monitors during group formation in a
form that is easier to use than having to fetch the information
separately.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

10 years agoReplace perror() with wpa_printf(strerror) in ctrl_iface calls
Jouni Malinen [Mon, 26 Aug 2013 08:46:21 +0000 (11:46 +0300)]
Replace perror() with wpa_printf(strerror) in ctrl_iface calls

This replaces number of perror() calls with wpa_printf() to get the
error messages embedded within rest of the debug messages in the same
stream instead of pushing these to stderr which may get directed to
another location.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agotests: Stop valgrind.bin regardless of which option is started
Jouni Malinen [Mon, 26 Aug 2013 08:28:32 +0000 (11:28 +0300)]
tests: Stop valgrind.bin regardless of which option is started

The previous design of having to provide valgrind parameter to
stop-wifi.sh did not work since the new test setup may no match the
previous one. Instead of trying to figure out what needs to be stopped
based on previous run, stop all wpa_supplicant/hostapd processes running
under valgrind unconditionally to avoid cases where new set of processes
cannot be started due to existing processed.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agotests: Use more enforced order for the RSN IBSS steps
Jouni Malinen [Sun, 25 Aug 2013 20:10:37 +0000 (23:10 +0300)]
tests: Use more enforced order for the RSN IBSS steps

test_ibss_rsn has been failing pretty frequently due to various issues
in getting all connections up. Try to address this initially by avoiding
concurrent operations and explicitly waiting for 4-way handshake
completion before testing data connection. Once this test case is
workign more robustly, a more difficult case with concurrent operations
can be added as a separate test case.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agoIBSS RSN: Add IBSS-RSN-COMPLETED event message
Jouni Malinen [Sun, 25 Aug 2013 20:09:22 +0000 (23:09 +0300)]
IBSS RSN: Add IBSS-RSN-COMPLETED event message

This new control interface event message is used to indicate when
both 4-way handshakes have been completed with a new IBSS peer.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agotests: Silence wlantest clear_tdls_counters output from stdout
Jouni Malinen [Sun, 25 Aug 2013 18:48:51 +0000 (21:48 +0300)]
tests: Silence wlantest clear_tdls_counters output from stdout

This removes unnecessary "OK" lines from test logs.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agotests: Redirect tcpdump output to a file
Jouni Malinen [Sun, 25 Aug 2013 18:43:21 +0000 (21:43 +0300)]
tests: Redirect tcpdump output to a file

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agoP2P: Add state info to global STATUS command
Jouni Malinen [Sun, 25 Aug 2013 18:02:12 +0000 (21:02 +0300)]
P2P: Add state info to global STATUS command

This can be used for debugging purposes to see what the current P2P
module state is.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agoAdd STATUS command to global control interface
Jouni Malinen [Sun, 25 Aug 2013 17:53:58 +0000 (20:53 +0300)]
Add STATUS command to global control interface

This provides global status information that is applicable to all
interfaces (e.g., P2P state). In addition, ifname/address pairs are
listed to get information of all the interfaces that are currently
managed through this wpa_supplicant instance.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agoAdd SAVE_CONFIG command to global control interface
Jouni Malinen [Sun, 25 Aug 2013 17:41:39 +0000 (20:41 +0300)]
Add SAVE_CONFIG command to global control interface

This iterates through all interfaces and saves configuration file
updates for each interface that allows it (update_config=1).

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agoAdd SET command for global control interface
Jouni Malinen [Sun, 25 Aug 2013 17:35:19 +0000 (20:35 +0300)]
Add SET command for global control interface

This allows global parameters to be set through the global control
interface without having to use IFNAME prefix. For now, this covers
only the wifi_display parameter.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agotests: Save debug log to a file and clean up stdout status
Jouni Malinen [Sun, 25 Aug 2013 17:15:54 +0000 (20:15 +0300)]
tests: Save debug log to a file and clean up stdout status

This makes it easier to figure out what failed and allows builbot to
integrate multiple logs and state information about the test cases.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agoClear EAPOL supplicant configuration info on current_ssid changes
Jouni Malinen [Sun, 25 Aug 2013 16:46:57 +0000 (19:46 +0300)]
Clear EAPOL supplicant configuration info on current_ssid changes

There were some code paths that allowed obsolete configuration data
pointer to be maintained within EAPOL supplicant in case a network was
removed while not connection to it (i.e., wpa_s->current_ssid not
pointing to the network that was removed). This could result in use of
freed memory, e.g., from eap_sm_notify_ctrl_attached() when a new
control interface connected prior to the EAPOL supplicant configuration
pointer got updated.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agohostapd: Add survey dump support
Michal Kazior [Wed, 24 Jul 2013 06:59:13 +0000 (08:59 +0200)]
hostapd: Add survey dump support

This adds survey dump support for all frequencies
and for specific desired frequencies. This will later
be used by ACS code for spectrum heuristics.

Signed-hostap: Michal Kazior <michal.kazior@tieto.com>

10 years agohostapd: Split up channel checking into helpers
Michal Kazior [Thu, 18 Jul 2013 07:17:06 +0000 (09:17 +0200)]
hostapd: Split up channel checking into helpers

This splits up the channel checking upon initialization into a few
helpers. This should make this a bit easier to follow. This also paves
the way for some initial ACS entry code.

Signed-hostap: Michal Kazior <michal.kazior@tieto.com>

10 years agowired: Wait for the link to become active before sending packets
Rui Paulo [Sun, 25 Aug 2013 08:40:19 +0000 (11:40 +0300)]
wired: Wait for the link to become active before sending packets

Interfaces that take one or two seconds to reconfigure the link after we
set IFF_ALLMULTI or after we bring the interface up were dropping the
initial TX EAPOL packet which caused excessive delays in authentication.
This change applies to FreeBSD/DragonFly only.

Signed-hostap: Rui Paulo <rpaulo@FreeBSD.org>

10 years agoP2P: Validate the freq in p2p_group_add
Ilan Peer [Sun, 25 Aug 2013 08:28:56 +0000 (11:28 +0300)]
P2P: Validate the freq in p2p_group_add

Add additional input verification for the frequency parameter in
p2p_group_add (and other P2P operations for that matter). Without this
verification invalid freq could be set and not handled properly.

Signed-hostap: Ilan Peer <ilan.peer@intel.com>

10 years agowpa_supplicant: Fix AP mode frequency initialization
Avraham Stern [Sun, 25 Aug 2013 08:24:29 +0000 (11:24 +0300)]
wpa_supplicant: Fix AP mode frequency initialization

In AP mode the frequency was initialized only after trying to set up the
AP which caused failure. Move AP frequency initialization to the right
place. This allows an AP mode network block without the frequency
parameter to be used with the default channel 11 being selected in that
case.

Signed-hostap: Avraham Stern <avraham.stern@intel.com>

10 years agoP2P: Skip non-P2P interface in p2p_group_remove *
Ilan Peer [Sun, 25 Aug 2013 08:17:14 +0000 (11:17 +0300)]
P2P: Skip non-P2P interface in p2p_group_remove *

When 'p2p_group_remove *' is called while the station interface
is connected, the flow also disconnects the station interface.
Fix this by skipping non-P2P interfaces in the iteration.

Signed-hostap: Ilan Peer <ilan.peer@intel.com>

10 years agoWPS: Set currently used RF band in RF Bands attribute
David Spinadel [Sun, 25 Aug 2013 07:55:53 +0000 (10:55 +0300)]
WPS: Set currently used RF band in RF Bands attribute

According to WSC specification (Ver 2.0.2, section 8.3), RF Bands
attribute should be set to the specific RF band used for the current
message. Add an option to set wanted band in wps_build_rf_bands() and
add a callback to get the current band from wpa_supplicant and hostapd.

Signed-hostap: David Spinadel <david.spinadel@intel.com>

10 years agonl80211: Start P2P Device when rfkill is unblocked
Ilan Peer [Sun, 25 Aug 2013 07:43:32 +0000 (10:43 +0300)]
nl80211: Start P2P Device when rfkill is unblocked

Signed-hostap: Ilan Peer <ilan.peer@intel.com>

10 years agonl80211: Do not change type to station on P2P interfaces
Ilan Peer [Sun, 25 Aug 2013 07:20:54 +0000 (10:20 +0300)]
nl80211: Do not change type to station on P2P interfaces

It is possible that when trying to remove a dynamically added interface,
changing its type to station mode is not possible (since the kernel does
not support so in its interface combinations).

Since P2P interfaces are always dynamically added, avoid changing their
type to station in the deinit_ap() and deinit_p2p_client() nl80211
callbacks, assuming that the interface is about to be removed.

Signed-hostap: Ilan Peer <ilan.peer@intel.com>

10 years agowpa_supplicant: Reduce wait time for control interfaces
Ilan Peer [Sun, 25 Aug 2013 06:48:27 +0000 (09:48 +0300)]
wpa_supplicant: Reduce wait time for control interfaces

Reduce the wait time for the monitor control interfaces to get
messages on wpa_supplicant de-init etc., as this significantly delays
the shutdown of the wpa_supplicant.

Signed-hostap: Ilan Peer <ilan.peer@intel.com>

10 years agoP2P: Allow separate interface GO to disconnect low-ack STAs
Arik Nemtsov [Sun, 25 Aug 2013 06:28:50 +0000 (09:28 +0300)]
P2P: Allow separate interface GO to disconnect low-ack STAs

Propagate the disassoc_low_ack setting from the main P2P interface to
the group interface.

Signed-hostap: Arik Nemtsov <arik@wizery.com>

10 years agoFT RRB: Clear pad field to avoid sending out uninitialized data
Jouni Malinen [Sat, 24 Aug 2013 21:35:10 +0000 (00:35 +0300)]
FT RRB: Clear pad field to avoid sending out uninitialized data

The pad field in the RRB messages is unused, but it should be
initialized to avoid sending out arbitrary data from stack. This was
also generating number of valgrind complaints about uninitialized memory
accesses in local FT tests.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agotests: Sleep even longer before starting valgrind tests
Jouni Malinen [Sat, 24 Aug 2013 20:47:40 +0000 (23:47 +0300)]
tests: Sleep even longer before starting valgrind tests

It looks like some virtual host setups are too slow to get
wpa_supplicant initialized under valgrind and this was triggering test
failures. Work around this by using even a longer wait before test case
execution.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agonl80211: Fix deinit path to unregister nl_mgmt socket
Jouni Malinen [Sat, 24 Aug 2013 20:45:11 +0000 (23:45 +0300)]
nl80211: Fix deinit path to unregister nl_mgmt socket

Commit 8e12685c43546d03ced5ec5dc4b56486a1204115 replaced call to
nl80211_mgmt_unsubscribe() on the deinit path with a
wpa_driver_nl80211_set_mode() call. This is not enough to unregister the
bss->nl_mgmt read socket in all cases. Fix this by unconditionally
unsubscribing from the nl80211 events after having change mode to
station.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agoFix DETACH command debug prints to avoid use of freed memory
Jouni Malinen [Sat, 24 Aug 2013 20:31:06 +0000 (23:31 +0300)]
Fix DETACH command debug prints to avoid use of freed memory

In case a control interface socket is detached because of sendmsg()
failing for the socket, function call to detach the socket uses a
pointer to the socket information in the structure to be freed. Reorder
code to print socket info before freeing the data to avoid use of freed
memory in case debug prints are enabled.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agotests: Make wpa_supplicant and hostapd executable through valgrind
Jouni Malinen [Sat, 24 Aug 2013 18:46:44 +0000 (21:46 +0300)]
tests: Make wpa_supplicant and hostapd executable through valgrind

It looks like valgrind could not under buildbot with the default file
mode. Fix this by making wpa_supplicant and hostapd binaries readable
and executable by everyone.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agotests: Continue even if device reset fails
Jouni Malinen [Sat, 24 Aug 2013 18:16:04 +0000 (21:16 +0300)]
tests: Continue even if device reset fails

This may provide better testing coverage by allowing temporary issues
during the test cycle to be ignored.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agotests: Add option to run test cases under valgrind/concurrent P2P
Jouni Malinen [Sat, 24 Aug 2013 17:33:21 +0000 (20:33 +0300)]
tests: Add option to run test cases under valgrind/concurrent P2P

./run-all.sh can now take an optional argument to select whether to run
all test cases as before (default), to run these under valgrind
("valgrind"), to run P2P test cases with concurrent station interface
("concurrent"), or the concurrent P2P test cases under valgrind
("concurrent-valgrind").

valgrind cases report errors if a test case fails or valgrind reports an
error.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agoMake global UNIX socket non-blocking for ctrl_iface
Jouni Malinen [Sat, 24 Aug 2013 17:31:04 +0000 (20:31 +0300)]
Make global UNIX socket non-blocking for ctrl_iface

This keeps wpa_supplicant from hanging forever if the other end of the
socket dies. This is similar to the earlier commit
4fdc8def8855ce9b90ffbbdc47152ce46ccdcb1e to make the global control
interface befave in the same way.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agotests: Use logger.info() instead of print to get one stream
Jouni Malinen [Sat, 24 Aug 2013 16:48:04 +0000 (19:48 +0300)]
tests: Use logger.info() instead of print to get one stream

print and logger.info() were directing output to different locations
(stdout and stderr, respectively) which resulted in buildbot showing
reordered entries. Use logger consistently to avoid that.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agotests: Check for exceptions during TEST-START/STOP
Jouni Malinen [Sat, 24 Aug 2013 16:41:08 +0000 (19:41 +0300)]
tests: Check for exceptions during TEST-START/STOP

It looks like the NOTE commands can time out in some cases. Avoid
stopping the test run in such a case to get more coverage if this is a
temporary issue.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agotests: Update concurrent P2P setup to match start.sh changes
Jouni Malinen [Sat, 24 Aug 2013 16:01:32 +0000 (19:01 +0300)]
tests: Update concurrent P2P setup to match start.sh changes

The design for launching AP mode interfaces was changed, but
start-p2p-concurrent.sh was not updated with matching changes.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agoChange WEP network selection to reject WPA/WPA2 APs
Jouni Malinen [Fri, 23 Aug 2013 16:27:25 +0000 (19:27 +0300)]
Change WEP network selection to reject WPA/WPA2 APs

Previously, wpa_supplicant behavior in WEP configuration was to try to
mimic a device that is not aware of WPA/WPA2 and as such, it tried to
connect to a WPA/WPA2 AP with the assumption that the AP could be
providing support for both WEP and WPA/WPA2 stations in the same BSS.
Such APs could have been used during transition from WEP to more secure
options, but that type of deployment have not been used in large number
and are not really of much use anymore taken into account that more or
less all new devices support WPA/WPA2. That combined with the preference
to deprecate WEP justifies removing this use case and making WEP
networking matching more strict by using the knowledge of AP advertising
WPA/WPA2 as an indication of WEP not being supported.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

10 years agoWPS: Fix failure path to allow WSC_NACK and EAP-Failure to be exchanged
Jouni Malinen [Fri, 23 Aug 2013 14:43:01 +0000 (17:43 +0300)]
WPS: Fix failure path to allow WSC_NACK and EAP-Failure to be exchanged

Commit c7a67a77195464d667d6f482777a75325b6f3642 forced disconnection
when wpas_clear_wps() is called. Call this function from a registered
timeout when processing a failure event in order to allow the WPS
handshake to be completed with WSC_NACK and EAP-Failure.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

10 years agoWPS: Add control interface command for fetching latest status
Jeffin Mammen [Fri, 23 Aug 2013 13:03:15 +0000 (16:03 +0300)]
WPS: Add control interface command for fetching latest status

The new wps_get_status command can be used to fetch the result of the
latest WPS operation and the current PBC state from hostapd.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

10 years agoWPS: Track peer MAC address from the last operations
Jeffin Mammen [Fri, 23 Aug 2013 13:01:55 +0000 (16:01 +0300)]
WPS: Track peer MAC address from the last operations

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

10 years agoWPS: Track PBC status
Jeffin Mammen [Fri, 23 Aug 2013 13:51:27 +0000 (16:51 +0300)]
WPS: Track PBC status

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

10 years agoWPS: Track result of the latest WPS operation
Jeffin Mammen [Fri, 23 Aug 2013 13:38:16 +0000 (16:38 +0300)]
WPS: Track result of the latest WPS operation

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

10 years agoWPS: Add PBC mode activated/disabled events
Jeffin Mammen [Fri, 23 Aug 2013 13:01:30 +0000 (16:01 +0300)]
WPS: Add PBC mode activated/disabled events

This makes it easier to track PBC state on the registrar.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

10 years agoWPS: Share a common function for error strings
Jouni Malinen [Wed, 31 Jul 2013 14:30:45 +0000 (17:30 +0300)]
WPS: Share a common function for error strings

This makes it easier to maintain the list of WPS_EI_* error values and
matching strings.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

10 years agonl80211: Update the assoc_freq during connect
Sunil Dutt [Fri, 23 Aug 2013 12:41:05 +0000 (15:41 +0300)]
nl80211: Update the assoc_freq during connect

drv->assoc_freq was not updated during the connect command (neither
during the command's invocation nor after getting the event) unlike with
auth/assoc case where assoc_freq is updated. This resulted in
nl80211_get_link_noise() (and any other function for that matter) using
the improper drv->assoc_freq value with drivers that use the connect
API. Fix this by updating drv->assoc_freq on connect command and when
fetching the frequency from the driver.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

10 years agonl80211: Add more debug prints for DEL_STATION commands
Jouni Malinen [Fri, 23 Aug 2013 09:03:28 +0000 (12:03 +0300)]
nl80211: Add more debug prints for DEL_STATION commands

This makes the debug log clearer on AP mode STA operations.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

10 years agoVLAN: Simplify no-WEP with VLAN check
Jouni Malinen [Wed, 7 Aug 2013 09:24:18 +0000 (12:24 +0300)]
VLAN: Simplify no-WEP with VLAN check

No need to have a local variable and two #ifndef blocks for this.

Signed-hostap: Jouni Malinen <j@w1.fi>

10 years agoWEP: Remove VLAN support from hostapd
Michael Braun [Wed, 7 Aug 2013 09:22:38 +0000 (12:22 +0300)]
WEP: Remove VLAN support from hostapd

This removes WEP with VLAN support and thus avoids increasing
complexity for tagged VLANs.

Signed-hostap: Michael Braun <michael-dev@fami-braun.de>

10 years agobsd: Add a commit routine
Rui Paulo [Wed, 7 Aug 2013 08:03:44 +0000 (11:03 +0300)]
bsd: Add a commit routine

Signed-hostap: Rui Paulo <rpaulo@FreeBSD.org>

10 years agobsd: Mark define sta_set_flags() only for hostapd
Rui Paulo [Wed, 7 Aug 2013 08:02:55 +0000 (11:02 +0300)]
bsd: Mark define sta_set_flags() only for hostapd

Signed-hostap: Rui Paulo <rpaulo@FreeBSD.org>

10 years agobsd: Mark the interface down before opening the routing socket
Rui Paulo [Wed, 7 Aug 2013 08:01:12 +0000 (11:01 +0300)]
bsd: Mark the interface down before opening the routing socket

Signed-hostap: Rui Paulo <rpaulo@FreeBSD.org>

10 years agobsd: Compute the RSSI level
Rui Paulo [Wed, 7 Aug 2013 07:57:51 +0000 (10:57 +0300)]
bsd: Compute the RSSI level

Signed-hostap: Rui Paulo <rpaulo@FreeBSD.org>

10 years agobsd: Set IEEE80211_KEY_NOREPLAY in IBSS/AHDEMO mode
Rui Paulo [Wed, 7 Aug 2013 07:57:10 +0000 (10:57 +0300)]
bsd: Set IEEE80211_KEY_NOREPLAY in IBSS/AHDEMO mode

Signed-hostap: Rui Paulo <rpaulo@FreeBSD.org>

10 years agobsd: Skip SIOCSIFFFLAGS ioctl when there is no change.
Rui Paulo [Wed, 7 Aug 2013 07:54:16 +0000 (10:54 +0300)]
bsd: Skip SIOCSIFFFLAGS ioctl when there is no change.

Don't issue SIOCSIFFLAGS if the interface is already up or already down.

Signed-hostap: Rui Paulo <rpaulo@FreeBSD.org>