mech_eap.git
13 years agowlantest: Add counters for AP deauth/disassoc while asleep/awake
Jouni Malinen [Fri, 7 Jan 2011 14:52:56 +0000 (16:52 +0200)]
wlantest: Add counters for AP deauth/disassoc while asleep/awake

These can be used to check whether the STA is in power save mode
and because of that, is not seeing disconnection notifications.

13 years agowlantest: Track station PS state
Jouni Malinen [Fri, 7 Jan 2011 13:54:58 +0000 (15:54 +0200)]
wlantest: Track station PS state

13 years agowlantest: Add more details for replay debug messages
Jouni Malinen [Fri, 7 Jan 2011 12:17:08 +0000 (14:17 +0200)]
wlantest: Add more details for replay debug messages

These make it easier to find the frame in question when looking at
the capture in Wireshark.

13 years agoWPS: Make WPS-AP-AVAILABLE* events a bit more consistent
Jouni Malinen [Wed, 5 Jan 2011 09:49:03 +0000 (11:49 +0200)]
WPS: Make WPS-AP-AVAILABLE* events a bit more consistent

The BSS table entries may be in more or less random order and it is
better to show the most likely WPS configuration method in a way that is
somewhat more consistent instead of just showing the method of the first
BSS entry found in the table.

13 years agowlantest: Skip frames inserted by wlantest when reading pcap file
Jouni Malinen [Wed, 5 Jan 2011 08:41:51 +0000 (10:41 +0200)]
wlantest: Skip frames inserted by wlantest when reading pcap file

This makes debug output clearer when re-reading a file that has
previously been processed and decrypted by wlantest.

13 years agowlantest: Count number of STA ACK'ed Deauth/Disassoc frames
Jouni Malinen [Mon, 3 Jan 2011 17:28:40 +0000 (19:28 +0200)]
wlantest: Count number of STA ACK'ed Deauth/Disassoc frames

13 years agowlantest: Add ping_ok_first_assoc STA counter
Jouni Malinen [Mon, 3 Jan 2011 14:54:14 +0000 (16:54 +0200)]
wlantest: Add ping_ok_first_assoc STA counter

This can be used to verify whether ping goes through between
clearing of the STA counters and the first (re)association.

13 years agoFix wpa_supplicant_ssid_bss_match() handler for non-WPA
Jouni Malinen [Thu, 30 Dec 2010 16:27:33 +0000 (18:27 +0200)]
Fix wpa_supplicant_ssid_bss_match() handler for non-WPA

The proto configuration may be left to non-zero when moving from one
configuration to another. To avoid misidentifying a network
configuration as enabling WPA, check key_mgmt field, too.

13 years agoatheros: Rename "madwifi_" prefix to "atheros_"
Shan Palanisamy [Mon, 20 Dec 2010 10:35:57 +0000 (12:35 +0200)]
atheros: Rename "madwifi_" prefix to "atheros_"

13 years agobsd: Fix receive buffer alignment issue
Yi Zhu [Thu, 9 Dec 2010 19:30:20 +0000 (11:30 -0800)]
bsd: Fix receive buffer alignment issue

wpa_supplicant seems to crash from time to time on a NetBSD 4.0 MIPS
platform. The root cause turned out to be a MIPS alignment issue.

In my wpa_supplicant crash case, in function
wpa_driver_bsd_event_receive (from driver_bsd.c), the buf[2048] address
is started from i.e. 0x7fffd546, which is not 4 bytes aligned. Later
when it is casted to (struct if_msghdr *), and rtm->rtm_flags is used.
rtm->rtm_flags is "int" type, but its address is not 4 bytes aligned.
This is because the start address of rtm is not 4 bytes aligned.
Unfortunately in NetBSD MIPS kernel (unlike Linux MIPS kernel emulates
unaligned access in its exception handler), the default behavior is to
generate a memory fault to the application that accesses unaligned
memory address. Thus comes the early mentioned wpa_supplicant crash. An
interesting note is when I'm using the wpa_supplicant version 0.4.9, I
never saw this problem. Maybe the stack layout is different. But I
didn't look into details.

I used below patch to resolve this problem. Now it runs correctly for at
least several hours. But you might have a better fix (maybe we can use
malloc/free so that it is at least cache line aligned?). I'm also not
sure if other drivers should have the same problem.

13 years agoFix driver_bsd.c compile error
Yi Zhu [Thu, 9 Dec 2010 19:29:26 +0000 (11:29 -0800)]
Fix driver_bsd.c compile error

I got an error for WPA_KEY_RSC_LEN is not defined when compiling the
driver_bsd.c on NetBSD 4.0. Below patch fixed it.

13 years agoP2P: Add initial support for driver-based P2P management
Jouni Malinen [Thu, 30 Dec 2010 10:48:55 +0000 (12:48 +0200)]
P2P: Add initial support for driver-based P2P management

This adds partial callbacks and events to allow P2P management to be
implemented in a driver/firmware. This is not yet complete and is
very much subject to change in the future.

13 years agoWPS: Add option to disable open networks by default
Jouni Malinen [Wed, 22 Dec 2010 09:33:59 +0000 (11:33 +0200)]
WPS: Add option to disable open networks by default

