[pkg-wpa-devel] r1326 - in /wpasupplicant/trunk: debian/ debian/config/ debian/patches/ src/ src/common/ src/crypto/ src/drivers/ src/eap_common/ src/eap_peer/ src/eap_server/ src/eapol_supp/ src/hlr_auc_gw/ src/l2_packet/ src/radius/ src/rsn_supp/ src/tls/ src/utils/ src/wps/ wpa_supplicant/ wpa_supplicant/tests/ wpa_supplicant/wpa_gui-qt4/

kelmo-guest at users.alioth.debian.org kelmo-guest at users.alioth.debian.org
Sun Feb 15 20:49:58 UTC 2009


Author: kelmo-guest
Date: Sun Feb 15 20:49:57 2009
New Revision: 1326

URL: http://svn.debian.org/wsvn/pkg-wpa/?sc=1&rev=1326
Log:
* New upstream release.
* Drop patches applied upstream:
  - 10_wpa_gui_qt4_wps_tab_cleanups.patch
  - 11_wpa_gui_qt4_qsession.patch
* Refresh debian/patches/04_append_mmd_to_default_cflags.patch to
  apply.
* Refresh all other patches to apply without offset.
* Activate CONFIG_DRIVER_NL80211 in debian/config/linux.
* Sync debian/config/linux with wpa_supplicant/defconfig.
* Add libnl-dev to build dependencies.
* Modify debian/wpasupplicant.postrm and debian/wpasupplicant.postinst
  to set -e in body of script rather than in shebang line as per
  pedantic lintian suggestion.
* Upload to unstable.
* Add copyright information for src/wps/wps* to debian/copyright.

Added:
    wpasupplicant/trunk/src/wps/httpread.c
      - copied unchanged from r1325, wpasupplicant/branches/upstream/current/src/wps/httpread.c
    wpasupplicant/trunk/src/wps/httpread.h
      - copied unchanged from r1325, wpasupplicant/branches/upstream/current/src/wps/httpread.h
    wpasupplicant/trunk/src/wps/wps_upnp.c
      - copied unchanged from r1325, wpasupplicant/branches/upstream/current/src/wps/wps_upnp.c
    wpasupplicant/trunk/src/wps/wps_upnp.h
      - copied unchanged from r1325, wpasupplicant/branches/upstream/current/src/wps/wps_upnp.h
    wpasupplicant/trunk/src/wps/wps_upnp_event.c
      - copied unchanged from r1325, wpasupplicant/branches/upstream/current/src/wps/wps_upnp_event.c
    wpasupplicant/trunk/src/wps/wps_upnp_i.h
      - copied unchanged from r1325, wpasupplicant/branches/upstream/current/src/wps/wps_upnp_i.h
    wpasupplicant/trunk/src/wps/wps_upnp_ssdp.c
      - copied unchanged from r1325, wpasupplicant/branches/upstream/current/src/wps/wps_upnp_ssdp.c
    wpasupplicant/trunk/src/wps/wps_upnp_web.c
      - copied unchanged from r1325, wpasupplicant/branches/upstream/current/src/wps/wps_upnp_web.c
Removed:
    wpasupplicant/trunk/debian/patches/10_wpa_gui_qt4_wps_tab_cleanups.patch
    wpasupplicant/trunk/debian/patches/11_wpa_gui_qt4_qsession.patch
Modified:
    wpasupplicant/trunk/debian/changelog
    wpasupplicant/trunk/debian/config/linux
    wpasupplicant/trunk/debian/control
    wpasupplicant/trunk/debian/copyright
    wpasupplicant/trunk/debian/patches/01_use_pkg-config_for_pcsc-lite_module.patch
    wpasupplicant/trunk/debian/patches/04_append_mmd_to_default_cflags.patch
    wpasupplicant/trunk/debian/patches/05_qmake_version_makefile.patch
    wpasupplicant/trunk/debian/patches/series
    wpasupplicant/trunk/debian/wpasupplicant.postinst
    wpasupplicant/trunk/debian/wpasupplicant.postrm
    wpasupplicant/trunk/src/Makefile
    wpasupplicant/trunk/src/common/Makefile
    wpasupplicant/trunk/src/common/ieee802_11_common.c
    wpasupplicant/trunk/src/common/ieee802_11_common.h
    wpasupplicant/trunk/src/common/ieee802_11_defs.h
    wpasupplicant/trunk/src/common/nl80211_copy.h
    wpasupplicant/trunk/src/common/privsep_commands.h
    wpasupplicant/trunk/src/common/version.h
    wpasupplicant/trunk/src/common/wpa_ctrl.c
    wpasupplicant/trunk/src/common/wpa_ctrl.h
    wpasupplicant/trunk/src/crypto/Makefile
    wpasupplicant/trunk/src/crypto/aes_wrap.c
    wpasupplicant/trunk/src/crypto/crypto_gnutls.c
    wpasupplicant/trunk/src/crypto/crypto_openssl.c
    wpasupplicant/trunk/src/crypto/tls_gnutls.c
    wpasupplicant/trunk/src/drivers/Makefile
    wpasupplicant/trunk/src/drivers/driver_broadcom.c
    wpasupplicant/trunk/src/drivers/driver_bsd.c
    wpasupplicant/trunk/src/drivers/driver_madwifi.c
    wpasupplicant/trunk/src/drivers/driver_nl80211.c
    wpasupplicant/trunk/src/drivers/driver_privsep.c
    wpasupplicant/trunk/src/drivers/driver_roboswitch.c
    wpasupplicant/trunk/src/drivers/driver_wext.c
    wpasupplicant/trunk/src/drivers/scan_helpers.c
    wpasupplicant/trunk/src/eap_common/Makefile
    wpasupplicant/trunk/src/eap_peer/Makefile
    wpasupplicant/trunk/src/eap_peer/eap.c
    wpasupplicant/trunk/src/eap_peer/eap_aka.c
    wpasupplicant/trunk/src/eap_peer/eap_i.h
    wpasupplicant/trunk/src/eap_peer/eap_tls_common.c
    wpasupplicant/trunk/src/eap_peer/eap_wsc.c
    wpasupplicant/trunk/src/eap_server/Makefile
    wpasupplicant/trunk/src/eap_server/eap_aka.c
    wpasupplicant/trunk/src/eap_server/eap_wsc.c
    wpasupplicant/trunk/src/eapol_supp/Makefile
    wpasupplicant/trunk/src/eapol_supp/eapol_supp_sm.c
    wpasupplicant/trunk/src/hlr_auc_gw/Makefile
    wpasupplicant/trunk/src/hlr_auc_gw/hlr_auc_gw.milenage_db
    wpasupplicant/trunk/src/l2_packet/Makefile
    wpasupplicant/trunk/src/radius/Makefile
    wpasupplicant/trunk/src/radius/radius.c
    wpasupplicant/trunk/src/radius/radius.h
    wpasupplicant/trunk/src/radius/radius_client.c
    wpasupplicant/trunk/src/radius/radius_client.h
    wpasupplicant/trunk/src/rsn_supp/Makefile
    wpasupplicant/trunk/src/tls/Makefile
    wpasupplicant/trunk/src/utils/Makefile
    wpasupplicant/trunk/src/utils/os_unix.c
    wpasupplicant/trunk/src/utils/wpabuf.c
    wpasupplicant/trunk/src/utils/wpabuf.h
    wpasupplicant/trunk/src/wps/Makefile
    wpasupplicant/trunk/src/wps/wps.c
    wpasupplicant/trunk/src/wps/wps.h
    wpasupplicant/trunk/src/wps/wps_attr_build.c
    wpasupplicant/trunk/src/wps/wps_attr_process.c
    wpasupplicant/trunk/src/wps/wps_common.c
    wpasupplicant/trunk/src/wps/wps_enrollee.c
    wpasupplicant/trunk/src/wps/wps_i.h
    wpasupplicant/trunk/src/wps/wps_registrar.c
    wpasupplicant/trunk/wpa_supplicant/ChangeLog
    wpasupplicant/trunk/wpa_supplicant/Makefile
    wpasupplicant/trunk/wpa_supplicant/README
    wpasupplicant/trunk/wpa_supplicant/README-WPS
    wpasupplicant/trunk/wpa_supplicant/config.h
    wpasupplicant/trunk/wpa_supplicant/config_file.c
    wpasupplicant/trunk/wpa_supplicant/config_winreg.c
    wpasupplicant/trunk/wpa_supplicant/ctrl_iface_dbus.c
    wpasupplicant/trunk/wpa_supplicant/ctrl_iface_dbus.h
    wpasupplicant/trunk/wpa_supplicant/defconfig
    wpasupplicant/trunk/wpa_supplicant/eapol_test.c
    wpasupplicant/trunk/wpa_supplicant/events.c
    wpasupplicant/trunk/wpa_supplicant/mlme.c
    wpasupplicant/trunk/wpa_supplicant/nmake.mak
    wpasupplicant/trunk/wpa_supplicant/scan.c
    wpasupplicant/trunk/wpa_supplicant/tests/test_sha256.c
    wpasupplicant/trunk/wpa_supplicant/wpa_cli.c
    wpasupplicant/trunk/wpa_supplicant/wpa_gui-qt4/main.cpp
    wpasupplicant/trunk/wpa_supplicant/wpa_gui-qt4/wpagui.cpp
    wpasupplicant/trunk/wpa_supplicant/wpa_gui-qt4/wpagui.h
    wpasupplicant/trunk/wpa_supplicant/wpa_gui-qt4/wpagui.ui
    wpasupplicant/trunk/wpa_supplicant/wpa_priv.c
    wpasupplicant/trunk/wpa_supplicant/wpa_supplicant.c
    wpasupplicant/trunk/wpa_supplicant/wpa_supplicant.conf
    wpasupplicant/trunk/wpa_supplicant/wpa_supplicant_i.h
    wpasupplicant/trunk/wpa_supplicant/wps_supplicant.c
    wpasupplicant/trunk/wpa_supplicant/wps_supplicant.h

Modified: wpasupplicant/trunk/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/debian/changelog?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/debian/changelog (original)
+++ wpasupplicant/trunk/debian/changelog Sun Feb 15 20:49:57 2009
@@ -1,3 +1,23 @@
+wpasupplicant (0.6.8-1) unstable; urgency=low
+
+  * New upstream release.
+  * Drop patches applied upstream:
+    - 10_wpa_gui_qt4_wps_tab_cleanups.patch
+    - 11_wpa_gui_qt4_qsession.patch
+  * Refresh debian/patches/04_append_mmd_to_default_cflags.patch to
+    apply.
+  * Refresh all other patches to apply without offset.
+  * Activate CONFIG_DRIVER_NL80211 in debian/config/linux.
+  * Sync debian/config/linux with wpa_supplicant/defconfig.
+  * Add libnl-dev to build dependencies.
+  * Modify debian/wpasupplicant.postrm and debian/wpasupplicant.postinst
+    to set -e in body of script rather than in shebang line as per
+    pedantic lintian suggestion.
+  * Upload to unstable.
+  * Add copyright information for src/wps/wps* to debian/copyright.
+
+ -- Kel Modderman <kel at otaku42.de>  Mon, 16 Feb 2009 06:49:33 +1000
+
 wpasupplicant (0.6.7-1) experimental; urgency=low
 
   * New upstream release.

Modified: wpasupplicant/trunk/debian/config/linux
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/debian/config/linux?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/debian/config/linux (original)
+++ wpasupplicant/trunk/debian/config/linux Sun Feb 15 20:49:57 2009
@@ -14,8 +14,8 @@
 # Driver interface for madwifi driver
 # XXX: madwifi driver supports wext in all Debian releases so far
 #CONFIG_DRIVER_MADWIFI=y
-# Change include directories to match with the local setup
-#CFLAGS += -I../debian/madwifi-headers
+# Set include directory to the madwifi source tree
+#CFLAGS += -I../../madwifi
 
 # Driver interface for Prism54 driver
 # (Note: Prism54 is not yet supported, i.e., this will not work as-is and is
@@ -29,8 +29,10 @@
 # Driver interface for Atmel driver
 CONFIG_DRIVER_ATMEL=y
 
-# Driver interface for Broadcom driver
-# XXX: Non-GPL header required
+# Driver interface for old Broadcom driver
+# Please note that the newer Broadcom driver ("hybrid Linux driver") supports
+# Linux wireless extensions and does not need (or even work) with the old
+# driver wrapper. Use CONFIG_DRIVER_WEXT=y with that driver.
 #CONFIG_DRIVER_BROADCOM=y
 # Example path for wlioctl.h; change to match your configuration
 #CFLAGS += -I/opt/WRT54GS/release/src/include
@@ -45,6 +47,9 @@
 
 # Driver interface for generic Linux wireless extensions
 CONFIG_DRIVER_WEXT=y
+
+# Driver interface for Linux drivers using the nl80211 kernel interface
+CONFIG_DRIVER_NL80211=y
 
 # Driver interface for FreeBSD net80211 layer (e.g., Atheros driver)
 # XXX: we are not FreeBSD
@@ -75,6 +80,9 @@
 # Driver interface for wired Ethernet drivers
 CONFIG_DRIVER_WIRED=y
 
+# Driver interface for the Broadcom RoboSwitch family
+#CONFIG_DRIVER_ROBOSWITCH=y
+
 # Enable IEEE 802.1X Supplicant (automatically included if any EAP method is
 # included)
 CONFIG_IEEE8021X_EAPOL=y
@@ -121,6 +129,12 @@
 
 # EAP-AKA (enable CONFIG_PCSC, if EAP-AKA is used)
 CONFIG_EAP_AKA=y
+
+# This requires CONFIG_EAP_AKA to be enabled, too.
+#CONFIG_EAP_AKA_PRIME=y
+
+# Enable USIM simulator (Milenage) for EAP-AKA
+#CONFIG_USIM_SIMULATOR=y
 
 # EAP-SAKE
 #CONFIG_EAP_SAKE=y
@@ -315,15 +329,11 @@
 #CONFIG_DYNAMIC_EAP_METHODS=y
 
 # Include client MLME (management frame processing).
-# This can be used to move MLME processing of Devicescape IEEE 802.11 stack
-# into user space.
+# This can be used to move MLME processing of Linux mac80211 stack into user
+# space. Please note that this is currently only available with
+# driver_nl80211.c and only with a modified version of Linux kernel and
+# wpa_supplicant.
 #CONFIG_CLIENT_MLME=y
-# Currently, driver_devicescape.c build requires some additional parameters
-# to be able to include some of the kernel header files. Following lines can
-# be used to set these (WIRELESS_DEV must point to the root directory of the
-# wireless-dev.git tree).
-#WIRELESS_DEV=/usr/src/wireless-dev
-#CFLAGS += -I$(WIRELESS_DEV)/net/mac80211
 
 # IEEE Std 802.11r-2008 (Fast BSS Transition)
 CONFIG_IEEE80211R=y

Modified: wpasupplicant/trunk/debian/control
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/debian/control?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/debian/control (original)
+++ wpasupplicant/trunk/debian/control Sun Feb 15 20:49:57 2009
@@ -11,6 +11,7 @@
  libreadline5-dev,
  libqt4-dev,
  libdbus-1-dev,
+ libnl-dev,
  docbook,
  docbook-utils,
  pkg-config,

Modified: wpasupplicant/trunk/debian/copyright
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/debian/copyright?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/debian/copyright (original)
+++ wpasupplicant/trunk/debian/copyright Sun Feb 15 20:49:57 2009
@@ -73,6 +73,10 @@
 Copyright: Copyright (c) 2003-2004,  David Young
 License: BSD
 
+Files: src/wps/wps*
+Copyright: Copyright (c) 2007 - 2008, Jouni Malinen <j at w1.fi>
+License: BSD | GPL-2
+
 Files: wpa_supplicant/ctrl_iface_dbus*, wpa_supplicant/dbus_dict_helpers.*
 Copyright: Copyright (c) 2006, Dan Williams <dcbw at redhat.com> and Red Hat, Inc.
 License: BSD | GPL-2

Modified: wpasupplicant/trunk/debian/patches/01_use_pkg-config_for_pcsc-lite_module.patch
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/debian/patches/01_use_pkg-config_for_pcsc-lite_module.patch?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/debian/patches/01_use_pkg-config_for_pcsc-lite_module.patch (original)
+++ wpasupplicant/trunk/debian/patches/01_use_pkg-config_for_pcsc-lite_module.patch Sun Feb 15 20:49:57 2009
@@ -6,7 +6,7 @@
 
 --- a/wpa_supplicant/Makefile
 +++ b/wpa_supplicant/Makefile
-@@ -615,7 +615,7 @@ ifdef CONFIG_NATIVE_WINDOWS
+@@ -627,7 +627,7 @@ ifdef CONFIG_NATIVE_WINDOWS
  #dynamic symbol loading that is now used in pcsc_funcs.c
  #LIBS += -lwinscard
  else

Modified: wpasupplicant/trunk/debian/patches/04_append_mmd_to_default_cflags.patch
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/debian/patches/04_append_mmd_to_default_cflags.patch?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/debian/patches/04_append_mmd_to_default_cflags.patch (original)
+++ wpasupplicant/trunk/debian/patches/04_append_mmd_to_default_cflags.patch Sun Feb 15 20:49:57 2009
@@ -8,7 +8,7 @@
 
 --- a/wpa_supplicant/Makefile
 +++ b/wpa_supplicant/Makefile
-@@ -3,9 +3,10 @@ CC=gcc
+@@ -3,12 +3,13 @@ CC=gcc
  endif
  
  ifndef CFLAGS
@@ -16,6 +16,9 @@
 +CFLAGS = -O2 -Wall -g
  endif
  
+ export LIBDIR ?= /usr/local/lib/
+ export BINDIR ?= /usr/local/sbin/
+ 
 +CFLAGS += -MMD
  CFLAGS += -I../src
  CFLAGS += -I../src/crypto

Modified: wpasupplicant/trunk/debian/patches/05_qmake_version_makefile.patch
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/debian/patches/05_qmake_version_makefile.patch?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/debian/patches/05_qmake_version_makefile.patch (original)
+++ wpasupplicant/trunk/debian/patches/05_qmake_version_makefile.patch Sun Feb 15 20:49:57 2009
@@ -7,7 +7,7 @@
 
 --- a/wpa_supplicant/Makefile
 +++ b/wpa_supplicant/Makefile
-@@ -1147,13 +1147,13 @@ windows-bin: $(WINALL)
+@@ -1160,13 +1160,13 @@ windows-bin: $(WINALL)
  	$(STRIP) $(WINALL)
  
  wpa_gui/Makefile:

Modified: wpasupplicant/trunk/debian/patches/series
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/debian/patches/series?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/debian/patches/series (original)
+++ wpasupplicant/trunk/debian/patches/series Sun Feb 15 20:49:57 2009
@@ -4,5 +4,3 @@
 04_append_mmd_to_default_cflags.patch
 05_qmake_version_makefile.patch
 06_wpa_gui_menu_exec_path.patch
-10_wpa_gui_qt4_wps_tab_cleanups.patch
-11_wpa_gui_qt4_qsession.patch

Modified: wpasupplicant/trunk/debian/wpasupplicant.postinst
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/debian/wpasupplicant.postinst?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/debian/wpasupplicant.postinst (original)
+++ wpasupplicant/trunk/debian/wpasupplicant.postinst Sun Feb 15 20:49:57 2009
@@ -1,4 +1,4 @@
-#!/bin/sh -e
+#!/bin/sh
 # This script can be called in the following ways:
 #
 # After the package was installed:
@@ -14,6 +14,8 @@
 #
 # If prerm fails during replacement due to conflict:
 #       <postinst> abort-remove in-favour <new-package> <version>
+
+set -e
 
 case "$1" in
 	configure)

Modified: wpasupplicant/trunk/debian/wpasupplicant.postrm
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/debian/wpasupplicant.postrm?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/debian/wpasupplicant.postrm (original)
+++ wpasupplicant/trunk/debian/wpasupplicant.postrm Sun Feb 15 20:49:57 2009
@@ -1,4 +1,4 @@
-#!/bin/sh -e
+#!/bin/sh
 # This script can be called in the following ways:
 #
 # After the package was removed:
@@ -26,6 +26,8 @@
 # If preinst fails during upgrade:
 #       <new-postrm> abort-upgrade <old-version>
 
+set -e
+
 case "$1" in
 	remove)
 		;;

Modified: wpasupplicant/trunk/src/Makefile
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/Makefile?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/Makefile (original)
+++ wpasupplicant/trunk/src/Makefile Sun Feb 15 20:49:57 2009
@@ -6,3 +6,6 @@
 clean:
 	for d in $(SUBDIRS); do [ -d $$d ] && $(MAKE) -C $$d clean; done
 	rm -f *~
+
+install:
+	for d in $(SUBDIRS); do [ -d $$d ] && $(MAKE) -C $$d install; done

Modified: wpasupplicant/trunk/src/common/Makefile
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/common/Makefile?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/common/Makefile (original)
+++ wpasupplicant/trunk/src/common/Makefile Sun Feb 15 20:49:57 2009
@@ -4,3 +4,6 @@
 clean:
 	for d in $(SUBDIRS); do make -C $$d clean; done
 	rm -f *~ *.o *.d
+
+install:
+	@echo Nothing to be made.

Modified: wpasupplicant/trunk/src/common/ieee802_11_common.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/common/ieee802_11_common.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/common/ieee802_11_common.c (original)
+++ wpasupplicant/trunk/src/common/ieee802_11_common.c Sun Feb 15 20:49:57 2009
@@ -116,6 +116,14 @@
 }
 
 
+/**
+ * ieee802_11_parse_elems - Parse information elements in management frames
+ * @start: Pointer to the start of IEs
+ * @len: Length of IE buffer in octets
+ * @elems: Data structure for parsed elements
+ * @show_errors: Whether to show parsing errors in debug log
+ * Returns: Parsing result
+ */
 ParseRes ieee802_11_parse_elems(u8 *start, size_t len,
 				struct ieee802_11_elems *elems,
 				int show_errors)
@@ -211,6 +219,10 @@
 			elems->ftie = pos;
 			elems->ftie_len = elen;
 			break;
+		case WLAN_EID_TIMEOUT_INTERVAL:
+			elems->timeout_int = pos;
+			elems->timeout_int_len = elen;
+			break;
 		case WLAN_EID_HT_CAP:
 			elems->ht_capabilities = pos;
 			elems->ht_capabilities_len = elen;
@@ -218,10 +230,6 @@
 		case WLAN_EID_HT_OPERATION:
 			elems->ht_operation = pos;
 			elems->ht_operation_len = elen;
-			break;
-		case WLAN_EID_ASSOC_COMEBACK_TIME:
-			elems->assoc_comeback = pos;
-			elems->assoc_comeback_len = elen;
 			break;
 		default:
 			unknown++;

Modified: wpasupplicant/trunk/src/common/ieee802_11_common.h
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/common/ieee802_11_common.h?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/common/ieee802_11_common.h (original)
+++ wpasupplicant/trunk/src/common/ieee802_11_common.h Sun Feb 15 20:49:57 2009
@@ -55,12 +55,12 @@
 	u8 mdie_len;
 	u8 *ftie;
 	u8 ftie_len;
+	u8 *timeout_int;
+	u8 timeout_int_len;
 	u8 *ht_capabilities;
 	u8 ht_capabilities_len;
 	u8 *ht_operation;
 	u8 ht_operation_len;
-	u8 *assoc_comeback;
-	u8 assoc_comeback_len;
 	u8 *vendor_ht_cap;
 	u8 vendor_ht_cap_len;
 };

Modified: wpasupplicant/trunk/src/common/ieee802_11_defs.h
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/common/ieee802_11_defs.h?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/common/ieee802_11_defs.h (original)
+++ wpasupplicant/trunk/src/common/ieee802_11_defs.h Sun Feb 15 20:49:57 2009
@@ -203,7 +203,6 @@
 #define WLAN_EID_20_40_BSS_INTOLERANT 73
 #define WLAN_EID_OVERLAPPING_BSS_SCAN_PARAMS 74
 #define WLAN_EID_MMIE 76
-#define WLAN_EID_ASSOC_COMEBACK_TIME 77
 #define WLAN_EID_VENDOR_SPECIFIC 221
 
 
@@ -222,6 +221,11 @@
 #define WLAN_SA_QUERY_RESPONSE 1
 
 #define WLAN_SA_QUERY_TR_ID_LEN 16
+
+/* Timeout Interval Type */
+#define WLAN_TIMEOUT_REASSOC_DEADLINE 1
+#define WLAN_TIMEOUT_KEY_LIFETIME 2
+#define WLAN_TIMEOUT_ASSOC_COMEBACK 3
 
 
 #ifdef _MSC_VER

Modified: wpasupplicant/trunk/src/common/nl80211_copy.h
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/common/nl80211_copy.h?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/common/nl80211_copy.h (original)
+++ wpasupplicant/trunk/src/common/nl80211_copy.h Sun Feb 15 20:49:57 2009
@@ -47,7 +47,7 @@
  * @NL80211_CMD_SET_WIPHY: set wiphy parameters, needs %NL80211_ATTR_WIPHY or
  *	%NL80211_ATTR_IFINDEX; can be used to set %NL80211_ATTR_WIPHY_NAME,
  *	%NL80211_ATTR_WIPHY_TXQ_PARAMS, %NL80211_ATTR_WIPHY_FREQ, and/or
- *	%NL80211_ATTR_WIPHY_SEC_CHAN_OFFSET.
+ *	%NL80211_ATTR_WIPHY_CHANNEL_TYPE.
  * @NL80211_CMD_NEW_WIPHY: Newly created wiphy, response to get request
  *	or rename notification. Has attributes %NL80211_ATTR_WIPHY and
  *	%NL80211_ATTR_WIPHY_NAME.
@@ -84,7 +84,7 @@
  *	%NL80222_CMD_NEW_BEACON message)
  * @NL80211_CMD_SET_BEACON: set the beacon on an access point interface
  *	using the %NL80211_ATTR_BEACON_INTERVAL, %NL80211_ATTR_DTIM_PERIOD,
- *	%NL80211_BEACON_HEAD and %NL80211_BEACON_TAIL attributes.
+ *	%NL80211_ATTR_BEACON_HEAD and %NL80211_ATTR_BEACON_TAIL attributes.
  * @NL80211_CMD_NEW_BEACON: add a new beacon to an access point interface,
  *	parameters are like for %NL80211_CMD_SET_BEACON.
  * @NL80211_CMD_DEL_BEACON: remove the beacon, stop sending it
@@ -113,6 +113,8 @@
  * @NL80211_CMD_SET_BSS: Set BSS attributes for BSS identified by
  *	%NL80211_ATTR_IFINDEX.
  *
+ * @NL80211_CMD_GET_REG: ask the wireless core to send us its currently set
+ * 	regulatory domain.
  * @NL80211_CMD_SET_REG: Set current regulatory domain. CRDA sends this command
  *	after being queried by the kernel. CRDA replies by sending a regulatory
  *	domain structure which consists of %NL80211_ATTR_REG_ALPHA set to our
@@ -133,6 +135,21 @@
  * @NL80211_CMD_SET_MESH_PARAMS: Set mesh networking properties for the
  *      interface identified by %NL80211_ATTR_IFINDEX
  *
+ * @NL80211_CMD_SET_MGMT_EXTRA_IE: Set extra IEs for management frames. The
+ *	interface is identified with %NL80211_ATTR_IFINDEX and the management
+ *	frame subtype with %NL80211_ATTR_MGMT_SUBTYPE. The extra IE data to be
+ *	added to the end of the specified management frame is specified with
+ *	%NL80211_ATTR_IE. If the command succeeds, the requested data will be
+ *	added to all specified management frames generated by
+ *	kernel/firmware/driver.
+ *
+ * @NL80211_CMD_GET_SCAN: get scan results
+ * @NL80211_CMD_TRIGGER_SCAN: trigger a new scan with the given parameters
+ * @NL80211_CMD_NEW_SCAN_RESULTS: scan notification (as a reply to
+ *	NL80211_CMD_GET_SCAN and on the "scan" multicast group)
+ * @NL80211_CMD_SCAN_ABORTED: scan was aborted, for unspecified reasons,
+ *	partial scan results may be available
+ *
  * @NL80211_CMD_MAX: highest used command number
  * @__NL80211_CMD_AFTER_LAST: internal use
  */
@@ -178,6 +195,15 @@
 	NL80211_CMD_GET_MESH_PARAMS,
 	NL80211_CMD_SET_MESH_PARAMS,
 
+	NL80211_CMD_SET_MGMT_EXTRA_IE,
+
+	NL80211_CMD_GET_REG,
+
+	NL80211_CMD_GET_SCAN,
+	NL80211_CMD_TRIGGER_SCAN,
+	NL80211_CMD_NEW_SCAN_RESULTS,
+	NL80211_CMD_SCAN_ABORTED,
+
 	/* add new commands above here */
 
 	/* used to define NL80211_CMD_MAX below */