CONFIG_WPS_REG_DISABLE_OPEN=y can be used to configure wpa_supplicant
to disable open networks by default when wps_reg command is used to
learn the current AP settings. When this is enabled, there will be a
WPS-OPEN-NETWORK ctrl_iface event and the user will need to explicitly
enable the network (e.g., with "select_network <id>") to connect to
the open network.

13 years agonl80211: Use driver-based off-channel TX if available
Johannes Berg [Wed, 29 Dec 2010 12:05:34 +0000 (14:05 +0200)]
nl80211: Use driver-based off-channel TX if available

If the underlying driver supports off-channel TX, it will now be used by
the nl80211 driver wrapper, setting WPA_DRIVER_FLAGS_OFFCHANNEL_TX
accordingly.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
13 years agoP2P: Add option for offloading off-channel TX to the driver
Johannes Berg [Wed, 29 Dec 2010 11:59:17 +0000 (13:59 +0200)]
P2P: Add option for offloading off-channel TX to the driver

With the new kernel functionality coming to Linux to allow off-channel
TX, we can take advantage of that in the P2P code that currently uses
remain-on-channel. If a driver advertises support for it, it will be
asked to handle off-channel TX by itself.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
13 years agoAllow AP mode to disconnect STAs based on low ACK condition
Johannes Berg [Tue, 28 Dec 2010 15:15:01 +0000 (17:15 +0200)]
Allow AP mode to disconnect STAs based on low ACK condition

The nl80211 driver can report low ACK condition (in fact it reports
complete loss right now only). Use that, along with a config option, to
disconnect stations when the data connection is not working properly,
e.g., due to the STA having went outside the range of the AP. This is
disabled by default and can be enabled with disassoc_low_ack=1 in
hostapd or wpa_supplicant configuration file.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
13 years agoRe-initialize EAP ClientTimeout on for each session
Jouni Malinen [Tue, 28 Dec 2010 10:09:14 +0000 (12:09 +0200)]
Re-initialize EAP ClientTimeout on for each session

ClientTimeout changes from EAP peer methods were not supposed to
change behavior for other EAP peer methods or even other sessions
of the same method. Re-initialize ClientTimeout whenever an EAP
peer method is initialized to avoid this. This addresses problems
where WPS (EAP-WSC) reduces the timeout and consecutive EAP runs
may fail due to too small timeout.

13 years agoP2P: Limit the retransmission of GO Negotiation request to 120
Fabien Marotte [Tue, 28 Dec 2010 09:48:58 +0000 (11:48 +0200)]
P2P: Limit the retransmission of GO Negotiation request to 120

If the peer you want to connect to is no longer available (does not
acknowledge frames) when wpa_supplicant sends GO Negotition Request
frames, retransmission of this frame is done until the associated
p2p_device  structure is removed on timeout. In that case, no signal
is emitted to  inform the GO Negotiation has failed.

When sending an Invitation Request frame, the same retransmission
mechanism is in place but limit the transmission to 100 and hitting
the limit generates an event.

This patch adds the same mechanism as the one in place for Invitation
Request, but with limit of 120 to match the existing wait_count for
for GO Negotiation.

13 years agoWPS: Require PBC match with wps_pbc that specifies BSSID
Jouni Malinen [Tue, 28 Dec 2010 06:56:23 +0000 (08:56 +0200)]
WPS: Require PBC match with wps_pbc that specifies BSSID

The WPS mode was already verified when the AP was configured for
WPA/WPA2, but this was not done with AP that was in open mode.
Fix this by allowing wpa_supplicant_ssid_bss_match() to be called
in non-WPA configuration, too. With this change, wps_pbc BSSID
command will wait until the specified target AP is in active PBC
mode before trying to connect to it.

13 years agowlantest: Add more debug output for frame injection failures
Jouni Malinen [Tue, 21 Dec 2010 10:48:53 +0000 (12:48 +0200)]
wlantest: Add more debug output for frame injection failures

13 years agowlantest: Fix management frame injection
Jouni Malinen [Tue, 21 Dec 2010 10:48:03 +0000 (12:48 +0200)]
wlantest: Fix management frame injection

The TDLS special case was supposed to apply to only Data frames.

13 years agoWPS: Include all Config Methods in Probe Request
Jouni Malinen [Mon, 20 Dec 2010 10:54:10 +0000 (12:54 +0200)]
WPS: Include all Config Methods in Probe Request

Do not use active PBC state to figure out which ConfigMethods are
included in Probe Request; instead, include all supported ones.

13 years agoFix CONFIG_SME build without CONFIG_IEEE80211W
Jouni Malinen [Sun, 19 Dec 2010 10:44:58 +0000 (12:44 +0200)]
Fix CONFIG_SME build without CONFIG_IEEE80211W

13 years agonl80211: Remove extra \n from debug messages
Jouni Malinen [Sun, 19 Dec 2010 10:00:24 +0000 (12:00 +0200)]
nl80211: Remove extra \n from debug messages

13 years agoUse SA Query procedure to recovery from AP/STA state mismatch
Jouni Malinen [Sun, 19 Dec 2010 09:58:00 +0000 (11:58 +0200)]
Use SA Query procedure to recovery from AP/STA state mismatch

If a station received unprotected Deauthentication or Disassociation
frame with reason code 6 or 7 from the current AP, there may be a
mismatch in association state between the AP and STA. Verify whether
this is the case by using SA Query procedure. If not response is
received from the AP, deauthenticate.

This implementation is only for user space SME with
driver_nl80211.c.

13 years agoP2P: Allow access to group members
Johannes Berg [Fri, 17 Dec 2010 16:34:16 +0000 (18:34 +0200)]
P2P: Allow access to group members

Some new code will require access to P2P group members, so add API to
retrieve the number of members and iterate the members themselves.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
13 years agoP2P: Fix some int size warnings
Johannes Berg [Fri, 17 Dec 2010 15:09:50 +0000 (17:09 +0200)]
P2P: Fix some int size warnings

When u64 != unsigned long, the compiler will give
some warnings. Fix these.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
13 years agodbus: Emit property changed events when adding/removing BSSes
Dan Williams [Fri, 17 Dec 2010 13:56:01 +0000 (15:56 +0200)]
dbus: Emit property changed events when adding/removing BSSes

The supplicant was not emitting property changed events when the BSSs
property changed.

Signed-off-by: Dan Williams <dcbw@redhat.com>
13 years agoAllow setting scan_res_handler from the callback function
Johannes Berg [Fri, 17 Dec 2010 13:31:05 +0000 (15:31 +0200)]
Allow setting scan_res_handler from the callback function

Some new code I'm working on will need the scan_res_handler assigned all
the time in certain circumstances, so the easiest way is to reset it
within the handler. This is currently prevented by the way the code in
the event handler works -- change that to permit such usage.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
13 years agodbus: Fix type in wpa_dbus_dict_begin_string_array
Johannes Berg [Fri, 17 Dec 2010 13:20:32 +0000 (15:20 +0200)]
dbus: Fix type in wpa_dbus_dict_begin_string_array

The array's type should be given as the proper
DBUS_TYPE_STRING_AS_STRING, but evidently it
doesn't matter since it's all packed into a
variant type.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
13 years agoP2P: Cancel group formation timeout on p2p_cancel
Sudhakar Swaminathan [Fri, 17 Dec 2010 13:06:48 +0000 (15:06 +0200)]
P2P: Cancel group formation timeout on p2p_cancel

13 years agoP2P: Unauthorize pending P2P GO Neg peer on p2p_cancel
Sudhakar Swaminathan [Fri, 17 Dec 2010 13:05:35 +0000 (15:05 +0200)]
P2P: Unauthorize pending P2P GO Neg peer on p2p_cancel

If there is a pending GO Negotiation when p2p_cancel is used,
unauthorize the peer to avoid immediate reconnection from being
accepted without a new p2p_connect command.

13 years agoP2P: Cancel group formation on PBC overlap
Sudhakar Swaminathan [Fri, 17 Dec 2010 13:04:14 +0000 (15:04 +0200)]
P2P: Cancel group formation on PBC overlap

We should cancel group formation completely on PBC overlap instead
of just partially notifying that operations were stopped. There is
no point in waiting for the group formation timeout in this case.

13 years agoP2P: Fix wpa_cli help typo
Masashi Honma [Fri, 17 Dec 2010 13:01:28 +0000 (15:01 +0200)]
P2P: Fix wpa_cli help typo

13 years agonl80211: Stop driver init sooner if the interface does not exist
Masashi Honma [Fri, 17 Dec 2010 11:55:13 +0000 (13:55 +0200)]
nl80211: Stop driver init sooner if the interface does not exist

13 years agonl80211: Add forgotten deinit code on failure path
Jouni Malinen [Fri, 17 Dec 2010 11:49:38 +0000 (13:49 +0200)]
nl80211: Add forgotten deinit code on failure path

13 years agonl80211: Sync definitions with wireless-testing.git
Jouni Malinen [Fri, 17 Dec 2010 11:07:32 +0000 (13:07 +0200)]
nl80211: Sync definitions with wireless-testing.git

13 years agowlantest: Fix buffer read overflow on CCMP encryption
Jouni Malinen [Fri, 17 Dec 2010 09:02:56 +0000 (11:02 +0200)]
wlantest: Fix buffer read overflow on CCMP encryption

The encryption code may write a full AES block to the end of the
buffer, so make sure the temporary buffer is long enough to fit that
data.

13 years agowlantest: Fix error path in TDLS-not-found case
Jouni Malinen [Fri, 17 Dec 2010 06:26:39 +0000 (08:26 +0200)]
wlantest: Fix error path in TDLS-not-found case

13 years agowlantest: Avoid aliasing a function parameter by renaming local variable
Jouni Malinen [Fri, 17 Dec 2010 06:22:07 +0000 (08:22 +0200)]
wlantest: Avoid aliasing a function parameter by renaming local variable

13 years agowlantest: Remove unnecessary validation code
Jouni Malinen [Fri, 17 Dec 2010 06:16:12 +0000 (08:16 +0200)]
wlantest: Remove unnecessary validation code

This condition is already checked above when figuring out whether a key
is known and as such, there is no point in keeping this check here.