@@ -190,6 +216,7 @@
  * here
  */
 #define NL80211_CMD_SET_BSS NL80211_CMD_SET_BSS
+#define NL80211_CMD_SET_MGMT_EXTRA_IE NL80211_CMD_SET_MGMT_EXTRA_IE
 
 /**
  * enum nl80211_attrs - nl80211 netlink attributes
@@ -284,6 +311,24 @@
  *	supported interface types, each a flag attribute with the number
  *	of the interface mode.
  *
+ * @NL80211_ATTR_MGMT_SUBTYPE: Management frame subtype for
+ *	%NL80211_CMD_SET_MGMT_EXTRA_IE.
+ *
+ * @NL80211_ATTR_IE: Information element(s) data (used, e.g., with
+ *	%NL80211_CMD_SET_MGMT_EXTRA_IE).
+ *
+ * @NL80211_ATTR_MAX_NUM_SCAN_SSIDS: number of SSIDs you can scan with
+ *	a single scan request, a wiphy attribute.
+ *
+ * @NL80211_ATTR_SCAN_FREQUENCIES: nested attribute with frequencies (in MHz)
+ * @NL80211_ATTR_SCAN_SSIDS: nested attribute with SSIDs, leave out for passive
+ *	scanning and include a zero-length SSID (wildcard) for wildcard scan
+ * @NL80211_ATTR_SCAN_GENERATION: the scan generation increases whenever the
+ *	scan result list changes (BSS expired or added) so that applications
+ *	can verify that they got a single, consistent snapshot (when all dump
+ *	messages carried the same generation number)
+ * @NL80211_ATTR_BSS: scan result BSS
+ *
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
  */
@@ -348,6 +393,16 @@
 
 	NL80211_ATTR_KEY_DEFAULT_MGMT,
 
+	NL80211_ATTR_MGMT_SUBTYPE,
+	NL80211_ATTR_IE,
+
+	NL80211_ATTR_MAX_NUM_SCAN_SSIDS,
+
+	NL80211_ATTR_SCAN_FREQUENCIES,
+	NL80211_ATTR_SCAN_SSIDS,
+	NL80211_ATTR_SCAN_GENERATION,
+	NL80211_ATTR_BSS,
+
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,
@@ -362,7 +417,9 @@
 #define NL80211_ATTR_BSS_BASIC_RATES NL80211_ATTR_BSS_BASIC_RATES
 #define NL80211_ATTR_WIPHY_TXQ_PARAMS NL80211_ATTR_WIPHY_TXQ_PARAMS
 #define NL80211_ATTR_WIPHY_FREQ NL80211_ATTR_WIPHY_FREQ
-#define NL80211_ATTR_WIPHY_SEC_CHAN_OFFSET NL80211_ATTR_WIPHY_SEC_CHAN_OFFSET
+#define NL80211_ATTR_WIPHY_CHANNEL_TYPE NL80211_ATTR_WIPHY_CHANNEL_TYPE
+#define NL80211_ATTR_MGMT_SUBTYPE NL80211_ATTR_MGMT_SUBTYPE
+#define NL80211_ATTR_IE NL80211_ATTR_IE
 
 #define NL80211_MAX_SUPP_RATES			32
 #define NL80211_MAX_SUPP_REG_RULES		32
@@ -815,4 +872,38 @@
 	NL80211_CHAN_HT40MINUS,
 	NL80211_CHAN_HT40PLUS
 };
+
+/**
+ * enum nl80211_bss - netlink attributes for a BSS
+ *
+ * @__NL80211_BSS_INVALID: invalid
+ * @NL80211_BSS_FREQUENCY: frequency in MHz (u32)
+ * @NL80211_BSS_TSF: TSF of the received probe response/beacon (u64)
+ * @NL80211_BSS_BEACON_INTERVAL: beacon interval of the (I)BSS (u16)
+ * @NL80211_BSS_CAPABILITY: capability field (CPU order, u16)
+ * @NL80211_BSS_INFORMATION_ELEMENTS: binary attribute containing the
+ *	raw information elements from the probe response/beacon (bin)
+ * @NL80211_BSS_SIGNAL_MBM: signal strength of probe response/beacon
+ *	in mBm (100 * dBm) (s32)
+ * @NL80211_BSS_SIGNAL_UNSPEC: signal strength of the probe response/beacon
+ *	in unspecified units, scaled to 0..100 (u8)
+ * @__NL80211_BSS_AFTER_LAST: internal
+ * @NL80211_BSS_MAX: highest BSS attribute
+ */
+enum nl80211_bss {
+	__NL80211_BSS_INVALID,
+	NL80211_BSS_BSSID,
+	NL80211_BSS_FREQUENCY,
+	NL80211_BSS_TSF,
+	NL80211_BSS_BEACON_INTERVAL,
+	NL80211_BSS_CAPABILITY,
+	NL80211_BSS_INFORMATION_ELEMENTS,
+	NL80211_BSS_SIGNAL_MBM,
+	NL80211_BSS_SIGNAL_UNSPEC,
+
+	/* keep last */
+	__NL80211_BSS_AFTER_LAST,
+	NL80211_BSS_MAX = __NL80211_BSS_AFTER_LAST - 1
+};
+
 #endif /* __LINUX_NL80211_H */

Modified: wpasupplicant/trunk/src/common/privsep_commands.h
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/common/privsep_commands.h?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/common/privsep_commands.h (original)
+++ wpasupplicant/trunk/src/common/privsep_commands.h Sun Feb 15 20:49:57 2009
@@ -1,6 +1,6 @@
 /*
  * WPA Supplicant - privilege separation commands
- * Copyright (c) 2007, Jouni Malinen <j at w1.fi>
+ * Copyright (c) 2007-2009, Jouni Malinen <j at w1.fi>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -31,6 +31,7 @@
 	PRIVSEP_CMD_L2_NOTIFY_AUTH_START,
 	PRIVSEP_CMD_L2_SEND,
 	PRIVSEP_CMD_SET_MODE,
+	PRIVSEP_CMD_SET_COUNTRY,
 };
 
 struct privsep_cmd_associate
@@ -71,6 +72,7 @@
 	PRIVSEP_EVENT_STKSTART,
 	PRIVSEP_EVENT_FT_RESPONSE,
 	PRIVSEP_EVENT_RX_EAPOL,
+	PRIVSEP_EVENT_STA_RX,
 };
 
 #endif /* PRIVSEP_COMMANDS_H */

Modified: wpasupplicant/trunk/src/common/version.h
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/common/version.h?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/common/version.h (original)
+++ wpasupplicant/trunk/src/common/version.h Sun Feb 15 20:49:57 2009
@@ -1,6 +1,6 @@
 #ifndef VERSION_H
 #define VERSION_H
 
-#define VERSION_STR "0.6.7"
+#define VERSION_STR "0.6.8"
 
 #endif /* VERSION_H */

Modified: wpasupplicant/trunk/src/common/wpa_ctrl.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/common/wpa_ctrl.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/common/wpa_ctrl.c (original)
+++ wpasupplicant/trunk/src/common/wpa_ctrl.c Sun Feb 15 20:49:57 2009
@@ -64,6 +64,7 @@
 	static int counter = 0;
 	int ret;
 	size_t res;
+	int tries = 0;
 
 	ctrl = os_malloc(sizeof(*ctrl));
 	if (ctrl == NULL)
@@ -77,15 +78,28 @@
 	}
 
 	ctrl->local.sun_family = AF_UNIX;
+	counter++;
+try_again:
 	ret = os_snprintf(ctrl->local.sun_path, sizeof(ctrl->local.sun_path),
-			  "/tmp/wpa_ctrl_%d-%d", getpid(), counter++);
+			  "/tmp/wpa_ctrl_%d-%d", getpid(), counter);
 	if (ret < 0 || (size_t) ret >= sizeof(ctrl->local.sun_path)) {
 		close(ctrl->s);
 		os_free(ctrl);
 		return NULL;
 	}
+	tries++;
 	if (bind(ctrl->s, (struct sockaddr *) &ctrl->local,
 		    sizeof(ctrl->local)) < 0) {
+		if (errno == EADDRINUSE && tries < 2) {
+			/*
+			 * getpid() returns unique identifier for this instance
+			 * of wpa_ctrl, so the existing socket file must have
+			 * been left by unclean termination of an earlier run.
+			 * Remove the file and try again.
+			 */
+			unlink(ctrl->local.sun_path);
+			goto try_again;
+		}
 		close(ctrl->s);
 		os_free(ctrl);
 		return NULL;

Modified: wpasupplicant/trunk/src/common/wpa_ctrl.h
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/common/wpa_ctrl.h?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/common/wpa_ctrl.h (original)
+++ wpasupplicant/trunk/src/common/wpa_ctrl.h Sun Feb 15 20:49:57 2009
@@ -66,10 +66,14 @@
 #define WPS_EVENT_FAIL "WPS-FAIL "
 /** WPS registration completed successfully */
 #define WPS_EVENT_SUCCESS "WPS-SUCCESS "
+/** WPS enrollment attempt timed out and was terminated */
+#define WPS_EVENT_TIMEOUT "WPS-TIMEOUT "
 
 /* hostapd control interface - fixed message prefixes */
 #define WPS_EVENT_PIN_NEEDED "WPS-PIN-NEEDED "
 #define WPS_EVENT_NEW_AP_SETTINGS "WPS-NEW-AP-SETTINGS "
+#define WPS_EVENT_REG_SUCCESS "WPS-REG-SUCCESS "
+#define WPS_EVENT_AP_SETUP_LOCKED "WPS-AP-SETUP-LOCKED "
 
 
 /* wpa_supplicant/hostapd control interface access */

Modified: wpasupplicant/trunk/src/crypto/Makefile
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/crypto/Makefile?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/crypto/Makefile (original)
+++ wpasupplicant/trunk/src/crypto/Makefile Sun Feb 15 20:49:57 2009
@@ -4,3 +4,6 @@
 clean:
 	for d in $(SUBDIRS); do make -C $$d clean; done
 	rm -f *~ *.o *.d
+
+install:
+	@echo Nothing to be made.

Modified: wpasupplicant/trunk/src/crypto/aes_wrap.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/crypto/aes_wrap.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/crypto/aes_wrap.c (original)
+++ wpasupplicant/trunk/src/crypto/aes_wrap.c Sun Feb 15 20:49:57 2009
@@ -86,6 +86,8 @@
 #endif /* CONFIG_NO_AES_WRAP */
 
 
+#ifndef CONFIG_NO_AES_UNWRAP
+
 /**
  * aes_unwrap - Unwrap key with AES Key Wrap Algorithm (128-bit KEK) (RFC3394)
  * @kek: Key encryption key (KEK)
@@ -145,6 +147,8 @@
 	return 0;
 }
 
+#endif /* CONFIG_NO_AES_UNWRAP */
+
 
 #define BLOCK_SIZE 16
 

Modified: wpasupplicant/trunk/src/crypto/crypto_gnutls.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/crypto/crypto_gnutls.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/crypto/crypto_gnutls.c (original)
+++ wpasupplicant/trunk/src/crypto/crypto_gnutls.c Sun Feb 15 20:49:57 2009
@@ -1,6 +1,6 @@
 /*
  * WPA Supplicant / wrapper functions for libgcrypt
- * Copyright (c) 2004-2005, Jouni Malinen <j at w1.fi>
+ * Copyright (c) 2004-2009, Jouni Malinen <j at w1.fi>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -163,3 +163,151 @@
 	gcry_cipher_close(hd);
 }
 #endif /* EAP_TLS_FUNCS */
+
+
+int crypto_mod_exp(const u8 *base, size_t base_len,
+		   const u8 *power, size_t power_len,
+		   const u8 *modulus, size_t modulus_len,
+		   u8 *result, size_t *result_len)
+{
+	gcry_mpi_t bn_base = NULL, bn_exp = NULL, bn_modulus = NULL,
+		bn_result = NULL;
+	int ret = -1;
+
+	if (gcry_mpi_scan(&bn_base, GCRYMPI_FMT_USG, base, base_len, NULL) !=
+	    GPG_ERR_NO_ERROR ||
+	    gcry_mpi_scan(&bn_exp, GCRYMPI_FMT_USG, power, power_len, NULL) !=
+	    GPG_ERR_NO_ERROR ||
+	    gcry_mpi_scan(&bn_modulus, GCRYMPI_FMT_USG, modulus, modulus_len,
+			  NULL) != GPG_ERR_NO_ERROR)
+		goto error;
+	bn_result = gcry_mpi_new(modulus_len * 8);
+
+	gcry_mpi_powm(bn_result, bn_base, bn_exp, bn_modulus);
+
+	if (gcry_mpi_print(GCRYMPI_FMT_USG, result, *result_len, result_len,
+			   bn_result) != GPG_ERR_NO_ERROR)
+		goto error;
+
+	ret = 0;
+
+error:
+	gcry_mpi_release(bn_base);
+	gcry_mpi_release(bn_exp);
+	gcry_mpi_release(bn_modulus);
+	gcry_mpi_release(bn_result);
+	return ret;
+}
+
+
+struct crypto_cipher {
+	gcry_cipher_hd_t enc;
+	gcry_cipher_hd_t dec;
+};
+
+
+struct crypto_cipher * crypto_cipher_init(enum crypto_cipher_alg alg,
+					  const u8 *iv, const u8 *key,
+					  size_t key_len)
+{
+	struct crypto_cipher *ctx;
+	gcry_error_t res;
+	enum gcry_cipher_algos a;
+	int ivlen;
+
+	ctx = os_zalloc(sizeof(*ctx));
+	if (ctx == NULL)
+		return NULL;
+
+	switch (alg) {
+	case CRYPTO_CIPHER_ALG_RC4:
+		a = GCRY_CIPHER_ARCFOUR;
+		res = gcry_cipher_open(&ctx->enc, a, GCRY_CIPHER_MODE_STREAM,
+				       0);
+		gcry_cipher_open(&ctx->dec, a, GCRY_CIPHER_MODE_STREAM, 0);
+		break;
+	case CRYPTO_CIPHER_ALG_AES:
+		if (key_len == 24)
+			a = GCRY_CIPHER_AES192;
+		else if (key_len == 32)
+			a = GCRY_CIPHER_AES256;
+		else
+			a = GCRY_CIPHER_AES;
+		res = gcry_cipher_open(&ctx->enc, a, GCRY_CIPHER_MODE_CBC, 0);
+		gcry_cipher_open(&ctx->dec, a, GCRY_CIPHER_MODE_CBC, 0);
+		break;
+	case CRYPTO_CIPHER_ALG_3DES:
+		a = GCRY_CIPHER_3DES;
+		res = gcry_cipher_open(&ctx->enc, a, GCRY_CIPHER_MODE_CBC, 0);
+		gcry_cipher_open(&ctx->dec, a, GCRY_CIPHER_MODE_CBC, 0);
+		break;
+	case CRYPTO_CIPHER_ALG_DES:
+		a = GCRY_CIPHER_DES;
+		res = gcry_cipher_open(&ctx->enc, a, GCRY_CIPHER_MODE_CBC, 0);
+		gcry_cipher_open(&ctx->dec, a, GCRY_CIPHER_MODE_CBC, 0);
+		break;
+	case CRYPTO_CIPHER_ALG_RC2:
+		if (key_len == 5)
+			a = GCRY_CIPHER_RFC2268_40;
+		else
+			a = GCRY_CIPHER_RFC2268_128;
+		res = gcry_cipher_open(&ctx->enc, a, GCRY_CIPHER_MODE_CBC, 0);
+		gcry_cipher_open(&ctx->dec, a, GCRY_CIPHER_MODE_CBC, 0);
+		break;
+	default:
+		os_free(ctx);
+		return NULL;
+	}
+
+	if (res != GPG_ERR_NO_ERROR) {
+		os_free(ctx);
+		return NULL;
+	}
+
+	if (gcry_cipher_setkey(ctx->enc, key, key_len) != GPG_ERR_NO_ERROR ||
+	    gcry_cipher_setkey(ctx->dec, key, key_len) != GPG_ERR_NO_ERROR) {
+		gcry_cipher_close(ctx->enc);
+		gcry_cipher_close(ctx->dec);
+		os_free(ctx);
+		return NULL;
+	}
+
+	ivlen = gcry_cipher_get_algo_blklen(a);
+	if (gcry_cipher_setiv(ctx->enc, iv, ivlen) != GPG_ERR_NO_ERROR ||
+	    gcry_cipher_setiv(ctx->dec, iv, ivlen) != GPG_ERR_NO_ERROR) {
+		gcry_cipher_close(ctx->enc);
+		gcry_cipher_close(ctx->dec);
+		os_free(ctx);
+		return NULL;
+	}
+
+	return ctx;
+}
+
+
+int crypto_cipher_encrypt(struct crypto_cipher *ctx, const u8 *plain,
+			  u8 *crypt, size_t len)
+{
+	if (gcry_cipher_encrypt(ctx->enc, crypt, len, plain, len) !=
+	    GPG_ERR_NO_ERROR)
+		return -1;
+	return 0;
+}
+
+
+int crypto_cipher_decrypt(struct crypto_cipher *ctx, const u8 *crypt,
+			  u8 *plain, size_t len)
+{
+	if (gcry_cipher_decrypt(ctx->dec, plain, len, crypt, len) !=
+	    GPG_ERR_NO_ERROR)
+		return -1;
+	return 0;
+}
+
+
+void crypto_cipher_deinit(struct crypto_cipher *ctx)
+{
+	gcry_cipher_close(ctx->enc);
+	gcry_cipher_close(ctx->dec);
+	os_free(ctx);
+}

Modified: wpasupplicant/trunk/src/crypto/crypto_openssl.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/crypto/crypto_openssl.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/crypto/crypto_openssl.c (original)
+++ wpasupplicant/trunk/src/crypto/crypto_openssl.c Sun Feb 15 20:49:57 2009
@@ -283,6 +283,7 @@
 			cipher = EVP_aes_256_cbc();
 			break;
 		default:
+			os_free(ctx);
 			return NULL;
 		}
 		break;
@@ -301,6 +302,7 @@
 		break;
 #endif /* OPENSSL_NO_RC2 */
 	default:
+		os_free(ctx);
 		return NULL;
 	}
 

Modified: wpasupplicant/trunk/src/crypto/tls_gnutls.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/crypto/tls_gnutls.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/crypto/tls_gnutls.c (original)
+++ wpasupplicant/trunk/src/crypto/tls_gnutls.c Sun Feb 15 20:49:57 2009
@@ -254,8 +254,9 @@
 		conn->pull_buf = conn->pull_buf_offset = NULL;
 		conn->pull_buf_len = 0;
 	} else {
-		wpa_printf(MSG_DEBUG, "%s - %d bytes remaining in pull_buf",
-			   __func__, end - conn->pull_buf_offset);
+		wpa_printf(MSG_DEBUG, "%s - %lu bytes remaining in pull_buf",
+			   __func__,
+			   (unsigned long) (end - conn->pull_buf_offset));
 	}
 	return len;
 }
@@ -943,8 +944,9 @@
 
 	if (in_data && in_len) {
 		if (conn->pull_buf) {
-			wpa_printf(MSG_DEBUG, "%s - %d bytes remaining in "
-				   "pull_buf", __func__, conn->pull_buf_len);
+			wpa_printf(MSG_DEBUG, "%s - %lu bytes remaining in "
+				   "pull_buf", __func__,
+				   (unsigned long) conn->pull_buf_len);
 			os_free(conn->pull_buf);
 		}
 		conn->pull_buf = os_malloc(in_len);
@@ -1058,6 +1060,14 @@
 		return -1;
 	if (conn->push_buf_len < out_len)
 		out_len = conn->push_buf_len;
+	else if (conn->push_buf_len > out_len) {
+		wpa_printf(MSG_INFO, "GnuTLS: Not enough buffer space for "
+			   "encrypted message (in_len=%lu push_buf_len=%lu "
+			   "out_len=%lu",
+			   (unsigned long) in_len,
+			   (unsigned long) conn->push_buf_len,
+			   (unsigned long) out_len);
+	}
 	os_memcpy(out_data, conn->push_buf, out_len);
 	os_free(conn->push_buf);
 	conn->push_buf = NULL;
@@ -1073,8 +1083,9 @@
 	ssize_t res;
 
 	if (conn->pull_buf) {
-		wpa_printf(MSG_DEBUG, "%s - %d bytes remaining in "
-			   "pull_buf", __func__, conn->pull_buf_len);
+		wpa_printf(MSG_DEBUG, "%s - %lu bytes remaining in "
+			   "pull_buf", __func__,
+			   (unsigned long) conn->pull_buf_len);
 		os_free(conn->pull_buf);
 	}
 	conn->pull_buf = os_malloc(in_len);
@@ -1132,7 +1143,7 @@
 
 		if (res < 0) {
 			wpa_printf(MSG_DEBUG, "%s - gnutls_ia_recv failed: %d "
-				   "(%s)", __func__, res,
+				   "(%s)", __func__, (int) res,
 				   gnutls_strerror(res));
 		}
 		return res;
@@ -1142,7 +1153,7 @@
 	res = gnutls_record_recv(conn->session, out_data, out_len);
 	if (res < 0) {
 		wpa_printf(MSG_DEBUG, "%s - gnutls_record_recv failed: %d "
-			   "(%s)", __func__, res, gnutls_strerror(res));
+			   "(%s)", __func__, (int) res, gnutls_strerror(res));
 	}
 
 	return res;

Modified: wpasupplicant/trunk/src/drivers/Makefile
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/drivers/Makefile?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/drivers/Makefile (original)
+++ wpasupplicant/trunk/src/drivers/Makefile Sun Feb 15 20:49:57 2009
@@ -4,3 +4,6 @@
 clean:
 	for d in $(SUBDIRS); do make -C $$d clean; done
 	rm -f *~ *.o *.d
+
+install:
+	@echo Nothing to be made.

Modified: wpasupplicant/trunk/src/drivers/driver_broadcom.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/drivers/driver_broadcom.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/drivers/driver_broadcom.c (original)
+++ wpasupplicant/trunk/src/drivers/driver_broadcom.c Sun Feb 15 20:49:57 2009
@@ -1,5 +1,5 @@
 /*
- * WPA Supplicant - driver interaction with Broadcom wl.o driver
+ * WPA Supplicant - driver interaction with old Broadcom wl.o driver
  * Copyright (c) 2004, Nikki Chumkov <nikki at gattaca.ru>
  * Copyright (c) 2004, Jouni Malinen <j at w1.fi>
  *
@@ -11,6 +11,10 @@
  * license.
  *
  * See README and COPYING for more details.
+ *
+ * Please note that the newer Broadcom driver ("hybrid Linux driver") supports
+ * Linux wireless extensions and does not need (or even work) with this old
+ * driver wrapper. Use driver_wext.c with that driver.
  */
 
 #include "includes.h"

Modified: wpasupplicant/trunk/src/drivers/driver_bsd.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/drivers/driver_bsd.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/drivers/driver_bsd.c (original)
+++ wpasupplicant/trunk/src/drivers/driver_bsd.c Sun Feb 15 20:49:57 2009
@@ -21,7 +21,13 @@
 #include "ieee802_11_defs.h"
 
 #include <net/if.h>
+
+#ifdef __NetBSD__
+#include <net/if_ether.h>
+#define COMPAT_FREEBSD_NET80211
+#else
 #include <net/ethernet.h>
+#endif
 
 #include <net80211/ieee80211.h>
 #include <net80211/ieee80211_crypto.h>
@@ -449,7 +455,12 @@
 }
 
 #include <net/route.h>
+#if __FreeBSD__
 #include <net80211/ieee80211_freebsd.h>
+#endif
+#if __NetBSD__
+#include <net80211/ieee80211_netbsd.h>
+#endif
 
 static void
 wpa_driver_bsd_event_receive(int sock, void *ctx, void *sock_ctx)

Modified: wpasupplicant/trunk/src/drivers/driver_madwifi.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/drivers/driver_madwifi.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/drivers/driver_madwifi.c (original)
+++ wpasupplicant/trunk/src/drivers/driver_madwifi.c Sun Feb 15 20:49:57 2009
@@ -59,7 +59,8 @@
 
 	os_memset(&iwr, 0, sizeof(iwr));
 	os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