13 years agowlantest: Replace pcap header directory
Jouni Malinen [Fri, 17 Dec 2010 06:06:52 +0000 (08:06 +0200)]
wlantest: Replace pcap header directory

The use of the pcap subdirectory seems to be limited to some of the
newer Linux distros only, so use the older paths to pcap.h and
pcap-bpf.h to make wlantest bit more easier to compile on older
systems.

13 years agowlantest: Add counters and AP/direct path validation for TDLS
Jouni Malinen [Thu, 16 Dec 2010 17:08:49 +0000 (19:08 +0200)]
wlantest: Add counters and AP/direct path validation for TDLS

These can be used to write automated test scripts for verifying
that TDLS STAs are using correct data path.

13 years agowlantest: Check FTIE MIC in TDLS Teardown messages
Jouni Malinen [Thu, 16 Dec 2010 15:08:00 +0000 (17:08 +0200)]
wlantest: Check FTIE MIC in TDLS Teardown messages

13 years agowlantest: Add send command for injecting raw frames
Jouni Malinen [Thu, 16 Dec 2010 14:11:54 +0000 (16:11 +0200)]
wlantest: Add send command for injecting raw frames

This can be used by external programs (e.g., wlantest_cli) to inject
raw frames (hex dump of the frame header and body). The data can be
requested to be sent as-is or protected with the current key.

13 years agoRemoved unused variable from non-Linux builds
Jouni Malinen [Tue, 14 Dec 2010 15:10:39 +0000 (17:10 +0200)]
Removed unused variable from non-Linux builds

13 years agonl80211: Set cipher suites when using user space SME
Jouni Malinen [Mon, 13 Dec 2010 19:08:53 +0000 (21:08 +0200)]
nl80211: Set cipher suites when using user space SME

Previously, pairwise and group cipher suites were configured only
when kernel SME (nl80211 connect API) was used. However, mac80211
needs this information even in the user space SME case for one
thing: to disable HT when TKIP/WEP is used. Add
NL80211_ATTR_CIPHER_SUITES_PAIRWISE to fix this special case with
user space SME. This allows mac80211 to disable HT properly when
the AP is configured with configuration that is not allowed.

13 years agowlantest: Add support for decrypting TDLS frames
Jouni Malinen [Mon, 13 Dec 2010 09:20:55 +0000 (11:20 +0200)]
wlantest: Add support for decrypting TDLS frames

Derive TPK based on TDLS TPK Handshake and decrypt frames on the
direct link with TPK-TK.

13 years agoRSN IBSS: RX GTK configuration with nl80211
Jouni Malinen [Sun, 5 Dec 2010 04:31:22 +0000 (20:31 -0800)]
RSN IBSS: RX GTK configuration with nl80211

This add preliminary code for setting the per-STA RX GTK for
RSN IBSS when nl80211 drivers. For some reason, this does not
seem to fully work, but at least driver_nl80211.c is now aware of
what kind of key is being set and the whatever is missing from
making this key configuration go through should be specific to
nl80211/cfg80211.

13 years agonl80211: Generate EVENT_IBSS_RSN_START events
Jouni Malinen [Sun, 5 Dec 2010 02:17:58 +0000 (18:17 -0800)]
nl80211: Generate EVENT_IBSS_RSN_START events

This is needed to trigger start of 4-way handshake when a new STA is
detected in an RSN IBSS.

13 years agoIBSS RSN: Do not start 4-way handshake unless RSN is enabled
Jouni Malinen [Sun, 5 Dec 2010 02:17:05 +0000 (18:17 -0800)]
IBSS RSN: Do not start 4-way handshake unless RSN is enabled

13 years agoDo not send Deauth/Disassoc to unknown STA if SA is invalid
Jouni Malinen [Sun, 5 Dec 2010 01:40:36 +0000 (17:40 -0800)]
Do not send Deauth/Disassoc to unknown STA if SA is invalid

The frame needs to be sent from an individual (non-group) address,
so drop invalid frames before sending Deauth/Disassoc frames to
not associated STAs.

13 years agodbus_new_handlers: Omit errant dbus_message_unref
Paul Stewart [Sat, 4 Dec 2010 19:58:44 +0000 (11:58 -0800)]
dbus_new_handlers: Omit errant dbus_message_unref

This unref is guaranteed to be freeing a NULL pointer.

Tested manually: use dbus-send to send an invalid debug level parameter

Before change:

$ dbus-send --system --dest=fi.w1.wpa_supplicant1 --print-reply
/fi/w1/wpa_supplicant1 org.freedesktop.DBus.Properties.Set
string:fi.w1.wpa_supplicant1 string:DebugLevel variant:string:msgdumpf
Error org.freedesktop.DBus.Error.NoReply: Message did not receive a reply
(timeout by message bus)
(and then wpa_supplicant crashes)

After change:

$ dbus-send --system --dest=fi.w1.wpa_supplicant1 --print-reply
/fi/w1/wpa_supplicant1 org.freedesktop.DBus.Properties.Set
string:fi.w1.wpa_supplicant1 string:DebugLevel variant:string:msgdumpf
Error fi.w1.wpa_supplicant1.InvalidArgs: Did not receive correct message
arguments.

Signed-off-by: Paul Stewart <pstew@google.com>
13 years agoFix EAP-FAST PAC file writer to avoid crash with multiple PACs
Jouni Malinen [Sat, 4 Dec 2010 19:37:41 +0000 (11:37 -0800)]
Fix EAP-FAST PAC file writer to avoid crash with multiple PACs

One of the pointers to the PAC buffer was not updated after realloc
and if the realloc ended up returning new pointer, the *pos pointer
was still pointing at the old location (i.e., freed memory at
this point).

13 years agowlantest: Add support for reading DLT_IEEE802_11 pcap files
Jouni Malinen [Sat, 4 Dec 2010 19:18:21 +0000 (11:18 -0800)]
wlantest: Add support for reading DLT_IEEE802_11 pcap files

13 years agowlantest: Add support for reading pcap files with prism header
Jouni Malinen [Thu, 2 Dec 2010 20:56:37 +0000 (12:56 -0800)]
wlantest: Add support for reading pcap files with prism header

13 years agonl80211: Fix compiler warnings on non-P2P build
Jouni Malinen [Sat, 27 Nov 2010 11:05:37 +0000 (13:05 +0200)]
nl80211: Fix compiler warnings on non-P2P build

13 years agoEnable sharing of scan result events among virtual interfaces
Ben Greear [Fri, 26 Nov 2010 19:46:30 +0000 (21:46 +0200)]
Enable sharing of scan result events among virtual interfaces

When controlling multiple virtual interfaces on the same physical
radio, share the scan results events with sibling interfaces. This
decreases the time it takes to connect many virtual interfaces.

This is currently only supported on Linux with cfg80211-based
drivers when using nl80211 or wext driver interface.

Signed-off-by: Ben Greear <greearb@candelatech.com>
13 years agoAdd interface name to some debug prints
Ben Greear [Fri, 26 Nov 2010 19:16:36 +0000 (21:16 +0200)]
Add interface name to some debug prints

This makes it easier to figure out what is happening when controlling
multiple interfaces from a single wpa_supplicant process.

13 years agodbus: Fix new dbus API for WPS
Tomasz Bursztyka [Fri, 26 Nov 2010 17:47:24 +0000 (19:47 +0200)]
dbus: Fix new dbus API for WPS

Start() method's optional Bssid argument needs a byte array, not an
array of arrays.

13 years agonl80211: Track used interfaces and support multiple P2P groups
Jouni Malinen [Fri, 26 Nov 2010 16:14:51 +0000 (18:14 +0200)]
nl80211: Track used interfaces and support multiple P2P groups

Track all the P2P group interfaces within driver_nl80211.c to make
it easier to generate unique P2P Interface Addresses.

13 years agoAllow driver wrappers to indicate whether result codes are sane
Jouni Malinen [Fri, 26 Nov 2010 15:41:21 +0000 (17:41 +0200)]
Allow driver wrappers to indicate whether result codes are sane

Some drivers are not providing exactly reliable error codes (e.g.,
with WEXT), but others may actually indicate reliable information.
Allow driver wrappers to indicate if that is the case and use
optimizations if so. For now, this improves nl80211 with
NL80211_CMD_CONNECT for a case where connection request fails.

13 years agonl80211: Add BSSID to NL80211_CMD_CONNECT assoc reject event
Jouni Malinen [Fri, 26 Nov 2010 15:40:10 +0000 (17:40 +0200)]
nl80211: Add BSSID to NL80211_CMD_CONNECT assoc reject event

13 years agonl80211: Fix NL80211_CMD_CONNECT with WPA/WPS networks
Jouni Malinen [Fri, 26 Nov 2010 15:39:31 +0000 (17:39 +0200)]
nl80211: Fix NL80211_CMD_CONNECT with WPA/WPS networks

13 years agoDo not segfault on EVENT_ASSOC_REJECT without BSSID
Jouni Malinen [Fri, 26 Nov 2010 15:38:46 +0000 (17:38 +0200)]
Do not segfault on EVENT_ASSOC_REJECT without BSSID

13 years agoSME: Optimize recovery from assocication command failures
Jouni Malinen [Fri, 26 Nov 2010 15:37:22 +0000 (17:37 +0200)]
SME: Optimize recovery from assocication command failures

mac80211 can indicate this mainly because of channel selection
conflicts with other vifs. If there is another BSS on another
channel, we should try to connect to it instead.

13 years agonl80211: Add preliminary code for testing separate P2P group interface
Jouni Malinen [Fri, 26 Nov 2010 13:54:53 +0000 (15:54 +0200)]
nl80211: Add preliminary code for testing separate P2P group interface

driver_param=use_p2p_group_interface=1 can now be used to test
nl80211-drivers with separate P2P group interface. In other words,
the main interface (e.g., wlan0) is reserved for P2P management
operations and non-P2P connections and a new group interface (e.g.,
p2p-wlan0-0) is created for the P2P group.

This implementation is very minimal, i.e., it only support address
allocation for a single P2P group interface (if the driver does not
handle this internally). In addition, not all functionality has yet
been tested, so for now, this is disabled by default and needs that
special driver_param to enable.