-	if (len < IFNAMSIZ) {
+	if (len < IFNAMSIZ &&
+	    op != IEEE80211_IOCTL_SET_APPIEBUF) {
 		/*
 		 * Argument data fits inline; put it there.
 		 */
@@ -90,7 +91,7 @@
 				"ioctl[IEEE80211_IOCTL_GETCHANLIST]",
 				"ioctl[IEEE80211_IOCTL_CHANSWITCH]",
 				NULL,
-				NULL,
+				"ioctl[IEEE80211_IOCTL_SET_APPIEBUF]",
 				"ioctl[IEEE80211_IOCTL_GETSCANRESULTS]",
 				NULL,
 				"ioctl[IEEE80211_IOCTL_GETCHANINFO]",
@@ -482,6 +483,30 @@
 }
 
 
+static int wpa_driver_madwifi_set_probe_req_ie(void *priv, const u8 *ies,
+					       size_t ies_len)
+{
+	struct ieee80211req_getset_appiebuf *probe_req_ie;
+	int ret;
+
+	probe_req_ie = os_malloc(sizeof(*probe_req_ie) + ies_len);
+	if (probe_req_ie == NULL)
+		return -1;
+
+	probe_req_ie->app_frmtype = IEEE80211_APPIE_FRAME_PROBE_REQ;
+	probe_req_ie->app_buflen = ies_len;
+	os_memcpy(probe_req_ie->app_buf, ies, ies_len);
+
+	ret = set80211priv(priv, IEEE80211_IOCTL_SET_APPIEBUF, probe_req_ie,
+			   sizeof(struct ieee80211req_getset_appiebuf) +
+			   ies_len, 1);
+
+	os_free(probe_req_ie);
+
+	return ret;
+}
+
+
 static void * wpa_driver_madwifi_init(void *ctx, const char *ifname)
 {
 	struct wpa_driver_madwifi_data *drv;
@@ -568,4 +593,5 @@
 	.associate		= wpa_driver_madwifi_associate,
 	.set_auth_alg		= wpa_driver_madwifi_set_auth_alg,
 	.set_operstate		= wpa_driver_madwifi_set_operstate,
+	.set_probe_req_ie	= wpa_driver_madwifi_set_probe_req_ie,
 };

Modified: wpasupplicant/trunk/src/drivers/driver_nl80211.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/drivers/driver_nl80211.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/drivers/driver_nl80211.c (original)
+++ wpasupplicant/trunk/src/drivers/driver_nl80211.c Sun Feb 15 20:49:57 2009
@@ -49,7 +49,7 @@
 
 struct wpa_driver_nl80211_data {
 	void *ctx;
-	int event_sock;
+	int wext_event_sock;
 	int ioctl_sock;
 	char ifname[IFNAMSIZ + 1];
 	int ifindex;
@@ -151,6 +151,68 @@
 }
 
 
+struct family_data {
+	const char *group;
+	int id;
+};
+
+
+static int family_handler(struct nl_msg *msg, void *arg)
+{
+	struct family_data *res = arg;
+	struct nlattr *tb[CTRL_ATTR_MAX + 1];
+	struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
+	struct nlattr *mcgrp;
+	int i;
+
+	nla_parse(tb, CTRL_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
+		  genlmsg_attrlen(gnlh, 0), NULL);
+	if (!tb[CTRL_ATTR_MCAST_GROUPS])
+		return NL_SKIP;
+
+	nla_for_each_nested(mcgrp, tb[CTRL_ATTR_MCAST_GROUPS], i) {
+		struct nlattr *tb2[CTRL_ATTR_MCAST_GRP_MAX + 1];
+		nla_parse(tb2, CTRL_ATTR_MCAST_GRP_MAX, nla_data(mcgrp),
+			  nla_len(mcgrp), NULL);
+		if (!tb2[CTRL_ATTR_MCAST_GRP_NAME] ||
+		    !tb2[CTRL_ATTR_MCAST_GRP_ID] ||
+		    os_strncmp(nla_data(tb2[CTRL_ATTR_MCAST_GRP_NAME]),
+			       res->group,
+			       nla_len(tb2[CTRL_ATTR_MCAST_GRP_NAME])) != 0)
+			continue;
+		res->id = nla_get_u32(tb2[CTRL_ATTR_MCAST_GRP_ID]);
+		break;
+	};
+
+	return NL_SKIP;
+}
+
+
+static int nl_get_multicast_id(struct wpa_driver_nl80211_data *drv,
+			       const char *family, const char *group)
+{
+	struct nl_msg *msg;
+	int ret = -1;
+	struct family_data res = { group, -ENOENT };
+
+	msg = nlmsg_alloc();
+	if (!msg)
+		return -ENOMEM;
+	genlmsg_put(msg, 0, 0, genl_ctrl_resolve(drv->nl_handle, "nlctrl"),
+		    0, 0, CTRL_CMD_GETFAMILY, 0);
+	NLA_PUT_STRING(msg, CTRL_ATTR_FAMILY_NAME, family);
+
+	ret = send_and_recv_msgs(drv, msg, family_handler, &res);
+	msg = NULL;
+	if (ret == 0)
+		ret = res.id;
+
+nla_put_failure:
+	nlmsg_free(msg);
+	return ret;
+}
+
+
 static int wpa_driver_nl80211_send_oper_ifla(
 	struct wpa_driver_nl80211_data *drv,
 	int linkmode, int operstate)
@@ -200,7 +262,7 @@
 	wpa_printf(MSG_DEBUG, "WEXT: Operstate: linkmode=%d, operstate=%d",
 		   linkmode, operstate);
 
-	ret = send(drv->event_sock, &req, req.hdr.nlmsg_len, 0);
+	ret = send(drv->wext_event_sock, &req, req.hdr.nlmsg_len, 0);
 	if (ret < 0) {
 		wpa_printf(MSG_DEBUG, "WEXT: Sending operstate IFLA failed: "
 			   "%s (assume operstate is not supported)",
@@ -631,12 +693,6 @@
 			wpa_driver_nl80211_event_wireless_custom(ctx, buf);
 			os_free(buf);
 			break;
-		case SIOCGIWSCAN:
-			drv->scan_complete_events = 1;
-			eloop_cancel_timeout(wpa_driver_nl80211_scan_timeout,
-					     drv, ctx);
-			wpa_supplicant_event(ctx, EVENT_SCAN_RESULTS, NULL);
-			break;
 		case IWEVASSOCREQIE:
 			wpa_driver_nl80211_event_wireless_assocreqie(
 				drv, custom, iwe->u.data.length);
@@ -832,8 +888,8 @@
 }
 
 
-static void wpa_driver_nl80211_event_receive(int sock, void *eloop_ctx,
-					  void *sock_ctx)
+static void wpa_driver_nl80211_event_receive_wext(int sock, void *eloop_ctx,
+						  void *sock_ctx)
 {
 	char buf[8192];
 	int left;
@@ -899,6 +955,77 @@
 }
 
 
+static int no_seq_check(struct nl_msg *msg, void *arg)
+{
+	return NL_OK;
+}
+
+
+static int process_event(struct nl_msg *msg, void *arg)
+{
+	struct wpa_driver_nl80211_data *drv = arg;
+	struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
+	struct nlattr *tb[NL80211_ATTR_MAX + 1];
+
+	nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
+		  genlmsg_attrlen(gnlh, 0), NULL);
+
+	if (tb[NL80211_ATTR_IFINDEX]) {
+		int ifindex = nla_get_u32(tb[NL80211_ATTR_IFINDEX]);
+		if (ifindex != drv->ifindex) {
+			wpa_printf(MSG_DEBUG, "nl80211: Ignored event (cmd=%d)"
+				   " for foreign interface (ifindex %d)",
+				   gnlh->cmd, ifindex);
+			return NL_SKIP;
+		}
+	}
+
+	switch (gnlh->cmd) {
+	case NL80211_CMD_NEW_SCAN_RESULTS:
+		wpa_printf(MSG_DEBUG, "nl80211: New scan results available");
+		drv->scan_complete_events = 1;
+		eloop_cancel_timeout(wpa_driver_nl80211_scan_timeout, drv,
+				     drv->ctx);
+		wpa_supplicant_event(drv->ctx, EVENT_SCAN_RESULTS, NULL);
+		break;
+	case NL80211_CMD_SCAN_ABORTED:
+		wpa_printf(MSG_DEBUG, "nl80211: Scan aborted");
+		/*
+		 * Need to indicate that scan results are available in order
+		 * not to make wpa_supplicant stop its scanning.
+		 */
+		eloop_cancel_timeout(wpa_driver_nl80211_scan_timeout, drv,
+				     drv->ctx);
+		wpa_supplicant_event(drv->ctx, EVENT_SCAN_RESULTS, NULL);
+		break;
+	default:
+		wpa_printf(MSG_DEBUG, "nl0211: Ignored unknown event (cmd=%d)",
+			   gnlh->cmd);
+		break;
+	}
+
+	return NL_SKIP;
+}
+
+
+static void wpa_driver_nl80211_event_receive(int sock, void *eloop_ctx,
+					     void *sock_ctx)
+{
+	struct nl_cb *cb;
+	struct wpa_driver_nl80211_data *drv = eloop_ctx;
+
+	wpa_printf(MSG_DEBUG, "nl80211: Event message available");
+
+	cb = nl_cb_clone(drv->nl_cb);
+	if (!cb)
+		return;
+	nl_cb_set(cb, NL_CB_SEQ_CHECK, NL_CB_CUSTOM, no_seq_check, NULL);
+	nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, process_event, drv);
+	nl_recvmsgs(drv->nl_handle, cb);
+	nl_cb_put(cb);
+}
+
+
 static int wpa_driver_nl80211_get_ifflags_ifname(struct wpa_driver_nl80211_data *drv,
 					      const char *ifname, int *flags)
 {
@@ -990,6 +1117,36 @@
 	return 0;
 nla_put_failure:
 	return -EINVAL;
+}
+
+
+static int wpa_driver_nl80211_set_probe_req_ie(void *priv, const u8 *ies,
+					       size_t ies_len)
+{
+	struct wpa_driver_nl80211_data *drv = priv;
+	struct nl_msg *msg;
+	int ret = -1;
+
+	msg = nlmsg_alloc();
+	if (!msg)
+		return -ENOMEM;
+
+	genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0, 0,
+		    NL80211_CMD_SET_MGMT_EXTRA_IE, 0);
+
+	NLA_PUT_U8(msg, NL80211_ATTR_MGMT_SUBTYPE, 4 /* ProbeReq */);
+	if (ies)
+		NLA_PUT(msg, NL80211_ATTR_IE, ies_len, ies);
+
+	ret = 0;
+
+	NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, drv->ifindex);
+
+	ret = send_and_recv_msgs(drv, msg, NULL, NULL);
+	return ret;
+
+nla_put_failure:
+	return -ENOBUFS;
 }
 
 
@@ -1254,7 +1411,7 @@
  */
 static void * wpa_driver_nl80211_init(void *ctx, const char *ifname)
 {
-	int s;
+	int s, ret;
 	struct sockaddr_nl local;
 	struct wpa_driver_nl80211_data *drv;
 
@@ -1297,6 +1454,18 @@
 			   "found");
 		goto err4;
 	}
+
+	ret = nl_get_multicast_id(drv, "nl80211", "scan");
+	if (ret >= 0)
+		ret = nl_socket_add_membership(drv->nl_handle, ret);
+	if (ret < 0) {
+		wpa_printf(MSG_ERROR, "nl80211: Could not add multicast "
+			   "membership for scan events: %d (%s)",
+			   ret, strerror(-ret));
+		goto err4;
+	}
+	eloop_register_read_sock(nl_socket_get_fd(drv->nl_handle),
+				 wpa_driver_nl80211_event_receive, drv, ctx);
 
 	drv->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0);
 	if (drv->ioctl_sock < 0) {
@@ -1319,9 +1488,9 @@
 		goto err6;
 	}
 
-	eloop_register_read_sock(s, wpa_driver_nl80211_event_receive, drv,
+	eloop_register_read_sock(s, wpa_driver_nl80211_event_receive_wext, drv,
 				 ctx);
-	drv->event_sock = s;
+	drv->wext_event_sock = s;
 
 	wpa_driver_nl80211_finish_drv_init(drv);
 
@@ -1354,17 +1523,6 @@
 		if (wpa_driver_nl80211_set_ifflags(drv, flags | IFF_UP) != 0) {
 			printf("Could not set interface '%s' UP\n",
 			       drv->ifname);
-		} else {
-			/*
-			 * Wait some time to allow driver to initialize before
-			 * starting configuring the driver. This seems to be
-			 * needed at least some drivers that load firmware etc.
-			 * when the interface is set up.
-			 */
-			wpa_printf(MSG_DEBUG, "Interface %s set UP - waiting "
-				   "a second for the driver to complete "
-				   "initialization", drv->ifname);
-			sleep(1);
 		}
 	}
 
@@ -1419,16 +1577,17 @@
 
 	wpa_driver_nl80211_send_oper_ifla(priv, 0, IF_OPER_UP);
 
-	eloop_unregister_read_sock(drv->event_sock);
+	eloop_unregister_read_sock(drv->wext_event_sock);
 
 	if (wpa_driver_nl80211_get_ifflags(drv, &flags) == 0)
 		(void) wpa_driver_nl80211_set_ifflags(drv, flags & ~IFF_UP);
 
-	close(drv->event_sock);
+	close(drv->wext_event_sock);
 	close(drv->ioctl_sock);
 	os_free(drv->assoc_req_ies);
 	os_free(drv->assoc_resp_ies);
 
+	eloop_unregister_read_sock(nl_socket_get_fd(drv->nl_handle));
 	genl_family_put(drv->nl80211);
 	nl_cache_free(drv->nl_cache);
 	nl_handle_destroy(drv->nl_handle);
@@ -1465,38 +1624,42 @@
 static int wpa_driver_nl80211_scan(void *priv, const u8 *ssid, size_t ssid_len)
 {
 	struct wpa_driver_nl80211_data *drv = priv;
-	struct iwreq iwr;
 	int ret = 0, timeout;
-	struct iw_scan_req req;
-
-	if (ssid_len > IW_ESSID_MAX_SIZE) {
-		wpa_printf(MSG_DEBUG, "%s: too long SSID (%lu)",
-			   __FUNCTION__, (unsigned long) ssid_len);
+	struct nl_msg *msg, *ssids;
+
+	msg = nlmsg_alloc();
+	ssids = nlmsg_alloc();
+	if (!msg || !ssids) {
+		nlmsg_free(msg);
+		nlmsg_free(ssids);
 		return -1;
 	}
 
-	os_memset(&iwr, 0, sizeof(iwr));
-	os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
+	genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0, 0,
+		    NL80211_CMD_TRIGGER_SCAN, 0);
+
+	NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, drv->ifindex);
 
 	if (ssid && ssid_len) {
-		os_memset(&req, 0, sizeof(req));
-		req.essid_len = ssid_len;
-		req.bssid.sa_family = ARPHRD_ETHER;
-		os_memset(req.bssid.sa_data, 0xff, ETH_ALEN);
-		os_memcpy(req.essid, ssid, ssid_len);
-		iwr.u.data.pointer = (caddr_t) &req;
-		iwr.u.data.length = sizeof(req);
-		iwr.u.data.flags = IW_SCAN_THIS_ESSID;
-	}
-
-	if (ioctl(drv->ioctl_sock, SIOCSIWSCAN, &iwr) < 0) {
-		perror("ioctl[SIOCSIWSCAN]");
-		ret = -1;
+		/* Request an active scan for a specific SSID */
+		NLA_PUT(ssids, 1, ssid_len, ssid);
+	} else {
+		/* Request an active scan for wildcard SSID */
+		NLA_PUT(ssids, 1, 0, "");
+	}
+	nla_put_nested(msg, NL80211_ATTR_SCAN_SSIDS, ssids);
+
+	ret = send_and_recv_msgs(drv, msg, NULL, NULL);
+	msg = NULL;
+	if (ret) {
+		wpa_printf(MSG_DEBUG, "nl80211: Scan trigger failed: ret=%d "
+			   "(%s)", ret, strerror(-ret));
+		goto nla_put_failure;
 	}
 
 	/* Not all drivers generate "scan completed" wireless event, so try to
 	 * read results after a timeout. */
-	timeout = 5;
+	timeout = 10;
 	if (drv->scan_complete_events) {
 		/*
 		 * The driver seems to deliver SIOCGIWSCAN events to notify
@@ -1508,341 +1671,86 @@
 	wpa_printf(MSG_DEBUG, "Scan requested (ret=%d) - scan timeout %d "
 		   "seconds", ret, timeout);
 	eloop_cancel_timeout(wpa_driver_nl80211_scan_timeout, drv, drv->ctx);
-	eloop_register_timeout(timeout, 0, wpa_driver_nl80211_scan_timeout, drv,
-			       drv->ctx);
-
+	eloop_register_timeout(timeout, 0, wpa_driver_nl80211_scan_timeout,
+			       drv, drv->ctx);
+
+nla_put_failure:
+	nlmsg_free(ssids);
+	nlmsg_free(msg);
 	return ret;
 }
 
 
-static u8 * wpa_driver_nl80211_giwscan(struct wpa_driver_nl80211_data *drv,
-				    size_t *len)
-{
-	struct iwreq iwr;
-	u8 *res_buf;
-	size_t res_buf_len;
-
-	res_buf_len = IW_SCAN_MAX_DATA;
-	for (;;) {
-		res_buf = os_malloc(res_buf_len);
-		if (res_buf == NULL)
-			return NULL;
-		os_memset(&iwr, 0, sizeof(iwr));
-		os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
-		iwr.u.data.pointer = res_buf;
-		iwr.u.data.length = res_buf_len;
-
-		if (ioctl(drv->ioctl_sock, SIOCGIWSCAN, &iwr) == 0)
-			break;
-
-		if (errno == E2BIG && res_buf_len < 100000) {
-			os_free(res_buf);
-			res_buf = NULL;
-			res_buf_len *= 2;
-			wpa_printf(MSG_DEBUG, "Scan results did not fit - "
-				   "trying larger buffer (%lu bytes)",
-				   (unsigned long) res_buf_len);
-		} else {
-			perror("ioctl[SIOCGIWSCAN]");
-			os_free(res_buf);
-			return NULL;
-		}
-	}
-
-	if (iwr.u.data.length > res_buf_len) {
-		os_free(res_buf);
-		return NULL;
-	}
-	*len = iwr.u.data.length;
-
-	return res_buf;
-}
-
-
-/*
- * Data structure for collecting WEXT scan results. This is needed to allow
- * the various methods of reporting IEs to be combined into a single IE buffer.
- */
-struct wext_scan_data {
-	struct wpa_scan_res res;
-	u8 *ie;
-	size_t ie_len;
-	u8 ssid[32];
-	size_t ssid_len;
-	int maxrate;
-};
-
-
-static void wext_get_scan_mode(struct iw_event *iwe,
-			       struct wext_scan_data *res)
-{
-	if (iwe->u.mode == IW_MODE_ADHOC)
-		res->res.caps |= IEEE80211_CAP_IBSS;
-	else if (iwe->u.mode == IW_MODE_MASTER || iwe->u.mode == IW_MODE_INFRA)
-		res->res.caps |= IEEE80211_CAP_ESS;
-}
-
-
-static void wext_get_scan_ssid(struct iw_event *iwe,
-			       struct wext_scan_data *res, char *custom,
-			       char *end)
-{
-	int ssid_len = iwe->u.essid.length;
-	if (custom + ssid_len > end)
-		return;
-	if (iwe->u.essid.flags &&
-	    ssid_len > 0 &&
-	    ssid_len <= IW_ESSID_MAX_SIZE) {
-		os_memcpy(res->ssid, custom, ssid_len);
-		res->ssid_len = ssid_len;
-	}
-}
-
-
-static void wext_get_scan_freq(struct iw_event *iwe,
-			       struct wext_scan_data *res)
-{
-	int divi = 1000000, i;
-
-	if (iwe->u.freq.e == 0) {
-		/*
-		 * Some drivers do not report frequency, but a channel.
-		 * Try to map this to frequency by assuming they are using
-		 * IEEE 802.11b/g.  But don't overwrite a previously parsed
-		 * frequency if the driver sends both frequency and channel,
-		 * since the driver may be sending an A-band channel that we
-		 * don't handle here.
-		 */
-
-		if (res->res.freq)
-			return;
-
-		if (iwe->u.freq.m >= 1 && iwe->u.freq.m <= 13) {
-			res->res.freq = 2407 + 5 * iwe->u.freq.m;
-			return;
-		} else if (iwe->u.freq.m == 14) {
-			res->res.freq = 2484;
-			return;
-		}
-	}
-
-	if (iwe->u.freq.e > 6) {
-		wpa_printf(MSG_DEBUG, "Invalid freq in scan results (BSSID="
-			   MACSTR " m=%d e=%d)",
-			   MAC2STR(res->res.bssid), iwe->u.freq.m,
-			   iwe->u.freq.e);
-		return;
-	}
-
-	for (i = 0; i < iwe->u.freq.e; i++)
-		divi /= 10;
-	res->res.freq = iwe->u.freq.m / divi;
-}
-
-
-static void wext_get_scan_qual(struct iw_event *iwe,
-			       struct wext_scan_data *res)
-{
-	res->res.qual = iwe->u.qual.qual;
-	res->res.noise = iwe->u.qual.noise;
-	res->res.level = iwe->u.qual.level;
-}
-
-
-static void wext_get_scan_encode(struct iw_event *iwe,
-				 struct wext_scan_data *res)
-{
-	if (!(iwe->u.data.flags & IW_ENCODE_DISABLED))
-		res->res.caps |= IEEE80211_CAP_PRIVACY;
-}
-
-
-static void wext_get_scan_rate(struct iw_event *iwe,
-			       struct wext_scan_data *res, char *pos,
-			       char *end)
-{
-	int maxrate;
-	char *custom = pos + IW_EV_LCP_LEN;
-	struct iw_param p;
-	size_t clen;
-
-	clen = iwe->len;
-	if (custom + clen > end)
-		return;
-	maxrate = 0;
-	while (((ssize_t) clen) >= (ssize_t) sizeof(struct iw_param)) {
-		/* Note: may be misaligned, make a local, aligned copy */
-		os_memcpy(&p, custom, sizeof(struct iw_param));
-		if (p.value > maxrate)
-			maxrate = p.value;
-		clen -= sizeof(struct iw_param);
-		custom += sizeof(struct iw_param);
-	}
-
-	/* Convert the maxrate from WE-style (b/s units) to
-	 * 802.11 rates (500000 b/s units).
-	 */
-	res->maxrate = maxrate / 500000;
-}
-
-
-static void wext_get_scan_iwevgenie(struct iw_event *iwe,
-				    struct wext_scan_data *res, char *custom,
-				    char *end)
-{
-	char *genie, *gpos, *gend;
-	u8 *tmp;
-
-	if (iwe->u.data.length == 0)
-		return;
-
-	gpos = genie = custom;
-	gend = genie + iwe->u.data.length;
-	if (gend > end) {
-		wpa_printf(MSG_INFO, "IWEVGENIE overflow");
-		return;
-	}
-
-	tmp = os_realloc(res->ie, res->ie_len + gend - gpos);
-	if (tmp == NULL)
-		return;
-	os_memcpy(tmp + res->ie_len, gpos, gend - gpos);
-	res->ie = tmp;
-	res->ie_len += gend - gpos;
-}
-
-
-static void wext_get_scan_custom(struct iw_event *iwe,
-				 struct wext_scan_data *res, char *custom,
-				 char *end)
-{
-	size_t clen;
-	u8 *tmp;
-
-	clen = iwe->u.data.length;
-	if (custom + clen > end)
-		return;
-
-	if (clen > 7 && os_strncmp(custom, "wpa_ie=", 7) == 0) {
-		char *spos;
-		int bytes;
-		spos = custom + 7;
-		bytes = custom + clen - spos;
-		if (bytes & 1 || bytes == 0)
-			return;
-		bytes /= 2;
-		tmp = os_realloc(res->ie, res->ie_len + bytes);
-		if (tmp == NULL)
-			return;
-		hexstr2bin(spos, tmp + res->ie_len, bytes);
-		res->ie = tmp;
-		res->ie_len += bytes;
-	} else if (clen > 7 && os_strncmp(custom, "rsn_ie=", 7) == 0) {
-		char *spos;
-		int bytes;
-		spos = custom + 7;
-		bytes = custom + clen - spos;
-		if (bytes & 1 || bytes == 0)
-			return;
-		bytes /= 2;
-		tmp = os_realloc(res->ie, res->ie_len + bytes);
-		if (tmp == NULL)
-			return;
-		hexstr2bin(spos, tmp + res->ie_len, bytes);
-		res->ie = tmp;
-		res->ie_len += bytes;
-	} else if (clen > 4 && os_strncmp(custom, "tsf=", 4) == 0) {
-		char *spos;
-		int bytes;
-		u8 bin[8];
-		spos = custom + 4;
-		bytes = custom + clen - spos;
-		if (bytes != 16) {
-			wpa_printf(MSG_INFO, "Invalid TSF length (%d)", bytes);
-			return;
-		}
-		bytes /= 2;
-		hexstr2bin(spos, bin, bytes);
-		res->res.tsf += WPA_GET_BE64(bin);
-	}
-}
-
-
-static int wext_19_iw_point(struct wpa_driver_nl80211_data *drv, u16 cmd)
-{
-	return drv->we_version_compiled > 18 &&
-		(cmd == SIOCGIWESSID || cmd == SIOCGIWENCODE ||
-		 cmd == IWEVGENIE || cmd == IWEVCUSTOM);
-}
-
-
-static void wpa_driver_nl80211_add_scan_entry(struct wpa_scan_results *res,
-					   struct wext_scan_data *data)
-{
+static int bss_info_handler(struct nl_msg *msg, void *arg)
+{
+	struct nlattr *tb[NL80211_ATTR_MAX + 1];
+	struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
+	struct nlattr *bss[NL80211_BSS_MAX + 1];
+	static struct nla_policy bss_policy[NL80211_BSS_MAX + 1] = {
+		[NL80211_BSS_BSSID] = { .type = NLA_UNSPEC },
+		[NL80211_BSS_FREQUENCY] = { .type = NLA_U32 },
+		[NL80211_BSS_TSF] = { .type = NLA_U64 },
+		[NL80211_BSS_BEACON_INTERVAL] = { .type = NLA_U16 },
+		[NL80211_BSS_CAPABILITY] = { .type = NLA_U16 },
+		[NL80211_BSS_INFORMATION_ELEMENTS] = { .type = NLA_UNSPEC },
+		[NL80211_BSS_SIGNAL_MBM] = { .type = NLA_U32 },
+		[NL80211_BSS_SIGNAL_UNSPEC] = { .type = NLA_U8 },
+	};
+	struct wpa_scan_results *res = arg;
 	struct wpa_scan_res **tmp;
 	struct wpa_scan_res *r;
-	size_t extra_len;
-	u8 *pos, *end, *ssid_ie = NULL, *rate_ie = NULL;
-
-	/* Figure out whether we need to fake any IEs */
-	pos = data->ie;
-	end = pos + data->ie_len;
-	while (pos && pos + 1 < end) {
-		if (pos + 2 + pos[1] > end)
-			break;
-		if (pos[0] == WLAN_EID_SSID)
-			ssid_ie = pos;
-		else if (pos[0] == WLAN_EID_SUPP_RATES)
-			rate_ie = pos;
-		else if (pos[0] == WLAN_EID_EXT_SUPP_RATES)
-			rate_ie = pos;
-		pos += 2 + pos[1];
-	}
-
-	extra_len = 0;
-	if (ssid_ie == NULL)
-		extra_len += 2 + data->ssid_len;
-	if (rate_ie == NULL && data->maxrate)
-		extra_len += 3;
-
-	r = os_zalloc(sizeof(*r) + extra_len + data->ie_len);
+	const u8 *ie;
+	size_t ie_len;
+
+	nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
+		  genlmsg_attrlen(gnlh, 0), NULL);
+	if (!tb[NL80211_ATTR_BSS])
+		return NL_SKIP;
+	if (nla_parse_nested(bss, NL80211_BSS_MAX, tb[NL80211_ATTR_BSS],
+			     bss_policy))
+		return NL_SKIP;
+	if (bss[NL80211_BSS_INFORMATION_ELEMENTS]) {
+		ie = nla_data(bss[NL80211_BSS_INFORMATION_ELEMENTS]);
+		ie_len = nla_len(bss[NL80211_BSS_INFORMATION_ELEMENTS]);
+	} else {
+		ie = NULL;
+		ie_len = 0;
+	}
+
+	r = os_zalloc(sizeof(*r) + ie_len);
 	if (r == NULL)
-		return;
-	os_memcpy(r, &data->res, sizeof(*r));
-	r->ie_len = extra_len + data->ie_len;
-	pos = (u8 *) (r + 1);
-	if (ssid_ie == NULL) {
-		/*
-		 * Generate a fake SSID IE since the driver did not report
-		 * a full IE list.
-		 */
-		*pos++ = WLAN_EID_SSID;
-		*pos++ = data->ssid_len;
-		os_memcpy(pos, data->ssid, data->ssid_len);
-		pos += data->ssid_len;
-	}
-	if (rate_ie == NULL && data->maxrate) {
-		/*
-		 * Generate a fake Supported Rates IE since the driver did not
-		 * report a full IE list.
-		 */
-		*pos++ = WLAN_EID_SUPP_RATES;
-		*pos++ = 1;
-		*pos++ = data->maxrate;
-	}
-	if (data->ie)
-		os_memcpy(pos, data->ie, data->ie_len);
+		return NL_SKIP;
+	if (bss[NL80211_BSS_BSSID])
+		os_memcpy(r->bssid, nla_data(bss[NL80211_BSS_BSSID]),
+			  ETH_ALEN);
+	if (bss[NL80211_BSS_FREQUENCY])
+		r->freq = nla_get_u32(bss[NL80211_BSS_FREQUENCY]);
+	if (bss[NL80211_BSS_BEACON_INTERVAL])
+		r->beacon_int = nla_get_u16(bss[NL80211_BSS_BEACON_INTERVAL]);
+	if (bss[NL80211_BSS_CAPABILITY])
+		r->caps = nla_get_u16(bss[NL80211_BSS_CAPABILITY]);
+	if (bss[NL80211_BSS_SIGNAL_UNSPEC])
+		r->qual = nla_get_u8(bss[NL80211_BSS_SIGNAL_UNSPEC]);
+	if (bss[NL80211_BSS_SIGNAL_MBM])
+		r->level = nla_get_u32(bss[NL80211_BSS_SIGNAL_MBM]);
+	if (bss[NL80211_BSS_TSF])
+		r->tsf = nla_get_u64(bss[NL80211_BSS_TSF]);
+	r->ie_len = ie_len;
+	if (ie)
+		os_memcpy(r + 1, ie, ie_len);
 
 	tmp = os_realloc(res->res,
 			 (res->num + 1) * sizeof(struct wpa_scan_res *));
 	if (tmp == NULL) {
 		os_free(r);
-		return;
+		return NL_SKIP;
 	}
 	tmp[res->num++] = r;
 	res->res = tmp;
-}
-				      
+
+	return NL_SKIP;
+}
+
 
 /**
  * wpa_driver_nl80211_get_scan_results - Fetch the latest scan results
@@ -1853,98 +1761,34 @@
 wpa_driver_nl80211_get_scan_results(void *priv)
 {
 	struct wpa_driver_nl80211_data *drv = priv;
-	size_t ap_num = 0, len;
-	int first;
-	u8 *res_buf;
-	struct iw_event iwe_buf, *iwe = &iwe_buf;
-	char *pos, *end, *custom;
+	struct nl_msg *msg;
 	struct wpa_scan_results *res;
-	struct wext_scan_data data;
-
-	res_buf = wpa_driver_nl80211_giwscan(drv, &len);
-	if (res_buf == NULL)
-		return NULL;
-
-	ap_num = 0;
-	first = 1;
+	int ret;
 
 	res = os_zalloc(sizeof(*res));
-	if (res == NULL) {
-		os_free(res_buf);
-		return NULL;
-	}
-
-	pos = (char *) res_buf;
-	end = (char *) res_buf + len;
-	os_memset(&data, 0, sizeof(data));
-
-	while (pos + IW_EV_LCP_LEN <= end) {
-		/* Event data may be unaligned, so make a local, aligned copy
-		 * before processing. */
-		os_memcpy(&iwe_buf, pos, IW_EV_LCP_LEN);
-		if (iwe->len <= IW_EV_LCP_LEN)
-			break;
-
-		custom = pos + IW_EV_POINT_LEN;
-		if (wext_19_iw_point(drv, iwe->cmd)) {
-			/* WE-19 removed the pointer from struct iw_point */
-			char *dpos = (char *) &iwe_buf.u.data.length;
-			int dlen = dpos - (char *) &iwe_buf;
-			os_memcpy(dpos, pos + IW_EV_LCP_LEN,
-				  sizeof(struct iw_event) - dlen);
-		} else {
-			os_memcpy(&iwe_buf, pos, sizeof(struct iw_event));
-			custom += IW_EV_POINT_OFF;
-		}
-
-		switch (iwe->cmd) {
-		case SIOCGIWAP:
-			if (!first)
-				wpa_driver_nl80211_add_scan_entry(res, &data);
-			first = 0;
-			os_free(data.ie);
-			os_memset(&data, 0, sizeof(data));
-			os_memcpy(data.res.bssid,
-				  iwe->u.ap_addr.sa_data, ETH_ALEN);
-			break;
-		case SIOCGIWMODE:
-			wext_get_scan_mode(iwe, &data);
-			break;
-		case SIOCGIWESSID:
-			wext_get_scan_ssid(iwe, &data, custom, end);
-			break;
-		case SIOCGIWFREQ:
-			wext_get_scan_freq(iwe, &data);
-			break;
-		case IWEVQUAL:
-			wext_get_scan_qual(iwe, &data);
-			break;
-		case SIOCGIWENCODE:
-			wext_get_scan_encode(iwe, &data);
-			break;
-		case SIOCGIWRATE:
-			wext_get_scan_rate(iwe, &data, pos, end);
-			break;
-		case IWEVGENIE:
-			wext_get_scan_iwevgenie(iwe, &data, custom, end);
-			break;
-		case IWEVCUSTOM:
-			wext_get_scan_custom(iwe, &data, custom, end);
-			break;
-		}
-
-		pos += iwe->len;
-	}
-	os_free(res_buf);
-	res_buf = NULL;
-	if (!first)
-		wpa_driver_nl80211_add_scan_entry(res, &data);
-	os_free(data.ie);
-
-	wpa_printf(MSG_DEBUG, "Received %lu bytes of scan results (%lu BSSes)",
-		   (unsigned long) len, (unsigned long) res->num);
-
-	return res;
+	if (res == NULL)
+		return 0;
+	msg = nlmsg_alloc();
+	if (!msg)
+		goto nla_put_failure;
+
+	genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0, NLM_F_DUMP,
+		    NL80211_CMD_GET_SCAN, 0);
+	NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, drv->ifindex);
+
+	ret = send_and_recv_msgs(drv, msg, bss_info_handler, res);
+	msg = NULL;
+	if (ret == 0) {
+		wpa_printf(MSG_DEBUG, "Received scan results (%lu BSSes)",
+			   (unsigned long) res->num);
+		return res;
+	}
+	wpa_printf(MSG_DEBUG, "nl80211: Scan result fetch failed: ret=%d "
+		   "(%s)", ret, strerror(-ret));
+nla_put_failure:
+	nlmsg_free(msg);
+	wpa_scan_results_free(res);
+	return NULL;
 }
 
 