13 years agoP2P: Add new driver option for interface allocation
Jouni Malinen [Fri, 26 Nov 2010 13:52:16 +0000 (15:52 +0200)]
P2P: Add new driver option for interface allocation

WPA_DRIVER_FLAGS_P2P_MGMT_AND_NON_P2P flag can now be used to
indicate that the initial interface (e.g., wlan0) is used for
P2P management operations and potentially non-P2P connections.
This is otherwise identical to
WPA_DRIVER_FLAGS_P2P_DEDICATED_INTERFACE, but the possibility of
non-P2P connections makes some operations differ.

13 years agoP2P: Rename the group interface name to use p2p- prefix
Jouni Malinen [Fri, 26 Nov 2010 13:50:22 +0000 (15:50 +0200)]
P2P: Rename the group interface name to use p2p- prefix

This may make it less likely for udev to rename the interface that
would previously have been called wlan0-p2p-# (now: p2p-wlan0-#).
In addition, add some workaround code to handle the case where the
main interface name is close to the IFNAMSIZ length limit to
avoid going over that for the P2P group interface.

13 years agoP2P: Use larger pending_interface_name buffer
Jouni Malinen [Fri, 26 Nov 2010 13:49:26 +0000 (15:49 +0200)]
P2P: Use larger pending_interface_name buffer

In theory, the interface name could be longer than IFNAMSIZ in
some systems, so use the same size buffer for this field as is
used with the main interface name.

13 years agoP2P: Use alternative way of starting dnsmasq if needed
Jouni Malinen [Fri, 26 Nov 2010 13:47:13 +0000 (15:47 +0200)]
P2P: Use alternative way of starting dnsmasq if needed

Some other dnsmasq users (like libvirt) seem to be binding the DHCP
server to all interfaces which prevents the previously used mechanism
here from working (bind on the DHCP socket fails). If a failure is
noticed, try to start dnsmasq with -z option to avoid that.

13 years agoExtend load balancing optimization in BSS blacklisting
Jouni Malinen [Fri, 26 Nov 2010 09:36:03 +0000 (11:36 +0200)]
Extend load balancing optimization in BSS blacklisting

Move the previously SME specific optimization code into generic
function that can be used from non-SME code, too, and use it to
handle disconnection events. In other words, allow disconnection
event to trigger similar optimized scanning case to handle a
common load balancing mechanism. If there is another BSS in the
same ESS when we receive a disconnection event, scan only the
known frequencies of such other BSSes on the next attempt to
speed up recovery.

13 years agoBlacklist BSS on first failure if only a single network is enabled
Jouni Malinen [Fri, 26 Nov 2010 09:23:50 +0000 (11:23 +0200)]
Blacklist BSS on first failure if only a single network is enabled

The special case of requiring blacklisting count to be 2 or higher
is only needed when more than a single network is currently enabled.
As such, we should not do that when only a single network is enabled.
This make the station more likely to follow network side load
balancing attempts where the current AP may disassociate us with
an assumption that we would move to another AP.

13 years agoFix CONFIG_AP=y build without NEED_AP_MLME driver
Jouni Malinen [Thu, 25 Nov 2010 21:41:32 +0000 (23:41 +0200)]
Fix CONFIG_AP=y build without NEED_AP_MLME driver

13 years agoFix CONFIG_AP=y build without CONFIG_WPS=y
Jouni Malinen [Thu, 25 Nov 2010 21:34:56 +0000 (23:34 +0200)]
Fix CONFIG_AP=y build without CONFIG_WPS=y

13 years agorandom: Fix a compiler warning about unused variable
Jouni Malinen [Thu, 25 Nov 2010 21:32:17 +0000 (23:32 +0200)]
random: Fix a compiler warning about unused variable

In CONFIG_NO_STDOUT_DEBUG=y case, the error variable was not used.

13 years agoSME: Optimize recovery from common load balancing mechanisms
Jouni Malinen [Thu, 25 Nov 2010 20:51:56 +0000 (22:51 +0200)]
SME: Optimize recovery from common load balancing mechanisms

When authentication or association fails when trying to connect to
a BSS in an ESS that has multiple BSSes based on previous scans,
limit the first recovery scan to only the known channels that has
been seen previously. This speeds up recovery in some of the most
commonly used load balancing mechanisms in enterprise WLAN
networks.

13 years agoSME: Fix re-try after auth/assoc timeout/failure
Jouni Malinen [Thu, 25 Nov 2010 20:00:04 +0000 (22:00 +0200)]
SME: Fix re-try after auth/assoc timeout/failure

There were various issues in how the SME (i.e., nl80211-based driver
interface) handled various authentication and association timeouts and
failures. Authentication failure was not handled at all (wpa_supplicant
just stopped trying to connect completely), authentication timeout
resulted in blacklisting not working in the expected way (i.e., the same
BSS could be selected continuously), and association cases had similar
problems.

Use a common function to handle all these cases and fix the blacklist
operation. Use smaller delay before trying to scan again during the
initial cycle through the available APs to speed up connection. Add
a special case for another-BSS-in-the-same-ESS being present to
speed up recovery from networks with multiple APs doing load balancing
in various odd ways that are deployed out there.

13 years agoP2P: Fix Action frame sending after disconnection
Jouni Malinen [Thu, 25 Nov 2010 14:04:07 +0000 (16:04 +0200)]
P2P: Fix Action frame sending after disconnection

assoc_freq needs to be cleared when an interface gets disconnected.
This fixes an issue where P2P Action frame transmission may fail
because of missing remain-on-channel operation when using the same
interface for group operations (or non-P2P connections) and P2P
management operations.

13 years agoP2P: Add p2p_unauthorize command
Sudhakar Swaminathan [Thu, 25 Nov 2010 11:09:50 +0000 (13:09 +0200)]
P2P: Add p2p_unauthorize command

This can be used to remove authorization from a previous p2p_connect
commands that has not yet resulted in completed GO Negotiation.

13 years agoConvert most commonly used drv ops to real function calls
Jouni Malinen [Wed, 24 Nov 2010 15:01:21 +0000 (17:01 +0200)]
Convert most commonly used drv ops to real function calls

Getting rid of these inline functions seems to reduce the code size
quite a bit, so convert the most commonly used hostapd driver ops to
function calls.

13 years agoFix CONFIG_AP=y build without CONFIG_P2P=y
Jouni Malinen [Wed, 24 Nov 2010 14:55:17 +0000 (16:55 +0200)]
Fix CONFIG_AP=y build without CONFIG_P2P=y

13 years agoFix wpa_supplicant AP mode build after hostapd changes
Jouni Malinen [Wed, 24 Nov 2010 14:52:04 +0000 (16:52 +0200)]
Fix wpa_supplicant AP mode build after hostapd changes

13 years agoGet rid of struct hostapd_driver_ops abstraction
Jouni Malinen [Wed, 24 Nov 2010 14:50:06 +0000 (16:50 +0200)]
Get rid of struct hostapd_driver_ops abstraction

This is not needed anymore and just makes things more difficult
to understand, so move the remaining function pointers to direct
function calls and get rid of the struct hostapd_driver_ops.

13 years agohostapd_driver_ops reduction
Jouni Malinen [Wed, 24 Nov 2010 14:34:49 +0000 (16:34 +0200)]
hostapd_driver_ops reduction

send_eapol, set_key, read_sta_data, sta_clear_stats,
set_radius_acl_auth, set_radius_acl_expire, and set_beacon
to use inline functions instead of extra abstraction.

13 years agohostapd_driver_ops reduction
Jouni Malinen [Wed, 24 Nov 2010 13:36:02 +0000 (15:36 +0200)]
hostapd_driver_ops reduction

set_sta_vlan, get_inact_sec, sta_deauth, sta_disassoc, and sta_remove
to use inline functions instead of extra abstraction.

13 years agohostapd_driver_ops reduction: set_countermeasures
Jouni Malinen [Wed, 24 Nov 2010 13:26:44 +0000 (15:26 +0200)]
hostapd_driver_ops reduction: set_countermeasures

13 years agohostapd: Start removing struct hostapd_driver_ops abstraction
Jouni Malinen [Wed, 24 Nov 2010 13:19:50 +0000 (15:19 +0200)]
hostapd: Start removing struct hostapd_driver_ops abstraction

Commit bf65bc638fe438b96f2986580ad167d5e276ef4c started the path to
add this new abstraction for driver operations in AP mode to allow
wpa_supplicant to control AP mode operations. At that point, the
extra abstraction was needed, but it is not needed anymore since
hostapd and wpa_supplicant share the same struct wpa_driver_ops.

Start removing the unneeded abstraction by converting
send_mgmt_frame() to an inline function, hostapd_drv_send_mlme().
This is similar to the design that is used in wpa_supplicant and
that was used in hostapd in the past (hostapd_send_mgmt_frame()
inline function).

13 years agol2_packet: Use wpa_printf() instead of perror()
Jouni Malinen [Wed, 24 Nov 2010 13:00:22 +0000 (15:00 +0200)]
l2_packet: Use wpa_printf() instead of perror()

13 years agonl80211: Fix send commands to return 0 on success
Jouni Malinen [Wed, 24 Nov 2010 12:58:58 +0000 (14:58 +0200)]
nl80211: Fix send commands to return 0 on success

driver.h defines these functions to return 0 on success, not
number of bytes transmitted. Most callers are checking "< 0" for
error condition, but not all. Address this by following the driver
API specification on 0 meaning success.

13 years agoP2P: Fix RX ack status on Action frames sent via interface in GO mode
Albert Liu [Wed, 24 Nov 2010 12:25:33 +0000 (14:25 +0200)]
P2P: Fix RX ack status on Action frames sent via interface in GO mode

The wpa_supplicant_event() EVENT_TX_STATUS ack field needs to be
converted to use wpas_send_action_tx_status()
enum p2p_send_action_result in this case, too, to avoid getting
incorrect TX status for P2P processing.

13 years agohostapd: Verify availability of random data when using WPA/WPA2
Jouni Malinen [Wed, 24 Nov 2010 11:08:03 +0000 (13:08 +0200)]
hostapd: Verify availability of random data when using WPA/WPA2