@@ -2895,6 +2739,7 @@
 	.get_capa = wpa_driver_nl80211_get_capa,
 	.set_operstate = wpa_driver_nl80211_set_operstate,
 	.set_country = wpa_driver_nl80211_set_country,
+	.set_probe_req_ie = wpa_driver_nl80211_set_probe_req_ie,
 #ifdef CONFIG_CLIENT_MLME
 	.get_hw_feature_data = wpa_driver_nl80211_get_hw_feature_data,
 	.set_channel = wpa_driver_nl80211_set_channel,

Modified: wpasupplicant/trunk/src/drivers/driver_privsep.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/drivers/driver_privsep.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/drivers/driver_privsep.c (original)
+++ wpasupplicant/trunk/src/drivers/driver_privsep.c Sun Feb 15 20:49:57 2009
@@ -1,6 +1,6 @@
 /*
  * WPA Supplicant - privilege separated driver interface
- * Copyright (c) 2007, Jouni Malinen <j at w1.fi>
+ * Copyright (c) 2007-2009, Jouni Malinen <j at w1.fi>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -443,6 +443,22 @@
 }
 
 
+static void wpa_driver_privsep_event_sta_rx(void *ctx, u8 *buf, size_t len)
+{
+#ifdef CONFIG_CLIENT_MLME
+	struct ieee80211_rx_status *rx_status;
+
+	if (len < sizeof(*rx_status))
+		return;
+	rx_status = (struct ieee80211_rx_status *) buf;
+	buf += sizeof(*rx_status);
+	len -= sizeof(*rx_status);
+
+	wpa_supplicant_sta_rx(ctx, buf, len, rx_status);
+#endif /* CONFIG_CLIENT_MLME */
+}
+
+
 static void wpa_driver_privsep_receive(int sock, void *eloop_ctx,
 				       void *sock_ctx)
 {
@@ -476,8 +492,8 @@
 	os_memcpy(&event, buf, sizeof(int));
 	event_buf = &buf[sizeof(int)];
 	event_len = res - sizeof(int);
-	wpa_printf(MSG_DEBUG, "privsep: Event %d received (len=%d)",
-		   event, event_len);
+	wpa_printf(MSG_DEBUG, "privsep: Event %d received (len=%lu)",
+		   event, (unsigned long) event_len);
 
 	e = event;
 	switch (e) {
@@ -518,6 +534,11 @@
 	case PRIVSEP_EVENT_RX_EAPOL:
 		wpa_driver_privsep_event_rx_eapol(drv->ctx, event_buf,
 						  event_len);
+		break;
+	case PRIVSEP_EVENT_STA_RX:
+		wpa_driver_privsep_event_sta_rx(drv->ctx, event_buf,
+						event_len);
+		break;
 	}
 
 	os_free(buf);
@@ -732,6 +753,15 @@
 	wpa_printf(MSG_DEBUG, "%s mode=%d", __func__, mode);
 	return wpa_priv_cmd(drv, PRIVSEP_CMD_SET_MODE, &mode, sizeof(mode),
 			    NULL, NULL);
+}
+
+
+static int wpa_driver_privsep_set_country(void *priv, const char *alpha2)
+{
+	struct wpa_driver_privsep_data *drv = priv;
+	wpa_printf(MSG_DEBUG, "%s country='%s'", __func__, alpha2);
+	return wpa_priv_cmd(drv, PRIVSEP_CMD_SET_COUNTRY, alpha2,
+			    os_strlen(alpha2), NULL, NULL);
 }
 
 
@@ -775,7 +805,7 @@
 	wpa_driver_privsep_get_scan_results2,
 	NULL /* set_probe_req_ie */,
 	wpa_driver_privsep_set_mode,
-	NULL /* set_country */,
+	wpa_driver_privsep_set_country,
 	NULL /* global_init */,
 	NULL /* global_deinit */,
 	NULL /* init2 */,

Modified: wpasupplicant/trunk/src/drivers/driver_roboswitch.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/drivers/driver_roboswitch.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/drivers/driver_roboswitch.c (original)
+++ wpasupplicant/trunk/src/drivers/driver_roboswitch.c Sun Feb 15 20:49:57 2009
@@ -1,6 +1,6 @@
 /*
  * WPA Supplicant - roboswitch driver interface
- * Copyright (c) 2008 Jouke Witteveen
+ * Copyright (c) 2008-2009 Jouke Witteveen
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -47,7 +47,9 @@
 
 /* VLAN page registers */
 #define ROBO_VLAN_ACCESS	0x06	/* VLAN table Access register */
+#define ROBO_VLAN_ACCESS_5365	0x08	/* VLAN table Access register (5365) */
 #define ROBO_VLAN_READ		0x0C	/* VLAN read register */
+#define ROBO_VLAN_MAX		0xFF	/* Maximum number of VLANs */
 
 
 static const u8 pae_group_addr[ETH_ALEN] =
@@ -240,32 +242,44 @@
 				       const u8 *addr)
 {
 	int i;
-	u8 mport[4] = { ROBO_ARLCTRL_VEC_1, ROBO_ARLCTRL_ADDR_1,
-			ROBO_ARLCTRL_VEC_2, ROBO_ARLCTRL_ADDR_2 };
 	u16 _read[3], zero = 0;
-	/* same as at join */
-	u16 addr_word[ETH_ALEN / 2];
+	u16 addr_word[ETH_ALEN / 2]; /* same as at join */
 
 	for (i = 0; i < ETH_ALEN; i += 2)
 		addr_word[(ETH_ALEN - i) / 2 - 1] = WPA_GET_BE16(addr + i);
 
-	/* find our address/vector pair */
-	for (i = 0; i < 4; i += 2) {
-		wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE, mport[i],
-					   _read, 1);
-		if (_read[0] == drv->ports) {
-			wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE,
-						   mport[i + 1], _read, 3);
-			if (os_memcmp(_read, addr_word, 6) == 0)
-				break;
+	/* check if multiport address 1 was used */
+	wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE, ROBO_ARLCTRL_VEC_1,
+				   _read, 1);
+	if (_read[0] == drv->ports) {
+		wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE,
+					   ROBO_ARLCTRL_ADDR_1, _read, 3);
+		if (os_memcmp(_read, addr_word, 6) == 0) {
+			wpa_driver_roboswitch_write(drv, ROBO_ARLCTRL_PAGE,
+						    ROBO_ARLCTRL_VEC_1, &zero,
+						    1);
+			goto clean_up;
 		}
 	}
-	/* check if we found our address/vector pair and deactivate it */
-	if (i == 4)
-		return -1;
-	wpa_driver_roboswitch_write(drv, ROBO_ARLCTRL_PAGE, mport[i], &zero,
-				    1);
-
+
+	/* check if multiport address 2 was used */
+	wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE, ROBO_ARLCTRL_VEC_2,
+				   _read, 1);
+	if (_read[0] == drv->ports) {
+		wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE,
+					   ROBO_ARLCTRL_ADDR_2, _read, 3);
+		if (os_memcmp(_read, addr_word, 6) == 0) {
+			wpa_driver_roboswitch_write(drv, ROBO_ARLCTRL_PAGE,
+						    ROBO_ARLCTRL_VEC_2, &zero,
+						    1);
+			goto clean_up;
+		}
+	}
+
+	/* used multiport address not found */
+	return -1;
+
+clean_up:
 	/* leave the multiport registers in a sane state */
 	wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE, ROBO_ARLCTRL_VEC_1,
 				   _read, 1);
@@ -306,7 +320,7 @@
 {
 	struct wpa_driver_roboswitch_data *drv;
 	int len = -1, sep = -1;
-	u16 vlan = 0, vlan_read[2];
+	u16 vlan_max = ROBO_VLAN_MAX, vlan = 0, vlan_read[2];
 
 	drv = os_zalloc(sizeof(*drv));
 	if (drv == NULL) return NULL;
@@ -339,7 +353,7 @@
 		}
 		vlan *= 10;
 		vlan += ifname[sep] - '0';