On Linux, verify that the kernel entropy pool is capable of providing
strong random data before allowing WPA/WPA2 connection to be
established. If 20 bytes of data cannot be read from /dev/random,
force first two 4-way handshakes to fail while collecting entropy
into the internal pool in hostapd. After that, give up on /dev/random
and allow the AP to function based on the combination of /dev/urandom
and whatever data has been collected into the internal entropy pool.

13 years agoFix memory leak on EAPOL Authenticator error path
Masashi Honma [Tue, 23 Nov 2010 23:42:50 +0000 (01:42 +0200)]
Fix memory leak on EAPOL Authenticator error path

wlan0: RADIUS No authentication server configured
MEMLEAK[0x999feb8]: len 1040
WPA_TRACE: memleak - START
[3]: ./hostapd(radius_msg_new+0x33) [0x8074f43]
     radius_msg_new() ../src/radius/radius.c:117
[4]: ./hostapd() [0x806095e]
     ieee802_1x_encapsulate_radius() ../src/ap/ieee802_1x.c:439
     ieee802_1x_aaa_send() ../src/ap/ieee802_1x.c:1496

For example, this error occured when I used WPS hostapd without
"eap_server=1" definition in configuration file.

13 years agoMaintain internal entropy pool for augmenting random number generation
Jouni Malinen [Tue, 23 Nov 2010 23:29:40 +0000 (01:29 +0200)]
Maintain internal entropy pool for augmenting random number generation

By default, make hostapd and wpa_supplicant maintain an internal
entropy pool that is fed with following information:

hostapd:
- Probe Request frames (timing, RSSI)
- Association events (timing)
- SNonce from Supplicants

wpa_supplicant:
- Scan results (timing, signal/noise)
- Association events (timing)

The internal pool is used to augment the random numbers generated
with the OS mechanism (os_get_random()). While the internal
implementation is not expected to be very strong due to limited
amount of generic (non-platform specific) information to feed the
pool, this may strengthen key derivation on some devices that are
not configured to provide strong random numbers through
os_get_random() (e.g., /dev/urandom on Linux/BSD).

This new mechanism is not supposed to replace proper OS provided
random number generation mechanism. The OS mechanism needs to be
initialized properly (e.g., hw random number generator,
maintaining entropy pool over reboots, etc.) for any of the
security assumptions to hold.

If the os_get_random() is known to provide strong ramdom data (e.g., on
Linux/BSD, the board in question is known to have reliable source of
random data from /dev/urandom), the internal hostapd random pool can be
disabled. This will save some in binary size and CPU use. However, this
should only be considered for builds that are known to be used on
devices that meet the requirements described above. The internal pool
is disabled by adding CONFIG_NO_RANDOM_POOL=y to the .config file.

13 years agoFix hlr_auc_gw build with CONFIG_WPA_TRACE=y
Jouni Malinen [Tue, 23 Nov 2010 23:10:48 +0000 (01:10 +0200)]
Fix hlr_auc_gw build with CONFIG_WPA_TRACE=y

13 years agoAnnotate places depending on strong random numbers
Jouni Malinen [Tue, 23 Nov 2010 23:05:20 +0000 (01:05 +0200)]
Annotate places depending on strong random numbers

This commit adds a new wrapper, random_get_bytes(), that is currently
defined to use os_get_random() as is. The places using
random_get_bytes() depend on the returned value being strong random
number, i.e., something that is infeasible for external device to
figure out. These values are used either directly as a key or as
nonces/challenges that are used as input for key derivation or
authentication.

The remaining direct uses of os_get_random() do not need as strong
random numbers to function correctly.

13 years agoRe-initialize GMK and Key Counter on first station connection
Jouni Malinen [Tue, 23 Nov 2010 22:52:46 +0000 (00:52 +0200)]
Re-initialize GMK and Key Counter on first station connection

This adds more time for the system entropy pool to be filled before
requesting random data for generating the WPA/WPA2 encryption keys.
This can be helpful especially on embedded devices that do not have
hardware random number generator and may lack good sources of
randomness especially early in the bootup sequence when hostapd is
likely to be started.

GMK and Key Counter are still initialized once in the beginning to
match the RSN Authenticator state machine behavior and to make sure
that the driver does not transmit broadcast frames unencrypted.
However, both GMK (and GTK derived from it) and Key Counter will be
re-initialized when the first station connects and is about to
enter 4-way handshake.

13 years agowlantest: Update STA State based on broadcast Deauth/Disassoc
Jouni Malinen [Tue, 23 Nov 2010 12:37:21 +0000 (14:37 +0200)]
wlantest: Update STA State based on broadcast Deauth/Disassoc

13 years agowlantest: Implement IEEE 802.11 duplicate detection
Jouni Malinen [Tue, 23 Nov 2010 12:27:28 +0000 (14:27 +0200)]
wlantest: Implement IEEE 802.11 duplicate detection

This cleans up debug logs by avoiding incorrect entries on TKIP/CCMP
replays and some state changes.

13 years agowlantest: Show broadcast Deauth/Disassoc info in debug
Jouni Malinen [Tue, 23 Nov 2010 11:16:23 +0000 (13:16 +0200)]
wlantest: Show broadcast Deauth/Disassoc info in debug