-		if (vlan > 255) {
+		if (vlan > ROBO_VLAN_MAX) {
 			wpa_printf(MSG_INFO, "%s: VLAN out of range in "
 				   "interface name %s", __func__, ifname);
 			os_free(drv);
@@ -368,10 +382,19 @@
 		return NULL;
 	}
 
+	/* set the read bit */
 	vlan |= 1 << 13;
-	/* The BCM5365 uses a different register and is not accounted for. */
+	/* set and read back to see if the register can be used */
 	wpa_driver_roboswitch_write(drv, ROBO_VLAN_PAGE, ROBO_VLAN_ACCESS,
-				    &vlan, 1);
+				    &vlan_max, 1);
+	wpa_driver_roboswitch_read(drv, ROBO_VLAN_PAGE, ROBO_VLAN_ACCESS,
+				   &vlan_max, 1);
+	if (vlan_max == ROBO_VLAN_MAX) /* pre-5365 */
+		wpa_driver_roboswitch_write(drv, ROBO_VLAN_PAGE,
+					    ROBO_VLAN_ACCESS, &vlan, 1);
+	else /* 5365 uses a different register */
+		wpa_driver_roboswitch_write(drv, ROBO_VLAN_PAGE,
+					    ROBO_VLAN_ACCESS_5365, &vlan, 1);
 	wpa_driver_roboswitch_read(drv, ROBO_VLAN_PAGE, ROBO_VLAN_READ,
 				   vlan_read, 2);
 	if (!(vlan_read[1] & (1 << 4))) {

Modified: wpasupplicant/trunk/src/drivers/driver_wext.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/drivers/driver_wext.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/drivers/driver_wext.c (original)
+++ wpasupplicant/trunk/src/drivers/driver_wext.c Sun Feb 15 20:49:57 2009
@@ -1140,10 +1140,12 @@
 		if (ioctl(drv->ioctl_sock, SIOCGIWSCAN, &iwr) == 0)
 			break;
 
-		if (errno == E2BIG && res_buf_len < 100000) {
+		if (errno == E2BIG && res_buf_len < 65535) {
 			os_free(res_buf);
 			res_buf = NULL;
 			res_buf_len *= 2;
+			if (res_buf_len > 65535)
+				res_buf_len = 65535; /* 16-bit length field */
 			wpa_printf(MSG_DEBUG, "Scan results did not fit - "
 				   "trying larger buffer (%lu bytes)",
 				   (unsigned long) res_buf_len);
@@ -1690,6 +1692,7 @@
 	os_memset(&iwr, 0, sizeof(iwr));
 	os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
 	iwr.u.encoding.flags = key_idx + 1;
+	iwr.u.encoding.flags |= IW_ENCODE_TEMP;
 	if (alg == WPA_ALG_NONE)
 		iwr.u.encoding.flags |= IW_ENCODE_DISABLED;
 	iwr.u.encoding.pointer = (caddr_t) ext;
@@ -1819,6 +1822,7 @@
 	os_memset(&iwr, 0, sizeof(iwr));
 	os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
 	iwr.u.encoding.flags = key_idx + 1;
+	iwr.u.encoding.flags |= IW_ENCODE_TEMP;
 	if (alg == WPA_ALG_NONE)
 		iwr.u.encoding.flags |= IW_ENCODE_DISABLED;
 	iwr.u.encoding.pointer = (caddr_t) key;
@@ -1833,6 +1837,7 @@
 		os_memset(&iwr, 0, sizeof(iwr));
 		os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
 		iwr.u.encoding.flags = key_idx + 1;
+		iwr.u.encoding.flags |= IW_ENCODE_TEMP;
 		iwr.u.encoding.pointer = (caddr_t) NULL;
 		iwr.u.encoding.length = 0;
 		if (ioctl(drv->ioctl_sock, SIOCSIWENCODE, &iwr) < 0) {
@@ -1893,12 +1898,35 @@
 }
 
 
+static void wpa_driver_wext_disconnect(struct wpa_driver_wext_data *drv)
+{
+	const u8 null_bssid[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 };
+	u8 ssid[32];
+	int i;
+
+	/*
+	 * Clear the BSSID selection and set a random SSID to make sure the
+	 * driver will not be trying to associate with something even if it
+	 * does not understand SIOCSIWMLME commands (or tries to associate
+	 * automatically after deauth/disassoc).
+	 */
+	wpa_driver_wext_set_bssid(drv, null_bssid);
+
+	for (i = 0; i < 32; i++)
+		ssid[i] = rand() & 0xFF;
+	wpa_driver_wext_set_ssid(drv, ssid, 32);
+}
+
+
 static int wpa_driver_wext_deauthenticate(void *priv, const u8 *addr,
 					  int reason_code)
 {
 	struct wpa_driver_wext_data *drv = priv;
+	int ret;
 	wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
-	return wpa_driver_wext_mlme(drv, addr, IW_MLME_DEAUTH, reason_code);
+	wpa_driver_wext_disconnect(drv);
+	ret = wpa_driver_wext_mlme(drv, addr, IW_MLME_DEAUTH, reason_code);
+	return ret;
 }
 
 
@@ -1906,9 +1934,11 @@
 					int reason_code)
 {
 	struct wpa_driver_wext_data *drv = priv;
+	int ret;
 	wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
-	return wpa_driver_wext_mlme(drv, addr, IW_MLME_DISASSOC,
-				    reason_code);
+	ret = wpa_driver_wext_mlme(drv, addr, IW_MLME_DISASSOC, reason_code);
+	wpa_driver_wext_disconnect(drv);
+	return ret;
 }
 
 

Modified: wpasupplicant/trunk/src/drivers/scan_helpers.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/drivers/scan_helpers.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/drivers/scan_helpers.c (original)
+++ wpasupplicant/trunk/src/drivers/scan_helpers.c Sun Feb 15 20:49:57 2009
@@ -156,10 +156,13 @@
 		return -1;
 
 	/* best/max rate preferred if signal level close enough XXX */
-	maxrate_a = wpa_scan_get_max_rate(wa);
-	maxrate_b = wpa_scan_get_max_rate(wb);
-	if (maxrate_a != maxrate_b && abs(wb->level - wa->level) < 5)
-		return maxrate_b - maxrate_a;
+	if ((wa->level && wb->level && abs(wb->level - wa->level) < 5) ||
+	    (wa->qual && wb->qual && abs(wb->qual - wa->qual) < 10)) {
+		maxrate_a = wpa_scan_get_max_rate(wa);
+		maxrate_b = wpa_scan_get_max_rate(wb);
+		if (maxrate_a != maxrate_b)
+			return maxrate_b - maxrate_a;
+	}
 
 	/* use freq for channel preference */
 

Modified: wpasupplicant/trunk/src/eap_common/Makefile
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/eap_common/Makefile?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/eap_common/Makefile (original)
+++ wpasupplicant/trunk/src/eap_common/Makefile Sun Feb 15 20:49:57 2009
@@ -4,3 +4,6 @@
 clean:
 	for d in $(SUBDIRS); do make -C $$d clean; done
 	rm -f *~ *.o *.d
+
+install:
+	@echo Nothing to be made.

Modified: wpasupplicant/trunk/src/eap_peer/Makefile
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/eap_peer/Makefile?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/eap_peer/Makefile (original)
+++ wpasupplicant/trunk/src/eap_peer/Makefile Sun Feb 15 20:49:57 2009
@@ -3,4 +3,10 @@
 
 clean:
 	for d in $(SUBDIRS); do make -C $$d clean; done
-	rm -f *~ *.o *.d
+	rm -f *~ *.o *.so *.d
+
+install:
+	if ls *.so >/dev/null 2>&1; then \
+		install -d $(DESTDIR)$(LIBDIR)/wpa_supplicant && \
+		cp *.so $(DESTDIR)$(LIBDIR)/wpa_supplicant \
+	; fi

Modified: wpasupplicant/trunk/src/eap_peer/eap.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/eap_peer/eap.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/eap_peer/eap.c (original)
+++ wpasupplicant/trunk/src/eap_peer/eap.c Sun Feb 15 20:49:57 2009
@@ -134,7 +134,8 @@
 {
 	SM_ENTRY(EAP, INITIALIZE);
 	if (sm->fast_reauth && sm->m && sm->m->has_reauth_data &&
-	    sm->m->has_reauth_data(sm, sm->eap_method_priv)) {
+	    sm->m->has_reauth_data(sm, sm->eap_method_priv) &&
+	    !sm->prev_failure) {
 		wpa_printf(MSG_DEBUG, "EAP: maintaining EAP method data for "
 			   "fast reauthentication");
 		sm->m->deinit_for_reauth(sm, sm->eap_method_priv);
@@ -165,6 +166,7 @@
 	eapol_set_bool(sm, EAPOL_eapResp, FALSE);
 	eapol_set_bool(sm, EAPOL_eapNoResp, FALSE);
 	sm->num_rounds = 0;
+	sm->prev_failure = 0;
 }
 
 
@@ -505,6 +507,8 @@
 
 	wpa_msg(sm->msg_ctx, MSG_INFO, WPA_EVENT_EAP_FAILURE
 		"EAP authentication failed");
+
+	sm->prev_failure = 1;
 }
 
 

Modified: wpasupplicant/trunk/src/eap_peer/eap_aka.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/eap_peer/eap_aka.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/eap_peer/eap_aka.c (original)
+++ wpasupplicant/trunk/src/eap_peer/eap_aka.c Sun Feb 15 20:49:57 2009
@@ -60,6 +60,7 @@
 	u8 *network_name;
 	size_t network_name_len;
 	u16 kdf;
+	int kdf_negotiation;
 };
 
 
@@ -665,6 +666,7 @@
 {
 	struct eap_sim_msg *msg;
 
+	data->kdf_negotiation = 1;
 	data->kdf = kdf;
 	wpa_printf(MSG_DEBUG, "Generating EAP-AKA Challenge (id=%d) (KDF "
 		   "select)", id);
@@ -704,7 +706,7 @@
 	/* The only allowed (and required) duplication of a KDF is the addition
 	 * of the selected KDF into the beginning of the list. */
 
-	if (data->kdf) {
+	if (data->kdf_negotiation) {
 		if (attr->kdf[0] != data->kdf) {
 			wpa_printf(MSG_WARNING, "EAP-AKA': The server did not "
 				   "accept the selected KDF");
@@ -840,7 +842,13 @@
 #ifdef EAP_AKA_PRIME
 	if (data->eap_method == EAP_TYPE_AKA_PRIME) {
 		/* Note: AUTN = (SQN ^ AK) || AMF || MAC which gives us the
-		 * needed 6-octet SQN ^AK for CK',IK' derivation */
+		 * needed 6-octet SQN ^ AK for CK',IK' derivation */
+		u16 amf = WPA_GET_BE16(data->autn + 6);
+		if (!(amf & 0x8000)) {
+			wpa_printf(MSG_WARNING, "EAP-AKA': AMF separation bit "
+				   "not set (AMF=0x%4x)", amf);
+			return eap_aka_authentication_reject(data, id);
+		}
 		eap_aka_prime_derive_ck_ik_prime(data->ck, data->ik,
 						 data->autn,
 						 data->network_name,
@@ -1245,6 +1253,7 @@
 	wpabuf_free(data->id_msgs);
 	data->id_msgs = NULL;
 	data->use_result_ind = 0;
+	data->kdf_negotiation = 0;
 }
 
 

Modified: wpasupplicant/trunk/src/eap_peer/eap_i.h
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/eap_peer/eap_i.h?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/eap_peer/eap_i.h (original)
+++ wpasupplicant/trunk/src/eap_peer/eap_i.h Sun Feb 15 20:49:57 2009
@@ -333,6 +333,8 @@
 	int force_disabled;
 
 	struct wps_context *wps;
+
+	int prev_failure;
 };
 
 const u8 * eap_get_config_identity(struct eap_sm *sm, size_t *len);

Modified: wpasupplicant/trunk/src/eap_peer/eap_tls_common.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/eap_peer/eap_tls_common.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/eap_peer/eap_tls_common.c (original)
+++ wpasupplicant/trunk/src/eap_peer/eap_tls_common.c Sun Feb 15 20:49:57 2009
@@ -904,7 +904,7 @@
 
 	if (in_data) {
 		eap_peer_tls_reset_output(data);
-		len = wpabuf_len(in_data) + 100;
+		len = wpabuf_len(in_data) + 300;
 		data->tls_out = os_malloc(len);
 		if (data->tls_out == NULL)
 			return -1;

Modified: wpasupplicant/trunk/src/eap_peer/eap_wsc.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/eap_peer/eap_wsc.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/eap_peer/eap_wsc.c (original)
+++ wpasupplicant/trunk/src/eap_peer/eap_wsc.c Sun Feb 15 20:49:57 2009
@@ -405,6 +405,7 @@
 		eap_wsc_state(data, MESG);
 		break;
 	case WPS_FAILURE:
+	case WPS_PENDING:
 		wpa_printf(MSG_DEBUG, "EAP-WSC: WPS processing failed");
 		eap_wsc_state(data, FAIL);
 		break;

Modified: wpasupplicant/trunk/src/eap_server/Makefile
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/eap_server/Makefile?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/eap_server/Makefile (original)
+++ wpasupplicant/trunk/src/eap_server/Makefile Sun Feb 15 20:49:57 2009
@@ -4,3 +4,6 @@
 clean:
 	for d in $(SUBDIRS); do make -C $$d clean; done
 	rm -f *~ *.o *.d
+
+install:
+	@echo Nothing to be made.

Modified: wpasupplicant/trunk/src/eap_server/eap_aka.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/eap_server/eap_aka.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/eap_server/eap_aka.c (original)
+++ wpasupplicant/trunk/src/eap_server/eap_aka.c Sun Feb 15 20:49:57 2009
@@ -369,15 +369,19 @@
 			       EAP_AKA_SUBTYPE_CHALLENGE);
 	wpa_printf(MSG_DEBUG, "   AT_RAND");
 	eap_sim_msg_add(msg, EAP_SIM_AT_RAND, 0, data->rand, EAP_AKA_RAND_LEN);
+	wpa_printf(MSG_DEBUG, "   AT_AUTN");
 	eap_sim_msg_add(msg, EAP_SIM_AT_AUTN, 0, data->autn, EAP_AKA_AUTN_LEN);
 	if (data->eap_method == EAP_TYPE_AKA_PRIME) {
 		if (data->kdf) {
 			/* Add the selected KDF into the beginning */
+			wpa_printf(MSG_DEBUG, "   AT_KDF");
 			eap_sim_msg_add(msg, EAP_SIM_AT_KDF, data->kdf,
 					NULL, 0);
 		}
+		wpa_printf(MSG_DEBUG, "   AT_KDF");
 		eap_sim_msg_add(msg, EAP_SIM_AT_KDF, EAP_AKA_PRIME_KDF,
 				NULL, 0);
+		wpa_printf(MSG_DEBUG, "   AT_KDF_INPUT");
 		eap_sim_msg_add(msg, EAP_SIM_AT_KDF_INPUT,
 				data->network_name_len,
 				data->network_name, data->network_name_len);

Modified: wpasupplicant/trunk/src/eap_server/eap_wsc.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/eap_server/eap_wsc.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/eap_server/eap_wsc.c (original)
+++ wpasupplicant/trunk/src/eap_server/eap_wsc.c Sun Feb 15 20:49:57 2009
@@ -15,6 +15,7 @@
 #include "includes.h"
 
 #include "common.h"
+#include "eloop.h"
 #include "eap_i.h"
 #include "eap_common/eap_wsc_common.h"
 #include "wps/wps.h"
@@ -29,6 +30,7 @@
 	size_t out_used;
 	size_t fragment_size;
 	struct wps_data *wps;
+	int ext_reg_timeout;
 };
 
 
@@ -62,6 +64,21 @@
 }
 
 
+static void eap_wsc_ext_reg_timeout(void *eloop_ctx, void *timeout_ctx)
+{
+	struct eap_sm *sm = eloop_ctx;
+	struct eap_wsc_data *data = timeout_ctx;
+
+	if (sm->method_pending != METHOD_PENDING_WAIT)
+		return;
+
+	wpa_printf(MSG_DEBUG, "EAP-WSC: Timeout while waiting for an External "
+		   "Registrar");
+	data->ext_reg_timeout = 1;
+	eap_sm_pending_cb(sm);
+}
+
+
 static void * eap_wsc_init(struct eap_sm *sm)
 {
 	struct eap_wsc_data *data;
@@ -123,6 +140,7 @@
 static void eap_wsc_reset(struct eap_sm *sm, void *priv)
 {
 	struct eap_wsc_data *data = priv;
+	eloop_cancel_timeout(eap_wsc_ext_reg_timeout, sm, data);
 	wpabuf_free(data->in_buf);
 	wpabuf_free(data->out_buf);
 	wps_deinit(data->wps);
@@ -324,6 +342,12 @@
 	enum wps_process_res res;
 	struct wpabuf tmpbuf;
 
+	eloop_cancel_timeout(eap_wsc_ext_reg_timeout, sm, data);
+	if (data->ext_reg_timeout) {
+		eap_wsc_state(data, FAIL);
+		return;
+	}
+
 	pos = eap_hdr_validate(EAP_VENDOR_WFA, EAP_VENDOR_TYPE_WSC,
 			       respData, &len);
 	if (pos == NULL || len < 2)
@@ -408,6 +432,13 @@
 	case WPS_FAILURE:
 		wpa_printf(MSG_DEBUG, "EAP-WSC: WPS processing failed");
 		eap_wsc_state(data, FAIL);
+		break;
+	case WPS_PENDING:
+		eap_wsc_state(data, MSG);
+		sm->method_pending = METHOD_PENDING_WAIT;
+		eloop_cancel_timeout(eap_wsc_ext_reg_timeout, sm, data);
+		eloop_register_timeout(5, 0, eap_wsc_ext_reg_timeout,
+				       sm, data);
 		break;
 	}
 

Modified: wpasupplicant/trunk/src/eapol_supp/Makefile
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/eapol_supp/Makefile?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/eapol_supp/Makefile (original)
+++ wpasupplicant/trunk/src/eapol_supp/Makefile Sun Feb 15 20:49:57 2009
@@ -4,3 +4,6 @@
 clean:
 	for d in $(SUBDIRS); do make -C $$d clean; done
 	rm -f *~ *.o *.d
+
+install:
+	@echo Nothing to be made.

Modified: wpasupplicant/trunk/src/eapol_supp/eapol_supp_sm.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/eapol_supp/eapol_supp_sm.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/eapol_supp/eapol_supp_sm.c (original)
+++ wpasupplicant/trunk/src/eapol_supp/eapol_supp_sm.c Sun Feb 15 20:49:57 2009
@@ -1165,6 +1165,31 @@
 		sm->dot1xSuppEapLengthErrorFramesRx++;
 		return 0;
 	}
+#ifdef CONFIG_WPS
+	if (sm->conf.workaround &&
+	    plen < len - sizeof(*hdr) &&
+	    hdr->type == IEEE802_1X_TYPE_EAP_PACKET &&
+	    len - sizeof(*hdr) > sizeof(struct eap_hdr)) {
+		const struct eap_hdr *ehdr =
+			(const struct eap_hdr *) (hdr + 1);
+		u16 elen;
+
+		elen = be_to_host16(ehdr->length);
+		if (elen > plen && elen <= len - sizeof(*hdr)) {
+			/*
+			 * Buffalo WHR-G125 Ver.1.47 seems to send EAP-WPS
+			 * packets with too short EAPOL header length field
+			 * (14 octets). This is fixed in firmware Ver.1.49.
+			 * As a workaround, fix the EAPOL header based on the
+			 * correct length in the EAP packet.
+			 */
+			wpa_printf(MSG_DEBUG, "EAPOL: Workaround - fix EAPOL "
+				   "payload length based on EAP header: "
+				   "%d -> %d", (int) plen, elen);
+			plen = elen;
+		}
+	}
+#endif /* CONFIG_WPS */
 	data_len = plen + sizeof(*hdr);
 
 	switch (hdr->type) {
@@ -1349,6 +1374,7 @@
 	sm->conf.accept_802_1x_keys = conf->accept_802_1x_keys;
 	sm->conf.required_keys = conf->required_keys;
 	sm->conf.fast_reauth = conf->fast_reauth;
+	sm->conf.workaround = conf->workaround;
 	if (sm->eap) {
 		eap_set_fast_reauth(sm->eap, conf->fast_reauth);
 		eap_set_workaround(sm->eap, conf->workaround);

Modified: wpasupplicant/trunk/src/hlr_auc_gw/Makefile
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/hlr_auc_gw/Makefile?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/hlr_auc_gw/Makefile (original)
+++ wpasupplicant/trunk/src/hlr_auc_gw/Makefile Sun Feb 15 20:49:57 2009
@@ -4,3 +4,6 @@
 clean:
 	for d in $(SUBDIRS); do make -C $$d clean; done
 	rm -f *~ *.o *.d
+
+install:
+	@echo Nothing to be made.

Modified: wpasupplicant/trunk/src/hlr_auc_gw/hlr_auc_gw.milenage_db
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/hlr_auc_gw/hlr_auc_gw.milenage_db?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/hlr_auc_gw/hlr_auc_gw.milenage_db (original)
+++ wpasupplicant/trunk/src/hlr_auc_gw/hlr_auc_gw.milenage_db Sun Feb 15 20:49:57 2009
@@ -7,3 +7,7 @@
 
 # IMSI Ki OPc AMF SQN
 232010000000000 90dca4eda45b53cf0f12d7c9c3bc6a89 cb9cccc4b9258e6dca4760379fb82581 61df 000000000000
+
+# These values are from Test Set 19 which has the AMF separation bit set to 1
+# and as such, is suitable for EAP-AKA' test.
+555444333222111 5122250214c33e723a5dd523fc145fc0 981d464c7c52eb6e5036234984ad0bcf c3ab 16f3b3f70fc1

Modified: wpasupplicant/trunk/src/l2_packet/Makefile
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/l2_packet/Makefile?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/l2_packet/Makefile (original)
+++ wpasupplicant/trunk/src/l2_packet/Makefile Sun Feb 15 20:49:57 2009
@@ -4,3 +4,6 @@
 clean:
 	for d in $(SUBDIRS); do make -C $$d clean; done
 	rm -f *~ *.o *.d
+
+install:
+	@echo Nothing to be made.

Modified: wpasupplicant/trunk/src/radius/Makefile
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/radius/Makefile?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/radius/Makefile (original)
+++ wpasupplicant/trunk/src/radius/Makefile Sun Feb 15 20:49:57 2009
@@ -4,3 +4,6 @@
 clean:
 	for d in $(SUBDIRS); do make -C $$d clean; done
 	rm -f *~ *.o *.d
+
+install:
+	@echo Nothing to be made.

Modified: wpasupplicant/trunk/src/radius/radius.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/radius/radius.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/radius/radius.c (original)
+++ wpasupplicant/trunk/src/radius/radius.c Sun Feb 15 20:49:57 2009
@@ -293,7 +293,8 @@
 }
 
 
-int radius_msg_finish(struct radius_msg *msg, u8 *secret, size_t secret_len)
+int radius_msg_finish(struct radius_msg *msg, const u8 *secret,
+		      size_t secret_len)
 {
 	if (secret) {
 		u8 auth[MD5_MAC_LEN];
@@ -364,7 +365,7 @@
 }
 
 
-void radius_msg_finish_acct(struct radius_msg *msg, u8 *secret,
+void radius_msg_finish_acct(struct radius_msg *msg, const u8 *secret,
 			    size_t secret_len)
 {
 	const u8 *addr[2];
@@ -899,7 +900,7 @@
 
 struct radius_ms_mppe_keys *
 radius_msg_get_ms_keys(struct radius_msg *msg, struct radius_msg *sent_msg,
-		       u8 *secret, size_t secret_len)
+		       const u8 *secret, size_t secret_len)
 {
 	u8 *key;
 	size_t keylen;
@@ -940,7 +941,7 @@
 
 struct radius_ms_mppe_keys *
 radius_msg_get_cisco_keys(struct radius_msg *msg, struct radius_msg *sent_msg,
-			  u8 *secret, size_t secret_len)
+			  const u8 *secret, size_t secret_len)
 {
 	u8 *key;
 	size_t keylen;
@@ -1043,8 +1044,8 @@
  * in RFC 2865, Chap. 5.2 */
 struct radius_attr_hdr *
 radius_msg_add_attr_user_password(struct radius_msg *msg,
-				  u8 *data, size_t data_len,
-				  u8 *secret, size_t secret_len)
+				  const u8 *data, size_t data_len,
+				  const u8 *secret, size_t secret_len)
 {
 	u8 buf[128];
 	int padlen, i;

Modified: wpasupplicant/trunk/src/radius/radius.h
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/radius/radius.h?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/radius/radius.h (original)
+++ wpasupplicant/trunk/src/radius/radius.h Sun Feb 15 20:49:57 2009
@@ -207,10 +207,11 @@
 void radius_msg_set_hdr(struct radius_msg *msg, u8 code, u8 identifier);
 void radius_msg_free(struct radius_msg *msg);
 void radius_msg_dump(struct radius_msg *msg);
-int radius_msg_finish(struct radius_msg *msg, u8 *secret, size_t secret_len);
+int radius_msg_finish(struct radius_msg *msg, const u8 *secret,
+		      size_t secret_len);
 int radius_msg_finish_srv(struct radius_msg *msg, const u8 *secret,
 			  size_t secret_len, const u8 *req_authenticator);
-void radius_msg_finish_acct(struct radius_msg *msg, u8 *secret,
+void radius_msg_finish_acct(struct radius_msg *msg, const u8 *secret,
 			    size_t secret_len);
 struct radius_attr_hdr *radius_msg_add_attr(struct radius_msg *msg, u8 type,
 					    const u8 *data, size_t data_len);
@@ -229,10 +230,10 @@
 				   const u8 *data, size_t len);
 struct radius_ms_mppe_keys *
 radius_msg_get_ms_keys(struct radius_msg *msg, struct radius_msg *sent_msg,
-		       u8 *secret, size_t secret_len);
+		       const u8 *secret, size_t secret_len);
 struct radius_ms_mppe_keys *
 radius_msg_get_cisco_keys(struct radius_msg *msg, struct radius_msg *sent_msg,
-			  u8 *secret, size_t secret_len);
+			  const u8 *secret, size_t secret_len);
 int radius_msg_add_mppe_keys(struct radius_msg *msg,
 			     const u8 *req_authenticator,
 			     const u8 *secret, size_t secret_len,
@@ -240,8 +241,8 @@
 			     const u8 *recv_key, size_t recv_key_len);
 struct radius_attr_hdr *
 radius_msg_add_attr_user_password(struct radius_msg *msg,
-				  u8 *data, size_t data_len,
-				  u8 *secret, size_t secret_len);
+				  const u8 *data, size_t data_len,
+				  const u8 *secret, size_t secret_len);
 int radius_msg_get_attr(struct radius_msg *msg, u8 type, u8 *buf, size_t len);
 int radius_msg_get_vlanid(struct radius_msg *msg);
 

Modified: wpasupplicant/trunk/src/radius/radius_client.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/radius/radius_client.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/radius/radius_client.c (original)
+++ wpasupplicant/trunk/src/radius/radius_client.c Sun Feb 15 20:49:57 2009
@@ -35,7 +35,8 @@
 struct radius_rx_handler {
 	RadiusRxResult (*handler)(struct radius_msg *msg,
 				  struct radius_msg *req,
-				  u8 *shared_secret, size_t shared_secret_len,
+				  const u8 *shared_secret,
+				  size_t shared_secret_len,
 				  void *data);
 	void *data;
 };
@@ -106,7 +107,7 @@
 			   RadiusType msg_type,
 			   RadiusRxResult (*handler)(struct radius_msg *msg,
 						     struct radius_msg *req,
-						     u8 *shared_secret,
+						     const u8 *shared_secret,
 						     size_t shared_secret_len,
 						     void *data),
 			   void *data)

Modified: wpasupplicant/trunk/src/radius/radius_client.h
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/radius/radius_client.h?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/radius/radius_client.h (original)
+++ wpasupplicant/trunk/src/radius/radius_client.h Sun Feb 15 20:49:57 2009
@@ -85,7 +85,7 @@
 			   RadiusType msg_type,
 			   RadiusRxResult (*handler)
 			   (struct radius_msg *msg, struct radius_msg *req,
-			    u8 *shared_secret, size_t shared_secret_len,
+			    const u8 *shared_secret, size_t shared_secret_len,
 			    void *data),
 			   void *data);
 int radius_client_send(struct radius_client_data *radius,

Modified: wpasupplicant/trunk/src/rsn_supp/Makefile
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/rsn_supp/Makefile?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/rsn_supp/Makefile (original)
+++ wpasupplicant/trunk/src/rsn_supp/Makefile Sun Feb 15 20:49:57 2009
@@ -4,3 +4,6 @@
 clean:
 	for d in $(SUBDIRS); do make -C $$d clean; done
 	rm -f *~ *.o *.d
+
+install:
+	@echo Nothing to be made.

Modified: wpasupplicant/trunk/src/tls/Makefile
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/tls/Makefile?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/tls/Makefile (original)
+++ wpasupplicant/trunk/src/tls/Makefile Sun Feb 15 20:49:57 2009
@@ -4,3 +4,6 @@
 clean:
 	for d in $(SUBDIRS); do make -C $$d clean; done
 	rm -f *~ *.o *.d
+
+install:
+	@echo Nothing to be made.

Modified: wpasupplicant/trunk/src/utils/Makefile
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/utils/Makefile?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/utils/Makefile (original)
+++ wpasupplicant/trunk/src/utils/Makefile Sun Feb 15 20:49:57 2009
@@ -4,3 +4,6 @@
 clean:
 	for d in $(SUBDIRS); do make -C $$d clean; done
 	rm -f *~ *.o *.d
+
+install:
+	@echo Nothing to be made.

Modified: wpasupplicant/trunk/src/utils/os_unix.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/utils/os_unix.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/utils/os_unix.c (original)
+++ wpasupplicant/trunk/src/utils/os_unix.c Sun Feb 15 20:49:57 2009
@@ -76,12 +76,47 @@
 }
 
 
+#ifdef __APPLE__
+#include <fcntl.h>
+static int os_daemon(int nochdir, int noclose)
+{
+	int devnull;
+
+	if (chdir("/") < 0)
+		return -1;
+
+	devnull = open("/dev/null", O_RDWR);
+	if (devnull < 0)
+		return -1;
+
+	if (dup2(devnull, STDIN_FILENO) < 0) {
+		close(devnull);
+		return -1;
+	}
+
+	if (dup2(devnull, STDOUT_FILENO) < 0) {
+		close(devnull);
+		return -1;
+	}
+
+	if (dup2(devnull, STDERR_FILENO) < 0) {
+		close(devnull);
+		return -1;
+	}
+
+	return 0;
+}
+#else /* __APPLE__ */
+#define os_daemon daemon
+#endif /* __APPLE__ */
+
+
 int os_daemonize(const char *pid_file)
 {
 #ifdef __uClinux__
 	return -1;
 #else /* __uClinux__ */
-	if (daemon(0, 0)) {
+	if (os_daemon(0, 0)) {
 		perror("daemon");
 		return -1;
 	}

Modified: wpasupplicant/trunk/src/utils/wpabuf.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/utils/wpabuf.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/utils/wpabuf.c (original)
+++ wpasupplicant/trunk/src/utils/wpabuf.c Sun Feb 15 20:49:57 2009
@@ -1,6 +1,6 @@
 /*
  * Dynamic data buffer
- * Copyright (c) 2007-2008, Jouni Malinen <j at w1.fi>
+ * Copyright (c) 2007-2009, Jouni Malinen <j at w1.fi>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -160,3 +160,53 @@
 
 	return n;
 }
+
+
+/**
+ * wpabuf_zeropad - Pad buffer with 0x00 octets (prefix) to specified length
+ * @buf: Buffer to be padded
+ * @len: Length for the padded buffer
+ * Returns: wpabuf padded to len octets or %NULL on failure
+ *
+ * If buf is longer than len octets or of same size, it will be returned as-is.
+ * Otherwise a new buffer is allocated and prefixed with 0x00 octets followed
+ * by the source data. The source buffer will be freed on error, i.e., caller
+ * will only be responsible on freeing the returned buffer. If buf is %NULL,
+ * %NULL will be returned.
+ */
+struct wpabuf * wpabuf_zeropad(struct wpabuf *buf, size_t len)
+{
+	struct wpabuf *ret;
+	size_t blen;
+
+	if (buf == NULL)
+		return NULL;
+
+	blen = wpabuf_len(buf);
+	if (blen >= len)
+		return buf;
+
+	ret = wpabuf_alloc(len);
+	if (ret) {
+		os_memset(wpabuf_put(ret, len - blen), 0, len - blen);
+		wpabuf_put_buf(ret, buf);
+	}
+	wpabuf_free(buf);
+
+	return ret;
+}
+
+
+void wpabuf_printf(struct wpabuf *buf, char *fmt, ...)
+{
+	va_list ap;
+	void *tmp = wpabuf_mhead_u8(buf) + wpabuf_len(buf);
+	int res;
+
+	va_start(ap, fmt);
+	res = vsnprintf(tmp, buf->size - buf->used, fmt, ap);
+	va_end(ap);
+	if (res < 0 || (size_t) res >= buf->size - buf->used)
+		wpabuf_overflow(buf, res);
+	buf->used += res;
+}

Modified: wpasupplicant/trunk/src/utils/wpabuf.h
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/utils/wpabuf.h?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/utils/wpabuf.h (original)
+++ wpasupplicant/trunk/src/utils/wpabuf.h Sun Feb 15 20:49:57 2009
@@ -1,6 +1,6 @@
 /*
  * Dynamic data buffer
- * Copyright (c) 2007, Jouni Malinen <j at w1.fi>
+ * Copyright (c) 2007-2009, Jouni Malinen <j at w1.fi>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -37,6 +37,8 @@
 void wpabuf_free(struct wpabuf *buf);
 void * wpabuf_put(struct wpabuf *buf, size_t len);
 struct wpabuf * wpabuf_concat(struct wpabuf *a, struct wpabuf *b);
+struct wpabuf * wpabuf_zeropad(struct wpabuf *buf, size_t len);
+void wpabuf_printf(struct wpabuf *buf, char *fmt, ...) PRINTF_FORMAT(2, 3);
 
 
 /**
@@ -146,4 +148,9 @@
 	buf->size = buf->used = len;
 }
 
+static inline void wpabuf_put_str(struct wpabuf *dst, const char *str)
+{
+	wpabuf_put_data(dst, str, os_strlen(str));
+}
+
 #endif /* WPABUF_H */

Modified: wpasupplicant/trunk/src/wps/Makefile
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/wps/Makefile?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/wps/Makefile (original)
+++ wpasupplicant/trunk/src/wps/Makefile Sun Feb 15 20:49:57 2009
@@ -4,3 +4,6 @@
 clean:
 	for d in $(SUBDIRS); do make -C $$d clean; done
 	rm -f *~ *.o *.d
+
+install:
+	@echo Nothing to be made.

Modified: wpasupplicant/trunk/src/wps/wps.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/wps/wps.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/wps/wps.c (original)
+++ wpasupplicant/trunk/src/wps/wps.c Sun Feb 15 20:49:57 2009
@@ -186,7 +186,7 @@
 
 
 /**
- * wps_is_selected_pbc_registrar - Check whether WPS IE indicates active PIN
+ * wps_is_selected_pin_registrar - Check whether WPS IE indicates active PIN
  * @msg: WPS IE contents from Beacon or Probe Response frame
  * Returns: 1 if PIN Registrar is active, 0 if not
  */
@@ -202,9 +202,13 @@
 	 * Device Password ID here.
 	 */
 
-	if (wps_parse_msg(msg, &attr) < 0 ||
-	    !attr.selected_registrar || *attr.selected_registrar == 0 ||
-	    !attr.dev_password_id ||
+	if (wps_parse_msg(msg, &attr) < 0)
+		return 0;
+
+	if (!attr.selected_registrar || *attr.selected_registrar == 0)
+		return 0;
+
+	if (attr.dev_password_id != NULL &&
 	    WPA_GET_BE16(attr.dev_password_id) == DEV_PW_PUSHBUTTON)
 		return 0;
 
@@ -316,3 +320,16 @@
 
 	return ie;
 }
+
+
+void wps_free_pending_msgs(struct upnp_pending_message *msgs)
+{
+	struct upnp_pending_message *p, *prev;
+	p = msgs;
+	while (p) {
+		prev = p;
+		p = p->next;
+		wpabuf_free(prev->msg);
+		os_free(prev);
+	}
+}

Modified: wpasupplicant/trunk/src/wps/wps.h
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/wps/wps.h?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/wps/wps.h (original)
+++ wpasupplicant/trunk/src/wps/wps.h Sun Feb 15 20:49:57 2009
@@ -21,6 +21,7 @@
  * enum wsc_op_code - EAP-WSC OP-Code values
  */
 enum wsc_op_code {
+	WSC_UPnP = 0 /* No OP Code in UPnP transport */,
 	WSC_Start = 0x01,
 	WSC_ACK = 0x02,
 	WSC_NACK = 0x03,
@@ -30,6 +31,7 @@
 };
 
 struct wps_registrar;
+struct upnp_wps_device_sm;
 
 /**
  * struct wps_credential - WPS Credential
@@ -41,6 +43,9 @@
  * @key: Key
  * @key_len: Key length in octets
  * @mac_addr: MAC address of the peer
+ * @cred_attr: Unparsed Credential attribute data (used only in cred_cb());
+ *	this may be %NULL, if not used
+ * @cred_attr_len: Length of cred_attr in octets
  */
 struct wps_credential {
 	u8 ssid[32];
@@ -51,6 +56,8 @@
 	u8 key[64];
 	size_t key_len;
 	u8 mac_addr[ETH_ALEN];
+	const u8 *cred_attr;
+	size_t cred_attr_len;
 };
 
 /**
@@ -137,7 +144,13 @@
 	/**
 	 * WPS_FAILURE - Processing failed
 	 */
-	WPS_FAILURE
+	WPS_FAILURE,
+
+	/**
+	 * WPS_PENDING - Processing continues, but waiting for an external
+	 *	event (e.g., UPnP message from an external Registrar)
+	 */
+	WPS_PENDING
 };
 enum wps_process_res wps_process_msg(struct wps_data *wps,
 				     enum wsc_op_code op_code,
@@ -201,9 +214,58 @@
 			      const struct wps_device_data *dev);
 
 	/**
+	 * reg_success_cb - Callback for reporting successful registration
+	 * @ctx: Higher layer context data (cb_ctx)
+	 * @mac_addr: MAC address of the Enrollee
+	 * @uuid_e: UUID-E of the Enrollee
+	 *
+	 * This callback is called whenever an Enrollee completes registration
+	 * successfully.
+	 */
+	void (*reg_success_cb)(void *ctx, const u8 *mac_addr,
+			       const u8 *uuid_e);
+
+	/**
 	 * cb_ctx: Higher layer context data for Registrar callbacks
 	 */
 	void *cb_ctx;
+
+	/**
+	 * skip_cred_build: Do not build credential
+	 *
+	 * This option can be used to disable internal code that builds
+	 * Credential attribute into M8 based on the current network
+	 * configuration and Enrollee capabilities. The extra_cred data will
+	 * then be used as the Credential(s).
+	 */
+	int skip_cred_build;
+
+	/**
+	 * extra_cred: Additional Credential attribute(s)
+	 *
+	 * This optional data (set to %NULL to disable) can be used to add
+	 * Credential attribute(s) for other networks into M8. If
+	 * skip_cred_build is set, this will also override the automatically
+	 * generated Credential attribute.
+	 */
+	const u8 *extra_cred;
+
+	/**
+	 * extra_cred_len: Length of extra_cred in octets
+	 */
+	size_t extra_cred_len;
+
+	/**
+	 * disable_auto_conf - Disable auto-configuration on first registration
+	 *
+	 * By default, the AP that is started in not configured state will
+	 * generate a random PSK and move to configured state when the first
+	 * registration protocol run is completed successfully. This option can
+	 * be used to disable this functionality and leave it up to an external
+	 * program to take care of configuration. This requires the extra_cred
+	 * to be set with a suitable Credential and skip_cred_build being used.
+	 */
+	int disable_auto_conf;
 };
 
 
@@ -224,7 +286,12 @@
 	/**
 	 * WPS_EV_SUCCESS - Registration succeeded
 	 */
-	WPS_EV_SUCCESS
+	WPS_EV_SUCCESS,
+
+	/**
+	 * WPS_EV_PWD_AUTH_FAIL - Password authentication failed
+	 */
+	WPS_EV_PWD_AUTH_FAIL
 };
 
 /**
@@ -258,6 +325,25 @@
 	struct wps_event_fail {
 		int msg;
 	} fail;
+
+	struct wps_event_pwd_auth_fail {
+		int enrollee;
+		int part;
+	} pwd_auth_fail;
+};
+
+/**
+ * struct upnp_pending_message - Pending PutWLANResponse messages
+ * @next: Pointer to next pending message or %NULL
+ * @addr: NewWLANEventMAC
+ * @msg: NewMessage
+ * @type: Message Type
+ */
+struct upnp_pending_message {
+	struct upnp_pending_message *next;
+	u8 addr[ETH_ALEN];
+	struct wpabuf *msg;
+	enum wps_msg_type type;
 };
 
 /**
@@ -343,6 +429,44 @@
 	size_t network_key_len;
 
 	/**
+	 * ap_settings - AP Settings override for M7 (only used at AP)
+	 *
+	 * If %NULL, AP Settings attributes will be generated based on the
+	 * current network configuration.
+	 */
+	u8 *ap_settings;
+
+	/**
+	 * ap_settings_len - Length of ap_settings in octets
+	 */
+	size_t ap_settings_len;
+
+	/**
+	 * friendly_name - Friendly Name (required for UPnP)
+	 */
+	char *friendly_name;
+
+	/**
+	 * manufacturer_url - Manufacturer URL (optional for UPnP)
+	 */
+	char *manufacturer_url;
+
+	/**
+	 * model_description - Model Description (recommended for UPnP)
+	 */
+	char *model_description;
+
+	/**
+	 * model_url - Model URL (optional for UPnP)
+	 */
+	char *model_url;
+
+	/**
+	 * upc - Universal Product Code (optional for UPnP)
+	 */
+	char *upc;
+
+	/**
 	 * cred_cb - Callback to notify that new Credentials were received
 	 * @ctx: Higher layer context data (cb_ctx)
 	 * @cred: The received Credential
@@ -363,6 +487,11 @@
 	 * cb_ctx: Higher layer context data for callbacks
 	 */
 	void *cb_ctx;
+
+	struct upnp_wps_device_sm *wps_upnp;
+
+	/* Pending messages from UPnP PutWLANResponse */
+	struct upnp_pending_message *upnp_msgs;
 };
 
 
@@ -377,9 +506,13 @@
 int wps_registrar_button_pushed(struct wps_registrar *reg);
 void wps_registrar_probe_req_rx(struct wps_registrar *reg, const u8 *addr,
 				const struct wpabuf *wps_data);
+int wps_registrar_update_ie(struct wps_registrar *reg);
+int wps_registrar_set_selected_registrar(struct wps_registrar *reg,
+					 const struct wpabuf *msg);
 
 unsigned int wps_pin_checksum(unsigned int pin);
 unsigned int wps_pin_valid(unsigned int pin);
 unsigned int wps_generate_pin(void);
+void wps_free_pending_msgs(struct upnp_pending_message *msgs);
 
 #endif /* WPS_H */

Modified: wpasupplicant/trunk/src/wps/wps_attr_build.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/wps/wps_attr_build.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/wps/wps_attr_build.c (original)
+++ wpasupplicant/trunk/src/wps/wps_attr_build.c Sun Feb 15 20:49:57 2009
@@ -27,6 +27,7 @@
 
 	wpa_printf(MSG_DEBUG, "WPS:  * Public Key");
 	pubkey = dh_init(dh_groups_get(WPS_DH_GROUP), &wps->dh_privkey);
+	pubkey = wpabuf_zeropad(pubkey, 192);
 	if (pubkey == NULL) {
 		wpa_printf(MSG_DEBUG, "WPS: Failed to initialize "
 			   "Diffie-Hellman handshake");

Modified: wpasupplicant/trunk/src/wps/wps_attr_process.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/wps/wps_attr_process.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/wps/wps_attr_process.c (original)
+++ wpasupplicant/trunk/src/wps/wps_attr_process.c Sun Feb 15 20:49:57 2009
@@ -254,6 +254,23 @@
 	wpa_printf(MSG_DEBUG, "WPS: 802.1X Enabled: %d", *dot1x_enabled);
 
 	return 0;
+}
+
+
+static void wps_workaround_cred_key(struct wps_credential *cred)
+{
+	if (cred->auth_type & (WPS_AUTH_WPAPSK | WPS_AUTH_WPA2PSK) &&
+	    cred->key_len > 8 && cred->key_len < 64 &&
+	    cred->key[cred->key_len - 1] == 0) {
+		/*
+		 * A deployed external registrar is known to encode ASCII
+		 * passphrases incorrectly. Remove the extra NULL termination
+		 * to fix the encoding.
+		 */
+		wpa_printf(MSG_DEBUG, "WPS: Workaround - remove NULL "
+			   "termination from ASCII passphrase");
+		cred->key_len--;
+	}
 }
 
 
@@ -279,6 +296,8 @@
 	    wps_process_cred_802_1x_enabled(cred, attr->dot1x_enabled))
 		return -1;
 
+	wps_workaround_cred_key(cred);
+
 	return 0;
 }
 
@@ -298,5 +317,7 @@
 	    wps_process_cred_mac_addr(cred, attr->mac_addr))
 		return -1;
 
-	return 0;
-}
+	wps_workaround_cred_key(cred);
+
+	return 0;
+}

Modified: wpasupplicant/trunk/src/wps/wps_common.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/wps/wps_common.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/wps/wps_common.c (original)
+++ wpasupplicant/trunk/src/wps/wps_common.c Sun Feb 15 20:49:57 2009
@@ -82,6 +82,7 @@
 
 	dh_shared = dh_derive_shared(pubkey, wps->dh_privkey,
 				     dh_groups_get(WPS_DH_GROUP));
+	dh_shared = wpabuf_zeropad(dh_shared, 192);
 	if (dh_shared == NULL) {
 		wpa_printf(MSG_DEBUG, "WPS: Failed to derive DH shared key");
 		return -1;
@@ -320,3 +321,17 @@
 
 	wps->event_cb(wps->cb_ctx, WPS_EV_SUCCESS, NULL);
 }
+
+
+void wps_pwd_auth_fail_event(struct wps_context *wps, int enrollee, int part)
+{
+	union wps_event_data data;
+
+	if (wps->event_cb == NULL)
+		return;
+
+	os_memset(&data, 0, sizeof(data));
+	data.pwd_auth_fail.enrollee = enrollee;
+	data.pwd_auth_fail.part = part;
+	wps->event_cb(wps->cb_ctx, WPS_EV_PWD_AUTH_FAIL, &data);
+}

Modified: wpasupplicant/trunk/src/wps/wps_enrollee.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/wps/wps_enrollee.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/wps/wps_enrollee.c (original)
+++ wpasupplicant/trunk/src/wps/wps_enrollee.c Sun Feb 15 20:49:57 2009
@@ -32,10 +32,16 @@
 
 static int wps_build_wps_state(struct wps_data *wps, struct wpabuf *msg)
 {
-	wpa_printf(MSG_DEBUG, "WPS:  * Wi-Fi Protected Setup State");
+	u8 state;
+	if (wps->wps->ap)
+		state = wps->wps->wps_state;
+	else
+		state = WPS_STATE_NOT_CONFIGURED;
+	wpa_printf(MSG_DEBUG, "WPS:  * Wi-Fi Protected Setup State (%d)",
+		   state);
 	wpabuf_put_be16(msg, ATTR_WPS_STATE);
 	wpabuf_put_be16(msg, 1);
-	wpabuf_put_u8(msg, WPS_STATE_CONFIGURED);
+	wpabuf_put_u8(msg, WPS_STATE_NOT_CONFIGURED);
 	return 0;
 }
 
@@ -268,17 +274,34 @@
 }
 
 
+static int wps_build_ap_settings(struct wps_data *wps, struct wpabuf *plain)
+{
+	if (wps->wps->ap_settings) {
+		wpa_printf(MSG_DEBUG, "WPS:  * AP Settings (pre-configured)");
+		wpabuf_put_data(plain, wps->wps->ap_settings,
+				wps->wps->ap_settings_len);
+		return 0;
+	}
+
+	return wps_build_cred_ssid(wps, plain) ||
+		wps_build_cred_mac_addr(wps, plain) ||
+		wps_build_cred_auth_type(wps, plain) ||
+		wps_build_cred_encr_type(wps, plain) ||
+		wps_build_cred_network_key(wps, plain);
+}
+
+
 static struct wpabuf * wps_build_m7(struct wps_data *wps)
 {
 	struct wpabuf *msg, *plain;
 
 	wpa_printf(MSG_DEBUG, "WPS: Building Message M7");
 
-	plain = wpabuf_alloc(500);
+	plain = wpabuf_alloc(500 + wps->wps->ap_settings_len);
 	if (plain == NULL)
 		return NULL;
 
-	msg = wpabuf_alloc(1000);
+	msg = wpabuf_alloc(1000 + wps->wps->ap_settings_len);
 	if (msg == NULL) {
 		wpabuf_free(plain);
 		return NULL;
@@ -288,12 +311,7 @@
 	    wps_build_msg_type(msg, WPS_M7) ||
 	    wps_build_registrar_nonce(wps, msg) ||
 	    wps_build_e_snonce2(wps, plain) ||
-	    (wps->wps->ap &&
-	     (wps_build_cred_ssid(wps, plain) ||
-	      wps_build_cred_mac_addr(wps, plain) ||
-	      wps_build_cred_auth_type(wps, plain) ||
-	      wps_build_cred_encr_type(wps, plain) ||
-	      wps_build_cred_network_key(wps, plain))) ||
+	    (wps->wps->ap && wps_build_ap_settings(wps, plain)) ||
 	    wps_build_key_wrap_auth(wps, plain) ||
 	    wps_build_encr_settings(wps, msg, plain) ||
 	    wps_build_authenticator(wps, msg)) {
@@ -568,6 +586,7 @@
 		wpa_printf(MSG_DEBUG, "WPS: R-Hash1 derived from R-S1 does "
 			   "not match with the pre-committed value");
 		wps->config_error = WPS_CFG_DEV_PASSWORD_AUTH_FAILURE;
+		wps_pwd_auth_fail_event(wps->wps, 1, 1);
 		return -1;
 	}
 
@@ -607,6 +626,7 @@
 		wpa_printf(MSG_DEBUG, "WPS: R-Hash2 derived from R-S2 does "
 			   "not match with the pre-committed value");
 		wps->config_error = WPS_CFG_DEV_PASSWORD_AUTH_FAILURE;
+		wps_pwd_auth_fail_event(wps->wps, 1, 2);
 		return -1;
 	}
 
@@ -630,8 +650,13 @@
 	    wps_process_cred(&attr, &wps->cred))
 		return -1;
 
-	if (wps->wps->cred_cb)
+	if (wps->wps->cred_cb) {
+		wps->cred.cred_attr = cred - 4;
+		wps->cred.cred_attr_len = cred_len + 4;
 		wps->wps->cred_cb(wps->wps->cb_ctx, &wps->cred);
+		wps->cred.cred_attr = NULL;
+		wps->cred.cred_attr_len = 0;
+	}
 
 	return 0;
 }
@@ -661,7 +686,8 @@
 
 
 static int wps_process_ap_settings_e(struct wps_data *wps,
-				     struct wps_parse_attr *attr)
+				     struct wps_parse_attr *attr,
+				     struct wpabuf *attrs)
 {
 	struct wps_credential cred;
 
@@ -674,8 +700,11 @@
 	wpa_printf(MSG_INFO, "WPS: Received new AP configuration from "
 		   "Registrar");
 
-	if (wps->wps->cred_cb)
+	if (wps->wps->cred_cb) {
+		cred.cred_attr = wpabuf_head(attrs);
+		cred.cred_attr_len = wpabuf_len(attrs);
 		wps->wps->cred_cb(wps->wps->cb_ctx, &cred);
+	}
 
 	return 0;
 }
@@ -904,7 +933,7 @@
 	    wps_process_key_wrap_auth(wps, decrypted, eattr.key_wrap_auth) ||
 	    wps_process_creds(wps, eattr.cred, eattr.cred_len,
 			      eattr.num_cred) ||
-	    wps_process_ap_settings_e(wps, &eattr)) {
+	    wps_process_ap_settings_e(wps, &eattr, decrypted)) {
 		wpabuf_free(decrypted);
 		wps->state = SEND_WSC_NACK;
 		return WPS_CONTINUE;
@@ -927,7 +956,7 @@
 	if (wps_parse_msg(msg, &attr) < 0)
 		return WPS_FAILURE;
 
-	if (attr.version == NULL || *attr.version != WPS_VERSION) {
+	if (!wps_version_supported(attr.version)) {
 		wpa_printf(MSG_DEBUG, "WPS: Unsupported message version 0x%x",
 			   attr.version ? *attr.version : 0);
 		return WPS_FAILURE;
@@ -972,7 +1001,14 @@
 		return WPS_FAILURE;
 	}
 
-	if (ret == WPS_CONTINUE) {
+	/*
+	 * Save a copy of the last message for Authenticator derivation if we
+	 * are continuing. However, skip M2D since it is not authenticated and
+	 * neither is the ACK/NACK response frame. This allows the possibly
+	 * following M2 to be processed correctly by using the previously sent
+	 * M1 in Authenticator derivation.
+	 */
+	if (ret == WPS_CONTINUE && *attr.msg_type != WPS_M2D) {
 		/* Save a copy of the last message for Authenticator derivation
 		 */
 		wpabuf_free(wps->last_msg);
@@ -993,7 +1029,7 @@
 	if (wps_parse_msg(msg, &attr) < 0)
 		return WPS_FAILURE;
 
-	if (attr.version == NULL || *attr.version != WPS_VERSION) {
+	if (!wps_version_supported(attr.version)) {
 		wpa_printf(MSG_DEBUG, "WPS: Unsupported message version 0x%x",
 			   attr.version ? *attr.version : 0);
 		return WPS_FAILURE;
@@ -1045,7 +1081,7 @@
 	if (wps_parse_msg(msg, &attr) < 0)
 		return WPS_FAILURE;
 
-	if (attr.version == NULL || *attr.version != WPS_VERSION) {
+	if (!wps_version_supported(attr.version)) {
 		wpa_printf(MSG_DEBUG, "WPS: Unsupported message version 0x%x",
 			   attr.version ? *attr.version : 0);
 		return WPS_FAILURE;
@@ -1125,6 +1161,7 @@
 
 	switch (op_code) {
 	case WSC_MSG:
+	case WSC_UPnP:
 		return wps_process_wsc_msg(wps, msg);
 	case WSC_ACK:
 		return wps_process_wsc_ack(wps, msg);

Modified: wpasupplicant/trunk/src/wps/wps_i.h
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/wps/wps_i.h?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/wps/wps_i.h (original)
+++ wpasupplicant/trunk/src/wps/wps_i.h Sun Feb 15 20:49:57 2009
@@ -101,6 +101,8 @@
 	 * config_error - Configuration Error value to be used in NACK
 	 */
 	u16 config_error;
+
+	int ext_reg;
 };
 
 
@@ -187,6 +189,7 @@
 					  size_t encr_len);
 void wps_fail_event(struct wps_context *wps, enum wps_msg_type msg);
 void wps_success_event(struct wps_context *wps);
+void wps_pwd_auth_fail_event(struct wps_context *wps, int enrollee, int part);
 
 /* wps_attr_parse.c */
 int wps_parse_msg(const struct wpabuf *msg, struct wps_parse_attr *attr);
@@ -235,4 +238,11 @@
 					       enum wsc_op_code op_code,
 					       const struct wpabuf *msg);
 
+
+static inline int wps_version_supported(const u8 *version)
+{
+	/* Require major version match, but allow minor version differences */
+	return version && (*version & 0xf0) == (WPS_VERSION & 0xf0);
+}
+
 #endif /* WPS_I_H */

Modified: wpasupplicant/trunk/src/wps/wps_registrar.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/src/wps/wps_registrar.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/src/wps/wps_registrar.c (original)
+++ wpasupplicant/trunk/src/wps/wps_registrar.c Sun Feb 15 20:49:57 2009
@@ -21,6 +21,7 @@
 #include "eloop.h"
 #include "wps_i.h"
 #include "wps_dev_attr.h"
+#include "wps_upnp.h"
 
 
 struct wps_uuid_pin {
@@ -85,15 +86,25 @@
 			 const u8 *probe_resp_ie, size_t probe_resp_ie_len);
 	void (*pin_needed_cb)(void *ctx, const u8 *uuid_e,
 			      const struct wps_device_data *dev);
+	void (*reg_success_cb)(void *ctx, const u8 *mac_addr,
+			       const u8 *uuid_e);
 	void *cb_ctx;
 
 	struct wps_uuid_pin *pins;
 	struct wps_pbc_session *pbc_sessions;
+
+	int skip_cred_build;
+	struct wpabuf *extra_cred;
+	int disable_auto_conf;
+	int sel_reg_dev_password_id_override;
+	int sel_reg_config_methods_override;
 };
 
 
 static int wps_set_ie(struct wps_registrar *reg);
 static void wps_registrar_pbc_timeout(void *eloop_ctx, void *timeout_ctx);
+static void wps_registrar_set_selected_timeout(void *eloop_ctx,
+					       void *timeout_ctx);
 
 
 static void wps_registrar_add_pbc_session(struct wps_registrar *reg,
@@ -205,6 +216,31 @@
 }
 
 
+#ifdef CONFIG_WPS_UPNP
+static void wps_registrar_free_pending_m2(struct wps_context *wps)
+{
+	struct upnp_pending_message *p, *p2, *prev = NULL;
+	p = wps->upnp_msgs;
+	while (p) {
+		if (p->type == WPS_M2 || p->type == WPS_M2D) {
+			if (prev == NULL)
+				wps->upnp_msgs = p->next;
+			else
+				prev->next = p->next;
+			wpa_printf(MSG_DEBUG, "WPS UPnP: Drop pending M2/M2D");
+			p2 = p;
+			p = p->next;
+			wpabuf_free(p2->msg);
+			os_free(p2);
+			continue;
+		}
+		prev = p;
+		p = p->next;
+	}
+}
+#endif /* CONFIG_WPS_UPNP */
+
+
 static int wps_build_ap_setup_locked(struct wps_context *wps,
 				     struct wpabuf *msg)
 {
@@ -237,6 +273,8 @@
 	u16 id = reg->pbc ? DEV_PW_PUSHBUTTON : DEV_PW_DEFAULT;
 	if (!reg->selected_registrar)
 		return 0;
+	if (reg->sel_reg_dev_password_id_override >= 0)
+		id = reg->sel_reg_dev_password_id_override;
 	wpa_printf(MSG_DEBUG, "WPS:  * Device Password ID (%d)", id);
 	wpabuf_put_be16(msg, ATTR_DEV_PASSWORD_ID);
 	wpabuf_put_be16(msg, 2);
@@ -254,6 +292,8 @@
 	methods = reg->wps->config_methods & ~WPS_CONFIG_PUSHBUTTON;
 	if (reg->pbc)
 		methods |= WPS_CONFIG_PUSHBUTTON;
+	if (reg->sel_reg_config_methods_override >= 0)
+		methods = reg->sel_reg_config_methods_override;
 	wpa_printf(MSG_DEBUG, "WPS:  * Selected Registrar Config Methods (%x)",
 		   methods);
 	wpabuf_put_be16(msg, ATTR_SELECTED_REGISTRAR_CONFIG_METHODS);
@@ -322,7 +362,20 @@
 	reg->new_psk_cb = cfg->new_psk_cb;
 	reg->set_ie_cb = cfg->set_ie_cb;
 	reg->pin_needed_cb = cfg->pin_needed_cb;
+	reg->reg_success_cb = cfg->reg_success_cb;
 	reg->cb_ctx = cfg->cb_ctx;
+	reg->skip_cred_build = cfg->skip_cred_build;
+	if (cfg->extra_cred) {
+		reg->extra_cred = wpabuf_alloc_copy(cfg->extra_cred,
+						    cfg->extra_cred_len);
+		if (reg->extra_cred == NULL) {
+			os_free(reg);
+			return NULL;
+		}
+	}
+	reg->disable_auto_conf = cfg->disable_auto_conf;
+	reg->sel_reg_dev_password_id_override = -1;
+	reg->sel_reg_config_methods_override = -1;
 
 	if (wps_set_ie(reg)) {
 		wps_registrar_deinit(reg);
@@ -342,8 +395,10 @@
 	if (reg == NULL)
 		return;
 	eloop_cancel_timeout(wps_registrar_pbc_timeout, reg, NULL);
+	eloop_cancel_timeout(wps_registrar_set_selected_timeout, reg, NULL);
 	wps_free_pins(reg->pins);
 	wps_free_pbc_sessions(reg->pbc_sessions);
+	wpabuf_free(reg->extra_cred);
 	os_free(reg);
 }
 
@@ -573,8 +628,9 @@
 			"WPS: Probe Request with WPS data received",
 			wps_data);
 
-	if (wps_parse_msg(wps_data, &attr) < 0 ||
-	    attr.version == NULL || *attr.version != WPS_VERSION) {
+	if (wps_parse_msg(wps_data, &attr) < 0)
+		return;
+	if (!wps_version_supported(attr.version)) {
 		wpa_printf(MSG_DEBUG, "WPS: Unsupported ProbeReq WPS IE "
 			   "version 0x%x", attr.version ? *attr.version : 0);
 		return;
@@ -614,6 +670,16 @@
 		return;
 
 	reg->pin_needed_cb(reg->cb_ctx, uuid_e, dev);
+}
+
+
+static void wps_cb_reg_success(struct wps_registrar *reg, const u8 *mac_addr,
+			       const u8 *uuid_e)
+{
+	if (reg->reg_success_cb == NULL)
+		return;
+
+	reg->reg_success_cb(reg->cb_ctx, mac_addr, uuid_e);
 }
 
 
@@ -838,7 +904,7 @@
 	wpa_printf(MSG_DEBUG, "WPS:  * Network Index");
 	wpabuf_put_be16(msg, ATTR_NETWORK_INDEX);
 	wpabuf_put_be16(msg, 1);
-	wpabuf_put_u8(msg, 0);
+	wpabuf_put_u8(msg, 1);
 	return 0;
 }
 
@@ -892,7 +958,8 @@
 static int wps_build_cred_mac_addr(struct wpabuf *msg,
 				   struct wps_credential *cred)
 {
-	wpa_printf(MSG_DEBUG, "WPS:  * MAC Address");
+	wpa_printf(MSG_DEBUG, "WPS:  * MAC Address (" MACSTR ")",
+		   MAC2STR(cred->mac_addr));
 	wpabuf_put_be16(msg, ATTR_MAC_ADDR);
 	wpabuf_put_be16(msg, ETH_ALEN);
 	wpabuf_put_data(msg, cred->mac_addr, ETH_ALEN);
@@ -917,6 +984,9 @@
 static int wps_build_cred(struct wps_data *wps, struct wpabuf *msg)
 {
 	struct wpabuf *cred;
+
+	if (wps->wps->registrar->skip_cred_build)
+		goto skip_cred_build;
 
 	wpa_printf(MSG_DEBUG, "WPS:  * Credential");
 	os_memset(&wps->cred, 0, sizeof(wps->cred));
@@ -963,9 +1033,11 @@
 		}
 	}
 	wps->cred.encr_type = wps->encr_type;
-	os_memcpy(wps->cred.mac_addr, wps->mac_addr_e, ETH_ALEN);
-
-	if (wps->wps->wps_state == WPS_STATE_NOT_CONFIGURED && wps->wps->ap) {
+	/* Set MAC address in the Credential to be the AP's address (BSSID) */
+	os_memcpy(wps->cred.mac_addr, wps->wps->dev.mac_addr, ETH_ALEN);
+
+	if (wps->wps->wps_state == WPS_STATE_NOT_CONFIGURED && wps->wps->ap &&
+	    !wps->wps->registrar->disable_auto_conf) {
 		u8 r[16];
 		/* Generate a random passphrase */
 		if (os_get_random(r, sizeof(r)) < 0)
@@ -1021,6 +1093,12 @@
 	wpabuf_put_buf(msg, cred);
 	wpabuf_free(cred);
 
+skip_cred_build:
+	if (wps->wps->registrar->extra_cred) {
+		wpa_printf(MSG_DEBUG, "WPS:  * Credential (pre-configured)");
+		wpabuf_put_buf(msg, wps->wps->registrar->extra_cred);
+	}
+
 	return 0;
 }
 
@@ -1066,7 +1144,7 @@
 	    wps_build_rf_bands(&wps->wps->dev, msg) ||
 	    wps_build_assoc_state(wps, msg) ||
 	    wps_build_config_error(msg, WPS_CFG_NO_ERROR) ||
-	    wps_build_dev_password_id(msg, DEV_PW_DEFAULT) ||
+	    wps_build_dev_password_id(msg, wps->dev_pw_id) ||
 	    wps_build_os_version(&wps->wps->dev, msg) ||
 	    wps_build_authenticator(wps, msg)) {
 		wpabuf_free(msg);
@@ -1270,6 +1348,39 @@
 				      enum wsc_op_code *op_code)
 {
 	struct wpabuf *msg;
+
+#ifdef CONFIG_WPS_UPNP
+	if (wps->wps->wps_upnp) {
+		struct upnp_pending_message *p, *prev = NULL;
+		if (wps->ext_reg > 1)
+			wps_registrar_free_pending_m2(wps->wps);
+		p = wps->wps->upnp_msgs;
+		/* TODO: check pending message MAC address */
+		while (p && p->next) {
+			prev = p;
+			p = p->next;
+		}
+		if (p) {
+			wpa_printf(MSG_DEBUG, "WPS: Use pending message from "
+				   "UPnP");
+			if (prev)
+				prev->next = NULL;
+			else
+				wps->wps->upnp_msgs = NULL;
+			msg = p->msg;
+			os_free(p);
+			*op_code = WSC_MSG;
+			if (wps->ext_reg == 0)
+				wps->ext_reg = 1;
+			return msg;
+		}
+	}
+	if (wps->ext_reg) {
+		wpa_printf(MSG_DEBUG, "WPS: Using external Registrar, but no "
+			   "pending message available");
+		return NULL;
+	}
+#endif /* CONFIG_WPS_UPNP */
 
 	switch (wps->state) {
 	case SEND_M2:
@@ -1437,6 +1548,7 @@
 		wpa_printf(MSG_DEBUG, "WPS: E-Hash1 derived from E-S1 does "
 			   "not match with the pre-committed value");
 		wps->config_error = WPS_CFG_DEV_PASSWORD_AUTH_FAILURE;
+		wps_pwd_auth_fail_event(wps->wps, 0, 1);
 		return -1;
 	}
 
@@ -1477,6 +1589,7 @@
 			   "not match with the pre-committed value");
 		wps_registrar_invalidate_pin(wps->wps->registrar, wps->uuid_e);
 		wps->config_error = WPS_CFG_DEV_PASSWORD_AUTH_FAILURE;
+		wps_pwd_auth_fail_event(wps->wps, 0, 2);
 		return -1;
 	}
 
@@ -1864,7 +1977,7 @@
 	if (wps_parse_msg(msg, &attr) < 0)
 		return WPS_FAILURE;
 
-	if (attr.version == NULL || *attr.version != WPS_VERSION) {
+	if (!wps_version_supported(attr.version)) {
 		wpa_printf(MSG_DEBUG, "WPS: Unsupported message version 0x%x",
 			   attr.version ? *attr.version : 0);
 		return WPS_FAILURE;
@@ -1885,6 +1998,17 @@
 
 	switch (*attr.msg_type) {
 	case WPS_M1:
+#ifdef CONFIG_WPS_UPNP
+		if (wps->wps->wps_upnp && attr.mac_addr) {
+			/* Remove old pending messages when starting new run */
+			wps_free_pending_msgs(wps->wps->upnp_msgs);
+			wps->wps->upnp_msgs = NULL;
+
+			upnp_wps_device_send_wlan_event(
+				wps->wps->wps_upnp, attr.mac_addr,
+				UPNP_WPS_WLANEVENT_TYPE_EAP, msg);
+		}
+#endif /* CONFIG_WPS_UPNP */
 		ret = wps_process_m1(wps, &attr);
 		break;
 	case WPS_M3:
@@ -1929,7 +2053,7 @@
 	if (wps_parse_msg(msg, &attr) < 0)
 		return WPS_FAILURE;
 
-	if (attr.version == NULL || *attr.version != WPS_VERSION) {
+	if (!wps_version_supported(attr.version)) {
 		wpa_printf(MSG_DEBUG, "WPS: Unsupported message version 0x%x",
 			   attr.version ? *attr.version : 0);
 		return WPS_FAILURE;
@@ -1945,6 +2069,17 @@
 			   *attr.msg_type);
 		return WPS_FAILURE;
 	}
+
+#ifdef CONFIG_WPS_UPNP
+	if (wps->wps->wps_upnp && wps->ext_reg && wps->state == RECV_M2D_ACK &&
+	    upnp_wps_subscribers(wps->wps->wps_upnp)) {
+		if (wps->wps->upnp_msgs)
+			return WPS_CONTINUE;
+		wpa_printf(MSG_DEBUG, "WPS: Wait for response from an "
+			   "external Registrar");
+		return WPS_PENDING;
+	}
+#endif /* CONFIG_WPS_UPNP */
 
 	if (attr.registrar_nonce == NULL ||
 	    os_memcmp(wps->nonce_r, attr.registrar_nonce, WPS_NONCE_LEN != 0))
@@ -1960,8 +2095,18 @@
 	}
 
 	if (wps->state == RECV_M2D_ACK) {
-		/* TODO: support for multiple registrars and sending of
-		 * multiple M2/M2D messages */
+#ifdef CONFIG_WPS_UPNP
+		if (wps->wps->wps_upnp &&
+		    upnp_wps_subscribers(wps->wps->wps_upnp)) {
+			if (wps->wps->upnp_msgs)
+				return WPS_CONTINUE;
+			if (wps->ext_reg == 0)
+				wps->ext_reg = 1;
+			wpa_printf(MSG_DEBUG, "WPS: Wait for response from an "
+				   "external Registrar");
+			return WPS_PENDING;
+		}
+#endif /* CONFIG_WPS_UPNP */
 
 		wpa_printf(MSG_DEBUG, "WPS: No more registrars available - "
 			   "terminate negotiation");
@@ -1985,7 +2130,7 @@
 	if (wps_parse_msg(msg, &attr) < 0)
 		return WPS_FAILURE;
 
-	if (attr.version == NULL || *attr.version != WPS_VERSION) {
+	if (!wps_version_supported(attr.version)) {
 		wpa_printf(MSG_DEBUG, "WPS: Unsupported message version 0x%x",
 			   attr.version ? *attr.version : 0);
 		return WPS_FAILURE;
@@ -2001,6 +2146,14 @@
 			   *attr.msg_type);
 		return WPS_FAILURE;
 	}
+
+#ifdef CONFIG_WPS_UPNP
+	if (wps->wps->wps_upnp && wps->ext_reg) {
+		wpa_printf(MSG_DEBUG, "WPS: Negotiation using external "
+			   "Registrar terminated by the Enrollee");
+		return WPS_FAILURE;
+	}
+#endif /* CONFIG_WPS_UPNP */
 
 	if (attr.registrar_nonce == NULL ||
 	    os_memcmp(wps->nonce_r, attr.registrar_nonce, WPS_NONCE_LEN != 0))
@@ -2052,7 +2205,8 @@
 
 	wpa_printf(MSG_DEBUG, "WPS: Received WSC_Done");
 
-	if (wps->state != RECV_DONE) {
+	if (wps->state != RECV_DONE &&
+	    (!wps->wps->wps_upnp || !wps->ext_reg)) {
 		wpa_printf(MSG_DEBUG, "WPS: Unexpected state (%d) for "
 			   "receiving WSC_Done", wps->state);
 		return WPS_FAILURE;
@@ -2061,7 +2215,7 @@
 	if (wps_parse_msg(msg, &attr) < 0)
 		return WPS_FAILURE;
 
-	if (attr.version == NULL || *attr.version != WPS_VERSION) {
+	if (!wps_version_supported(attr.version)) {
 		wpa_printf(MSG_DEBUG, "WPS: Unsupported message version 0x%x",
 			   attr.version ? *attr.version : 0);
 		return WPS_FAILURE;
@@ -2077,6 +2231,14 @@
 			   *attr.msg_type);
 		return WPS_FAILURE;
 	}
+
+#ifdef CONFIG_WPS_UPNP
+	if (wps->wps->wps_upnp && wps->ext_reg) {
+		wpa_printf(MSG_DEBUG, "WPS: Negotiation using external "
+			   "Registrar completed successfully");
+		return WPS_DONE;
+	}
+#endif /* CONFIG_WPS_UPNP */
 
 	if (attr.registrar_nonce == NULL ||
 	    os_memcmp(wps->nonce_r, attr.registrar_nonce, WPS_NONCE_LEN != 0))
@@ -2094,7 +2256,7 @@
 	wpa_printf(MSG_DEBUG, "WPS: Negotiation completed successfully");
 
 	if (wps->wps->wps_state == WPS_STATE_NOT_CONFIGURED && wps->new_psk &&
-	    wps->wps->ap) {
+	    wps->wps->ap && !wps->wps->registrar->disable_auto_conf) {
 		struct wps_credential cred;
 
 		wpa_printf(MSG_DEBUG, "WPS: Moving to Configured state based "
@@ -2136,6 +2298,8 @@
 		wps->new_psk = NULL;
 	}
 
+	wps_cb_reg_success(wps->wps->registrar, wps->mac_addr_e, wps->uuid_e);
+
 	if (wps->pbc) {
 		wps_registrar_remove_pbc_session(wps->wps->registrar,
 						 wps->mac_addr_e, wps->uuid_e);
@@ -2157,6 +2321,39 @@
 	wpa_printf(MSG_DEBUG, "WPS: Processing received message (len=%lu "
 		   "op_code=%d)",
 		   (unsigned long) wpabuf_len(msg), op_code);
+
+#ifdef CONFIG_WPS_UPNP
+	if (wps->wps->wps_upnp && op_code == WSC_MSG && wps->ext_reg == 1) {
+		struct wps_parse_attr attr;
+		if (wps_parse_msg(msg, &attr) == 0 && attr.msg_type &&
+		    *attr.msg_type == WPS_M3)
+			wps->ext_reg = 2; /* past M2/M2D phase */
+	}
+	if (wps->ext_reg > 1)
+		wps_registrar_free_pending_m2(wps->wps);
+	if (wps->wps->wps_upnp && wps->ext_reg &&
+	    wps->wps->upnp_msgs == NULL &&
+	    (op_code == WSC_MSG || op_code == WSC_Done)) {
+		struct wps_parse_attr attr;
+		int type;
+		if (wps_parse_msg(msg, &attr) < 0 || attr.msg_type == NULL)
+			type = -1;
+		else
+			type = *attr.msg_type;
+		wpa_printf(MSG_DEBUG, "WPS: Sending received message (type %d)"
+			   " to external Registrar for processing", type);
+		upnp_wps_device_send_wlan_event(wps->wps->wps_upnp,
+						wps->mac_addr_e,
+						UPNP_WPS_WLANEVENT_TYPE_EAP,
+						msg);
+		if (op_code == WSC_MSG)
+			return WPS_PENDING;
+	} else if (wps->wps->wps_upnp && wps->ext_reg && op_code == WSC_MSG) {
+		wpa_printf(MSG_DEBUG, "WPS: Skip internal processing - using "
+			   "external Registrar");
+		return WPS_CONTINUE;
+	}
+#endif /* CONFIG_WPS_UPNP */
 
 	switch (op_code) {
 	case WSC_MSG:
@@ -2177,3 +2374,75 @@
 		return WPS_FAILURE;
 	}
 }
+
+
+int wps_registrar_update_ie(struct wps_registrar *reg)
+{
+	return wps_set_ie(reg);
+}
+
+
+static void wps_registrar_set_selected_timeout(void *eloop_ctx,
+					       void *timeout_ctx)
+{
+	struct wps_registrar *reg = eloop_ctx;
+
+	wpa_printf(MSG_DEBUG, "WPS: SetSelectedRegistrar timed out - "
+		   "unselect Registrar");
+	reg->selected_registrar = 0;
+	reg->pbc = 0;
+	reg->sel_reg_dev_password_id_override = -1;
+	reg->sel_reg_config_methods_override = -1;
+	wps_set_ie(reg);
+}
+
+
+/**
+ * wps_registrar_set_selected_registrar - Notification of SetSelectedRegistrar
+ * @reg: Registrar data from wps_registrar_init()
+ * @msg: Received message from SetSelectedRegistrar
+ * @msg_len: Length of msg in octets
+ * Returns: 0 on success, -1 on failure
+ *
+ * This function is called when an AP receives a SetSelectedRegistrar UPnP
+ * message.
+ */
+int wps_registrar_set_selected_registrar(struct wps_registrar *reg,
+					 const struct wpabuf *msg)
+{
+	struct wps_parse_attr attr;
+
+	wpa_hexdump_buf(MSG_MSGDUMP, "WPS: SetSelectedRegistrar attributes",
+			msg);
+
+	if (wps_parse_msg(msg, &attr) < 0)
+		return -1;
+	if (!wps_version_supported(attr.version)) {
+		wpa_printf(MSG_DEBUG, "WPS: Unsupported SetSelectedRegistrar "
+			   "version 0x%x", attr.version ? *attr.version : 0);
+		return -1;
+	}
+
+	if (attr.selected_registrar == NULL ||
+	    *attr.selected_registrar == 0) {
+		wpa_printf(MSG_DEBUG, "WPS: SetSelectedRegistrar: Disable "
+			   "Selected Registrar");
+		eloop_cancel_timeout(wps_registrar_set_selected_timeout, reg,
+				     NULL);
+		wps_registrar_set_selected_timeout(reg, NULL);
+		return 0;
+	}
+
+	reg->selected_registrar = 1;
+	reg->sel_reg_dev_password_id_override = attr.dev_password_id ?
+		WPA_GET_BE16(attr.dev_password_id) : DEV_PW_DEFAULT;
+	reg->sel_reg_config_methods_override = attr.sel_reg_config_methods ?
+		WPA_GET_BE16(attr.sel_reg_config_methods) : -1;
+	wps_set_ie(reg);
+
+	eloop_cancel_timeout(wps_registrar_set_selected_timeout, reg, NULL);
+	eloop_register_timeout(WPS_PBC_WALK_TIME, 0,
+			       wps_registrar_set_selected_timeout,
+			       reg, NULL);
+	return 0;
+}

Modified: wpasupplicant/trunk/wpa_supplicant/ChangeLog
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/wpa_supplicant/ChangeLog?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/wpa_supplicant/ChangeLog (original)
+++ wpasupplicant/trunk/wpa_supplicant/ChangeLog Sun Feb 15 20:49:57 2009
@@ -1,4 +1,10 @@
 ChangeLog for wpa_supplicant
+
+2009-02-15 - v0.6.8
+	* increased wpa_cli ping interval to 5 seconds and made this
+	  configurable with a new command line options (-G<seconds>)
+	* fixed scan buffer processing with WEXT to handle up to 65535
+	  byte result buffer (previously, limited to 32768 bytes)
 
 2009-01-06 - v0.6.7
 	* added support for Wi-Fi Protected Setup (WPS)

Modified: wpasupplicant/trunk/wpa_supplicant/Makefile
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/wpa_supplicant/Makefile?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/wpa_supplicant/Makefile (original)
+++ wpasupplicant/trunk/wpa_supplicant/Makefile Sun Feb 15 20:49:57 2009
@@ -5,6 +5,9 @@
 ifndef CFLAGS
 CFLAGS = -MMD -O2 -Wall -g
 endif
+
+export LIBDIR ?= /usr/local/lib/
+export BINDIR ?= /usr/local/sbin/
 
 CFLAGS += -I../src
 CFLAGS += -I../src/crypto
@@ -35,8 +38,9 @@
 	echo CONFIG_WIRELESS_EXTENSION=y >> .config
 
 install: all
-	mkdir -p $(DESTDIR)/usr/local/sbin/
-	for i in $(ALL); do cp $$i $(DESTDIR)/usr/local/sbin/$$i; done
+	mkdir -p $(DESTDIR)$(BINDIR)
+	for i in $(ALL); do cp $$i $(DESTDIR)$(BINDIR)/$$i; done
+	$(MAKE) -C ../src install
 
 OBJS = config.o
 OBJS += ../src/utils/common.o
@@ -505,10 +509,6 @@
 
 ifdef CONFIG_WPS
 # EAP-WSC
-ifeq ($(CONFIG_EAP_WSC), dyn)
-CFLAGS += -DCONFIG_WPS -DEAP_WSC_DYNAMIC
-EAPDYN += ../src/eap_peer/eap_wsc.so
-else
 CFLAGS += -DCONFIG_WPS -DEAP_WSC
 OBJS += wps_supplicant.o
 OBJS += ../src/utils/uuid.o
@@ -522,11 +522,20 @@
 OBJS += ../src/wps/wps_enrollee.o
 OBJS += ../src/wps/wps_registrar.o
 OBJS_h += ../src/eap_server/eap_wsc.o
-endif
 CONFIG_IEEE8021X_EAPOL=y
 NEED_DH_GROUPS=y
 NEED_SHA256=y
 NEED_BASE64=y
+
+ifdef CONFIG_WPS_UPNP
+CFLAGS += -DCONFIG_WPS_UPNP
+OBJS += ../src/wps/wps_upnp.o
+OBJS += ../src/wps/wps_upnp_ssdp.o
+OBJS += ../src/wps/wps_upnp_web.o
+OBJS += ../src/wps/wps_upnp_event.o
+OBJS += ../src/wps/httpread.o
+endif
+
 endif
 
 ifdef CONFIG_EAP_IKEV2
@@ -564,6 +573,9 @@
 OBJS += ../src/eap_peer/eap_tnc.o
 OBJS += ../src/eap_peer/tncc.o
 NEED_BASE64=y
+ifndef CONFIG_NATIVE_WINDOWS
+LIBS += -ldl
+endif
 endif
 
 ifdef CONFIG_IEEE8021X_EAPOL
@@ -1017,6 +1029,7 @@
 OBJS_priv += ../src/utils/$(CONFIG_ELOOP).o
 OBJS_priv += ../src/utils/common.o
 OBJS_priv += ../src/utils/wpa_debug.o
+OBJS_priv += ../src/utils/wpabuf.o
 OBJS_priv += wpa_priv.o
 ifdef CONFIG_DRIVER_TEST
 OBJS_priv += ../src/crypto/sha1.o
@@ -1126,7 +1139,7 @@
 
 %.so: %.c
 	$(CC) -o $@ $(CFLAGS) -shared -rdynamic -fPIC $< \
-		-D$(*:eap_%=eap_peer_%)_register=eap_peer_method_dynamic_init
+		-D$(*F:eap_%=eap_peer_%)_register=eap_peer_method_dynamic_init
 
 
 wpa_supplicant.exe: wpa_supplicant
@@ -1170,7 +1183,7 @@
 	./test-sha1
 	rm test-sha1
 
-TEST_SHA256_OBJS = ../src/crypto/sha256.o ../src/crypto/md5.o tests/test_sha256.o ../src/crypto/crypto_openssl.o
+TEST_SHA256_OBJS = ../src/crypto/sha256.o ../src/crypto/md5.o tests/test_sha256.o ../src/utils/os_unix.o ../src/crypto/crypto_openssl.o
 test-sha256: $(TEST_SHA256_OBJS)
 	$(LDO) $(LDFLAGS) -o $@ $(TEST_SHA256_OBJS) $(LIBS)
 	./test-sha256

Modified: wpasupplicant/trunk/wpa_supplicant/README
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/wpa_supplicant/README?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/wpa_supplicant/README (original)
+++ wpasupplicant/trunk/wpa_supplicant/README Sun Feb 15 20:49:57 2009
@@ -166,7 +166,7 @@
 	Linux ndiswrapper (http://ndiswrapper.sourceforge.net/) with
 	Windows NDIS driver.
 
-	Broadcom wl.o driver
+	Broadcom wl.o driver (old version only)
 	This is a generic Linux driver for Broadcom IEEE 802.11a/g cards.
 	However, it is proprietary driver that is not publicly available
 	except for couple of exceptions, mainly Broadcom-based APs/wireless
@@ -176,7 +176,10 @@
 	the needed header file, wlioctl.h, for compiling wpa_supplicant.
 	This driver support in wpa_supplicant is expected to work also with
 	other devices based on Broadcom driver (assuming the driver includes
-	client mode support).
+	client mode support). Please note that the newer Broadcom driver
+	("hybrid Linux driver") supports Linux wireless extensions and does
+	not need (or even work) with the specific driver wrapper. Use -Dwext
+	with that driver.
 
 	Intel ipw2100 driver
 	(http://sourceforge.net/projects/ipw2100/)

Modified: wpasupplicant/trunk/wpa_supplicant/README-WPS
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/wpa_supplicant/README-WPS?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/wpa_supplicant/README-WPS (original)
+++ wpasupplicant/trunk/wpa_supplicant/README-WPS Sun Feb 15 20:49:57 2009
@@ -163,3 +163,22 @@
 WPS tab that guides user through WPS registration with automatic AP
 selection. In addition, it shows how WPS can be started manually by
 selecting an AP from scan results.
+
+
+Credential processing
+---------------------
+
+By default, wpa_supplicant processes received credentials and updates
+its configuration internally. However, it is possible to
+control these operations from external programs, if desired.
+
+This internal processing can be disabled with wps_cred_processing=1
+option. When this is used, an external program is responsible for
+processing the credential attributes and updating wpa_supplicant
+configuration based on them.
+
+Following control interface messages are sent out for external programs:
+
+WPS-CRED-RECEIVED  <hexdump of Credential attribute(s)>
+For example:
+<2>WPS-CRED-RECEIVED 100e006f10260001011045000c6a6b6d2d7770732d74657374100300020020100f000200081027004030653462303435366332363666653064333961643135353461316634626637313234333761636664623766333939653534663166316230323061643434386235102000060266a0ee1727

Modified: wpasupplicant/trunk/wpa_supplicant/config.h
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/wpa_supplicant/config.h?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/wpa_supplicant/config.h (original)
+++ wpasupplicant/trunk/wpa_supplicant/config.h Sun Feb 15 20:49:57 2009
@@ -312,6 +312,17 @@
 	 * in
 	 */
 	char country[2];
+
+	/**
+	 * wps_cred_processing - Credential processing
+	 *
+	 *   0 = process received credentials internally
+	 *   1 = do not process received credentials; just pass them over
+	 *	ctrl_iface to external program(s)
+	 *   2 = process received credentials internally and pass them over
+	 *	ctrl_iface to external program(s)
+	 */
+	int wps_cred_processing;
 };
 
 

Modified: wpasupplicant/trunk/wpa_supplicant/config_file.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/wpa_supplicant/config_file.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/wpa_supplicant/config_file.c (original)
+++ wpasupplicant/trunk/wpa_supplicant/config_file.c Sun Feb 15 20:49:57 2009
@@ -456,6 +456,7 @@
 	{ STR_RANGE(serial_number, 0, 32) },
 	{ STR(device_type) },
 	{ FUNC(os_version) },
+	{ INT_RANGE(wps_cred_processing, 0, 2) },
 #endif /* CONFIG_WPS */
 	{ FUNC(country) }
 };
@@ -881,6 +882,9 @@
 	if (WPA_GET_BE32(config->os_version))
 		fprintf(f, "os_version=%08x\n",
 			WPA_GET_BE32(config->os_version));
+	if (config->wps_cred_processing)
+		fprintf(f, "wps_cred_processing=%d\n",
+			config->wps_cred_processing);
 #endif /* CONFIG_WPS */
 	if (config->country[0] && config->country[1]) {
 		fprintf(f, "country=%c%c\n",

Modified: wpasupplicant/trunk/wpa_supplicant/config_winreg.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/wpa_supplicant/config_winreg.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/wpa_supplicant/config_winreg.c (original)
+++ wpasupplicant/trunk/wpa_supplicant/config_winreg.c Sun Feb 15 20:49:57 2009
@@ -251,6 +251,8 @@
 		hk, TEXT("device_type"));
 	if (wpa_config_read_global_os_version(config, hk))
 		errors++;
+	wpa_config_read_reg_dword(hk, TEXT("wps_cred_processing"),
+				  &config->wps_cred_processing);
 #endif /* CONFIG_WPS */
 
 	return errors ? -1 : 0;
@@ -573,6 +575,8 @@
 			    WPA_GET_BE32(config->os_version));
 		wpa_config_write_reg_string(hk, "os_version", vbuf);
 	}
+	wpa_config_write_reg_dword(hk, TEXT("wps_cred_processing"),
+				   config->wps_cred_processing, 0);
 #endif /* CONFIG_WPS */
 
 	return 0;

Modified: wpasupplicant/trunk/wpa_supplicant/ctrl_iface_dbus.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/wpa_supplicant/ctrl_iface_dbus.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/wpa_supplicant/ctrl_iface_dbus.c (original)
+++ wpasupplicant/trunk/wpa_supplicant/ctrl_iface_dbus.c Sun Feb 15 20:49:57 2009
@@ -18,6 +18,7 @@
 #include "eloop.h"
 #include "config.h"
 #include "wpa_supplicant_i.h"
+#include "wps/wps.h"
 #include "ctrl_iface_dbus.h"
 #include "ctrl_iface_dbus_handlers.h"
 
@@ -547,7 +548,8 @@
 
 	/* If the message was handled, send back the reply */
 	if (reply) {
-		dbus_connection_send(connection, reply, NULL);
+		if (!dbus_message_get_no_reply(message))
+			dbus_connection_send(connection, reply, NULL);
 		dbus_message_unref(reply);
 	}
 
@@ -606,7 +608,8 @@
 
 	/* If the message was handled, send back the reply */
 	if (reply) {
-		dbus_connection_send(connection, reply, NULL);
+		if (!dbus_message_get_no_reply(message))
+			dbus_connection_send(connection, reply, NULL);
 		dbus_message_unref(reply);
 	}
 
@@ -736,6 +739,63 @@
 out:
 	dbus_message_unref(_signal);
 }
+
+
+#ifdef CONFIG_WPS
+void wpa_supplicant_dbus_notify_wps_cred(struct wpa_supplicant *wpa_s,
+					 const struct wps_credential *cred)
+{
+	struct ctrl_iface_dbus_priv *iface;
+	DBusMessage *_signal = NULL;
+	const char *path;
+
+	/* Do nothing if the control interface is not turned on */
+	if (wpa_s->global == NULL)
+		return;
+	iface = wpa_s->global->dbus_ctrl_iface;
+	if (iface == NULL)
+		return;
+
+	path = wpa_supplicant_get_dbus_path(wpa_s);
+	if (path == NULL) {
+		perror("wpa_supplicant_dbus_notify_wps_cred[dbus]: "
+		       "interface didn't have a dbus path");
+		wpa_printf(MSG_ERROR,
+		           "wpa_supplicant_dbus_notify_wps_cred[dbus]: "
+		           "interface didn't have a dbus path; can't send "
+		           "signal.");
+		return;
+	}
+	_signal = dbus_message_new_signal(path, WPAS_DBUS_IFACE_INTERFACE,
+					  "WpsCred");
+	if (_signal == NULL) {
+		perror("wpa_supplicant_dbus_notify_wps_cred[dbus]: "
+		       "couldn't create dbus signal; likely out of memory");
+		wpa_printf(MSG_ERROR,
+		           "wpa_supplicant_dbus_notify_wps_cred[dbus]: "
+		           "couldn't create dbus signal; likely out of "
+		           "memory.");
+		return;
+	}
+
+	if (!dbus_message_append_args(_signal,
+	                              DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
+				      &cred->cred_attr, cred->cred_attr_len,
+	                              DBUS_TYPE_INVALID)) {
+		perror("wpa_supplicant_dbus_notify_wps_cred[dbus]: "
+		       "not enough memory to construct signal.");
+		wpa_printf(MSG_ERROR,
+		           "wpa_supplicant_dbus_notify_wps_cred[dbus]: "
+		           "not enough memory to construct signal.");
+		goto out;
+	}
+
+	dbus_connection_send(iface->con, _signal, NULL);
+
+out:
+	dbus_message_unref(_signal);
+}
+#endif /* CONFIG_WPS */
 
 
 /**

Modified: wpasupplicant/trunk/wpa_supplicant/ctrl_iface_dbus.h
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/wpa_supplicant/ctrl_iface_dbus.h?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/wpa_supplicant/ctrl_iface_dbus.h (original)
+++ wpasupplicant/trunk/wpa_supplicant/ctrl_iface_dbus.h Sun Feb 15 20:49:57 2009
@@ -14,6 +14,8 @@
 
 #ifndef CTRL_IFACE_DBUS_H
 #define CTRL_IFACE_DBUS_H
+
+struct wps_credential;
 
 #ifdef CONFIG_CTRL_IFACE_DBUS
 
@@ -84,6 +86,8 @@
 void wpa_supplicant_dbus_notify_state_change(struct wpa_supplicant *wpa_s,
 					     wpa_states new_state,
 					     wpa_states old_state);
+void wpa_supplicant_dbus_notify_wps_cred(struct wpa_supplicant *wpa_s,
+					 const struct wps_credential *cred);
 
 char * wpas_dbus_decompose_object_path(const char *path, char **network,
                                        char **bssid);
@@ -129,6 +133,12 @@
 {
 }
 
+static inline void
+wpa_supplicant_dbus_notify_wps_cred(struct wpa_supplicant *wpa_s,
+				    const struct wps_credential *cred)
+{
+}
+
 static inline int
 wpas_dbus_register_iface(struct wpa_supplicant *wpa_s)
 {

Modified: wpasupplicant/trunk/wpa_supplicant/defconfig
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/wpa_supplicant/defconfig?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/wpa_supplicant/defconfig (original)
+++ wpasupplicant/trunk/wpa_supplicant/defconfig Sun Feb 15 20:49:57 2009
@@ -51,8 +51,8 @@
 
 # Driver interface for madwifi driver
 #CONFIG_DRIVER_MADWIFI=y
-# Change include directories to match with the local setup
-#CFLAGS += -I../madwifi/wpa
+# Set include directory to the madwifi source tree
+#CFLAGS += -I../../madwifi
 
 # Driver interface for Prism54 driver
 # (Note: Prism54 is not yet supported, i.e., this will not work as-is and is
@@ -65,7 +65,10 @@
 # Driver interface for Atmel driver
 CONFIG_DRIVER_ATMEL=y
 
-# Driver interface for Broadcom driver
+# Driver interface for old Broadcom driver
+# Please note that the newer Broadcom driver ("hybrid Linux driver") supports
+# Linux wireless extensions and does not need (or even work) with the old
+# driver wrapper. Use CONFIG_DRIVER_WEXT=y with that driver.
 #CONFIG_DRIVER_BROADCOM=y
 # Example path for wlioctl.h; change to match your configuration
 #CFLAGS += -I/opt/WRT54GS/release/src/include
@@ -78,6 +81,9 @@
 
 # Driver interface for generic Linux wireless extensions
 CONFIG_DRIVER_WEXT=y
+
+# Driver interface for Linux drivers using the nl80211 kernel interface
+#CONFIG_DRIVER_NL80211=y
 
 # Driver interface for FreeBSD net80211 layer (e.g., Atheros driver)
 #CONFIG_DRIVER_BSD=y
@@ -357,15 +363,10 @@
 
 # Include client MLME (management frame processing).
 # This can be used to move MLME processing of Linux mac80211 stack into user
-# space.
+# space. Please note that this is currently only available with
+# driver_nl80211.c and only with a modified version of Linux kernel and
+# wpa_supplicant.
 #CONFIG_CLIENT_MLME=y
-# Currently, driver_nl80211.c build requires some additional parameters to be
-# able to include some of the kernel header files. Following lines can be used
-# to set these (WIRELESS_DEV must point to the root directory of the
-# wireless-testing.git tree). In addition, mac80211 may need external patches
-# to enable userspace MLME support.
-#WIRELESS_DEV=/usr/src/wireless-testing
-#CFLAGS += -I$(WIRELESS_DEV)/net/mac80211
 
 # IEEE Std 802.11r-2008 (Fast BSS Transition)
 #CONFIG_IEEE80211R=y

Modified: wpasupplicant/trunk/wpa_supplicant/eapol_test.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/wpa_supplicant/eapol_test.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/wpa_supplicant/eapol_test.c (original)
+++ wpasupplicant/trunk/wpa_supplicant/eapol_test.c Sun Feb 15 20:49:57 2009
@@ -156,6 +156,18 @@
 }
 
 
+static struct extra_radius_attr *
+find_extra_attr(struct extra_radius_attr *attrs, u8 type)
+{
+	struct extra_radius_attr *p;
+	for (p = attrs; p; p = p->next) {
+		if (p->type == type)
+			return p;
+	}
+	return NULL;
+}
+
+
 static void ieee802_1x_encapsulate_radius(struct eapol_test_data *e,
 					  const u8 *eap, size_t len)
 {
@@ -200,7 +212,8 @@
 		goto fail;
 	}
 
-	if (!radius_msg_add_attr(msg, RADIUS_ATTR_NAS_IP_ADDRESS,
+	if (!find_extra_attr(e->extra_attrs, RADIUS_ATTR_NAS_IP_ADDRESS) &&
+	    !radius_msg_add_attr(msg, RADIUS_ATTR_NAS_IP_ADDRESS,
 				 (u8 *) &e->own_ip_addr, 4)) {
 		printf("Could not add NAS-IP-Address\n");
 		goto fail;
@@ -208,7 +221,9 @@
 
 	os_snprintf(buf, sizeof(buf), RADIUS_802_1X_ADDR_FORMAT,
 		    MAC2STR(e->wpa_s->own_addr));
-	if (!radius_msg_add_attr(msg, RADIUS_ATTR_CALLING_STATION_ID,
+	if (!find_extra_attr(e->extra_attrs, RADIUS_ATTR_CALLING_STATION_ID)
+	    &&
+	    !radius_msg_add_attr(msg, RADIUS_ATTR_CALLING_STATION_ID,
 				 (u8 *) buf, os_strlen(buf))) {
 		printf("Could not add Calling-Station-Id\n");
 		goto fail;
@@ -217,19 +232,22 @@
 	/* TODO: should probably check MTU from driver config; 2304 is max for
 	 * IEEE 802.11, but use 1400 to avoid problems with too large packets
 	 */
-	if (!radius_msg_add_attr_int32(msg, RADIUS_ATTR_FRAMED_MTU, 1400)) {
+	if (!find_extra_attr(e->extra_attrs, RADIUS_ATTR_FRAMED_MTU) &&
+	    !radius_msg_add_attr_int32(msg, RADIUS_ATTR_FRAMED_MTU, 1400)) {
 		printf("Could not add Framed-MTU\n");
 		goto fail;
 	}
 
-	if (!radius_msg_add_attr_int32(msg, RADIUS_ATTR_NAS_PORT_TYPE,
+	if (!find_extra_attr(e->extra_attrs, RADIUS_ATTR_NAS_PORT_TYPE) &&
+	    !radius_msg_add_attr_int32(msg, RADIUS_ATTR_NAS_PORT_TYPE,
 				       RADIUS_NAS_PORT_TYPE_IEEE_802_11)) {
 		printf("Could not add NAS-Port-Type\n");
 		goto fail;
 	}
 
 	os_snprintf(buf, sizeof(buf), "%s", e->connect_info);
-	if (!radius_msg_add_attr(msg, RADIUS_ATTR_CONNECT_INFO,
+	if (!find_extra_attr(e->extra_attrs, RADIUS_ATTR_CONNECT_INFO) &&
+	    !radius_msg_add_attr(msg, RADIUS_ATTR_CONNECT_INFO,
 				 (u8 *) buf, os_strlen(buf))) {
 		printf("Could not add Connect-Info\n");
 		goto fail;

Modified: wpasupplicant/trunk/wpa_supplicant/events.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/wpa_supplicant/events.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/wpa_supplicant/events.c (original)
+++ wpasupplicant/trunk/wpa_supplicant/events.c Sun Feb 15 20:49:57 2009
@@ -270,7 +270,8 @@
 }
 
 
-static int wpa_supplicant_ssid_bss_match(struct wpa_ssid *ssid,
+static int wpa_supplicant_ssid_bss_match(struct wpa_supplicant *wpa_s,
+					 struct wpa_ssid *ssid,
 					 struct wpa_scan_res *bss)
 {
 	struct wpa_ie_data ie;
@@ -278,7 +279,7 @@
 	const u8 *rsn_ie, *wpa_ie;
 	int ret;
 
-	ret = wpas_wps_ssid_bss_match(ssid, bss);
+	ret = wpas_wps_ssid_bss_match(wpa_s, ssid, bss);
 	if (ret >= 0)
 		return ret;
 
@@ -424,7 +425,7 @@
 
 #ifdef CONFIG_WPS
 			if (ssid->ssid_len == 0 &&
-			    wpas_wps_ssid_wildcard_ok(ssid, bss))
+			    wpas_wps_ssid_wildcard_ok(wpa_s, ssid, bss))
 				check_ssid = 0;
 #endif /* CONFIG_WPS */
 
@@ -444,7 +445,7 @@
 				continue;
 			}
 
-			if (!wpa_supplicant_ssid_bss_match(ssid, bss))
+			if (!wpa_supplicant_ssid_bss_match(wpa_s, ssid, bss))
 				continue;
 
 			wpa_printf(MSG_DEBUG, "   selected WPA AP "
@@ -514,7 +515,8 @@
 				 * with our mode. */
 				check_ssid = 1;
 				if (ssid->ssid_len == 0 &&
-				    wpas_wps_ssid_wildcard_ok(ssid, bss))
+				    wpas_wps_ssid_wildcard_ok(wpa_s, ssid,
+							      bss))
 					check_ssid = 0;
 			}
 #endif /* CONFIG_WPS */
@@ -645,6 +647,7 @@
 			wpa_printf(MSG_DEBUG, "No APs found - clear blacklist "
 				   "and try again");
 			wpa_blacklist_clear(wpa_s);
+			wpa_s->blacklist_cleared++;
 		} else if (selected == NULL) {
 			break;
 		}

Modified: wpasupplicant/trunk/wpa_supplicant/mlme.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/wpa_supplicant/mlme.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/wpa_supplicant/mlme.c (original)
+++ wpasupplicant/trunk/wpa_supplicant/mlme.c Sun Feb 15 20:49:57 2009
@@ -1087,9 +1087,10 @@
 			   status_code);
 #ifdef CONFIG_IEEE80211W
 		if (status_code == WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY &&
-		    elems.assoc_comeback && elems.assoc_comeback_len == 4) {
+		    elems.timeout_int && elems.timeout_int_len == 5 &&
+		    elems.timeout_int[0] == WLAN_TIMEOUT_ASSOC_COMEBACK) {
 			u32 tu, ms;
-			tu = WPA_GET_LE32(elems.assoc_comeback);
+			tu = WPA_GET_LE32(elems.timeout_int + 1);
 			ms = tu * 1024 / 1000;
 			wpa_printf(MSG_DEBUG, "MLME: AP rejected association "
 				   "temporarily; comeback duration %u TU "

Modified: wpasupplicant/trunk/wpa_supplicant/nmake.mak
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/wpa_supplicant/nmake.mak?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/wpa_supplicant/nmake.mak (original)
+++ wpasupplicant/trunk/wpa_supplicant/nmake.mak Sun Feb 15 20:49:57 2009
@@ -81,12 +81,13 @@
 	$(OBJDIR)\eap_common.obj \
 	$(OBJDIR)\chap.obj \
 	$(OBJDIR)\eap_methods.obj \
-	$(OBJDIR)\eap_tlv.obj \
 	$(OBJDIR)\eap_md5.obj \
 	$(OBJDIR)\eap_tls.obj \
 	$(OBJDIR)\eap_tls_common.obj \
 	$(OBJDIR)\eap_mschapv2.obj \
+	$(OBJDIR)\mschapv2.obj \
 	$(OBJDIR)\eap_peap.obj \
+	$(OBJDIR)\eap_peap_common.obj \
 	$(OBJDIR)\eap_ttls.obj \
 	$(OBJDIR)\eap_gtc.obj \
 	$(OBJDIR)\eap_otp.obj \

Modified: wpasupplicant/trunk/wpa_supplicant/scan.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/wpa_supplicant/scan.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/wpa_supplicant/scan.c (original)
+++ wpasupplicant/trunk/wpa_supplicant/scan.c Sun Feb 15 20:49:57 2009
@@ -204,7 +204,8 @@
 	if (ret) {
 		wpa_printf(MSG_WARNING, "Failed to initiate AP scan.");
 		wpa_supplicant_req_scan(wpa_s, 10, 0);
-	}
+	} else
+		wpa_s->scan_runs++;
 }
 
 

Modified: wpasupplicant/trunk/wpa_supplicant/tests/test_sha256.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/wpa_supplicant/tests/test_sha256.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/wpa_supplicant/tests/test_sha256.c (original)
+++ wpasupplicant/trunk/wpa_supplicant/tests/test_sha256.c Sun Feb 15 20:49:57 2009
@@ -323,7 +323,8 @@
 	}
 
 	printf("Test IEEE 802.11r KDF\n");
-	sha256_prf("abc", 3, "KDF test", "data", 4, hash, sizeof(hash));
+	sha256_prf((u8 *) "abc", 3, "KDF test", (u8 *) "data", 4,
+		   hash, sizeof(hash));
 	/* TODO: add proper test case for this */
 
 	return errors;

Modified: wpasupplicant/trunk/wpa_supplicant/wpa_cli.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/wpa_supplicant/wpa_cli.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/wpa_supplicant/wpa_cli.c (original)
+++ wpasupplicant/trunk/wpa_supplicant/wpa_cli.c Sun Feb 15 20:49:57 2009
@@ -95,6 +95,7 @@
 static char *ctrl_ifname = NULL;
 static const char *pid_file = NULL;
 static const char *action_file = NULL;
+static int ping_interval = 5;
 
 
 static void print_help();
@@ -104,7 +105,8 @@
 {
 	printf("wpa_cli [-p<path to ctrl sockets>] [-i<ifname>] [-hvB] "
 	       "[-a<action file>] \\\n"
-	       "        [-P<pid file>] [-g<global ctrl>]  [command..]\n"
+	       "        [-P<pid file>] [-g<global ctrl>] [-G<ping interval>]  "
+	       "[command..]\n"
 	       "  -h = help (show this usage text)\n"
 	       "  -v = shown version information\n"
 	       "  -a = run in daemon mode executing the action file based on "
@@ -1563,7 +1565,7 @@
 	do {
 		wpa_cli_recv_pending(ctrl_conn, 0, 0);
 #ifndef CONFIG_NATIVE_WINDOWS
-		alarm(1);
+		alarm(ping_interval);
 #endif /* CONFIG_NATIVE_WINDOWS */
 #ifdef CONFIG_READLINE
 		cmd = readline("> ");
@@ -1667,7 +1669,7 @@
 	while (!wpa_cli_quit) {
 		FD_ZERO(&rfds);
 		FD_SET(fd, &rfds);
-		tv.tv_sec = 2;
+		tv.tv_sec = ping_interval;
 		tv.tv_usec = 0;
 		res = select(fd + 1, &rfds, NULL, NULL, &tv);
 		if (res < 0 && errno != EINTR) {
@@ -1721,7 +1723,7 @@
 		wpa_cli_reconnect();
 	if (ctrl_conn)
 		wpa_cli_recv_pending(ctrl_conn, 1, 0);
-	alarm(1);
+	alarm(ping_interval);
 }
 #endif /* CONFIG_NATIVE_WINDOWS */
 
@@ -1794,7 +1796,7 @@
 		return -1;
 
 	for (;;) {
-		c = getopt(argc, argv, "a:Bg:hi:p:P:v");
+		c = getopt(argc, argv, "a:Bg:G:hi:p:P:v");
 		if (c < 0)
 			break;
 		switch (c) {
@@ -1806,6 +1808,9 @@
 			break;
 		case 'g':
 			global = optarg;
+			break;
+		case 'G':
+			ping_interval = atoi(optarg);
 			break;
 		case 'h':
 			usage();

Modified: wpasupplicant/trunk/wpa_supplicant/wpa_gui-qt4/main.cpp
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/wpa_supplicant/wpa_gui-qt4/main.cpp?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/wpa_supplicant/wpa_gui-qt4/main.cpp (original)
+++ wpasupplicant/trunk/wpa_supplicant/wpa_gui-qt4/main.cpp Sun Feb 15 20:49:57 2009
@@ -18,10 +18,32 @@
 #include <QApplication>
 #include "wpagui.h"
 
+
+class WpaGuiApp : public QApplication
+{
+public:
+	WpaGuiApp(int &argc, char **argv);
+
+	virtual void saveState(QSessionManager &manager);
+
+	WpaGui *w;
+};
+
+WpaGuiApp::WpaGuiApp(int &argc, char **argv) : QApplication(argc, argv)
+{
+}
+
+void WpaGuiApp::saveState(QSessionManager &manager)
+{
+	QApplication::saveState(manager);
+	w->saveState();
+}
+
+
 int main(int argc, char *argv[])
 {
-	QApplication app(argc, argv);
-	WpaGui w;
+	WpaGuiApp app(argc, argv);
+	WpaGui w(&app);
 	int ret;
 
 #ifdef CONFIG_NATIVE_WINDOWS
@@ -32,6 +54,8 @@
 	}
 #endif /* CONFIG_NATIVE_WINDOWS */
 
+	app.w = &w;
+
 	ret = app.exec();
 
 #ifdef CONFIG_NATIVE_WINDOWS

Modified: wpasupplicant/trunk/wpa_supplicant/wpa_gui-qt4/wpagui.cpp
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/wpa_supplicant/wpa_gui-qt4/wpagui.cpp?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/wpa_supplicant/wpa_gui-qt4/wpagui.cpp (original)
+++ wpasupplicant/trunk/wpa_supplicant/wpa_gui-qt4/wpagui.cpp Sun Feb 15 20:49:57 2009
@@ -25,6 +25,7 @@
 #include <QMessageBox>
 #include <QCloseEvent>
 #include <QImageReader>
+#include <QSettings>
 
 #include "wpagui.h"
 #include "dirent.h"
@@ -41,8 +42,8 @@
 }
 #endif
 
-WpaGui::WpaGui(QWidget *parent, const char *, Qt::WFlags)
-	: QMainWindow(parent)
+WpaGui::WpaGui(QApplication *_app, QWidget *parent, const char *, Qt::WFlags)
+	: QMainWindow(parent), app(_app)
 {
 	setupUi(this);
 
@@ -71,6 +72,13 @@
 #endif /* CONFIG_NATIVE_WINDOWS */
 
 	(void) statusBar();
+
+	/*
+	 * Disable WPS tab by default; it will be enabled if wpa_supplicant is
+	 * built with WPS support.
+	 */
+	wpsTab->setEnabled(false);
+	wpaguiTab->setTabEnabled(wpaguiTab->indexOf(wpsTab), false);
 
 	connect(fileEventHistoryAction, SIGNAL(triggered()), this,
 		SLOT(eventHistory()));
@@ -137,6 +145,15 @@
 
 	parse_argv();
 
+	if (app->isSessionRestored()) {
+		QSettings settings("wpa_supplicant", "wpa_gui");
+		settings.beginGroup("state");
+		if (app->sessionId().compare(settings.value("session_id").
+					     toString()) == 0)
+			startInTray = settings.value("in_tray").toBool();
+		settings.endGroup();
+	}
+
 	if (QSystemTrayIcon::isSystemTrayAvailable())
 		createTrayIcon(startInTray);
 	else
@@ -406,7 +423,10 @@
 
 		QString res(buf);
 		QStringList types = res.split(QChar(' '));
-		actionWPS->setEnabled(types.contains("WSC"));
+		bool wps = types.contains("WSC");
+		actionWPS->setEnabled(wps);
+		wpsTab->setEnabled(wps);
+		wpaguiTab->setTabEnabled(wpaguiTab->indexOf(wpsTab), wps);
 	}
 
 	return 0;
@@ -1293,6 +1313,7 @@
 
 	if (!trayOnly)
 		show();
+	inTray = trayOnly;
 }
 
 
@@ -1316,10 +1337,13 @@
 	 * custom closeEvent handler take care of children */
 	case QSystemTrayIcon::Trigger:
 		ackTrayIcon = true;
-		if (isVisible())
+		if (isVisible()) {
 			close();
-		else
+			inTray = true;
+		} else {
 			show();
+			inTray = false;
+		}
 		break;
 	case QSystemTrayIcon::MiddleClick:
 		showTrayStatus();
@@ -1663,3 +1687,13 @@
 	add_iface->show();
 	add_iface->exec();
 }
+
+
+void WpaGui::saveState()
+{
+	QSettings settings("wpa_supplicant", "wpa_gui");
+	settings.beginGroup("state");
+	settings.setValue("session_id", app->sessionId());
+	settings.setValue("in_tray", inTray);
+	settings.endGroup();
+}

Modified: wpasupplicant/trunk/wpa_supplicant/wpa_gui-qt4/wpagui.h
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/wpa_supplicant/wpa_gui-qt4/wpagui.h?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/wpa_supplicant/wpa_gui-qt4/wpagui.h (original)
+++ wpasupplicant/trunk/wpa_supplicant/wpa_gui-qt4/wpagui.h Sun Feb 15 20:49:57 2009
@@ -28,7 +28,7 @@
 	Q_OBJECT
 
 public:
-	WpaGui(QWidget *parent = 0, const char *name = 0,
+	WpaGui(QApplication *app, QWidget *parent = 0, const char *name = 0,
 	       Qt::WFlags fl = 0);
 	~WpaGui();
 
@@ -40,6 +40,7 @@
 	virtual void disableNetwork(const QString &sel);
 	virtual int getNetworkDisabled(const QString &sel);
 	void setBssFromScan(const QString &bssid);
+	void saveState();
 
 public slots:
 	virtual void parse_argv();
@@ -136,6 +137,9 @@
 	AddInterface *add_iface;
 
 	bool connectedToService;
+
+	QApplication *app;
+	bool inTray;
 };
 
 #endif /* WPAGUI_H */

Modified: wpasupplicant/trunk/wpa_supplicant/wpa_gui-qt4/wpagui.ui
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/wpa_supplicant/wpa_gui-qt4/wpagui.ui?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/wpa_supplicant/wpa_gui-qt4/wpagui.ui (original)
+++ wpasupplicant/trunk/wpa_supplicant/wpa_gui-qt4/wpagui.ui Sun Feb 15 20:49:57 2009
@@ -293,7 +293,7 @@
        <attribute name="title" >
         <string>WPS</string>
        </attribute>
-       <layout class="QGridLayout" name="gridLayout" >
+       <layout class="QGridLayout" name="wpsGridLayout" >
         <item row="0" column="0" >
          <widget class="QLabel" name="label_2" >
           <property name="text" >

Modified: wpasupplicant/trunk/wpa_supplicant/wpa_priv.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/wpa_supplicant/wpa_priv.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/wpa_supplicant/wpa_priv.c (original)
+++ wpasupplicant/trunk/wpa_supplicant/wpa_priv.c Sun Feb 15 20:49:57 2009
@@ -1,6 +1,6 @@
 /*
  * WPA Supplicant / privileged helper program
- * Copyright (c) 2007, Jouni Malinen <j at w1.fi>
+ * Copyright (c) 2007-2009, Jouni Malinen <j at w1.fi>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -575,10 +575,21 @@
 }
 
 
+static void wpa_priv_cmd_set_country(struct wpa_priv_interface *iface,
+				     char *buf)
+{
+	if (iface->drv_priv == NULL || iface->driver->set_country == NULL ||
+	    *buf == '\0')
+		return;
+
+	iface->driver->set_country(iface->drv_priv, buf);
+}
+
+
 static void wpa_priv_receive(int sock, void *eloop_ctx, void *sock_ctx)
 {
 	struct wpa_priv_interface *iface = eloop_ctx;
-	char buf[2000];
+	char buf[2000], *pos;
 	void *cmd_buf;
 	size_t cmd_len;
 	int res, cmd;
@@ -648,6 +659,13 @@
 		break;
 	case PRIVSEP_CMD_SET_MODE:
 		wpa_priv_cmd_set_mode(iface, cmd_buf, cmd_len);
+		break;
+	case PRIVSEP_CMD_SET_COUNTRY:
+		pos = cmd_buf;
+		if (pos + cmd_len >= buf + sizeof(buf))
+			break;
+		pos[cmd_len] = '\0';
+		wpa_priv_cmd_set_country(iface, pos);
 		break;
 	}
 }
@@ -1030,6 +1048,53 @@
 		perror("sendmsg(wpas_socket)");
 }
 
+
+#ifdef CONFIG_CLIENT_MLME
+void wpa_supplicant_sta_free_hw_features(struct wpa_hw_modes *hw_features,
+					 size_t num_hw_features)
+{
+	size_t i;
+
+	if (hw_features == NULL)
+		return;
+
+	for (i = 0; i < num_hw_features; i++) {
+		os_free(hw_features[i].channels);
+		os_free(hw_features[i].rates);
+	}
+
+	os_free(hw_features);
+}
+
+
+void wpa_supplicant_sta_rx(void *ctx, const u8 *buf, size_t len,
+			   struct ieee80211_rx_status *rx_status)
+{
+	struct wpa_priv_interface *iface = ctx;
+	struct msghdr msg;
+	struct iovec io[3];
+	int event = PRIVSEP_EVENT_STA_RX;
+
+	wpa_printf(MSG_DEBUG, "STA RX from driver");
+	io[0].iov_base = &event;
+	io[0].iov_len = sizeof(event);
+	io[1].iov_base = (u8 *) rx_status;
+	io[1].iov_len = sizeof(*rx_status);
+	io[2].iov_base = (u8 *) buf;
+	io[2].iov_len = len;
+
+	os_memset(&msg, 0, sizeof(msg));
+	msg.msg_iov = io;
+	msg.msg_iovlen = 3;
+	msg.msg_name = &iface->drv_addr;
+	msg.msg_namelen = sizeof(iface->drv_addr);
+
+	if (sendmsg(iface->fd, &msg, 0) < 0)
+		perror("sendmsg(wpas_socket)");
+}
+#endif /* CONFIG_CLIENT_MLME */
+
+
 static void wpa_priv_terminate(int sig, void *eloop_ctx, void *signal_ctx)
 {
 	wpa_printf(MSG_DEBUG, "wpa_priv termination requested");
@@ -1060,7 +1125,8 @@
 static void usage(void)
 {
 	printf("wpa_priv v" VERSION_STR "\n"
-	       "Copyright (c) 2007, Jouni Malinen <j at w1.fi> and contributors\n"
+	       "Copyright (c) 2007-2009, Jouni Malinen <j at w1.fi> and "
+	       "contributors\n"
 	       "\n"
 	       "usage:\n"
 	       "  wpa_priv [-Bdd] [-P<pid file>] <driver:ifname> "

Modified: wpasupplicant/trunk/wpa_supplicant/wpa_supplicant.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/wpa_supplicant/wpa_supplicant.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/wpa_supplicant/wpa_supplicant.c (original)
+++ wpasupplicant/trunk/wpa_supplicant/wpa_supplicant.c Sun Feb 15 20:49:57 2009
@@ -1219,7 +1219,7 @@
  * @wpa_s: Pointer to wpa_supplicant data
  * @reason_code: IEEE 802.11 reason code for the deauthenticate frame
  *
- * This function is used to request %wpa_supplicant to disassociate with the
+ * This function is used to request %wpa_supplicant to deauthenticate from the
  * current AP.
  */
 void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
@@ -2150,7 +2150,7 @@
 
 	eap_peer_unregister_methods();
 
-	for (i = 0; wpa_supplicant_drivers[i]; i++) {
+	for (i = 0; wpa_supplicant_drivers[i] && global->drv_priv; i++) {
 		if (!global->drv_priv[i])
 			continue;
 		wpa_supplicant_drivers[i]->global_deinit(global->drv_priv[i]);

Modified: wpasupplicant/trunk/wpa_supplicant/wpa_supplicant.conf
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/wpa_supplicant/wpa_supplicant.conf?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/wpa_supplicant/wpa_supplicant.conf (original)
+++ wpasupplicant/trunk/wpa_supplicant/wpa_supplicant.conf Sun Feb 15 20:49:57 2009
@@ -190,6 +190,13 @@
 # 4-octet operating system version number (hex string)
 #os_version=01020300
 
+# Credential processing
+#   0 = process received credentials internally (default)
+#   1 = do not process received credentials; just pass them over ctrl_iface to
+#	external program(s)
+#   2 = process received credentials internally and pass them over ctrl_iface
+#	to external program(s)
+#wps_cred_processing=0
 
 # network block
 #
@@ -255,8 +262,7 @@
 #
 # key_mgmt: list of accepted authenticated key management protocols
 # WPA-PSK = WPA pre-shared key (this requires 'psk' field)
-# WPA-EAP = WPA using EAP authentication (this can use an external
-#	program, e.g., Xsupplicant, for IEEE 802.1X EAP Authentication
+# WPA-EAP = WPA using EAP authentication
 # IEEE8021X = IEEE 802.1X using EAP authentication and (optionally) dynamically
 #	generated WEP keys
 # NONE = WPA is not used; plaintext or static WEP could be used

Modified: wpasupplicant/trunk/wpa_supplicant/wpa_supplicant_i.h
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/wpa_supplicant/wpa_supplicant_i.h?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/wpa_supplicant/wpa_supplicant_i.h (original)
+++ wpasupplicant/trunk/wpa_supplicant/wpa_supplicant_i.h Sun Feb 15 20:49:57 2009
@@ -345,6 +345,7 @@
 			     * results without a new scan request; this is used
 			     * to speed up the first association if the driver
 			     * has already available scan results. */
+	int scan_runs; /* number of scan runs since WPS was started */
 
 	struct wpa_client_mlme mlme;
 	int use_client_mlme;
@@ -355,6 +356,8 @@
 	int mic_errors_seen; /* Michael MIC errors with the current PTK */
 
 	struct wps_context *wps;
+	int wps_success; /* WPS success event received */
+	int blacklist_cleared;
 };
 
 

Modified: wpasupplicant/trunk/wpa_supplicant/wps_supplicant.c
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/wpa_supplicant/wps_supplicant.c?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/wpa_supplicant/wps_supplicant.c (original)
+++ wpasupplicant/trunk/wpa_supplicant/wps_supplicant.c Sun Feb 15 20:49:57 2009
@@ -23,9 +23,12 @@
 #include "eloop.h"
 #include "uuid.h"
 #include "wpa_ctrl.h"
+#include "ctrl_iface_dbus.h"
 #include "eap_common/eap_wsc_common.h"
+#include "blacklist.h"
 #include "wps_supplicant.h"
 
+#define WPS_PIN_SCAN_IGNORE_SEL_REG 3
 
 static void wpas_wps_timeout(void *eloop_ctx, void *timeout_ctx);
 static void wpas_clear_wps(struct wpa_supplicant *wpa_s);
@@ -33,6 +36,27 @@
 
 int wpas_wps_eapol_cb(struct wpa_supplicant *wpa_s)
 {
+	if (!wpa_s->wps_success &&
+	    wpa_s->current_ssid &&
+	    eap_is_wps_pin_enrollee(&wpa_s->current_ssid->eap)) {
+		const u8 *bssid = wpa_s->bssid;
+		if (is_zero_ether_addr(bssid))
+			bssid = wpa_s->pending_bssid;
+
+		wpa_printf(MSG_DEBUG, "WPS: PIN registration with " MACSTR
+			   " did not succeed - continue trying to find "
+			   "suitable AP", MAC2STR(bssid));
+		wpa_blacklist_add(wpa_s, bssid);
+
+		wpa_supplicant_deauthenticate(wpa_s,
+					      WLAN_REASON_DEAUTH_LEAVING);
+		wpa_s->reassociate = 1;
+		wpa_supplicant_req_scan(wpa_s,
+					wpa_s->blacklist_cleared ? 5 : 0, 0);
+		wpa_s->blacklist_cleared = 0;
+		return 1;
+	}
+
 	eloop_cancel_timeout(wpas_wps_timeout, wpa_s, NULL);
 
 	if (wpa_s->key_mgmt == WPA_KEY_MGMT_WPS && wpa_s->current_ssid &&
@@ -46,6 +70,15 @@
 		return 1;
 	}
 
+	if (wpa_s->key_mgmt == WPA_KEY_MGMT_WPS && wpa_s->current_ssid) {
+		wpa_printf(MSG_DEBUG, "WPS: Registration completed - waiting "
+			   "for external credential processing");
+		wpas_clear_wps(wpa_s);
+		wpa_supplicant_deauthenticate(wpa_s,
+					      WLAN_REASON_DEAUTH_LEAVING);
+		return 1;
+	}
+
 	return 0;
 }
 
@@ -56,7 +89,36 @@
 	struct wpa_supplicant *wpa_s = ctx;
 	struct wpa_ssid *ssid = wpa_s->current_ssid;
 
-	wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_CRED_RECEIVED);
+	if ((wpa_s->conf->wps_cred_processing == 1 ||
+	     wpa_s->conf->wps_cred_processing == 2) && cred->cred_attr) {
+		size_t blen = cred->cred_attr_len * 2 + 1;
+		char *buf = os_malloc(blen);
+		if (buf) {
+			wpa_snprintf_hex(buf, blen,
+					 cred->cred_attr, cred->cred_attr_len);
+			wpa_msg(wpa_s, MSG_INFO, "%s%s",
+				WPS_EVENT_CRED_RECEIVED, buf);
+			os_free(buf);
+		}
+		wpa_supplicant_dbus_notify_wps_cred(wpa_s, cred);
+	} else
+		wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_CRED_RECEIVED);
+
+	wpa_hexdump_key(MSG_DEBUG, "WPS: Received Credential attribute",
+			cred->cred_attr, cred->cred_attr_len);
+
+	if (wpa_s->conf->wps_cred_processing == 1)
+		return 0;
+
+	if (cred->auth_type != WPS_AUTH_OPEN &&
+	    cred->auth_type != WPS_AUTH_SHARED &&
+	    cred->auth_type != WPS_AUTH_WPAPSK &&
+	    cred->auth_type != WPS_AUTH_WPA2PSK) {
+		wpa_printf(MSG_DEBUG, "WPS: Ignored credentials for "
+			   "unsupported authentication type %d",
+			   cred->auth_type);
+		return 0;
+	}
 
 	if (ssid && (ssid->key_mgmt & WPA_KEY_MGMT_WPS)) {
 		wpa_printf(MSG_DEBUG, "WPS: Replace WPS network block based "
@@ -87,11 +149,8 @@
 
 	switch (cred->encr_type) {
 	case WPS_ENCR_NONE:
-		ssid->pairwise_cipher = ssid->group_cipher = WPA_CIPHER_NONE;
 		break;
 	case WPS_ENCR_WEP:
-		ssid->pairwise_cipher = ssid->group_cipher =
-			WPA_CIPHER_WEP40 | WPA_CIPHER_WEP104;
 		if (cred->key_len > 0 && cred->key_len <= MAX_WEP_KEY_LEN &&
 		    cred->key_idx < NUM_WEP_KEYS) {
 			os_memcpy(ssid->wep_key[cred->key_idx], cred->key,
@@ -102,11 +161,9 @@
 		break;
 	case WPS_ENCR_TKIP:
 		ssid->pairwise_cipher = WPA_CIPHER_TKIP;
-		ssid->group_cipher = WPA_CIPHER_TKIP;
 		break;
 	case WPS_ENCR_AES:
 		ssid->pairwise_cipher = WPA_CIPHER_CCMP;
-		ssid->group_cipher = WPA_CIPHER_CCMP | WPA_CIPHER_TKIP;
 		break;
 	}
 
@@ -200,6 +257,7 @@
 static void wpa_supplicant_wps_event_success(struct wpa_supplicant *wpa_s)
 {
 	wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_SUCCESS);
+	wpa_s->wps_success = 1;
 }
 
 
@@ -216,6 +274,8 @@
 		break;
 	case WPS_EV_SUCCESS:
 		wpa_supplicant_wps_event_success(wpa_s);
+		break;
+	case WPS_EV_PWD_AUTH_FAIL:
 		break;
 	}
 }
@@ -257,7 +317,8 @@
 static void wpas_wps_timeout(void *eloop_ctx, void *timeout_ctx)
 {
 	struct wpa_supplicant *wpa_s = eloop_ctx;
-	wpa_printf(MSG_DEBUG, "WPS: Requested operation timed out");
+	wpa_printf(MSG_INFO, WPS_EVENT_TIMEOUT "Requested operation timed "
+		   "out");
 	wpas_clear_wps(wpa_s);
 }
 
@@ -329,6 +390,9 @@
 	}
 	wpa_s->disconnected = 0;
 	wpa_s->reassociate = 1;
+	wpa_s->scan_runs = 0;
+	wpa_s->wps_success = 0;
+	wpa_s->blacklist_cleared = 0;
 	wpa_supplicant_req_scan(wpa_s, 0, 0);
 }
 
@@ -516,7 +580,8 @@
 }
 
 
-int wpas_wps_ssid_bss_match(struct wpa_ssid *ssid, struct wpa_scan_res *bss)
+int wpas_wps_ssid_bss_match(struct wpa_supplicant *wpa_s,
+			    struct wpa_ssid *ssid, struct wpa_scan_res *bss)
 {
 	struct wpabuf *wps_ie;
 
@@ -550,14 +615,24 @@
 			return 0;
 		}
 
+		/*
+		 * Start with WPS APs that advertise active PIN Registrar and
+		 * allow any WPS AP after third scan since some APs do not set
+		 * Selected Registrar attribute properly when using external
+		 * Registrar.
+		 */
 		if (!wps_is_selected_pin_registrar(wps_ie)) {
-			wpa_printf(MSG_DEBUG, "   skip - WPS AP "
-				   "without active PIN Registrar");
-			wpabuf_free(wps_ie);
-			return 0;
-		}
-		wpa_printf(MSG_DEBUG, "   selected based on WPS IE "
-			   "(Active PIN)");
+			if (wpa_s->scan_runs < WPS_PIN_SCAN_IGNORE_SEL_REG) {
+				wpa_printf(MSG_DEBUG, "   skip - WPS AP "
+					   "without active PIN Registrar");
+				wpabuf_free(wps_ie);
+				return 0;
+			}
+			wpa_printf(MSG_DEBUG, "   selected based on WPS IE");
+		} else {
+			wpa_printf(MSG_DEBUG, "   selected based on WPS IE "
+				   "(Active PIN)");
+		}
 		wpabuf_free(wps_ie);
 		return 1;
 	}
@@ -572,7 +647,8 @@
 }
 
 
-int wpas_wps_ssid_wildcard_ok(struct wpa_ssid *ssid,
+int wpas_wps_ssid_wildcard_ok(struct wpa_supplicant *wpa_s,
+			      struct wpa_ssid *ssid,
 			      struct wpa_scan_res *bss)
 {
 	struct wpabuf *wps_ie = NULL;
@@ -586,7 +662,9 @@
 		}
 	} else if (eap_is_wps_pin_enrollee(&ssid->eap)) {
 		wps_ie = wpa_scan_get_vendor_ie_multi(bss, WPS_IE_VENDOR_TYPE);
-		if (wps_ie && wps_is_selected_pin_registrar(wps_ie)) {
+		if (wps_ie &&
+		    (wps_is_selected_pin_registrar(wps_ie) ||
+		     wpa_s->scan_runs >= WPS_PIN_SCAN_IGNORE_SEL_REG)) {
 			/* allow wildcard SSID for WPS PIN */
 			ret = 1;
 		}

Modified: wpasupplicant/trunk/wpa_supplicant/wps_supplicant.h
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/wpa_supplicant/wps_supplicant.h?rev=1326&op=diff
==============================================================================
--- wpasupplicant/trunk/wpa_supplicant/wps_supplicant.h (original)
+++ wpasupplicant/trunk/wpa_supplicant/wps_supplicant.h Sun Feb 15 20:49:57 2009
@@ -29,8 +29,10 @@
 		       const char *pin);
 int wpas_wps_start_reg(struct wpa_supplicant *wpa_s, const u8 *bssid,
 		       const char *pin);
-int wpas_wps_ssid_bss_match(struct wpa_ssid *ssid, struct wpa_scan_res *bss);
-int wpas_wps_ssid_wildcard_ok(struct wpa_ssid *ssid, struct wpa_scan_res *bss);
+int wpas_wps_ssid_bss_match(struct wpa_supplicant *wpa_s,
+			    struct wpa_ssid *ssid, struct wpa_scan_res *bss);
+int wpas_wps_ssid_wildcard_ok(struct wpa_supplicant *wpa_s,
+			      struct wpa_ssid *ssid, struct wpa_scan_res *bss);
 int wpas_wps_scan_pbc_overlap(struct wpa_supplicant *wpa_s,
 			      struct wpa_scan_res *selected,
 			      struct wpa_ssid *ssid);
@@ -58,13 +60,15 @@
 	return 0;
 }
 
-static inline int wpas_wps_ssid_bss_match(struct wpa_ssid *ssid,
+static inline int wpas_wps_ssid_bss_match(struct wpa_supplicant *wpa_s,
+					  struct wpa_ssid *ssid,
 					  struct wpa_scan_res *bss)
 {
 	return -1;
 }
 
-static inline int wpas_wps_ssid_wildcard_ok(struct wpa_ssid *ssid,
+static inline int wpas_wps_ssid_wildcard_ok(struct wpa_supplicant *wpa_s,
+					    struct wpa_ssid *ssid,
 					    struct wpa_scan_res *bss)
 {
 	return 0;




More information about the Pkg-wpa-devel mailing list