summaryrefslogtreecommitdiff
path: root/wpa_supplicant
diff options
context:
space:
mode:
authorAndrew Shadura <andrewsh@debian.org>2016-07-23 12:51:30 +0200
committerAndrew Shadura <andrewsh@debian.org>2016-07-23 12:51:30 +0200
commitaa5e2237f3bbd73853b3ffbb4bf693298c409792 (patch)
tree26bd471557f364e950d823e12e7d9d83a73778c0 /wpa_supplicant
parent2b2675a5c8455e6a7224b153a28a6c2b5f1acd70 (diff)
Imported Upstream version 2.5
Diffstat (limited to 'wpa_supplicant')
-rw-r--r--wpa_supplicant/Android.mk74
-rw-r--r--wpa_supplicant/ChangeLog63
-rw-r--r--wpa_supplicant/Makefile102
-rw-r--r--wpa_supplicant/android.config3
-rw-r--r--wpa_supplicant/ap.c46
-rw-r--r--wpa_supplicant/ap.h2
-rw-r--r--wpa_supplicant/bss.c76
-rw-r--r--wpa_supplicant/bss.h2
-rw-r--r--wpa_supplicant/config.c69
-rw-r--r--wpa_supplicant/config.h86
-rw-r--r--wpa_supplicant/config_file.c67
-rw-r--r--wpa_supplicant/config_ssid.h17
-rw-r--r--wpa_supplicant/ctrl_iface.c751
-rw-r--r--wpa_supplicant/ctrl_iface_named_pipe.c3
-rw-r--r--wpa_supplicant/ctrl_iface_udp.c3
-rw-r--r--wpa_supplicant/ctrl_iface_unix.c118
-rw-r--r--wpa_supplicant/dbus/dbus_new.c378
-rw-r--r--wpa_supplicant/dbus/dbus_new.h43
-rw-r--r--wpa_supplicant/dbus/dbus_new_handlers.c128
-rw-r--r--wpa_supplicant/dbus/dbus_new_handlers.h6
-rw-r--r--wpa_supplicant/dbus/dbus_new_handlers_p2p.c317
-rw-r--r--wpa_supplicant/dbus/dbus_new_handlers_p2p.h22
-rw-r--r--wpa_supplicant/dbus/dbus_new_handlers_wps.c26
-rw-r--r--wpa_supplicant/dbus/dbus_new_helpers.c7
-rw-r--r--wpa_supplicant/dbus/dbus_new_introspect.c2
-rw-r--r--wpa_supplicant/dbus/dbus_old.c10
-rw-r--r--wpa_supplicant/dbus/dbus_old_handlers.c26
-rw-r--r--wpa_supplicant/defconfig9
-rw-r--r--wpa_supplicant/doc/docbook/wpa_gui.sgml17
-rw-r--r--wpa_supplicant/driver_i.h40
-rw-r--r--wpa_supplicant/eapol_test.c131
-rwxr-xr-xwpa_supplicant/eapol_test.py142
-rw-r--r--wpa_supplicant/events.c279
-rw-r--r--wpa_supplicant/hs20_supplicant.c18
-rw-r--r--wpa_supplicant/ibss_rsn.c6
-rw-r--r--wpa_supplicant/interworking.c16
-rw-r--r--wpa_supplicant/main.c18
-rw-r--r--wpa_supplicant/mesh.c17
-rw-r--r--wpa_supplicant/mesh_mpm.c9
-rw-r--r--wpa_supplicant/mesh_rsn.c8
-rw-r--r--wpa_supplicant/notify.c58
-rw-r--r--wpa_supplicant/notify.h9
-rw-r--r--wpa_supplicant/p2p_supplicant.c2402
-rw-r--r--wpa_supplicant/p2p_supplicant.h33
-rw-r--r--wpa_supplicant/p2p_supplicant_sd.c1273
-rw-r--r--wpa_supplicant/preauth_test.c2
-rw-r--r--wpa_supplicant/scan.c76
-rw-r--r--wpa_supplicant/sme.c70
-rw-r--r--wpa_supplicant/systemd/wpa_supplicant-nl80211.service.arg.in2
-rw-r--r--wpa_supplicant/systemd/wpa_supplicant-wired.service.arg.in2
-rw-r--r--wpa_supplicant/systemd/wpa_supplicant.service.arg.in2
-rw-r--r--wpa_supplicant/systemd/wpa_supplicant.service.in2
-rw-r--r--wpa_supplicant/wpa_cli.c511
-rw-r--r--wpa_supplicant/wpa_gui-qt4/addinterface.cpp8
-rw-r--r--wpa_supplicant/wpa_gui-qt4/addinterface.h6
-rw-r--r--wpa_supplicant/wpa_gui-qt4/eventhistory.cpp6
-rw-r--r--wpa_supplicant/wpa_gui-qt4/eventhistory.h2
-rw-r--r--wpa_supplicant/wpa_gui-qt4/main.cpp21
-rw-r--r--wpa_supplicant/wpa_gui-qt4/networkconfig.cpp33
-rw-r--r--wpa_supplicant/wpa_gui-qt4/networkconfig.h2
-rw-r--r--wpa_supplicant/wpa_gui-qt4/peers.cpp46
-rw-r--r--wpa_supplicant/wpa_gui-qt4/peers.h2
-rw-r--r--wpa_supplicant/wpa_gui-qt4/scanresults.cpp6
-rw-r--r--wpa_supplicant/wpa_gui-qt4/scanresults.h2
-rw-r--r--wpa_supplicant/wpa_gui-qt4/scanresultsitem.h2
-rw-r--r--wpa_supplicant/wpa_gui-qt4/userdatarequest.cpp4
-rw-r--r--wpa_supplicant/wpa_gui-qt4/userdatarequest.h2
-rw-r--r--wpa_supplicant/wpa_gui-qt4/wpa_gui.pro1
-rw-r--r--wpa_supplicant/wpa_gui-qt4/wpagui.cpp190
-rw-r--r--wpa_supplicant/wpa_gui-qt4/wpagui.h36
-rw-r--r--wpa_supplicant/wpa_priv.c155
-rw-r--r--wpa_supplicant/wpa_supplicant.c379
-rw-r--r--wpa_supplicant/wpa_supplicant.conf47
-rw-r--r--wpa_supplicant/wpa_supplicant_i.h81
-rw-r--r--wpa_supplicant/wpas_glue.c61
-rw-r--r--wpa_supplicant/wpas_glue.h3
-rw-r--r--wpa_supplicant/wps_supplicant.c122
-rw-r--r--wpa_supplicant/wps_supplicant.h1
78 files changed, 6437 insertions, 2380 deletions
diff --git a/wpa_supplicant/Android.mk b/wpa_supplicant/Android.mk
index 579582b..0d818ed 100644
--- a/wpa_supplicant/Android.mk
+++ b/wpa_supplicant/Android.mk
@@ -27,8 +27,9 @@ L_CFLAGS += -Wno-unused-parameter
# Set Android extended P2P functionality
L_CFLAGS += -DANDROID_P2P
+
ifeq ($(BOARD_WPA_SUPPLICANT_PRIVATE_LIB),)
-L_CFLAGS += -DANDROID_P2P_STUB
+L_CFLAGS += -DANDROID_LIB_STUB
endif
# Disable roaming in wpa_supplicant
@@ -38,7 +39,10 @@ endif
# Use Android specific directory for control interface sockets
L_CFLAGS += -DCONFIG_CTRL_IFACE_CLIENT_DIR=\"/data/misc/wifi/sockets\"
-L_CFLAGS += -DCONFIG_CTRL_IFACE_DIR=\"/data/system/wpa_supplicant\"
+L_CFLAGS += -DCONFIG_CTRL_IFACE_DIR=\"/data/misc/wifi/sockets\"
+
+# Use Android specific directory for wpa_cli command completion history
+L_CFLAGS += -DCONFIG_WPA_CLI_HISTORY_DIR=\"/data/misc/wifi\"
# To force sizeof(enum) = 4
ifeq ($(TARGET_ARCH),arm)
@@ -271,6 +275,7 @@ endif
ifdef CONFIG_P2P
OBJS += p2p_supplicant.c
+OBJS += p2p_supplicant_sd.c
OBJS += src/p2p/p2p.c
OBJS += src/p2p/p2p_utils.c
OBJS += src/p2p/p2p_parse.c
@@ -311,6 +316,22 @@ L_CFLAGS += -DCONFIG_INTERWORKING
NEED_GAS=y
endif
+ifdef CONFIG_FST
+L_CFLAGS += -DCONFIG_FST
+OBJS += src/fst/fst.c
+OBJS += src/fst/fst_session.c
+OBJS += src/fst/fst_iface.c
+OBJS += src/fst/fst_group.c
+OBJS += src/fst/fst_ctrl_aux.c
+ifdef CONFIG_FST_TEST
+L_CFLAGS += -DCONFIG_FST_TEST
+endif
+ifdef CONFIG_CTRL_IFACE
+OBJS += src/fst/fst_ctrl_iface.c
+endif
+endif
+
+
include $(LOCAL_PATH)/src/drivers/drivers.mk
ifdef CONFIG_AP
@@ -374,7 +395,7 @@ endif
ifdef CONFIG_EAP_UNAUTH_TLS
# EAP-UNAUTH-TLS
L_CFLAGS += -DEAP_UNAUTH_TLS
-ifndef CONFIG_EAP_UNAUTH_TLS
+ifndef CONFIG_EAP_TLS
OBJS += src/eap_peer/eap_tls.c
OBJS_h += src/eap_server/eap_server_tls.c
TLS_FUNCS=y
@@ -407,9 +428,11 @@ L_CFLAGS += -DEAP_TTLS
OBJS += src/eap_peer/eap_ttls.c
OBJS_h += src/eap_server/eap_server_ttls.c
endif
-MS_FUNCS=y
TLS_FUNCS=y
+ifndef CONFIG_FIPS
+MS_FUNCS=y
CHAP=y
+endif
CONFIG_IEEE8021X_EAPOL=y
endif
@@ -642,6 +665,7 @@ CONFIG_IEEE8021X_EAPOL=y
NEED_DH_GROUPS=y
NEED_DH_GROUPS_ALL=y
NEED_SHA256=y
+NEED_AES_CBC=y
endif
ifdef CONFIG_WPS
@@ -969,6 +993,8 @@ OBJS_p += src/crypto/crypto_openssl.c
ifdef NEED_FIPS186_2_PRF
OBJS += src/crypto/fips_prf_openssl.c
endif
+NEED_SHA256=y
+NEED_TLS_PRF_SHA256=y
LIBS += -lcrypto
LIBS_p += -lcrypto
ifdef CONFIG_TLS_ADD_DL
@@ -995,21 +1021,6 @@ CONFIG_INTERNAL_RC4=y
CONFIG_INTERNAL_DH_GROUP5=y
endif
-ifeq ($(CONFIG_TLS), schannel)
-ifdef TLS_FUNCS
-OBJS += src/crypto/tls_schannel.c
-endif
-OBJS += src/crypto/crypto_cryptoapi.c
-OBJS_p += src/crypto/crypto_cryptoapi.c
-ifdef NEED_FIPS186_2_PRF
-OBJS += src/crypto/fips_prf_internal.c
-OBJS += src/crypto/sha1-internal.c
-endif
-CONFIG_INTERNAL_SHA256=y
-CONFIG_INTERNAL_RC4=y
-CONFIG_INTERNAL_DH_GROUP5=y
-endif
-
ifeq ($(CONFIG_TLS), internal)
ifndef CONFIG_CRYPTO
CONFIG_CRYPTO=internal
@@ -1128,6 +1139,20 @@ AESOBJS += src/crypto/aes-internal.c src/crypto/aes-internal-dec.c
endif
ifneq ($(CONFIG_TLS), openssl)
+NEED_INTERNAL_AES_WRAP=y
+endif
+ifdef CONFIG_OPENSSL_INTERNAL_AES_WRAP
+# Seems to be needed at least with BoringSSL
+NEED_INTERNAL_AES_WRAP=y
+L_CFLAGS += -DCONFIG_OPENSSL_INTERNAL_AES_WRAP
+endif
+ifdef CONFIG_FIPS
+# Have to use internal AES key wrap routines to use OpenSSL EVP since the
+# OpenSSL AES_wrap_key()/AES_unwrap_key() API is not available in FIPS mode.
+NEED_INTERNAL_AES_WRAP=y
+endif
+
+ifdef NEED_INTERNAL_AES_WRAP
AESOBJS += src/crypto/aes-unwrap.c
endif
ifdef NEED_AES_EAX
@@ -1150,14 +1175,16 @@ endif
endif
ifdef NEED_AES_WRAP
NEED_AES_ENC=y
-ifneq ($(CONFIG_TLS), openssl)
+ifdef NEED_INTERNAL_AES_WRAP
AESOBJS += src/crypto/aes-wrap.c
endif
endif
ifdef NEED_AES_CBC
NEED_AES_ENC=y
+ifneq ($(CONFIG_TLS), openssl)
AESOBJS += src/crypto/aes-cbc.c
endif
+endif
ifdef NEED_AES_ENC
ifdef CONFIG_INTERNAL_AES
AESOBJS += src/crypto/aes-internal-enc.c
@@ -1224,11 +1251,17 @@ DESOBJS += src/crypto/des-internal.c
endif
endif
+ifdef CONFIG_NO_RC4
+L_CFLAGS += -DCONFIG_NO_RC4
+endif
+
ifdef NEED_RC4
ifdef CONFIG_INTERNAL_RC4
+ifndef CONFIG_NO_RC4
OBJS += src/crypto/rc4.c
endif
endif
+endif
SHA256OBJS = # none by default
ifdef NEED_SHA256
@@ -1250,6 +1283,7 @@ OBJS += $(SHA256OBJS)
endif
ifdef NEED_SHA384
L_CFLAGS += -DCONFIG_SHA384
+OBJS += src/crypto/sha384-prf.c
endif
ifdef NEED_DH_GROUPS
diff --git a/wpa_supplicant/ChangeLog b/wpa_supplicant/ChangeLog
index 1ac79b4..facd90e 100644
--- a/wpa_supplicant/ChangeLog
+++ b/wpa_supplicant/ChangeLog
@@ -1,5 +1,68 @@
ChangeLog for wpa_supplicant
+2015-09-27 - v2.5
+ * fixed P2P validation of SSID element length before copying it
+ [http://w1.fi/security/2015-1/] (CVE-2015-1863)
+ * fixed WPS UPnP vulnerability with HTTP chunked transfer encoding
+ [http://w1.fi/security/2015-2/] (CVE-2015-4141)
+ * fixed WMM Action frame parser (AP mode)
+ [http://w1.fi/security/2015-3/] (CVE-2015-4142)
+ * fixed EAP-pwd peer missing payload length validation
+ [http://w1.fi/security/2015-4/]
+ (CVE-2015-4143, CVE-2015-4144, CVE-2015-4145, CVE-2015-4146)
+ * fixed validation of WPS and P2P NFC NDEF record payload length
+ [http://w1.fi/security/2015-5/]
+ * nl80211:
+ - added VHT configuration for IBSS
+ - fixed vendor command handling to check OUI properly
+ - allow driver-based roaming to change ESS
+ * added AVG_BEACON_RSSI to SIGNAL_POLL output
+ * wpa_cli: added tab completion for number of commands
+ * removed unmaintained and not yet completed SChannel/CryptoAPI support
+ * modified Extended Capabilities element use in Probe Request frames to
+ include all cases if any of the values are non-zero
+ * added support for dynamically creating/removing a virtual interface
+ with interface_add/interface_remove
+ * added support for hashed password (NtHash) in EAP-pwd peer
+ * added support for memory-only PSK/passphrase (mem_only_psk=1 and
+ CTRL-REQ/RSP-PSK_PASSPHRASE)
+ * P2P
+ - optimize scan frequencies list when re-joining a persistent group
+ - fixed number of sequences with nl80211 P2P Device interface
+ - added operating class 125 for P2P use cases (this allows 5 GHz
+ channels 161 and 169 to be used if they are enabled in the current
+ regulatory domain)
+ - number of fixes to P2PS functionality
+ - do not allow 40 MHz co-ex PRI/SEC switch to force MCC
+ - extended support for preferred channel listing
+ * D-Bus:
+ - fixed WPS property of fi.w1.wpa_supplicant1.BSS interface
+ - fixed PresenceRequest to use group interface
+ - added new signals: FindStopped, WPS pbc-overlap,
+ GroupFormationFailure, WPS timeout, InvitationReceived
+ - added new methods: WPS Cancel, P2P Cancel, Reconnect, RemoveClient
+ - added manufacturer info
+ * added EAP-EKE peer support for deriving Session-Id
+ * added wps_priority configuration parameter to set the default priority
+ for all network profiles added by WPS
+ * added support to request a scan with specific SSIDs with the SCAN
+ command (optional "ssid <hexdump>" arguments)
+ * removed support for WEP40/WEP104 as a group cipher with WPA/WPA2
+ * fixed SAE group selection in an error case
+ * modified SAE routines to be more robust and PWE generation to be
+ stronger against timing attacks
+ * added support for Brainpool Elliptic Curves with SAE
+ * added support for CCMP-256 and GCMP-256 as group ciphers with FT
+ * fixed BSS selection based on estimated throughput
+ * added option to disable TLSv1.0 with OpenSSL
+ (phase1="tls_disable_tlsv1_0=1")
+ * added Fast Session Transfer (FST) module
+ * fixed OpenSSL PKCS#12 extra certificate handling
+ * fixed key derivation for Suite B 192-bit AKM (this breaks
+ compatibility with the earlier version)
+ * added RSN IE to Mesh Peering Open/Confirm frames
+ * number of small fixes
+
2015-03-15 - v2.4
* allow OpenSSL cipher configuration to be set for internal EAP server
(openssl_ciphers parameter)
diff --git a/wpa_supplicant/Makefile b/wpa_supplicant/Makefile
index 0f82af9..ad9ead9 100644
--- a/wpa_supplicant/Makefile
+++ b/wpa_supplicant/Makefile
@@ -7,6 +7,7 @@ CFLAGS = -MMD -O2 -Wall -g
endif
export LIBDIR ?= /usr/local/lib/
+export INCDIR ?= /usr/local/include/
export BINDIR ?= /usr/local/sbin/
PKG_CONFIG ?= pkg-config
@@ -35,6 +36,9 @@ ALL += systemd/wpa_supplicant-nl80211@.service
ALL += systemd/wpa_supplicant-wired@.service
ALL += dbus/fi.epitest.hostap.WPASupplicant.service
ALL += dbus/fi.w1.wpa_supplicant1.service
+ifdef CONFIG_BUILD_WPA_CLIENT_SO
+ALL += libwpa_client.so
+endif
all: verify_config $(ALL) dynamic_eap_methods
@@ -61,6 +65,10 @@ $(DESTDIR)$(BINDIR)/%: %
install: $(addprefix $(DESTDIR)$(BINDIR)/,$(BINALL))
$(MAKE) -C ../src install
+ifdef CONFIG_BUILD_WPA_CLIENT_SO
+ install -m 0644 -D libwpa_client.so $(DESTDIR)/$(LIBDIR)/libwpa_client.so
+ install -m 0644 -D ../src/common/wpa_ctrl.h $(DESTDIR)/$(INCDIR)/wpa_ctrl.h
+endif
ifdef CONFIG_FIPS
CONFIG_NO_RANDOM_POOL=
@@ -106,6 +114,7 @@ OBJS_p += ../src/utils/trace.o
OBJS_c += ../src/utils/trace.o
OBJS_priv += ../src/utils/trace.o
LIBCTRL += ../src/utils/trace.o
+LIBCTRLSO += ../src/utils/trace.c
LDFLAGS += -rdynamic
CFLAGS += -funwind-tables
ifdef CONFIG_WPA_TRACE_BFD
@@ -122,12 +131,15 @@ endif
OBJS += ../src/utils/$(CONFIG_ELOOP).o
OBJS_c += ../src/utils/$(CONFIG_ELOOP).o
+ifndef CONFIG_OSX
ifeq ($(CONFIG_ELOOP), eloop)
# Using glibc < 2.17 requires -lrt for clock_gettime()
+# OS X has an alternate implementation
LIBS += -lrt
LIBS_c += -lrt
LIBS_p += -lrt
endif
+endif
ifdef CONFIG_ELOOP_POLL
CFLAGS += -DCONFIG_ELOOP_POLL
@@ -276,6 +288,7 @@ endif
ifdef CONFIG_P2P
OBJS += p2p_supplicant.o
+OBJS += p2p_supplicant_sd.o
OBJS += ../src/p2p/p2p.o
OBJS += ../src/p2p/p2p_utils.o
OBJS += ../src/p2p/p2p_parse.o
@@ -316,6 +329,10 @@ CFLAGS += -DCONFIG_INTERWORKING
NEED_GAS=y
endif
+ifdef CONFIG_NO_ROAMING
+CFLAGS += -DCONFIG_NO_ROAMING
+endif
+
include ../src/drivers/drivers.mak
ifdef CONFIG_AP
OBJS_d += $(DRV_BOTH_OBJS)
@@ -378,7 +395,7 @@ endif
ifdef CONFIG_EAP_UNAUTH_TLS
# EAP-UNAUTH-TLS
CFLAGS += -DEAP_UNAUTH_TLS
-ifndef CONFIG_EAP_UNAUTH_TLS
+ifndef CONFIG_EAP_TLS
OBJS += ../src/eap_peer/eap_tls.o
OBJS_h += ../src/eap_server/eap_server_tls.o
TLS_FUNCS=y
@@ -411,9 +428,11 @@ CFLAGS += -DEAP_TTLS
OBJS += ../src/eap_peer/eap_ttls.o
OBJS_h += ../src/eap_server/eap_server_ttls.o
endif
-MS_FUNCS=y
TLS_FUNCS=y
+ifndef CONFIG_FIPS
+MS_FUNCS=y
CHAP=y
+endif
CONFIG_IEEE8021X_EAPOL=y
endif
@@ -646,6 +665,7 @@ CONFIG_IEEE8021X_EAPOL=y
NEED_DH_GROUPS=y
NEED_DH_GROUPS_ALL=y
NEED_SHA256=y
+NEED_AES_CBC=y
endif
ifdef CONFIG_WPS
@@ -983,9 +1003,12 @@ LIBS += -lssl
endif
OBJS += ../src/crypto/crypto_openssl.o
OBJS_p += ../src/crypto/crypto_openssl.o
+OBJS_priv += ../src/crypto/crypto_openssl.o
ifdef NEED_FIPS186_2_PRF
OBJS += ../src/crypto/fips_prf_openssl.o
endif
+NEED_SHA256=y
+NEED_TLS_PRF_SHA256=y
LIBS += -lcrypto
LIBS_p += -lcrypto
ifdef CONFIG_TLS_ADD_DL
@@ -1001,6 +1024,7 @@ LIBS += -lgnutls -lgpg-error
endif
OBJS += ../src/crypto/crypto_gnutls.o
OBJS_p += ../src/crypto/crypto_gnutls.o
+OBJS_priv += ../src/crypto/crypto_gnutls.o
ifdef NEED_FIPS186_2_PRF
OBJS += ../src/crypto/fips_prf_internal.o
SHA1OBJS += ../src/crypto/sha1-internal.o
@@ -1012,21 +1036,6 @@ CONFIG_INTERNAL_RC4=y
CONFIG_INTERNAL_DH_GROUP5=y
endif
-ifeq ($(CONFIG_TLS), schannel)
-ifdef TLS_FUNCS
-OBJS += ../src/crypto/tls_schannel.o
-endif
-OBJS += ../src/crypto/crypto_cryptoapi.o
-OBJS_p += ../src/crypto/crypto_cryptoapi.o
-ifdef NEED_FIPS186_2_PRF
-OBJS += ../src/crypto/fips_prf_internal.o
-SHA1OBJS += ../src/crypto/sha1-internal.o
-endif
-CONFIG_INTERNAL_SHA256=y
-CONFIG_INTERNAL_RC4=y
-CONFIG_INTERNAL_DH_GROUP5=y
-endif
-
ifeq ($(CONFIG_TLS), internal)
ifndef CONFIG_CRYPTO
CONFIG_CRYPTO=internal
@@ -1145,6 +1154,20 @@ AESOBJS += ../src/crypto/aes-internal.o ../src/crypto/aes-internal-dec.o
endif
ifneq ($(CONFIG_TLS), openssl)
+NEED_INTERNAL_AES_WRAP=y
+endif
+ifdef CONFIG_OPENSSL_INTERNAL_AES_WRAP
+# Seems to be needed at least with BoringSSL
+NEED_INTERNAL_AES_WRAP=y
+CFLAGS += -DCONFIG_OPENSSL_INTERNAL_AES_WRAP
+endif
+ifdef CONFIG_FIPS
+# Have to use internal AES key wrap routines to use OpenSSL EVP since the
+# OpenSSL AES_wrap_key()/AES_unwrap_key() API is not available in FIPS mode.
+NEED_INTERNAL_AES_WRAP=y
+endif
+
+ifdef NEED_INTERNAL_AES_WRAP
AESOBJS += ../src/crypto/aes-unwrap.o
endif
ifdef NEED_AES_EAX
@@ -1170,14 +1193,16 @@ AESOBJS += ../src/crypto/aes-siv.o
endif
ifdef NEED_AES_WRAP
NEED_AES_ENC=y
-ifneq ($(CONFIG_TLS), openssl)
+ifdef NEED_INTERNAL_AES_WRAP
AESOBJS += ../src/crypto/aes-wrap.o
endif
endif
ifdef NEED_AES_CBC
NEED_AES_ENC=y
+ifneq ($(CONFIG_TLS), openssl)
AESOBJS += ../src/crypto/aes-cbc.o
endif
+endif
ifdef NEED_AES_ENC
ifdef CONFIG_INTERNAL_AES
AESOBJS += ../src/crypto/aes-internal-enc.o
@@ -1224,6 +1249,7 @@ MD5OBJS += ../src/crypto/md5-internal.o
endif
OBJS += $(MD5OBJS)
OBJS_p += $(MD5OBJS)
+OBJS_priv += $(MD5OBJS)
endif
ifdef NEED_MD4
@@ -1239,11 +1265,17 @@ DESOBJS += ../src/crypto/des-internal.o
endif
endif
+ifdef CONFIG_NO_RC4
+CFLAGS += -DCONFIG_NO_RC4
+endif
+
ifdef NEED_RC4
ifdef CONFIG_INTERNAL_RC4
+ifndef CONFIG_NO_RC4
OBJS += ../src/crypto/rc4.o
endif
endif
+endif
SHA256OBJS = # none by default
ifdef NEED_SHA256
@@ -1265,6 +1297,7 @@ OBJS += $(SHA256OBJS)
endif
ifdef NEED_SHA384
CFLAGS += -DCONFIG_SHA384
+OBJS += ../src/crypto/sha384-prf.o
endif
ifdef NEED_DH_GROUPS
@@ -1460,6 +1493,7 @@ OBJS += $(SHA1OBJS) $(DESOBJS)
OBJS_p += $(SHA1OBJS)
OBJS_p += $(SHA256OBJS)
+OBJS_priv += $(SHA1OBJS)
ifdef CONFIG_BGSCAN_SIMPLE
CFLAGS += -DCONFIG_BGSCAN_SIMPLE
@@ -1586,6 +1620,24 @@ EXTRALIBS += WbemUuid.Lib
endif
endif
+ifdef CONFIG_FST
+CFLAGS += -DCONFIG_FST
+ifdef CONFIG_FST_TEST
+CFLAGS += -DCONFIG_FST_TEST
+endif
+FST_OBJS += ../src/fst/fst.o
+FST_OBJS += ../src/fst/fst_session.o
+FST_OBJS += ../src/fst/fst_iface.o
+FST_OBJS += ../src/fst/fst_group.o
+FST_OBJS += ../src/fst/fst_ctrl_aux.o
+ifdef CONFIG_CTRL_IFACE
+FST_OBJS += ../src/fst/fst_ctrl_iface.o
+endif
+OBJS += $(FST_OBJS)
+OBJS_t += $(FST_OBJS)
+OBJS_t2 += $(FST_OBJS)
+endif
+
ifndef LDO
LDO=$(CC)
endif
@@ -1640,12 +1692,19 @@ wpa_cli: $(OBJS_c)
LIBCTRL += ../src/common/wpa_ctrl.o
LIBCTRL += ../src/utils/os_$(CONFIG_OS).o
LIBCTRL += ../src/utils/wpa_debug.o
+LIBCTRLSO += ../src/common/wpa_ctrl.c
+LIBCTRLSO += ../src/utils/os_$(CONFIG_OS).c
+LIBCTRLSO += ../src/utils/wpa_debug.c
-libwpa_ctrl.a: $(LIBCTRL)
+libwpa_client.a: $(LIBCTRL)
$(Q)rm -f $@
$(Q)$(AR) crs $@ $?
@$(E) " AR " $@
+libwpa_client.so: $(LIBCTRLSO)
+ @$(E) " CC $@ ($^)"
+ $(Q)$(CC) $(LDFLAGS) -o $@ $(CFLAGS) -shared -fPIC $^
+
link_test: $(OBJS) $(OBJS_h) tests/link_test.o
$(Q)$(LDO) $(LDFLAGS) -o link_test $(OBJS) $(OBJS_h) tests/link_test.o $(LIBS)
@$(E) " LD " $@
@@ -1728,7 +1787,7 @@ wpa_gui:
@echo "wpa_gui has been removed - see wpa_gui-qt4 for replacement"
wpa_gui-qt4/Makefile:
- qmake -o wpa_gui-qt4/Makefile wpa_gui-qt4/wpa_gui.pro
+ qmake -o wpa_gui-qt4/Makefile wpa_gui-qt4/wpa_gui.pro
wpa_gui-qt4/lang/wpa_gui_de.qm: wpa_gui-qt4/lang/wpa_gui_de.ts
lrelease wpa_gui-qt4/wpa_gui.pro
@@ -1765,6 +1824,7 @@ clean:
rm -f nfc_pw_token
rm -f lcov.info
rm -rf lcov-html
- rm -f libwpa_ctrl.a
+ rm -f libwpa_client.a
+ rm -f libwpa_client.so
-include $(OBJS:%.o=%.d)
diff --git a/wpa_supplicant/android.config b/wpa_supplicant/android.config
index 8d27bb2..6c3ee6d 100644
--- a/wpa_supplicant/android.config
+++ b/wpa_supplicant/android.config
@@ -476,4 +476,7 @@ CONFIG_WIFI_DISPLAY=y
# External password backend for testing purposes (developer use)
#CONFIG_EXT_PASSWORD_TEST=y
+# Enable Fast Session Transfer (FST)
+#CONFIG_FST=y
+
include $(wildcard $(LOCAL_PATH)/android_config_*.inc)
diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c
index 7ecf7a8..7a4f4cf 100644
--- a/wpa_supplicant/ap.c
+++ b/wpa_supplicant/ap.c
@@ -142,6 +142,29 @@ void wpa_supplicant_conf_ap_ht(struct wpa_supplicant *wpa_s,
}
}
}
+
+ if (conf->secondary_channel) {
+ struct wpa_supplicant *iface;
+
+ for (iface = wpa_s->global->ifaces; iface; iface = iface->next)
+ {
+ if (iface == wpa_s ||
+ iface->wpa_state < WPA_AUTHENTICATING ||
+ (int) iface->assoc_freq != ssid->frequency)
+ continue;
+
+ /*
+ * Do not allow 40 MHz co-ex PRI/SEC switch to force us
+ * to change our PRI channel since we have an existing,
+ * concurrent connection on that channel and doing
+ * multi-channel concurrency is likely to cause more
+ * harm than using different PRI/SEC selection in
+ * environment with multiple BSSes on these two channels
+ * with mixed 20 MHz or PRI channel selection.
+ */
+ conf->no_pri_sec_switch = 1;
+ }
+ }
#endif /* CONFIG_IEEE80211N */
}
@@ -485,8 +508,13 @@ static int ap_probe_req_rx(void *ctx, const u8 *sa, const u8 *da,
int ssi_signal)
{
struct wpa_supplicant *wpa_s = ctx;
+ unsigned int freq = 0;
+
+ if (wpa_s->ap_iface)
+ freq = wpa_s->ap_iface->freq;
+
return wpas_p2p_probe_req_rx(wpa_s, sa, da, bssid, ie, ie_len,
- ssi_signal);
+ freq, ssi_signal);
}
@@ -1156,6 +1184,7 @@ int ap_switch_channel(struct wpa_supplicant *wpa_s,
}
+#ifdef CONFIG_CTRL_IFACE
int ap_ctrl_iface_chanswitch(struct wpa_supplicant *wpa_s, const char *pos)
{
struct csa_settings settings;
@@ -1166,6 +1195,7 @@ int ap_ctrl_iface_chanswitch(struct wpa_supplicant *wpa_s, const char *pos)
return ap_switch_channel(wpa_s, &settings);
}
+#endif /* CONFIG_CTRL_IFACE */
void wpas_ap_ch_switch(struct wpa_supplicant *wpa_s, int freq, int ht,
@@ -1175,7 +1205,10 @@ void wpas_ap_ch_switch(struct wpa_supplicant *wpa_s, int freq, int ht,
return;
wpa_s->assoc_freq = freq;
- hostapd_event_ch_switch(wpa_s->ap_iface->bss[0], freq, ht, offset, width, cf1, cf1);
+ if (wpa_s->current_ssid)
+ wpa_s->current_ssid->frequency = freq;
+ hostapd_event_ch_switch(wpa_s->ap_iface->bss[0], freq, ht,
+ offset, width, cf1, cf2);
}
@@ -1265,6 +1298,7 @@ int wpas_ap_wps_add_nfc_pw(struct wpa_supplicant *wpa_s, u16 pw_id,
#endif /* CONFIG_WPS_NFC */
+#ifdef CONFIG_CTRL_IFACE
int wpas_ap_stop_ap(struct wpa_supplicant *wpa_s)
{
struct hostapd_data *hapd;
@@ -1274,6 +1308,7 @@ int wpas_ap_stop_ap(struct wpa_supplicant *wpa_s)
hapd = wpa_s->ap_iface->bss[0];
return hostapd_ctrl_iface_stop_ap(hapd);
}
+#endif /* CONFIG_CTRL_IFACE */
#ifdef NEED_AP_MLME
@@ -1337,3 +1372,10 @@ void wpas_event_dfs_cac_nop_finished(struct wpa_supplicant *wpa_s,
radar->chan_width, radar->cf1, radar->cf2);
}
#endif /* NEED_AP_MLME */
+
+
+void ap_periodic(struct wpa_supplicant *wpa_s)
+{
+ if (wpa_s->ap_iface)
+ hostapd_periodic_iface(wpa_s->ap_iface);
+}
diff --git a/wpa_supplicant/ap.h b/wpa_supplicant/ap.h
index 3f4151d..594168c 100644
--- a/wpa_supplicant/ap.h
+++ b/wpa_supplicant/ap.h
@@ -93,4 +93,6 @@ void wpas_event_dfs_cac_aborted(struct wpa_supplicant *wpa_s,
void wpas_event_dfs_cac_nop_finished(struct wpa_supplicant *wpa_s,
struct dfs_event *radar);
+void ap_periodic(struct wpa_supplicant *wpa_s);
+
#endif /* AP_H */
diff --git a/wpa_supplicant/bss.c b/wpa_supplicant/bss.c
index b4c47e2..1051ee3 100644
--- a/wpa_supplicant/bss.c
+++ b/wpa_supplicant/bss.c
@@ -19,11 +19,6 @@
#include "bss.h"
-/**
- * WPA_BSS_EXPIRATION_PERIOD - Period of expiration run in seconds
- */
-#define WPA_BSS_EXPIRATION_PERIOD 10
-
#define WPA_BSS_FREQ_CHANGED_FLAG BIT(0)
#define WPA_BSS_SIGNAL_CHANGED_FLAG BIT(1)
#define WPA_BSS_PRIVACY_CHANGED_FLAG BIT(2)
@@ -311,10 +306,18 @@ static int wpa_bss_known(struct wpa_supplicant *wpa_s, struct wpa_bss *bss)
static int wpa_bss_in_use(struct wpa_supplicant *wpa_s, struct wpa_bss *bss)
{
- return bss == wpa_s->current_bss ||
- (!is_zero_ether_addr(bss->bssid) &&
- (os_memcmp(bss->bssid, wpa_s->bssid, ETH_ALEN) == 0 ||
- os_memcmp(bss->bssid, wpa_s->pending_bssid, ETH_ALEN) == 0));
+ if (bss == wpa_s->current_bss)
+ return 1;
+
+ if (wpa_s->current_bss &&
+ (bss->ssid_len != wpa_s->current_bss->ssid_len ||
+ os_memcmp(bss->ssid, wpa_s->current_bss->ssid,
+ bss->ssid_len) != 0))
+ return 0; /* SSID has changed */
+
+ return !is_zero_ether_addr(bss->bssid) &&
+ (os_memcmp(bss->bssid, wpa_s->bssid, ETH_ALEN) == 0 ||
+ os_memcmp(bss->bssid, wpa_s->pending_bssid, ETH_ALEN) == 0);
}
@@ -390,15 +393,16 @@ static struct wpa_bss * wpa_bss_add(struct wpa_supplicant *wpa_s,
dl_list_add_tail(&wpa_s->bss_id, &bss->list_id);
wpa_s->num_bss++;
wpa_dbg(wpa_s, MSG_DEBUG, "BSS: Add new id %u BSSID " MACSTR
- " SSID '%s'",
- bss->id, MAC2STR(bss->bssid), wpa_ssid_txt(ssid, ssid_len));
+ " SSID '%s' freq %d",
+ bss->id, MAC2STR(bss->bssid), wpa_ssid_txt(ssid, ssid_len),
+ bss->freq);
wpas_notify_bss_added(wpa_s, bss->bssid, bss->id);
return bss;
}
static int are_ies_equal(const struct wpa_bss *old,
- const struct wpa_scan_res *new, u32 ie)
+ const struct wpa_scan_res *new_res, u32 ie)
{
const u8 *old_ie, *new_ie;
struct wpabuf *old_ie_buff = NULL;
@@ -408,19 +412,19 @@ static int are_ies_equal(const struct wpa_bss *old,
switch (ie) {
case WPA_IE_VENDOR_TYPE:
old_ie = wpa_bss_get_vendor_ie(old, ie);
- new_ie = wpa_scan_get_vendor_ie(new, ie);
+ new_ie = wpa_scan_get_vendor_ie(new_res, ie);
is_multi = 0;
break;
case WPS_IE_VENDOR_TYPE:
old_ie_buff = wpa_bss_get_vendor_ie_multi(old, ie);
- new_ie_buff = wpa_scan_get_vendor_ie_multi(new, ie);
+ new_ie_buff = wpa_scan_get_vendor_ie_multi(new_res, ie);
is_multi = 1;
break;
case WLAN_EID_RSN:
case WLAN_EID_SUPP_RATES:
case WLAN_EID_EXT_SUPP_RATES:
old_ie = wpa_bss_get_ie(old, ie);
- new_ie = wpa_scan_get_ie(new, ie);
+ new_ie = wpa_scan_get_ie(new_res, ie);
is_multi = 0;
break;
default:
@@ -454,15 +458,15 @@ static int are_ies_equal(const struct wpa_bss *old,
static u32 wpa_bss_compare_res(const struct wpa_bss *old,
- const struct wpa_scan_res *new)
+ const struct wpa_scan_res *new_res)
{
u32 changes = 0;
- int caps_diff = old->caps ^ new->caps;
+ int caps_diff = old->caps ^ new_res->caps;
- if (old->freq != new->freq)
+ if (old->freq != new_res->freq)
changes |= WPA_BSS_FREQ_CHANGED_FLAG;
- if (old->level != new->level)
+ if (old->level != new_res->level)
changes |= WPA_BSS_SIGNAL_CHANGED_FLAG;
if (caps_diff & IEEE80211_CAP_PRIVACY)
@@ -471,22 +475,22 @@ static u32 wpa_bss_compare_res(const struct wpa_bss *old,
if (caps_diff & IEEE80211_CAP_IBSS)
changes |= WPA_BSS_MODE_CHANGED_FLAG;
- if (old->ie_len == new->ie_len &&
- os_memcmp(old + 1, new + 1, old->ie_len) == 0)
+ if (old->ie_len == new_res->ie_len &&
+ os_memcmp(old + 1, new_res + 1, old->ie_len) == 0)
return changes;
changes |= WPA_BSS_IES_CHANGED_FLAG;
- if (!are_ies_equal(old, new, WPA_IE_VENDOR_TYPE))
+ if (!are_ies_equal(old, new_res, WPA_IE_VENDOR_TYPE))
changes |= WPA_BSS_WPAIE_CHANGED_FLAG;
- if (!are_ies_equal(old, new, WLAN_EID_RSN))
+ if (!are_ies_equal(old, new_res, WLAN_EID_RSN))
changes |= WPA_BSS_RSNIE_CHANGED_FLAG;
- if (!are_ies_equal(old, new, WPS_IE_VENDOR_TYPE))
+ if (!are_ies_equal(old, new_res, WPS_IE_VENDOR_TYPE))
changes |= WPA_BSS_WPS_CHANGED_FLAG;
- if (!are_ies_equal(old, new, WLAN_EID_SUPP_RATES) ||
- !are_ies_equal(old, new, WLAN_EID_EXT_SUPP_RATES))
+ if (!are_ies_equal(old, new_res, WLAN_EID_SUPP_RATES) ||
+ !are_ies_equal(old, new_res, WLAN_EID_EXT_SUPP_RATES))
changes |= WPA_BSS_RATES_CHANGED_FLAG;
return changes;
@@ -534,6 +538,9 @@ wpa_bss_update(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
u32 changes;
changes = wpa_bss_compare_res(bss, res);
+ if (changes & WPA_BSS_FREQ_CHANGED_FLAG)
+ wpa_printf(MSG_DEBUG, "BSS: " MACSTR " changed freq %d --> %d",
+ MAC2STR(bss->bssid), bss->freq, res->freq);
bss->scan_miss_count = 0;
bss->last_update_idx = wpa_s->bss_update_idx;
wpa_bss_copy_res(bss, res, fetch_time);
@@ -652,7 +659,7 @@ void wpa_bss_update_scan_res(struct wpa_supplicant *wpa_s,
MACSTR, MAC2STR(res->bssid));
return;
}
- if (ssid[1] > 32) {
+ if (ssid[1] > SSID_MAX_LEN) {
wpa_dbg(wpa_s, MSG_DEBUG, "BSS: Too long SSID IE included for "
MACSTR, MAC2STR(res->bssid));
return;
@@ -679,7 +686,7 @@ void wpa_bss_update_scan_res(struct wpa_supplicant *wpa_s,
* (to save memory) */
mesh = wpa_scan_get_ie(res, WLAN_EID_MESH_ID);
- if (mesh && mesh[1] <= 32)
+ if (mesh && mesh[1] <= SSID_MAX_LEN)
ssid = mesh;
bss = wpa_bss_get(wpa_s, res->bssid, ssid + 2, ssid[1]);
@@ -828,16 +835,6 @@ void wpa_bss_flush_by_age(struct wpa_supplicant *wpa_s, int age)
}
-static void wpa_bss_timeout(void *eloop_ctx, void *timeout_ctx)
-{
- struct wpa_supplicant *wpa_s = eloop_ctx;
-
- wpa_bss_flush_by_age(wpa_s, wpa_s->conf->bss_expiration_age);
- eloop_register_timeout(WPA_BSS_EXPIRATION_PERIOD, 0,
- wpa_bss_timeout, wpa_s, NULL);
-}
-
-
/**
* wpa_bss_init - Initialize BSS table
* @wpa_s: Pointer to wpa_supplicant data
@@ -850,8 +847,6 @@ int wpa_bss_init(struct wpa_supplicant *wpa_s)
{
dl_list_init(&wpa_s->bss);
dl_list_init(&wpa_s->bss_id);
- eloop_register_timeout(WPA_BSS_EXPIRATION_PERIOD, 0,
- wpa_bss_timeout, wpa_s, NULL);
return 0;
}
@@ -883,7 +878,6 @@ void wpa_bss_flush(struct wpa_supplicant *wpa_s)
*/
void wpa_bss_deinit(struct wpa_supplicant *wpa_s)
{
- eloop_cancel_timeout(wpa_bss_timeout, wpa_s, NULL);
wpa_bss_flush(wpa_s);
}
diff --git a/wpa_supplicant/bss.h b/wpa_supplicant/bss.h
index 634aa3c..b215380 100644
--- a/wpa_supplicant/bss.h
+++ b/wpa_supplicant/bss.h
@@ -69,7 +69,7 @@ struct wpa_bss {
/** HESSID */
u8 hessid[ETH_ALEN];
/** SSID */
- u8 ssid[32];
+ u8 ssid[SSID_MAX_LEN];
/** Length of SSID */
size_t ssid_len;
/** Frequency of the channel in MHz (e.g., 2412 = channel 1) */
diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
index 8e6cd20..b1adab7 100644
--- a/wpa_supplicant/config.c
+++ b/wpa_supplicant/config.c
@@ -15,6 +15,7 @@
#include "rsn_supp/wpa.h"
#include "eap_peer/eap.h"
#include "p2p/p2p.h"
+#include "fst/fst.h"
#include "config.h"
@@ -967,6 +968,13 @@ static int wpa_config_parse_group(const struct parse_data *data,
val = wpa_config_parse_cipher(line, value);
if (val == -1)
return -1;
+
+ /*
+ * Backwards compatibility - filter out WEP ciphers that were previously
+ * allowed.
+ */
+ val &= ~(WPA_CIPHER_WEP104 | WPA_CIPHER_WEP40);
+
if (val & ~WPA_ALLOWED_GROUP_CIPHERS) {
wpa_printf(MSG_ERROR, "Line %d: not allowed group cipher "
"(0x%x).", line, val);
@@ -1296,6 +1304,7 @@ static int wpa_config_parse_eap(const struct parse_data *data,
}
+#ifndef NO_CONFIG_WRITE
static char * wpa_config_write_eap(const struct parse_data *data,
struct wpa_ssid *ssid)
{
@@ -1329,6 +1338,7 @@ static char * wpa_config_write_eap(const struct parse_data *data,
return buf;
}
+#endif /* NO_CONFIG_WRITE */
static int wpa_config_parse_password(const struct parse_data *data,
@@ -1411,6 +1421,7 @@ static int wpa_config_parse_password(const struct parse_data *data,
}
+#ifndef NO_CONFIG_WRITE
static char * wpa_config_write_password(const struct parse_data *data,
struct wpa_ssid *ssid)
{
@@ -1444,6 +1455,7 @@ static char * wpa_config_write_password(const struct parse_data *data,
return buf;
}
+#endif /* NO_CONFIG_WRITE */
#endif /* IEEE8021X_EAPOL */
@@ -1810,12 +1822,13 @@ static char * wpa_config_write_mesh_basic_rates(const struct parse_data *data,
* functions.
*/
static const struct parse_data ssid_fields[] = {
- { STR_RANGE(ssid, 0, MAX_SSID_LEN) },
+ { STR_RANGE(ssid, 0, SSID_MAX_LEN) },
{ INT_RANGE(scan_ssid, 0, 1) },
{ FUNC(bssid) },
{ FUNC(bssid_blacklist) },
{ FUNC(bssid_whitelist) },
{ FUNC_KEY(psk) },
+ { INT(mem_only_psk) },
{ FUNC(proto) },
{ FUNC(key_mgmt) },
{ INT(bg_scan_period) },
@@ -2257,6 +2270,7 @@ void wpa_config_free(struct wpa_config *config)
os_free(config->osu_dir);
os_free(config->bgscan);
os_free(config->wowlan_triggers);
+ os_free(config->fst_group_id);
os_free(config);
}
@@ -2516,6 +2530,9 @@ int wpa_config_set_quoted(struct wpa_ssid *ssid, const char *var,
*/
char ** wpa_config_get_all(struct wpa_ssid *ssid, int get_keys)
{
+#ifdef NO_CONFIG_WRITE
+ return NULL;
+#else /* NO_CONFIG_WRITE */
const struct parse_data *field;
char *key, *value;
size_t i;
@@ -2561,6 +2578,7 @@ err:
os_free(value++);
os_free(props);
return NULL;
+#endif /* NO_CONFIG_WRITE */
}
@@ -2947,7 +2965,7 @@ int wpa_config_set_cred(struct wpa_cred *cred, const char *var,
if (os_strcmp(var, "excluded_ssid") == 0) {
struct excluded_ssid *e;
- if (len > MAX_SSID_LEN) {
+ if (len > SSID_MAX_LEN) {
wpa_printf(MSG_ERROR, "Line %d: invalid "
"excluded_ssid length %d", line, (int) len);
os_free(val);
@@ -3499,9 +3517,12 @@ struct wpa_config * wpa_config_alloc_empty(const char *ctrl_interface,
config->user_mpm = DEFAULT_USER_MPM;
config->max_peer_links = DEFAULT_MAX_PEER_LINKS;
config->mesh_max_inactivity = DEFAULT_MESH_MAX_INACTIVITY;
+ config->dot11RSNASAERetransPeriod =
+ DEFAULT_DOT11_RSNA_SAE_RETRANS_PERIOD;
config->fast_reauth = DEFAULT_FAST_REAUTH;
config->p2p_go_intent = DEFAULT_P2P_GO_INTENT;
config->p2p_intra_bss = DEFAULT_P2P_INTRA_BSS;
+ config->p2p_go_freq_change_policy = DEFAULT_P2P_GO_FREQ_MOVE;
config->p2p_go_max_inactivity = DEFAULT_P2P_GO_MAX_INACTIVITY;
config->p2p_optimize_listen_chan = DEFAULT_P2P_OPTIMIZE_LISTEN_CHAN;
config->p2p_go_ctwindow = DEFAULT_P2P_GO_CTWINDOW;
@@ -4052,6 +4073,31 @@ static int wpa_config_get_str(const char *name, struct wpa_config *config,
}
+#ifdef CONFIG_P2P
+static int wpa_config_get_ipv4(const char *name, struct wpa_config *config,
+ long offset, char *buf, size_t buflen,
+ int pretty_print)
+{
+ void *val = ((u8 *) config) + (long) offset;
+ int res;
+ char addr[INET_ADDRSTRLEN];
+
+ if (!val || !inet_ntop(AF_INET, val, addr, sizeof(addr)))
+ return -1;
+
+ if (pretty_print)
+ res = os_snprintf(buf, buflen, "%s=%s\n", name, addr);
+ else
+ res = os_snprintf(buf, buflen, "%s", addr);
+
+ if (os_snprintf_error(buflen, res))
+ res = -1;
+
+ return res;
+}
+#endif /* CONFIG_P2P */
+
+
#ifdef OFFSET
#undef OFFSET
#endif /* OFFSET */
@@ -4067,7 +4113,8 @@ static int wpa_config_get_str(const char *name, struct wpa_config *config,
#define STR(f) _STR(f), NULL, NULL
#define STR_RANGE(f, min, max) _STR(f), (void *) min, (void *) max
#define BIN(f) #f, wpa_global_config_parse_bin, NULL, OFFSET(f), NULL, NULL
-#define IPV4(f) #f, wpa_global_config_parse_ipv4, NULL, OFFSET(f), NULL, NULL
+#define IPV4(f) #f, wpa_global_config_parse_ipv4, wpa_config_get_ipv4, \
+ OFFSET(f), NULL, NULL
static const struct global_parse_data global_fields[] = {
#ifdef CONFIG_CTRL_IFACE
@@ -4086,6 +4133,7 @@ static const struct global_parse_data global_fields[] = {
{ INT(user_mpm), 0 },
{ INT_RANGE(max_peer_links, 0, 255), 0 },
{ INT(mesh_max_inactivity), 0 },
+ { INT(dot11RSNASAERetransPeriod), 0 },
#endif /* CONFIG_MESH */
{ INT(disable_scan_offload), 0 },
{ INT(fast_reauth), 0 },
@@ -4106,7 +4154,8 @@ static const struct global_parse_data global_fields[] = {
{ FUNC_NO_VAR(load_dynamic_eap), 0 },
#ifdef CONFIG_WPS
{ FUNC(uuid), CFG_CHANGED_UUID },
- { STR_RANGE(device_name, 0, 32), CFG_CHANGED_DEVICE_NAME },
+ { STR_RANGE(device_name, 0, WPS_DEV_NAME_MAX_LEN),
+ CFG_CHANGED_DEVICE_NAME },
{ STR_RANGE(manufacturer, 0, 64), CFG_CHANGED_WPS_STRING },
{ STR_RANGE(model_name, 0, 32), CFG_CHANGED_WPS_STRING },
{ STR_RANGE(model_number, 0, 32), CFG_CHANGED_WPS_STRING },
@@ -4119,8 +4168,8 @@ static const struct global_parse_data global_fields[] = {
#endif /* CONFIG_WPS */
#ifdef CONFIG_P2P
{ FUNC(sec_device_type), CFG_CHANGED_SEC_DEVICE_TYPE },
- { INT(p2p_listen_reg_class), 0 },
- { INT(p2p_listen_channel), 0 },
+ { INT(p2p_listen_reg_class), CFG_CHANGED_P2P_LISTEN_CHANNEL },
+ { INT(p2p_listen_channel), CFG_CHANGED_P2P_LISTEN_CHANNEL },
{ INT(p2p_oper_reg_class), CFG_CHANGED_P2P_OPER_CHANNEL },
{ INT(p2p_oper_channel), CFG_CHANGED_P2P_OPER_CHANNEL },
{ INT_RANGE(p2p_go_intent, 0, 15), 0 },
@@ -4128,6 +4177,7 @@ static const struct global_parse_data global_fields[] = {
{ INT_RANGE(persistent_reconnect, 0, 1), 0 },
{ INT_RANGE(p2p_intra_bss, 0, 1), CFG_CHANGED_P2P_INTRA_BSS },
{ INT(p2p_group_idle), 0 },
+ { INT_RANGE(p2p_go_freq_change_policy, 0, P2P_GO_FREQ_MOVE_MAX), 0 },
{ INT_RANGE(p2p_passphrase_len, 8, 63),
CFG_CHANGED_P2P_PASSPHRASE_LEN },
{ FUNC(p2p_pref_chan), CFG_CHANGED_P2P_PREF_CHAN },
@@ -4144,6 +4194,7 @@ static const struct global_parse_data global_fields[] = {
{ IPV4(ip_addr_mask), 0 },
{ IPV4(ip_addr_start), 0 },
{ IPV4(ip_addr_end), 0 },
+ { INT_RANGE(p2p_cli_probe, 0, 1), 0 },
#endif /* CONFIG_P2P */
{ FUNC(country), CFG_CHANGED_COUNTRY },
{ INT(bss_max_count), 0 },
@@ -4189,6 +4240,12 @@ static const struct global_parse_data global_fields[] = {
{ INT(key_mgmt_offload), 0},
{ INT(passive_scan), 0 },
{ INT(reassoc_same_bss_optim), 0 },
+ { INT(wps_priority), 0},
+#ifdef CONFIG_FST
+ { STR_RANGE(fst_group_id, 1, FST_MAX_GROUP_ID_LEN), 0 },
+ { INT_RANGE(fst_priority, 1, FST_MAX_PRIO_VALUE), 0 },
+ { INT_RANGE(fst_llt, 1, FST_MAX_LLT_MS), 0 },
+#endif /* CONFIG_FST */
};
#undef FUNC
diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h
index 34b754e..627f38b 100644
--- a/wpa_supplicant/config.h
+++ b/wpa_supplicant/config.h
@@ -18,6 +18,11 @@
#define DEFAULT_USER_MPM 1
#define DEFAULT_MAX_PEER_LINKS 99
#define DEFAULT_MESH_MAX_INACTIVITY 300
+/*
+ * The default dot11RSNASAERetransPeriod is defined as 40 ms in the standard,
+ * but use 1000 ms in practice to avoid issues on low power CPUs.
+ */
+#define DEFAULT_DOT11_RSNA_SAE_RETRANS_PERIOD 1000
#define DEFAULT_FAST_REAUTH 1
#define DEFAULT_P2P_GO_INTENT 7
#define DEFAULT_P2P_INTRA_BSS 1
@@ -37,6 +42,7 @@
#include "config_ssid.h"
#include "wps/wps.h"
+#include "common/ieee802_11_defs.h"
#include "common/ieee802_11_common.h"
@@ -241,7 +247,7 @@ struct wpa_cred {
char *phase2;
struct excluded_ssid {
- u8 ssid[MAX_SSID_LEN];
+ u8 ssid[SSID_MAX_LEN];
size_t ssid_len;
} *excluded_ssid;
size_t num_excluded_ssid;
@@ -400,6 +406,11 @@ struct wpa_config {
* one by one until the driver reports successful association; each
* network block should have explicit security policy (i.e., only one
* option in the lists) for key_mgmt, pairwise, group, proto variables.
+ *
+ * Note: ap_scan=2 should not be used with the nl80211 driver interface
+ * (the current Linux interface). ap_scan=1 is optimized work working
+ * with nl80211. For finding networks using hidden SSID, scan_ssid=1 in
+ * the network block can be used with nl80211.
*/
int ap_scan;
@@ -733,6 +744,34 @@ struct wpa_config {
int p2p_group_idle;
/**
+ * p2p_go_freq_change_policy - The GO frequency change policy
+ *
+ * This controls the behavior of the GO when there is a change in the
+ * map of the currently used frequencies in case more than one channel
+ * is supported.
+ *
+ * @P2P_GO_FREQ_MOVE_SCM: Prefer working in a single channel mode if
+ * possible. In case the GO is the only interface using its frequency
+ * and there are other station interfaces on other frequencies, the GO
+ * will migrate to one of these frequencies.
+ *
+ * @P2P_GO_FREQ_MOVE_SCM_PEER_SUPPORTS: Same as P2P_GO_FREQ_MOVE_SCM,
+ * but a transition is possible only in case one of the other used
+ * frequencies is one of the frequencies in the intersection of the
+ * frequency list of the local device and the peer device.
+ *
+ * @P2P_GO_FREQ_MOVE_STAY: Prefer to stay on the current frequency.
+ */
+ enum {
+ P2P_GO_FREQ_MOVE_SCM = 0,
+ P2P_GO_FREQ_MOVE_SCM_PEER_SUPPORTS = 1,
+ P2P_GO_FREQ_MOVE_STAY = 2,
+ P2P_GO_FREQ_MOVE_MAX = P2P_GO_FREQ_MOVE_STAY,
+ } p2p_go_freq_change_policy;
+
+#define DEFAULT_P2P_GO_FREQ_MOVE P2P_GO_FREQ_MOVE_STAY
+
+ /**
* p2p_passphrase_len - Passphrase length (8..63) for P2P GO
*
* This parameter controls the length of the random passphrase that is
@@ -967,6 +1006,18 @@ struct wpa_config {
int p2p_no_group_iface;
/**
+ * p2p_cli_probe - Enable/disable P2P CLI probe request handling
+ *
+ * If this parameter is set to 1, a connected P2P Client will receive
+ * and handle Probe Request frames. Setting this parameter to 0
+ * disables this option. Default value: 0.
+ *
+ * Note: Setting this property at run time takes effect on the following
+ * interface state transition to/from the WPA_COMPLETED state.
+ */
+ int p2p_cli_probe;
+
+ /**
* okc - Whether to enable opportunistic key caching by default
*
* By default, OKC is disabled unless enabled by the per-network
@@ -1148,6 +1199,15 @@ struct wpa_config {
int mesh_max_inactivity;
/**
+ * dot11RSNASAERetransPeriod - Timeout to retransmit SAE Auth frame
+ *
+ * This timeout value is used in mesh STA to retransmit
+ * SAE Authentication frame.
+ * By default: 1000 milliseconds.
+ */
+ int dot11RSNASAERetransPeriod;
+
+ /**
* passive_scan - Whether to force passive scan for network connection
*
* This parameter can be used to force only passive scanning to be used
@@ -1163,6 +1223,30 @@ struct wpa_config {
* reassoc_same_bss_optim - Whether to optimize reassoc-to-same-BSS
*/
int reassoc_same_bss_optim;
+
+ /**
+ * wps_priority - Priority for the networks added through WPS
+ *
+ * This priority value will be set to each network profile that is added
+ * by executing the WPS protocol.
+ */
+ int wps_priority;
+
+ /**
+ * fst_group_id - FST group ID
+ */
+ char *fst_group_id;
+
+ /**
+ * fst_priority - priority of the interface within the FST group
+ */
+ int fst_priority;
+
+ /**
+ * fst_llt - default FST LLT (Link-Lost Timeout) to be used for the
+ * interface.
+ */
+ int fst_llt;
};
diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c
index 3d3a6e4..fb438ea 100644
--- a/wpa_supplicant/config_file.c
+++ b/wpa_supplicant/config_file.c
@@ -501,7 +501,12 @@ static void write_bssid(FILE *f, struct wpa_ssid *ssid)
static void write_psk(FILE *f, struct wpa_ssid *ssid)
{
- char *value = wpa_config_get(ssid, "psk");
+ char *value;
+
+ if (ssid->mem_only_psk)
+ return;
+
+ value = wpa_config_get(ssid, "psk");
if (value == NULL)
return;
fprintf(f, "\tpsk=%s\n", value);
@@ -673,6 +678,7 @@ static void wpa_config_write_network(FILE *f, struct wpa_ssid *ssid)
write_str(f, "bssid_blacklist", ssid);
write_str(f, "bssid_whitelist", ssid);
write_psk(f, ssid);
+ INT(mem_only_psk);
write_proto(f, ssid);
write_key_mgmt(f, ssid);
INT_DEF(bg_scan_period, DEFAULT_BG_SCAN_PERIOD);
@@ -1010,13 +1016,13 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config)
if (config->driver_param)
fprintf(f, "driver_param=%s\n", config->driver_param);
if (config->dot11RSNAConfigPMKLifetime)
- fprintf(f, "dot11RSNAConfigPMKLifetime=%d\n",
+ fprintf(f, "dot11RSNAConfigPMKLifetime=%u\n",
config->dot11RSNAConfigPMKLifetime);
if (config->dot11RSNAConfigPMKReauthThreshold)
- fprintf(f, "dot11RSNAConfigPMKReauthThreshold=%d\n",
+ fprintf(f, "dot11RSNAConfigPMKReauthThreshold=%u\n",
config->dot11RSNAConfigPMKReauthThreshold);
if (config->dot11RSNAConfigSATimeout)
- fprintf(f, "dot11RSNAConfigSATimeout=%d\n",
+ fprintf(f, "dot11RSNAConfigSATimeout=%u\n",
config->dot11RSNAConfigSATimeout);
if (config->update_config)
fprintf(f, "update_config=%d\n", config->update_config);
@@ -1064,27 +1070,27 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config)
#endif /* CONFIG_WPS */
#ifdef CONFIG_P2P
if (config->p2p_listen_reg_class)
- fprintf(f, "p2p_listen_reg_class=%u\n",
+ fprintf(f, "p2p_listen_reg_class=%d\n",
config->p2p_listen_reg_class);
if (config->p2p_listen_channel)
- fprintf(f, "p2p_listen_channel=%u\n",
+ fprintf(f, "p2p_listen_channel=%d\n",
config->p2p_listen_channel);
if (config->p2p_oper_reg_class)
- fprintf(f, "p2p_oper_reg_class=%u\n",
+ fprintf(f, "p2p_oper_reg_class=%d\n",
config->p2p_oper_reg_class);
if (config->p2p_oper_channel)
- fprintf(f, "p2p_oper_channel=%u\n", config->p2p_oper_channel);
+ fprintf(f, "p2p_oper_channel=%d\n", config->p2p_oper_channel);
if (config->p2p_go_intent != DEFAULT_P2P_GO_INTENT)
- fprintf(f, "p2p_go_intent=%u\n", config->p2p_go_intent);
+ fprintf(f, "p2p_go_intent=%d\n", config->p2p_go_intent);
if (config->p2p_ssid_postfix)
fprintf(f, "p2p_ssid_postfix=%s\n", config->p2p_ssid_postfix);
if (config->persistent_reconnect)
- fprintf(f, "persistent_reconnect=%u\n",
+ fprintf(f, "persistent_reconnect=%d\n",
config->persistent_reconnect);
if (config->p2p_intra_bss != DEFAULT_P2P_INTRA_BSS)
- fprintf(f, "p2p_intra_bss=%u\n", config->p2p_intra_bss);
+ fprintf(f, "p2p_intra_bss=%d\n", config->p2p_intra_bss);
if (config->p2p_group_idle)
- fprintf(f, "p2p_group_idle=%u\n", config->p2p_group_idle);
+ fprintf(f, "p2p_group_idle=%d\n", config->p2p_group_idle);
if (config->p2p_passphrase_len)
fprintf(f, "p2p_passphrase_len=%u\n",
config->p2p_passphrase_len);
@@ -1112,19 +1118,24 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config)
fprintf(f, "p2p_optimize_listen_chan=%d\n",
config->p2p_optimize_listen_chan);
if (config->p2p_go_ht40)
- fprintf(f, "p2p_go_ht40=%u\n", config->p2p_go_ht40);
+ fprintf(f, "p2p_go_ht40=%d\n", config->p2p_go_ht40);
if (config->p2p_go_vht)
- fprintf(f, "p2p_go_vht=%u\n", config->p2p_go_vht);
+ fprintf(f, "p2p_go_vht=%d\n", config->p2p_go_vht);
if (config->p2p_go_ctwindow != DEFAULT_P2P_GO_CTWINDOW)
- fprintf(f, "p2p_go_ctwindow=%u\n", config->p2p_go_ctwindow);
+ fprintf(f, "p2p_go_ctwindow=%d\n", config->p2p_go_ctwindow);
if (config->p2p_disabled)
- fprintf(f, "p2p_disabled=%u\n", config->p2p_disabled);
+ fprintf(f, "p2p_disabled=%d\n", config->p2p_disabled);
if (config->p2p_no_group_iface)
- fprintf(f, "p2p_no_group_iface=%u\n",
+ fprintf(f, "p2p_no_group_iface=%d\n",
config->p2p_no_group_iface);
if (config->p2p_ignore_shared_freq)
- fprintf(f, "p2p_ignore_shared_freq=%u\n",
+ fprintf(f, "p2p_ignore_shared_freq=%d\n",
config->p2p_ignore_shared_freq);
+ if (config->p2p_cli_probe)
+ fprintf(f, "p2p_cli_probe=%d\n", config->p2p_cli_probe);
+ if (config->p2p_go_freq_change_policy != DEFAULT_P2P_GO_FREQ_MOVE)
+ fprintf(f, "p2p_go_freq_change_policy=%u\n",
+ config->p2p_go_freq_change_policy);
#endif /* CONFIG_P2P */
if (config->country[0] && config->country[1]) {
fprintf(f, "country=%c%c\n",
@@ -1144,14 +1155,14 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config)
if (config->max_num_sta != DEFAULT_MAX_NUM_STA)
fprintf(f, "max_num_sta=%u\n", config->max_num_sta);
if (config->disassoc_low_ack)
- fprintf(f, "disassoc_low_ack=%u\n", config->disassoc_low_ack);
+ fprintf(f, "disassoc_low_ack=%d\n", config->disassoc_low_ack);
#ifdef CONFIG_HS20
if (config->hs20)
fprintf(f, "hs20=1\n");
#endif /* CONFIG_HS20 */
#ifdef CONFIG_INTERWORKING
if (config->interworking)
- fprintf(f, "interworking=%u\n", config->interworking);
+ fprintf(f, "interworking=%d\n", config->interworking);
if (!is_zero_ether_addr(config->hessid))
fprintf(f, "hessid=" MACSTR "\n", MAC2STR(config->hessid));
if (config->access_network_type != DEFAULT_ACCESS_NETWORK_TYPE)
@@ -1159,7 +1170,7 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config)
config->access_network_type);
#endif /* CONFIG_INTERWORKING */
if (config->pbc_in_m1)
- fprintf(f, "pbc_in_m1=%u\n", config->pbc_in_m1);
+ fprintf(f, "pbc_in_m1=%d\n", config->pbc_in_m1);
if (config->wps_nfc_pw_from_config) {
if (config->wps_nfc_dev_pw_id)
fprintf(f, "wps_nfc_dev_pw_id=%d\n",
@@ -1218,7 +1229,7 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config)
int i;
fprintf(f, "freq_list=");
for (i = 0; config->freq_list[i]; i++) {
- fprintf(f, "%s%u", i > 0 ? " " : "",
+ fprintf(f, "%s%d", i > 0 ? " " : "",
config->freq_list[i]);
}
fprintf(f, "\n");
@@ -1259,7 +1270,7 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config)
fprintf(f, "preassoc_mac_addr=%d\n", config->preassoc_mac_addr);
if (config->key_mgmt_offload != DEFAULT_KEY_MGMT_OFFLOAD)
- fprintf(f, "key_mgmt_offload=%u\n", config->key_mgmt_offload);
+ fprintf(f, "key_mgmt_offload=%d\n", config->key_mgmt_offload);
if (config->user_mpm != DEFAULT_USER_MPM)
fprintf(f, "user_mpm=%d\n", config->user_mpm);
@@ -1274,12 +1285,20 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config)
fprintf(f, "mesh_max_inactivity=%d\n",
config->mesh_max_inactivity);
+ if (config->dot11RSNASAERetransPeriod !=
+ DEFAULT_DOT11_RSNA_SAE_RETRANS_PERIOD)
+ fprintf(f, "dot11RSNASAERetransPeriod=%d\n",
+ config->dot11RSNASAERetransPeriod);
+
if (config->passive_scan)
fprintf(f, "passive_scan=%d\n", config->passive_scan);
if (config->reassoc_same_bss_optim)
fprintf(f, "reassoc_same_bss_optim=%d\n",
config->reassoc_same_bss_optim);
+
+ if (config->wps_priority)
+ fprintf(f, "wps_priority=%d\n", config->wps_priority);
}
#endif /* CONFIG_NO_CONFIG_WRITE */
@@ -1342,6 +1361,8 @@ int wpa_config_write(const char *name, struct wpa_config *config)
}
#endif /* CONFIG_NO_CONFIG_BLOBS */
+ os_fdatasync(f);
+
fclose(f);
if (tmp_name) {
diff --git a/wpa_supplicant/config_ssid.h b/wpa_supplicant/config_ssid.h
index 7c826cf..7ef326c 100644
--- a/wpa_supplicant/config_ssid.h
+++ b/wpa_supplicant/config_ssid.h
@@ -13,8 +13,6 @@
#include "utils/list.h"
#include "eap_peer/eap_config.h"
-#define MAX_SSID_LEN 32
-
#define DEFAULT_EAP_WORKAROUND ((unsigned int) -1)
#define DEFAULT_EAPOL_FLAGS (EAPOL_FLAG_REQUIRE_KEY_UNICAST | \
@@ -22,8 +20,7 @@
#define DEFAULT_PROTO (WPA_PROTO_WPA | WPA_PROTO_RSN)
#define DEFAULT_KEY_MGMT (WPA_KEY_MGMT_PSK | WPA_KEY_MGMT_IEEE8021X)
#define DEFAULT_PAIRWISE (WPA_CIPHER_CCMP | WPA_CIPHER_TKIP)
-#define DEFAULT_GROUP (WPA_CIPHER_CCMP | WPA_CIPHER_TKIP | \
- WPA_CIPHER_WEP104 | WPA_CIPHER_WEP40)
+#define DEFAULT_GROUP (WPA_CIPHER_CCMP | WPA_CIPHER_TKIP)
#define DEFAULT_FRAGMENT_SIZE 1398
#define DEFAULT_BG_SCAN_PERIOD -1
@@ -181,6 +178,14 @@ struct wpa_ssid {
char *ext_psk;
/**
+ * mem_only_psk - Whether to keep PSK/passphrase only in memory
+ *
+ * 0 = allow psk/passphrase to be stored to the configuration file
+ * 1 = do not store psk/passphrase to the configuration file
+ */
+ int mem_only_psk;
+
+ /**
* pairwise_cipher - Bitfield of allowed pairwise ciphers, WPA_CIPHER_*
*/
int pairwise_cipher;
@@ -220,7 +225,9 @@ struct wpa_ssid {
*
* scan_ssid can be used to scan for APs using hidden SSIDs.
* Note: Many drivers do not support this. ap_mode=2 can be used with
- * such drivers to use hidden SSIDs.
+ * such drivers to use hidden SSIDs. Note2: Most nl80211-based drivers
+ * do support scan_ssid=1 and that should be used with them instead of
+ * ap_scan=2.
*/
int scan_ssid;
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index b4aefb6..3b97806 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -28,6 +28,8 @@
#include "rsn_supp/pmksa_cache.h"
#include "l2_packet/l2_packet.h"
#include "wps/wps.h"
+#include "fst/fst.h"
+#include "fst/fst_ctrl_iface.h"
#include "config.h"
#include "wpa_supplicant_i.h"
#include "driver_i.h"
@@ -153,7 +155,8 @@ static int set_disallow_aps(struct wpa_supplicant *wpa_s, char *val)
}
ssid = ns;
- if ((end - pos) & 0x01 || end - pos > 2 * 32 ||
+ if ((end - pos) & 0x01 ||
+ end - pos > 2 * SSID_MAX_LEN ||
hexstr2bin(pos, ssid[ssid_count].ssid,
(end - pos) / 2) < 0) {
os_free(ssid);
@@ -283,6 +286,30 @@ static int wpas_ctrl_pno(struct wpa_supplicant *wpa_s, char *cmd)
}
+static int wpas_ctrl_set_band(struct wpa_supplicant *wpa_s, char *band)
+{
+ union wpa_event_data event;
+
+ if (os_strcmp(band, "AUTO") == 0)
+ wpa_s->setband = WPA_SETBAND_AUTO;
+ else if (os_strcmp(band, "5G") == 0)
+ wpa_s->setband = WPA_SETBAND_5G;
+ else if (os_strcmp(band, "2G") == 0)
+ wpa_s->setband = WPA_SETBAND_2G;
+ else
+ return -1;
+
+ if (wpa_drv_setband(wpa_s, wpa_s->setband) == 0) {
+ os_memset(&event, 0, sizeof(event));
+ event.channel_list_changed.initiator = REGDOM_SET_BY_USER;
+ event.channel_list_changed.type = REGDOM_TYPE_UNKNOWN;
+ wpa_supplicant_event(wpa_s, EVENT_CHANNEL_LIST_CHANGED, &event);
+ }
+
+ return 0;
+}
+
+
static int wpa_supplicant_ctrl_iface_set(struct wpa_supplicant *wpa_s,
char *cmd)
{
@@ -446,14 +473,7 @@ static int wpa_supplicant_ctrl_iface_set(struct wpa_supplicant *wpa_s,
ret = wpas_ctrl_set_blob(wpa_s, value);
#endif /* CONFIG_NO_CONFIG_BLOBS */
} else if (os_strcasecmp(cmd, "setband") == 0) {
- if (os_strcmp(value, "AUTO") == 0)
- wpa_s->setband = WPA_SETBAND_AUTO;
- else if (os_strcmp(value, "5G") == 0)
- wpa_s->setband = WPA_SETBAND_5G;
- else if (os_strcmp(value, "2G") == 0)
- wpa_s->setband = WPA_SETBAND_2G;
- else
- ret = -1;
+ ret = wpas_ctrl_set_band(wpa_s, value);
} else {
value[-1] = '=';
ret = wpa_config_process_global(wpa_s->conf, cmd, -1);
@@ -759,6 +779,33 @@ static int wpa_supplicant_ctrl_iface_tdls_cancel_chan_switch(
return wpa_tdls_disable_chan_switch(wpa_s->wpa, peer);
}
+
+static int wpa_supplicant_ctrl_iface_tdls_link_status(
+ struct wpa_supplicant *wpa_s, const char *addr,
+ char *buf, size_t buflen)
+{
+ u8 peer[ETH_ALEN];
+ const char *tdls_status;
+ int ret;
+
+ if (hwaddr_aton(addr, peer)) {
+ wpa_printf(MSG_DEBUG,
+ "CTRL_IFACE TDLS_LINK_STATUS: Invalid address '%s'",
+ addr);
+ return -1;
+ }
+ wpa_printf(MSG_DEBUG, "CTRL_IFACE TDLS_LINK_STATUS " MACSTR,
+ MAC2STR(peer));
+
+ tdls_status = wpa_tdls_get_link_status(wpa_s->wpa, peer);
+ wpa_printf(MSG_DEBUG, "CTRL_IFACE TDLS_LINK_STATUS: %s", tdls_status);
+ ret = os_snprintf(buf, buflen, "TDLS link status: %s\n", tdls_status);
+ if (os_snprintf_error(buflen, ret))
+ return -1;
+
+ return ret;
+}
+
#endif /* CONFIG_TDLS */
@@ -1728,7 +1775,7 @@ static int wpa_supplicant_ctrl_iface_status(struct wpa_supplicant *wpa_s,
if (ssid) {
u8 *_ssid = ssid->ssid;
size_t ssid_len = ssid->ssid_len;
- u8 ssid_buf[MAX_SSID_LEN];
+ u8 ssid_buf[SSID_MAX_LEN];
if (ssid_len == 0) {
int _res = wpa_drv_get_ssid(wpa_s, ssid_buf);
if (_res < 0)
@@ -2089,45 +2136,6 @@ static int wpa_supplicant_ctrl_iface_blacklist(struct wpa_supplicant *wpa_s,
}
-static const char * debug_level_str(int level)
-{
- switch (level) {
- case MSG_EXCESSIVE:
- return "EXCESSIVE";
- case MSG_MSGDUMP:
- return "MSGDUMP";
- case MSG_DEBUG:
- return "DEBUG";
- case MSG_INFO:
- return "INFO";
- case MSG_WARNING:
- return "WARNING";
- case MSG_ERROR:
- return "ERROR";
- default:
- return "?";
- }
-}
-
-
-static int str_to_debug_level(const char *s)
-{
- if (os_strcasecmp(s, "EXCESSIVE") == 0)
- return MSG_EXCESSIVE;
- if (os_strcasecmp(s, "MSGDUMP") == 0)
- return MSG_MSGDUMP;
- if (os_strcasecmp(s, "DEBUG") == 0)
- return MSG_DEBUG;
- if (os_strcasecmp(s, "INFO") == 0)
- return MSG_INFO;
- if (os_strcasecmp(s, "WARNING") == 0)
- return MSG_WARNING;
- if (os_strcasecmp(s, "ERROR") == 0)
- return MSG_ERROR;
- return -1;
-}
-
-
static int wpa_supplicant_ctrl_iface_log_level(struct wpa_supplicant *wpa_s,
char *cmd, char *buf,
size_t buflen)
@@ -2160,7 +2168,7 @@ static int wpa_supplicant_ctrl_iface_log_level(struct wpa_supplicant *wpa_s,
}
}
- if (cmd && os_strlen(cmd)) {
+ if (os_strlen(cmd)) {
int level = str_to_debug_level(cmd);
if (level < 0)
return -1;
@@ -2366,6 +2374,14 @@ static char * wpa_supplicant_ie_txt(char *pos, char *end, const char *proto,
}
#endif /* CONFIG_SUITEB192 */
+ if (data.key_mgmt & WPA_KEY_MGMT_OSEN) {
+ ret = os_snprintf(pos, end - pos, "%sOSEN",
+ pos == start ? "" : "+");
+ if (os_snprintf_error(end - pos, ret))
+ return pos;
+ pos += ret;
+ }
+
pos = wpa_supplicant_cipher_txt(pos, end, data.pairwise_cipher);
if (data.capabilities & WPA_CAPABILITY_PREAUTH) {
@@ -2433,7 +2449,7 @@ static int wpa_supplicant_ctrl_iface_scan_result(
{
char *pos, *end;
int ret;
- const u8 *ie, *ie2, *p2p, *mesh;
+ const u8 *ie, *ie2, *osen_ie, *p2p, *mesh;
mesh = wpa_bss_get_ie(bss, WLAN_EID_MESH_ID);
p2p = wpa_bss_get_vendor_ie(bss, P2P_IE_VENDOR_TYPE);
@@ -2460,8 +2476,12 @@ static int wpa_supplicant_ctrl_iface_scan_result(
pos = wpa_supplicant_ie_txt(pos, end, mesh ? "RSN" : "WPA2",
ie2, 2 + ie2[1]);
}
+ osen_ie = wpa_bss_get_vendor_ie(bss, OSEN_IE_VENDOR_TYPE);
+ if (osen_ie)
+ pos = wpa_supplicant_ie_txt(pos, end, "OSEN",
+ osen_ie, 2 + osen_ie[1]);
pos = wpa_supplicant_wps_ie_txt(wpa_s, pos, end, bss);
- if (!ie && !ie2 && bss->caps & IEEE80211_CAP_PRIVACY) {
+ if (!ie && !ie2 && !osen_ie && (bss->caps & IEEE80211_CAP_PRIVACY)) {
ret = os_snprintf(pos, end - pos, "[WEP]");
if (os_snprintf_error(end - pos, ret))
return -1;
@@ -2525,6 +2545,14 @@ static int wpa_supplicant_ctrl_iface_scan_result(
pos += ret;
}
#endif /* CONFIG_HS20 */
+#ifdef CONFIG_FST
+ if (wpa_bss_get_ie(bss, WLAN_EID_MULTI_BAND)) {
+ ret = os_snprintf(pos, end - pos, "[FST]");
+ if (os_snprintf_error(end - pos, ret))
+ return -1;
+ pos += ret;
+ }
+#endif /* CONFIG_FST */
ret = os_snprintf(pos, end - pos, "\t%s",
wpa_ssid_txt(bss->ssid, bss->ssid_len));
@@ -2716,6 +2744,8 @@ static int wpa_supplicant_ctrl_iface_select_network(
}
}
+ wpa_s->scan_min_time.sec = 0;
+ wpa_s->scan_min_time.usec = 0;
wpa_supplicant_select_network(wpa_s, ssid);
return 0;
@@ -2753,6 +2783,8 @@ static int wpa_supplicant_ctrl_iface_enable_network(
return 0;
}
}
+ wpa_s->scan_min_time.sec = 0;
+ wpa_s->scan_min_time.usec = 0;
wpa_supplicant_enable_network(wpa_s, ssid);
return 0;
@@ -2836,7 +2868,8 @@ static int wpa_supplicant_ctrl_iface_remove_network(
#endif /* CONFIG_SME */
wpa_sm_set_config(wpa_s->wpa, NULL);
eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
- wpa_s->own_disconnect_req = 1;
+ if (wpa_s->wpa_state >= WPA_AUTHENTICATING)
+ wpa_s->own_disconnect_req = 1;
wpa_supplicant_deauthenticate(
wpa_s, WLAN_REASON_DEAUTH_LEAVING);
}
@@ -2883,7 +2916,8 @@ static int wpa_supplicant_ctrl_iface_remove_network(
wpa_sm_set_config(wpa_s->wpa, NULL);
eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
- wpa_s->own_disconnect_req = 1;
+ if (wpa_s->wpa_state >= WPA_AUTHENTICATING)
+ wpa_s->own_disconnect_req = 1;
wpa_supplicant_deauthenticate(wpa_s,
WLAN_REASON_DEAUTH_LEAVING);
}
@@ -3005,19 +3039,19 @@ static int wpa_supplicant_ctrl_iface_get_network(
*name++ = '\0';
id = atoi(cmd);
- wpa_printf(MSG_DEBUG, "CTRL_IFACE: GET_NETWORK id=%d name='%s'",
+ wpa_printf(MSG_EXCESSIVE, "CTRL_IFACE: GET_NETWORK id=%d name='%s'",
id, name);
ssid = wpa_config_get_network(wpa_s->conf, id);
if (ssid == NULL) {
- wpa_printf(MSG_DEBUG, "CTRL_IFACE: Could not find network "
+ wpa_printf(MSG_EXCESSIVE, "CTRL_IFACE: Could not find network "
"id=%d", id);
return -1;
}
value = wpa_config_get_no_key(ssid, name);
if (value == NULL) {
- wpa_printf(MSG_DEBUG, "CTRL_IFACE: Failed to get network "
+ wpa_printf(MSG_EXCESSIVE, "CTRL_IFACE: Failed to get network "
"variable '%s'", name);
return -1;
}
@@ -3035,7 +3069,8 @@ static int wpa_supplicant_ctrl_iface_get_network(
static int wpa_supplicant_ctrl_iface_dup_network(
- struct wpa_supplicant *wpa_s, char *cmd)
+ struct wpa_supplicant *wpa_s, char *cmd,
+ struct wpa_supplicant *dst_wpa_s)
{
struct wpa_ssid *ssid_s, *ssid_d;
char *name, *id, *value;
@@ -3054,8 +3089,10 @@ static int wpa_supplicant_ctrl_iface_dup_network(
id_s = atoi(cmd);
id_d = atoi(id);
- wpa_printf(MSG_DEBUG, "CTRL_IFACE: DUP_NETWORK id=%d -> %d name='%s'",
- id_s, id_d, name);
+
+ wpa_printf(MSG_DEBUG,
+ "CTRL_IFACE: DUP_NETWORK ifname=%s->%s id=%d->%d name='%s'",
+ wpa_s->ifname, dst_wpa_s->ifname, id_s, id_d, name);
ssid_s = wpa_config_get_network(wpa_s->conf, id_s);
if (ssid_s == NULL) {
@@ -3064,7 +3101,7 @@ static int wpa_supplicant_ctrl_iface_dup_network(
return -1;
}
- ssid_d = wpa_config_get_network(wpa_s->conf, id_d);
+ ssid_d = wpa_config_get_network(dst_wpa_s->conf, id_d);
if (ssid_d == NULL) {
wpa_printf(MSG_DEBUG, "CTRL_IFACE: Could not find "
"network id=%d", id_d);
@@ -3078,7 +3115,7 @@ static int wpa_supplicant_ctrl_iface_dup_network(
return -1;
}
- ret = wpa_supplicant_ctrl_iface_update_network(wpa_s, ssid_d, name,
+ ret = wpa_supplicant_ctrl_iface_update_network(dst_wpa_s, ssid_d, name,
value);
os_free(value);
@@ -3889,6 +3926,15 @@ static int wpa_supplicant_ctrl_iface_get_capability(
}
#endif /* CONFIG_EPR */
+#ifdef CONFIG_FIPS
+ if (os_strcmp(field, "fips") == 0) {
+ res = os_snprintf(buf, buflen, "FIPS");
+ if (os_snprintf_error(buflen, res))
+ return -1;
+ return res;
+ }
+#endif /* CONFIG_FIPS */
+
wpa_printf(MSG_DEBUG, "CTRL_IFACE: Unknown GET_CAPABILITY field '%s'",
field);
@@ -3937,7 +3983,7 @@ static int print_bss_info(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
size_t i;
int ret;
char *pos, *end;
- const u8 *ie, *ie2;
+ const u8 *ie, *ie2, *osen_ie;
pos = buf;
end = buf + buflen;
@@ -4054,8 +4100,13 @@ static int print_bss_info(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
if (ie2)
pos = wpa_supplicant_ie_txt(pos, end, "WPA2", ie2,
2 + ie2[1]);
+ osen_ie = wpa_bss_get_vendor_ie(bss, OSEN_IE_VENDOR_TYPE);
+ if (osen_ie)
+ pos = wpa_supplicant_ie_txt(pos, end, "OSEN",
+ osen_ie, 2 + osen_ie[1]);
pos = wpa_supplicant_wps_ie_txt(wpa_s, pos, end, bss);
- if (!ie && !ie2 && bss->caps & IEEE80211_CAP_PRIVACY) {
+ if (!ie && !ie2 && !osen_ie &&
+ (bss->caps & IEEE80211_CAP_PRIVACY)) {
ret = os_snprintf(pos, end - pos, "[WEP]");
if (os_snprintf_error(end - pos, ret))
return 0;
@@ -4133,9 +4184,10 @@ static int print_bss_info(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
if (mask & WPA_BSS_MASK_WPS_SCAN) {
ie = (const u8 *) (bss + 1);
ret = wpas_wps_scan_result_text(ie, bss->ie_len, pos, end);
- if (ret < 0 || ret >= end - pos)
+ if (ret >= end - pos)
return 0;
- pos += ret;
+ if (ret > 0)
+ pos += ret;
}
#endif /* CONFIG_WPS */
@@ -4236,6 +4288,15 @@ static int print_bss_info(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
pos += ret;
}
+#ifdef CONFIG_FST
+ if (mask & WPA_BSS_MASK_FST) {
+ ret = fst_ctrl_iface_mb_info(bss->bssid, pos, end - pos);
+ if (ret < 0 || ret >= end - pos)
+ return 0;
+ pos += ret;
+ }
+#endif /* CONFIG_FST */
+
if (mask & WPA_BSS_MASK_DELIM) {
ret = os_snprintf(pos, end - pos, "====\n");
if (os_snprintf_error(end - pos, ret))
@@ -4548,37 +4609,83 @@ static int p2p_ctrl_find(struct wpa_supplicant *wpa_s, char *cmd)
} else
search_delay = wpas_p2p_search_delay(wpa_s);
+ pos = os_strstr(cmd, "freq=");
+ if (pos) {
+ pos += 5;
+ freq = atoi(pos);
+ if (freq <= 0)
+ return -1;
+ }
+
/* Must be searched for last, because it adds nul termination */
pos = os_strstr(cmd, " seek=");
+ if (pos)
+ pos += 6;
while (pos && seek_count < P2P_MAX_QUERY_HASH + 1) {
char *term;
- term = os_strchr(pos + 1, ' ');
- _seek[seek_count++] = pos + 6;
+ _seek[seek_count++] = pos;
seek = _seek;
- pos = os_strstr(pos + 6, " seek=");
-
- if (term)
- *term = '\0';
+ term = os_strchr(pos, ' ');
+ if (!term)
+ break;
+ *term = '\0';
+ pos = os_strstr(term + 1, "seek=");
+ if (pos)
+ pos += 5;
}
if (seek_count > P2P_MAX_QUERY_HASH) {
seek[0] = NULL;
seek_count = 1;
}
- pos = os_strstr(cmd, "freq=");
- if (pos) {
- pos += 5;
- freq = atoi(pos);
- if (freq <= 0)
- return -1;
- }
-
return wpas_p2p_find(wpa_s, timeout, type, _dev_type != NULL, _dev_type,
_dev_id, search_delay, seek_count, seek, freq);
}
+static int p2ps_ctrl_parse_cpt_priority(const char *pos, u8 *cpt)
+{
+ const char *last = NULL;
+ const char *token;
+ long int token_len;
+ unsigned int i;
+
+ /* Expected predefined CPT names delimited by ':' */
+ for (i = 0; (token = cstr_token(pos, ": \t", &last)); i++) {
+ if (i >= P2PS_FEATURE_CAPAB_CPT_MAX) {
+ wpa_printf(MSG_ERROR,
+ "P2PS: CPT name list is too long, expected up to %d names",
+ P2PS_FEATURE_CAPAB_CPT_MAX);
+ cpt[0] = 0;
+ return -1;
+ }
+
+ token_len = last - token;
+
+ if (token_len == 3 &&
+ os_memcmp(token, "UDP", token_len) == 0) {
+ cpt[i] = P2PS_FEATURE_CAPAB_UDP_TRANSPORT;
+ } else if (token_len == 3 &&
+ os_memcmp(token, "MAC", token_len) == 0) {
+ cpt[i] = P2PS_FEATURE_CAPAB_MAC_TRANSPORT;
+ } else {
+ wpa_printf(MSG_ERROR,
+ "P2PS: Unsupported CPT name '%s'", token);
+ cpt[0] = 0;
+ return -1;
+ }
+
+ if (isblank(*last)) {
+ i++;
+ break;
+ }
+ }
+ cpt[i] = 0;
+ return 0;
+}
+
+
static struct p2ps_provision * p2p_parse_asp_provision_cmd(const char *cmd)
{
struct p2ps_provision *p2ps_prov;
@@ -4587,6 +4694,7 @@ static struct p2ps_provision * p2p_parse_asp_provision_cmd(const char *cmd)
char *info = NULL;
u8 role = P2PS_SETUP_NONE;
long long unsigned val;
+ int i;
pos = os_strstr(cmd, "info=");
if (pos) {
@@ -4645,6 +4753,18 @@ static struct p2ps_provision * p2p_parse_asp_provision_cmd(const char *cmd)
if (!pos || hwaddr_aton(pos + 12, p2ps_prov->session_mac))
goto invalid_args;
+ pos = os_strstr(cmd, "cpt=");
+ if (pos) {
+ if (p2ps_ctrl_parse_cpt_priority(pos + 4,
+ p2ps_prov->cpt_priority))
+ goto invalid_args;
+ } else {
+ p2ps_prov->cpt_priority[0] = P2PS_FEATURE_CAPAB_UDP_TRANSPORT;
+ }
+
+ for (i = 0; p2ps_prov->cpt_priority[i]; i++)
+ p2ps_prov->cpt_mask |= p2ps_prov->cpt_priority[i];
+
/* force conncap with tstCap (no sanity checks) */
pos = os_strstr(cmd, "tstCap=");
if (pos) {
@@ -4721,6 +4841,8 @@ static int p2p_ctrl_asp_provision(struct wpa_supplicant *wpa_s, char *cmd)
if (!p2ps_prov)
return -1;
+ p2ps_prov->pd_seeker = 1;
+
return wpas_p2p_prov_disc(wpa_s, addr, NULL, WPAS_P2P_PD_FOR_ASP,
p2ps_prov);
}
@@ -5140,6 +5262,8 @@ static int p2p_ctrl_service_add_asp(struct wpa_supplicant *wpa_s,
char *adv_str;
u32 auto_accept, adv_id, svc_state, config_methods;
char *svc_info = NULL;
+ char *cpt_prio_str;
+ u8 cpt_prio[P2PS_FEATURE_CAPAB_CPT_MAX + 1];
pos = os_strchr(cmd, ' ');
if (pos == NULL)
@@ -5212,6 +5336,19 @@ static int p2p_ctrl_service_add_asp(struct wpa_supplicant *wpa_s,
if (pos != NULL)
*pos++ = '\0';
+ cpt_prio_str = (pos && pos[0]) ? os_strstr(pos, "cpt=") : NULL;
+ if (cpt_prio_str) {
+ pos = os_strchr(pos, ' ');
+ if (pos != NULL)
+ *pos++ = '\0';
+
+ if (p2ps_ctrl_parse_cpt_priority(cpt_prio_str + 4, cpt_prio))
+ return -1;
+ } else {
+ cpt_prio[0] = P2PS_FEATURE_CAPAB_UDP_TRANSPORT;
+ cpt_prio[1] = 0;
+ }
+
/* Service and Response Information are optional */
if (pos && pos[0]) {
size_t len;
@@ -5229,7 +5366,7 @@ static int p2p_ctrl_service_add_asp(struct wpa_supplicant *wpa_s,
return wpas_p2p_service_add_asp(wpa_s, auto_accept, adv_id, adv_str,
(u8) svc_state, (u16) config_methods,
- svc_info);
+ svc_info, cpt_prio);
}
@@ -5299,6 +5436,11 @@ static int p2p_ctrl_service_del_asp(struct wpa_supplicant *wpa_s, char *cmd)
{
u32 adv_id;
+ if (os_strcmp(cmd, "all") == 0) {
+ wpas_p2p_service_flush_asp(wpa_s);
+ return 0;
+ }
+
if (sscanf(cmd, "%x", &adv_id) != 1)
return -1;
@@ -5449,13 +5591,10 @@ static int p2p_ctrl_invite(struct wpa_supplicant *wpa_s, char *cmd)
static int p2p_ctrl_group_add_persistent(struct wpa_supplicant *wpa_s,
- char *cmd, int freq, int ht40,
- int vht)
+ int id, int freq, int ht40, int vht)
{
- int id;
struct wpa_ssid *ssid;
- id = atoi(cmd);
ssid = wpa_config_get_network(wpa_s->conf, id);
if (ssid == NULL || ssid->disabled != 2) {
wpa_printf(MSG_DEBUG, "CTRL_IFACE: Could not find SSID id=%d "
@@ -5465,37 +5604,41 @@ static int p2p_ctrl_group_add_persistent(struct wpa_supplicant *wpa_s,
}
return wpas_p2p_group_add_persistent(wpa_s, ssid, 0, freq, 0, ht40, vht,
- NULL, 0);
+ NULL, 0, 0);
}
static int p2p_ctrl_group_add(struct wpa_supplicant *wpa_s, char *cmd)
{
- int freq = 0, ht40, vht;
- char *pos;
+ int freq = 0, persistent = 0, group_id = -1;
+ int vht = wpa_s->conf->p2p_go_vht;
+ int ht40 = wpa_s->conf->p2p_go_ht40 || vht;
+ char *token, *context = NULL;
- pos = os_strstr(cmd, "freq=");
- if (pos)
- freq = atoi(pos + 5);
+ while ((token = str_token(cmd, " ", &context))) {
+ if (sscanf(token, "freq=%d", &freq) == 1 ||
+ sscanf(token, "persistent=%d", &group_id) == 1) {
+ continue;
+ } else if (os_strcmp(token, "ht40") == 0) {
+ ht40 = 1;
+ } else if (os_strcmp(token, "vht") == 0) {
+ vht = 1;
+ ht40 = 1;
+ } else if (os_strcmp(token, "persistent") == 0) {
+ persistent = 1;
+ } else {
+ wpa_printf(MSG_DEBUG,
+ "CTRL: Invalid P2P_GROUP_ADD parameter: '%s'",
+ token);
+ return -1;
+ }
+ }
- vht = (os_strstr(cmd, "vht") != NULL) || wpa_s->conf->p2p_go_vht;
- ht40 = (os_strstr(cmd, "ht40") != NULL) || wpa_s->conf->p2p_go_ht40 ||
- vht;
+ if (group_id >= 0)
+ return p2p_ctrl_group_add_persistent(wpa_s, group_id,
+ freq, ht40, vht);
- if (os_strncmp(cmd, "persistent=", 11) == 0)
- return p2p_ctrl_group_add_persistent(wpa_s, cmd + 11, freq,
- ht40, vht);
- if (os_strcmp(cmd, "persistent") == 0 ||
- os_strncmp(cmd, "persistent ", 11) == 0)
- return wpas_p2p_group_add(wpa_s, 1, freq, ht40, vht);
- if (os_strncmp(cmd, "freq=", 5) == 0)
- return wpas_p2p_group_add(wpa_s, 0, freq, ht40, vht);
- if (ht40)
- return wpas_p2p_group_add(wpa_s, 0, freq, ht40, vht);
-
- wpa_printf(MSG_DEBUG, "CTRL: Invalid P2P_GROUP_ADD parameters '%s'",
- cmd);
- return -1;
+ return wpas_p2p_group_add(wpa_s, persistent, freq, ht40, vht);
}
@@ -5625,7 +5768,7 @@ static int p2p_ctrl_disallow_freq(struct wpa_supplicant *wpa_s,
freq->min, freq->max);
}
- wpas_p2p_update_channel_list(wpa_s);
+ wpas_p2p_update_channel_list(wpa_s, WPAS_P2P_CHANNEL_UPDATE_DISALLOW);
return 0;
}
@@ -5842,6 +5985,7 @@ static void p2p_ctrl_flush(struct wpa_supplicant *wpa_s)
os_memset(wpa_s->p2p_auth_invite, 0, ETH_ALEN);
wpa_s->force_long_sd = 0;
wpas_p2p_stop_find(wpa_s);
+ wpa_s->parent->p2ps_method_config_any = 0;
if (wpa_s->global->p2p)
p2p_flush(wpa_s->global->p2p);
}
@@ -6476,6 +6620,61 @@ static int wpa_supplicant_signal_poll(struct wpa_supplicant *wpa_s, char *buf,
pos += ret;
}
+ if (si.avg_beacon_signal) {
+ ret = os_snprintf(pos, end - pos,
+ "AVG_BEACON_RSSI=%d\n", si.avg_beacon_signal);
+ if (os_snprintf_error(end - pos, ret))
+ return -1;
+ pos += ret;
+ }
+
+ return pos - buf;
+}
+
+
+static int wpas_ctrl_iface_get_pref_freq_list(
+ struct wpa_supplicant *wpa_s, char *cmd, char *buf, size_t buflen)
+{
+ unsigned int freq_list[100], num = 100, i;
+ int ret;
+ enum wpa_driver_if_type iface_type;
+ char *pos, *end;
+
+ pos = buf;
+ end = buf + buflen;
+
+ /* buf: "<interface_type>" */
+ if (os_strcmp(cmd, "STATION") == 0)
+ iface_type = WPA_IF_STATION;
+ else if (os_strcmp(cmd, "AP") == 0)
+ iface_type = WPA_IF_AP_BSS;
+ else if (os_strcmp(cmd, "P2P_GO") == 0)
+ iface_type = WPA_IF_P2P_GO;
+ else if (os_strcmp(cmd, "P2P_CLIENT") == 0)
+ iface_type = WPA_IF_P2P_CLIENT;
+ else if (os_strcmp(cmd, "IBSS") == 0)
+ iface_type = WPA_IF_IBSS;
+ else if (os_strcmp(cmd, "TDLS") == 0)
+ iface_type = WPA_IF_TDLS;
+ else
+ return -1;
+
+ wpa_printf(MSG_DEBUG,
+ "CTRL_IFACE: GET_PREF_FREQ_LIST iface_type=%d (%s)",
+ iface_type, buf);
+
+ ret = wpa_drv_get_pref_freq_list(wpa_s, iface_type, &num, freq_list);
+ if (ret)
+ return -1;
+
+ for (i = 0; i < num; i++) {
+ ret = os_snprintf(pos, end - pos, "%s%u",
+ i > 0 ? "," : "", freq_list[i]);
+ if (os_snprintf_error(end - pos, ret))
+ return -1;
+ pos += ret;
+ }
+
return pos - buf;
}
@@ -6602,6 +6801,7 @@ static void wpa_supplicant_ctrl_iface_flush(struct wpa_supplicant *wpa_s)
p2p_wpa_s->p2p_disable_ip_addr_req = 0;
os_free(p2p_wpa_s->global->p2p_go_avoid_freq.range);
p2p_wpa_s->global->p2p_go_avoid_freq.range = NULL;
+ p2p_wpa_s->global->p2p_go_avoid_freq.num = 0;
p2p_wpa_s->global->pending_p2ps_group = 0;
#endif /* CONFIG_P2P */
@@ -6689,6 +6889,8 @@ static void wpa_supplicant_ctrl_iface_flush(struct wpa_supplicant *wpa_s)
MAC2STR(wpa_s->bssid),
MAC2STR(wpa_s->pending_bssid));
}
+
+ eloop_cancel_timeout(wpas_network_reenabled, wpa_s, NULL);
}
@@ -6922,6 +7124,8 @@ static void wpas_ctrl_scan(struct wpa_supplicant *wpa_s, char *params,
void (*scan_res_handler)(struct wpa_supplicant *wpa_s,
struct wpa_scan_results *scan_res);
int *manual_scan_freqs = NULL;
+ struct wpa_ssid_value *ssid = NULL, *ns;
+ unsigned int ssid_count = 0;
if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
*reply_len = -1;
@@ -6935,6 +7139,15 @@ static void wpas_ctrl_scan(struct wpa_supplicant *wpa_s, char *params,
return;
}
+#ifdef CONFIG_INTERWORKING
+ if (wpa_s->fetch_anqp_in_progress || wpa_s->network_select) {
+ wpa_printf(MSG_DEBUG,
+ "Interworking select in progress - reject new scan");
+ *reply_len = os_snprintf(reply, reply_size, "FAIL-BUSY\n");
+ return;
+ }
+#endif /* CONFIG_INTERWORKING */
+
if (params) {
if (os_strncasecmp(params, "TYPE=ONLY", 9) == 0)
scan_only = 1;
@@ -6967,6 +7180,60 @@ static void wpas_ctrl_scan(struct wpa_supplicant *wpa_s, char *params,
*reply_len = -1;
goto done;
}
+
+ pos = params;
+ while (pos && *pos != '\0') {
+ if (os_strncmp(pos, "ssid ", 5) == 0) {
+ char *end;
+
+ pos += 5;
+ end = pos;
+ while (*end) {
+ if (*end == '\0' || *end == ' ')
+ break;
+ end++;
+ }
+
+ ns = os_realloc_array(
+ ssid, ssid_count + 1,
+ sizeof(struct wpa_ssid_value));
+ if (ns == NULL) {
+ *reply_len = -1;
+ goto done;
+ }
+ ssid = ns;
+
+ if ((end - pos) & 0x01 ||
+ end - pos > 2 * SSID_MAX_LEN ||
+ hexstr2bin(pos, ssid[ssid_count].ssid,
+ (end - pos) / 2) < 0) {
+ wpa_printf(MSG_DEBUG,
+ "Invalid SSID value '%s'",
+ pos);
+ *reply_len = -1;
+ goto done;
+ }
+ ssid[ssid_count].ssid_len = (end - pos) / 2;
+ wpa_hexdump_ascii(MSG_DEBUG, "scan SSID",
+ ssid[ssid_count].ssid,
+ ssid[ssid_count].ssid_len);
+ ssid_count++;
+ pos = end;
+ }
+
+ pos = os_strchr(pos, ' ');
+ if (pos)
+ pos++;
+ }
+ }
+
+ wpa_s->num_ssids_from_scan_req = ssid_count;
+ os_free(wpa_s->ssids_from_scan_req);
+ if (ssid_count) {
+ wpa_s->ssids_from_scan_req = ssid;
+ ssid = NULL;
+ } else {
+ wpa_s->ssids_from_scan_req = NULL;
}
if (scan_only)
@@ -7030,6 +7297,7 @@ static void wpas_ctrl_scan(struct wpa_supplicant *wpa_s, char *params,
done:
os_free(manual_scan_freqs);
+ os_free(ssid);
}
@@ -7231,7 +7499,7 @@ void wpas_data_test_rx(void *ctx, const u8 *src_addr, const u8 *buf, size_t len)
{
struct wpa_supplicant *wpa_s = ctx;
const struct ether_header *eth;
- const struct iphdr *ip;
+ struct iphdr ip;
const u8 *pos;
unsigned int i;
@@ -7239,14 +7507,14 @@ void wpas_data_test_rx(void *ctx, const u8 *src_addr, const u8 *buf, size_t len)
return;
eth = (const struct ether_header *) buf;
- ip = (const struct iphdr *) (eth + 1);
- pos = (const u8 *) (ip + 1);
+ os_memcpy(&ip, eth + 1, sizeof(ip));
+ pos = &buf[sizeof(*eth) + sizeof(ip)];
- if (ip->ihl != 5 || ip->version != 4 ||
- ntohs(ip->tot_len) != HWSIM_IP_LEN)
+ if (ip.ihl != 5 || ip.version != 4 ||
+ ntohs(ip.tot_len) != HWSIM_IP_LEN)
return;
- for (i = 0; i < HWSIM_IP_LEN - sizeof(*ip); i++) {
+ for (i = 0; i < HWSIM_IP_LEN - sizeof(ip); i++) {
if (*pos != (u8) i)
return;
pos++;
@@ -7293,7 +7561,7 @@ static int wpas_ctrl_iface_data_test_tx(struct wpa_supplicant *wpa_s, char *cmd)
int used;
long int val;
u8 tos;
- u8 buf[HWSIM_PACKETLEN];
+ u8 buf[2 + HWSIM_PACKETLEN];
struct ether_header *eth;
struct iphdr *ip;
u8 *dpos;
@@ -7321,7 +7589,7 @@ static int wpas_ctrl_iface_data_test_tx(struct wpa_supplicant *wpa_s, char *cmd)
return -1;
tos = val;
- eth = (struct ether_header *) buf;
+ eth = (struct ether_header *) &buf[2];
os_memcpy(eth->ether_dhost, dst, ETH_ALEN);
os_memcpy(eth->ether_shost, src, ETH_ALEN);
eth->ether_type = htons(ETHERTYPE_IP);
@@ -7333,14 +7601,14 @@ static int wpas_ctrl_iface_data_test_tx(struct wpa_supplicant *wpa_s, char *cmd)
ip->tos = tos;
ip->tot_len = htons(HWSIM_IP_LEN);
ip->protocol = 1;
- ip->saddr = htonl(192 << 24 | 168 << 16 | 1 << 8 | 1);
- ip->daddr = htonl(192 << 24 | 168 << 16 | 1 << 8 | 2);
+ ip->saddr = htonl(192U << 24 | 168 << 16 | 1 << 8 | 1);
+ ip->daddr = htonl(192U << 24 | 168 << 16 | 1 << 8 | 2);
ip->check = ipv4_hdr_checksum(ip, sizeof(*ip));
dpos = (u8 *) (ip + 1);
for (i = 0; i < HWSIM_IP_LEN - sizeof(*ip); i++)
*dpos++ = i;
- if (l2_packet_send(wpa_s->l2_test, dst, ETHERTYPE_IP, buf,
+ if (l2_packet_send(wpa_s->l2_test, dst, ETHERTYPE_IP, &buf[2],
HWSIM_PACKETLEN) < 0)
return -1;
@@ -7429,6 +7697,44 @@ static int wpas_ctrl_get_alloc_fail(struct wpa_supplicant *wpa_s,
#endif /* WPA_TRACE_BFD */
}
+
+static int wpas_ctrl_test_fail(struct wpa_supplicant *wpa_s, char *cmd)
+{
+#ifdef WPA_TRACE_BFD
+ extern char wpa_trace_test_fail_func[256];
+ extern unsigned int wpa_trace_test_fail_after;
+ char *pos;
+
+ wpa_trace_test_fail_after = atoi(cmd);
+ pos = os_strchr(cmd, ':');
+ if (pos) {
+ pos++;
+ os_strlcpy(wpa_trace_test_fail_func, pos,
+ sizeof(wpa_trace_test_fail_func));
+ } else {
+ wpa_trace_test_fail_after = 0;
+ }
+ return 0;
+#else /* WPA_TRACE_BFD */
+ return -1;
+#endif /* WPA_TRACE_BFD */
+}
+
+
+static int wpas_ctrl_get_fail(struct wpa_supplicant *wpa_s,
+ char *buf, size_t buflen)
+{
+#ifdef WPA_TRACE_BFD
+ extern char wpa_trace_test_fail_func[256];
+ extern unsigned int wpa_trace_test_fail_after;
+
+ return os_snprintf(buf, buflen, "%u:%s", wpa_trace_test_fail_after,
+ wpa_trace_test_fail_func);
+#else /* WPA_TRACE_BFD */
+ return -1;
+#endif /* WPA_TRACE_BFD */
+}
+
#endif /* CONFIG_TESTING_OPTIONS */
@@ -7665,7 +7971,7 @@ static int wpas_ctrl_iface_send_neigbor_rep(struct wpa_supplicant *wpa_s,
if (os_strncmp(cmd, " ssid=", 6) == 0) {
ssid.ssid_len = os_strlen(cmd + 6);
- if (ssid.ssid_len > 32)
+ if (ssid.ssid_len > SSID_MAX_LEN)
return -1;
ssid.ssid = (u8 *) (cmd + 6);
ssid_p = &ssid;
@@ -7806,6 +8112,19 @@ static int wpas_ctrl_iface_mac_rand_scan(struct wpa_supplicant *wpa_s,
}
+static int wpas_ctrl_cmd_debug_level(const char *cmd)
+{
+ if (os_strcmp(cmd, "PING") == 0 ||
+ os_strncmp(cmd, "BSS ", 4) == 0 ||
+ os_strncmp(cmd, "GET_NETWORK ", 12) == 0 ||
+ os_strncmp(cmd, "STATUS", 6) == 0 ||
+ os_strncmp(cmd, "STA ", 4) == 0 ||
+ os_strncmp(cmd, "STA-", 4) == 0)
+ return MSG_EXCESSIVE;
+ return MSG_DEBUG;
+}
+
+
char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
char *buf, size_t *resp_len)
{
@@ -7829,9 +8148,7 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
wpa_hexdump_ascii_key(MSG_DEBUG, "RX ctrl_iface",
(const u8 *) buf, os_strlen(buf));
} else {
- int level = MSG_DEBUG;
- if (os_strcmp(buf, "PING") == 0)
- level = MSG_EXCESSIVE;
+ int level = wpas_ctrl_cmd_debug_level(buf);
wpa_dbg(wpa_s, level, "Control interface command '%s'", buf);
}
@@ -8066,7 +8383,7 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
if (wpas_p2p_group_remove(wpa_s, buf + 17))
reply_len = -1;
} else if (os_strcmp(buf, "P2P_GROUP_ADD") == 0) {
- if (wpas_p2p_group_add(wpa_s, 0, 0, 0, 0))
+ if (p2p_ctrl_group_add(wpa_s, ""))
reply_len = -1;
} else if (os_strncmp(buf, "P2P_GROUP_ADD ", 14) == 0) {
if (p2p_ctrl_group_add(wpa_s, buf + 14))
@@ -8240,6 +8557,7 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
wpa_supplicant_cancel_scan(wpa_s);
wpa_supplicant_deauthenticate(wpa_s,
WLAN_REASON_DEAUTH_LEAVING);
+ eloop_cancel_timeout(wpas_network_reenabled, wpa_s, NULL);
} else if (os_strcmp(buf, "SCAN") == 0) {
wpas_ctrl_scan(wpa_s, NULL, reply, reply_size, &reply_len);
} else if (os_strncmp(buf, "SCAN ", 5) == 0) {
@@ -8269,7 +8587,8 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
reply_len = wpa_supplicant_ctrl_iface_get_network(
wpa_s, buf + 12, reply, reply_size);
} else if (os_strncmp(buf, "DUP_NETWORK ", 12) == 0) {
- if (wpa_supplicant_ctrl_iface_dup_network(wpa_s, buf + 12))
+ if (wpa_supplicant_ctrl_iface_dup_network(wpa_s, buf + 12,
+ wpa_s))
reply_len = -1;
} else if (os_strcmp(buf, "LIST_CREDS") == 0) {
reply_len = wpa_supplicant_ctrl_iface_list_creds(
@@ -8372,6 +8691,9 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
if (wpa_supplicant_ctrl_iface_tdls_cancel_chan_switch(wpa_s,
buf + 24))
reply_len = -1;
+ } else if (os_strncmp(buf, "TDLS_LINK_STATUS ", 17) == 0) {
+ reply_len = wpa_supplicant_ctrl_iface_tdls_link_status(
+ wpa_s, buf + 17, reply, reply_size);
#endif /* CONFIG_TDLS */
} else if (os_strcmp(buf, "WMM_AC_STATUS") == 0) {
reply_len = wpas_wmm_ac_status(wpa_s, reply, reply_size);
@@ -8442,6 +8764,11 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
reply_len = -1;
} else if (os_strcmp(buf, "GET_ALLOC_FAIL") == 0) {
reply_len = wpas_ctrl_get_alloc_fail(wpa_s, reply, reply_size);
+ } else if (os_strncmp(buf, "TEST_FAIL ", 10) == 0) {
+ if (wpas_ctrl_test_fail(wpa_s, buf + 10) < 0)
+ reply_len = -1;
+ } else if (os_strcmp(buf, "GET_FAIL") == 0) {
+ reply_len = wpas_ctrl_get_fail(wpa_s, reply, reply_size);
#endif /* CONFIG_TESTING_OPTIONS */
} else if (os_strncmp(buf, "VENDOR_ELEM_ADD ", 16) == 0) {
if (wpas_ctrl_vendor_elem_add(wpa_s, buf + 16) < 0)
@@ -8460,6 +8787,9 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
} else if (os_strncmp(buf, "MAC_RAND_SCAN ", 14) == 0) {
if (wpas_ctrl_iface_mac_rand_scan(wpa_s, buf + 14))
reply_len = -1;
+ } else if (os_strncmp(buf, "GET_PREF_FREQ_LIST ", 19) == 0) {
+ reply_len = wpas_ctrl_iface_get_pref_freq_list(
+ wpa_s, buf + 19, reply, reply_size);
} else {
os_memcpy(reply, "UNKNOWN COMMAND\n", 16);
reply_len = 16;
@@ -8479,11 +8809,14 @@ static int wpa_supplicant_global_iface_add(struct wpa_global *global,
char *cmd)
{
struct wpa_interface iface;
- char *pos;
+ char *pos, *extra;
+ struct wpa_supplicant *wpa_s;
+ unsigned int create_iface = 0;
+ u8 mac_addr[ETH_ALEN];
/*
* <ifname>TAB<confname>TAB<driver>TAB<ctrl_interface>TAB<driver_param>
- * TAB<bridge_ifname>
+ * TAB<bridge_ifname>[TAB<create>]
*/
wpa_printf(MSG_DEBUG, "CTRL_IFACE GLOBAL INTERFACE_ADD '%s'", cmd);
@@ -8543,12 +8876,54 @@ static int wpa_supplicant_global_iface_add(struct wpa_global *global,
iface.bridge_ifname = NULL;
if (pos == NULL)
break;
+
+ extra = pos;
+ pos = os_strchr(pos, '\t');
+ if (pos)
+ *pos++ = '\0';
+ if (!extra[0])
+ break;
+
+ if (os_strcmp(extra, "create") == 0)
+ create_iface = 1;
+ else {
+ wpa_printf(MSG_DEBUG,
+ "INTERFACE_ADD unsupported extra parameter: '%s'",
+ extra);
+ return -1;
+ }
} while (0);
+ if (create_iface) {
+ wpa_printf(MSG_DEBUG, "CTRL_IFACE creating interface '%s'",
+ iface.ifname);
+ if (!global->ifaces)
+ return -1;
+ if (wpa_drv_if_add(global->ifaces, WPA_IF_STATION, iface.ifname,
+ NULL, NULL, NULL, mac_addr, NULL) < 0) {
+ wpa_printf(MSG_ERROR,
+ "CTRL_IFACE interface creation failed");
+ return -1;
+ }
+
+ wpa_printf(MSG_DEBUG,
+ "CTRL_IFACE interface '%s' created with MAC addr: "
+ MACSTR, iface.ifname, MAC2STR(mac_addr));
+ }
+
if (wpa_supplicant_get_iface(global, iface.ifname))
- return -1;
+ goto fail;
+
+ wpa_s = wpa_supplicant_add_iface(global, &iface, NULL);
+ if (!wpa_s)
+ goto fail;
+ wpa_s->added_vif = create_iface;
+ return 0;
- return wpa_supplicant_add_iface(global, &iface, NULL) ? 0 : -1;
+fail:
+ if (create_iface)
+ wpa_drv_if_remove(global->ifaces, WPA_IF_STATION, iface.ifname);
+ return -1;
}
@@ -8556,13 +8931,22 @@ static int wpa_supplicant_global_iface_remove(struct wpa_global *global,
char *cmd)
{
struct wpa_supplicant *wpa_s;
+ int ret;
+ unsigned int delete_iface;
wpa_printf(MSG_DEBUG, "CTRL_IFACE GLOBAL INTERFACE_REMOVE '%s'", cmd);
wpa_s = wpa_supplicant_get_iface(global, cmd);
if (wpa_s == NULL)
return -1;
- return wpa_supplicant_remove_iface(global, wpa_s, 0);
+ delete_iface = wpa_s->added_vif;
+ ret = wpa_supplicant_remove_iface(global, wpa_s, 0);
+ if (!ret && delete_iface) {
+ wpa_printf(MSG_DEBUG, "CTRL_IFACE deleting the interface '%s'",
+ cmd);
+ ret = wpa_drv_if_remove(global->ifaces, WPA_IF_STATION, cmd);
+ }
+ return ret;
}
@@ -8589,7 +8973,7 @@ static int wpa_supplicant_global_iface_list(struct wpa_global *global,
char *pos, *end;
for (i = 0; wpa_drivers[i]; i++) {
- struct wpa_driver_ops *drv = wpa_drivers[i];
+ const struct wpa_driver_ops *drv = wpa_drivers[i];
if (drv->get_interfaces == NULL)
continue;
tmp = drv->get_interfaces(global->drv_priv[i]);
@@ -8807,6 +9191,41 @@ static int wpas_global_ctrl_iface_set(struct wpa_global *global, char *cmd)
}
+static int wpas_global_ctrl_iface_dup_network(struct wpa_global *global,
+ char *cmd)
+{
+ struct wpa_supplicant *wpa_s[2]; /* src, dst */
+ char *p;
+ unsigned int i;
+
+ /* cmd: "<src ifname> <dst ifname> <src network id> <dst network id>
+ * <variable name> */
+
+ for (i = 0; i < ARRAY_SIZE(wpa_s) ; i++) {
+ p = os_strchr(cmd, ' ');
+ if (p == NULL)
+ return -1;
+ *p = '\0';
+
+ wpa_s[i] = global->ifaces;
+ for (; wpa_s[i]; wpa_s[i] = wpa_s[i]->next) {
+ if (os_strcmp(cmd, wpa_s[i]->ifname) == 0)
+ break;
+ }
+
+ if (!wpa_s[i]) {
+ wpa_printf(MSG_DEBUG,
+ "CTRL_IFACE: Could not find iface=%s", cmd);
+ return -1;
+ }
+
+ cmd = p + 1;
+ }
+
+ return wpa_supplicant_ctrl_iface_dup_network(wpa_s[0], cmd, wpa_s[1]);
+}
+
+
#ifndef CONFIG_NO_CONFIG_WRITE
static int wpas_global_ctrl_iface_save_config(struct wpa_global *global)
{
@@ -8888,6 +9307,59 @@ static int wpas_global_ctrl_iface_status(struct wpa_global *global,
}
+#ifdef CONFIG_FST
+
+static int wpas_global_ctrl_iface_fst_attach(struct wpa_global *global,
+ char *cmd, char *buf,
+ size_t reply_size)
+{
+ char ifname[IFNAMSIZ + 1];
+ struct fst_iface_cfg cfg;
+ struct wpa_supplicant *wpa_s;
+ struct fst_wpa_obj iface_obj;
+
+ if (!fst_parse_attach_command(cmd, ifname, sizeof(ifname), &cfg)) {
+ wpa_s = wpa_supplicant_get_iface(global, ifname);
+ if (wpa_s) {
+ if (wpa_s->fst) {
+ wpa_printf(MSG_INFO, "FST: Already attached");
+ return -1;
+ }
+ fst_wpa_supplicant_fill_iface_obj(wpa_s, &iface_obj);
+ wpa_s->fst = fst_attach(ifname, wpa_s->own_addr,
+ &iface_obj, &cfg);
+ if (wpa_s->fst)
+ return os_snprintf(buf, reply_size, "OK\n");
+ }
+ }
+
+ return -1;
+}
+
+
+static int wpas_global_ctrl_iface_fst_detach(struct wpa_global *global,
+ char *cmd, char *buf,
+ size_t reply_size)
+{
+ char ifname[IFNAMSIZ + 1];
+ struct wpa_supplicant *wpa_s;
+
+ if (!fst_parse_detach_command(cmd, ifname, sizeof(ifname))) {
+ wpa_s = wpa_supplicant_get_iface(global, ifname);
+ if (wpa_s) {
+ if (!fst_iface_detach(ifname)) {
+ wpa_s->fst = NULL;
+ return os_snprintf(buf, reply_size, "OK\n");
+ }
+ }
+ }
+
+ return -1;
+}
+
+#endif /* CONFIG_FST */
+
+
char * wpa_supplicant_global_ctrl_iface_process(struct wpa_global *global,
char *buf, size_t *resp_len)
{
@@ -8939,6 +9411,18 @@ char * wpa_supplicant_global_ctrl_iface_process(struct wpa_global *global,
} else if (os_strcmp(buf, "INTERFACES") == 0) {
reply_len = wpa_supplicant_global_iface_interfaces(
global, reply, reply_size);
+#ifdef CONFIG_FST
+ } else if (os_strncmp(buf, "FST-ATTACH ", 11) == 0) {
+ reply_len = wpas_global_ctrl_iface_fst_attach(global, buf + 11,
+ reply,
+ reply_size);
+ } else if (os_strncmp(buf, "FST-DETACH ", 11) == 0) {
+ reply_len = wpas_global_ctrl_iface_fst_detach(global, buf + 11,
+ reply,
+ reply_size);
+ } else if (os_strncmp(buf, "FST-MANAGER ", 12) == 0) {
+ reply_len = fst_ctrl_iface_receive(buf + 12, reply, reply_size);
+#endif /* CONFIG_FST */
} else if (os_strcmp(buf, "TERMINATE") == 0) {
wpa_supplicant_terminate_proc(global);
} else if (os_strcmp(buf, "SUSPEND") == 0) {
@@ -8959,6 +9443,9 @@ char * wpa_supplicant_global_ctrl_iface_process(struct wpa_global *global,
#endif /* CONFIG_P2P */
reply_len = -1;
}
+ } else if (os_strncmp(buf, "DUP_NETWORK ", 12) == 0) {
+ if (wpas_global_ctrl_iface_dup_network(global, buf + 12))
+ reply_len = -1;
#ifndef CONFIG_NO_CONFIG_WRITE
} else if (os_strcmp(buf, "SAVE_CONFIG") == 0) {
if (wpas_global_ctrl_iface_save_config(global))
diff --git a/wpa_supplicant/ctrl_iface_named_pipe.c b/wpa_supplicant/ctrl_iface_named_pipe.c
index dc02db2..54e0e2f 100644
--- a/wpa_supplicant/ctrl_iface_named_pipe.c
+++ b/wpa_supplicant/ctrl_iface_named_pipe.c
@@ -423,7 +423,8 @@ static int ctrl_iface_parse(struct ctrl_iface_priv *priv, const char *params)
}
-static void wpa_supplicant_ctrl_iface_msg_cb(void *ctx, int level, int global,
+static void wpa_supplicant_ctrl_iface_msg_cb(void *ctx, int level,
+ enum wpa_msg_type type,
const char *txt, size_t len)
{
struct wpa_supplicant *wpa_s = ctx;
diff --git a/wpa_supplicant/ctrl_iface_udp.c b/wpa_supplicant/ctrl_iface_udp.c
index bf6a3df..76f69f2 100644
--- a/wpa_supplicant/ctrl_iface_udp.c
+++ b/wpa_supplicant/ctrl_iface_udp.c
@@ -322,7 +322,8 @@ static void wpa_supplicant_ctrl_iface_receive(int sock, void *eloop_ctx,
}
-static void wpa_supplicant_ctrl_iface_msg_cb(void *ctx, int level, int global,
+static void wpa_supplicant_ctrl_iface_msg_cb(void *ctx, int level,
+ enum wpa_msg_type type,
const char *txt, size_t len)
{
struct wpa_supplicant *wpa_s = ctx;
diff --git a/wpa_supplicant/ctrl_iface_unix.c b/wpa_supplicant/ctrl_iface_unix.c
index b1ac766..11f2814 100644
--- a/wpa_supplicant/ctrl_iface_unix.c
+++ b/wpa_supplicant/ctrl_iface_unix.c
@@ -13,6 +13,10 @@
#include <stddef.h>
#include <unistd.h>
#include <fcntl.h>
+#ifdef __linux__
+#include <sys/ioctl.h>
+#include <linux/sockios.h>
+#endif /* __linux__ */
#ifdef ANDROID
#include <cutils/sockets.h>
#endif /* ANDROID */
@@ -72,6 +76,32 @@ static int wpas_ctrl_iface_global_reinit(struct wpa_global *global,
struct ctrl_iface_global_priv *priv);
+static void wpas_ctrl_sock_debug(const char *title, int sock, const char *buf,
+ size_t len)
+{
+#ifdef __linux__
+ socklen_t optlen;
+ int sndbuf, outq;
+ int level = MSG_MSGDUMP;
+
+ if (len >= 5 && os_strncmp(buf, "PONG\n", 5) == 0)
+ level = MSG_EXCESSIVE;
+
+ optlen = sizeof(sndbuf);
+ sndbuf = 0;
+ if (getsockopt(sock, SOL_SOCKET, SO_SNDBUF, &sndbuf, &optlen) < 0)
+ sndbuf = -1;
+
+ if (ioctl(sock, SIOCOUTQ, &outq) < 0)
+ outq = -1;
+
+ wpa_printf(level,
+ "CTRL-DEBUG: %s: sock=%d sndbuf=%d outq=%d send_len=%d",
+ title, sock, sndbuf, outq, (int) len);
+#endif /* __linux__ */
+}
+
+
static int wpa_supplicant_ctrl_iface_attach(struct dl_list *ctrl_dst,
struct sockaddr_un *from,
socklen_t fromlen, int global)
@@ -197,6 +227,13 @@ static void wpa_supplicant_ctrl_iface_receive(int sock, void *eloop_ctx,
reply_buf = wpa_supplicant_ctrl_iface_process(wpa_s, buf,
&reply_len);
reply = reply_buf;
+
+ /*
+ * There could be some password/key material in the command, so
+ * clear the buffer explicitly now that it is not needed
+ * anymore.
+ */
+ os_memset(buf, 0, res);
}
if (!reply && reply_len == 1) {
@@ -208,6 +245,8 @@ static void wpa_supplicant_ctrl_iface_receive(int sock, void *eloop_ctx,
}
if (reply) {
+ wpas_ctrl_sock_debug("ctrl_sock-sendto", sock, reply,
+ reply_len);
if (sendto(sock, reply, reply_len, 0, (struct sockaddr *) &from,
fromlen) < 0) {
int _errno = errno;
@@ -295,7 +334,8 @@ static char * wpa_supplicant_ctrl_iface_path(struct wpa_supplicant *wpa_s)
}
-static void wpa_supplicant_ctrl_iface_msg_cb(void *ctx, int level, int global,
+static void wpa_supplicant_ctrl_iface_msg_cb(void *ctx, int level,
+ enum wpa_msg_type type,
const char *txt, size_t len)
{
struct wpa_supplicant *wpa_s = ctx;
@@ -303,19 +343,19 @@ static void wpa_supplicant_ctrl_iface_msg_cb(void *ctx, int level, int global,
if (wpa_s == NULL)
return;
- if (global != 2 && wpa_s->global->ctrl_iface) {
+ if (type != WPA_MSG_NO_GLOBAL && wpa_s->global->ctrl_iface) {
struct ctrl_iface_global_priv *priv = wpa_s->global->ctrl_iface;
if (!dl_list_empty(&priv->ctrl_dst)) {
- wpa_supplicant_ctrl_iface_send(wpa_s, global ? NULL :
- wpa_s->ifname,
- priv->sock,
- &priv->ctrl_dst,
- level, txt, len, NULL,
- priv);
+ wpa_supplicant_ctrl_iface_send(
+ wpa_s,
+ type != WPA_MSG_PER_INTERFACE ?
+ NULL : wpa_s->ifname,
+ priv->sock, &priv->ctrl_dst, level, txt, len,
+ NULL, priv);
}
}
- if (wpa_s->ctrl_iface == NULL)
+ if (type == WPA_MSG_ONLY_GLOBAL || wpa_s->ctrl_iface == NULL)
return;
wpa_supplicant_ctrl_iface_send(wpa_s, NULL, wpa_s->ctrl_iface->sock,
&wpa_s->ctrl_iface->ctrl_dst,
@@ -544,6 +584,53 @@ wpa_supplicant_ctrl_iface_init(struct wpa_supplicant *wpa_s)
if (wpa_s->conf->ctrl_interface == NULL)
return priv;
+#ifdef ANDROID
+ if (wpa_s->global->params.ctrl_interface) {
+ int same = 0;
+
+ if (wpa_s->global->params.ctrl_interface[0] == '/') {
+ if (os_strcmp(wpa_s->global->params.ctrl_interface,
+ wpa_s->conf->ctrl_interface) == 0)
+ same = 1;
+ } else if (os_strncmp(wpa_s->global->params.ctrl_interface,
+ "@android:", 9) == 0 ||
+ os_strncmp(wpa_s->global->params.ctrl_interface,
+ "@abstract:", 10) == 0) {
+ char *pos;
+
+ /*
+ * Currently, Android uses @android:wpa_* as the naming
+ * convention for the global ctrl interface. This logic
+ * needs to be revisited if the above naming convention
+ * is modified.
+ */
+ pos = os_strchr(wpa_s->global->params.ctrl_interface,
+ '_');
+ if (pos &&
+ os_strcmp(pos + 1,
+ wpa_s->conf->ctrl_interface) == 0)
+ same = 1;
+ }
+
+ if (same) {
+ /*
+ * The invalid configuration combination might be
+ * possible to hit in an Android OTA upgrade case, so
+ * instead of refusing to start the wpa_supplicant
+ * process, do not open the per-interface ctrl_iface
+ * and continue with the global control interface that
+ * was set from the command line since the Wi-Fi
+ * framework will use it for operations.
+ */
+ wpa_printf(MSG_ERROR,
+ "global ctrl interface %s matches ctrl interface %s - do not open per-interface ctrl interface",
+ wpa_s->global->params.ctrl_interface,
+ wpa_s->conf->ctrl_interface);
+ return priv;
+ }
+ }
+#endif /* ANDROID */
+
if (wpas_ctrl_iface_open_sock(wpa_s, priv) < 0) {
os_free(priv);
return NULL;
@@ -708,8 +795,10 @@ static void wpa_supplicant_ctrl_iface_send(struct wpa_supplicant *wpa_s,
offsetof(struct sockaddr_un, sun_path));
msg.msg_name = (void *) &dst->addr;
msg.msg_namelen = dst->addrlen;
+ wpas_ctrl_sock_debug("ctrl_sock-sendmsg", sock, buf, len);
if (sendmsg(sock, &msg, MSG_DONTWAIT) >= 0) {
- wpa_printf(MSG_DEBUG, "CTRL_IFACE monitor sent successfully to %s",
+ wpa_printf(MSG_MSGDUMP,
+ "CTRL_IFACE monitor sent successfully to %s",
addr_txt);
dst->errors = 0;
continue;
@@ -846,6 +935,13 @@ static void wpa_supplicant_global_ctrl_iface_receive(int sock, void *eloop_ctx,
reply_buf = wpa_supplicant_global_ctrl_iface_process(
global, buf, &reply_len);
reply = reply_buf;
+
+ /*
+ * There could be some password/key material in the command, so
+ * clear the buffer explicitly now that it is not needed
+ * anymore.
+ */
+ os_memset(buf, 0, res);
}
if (!reply && reply_len == 1) {
@@ -857,6 +953,8 @@ static void wpa_supplicant_global_ctrl_iface_receive(int sock, void *eloop_ctx,
}
if (reply) {
+ wpas_ctrl_sock_debug("global_ctrl_sock-sendto",
+ sock, reply, reply_len);
if (sendto(sock, reply, reply_len, 0, (struct sockaddr *) &from,
fromlen) < 0) {
wpa_printf(MSG_DEBUG, "ctrl_iface sendto failed: %s",
diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c
index 30ef03a..67d0e28 100644
--- a/wpa_supplicant/dbus/dbus_new.c
+++ b/wpa_supplicant/dbus/dbus_new.c
@@ -137,7 +137,7 @@ static void wpas_dbus_signal_interface(struct wpa_supplicant *wpa_s,
iface = wpa_s->global->dbus;
/* Do nothing if the control interface is not turned on */
- if (iface == NULL)
+ if (iface == NULL || !wpa_s->dbus_new_path)
return;
msg = dbus_message_new_signal(WPAS_DBUS_NEW_PATH,
@@ -200,7 +200,7 @@ void wpas_dbus_signal_scan_done(struct wpa_supplicant *wpa_s, int success)
iface = wpa_s->global->dbus;
/* Do nothing if the control interface is not turned on */
- if (iface == NULL)
+ if (iface == NULL || !wpa_s->dbus_new_path)
return;
msg = dbus_message_new_signal(wpa_s->dbus_new_path,
@@ -239,7 +239,7 @@ static void wpas_dbus_signal_bss(struct wpa_supplicant *wpa_s,
iface = wpa_s->global->dbus;
/* Do nothing if the control interface is not turned on */
- if (iface == NULL)
+ if (iface == NULL || !wpa_s->dbus_new_path)
return;
msg = dbus_message_new_signal(wpa_s->dbus_new_path,
@@ -307,7 +307,7 @@ static void wpas_dbus_signal_blob(struct wpa_supplicant *wpa_s,
iface = wpa_s->global->dbus;
/* Do nothing if the control interface is not turned on */
- if (iface == NULL)
+ if (iface == NULL || !wpa_s->dbus_new_path)
return;
msg = dbus_message_new_signal(wpa_s->dbus_new_path,
@@ -374,7 +374,7 @@ static void wpas_dbus_signal_network(struct wpa_supplicant *wpa_s,
iface = wpa_s->global->dbus;
/* Do nothing if the control interface is not turned on */
- if (iface == NULL)
+ if (iface == NULL || !wpa_s->dbus_new_path)
return;
os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
@@ -467,7 +467,7 @@ void wpas_dbus_signal_network_request(struct wpa_supplicant *wpa_s,
iface = wpa_s->global->dbus;
/* Do nothing if the control interface is not turned on */
- if (iface == NULL)
+ if (iface == NULL || !wpa_s->dbus_new_path)
return;
field = wpa_supplicant_ctrl_req_to_string(rtype, default_txt, &txt);
@@ -511,6 +511,8 @@ void wpas_dbus_signal_network_enabled_changed(struct wpa_supplicant *wpa_s,
char path[WPAS_DBUS_OBJECT_PATH_MAX];
+ if (!wpa_s->dbus_new_path)
+ return;
os_snprintf(path, WPAS_DBUS_OBJECT_PATH_MAX,
"%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%d",
wpa_s->dbus_new_path, ssid->id);
@@ -523,6 +525,44 @@ void wpas_dbus_signal_network_enabled_changed(struct wpa_supplicant *wpa_s,
#ifdef CONFIG_WPS
/**
+ * wpas_dbus_signal_wps_event_pbc_overlap - Signals PBC overlap WPS event
+ * @wpa_s: %wpa_supplicant network interface data
+ *
+ * Sends Event dbus signal with name "pbc-overlap" and empty dict as arguments
+ */
+void wpas_dbus_signal_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s)
+{
+
+ DBusMessage *msg;
+ DBusMessageIter iter, dict_iter;
+ struct wpas_dbus_priv *iface;
+ char *key = "pbc-overlap";
+
+ iface = wpa_s->global->dbus;
+
+ /* Do nothing if the control interface is not turned on */
+ if (iface == NULL || !wpa_s->dbus_new_path)
+ return;
+
+ msg = dbus_message_new_signal(wpa_s->dbus_new_path,
+ WPAS_DBUS_NEW_IFACE_WPS, "Event");
+ if (msg == NULL)
+ return;
+
+ dbus_message_iter_init_append(msg, &iter);
+
+ if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &key) ||
+ !wpa_dbus_dict_open_write(&iter, &dict_iter) ||
+ !wpa_dbus_dict_close_write(&iter, &dict_iter))
+ wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
+ else
+ dbus_connection_send(iface->con, msg, NULL);
+
+ dbus_message_unref(msg);
+}
+
+
+/**
* wpas_dbus_signal_wps_event_success - Signals Success WPS event
* @wpa_s: %wpa_supplicant network interface data
*
@@ -539,7 +579,7 @@ void wpas_dbus_signal_wps_event_success(struct wpa_supplicant *wpa_s)
iface = wpa_s->global->dbus;
/* Do nothing if the control interface is not turned on */
- if (iface == NULL)
+ if (iface == NULL || !wpa_s->dbus_new_path)
return;
msg = dbus_message_new_signal(wpa_s->dbus_new_path,
@@ -563,6 +603,7 @@ void wpas_dbus_signal_wps_event_success(struct wpa_supplicant *wpa_s)
/**
* wpas_dbus_signal_wps_event_fail - Signals Fail WPS event
* @wpa_s: %wpa_supplicant network interface data
+ * @fail: WPS failure information
*
* Sends Event dbus signal with name "fail" and dictionary containing
* "msg field with fail message number (int32) as arguments
@@ -579,7 +620,7 @@ void wpas_dbus_signal_wps_event_fail(struct wpa_supplicant *wpa_s,
iface = wpa_s->global->dbus;
/* Do nothing if the control interface is not turned on */
- if (iface == NULL)
+ if (iface == NULL || !wpa_s->dbus_new_path)
return;
msg = dbus_message_new_signal(wpa_s->dbus_new_path,
@@ -592,6 +633,10 @@ void wpas_dbus_signal_wps_event_fail(struct wpa_supplicant *wpa_s,
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &key) ||
!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
!wpa_dbus_dict_append_int32(&dict_iter, "msg", fail->msg) ||
+ !wpa_dbus_dict_append_int32(&dict_iter, "config_error",
+ fail->config_error) ||
+ !wpa_dbus_dict_append_int32(&dict_iter, "error_indication",
+ fail->error_indication) ||
!wpa_dbus_dict_close_write(&iter, &dict_iter))
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
else
@@ -604,6 +649,7 @@ void wpas_dbus_signal_wps_event_fail(struct wpa_supplicant *wpa_s,
/**
* wpas_dbus_signal_wps_event_m2d - Signals M2D WPS event
* @wpa_s: %wpa_supplicant network interface data
+ * @m2d: M2D event data information
*
* Sends Event dbus signal with name "m2d" and dictionary containing
* fields of wps_event_m2d structure.
@@ -620,7 +666,7 @@ void wpas_dbus_signal_wps_event_m2d(struct wpa_supplicant *wpa_s,
iface = wpa_s->global->dbus;
/* Do nothing if the control interface is not turned on */
- if (iface == NULL)
+ if (iface == NULL || !wpa_s->dbus_new_path)
return;
msg = dbus_message_new_signal(wpa_s->dbus_new_path,
@@ -669,6 +715,7 @@ void wpas_dbus_signal_wps_event_m2d(struct wpa_supplicant *wpa_s,
/**
* wpas_dbus_signal_wps_cred - Signals new credentials
* @wpa_s: %wpa_supplicant network interface data
+ * @cred: WPS Credential information
*
* Sends signal with credentials in directory argument
*/
@@ -686,7 +733,7 @@ void wpas_dbus_signal_wps_cred(struct wpa_supplicant *wpa_s,
iface = wpa_s->global->dbus;
/* Do nothing if the control interface is not turned on */
- if (iface == NULL)
+ if (iface == NULL || !wpa_s->dbus_new_path)
return;
msg = dbus_message_new_signal(wpa_s->dbus_new_path,
@@ -760,7 +807,7 @@ void wpas_dbus_signal_certification(struct wpa_supplicant *wpa_s,
iface = wpa_s->global->dbus;
/* Do nothing if the control interface is not turned on */
- if (iface == NULL)
+ if (iface == NULL || !wpa_s->dbus_new_path)
return;
msg = dbus_message_new_signal(wpa_s->dbus_new_path,
@@ -801,7 +848,7 @@ void wpas_dbus_signal_eap_status(struct wpa_supplicant *wpa_s,
iface = wpa_s->global->dbus;
/* Do nothing if the control interface is not turned on */
- if (iface == NULL)
+ if (iface == NULL || !wpa_s->dbus_new_path)
return;
msg = dbus_message_new_signal(wpa_s->dbus_new_path,
@@ -844,7 +891,7 @@ static void wpas_dbus_signal_sta(struct wpa_supplicant *wpa_s,
iface = wpa_s->global->dbus;
/* Do nothing if the control interface is not turned on */
- if (iface == NULL)
+ if (iface == NULL || !wpa_s->dbus_new_path)
return;
msg = dbus_message_new_signal(wpa_s->dbus_new_path,
@@ -916,7 +963,8 @@ void wpas_dbus_signal_p2p_group_removed(struct wpa_supplicant *wpa_s,
if (parent->p2p_mgmt)
parent = parent->parent;
- if (!wpa_s->dbus_groupobj_path)
+ if (!wpa_s->dbus_groupobj_path || !wpa_s->dbus_new_path ||
+ !parent->dbus_new_path)
return;
msg = dbus_message_new_signal(parent->dbus_new_path,
@@ -984,6 +1032,8 @@ void wpas_dbus_signal_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
if (wpa_s->p2p_mgmt)
wpa_s = wpa_s->parent;
+ if (!wpa_s->dbus_new_path)
+ return;
if (request || !status) {
if (config_methods & WPS_CONFIG_DISPLAY)
@@ -1057,8 +1107,19 @@ error:
}
+/**
+ * wpas_dbus_signal_p2p_go_neg_req - Signal P2P GO Negotiation Request RX
+ * @wpa_s: %wpa_supplicant network interface data
+ * @src: Source address of the message triggering this notification
+ * @dev_passwd_id: WPS Device Password Id
+ * @go_intent: Peer's GO Intent value
+ *
+ * Sends signal to notify that a peer P2P Device is requesting group owner
+ * negotiation with us.
+ */
void wpas_dbus_signal_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
- const u8 *src, u16 dev_passwd_id)
+ const u8 *src, u16 dev_passwd_id,
+ u8 go_intent)
{
DBusMessage *msg;
DBusMessageIter iter;
@@ -1073,6 +1134,8 @@ void wpas_dbus_signal_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
if (wpa_s->p2p_mgmt)
wpa_s = wpa_s->parent;
+ if (!wpa_s->dbus_new_path)
+ return;
os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
"%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
@@ -1090,7 +1153,9 @@ void wpas_dbus_signal_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
&path) ||
!dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT16,
- &dev_passwd_id))
+ &dev_passwd_id) ||
+ !dbus_message_iter_append_basic(&iter, DBUS_TYPE_BYTE,
+ &go_intent))
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
else
dbus_connection_send(iface->con, msg, NULL);
@@ -1105,7 +1170,8 @@ static int wpas_dbus_get_group_obj_path(struct wpa_supplicant *wpa_s,
{
char group_name[3];
- if (os_memcmp(ssid->ssid, P2P_WILDCARD_SSID, P2P_WILDCARD_SSID_LEN))
+ if (!wpa_s->dbus_new_path ||
+ os_memcmp(ssid->ssid, P2P_WILDCARD_SSID, P2P_WILDCARD_SSID_LEN))
return -1;
os_memcpy(group_name, ssid->ssid + P2P_WILDCARD_SSID_LEN, 2);
@@ -1209,7 +1275,7 @@ void wpas_dbus_signal_p2p_group_started(struct wpa_supplicant *wpa_s,
iface = parent->global->dbus;
/* Do nothing if the control interface is not turned on */
- if (iface == NULL)
+ if (iface == NULL || !parent->dbus_new_path || !wpa_s->dbus_new_path)
return;
if (wpa_s->dbus_groupobj_path == NULL)
@@ -1248,10 +1314,9 @@ void wpas_dbus_signal_p2p_group_started(struct wpa_supplicant *wpa_s,
/**
- *
- * Method to emit GONegotiation Success or Failure signals based
- * on status.
- * @status: Status of the GO neg request. 0 for success, other for errors.
+ * wpas_dbus_signal_p2p_go_neg_resp - Emit GONegotiation Success/Failure signal
+ * @wpa_s: %wpa_supplicant network interface data
+ * @res: Result of the GO Neg Request
*/
void wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant *wpa_s,
struct p2p_go_neg_results *res)
@@ -1272,7 +1337,7 @@ void wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant *wpa_s,
os_memset(freqs, 0, sizeof(freqs));
/* Do nothing if the control interface is not turned on */
- if (iface == NULL)
+ if (iface == NULL || !wpa_s->dbus_new_path)
return;
os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
@@ -1363,12 +1428,10 @@ err:
/**
- *
- * Method to emit Invitation Result signal based on status and
- * bssid
- * @status: Status of the Invite request. 0 for success, other
- * for errors
- * @bssid : Basic Service Set Identifier
+ * wpas_dbus_signal_p2p_invitation_result - Emit InvitationResult signal
+ * @wpa_s: %wpa_supplicant network interface data
+ * @status: Status of invitation process
+ * @bssid: Basic Service Set Identifier
*/
void wpas_dbus_signal_p2p_invitation_result(struct wpa_supplicant *wpa_s,
int status, const u8 *bssid)
@@ -1386,6 +1449,8 @@ void wpas_dbus_signal_p2p_invitation_result(struct wpa_supplicant *wpa_s,
if (wpa_s->p2p_mgmt)
wpa_s = wpa_s->parent;
+ if (!wpa_s->dbus_new_path)
+ return;
msg = dbus_message_new_signal(wpa_s->dbus_new_path,
WPAS_DBUS_NEW_IFACE_P2PDEVICE,
@@ -1439,6 +1504,8 @@ void wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant *wpa_s,
parent = wpa_s->parent;
if (parent->p2p_mgmt)
parent = parent->parent;
+ if (!parent->dbus_new_path)
+ return;
os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
"%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
@@ -1494,6 +1561,8 @@ void wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant *wpa_s,
parent = wpa_s->parent;
if (parent->p2p_mgmt)
parent = parent->parent;
+ if (!parent->dbus_new_path)
+ return;
os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
"%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
@@ -1551,6 +1620,8 @@ void wpas_dbus_signal_p2p_sd_request(struct wpa_supplicant *wpa_s,
if (wpa_s->p2p_mgmt)
wpa_s = wpa_s->parent;
+ if (!wpa_s->dbus_new_path)
+ return;
/* Check if this is a known peer */
if (!p2p_peer_known(wpa_s->global->p2p, sa))
@@ -1617,6 +1688,8 @@ void wpas_dbus_signal_p2p_sd_response(struct wpa_supplicant *wpa_s,
if (wpa_s->p2p_mgmt)
wpa_s = wpa_s->parent;
+ if (!wpa_s->dbus_new_path)
+ return;
/* Check if this is a known peer */
if (!p2p_peer_known(wpa_s->global->p2p, sa))
@@ -1678,6 +1751,8 @@ static void wpas_dbus_signal_persistent_group(struct wpa_supplicant *wpa_s,
if (wpa_s->p2p_mgmt)
wpa_s = wpa_s->parent;
+ if (!wpa_s->dbus_new_path)
+ return;
os_snprintf(pgrp_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
"%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART "/%u",
@@ -1740,6 +1815,7 @@ static void wpas_dbus_signal_persistent_group_removed(
/**
* wpas_dbus_signal_p2p_wps_failed - Signals WpsFailed event
* @wpa_s: %wpa_supplicant network interface data
+ * @fail: WPS failure information
*
* Sends Event dbus signal with name "fail" and dictionary containing
* "msg" field with fail message number (int32) as arguments
@@ -1762,6 +1838,8 @@ void wpas_dbus_signal_p2p_wps_failed(struct wpa_supplicant *wpa_s,
if (wpa_s->p2p_mgmt)
wpa_s = wpa_s->parent;
+ if (!wpa_s->dbus_new_path)
+ return;
msg = dbus_message_new_signal(wpa_s->dbus_new_path,
WPAS_DBUS_NEW_IFACE_P2PDEVICE,
"WpsFailed");
@@ -1783,6 +1861,98 @@ void wpas_dbus_signal_p2p_wps_failed(struct wpa_supplicant *wpa_s,
dbus_message_unref(msg);
}
+
+/**
+ * wpas_dbus_signal_p2p_group_formation_failure - Signals GroupFormationFailure event
+ * @wpa_s: %wpa_supplicant network interface data
+ * @reason: indicates the reason code for group formation failure
+ *
+ * Sends Event dbus signal and string reason code when available.
+ */
+void wpas_dbus_signal_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
+ const char *reason)
+{
+ DBusMessage *msg;
+ struct wpas_dbus_priv *iface;
+
+ iface = wpa_s->global->dbus;
+
+ /* Do nothing if the control interface is not turned on */
+ if (iface == NULL)
+ return;
+
+ msg = dbus_message_new_signal(wpa_s->dbus_new_path,
+ WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ "GroupFormationFailure");
+ if (msg == NULL)
+ return;
+
+ if (dbus_message_append_args(msg, DBUS_TYPE_STRING, &reason,
+ DBUS_TYPE_INVALID))
+ dbus_connection_send(iface->con, msg, NULL);
+ else
+ wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
+
+ dbus_message_unref(msg);
+}
+
+
+/**
+ * wpas_dbus_signal_p2p_invitation_received - Emit InvitationReceived signal
+ * @wpa_s: %wpa_supplicant network interface data
+ * @sa: Source address of the Invitation Request
+ * @dev_add: GO Device Address
+ * @bssid: P2P Group BSSID or %NULL if not received
+ * @id: Persistent group id or %0 if not persistent group
+ * @op_freq: Operating frequency for the group
+ */
+
+void wpas_dbus_signal_p2p_invitation_received(struct wpa_supplicant *wpa_s,
+ const u8 *sa, const u8 *dev_addr,
+ const u8 *bssid, int id,
+ int op_freq)
+{
+ DBusMessage *msg;
+ DBusMessageIter iter, dict_iter;
+ struct wpas_dbus_priv *iface;
+
+ iface = wpa_s->global->dbus;
+
+ /* Do nothing if the control interface is not turned on */
+ if (iface == NULL)
+ return;
+
+ msg = dbus_message_new_signal(wpa_s->dbus_new_path,
+ WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ "InvitationReceived");
+ if (msg == NULL)
+ return;
+
+ dbus_message_iter_init_append(msg, &iter);
+ if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
+ (sa &&
+ !wpa_dbus_dict_append_byte_array(&dict_iter, "sa",
+ (const char *) sa, ETH_ALEN)) ||
+ (dev_addr &&
+ !wpa_dbus_dict_append_byte_array(&dict_iter, "go_dev_addr",
+ (const char *) dev_addr,
+ ETH_ALEN)) ||
+ (bssid &&
+ !wpa_dbus_dict_append_byte_array(&dict_iter, "bssid",
+ (const char *) bssid,
+ ETH_ALEN)) ||
+ (id &&
+ !wpa_dbus_dict_append_int32(&dict_iter, "persistent_id", id)) ||
+ !wpa_dbus_dict_append_int32(&dict_iter, "op_freq", op_freq) ||
+ !wpa_dbus_dict_close_write(&iter, &dict_iter)) {
+ dbus_message_unref(msg);
+ return;
+ }
+
+ dbus_connection_send(iface->con, msg, NULL);
+}
+
+
#endif /* CONFIG_P2P */
@@ -1862,6 +2032,9 @@ void wpas_dbus_bss_signal_prop_changed(struct wpa_supplicant *wpa_s,
char path[WPAS_DBUS_OBJECT_PATH_MAX];
char *prop;
+ if (!wpa_s->dbus_new_path)
+ return;
+
switch (property) {
case WPAS_DBUS_BSS_PROP_SIGNAL:
prop = "Signal";
@@ -2177,7 +2350,7 @@ int wpas_dbus_register_network(struct wpa_supplicant *wpa_s,
#endif /* CONFIG_P2P */
/* Do nothing if the control interface is not turned on */
- if (wpa_s == NULL || wpa_s->global == NULL)
+ if (wpa_s == NULL || wpa_s->global == NULL || !wpa_s->dbus_new_path)
return 0;
ctrl_iface = wpa_s->global->dbus;
if (ctrl_iface == NULL)
@@ -2351,7 +2524,7 @@ int wpas_dbus_unregister_bss(struct wpa_supplicant *wpa_s,
char bss_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
/* Do nothing if the control interface is not turned on */
- if (wpa_s == NULL || wpa_s->global == NULL)
+ if (wpa_s == NULL || wpa_s->global == NULL || !wpa_s->dbus_new_path)
return 0;
ctrl_iface = wpa_s->global->dbus;
if (ctrl_iface == NULL)
@@ -2394,7 +2567,7 @@ int wpas_dbus_register_bss(struct wpa_supplicant *wpa_s,
struct bss_handler_args *arg;
/* Do nothing if the control interface is not turned on */
- if (wpa_s == NULL || wpa_s->global == NULL)
+ if (wpa_s == NULL || wpa_s->global == NULL || !wpa_s->dbus_new_path)
return 0;
ctrl_iface = wpa_s->global->dbus;
if (ctrl_iface == NULL)
@@ -2486,6 +2659,12 @@ static const struct wpa_dbus_method_desc wpas_dbus_interface_methods[] = {
END_ARGS
}
},
+ { "Reconnect", WPAS_DBUS_NEW_IFACE_INTERFACE,
+ (WPADBusMethodHandler) wpas_dbus_handler_reconnect,
+ {
+ END_ARGS
+ }
+ },
{ "RemoveNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE,
(WPADBusMethodHandler) wpas_dbus_handler_remove_network,
{
@@ -2558,6 +2737,12 @@ static const struct wpa_dbus_method_desc wpas_dbus_interface_methods[] = {
END_ARGS
}
},
+ { "Cancel", WPAS_DBUS_NEW_IFACE_WPS,
+ (WPADBusMethodHandler) wpas_dbus_handler_wps_cancel,
+ {
+ END_ARGS
+ }
+ },
#endif /* CONFIG_WPS */
#ifdef CONFIG_P2P
{ "Find", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
@@ -2617,6 +2802,12 @@ static const struct wpa_dbus_method_desc wpas_dbus_interface_methods[] = {
END_ARGS
}
},
+ { "Cancel", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ (WPADBusMethodHandler) wpas_dbus_handler_p2p_cancel,
+ {
+ END_ARGS
+ }
+ },
{ "Invite", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
(WPADBusMethodHandler) wpas_dbus_handler_p2p_invite,
{
@@ -2637,6 +2828,13 @@ static const struct wpa_dbus_method_desc wpas_dbus_interface_methods[] = {
END_ARGS
}
},
+ { "RemoveClient", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ (WPADBusMethodHandler) wpas_dbus_handler_p2p_remove_client,
+ {
+ { "args", "a{sv}", ARG_IN },
+ END_ARGS
+ }
+ },
{ "Flush", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
(WPADBusMethodHandler) wpas_dbus_handler_p2p_flush,
{
@@ -3014,6 +3212,11 @@ static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = {
END_ARGS
}
},
+ { "FindStopped", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ {
+ END_ARGS
+ }
+ },
{ "ProvisionDiscoveryRequestDisplayPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
{
{ "peer_object", "o", ARG_OUT },
@@ -3065,6 +3268,12 @@ static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = {
END_ARGS
}
},
+ { "GroupFormationFailure", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ {
+ { "reason", "s", ARG_OUT },
+ END_ARGS
+ }
+ },
{ "GONegotiationSuccess", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
{
{ "properties", "a{sv}", ARG_OUT },
@@ -3080,7 +3289,8 @@ static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = {
{ "GONegotiationRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
{
{ "path", "o", ARG_OUT },
- { "dev_passwd_id", "i", ARG_OUT },
+ { "dev_passwd_id", "q", ARG_OUT },
+ { "device_go_intent", "y", ARG_OUT },
END_ARGS
}
},
@@ -3128,6 +3338,12 @@ static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = {
END_ARGS
}
},
+ { "InvitationReceived", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ {
+ { "properties", "a{sv}", ARG_OUT },
+ END_ARGS
+ }
+ },
#endif /* CONFIG_P2P */
#ifdef CONFIG_AP
{ "ProbeRequest", WPAS_DBUS_NEW_IFACE_INTERFACE,
@@ -3174,6 +3390,11 @@ static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = {
};
+/**
+ * wpas_dbus_register_interface - Register an interface with D-Bus
+ * @wpa_s: wpa_supplicant interface structure
+ * Returns: 0 on success, -1 on failure
+ */
int wpas_dbus_register_interface(struct wpa_supplicant *wpa_s)
{
@@ -3224,6 +3445,11 @@ err:
}
+/**
+ * wpas_dbus_unregister_interface - Unregister the interface from D-Bus
+ * @wpa_s: wpa_supplicant interface structure
+ * Returns: 0 on success, -1 on failure
+ */
int wpas_dbus_unregister_interface(struct wpa_supplicant *wpa_s)
{
struct wpas_dbus_priv *ctrl_iface;
@@ -3265,6 +3491,22 @@ static const struct wpa_dbus_property_desc wpas_dbus_p2p_peer_properties[] = {
wpas_dbus_getter_p2p_peer_device_name,
NULL
},
+ { "Manufacturer", WPAS_DBUS_NEW_IFACE_P2P_PEER, "s",
+ wpas_dbus_getter_p2p_peer_manufacturer,
+ NULL
+ },
+ { "ModelName", WPAS_DBUS_NEW_IFACE_P2P_PEER, "s",
+ wpas_dbus_getter_p2p_peer_modelname,
+ NULL
+ },
+ { "ModelNumber", WPAS_DBUS_NEW_IFACE_P2P_PEER, "s",
+ wpas_dbus_getter_p2p_peer_modelnumber,
+ NULL
+ },
+ { "SerialNumber", WPAS_DBUS_NEW_IFACE_P2P_PEER, "s",
+ wpas_dbus_getter_p2p_peer_serialnumber,
+ NULL
+ },
{ "PrimaryDeviceType", WPAS_DBUS_NEW_IFACE_P2P_PEER, "ay",
wpas_dbus_getter_p2p_peer_primary_device_type,
NULL
@@ -3345,7 +3587,7 @@ static void wpas_dbus_signal_peer(struct wpa_supplicant *wpa_s,
iface = wpa_s->global->dbus;
/* Do nothing if the control interface is not turned on */
- if (iface == NULL)
+ if (iface == NULL || !wpa_s->dbus_new_path)
return;
os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
@@ -3372,7 +3614,7 @@ static void wpas_dbus_signal_peer(struct wpa_supplicant *wpa_s,
/**
* wpas_dbus_signal_peer_found - Send a peer found signal
* @wpa_s: %wpa_supplicant network interface data
- * @dev: peer device object
+ * @dev_addr: Peer P2P Device Address
*
* Notify listeners about find a p2p peer device found
*/
@@ -3387,7 +3629,7 @@ void wpas_dbus_signal_peer_device_found(struct wpa_supplicant *wpa_s,
/**
* wpas_dbus_signal_peer_lost - Send a peer lost signal
* @wpa_s: %wpa_supplicant network interface data
- * @dev: peer device object
+ * @dev_addr: Peer P2P Device Address
*
* Notify listeners about lost a p2p peer device
*/
@@ -3402,7 +3644,7 @@ void wpas_dbus_signal_peer_device_lost(struct wpa_supplicant *wpa_s,
/**
* wpas_dbus_register_peer - Register a discovered peer object with dbus
* @wpa_s: wpa_supplicant interface structure
- * @ssid: network configuration data
+ * @dev_addr: P2P Device Address of the peer
* Returns: 0 on success, -1 on failure
*
* Registers network representing object with dbus
@@ -3422,8 +3664,9 @@ int wpas_dbus_register_peer(struct wpa_supplicant *wpa_s, const u8 *dev_addr)
if (ctrl_iface == NULL)
return 0;
- if (wpa_s->p2p_mgmt)
- wpa_s = wpa_s->parent;
+ wpa_s = wpa_s->parent->parent;
+ if (!wpa_s->dbus_new_path)
+ return 0;
os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
"%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
@@ -3481,12 +3724,12 @@ int wpas_dbus_unregister_peer(struct wpa_supplicant *wpa_s,
int ret;
/* Do nothing if the control interface is not turned on */
- if (wpa_s == NULL || wpa_s->global == NULL ||
- wpa_s->dbus_new_path == NULL)
+ if (wpa_s == NULL || wpa_s->global == NULL)
return 0;
- if (wpa_s->p2p_mgmt)
- wpa_s = wpa_s->parent;
+ wpa_s = wpa_s->parent->parent;
+ if (!wpa_s->dbus_new_path)
+ return 0;
ctrl_iface = wpa_s->global->dbus;
if (ctrl_iface == NULL)
@@ -3504,6 +3747,42 @@ int wpas_dbus_unregister_peer(struct wpa_supplicant *wpa_s,
}
+/**
+ * wpas_dbus_signal_p2p_find_stopped - Send P2P Find stopped signal
+ * @wpa_s: %wpa_supplicant network interface data
+ *
+ * Notify listeners about P2P Find stopped
+ */
+void wpas_dbus_signal_p2p_find_stopped(struct wpa_supplicant *wpa_s)
+{
+ struct wpas_dbus_priv *iface;
+ DBusMessage *msg;
+
+ iface = wpa_s->global->dbus;
+
+ /* Do nothing if the control interface is not turned on */
+ if (iface == NULL || !wpa_s->dbus_new_path)
+ return;
+
+ msg = dbus_message_new_signal(wpa_s->dbus_new_path,
+ WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ "FindStopped");
+ if (msg == NULL)
+ return;
+
+ dbus_connection_send(iface->con, msg, NULL);
+
+ dbus_message_unref(msg);
+}
+
+
+/**
+ * wpas_dbus_signal_peer_groups_changed - Send peer group change property signal
+ * @wpa_s: %wpa_supplicant network interface data
+ * @dev_addr: P2P Device Address
+ *
+ * Notify listeners about peer Groups property changes.
+ */
void wpas_dbus_signal_peer_groups_changed(struct wpa_supplicant *wpa_s,
const u8 *dev_addr)
{
@@ -3512,6 +3791,8 @@ void wpas_dbus_signal_peer_groups_changed(struct wpa_supplicant *wpa_s,
if (wpa_s->p2p_mgmt)
wpa_s = wpa_s->parent;
+ if (!wpa_s->dbus_new_path)
+ return;
os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
"%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
wpa_s->dbus_new_path, MAC2STR(dev_addr));
@@ -3713,6 +3994,9 @@ int wpas_dbus_register_persistent_group(struct wpa_supplicant *wpa_s,
/* Do nothing if the control interface is not turned on */
if (wpa_s == NULL || wpa_s->global == NULL)
return 0;
+ wpa_s = wpa_s->parent->parent;
+ if (!wpa_s->dbus_new_path)
+ return 0;
/* Make sure ssid is a persistent group */
if (ssid->disabled != 2 && !ssid->p2p_persistent_group)
@@ -3797,15 +4081,13 @@ int wpas_dbus_unregister_persistent_group(struct wpa_supplicant *wpa_s,
int ret;
/* Do nothing if the control interface is not turned on */
- if (wpa_s == NULL || wpa_s->global == NULL ||
- wpa_s->dbus_new_path == NULL)
+ if (wpa_s == NULL || wpa_s->global == NULL)
return 0;
- if (wpa_s->p2p_mgmt)
- wpa_s = wpa_s->parent;
+ wpa_s = wpa_s->parent->parent;
ctrl_iface = wpa_s->global->dbus;
- if (ctrl_iface == NULL)
+ if (ctrl_iface == NULL || !wpa_s->dbus_new_path)
return 0;
os_snprintf(pgrp_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
diff --git a/wpa_supplicant/dbus/dbus_new.h b/wpa_supplicant/dbus/dbus_new.h
index d162d2b..6d240ff 100644
--- a/wpa_supplicant/dbus/dbus_new.h
+++ b/wpa_supplicant/dbus/dbus_new.h
@@ -152,6 +152,7 @@ void wpas_dbus_signal_wps_event_m2d(struct wpa_supplicant *wpa_s,
void wpas_dbus_signal_wps_event_fail(struct wpa_supplicant *wpa_s,
struct wps_event_fail *fail);
void wpas_dbus_signal_wps_event_success(struct wpa_supplicant *wpa_s);
+void wpas_dbus_signal_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s);
int wpas_dbus_register_network(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid);
int wpas_dbus_unregister_network(struct wpa_supplicant *wpa_s, int nid);
@@ -168,6 +169,7 @@ void wpas_dbus_signal_debug_timestamp_changed(struct wpa_global *global);
void wpas_dbus_signal_debug_show_keys_changed(struct wpa_global *global);
int wpas_dbus_register_peer(struct wpa_supplicant *wpa_s, const u8 *dev_addr);
+void wpas_dbus_signal_p2p_find_stopped(struct wpa_supplicant *wpa_s);
void wpas_dbus_signal_peer_device_found(struct wpa_supplicant *wpa_s,
const u8 *dev_addr);
int wpas_dbus_unregister_peer(struct wpa_supplicant *wpa_s,
@@ -184,10 +186,13 @@ void wpas_dbus_signal_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
u16 config_methods,
unsigned int generated_pin);
void wpas_dbus_signal_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
- const u8 *src, u16 dev_passwd_id);
+ const u8 *src, u16 dev_passwd_id,
+ u8 go_intent);
void wpas_dbus_signal_p2p_group_started(struct wpa_supplicant *wpa_s,
const struct wpa_ssid *ssid,
int client, int network_id);
+void wpas_dbus_signal_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
+ const char *reason);
void wpas_dbus_register_p2p_group(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid);
void wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant *wpa_s,
@@ -228,6 +233,10 @@ void wpas_dbus_signal_sta_authorized(struct wpa_supplicant *wpa_s,
const u8 *sta);
void wpas_dbus_signal_sta_deauthorized(struct wpa_supplicant *wpa_s,
const u8 *sta);
+void wpas_dbus_signal_p2p_invitation_received(struct wpa_supplicant *wpa_s,
+ const u8 *sa, const u8 *dev_addr,
+ const u8 *bssid, int id,
+ int op_freq);
#else /* CONFIG_CTRL_IFACE_DBUS_NEW */
@@ -295,6 +304,11 @@ static inline void wpas_dbus_signal_wps_event_success(
{
}
+static inline void wpas_dbus_signal_wps_event_pbc_overlap(
+ struct wpa_supplicant *wpa_s)
+{
+}
+
static inline int wpas_dbus_register_network(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid)
{
@@ -377,10 +391,10 @@ wpas_dbus_signal_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
{
}
-static inline void wpas_dbus_signal_p2p_go_neg_req(
- struct wpa_supplicant *wpa_s,
- const u8 *src,
- u16 dev_passwd_id)
+static inline void wpas_dbus_signal_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
+ const u8 *src,
+ u16 dev_passwd_id,
+ u8 go_intent)
{
}
@@ -392,6 +406,12 @@ wpas_dbus_signal_p2p_group_started(struct wpa_supplicant *wpa_s,
}
static inline void
+wpas_dbus_signal_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
+ const char *reason)
+{
+}
+
+static inline void
wpas_dbus_register_p2p_group(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid)
{
@@ -460,6 +480,11 @@ wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant *wpa_s,
}
static inline void
+wpas_dbus_signal_p2p_find_stopped(struct wpa_supplicant *wpa_s)
+{
+}
+
+static inline void
wpas_dbus_signal_peer_device_found(struct wpa_supplicant *wpa_s,
const u8 *dev_addr)
{
@@ -519,6 +544,14 @@ void wpas_dbus_signal_sta_deauthorized(struct wpa_supplicant *wpa_s,
{
}
+static inline
+void wpas_dbus_signal_p2p_invitation_received(struct wpa_supplicant *wpa_s,
+ const u8 *sa, const u8 *dev_addr,
+ const u8 *bssid, int id,
+ int op_freq)
+{
+}
+
#endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
#endif /* CTRL_IFACE_DBUS_H_NEW */
diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c
index f2e62ca..67562a5 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers.c
@@ -157,7 +157,8 @@ static struct wpa_supplicant * get_iface_by_dbus_path(
struct wpa_supplicant *wpa_s;
for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
- if (os_strcmp(wpa_s->dbus_new_path, path) == 0)
+ if (wpa_s->dbus_new_path &&
+ os_strcmp(wpa_s->dbus_new_path, path) == 0)
return wpa_s;
}
return NULL;
@@ -213,7 +214,7 @@ dbus_bool_t set_network_properties(struct wpa_supplicant *wpa_s,
} else if (entry.type == DBUS_TYPE_STRING) {
if (should_quote_opt(entry.key)) {
size = os_strlen(entry.str_value);
- if (size <= 0)
+ if (size == 0)
goto error;
size += 3;
@@ -600,7 +601,7 @@ DBusMessage * wpas_dbus_handler_create_interface(DBusMessage *message,
iface.bridge_ifname = bridge_ifname;
/* Otherwise, have wpa_supplicant attach to it. */
wpa_s = wpa_supplicant_add_iface(global, &iface, NULL);
- if (wpa_s) {
+ if (wpa_s && wpa_s->dbus_new_path) {
const char *path = wpa_s->dbus_new_path;
reply = dbus_message_new_method_return(message);
@@ -684,7 +685,7 @@ DBusMessage * wpas_dbus_handler_get_interface(DBusMessage *message,
DBUS_TYPE_INVALID);
wpa_s = wpa_supplicant_get_iface(global, ifname);
- if (wpa_s == NULL)
+ if (wpa_s == NULL || wpa_s->dbus_new_path == NULL)
return wpas_dbus_error_iface_unknown(message);
path = wpa_s->dbus_new_path;
@@ -876,8 +877,10 @@ dbus_bool_t wpas_dbus_getter_interfaces(DBusMessageIter *iter,
unsigned int i = 0, num = 0;
dbus_bool_t success;
- for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
- num++;
+ for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
+ if (wpa_s->dbus_new_path)
+ num++;
+ }
paths = os_calloc(num, sizeof(char *));
if (!paths) {
@@ -885,8 +888,10 @@ dbus_bool_t wpas_dbus_getter_interfaces(DBusMessageIter *iter,
return FALSE;
}
- for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
- paths[i++] = wpa_s->dbus_new_path;
+ for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
+ if (wpa_s->dbus_new_path)
+ paths[i++] = wpa_s->dbus_new_path;
+ }
success = wpas_dbus_simple_array_property_getter(iter,
DBUS_TYPE_OBJECT_PATH,
@@ -1034,10 +1039,10 @@ static int wpas_dbus_get_scan_ssids(DBusMessage *message, DBusMessageIter *var,
dbus_message_iter_get_fixed_array(&sub_array_iter, &val, &len);
- if (len > MAX_SSID_LEN) {
+ if (len > SSID_MAX_LEN) {
wpa_printf(MSG_DEBUG,
"%s[dbus]: SSID too long (len=%d max_len=%d)",
- __func__, len, MAX_SSID_LEN);
+ __func__, len, SSID_MAX_LEN);
*reply = wpas_dbus_error_invalid_args(
message, "Invalid SSID: too long");
return -1;
@@ -1327,14 +1332,26 @@ DBusMessage * wpas_dbus_handler_scan(DBusMessage *message,
message,
"You can specify only Channels in passive scan");
goto out;
- } else if (params.freqs && params.freqs[0]) {
- if (wpa_supplicant_trigger_scan(wpa_s, &params)) {
- reply = wpas_dbus_error_scan_error(
- message, "Scan request rejected");
- }
} else {
- wpa_s->scan_req = MANUAL_SCAN_REQ;
- wpa_supplicant_req_scan(wpa_s, 0, 0);
+ if (wpa_s->sched_scanning) {
+ wpa_printf(MSG_DEBUG,
+ "%s[dbus]: Stop ongoing sched_scan to allow requested scan to proceed",
+ __func__);
+ wpa_supplicant_cancel_sched_scan(wpa_s);
+ }
+
+ if (params.freqs && params.freqs[0]) {
+ wpa_s->last_scan_req = MANUAL_SCAN_REQ;
+ if (wpa_supplicant_trigger_scan(wpa_s,
+ &params)) {
+ reply = wpas_dbus_error_scan_error(
+ message,
+ "Scan request rejected");
+ }
+ } else {
+ wpa_s->scan_req = MANUAL_SCAN_REQ;
+ wpa_supplicant_req_scan(wpa_s, 0, 0);
+ }
}
} else if (os_strcmp(type, "active") == 0) {
if (!params.num_ssids) {
@@ -1344,6 +1361,14 @@ DBusMessage * wpas_dbus_handler_scan(DBusMessage *message,
#ifdef CONFIG_AUTOSCAN
autoscan_deinit(wpa_s);
#endif /* CONFIG_AUTOSCAN */
+ if (wpa_s->sched_scanning) {
+ wpa_printf(MSG_DEBUG,
+ "%s[dbus]: Stop ongoing sched_scan to allow requested scan to proceed",
+ __func__);
+ wpa_supplicant_cancel_sched_scan(wpa_s);
+ }
+
+ wpa_s->last_scan_req = MANUAL_SCAN_REQ;
if (wpa_supplicant_trigger_scan(wpa_s, &params)) {
reply = wpas_dbus_error_scan_error(
message, "Scan request rejected");
@@ -1478,7 +1503,8 @@ DBusMessage * wpas_dbus_handler_add_network(DBusMessage *message,
dbus_message_iter_init(message, &iter);
- ssid = wpa_config_add_network(wpa_s->conf);
+ if (wpa_s->dbus_new_path)
+ ssid = wpa_config_add_network(wpa_s->conf);
if (ssid == NULL) {
wpa_printf(MSG_ERROR, "%s[dbus]: can't add new interface.",
__func__);
@@ -1577,6 +1603,30 @@ DBusMessage * wpas_dbus_handler_reattach(DBusMessage *message,
/**
+ * wpas_dbus_handler_reconnect - Reconnect if disconnected
+ * @message: Pointer to incoming dbus message
+ * @wpa_s: wpa_supplicant structure for a network interface
+ * Returns: InterfaceDisabled DBus error message if disabled
+ * or NULL otherwise.
+ *
+ * Handler function for "Reconnect" method call of network interface.
+ */
+DBusMessage * wpas_dbus_handler_reconnect(DBusMessage *message,
+ struct wpa_supplicant *wpa_s)
+{
+ if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
+ return dbus_message_new_error(message,
+ WPAS_DBUS_ERROR_IFACE_DISABLED,
+ "This interface is disabled");
+ }
+
+ if (wpa_s->disconnected)
+ wpas_request_connection(wpa_s);
+ return NULL;
+}
+
+
+/**
* wpas_dbus_handler_remove_network - Remove a configured network
* @message: Pointer to incoming dbus message
* @wpa_s: wpa_supplicant structure for a network interface
@@ -1602,7 +1652,7 @@ DBusMessage * wpas_dbus_handler_remove_network(DBusMessage *message,
iface = wpas_dbus_new_decompose_object_path(op,
WPAS_DBUS_NEW_NETWORKS_PART,
&net_id);
- if (iface == NULL || net_id == NULL ||
+ if (iface == NULL || net_id == NULL || !wpa_s->dbus_new_path ||
os_strcmp(iface, wpa_s->dbus_new_path) != 0) {
reply = wpas_dbus_error_invalid_args(message, op);
goto out;
@@ -1715,7 +1765,7 @@ DBusMessage * wpas_dbus_handler_select_network(DBusMessage *message,
iface = wpas_dbus_new_decompose_object_path(op,
WPAS_DBUS_NEW_NETWORKS_PART,
&net_id);
- if (iface == NULL || net_id == NULL ||
+ if (iface == NULL || net_id == NULL || !wpa_s->dbus_new_path ||
os_strcmp(iface, wpa_s->dbus_new_path) != 0) {
reply = wpas_dbus_error_invalid_args(message, op);
goto out;
@@ -1773,7 +1823,7 @@ DBusMessage * wpas_dbus_handler_network_reply(DBusMessage *message,
iface = wpas_dbus_new_decompose_object_path(op,
WPAS_DBUS_NEW_NETWORKS_PART,
&net_id);
- if (iface == NULL || net_id == NULL ||
+ if (iface == NULL || net_id == NULL || !wpa_s->dbus_new_path ||
os_strcmp(iface, wpa_s->dbus_new_path) != 0) {
reply = wpas_dbus_error_invalid_args(message, op);
goto out;
@@ -2266,12 +2316,14 @@ DBusMessage * wpas_dbus_handler_set_pkcs11_engine_and_module_path(
message, DBUS_ERROR_FAILED,
"Reinit of the EAPOL state machine with the new PKCS #11 engine and module path failed.");
- wpa_dbus_mark_property_changed(
- wpa_s->global->dbus, wpa_s->dbus_new_path,
- WPAS_DBUS_NEW_IFACE_INTERFACE, "PKCS11EnginePath");
- wpa_dbus_mark_property_changed(
- wpa_s->global->dbus, wpa_s->dbus_new_path,
- WPAS_DBUS_NEW_IFACE_INTERFACE, "PKCS11ModulePath");
+ if (wpa_s->dbus_new_path) {
+ wpa_dbus_mark_property_changed(
+ wpa_s->global->dbus, wpa_s->dbus_new_path,
+ WPAS_DBUS_NEW_IFACE_INTERFACE, "PKCS11EnginePath");
+ wpa_dbus_mark_property_changed(
+ wpa_s->global->dbus, wpa_s->dbus_new_path,
+ WPAS_DBUS_NEW_IFACE_INTERFACE, "PKCS11ModulePath");
+ }
return NULL;
}
@@ -3024,7 +3076,7 @@ dbus_bool_t wpas_dbus_getter_current_bss(DBusMessageIter *iter,
struct wpa_supplicant *wpa_s = user_data;
char path_buf[WPAS_DBUS_OBJECT_PATH_MAX], *bss_obj_path = path_buf;
- if (wpa_s->current_bss)
+ if (wpa_s->current_bss && wpa_s->dbus_new_path)
os_snprintf(bss_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
"%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u",
wpa_s->dbus_new_path, wpa_s->current_bss->id);
@@ -3052,7 +3104,7 @@ dbus_bool_t wpas_dbus_getter_current_network(DBusMessageIter *iter,
struct wpa_supplicant *wpa_s = user_data;
char path_buf[WPAS_DBUS_OBJECT_PATH_MAX], *net_obj_path = path_buf;
- if (wpa_s->current_ssid)
+ if (wpa_s->current_ssid && wpa_s->dbus_new_path)
os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
"%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u",
wpa_s->dbus_new_path, wpa_s->current_ssid->id);
@@ -3140,6 +3192,12 @@ dbus_bool_t wpas_dbus_getter_bsss(DBusMessageIter *iter, DBusError *error,
unsigned int i = 0;
dbus_bool_t success = FALSE;
+ if (!wpa_s->dbus_new_path) {
+ dbus_set_error(error, DBUS_ERROR_FAILED,
+ "%s: no D-Bus interface", __func__);
+ return FALSE;
+ }
+
paths = os_calloc(wpa_s->num_bss, sizeof(char *));
if (!paths) {
dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
@@ -3191,6 +3249,12 @@ dbus_bool_t wpas_dbus_getter_networks(DBusMessageIter *iter, DBusError *error,
unsigned int i = 0, num = 0;
dbus_bool_t success = FALSE;
+ if (!wpa_s->dbus_new_path) {
+ dbus_set_error(error, DBUS_ERROR_FAILED,
+ "%s: no D-Bus interface", __func__);
+ return FALSE;
+ }
+
for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next)
if (!network_is_persistent_group(ssid))
num++;
@@ -3791,6 +3855,7 @@ dbus_bool_t wpas_dbus_getter_bss_wps(DBusMessageIter *iter, DBusError *error,
struct wpabuf *wps_ie;
#endif /* CONFIG_WPS */
DBusMessageIter iter_dict, variant_iter;
+ int wps_support = 0;
const char *type = "";
res = get_bss_helper(args, error, __func__);
@@ -3805,6 +3870,7 @@ dbus_bool_t wpas_dbus_getter_bss_wps(DBusMessageIter *iter, DBusError *error,
#ifdef CONFIG_WPS
wps_ie = wpa_bss_get_vendor_ie_multi(res, WPS_IE_VENDOR_TYPE);
if (wps_ie) {
+ wps_support = 1;
if (wps_is_selected_pbc_registrar(wps_ie))
type = "pbc";
else if (wps_is_selected_pin_registrar(wps_ie))
@@ -3814,7 +3880,7 @@ dbus_bool_t wpas_dbus_getter_bss_wps(DBusMessageIter *iter, DBusError *error,
}
#endif /* CONFIG_WPS */
- if (!wpa_dbus_dict_append_string(&iter_dict, "Type", type) ||
+ if ((wps_support && !wpa_dbus_dict_append_string(&iter_dict, "Type", type)) ||
!wpa_dbus_dict_close_write(&variant_iter, &iter_dict) ||
!dbus_message_iter_close_container(iter, &variant_iter))
goto nomem;
@@ -4102,7 +4168,7 @@ void wpas_dbus_signal_preq(struct wpa_supplicant *wpa_s,
struct wpas_dbus_priv *priv = wpa_s->global->dbus;
/* Do nothing if the control interface is not turned on */
- if (priv == NULL)
+ if (priv == NULL || !wpa_s->dbus_new_path)
return;
if (wpa_s->preq_notify_peer == NULL)
diff --git a/wpa_supplicant/dbus/dbus_new_handlers.h b/wpa_supplicant/dbus/dbus_new_handlers.h
index 6113db5..50f72ec 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.h
+++ b/wpa_supplicant/dbus/dbus_new_handlers.h
@@ -107,6 +107,9 @@ DBusMessage * wpas_dbus_handler_reassociate(DBusMessage *message,
DBusMessage * wpas_dbus_handler_reattach(DBusMessage *message,
struct wpa_supplicant *wpa_s);
+DBusMessage * wpas_dbus_handler_reconnect(DBusMessage *message,
+ struct wpa_supplicant *wpa_s);
+
DBusMessage * wpas_dbus_handler_remove_network(DBusMessage *message,
struct wpa_supplicant *wpa_s);
@@ -291,6 +294,9 @@ dbus_bool_t wpas_dbus_setter_network_properties(DBusMessageIter *iter,
DBusMessage * wpas_dbus_handler_wps_start(DBusMessage *message,
struct wpa_supplicant *wpa_s);
+DBusMessage * wpas_dbus_handler_wps_cancel(DBusMessage *message,
+ struct wpa_supplicant *wpa_s);
+
dbus_bool_t wpas_dbus_getter_process_credentials(DBusMessageIter *iter,
DBusError *error, void *user_data);
diff --git a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
index 0eff763..67c079e 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
@@ -127,8 +127,7 @@ DBusMessage * wpas_dbus_handler_p2p_find(DBusMessage *message,
wpa_dbus_dict_entry_clear(&entry);
}
- if (wpa_s->p2p_dev)
- wpa_s = wpa_s->p2p_dev;
+ wpa_s = wpa_s->global->p2p_init_wpa_s;
wpas_p2p_find(wpa_s, timeout, type, num_req_dev_types, req_dev_types,
NULL, 0, 0, NULL, 0);
@@ -147,10 +146,7 @@ error:
DBusMessage * wpas_dbus_handler_p2p_stop_find(DBusMessage *message,
struct wpa_supplicant *wpa_s)
{
- if (wpa_s->p2p_dev)
- wpa_s = wpa_s->p2p_dev;
-
- wpas_p2p_stop_find(wpa_s);
+ wpas_p2p_stop_find(wpa_s->global->p2p_init_wpa_s);
return NULL;
}
@@ -168,8 +164,7 @@ DBusMessage * wpas_dbus_handler_p2p_rejectpeer(DBusMessage *message,
if (parse_peer_object_path(peer_object_path, peer_addr) < 0)
return wpas_dbus_error_invalid_args(message, NULL);
- if (wpa_s->p2p_dev)
- wpa_s = wpa_s->p2p_dev;
+ wpa_s = wpa_s->global->p2p_init_wpa_s;
if (wpas_p2p_reject(wpa_s, peer_addr) < 0)
return wpas_dbus_error_unknown_error(message,
@@ -188,8 +183,7 @@ DBusMessage * wpas_dbus_handler_p2p_listen(DBusMessage *message,
DBUS_TYPE_INVALID))
return wpas_dbus_error_no_memory(message);
- if (wpa_s->p2p_dev)
- wpa_s = wpa_s->p2p_dev;
+ wpa_s = wpa_s->global->p2p_init_wpa_s;
if (wpas_p2p_listen(wpa_s, (unsigned int) timeout)) {
return dbus_message_new_error(message,
@@ -230,8 +224,7 @@ DBusMessage * wpas_dbus_handler_p2p_extendedlisten(
wpa_dbus_dict_entry_clear(&entry);
}
- if (wpa_s->p2p_dev)
- wpa_s = wpa_s->p2p_dev;
+ wpa_s = wpa_s->global->p2p_init_wpa_s;
if (wpas_p2p_ext_listen(wpa_s, period, interval))
return wpas_dbus_error_unknown_error(
@@ -282,9 +275,6 @@ DBusMessage * wpas_dbus_handler_p2p_presence_request(
wpa_dbus_dict_entry_clear(&entry);
}
- if (wpa_s->p2p_dev)
- wpa_s = wpa_s->p2p_dev;
-
if (wpas_p2p_presence_req(wpa_s, dur1, int1, dur2, int2) < 0)
return wpas_dbus_error_unknown_error(message,
"Failed to invoke presence request.");
@@ -339,8 +329,7 @@ DBusMessage * wpas_dbus_handler_p2p_group_add(DBusMessage *message,
wpa_dbus_dict_entry_clear(&entry);
}
- if (wpa_s->p2p_dev)
- wpa_s = wpa_s->p2p_dev;
+ wpa_s = wpa_s->global->p2p_init_wpa_s;
if (pg_object_path != NULL) {
char *net_id_str;
@@ -354,7 +343,8 @@ DBusMessage * wpas_dbus_handler_p2p_group_add(DBusMessage *message,
pg_object_path, WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART,
&net_id_str);
if (iface == NULL || net_id_str == NULL ||
- os_strcmp(iface, wpa_s->dbus_new_path) != 0) {
+ !wpa_s->parent->dbus_new_path ||
+ os_strcmp(iface, wpa_s->parent->dbus_new_path) != 0) {
reply =
wpas_dbus_error_invalid_args(message,
pg_object_path);
@@ -374,7 +364,7 @@ DBusMessage * wpas_dbus_handler_p2p_group_add(DBusMessage *message,
goto inv_args;
if (wpas_p2p_group_add_persistent(wpa_s, ssid, 0, freq, 0, 0, 0,
- NULL, 0)) {
+ NULL, 0, 0)) {
reply = wpas_dbus_error_unknown_error(
message,
"Failed to reinvoke a persistent group");
@@ -426,6 +416,64 @@ static dbus_bool_t wpa_dbus_p2p_check_enabled(struct wpa_supplicant *wpa_s,
}
+DBusMessage * wpas_dbus_handler_p2p_remove_client(DBusMessage *message,
+ struct wpa_supplicant *wpa_s)
+{
+ DBusMessageIter iter_dict;
+ DBusMessage *reply = NULL;
+ DBusMessageIter iter;
+ struct wpa_dbus_dict_entry entry;
+ char *peer_object_path = NULL;
+ char *interface_addr = NULL;
+ u8 peer_addr[ETH_ALEN];
+
+ if (!wpa_dbus_p2p_check_enabled(wpa_s, message, &reply, NULL))
+ return reply;
+
+ dbus_message_iter_init(message, &iter);
+
+ if (!wpa_dbus_dict_open_read(&iter, &iter_dict, NULL))
+ goto err;
+
+ while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
+ if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
+ goto err;
+
+ if (os_strcmp(entry.key, "peer") == 0 &&
+ entry.type == DBUS_TYPE_OBJECT_PATH) {
+ os_free(peer_object_path);
+ peer_object_path = os_strdup(entry.str_value);
+ wpa_dbus_dict_entry_clear(&entry);
+ } else if (os_strcmp(entry.key, "iface") == 0 &&
+ entry.type == DBUS_TYPE_STRING) {
+ os_free(interface_addr);
+ interface_addr = os_strdup(entry.str_value);
+ wpa_dbus_dict_entry_clear(&entry);
+ } else {
+ wpa_dbus_dict_entry_clear(&entry);
+ goto err;
+ }
+ }
+
+ if ((!peer_object_path && !interface_addr) ||
+ (peer_object_path &&
+ (parse_peer_object_path(peer_object_path, peer_addr) < 0 ||
+ !p2p_peer_known(wpa_s->global->p2p, peer_addr))) ||
+ (interface_addr && hwaddr_aton(interface_addr, peer_addr) < 0))
+ goto err;
+
+ wpas_p2p_remove_client(wpa_s, peer_addr, interface_addr != NULL);
+ reply = NULL;
+out:
+ os_free(peer_object_path);
+ os_free(interface_addr);
+ return reply;
+err:
+ reply = wpas_dbus_error_invalid_args(message, "Invalid address format");
+ goto out;
+}
+
+
DBusMessage * wpas_dbus_handler_p2p_flush(DBusMessage *message,
struct wpa_supplicant *wpa_s)
{
@@ -434,8 +482,7 @@ DBusMessage * wpas_dbus_handler_p2p_flush(DBusMessage *message,
if (!wpa_dbus_p2p_check_enabled(wpa_s, message, &reply, NULL))
return reply;
- if (wpa_s->p2p_dev)
- wpa_s = wpa_s->p2p_dev;
+ wpa_s = wpa_s->global->p2p_init_wpa_s;
os_memset(wpa_s->p2p_auth_invite, 0, ETH_ALEN);
wpa_s->force_long_sd = 0;
@@ -531,8 +578,7 @@ DBusMessage * wpas_dbus_handler_p2p_connect(DBusMessage *message,
if ((!pin || !pin[0]) && wps_method == WPS_PIN_KEYPAD)
goto inv_args;
- if (wpa_s->p2p_dev)
- wpa_s = wpa_s->p2p_dev;
+ wpa_s = wpa_s->global->p2p_init_wpa_s;
new_pin = wpas_p2p_connect(wpa_s, addr, pin, wps_method,
persistent_group, 0, join, authorize_only,
@@ -587,6 +633,26 @@ inv_args:
}
+/**
+ * wpas_dbus_handler_p2p_cancel - Cancel P2P group formation
+ * @message: Pointer to incoming dbus message
+ * @wpa_s: %wpa_supplicant data structure
+ * Returns: NULL on success or DBus error on failure
+ *
+ * Handler for "Cancel" method call. Returns NULL if P2P cancel succeeds or DBus
+ * error on P2P cancel failure
+ */
+DBusMessage * wpas_dbus_handler_p2p_cancel(DBusMessage *message,
+ struct wpa_supplicant *wpa_s)
+{
+ if (wpas_p2p_cancel(wpa_s))
+ return wpas_dbus_error_unknown_error(message,
+ "P2P cancel failed");
+
+ return NULL;
+}
+
+
DBusMessage * wpas_dbus_handler_p2p_invite(DBusMessage *message,
struct wpa_supplicant *wpa_s)
{
@@ -634,8 +700,7 @@ DBusMessage * wpas_dbus_handler_p2p_invite(DBusMessage *message,
!p2p_peer_known(wpa_s->global->p2p, peer_addr))
goto err;
- if (wpa_s->p2p_dev)
- wpa_s = wpa_s->p2p_dev;
+ wpa_s = wpa_s->global->p2p_init_wpa_s;
if (persistent) {
char *net_id_str;
@@ -649,7 +714,8 @@ DBusMessage * wpas_dbus_handler_p2p_invite(DBusMessage *message,
WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART,
&net_id_str);
if (iface == NULL || net_id_str == NULL ||
- os_strcmp(iface, wpa_s->dbus_new_path) != 0) {
+ !wpa_s->parent->dbus_new_path ||
+ os_strcmp(iface, wpa_s->parent->dbus_new_path) != 0) {
reply = wpas_dbus_error_invalid_args(message,
pg_object_path);
goto out;
@@ -726,8 +792,7 @@ DBusMessage * wpas_dbus_handler_p2p_prov_disc_req(DBusMessage *message,
os_strcmp(config_method, "pushbutton"))
return wpas_dbus_error_invalid_args(message, NULL);
- if (wpa_s->p2p_dev)
- wpa_s = wpa_s->p2p_dev;
+ wpa_s = wpa_s->global->p2p_init_wpa_s;
if (wpas_p2p_prov_disc(wpa_s, peer_addr, config_method,
WPAS_P2P_PD_FOR_GO_NEG, NULL) < 0)
@@ -758,8 +823,7 @@ dbus_bool_t wpas_dbus_getter_p2p_device_config(DBusMessageIter *iter,
if (!wpa_dbus_p2p_check_enabled(wpa_s, NULL, NULL, error))
return FALSE;
- if (wpa_s->p2p_dev)
- wpa_s = wpa_s->p2p_dev;
+ wpa_s = wpa_s->global->p2p_init_wpa_s;
if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
"a{sv}", &variant_iter) ||
@@ -864,8 +928,7 @@ dbus_bool_t wpas_dbus_setter_p2p_device_config(DBusMessageIter *iter,
if (!wpa_dbus_p2p_check_enabled(wpa_s, NULL, NULL, error))
return FALSE;
- if (wpa_s->p2p_dev)
- wpa_s = wpa_s->p2p_dev;
+ wpa_s = wpa_s->global->p2p_init_wpa_s;
dbus_message_iter_recurse(iter, &variant_iter);
if (!wpa_dbus_dict_open_read(&variant_iter, &iter_dict, error))
@@ -1043,7 +1106,8 @@ dbus_bool_t wpas_dbus_getter_p2p_peers(DBusMessageIter *iter, DBusError *error,
char **peer_obj_paths = NULL;
- if (!wpa_dbus_p2p_check_enabled(wpa_s, NULL, NULL, error))
+ if (!wpa_dbus_p2p_check_enabled(wpa_s, NULL, NULL, error) ||
+ !wpa_s->parent->parent->dbus_new_path)
return FALSE;
dl_list_init(&peer_objpath_list);
@@ -1064,7 +1128,8 @@ dbus_bool_t wpas_dbus_getter_p2p_peers(DBusMessageIter *iter, DBusError *error,
os_snprintf(node->path, WPAS_DBUS_OBJECT_PATH_MAX,
"%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/" COMPACT_MACSTR,
- wpa_s->dbus_new_path, MAC2STR(addr));
+ wpa_s->parent->parent->dbus_new_path,
+ MAC2STR(addr));
dl_list_add_tail(&peer_objpath_list, &node->list);
num++;
@@ -1184,13 +1249,17 @@ dbus_bool_t wpas_dbus_getter_p2p_peergo(DBusMessageIter *iter,
struct wpa_supplicant *wpa_s = user_data;
char go_peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
+ if (!wpa_s->parent->parent->dbus_new_path)
+ return FALSE;
+
if (wpas_get_p2p_role(wpa_s) != WPAS_P2P_ROLE_CLIENT)
os_snprintf(go_peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX, "/");
else
os_snprintf(go_peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
"%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
COMPACT_MACSTR,
- wpa_s->dbus_new_path, MAC2STR(wpa_s->go_dev_addr));
+ wpa_s->parent->parent->dbus_new_path,
+ MAC2STR(wpa_s->go_dev_addr));
path = go_peer_obj_path;
return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_OBJECT_PATH,
@@ -1240,6 +1309,154 @@ dbus_bool_t wpas_dbus_getter_p2p_peer_device_name(DBusMessageIter *iter,
}
+dbus_bool_t wpas_dbus_getter_p2p_peer_manufacturer(DBusMessageIter *iter,
+ DBusError *error,
+ void *user_data)
+{
+ struct peer_handler_args *peer_args = user_data;
+ const struct p2p_peer_info *info;
+ char *tmp;
+
+ if (!wpa_dbus_p2p_check_enabled(peer_args->wpa_s, NULL, NULL, error))
+ return FALSE;
+
+ /* get the peer info */
+ info = p2p_get_peer_found(peer_args->wpa_s->global->p2p,
+ peer_args->p2p_device_addr, 0);
+ if (info == NULL) {
+ dbus_set_error(error, DBUS_ERROR_FAILED, "failed to find peer");
+ return FALSE;
+ }
+
+ tmp = os_strdup(info->manufacturer);
+ if (!tmp) {
+ dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
+ return FALSE;
+ }
+
+ if (!wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING, &tmp,
+ error)) {
+ dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
+ os_free(tmp);
+ return FALSE;
+ }
+
+ os_free(tmp);
+ return TRUE;
+}
+
+
+dbus_bool_t wpas_dbus_getter_p2p_peer_modelname(DBusMessageIter *iter,
+ DBusError *error,
+ void *user_data)
+{
+ struct peer_handler_args *peer_args = user_data;
+ const struct p2p_peer_info *info;
+ char *tmp;
+
+ if (!wpa_dbus_p2p_check_enabled(peer_args->wpa_s, NULL, NULL, error))
+ return FALSE;
+
+ /* get the peer info */
+ info = p2p_get_peer_found(peer_args->wpa_s->global->p2p,
+ peer_args->p2p_device_addr, 0);
+ if (info == NULL) {
+ dbus_set_error(error, DBUS_ERROR_FAILED, "failed to find peer");
+ return FALSE;
+ }
+
+ tmp = os_strdup(info->model_name);
+ if (!tmp) {
+ dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
+ return FALSE;
+ }
+
+ if (!wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING, &tmp,
+ error)) {
+ dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
+ os_free(tmp);
+ return FALSE;
+ }
+
+ os_free(tmp);
+ return TRUE;
+}
+
+
+dbus_bool_t wpas_dbus_getter_p2p_peer_modelnumber(DBusMessageIter *iter,
+ DBusError *error,
+ void *user_data)
+{
+ struct peer_handler_args *peer_args = user_data;
+ const struct p2p_peer_info *info;
+ char *tmp;
+
+ if (!wpa_dbus_p2p_check_enabled(peer_args->wpa_s, NULL, NULL, error))
+ return FALSE;
+
+ /* get the peer info */
+ info = p2p_get_peer_found(peer_args->wpa_s->global->p2p,
+ peer_args->p2p_device_addr, 0);
+ if (info == NULL) {
+ dbus_set_error(error, DBUS_ERROR_FAILED, "failed to find peer");
+ return FALSE;
+ }
+
+ tmp = os_strdup(info->model_number);
+ if (!tmp) {
+ dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
+ return FALSE;
+ }
+
+ if (!wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING, &tmp,
+ error)) {
+ dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
+ os_free(tmp);
+ return FALSE;
+ }
+
+ os_free(tmp);
+ return TRUE;
+}
+
+
+dbus_bool_t wpas_dbus_getter_p2p_peer_serialnumber(DBusMessageIter *iter,
+ DBusError *error,
+ void *user_data)
+{
+ struct peer_handler_args *peer_args = user_data;
+ const struct p2p_peer_info *info;
+ char *tmp;
+
+ if (!wpa_dbus_p2p_check_enabled(peer_args->wpa_s, NULL, NULL, error))
+ return FALSE;
+
+ /* get the peer info */
+ info = p2p_get_peer_found(peer_args->wpa_s->global->p2p,
+ peer_args->p2p_device_addr, 0);
+ if (info == NULL) {
+ dbus_set_error(error, DBUS_ERROR_FAILED, "failed to find peer");
+ return FALSE;
+ }
+
+ tmp = os_strdup(info->serial_number);
+ if (!tmp) {
+ dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
+ return FALSE;
+ }
+
+ if (!wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING, &tmp,
+ error)) {
+ dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
+ os_free(tmp);
+ return FALSE;
+ }
+
+ os_free(tmp);
+ return TRUE;
+}
+
+
dbus_bool_t wpas_dbus_getter_p2p_peer_primary_device_type(
DBusMessageIter *iter, DBusError *error, void *user_data)
{
@@ -1578,8 +1795,7 @@ dbus_bool_t wpas_dbus_getter_p2p_peer_groups(DBusMessageIter *iter,
os_memset(&data, 0, sizeof(data));
wpa_s = peer_args->wpa_s;
- if (wpa_s->p2p_dev)
- wpa_s = wpa_s->p2p_dev;
+ wpa_s = wpa_s->global->p2p_init_wpa_s;
wpa_s_go = wpas_get_p2p_client_iface(wpa_s, info->p2p_device_addr);
if (wpa_s_go) {
@@ -1636,6 +1852,10 @@ dbus_bool_t wpas_dbus_getter_persistent_groups(DBusMessageIter *iter,
unsigned int i = 0, num = 0;
dbus_bool_t success = FALSE;
+ wpa_s = wpa_s->global->p2p_init_wpa_s;
+ if (!wpa_s->parent->dbus_new_path)
+ return FALSE;
+
for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next)
if (network_is_persistent_group(ssid))
num++;
@@ -1659,7 +1879,7 @@ dbus_bool_t wpas_dbus_getter_persistent_groups(DBusMessageIter *iter,
/* Construct the object path for this network. */
os_snprintf(paths[i++], WPAS_DBUS_OBJECT_PATH_MAX,
"%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART "/%d",
- wpa_s->dbus_new_path, ssid->id);
+ wpa_s->parent->dbus_new_path, ssid->id);
}
success = wpas_dbus_simple_array_property_getter(iter,
@@ -1698,7 +1918,7 @@ dbus_bool_t wpas_dbus_getter_persistent_group_properties(DBusMessageIter *iter,
/**
- * wpas_dbus_setter_persistent_group_properties - Get options for a persistent
+ * wpas_dbus_setter_persistent_group_properties - Set options for a persistent
* group
* @iter: Pointer to incoming dbus message iter
* @error: Location to store error on failure
@@ -1746,7 +1966,9 @@ DBusMessage * wpas_dbus_handler_add_persistent_group(
dbus_message_iter_init(message, &iter);
- ssid = wpa_config_add_network(wpa_s->conf);
+ wpa_s = wpa_s->global->p2p_init_wpa_s;
+ if (wpa_s->parent->dbus_new_path)
+ ssid = wpa_config_add_network(wpa_s->conf);
if (ssid == NULL) {
wpa_printf(MSG_ERROR,
"dbus: %s: Cannot add new persistent group",
@@ -1779,7 +2001,7 @@ DBusMessage * wpas_dbus_handler_add_persistent_group(
/* Construct the object path for this network. */
os_snprintf(path, WPAS_DBUS_OBJECT_PATH_MAX,
"%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART "/%d",
- wpa_s->dbus_new_path, ssid->id);
+ wpa_s->parent->dbus_new_path, ssid->id);
reply = dbus_message_new_method_return(message);
if (reply == NULL) {
@@ -1826,6 +2048,8 @@ DBusMessage * wpas_dbus_handler_remove_persistent_group(
dbus_message_get_args(message, NULL, DBUS_TYPE_OBJECT_PATH, &op,
DBUS_TYPE_INVALID);
+ wpa_s = wpa_s->global->p2p_init_wpa_s;
+
/*
* Extract the network ID and ensure the network is actually a child of
* this interface.
@@ -1834,7 +2058,8 @@ DBusMessage * wpas_dbus_handler_remove_persistent_group(
op, WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART,
&persistent_group_id);
if (iface == NULL || persistent_group_id == NULL ||
- os_strcmp(iface, wpa_s->dbus_new_path) != 0) {
+ !wpa_s->parent->dbus_new_path ||
+ os_strcmp(iface, wpa_s->parent->dbus_new_path) != 0) {
reply = wpas_dbus_error_invalid_args(message, op);
goto out;
}
@@ -1899,6 +2124,8 @@ DBusMessage * wpas_dbus_handler_remove_all_persistent_groups(
struct wpa_ssid *ssid, *next;
struct wpa_config *config;
+ wpa_s = wpa_s->global->p2p_init_wpa_s;
+
config = wpa_s->conf;
ssid = config->ssid;
while (ssid) {
@@ -1928,6 +2155,9 @@ dbus_bool_t wpas_dbus_getter_p2p_group_members(DBusMessageIter *iter,
const u8 *addr;
dbus_bool_t success = FALSE;
+ if (!wpa_s->parent->parent->dbus_new_path)
+ return FALSE;
+
/* Verify correct role for this property */
if (wpas_get_p2p_role(wpa_s) != WPAS_P2P_ROLE_GO) {
return wpas_dbus_simple_array_property_getter(
@@ -1955,7 +2185,8 @@ dbus_bool_t wpas_dbus_getter_p2p_group_members(DBusMessageIter *iter,
os_snprintf(paths[i], WPAS_DBUS_OBJECT_PATH_MAX,
"%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/" COMPACT_MACSTR,
- wpa_s->parent->dbus_new_path, MAC2STR(addr));
+ wpa_s->parent->parent->dbus_new_path,
+ MAC2STR(addr));
i++;
}
diff --git a/wpa_supplicant/dbus/dbus_new_handlers_p2p.h b/wpa_supplicant/dbus/dbus_new_handlers_p2p.h
index fdaccba..2aecbbe 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers_p2p.h
+++ b/wpa_supplicant/dbus/dbus_new_handlers_p2p.h
@@ -46,6 +46,9 @@ DBusMessage *wpas_dbus_handler_p2p_connect(
DBusMessage *message,
struct wpa_supplicant *wpa_s);
+DBusMessage * wpas_dbus_handler_p2p_cancel(DBusMessage *message,
+ struct wpa_supplicant *wpa_s);
+
DBusMessage *wpas_dbus_handler_p2p_invite(
DBusMessage *message,
struct wpa_supplicant *wpa_s);
@@ -53,6 +56,9 @@ DBusMessage *wpas_dbus_handler_p2p_invite(
DBusMessage *wpas_dbus_handler_p2p_disconnect(
DBusMessage *message, struct wpa_supplicant *wpa_s);
+DBusMessage * wpas_dbus_handler_p2p_remove_client(
+ DBusMessage *message, struct wpa_supplicant *wpa_s);
+
DBusMessage *wpas_dbus_handler_p2p_flush(
DBusMessage *message, struct wpa_supplicant *wpa_s);
@@ -112,6 +118,22 @@ dbus_bool_t wpas_dbus_getter_p2p_peer_device_name(DBusMessageIter *iter,
DBusError *error,
void *user_data);
+dbus_bool_t wpas_dbus_getter_p2p_peer_manufacturer(DBusMessageIter *iter,
+ DBusError *error,
+ void *user_data);
+
+dbus_bool_t wpas_dbus_getter_p2p_peer_modelname(DBusMessageIter *iter,
+ DBusError *error,
+ void *user_data);
+
+dbus_bool_t wpas_dbus_getter_p2p_peer_modelnumber(DBusMessageIter *iter,
+ DBusError *error,
+ void *user_data);
+
+dbus_bool_t wpas_dbus_getter_p2p_peer_serialnumber(DBusMessageIter *iter,
+ DBusError *error,
+ void *user_data);
+
dbus_bool_t wpas_dbus_getter_p2p_peer_primary_device_type(
DBusMessageIter *iter, DBusError *error, void *user_data);
diff --git a/wpa_supplicant/dbus/dbus_new_handlers_wps.c b/wpa_supplicant/dbus/dbus_new_handlers_wps.c
index a94a0e5..b2251ba 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers_wps.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers_wps.c
@@ -53,7 +53,7 @@ static int wpas_dbus_handler_wps_role(DBusMessage *message,
else if (os_strcmp(val, "registrar") == 0)
params->role = 2;
else {
- wpa_printf(MSG_DEBUG, "dbus: WPS.Start - Uknown role %s", val);
+ wpa_printf(MSG_DEBUG, "dbus: WPS.Start - Unknown role %s", val);
*reply = wpas_dbus_error_invalid_args(message, val);
return -1;
}
@@ -113,7 +113,7 @@ static int wpas_dbus_handler_wps_bssid(DBusMessage *message,
dbus_message_iter_recurse(&variant_iter, &array_iter);
dbus_message_iter_get_fixed_array(&array_iter, &params->bssid, &len);
if (len != ETH_ALEN) {
- wpa_printf(MSG_DEBUG, "dbus: WPS.Stsrt - Wrong Bssid length %d",
+ wpa_printf(MSG_DEBUG, "dbus: WPS.Start - Wrong Bssid length %d",
len);
*reply = wpas_dbus_error_invalid_args(message,
"Bssid is wrong length");
@@ -320,6 +320,26 @@ DBusMessage * wpas_dbus_handler_wps_start(DBusMessage *message,
/**
+ * wpas_dbus_handler_wps_cancel - Cancel ongoing WPS configuration
+ * @message: Pointer to incoming dbus message
+ * @wpa_s: %wpa_supplicant data structure
+ * Returns: NULL on success or DBus error on failure
+ *
+ * Handler for "Cancel" method call. Returns NULL if WPS cancel successfull
+ * or DBus error on WPS cancel failure
+ */
+DBusMessage * wpas_dbus_handler_wps_cancel(DBusMessage *message,
+ struct wpa_supplicant *wpa_s)
+{
+ if (wpas_wps_cancel(wpa_s))
+ return wpas_dbus_error_unknown_error(message,
+ "WPS cancel failed");
+
+ return NULL;
+}
+
+
+/**
* wpas_dbus_getter_process_credentials - Check if credentials are processed
* @message: Pointer to incoming dbus message
* @wpa_s: %wpa_supplicant data structure
@@ -358,6 +378,8 @@ dbus_bool_t wpas_dbus_setter_process_credentials(DBusMessageIter *iter,
struct wpa_supplicant *wpa_s = user_data;
dbus_bool_t process_credentials, old_pc;
+ if (!wpa_s->dbus_new_path)
+ return FALSE;
if (!wpas_dbus_simple_property_setter(iter, error, DBUS_TYPE_BOOLEAN,
&process_credentials))
return FALSE;
diff --git a/wpa_supplicant/dbus/dbus_new_helpers.c b/wpa_supplicant/dbus/dbus_new_helpers.c
index 15b0901..45623f3 100644
--- a/wpa_supplicant/dbus/dbus_new_helpers.c
+++ b/wpa_supplicant/dbus/dbus_new_helpers.c
@@ -46,8 +46,13 @@ static dbus_bool_t fill_dict_with_properties(
goto error;
/* An error getting a property fails the request entirely */
- if (!dsc->getter(&entry_iter, error, user_data))
+ if (!dsc->getter(&entry_iter, error, user_data)) {
+ wpa_printf(MSG_INFO,
+ "dbus: %s dbus_interface=%s dbus_property=%s getter failed",
+ __func__, dsc->dbus_interface,
+ dsc->dbus_property);
return FALSE;
+ }
if (!dbus_message_iter_close_container(dict_iter, &entry_iter))
goto error;
diff --git a/wpa_supplicant/dbus/dbus_new_introspect.c b/wpa_supplicant/dbus/dbus_new_introspect.c
index 6209c67..fba57e6 100644
--- a/wpa_supplicant/dbus/dbus_new_introspect.c
+++ b/wpa_supplicant/dbus/dbus_new_introspect.c
@@ -257,7 +257,7 @@ DBusMessage * wpa_dbus_introspect(DBusMessage *message,
DBusMessage *reply;
struct wpabuf *xml;
- xml = wpabuf_alloc(10000);
+ xml = wpabuf_alloc(15000);
if (xml == NULL)
return NULL;
diff --git a/wpa_supplicant/dbus/dbus_old.c b/wpa_supplicant/dbus/dbus_old.c
index 45bb402..88227af 100644
--- a/wpa_supplicant/dbus/dbus_old.c
+++ b/wpa_supplicant/dbus/dbus_old.c
@@ -383,7 +383,7 @@ void wpa_supplicant_dbus_notify_scan_results(struct wpa_supplicant *wpa_s)
DBusMessage *_signal;
/* Do nothing if the control interface is not turned on */
- if (iface == NULL)
+ if (iface == NULL || !wpa_s->dbus_path)
return;
_signal = dbus_message_new_signal(wpa_s->dbus_path,
@@ -474,7 +474,7 @@ void wpa_supplicant_dbus_notify_scanning(struct wpa_supplicant *wpa_s)
dbus_bool_t scanning = wpa_s->scanning ? TRUE : FALSE;
/* Do nothing if the control interface is not turned on */
- if (iface == NULL)
+ if (iface == NULL || !wpa_s->dbus_path)
return;
_signal = dbus_message_new_signal(wpa_s->dbus_path,
@@ -509,7 +509,7 @@ void wpa_supplicant_dbus_notify_wps_cred(struct wpa_supplicant *wpa_s,
if (wpa_s->global == NULL)
return;
iface = wpa_s->global->dbus;
- if (iface == NULL)
+ if (iface == NULL || !wpa_s->dbus_path)
return;
_signal = dbus_message_new_signal(wpa_s->dbus_path,
@@ -559,7 +559,7 @@ void wpa_supplicant_dbus_notify_certification(struct wpa_supplicant *wpa_s,
if (wpa_s->global == NULL)
return;
iface = wpa_s->global->dbus;
- if (iface == NULL)
+ if (iface == NULL || !wpa_s->dbus_path)
return;
_signal = dbus_message_new_signal(wpa_s->dbus_path,
@@ -738,7 +738,7 @@ struct wpa_supplicant * wpa_supplicant_get_iface_by_dbus_path(
struct wpa_supplicant *wpa_s;
for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
- if (strcmp(wpa_s->dbus_path, path) == 0)
+ if (wpa_s->dbus_path && strcmp(wpa_s->dbus_path, path) == 0)
return wpa_s;
}
return NULL;
diff --git a/wpa_supplicant/dbus/dbus_old_handlers.c b/wpa_supplicant/dbus/dbus_old_handlers.c
index 773ee8b..e8f62ef 100644
--- a/wpa_supplicant/dbus/dbus_old_handlers.c
+++ b/wpa_supplicant/dbus/dbus_old_handlers.c
@@ -166,7 +166,7 @@ DBusMessage * wpas_dbus_global_add_interface(DBusMessage *message,
iface.bridge_ifname = bridge_ifname;
/* Otherwise, have wpa_supplicant attach to it. */
wpa_s = wpa_supplicant_add_iface(global, &iface, NULL);
- if (wpa_s) {
+ if (wpa_s && wpa_s->dbus_path) {
const char *path = wpa_s->dbus_path;
reply = dbus_message_new_method_return(message);
@@ -262,7 +262,7 @@ DBusMessage * wpas_dbus_global_get_interface(DBusMessage *message,
}
wpa_s = wpa_supplicant_get_iface(global, ifname);
- if (wpa_s == NULL) {
+ if (wpa_s == NULL || !wpa_s->dbus_path) {
reply = wpas_dbus_new_invalid_iface_error(message);
goto out;
}
@@ -354,6 +354,11 @@ DBusMessage * wpas_dbus_iface_scan_results(DBusMessage *message,
DBusMessageIter sub_iter;
struct wpa_bss *bss;
+ if (!wpa_s->dbus_path)
+ return dbus_message_new_error(message,
+ WPAS_ERROR_INTERNAL_ERROR,
+ "no D-Bus interface available");
+
/* Create and initialize the return message */
reply = dbus_message_new_method_return(message);
dbus_message_iter_init_append(reply, &iter);
@@ -495,7 +500,7 @@ DBusMessage * wpas_dbus_iface_capabilities(DBusMessage *message,
/* EAP methods */
eap_methods = eap_get_names_as_string_array(&num_items);
if (eap_methods) {
- dbus_bool_t success = FALSE;
+ dbus_bool_t success;
size_t i = 0;
success = wpa_dbus_dict_append_string_array(
@@ -708,10 +713,11 @@ DBusMessage * wpas_dbus_iface_add_network(DBusMessage *message,
struct wpa_supplicant *wpa_s)
{
DBusMessage *reply = NULL;
- struct wpa_ssid *ssid;
+ struct wpa_ssid *ssid = NULL;
char path_buf[WPAS_DBUS_OBJECT_PATH_MAX], *path = path_buf;
- ssid = wpa_config_add_network(wpa_s->conf);
+ if (wpa_s->dbus_path)
+ ssid = wpa_config_add_network(wpa_s->conf);
if (ssid == NULL) {
reply = dbus_message_new_error(
message, WPAS_ERROR_ADD_NETWORK_ERROR,
@@ -769,7 +775,7 @@ DBusMessage * wpas_dbus_iface_remove_network(DBusMessage *message,
}
/* Ensure the network is actually a child of this interface */
- if (os_strcmp(iface, wpa_s->dbus_path) != 0) {
+ if (!wpa_s->dbus_path || os_strcmp(iface, wpa_s->dbus_path) != 0) {
reply = wpas_dbus_new_invalid_network_error(message);
goto out;
}
@@ -803,10 +809,10 @@ out:
}
-static const char const *dont_quote[] = {
+static const char * const dont_quote[] = {
"key_mgmt", "proto", "pairwise", "auth_alg", "group", "eap",
"opensc_engine_path", "pkcs11_engine_path", "pkcs11_module_path",
- "bssid", NULL
+ "bssid", "scan_freq", "freq_list", NULL
};
@@ -878,7 +884,7 @@ DBusMessage * wpas_dbus_iface_set_network(DBusMessage *message,
if (should_quote_opt(entry.key)) {
size = os_strlen(entry.str_value);
/* Zero-length option check */
- if (size <= 0)
+ if (size == 0)
goto error;
size += 3; /* For quotes and terminator */
value = os_zalloc(size);
@@ -1020,7 +1026,7 @@ DBusMessage * wpas_dbus_iface_select_network(DBusMessage *message,
goto out;
}
/* Ensure the object path really points to this interface */
- if (network == NULL ||
+ if (network == NULL || !wpa_s->dbus_path ||
os_strcmp(iface_obj_path, wpa_s->dbus_path) != 0) {
reply = wpas_dbus_new_invalid_network_error(message);
goto out;
diff --git a/wpa_supplicant/defconfig b/wpa_supplicant/defconfig
index 7f627fd..01a8c2c 100644
--- a/wpa_supplicant/defconfig
+++ b/wpa_supplicant/defconfig
@@ -495,3 +495,12 @@ CONFIG_PEERKEY=y
#
# External password backend for testing purposes (developer use)
#CONFIG_EXT_PASSWORD_TEST=y
+
+# Enable Fast Session Transfer (FST)
+#CONFIG_FST=y
+
+# Enable CLI commands for FST testing
+#CONFIG_FST_TEST=y
+
+# OS X builds. This is only for building eapol_test.
+#CONFIG_OSX=y
diff --git a/wpa_supplicant/doc/docbook/wpa_gui.sgml b/wpa_supplicant/doc/docbook/wpa_gui.sgml
index 84766db..5f7b49d 100644
--- a/wpa_supplicant/doc/docbook/wpa_gui.sgml
+++ b/wpa_supplicant/doc/docbook/wpa_gui.sgml
@@ -16,7 +16,9 @@
<command>wpa_gui</command>
<arg>-p <replaceable>path to ctrl sockets</replaceable></arg>
<arg>-i <replaceable>ifname</replaceable></arg>
+ <arg>-m <replaceable>seconds</replaceable></arg>
<arg>-t</arg>
+ <arg>-q</arg>
</cmdsynopsis>
</refsynopsisdiv>
@@ -51,12 +53,27 @@
</varlistentry>
<varlistentry>
+ <term>-m seconds</term>
+
+ <listitem><para>Set the update interval in seconds for the signal
+ strength meter. This value must be a positive integer, otherwise
+ meter is not enabled (default behavior).</para></listitem>
+ </varlistentry>
+
+ <varlistentry>
<term>-t</term>
<listitem><para>Start program in the system tray only (if the window
manager supports it). By default the main status window is
shown.</para></listitem>
</varlistentry>
+
+ <varlistentry>
+ <term>-q</term>
+
+ <listitem><para>Run program in the quiet mode - do not display tray
+ icon pop-up messages.</para></listitem>
+ </varlistentry>
</variablelist>
</refsect1>
<refsect1>
diff --git a/wpa_supplicant/driver_i.h b/wpa_supplicant/driver_i.h
index 65b430d..73768c7 100644
--- a/wpa_supplicant/driver_i.h
+++ b/wpa_supplicant/driver_i.h
@@ -286,11 +286,13 @@ static inline int wpa_drv_set_country(struct wpa_supplicant *wpa_s,
}
static inline int wpa_drv_send_mlme(struct wpa_supplicant *wpa_s,
- const u8 *data, size_t data_len, int noack)
+ const u8 *data, size_t data_len, int noack,
+ unsigned int freq)
{
if (wpa_s->driver->send_mlme)
return wpa_s->driver->send_mlme(wpa_s->drv_priv,
- data, data_len, noack);
+ data, data_len, noack,
+ freq);
return -1;
}
@@ -503,13 +505,6 @@ static inline int wpa_drv_set_ap_wps_ie(struct wpa_supplicant *wpa_s,
proberesp, assocresp);
}
-static inline int wpa_drv_shared_freq(struct wpa_supplicant *wpa_s)
-{
- if (!wpa_s->driver->shared_freq)
- return -1;
- return wpa_s->driver->shared_freq(wpa_s->drv_priv);
-}
-
static inline int wpa_drv_get_noa(struct wpa_supplicant *wpa_s,
u8 *buf, size_t buf_len)
{
@@ -890,4 +885,31 @@ static inline int wpa_drv_disable_transmit_sa(struct wpa_supplicant *wpa_s,
}
#endif /* CONFIG_MACSEC */
+static inline int wpa_drv_setband(struct wpa_supplicant *wpa_s,
+ enum set_band band)
+{
+ if (!wpa_s->driver->set_band)
+ return -1;
+ return wpa_s->driver->set_band(wpa_s->drv_priv, band);
+}
+
+static inline int wpa_drv_get_pref_freq_list(struct wpa_supplicant *wpa_s,
+ enum wpa_driver_if_type if_type,
+ unsigned int *num,
+ unsigned int *freq_list)
+{
+ if (!wpa_s->driver->get_pref_freq_list)
+ return -1;
+ return wpa_s->driver->get_pref_freq_list(wpa_s->drv_priv, if_type,
+ num, freq_list);
+}
+
+static inline int wpa_drv_set_prob_oper_freq(struct wpa_supplicant *wpa_s,
+ unsigned int freq)
+{
+ if (!wpa_s->driver->set_prob_oper_freq)
+ return 0;
+ return wpa_s->driver->set_prob_oper_freq(wpa_s->drv_priv, freq);
+}
+
#endif /* DRIVER_I_H */
diff --git a/wpa_supplicant/eapol_test.c b/wpa_supplicant/eapol_test.c
index 9b7af30..dce7d1f 100644
--- a/wpa_supplicant/eapol_test.c
+++ b/wpa_supplicant/eapol_test.c
@@ -30,7 +30,7 @@
#include "wpas_glue.h"
-struct wpa_driver_ops *wpa_drivers[] = { NULL };
+const struct wpa_driver_ops *const wpa_drivers[] = { NULL };
struct extra_radius_attr {
@@ -76,6 +76,9 @@ struct eapol_test_data {
const char *pcsc_reader;
const char *pcsc_pin;
+
+ unsigned int ctrl_iface:1;
+ unsigned int id_req_sent:1;
};
static struct eapol_test_data eapol_test;
@@ -329,7 +332,11 @@ eapol_test_get_config_blob(void *ctx, const char *name)
static void eapol_test_eapol_done_cb(void *ctx)
{
+ struct eapol_test_data *e = ctx;
+
printf("WPA: EAPOL processing complete\n");
+ wpa_supplicant_cancel_auth_timeout(e->wpa_s);
+ wpa_supplicant_set_state(e->wpa_s, WPA_COMPLETED);
}
@@ -407,6 +414,9 @@ static void eapol_sm_cb(struct eapol_sm *eapol, enum eapol_supp_result result,
{
struct eapol_test_data *e = ctx;
printf("eapol_sm_cb: result=%d\n", result);
+ e->id_req_sent = 0;
+ if (e->ctrl_iface)
+ return;
e->eapol_test_num_reauths--;
if (e->eapol_test_num_reauths < 0)
eloop_terminate();
@@ -552,11 +562,21 @@ static void eapol_test_set_anon_id(void *ctx, const u8 *id, size_t len)
}
+static enum wpa_states eapol_test_get_state(void *ctx)
+{
+ struct eapol_test_data *e = ctx;
+ struct wpa_supplicant *wpa_s = e->wpa_s;
+
+ return wpa_s->wpa_state;
+}
+
+
static int test_eapol(struct eapol_test_data *e, struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid)
{
struct eapol_config eapol_conf;
struct eapol_ctx *ctx;
+ struct wpa_sm_ctx *wctx;
ctx = os_zalloc(sizeof(*ctx));
if (ctx == NULL) {
@@ -590,6 +610,25 @@ static int test_eapol(struct eapol_test_data *e, struct wpa_supplicant *wpa_s,
return -1;
}
+ wpa_s->key_mgmt = WPA_KEY_MGMT_IEEE8021X_NO_WPA;
+ wctx = os_zalloc(sizeof(*wctx));
+ if (wctx == NULL) {
+ os_free(ctx);
+ return -1;
+ }
+ wctx->ctx = e;
+ wctx->msg_ctx = wpa_s;
+ wctx->get_state = eapol_test_get_state;
+ wpa_s->wpa = wpa_sm_init(wctx);
+ if (!wpa_s->wpa) {
+ os_free(ctx);
+ os_free(wctx);
+ return -1;
+ }
+
+ if (!ssid)
+ return 0;
+
wpa_s->current_ssid = ssid;
os_memset(&eapol_conf, 0, sizeof(eapol_conf));
eapol_conf.accept_802_1x_keys = 1;
@@ -614,6 +653,8 @@ static void test_eapol_clean(struct eapol_test_data *e,
{
struct extra_radius_attr *p, *prev;
+ wpa_sm_deinit(wpa_s->wpa);
+ wpa_s->wpa = NULL;
radius_client_deinit(e->radius);
wpabuf_free(e->last_eap_radius);
radius_msg_free(e->last_recv_radius);
@@ -757,6 +798,8 @@ static void ieee802_1x_decapsulate_radius(struct eapol_test_data *e)
break;
case EAP_CODE_FAILURE:
os_strlcpy(buf, "EAP Failure", sizeof(buf));
+ if (e->ctrl_iface)
+ break;
eloop_terminate();
break;
default:
@@ -901,25 +944,66 @@ ieee802_1x_receive_auth(struct radius_msg *msg, struct radius_msg *req,
if ((hdr->code == RADIUS_CODE_ACCESS_ACCEPT &&
e->eapol_test_num_reauths < 0) ||
hdr->code == RADIUS_CODE_ACCESS_REJECT) {
- eloop_terminate();
+ if (!e->ctrl_iface)
+ eloop_terminate();
}
return RADIUS_RX_QUEUED;
}
+static int driver_get_ssid(void *priv, u8 *ssid)
+{
+ ssid[0] = 0;
+ return 0;
+}
+
+
+static int driver_get_bssid(void *priv, u8 *bssid)
+{
+ struct eapol_test_data *e = priv;
+
+ if (e->ctrl_iface && !e->id_req_sent) {
+ eloop_register_timeout(0, 0, send_eap_request_identity,
+ e->wpa_s, NULL);
+ e->id_req_sent = 1;
+ }
+
+ os_memset(bssid, 0, ETH_ALEN);
+ bssid[5] = 1;
+ return 0;
+}
+
+
+static int driver_get_capa(void *priv, struct wpa_driver_capa *capa)
+{
+ os_memset(capa, 0, sizeof(*capa));
+ capa->flags = WPA_DRIVER_FLAGS_WIRED;
+ return 0;
+}
+
+
+struct wpa_driver_ops eapol_test_drv_ops = {
+ .name = "test",
+ .get_ssid = driver_get_ssid,
+ .get_bssid = driver_get_bssid,
+ .get_capa = driver_get_capa,
+};
+
static void wpa_init_conf(struct eapol_test_data *e,
struct wpa_supplicant *wpa_s, const char *authsrv,
int port, const char *secret,
- const char *cli_addr)
+ const char *cli_addr, const char *ifname)
{
struct hostapd_radius_server *as;
int res;
+ wpa_s->driver = &eapol_test_drv_ops;
+ wpa_s->drv_priv = e;
wpa_s->bssid[5] = 1;
os_memcpy(wpa_s->own_addr, e->own_addr, ETH_ALEN);
e->own_ip_addr.s_addr = htonl((127 << 24) | 1);
- os_strlcpy(wpa_s->ifname, "test", sizeof(wpa_s->ifname));
+ os_strlcpy(wpa_s->ifname, ifname, sizeof(wpa_s->ifname));
e->radius_conf = os_zalloc(sizeof(struct hostapd_radius_servers));
assert(e->radius_conf != NULL);
@@ -938,13 +1022,12 @@ static void wpa_init_conf(struct eapol_test_data *e,
*pos++ = a[3];
}
#else /* CONFIG_NATIVE_WINDOWS or CONFIG_ANSI_C_EXTRA */
- if (inet_aton(authsrv, &as->addr.u.v4) < 0) {
+ if (hostapd_parse_ip_addr(authsrv, &as->addr) < 0) {
wpa_printf(MSG_ERROR, "Invalid IP address '%s'",
authsrv);
assert(0);
}
#endif /* CONFIG_NATIVE_WINDOWS or CONFIG_ANSI_C_EXTRA */
- as->addr.af = AF_INET;
as->port = port;
as->shared_secret = (u8 *) os_strdup(secret);
as->shared_secret_len = os_strlen(secret);
@@ -1162,7 +1245,7 @@ static void usage(void)
" [-M<client MAC address>] [-o<server cert file] \\\n"
" [-N<attr spec>] [-R<PC/SC reader>] "
"[-P<PC/SC PIN>] \\\n"
- " [-A<client IP>]\n"
+ " [-A<client IP>] [-i<ifname>] [-T<ctrl_iface>]\n"
"eapol_test scard\n"
"eapol_test sim <PIN> <num triplets> [debug]\n"
"\n");
@@ -1217,6 +1300,8 @@ int main(int argc, char *argv[])
int timeout = 30;
char *pos;
struct extra_radius_attr *p = NULL, *p1;
+ const char *ifname = "test";
+ const char *ctrl_iface = NULL;
if (os_program_init())
return -1;
@@ -1232,7 +1317,7 @@ int main(int argc, char *argv[])
wpa_debug_show_keys = 1;
for (;;) {
- c = getopt(argc, argv, "a:A:c:C:eM:nN:o:p:P:r:R:s:St:W");
+ c = getopt(argc, argv, "a:A:c:C:ei:M:nN:o:p:P:r:R:s:St:T:W");
if (c < 0)
break;
switch (c) {
@@ -1251,6 +1336,9 @@ int main(int argc, char *argv[])
case 'e':
eapol_test.req_eap_key_name = 1;
break;
+ case 'i':
+ ifname = optarg;
+ break;
case 'M':
if (hwaddr_aton(optarg, eapol_test.own_addr)) {
usage();
@@ -1291,6 +1379,10 @@ int main(int argc, char *argv[])
case 't':
timeout = atoi(optarg);
break;
+ case 'T':
+ ctrl_iface = optarg;
+ eapol_test.ctrl_iface = 1;
+ break;
case 'W':
wait_for_monitor++;
break;
@@ -1337,7 +1429,7 @@ int main(int argc, char *argv[])
&argv[optind + 1]);
}
- if (conf == NULL) {
+ if (conf == NULL && !ctrl_iface) {
usage();
printf("Configuration file is required.\n");
return -1;
@@ -1359,12 +1451,15 @@ int main(int argc, char *argv[])
eapol_test.wpa_s = &wpa_s;
dl_list_init(&wpa_s.bss);
dl_list_init(&wpa_s.bss_id);
- wpa_s.conf = wpa_config_read(conf, NULL);
+ if (conf)
+ wpa_s.conf = wpa_config_read(conf, NULL);
+ else
+ wpa_s.conf = wpa_config_alloc_empty(ctrl_iface, NULL);
if (wpa_s.conf == NULL) {
printf("Failed to parse configuration file '%s'.\n", conf);
return -1;
}
- if (wpa_s.conf->ssid == NULL) {
+ if (!ctrl_iface && wpa_s.conf->ssid == NULL) {
printf("No networks defined.\n");
return -1;
}
@@ -1375,7 +1470,7 @@ int main(int argc, char *argv[])
}
wpa_init_conf(&eapol_test, &wpa_s, as_addr, as_port, as_secret,
- cli_addr);
+ cli_addr, ifname);
wpa_s.ctrl_iface = wpa_supplicant_ctrl_iface_init(&wpa_s);
if (wpa_s.ctrl_iface == NULL) {
printf("Failed to initialize control interface '%s'.\n"
@@ -1388,7 +1483,8 @@ int main(int argc, char *argv[])
wpa_s.conf->ctrl_interface);
return -1;
}
- if (wpa_supplicant_scard_init(&wpa_s, wpa_s.conf->ssid))
+ if (wpa_s.conf->ssid &&
+ wpa_supplicant_scard_init(&wpa_s, wpa_s.conf->ssid))
return -1;
if (test_eapol(&eapol_test, &wpa_s, wpa_s.conf->ssid))
@@ -1400,9 +1496,12 @@ int main(int argc, char *argv[])
if (wait_for_monitor)
wpa_supplicant_ctrl_iface_wait(wpa_s.ctrl_iface);
- eloop_register_timeout(timeout, 0, eapol_test_timeout, &eapol_test,
- NULL);
- eloop_register_timeout(0, 0, send_eap_request_identity, &wpa_s, NULL);
+ if (!ctrl_iface) {
+ eloop_register_timeout(timeout, 0, eapol_test_timeout,
+ &eapol_test, NULL);
+ eloop_register_timeout(0, 0, send_eap_request_identity, &wpa_s,
+ NULL);
+ }
eloop_register_signal_terminate(eapol_test_terminate, &wpa_s);
eloop_register_signal_reconfig(eapol_test_terminate, &wpa_s);
eloop_run();
diff --git a/wpa_supplicant/eapol_test.py b/wpa_supplicant/eapol_test.py
new file mode 100755
index 0000000..80e7dfc
--- /dev/null
+++ b/wpa_supplicant/eapol_test.py
@@ -0,0 +1,142 @@
+#!/usr/bin/env python2
+#
+# eapol_test controller
+# Copyright (c) 2015, Jouni Malinen <j@w1.fi>
+#
+# This software may be distributed under the terms of the BSD license.
+# See README for more details.
+
+import argparse
+import logging
+import os
+import Queue
+import sys
+import threading
+
+logger = logging.getLogger()
+dir = os.path.dirname(os.path.realpath(sys.modules[__name__].__file__))
+sys.path.append(os.path.join(dir, '..', 'wpaspy'))
+import wpaspy
+wpas_ctrl = '/tmp/eapol_test'
+
+class eapol_test:
+ def __init__(self, ifname):
+ self.ifname = ifname
+ self.ctrl = wpaspy.Ctrl(os.path.join(wpas_ctrl, ifname))
+ if "PONG" not in self.ctrl.request("PING"):
+ raise Exception("Failed to connect to eapol_test (%s)" % ifname)
+ self.mon = wpaspy.Ctrl(os.path.join(wpas_ctrl, ifname))
+ self.mon.attach()
+
+ def add_network(self):
+ id = self.request("ADD_NETWORK")
+ if "FAIL" in id:
+ raise Exception("ADD_NETWORK failed")
+ return int(id)
+
+ def remove_network(self, id):
+ id = self.request("REMOVE_NETWORK " + str(id))
+ if "FAIL" in id:
+ raise Exception("REMOVE_NETWORK failed")
+ return None
+
+ def set_network(self, id, field, value):
+ res = self.request("SET_NETWORK " + str(id) + " " + field + " " + value)
+ if "FAIL" in res:
+ raise Exception("SET_NETWORK failed")
+ return None
+
+ def set_network_quoted(self, id, field, value):
+ res = self.request("SET_NETWORK " + str(id) + " " + field + ' "' + value + '"')
+ if "FAIL" in res:
+ raise Exception("SET_NETWORK failed")
+ return None
+
+ def request(self, cmd, timeout=10):
+ return self.ctrl.request(cmd, timeout=timeout)
+
+ def wait_event(self, events, timeout=10):
+ start = os.times()[4]
+ while True:
+ while self.mon.pending():
+ ev = self.mon.recv()
+ logger.debug(self.ifname + ": " + ev)
+ for event in events:
+ if event in ev:
+ return ev
+ now = os.times()[4]
+ remaining = start + timeout - now
+ if remaining <= 0:
+ break
+ if not self.mon.pending(timeout=remaining):
+ break
+ return None
+
+def run(ifname, count, no_fast_reauth, res):
+ et = eapol_test(ifname)
+
+ et.request("AP_SCAN 0")
+ if no_fast_reauth:
+ et.request("SET fast_reauth 0")
+ else:
+ et.request("SET fast_reauth 1")
+ id = et.add_network()
+ et.set_network(id, "key_mgmt", "IEEE8021X")
+ et.set_network(id, "eapol_flags", "0")
+ et.set_network(id, "eap", "TLS")
+ et.set_network_quoted(id, "identity", "user")
+ et.set_network_quoted(id, "ca_cert", 'ca.pem')
+ et.set_network_quoted(id, "client_cert", 'client.pem')
+ et.set_network_quoted(id, "private_key", 'client.key')
+ et.set_network_quoted(id, "private_key_passwd", 'whatever')
+ et.set_network(id, "disabled", "0")
+
+ fail = False
+ for i in range(count):
+ et.request("REASSOCIATE")
+ ev = et.wait_event(["CTRL-EVENT-CONNECTED", "CTRL-EVENT-EAP-FAILURE"])
+ if ev is None or "CTRL-EVENT-CONNECTED" not in ev:
+ fail = True
+ break
+
+ et.remove_network(id)
+
+ if fail:
+ res.put("FAIL (%d OK)" % i)
+ else:
+ res.put("PASS %d" % (i + 1))
+
+def main():
+ parser = argparse.ArgumentParser(description='eapol_test controller')
+ parser.add_argument('--ctrl', help='control interface directory')
+ parser.add_argument('--num', help='number of processes')
+ parser.add_argument('--iter', help='number of iterations')
+ parser.add_argument('--no-fast-reauth', action='store_true',
+ dest='no_fast_reauth',
+ help='disable TLS session resumption')
+ args = parser.parse_args()
+
+ num = int(args.num)
+ iter = int(args.iter)
+ if args.ctrl:
+ global wpas_ctrl
+ wpas_ctrl = args.ctrl
+
+ t = {}
+ res = {}
+ for i in range(num):
+ res[i] = Queue.Queue()
+ t[i] = threading.Thread(target=run, args=(str(i), iter,
+ args.no_fast_reauth, res[i]))
+ for i in range(num):
+ t[i].start()
+ for i in range(num):
+ t[i].join()
+ try:
+ results = res[i].get(False)
+ except:
+ results = "N/A"
+ print "%d: %s" % (i, results)
+
+if __name__ == "__main__":
+ main()
diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index d275ca4..3af1c7d 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -23,6 +23,7 @@
#include "eap_peer/eap.h"
#include "ap/hostapd.h"
#include "p2p/p2p.h"
+#include "fst/fst.h"
#include "wnm_sta.h"
#include "notify.h"
#include "common/ieee802_11_defs.h"
@@ -71,6 +72,59 @@ static int wpas_temp_disabled(struct wpa_supplicant *wpa_s,
}
+/**
+ * wpas_reenabled_network_time - Time until first network is re-enabled
+ * @wpa_s: Pointer to wpa_supplicant data
+ * Returns: If all enabled networks are temporarily disabled, returns the time
+ * (in sec) until the first network is re-enabled. Otherwise returns 0.
+ *
+ * This function is used in case all enabled networks are temporarily disabled,
+ * in which case it returns the time (in sec) that the first network will be
+ * re-enabled. The function assumes that at least one network is enabled.
+ */
+static int wpas_reenabled_network_time(struct wpa_supplicant *wpa_s)
+{
+ struct wpa_ssid *ssid;
+ int disabled_for, res = 0;
+
+#ifdef CONFIG_INTERWORKING
+ if (wpa_s->conf->auto_interworking && wpa_s->conf->interworking &&
+ wpa_s->conf->cred)
+ return 0;
+#endif /* CONFIG_INTERWORKING */
+
+ for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) {
+ if (ssid->disabled)
+ continue;
+
+ disabled_for = wpas_temp_disabled(wpa_s, ssid);
+ if (!disabled_for)
+ return 0;
+
+ if (!res || disabled_for < res)
+ res = disabled_for;
+ }
+
+ return res;
+}
+
+
+void wpas_network_reenabled(void *eloop_ctx, void *timeout_ctx)
+{
+ struct wpa_supplicant *wpa_s = eloop_ctx;
+
+ if (wpa_s->disconnected || wpa_s->wpa_state != WPA_SCANNING)
+ return;
+
+ wpa_dbg(wpa_s, MSG_DEBUG,
+ "Try to associate due to network getting re-enabled");
+ if (wpa_supplicant_fast_associate(wpa_s) != 1) {
+ wpa_supplicant_cancel_sched_scan(wpa_s);
+ wpa_supplicant_req_scan(wpa_s, 0, 0);
+ }
+}
+
+
static struct wpa_bss * wpa_supplicant_get_new_bss(
struct wpa_supplicant *wpa_s, const u8 *bssid)
{
@@ -105,11 +159,32 @@ static void wpa_supplicant_update_current_bss(struct wpa_supplicant *wpa_s)
static int wpa_supplicant_select_config(struct wpa_supplicant *wpa_s)
{
struct wpa_ssid *ssid, *old_ssid;
+ u8 drv_ssid[SSID_MAX_LEN];
+ size_t drv_ssid_len;
int res;
if (wpa_s->conf->ap_scan == 1 && wpa_s->current_ssid) {
wpa_supplicant_update_current_bss(wpa_s);
- return 0;
+
+ if (wpa_s->current_ssid->ssid_len == 0)
+ return 0; /* current profile still in use */
+ res = wpa_drv_get_ssid(wpa_s, drv_ssid);
+ if (res < 0) {
+ wpa_msg(wpa_s, MSG_INFO,
+ "Failed to read SSID from driver");
+ return 0; /* try to use current profile */
+ }
+ drv_ssid_len = res;
+
+ if (drv_ssid_len == wpa_s->current_ssid->ssid_len &&
+ os_memcmp(drv_ssid, wpa_s->current_ssid->ssid,
+ drv_ssid_len) == 0)
+ return 0; /* current profile still in use */
+
+ wpa_msg(wpa_s, MSG_DEBUG,
+ "Driver-initiated BSS selection changed the SSID to %s",
+ wpa_ssid_txt(drv_ssid, drv_ssid_len));
+ /* continue selecting a new network profile */
}
wpa_dbg(wpa_s, MSG_DEBUG, "Select network based on association "
@@ -212,9 +287,6 @@ void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s)
os_memset(wpa_s->bssid, 0, ETH_ALEN);
os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
sme_clear_on_disassoc(wpa_s);
-#ifdef CONFIG_P2P
- os_memset(wpa_s->go_dev_addr, 0, ETH_ALEN);
-#endif /* CONFIG_P2P */
wpa_s->current_bss = NULL;
wpa_s->assoc_freq = 0;
@@ -756,9 +828,9 @@ static struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s,
osen = ie != NULL;
wpa_dbg(wpa_s, MSG_DEBUG, "%d: " MACSTR " ssid='%s' "
- "wpa_ie_len=%u rsn_ie_len=%u caps=0x%x level=%d%s%s%s",
+ "wpa_ie_len=%u rsn_ie_len=%u caps=0x%x level=%d freq=%d %s%s%s",
i, MAC2STR(bss->bssid), wpa_ssid_txt(bss->ssid, bss->ssid_len),
- wpa_ie_len, rsn_ie_len, bss->caps, bss->level,
+ wpa_ie_len, rsn_ie_len, bss->caps, bss->level, bss->freq,
wpa_bss_get_vendor_ie(bss, WPS_IE_VENDOR_TYPE) ? " wps" : "",
(wpa_bss_get_vendor_ie(bss, P2P_IE_VENDOR_TYPE) ||
wpa_bss_get_vendor_ie_beacon(bss, P2P_IE_VENDOR_TYPE)) ?
@@ -964,6 +1036,19 @@ static struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s,
*/
#endif /* CONFIG_P2P */
+ if (os_reltime_before(&bss->last_update, &wpa_s->scan_min_time))
+ {
+ struct os_reltime diff;
+
+ os_reltime_sub(&wpa_s->scan_min_time,
+ &bss->last_update, &diff);
+ wpa_dbg(wpa_s, MSG_DEBUG,
+ " skip - scan result not recent enough (%u.%06u seconds too old)",
+ (unsigned int) diff.sec,
+ (unsigned int) diff.usec);
+ continue;
+ }
+
/* Matching configuration found */
return ssid;
}
@@ -1011,14 +1096,13 @@ struct wpa_bss * wpa_supplicant_pick_network(struct wpa_supplicant *wpa_s,
struct wpa_bss *selected = NULL;
int prio;
struct wpa_ssid *next_ssid = NULL;
+ struct wpa_ssid *ssid;
if (wpa_s->last_scan_res == NULL ||
wpa_s->last_scan_res_used == 0)
return NULL; /* no scan results from last update */
if (wpa_s->next_ssid) {
- struct wpa_ssid *ssid;
-
/* check that next_ssid is still valid */
for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) {
if (ssid == wpa_s->next_ssid)
@@ -1054,6 +1138,27 @@ struct wpa_bss * wpa_supplicant_pick_network(struct wpa_supplicant *wpa_s,
break;
}
+ ssid = *selected_ssid;
+ if (selected && ssid && ssid->mem_only_psk && !ssid->psk_set &&
+ !ssid->passphrase && !ssid->ext_psk) {
+ const char *field_name, *txt = NULL;
+
+ wpa_dbg(wpa_s, MSG_DEBUG,
+ "PSK/passphrase not yet available for the selected network");
+
+ wpas_notify_network_request(wpa_s, ssid,
+ WPA_CTRL_REQ_PSK_PASSPHRASE, NULL);
+
+ field_name = wpa_supplicant_ctrl_req_to_string(
+ WPA_CTRL_REQ_PSK_PASSPHRASE, NULL, &txt);
+ if (field_name == NULL)
+ return NULL;
+
+ wpas_send_ctrl_req(wpa_s, ssid, field_name, txt);
+
+ selected = NULL;
+ }
+
return selected;
}
@@ -1085,6 +1190,7 @@ int wpa_supplicant_connect(struct wpa_supplicant *wpa_s,
if (wpas_wps_scan_pbc_overlap(wpa_s, selected, ssid)) {
wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_OVERLAP
"PBC session overlap");
+ wpas_notify_wps_event_pbc_overlap(wpa_s);
#ifdef CONFIG_P2P
if (wpa_s->p2p_group_interface == P2P_GROUP_INTERFACE_CLIENT ||
wpa_s->p2p_in_provisioning) {
@@ -1095,6 +1201,7 @@ int wpa_supplicant_connect(struct wpa_supplicant *wpa_s,
#endif /* CONFIG_P2P */
#ifdef CONFIG_WPS
+ wpas_wps_pbc_overlap(wpa_s);
wpas_wps_cancel(wpa_s);
#endif /* CONFIG_WPS */
return -1;
@@ -1192,7 +1299,9 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid)
{
struct wpa_bss *current_bss = NULL;
+#ifndef CONFIG_NO_ROAMING
int min_diff;
+#endif /* CONFIG_NO_ROAMING */
if (wpa_s->reassociate)
return 1; /* explicit request to reassociate */
@@ -1421,6 +1530,17 @@ static int wpas_select_network_from_last_scan(struct wpa_supplicant *wpa_s,
{
struct wpa_bss *selected;
struct wpa_ssid *ssid = NULL;
+ int time_to_reenable = wpas_reenabled_network_time(wpa_s);
+
+ if (time_to_reenable > 0) {
+ wpa_dbg(wpa_s, MSG_DEBUG,
+ "Postpone network selection by %d seconds since all networks are disabled",
+ time_to_reenable);
+ eloop_cancel_timeout(wpas_network_reenabled, wpa_s, NULL);
+ eloop_register_timeout(time_to_reenable, 0,
+ wpas_network_reenabled, wpa_s, NULL);
+ return 0;
+ }
if (wpa_s->p2p_mgmt)
return 0; /* no normal connection on p2p_mgmt interface */
@@ -1520,6 +1640,9 @@ static int wpas_select_network_from_last_scan(struct wpa_supplicant *wpa_s,
if (wpa_supplicant_req_sched_scan(wpa_s))
wpa_supplicant_req_new_scan(wpa_s, timeout_sec,
timeout_usec);
+
+ wpa_msg_ctrl(wpa_s, MSG_INFO,
+ WPA_EVENT_NETWORK_NOT_FOUND);
}
}
return 0;
@@ -1577,7 +1700,7 @@ int wpa_supplicant_fast_associate(struct wpa_supplicant *wpa_s)
#else /* CONFIG_NO_SCAN_PROCESSING */
struct os_reltime now;
- if (wpa_s->last_scan_res_used <= 0)
+ if (wpa_s->last_scan_res_used == 0)
return -1;
os_get_reltime(&now);
@@ -1889,6 +2012,19 @@ static int wpa_supplicant_event_associnfo(struct wpa_supplicant *wpa_s,
if (wpa_found || rsn_found)
wpa_s->ap_ies_from_associnfo = 1;
+#ifdef CONFIG_FST
+ wpabuf_free(wpa_s->received_mb_ies);
+ wpa_s->received_mb_ies = NULL;
+ if (wpa_s->fst) {
+ struct mb_ies_info mb_ies;
+
+ wpa_printf(MSG_DEBUG, "Looking for MB IE");
+ if (!mb_ies_info_by_ies(&mb_ies, data->assoc_info.resp_ies,
+ data->assoc_info.resp_ies_len))
+ wpa_s->received_mb_ies = mb_ies_by_info(&mb_ies);
+ }
+#endif /* CONFIG_FST */
+
if (wpa_s->assoc_freq && data->assoc_info.freq &&
wpa_s->assoc_freq != data->assoc_info.freq) {
wpa_printf(MSG_DEBUG, "Operating frequency changed from "
@@ -1932,6 +2068,7 @@ static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s,
{
u8 bssid[ETH_ALEN];
int ft_completed;
+ int new_bss = 0;
#ifdef CONFIG_AP
if (wpa_s->ap_iface) {
@@ -1946,6 +2083,8 @@ static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s,
}
#endif /* CONFIG_AP */
+ eloop_cancel_timeout(wpas_network_reenabled, wpa_s, NULL);
+
ft_completed = wpa_ft_is_completed(wpa_s->wpa);
if (data && wpa_supplicant_event_associnfo(wpa_s, data) < 0)
return;
@@ -1961,6 +2100,7 @@ static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s,
if (os_memcmp(bssid, wpa_s->bssid, ETH_ALEN) != 0) {
wpa_dbg(wpa_s, MSG_DEBUG, "Associated to a new BSS: BSSID="
MACSTR, MAC2STR(bssid));
+ new_bss = 1;
random_add_randomness(bssid, ETH_ALEN);
os_memcpy(wpa_s->bssid, bssid, ETH_ALEN);
os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
@@ -1974,13 +2114,13 @@ static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s,
wpa_s, WLAN_REASON_DEAUTH_LEAVING);
return;
}
+ }
- if (wpa_s->conf->ap_scan == 1 &&
- wpa_s->drv_flags & WPA_DRIVER_FLAGS_BSS_SELECTION) {
- if (wpa_supplicant_assoc_update_ie(wpa_s) < 0)
- wpa_msg(wpa_s, MSG_WARNING,
- "WPA/RSN IEs not updated");
- }
+ if (wpa_s->conf->ap_scan == 1 &&
+ wpa_s->drv_flags & WPA_DRIVER_FLAGS_BSS_SELECTION) {
+ if (wpa_supplicant_assoc_update_ie(wpa_s) < 0 && new_bss)
+ wpa_msg(wpa_s, MSG_WARNING,
+ "WPA/RSN IEs not updated");
}
#ifdef CONFIG_SME
@@ -2253,7 +2393,8 @@ static void wpa_supplicant_event_disassoc_finish(struct wpa_supplicant *wpa_s,
"try to re-connect");
wpa_s->reassociate = 0;
wpa_s->disconnected = 1;
- wpa_supplicant_cancel_sched_scan(wpa_s);
+ if (!wpa_s->pno)
+ wpa_supplicant_cancel_sched_scan(wpa_s);
}
bssid = wpa_s->bssid;
if (is_zero_ether_addr(bssid))
@@ -2443,6 +2584,21 @@ wpa_supplicant_event_interface_status(struct wpa_supplicant *wpa_s,
wpa_msg(wpa_s, MSG_INFO, "Failed to initialize the "
"driver after interface was added");
}
+
+#ifdef CONFIG_P2P
+ if (!wpa_s->global->p2p &&
+ !wpa_s->global->p2p_disabled &&
+ !wpa_s->conf->p2p_disabled &&
+ (wpa_s->drv_flags &
+ WPA_DRIVER_FLAGS_DEDICATED_P2P_DEVICE) &&
+ wpas_p2p_add_p2pdev_interface(
+ wpa_s, wpa_s->global->params.conf_p2p_dev) < 0) {
+ wpa_printf(MSG_INFO,
+ "P2P: Failed to enable P2P Device interface");
+ /* Try to continue without. P2P will be disabled. */
+ }
+#endif /* CONFIG_P2P */
+
break;
case EVENT_INTERFACE_REMOVED:
wpa_dbg(wpa_s, MSG_DEBUG, "Configured interface was removed");
@@ -2451,6 +2607,21 @@ wpa_supplicant_event_interface_status(struct wpa_supplicant *wpa_s,
wpa_supplicant_set_state(wpa_s, WPA_INTERFACE_DISABLED);
l2_packet_deinit(wpa_s->l2);
wpa_s->l2 = NULL;
+
+#ifdef CONFIG_P2P
+ if (wpa_s->global->p2p &&
+ wpa_s->global->p2p_init_wpa_s->parent == wpa_s &&
+ (wpa_s->drv_flags &
+ WPA_DRIVER_FLAGS_DEDICATED_P2P_DEVICE)) {
+ wpa_dbg(wpa_s, MSG_DEBUG,
+ "Removing P2P Device interface");
+ wpa_supplicant_remove_iface(
+ wpa_s->global, wpa_s->global->p2p_init_wpa_s,
+ 0);
+ wpa_s->global->p2p_init_wpa_s = NULL;
+ }
+#endif /* CONFIG_P2P */
+
#ifdef CONFIG_TERMINATE_ONLASTIF
/* check if last interface */
if (!any_interfaces(wpa_s->global->ifaces))
@@ -2844,26 +3015,24 @@ static void wpa_supplicant_update_channel_list(
if (wpa_s->drv_priv == NULL)
return; /* Ignore event during drv initialization */
- free_hw_features(wpa_s);
- wpa_s->hw.modes = wpa_drv_get_hw_feature_data(
- wpa_s, &wpa_s->hw.num_modes, &wpa_s->hw.flags);
-
- wpas_p2p_update_channel_list(wpa_s);
-
- /*
- * Check other interfaces to see if they share the same radio. If
- * so, they get updated with this same hw mode info.
- */
dl_list_for_each(ifs, &wpa_s->radio->ifaces, struct wpa_supplicant,
radio_list) {
- if (ifs != wpa_s) {
- wpa_printf(MSG_DEBUG, "%s: Updating hw mode",
- ifs->ifname);
- free_hw_features(ifs);
- ifs->hw.modes = wpa_drv_get_hw_feature_data(
- ifs, &ifs->hw.num_modes, &ifs->hw.flags);
- }
+ wpa_printf(MSG_DEBUG, "%s: Updating hw mode",
+ ifs->ifname);
+ free_hw_features(ifs);
+ ifs->hw.modes = wpa_drv_get_hw_feature_data(
+ ifs, &ifs->hw.num_modes, &ifs->hw.flags);
+ }
+
+ /* Restart sched_scan with updated channel list */
+ if (wpa_s->sched_scanning) {
+ wpa_dbg(wpa_s, MSG_DEBUG,
+ "Channel list changed restart sched scan.");
+ wpa_supplicant_cancel_sched_scan(wpa_s);
+ wpa_supplicant_req_scan(wpa_s, 0, 0);
}
+
+ wpas_p2p_update_channel_list(wpa_s, WPAS_P2P_CHANNEL_UPDATE_DRIVER);
}
@@ -2964,6 +3133,13 @@ static void wpas_event_rx_mgmt_action(struct wpa_supplicant *wpa_s,
return;
}
+#ifdef CONFIG_FST
+ if (mgmt->u.action.category == WLAN_ACTION_FST && wpa_s->fst) {
+ fst_rx_action(wpa_s->fst, mgmt, len);
+ return;
+ }
+#endif /* CONFIG_FST */
+
wpas_p2p_rx_action(wpa_s, mgmt->da, mgmt->sa, mgmt->bssid,
category, payload, plen, freq);
if (wpa_s->ifmsh)
@@ -2974,9 +3150,6 @@ static void wpas_event_rx_mgmt_action(struct wpa_supplicant *wpa_s,
static void wpa_supplicant_notify_avoid_freq(struct wpa_supplicant *wpa_s,
union wpa_event_data *event)
{
-#ifdef CONFIG_P2P
- struct wpa_supplicant *ifs;
-#endif /* CONFIG_P2P */
struct wpa_freq_range_list *list;
char *str = NULL;
@@ -2993,29 +3166,13 @@ static void wpa_supplicant_notify_avoid_freq(struct wpa_supplicant *wpa_s,
__func__);
} else {
wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Update channel list based on frequency avoid event");
- wpas_p2p_update_channel_list(wpa_s);
- }
-
- for (ifs = wpa_s->global->ifaces; ifs; ifs = ifs->next) {
- int freq;
- if (!ifs->current_ssid ||
- !ifs->current_ssid->p2p_group ||
- (ifs->current_ssid->mode != WPAS_MODE_P2P_GO &&
- ifs->current_ssid->mode != WPAS_MODE_P2P_GROUP_FORMATION))
- continue;
- freq = ifs->current_ssid->frequency;
- if (!freq_range_list_includes(list, freq)) {
- wpa_dbg(ifs, MSG_DEBUG, "P2P GO operating frequency %d MHz in safe range",
- freq);
- continue;
- }
-
- wpa_dbg(ifs, MSG_DEBUG, "P2P GO operating in unsafe frequency %d MHz",
- freq);
- /* TODO: Consider using CSA or removing the group within
- * wpa_supplicant */
- wpa_msg(ifs, MSG_INFO, P2P_EVENT_REMOVE_AND_REFORM_GROUP);
+ /*
+ * The update channel flow will also take care of moving a GO
+ * from the unsafe frequency if needed.
+ */
+ wpas_p2p_update_channel_list(wpa_s,
+ WPAS_P2P_CHANNEL_UPDATE_AVOID);
}
#endif /* CONFIG_P2P */
@@ -3047,6 +3204,7 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
union wpa_event_data *data)
{
struct wpa_supplicant *wpa_s = ctx;
+ int resched;
if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED &&
event != EVENT_INTERFACE_ENABLED &&
@@ -3372,6 +3530,7 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
wpas_p2p_probe_req_rx(
wpa_s, src, mgmt->da,
mgmt->bssid, ie, ie_len,
+ data->rx_mgmt.freq,
data->rx_mgmt.ssi_signal);
break;
}
@@ -3443,6 +3602,7 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
data->rx_probe_req.bssid,
data->rx_probe_req.ie,
data->rx_probe_req.ie_len,
+ 0,
data->rx_probe_req.ssi_signal);
break;
case EVENT_REMAIN_ON_CHANNEL:
@@ -3613,6 +3773,7 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
case EVENT_SCHED_SCAN_STOPPED:
wpa_s->pno = 0;
wpa_s->sched_scanning = 0;
+ resched = wpa_s->scanning;
wpa_supplicant_notify_scanning(wpa_s, 0);
if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED)
@@ -3627,6 +3788,8 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
} else if (wpa_s->pno_sched_pending) {
wpa_s->pno_sched_pending = 0;
wpas_start_pno(wpa_s);
+ } else if (resched) {
+ wpa_supplicant_req_scan(wpa_s, 0, 0);
}
break;
diff --git a/wpa_supplicant/hs20_supplicant.c b/wpa_supplicant/hs20_supplicant.c
index b9cd681..a1afc85 100644
--- a/wpa_supplicant/hs20_supplicant.c
+++ b/wpa_supplicant/hs20_supplicant.c
@@ -46,7 +46,7 @@ struct osu_icon {
struct osu_provider {
u8 bssid[ETH_ALEN];
- u8 osu_ssid[32];
+ u8 osu_ssid[SSID_MAX_LEN];
u8 osu_ssid_len;
char server_uri[256];
u32 osu_methods; /* bit 0 = OMA-DM, bit 1 = SOAP-XML SPP */
@@ -188,14 +188,16 @@ int hs20_anqp_send_req(struct wpa_supplicant *wpa_s, const u8 *dst, u32 stypes,
struct wpa_bss *bss;
int res;
- freq = wpa_s->assoc_freq;
bss = wpa_bss_get_bssid(wpa_s, dst);
- if (bss) {
- wpa_bss_anqp_unshare_alloc(bss);
- freq = bss->freq;
- }
- if (freq <= 0)
+ if (!bss) {
+ wpa_printf(MSG_WARNING,
+ "ANQP: Cannot send query to unknown BSS "
+ MACSTR, MAC2STR(dst));
return -1;
+ }
+
+ wpa_bss_anqp_unshare_alloc(bss);
+ freq = bss->freq;
wpa_printf(MSG_DEBUG, "HS20: ANQP Query Request to " MACSTR " for "
"subtypes 0x%x", MAC2STR(dst), stypes);
@@ -822,7 +824,7 @@ void hs20_osu_icon_fetch(struct wpa_supplicant *wpa_s)
continue;
}
osu_ssid_len = *pos++;
- if (osu_ssid_len > 32) {
+ if (osu_ssid_len > SSID_MAX_LEN) {
wpa_printf(MSG_DEBUG, "HS 2.0: Invalid OSU SSID "
"Length %u", osu_ssid_len);
continue;
diff --git a/wpa_supplicant/ibss_rsn.c b/wpa_supplicant/ibss_rsn.c
index d0ae135..d9d0ae7 100644
--- a/wpa_supplicant/ibss_rsn.c
+++ b/wpa_supplicant/ibss_rsn.c
@@ -571,6 +571,9 @@ int ibss_rsn_start(struct ibss_rsn *ibss_rsn, const u8 *addr)
struct ibss_rsn_peer *peer;
int res;
+ if (!ibss_rsn)
+ return -1;
+
/* if the peer already exists, exit immediately */
peer = ibss_rsn_get_peer(ibss_rsn, addr);
if (peer)
@@ -694,7 +697,8 @@ void ibss_rsn_deinit(struct ibss_rsn *ibss_rsn)
ibss_rsn_free(prev);
}
- wpa_deinit(ibss_rsn->auth_group);
+ if (ibss_rsn->auth_group)
+ wpa_deinit(ibss_rsn->auth_group);
os_free(ibss_rsn);
}
diff --git a/wpa_supplicant/interworking.c b/wpa_supplicant/interworking.c
index 4a39665..fd47c17 100644
--- a/wpa_supplicant/interworking.c
+++ b/wpa_supplicant/interworking.c
@@ -2058,7 +2058,7 @@ static struct wpa_cred * interworking_credentials_available_helper(
int *excluded)
{
struct wpa_cred *cred, *cred2;
- int excluded1, excluded2;
+ int excluded1, excluded2 = 0;
if (disallowed_bssid(wpa_s, bss->bssid) ||
disallowed_ssid(wpa_s, bss->ssid, bss->ssid_len)) {
@@ -2673,14 +2673,16 @@ int anqp_send_req(struct wpa_supplicant *wpa_s, const u8 *dst,
struct wpa_bss *bss;
int res;
- freq = wpa_s->assoc_freq;
bss = wpa_bss_get_bssid(wpa_s, dst);
- if (bss) {
- wpa_bss_anqp_unshare_alloc(bss);
- freq = bss->freq;
- }
- if (freq <= 0)
+ if (!bss) {
+ wpa_printf(MSG_WARNING,
+ "ANQP: Cannot send query to unknown BSS "
+ MACSTR, MAC2STR(dst));
return -1;
+ }
+
+ wpa_bss_anqp_unshare_alloc(bss);
+ freq = bss->freq;
wpa_msg(wpa_s, MSG_DEBUG,
"ANQP: Query Request to " MACSTR " for %u id(s)",
diff --git a/wpa_supplicant/main.c b/wpa_supplicant/main.c
index 2282747..d5d47e1 100644
--- a/wpa_supplicant/main.c
+++ b/wpa_supplicant/main.c
@@ -12,6 +12,7 @@
#endif /* __linux__ */
#include "common.h"
+#include "fst/fst.h"
#include "wpa_supplicant_i.h"
#include "driver_i.h"
#include "p2p_supplicant.h"
@@ -237,7 +238,7 @@ int main(int argc, char *argv[])
goto out;
#ifdef CONFIG_P2P
case 'm':
- iface->conf_p2p_dev = optarg;
+ params.conf_p2p_dev = optarg;
break;
#endif /* CONFIG_P2P */
case 'o':
@@ -288,7 +289,7 @@ int main(int argc, char *argv[])
if (iface == NULL)
goto out;
ifaces = iface;
- iface = &ifaces[iface_count - 1];
+ iface = &ifaces[iface_count - 1];
os_memset(iface, 0, sizeof(*iface));
break;
default:
@@ -309,6 +310,17 @@ int main(int argc, char *argv[])
"wpa_supplicant");
}
+ if (fst_global_init()) {
+ wpa_printf(MSG_ERROR, "Failed to initialize FST");
+ exitcode = -1;
+ goto out;
+ }
+
+#if defined(CONFIG_FST) && defined(CONFIG_CTRL_IFACE)
+ if (!fst_global_add_ctrl(fst_ctrl_cli))
+ wpa_printf(MSG_WARNING, "Failed to add CLI FST ctrl");
+#endif
+
for (i = 0; exitcode == 0 && i < iface_count; i++) {
struct wpa_supplicant *wpa_s;
@@ -334,6 +346,8 @@ int main(int argc, char *argv[])
wpa_supplicant_deinit(global);
+ fst_global_deinit();
+
out:
wpa_supplicant_fd_workaround(0);
os_free(ifaces);
diff --git a/wpa_supplicant/mesh.c b/wpa_supplicant/mesh.c
index 33b4af3..77f708b 100644
--- a/wpa_supplicant/mesh.c
+++ b/wpa_supplicant/mesh.c
@@ -47,8 +47,8 @@ void wpa_supplicant_mesh_iface_deinit(struct wpa_supplicant *wpa_s,
if (ifmsh->mconf) {
mesh_mpm_deinit(wpa_s, ifmsh);
- if (ifmsh->mconf->ies) {
- ifmsh->mconf->ies = NULL;
+ if (ifmsh->mconf->rsn_ie) {
+ ifmsh->mconf->rsn_ie = NULL;
/* We cannot free this struct
* because wpa_authenticator on
* hostapd side is also using it
@@ -171,6 +171,8 @@ static int wpa_supplicant_mesh_init(struct wpa_supplicant *wpa_s,
ifmsh->conf = conf;
ifmsh->bss[0]->max_plinks = wpa_s->conf->max_peer_links;
+ ifmsh->bss[0]->dot11RSNASAERetransPeriod =
+ wpa_s->conf->dot11RSNASAERetransPeriod;
os_strlcpy(bss->conf->iface, wpa_s->ifname, sizeof(bss->conf->iface));
mconf = mesh_config_create(ssid);
@@ -350,8 +352,8 @@ int wpa_supplicant_join_mesh(struct wpa_supplicant *wpa_s,
}
if (wpa_s->ifmsh) {
- params.ies = wpa_s->ifmsh->mconf->ies;
- params.ie_len = wpa_s->ifmsh->mconf->ie_len;
+ params.ies = wpa_s->ifmsh->mconf->rsn_ie;
+ params.ie_len = wpa_s->ifmsh->mconf->rsn_ie_len;
params.basic_rates = wpa_s->ifmsh->basic_rates;
}
@@ -453,22 +455,23 @@ static int mesh_attr_text(const u8 *ies, size_t ies_len, char *buf, char *end)
ret = os_snprintf(pos, end - pos, "bss_basic_rate_set=%d",
bss_basic_rate_set[0]);
if (os_snprintf_error(end - pos, ret))
- return pos - buf;
+ goto fail;
pos += ret;
for (i = 1; i < bss_basic_rate_set_len; i++) {
ret = os_snprintf(pos, end - pos, " %d",
bss_basic_rate_set[i]);
if (os_snprintf_error(end - pos, ret))
- return pos - buf;
+ goto fail;
pos += ret;
}
ret = os_snprintf(pos, end - pos, "\n");
if (os_snprintf_error(end - pos, ret))
- return pos - buf;
+ goto fail;
pos += ret;
}
+fail:
os_free(bss_basic_rate_set);
return pos - buf;
diff --git a/wpa_supplicant/mesh_mpm.c b/wpa_supplicant/mesh_mpm.c
index 1d6f2be..f81b88c 100644
--- a/wpa_supplicant/mesh_mpm.c
+++ b/wpa_supplicant/mesh_mpm.c
@@ -239,6 +239,9 @@ static void mesh_mpm_send_plink_action(struct wpa_supplicant *wpa_s,
2 + 22; /* HT operation */
}
#endif /* CONFIG_IEEE80211N */
+ if (type != PLINK_CLOSE)
+ buf_len += conf->rsn_ie_len; /* RSN IE */
+
buf = wpabuf_alloc(buf_len);
if (!buf)
return;
@@ -262,6 +265,9 @@ static void mesh_mpm_send_plink_action(struct wpa_supplicant *wpa_s,
pos = hostapd_eid_ext_supp_rates(bss, pos);
wpabuf_put_data(buf, supp_rates, pos - supp_rates);
+ /* IE: RSN IE */
+ wpabuf_put_data(buf, conf->rsn_ie, conf->rsn_ie_len);
+
/* IE: Mesh ID */
wpabuf_put_u8(buf, WLAN_EID_MESH_ID);
wpabuf_put_u8(buf, conf->meshid_len);
@@ -551,8 +557,7 @@ static struct sta_info * mesh_mpm_add_peer(struct wpa_supplicant *wpa_s,
mesh_mpm_init_link(wpa_s, sta);
#ifdef CONFIG_IEEE80211N
- copy_sta_ht_capab(data, sta, elems->ht_capabilities,
- elems->ht_capabilities_len);
+ copy_sta_ht_capab(data, sta, elems->ht_capabilities);
update_ht_state(data, sta);
#endif /* CONFIG_IEEE80211N */
diff --git a/wpa_supplicant/mesh_rsn.c b/wpa_supplicant/mesh_rsn.c
index 936002d..747f1ae 100644
--- a/wpa_supplicant/mesh_rsn.c
+++ b/wpa_supplicant/mesh_rsn.c
@@ -190,7 +190,8 @@ static int __mesh_rsn_auth_init(struct mesh_rsn *rsn, const u8 *addr)
static void mesh_rsn_deinit(struct mesh_rsn *rsn)
{
os_memset(rsn->mgtk, 0, sizeof(rsn->mgtk));
- wpa_deinit(rsn->auth);
+ if (rsn->auth)
+ wpa_deinit(rsn->auth);
}
@@ -209,14 +210,15 @@ struct mesh_rsn *mesh_rsn_auth_init(struct wpa_supplicant *wpa_s,
if (__mesh_rsn_auth_init(mesh_rsn, wpa_s->own_addr) < 0) {
mesh_rsn_deinit(mesh_rsn);
+ os_free(mesh_rsn);
return NULL;
}
bss->wpa_auth = mesh_rsn->auth;
ie = wpa_auth_get_wpa_ie(mesh_rsn->auth, &ie_len);
- conf->ies = (u8 *) ie;
- conf->ie_len = ie_len;
+ conf->rsn_ie = (u8 *) ie;
+ conf->rsn_ie_len = ie_len;
wpa_supplicant_rsn_supp_set_config(wpa_s, wpa_s->current_ssid);
diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c
index ea7dbdb..45d06bf 100644
--- a/wpa_supplicant/notify.c
+++ b/wpa_supplicant/notify.c
@@ -17,6 +17,7 @@
#include "dbus/dbus_old.h"
#include "dbus/dbus_new.h"
#include "rsn_supp/wpa.h"
+#include "fst/fst.h"
#include "driver_i.h"
#include "scan.h"
#include "p2p_supplicant.h"
@@ -88,6 +89,16 @@ void wpas_notify_state_changed(struct wpa_supplicant *wpa_s,
/* notify the new DBus API */
wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE);
+#ifdef CONFIG_FST
+ if (wpa_s->fst && !is_zero_ether_addr(wpa_s->bssid)) {
+ if (new_state == WPA_COMPLETED)
+ fst_notify_peer_connected(wpa_s->fst, wpa_s->bssid);
+ else if (old_state >= WPA_ASSOCIATED &&
+ new_state < WPA_ASSOCIATED)
+ fst_notify_peer_disconnected(wpa_s->fst, wpa_s->bssid);
+ }
+#endif /* CONFIG_FST */
+
if (new_state == WPA_COMPLETED)
wpas_p2p_notif_connected(wpa_s);
else if (old_state >= WPA_ASSOCIATED && new_state < WPA_ASSOCIATED)
@@ -268,6 +279,16 @@ void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
#endif /* CONFIG_WPS */
}
+void wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s)
+{
+ if (wpa_s->p2p_mgmt)
+ return;
+
+#ifdef CONFIG_WPS
+ wpas_dbus_signal_wps_event_pbc_overlap(wpa_s);
+#endif /* CONFIG_WPS */
+}
+
void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid)
@@ -307,14 +328,12 @@ void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s,
void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid)
{
- if (wpa_s->p2p_mgmt)
- return;
-
if (wpa_s->next_ssid == ssid)
wpa_s->next_ssid = NULL;
if (wpa_s->wpa)
wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
- if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s)
+ if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s &&
+ !wpa_s->p2p_mgmt)
wpas_dbus_unregister_network(wpa_s, ssid->id);
if (network_is_persistent_group(ssid))
wpas_notify_persistent_group_removed(wpa_s, ssid);
@@ -522,6 +541,13 @@ void wpas_notify_resume(struct wpa_global *global)
#ifdef CONFIG_P2P
+void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s)
+{
+ /* Notify P2P find has stopped */
+ wpas_dbus_signal_p2p_find_stopped(wpa_s);
+}
+
+
void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
const u8 *dev_addr, int new_device)
{
@@ -556,9 +582,9 @@ void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
- const u8 *src, u16 dev_passwd_id)
+ const u8 *src, u16 dev_passwd_id, u8 go_intent)
{
- wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id);
+ wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
}
@@ -631,12 +657,30 @@ void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
}
+void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
+ const char *reason)
+{
+ /* Notify a group formation failed */
+ wpas_dbus_signal_p2p_group_formation_failure(wpa_s, reason);
+}
+
+
void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
struct wps_event_fail *fail)
{
wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
}
+
+void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
+ const u8 *sa, const u8 *go_dev_addr,
+ const u8 *bssid, int id, int op_freq)
+{
+ /* Notify a P2P Invitation Request */
+ wpas_dbus_signal_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
+ id, op_freq);
+}
+
#endif /* CONFIG_P2P */
@@ -775,10 +819,12 @@ void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
ssid->disabled = 0;
wpas_dbus_unregister_network(wpa_s, ssid->id);
ssid->disabled = 2;
+ ssid->p2p_persistent_group = 1;
wpas_dbus_register_persistent_group(wpa_s, ssid);
} else {
/* Changed from persistent group to normal network profile */
wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
+ ssid->p2p_persistent_group = 0;
wpas_dbus_register_network(wpa_s, ssid);
}
#endif /* CONFIG_P2P */
diff --git a/wpa_supplicant/notify.h b/wpa_supplicant/notify.h
index b268332..d9f0f5a 100644
--- a/wpa_supplicant/notify.h
+++ b/wpa_supplicant/notify.h
@@ -45,6 +45,7 @@ void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
struct wps_event_fail *fail);
void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s);
+void wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s);
void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid);
void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
@@ -84,6 +85,7 @@ void wpas_notify_resume(struct wpa_global *global);
void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
const u8 *mac_addr, int authorized,
const u8 *p2p_dev_addr);
+void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s);
void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
const u8 *dev_addr, int new_device);
void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
@@ -92,7 +94,7 @@ void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
const struct wpa_ssid *ssid,
const char *role);
void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
- const u8 *src, u16 dev_passwd_id);
+ const u8 *src, u16 dev_passwd_id, u8 go_intent);
void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s,
struct p2p_go_neg_results *res);
void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
@@ -112,6 +114,8 @@ void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid, int network_id,
int client);
+void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
+ const char *reason);
void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid);
void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s,
@@ -133,5 +137,8 @@ void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid);
void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid);
+void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
+ const u8 *sa, const u8 *go_dev_addr,
+ const u8 *bssid, int id, int op_freq);
#endif /* NOTIFY_H */
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index b200ca0..78bdd08 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -47,6 +47,12 @@
#define P2P_AUTO_PD_SCAN_ATTEMPTS 5
+/**
+ * Defines time interval in seconds when a GO needs to evacuate a frequency that
+ * it is currently using, but is no longer valid for P2P use cases.
+ */
+#define P2P_GO_FREQ_CHANGE_TIME 5
+
#ifndef P2P_MAX_CLIENT_IDLE
/*
* How many seconds to try to reconnect to the GO when connection in P2P client
@@ -85,6 +91,12 @@
#define P2P_MGMT_DEVICE_PREFIX "p2p-dev-"
+/*
+ * How many seconds to wait to re-attempt to move GOs, in case previous attempt
+ * was not possible.
+ */
+#define P2P_RECONSIDER_GO_MOVE_DELAY 30
+
enum p2p_group_removal_reason {
P2P_GROUP_REMOVAL_UNKNOWN,
P2P_GROUP_REMOVAL_SILENT,
@@ -94,7 +106,8 @@ enum p2p_group_removal_reason {
P2P_GROUP_REMOVAL_UNAVAILABLE,
P2P_GROUP_REMOVAL_GO_ENDING_SESSION,
P2P_GROUP_REMOVAL_PSK_FAILURE,
- P2P_GROUP_REMOVAL_FREQ_CONFLICT
+ P2P_GROUP_REMOVAL_FREQ_CONFLICT,
+ P2P_GROUP_REMOVAL_GO_LEAVE_CHANNEL
};
@@ -126,6 +139,18 @@ static void wpas_p2p_psk_failure_removal(void *eloop_ctx, void *timeout_ctx);
static void wpas_p2p_group_deinit(struct wpa_supplicant *wpa_s);
static int wpas_p2p_add_group_interface(struct wpa_supplicant *wpa_s,
enum wpa_driver_if_type type);
+static void wpas_p2p_group_formation_failed(struct wpa_supplicant *wpa_s,
+ int already_deleted);
+static void wpas_p2p_optimize_listen_channel(struct wpa_supplicant *wpa_s,
+ struct wpa_used_freq_data *freqs,
+ unsigned int num);
+static void wpas_p2p_move_go(void *eloop_ctx, void *timeout_ctx);
+static int wpas_p2p_go_is_peer_freq(struct wpa_supplicant *wpa_s, int freq);
+static void
+wpas_p2p_consider_moving_gos(struct wpa_supplicant *wpa_s,
+ struct wpa_used_freq_data *freqs, unsigned int num,
+ enum wpas_p2p_channel_update_trig trig);
+static void wpas_p2p_reconsider_moving_go(void *eloop_ctx, void *timeout_ctx);
/*
@@ -191,7 +216,11 @@ static void wpas_p2p_set_own_freq_preference(struct wpa_supplicant *wpa_s,
{
if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
return;
- if (wpa_s->parent->conf->p2p_ignore_shared_freq &&
+
+ /* Use the wpa_s used to control the P2P Device operation */
+ wpa_s = wpa_s->global->p2p_init_wpa_s;
+
+ if (wpa_s->conf->p2p_ignore_shared_freq &&
freq > 0 && wpa_s->num_multichan_concurrent > 1 &&
wpas_p2p_num_unused_channels(wpa_s) > 0) {
wpa_printf(MSG_DEBUG, "P2P: Ignore own channel preference %d MHz due to p2p_ignore_shared_freq=1 configuration",
@@ -600,7 +629,7 @@ static u8 p2ps_group_capability(void *ctx, u8 incoming, u8 role)
*/
go_wpa_s = wpas_p2p_get_go_group(wpa_s);
persistent_go = wpas_p2p_get_persistent_go(wpa_s);
- p2p_no_group_iface = wpa_s->conf->p2p_no_group_iface;
+ p2p_no_group_iface = !wpas_p2p_create_iface(wpa_s);
wpa_printf(MSG_DEBUG, "P2P: GO(iface)=%p persistent(ssid)=%p",
go_wpa_s, persistent_go);
@@ -866,9 +895,12 @@ static int wpas_p2p_group_delete(struct wpa_supplicant *wpa_s,
wpa_printf(MSG_DEBUG, "P2P: Cancelled P2P group formation "
"timeout");
wpa_s->p2p_in_provisioning = 0;
+ wpas_p2p_group_formation_failed(wpa_s, 1);
}
wpa_s->p2p_in_invitation = 0;
+ eloop_cancel_timeout(wpas_p2p_move_go, wpa_s, NULL);
+ eloop_cancel_timeout(wpas_p2p_reconsider_moving_go, wpa_s, NULL);
/*
* Make sure wait for the first client does not remain active after the
@@ -940,6 +972,8 @@ static int wpas_p2p_group_delete(struct wpa_supplicant *wpa_s,
else
wpa_drv_deinit_p2p_cli(wpa_s);
+ os_memset(wpa_s->go_dev_addr, 0, ETH_ALEN);
+
return 0;
}
@@ -1109,13 +1143,14 @@ static void wpas_p2p_add_persistent_group_client(struct wpa_supplicant *wpa_s,
u8 *n;
size_t i;
int found = 0;
+ struct wpa_supplicant *p2p_wpa_s = wpa_s->global->p2p_init_wpa_s;
ssid = wpa_s->current_ssid;
if (ssid == NULL || ssid->mode != WPAS_MODE_P2P_GO ||
!ssid->p2p_persistent_group)
return;
- for (s = wpa_s->parent->conf->ssid; s; s = s->next) {
+ for (s = p2p_wpa_s->conf->ssid; s; s = s->next) {
if (s->disabled != 2 || s->mode != WPAS_MODE_P2P_GO)
continue;
@@ -1174,8 +1209,8 @@ static void wpas_p2p_add_persistent_group_client(struct wpa_supplicant *wpa_s,
0xff, ETH_ALEN);
}
- if (wpa_s->parent->conf->update_config &&
- wpa_config_write(wpa_s->parent->confname, wpa_s->parent->conf))
+ if (p2p_wpa_s->conf->update_config &&
+ wpa_config_write(p2p_wpa_s->confname, p2p_wpa_s->conf))
wpa_printf(MSG_DEBUG, "P2P: Failed to update configuration");
}
@@ -1226,7 +1261,7 @@ static void wpas_p2p_group_started(struct wpa_supplicant *wpa_s,
static void wpas_group_formation_completed(struct wpa_supplicant *wpa_s,
- int success)
+ int success, int already_deleted)
{
struct wpa_ssid *ssid;
int client;
@@ -1251,6 +1286,9 @@ static void wpas_group_formation_completed(struct wpa_supplicant *wpa_s,
if (!success) {
wpa_msg_global(wpa_s->parent, MSG_INFO,
P2P_EVENT_GROUP_FORMATION_FAILURE);
+ wpas_notify_p2p_group_formation_failure(wpa_s, "");
+ if (already_deleted)
+ return;
wpas_p2p_group_delete(wpa_s,
P2P_GROUP_REMOVAL_FORMATION_FAILED);
return;
@@ -1677,14 +1715,22 @@ static void p2p_go_configured(void *ctx, void *data)
params->persistent_group, "");
wpa_s->group_formation_reported = 1;
- if (wpa_s->parent->p2ps_join_addr_valid) {
- wpa_dbg(wpa_s, MSG_DEBUG,
- "P2PS: Setting default PIN for " MACSTR,
- MAC2STR(wpa_s->parent->p2ps_join_addr));
- wpa_supplicant_ap_wps_pin(wpa_s,
- wpa_s->parent->p2ps_join_addr,
- "12345670", NULL, 0, 0);
- wpa_s->parent->p2ps_join_addr_valid = 0;
+ if (wpa_s->parent->p2ps_method_config_any) {
+ if (is_zero_ether_addr(wpa_s->parent->p2ps_join_addr)) {
+ wpa_dbg(wpa_s, MSG_DEBUG,
+ "P2PS: Setting default PIN for ANY");
+ wpa_supplicant_ap_wps_pin(wpa_s, NULL,
+ "12345670", NULL, 0,
+ 0);
+ } else {
+ wpa_dbg(wpa_s, MSG_DEBUG,
+ "P2PS: Setting default PIN for " MACSTR,
+ MAC2STR(wpa_s->parent->p2ps_join_addr));
+ wpa_supplicant_ap_wps_pin(
+ wpa_s, wpa_s->parent->p2ps_join_addr,
+ "12345670", NULL, 0, 0);
+ }
+ wpa_s->parent->p2ps_method_config_any = 0;
}
os_get_reltime(&wpa_s->global->p2p_go_wait_client);
@@ -1771,6 +1817,7 @@ static void wpas_start_wps_go(struct wpa_supplicant *wpa_s,
wpa_s->show_group_started = 0;
wpa_s->p2p_go_group_formation_completed = 0;
wpa_s->group_formation_reported = 0;
+ os_memset(wpa_s->go_dev_addr, 0, ETH_ALEN);
wpa_config_set_network_defaults(ssid);
ssid->temporary = 1;
@@ -1853,6 +1900,7 @@ static void wpas_p2p_clone_config(struct wpa_supplicant *dst,
d->num_sec_device_types = s->num_sec_device_types;
d->p2p_group_idle = s->p2p_group_idle;
+ d->p2p_go_freq_change_policy = s->p2p_go_freq_change_policy;
d->p2p_intra_bss = s->p2p_intra_bss;
d->persistent_reconnect = s->persistent_reconnect;
d->max_num_sta = s->max_num_sta;
@@ -1869,6 +1917,7 @@ static void wpas_p2p_clone_config(struct wpa_supplicant *dst,
d->wps_nfc_dh_privkey = wpabuf_dup(s->wps_nfc_dh_privkey);
d->wps_nfc_dh_pubkey = wpabuf_dup(s->wps_nfc_dh_pubkey);
}
+ d->p2p_cli_probe = s->p2p_cli_probe;
}
@@ -2014,17 +2063,18 @@ static void wpas_p2p_group_formation_timeout(void *eloop_ctx,
{
struct wpa_supplicant *wpa_s = eloop_ctx;
wpa_printf(MSG_DEBUG, "P2P: Group Formation timed out");
- wpas_p2p_group_formation_failed(wpa_s);
+ wpas_p2p_group_formation_failed(wpa_s, 0);
}
-void wpas_p2p_group_formation_failed(struct wpa_supplicant *wpa_s)
+static void wpas_p2p_group_formation_failed(struct wpa_supplicant *wpa_s,
+ int already_deleted)
{
eloop_cancel_timeout(wpas_p2p_group_formation_timeout,
wpa_s->parent, NULL);
if (wpa_s->global->p2p)
p2p_group_formation_failed(wpa_s->global->p2p);
- wpas_group_formation_completed(wpa_s, 0);
+ wpas_group_formation_completed(wpa_s, 0, already_deleted);
}
@@ -2070,6 +2120,11 @@ static void wpas_go_neg_completed(void *ctx, struct p2p_go_neg_results *res)
return;
}
+ if (!res->role_go) {
+ /* Inform driver of the operating channel of GO. */
+ wpa_drv_set_prob_oper_freq(wpa_s, res->freq);
+ }
+
if (wpa_s->p2p_go_ht40)
res->ht40 = 1;
if (wpa_s->p2p_go_vht)
@@ -2105,7 +2160,7 @@ static void wpas_go_neg_completed(void *ctx, struct p2p_go_neg_results *res)
wpas_p2p_remove_pending_group_interface(wpa_s);
eloop_cancel_timeout(wpas_p2p_long_listen_timeout,
wpa_s, NULL);
- wpas_p2p_group_formation_failed(wpa_s);
+ wpas_p2p_group_formation_failed(wpa_s, 1);
return;
}
if (group_wpa_s != wpa_s) {
@@ -2117,18 +2172,22 @@ static void wpas_go_neg_completed(void *ctx, struct p2p_go_neg_results *res)
wpa_s->pending_interface_name[0] = '\0';
group_wpa_s->p2p_in_provisioning = 1;
- if (res->role_go)
+ if (res->role_go) {
wpas_start_wps_go(group_wpa_s, res, 1);
- else
+ } else {
+ os_get_reltime(&group_wpa_s->scan_min_time);
wpas_start_wps_enrollee(group_wpa_s, res);
+ }
} else {
wpa_s->p2p_in_provisioning = 1;
wpa_s->global->p2p_group_formation = wpa_s;
- if (res->role_go)
+ if (res->role_go) {
wpas_start_wps_go(wpa_s, res, 1);
- else
+ } else {
+ os_get_reltime(&wpa_s->scan_min_time);
wpas_start_wps_enrollee(ctx, res);
+ }
}
wpa_s->p2p_long_listen = 0;
@@ -2141,13 +2200,15 @@ static void wpas_go_neg_completed(void *ctx, struct p2p_go_neg_results *res)
}
-static void wpas_go_neg_req_rx(void *ctx, const u8 *src, u16 dev_passwd_id)
+static void wpas_go_neg_req_rx(void *ctx, const u8 *src, u16 dev_passwd_id,
+ u8 go_intent)
{
struct wpa_supplicant *wpa_s = ctx;
wpa_msg_global(wpa_s, MSG_INFO, P2P_EVENT_GO_NEG_REQUEST MACSTR
- " dev_passwd_id=%u", MAC2STR(src), dev_passwd_id);
+ " dev_passwd_id=%u go_intent=%u", MAC2STR(src),
+ dev_passwd_id, go_intent);
- wpas_notify_p2p_go_neg_req(wpa_s, src, dev_passwd_id);
+ wpas_notify_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
}
@@ -2248,6 +2309,7 @@ static void wpas_find_stopped(void *ctx)
{
struct wpa_supplicant *wpa_s = ctx;
wpa_msg_global(wpa_s, MSG_INFO, P2P_EVENT_FIND_STOPPED);
+ wpas_notify_p2p_find_stopped(wpa_s);
}
@@ -2376,1236 +2438,24 @@ static void wpas_stop_listen(void *ctx)
wpa_s->roc_waiting_drv_freq = 0;
}
wpa_drv_set_ap_wps_ie(wpa_s, NULL, NULL, NULL);
- wpa_drv_probe_req_report(wpa_s, 0);
- wpas_p2p_listen_work_done(wpa_s);
-}
-
-
-static int wpas_send_probe_resp(void *ctx, const struct wpabuf *buf)
-{
- struct wpa_supplicant *wpa_s = ctx;
- return wpa_drv_send_mlme(wpa_s, wpabuf_head(buf), wpabuf_len(buf), 1);
-}
-
-
-/*
- * DNS Header section is used only to calculate compression pointers, so the
- * contents of this data does not matter, but the length needs to be reserved
- * in the virtual packet.
- */
-#define DNS_HEADER_LEN 12
-
-/*
- * 27-octet in-memory packet from P2P specification containing two implied
- * queries for _tcp.lcoal. PTR IN and _udp.local. PTR IN
- */
-#define P2P_SD_IN_MEMORY_LEN 27
-
-static int p2p_sd_dns_uncompress_label(char **upos, char *uend, u8 *start,
- u8 **spos, const u8 *end)
-{
- while (*spos < end) {
- u8 val = ((*spos)[0] & 0xc0) >> 6;
- int len;
-
- if (val == 1 || val == 2) {
- /* These are reserved values in RFC 1035 */
- wpa_printf(MSG_DEBUG, "P2P: Invalid domain name "
- "sequence starting with 0x%x", val);
- return -1;
- }
-
- if (val == 3) {
- u16 offset;
- u8 *spos_tmp;
-
- /* Offset */
- if (*spos + 2 > end) {
- wpa_printf(MSG_DEBUG, "P2P: No room for full "
- "DNS offset field");
- return -1;
- }
-
- offset = (((*spos)[0] & 0x3f) << 8) | (*spos)[1];
- if (offset >= *spos - start) {
- wpa_printf(MSG_DEBUG, "P2P: Invalid DNS "
- "pointer offset %u", offset);
- return -1;
- }
-
- (*spos) += 2;
- spos_tmp = start + offset;
- return p2p_sd_dns_uncompress_label(upos, uend, start,
- &spos_tmp,
- *spos - 2);
- }
-
- /* Label */
- len = (*spos)[0] & 0x3f;
- if (len == 0)
- return 0;
-
- (*spos)++;
- if (*spos + len > end) {
- wpa_printf(MSG_DEBUG, "P2P: Invalid domain name "
- "sequence - no room for label with length "
- "%u", len);
- return -1;
- }
-
- if (*upos + len + 2 > uend)
- return -2;
-
- os_memcpy(*upos, *spos, len);
- *spos += len;
- *upos += len;
- (*upos)[0] = '.';
- (*upos)++;
- (*upos)[0] = '\0';
- }
-
- return 0;
-}
-
-
-/* Uncompress domain names per RFC 1035 using the P2P SD in-memory packet.
- * Returns -1 on parsing error (invalid input sequence), -2 if output buffer is
- * not large enough */
-static int p2p_sd_dns_uncompress(char *buf, size_t buf_len, const u8 *msg,
- size_t msg_len, size_t offset)
-{
- /* 27-octet in-memory packet from P2P specification */
- const char *prefix = "\x04_tcp\x05local\x00\x00\x0C\x00\x01"
- "\x04_udp\xC0\x11\x00\x0C\x00\x01";
- u8 *tmp, *end, *spos;
- char *upos, *uend;
- int ret = 0;
-
- if (buf_len < 2)
- return -1;
- if (offset > msg_len)
- return -1;
-
- tmp = os_malloc(DNS_HEADER_LEN + P2P_SD_IN_MEMORY_LEN + msg_len);
- if (tmp == NULL)
- return -1;
- spos = tmp + DNS_HEADER_LEN + P2P_SD_IN_MEMORY_LEN;
- end = spos + msg_len;
- spos += offset;
-
- os_memset(tmp, 0, DNS_HEADER_LEN);
- os_memcpy(tmp + DNS_HEADER_LEN, prefix, P2P_SD_IN_MEMORY_LEN);
- os_memcpy(tmp + DNS_HEADER_LEN + P2P_SD_IN_MEMORY_LEN, msg, msg_len);
-
- upos = buf;
- uend = buf + buf_len;
-
- ret = p2p_sd_dns_uncompress_label(&upos, uend, tmp, &spos, end);
- if (ret) {
- os_free(tmp);
- return ret;
- }
-
- if (upos == buf) {
- upos[0] = '.';
- upos[1] = '\0';
- } else if (upos[-1] == '.')
- upos[-1] = '\0';
-
- os_free(tmp);
- return 0;
-}
-
-
-static struct p2p_srv_bonjour *
-wpas_p2p_service_get_bonjour(struct wpa_supplicant *wpa_s,
- const struct wpabuf *query)
-{
- struct p2p_srv_bonjour *bsrv;
- size_t len;
-
- len = wpabuf_len(query);
- dl_list_for_each(bsrv, &wpa_s->global->p2p_srv_bonjour,
- struct p2p_srv_bonjour, list) {
- if (len == wpabuf_len(bsrv->query) &&
- os_memcmp(wpabuf_head(query), wpabuf_head(bsrv->query),
- len) == 0)
- return bsrv;
- }
- return NULL;
-}
-
-
-static struct p2p_srv_upnp *
-wpas_p2p_service_get_upnp(struct wpa_supplicant *wpa_s, u8 version,
- const char *service)
-{
- struct p2p_srv_upnp *usrv;
-
- dl_list_for_each(usrv, &wpa_s->global->p2p_srv_upnp,
- struct p2p_srv_upnp, list) {
- if (version == usrv->version &&
- os_strcmp(service, usrv->service) == 0)
- return usrv;
- }
- return NULL;
-}
-
-
-static void wpas_sd_add_empty(struct wpabuf *resp, u8 srv_proto,
- u8 srv_trans_id, u8 status)
-{
- u8 *len_pos;
-
- if (wpabuf_tailroom(resp) < 5)
- return;
-
- /* Length (to be filled) */
- len_pos = wpabuf_put(resp, 2);
- wpabuf_put_u8(resp, srv_proto);
- wpabuf_put_u8(resp, srv_trans_id);
- /* Status Code */
- wpabuf_put_u8(resp, status);
- /* Response Data: empty */
- WPA_PUT_LE16(len_pos, (u8 *) wpabuf_put(resp, 0) - len_pos - 2);
-}
-
-
-static void wpas_sd_add_proto_not_avail(struct wpabuf *resp, u8 srv_proto,
- u8 srv_trans_id)
-{
- wpas_sd_add_empty(resp, srv_proto, srv_trans_id,
- P2P_SD_PROTO_NOT_AVAILABLE);
-}
-
-
-static void wpas_sd_add_bad_request(struct wpabuf *resp, u8 srv_proto,
- u8 srv_trans_id)
-{
- wpas_sd_add_empty(resp, srv_proto, srv_trans_id, P2P_SD_BAD_REQUEST);
-}
-
-
-static void wpas_sd_add_not_found(struct wpabuf *resp, u8 srv_proto,
- u8 srv_trans_id)
-{
- wpas_sd_add_empty(resp, srv_proto, srv_trans_id,
- P2P_SD_REQUESTED_INFO_NOT_AVAILABLE);
-}
-
-
-static void wpas_sd_all_bonjour(struct wpa_supplicant *wpa_s,
- struct wpabuf *resp, u8 srv_trans_id)
-{
- struct p2p_srv_bonjour *bsrv;
- u8 *len_pos;
-
- wpa_printf(MSG_DEBUG, "P2P: SD Request for all Bonjour services");
-
- if (dl_list_empty(&wpa_s->global->p2p_srv_bonjour)) {
- wpa_printf(MSG_DEBUG, "P2P: Bonjour protocol not available");
- return;
- }
-
- dl_list_for_each(bsrv, &wpa_s->global->p2p_srv_bonjour,
- struct p2p_srv_bonjour, list) {
- if (wpabuf_tailroom(resp) <
- 5 + wpabuf_len(bsrv->query) + wpabuf_len(bsrv->resp))
- return;
- /* Length (to be filled) */
- len_pos = wpabuf_put(resp, 2);
- wpabuf_put_u8(resp, P2P_SERV_BONJOUR);
- wpabuf_put_u8(resp, srv_trans_id);
- /* Status Code */
- wpabuf_put_u8(resp, P2P_SD_SUCCESS);
- wpa_hexdump_ascii(MSG_DEBUG, "P2P: Matching Bonjour service",
- wpabuf_head(bsrv->resp),
- wpabuf_len(bsrv->resp));
- /* Response Data */
- wpabuf_put_buf(resp, bsrv->query); /* Key */
- wpabuf_put_buf(resp, bsrv->resp); /* Value */
- WPA_PUT_LE16(len_pos, (u8 *) wpabuf_put(resp, 0) - len_pos -
- 2);
- }
-}
-
-
-static int match_bonjour_query(struct p2p_srv_bonjour *bsrv, const u8 *query,
- size_t query_len)
-{
- char str_rx[256], str_srv[256];
-
- if (query_len < 3 || wpabuf_len(bsrv->query) < 3)
- return 0; /* Too short to include DNS Type and Version */
- if (os_memcmp(query + query_len - 3,
- wpabuf_head_u8(bsrv->query) + wpabuf_len(bsrv->query) - 3,
- 3) != 0)
- return 0; /* Mismatch in DNS Type or Version */
- if (query_len == wpabuf_len(bsrv->query) &&
- os_memcmp(query, wpabuf_head(bsrv->query), query_len - 3) == 0)
- return 1; /* Binary match */
-
- if (p2p_sd_dns_uncompress(str_rx, sizeof(str_rx), query, query_len - 3,
- 0))
- return 0; /* Failed to uncompress query */
- if (p2p_sd_dns_uncompress(str_srv, sizeof(str_srv),
- wpabuf_head(bsrv->query),
- wpabuf_len(bsrv->query) - 3, 0))
- return 0; /* Failed to uncompress service */
-
- return os_strcmp(str_rx, str_srv) == 0;
-}
-
-
-static void wpas_sd_req_bonjour(struct wpa_supplicant *wpa_s,
- struct wpabuf *resp, u8 srv_trans_id,
- const u8 *query, size_t query_len)
-{
- struct p2p_srv_bonjour *bsrv;
- u8 *len_pos;
- int matches = 0;
-
- wpa_hexdump_ascii(MSG_DEBUG, "P2P: SD Request for Bonjour",
- query, query_len);
- if (dl_list_empty(&wpa_s->global->p2p_srv_bonjour)) {
- wpa_printf(MSG_DEBUG, "P2P: Bonjour protocol not available");
- wpas_sd_add_proto_not_avail(resp, P2P_SERV_BONJOUR,
- srv_trans_id);
- return;
- }
-
- if (query_len == 0) {
- wpas_sd_all_bonjour(wpa_s, resp, srv_trans_id);
- return;
- }
-
- dl_list_for_each(bsrv, &wpa_s->global->p2p_srv_bonjour,
- struct p2p_srv_bonjour, list) {
- if (!match_bonjour_query(bsrv, query, query_len))
- continue;
-
- if (wpabuf_tailroom(resp) <
- 5 + query_len + wpabuf_len(bsrv->resp))
- return;
-
- matches++;
-
- /* Length (to be filled) */
- len_pos = wpabuf_put(resp, 2);
- wpabuf_put_u8(resp, P2P_SERV_BONJOUR);
- wpabuf_put_u8(resp, srv_trans_id);
-
- /* Status Code */
- wpabuf_put_u8(resp, P2P_SD_SUCCESS);
- wpa_hexdump_ascii(MSG_DEBUG, "P2P: Matching Bonjour service",
- wpabuf_head(bsrv->resp),
- wpabuf_len(bsrv->resp));
-
- /* Response Data */
- wpabuf_put_data(resp, query, query_len); /* Key */
- wpabuf_put_buf(resp, bsrv->resp); /* Value */
-
- WPA_PUT_LE16(len_pos, (u8 *) wpabuf_put(resp, 0) - len_pos - 2);
- }
-
- if (matches == 0) {
- wpa_printf(MSG_DEBUG, "P2P: Requested Bonjour service not "
- "available");
- if (wpabuf_tailroom(resp) < 5)
- return;
-
- /* Length (to be filled) */
- len_pos = wpabuf_put(resp, 2);
- wpabuf_put_u8(resp, P2P_SERV_BONJOUR);
- wpabuf_put_u8(resp, srv_trans_id);
-
- /* Status Code */
- wpabuf_put_u8(resp, P2P_SD_REQUESTED_INFO_NOT_AVAILABLE);
- /* Response Data: empty */
- WPA_PUT_LE16(len_pos, (u8 *) wpabuf_put(resp, 0) - len_pos -
- 2);
- }
-}
-
-
-static void wpas_sd_all_upnp(struct wpa_supplicant *wpa_s,
- struct wpabuf *resp, u8 srv_trans_id)
-{
- struct p2p_srv_upnp *usrv;
- u8 *len_pos;
-
- wpa_printf(MSG_DEBUG, "P2P: SD Request for all UPnP services");
-
- if (dl_list_empty(&wpa_s->global->p2p_srv_upnp)) {
- wpa_printf(MSG_DEBUG, "P2P: UPnP protocol not available");
- return;
- }
-
- dl_list_for_each(usrv, &wpa_s->global->p2p_srv_upnp,
- struct p2p_srv_upnp, list) {
- if (wpabuf_tailroom(resp) < 5 + 1 + os_strlen(usrv->service))
- return;
-
- /* Length (to be filled) */
- len_pos = wpabuf_put(resp, 2);
- wpabuf_put_u8(resp, P2P_SERV_UPNP);
- wpabuf_put_u8(resp, srv_trans_id);
-
- /* Status Code */
- wpabuf_put_u8(resp, P2P_SD_SUCCESS);
- /* Response Data */
- wpabuf_put_u8(resp, usrv->version);
- wpa_printf(MSG_DEBUG, "P2P: Matching UPnP Service: %s",
- usrv->service);
- wpabuf_put_str(resp, usrv->service);
- WPA_PUT_LE16(len_pos, (u8 *) wpabuf_put(resp, 0) - len_pos -
- 2);
- }
-}
-
-
-static void wpas_sd_req_upnp(struct wpa_supplicant *wpa_s,
- struct wpabuf *resp, u8 srv_trans_id,
- const u8 *query, size_t query_len)
-{
- struct p2p_srv_upnp *usrv;
- u8 *len_pos;
- u8 version;
- char *str;
- int count = 0;
-
- wpa_hexdump_ascii(MSG_DEBUG, "P2P: SD Request for UPnP",
- query, query_len);
-
- if (dl_list_empty(&wpa_s->global->p2p_srv_upnp)) {
- wpa_printf(MSG_DEBUG, "P2P: UPnP protocol not available");
- wpas_sd_add_proto_not_avail(resp, P2P_SERV_UPNP,
- srv_trans_id);
- return;
- }
-
- if (query_len == 0) {
- wpas_sd_all_upnp(wpa_s, resp, srv_trans_id);
- return;
- }
-
- if (wpabuf_tailroom(resp) < 5)
- return;
-
- /* Length (to be filled) */
- len_pos = wpabuf_put(resp, 2);
- wpabuf_put_u8(resp, P2P_SERV_UPNP);
- wpabuf_put_u8(resp, srv_trans_id);
-
- version = query[0];
- str = os_malloc(query_len);
- if (str == NULL)
- return;
- os_memcpy(str, query + 1, query_len - 1);
- str[query_len - 1] = '\0';
-
- dl_list_for_each(usrv, &wpa_s->global->p2p_srv_upnp,
- struct p2p_srv_upnp, list) {
- if (version != usrv->version)
- continue;
-
- if (os_strcmp(str, "ssdp:all") != 0 &&
- os_strstr(usrv->service, str) == NULL)
- continue;
-
- if (wpabuf_tailroom(resp) < 2)
- break;
- if (count == 0) {
- /* Status Code */
- wpabuf_put_u8(resp, P2P_SD_SUCCESS);
- /* Response Data */
- wpabuf_put_u8(resp, version);
- } else
- wpabuf_put_u8(resp, ',');
-
- count++;
-
- wpa_printf(MSG_DEBUG, "P2P: Matching UPnP Service: %s",
- usrv->service);
- if (wpabuf_tailroom(resp) < os_strlen(usrv->service))
- break;
- wpabuf_put_str(resp, usrv->service);
- }
- os_free(str);
-
- if (count == 0) {
- wpa_printf(MSG_DEBUG, "P2P: Requested UPnP service not "
- "available");
- /* Status Code */
- wpabuf_put_u8(resp, P2P_SD_REQUESTED_INFO_NOT_AVAILABLE);
- /* Response Data: empty */
- }
-
- WPA_PUT_LE16(len_pos, (u8 *) wpabuf_put(resp, 0) - len_pos - 2);
-}
-
-
-#ifdef CONFIG_WIFI_DISPLAY
-static void wpas_sd_req_wfd(struct wpa_supplicant *wpa_s,
- struct wpabuf *resp, u8 srv_trans_id,
- const u8 *query, size_t query_len)
-{
- const u8 *pos;
- u8 role;
- u8 *len_pos;
-
- wpa_hexdump(MSG_DEBUG, "P2P: SD Request for WFD", query, query_len);
-
- if (!wpa_s->global->wifi_display) {
- wpa_printf(MSG_DEBUG, "P2P: WFD protocol not available");
- wpas_sd_add_proto_not_avail(resp, P2P_SERV_WIFI_DISPLAY,
- srv_trans_id);
- return;
- }
-
- if (query_len < 1) {
- wpa_printf(MSG_DEBUG, "P2P: Missing WFD Requested Device "
- "Role");
- return;
- }
-
- if (wpabuf_tailroom(resp) < 5)
- return;
-
- pos = query;
- role = *pos++;
- wpa_printf(MSG_DEBUG, "P2P: WSD for device role 0x%x", role);
-
- /* TODO: role specific handling */
-
- /* Length (to be filled) */
- len_pos = wpabuf_put(resp, 2);
- wpabuf_put_u8(resp, P2P_SERV_WIFI_DISPLAY);
- wpabuf_put_u8(resp, srv_trans_id);
- wpabuf_put_u8(resp, P2P_SD_SUCCESS); /* Status Code */
-
- while (pos < query + query_len) {
- if (*pos < MAX_WFD_SUBELEMS &&
- wpa_s->global->wfd_subelem[*pos] &&
- wpabuf_tailroom(resp) >=
- wpabuf_len(wpa_s->global->wfd_subelem[*pos])) {
- wpa_printf(MSG_DEBUG, "P2P: Add WSD response "
- "subelement %u", *pos);
- wpabuf_put_buf(resp, wpa_s->global->wfd_subelem[*pos]);
- }
- pos++;
- }
-
- WPA_PUT_LE16(len_pos, (u8 *) wpabuf_put(resp, 0) - len_pos - 2);
-}
-#endif /* CONFIG_WIFI_DISPLAY */
-
-
-static int find_p2ps_substr(struct p2ps_advertisement *adv_data,
- const u8 *needle, size_t needle_len)
-{
- const u8 *haystack = (const u8 *) adv_data->svc_info;
- size_t haystack_len, i;
-
- /* Allow search term to be empty */
- if (!needle || !needle_len)
- return 1;
-
- if (!haystack)
- return 0;
-
- haystack_len = os_strlen(adv_data->svc_info);
- for (i = 0; i < haystack_len; i++) {
- if (haystack_len - i < needle_len)
- break;
- if (os_memcmp(haystack + i, needle, needle_len) == 0)
- return 1;
- }
-
- return 0;
-}
-
-
-static void wpas_sd_req_asp(struct wpa_supplicant *wpa_s,
- struct wpabuf *resp, u8 srv_trans_id,
- const u8 *query, size_t query_len)
-{
- struct p2ps_advertisement *adv_data;
- const u8 *svc = &query[1];
- const u8 *info = NULL;
- size_t svc_len = query[0];
- size_t info_len = 0;
- int prefix = 0;
- u8 *count_pos = NULL;
- u8 *len_pos = NULL;
-
- wpa_hexdump(MSG_DEBUG, "P2P: SD Request for ASP", query, query_len);
-
- if (!wpa_s->global->p2p) {
- wpa_printf(MSG_DEBUG, "P2P: ASP protocol not available");
- wpas_sd_add_proto_not_avail(resp, P2P_SERV_P2PS, srv_trans_id);
- return;
- }
-
- /* Info block is optional */
- if (svc_len + 1 < query_len) {
- info = &svc[svc_len];
- info_len = *info++;
- }
-
- /* Range check length of svc string and info block */
- if (svc_len + (info_len ? info_len + 2 : 1) > query_len) {
- wpa_printf(MSG_DEBUG, "P2P: ASP bad request");
- wpas_sd_add_bad_request(resp, P2P_SERV_P2PS, srv_trans_id);
- return;
- }
- /* Detect and correct for prefix search */
- if (svc_len && svc[svc_len - 1] == '*') {
- prefix = 1;
- svc_len--;
- }
-
- for (adv_data = p2p_get_p2ps_adv_list(wpa_s->global->p2p);
- adv_data; adv_data = adv_data->next) {
- /* If not a prefix match, reject length mismatches */
- if (!prefix && svc_len != os_strlen(adv_data->svc_name))
- continue;
-
- /* Search each service for request */
- if (os_memcmp(adv_data->svc_name, svc, svc_len) == 0 &&
- find_p2ps_substr(adv_data, info, info_len)) {
- size_t len = os_strlen(adv_data->svc_name);
- size_t svc_info_len = 0;
-
- if (adv_data->svc_info)
- svc_info_len = os_strlen(adv_data->svc_info);
-
- if (len > 0xff || svc_info_len > 0xffff)
- return;
-
- /* Length & Count to be filled as we go */
- if (!len_pos && !count_pos) {
- if (wpabuf_tailroom(resp) <
- len + svc_info_len + 16)
- return;
-
- len_pos = wpabuf_put(resp, 2);
- wpabuf_put_u8(resp, P2P_SERV_P2PS);
- wpabuf_put_u8(resp, srv_trans_id);
- /* Status Code */
- wpabuf_put_u8(resp, P2P_SD_SUCCESS);
- count_pos = wpabuf_put(resp, 1);
- *count_pos = 0;
- } else if (wpabuf_tailroom(resp) <
- len + svc_info_len + 10)
- return;
-
- if (svc_info_len) {
- wpa_printf(MSG_DEBUG,
- "P2P: Add Svc: %s info: %s",
- adv_data->svc_name,
- adv_data->svc_info);
- } else {
- wpa_printf(MSG_DEBUG, "P2P: Add Svc: %s",
- adv_data->svc_name);
- }
-
- /* Advertisement ID */
- wpabuf_put_le32(resp, adv_data->id);
-
- /* Config Methods */
- wpabuf_put_be16(resp, adv_data->config_methods);
-
- /* Service Name */
- wpabuf_put_u8(resp, (u8) len);
- wpabuf_put_data(resp, adv_data->svc_name, len);
-
- /* Service State */
- wpabuf_put_u8(resp, adv_data->state);
-
- /* Service Information */
- wpabuf_put_le16(resp, (u16) svc_info_len);
- wpabuf_put_data(resp, adv_data->svc_info, svc_info_len);
-
- /* Update length and count */
- (*count_pos)++;
- WPA_PUT_LE16(len_pos,
- (u8 *) wpabuf_put(resp, 0) - len_pos - 2);
- }
- }
-
- /* Return error if no matching svc found */
- if (count_pos == NULL) {
- wpa_printf(MSG_DEBUG, "P2P: ASP service not found");
- wpas_sd_add_not_found(resp, P2P_SERV_P2PS, srv_trans_id);
- }
-}
-
-
-static void wpas_sd_request(void *ctx, int freq, const u8 *sa, u8 dialog_token,
- u16 update_indic, const u8 *tlvs, size_t tlvs_len)
-{
- struct wpa_supplicant *wpa_s = ctx;
- const u8 *pos = tlvs;
- const u8 *end = tlvs + tlvs_len;
- const u8 *tlv_end;
- u16 slen;
- struct wpabuf *resp;
- u8 srv_proto, srv_trans_id;
- size_t buf_len;
- char *buf;
-
- wpa_hexdump(MSG_MSGDUMP, "P2P: Service Discovery Request TLVs",
- tlvs, tlvs_len);
- buf_len = 2 * tlvs_len + 1;
- buf = os_malloc(buf_len);
- if (buf) {
- wpa_snprintf_hex(buf, buf_len, tlvs, tlvs_len);
- wpa_msg_ctrl(wpa_s, MSG_INFO, P2P_EVENT_SERV_DISC_REQ "%d "
- MACSTR " %u %u %s",
- freq, MAC2STR(sa), dialog_token, update_indic,
- buf);
- os_free(buf);
- }
-
- if (wpa_s->p2p_sd_over_ctrl_iface) {
- wpas_notify_p2p_sd_request(wpa_s, freq, sa, dialog_token,
- update_indic, tlvs, tlvs_len);
- return; /* to be processed by an external program */
- }
-
- resp = wpabuf_alloc(10000);
- if (resp == NULL)
- return;
-
- while (pos + 1 < end) {
- wpa_printf(MSG_DEBUG, "P2P: Service Request TLV");
- slen = WPA_GET_LE16(pos);
- pos += 2;
- if (pos + slen > end || slen < 2) {
- wpa_printf(MSG_DEBUG, "P2P: Unexpected Query Data "
- "length");
- wpabuf_free(resp);
- return;
- }
- tlv_end = pos + slen;
-
- srv_proto = *pos++;
- wpa_printf(MSG_DEBUG, "P2P: Service Protocol Type %u",
- srv_proto);
- srv_trans_id = *pos++;
- wpa_printf(MSG_DEBUG, "P2P: Service Transaction ID %u",
- srv_trans_id);
-
- wpa_hexdump(MSG_MSGDUMP, "P2P: Query Data",
- pos, tlv_end - pos);
-
-
- if (wpa_s->force_long_sd) {
- wpa_printf(MSG_DEBUG, "P2P: SD test - force long "
- "response");
- wpas_sd_all_bonjour(wpa_s, resp, srv_trans_id);
- wpas_sd_all_upnp(wpa_s, resp, srv_trans_id);
- goto done;
- }
-
- switch (srv_proto) {
- case P2P_SERV_ALL_SERVICES:
- wpa_printf(MSG_DEBUG, "P2P: Service Discovery Request "
- "for all services");
- if (dl_list_empty(&wpa_s->global->p2p_srv_upnp) &&
- dl_list_empty(&wpa_s->global->p2p_srv_bonjour)) {
- wpa_printf(MSG_DEBUG, "P2P: No service "
- "discovery protocols available");
- wpas_sd_add_proto_not_avail(
- resp, P2P_SERV_ALL_SERVICES,
- srv_trans_id);
- break;
- }
- wpas_sd_all_bonjour(wpa_s, resp, srv_trans_id);
- wpas_sd_all_upnp(wpa_s, resp, srv_trans_id);
- break;
- case P2P_SERV_BONJOUR:
- wpas_sd_req_bonjour(wpa_s, resp, srv_trans_id,
- pos, tlv_end - pos);
- break;
- case P2P_SERV_UPNP:
- wpas_sd_req_upnp(wpa_s, resp, srv_trans_id,
- pos, tlv_end - pos);
- break;
-#ifdef CONFIG_WIFI_DISPLAY
- case P2P_SERV_WIFI_DISPLAY:
- wpas_sd_req_wfd(wpa_s, resp, srv_trans_id,
- pos, tlv_end - pos);
- break;
-#endif /* CONFIG_WIFI_DISPLAY */
- case P2P_SERV_P2PS:
- wpas_sd_req_asp(wpa_s, resp, srv_trans_id,
- pos, tlv_end - pos);
- break;
- default:
- wpa_printf(MSG_DEBUG, "P2P: Unavailable service "
- "protocol %u", srv_proto);
- wpas_sd_add_proto_not_avail(resp, srv_proto,
- srv_trans_id);
- break;
- }
-
- pos = tlv_end;
- }
-
-done:
- wpas_notify_p2p_sd_request(wpa_s, freq, sa, dialog_token,
- update_indic, tlvs, tlvs_len);
-
- wpas_p2p_sd_response(wpa_s, freq, sa, dialog_token, resp);
-
- wpabuf_free(resp);
-}
-
-
-static void wpas_sd_p2ps_serv_response(struct wpa_supplicant *wpa_s,
- const u8 *sa, u8 srv_trans_id,
- const u8 *pos, const u8 *tlv_end)
-{
- u8 left = *pos++;
- u32 adv_id;
- u8 svc_status;
- u16 config_methods;
- char svc_str[256];
-
- while (left-- && pos < tlv_end) {
- char *buf = NULL;
- size_t buf_len;
- u8 svc_len;
-
- /* Sanity check fixed length+svc_str */
- if (pos + 6 >= tlv_end)
- break;
- svc_len = pos[6];
- if (pos + svc_len + 10 > tlv_end)
- break;
-
- /* Advertisement ID */
- adv_id = WPA_GET_LE32(pos);
- pos += sizeof(u32);
-
- /* Config Methods */
- config_methods = WPA_GET_BE16(pos);
- pos += sizeof(u16);
-
- /* Service Name */
- pos++; /* svc_len */
- os_memcpy(svc_str, pos, svc_len);
- svc_str[svc_len] = '\0';
- pos += svc_len;
-
- /* Service Status */
- svc_status = *pos++;
-
- /* Service Information Length */
- buf_len = WPA_GET_LE16(pos);
- pos += sizeof(u16);
-
- /* Sanity check buffer length */
- if (buf_len > (unsigned int) (tlv_end - pos))
- break;
-
- if (buf_len) {
- buf = os_zalloc(2 * buf_len + 1);
- if (buf) {
- utf8_escape((const char *) pos, buf_len, buf,
- 2 * buf_len + 1);
- }
- }
-
- pos += buf_len;
+ /*
+ * Don't cancel Probe Request RX reporting for a connected P2P Client
+ * handling Probe Request frames.
+ */
+ if (!wpa_s->p2p_cli_probe)
+ wpa_drv_probe_req_report(wpa_s, 0);
- if (buf) {
- wpa_msg_global(wpa_s, MSG_INFO, P2P_EVENT_SERV_ASP_RESP
- MACSTR " %x %x %x %x %s '%s'",
- MAC2STR(sa), srv_trans_id, adv_id,
- svc_status, config_methods, svc_str,
- buf);
- os_free(buf);
- } else {
- wpa_msg_global(wpa_s, MSG_INFO, P2P_EVENT_SERV_ASP_RESP
- MACSTR " %x %x %x %x %s",
- MAC2STR(sa), srv_trans_id, adv_id,
- svc_status, config_methods, svc_str);
- }
- }
+ wpas_p2p_listen_work_done(wpa_s);
}
-static void wpas_sd_response(void *ctx, const u8 *sa, u16 update_indic,
- const u8 *tlvs, size_t tlvs_len)
+static int wpas_send_probe_resp(void *ctx, const struct wpabuf *buf,
+ unsigned int freq)
{
struct wpa_supplicant *wpa_s = ctx;
- const u8 *pos = tlvs;
- const u8 *end = tlvs + tlvs_len;
- const u8 *tlv_end;
- u16 slen;
- size_t buf_len;
- char *buf;
-
- wpa_hexdump(MSG_MSGDUMP, "P2P: Service Discovery Response TLVs",
- tlvs, tlvs_len);
- if (tlvs_len > 1500) {
- /* TODO: better way for handling this */
- wpa_msg_ctrl(wpa_s, MSG_INFO,
- P2P_EVENT_SERV_DISC_RESP MACSTR
- " %u <long response: %u bytes>",
- MAC2STR(sa), update_indic,
- (unsigned int) tlvs_len);
- } else {
- buf_len = 2 * tlvs_len + 1;
- buf = os_malloc(buf_len);
- if (buf) {
- wpa_snprintf_hex(buf, buf_len, tlvs, tlvs_len);
- wpa_msg_ctrl(wpa_s, MSG_INFO,
- P2P_EVENT_SERV_DISC_RESP MACSTR " %u %s",
- MAC2STR(sa), update_indic, buf);
- os_free(buf);
- }
- }
-
- while (pos < end) {
- u8 srv_proto, srv_trans_id, status;
-
- wpa_printf(MSG_DEBUG, "P2P: Service Response TLV");
- slen = WPA_GET_LE16(pos);
- pos += 2;
- if (pos + slen > end || slen < 3) {
- wpa_printf(MSG_DEBUG, "P2P: Unexpected Response Data "
- "length");
- return;
- }
- tlv_end = pos + slen;
-
- srv_proto = *pos++;
- wpa_printf(MSG_DEBUG, "P2P: Service Protocol Type %u",
- srv_proto);
- srv_trans_id = *pos++;
- wpa_printf(MSG_DEBUG, "P2P: Service Transaction ID %u",
- srv_trans_id);
- status = *pos++;
- wpa_printf(MSG_DEBUG, "P2P: Status Code ID %u",
- status);
-
- wpa_hexdump(MSG_MSGDUMP, "P2P: Response Data",
- pos, tlv_end - pos);
-
- if (srv_proto == P2P_SERV_P2PS && pos < tlv_end) {
- wpas_sd_p2ps_serv_response(wpa_s, sa, srv_trans_id,
- pos, tlv_end);
- }
-
- pos = tlv_end;
- }
-
- wpas_notify_p2p_sd_response(wpa_s, sa, update_indic, tlvs, tlvs_len);
-}
-
-
-u64 wpas_p2p_sd_request(struct wpa_supplicant *wpa_s, const u8 *dst,
- const struct wpabuf *tlvs)
-{
- if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
- return 0;
- return (uintptr_t) p2p_sd_request(wpa_s->global->p2p, dst, tlvs);
-}
-
-
-u64 wpas_p2p_sd_request_upnp(struct wpa_supplicant *wpa_s, const u8 *dst,
- u8 version, const char *query)
-{
- struct wpabuf *tlvs;
- u64 ret;
-
- tlvs = wpabuf_alloc(2 + 1 + 1 + 1 + os_strlen(query));
- if (tlvs == NULL)
- return 0;
- wpabuf_put_le16(tlvs, 1 + 1 + 1 + os_strlen(query));
- wpabuf_put_u8(tlvs, P2P_SERV_UPNP); /* Service Protocol Type */
- wpabuf_put_u8(tlvs, 1); /* Service Transaction ID */
- wpabuf_put_u8(tlvs, version);
- wpabuf_put_str(tlvs, query);
- ret = wpas_p2p_sd_request(wpa_s, dst, tlvs);
- wpabuf_free(tlvs);
- return ret;
-}
-
-
-u64 wpas_p2p_sd_request_asp(struct wpa_supplicant *wpa_s, const u8 *dst, u8 id,
- const char *svc_str, const char *info_substr)
-{
- struct wpabuf *tlvs;
- size_t plen, svc_len, substr_len = 0;
- u64 ret;
-
- svc_len = os_strlen(svc_str);
- if (info_substr)
- substr_len = os_strlen(info_substr);
-
- if (svc_len > 0xff || substr_len > 0xff)
- return 0;
-
- plen = 1 + 1 + 1 + svc_len + 1 + substr_len;
- tlvs = wpabuf_alloc(2 + plen);
- if (tlvs == NULL)
- return 0;
-
- wpabuf_put_le16(tlvs, plen);
- wpabuf_put_u8(tlvs, P2P_SERV_P2PS);
- wpabuf_put_u8(tlvs, id); /* Service Transaction ID */
- wpabuf_put_u8(tlvs, (u8) svc_len); /* Service String Length */
- wpabuf_put_data(tlvs, svc_str, svc_len);
- wpabuf_put_u8(tlvs, (u8) substr_len); /* Info Substring Length */
- wpabuf_put_data(tlvs, info_substr, substr_len);
- ret = wpas_p2p_sd_request(wpa_s, dst, tlvs);
- wpabuf_free(tlvs);
-
- return ret;
-}
-
-
-#ifdef CONFIG_WIFI_DISPLAY
-
-static u64 wpas_p2p_sd_request_wfd(struct wpa_supplicant *wpa_s, const u8 *dst,
- const struct wpabuf *tlvs)
-{
- if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
- return 0;
- return (uintptr_t) p2p_sd_request_wfd(wpa_s->global->p2p, dst, tlvs);
-}
-
-
-#define MAX_WFD_SD_SUBELEMS 20
-
-static void wfd_add_sd_req_role(struct wpabuf *tlvs, u8 id, u8 role,
- const char *subelems)
-{
- u8 *len;
- const char *pos;
- int val;
- int count = 0;
-
- len = wpabuf_put(tlvs, 2);
- wpabuf_put_u8(tlvs, P2P_SERV_WIFI_DISPLAY); /* Service Protocol Type */
- wpabuf_put_u8(tlvs, id); /* Service Transaction ID */
-
- wpabuf_put_u8(tlvs, role);
-
- pos = subelems;
- while (*pos) {
- val = atoi(pos);
- if (val >= 0 && val < 256) {
- wpabuf_put_u8(tlvs, val);
- count++;
- if (count == MAX_WFD_SD_SUBELEMS)
- break;
- }
- pos = os_strchr(pos + 1, ',');
- if (pos == NULL)
- break;
- pos++;
- }
-
- WPA_PUT_LE16(len, (u8 *) wpabuf_put(tlvs, 0) - len - 2);
-}
-
-
-u64 wpas_p2p_sd_request_wifi_display(struct wpa_supplicant *wpa_s,
- const u8 *dst, const char *role)
-{
- struct wpabuf *tlvs;
- u64 ret;
- const char *subelems;
- u8 id = 1;
-
- subelems = os_strchr(role, ' ');
- if (subelems == NULL)
- return 0;
- subelems++;
-
- tlvs = wpabuf_alloc(4 * (2 + 1 + 1 + 1 + MAX_WFD_SD_SUBELEMS));
- if (tlvs == NULL)
- return 0;
-
- if (os_strstr(role, "[source]"))
- wfd_add_sd_req_role(tlvs, id++, 0x00, subelems);
- if (os_strstr(role, "[pri-sink]"))
- wfd_add_sd_req_role(tlvs, id++, 0x01, subelems);
- if (os_strstr(role, "[sec-sink]"))
- wfd_add_sd_req_role(tlvs, id++, 0x02, subelems);
- if (os_strstr(role, "[source+sink]"))
- wfd_add_sd_req_role(tlvs, id++, 0x03, subelems);
-
- ret = wpas_p2p_sd_request_wfd(wpa_s, dst, tlvs);
- wpabuf_free(tlvs);
- return ret;
-}
-
-#endif /* CONFIG_WIFI_DISPLAY */
-
-
-int wpas_p2p_sd_cancel_request(struct wpa_supplicant *wpa_s, u64 req)
-{
- if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
- return -1;
- return p2p_sd_cancel_request(wpa_s->global->p2p,
- (void *) (uintptr_t) req);
-}
-
-
-void wpas_p2p_sd_response(struct wpa_supplicant *wpa_s, int freq,
- const u8 *dst, u8 dialog_token,
- const struct wpabuf *resp_tlvs)
-{
- if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
- return;
- p2p_sd_response(wpa_s->global->p2p, freq, dst, dialog_token,
- resp_tlvs);
-}
-
-
-void wpas_p2p_sd_service_update(struct wpa_supplicant *wpa_s)
-{
- if (wpa_s->global->p2p)
- p2p_sd_service_update(wpa_s->global->p2p);
-}
-
-
-static void wpas_p2p_srv_bonjour_free(struct p2p_srv_bonjour *bsrv)
-{
- dl_list_del(&bsrv->list);
- wpabuf_free(bsrv->query);
- wpabuf_free(bsrv->resp);
- os_free(bsrv);
-}
-
-
-static void wpas_p2p_srv_upnp_free(struct p2p_srv_upnp *usrv)
-{
- dl_list_del(&usrv->list);
- os_free(usrv->service);
- os_free(usrv);
-}
-
-
-void wpas_p2p_service_flush(struct wpa_supplicant *wpa_s)
-{
- struct p2p_srv_bonjour *bsrv, *bn;
- struct p2p_srv_upnp *usrv, *un;
-
- dl_list_for_each_safe(bsrv, bn, &wpa_s->global->p2p_srv_bonjour,
- struct p2p_srv_bonjour, list)
- wpas_p2p_srv_bonjour_free(bsrv);
-
- dl_list_for_each_safe(usrv, un, &wpa_s->global->p2p_srv_upnp,
- struct p2p_srv_upnp, list)
- wpas_p2p_srv_upnp_free(usrv);
-
- wpas_p2p_sd_service_update(wpa_s);
-}
-
-
-int wpas_p2p_service_p2ps_id_exists(struct wpa_supplicant *wpa_s, u32 adv_id)
-{
- if (adv_id == 0)
- return 1;
-
- if (p2p_service_p2ps_id(wpa_s->global->p2p, adv_id))
- return 1;
-
- return 0;
-}
-
-
-int wpas_p2p_service_del_asp(struct wpa_supplicant *wpa_s, u32 adv_id)
-{
- return p2p_service_del_asp(wpa_s->global->p2p, adv_id);
-}
-
-
-int wpas_p2p_service_add_asp(struct wpa_supplicant *wpa_s,
- int auto_accept, u32 adv_id,
- const char *adv_str, u8 svc_state,
- u16 config_methods, const char *svc_info)
-{
- return p2p_service_add_asp(wpa_s->global->p2p, auto_accept, adv_id,
- adv_str, svc_state, config_methods,
- svc_info);
-}
-
-
-int wpas_p2p_service_add_bonjour(struct wpa_supplicant *wpa_s,
- struct wpabuf *query, struct wpabuf *resp)
-{
- struct p2p_srv_bonjour *bsrv;
-
- bsrv = os_zalloc(sizeof(*bsrv));
- if (bsrv == NULL)
- return -1;
- bsrv->query = query;
- bsrv->resp = resp;
- dl_list_add(&wpa_s->global->p2p_srv_bonjour, &bsrv->list);
-
- wpas_p2p_sd_service_update(wpa_s);
- return 0;
-}
-
-
-int wpas_p2p_service_del_bonjour(struct wpa_supplicant *wpa_s,
- const struct wpabuf *query)
-{
- struct p2p_srv_bonjour *bsrv;
-
- bsrv = wpas_p2p_service_get_bonjour(wpa_s, query);
- if (bsrv == NULL)
- return -1;
- wpas_p2p_srv_bonjour_free(bsrv);
- wpas_p2p_sd_service_update(wpa_s);
- return 0;
-}
-
-
-int wpas_p2p_service_add_upnp(struct wpa_supplicant *wpa_s, u8 version,
- const char *service)
-{
- struct p2p_srv_upnp *usrv;
-
- if (wpas_p2p_service_get_upnp(wpa_s, version, service))
- return 0; /* Already listed */
- usrv = os_zalloc(sizeof(*usrv));
- if (usrv == NULL)
- return -1;
- usrv->version = version;
- usrv->service = os_strdup(service);
- if (usrv->service == NULL) {
- os_free(usrv);
- return -1;
- }
- dl_list_add(&wpa_s->global->p2p_srv_upnp, &usrv->list);
-
- wpas_p2p_sd_service_update(wpa_s);
- return 0;
-}
-
-
-int wpas_p2p_service_del_upnp(struct wpa_supplicant *wpa_s, u8 version,
- const char *service)
-{
- struct p2p_srv_upnp *usrv;
-
- usrv = wpas_p2p_service_get_upnp(wpa_s, version, service);
- if (usrv == NULL)
- return -1;
- wpas_p2p_srv_upnp_free(usrv);
- wpas_p2p_sd_service_update(wpa_s);
- return 0;
+ return wpa_drv_send_mlme(wpa_s, wpabuf_head(buf), wpabuf_len(buf), 1,
+ freq);
}
@@ -3776,12 +2626,62 @@ static void wpas_prov_disc_fail(void *ctx, const u8 *peer,
}
-static int freq_included(const struct p2p_channels *channels, unsigned int freq)
+static int freq_included(struct wpa_supplicant *wpa_s,
+ const struct p2p_channels *channels,
+ unsigned int freq)
{
- if (channels == NULL)
- return 1; /* Assume no restrictions */
- return p2p_channels_includes_freq(channels, freq);
+ if ((channels == NULL || p2p_channels_includes_freq(channels, freq)) &&
+ wpas_p2p_go_is_peer_freq(wpa_s, freq))
+ return 1;
+ return 0;
+}
+
+
+static void wpas_p2p_go_update_common_freqs(struct wpa_supplicant *wpa_s)
+{
+ unsigned int num = P2P_MAX_CHANNELS;
+ int *common_freqs;
+ int ret;
+
+ p2p_go_dump_common_freqs(wpa_s);
+ common_freqs = os_calloc(num, sizeof(int));
+ if (!common_freqs)
+ return;
+
+ ret = p2p_group_get_common_freqs(wpa_s->p2p_group, common_freqs, &num);
+ if (ret < 0) {
+ wpa_dbg(wpa_s, MSG_DEBUG,
+ "P2P: Failed to get group common freqs");
+ os_free(common_freqs);
+ return;
+ }
+ os_free(wpa_s->p2p_group_common_freqs);
+ wpa_s->p2p_group_common_freqs = common_freqs;
+ wpa_s->p2p_group_common_freqs_num = num;
+ p2p_go_dump_common_freqs(wpa_s);
+}
+
+
+/*
+ * Check if the given frequency is one of the possible operating frequencies
+ * set after the completion of the GO Negotiation.
+ */
+static int wpas_p2p_go_is_peer_freq(struct wpa_supplicant *wpa_s, int freq)
+{
+ unsigned int i;
+
+ p2p_go_dump_common_freqs(wpa_s);
+
+ /* assume no restrictions */
+ if (!wpa_s->p2p_group_common_freqs_num)
+ return 1;
+
+ for (i = 0; i < wpa_s->p2p_group_common_freqs_num; i++) {
+ if (wpa_s->p2p_group_common_freqs[i] == freq)
+ return 1;
+ }
+ return 0;
}
@@ -3957,7 +2857,7 @@ accept_inv:
"running a GO but we are capable of MCC, "
"figure out the best channel to use");
*force_freq = 0;
- } else if (!freq_included(channels, *force_freq)) {
+ } else if (!freq_included(wpa_s, channels, *force_freq)) {
/* We are the GO, and *force_freq is not in the
* intersection */
wpa_printf(MSG_DEBUG, "P2P: Forced GO freq %d MHz not "
@@ -3995,7 +2895,8 @@ static void wpas_invitation_received(void *ctx, const u8 *sa, const u8 *bssid,
int go = s->mode == WPAS_MODE_P2P_GO;
wpas_p2p_group_add_persistent(
wpa_s, s, go, 0, op_freq, 0, 0, NULL,
- go ? P2P_MAX_INITIAL_CONN_WAIT_GO_REINVOKE : 0);
+ go ? P2P_MAX_INITIAL_CONN_WAIT_GO_REINVOKE : 0,
+ 1);
} else if (bssid) {
wpa_s->user_initiated_pd = 0;
wpas_p2p_join(wpa_s, bssid, go_dev_addr,
@@ -4026,6 +2927,8 @@ static void wpas_invitation_received(void *ctx, const u8 *sa, const u8 *bssid,
" unknown-network",
MAC2STR(sa), MAC2STR(go_dev_addr));
}
+ wpas_notify_p2p_invitation_received(wpa_s, sa, go_dev_addr,
+ bssid, 0, op_freq);
return;
}
@@ -4038,6 +2941,8 @@ static void wpas_invitation_received(void *ctx, const u8 *sa, const u8 *bssid,
"sa=" MACSTR " persistent=%d",
MAC2STR(sa), s->id);
}
+ wpas_notify_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
+ s->id, op_freq);
}
@@ -4046,6 +2951,7 @@ static void wpas_remove_persistent_peer(struct wpa_supplicant *wpa_s,
const u8 *peer, int inv)
{
size_t i;
+ struct wpa_supplicant *p2p_wpa_s = wpa_s->global->p2p_init_wpa_s;
if (ssid == NULL)
return;
@@ -4075,8 +2981,8 @@ static void wpas_remove_persistent_peer(struct wpa_supplicant *wpa_s,
ssid->p2p_client_list + (i + 1) * 2 * ETH_ALEN,
(ssid->num_p2p_clients - i - 1) * 2 * ETH_ALEN);
ssid->num_p2p_clients--;
- if (wpa_s->parent->conf->update_config &&
- wpa_config_write(wpa_s->parent->confname, wpa_s->parent->conf))
+ if (p2p_wpa_s->conf->update_config &&
+ wpa_config_write(p2p_wpa_s->confname, p2p_wpa_s->conf))
wpa_printf(MSG_DEBUG, "P2P: Failed to update configuration");
}
@@ -4163,10 +3069,10 @@ static void wpas_invitation_result(void *ctx, int status, const u8 *bssid,
os_sleep(0, 50000);
if (neg_freq > 0 && ssid->mode == WPAS_MODE_P2P_GO &&
- freq_included(channels, neg_freq))
+ freq_included(wpa_s, channels, neg_freq))
freq = neg_freq;
else if (peer_oper_freq > 0 && ssid->mode != WPAS_MODE_P2P_GO &&
- freq_included(channels, peer_oper_freq))
+ freq_included(wpa_s, channels, peer_oper_freq))
freq = peer_oper_freq;
else
freq = 0;
@@ -4181,7 +3087,7 @@ static void wpas_invitation_result(void *ctx, int status, const u8 *bssid,
channels,
ssid->mode == WPAS_MODE_P2P_GO ?
P2P_MAX_INITIAL_CONN_WAIT_GO_REINVOKE :
- 0);
+ 0, 1);
}
@@ -4320,7 +3226,7 @@ struct p2p_oper_class_map {
enum { BW20, BW40PLUS, BW40MINUS, BW80, BW2160 } bw;
};
-static struct p2p_oper_class_map op_class[] = {
+static const struct p2p_oper_class_map op_class[] = {
{ HOSTAPD_MODE_IEEE80211G, 81, 1, 13, 1, BW20 },
#if 0 /* Do not enable HT40 on 2 GHz for now */
{ HOSTAPD_MODE_IEEE80211G, 83, 1, 9, 1, BW40PLUS },
@@ -4328,6 +3234,7 @@ static struct p2p_oper_class_map op_class[] = {
#endif
{ HOSTAPD_MODE_IEEE80211A, 115, 36, 48, 4, BW20 },
{ HOSTAPD_MODE_IEEE80211A, 124, 149, 161, 4, BW20 },
+ { HOSTAPD_MODE_IEEE80211A, 125, 149, 169, 4, BW20 },
{ HOSTAPD_MODE_IEEE80211A, 116, 36, 44, 8, BW40PLUS },
{ HOSTAPD_MODE_IEEE80211A, 117, 40, 48, 8, BW40MINUS },
{ HOSTAPD_MODE_IEEE80211A, 126, 149, 157, 8, BW40PLUS },
@@ -4453,7 +3360,7 @@ static int wpas_p2p_setup_channels(struct wpa_supplicant *wpa_s,
cla = cli_cla = 0;
for (op = 0; op_class[op].op_class; op++) {
- struct p2p_oper_class_map *o = &op_class[op];
+ const struct p2p_oper_class_map *o = &op_class[op];
u8 ch;
struct p2p_reg_class *reg = NULL, *cli_reg = NULL;
@@ -4512,12 +3419,13 @@ int wpas_p2p_get_ht40_mode(struct wpa_supplicant *wpa_s,
enum chan_allowed ret;
for (op = 0; op_class[op].op_class; op++) {
- struct p2p_oper_class_map *o = &op_class[op];
+ const struct p2p_oper_class_map *o = &op_class[op];
u8 ch;
for (ch = o->min_chan; ch <= o->max_chan; ch += o->inc) {
if (o->mode != HOSTAPD_MODE_IEEE80211A ||
- o->bw == BW20 || ch != channel)
+ (o->bw != BW40PLUS && o->bw != BW40MINUS) ||
+ ch != channel)
continue;
ret = wpas_p2p_verify_channel(wpa_s, mode, ch, o->bw);
if (ret == ALLOWED)
@@ -4581,12 +3489,7 @@ struct wpa_supplicant * wpas_get_p2p_client_iface(struct wpa_supplicant *wpa_s,
{
for (wpa_s = wpa_s->global->ifaces; wpa_s; wpa_s = wpa_s->next) {
struct wpa_ssid *ssid = wpa_s->current_ssid;
- if (ssid == NULL)
- continue;
- if (ssid->mode != WPAS_MODE_INFRA)
- continue;
- if (wpa_s->wpa_state != WPA_COMPLETED &&
- wpa_s->wpa_state != WPA_GROUP_HANDSHAKE)
+ if (ssid && (ssid->mode != WPAS_MODE_INFRA || !ssid->p2p_group))
continue;
if (os_memcmp(wpa_s->go_dev_addr, peer_dev_addr, ETH_ALEN) == 0)
return wpa_s;
@@ -4667,14 +3570,12 @@ int wpas_p2p_add_p2pdev_interface(struct wpa_supplicant *wpa_s,
iface.confname = wpa_s->confname;
iface.ctrl_interface = wpa_s->conf->ctrl_interface;
}
- iface.conf_p2p_dev = NULL;
p2pdev_wpa_s = wpa_supplicant_add_iface(wpa_s->global, &iface, wpa_s);
if (!p2pdev_wpa_s) {
wpa_printf(MSG_DEBUG, "P2P: Failed to add P2P Device interface");
return -1;
}
- wpa_s->p2p_dev = p2pdev_wpa_s;
wpa_s->pending_interface_name[0] = '\0';
return 0;
@@ -4705,7 +3606,8 @@ static void wpas_presence_resp(void *ctx, const u8 *src, u8 status,
static int wpas_get_persistent_group(void *ctx, const u8 *addr, const u8 *ssid,
size_t ssid_len, u8 *go_dev_addr,
- u8 *ret_ssid, size_t *ret_ssid_len)
+ u8 *ret_ssid, size_t *ret_ssid_len,
+ u8 *intended_iface_addr)
{
struct wpa_supplicant *wpa_s = ctx;
struct wpa_ssid *s;
@@ -4715,6 +3617,19 @@ static int wpas_get_persistent_group(void *ctx, const u8 *addr, const u8 *ssid,
os_memcpy(ret_ssid, s->ssid, s->ssid_len);
*ret_ssid_len = s->ssid_len;
os_memcpy(go_dev_addr, s->bssid, ETH_ALEN);
+
+ if (s->mode != WPAS_MODE_P2P_GO) {
+ os_memset(intended_iface_addr, 0, ETH_ALEN);
+ } else if (wpas_p2p_create_iface(wpa_s)) {
+ if (wpas_p2p_add_group_interface(wpa_s, WPA_IF_P2P_GO))
+ return 0;
+
+ os_memcpy(intended_iface_addr,
+ wpa_s->pending_interface_addr, ETH_ALEN);
+ } else {
+ os_memcpy(intended_iface_addr, wpa_s->own_addr,
+ ETH_ALEN);
+ }
return 1;
}
@@ -4729,17 +3644,24 @@ static int wpas_get_go_info(void *ctx, u8 *intended_addr,
struct wpa_ssid *s;
u8 bssid[ETH_ALEN];
+ /*
+ * group_iface will be set to 1 only if a dedicated interface for P2P
+ * role is required. First, we try to reuse an active GO. However,
+ * if it is not present, we will try to reactivate an existing
+ * persistent group and set group_iface to 1, so the caller will know
+ * that the pending interface should be used.
+ */
+ *group_iface = 0;
s = wpas_p2p_group_go_ssid(wpa_s, bssid);
if (!s) {
s = wpas_p2p_get_persistent_go(wpa_s);
+ *group_iface = wpas_p2p_create_iface(wpa_s);
if (s)
os_memcpy(bssid, s->bssid, ETH_ALEN);
+ else
+ return 0;
}
- *group_iface = wpas_p2p_create_iface(wpa_s);
- if (!s)
- return 0;
-
os_memcpy(intended_addr, bssid, ETH_ALEN);
os_memcpy(ssid, s->ssid, s->ssid_len);
*ssid_len = s->ssid_len;
@@ -4793,19 +3715,49 @@ static int wpas_remove_stale_groups(void *ctx, const u8 *peer, const u8 *go,
}
+static void wpas_p2ps_get_feat_cap_str(char *buf, size_t buf_len,
+ const u8 *feat_cap, size_t feat_cap_len)
+{
+ static const char pref[] = " feature_cap=";
+ int ret;
+
+ buf[0] = '\0';
+
+ /*
+ * We expect a feature capability to contain at least one byte to be
+ * reported. The string buffer provided by the caller function is
+ * expected to be big enough to contain all bytes of the attribute for
+ * known specifications. This function truncates the reported bytes if
+ * the feature capability data exceeds the string buffer size.
+ */
+ if (!feat_cap || !feat_cap_len || buf_len < sizeof(pref) + 2)
+ return;
+
+ os_memcpy(buf, pref, sizeof(pref));
+ ret = wpa_snprintf_hex(&buf[sizeof(pref) - 1],
+ buf_len - sizeof(pref) + 1,
+ feat_cap, feat_cap_len);
+
+ if (ret != (2 * (int) feat_cap_len))
+ wpa_printf(MSG_WARNING, "P2PS feature_cap bytes truncated");
+}
+
+
static void wpas_p2ps_prov_complete(void *ctx, u8 status, const u8 *dev,
const u8 *adv_mac, const u8 *ses_mac,
const u8 *grp_mac, u32 adv_id, u32 ses_id,
u8 conncap, int passwd_id,
const u8 *persist_ssid,
size_t persist_ssid_size, int response_done,
- int prov_start, const char *session_info)
+ int prov_start, const char *session_info,
+ const u8 *feat_cap, size_t feat_cap_len)
{
struct wpa_supplicant *wpa_s = ctx;
u8 mac[ETH_ALEN];
struct wpa_ssid *persistent_go, *stale, *s;
int save_config = 0;
struct wpa_supplicant *go_wpa_s;
+ char feat_cap_str[256];
if (!dev)
return;
@@ -4818,6 +3770,9 @@ static void wpas_p2ps_prov_complete(void *ctx, u8 status, const u8 *dev,
if (!grp_mac)
grp_mac = mac;
+ wpas_p2ps_get_feat_cap_str(feat_cap_str, sizeof(feat_cap_str),
+ feat_cap, feat_cap_len);
+
if (prov_start) {
if (session_info == NULL) {
wpa_msg_global(wpa_s, MSG_INFO,
@@ -4825,22 +3780,22 @@ static void wpas_p2ps_prov_complete(void *ctx, u8 status, const u8 *dev,
" adv_id=%x conncap=%x"
" adv_mac=" MACSTR
" session=%x mac=" MACSTR
- " dev_passwd_id=%d",
+ " dev_passwd_id=%d%s",
MAC2STR(dev), adv_id, conncap,
MAC2STR(adv_mac),
ses_id, MAC2STR(ses_mac),
- passwd_id);
+ passwd_id, feat_cap_str);
} else {
wpa_msg_global(wpa_s, MSG_INFO,
P2P_EVENT_P2PS_PROVISION_START MACSTR
" adv_id=%x conncap=%x"
" adv_mac=" MACSTR
" session=%x mac=" MACSTR
- " dev_passwd_id=%d info='%s'",
+ " dev_passwd_id=%d info='%s'%s",
MAC2STR(dev), adv_id, conncap,
MAC2STR(adv_mac),
ses_id, MAC2STR(ses_mac),
- passwd_id, session_info);
+ passwd_id, session_info, feat_cap_str);
}
return;
}
@@ -4862,16 +3817,24 @@ static void wpas_p2ps_prov_complete(void *ctx, u8 status, const u8 *dev,
P2P_EVENT_P2PS_PROVISION_DONE MACSTR
" status=%d"
" adv_id=%x adv_mac=" MACSTR
- " session=%x mac=" MACSTR,
+ " session=%x mac=" MACSTR "%s",
MAC2STR(dev), status,
adv_id, MAC2STR(adv_mac),
- ses_id, MAC2STR(ses_mac));
+ ses_id, MAC2STR(ses_mac), feat_cap_str);
return;
}
/* Clean up stale persistent groups with this device */
s = wpas_p2p_get_persistent(wpa_s, dev, persist_ssid,
persist_ssid_size);
+
+ if (persist_ssid && s && s->mode != WPAS_MODE_P2P_GO &&
+ is_zero_ether_addr(grp_mac)) {
+ wpa_dbg(wpa_s, MSG_ERROR,
+ "P2P: Peer device is a GO in a persistent group, but it did not provide the intended MAC address");
+ return;
+ }
+
for (;;) {
stale = wpas_p2p_get_persistent(wpa_s, dev, NULL, 0);
if (!stale)
@@ -4927,29 +3890,39 @@ static void wpas_p2ps_prov_complete(void *ctx, u8 status, const u8 *dev,
" status=%d"
" adv_id=%x adv_mac=" MACSTR
" session=%x mac=" MACSTR
- " persist=%d",
+ " persist=%d%s",
MAC2STR(dev), status,
adv_id, MAC2STR(adv_mac),
- ses_id, MAC2STR(ses_mac), s->id);
+ ses_id, MAC2STR(ses_mac), s->id, feat_cap_str);
return;
}
if (conncap == P2PS_SETUP_GROUP_OWNER) {
- const char *go_ifname = NULL;
+ /*
+ * We need to copy the interface name. Simply saving a
+ * pointer isn't enough, since if we use pending_interface_name
+ * it will be overwritten when the group is added.
+ */
+ char go_ifname[100];
+
+ go_ifname[0] = '\0';
if (!go_wpa_s) {
wpa_s->global->pending_p2ps_group = 1;
- if (wpa_s->conf->p2p_no_group_iface)
- go_ifname = wpa_s->ifname;
+ if (!wpas_p2p_create_iface(wpa_s))
+ os_memcpy(go_ifname, wpa_s->ifname,
+ sizeof(go_ifname));
else if (wpa_s->pending_interface_name[0])
- go_ifname = wpa_s->pending_interface_name;
+ os_memcpy(go_ifname,
+ wpa_s->pending_interface_name,
+ sizeof(go_ifname));
- if (!go_ifname) {
+ if (!go_ifname[0]) {
wpas_p2ps_prov_complete(
wpa_s, P2P_SC_FAIL_UNKNOWN_GROUP,
dev, adv_mac, ses_mac,
- NULL, adv_id, ses_id, 0, 0,
- NULL, 0, 0, 0, NULL);
+ grp_mac, adv_id, ses_id, 0, 0,
+ NULL, 0, 0, 0, NULL, NULL, 0);
return;
}
@@ -4961,30 +3934,37 @@ static void wpas_p2ps_prov_complete(void *ctx, u8 status, const u8 *dev,
persistent_go->mode ==
WPAS_MODE_P2P_GO ?
P2P_MAX_INITIAL_CONN_WAIT_GO_REINVOKE :
- 0);
+ 0, 0);
} else if (response_done) {
wpas_p2p_group_add(wpa_s, 1, 0, 0, 0);
}
if (passwd_id == DEV_PW_P2PS_DEFAULT) {
- os_memcpy(wpa_s->p2ps_join_addr, dev, ETH_ALEN);
- wpa_s->p2ps_join_addr_valid = 1;
- wpa_dbg(wpa_s, MSG_DEBUG,
- "P2PS: Saving PIN for " MACSTR,
- MAC2STR(dev));
+ os_memcpy(wpa_s->p2ps_join_addr, grp_mac,
+ ETH_ALEN);
+ wpa_s->p2ps_method_config_any = 1;
}
} else if (passwd_id == DEV_PW_P2PS_DEFAULT) {
- go_ifname = go_wpa_s->ifname;
-
- wpa_dbg(go_wpa_s, MSG_DEBUG,
- "P2P: Setting PIN-1 For " MACSTR, MAC2STR(dev));
- wpa_supplicant_ap_wps_pin(go_wpa_s, dev, "12345670",
- NULL, 0, 0);
+ os_memcpy(go_ifname, go_wpa_s->ifname,
+ sizeof(go_ifname));
+
+ if (is_zero_ether_addr(grp_mac)) {
+ wpa_dbg(go_wpa_s, MSG_DEBUG,
+ "P2P: Setting PIN-1 for ANY");
+ wpa_supplicant_ap_wps_pin(go_wpa_s, NULL,
+ "12345670", NULL, 0,
+ 0);
+ } else {
+ wpa_dbg(go_wpa_s, MSG_DEBUG,
+ "P2P: Setting PIN-1 for " MACSTR,
+ MAC2STR(grp_mac));
+ wpa_supplicant_ap_wps_pin(go_wpa_s, grp_mac,
+ "12345670", NULL, 0,
+ 0);
+ }
- os_memcpy(wpa_s->p2ps_join_addr, dev, ETH_ALEN);
- wpa_s->p2ps_join_addr_valid = 1;
- wpa_dbg(wpa_s, MSG_DEBUG,
- "P2PS: Saving PIN for " MACSTR, MAC2STR(dev));
+ os_memcpy(wpa_s->p2ps_join_addr, grp_mac, ETH_ALEN);
+ wpa_s->p2ps_method_config_any = 1;
}
wpa_msg_global(wpa_s, MSG_INFO,
@@ -4992,11 +3972,11 @@ static void wpas_p2ps_prov_complete(void *ctx, u8 status, const u8 *dev,
" status=%d conncap=%x"
" adv_id=%x adv_mac=" MACSTR
" session=%x mac=" MACSTR
- " dev_passwd_id=%d go=%s",
+ " dev_passwd_id=%d go=%s%s",
MAC2STR(dev), status, conncap,
adv_id, MAC2STR(adv_mac),
ses_id, MAC2STR(ses_mac),
- passwd_id, go_ifname);
+ passwd_id, go_ifname, feat_cap_str);
return;
}
@@ -5014,22 +3994,22 @@ static void wpas_p2ps_prov_complete(void *ctx, u8 status, const u8 *dev,
" status=%d conncap=%x"
" adv_id=%x adv_mac=" MACSTR
" session=%x mac=" MACSTR
- " dev_passwd_id=%d join=" MACSTR,
+ " dev_passwd_id=%d join=" MACSTR "%s",
MAC2STR(dev), status, conncap,
adv_id, MAC2STR(adv_mac),
ses_id, MAC2STR(ses_mac),
- passwd_id, MAC2STR(grp_mac));
+ passwd_id, MAC2STR(grp_mac), feat_cap_str);
} else {
wpa_msg_global(wpa_s, MSG_INFO,
P2P_EVENT_P2PS_PROVISION_DONE MACSTR
" status=%d conncap=%x"
" adv_id=%x adv_mac=" MACSTR
" session=%x mac=" MACSTR
- " dev_passwd_id=%d",
+ " dev_passwd_id=%d%s",
MAC2STR(dev), status, conncap,
adv_id, MAC2STR(adv_mac),
ses_id, MAC2STR(ses_mac),
- passwd_id);
+ passwd_id, feat_cap_str);
}
}
@@ -5059,7 +4039,7 @@ static int wpas_prov_disc_resp_cb(void *ctx)
wpas_p2p_group_add_persistent(
wpa_s, persistent_go, 0, 0, 0, 0, 0, NULL,
persistent_go->mode == WPAS_MODE_P2P_GO ?
- P2P_MAX_INITIAL_CONN_WAIT_GO_REINVOKE : 0);
+ P2P_MAX_INITIAL_CONN_WAIT_GO_REINVOKE : 0, 0);
} else {
wpas_p2p_group_add(wpa_s, 1, 0, 0, 0);
}
@@ -5068,6 +4048,17 @@ static int wpas_prov_disc_resp_cb(void *ctx)
}
+static int wpas_p2p_get_pref_freq_list(void *ctx, int go,
+ unsigned int *len,
+ unsigned int *freq_list)
+{
+ struct wpa_supplicant *wpa_s = ctx;
+
+ return wpa_drv_get_pref_freq_list(wpa_s, go ? WPA_IF_P2P_GO :
+ WPA_IF_P2P_CLIENT, len, freq_list);
+}
+
+
/**
* wpas_p2p_init - Initialize P2P module for %wpa_supplicant
* @global: Pointer to global data from wpa_supplicant_init()
@@ -5121,6 +4112,7 @@ int wpas_p2p_init(struct wpa_global *global, struct wpa_supplicant *wpa_s)
p2p.p2ps_prov_complete = wpas_p2ps_prov_complete;
p2p.prov_disc_resp_cb = wpas_prov_disc_resp_cb;
p2p.p2ps_group_capability = p2ps_group_capability;
+ p2p.get_pref_freq_list = wpas_p2p_get_pref_freq_list;
os_memcpy(wpa_s->global->p2p_dev_addr, wpa_s->own_addr, ETH_ALEN);
os_memcpy(p2p.dev_addr, wpa_s->global->p2p_dev_addr, ETH_ALEN);
@@ -5152,9 +4144,9 @@ int wpas_p2p_init(struct wpa_global *global, struct wpa_supplicant *wpa_s)
*/
if (p2p_config_get_random_social(&p2p, &p2p.reg_class,
&p2p.channel) != 0) {
- wpa_printf(MSG_ERROR,
- "P2P: Failed to select random social channel as listen channel");
- return -1;
+ wpa_printf(MSG_INFO,
+ "P2P: No social channels supported by the driver - do not enable P2P");
+ return 0;
}
p2p.channel_forced = 0;
}
@@ -5425,6 +4417,7 @@ static void wpas_p2p_check_join_scan_limit(struct wpa_supplicant *wpa_s)
}
wpa_msg_global(wpa_s->parent, MSG_INFO,
P2P_EVENT_GROUP_FORMATION_FAILURE);
+ wpas_notify_p2p_group_formation_failure(wpa_s, "");
}
}
@@ -5623,10 +4616,25 @@ static void wpas_p2p_scan_res_join(struct wpa_supplicant *wpa_s,
wpa_s->pending_join_iface_addr);
}
if (bss) {
+ u8 dev_addr[ETH_ALEN];
+
freq = bss->freq;
wpa_printf(MSG_DEBUG, "P2P: Target GO operating frequency "
"from BSS table: %d MHz (SSID %s)", freq,
wpa_ssid_txt(bss->ssid, bss->ssid_len));
+ if (p2p_parse_dev_addr((const u8 *) (bss + 1), bss->ie_len,
+ dev_addr) == 0 &&
+ os_memcmp(wpa_s->pending_join_dev_addr,
+ wpa_s->pending_join_iface_addr, ETH_ALEN) == 0 &&
+ os_memcmp(dev_addr, wpa_s->pending_join_dev_addr,
+ ETH_ALEN) != 0) {
+ wpa_printf(MSG_DEBUG,
+ "P2P: Update target GO device address based on BSS entry: " MACSTR " (was " MACSTR ")",
+ MAC2STR(dev_addr),
+ MAC2STR(wpa_s->pending_join_dev_addr));
+ os_memcpy(wpa_s->pending_join_dev_addr, dev_addr,
+ ETH_ALEN);
+ }
}
if (freq > 0) {
u16 method;
@@ -5635,6 +4643,8 @@ static void wpas_p2p_scan_res_join(struct wpa_supplicant *wpa_s,
wpa_msg_global(wpa_s->parent, MSG_INFO,
P2P_EVENT_GROUP_FORMATION_FAILURE
"reason=FREQ_CONFLICT");
+ wpas_notify_p2p_group_formation_failure(
+ wpa_s, "FREQ_CONFLICT");
return;
}
@@ -5654,6 +4664,9 @@ static void wpas_p2p_scan_res_join(struct wpa_supplicant *wpa_s,
case WPS_PBC:
method = WPS_CONFIG_PUSHBUTTON;
break;
+ case WPS_P2PS:
+ method = WPS_CONFIG_P2PS;
+ break;
default:
method = 0;
break;
@@ -5896,11 +4909,16 @@ static int wpas_p2p_join_start(struct wpa_supplicant *wpa_s, int freq,
static int wpas_p2p_setup_freqs(struct wpa_supplicant *wpa_s, int freq,
- int *force_freq, int *pref_freq, int go)
+ int *force_freq, int *pref_freq, int go,
+ unsigned int *pref_freq_list,
+ unsigned int *num_pref_freq)
{
struct wpa_used_freq_data *freqs;
int res, best_freq, num_unused;
- unsigned int freq_in_use = 0, num, i;
+ unsigned int freq_in_use = 0, num, i, max_pref_freq;
+
+ max_pref_freq = *num_pref_freq;
+ *num_pref_freq = 0;
freqs = os_calloc(wpa_s->num_multichan_concurrent,
sizeof(struct wpa_used_freq_data));
@@ -5965,6 +4983,47 @@ static int wpas_p2p_setup_freqs(struct wpa_supplicant *wpa_s, int freq,
best_freq = wpas_p2p_pick_best_used_freq(wpa_s, freqs, num);
+ if (!wpa_s->conf->num_p2p_pref_chan && *pref_freq == 0) {
+ enum wpa_driver_if_type iface_type;
+
+ if (go)
+ iface_type = WPA_IF_P2P_GO;
+ else
+ iface_type = WPA_IF_P2P_CLIENT;
+
+ wpa_printf(MSG_DEBUG, "P2P: best_freq=%d, go=%d",
+ best_freq, go);
+
+ res = wpa_drv_get_pref_freq_list(wpa_s, iface_type,
+ &max_pref_freq,
+ pref_freq_list);
+ if (!res && max_pref_freq > 0) {
+ *num_pref_freq = max_pref_freq;
+ i = 0;
+ while (wpas_p2p_disallowed_freq(wpa_s->global,
+ pref_freq_list[i]) &&
+ i < *num_pref_freq) {
+ wpa_printf(MSG_DEBUG,
+ "P2P: preferred_freq_list[%d]=%d is disallowed",
+ i, pref_freq_list[i]);
+ i++;
+ }
+ if (i != *num_pref_freq) {
+ best_freq = pref_freq_list[i];
+ wpa_printf(MSG_DEBUG,
+ "P2P: Using preferred_freq_list[%d]=%d",
+ i, best_freq);
+ } else {
+ wpa_printf(MSG_DEBUG,
+ "P2P: All driver preferred frequencies are disallowed for P2P use");
+ *num_pref_freq = 0;
+ }
+ } else {
+ wpa_printf(MSG_DEBUG,
+ "P2P: No preferred frequency list available");
+ }
+ }
+
/* We have a candidate frequency to use */
if (best_freq > 0) {
if (*pref_freq == 0 && num_unused > 0) {
@@ -6029,6 +5088,7 @@ int wpas_p2p_connect(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
enum wpa_driver_if_type iftype;
const u8 *if_addr;
struct wpa_ssid *ssid = NULL;
+ unsigned int pref_freq_list[P2P_MAX_PREF_CHANNELS], size;
if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
return -1;
@@ -6045,6 +5105,7 @@ int wpas_p2p_connect(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
wpa_s->global->p2p_fail_on_wps_complete = 0;
wpa_s->global->pending_p2ps_group = 0;
+ wpa_s->p2ps_method_config_any = 0;
if (go_intent < 0)
go_intent = wpa_s->conf->p2p_go_intent;
@@ -6105,13 +5166,16 @@ int wpas_p2p_connect(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
return ret;
}
+ size = P2P_MAX_PREF_CHANNELS;
res = wpas_p2p_setup_freqs(wpa_s, freq, &force_freq, &pref_freq,
- go_intent == 15);
+ go_intent == 15, pref_freq_list, &size);
if (res)
return res;
wpas_p2p_set_own_freq_preference(wpa_s,
force_freq ? force_freq : pref_freq);
+ p2p_set_own_pref_freq_list(wpa_s->global->p2p, pref_freq_list, size);
+
wpa_s->create_p2p_iface = wpas_p2p_create_iface(wpa_s);
if (wpa_s->create_p2p_iface) {
@@ -6126,8 +5190,10 @@ int wpas_p2p_connect(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
}
if_addr = wpa_s->pending_interface_addr;
- } else
+ } else {
if_addr = wpa_s->own_addr;
+ os_memset(wpa_s->go_dev_addr, 0, ETH_ALEN);
+ }
if (auth) {
if (wpas_p2p_auth_go_neg(wpa_s, peer_addr, wps_method,
@@ -6272,6 +5338,38 @@ static int wpas_p2p_select_go_freq(struct wpa_supplicant *wpa_s, int freq)
{
unsigned int r;
+ if (!wpa_s->conf->num_p2p_pref_chan && !freq) {
+ unsigned int i, size = P2P_MAX_PREF_CHANNELS;
+ unsigned int pref_freq_list[P2P_MAX_PREF_CHANNELS];
+ int res;
+
+ res = wpa_drv_get_pref_freq_list(wpa_s, WPA_IF_P2P_GO,
+ &size, pref_freq_list);
+ if (!res && size > 0) {
+ i = 0;
+ while (wpas_p2p_disallowed_freq(wpa_s->global,
+ pref_freq_list[i]) &&
+ i < size) {
+ wpa_printf(MSG_DEBUG,
+ "P2P: preferred_freq_list[%d]=%d is disallowed",
+ i, pref_freq_list[i]);
+ i++;
+ }
+ if (i != size) {
+ freq = pref_freq_list[i];
+ wpa_printf(MSG_DEBUG,
+ "P2P: Using preferred_freq_list[%d]=%d",
+ i, freq);
+ } else {
+ wpa_printf(MSG_DEBUG,
+ "P2P: All driver preferred frequencies are disallowed for P2P use");
+ }
+ } else {
+ wpa_printf(MSG_DEBUG,
+ "P2P: No preferred frequency list available");
+ }
+ }
+
if (freq == 2) {
wpa_printf(MSG_DEBUG, "P2P: Request to start GO on 2.4 GHz "
"band");
@@ -6335,30 +5433,45 @@ static int wpas_p2p_select_go_freq(struct wpa_supplicant *wpa_s, int freq)
}
-static int wpas_p2p_select_freq_no_pref(struct wpa_supplicant *wpa_s,
- struct p2p_go_neg_results *params,
- const struct p2p_channels *channels)
+static int wpas_p2p_supported_freq_go(struct wpa_supplicant *wpa_s,
+ const struct p2p_channels *channels,
+ int freq)
+{
+ if (!wpas_p2p_disallowed_freq(wpa_s->global, freq) &&
+ p2p_supported_freq_go(wpa_s->global->p2p, freq) &&
+ freq_included(wpa_s, channels, freq))
+ return 1;
+ return 0;
+}
+
+
+static void wpas_p2p_select_go_freq_no_pref(struct wpa_supplicant *wpa_s,
+ struct p2p_go_neg_results *params,
+ const struct p2p_channels *channels)
{
unsigned int i, r;
/* first try some random selection of the social channels */
if (os_get_random((u8 *) &r, sizeof(r)) < 0)
- return -1;
+ return;
for (i = 0; i < 3; i++) {
params->freq = 2412 + ((r + i) % 3) * 25;
- if (!wpas_p2p_disallowed_freq(wpa_s->global, params->freq) &&
- freq_included(channels, params->freq) &&
- p2p_supported_freq(wpa_s->global->p2p, params->freq))
+ if (wpas_p2p_supported_freq_go(wpa_s, channels, params->freq))
goto out;
}
- /* try all channels in reg. class 81 */
+ /* try all other channels in operating class 81 */
for (i = 0; i < 11; i++) {
params->freq = 2412 + i * 5;
- if (!wpas_p2p_disallowed_freq(wpa_s->global, params->freq) &&
- freq_included(channels, params->freq) &&
- p2p_supported_freq(wpa_s->global->p2p, params->freq))
+
+ /* skip social channels; covered in the previous loop */
+ if (params->freq == 2412 ||
+ params->freq == 2437 ||
+ params->freq == 2462)
+ continue;
+
+ if (wpas_p2p_supported_freq_go(wpa_s, channels, params->freq))
goto out;
}
@@ -6366,7 +5479,7 @@ static int wpas_p2p_select_freq_no_pref(struct wpa_supplicant *wpa_s,
for (i = 0; i < 4; i++) {
params->freq = 5180 + i * 20;
if (!wpas_p2p_disallowed_freq(wpa_s->global, params->freq) &&
- freq_included(channels, params->freq) &&
+ freq_included(wpa_s, channels, params->freq) &&
p2p_supported_freq(wpa_s->global->p2p, params->freq))
goto out;
}
@@ -6375,7 +5488,7 @@ static int wpas_p2p_select_freq_no_pref(struct wpa_supplicant *wpa_s,
for (i = 0; i < 4; i++) {
params->freq = 5745 + i * 20;
if (!wpas_p2p_disallowed_freq(wpa_s->global, params->freq) &&
- freq_included(channels, params->freq) &&
+ freq_included(wpa_s, channels, params->freq) &&
p2p_supported_freq(wpa_s->global->p2p, params->freq))
goto out;
}
@@ -6383,7 +5496,7 @@ static int wpas_p2p_select_freq_no_pref(struct wpa_supplicant *wpa_s,
/* try social channel class 180 channel 2 */
params->freq = 58320 + 1 * 2160;
if (!wpas_p2p_disallowed_freq(wpa_s->global, params->freq) &&
- freq_included(channels, params->freq) &&
+ freq_included(wpa_s, channels, params->freq) &&
p2p_supported_freq(wpa_s->global->p2p, params->freq))
goto out;
@@ -6391,17 +5504,17 @@ static int wpas_p2p_select_freq_no_pref(struct wpa_supplicant *wpa_s,
for (i = 0; i < 4; i++) {
params->freq = 58320 + i * 2160;
if (!wpas_p2p_disallowed_freq(wpa_s->global, params->freq) &&
- freq_included(channels, params->freq) &&
+ freq_included(wpa_s, channels, params->freq) &&
p2p_supported_freq(wpa_s->global->p2p, params->freq))
goto out;
}
+ params->freq = 0;
wpa_printf(MSG_DEBUG, "P2P: No 2.4, 5, or 60 GHz channel allowed");
- return -1;
+ return;
out:
wpa_printf(MSG_DEBUG, "P2P: Set GO freq %d MHz (no preference known)",
params->freq);
- return 0;
}
@@ -6411,129 +5524,186 @@ static int wpas_p2p_init_go_params(struct wpa_supplicant *wpa_s,
const struct p2p_channels *channels)
{
struct wpa_used_freq_data *freqs;
- unsigned int pref_freq, cand_freq;
+ unsigned int cand;
unsigned int num, i;
os_memset(params, 0, sizeof(*params));
params->role_go = 1;
params->ht40 = ht40;
params->vht = vht;
+
+ if (wpa_s->p2p_group_common_freqs_num)
+ wpa_printf(MSG_DEBUG, "P2P: %s called for an active GO",
+ __func__);
+
+ freqs = os_calloc(wpa_s->num_multichan_concurrent,
+ sizeof(struct wpa_used_freq_data));
+ if (!freqs)
+ return -1;
+
+ num = wpas_p2p_valid_oper_freqs(wpa_s, freqs,
+ wpa_s->num_multichan_concurrent);
+
+ /* try using the forced freq */
if (freq) {
- if (!freq_included(channels, freq)) {
- wpa_printf(MSG_DEBUG, "P2P: Forced GO freq %d MHz not "
- "accepted", freq);
- return -1;
+ if (!wpas_p2p_supported_freq_go(wpa_s, channels, freq)) {
+ wpa_printf(MSG_DEBUG,
+ "P2P: Forced GO freq %d MHz not accepted",
+ freq);
+ goto fail;
+ }
+
+ for (i = 0; i < num; i++) {
+ if (freqs[i].freq == freq) {
+ wpa_printf(MSG_DEBUG,
+ "P2P: forced freq (%d MHz) is also shared",
+ freq);
+ params->freq = freq;
+ goto success;
+ }
+ }
+
+ if (wpas_p2p_num_unused_channels(wpa_s) <= 0) {
+ wpa_printf(MSG_DEBUG,
+ "P2P: Cannot force GO on freq (%d MHz) as all the channels are in use",
+ freq);
+ goto fail;
}
- wpa_printf(MSG_DEBUG, "P2P: Set GO freq based on forced "
- "frequency %d MHz", freq);
+
+ wpa_printf(MSG_DEBUG,
+ "P2P: force GO freq (%d MHz) on a free channel",
+ freq);
params->freq = freq;
- } else if (wpa_s->conf->p2p_oper_reg_class == 81 &&
- wpa_s->conf->p2p_oper_channel >= 1 &&
- wpa_s->conf->p2p_oper_channel <= 11 &&
- freq_included(channels,
- 2407 + 5 * wpa_s->conf->p2p_oper_channel)) {
+ goto success;
+ }
+
+ /* consider using one of the shared frequencies */
+ if (num) {
+ cand = wpas_p2p_pick_best_used_freq(wpa_s, freqs, num);
+ if (wpas_p2p_supported_freq_go(wpa_s, channels, cand)) {
+ wpa_printf(MSG_DEBUG,
+ "P2P: Use shared freq (%d MHz) for GO",
+ freq);
+ params->freq = cand;
+ goto success;
+ }
+
+ /* try using one of the shared freqs */
+ for (i = 0; i < num; i++) {
+ if (wpas_p2p_supported_freq_go(wpa_s, channels,
+ freqs[i].freq)) {
+ wpa_printf(MSG_DEBUG,
+ "P2P: Use shared freq (%d MHz) for GO",
+ freq);
+ params->freq = freqs[i].freq;
+ goto success;
+ }
+ }
+ }
+
+ if (wpas_p2p_num_unused_channels(wpa_s) <= 0) {
+ wpa_printf(MSG_DEBUG,
+ "P2P: Cannot force GO on any of the channels we are already using");
+ goto fail;
+ }
+
+ /* try using the setting from the configuration file */
+ if (wpa_s->conf->p2p_oper_reg_class == 81 &&
+ wpa_s->conf->p2p_oper_channel >= 1 &&
+ wpa_s->conf->p2p_oper_channel <= 11 &&
+ wpas_p2p_supported_freq_go(
+ wpa_s, channels,
+ 2407 + 5 * wpa_s->conf->p2p_oper_channel)) {
params->freq = 2407 + 5 * wpa_s->conf->p2p_oper_channel;
wpa_printf(MSG_DEBUG, "P2P: Set GO freq based on configured "
"frequency %d MHz", params->freq);
- } else if ((wpa_s->conf->p2p_oper_reg_class == 115 ||
- wpa_s->conf->p2p_oper_reg_class == 116 ||
- wpa_s->conf->p2p_oper_reg_class == 117 ||
- wpa_s->conf->p2p_oper_reg_class == 124 ||
- wpa_s->conf->p2p_oper_reg_class == 126 ||
- wpa_s->conf->p2p_oper_reg_class == 127) &&
- freq_included(channels,
- 5000 + 5 * wpa_s->conf->p2p_oper_channel)) {
+ goto success;
+ }
+
+ if ((wpa_s->conf->p2p_oper_reg_class == 115 ||
+ wpa_s->conf->p2p_oper_reg_class == 116 ||
+ wpa_s->conf->p2p_oper_reg_class == 117 ||
+ wpa_s->conf->p2p_oper_reg_class == 124 ||
+ wpa_s->conf->p2p_oper_reg_class == 125 ||
+ wpa_s->conf->p2p_oper_reg_class == 126 ||
+ wpa_s->conf->p2p_oper_reg_class == 127) &&
+ wpas_p2p_supported_freq_go(wpa_s, channels,
+ 5000 +
+ 5 * wpa_s->conf->p2p_oper_channel)) {
params->freq = 5000 + 5 * wpa_s->conf->p2p_oper_channel;
wpa_printf(MSG_DEBUG, "P2P: Set GO freq based on configured "
"frequency %d MHz", params->freq);
- } else if (wpa_s->conf->p2p_oper_channel == 0 &&
- wpa_s->best_overall_freq > 0 &&
- p2p_supported_freq_go(wpa_s->global->p2p,
- wpa_s->best_overall_freq) &&
- freq_included(channels, wpa_s->best_overall_freq)) {
+ goto success;
+ }
+
+ /* Try using best channels */
+ if (wpa_s->conf->p2p_oper_channel == 0 &&
+ wpa_s->best_overall_freq > 0 &&
+ wpas_p2p_supported_freq_go(wpa_s, channels,
+ wpa_s->best_overall_freq)) {
params->freq = wpa_s->best_overall_freq;
wpa_printf(MSG_DEBUG, "P2P: Set GO freq based on best overall "
"channel %d MHz", params->freq);
- } else if (wpa_s->conf->p2p_oper_channel == 0 &&
- wpa_s->best_24_freq > 0 &&
- p2p_supported_freq_go(wpa_s->global->p2p,
- wpa_s->best_24_freq) &&
- freq_included(channels, wpa_s->best_24_freq)) {
+ goto success;
+ }
+
+ if (wpa_s->conf->p2p_oper_channel == 0 &&
+ wpa_s->best_24_freq > 0 &&
+ wpas_p2p_supported_freq_go(wpa_s, channels,
+ wpa_s->best_24_freq)) {
params->freq = wpa_s->best_24_freq;
wpa_printf(MSG_DEBUG, "P2P: Set GO freq based on best 2.4 GHz "
"channel %d MHz", params->freq);
- } else if (wpa_s->conf->p2p_oper_channel == 0 &&
- wpa_s->best_5_freq > 0 &&
- p2p_supported_freq_go(wpa_s->global->p2p,
- wpa_s->best_5_freq) &&
- freq_included(channels, wpa_s->best_5_freq)) {
+ goto success;
+ }
+
+ if (wpa_s->conf->p2p_oper_channel == 0 &&
+ wpa_s->best_5_freq > 0 &&
+ wpas_p2p_supported_freq_go(wpa_s, channels,
+ wpa_s->best_5_freq)) {
params->freq = wpa_s->best_5_freq;
wpa_printf(MSG_DEBUG, "P2P: Set GO freq based on best 5 GHz "
"channel %d MHz", params->freq);
- } else if ((pref_freq = p2p_get_pref_freq(wpa_s->global->p2p,
- channels))) {
- params->freq = pref_freq;
+ goto success;
+ }
+
+ /* try using preferred channels */
+ cand = p2p_get_pref_freq(wpa_s->global->p2p, channels);
+ if (cand && wpas_p2p_supported_freq_go(wpa_s, channels, cand)) {
+ params->freq = cand;
wpa_printf(MSG_DEBUG, "P2P: Set GO freq %d MHz from preferred "
"channels", params->freq);
- } else {
- /* no preference, select some channel */
- if (wpas_p2p_select_freq_no_pref(wpa_s, params, channels) < 0)
- return -1;
+ goto success;
}
- freqs = os_calloc(wpa_s->num_multichan_concurrent,
- sizeof(struct wpa_used_freq_data));
- if (!freqs)
- return -1;
-
- num = wpas_p2p_valid_oper_freqs(wpa_s, freqs,
- wpa_s->num_multichan_concurrent);
-
- cand_freq = wpas_p2p_pick_best_used_freq(wpa_s, freqs, num);
-
- /* First try the best used frequency if possible */
- if (!freq && cand_freq > 0 && freq_included(channels, cand_freq)) {
- params->freq = cand_freq;
- } else if (!freq) {
- /* Try any of the used frequencies */
- for (i = 0; i < num; i++) {
- if (freq_included(channels, freqs[i].freq)) {
- wpa_printf(MSG_DEBUG, "P2P: Force GO on a channel we are already using (%u MHz)",
- freqs[i].freq);
- params->freq = freqs[i].freq;
- break;
+ /* Try using one of the group common freqs */
+ if (wpa_s->p2p_group_common_freqs) {
+ for (i = 0; i < wpa_s->p2p_group_common_freqs_num; i++) {
+ cand = wpa_s->p2p_group_common_freqs[i];
+ if (wpas_p2p_supported_freq_go(wpa_s, channels, cand)) {
+ params->freq = cand;
+ wpa_printf(MSG_DEBUG,
+ "P2P: Use freq %d MHz common with the peer",
+ params->freq);
+ goto success;
}
}
+ }
- if (i == num) {
- if (wpas_p2p_num_unused_channels(wpa_s) <= 0) {
- wpa_printf(MSG_DEBUG, "P2P: Cannot force GO on any of the channels we are already using");
- os_free(freqs);
- return -1;
- } else {
- wpa_printf(MSG_DEBUG, "P2P: Cannot force GO on any of the channels we are already using. Use one of the free channels");
- }
- }
- } else {
- for (i = 0; i < num; i++) {
- if (freqs[i].freq == freq)
- break;
- }
+ /* no preference, select some channel */
+ wpas_p2p_select_go_freq_no_pref(wpa_s, params, channels);
- if (i == num) {
- if (wpas_p2p_num_unused_channels(wpa_s) <= 0) {
- if (freq)
- wpa_printf(MSG_DEBUG, "P2P: Cannot force GO on freq (%u MHz) as all the channels are in use", freq);
- os_free(freqs);
- return -1;
- } else {
- wpa_printf(MSG_DEBUG, "P2P: Use one of the free channels");
- }
- }
+ if (params->freq == 0) {
+ wpa_printf(MSG_DEBUG, "P2P: did not find a freq for GO use");
+ goto fail;
}
+success:
os_free(freqs);
return 0;
+fail:
+ os_free(freqs);
+ return -1;
}
@@ -6636,13 +5806,15 @@ int wpas_p2p_group_add(struct wpa_supplicant *wpa_s, int persistent_group,
static int wpas_start_p2p_client(struct wpa_supplicant *wpa_s,
struct wpa_ssid *params, int addr_allocated,
- int freq)
+ int freq, int force_scan)
{
struct wpa_ssid *ssid;
wpa_s = wpas_p2p_get_group_iface(wpa_s, addr_allocated, 0);
if (wpa_s == NULL)
return -1;
+ if (force_scan)
+ os_get_reltime(&wpa_s->scan_min_time);
wpa_s->p2p_last_4way_hs_fail = NULL;
wpa_supplicant_ap_deinit(wpa_s);
@@ -6650,6 +5822,7 @@ static int wpas_start_p2p_client(struct wpa_supplicant *wpa_s,
ssid = wpa_config_add_network(wpa_s->conf);
if (ssid == NULL)
return -1;
+ os_memset(wpa_s->go_dev_addr, 0, ETH_ALEN);
wpa_config_set_network_defaults(ssid);
ssid->temporary = 1;
ssid->proto = WPA_PROTO_RSN;
@@ -6691,7 +5864,7 @@ int wpas_p2p_group_add_persistent(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid, int addr_allocated,
int force_freq, int neg_freq, int ht40,
int vht, const struct p2p_channels *channels,
- int connection_timeout)
+ int connection_timeout, int force_scan)
{
struct p2p_go_neg_results params;
int go = 0, freq;
@@ -6703,6 +5876,23 @@ int wpas_p2p_group_add_persistent(struct wpa_supplicant *wpa_s,
go == (ssid->mode == WPAS_MODE_P2P_GO)) {
wpa_printf(MSG_DEBUG, "P2P: Requested persistent group is "
"already running");
+ if (go == 0 &&
+ eloop_cancel_timeout(wpas_p2p_group_formation_timeout,
+ wpa_s->parent, NULL)) {
+ /*
+ * This can happen if Invitation Response frame was lost
+ * and the peer (GO of a persistent group) tries to
+ * invite us again. Reschedule the timeout to avoid
+ * terminating the wait for the connection too early
+ * since we now know that the peer is still trying to
+ * invite us instead of having already started the GO.
+ */
+ wpa_printf(MSG_DEBUG,
+ "P2P: Reschedule group formation timeout since peer is still trying to invite us");
+ eloop_register_timeout(P2P_MAX_INITIAL_CONN_WAIT, 0,
+ wpas_p2p_group_formation_timeout,
+ wpa_s->parent, NULL);
+ }
return 0;
}
@@ -6722,21 +5912,30 @@ int wpas_p2p_group_add_persistent(struct wpa_supplicant *wpa_s,
} else {
freq = wpas_p2p_select_go_freq(wpa_s, neg_freq);
if (freq < 0 ||
- (freq > 0 && !freq_included(channels, freq)))
+ (freq > 0 && !freq_included(wpa_s, channels, freq)))
freq = 0;
}
- } else {
+ } else if (ssid->mode == WPAS_MODE_INFRA) {
freq = neg_freq;
- if (freq < 0 ||
- (freq > 0 && !freq_included(channels, freq)))
- freq = 0;
- }
-
- if (ssid->mode == WPAS_MODE_INFRA)
- return wpas_start_p2p_client(wpa_s, ssid, addr_allocated, freq);
+ if (freq <= 0 || !freq_included(wpa_s, channels, freq)) {
+ struct os_reltime now;
+ struct wpa_bss *bss =
+ wpa_bss_get_p2p_dev_addr(wpa_s, ssid->bssid);
+
+ os_get_reltime(&now);
+ if (bss &&
+ !os_reltime_expired(&now, &bss->last_update, 5) &&
+ freq_included(wpa_s, channels, bss->freq))
+ freq = bss->freq;
+ else
+ freq = 0;
+ }
- if (ssid->mode != WPAS_MODE_P2P_GO)
+ return wpas_start_p2p_client(wpa_s, ssid, addr_allocated, freq,
+ force_scan);
+ } else {
return -1;
+ }
if (wpas_p2p_init_go_params(wpa_s, &params, freq, ht40, vht, channels))
return -1;
@@ -6909,7 +6108,7 @@ void wpas_p2p_wps_success(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
}
if (wpa_s->global->p2p)
p2p_wps_success_cb(wpa_s->global->p2p, peer_addr);
- wpas_group_formation_completed(wpa_s, 1);
+ wpas_group_formation_completed(wpa_s, 1, 0);
}
@@ -7163,7 +6362,11 @@ int wpas_p2p_assoc_req_ie(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
if (wpa_s->global->p2p_disabled)
return -1;
- if (wpa_s->conf->p2p_disabled)
+ /*
+ * Advertize mandatory cross connection capability even on
+ * p2p_disabled=1 interface when associating with a P2P Manager WLAN AP.
+ */
+ if (wpa_s->conf->p2p_disabled && p2p_group)
return -1;
if (wpa_s->global->p2p == NULL)
return -1;
@@ -7181,7 +6384,8 @@ int wpas_p2p_assoc_req_ie(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
int wpas_p2p_probe_req_rx(struct wpa_supplicant *wpa_s, const u8 *addr,
const u8 *dst, const u8 *bssid,
- const u8 *ie, size_t ie_len, int ssi_signal)
+ const u8 *ie, size_t ie_len,
+ unsigned int rx_freq, int ssi_signal)
{
if (wpa_s->global->p2p_disabled)
return 0;
@@ -7189,7 +6393,7 @@ int wpas_p2p_probe_req_rx(struct wpa_supplicant *wpa_s, const u8 *addr,
return 0;
switch (p2p_probe_req_rx(wpa_s->global->p2p, addr, dst, bssid,
- ie, ie_len)) {
+ ie, ie_len, rx_freq)) {
case P2P_PREQ_NOT_P2P:
wpas_notify_preq(wpa_s, addr, dst, bssid, ie, ie_len,
ssi_signal);
@@ -7263,6 +6467,7 @@ int wpas_p2p_invite(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
int force_freq = 0;
int res;
int no_pref_freq_given = pref_freq == 0;
+ unsigned int pref_freq_list[P2P_MAX_PREF_CHANNELS], size;
wpa_s->global->p2p_invite_group = NULL;
if (peer_addr)
@@ -7296,10 +6501,13 @@ int wpas_p2p_invite(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
}
wpa_s->pending_invite_ssid_id = ssid->id;
+ size = P2P_MAX_PREF_CHANNELS;
res = wpas_p2p_setup_freqs(wpa_s, freq, &force_freq, &pref_freq,
- role == P2P_INVITE_ROLE_GO);
+ role == P2P_INVITE_ROLE_GO,
+ pref_freq_list, &size);
if (res)
return res;
+ p2p_set_own_pref_freq_list(wpa_s->global->p2p, pref_freq_list, size);
if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
return -1;
@@ -7336,6 +6544,7 @@ int wpas_p2p_invite_group(struct wpa_supplicant *wpa_s, const char *ifname,
int persistent;
int freq = 0, force_freq = 0, pref_freq = 0;
int res;
+ unsigned int pref_freq_list[P2P_MAX_PREF_CHANNELS], size;
wpa_s->p2p_persistent_go_freq = 0;
wpa_s->p2p_go_ht40 = 0;
@@ -7387,8 +6596,10 @@ int wpas_p2p_invite_group(struct wpa_supplicant *wpa_s, const char *ifname,
if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
return -1;
+ size = P2P_MAX_PREF_CHANNELS;
res = wpas_p2p_setup_freqs(wpa_s, freq, &force_freq, &pref_freq,
- role == P2P_INVITE_ROLE_ACTIVE_GO);
+ role == P2P_INVITE_ROLE_ACTIVE_GO,
+ pref_freq_list, &size);
if (res)
return res;
wpas_p2p_set_own_freq_preference(wpa_s, force_freq);
@@ -7921,7 +7132,7 @@ int wpas_p2p_notif_pbc_overlap(struct wpa_supplicant *wpa_s)
"session overlap");
if (wpa_s != wpa_s->parent)
wpa_msg_ctrl(wpa_s->parent, MSG_INFO, WPS_EVENT_OVERLAP);
- wpas_p2p_group_formation_failed(wpa_s);
+ wpas_p2p_group_formation_failed(wpa_s, 0);
return 1;
}
@@ -7933,14 +7144,22 @@ void wpas_p2p_pbc_overlap_cb(void *eloop_ctx, void *timeout_ctx)
}
-void wpas_p2p_update_channel_list(struct wpa_supplicant *wpa_s)
+void wpas_p2p_update_channel_list(struct wpa_supplicant *wpa_s,
+ enum wpas_p2p_channel_update_trig trig)
{
struct p2p_channels chan, cli_chan;
- struct wpa_supplicant *ifs;
+ struct wpa_used_freq_data *freqs = NULL;
+ unsigned int num = wpa_s->num_multichan_concurrent;
if (wpa_s->global == NULL || wpa_s->global->p2p == NULL)
return;
+ freqs = os_calloc(num, sizeof(struct wpa_used_freq_data));
+ if (!freqs)
+ return;
+
+ num = get_shared_radio_freqs_data(wpa_s, freqs, num);
+
os_memset(&chan, 0, sizeof(chan));
os_memset(&cli_chan, 0, sizeof(cli_chan));
if (wpas_p2p_setup_channels(wpa_s, &chan, &cli_chan)) {
@@ -7951,27 +7170,17 @@ void wpas_p2p_update_channel_list(struct wpa_supplicant *wpa_s)
p2p_update_channel_list(wpa_s->global->p2p, &chan, &cli_chan);
- for (ifs = wpa_s->global->ifaces; ifs; ifs = ifs->next) {
- int freq;
- if (!ifs->current_ssid ||
- !ifs->current_ssid->p2p_group ||
- (ifs->current_ssid->mode != WPAS_MODE_P2P_GO &&
- ifs->current_ssid->mode != WPAS_MODE_P2P_GROUP_FORMATION))
- continue;
- freq = ifs->current_ssid->frequency;
- if (freq_included(&chan, freq)) {
- wpa_dbg(ifs, MSG_DEBUG,
- "P2P GO operating frequency %d MHz in valid range",
- freq);
- continue;
- }
+ wpas_p2p_optimize_listen_channel(wpa_s, freqs, num);
- wpa_dbg(ifs, MSG_DEBUG,
- "P2P GO operating in invalid frequency %d MHz", freq);
- /* TODO: Consider using CSA or removing the group within
- * wpa_supplicant */
- wpa_msg(ifs, MSG_INFO, P2P_EVENT_REMOVE_AND_REFORM_GROUP);
- }
+ /*
+ * The used frequencies map changed, so it is possible that a GO is
+ * using a channel that is no longer valid for P2P use. It is also
+ * possible that due to policy consideration, it would be preferable to
+ * move it to a frequency already used by other station interfaces.
+ */
+ wpas_p2p_consider_moving_gos(wpa_s, freqs, num, trig);
+
+ os_free(freqs);
}
@@ -8031,7 +7240,7 @@ int wpas_p2p_cancel(struct wpa_supplicant *wpa_s)
eloop_cancel_timeout(wpas_p2p_group_formation_timeout,
wpa_s->parent, NULL);
if (wpa_s->p2p_in_provisioning) {
- wpas_group_formation_completed(wpa_s, 0);
+ wpas_group_formation_completed(wpa_s, 0, 0);
break;
}
wpas_p2p_group_delete(wpa_s,
@@ -8041,7 +7250,7 @@ int wpas_p2p_cancel(struct wpa_supplicant *wpa_s)
wpa_printf(MSG_DEBUG, "P2P: Interface %s in invitation found - cancelling",
wpa_s->ifname);
found = 1;
- wpas_p2p_group_formation_failed(wpa_s);
+ wpas_p2p_group_formation_failed(wpa_s, 0);
}
}
@@ -8237,7 +7446,7 @@ void wpas_p2p_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
*/
if (wpa_s->global->p2p)
p2p_wps_success_cb(wpa_s->global->p2p, addr);
- wpas_group_formation_completed(wpa_s, 1);
+ wpas_group_formation_completed(wpa_s, 1, 0);
}
}
if (!wpa_s->p2p_go_group_formation_completed) {
@@ -8262,7 +7471,7 @@ static int wpas_p2p_fallback_to_go_neg(struct wpa_supplicant *wpa_s,
if (wpa_s->global->p2p_group_formation)
group = wpa_s->global->p2p_group_formation;
- wpa_s = wpa_s->parent;
+ wpa_s = wpa_s->global->p2p_init_wpa_s;
offchannel_send_action_done(wpa_s);
if (group_added)
ret = wpas_p2p_group_delete(group, P2P_GROUP_REMOVAL_SILENT);
@@ -8517,16 +7726,17 @@ void wpas_p2p_remove_client(struct wpa_supplicant *wpa_s, const u8 *peer,
{
struct wpa_ssid *s;
struct wpa_supplicant *w;
+ struct wpa_supplicant *p2p_wpa_s = wpa_s->global->p2p_init_wpa_s;
wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Remove client " MACSTR, MAC2STR(peer));
/* Remove from any persistent group */
- for (s = wpa_s->parent->conf->ssid; s; s = s->next) {
+ for (s = p2p_wpa_s->conf->ssid; s; s = s->next) {
if (s->disabled != 2 || s->mode != WPAS_MODE_P2P_GO)
continue;
if (!iface_addr)
- wpas_remove_persistent_peer(wpa_s, s, peer, 0);
- wpas_p2p_remove_psk(wpa_s->parent, s, peer, iface_addr);
+ wpas_remove_persistent_peer(p2p_wpa_s, s, peer, 0);
+ wpas_p2p_remove_psk(p2p_wpa_s, s, peer, iface_addr);
}
/* Remove from any operating group */
@@ -9230,6 +8440,16 @@ static void wpas_p2p_optimize_listen_channel(struct wpa_supplicant *wpa_s,
u8 curr_chan, cand, chan;
unsigned int i;
+ /*
+ * If possible, optimize the Listen channel to be a channel that is
+ * already used by one of the other interfaces.
+ */
+ if (!wpa_s->conf->p2p_optimize_listen_chan)
+ return;
+
+ if (!wpa_s->current_ssid || wpa_s->wpa_state != WPA_COMPLETED)
+ return;
+
curr_chan = p2p_get_listen_channel(wpa_s->global->p2p);
for (i = 0, cand = 0; i < num; i++) {
ieee80211_freq_to_chan(freqs[i].freq, &chan);
@@ -9251,35 +8471,245 @@ static void wpas_p2p_optimize_listen_channel(struct wpa_supplicant *wpa_s,
}
-void wpas_p2p_indicate_state_change(struct wpa_supplicant *wpa_s)
+static int wpas_p2p_move_go_csa(struct wpa_supplicant *wpa_s)
{
- struct wpa_used_freq_data *freqs;
- unsigned int num = wpa_s->num_multichan_concurrent;
+ if (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_AP_CSA)) {
+ wpa_dbg(wpa_s, MSG_DEBUG, "CSA is not enabled");
+ return -1;
+ }
- if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
+ /* TODO: Add CSA support */
+ wpa_dbg(wpa_s, MSG_DEBUG, "Moving GO with CSA is not implemented");
+ return -1;
+}
+
+
+static void wpas_p2p_move_go_no_csa(struct wpa_supplicant *wpa_s)
+{
+ struct p2p_go_neg_results params;
+ struct wpa_ssid *current_ssid = wpa_s->current_ssid;
+
+ wpa_msg_global(wpa_s, MSG_INFO, P2P_EVENT_REMOVE_AND_REFORM_GROUP);
+
+ wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Move GO from freq=%d MHz",
+ current_ssid->frequency);
+
+ /* Stop the AP functionality */
+ /* TODO: Should do this in a way that does not indicated to possible
+ * P2P Clients in the group that the group is terminated. */
+ wpa_supplicant_ap_deinit(wpa_s);
+
+ /* Reselect the GO frequency */
+ if (wpas_p2p_init_go_params(wpa_s, &params, 0, 0, 0, NULL)) {
+ wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Failed to reselect freq");
+ wpas_p2p_group_delete(wpa_s,
+ P2P_GROUP_REMOVAL_GO_LEAVE_CHANNEL);
return;
+ }
+ wpa_dbg(wpa_s, MSG_DEBUG, "P2P: New freq selected for the GO (%u MHz)",
+ params.freq);
- /*
- * If possible, optimize the Listen channel to be a channel that is
- * already used by one of the other interfaces.
- */
- if (!wpa_s->conf->p2p_optimize_listen_chan)
+ if (params.freq &&
+ !p2p_supported_freq_go(wpa_s->global->p2p, params.freq)) {
+ wpa_printf(MSG_DEBUG,
+ "P2P: Selected freq (%u MHz) is not valid for P2P",
+ params.freq);
+ wpas_p2p_group_delete(wpa_s,
+ P2P_GROUP_REMOVAL_GO_LEAVE_CHANNEL);
return;
+ }
- if (!wpa_s->current_ssid || wpa_s->wpa_state != WPA_COMPLETED)
+ /* Update the frequency */
+ current_ssid->frequency = params.freq;
+ wpa_s->connect_without_scan = current_ssid;
+ wpa_s->reassociate = 1;
+ wpa_s->disconnected = 0;
+ wpa_supplicant_req_scan(wpa_s, 0, 0);
+}
+
+
+static void wpas_p2p_move_go(void *eloop_ctx, void *timeout_ctx)
+{
+ struct wpa_supplicant *wpa_s = eloop_ctx;
+
+ if (!wpa_s->ap_iface || !wpa_s->current_ssid)
return;
+ wpas_p2p_go_update_common_freqs(wpa_s);
+
+ /*
+ * First, try a channel switch flow. If it is not supported or fails,
+ * take down the GO and bring it up again.
+ */
+ if (wpas_p2p_move_go_csa(wpa_s) < 0)
+ wpas_p2p_move_go_no_csa(wpa_s);
+}
+
+
+static void wpas_p2p_reconsider_moving_go(void *eloop_ctx, void *timeout_ctx)
+{
+ struct wpa_supplicant *wpa_s = eloop_ctx;
+ struct wpa_used_freq_data *freqs = NULL;
+ unsigned int num = wpa_s->num_multichan_concurrent;
+
freqs = os_calloc(num, sizeof(struct wpa_used_freq_data));
if (!freqs)
return;
num = get_shared_radio_freqs_data(wpa_s, freqs, num);
- wpas_p2p_optimize_listen_channel(wpa_s, freqs, num);
+ /* Previous attempt to move a GO was not possible -- try again. */
+ wpas_p2p_consider_moving_gos(wpa_s, freqs, num,
+ WPAS_P2P_CHANNEL_UPDATE_ANY);
+
os_free(freqs);
}
+/*
+ * Consider moving a GO from its currently used frequency:
+ * 1. It is possible that due to regulatory consideration the frequency
+ * can no longer be used and there is a need to evacuate the GO.
+ * 2. It is possible that due to MCC considerations, it would be preferable
+ * to move the GO to a channel that is currently used by some other
+ * station interface.
+ *
+ * In case a frequency that became invalid is once again valid, cancel a
+ * previously initiated GO frequency change.
+ */
+static void wpas_p2p_consider_moving_one_go(struct wpa_supplicant *wpa_s,
+ struct wpa_used_freq_data *freqs,
+ unsigned int num)
+{
+ unsigned int i, invalid_freq = 0, policy_move = 0, flags = 0;
+ unsigned int timeout;
+ int freq;
+
+ wpas_p2p_go_update_common_freqs(wpa_s);
+
+ freq = wpa_s->current_ssid->frequency;
+ for (i = 0, invalid_freq = 0; i < num; i++) {
+ if (freqs[i].freq == freq) {
+ flags = freqs[i].flags;
+
+ /* The channel is invalid, must change it */
+ if (!p2p_supported_freq_go(wpa_s->global->p2p, freq)) {
+ wpa_dbg(wpa_s, MSG_DEBUG,
+ "P2P: Freq=%d MHz no longer valid for GO",
+ freq);
+ invalid_freq = 1;
+ }
+ } else if (freqs[i].flags == 0) {
+ /* Freq is not used by any other station interface */
+ continue;
+ } else if (!p2p_supported_freq(wpa_s->global->p2p,
+ freqs[i].freq)) {
+ /* Freq is not valid for P2P use cases */
+ continue;
+ } else if (wpa_s->conf->p2p_go_freq_change_policy ==
+ P2P_GO_FREQ_MOVE_SCM) {
+ policy_move = 1;
+ } else if (wpa_s->conf->p2p_go_freq_change_policy ==
+ P2P_GO_FREQ_MOVE_SCM_PEER_SUPPORTS &&
+ wpas_p2p_go_is_peer_freq(wpa_s, freqs[i].freq)) {
+ policy_move = 1;
+ }
+ }
+
+ wpa_dbg(wpa_s, MSG_DEBUG,
+ "P2P: GO move: invalid_freq=%u, policy_move=%u, flags=0x%X",
+ invalid_freq, policy_move, flags);
+
+ /*
+ * The channel is valid, or we are going to have a policy move, so
+ * cancel timeout.
+ */
+ if (!invalid_freq || policy_move) {
+ wpa_dbg(wpa_s, MSG_DEBUG,
+ "P2P: Cancel a GO move from freq=%d MHz", freq);
+ eloop_cancel_timeout(wpas_p2p_move_go, wpa_s, NULL);
+
+ if (wpas_p2p_in_progress(wpa_s)) {
+ wpa_dbg(wpa_s, MSG_DEBUG,
+ "P2P: GO move: policy CS is not allowed - setting timeout to re-consider GO move");
+ eloop_cancel_timeout(wpas_p2p_reconsider_moving_go,
+ wpa_s, NULL);
+ eloop_register_timeout(P2P_RECONSIDER_GO_MOVE_DELAY, 0,
+ wpas_p2p_reconsider_moving_go,
+ wpa_s, NULL);
+ return;
+ }
+ }
+
+ if (!invalid_freq && (!policy_move || flags != 0)) {
+ wpa_dbg(wpa_s, MSG_DEBUG,
+ "P2P: Not initiating a GO frequency change");
+ return;
+ }
+
+ if (invalid_freq && !wpas_p2p_disallowed_freq(wpa_s->global, freq))
+ timeout = P2P_GO_FREQ_CHANGE_TIME;
+ else
+ timeout = 0;
+
+ wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Move GO from freq=%d MHz in %d secs",
+ freq, timeout);
+ eloop_cancel_timeout(wpas_p2p_move_go, wpa_s, NULL);
+ eloop_register_timeout(timeout, 0, wpas_p2p_move_go, wpa_s, NULL);
+}
+
+
+static void wpas_p2p_consider_moving_gos(struct wpa_supplicant *wpa_s,
+ struct wpa_used_freq_data *freqs,
+ unsigned int num,
+ enum wpas_p2p_channel_update_trig trig)
+{
+ struct wpa_supplicant *ifs;
+
+ eloop_cancel_timeout(wpas_p2p_reconsider_moving_go, ELOOP_ALL_CTX,
+ NULL);
+
+ /*
+ * Travers all the radio interfaces, and for each GO interface, check
+ * if there is a need to move the GO from the frequency it is using,
+ * or in case the frequency is valid again, cancel the evacuation flow.
+ */
+ dl_list_for_each(ifs, &wpa_s->radio->ifaces, struct wpa_supplicant,
+ radio_list) {
+ if (ifs->current_ssid == NULL ||
+ ifs->current_ssid->mode != WPAS_MODE_P2P_GO)
+ continue;
+
+ /*
+ * The GO was just started or completed channel switch, no need
+ * to move it.
+ */
+ if (wpa_s == ifs &&
+ (trig == WPAS_P2P_CHANNEL_UPDATE_STATE_CHANGE ||
+ trig == WPAS_P2P_CHANNEL_UPDATE_CS)) {
+ wpa_dbg(wpa_s, MSG_DEBUG,
+ "P2P: GO move - schedule re-consideration");
+ eloop_register_timeout(P2P_RECONSIDER_GO_MOVE_DELAY, 0,
+ wpas_p2p_reconsider_moving_go,
+ wpa_s, NULL);
+ continue;
+ }
+
+ wpas_p2p_consider_moving_one_go(ifs, freqs, num);
+ }
+}
+
+
+void wpas_p2p_indicate_state_change(struct wpa_supplicant *wpa_s)
+{
+ if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
+ return;
+
+ wpas_p2p_update_channel_list(wpa_s,
+ WPAS_P2P_CHANNEL_UPDATE_STATE_CHANGE);
+}
+
+
void wpas_p2p_deinit_iface(struct wpa_supplicant *wpa_s)
{
if (wpa_s == wpa_s->global->p2p_init_wpa_s && wpa_s->global->p2p) {
diff --git a/wpa_supplicant/p2p_supplicant.h b/wpa_supplicant/p2p_supplicant.h
index b786178..56e6834 100644
--- a/wpa_supplicant/p2p_supplicant.h
+++ b/wpa_supplicant/p2p_supplicant.h
@@ -17,6 +17,15 @@ struct p2p_channels;
struct wps_event_fail;
struct p2ps_provision;
+enum wpas_p2p_channel_update_trig {
+ WPAS_P2P_CHANNEL_UPDATE_ANY,
+ WPAS_P2P_CHANNEL_UPDATE_DRIVER,
+ WPAS_P2P_CHANNEL_UPDATE_STATE_CHANGE,
+ WPAS_P2P_CHANNEL_UPDATE_AVOID,
+ WPAS_P2P_CHANNEL_UPDATE_DISALLOW,
+ WPAS_P2P_CHANNEL_UPDATE_CS,
+};
+
int wpas_p2p_add_p2pdev_interface(struct wpa_supplicant *wpa_s,
const char *conf_p2p_dev);
struct wpa_supplicant * wpas_get_p2p_go_iface(struct wpa_supplicant *wpa_s,
@@ -36,7 +45,7 @@ int wpas_p2p_group_add_persistent(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid, int addr_allocated,
int force_freq, int neg_freq, int ht40,
int vht, const struct p2p_channels *channels,
- int connection_timeout);
+ int connection_timeout, int force_scan);
struct p2p_group * wpas_p2p_group_init(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid);
enum wpas_p2p_prov_disc_use {
@@ -66,7 +75,6 @@ int wpas_p2p_listen_start(struct wpa_supplicant *wpa_s, unsigned int timeout);
int wpas_p2p_assoc_req_ie(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
u8 *buf, size_t len, int p2p_group);
void wpas_p2p_scan_ie(struct wpa_supplicant *wpa_s, struct wpabuf *ies);
-void wpas_p2p_group_formation_failed(struct wpa_supplicant *wpa_s);
u64 wpas_p2p_sd_request(struct wpa_supplicant *wpa_s, const u8 *dst,
const struct wpabuf *tlvs);
u64 wpas_p2p_sd_request_asp(struct wpa_supplicant *wpa_s, const u8 *dst, u8 id,
@@ -91,9 +99,15 @@ int wpas_p2p_service_del_upnp(struct wpa_supplicant *wpa_s, u8 version,
const char *service);
int wpas_p2p_service_add_asp(struct wpa_supplicant *wpa_s, int auto_accept,
u32 adv_id, const char *adv_str, u8 svc_state,
- u16 config_methods, const char *svc_info);
+ u16 config_methods, const char *svc_info,
+ const u8 *cpt_priority);
int wpas_p2p_service_del_asp(struct wpa_supplicant *wpa_s, u32 adv_id);
+void wpas_p2p_service_flush_asp(struct wpa_supplicant *wpa_s);
int wpas_p2p_service_p2ps_id_exists(struct wpa_supplicant *wpa_s, u32 adv_id);
+void wpas_sd_request(void *ctx, int freq, const u8 *sa, u8 dialog_token,
+ u16 update_indic, const u8 *tlvs, size_t tlvs_len);
+void wpas_sd_response(void *ctx, const u8 *sa, u16 update_indic,
+ const u8 *tlvs, size_t tlvs_len);
int wpas_p2p_reject(struct wpa_supplicant *wpa_s, const u8 *addr);
int wpas_p2p_invite(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
struct wpa_ssid *ssid, const u8 *go_dev_addr, int freq,
@@ -153,10 +167,13 @@ void wpas_p2p_update_config(struct wpa_supplicant *wpa_s);
int wpas_p2p_probe_req_rx(struct wpa_supplicant *wpa_s, const u8 *addr,
const u8 *dst, const u8 *bssid,
const u8 *ie, size_t ie_len,
- int ssi_signal);
+ unsigned int rx_freq, int ssi_signal);
void wpas_p2p_wps_success(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
int registrar);
-void wpas_p2p_update_channel_list(struct wpa_supplicant *wpa_s);
+
+void wpas_p2p_update_channel_list(struct wpa_supplicant *wpa_s,
+ enum wpas_p2p_channel_update_trig trig);
+
void wpas_p2p_update_best_channels(struct wpa_supplicant *wpa_s,
int freq_24, int freq_5, int freq_overall);
void wpas_p2p_rx_action(struct wpa_supplicant *wpa_s, const u8 *da,
@@ -207,7 +224,7 @@ static inline int wpas_p2p_probe_req_rx(struct wpa_supplicant *wpa_s,
const u8 *addr,
const u8 *dst, const u8 *bssid,
const u8 *ie, size_t ie_len,
- int ssi_signal)
+ unsigned int rx_freq, int ssi_signal)
{
return 0;
}
@@ -217,7 +234,9 @@ static inline void wpas_p2p_wps_success(struct wpa_supplicant *wpa_s,
{
}
-static inline void wpas_p2p_update_channel_list(struct wpa_supplicant *wpa_s)
+static inline void
+wpas_p2p_update_channel_list(struct wpa_supplicant *wpa_s,
+ enum wpas_p2p_channel_update_trig trig)
{
}
diff --git a/wpa_supplicant/p2p_supplicant_sd.c b/wpa_supplicant/p2p_supplicant_sd.c
new file mode 100644
index 0000000..fc07b07
--- /dev/null
+++ b/wpa_supplicant/p2p_supplicant_sd.c
@@ -0,0 +1,1273 @@
+/*
+ * wpa_supplicant - P2P service discovery
+ * Copyright (c) 2009-2010, Atheros Communications
+ * Copyright (c) 2010-2014, Jouni Malinen <j@w1.fi>
+ *
+ * This software may be distributed under the terms of the BSD license.
+ * See README for more details.
+ */
+
+#include "utils/includes.h"
+
+#include "utils/common.h"
+#include "p2p/p2p.h"
+#include "wpa_supplicant_i.h"
+#include "notify.h"
+#include "p2p_supplicant.h"
+
+
+/*
+ * DNS Header section is used only to calculate compression pointers, so the
+ * contents of this data does not matter, but the length needs to be reserved
+ * in the virtual packet.
+ */
+#define DNS_HEADER_LEN 12
+
+/*
+ * 27-octet in-memory packet from P2P specification containing two implied
+ * queries for _tcp.lcoal. PTR IN and _udp.local. PTR IN
+ */
+#define P2P_SD_IN_MEMORY_LEN 27
+
+static int p2p_sd_dns_uncompress_label(char **upos, char *uend, u8 *start,
+ u8 **spos, const u8 *end)
+{
+ while (*spos < end) {
+ u8 val = ((*spos)[0] & 0xc0) >> 6;
+ int len;
+
+ if (val == 1 || val == 2) {
+ /* These are reserved values in RFC 1035 */
+ wpa_printf(MSG_DEBUG, "P2P: Invalid domain name "
+ "sequence starting with 0x%x", val);
+ return -1;
+ }
+
+ if (val == 3) {
+ u16 offset;
+ u8 *spos_tmp;
+
+ /* Offset */
+ if (*spos + 2 > end) {
+ wpa_printf(MSG_DEBUG, "P2P: No room for full "
+ "DNS offset field");
+ return -1;
+ }
+
+ offset = (((*spos)[0] & 0x3f) << 8) | (*spos)[1];
+ if (offset >= *spos - start) {
+ wpa_printf(MSG_DEBUG, "P2P: Invalid DNS "
+ "pointer offset %u", offset);
+ return -1;
+ }
+
+ (*spos) += 2;
+ spos_tmp = start + offset;
+ return p2p_sd_dns_uncompress_label(upos, uend, start,
+ &spos_tmp,
+ *spos - 2);
+ }
+
+ /* Label */
+ len = (*spos)[0] & 0x3f;
+ if (len == 0)
+ return 0;
+
+ (*spos)++;
+ if (*spos + len > end) {
+ wpa_printf(MSG_DEBUG, "P2P: Invalid domain name "
+ "sequence - no room for label with length "
+ "%u", len);
+ return -1;
+ }
+
+ if (*upos + len + 2 > uend)
+ return -2;
+
+ os_memcpy(*upos, *spos, len);
+ *spos += len;
+ *upos += len;
+ (*upos)[0] = '.';
+ (*upos)++;
+ (*upos)[0] = '\0';
+ }
+
+ return 0;
+}
+
+
+/* Uncompress domain names per RFC 1035 using the P2P SD in-memory packet.
+ * Returns -1 on parsing error (invalid input sequence), -2 if output buffer is
+ * not large enough */
+static int p2p_sd_dns_uncompress(char *buf, size_t buf_len, const u8 *msg,
+ size_t msg_len, size_t offset)
+{
+ /* 27-octet in-memory packet from P2P specification */
+ const char *prefix = "\x04_tcp\x05local\x00\x00\x0C\x00\x01"
+ "\x04_udp\xC0\x11\x00\x0C\x00\x01";
+ u8 *tmp, *end, *spos;
+ char *upos, *uend;
+ int ret = 0;
+
+ if (buf_len < 2)
+ return -1;
+ if (offset > msg_len)
+ return -1;
+
+ tmp = os_malloc(DNS_HEADER_LEN + P2P_SD_IN_MEMORY_LEN + msg_len);
+ if (tmp == NULL)
+ return -1;
+ spos = tmp + DNS_HEADER_LEN + P2P_SD_IN_MEMORY_LEN;
+ end = spos + msg_len;
+ spos += offset;
+
+ os_memset(tmp, 0, DNS_HEADER_LEN);
+ os_memcpy(tmp + DNS_HEADER_LEN, prefix, P2P_SD_IN_MEMORY_LEN);
+ os_memcpy(tmp + DNS_HEADER_LEN + P2P_SD_IN_MEMORY_LEN, msg, msg_len);
+
+ upos = buf;
+ uend = buf + buf_len;
+
+ ret = p2p_sd_dns_uncompress_label(&upos, uend, tmp, &spos, end);
+ if (ret) {
+ os_free(tmp);
+ return ret;
+ }
+
+ if (upos == buf) {
+ upos[0] = '.';
+ upos[1] = '\0';
+ } else if (upos[-1] == '.')
+ upos[-1] = '\0';
+
+ os_free(tmp);
+ return 0;
+}
+
+
+static struct p2p_srv_bonjour *
+wpas_p2p_service_get_bonjour(struct wpa_supplicant *wpa_s,
+ const struct wpabuf *query)
+{
+ struct p2p_srv_bonjour *bsrv;
+ size_t len;
+
+ len = wpabuf_len(query);
+ dl_list_for_each(bsrv, &wpa_s->global->p2p_srv_bonjour,
+ struct p2p_srv_bonjour, list) {
+ if (len == wpabuf_len(bsrv->query) &&
+ os_memcmp(wpabuf_head(query), wpabuf_head(bsrv->query),
+ len) == 0)
+ return bsrv;
+ }
+ return NULL;
+}
+
+
+static struct p2p_srv_upnp *
+wpas_p2p_service_get_upnp(struct wpa_supplicant *wpa_s, u8 version,
+ const char *service)
+{
+ struct p2p_srv_upnp *usrv;
+
+ dl_list_for_each(usrv, &wpa_s->global->p2p_srv_upnp,
+ struct p2p_srv_upnp, list) {
+ if (version == usrv->version &&
+ os_strcmp(service, usrv->service) == 0)
+ return usrv;
+ }
+ return NULL;
+}
+
+
+static void wpas_sd_add_empty(struct wpabuf *resp, u8 srv_proto,
+ u8 srv_trans_id, u8 status)
+{
+ u8 *len_pos;
+
+ if (wpabuf_tailroom(resp) < 5)
+ return;
+
+ /* Length (to be filled) */
+ len_pos = wpabuf_put(resp, 2);
+ wpabuf_put_u8(resp, srv_proto);
+ wpabuf_put_u8(resp, srv_trans_id);
+ /* Status Code */
+ wpabuf_put_u8(resp, status);
+ /* Response Data: empty */
+ WPA_PUT_LE16(len_pos, (u8 *) wpabuf_put(resp, 0) - len_pos - 2);
+}
+
+
+static void wpas_sd_add_proto_not_avail(struct wpabuf *resp, u8 srv_proto,
+ u8 srv_trans_id)
+{
+ wpas_sd_add_empty(resp, srv_proto, srv_trans_id,
+ P2P_SD_PROTO_NOT_AVAILABLE);
+}
+
+
+static void wpas_sd_add_bad_request(struct wpabuf *resp, u8 srv_proto,
+ u8 srv_trans_id)
+{
+ wpas_sd_add_empty(resp, srv_proto, srv_trans_id, P2P_SD_BAD_REQUEST);
+}
+
+
+static void wpas_sd_add_not_found(struct wpabuf *resp, u8 srv_proto,
+ u8 srv_trans_id)
+{
+ wpas_sd_add_empty(resp, srv_proto, srv_trans_id,
+ P2P_SD_REQUESTED_INFO_NOT_AVAILABLE);
+}
+
+
+static void wpas_sd_all_bonjour(struct wpa_supplicant *wpa_s,
+ struct wpabuf *resp, u8 srv_trans_id)
+{
+ struct p2p_srv_bonjour *bsrv;
+ u8 *len_pos;
+
+ wpa_printf(MSG_DEBUG, "P2P: SD Request for all Bonjour services");
+
+ if (dl_list_empty(&wpa_s->global->p2p_srv_bonjour)) {
+ wpa_printf(MSG_DEBUG, "P2P: Bonjour protocol not available");
+ return;
+ }
+
+ dl_list_for_each(bsrv, &wpa_s->global->p2p_srv_bonjour,
+ struct p2p_srv_bonjour, list) {
+ if (wpabuf_tailroom(resp) <
+ 5 + wpabuf_len(bsrv->query) + wpabuf_len(bsrv->resp))
+ return;
+ /* Length (to be filled) */
+ len_pos = wpabuf_put(resp, 2);
+ wpabuf_put_u8(resp, P2P_SERV_BONJOUR);
+ wpabuf_put_u8(resp, srv_trans_id);
+ /* Status Code */
+ wpabuf_put_u8(resp, P2P_SD_SUCCESS);
+ wpa_hexdump_ascii(MSG_DEBUG, "P2P: Matching Bonjour service",
+ wpabuf_head(bsrv->resp),
+ wpabuf_len(bsrv->resp));
+ /* Response Data */
+ wpabuf_put_buf(resp, bsrv->query); /* Key */
+ wpabuf_put_buf(resp, bsrv->resp); /* Value */
+ WPA_PUT_LE16(len_pos, (u8 *) wpabuf_put(resp, 0) - len_pos -
+ 2);
+ }
+}
+
+
+static int match_bonjour_query(struct p2p_srv_bonjour *bsrv, const u8 *query,
+ size_t query_len)
+{
+ char str_rx[256], str_srv[256];
+
+ if (query_len < 3 || wpabuf_len(bsrv->query) < 3)
+ return 0; /* Too short to include DNS Type and Version */
+ if (os_memcmp(query + query_len - 3,
+ wpabuf_head_u8(bsrv->query) + wpabuf_len(bsrv->query) - 3,
+ 3) != 0)
+ return 0; /* Mismatch in DNS Type or Version */
+ if (query_len == wpabuf_len(bsrv->query) &&
+ os_memcmp(query, wpabuf_head(bsrv->query), query_len - 3) == 0)
+ return 1; /* Binary match */
+
+ if (p2p_sd_dns_uncompress(str_rx, sizeof(str_rx), query, query_len - 3,
+ 0))
+ return 0; /* Failed to uncompress query */
+ if (p2p_sd_dns_uncompress(str_srv, sizeof(str_srv),
+ wpabuf_head(bsrv->query),
+ wpabuf_len(bsrv->query) - 3, 0))
+ return 0; /* Failed to uncompress service */
+
+ return os_strcmp(str_rx, str_srv) == 0;
+}
+
+
+static void wpas_sd_req_bonjour(struct wpa_supplicant *wpa_s,
+ struct wpabuf *resp, u8 srv_trans_id,
+ const u8 *query, size_t query_len)
+{
+ struct p2p_srv_bonjour *bsrv;
+ u8 *len_pos;
+ int matches = 0;
+
+ wpa_hexdump_ascii(MSG_DEBUG, "P2P: SD Request for Bonjour",
+ query, query_len);
+ if (dl_list_empty(&wpa_s->global->p2p_srv_bonjour)) {
+ wpa_printf(MSG_DEBUG, "P2P: Bonjour protocol not available");
+ wpas_sd_add_proto_not_avail(resp, P2P_SERV_BONJOUR,
+ srv_trans_id);
+ return;
+ }
+
+ if (query_len == 0) {
+ wpas_sd_all_bonjour(wpa_s, resp, srv_trans_id);
+ return;
+ }
+
+ dl_list_for_each(bsrv, &wpa_s->global->p2p_srv_bonjour,
+ struct p2p_srv_bonjour, list) {
+ if (!match_bonjour_query(bsrv, query, query_len))
+ continue;
+
+ if (wpabuf_tailroom(resp) <
+ 5 + query_len + wpabuf_len(bsrv->resp))
+ return;
+
+ matches++;
+
+ /* Length (to be filled) */
+ len_pos = wpabuf_put(resp, 2);
+ wpabuf_put_u8(resp, P2P_SERV_BONJOUR);
+ wpabuf_put_u8(resp, srv_trans_id);
+
+ /* Status Code */
+ wpabuf_put_u8(resp, P2P_SD_SUCCESS);
+ wpa_hexdump_ascii(MSG_DEBUG, "P2P: Matching Bonjour service",
+ wpabuf_head(bsrv->resp),
+ wpabuf_len(bsrv->resp));
+
+ /* Response Data */
+ wpabuf_put_data(resp, query, query_len); /* Key */
+ wpabuf_put_buf(resp, bsrv->resp); /* Value */
+
+ WPA_PUT_LE16(len_pos, (u8 *) wpabuf_put(resp, 0) - len_pos - 2);
+ }
+
+ if (matches == 0) {
+ wpa_printf(MSG_DEBUG, "P2P: Requested Bonjour service not "
+ "available");
+ if (wpabuf_tailroom(resp) < 5)
+ return;
+
+ /* Length (to be filled) */
+ len_pos = wpabuf_put(resp, 2);
+ wpabuf_put_u8(resp, P2P_SERV_BONJOUR);
+ wpabuf_put_u8(resp, srv_trans_id);
+
+ /* Status Code */
+ wpabuf_put_u8(resp, P2P_SD_REQUESTED_INFO_NOT_AVAILABLE);
+ /* Response Data: empty */
+ WPA_PUT_LE16(len_pos, (u8 *) wpabuf_put(resp, 0) - len_pos -
+ 2);
+ }
+}
+
+
+static void wpas_sd_all_upnp(struct wpa_supplicant *wpa_s,
+ struct wpabuf *resp, u8 srv_trans_id)
+{
+ struct p2p_srv_upnp *usrv;
+ u8 *len_pos;
+
+ wpa_printf(MSG_DEBUG, "P2P: SD Request for all UPnP services");
+
+ if (dl_list_empty(&wpa_s->global->p2p_srv_upnp)) {
+ wpa_printf(MSG_DEBUG, "P2P: UPnP protocol not available");
+ return;
+ }
+
+ dl_list_for_each(usrv, &wpa_s->global->p2p_srv_upnp,
+ struct p2p_srv_upnp, list) {
+ if (wpabuf_tailroom(resp) < 5 + 1 + os_strlen(usrv->service))
+ return;
+
+ /* Length (to be filled) */
+ len_pos = wpabuf_put(resp, 2);
+ wpabuf_put_u8(resp, P2P_SERV_UPNP);
+ wpabuf_put_u8(resp, srv_trans_id);
+
+ /* Status Code */
+ wpabuf_put_u8(resp, P2P_SD_SUCCESS);
+ /* Response Data */
+ wpabuf_put_u8(resp, usrv->version);
+ wpa_printf(MSG_DEBUG, "P2P: Matching UPnP Service: %s",
+ usrv->service);
+ wpabuf_put_str(resp, usrv->service);
+ WPA_PUT_LE16(len_pos, (u8 *) wpabuf_put(resp, 0) - len_pos -
+ 2);
+ }
+}
+
+
+static void wpas_sd_req_upnp(struct wpa_supplicant *wpa_s,
+ struct wpabuf *resp, u8 srv_trans_id,
+ const u8 *query, size_t query_len)
+{
+ struct p2p_srv_upnp *usrv;
+ u8 *len_pos;
+ u8 version;
+ char *str;
+ int count = 0;
+
+ wpa_hexdump_ascii(MSG_DEBUG, "P2P: SD Request for UPnP",
+ query, query_len);
+
+ if (dl_list_empty(&wpa_s->global->p2p_srv_upnp)) {
+ wpa_printf(MSG_DEBUG, "P2P: UPnP protocol not available");
+ wpas_sd_add_proto_not_avail(resp, P2P_SERV_UPNP,
+ srv_trans_id);
+ return;
+ }
+
+ if (query_len == 0) {
+ wpas_sd_all_upnp(wpa_s, resp, srv_trans_id);
+ return;
+ }
+
+ if (wpabuf_tailroom(resp) < 5)
+ return;
+
+ /* Length (to be filled) */
+ len_pos = wpabuf_put(resp, 2);
+ wpabuf_put_u8(resp, P2P_SERV_UPNP);
+ wpabuf_put_u8(resp, srv_trans_id);
+
+ version = query[0];
+ str = os_malloc(query_len);
+ if (str == NULL)
+ return;
+ os_memcpy(str, query + 1, query_len - 1);
+ str[query_len - 1] = '\0';
+
+ dl_list_for_each(usrv, &wpa_s->global->p2p_srv_upnp,
+ struct p2p_srv_upnp, list) {
+ if (version != usrv->version)
+ continue;
+
+ if (os_strcmp(str, "ssdp:all") != 0 &&
+ os_strstr(usrv->service, str) == NULL)
+ continue;
+
+ if (wpabuf_tailroom(resp) < 2)
+ break;
+ if (count == 0) {
+ /* Status Code */
+ wpabuf_put_u8(resp, P2P_SD_SUCCESS);
+ /* Response Data */
+ wpabuf_put_u8(resp, version);
+ } else
+ wpabuf_put_u8(resp, ',');
+
+ count++;
+
+ wpa_printf(MSG_DEBUG, "P2P: Matching UPnP Service: %s",
+ usrv->service);
+ if (wpabuf_tailroom(resp) < os_strlen(usrv->service))
+ break;
+ wpabuf_put_str(resp, usrv->service);
+ }
+ os_free(str);
+
+ if (count == 0) {
+ wpa_printf(MSG_DEBUG, "P2P: Requested UPnP service not "
+ "available");
+ /* Status Code */
+ wpabuf_put_u8(resp, P2P_SD_REQUESTED_INFO_NOT_AVAILABLE);
+ /* Response Data: empty */
+ }
+
+ WPA_PUT_LE16(len_pos, (u8 *) wpabuf_put(resp, 0) - len_pos - 2);
+}
+
+
+#ifdef CONFIG_WIFI_DISPLAY
+static void wpas_sd_req_wfd(struct wpa_supplicant *wpa_s,
+ struct wpabuf *resp, u8 srv_trans_id,
+ const u8 *query, size_t query_len)
+{
+ const u8 *pos;
+ u8 role;
+ u8 *len_pos;
+
+ wpa_hexdump(MSG_DEBUG, "P2P: SD Request for WFD", query, query_len);
+
+ if (!wpa_s->global->wifi_display) {
+ wpa_printf(MSG_DEBUG, "P2P: WFD protocol not available");
+ wpas_sd_add_proto_not_avail(resp, P2P_SERV_WIFI_DISPLAY,
+ srv_trans_id);
+ return;
+ }
+
+ if (query_len < 1) {
+ wpa_printf(MSG_DEBUG, "P2P: Missing WFD Requested Device "
+ "Role");
+ return;
+ }
+
+ if (wpabuf_tailroom(resp) < 5)
+ return;
+
+ pos = query;
+ role = *pos++;
+ wpa_printf(MSG_DEBUG, "P2P: WSD for device role 0x%x", role);
+
+ /* TODO: role specific handling */
+
+ /* Length (to be filled) */
+ len_pos = wpabuf_put(resp, 2);
+ wpabuf_put_u8(resp, P2P_SERV_WIFI_DISPLAY);
+ wpabuf_put_u8(resp, srv_trans_id);
+ wpabuf_put_u8(resp, P2P_SD_SUCCESS); /* Status Code */
+
+ while (pos < query + query_len) {
+ if (*pos < MAX_WFD_SUBELEMS &&
+ wpa_s->global->wfd_subelem[*pos] &&
+ wpabuf_tailroom(resp) >=
+ wpabuf_len(wpa_s->global->wfd_subelem[*pos])) {
+ wpa_printf(MSG_DEBUG, "P2P: Add WSD response "
+ "subelement %u", *pos);
+ wpabuf_put_buf(resp, wpa_s->global->wfd_subelem[*pos]);
+ }
+ pos++;
+ }
+
+ WPA_PUT_LE16(len_pos, (u8 *) wpabuf_put(resp, 0) - len_pos - 2);
+}
+#endif /* CONFIG_WIFI_DISPLAY */
+
+
+static int find_p2ps_substr(struct p2ps_advertisement *adv_data,
+ const u8 *needle, size_t needle_len)
+{
+ const u8 *haystack = (const u8 *) adv_data->svc_info;
+ size_t haystack_len, i;
+
+ /* Allow search term to be empty */
+ if (!needle || !needle_len)
+ return 1;
+
+ if (!haystack)
+ return 0;
+
+ haystack_len = os_strlen(adv_data->svc_info);
+ for (i = 0; i < haystack_len; i++) {
+ if (haystack_len - i < needle_len)
+ break;
+ if (os_memcmp(haystack + i, needle, needle_len) == 0)
+ return 1;
+ }
+
+ return 0;
+}
+
+
+static void wpas_sd_req_asp(struct wpa_supplicant *wpa_s,
+ struct wpabuf *resp, u8 srv_trans_id,
+ const u8 *query, size_t query_len)
+{
+ struct p2ps_advertisement *adv_data;
+ const u8 *svc = &query[1];
+ const u8 *info = NULL;
+ size_t svc_len = query[0];
+ size_t info_len = 0;
+ int prefix = 0;
+ u8 *count_pos = NULL;
+ u8 *len_pos = NULL;
+
+ wpa_hexdump(MSG_DEBUG, "P2P: SD Request for ASP", query, query_len);
+
+ if (!wpa_s->global->p2p) {
+ wpa_printf(MSG_DEBUG, "P2P: ASP protocol not available");
+ wpas_sd_add_proto_not_avail(resp, P2P_SERV_P2PS, srv_trans_id);
+ return;
+ }
+
+ /* Info block is optional */
+ if (svc_len + 1 < query_len) {
+ info = &svc[svc_len];
+ info_len = *info++;
+ }
+
+ /* Range check length of svc string and info block */
+ if (svc_len + (info_len ? info_len + 2 : 1) > query_len) {
+ wpa_printf(MSG_DEBUG, "P2P: ASP bad request");
+ wpas_sd_add_bad_request(resp, P2P_SERV_P2PS, srv_trans_id);
+ return;
+ }
+
+ /* Detect and correct for prefix search */
+ if (svc_len && svc[svc_len - 1] == '*') {
+ prefix = 1;
+ svc_len--;
+ }
+
+ for (adv_data = p2p_get_p2ps_adv_list(wpa_s->global->p2p);
+ adv_data; adv_data = adv_data->next) {
+ /* If not a prefix match, reject length mismatches */
+ if (!prefix && svc_len != os_strlen(adv_data->svc_name))
+ continue;
+
+ /* Search each service for request */
+ if (os_memcmp(adv_data->svc_name, svc, svc_len) == 0 &&
+ find_p2ps_substr(adv_data, info, info_len)) {
+ size_t len = os_strlen(adv_data->svc_name);
+ size_t svc_info_len = 0;
+
+ if (adv_data->svc_info)
+ svc_info_len = os_strlen(adv_data->svc_info);
+
+ if (len > 0xff || svc_info_len > 0xffff)
+ return;
+
+ /* Length & Count to be filled as we go */
+ if (!len_pos && !count_pos) {
+ if (wpabuf_tailroom(resp) <
+ len + svc_info_len + 16)
+ return;
+
+ len_pos = wpabuf_put(resp, 2);
+ wpabuf_put_u8(resp, P2P_SERV_P2PS);
+ wpabuf_put_u8(resp, srv_trans_id);
+ /* Status Code */
+ wpabuf_put_u8(resp, P2P_SD_SUCCESS);
+ count_pos = wpabuf_put(resp, 1);
+ *count_pos = 0;
+ } else if (wpabuf_tailroom(resp) <
+ len + svc_info_len + 10)
+ return;
+
+ if (svc_info_len) {
+ wpa_printf(MSG_DEBUG,
+ "P2P: Add Svc: %s info: %s",
+ adv_data->svc_name,
+ adv_data->svc_info);
+ } else {
+ wpa_printf(MSG_DEBUG, "P2P: Add Svc: %s",
+ adv_data->svc_name);
+ }
+
+ /* Advertisement ID */
+ wpabuf_put_le32(resp, adv_data->id);
+
+ /* Config Methods */
+ wpabuf_put_be16(resp, adv_data->config_methods);
+
+ /* Service Name */
+ wpabuf_put_u8(resp, (u8) len);
+ wpabuf_put_data(resp, adv_data->svc_name, len);
+
+ /* Service State */
+ wpabuf_put_u8(resp, adv_data->state);
+
+ /* Service Information */
+ wpabuf_put_le16(resp, (u16) svc_info_len);
+ wpabuf_put_data(resp, adv_data->svc_info, svc_info_len);
+
+ /* Update length and count */
+ (*count_pos)++;
+ WPA_PUT_LE16(len_pos,
+ (u8 *) wpabuf_put(resp, 0) - len_pos - 2);
+ }
+ }
+
+ /* Return error if no matching svc found */
+ if (count_pos == NULL) {
+ wpa_printf(MSG_DEBUG, "P2P: ASP service not found");
+ wpas_sd_add_not_found(resp, P2P_SERV_P2PS, srv_trans_id);
+ }
+}
+
+
+static void wpas_sd_all_asp(struct wpa_supplicant *wpa_s,
+ struct wpabuf *resp, u8 srv_trans_id)
+{
+ /* Query data to add all P2PS advertisements:
+ * - Service name length: 1
+ * - Service name: '*'
+ * - Service Information Request Length: 0
+ */
+ const u8 q[] = { 1, (const u8) '*', 0 };
+
+ if (p2p_get_p2ps_adv_list(wpa_s->global->p2p))
+ wpas_sd_req_asp(wpa_s, resp, srv_trans_id, q, sizeof(q));
+}
+
+
+void wpas_sd_request(void *ctx, int freq, const u8 *sa, u8 dialog_token,
+ u16 update_indic, const u8 *tlvs, size_t tlvs_len)
+{
+ struct wpa_supplicant *wpa_s = ctx;
+ const u8 *pos = tlvs;
+ const u8 *end = tlvs + tlvs_len;
+ const u8 *tlv_end;
+ u16 slen;
+ struct wpabuf *resp;
+ u8 srv_proto, srv_trans_id;
+ size_t buf_len;
+ char *buf;
+
+ wpa_hexdump(MSG_MSGDUMP, "P2P: Service Discovery Request TLVs",
+ tlvs, tlvs_len);
+ buf_len = 2 * tlvs_len + 1;
+ buf = os_malloc(buf_len);
+ if (buf) {
+ wpa_snprintf_hex(buf, buf_len, tlvs, tlvs_len);
+ wpa_msg_ctrl(wpa_s, MSG_INFO, P2P_EVENT_SERV_DISC_REQ "%d "
+ MACSTR " %u %u %s",
+ freq, MAC2STR(sa), dialog_token, update_indic,
+ buf);
+ os_free(buf);
+ }
+
+ if (wpa_s->p2p_sd_over_ctrl_iface) {
+ wpas_notify_p2p_sd_request(wpa_s, freq, sa, dialog_token,
+ update_indic, tlvs, tlvs_len);
+ return; /* to be processed by an external program */
+ }
+
+ resp = wpabuf_alloc(10000);
+ if (resp == NULL)
+ return;
+
+ while (pos + 1 < end) {
+ wpa_printf(MSG_DEBUG, "P2P: Service Request TLV");
+ slen = WPA_GET_LE16(pos);
+ pos += 2;
+ if (pos + slen > end || slen < 2) {
+ wpa_printf(MSG_DEBUG, "P2P: Unexpected Query Data "
+ "length");
+ wpabuf_free(resp);
+ return;
+ }
+ tlv_end = pos + slen;
+
+ srv_proto = *pos++;
+ wpa_printf(MSG_DEBUG, "P2P: Service Protocol Type %u",
+ srv_proto);
+ srv_trans_id = *pos++;
+ wpa_printf(MSG_DEBUG, "P2P: Service Transaction ID %u",
+ srv_trans_id);
+
+ wpa_hexdump(MSG_MSGDUMP, "P2P: Query Data",
+ pos, tlv_end - pos);
+
+
+ if (wpa_s->force_long_sd) {
+ wpa_printf(MSG_DEBUG, "P2P: SD test - force long "
+ "response");
+ wpas_sd_all_bonjour(wpa_s, resp, srv_trans_id);
+ wpas_sd_all_upnp(wpa_s, resp, srv_trans_id);
+ wpas_sd_all_asp(wpa_s, resp, srv_trans_id);
+ goto done;
+ }
+
+ switch (srv_proto) {
+ case P2P_SERV_ALL_SERVICES:
+ wpa_printf(MSG_DEBUG, "P2P: Service Discovery Request "
+ "for all services");
+ if (dl_list_empty(&wpa_s->global->p2p_srv_upnp) &&
+ dl_list_empty(&wpa_s->global->p2p_srv_bonjour) &&
+ !p2p_get_p2ps_adv_list(wpa_s->global->p2p)) {
+ wpa_printf(MSG_DEBUG, "P2P: No service "
+ "discovery protocols available");
+ wpas_sd_add_proto_not_avail(
+ resp, P2P_SERV_ALL_SERVICES,
+ srv_trans_id);
+ break;
+ }
+ wpas_sd_all_bonjour(wpa_s, resp, srv_trans_id);
+ wpas_sd_all_upnp(wpa_s, resp, srv_trans_id);
+ wpas_sd_all_asp(wpa_s, resp, srv_trans_id);
+ break;
+ case P2P_SERV_BONJOUR:
+ wpas_sd_req_bonjour(wpa_s, resp, srv_trans_id,
+ pos, tlv_end - pos);
+ break;
+ case P2P_SERV_UPNP:
+ wpas_sd_req_upnp(wpa_s, resp, srv_trans_id,
+ pos, tlv_end - pos);
+ break;
+#ifdef CONFIG_WIFI_DISPLAY
+ case P2P_SERV_WIFI_DISPLAY:
+ wpas_sd_req_wfd(wpa_s, resp, srv_trans_id,
+ pos, tlv_end - pos);
+ break;
+#endif /* CONFIG_WIFI_DISPLAY */
+ case P2P_SERV_P2PS:
+ wpas_sd_req_asp(wpa_s, resp, srv_trans_id,
+ pos, tlv_end - pos);
+ break;
+ default:
+ wpa_printf(MSG_DEBUG, "P2P: Unavailable service "
+ "protocol %u", srv_proto);
+ wpas_sd_add_proto_not_avail(resp, srv_proto,
+ srv_trans_id);
+ break;
+ }
+
+ pos = tlv_end;
+ }
+
+done:
+ wpas_notify_p2p_sd_request(wpa_s, freq, sa, dialog_token,
+ update_indic, tlvs, tlvs_len);
+
+ wpas_p2p_sd_response(wpa_s, freq, sa, dialog_token, resp);
+
+ wpabuf_free(resp);
+}
+
+
+static void wpas_sd_p2ps_serv_response(struct wpa_supplicant *wpa_s,
+ const u8 *sa, u8 srv_trans_id,
+ const u8 *pos, const u8 *tlv_end)
+{
+ u8 left = *pos++;
+ u32 adv_id;
+ u8 svc_status;
+ u16 config_methods;
+ char svc_str[256];
+
+ while (left-- && pos < tlv_end) {
+ char *buf = NULL;
+ size_t buf_len;
+ u8 svc_len;
+
+ /* Sanity check fixed length+svc_str */
+ if (pos + 6 >= tlv_end)
+ break;
+ svc_len = pos[6];
+ if (pos + svc_len + 10 > tlv_end)
+ break;
+
+ /* Advertisement ID */
+ adv_id = WPA_GET_LE32(pos);
+ pos += sizeof(u32);
+
+ /* Config Methods */
+ config_methods = WPA_GET_BE16(pos);
+ pos += sizeof(u16);
+
+ /* Service Name */
+ pos++; /* svc_len */
+ os_memcpy(svc_str, pos, svc_len);
+ svc_str[svc_len] = '\0';
+ pos += svc_len;
+
+ /* Service Status */
+ svc_status = *pos++;
+
+ /* Service Information Length */
+ buf_len = WPA_GET_LE16(pos);
+ pos += sizeof(u16);
+
+ /* Sanity check buffer length */
+ if (buf_len > (unsigned int) (tlv_end - pos))
+ break;
+
+ if (buf_len) {
+ buf = os_zalloc(2 * buf_len + 1);
+ if (buf) {
+ utf8_escape((const char *) pos, buf_len, buf,
+ 2 * buf_len + 1);
+ }
+ }
+
+ pos += buf_len;
+
+ if (buf) {
+ wpa_msg_global(wpa_s, MSG_INFO, P2P_EVENT_SERV_ASP_RESP
+ MACSTR " %x %x %x %x %s '%s'",
+ MAC2STR(sa), srv_trans_id, adv_id,
+ svc_status, config_methods, svc_str,
+ buf);
+ os_free(buf);
+ } else {
+ wpa_msg_global(wpa_s, MSG_INFO, P2P_EVENT_SERV_ASP_RESP
+ MACSTR " %x %x %x %x %s",
+ MAC2STR(sa), srv_trans_id, adv_id,
+ svc_status, config_methods, svc_str);
+ }
+ }
+}
+
+
+void wpas_sd_response(void *ctx, const u8 *sa, u16 update_indic,
+ const u8 *tlvs, size_t tlvs_len)
+{
+ struct wpa_supplicant *wpa_s = ctx;
+ const u8 *pos = tlvs;
+ const u8 *end = tlvs + tlvs_len;
+ const u8 *tlv_end;
+ u16 slen;
+ size_t buf_len;
+ char *buf;
+
+ wpa_hexdump(MSG_MSGDUMP, "P2P: Service Discovery Response TLVs",
+ tlvs, tlvs_len);
+ if (tlvs_len > 1500) {
+ /* TODO: better way for handling this */
+ wpa_msg_ctrl(wpa_s, MSG_INFO,
+ P2P_EVENT_SERV_DISC_RESP MACSTR
+ " %u <long response: %u bytes>",
+ MAC2STR(sa), update_indic,
+ (unsigned int) tlvs_len);
+ } else {
+ buf_len = 2 * tlvs_len + 1;
+ buf = os_malloc(buf_len);
+ if (buf) {
+ wpa_snprintf_hex(buf, buf_len, tlvs, tlvs_len);
+ wpa_msg_ctrl(wpa_s, MSG_INFO,
+ P2P_EVENT_SERV_DISC_RESP MACSTR " %u %s",
+ MAC2STR(sa), update_indic, buf);
+ os_free(buf);
+ }
+ }
+
+ while (pos < end) {
+ u8 srv_proto, srv_trans_id, status;
+
+ wpa_printf(MSG_DEBUG, "P2P: Service Response TLV");
+ slen = WPA_GET_LE16(pos);
+ pos += 2;
+ if (pos + slen > end || slen < 3) {
+ wpa_printf(MSG_DEBUG, "P2P: Unexpected Response Data "
+ "length");
+ return;
+ }
+ tlv_end = pos + slen;
+
+ srv_proto = *pos++;
+ wpa_printf(MSG_DEBUG, "P2P: Service Protocol Type %u",
+ srv_proto);
+ srv_trans_id = *pos++;
+ wpa_printf(MSG_DEBUG, "P2P: Service Transaction ID %u",
+ srv_trans_id);
+ status = *pos++;
+ wpa_printf(MSG_DEBUG, "P2P: Status Code ID %u",
+ status);
+
+ wpa_hexdump(MSG_MSGDUMP, "P2P: Response Data",
+ pos, tlv_end - pos);
+
+ if (srv_proto == P2P_SERV_P2PS && pos < tlv_end) {
+ wpas_sd_p2ps_serv_response(wpa_s, sa, srv_trans_id,
+ pos, tlv_end);
+ }
+
+ pos = tlv_end;
+ }
+
+ wpas_notify_p2p_sd_response(wpa_s, sa, update_indic, tlvs, tlvs_len);
+}
+
+
+u64 wpas_p2p_sd_request(struct wpa_supplicant *wpa_s, const u8 *dst,
+ const struct wpabuf *tlvs)
+{
+ if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
+ return 0;
+ return (uintptr_t) p2p_sd_request(wpa_s->global->p2p, dst, tlvs);
+}
+
+
+u64 wpas_p2p_sd_request_upnp(struct wpa_supplicant *wpa_s, const u8 *dst,
+ u8 version, const char *query)
+{
+ struct wpabuf *tlvs;
+ u64 ret;
+
+ tlvs = wpabuf_alloc(2 + 1 + 1 + 1 + os_strlen(query));
+ if (tlvs == NULL)
+ return 0;
+ wpabuf_put_le16(tlvs, 1 + 1 + 1 + os_strlen(query));
+ wpabuf_put_u8(tlvs, P2P_SERV_UPNP); /* Service Protocol Type */
+ wpabuf_put_u8(tlvs, 1); /* Service Transaction ID */
+ wpabuf_put_u8(tlvs, version);
+ wpabuf_put_str(tlvs, query);
+ ret = wpas_p2p_sd_request(wpa_s, dst, tlvs);
+ wpabuf_free(tlvs);
+ return ret;
+}
+
+
+u64 wpas_p2p_sd_request_asp(struct wpa_supplicant *wpa_s, const u8 *dst, u8 id,
+ const char *svc_str, const char *info_substr)
+{
+ struct wpabuf *tlvs;
+ size_t plen, svc_len, substr_len = 0;
+ u64 ret;
+
+ svc_len = os_strlen(svc_str);
+ if (info_substr)
+ substr_len = os_strlen(info_substr);
+
+ if (svc_len > 0xff || substr_len > 0xff)
+ return 0;
+
+ plen = 1 + 1 + 1 + svc_len + 1 + substr_len;
+ tlvs = wpabuf_alloc(2 + plen);
+ if (tlvs == NULL)
+ return 0;
+
+ wpabuf_put_le16(tlvs, plen);
+ wpabuf_put_u8(tlvs, P2P_SERV_P2PS);
+ wpabuf_put_u8(tlvs, id); /* Service Transaction ID */
+ wpabuf_put_u8(tlvs, (u8) svc_len); /* Service String Length */
+ wpabuf_put_data(tlvs, svc_str, svc_len);
+ wpabuf_put_u8(tlvs, (u8) substr_len); /* Info Substring Length */
+ wpabuf_put_data(tlvs, info_substr, substr_len);
+ ret = wpas_p2p_sd_request(wpa_s, dst, tlvs);
+ wpabuf_free(tlvs);
+
+ return ret;
+}
+
+
+#ifdef CONFIG_WIFI_DISPLAY
+
+static u64 wpas_p2p_sd_request_wfd(struct wpa_supplicant *wpa_s, const u8 *dst,
+ const struct wpabuf *tlvs)
+{
+ if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
+ return 0;
+ return (uintptr_t) p2p_sd_request_wfd(wpa_s->global->p2p, dst, tlvs);
+}
+
+
+#define MAX_WFD_SD_SUBELEMS 20
+
+static void wfd_add_sd_req_role(struct wpabuf *tlvs, u8 id, u8 role,
+ const char *subelems)
+{
+ u8 *len;
+ const char *pos;
+ int val;
+ int count = 0;
+
+ len = wpabuf_put(tlvs, 2);
+ wpabuf_put_u8(tlvs, P2P_SERV_WIFI_DISPLAY); /* Service Protocol Type */
+ wpabuf_put_u8(tlvs, id); /* Service Transaction ID */
+
+ wpabuf_put_u8(tlvs, role);
+
+ pos = subelems;
+ while (*pos) {
+ val = atoi(pos);
+ if (val >= 0 && val < 256) {
+ wpabuf_put_u8(tlvs, val);
+ count++;
+ if (count == MAX_WFD_SD_SUBELEMS)
+ break;
+ }
+ pos = os_strchr(pos + 1, ',');
+ if (pos == NULL)
+ break;
+ pos++;
+ }
+
+ WPA_PUT_LE16(len, (u8 *) wpabuf_put(tlvs, 0) - len - 2);
+}
+
+
+u64 wpas_p2p_sd_request_wifi_display(struct wpa_supplicant *wpa_s,
+ const u8 *dst, const char *role)
+{
+ struct wpabuf *tlvs;
+ u64 ret;
+ const char *subelems;
+ u8 id = 1;
+
+ subelems = os_strchr(role, ' ');
+ if (subelems == NULL)
+ return 0;
+ subelems++;
+
+ tlvs = wpabuf_alloc(4 * (2 + 1 + 1 + 1 + MAX_WFD_SD_SUBELEMS));
+ if (tlvs == NULL)
+ return 0;
+
+ if (os_strstr(role, "[source]"))
+ wfd_add_sd_req_role(tlvs, id++, 0x00, subelems);
+ if (os_strstr(role, "[pri-sink]"))
+ wfd_add_sd_req_role(tlvs, id++, 0x01, subelems);
+ if (os_strstr(role, "[sec-sink]"))
+ wfd_add_sd_req_role(tlvs, id++, 0x02, subelems);
+ if (os_strstr(role, "[source+sink]"))
+ wfd_add_sd_req_role(tlvs, id++, 0x03, subelems);
+
+ ret = wpas_p2p_sd_request_wfd(wpa_s, dst, tlvs);
+ wpabuf_free(tlvs);
+ return ret;
+}
+
+#endif /* CONFIG_WIFI_DISPLAY */
+
+
+int wpas_p2p_sd_cancel_request(struct wpa_supplicant *wpa_s, u64 req)
+{
+ if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
+ return -1;
+ return p2p_sd_cancel_request(wpa_s->global->p2p,
+ (void *) (uintptr_t) req);
+}
+
+
+void wpas_p2p_sd_response(struct wpa_supplicant *wpa_s, int freq,
+ const u8 *dst, u8 dialog_token,
+ const struct wpabuf *resp_tlvs)
+{
+ if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
+ return;
+ p2p_sd_response(wpa_s->global->p2p, freq, dst, dialog_token,
+ resp_tlvs);
+}
+
+
+void wpas_p2p_sd_service_update(struct wpa_supplicant *wpa_s)
+{
+ if (wpa_s->global->p2p)
+ p2p_sd_service_update(wpa_s->global->p2p);
+}
+
+
+static void wpas_p2p_srv_bonjour_free(struct p2p_srv_bonjour *bsrv)
+{
+ dl_list_del(&bsrv->list);
+ wpabuf_free(bsrv->query);
+ wpabuf_free(bsrv->resp);
+ os_free(bsrv);
+}
+
+
+static void wpas_p2p_srv_upnp_free(struct p2p_srv_upnp *usrv)
+{
+ dl_list_del(&usrv->list);
+ os_free(usrv->service);
+ os_free(usrv);
+}
+
+
+void wpas_p2p_service_flush(struct wpa_supplicant *wpa_s)
+{
+ struct p2p_srv_bonjour *bsrv, *bn;
+ struct p2p_srv_upnp *usrv, *un;
+
+ dl_list_for_each_safe(bsrv, bn, &wpa_s->global->p2p_srv_bonjour,
+ struct p2p_srv_bonjour, list)
+ wpas_p2p_srv_bonjour_free(bsrv);
+
+ dl_list_for_each_safe(usrv, un, &wpa_s->global->p2p_srv_upnp,
+ struct p2p_srv_upnp, list)
+ wpas_p2p_srv_upnp_free(usrv);
+
+ wpas_p2p_service_flush_asp(wpa_s);
+ wpas_p2p_sd_service_update(wpa_s);
+}
+
+
+int wpas_p2p_service_p2ps_id_exists(struct wpa_supplicant *wpa_s, u32 adv_id)
+{
+ if (adv_id == 0)
+ return 1;
+
+ if (p2p_service_p2ps_id(wpa_s->global->p2p, adv_id))
+ return 1;
+
+ return 0;
+}
+
+
+int wpas_p2p_service_del_asp(struct wpa_supplicant *wpa_s, u32 adv_id)
+{
+ int ret;
+
+ ret = p2p_service_del_asp(wpa_s->global->p2p, adv_id);
+ if (ret == 0)
+ wpas_p2p_sd_service_update(wpa_s);
+ return ret;
+}
+
+
+int wpas_p2p_service_add_asp(struct wpa_supplicant *wpa_s,
+ int auto_accept, u32 adv_id,
+ const char *adv_str, u8 svc_state,
+ u16 config_methods, const char *svc_info,
+ const u8 *cpt_priority)
+{
+ int ret;
+
+ ret = p2p_service_add_asp(wpa_s->global->p2p, auto_accept, adv_id,
+ adv_str, svc_state, config_methods,
+ svc_info, cpt_priority);
+ if (ret == 0)
+ wpas_p2p_sd_service_update(wpa_s);
+ return ret;
+}
+
+
+void wpas_p2p_service_flush_asp(struct wpa_supplicant *wpa_s)
+{
+ p2p_service_flush_asp(wpa_s->global->p2p);
+}
+
+
+int wpas_p2p_service_add_bonjour(struct wpa_supplicant *wpa_s,
+ struct wpabuf *query, struct wpabuf *resp)
+{
+ struct p2p_srv_bonjour *bsrv;
+
+ bsrv = os_zalloc(sizeof(*bsrv));
+ if (bsrv == NULL)
+ return -1;
+ bsrv->query = query;
+ bsrv->resp = resp;
+ dl_list_add(&wpa_s->global->p2p_srv_bonjour, &bsrv->list);
+
+ wpas_p2p_sd_service_update(wpa_s);
+ return 0;
+}
+
+
+int wpas_p2p_service_del_bonjour(struct wpa_supplicant *wpa_s,
+ const struct wpabuf *query)
+{
+ struct p2p_srv_bonjour *bsrv;
+
+ bsrv = wpas_p2p_service_get_bonjour(wpa_s, query);
+ if (bsrv == NULL)
+ return -1;
+ wpas_p2p_srv_bonjour_free(bsrv);
+ wpas_p2p_sd_service_update(wpa_s);
+ return 0;
+}
+
+
+int wpas_p2p_service_add_upnp(struct wpa_supplicant *wpa_s, u8 version,
+ const char *service)
+{
+ struct p2p_srv_upnp *usrv;
+
+ if (wpas_p2p_service_get_upnp(wpa_s, version, service))
+ return 0; /* Already listed */
+ usrv = os_zalloc(sizeof(*usrv));
+ if (usrv == NULL)
+ return -1;
+ usrv->version = version;
+ usrv->service = os_strdup(service);
+ if (usrv->service == NULL) {
+ os_free(usrv);
+ return -1;
+ }
+ dl_list_add(&wpa_s->global->p2p_srv_upnp, &usrv->list);
+
+ wpas_p2p_sd_service_update(wpa_s);
+ return 0;
+}
+
+
+int wpas_p2p_service_del_upnp(struct wpa_supplicant *wpa_s, u8 version,
+ const char *service)
+{
+ struct p2p_srv_upnp *usrv;
+
+ usrv = wpas_p2p_service_get_upnp(wpa_s, version, service);
+ if (usrv == NULL)
+ return -1;
+ wpas_p2p_srv_upnp_free(usrv);
+ wpas_p2p_sd_service_update(wpa_s);
+ return 0;
+}
diff --git a/wpa_supplicant/preauth_test.c b/wpa_supplicant/preauth_test.c
index ed57085..f4bba98 100644
--- a/wpa_supplicant/preauth_test.c
+++ b/wpa_supplicant/preauth_test.c
@@ -27,7 +27,7 @@
#include "drivers/driver.h"
-struct wpa_driver_ops *wpa_drivers[] = { NULL };
+const struct wpa_driver_ops *const wpa_drivers[] = { NULL };
struct preauth_test_data {
diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c
index 805891a..d7049a1 100644
--- a/wpa_supplicant/scan.c
+++ b/wpa_supplicant/scan.c
@@ -418,22 +418,6 @@ static void wpa_supplicant_optimize_freqs(
static void wpas_add_interworking_elements(struct wpa_supplicant *wpa_s,
struct wpabuf *buf)
{
- if (wpa_s->conf->interworking == 0)
- return;
-
- wpabuf_put_u8(buf, WLAN_EID_EXT_CAPAB);
- wpabuf_put_u8(buf, 6);
- wpabuf_put_u8(buf, 0x00);
- wpabuf_put_u8(buf, 0x00);
- wpabuf_put_u8(buf, 0x00);
- wpabuf_put_u8(buf, 0x80); /* Bit 31 - Interworking */
- wpabuf_put_u8(buf, 0x00);
-#ifdef CONFIG_HS20
- wpabuf_put_u8(buf, 0x40); /* Bit 46 - WNM-Notification */
-#else /* CONFIG_HS20 */
- wpabuf_put_u8(buf, 0x00);
-#endif /* CONFIG_HS20 */
-
wpabuf_put_u8(buf, WLAN_EID_INTERWORKING);
wpabuf_put_u8(buf, is_zero_ether_addr(wpa_s->conf->hessid) ? 1 :
1 + ETH_ALEN);
@@ -448,11 +432,19 @@ static void wpas_add_interworking_elements(struct wpa_supplicant *wpa_s,
static struct wpabuf * wpa_supplicant_extra_ies(struct wpa_supplicant *wpa_s)
{
struct wpabuf *extra_ie = NULL;
+ u8 ext_capab[18];
+ int ext_capab_len;
#ifdef CONFIG_WPS
int wps = 0;
enum wps_request_type req_type = WPS_REQ_ENROLLEE_INFO;
#endif /* CONFIG_WPS */
+ ext_capab_len = wpas_build_ext_capab(wpa_s, ext_capab,
+ sizeof(ext_capab));
+ if (ext_capab_len > 0 &&
+ wpabuf_resize(&extra_ie, ext_capab_len) == 0)
+ wpabuf_put_data(extra_ie, ext_capab, ext_capab_len);
+
#ifdef CONFIG_INTERWORKING
if (wpa_s->conf->interworking &&
wpabuf_resize(&extra_ie, 100) == 0)
@@ -493,6 +485,12 @@ static struct wpabuf * wpa_supplicant_extra_ies(struct wpa_supplicant *wpa_s)
wpas_hs20_add_indication(extra_ie, -1);
#endif /* CONFIG_HS20 */
+#ifdef CONFIG_FST
+ if (wpa_s->fst_ies &&
+ wpabuf_resize(&extra_ie, wpabuf_len(wpa_s->fst_ies)) == 0)
+ wpabuf_put_buf(extra_ie, wpa_s->fst_ies);
+#endif /* CONFIG_FST */
+
return extra_ie;
}
@@ -622,6 +620,37 @@ static void wpa_set_scan_ssids(struct wpa_supplicant *wpa_s,
}
+static int wpa_set_ssids_from_scan_req(struct wpa_supplicant *wpa_s,
+ struct wpa_driver_scan_params *params,
+ size_t max_ssids)
+{
+ unsigned int i;
+
+ if (wpa_s->ssids_from_scan_req == NULL ||
+ wpa_s->num_ssids_from_scan_req == 0)
+ return 0;
+
+ if (wpa_s->num_ssids_from_scan_req > max_ssids) {
+ wpa_s->num_ssids_from_scan_req = max_ssids;
+ wpa_printf(MSG_DEBUG, "Over max scan SSIDs from scan req: %u",
+ (unsigned int) max_ssids);
+ }
+
+ for (i = 0; i < wpa_s->num_ssids_from_scan_req; i++) {
+ params->ssids[i].ssid = wpa_s->ssids_from_scan_req[i].ssid;
+ params->ssids[i].ssid_len =
+ wpa_s->ssids_from_scan_req[i].ssid_len;
+ wpa_hexdump_ascii(MSG_DEBUG, "specific SSID",
+ params->ssids[i].ssid,
+ params->ssids[i].ssid_len);
+ }
+
+ params->num_ssids = wpa_s->num_ssids_from_scan_req;
+ wpa_s->num_ssids_from_scan_req = 0;
+ return 1;
+}
+
+
static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx)
{
struct wpa_supplicant *wpa_s = eloop_ctx;
@@ -734,6 +763,12 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx)
goto scan;
}
+ if (wpa_s->last_scan_req == MANUAL_SCAN_REQ &&
+ wpa_set_ssids_from_scan_req(wpa_s, &params, max_ssids)) {
+ wpa_printf(MSG_DEBUG, "Use specific SSIDs from SCAN command");
+ goto ssid_list_set;
+ }
+
#ifdef CONFIG_P2P
if ((wpa_s->p2p_in_provisioning || wpa_s->show_group_started) &&
wpa_s->go_params && !wpa_s->conf->passive_scan) {
@@ -773,6 +808,9 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx)
}
if (wpa_s->last_scan_req != MANUAL_SCAN_REQ &&
+#ifdef CONFIG_AP
+ !wpa_s->ap_iface &&
+#endif /* CONFIG_AP */
wpa_s->conf->ap_scan == 2) {
wpa_s->connect_without_scan = NULL;
wpa_s->prev_scan_wildcard = 0;
@@ -899,10 +937,8 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx)
wpa_dbg(wpa_s, MSG_DEBUG, "Starting AP scan for wildcard "
"SSID");
}
-#ifdef CONFIG_P2P
-ssid_list_set:
-#endif /* CONFIG_P2P */
+ssid_list_set:
wpa_supplicant_optimize_freqs(wpa_s, &params);
extra_ie = wpa_supplicant_extra_ies(wpa_s);
@@ -1652,7 +1688,7 @@ static int wpa_scan_result_compar(const void *a, const void *b)
snr_a_full = wa->snr;
snr_a = MIN(wa->snr, GREAT_SNR);
snr_b_full = wb->snr;
- snr_b = MIN(wa->snr, GREAT_SNR);
+ snr_b = MIN(wb->snr, GREAT_SNR);
} else {
/* Level is not in dBm, so we can't calculate
* SNR. Just use raw level (units unknown). */
diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c
index 1788113..f2e5a43 100644
--- a/wpa_supplicant/sme.c
+++ b/wpa_supplicant/sme.c
@@ -67,7 +67,7 @@ static int sme_set_sae_group(struct wpa_supplicant *wpa_s)
for (;;) {
int group = groups[wpa_s->sme.sae_group_index];
- if (group < 0)
+ if (group <= 0)
break;
if (sae_set_group(&wpa_s->sme.sae, group) == 0) {
wpa_dbg(wpa_s, MSG_DEBUG, "SME: Selected SAE group %d",
@@ -438,6 +438,21 @@ static void sme_send_authentication(struct wpa_supplicant *wpa_s,
}
#endif /* CONFIG_HS20 */
+#ifdef CONFIG_FST
+ if (wpa_s->fst_ies) {
+ int fst_ies_len = wpabuf_len(wpa_s->fst_ies);
+
+ if (wpa_s->sme.assoc_req_ie_len + fst_ies_len <=
+ sizeof(wpa_s->sme.assoc_req_ie)) {
+ os_memcpy(wpa_s->sme.assoc_req_ie +
+ wpa_s->sme.assoc_req_ie_len,
+ wpabuf_head(wpa_s->fst_ies),
+ fst_ies_len);
+ wpa_s->sme.assoc_req_ie_len += fst_ies_len;
+ }
+ }
+#endif /* CONFIG_FST */
+
ext_capab_len = wpas_build_ext_capab(wpa_s, ext_capab,
sizeof(ext_capab));
if (ext_capab_len > 0) {
@@ -583,7 +598,8 @@ static void sme_auth_start_cb(struct wpa_radio_work *work, int deinit)
wpa_s->connect_work = work;
if (cwork->bss_removed ||
- !wpas_valid_bss_ssid(wpa_s, cwork->bss, cwork->ssid)) {
+ !wpas_valid_bss_ssid(wpa_s, cwork->bss, cwork->ssid) ||
+ wpas_network_disabled(wpa_s, cwork->ssid)) {
wpa_dbg(wpa_s, MSG_DEBUG, "SME: BSS/SSID entry for authentication not valid anymore - drop connection attempt");
wpas_connect_work_done(wpa_s);
return;
@@ -698,6 +714,8 @@ static int sme_sae_auth(struct wpa_supplicant *wpa_s, u16 auth_transaction,
return -1;
if (auth_transaction == 1) {
+ u16 res;
+
groups = wpa_s->conf->sae_groups;
wpa_dbg(wpa_s, MSG_DEBUG, "SME SAE commit");
@@ -708,8 +726,14 @@ static int sme_sae_auth(struct wpa_supplicant *wpa_s, u16 auth_transaction,
return -1;
if (groups && groups[0] <= 0)
groups = NULL;
- if (sae_parse_commit(&wpa_s->sme.sae, data, len, NULL, NULL,
- groups) != WLAN_STATUS_SUCCESS)
+ res = sae_parse_commit(&wpa_s->sme.sae, data, len, NULL, NULL,
+ groups);
+ if (res == SAE_SILENTLY_DISCARD) {
+ wpa_printf(MSG_DEBUG,
+ "SAE: Drop commit message due to reflection attack");
+ return 0;
+ }
+ if (res != WLAN_STATUS_SUCCESS)
return -1;
if (sae_process_commit(&wpa_s->sme.sae) < 0) {
@@ -793,8 +817,22 @@ void sme_event_auth(struct wpa_supplicant *wpa_s, union wpa_event_data *data)
#endif /* CONFIG_SAE */
if (data->auth.status_code != WLAN_STATUS_SUCCESS) {
- wpa_dbg(wpa_s, MSG_DEBUG, "SME: Authentication failed (status "
- "code %d)", data->auth.status_code);
+ char *ie_txt = NULL;
+
+ if (data->auth.ies && data->auth.ies_len) {
+ size_t buflen = 2 * data->auth.ies_len + 1;
+ ie_txt = os_malloc(buflen);
+ if (ie_txt) {
+ wpa_snprintf_hex(ie_txt, buflen, data->auth.ies,
+ data->auth.ies_len);
+ }
+ }
+ wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_AUTH_REJECT MACSTR
+ " auth_type=%u auth_transaction=%u status_code=%u ie=%s",
+ MAC2STR(data->auth.peer), data->auth.auth_type,
+ data->auth.auth_transaction, data->auth.status_code,
+ ie_txt);
+ os_free(ie_txt);
if (data->auth.status_code !=
WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG ||
@@ -831,12 +869,20 @@ void sme_event_auth(struct wpa_supplicant *wpa_s, union wpa_event_data *data)
#ifdef CONFIG_IEEE80211R
if (data->auth.auth_type == WLAN_AUTH_FT) {
- union wpa_event_data edata;
- os_memset(&edata, 0, sizeof(edata));
- edata.ft_ies.ies = data->auth.ies;
- edata.ft_ies.ies_len = data->auth.ies_len;
- os_memcpy(edata.ft_ies.target_ap, data->auth.peer, ETH_ALEN);
- wpa_supplicant_event(wpa_s, EVENT_FT_RESPONSE, &edata);
+ if (wpa_ft_process_response(wpa_s->wpa, data->auth.ies,
+ data->auth.ies_len, 0,
+ data->auth.peer, NULL, 0) < 0) {
+ wpa_dbg(wpa_s, MSG_DEBUG,
+ "SME: FT Authentication response processing failed");
+ wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DISCONNECTED "bssid="
+ MACSTR
+ " reason=%d locally_generated=1",
+ MAC2STR(wpa_s->pending_bssid),
+ WLAN_REASON_DEAUTH_LEAVING);
+ wpas_connection_failed(wpa_s, wpa_s->pending_bssid);
+ wpa_supplicant_mark_disassoc(wpa_s);
+ return;
+ }
}
#endif /* CONFIG_IEEE80211R */
diff --git a/wpa_supplicant/systemd/wpa_supplicant-nl80211.service.arg.in b/wpa_supplicant/systemd/wpa_supplicant-nl80211.service.arg.in
index bfdee25..03ac507 100644
--- a/wpa_supplicant/systemd/wpa_supplicant-nl80211.service.arg.in
+++ b/wpa_supplicant/systemd/wpa_supplicant-nl80211.service.arg.in
@@ -2,6 +2,8 @@
Description=WPA supplicant daemon (interface- and nl80211 driver-specific version)
Requires=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device
+Before=network.target
+Wants=network.target
# NetworkManager users will probably want the dbus version instead.
diff --git a/wpa_supplicant/systemd/wpa_supplicant-wired.service.arg.in b/wpa_supplicant/systemd/wpa_supplicant-wired.service.arg.in
index 20ba0ad..c8a744d 100644
--- a/wpa_supplicant/systemd/wpa_supplicant-wired.service.arg.in
+++ b/wpa_supplicant/systemd/wpa_supplicant-wired.service.arg.in
@@ -2,6 +2,8 @@
Description=WPA supplicant daemon (interface- and wired driver-specific version)
Requires=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device
+Before=network.target
+Wants=network.target
# NetworkManager users will probably want the dbus version instead.
diff --git a/wpa_supplicant/systemd/wpa_supplicant.service.arg.in b/wpa_supplicant/systemd/wpa_supplicant.service.arg.in
index 10e62bc..7788b38 100644
--- a/wpa_supplicant/systemd/wpa_supplicant.service.arg.in
+++ b/wpa_supplicant/systemd/wpa_supplicant.service.arg.in
@@ -2,6 +2,8 @@
Description=WPA supplicant daemon (interface-specific version)
Requires=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device
+Before=network.target
+Wants=network.target
# NetworkManager users will probably want the dbus version instead.
diff --git a/wpa_supplicant/systemd/wpa_supplicant.service.in b/wpa_supplicant/systemd/wpa_supplicant.service.in
index 4351ad8..ea964ce 100644
--- a/wpa_supplicant/systemd/wpa_supplicant.service.in
+++ b/wpa_supplicant/systemd/wpa_supplicant.service.in
@@ -1,5 +1,7 @@
[Unit]
Description=WPA supplicant
+Before=network.target
+Wants=network.target
[Service]
Type=dbus
diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c
index 5a0af0d..7ddae3d 100644
--- a/wpa_supplicant/wpa_cli.c
+++ b/wpa_supplicant/wpa_cli.c
@@ -26,16 +26,16 @@
#endif /* ANDROID */
-static const char *wpa_cli_version =
+static const char *const wpa_cli_version =
"wpa_cli v" VERSION_STR "\n"
"Copyright (c) 2004-2015, Jouni Malinen <j@w1.fi> and contributors";
-static const char *wpa_cli_license =
+static const char *const wpa_cli_license =
"This software may be distributed under the terms of the BSD license.\n"
"See README for more details.\n";
-static const char *wpa_cli_full_license =
+static const char *const wpa_cli_full_license =
"This software may be distributed under the terms of the BSD license.\n"
"\n"
"Redistribution and use in source and binary forms, with or without\n"
@@ -76,6 +76,7 @@ static int wpa_cli_last_id = 0;
#define CONFIG_CTRL_IFACE_DIR "/var/run/wpa_supplicant"
#endif /* CONFIG_CTRL_IFACE_DIR */
static const char *ctrl_iface_dir = CONFIG_CTRL_IFACE_DIR;
+static const char *client_socket_dir = NULL;
static char *ctrl_ifname = NULL;
static const char *pid_file = NULL;
static const char *action_file = NULL;
@@ -92,6 +93,7 @@ static DEFINE_DL_LIST(bsses); /* struct cli_txt_entry */
static DEFINE_DL_LIST(p2p_peers); /* struct cli_txt_entry */
static DEFINE_DL_LIST(p2p_groups); /* struct cli_txt_entry */
static DEFINE_DL_LIST(ifnames); /* struct cli_txt_entry */
+static DEFINE_DL_LIST(networks); /* struct cli_txt_entry */
static void print_help(const char *cmd);
@@ -99,13 +101,16 @@ static void wpa_cli_mon_receive(int sock, void *eloop_ctx, void *sock_ctx);
static void wpa_cli_close_connection(void);
static char * wpa_cli_get_default_ifname(void);
static char ** wpa_list_cmd_list(void);
+static void update_networks(struct wpa_ctrl *ctrl);
static void usage(void)
{
printf("wpa_cli [-p<path to ctrl sockets>] [-i<ifname>] [-hvB] "
"[-a<action file>] \\\n"
- " [-P<pid file>] [-g<global ctrl>] [-G<ping interval>] "
+ " [-P<pid file>] [-g<global ctrl>] [-G<ping interval>] "
+ "\\\n"
+ " [-s<wpa_client_socket_file_path>] "
"[command..]\n"
" -h = help (show this usage text)\n"
" -v = shown version information\n"
@@ -168,11 +173,12 @@ static void cli_txt_list_del_addr(struct dl_list *txt_list, const char *txt)
#ifdef CONFIG_P2P
-static void cli_txt_list_del_word(struct dl_list *txt_list, const char *txt)
+static void cli_txt_list_del_word(struct dl_list *txt_list, const char *txt,
+ int separator)
{
const char *end;
char *buf;
- end = os_strchr(txt, ' ');
+ end = os_strchr(txt, separator);
if (end == NULL)
end = txt + os_strlen(txt);
buf = dup_binstr(txt, end - txt);
@@ -213,14 +219,16 @@ static int cli_txt_list_add_addr(struct dl_list *txt_list, const char *txt)
os_snprintf(buf, sizeof(buf), MACSTR, MAC2STR(addr));
return cli_txt_list_add(txt_list, buf);
}
+#endif /* CONFIG_P2P */
-static int cli_txt_list_add_word(struct dl_list *txt_list, const char *txt)
+static int cli_txt_list_add_word(struct dl_list *txt_list, const char *txt,
+ int separator)
{
const char *end;
char *buf;
int ret;
- end = os_strchr(txt, ' ');
+ end = os_strchr(txt, separator);
if (end == NULL)
end = txt + os_strlen(txt);
buf = dup_binstr(txt, end - txt);
@@ -230,7 +238,6 @@ static int cli_txt_list_add_word(struct dl_list *txt_list, const char *txt)
os_free(buf);
return ret;
}
-#endif /* CONFIG_P2P */
static char ** cli_txt_list_array(struct dl_list *txt_list)
@@ -326,6 +333,13 @@ static int wpa_cli_open_connection(const char *ifname, int attach)
}
#endif /* ANDROID */
+ if (client_socket_dir && client_socket_dir[0] &&
+ access(client_socket_dir, F_OK) < 0) {
+ perror(client_socket_dir);
+ os_free(cfile);
+ return -1;
+ }
+
if (cfile == NULL) {
flen = os_strlen(ctrl_iface_dir) + os_strlen(ifname) + 2;
cfile = os_malloc(flen);
@@ -339,14 +353,14 @@ static int wpa_cli_open_connection(const char *ifname, int attach)
}
}
- ctrl_conn = wpa_ctrl_open(cfile);
+ ctrl_conn = wpa_ctrl_open2(cfile, client_socket_dir);
if (ctrl_conn == NULL) {
os_free(cfile);
return -1;
}
if (attach && interactive)
- mon_conn = wpa_ctrl_open(cfile);
+ mon_conn = wpa_ctrl_open2(cfile, client_socket_dir);
else
mon_conn = NULL;
os_free(cfile);
@@ -498,6 +512,10 @@ static int wpa_cli_cmd_status(struct wpa_ctrl *ctrl, int argc, char *argv[])
return wpa_ctrl_command(ctrl, "STATUS-WPS");
if (argc > 0 && os_strcmp(argv[0], "driver") == 0)
return wpa_ctrl_command(ctrl, "STATUS-DRIVER");
+#ifdef ANDROID
+ if (argc > 0 && os_strcmp(argv[0], "no_events") == 0)
+ return wpa_ctrl_command(ctrl, "STATUS-NO_EVENTS");
+#endif /* ANDROID */
return wpa_ctrl_command(ctrl, "STATUS");
}
@@ -608,35 +626,58 @@ static char ** wpa_cli_complete_set(const char *str, int pos)
"uapsd", "ps", "wifi_display", "bssid_filter", "disallow_aps",
"no_keep_alive",
/* global configuration parameters */
- "eapol_version", "ap_scan", "disable_scan_offload",
- "fast_reauth", "opensc_engine_path", "pkcs11_engine_path",
- "pkcs11_module_path", "openssl_ciphers",
- "pcsc_reader", "pcsc_pin",
- "driver_param", "dot11RSNAConfigPMKLifetime",
+#ifdef CONFIG_CTRL_IFACE
+ "ctrl_interface", "no_ctrl_interface", "ctrl_interface_group",
+#endif /* CONFIG_CTRL_IFACE */
+ "eapol_version", "ap_scan", "bgscan",
+#ifdef CONFIG_MESH
+ "user_mpm", "max_peer_links", "mesh_max_inactivity",
+ "dot11RSNASAERetransPeriod",
+#endif /* CONFIG_MESH */
+ "disable_scan_offload", "fast_reauth", "opensc_engine_path",
+ "pkcs11_engine_path", "pkcs11_module_path", "openssl_ciphers",
+ "pcsc_reader", "pcsc_pin", "external_sim", "driver_param",
+ "dot11RSNAConfigPMKLifetime",
"dot11RSNAConfigPMKReauthThreshold",
"dot11RSNAConfigSATimeout",
- "update_config", "load_dynamic_eap", "uuid", "device_name",
- "manufacturer", "model_name", "model_number", "serial_number",
- "device_type", "os_version", "config_methods",
- "wps_cred_processing", "wps_vendor_ext_m1", "sec_device_type",
+#ifndef CONFIG_NO_CONFIG_WRITE
+ "update_config",
+#endif /* CONFIG_NO_CONFIG_WRITE */
+ "load_dynamic_eap",
+#ifdef CONFIG_WPS
+ "uuid", "device_name", "manufacturer", "model_name",
+ "model_number", "serial_number", "device_type", "os_version",
+ "config_methods", "wps_cred_processing", "wps_vendor_ext_m1",
+#endif /* CONFIG_WPS */
+#ifdef CONFIG_P2P
+ "sec_device_type",
"p2p_listen_reg_class", "p2p_listen_channel",
- "p2p_oper_reg_class", "p2p_oper_channel",
- "p2p_go_intent", "p2p_ssid_postfix", "persistent_reconnect",
- "p2p_intra_bss", "p2p_group_idle", "p2p_pref_chan",
- "p2p_no_go_freq",
- "p2p_go_ht40", "p2p_disabled", "p2p_no_group_iface",
- "p2p_go_vht",
- "p2p_ignore_shared_freq", "country", "bss_max_count",
- "bss_expiration_age", "bss_expiration_scan_count",
- "filter_ssids", "filter_rssi", "max_num_sta",
- "disassoc_low_ack", "hs20", "interworking", "hessid",
- "access_network_type", "pbc_in_m1", "autoscan",
- "wps_nfc_dev_pw_id", "wps_nfc_dh_pubkey", "wps_nfc_dh_privkey",
- "wps_nfc_dev_pw", "ext_password_backend",
+ "p2p_oper_reg_class", "p2p_oper_channel", "p2p_go_intent",
+ "p2p_ssid_postfix", "persistent_reconnect", "p2p_intra_bss",
+ "p2p_group_idle", "p2p_passphrase_len", "p2p_pref_chan",
+ "p2p_no_go_freq", "p2p_add_cli_chan",
+ "p2p_optimize_listen_chan", "p2p_go_ht40", "p2p_go_vht",
+ "p2p_disabled", "p2p_go_ctwindow", "p2p_no_group_iface",
+ "p2p_ignore_shared_freq", "ip_addr_go", "ip_addr_mask",
+ "ip_addr_start", "ip_addr_end",
+#endif /* CONFIG_P2P */
+ "country", "bss_max_count", "bss_expiration_age",
+ "bss_expiration_scan_count", "filter_ssids", "filter_rssi",
+ "max_num_sta", "disassoc_low_ack",
+#ifdef CONFIG_HS20
+ "hs20",
+#endif /* CONFIG_HS20 */
+ "interworking", "hessid", "access_network_type", "pbc_in_m1",
+ "autoscan", "wps_nfc_dev_pw_id", "wps_nfc_dh_pubkey",
+ "wps_nfc_dh_privkey", "wps_nfc_dev_pw", "ext_password_backend",
"p2p_go_max_inactivity", "auto_interworking", "okc", "pmf",
- "sae_groups", "dtim_period", "beacon_int", "ap_vendor_elements",
- "ignore_old_scan_res", "freq_list", "external_sim",
- "tdls_external_control", "p2p_search_delay"
+ "sae_groups", "dtim_period", "beacon_int",
+ "ap_vendor_elements", "ignore_old_scan_res", "freq_list",
+ "scan_cur_freq", "sched_scan_interval",
+ "tdls_external_control", "osu_dir", "wowlan_triggers",
+ "p2p_search_delay", "mac_addr", "rand_addr_lifetime",
+ "preassoc_mac_addr", "key_mgmt_offload", "passive_scan",
+ "reassoc_same_bss_optim", "wps_priority"
};
int i, num_fields = ARRAY_SIZE(fields);
@@ -670,6 +711,74 @@ static int wpa_cli_cmd_get(struct wpa_ctrl *ctrl, int argc, char *argv[])
}
+static char ** wpa_cli_complete_get(const char *str, int pos)
+{
+ int arg = get_cmd_arg_num(str, pos);
+ const char *fields[] = {
+#ifdef CONFIG_CTRL_IFACE
+ "ctrl_interface", "ctrl_interface_group",
+#endif /* CONFIG_CTRL_IFACE */
+ "eapol_version", "ap_scan",
+#ifdef CONFIG_MESH
+ "user_mpm", "max_peer_links", "mesh_max_inactivity",
+#endif /* CONFIG_MESH */
+ "disable_scan_offload", "fast_reauth", "opensc_engine_path",
+ "pkcs11_engine_path", "pkcs11_module_path", "openssl_ciphers",
+ "pcsc_reader", "pcsc_pin", "external_sim", "driver_param",
+ "dot11RSNAConfigPMKLifetime",
+ "dot11RSNAConfigPMKReauthThreshold",
+ "dot11RSNAConfigSATimeout",
+#ifndef CONFIG_NO_CONFIG_WRITE
+ "update_config",
+#endif /* CONFIG_NO_CONFIG_WRITE */
+#ifdef CONFIG_WPS
+ "device_name", "manufacturer", "model_name", "model_number",
+ "serial_number", "config_methods", "wps_cred_processing",
+#endif /* CONFIG_WPS */
+#ifdef CONFIG_P2P
+ "p2p_listen_reg_class", "p2p_listen_channel",
+ "p2p_oper_reg_class", "p2p_oper_channel", "p2p_go_intent",
+ "p2p_ssid_postfix", "persistent_reconnect", "p2p_intra_bss",
+ "p2p_group_idle", "p2p_passphrase_len", "p2p_add_cli_chan",
+ "p2p_optimize_listen_chan", "p2p_go_ht40", "p2p_go_vht",
+ "p2p_disabled", "p2p_go_ctwindow", "p2p_no_group_iface",
+ "p2p_ignore_shared_freq", "ip_addr_go", "ip_addr_mask",
+ "ip_addr_start", "ip_addr_end",
+#endif /* CONFIG_P2P */
+ "bss_max_count", "bss_expiration_age",
+ "bss_expiration_scan_count", "filter_ssids", "filter_rssi",
+ "max_num_sta", "disassoc_low_ack",
+#ifdef CONFIG_HS20
+ "hs20",
+#endif /* CONFIG_HS20 */
+ "interworking", "access_network_type", "pbc_in_m1", "autoscan",
+ "wps_nfc_dev_pw_id", "ext_password_backend",
+ "p2p_go_max_inactivity", "auto_interworking", "okc", "pmf",
+ "dtim_period", "beacon_int", "ignore_old_scan_res",
+ "scan_cur_freq", "sched_scan_interval",
+ "tdls_external_control", "osu_dir", "wowlan_triggers",
+ "p2p_search_delay", "mac_addr", "rand_addr_lifetime",
+ "preassoc_mac_addr", "key_mgmt_offload", "passive_scan",
+ "reassoc_same_bss_optim"
+ };
+ int i, num_fields = ARRAY_SIZE(fields);
+
+ if (arg == 1) {
+ char **res = os_calloc(num_fields + 1, sizeof(char *));
+ if (res == NULL)
+ return NULL;
+ for (i = 0; i < num_fields; i++) {
+ res[i] = os_strdup(fields[i]);
+ if (res[i] == NULL)
+ return res;
+ }
+ return res;
+ }
+
+ return NULL;
+}
+
+
static int wpa_cli_cmd_logoff(struct wpa_ctrl *ctrl, int argc, char *argv[])
{
return wpa_ctrl_command(ctrl, "LOGOFF");
@@ -873,12 +982,12 @@ static int wpa_cli_cmd_wps_reg(struct wpa_ctrl *ctrl, int argc, char *argv[])
res = os_snprintf(cmd, sizeof(cmd), "WPS_REG %s %s",
argv[0], argv[1]);
else if (argc == 5 || argc == 6) {
- char ssid_hex[2 * 32 + 1];
+ char ssid_hex[2 * SSID_MAX_LEN + 1];
char key_hex[2 * 64 + 1];
int i;
ssid_hex[0] = '\0';
- for (i = 0; i < 32; i++) {
+ for (i = 0; i < SSID_MAX_LEN; i++) {
if (argv[2][i] == '\0')
break;
os_snprintf(&ssid_hex[i * 2], 3, "%02x", argv[2][i]);
@@ -1002,12 +1111,12 @@ static int wpa_cli_cmd_wps_er_config(struct wpa_ctrl *ctrl, int argc,
int res;
if (argc == 5 || argc == 6) {
- char ssid_hex[2 * 32 + 1];
+ char ssid_hex[2 * SSID_MAX_LEN + 1];
char key_hex[2 * 64 + 1];
int i;
ssid_hex[0] = '\0';
- for (i = 0; i < 32; i++) {
+ for (i = 0; i < SSID_MAX_LEN; i++) {
if (argv[2][i] == '\0')
break;
os_snprintf(&ssid_hex[i * 2], 3, "%02x", argv[2][i]);
@@ -1361,14 +1470,20 @@ static int wpa_cli_cmd_disable_network(struct wpa_ctrl *ctrl, int argc,
static int wpa_cli_cmd_add_network(struct wpa_ctrl *ctrl, int argc,
char *argv[])
{
- return wpa_ctrl_command(ctrl, "ADD_NETWORK");
+ int res = wpa_ctrl_command(ctrl, "ADD_NETWORK");
+ if (interactive)
+ update_networks(ctrl);
+ return res;
}
static int wpa_cli_cmd_remove_network(struct wpa_ctrl *ctrl, int argc,
char *argv[])
{
- return wpa_cli_cmd(ctrl, "REMOVE_NETWORK", 1, argc, argv);
+ int res = wpa_cli_cmd(ctrl, "REMOVE_NETWORK", 1, argc, argv);
+ if (interactive)
+ update_networks(ctrl);
+ return res;
}
@@ -1429,6 +1544,105 @@ static int wpa_cli_cmd_get_network(struct wpa_ctrl *ctrl, int argc,
}
+static const char *network_fields[] = {
+ "ssid", "scan_ssid", "bssid", "bssid_blacklist",
+ "bssid_whitelist", "psk", "proto", "key_mgmt",
+ "bg_scan_period", "pairwise", "group", "auth_alg", "scan_freq",
+ "freq_list",
+#ifdef IEEE8021X_EAPOL
+ "eap", "identity", "anonymous_identity", "password", "ca_cert",
+ "ca_path", "client_cert", "private_key", "private_key_passwd",
+ "dh_file", "subject_match", "altsubject_match",
+ "domain_suffix_match", "domain_match", "ca_cert2", "ca_path2",
+ "client_cert2", "private_key2", "private_key2_passwd",
+ "dh_file2", "subject_match2", "altsubject_match2",
+ "domain_suffix_match2", "domain_match2", "phase1", "phase2",
+ "pcsc", "pin", "engine_id", "key_id", "cert_id", "ca_cert_id",
+ "pin2", "engine2_id", "key2_id", "cert2_id", "ca_cert2_id",
+ "engine", "engine2", "eapol_flags", "sim_num",
+ "openssl_ciphers", "erp",
+#endif /* IEEE8021X_EAPOL */
+ "wep_key0", "wep_key1", "wep_key2", "wep_key3",
+ "wep_tx_keyidx", "priority",
+#ifdef IEEE8021X_EAPOL
+ "eap_workaround", "pac_file", "fragment_size", "ocsp",
+#endif /* IEEE8021X_EAPOL */
+#ifdef CONFIG_MESH
+ "mode", "no_auto_peer",
+#else /* CONFIG_MESH */
+ "mode",
+#endif /* CONFIG_MESH */
+ "proactive_key_caching", "disabled", "id_str",
+#ifdef CONFIG_IEEE80211W
+ "ieee80211w",
+#endif /* CONFIG_IEEE80211W */
+ "peerkey", "mixed_cell", "frequency", "fixed_freq",
+#ifdef CONFIG_MESH
+ "mesh_basic_rates", "dot11MeshMaxRetries",
+ "dot11MeshRetryTimeout", "dot11MeshConfirmTimeout",
+ "dot11MeshHoldingTimeout",
+#endif /* CONFIG_MESH */
+ "wpa_ptk_rekey", "bgscan", "ignore_broadcast_ssid",
+#ifdef CONFIG_P2P
+ "go_p2p_dev_addr", "p2p_client_list", "psk_list",
+#endif /* CONFIG_P2P */
+#ifdef CONFIG_HT_OVERRIDES
+ "disable_ht", "disable_ht40", "disable_sgi", "disable_ldpc",
+ "ht40_intolerant", "disable_max_amsdu", "ampdu_factor",
+ "ampdu_density", "ht_mcs",
+#endif /* CONFIG_HT_OVERRIDES */
+#ifdef CONFIG_VHT_OVERRIDES
+ "disable_vht", "vht_capa", "vht_capa_mask", "vht_rx_mcs_nss_1",
+ "vht_rx_mcs_nss_2", "vht_rx_mcs_nss_3", "vht_rx_mcs_nss_4",
+ "vht_rx_mcs_nss_5", "vht_rx_mcs_nss_6", "vht_rx_mcs_nss_7",
+ "vht_rx_mcs_nss_8", "vht_tx_mcs_nss_1", "vht_tx_mcs_nss_2",
+ "vht_tx_mcs_nss_3", "vht_tx_mcs_nss_4", "vht_tx_mcs_nss_5",
+ "vht_tx_mcs_nss_6", "vht_tx_mcs_nss_7", "vht_tx_mcs_nss_8",
+#endif /* CONFIG_VHT_OVERRIDES */
+ "ap_max_inactivity", "dtim_period", "beacon_int",
+#ifdef CONFIG_MACSEC
+ "macsec_policy",
+#endif /* CONFIG_MACSEC */
+#ifdef CONFIG_HS20
+ "update_identifier",
+#endif /* CONFIG_HS20 */
+ "mac_addr"
+};
+
+
+static char ** wpa_cli_complete_network(const char *str, int pos)
+{
+ int arg = get_cmd_arg_num(str, pos);
+ int i, num_fields = ARRAY_SIZE(network_fields);
+ char **res = NULL;
+
+ switch (arg) {
+ case 1:
+ res = cli_txt_list_array(&networks);
+ break;
+ case 2:
+ res = os_calloc(num_fields + 1, sizeof(char *));
+ if (res == NULL)
+ return NULL;
+ for (i = 0; i < num_fields; i++) {
+ res[i] = os_strdup(network_fields[i]);
+ if (res[i] == NULL)
+ break;
+ }
+ }
+ return res;
+}
+
+
+static char ** wpa_cli_complete_network_id(const char *str, int pos)
+{
+ int arg = get_cmd_arg_num(str, pos);
+ if (arg == 1)
+ return cli_txt_list_array(&networks);
+ return NULL;
+}
+
+
static int wpa_cli_cmd_dup_network(struct wpa_ctrl *ctrl, int argc,
char *argv[])
{
@@ -1447,6 +1661,31 @@ static int wpa_cli_cmd_dup_network(struct wpa_ctrl *ctrl, int argc,
}
+static char ** wpa_cli_complete_dup_network(const char *str, int pos)
+{
+ int arg = get_cmd_arg_num(str, pos);
+ int i, num_fields = ARRAY_SIZE(network_fields);
+ char **res = NULL;
+
+ switch (arg) {
+ case 1:
+ case 2:
+ res = cli_txt_list_array(&networks);
+ break;
+ case 3:
+ res = os_calloc(num_fields + 1, sizeof(char *));
+ if (res == NULL)
+ return NULL;
+ for (i = 0; i < num_fields; i++) {
+ res[i] = os_strdup(network_fields[i]);
+ if (res[i] == NULL)
+ break;
+ }
+ }
+ return res;
+}
+
+
static int wpa_cli_cmd_list_creds(struct wpa_ctrl *ctrl, int argc,
char *argv[])
{
@@ -1621,20 +1860,20 @@ static int wpa_cli_cmd_interface_add(struct wpa_ctrl *ctrl, int argc,
printf("Invalid INTERFACE_ADD command: needs at least one "
"argument (interface name)\n"
"All arguments: ifname confname driver ctrl_interface "
- "driver_param bridge_name\n");
+ "driver_param bridge_name [create]\n");
return -1;
}
/*
* INTERFACE_ADD <ifname>TAB<confname>TAB<driver>TAB<ctrl_interface>TAB
- * <driver_param>TAB<bridge_name>
+ * <driver_param>TAB<bridge_name>[TAB<create>]
*/
res = os_snprintf(cmd, sizeof(cmd),
- "INTERFACE_ADD %s\t%s\t%s\t%s\t%s\t%s",
+ "INTERFACE_ADD %s\t%s\t%s\t%s\t%s\t%s\t%s",
argv[0],
argc > 1 ? argv[1] : "", argc > 2 ? argv[2] : "",
argc > 3 ? argv[3] : "", argc > 4 ? argv[4] : "",
- argc > 5 ? argv[5] : "");
+ argc > 5 ? argv[5] : "", argc > 6 ? argv[6] : "");
if (os_snprintf_error(sizeof(cmd), res))
return -1;
cmd[sizeof(cmd) - 1] = '\0';
@@ -2431,6 +2670,13 @@ static int wpa_cli_cmd_tdls_teardown(struct wpa_ctrl *ctrl, int argc,
}
+static int wpa_cli_cmd_tdls_link_status(struct wpa_ctrl *ctrl, int argc,
+ char *argv[])
+{
+ return wpa_cli_cmd(ctrl, "TDLS_LINK_STATUS", 1, argc, argv);
+}
+
+
static int wpa_cli_cmd_wmm_ac_addts(struct wpa_ctrl *ctrl, int argc,
char *argv[])
{
@@ -2570,6 +2816,13 @@ static int wpa_cli_cmd_mac_rand_scan(struct wpa_ctrl *ctrl, int argc,
}
+static int wpa_cli_cmd_get_pref_freq_list(struct wpa_ctrl *ctrl, int argc,
+ char *argv[])
+{
+ return wpa_cli_cmd(ctrl, "GET_PREF_FREQ_LIST", 1, argc, argv);
+}
+
+
enum wpa_cli_cmd_flags {
cli_cmd_flag_none = 0x00,
cli_cmd_flag_sensitive = 0x01
@@ -2583,7 +2836,7 @@ struct wpa_cli_cmd {
const char *usage;
};
-static struct wpa_cli_cmd wpa_cli_commands[] = {
+static const struct wpa_cli_cmd wpa_cli_commands[] = {
{ "status", wpa_cli_cmd_status, NULL,
cli_cmd_flag_none,
"[verbose] = get current WPA/EAPOL/EAP status" },
@@ -2624,7 +2877,7 @@ static struct wpa_cli_cmd wpa_cli_commands[] = {
{ "dump", wpa_cli_cmd_dump, NULL,
cli_cmd_flag_none,
"= dump config variables" },
- { "get", wpa_cli_cmd_get, NULL,
+ { "get", wpa_cli_cmd_get, wpa_cli_complete_get,
cli_cmd_flag_none,
"<name> = get information" },
{ "logon", wpa_cli_cmd_logon, NULL,
@@ -2686,29 +2939,33 @@ static struct wpa_cli_cmd wpa_cli_commands[] = {
{ "list_networks", wpa_cli_cmd_list_networks, NULL,
cli_cmd_flag_none,
"= list configured networks" },
- { "select_network", wpa_cli_cmd_select_network, NULL,
+ { "select_network", wpa_cli_cmd_select_network,
+ wpa_cli_complete_network_id,
cli_cmd_flag_none,
"<network id> = select a network (disable others)" },
- { "enable_network", wpa_cli_cmd_enable_network, NULL,
+ { "enable_network", wpa_cli_cmd_enable_network,
+ wpa_cli_complete_network_id,
cli_cmd_flag_none,
"<network id> = enable a network" },
- { "disable_network", wpa_cli_cmd_disable_network, NULL,
+ { "disable_network", wpa_cli_cmd_disable_network,
+ wpa_cli_complete_network_id,
cli_cmd_flag_none,
"<network id> = disable a network" },
{ "add_network", wpa_cli_cmd_add_network, NULL,
cli_cmd_flag_none,
"= add a network" },
- { "remove_network", wpa_cli_cmd_remove_network, NULL,
+ { "remove_network", wpa_cli_cmd_remove_network,
+ wpa_cli_complete_network_id,
cli_cmd_flag_none,
"<network id> = remove a network" },
- { "set_network", wpa_cli_cmd_set_network, NULL,
+ { "set_network", wpa_cli_cmd_set_network, wpa_cli_complete_network,
cli_cmd_flag_sensitive,
"<network id> <variable> <value> = set network variables (shows\n"
" list of variables when run without arguments)" },
- { "get_network", wpa_cli_cmd_get_network, NULL,
+ { "get_network", wpa_cli_cmd_get_network, wpa_cli_complete_network,
cli_cmd_flag_none,
"<network id> <variable> = get network variables" },
- { "dup_network", wpa_cli_cmd_dup_network, NULL,
+ { "dup_network", wpa_cli_cmd_dup_network, wpa_cli_complete_dup_network,
cli_cmd_flag_none,
"<src network id> <dst network id> <variable> = duplicate network variables"
},
@@ -2750,7 +3007,7 @@ static struct wpa_cli_cmd wpa_cli_commands[] = {
{ "get_capability", wpa_cli_cmd_get_capability, NULL,
cli_cmd_flag_none,
"<eap/pairwise/group/key_mgmt/proto/auth_alg/channels/freq/modes> "
- "= get capabilies" },
+ "= get capabilities" },
{ "reconfigure", wpa_cli_cmd_reconfigure, NULL,
cli_cmd_flag_none,
"= force wpa_supplicant to re-read its configuration file" },
@@ -3054,6 +3311,9 @@ static struct wpa_cli_cmd wpa_cli_commands[] = {
{ "tdls_teardown", wpa_cli_cmd_tdls_teardown, NULL,
cli_cmd_flag_none,
"<addr> = tear down TDLS with <addr>" },
+ { "tdls_link_status", wpa_cli_cmd_tdls_link_status, NULL,
+ cli_cmd_flag_none,
+ "<addr> = TDLS link status with <addr>" },
{ "wmm_ac_addts", wpa_cli_cmd_wmm_ac_addts, NULL,
cli_cmd_flag_none,
"<uplink/downlink/bidi> <tsid=0..7> <up=0..7> [nominal_msdu_size=#] "
@@ -3117,6 +3377,9 @@ static struct wpa_cli_cmd wpa_cli_commands[] = {
"<scan|sched|pno|all> enable=<0/1> [addr=mac-address "
"mask=mac-address-mask] = scan MAC randomization"
},
+ { "get_pref_freq_list", wpa_cli_cmd_get_pref_freq_list, NULL,
+ cli_cmd_flag_none,
+ "<interface type> = retrieve preferred freq list for the specified interface type" },
{ NULL, NULL, NULL, cli_cmd_flag_none, NULL }
};
@@ -3124,7 +3387,7 @@ static struct wpa_cli_cmd wpa_cli_commands[] = {
/*
* Prints command usage, lines are padded with the specified string.
*/
-static void print_cmd_help(struct wpa_cli_cmd *cmd, const char *pad)
+static void print_cmd_help(const struct wpa_cli_cmd *cmd, const char *pad)
{
char c;
size_t n;
@@ -3262,7 +3525,7 @@ static char ** wpa_cli_edit_completion_cb(void *ctx, const char *str, int pos)
static int wpa_request(struct wpa_ctrl *ctrl, int argc, char *argv[])
{
- struct wpa_cli_cmd *cmd, *match = NULL;
+ const struct wpa_cli_cmd *cmd, *match = NULL;
int count;
int ret = 0;
@@ -3347,6 +3610,9 @@ static void wpa_cli_action_process(const char *msg)
const char *ifname = ctrl_ifname;
char ifname_buf[100];
+ if (eloop_terminated())
+ return;
+
pos = msg;
if (os_strncmp(pos, "IFNAME=", 7) == 0) {
const char *end;
@@ -3524,7 +3790,7 @@ static void cli_event(const char *str)
s = os_strchr(start, ' ');
if (s == NULL)
return;
- cli_txt_list_add_word(&p2p_groups, s + 1);
+ cli_txt_list_add_word(&p2p_groups, s + 1, ' ');
return;
}
@@ -3532,7 +3798,7 @@ static void cli_event(const char *str)
s = os_strchr(start, ' ');
if (s == NULL)
return;
- cli_txt_list_del_word(&p2p_groups, s + 1);
+ cli_txt_list_del_word(&p2p_groups, s + 1, ' ');
return;
}
#endif /* CONFIG_P2P */
@@ -3691,7 +3957,11 @@ static void start_edit(void)
ps = wpa_ctrl_get_remote_ifname(ctrl_conn);
#endif /* CONFIG_CTRL_IFACE_UDP_REMOTE */
+#ifdef CONFIG_WPA_CLI_HISTORY_DIR
+ home = CONFIG_WPA_CLI_HISTORY_DIR;
+#else /* CONFIG_WPA_CLI_HISTORY_DIR */
home = getenv("HOME");
+#endif /* CONFIG_WPA_CLI_HISTORY_DIR */
if (home) {
const char *fname = ".wpa_cli_history";
int hfile_len = os_strlen(home) + 1 + os_strlen(fname) + 1;
@@ -3774,6 +4044,38 @@ static void update_ifnames(struct wpa_ctrl *ctrl)
}
+static void update_networks(struct wpa_ctrl *ctrl)
+{
+ char buf[4096];
+ size_t len = sizeof(buf);
+ int ret;
+ char *cmd = "LIST_NETWORKS";
+ char *pos, *end;
+ int header = 1;
+
+ cli_txt_list_flush(&networks);
+
+ if (ctrl == NULL)
+ return;
+ ret = wpa_ctrl_request(ctrl, cmd, os_strlen(cmd), buf, &len, NULL);
+ if (ret < 0)
+ return;
+ buf[len] = '\0';
+
+ pos = buf;
+ while (pos) {
+ end = os_strchr(pos, '\n');
+ if (end == NULL)
+ break;
+ *end = '\0';
+ if (!header)
+ cli_txt_list_add_word(&networks, pos, '\t');
+ header = 0;
+ pos = end + 1;
+ }
+}
+
+
static void try_connection(void *eloop_ctx, void *timeout_ctx)
{
if (ctrl_conn)
@@ -3794,6 +4096,7 @@ static void try_connection(void *eloop_ctx, void *timeout_ctx)
}
update_bssid_list(ctrl_conn);
+ update_networks(ctrl_conn);
if (warning_displayed)
printf("Connection established.\n");
@@ -3815,6 +4118,7 @@ static void wpa_cli_interactive(void)
cli_txt_list_flush(&p2p_groups);
cli_txt_list_flush(&bsses);
cli_txt_list_flush(&ifnames);
+ cli_txt_list_flush(&networks);
if (edit_started)
edit_deinit(hfile, wpa_cli_edit_filter_history_cb);
os_free(hfile);
@@ -3823,45 +4127,49 @@ static void wpa_cli_interactive(void)
}
+static void wpa_cli_action_ping(void *eloop_ctx, void *timeout_ctx)
+{
+ struct wpa_ctrl *ctrl = eloop_ctx;
+ char buf[256];
+ size_t len;
+
+ /* verify that connection is still working */
+ len = sizeof(buf) - 1;
+ if (wpa_ctrl_request(ctrl, "PING", 4, buf, &len,
+ wpa_cli_action_cb) < 0 ||
+ len < 4 || os_memcmp(buf, "PONG", 4) != 0) {
+ printf("wpa_supplicant did not reply to PING command - exiting\n");
+ eloop_terminate();
+ return;
+ }
+ eloop_register_timeout(ping_interval, 0, wpa_cli_action_ping,
+ ctrl, NULL);
+}
+
+
+static void wpa_cli_action_receive(int sock, void *eloop_ctx, void *sock_ctx)
+{
+ struct wpa_ctrl *ctrl = eloop_ctx;
+
+ wpa_cli_recv_pending(ctrl, 1);
+}
+
+
static void wpa_cli_action(struct wpa_ctrl *ctrl)
{
#ifdef CONFIG_ANSI_C_EXTRA
/* TODO: ANSI C version(?) */
printf("Action processing not supported in ANSI C build.\n");
#else /* CONFIG_ANSI_C_EXTRA */
- fd_set rfds;
- int fd, res;
- struct timeval tv;
- char buf[256]; /* note: large enough to fit in unsolicited messages */
- size_t len;
+ int fd;
fd = wpa_ctrl_get_fd(ctrl);
-
- while (!wpa_cli_quit) {
- FD_ZERO(&rfds);
- FD_SET(fd, &rfds);
- tv.tv_sec = ping_interval;
- tv.tv_usec = 0;
- res = select(fd + 1, &rfds, NULL, NULL, &tv);
- if (res < 0 && errno != EINTR) {
- perror("select");
- break;
- }
-
- if (FD_ISSET(fd, &rfds))
- wpa_cli_recv_pending(ctrl, 1);
- else {
- /* verify that connection is still working */
- len = sizeof(buf) - 1;
- if (wpa_ctrl_request(ctrl, "PING", 4, buf, &len,
- wpa_cli_action_cb) < 0 ||
- len < 4 || os_memcmp(buf, "PONG", 4) != 0) {
- printf("wpa_supplicant did not reply to PING "
- "command - exiting\n");
- break;
- }
- }
- }
+ eloop_register_timeout(ping_interval, 0, wpa_cli_action_ping,
+ ctrl, NULL);
+ eloop_register_read_sock(fd, wpa_cli_action_receive, ctrl, NULL);
+ eloop_run();
+ eloop_cancel_timeout(wpa_cli_action_ping, ctrl, NULL);
+ eloop_unregister_read_sock(fd);
#endif /* CONFIG_ANSI_C_EXTRA */
}
@@ -3886,18 +4194,17 @@ static char * wpa_cli_get_default_ifname(void)
{
char *ifname = NULL;
+#ifdef ANDROID
+ char ifprop[PROPERTY_VALUE_MAX];
+ if (property_get("wifi.interface", ifprop, NULL) != 0) {
+ ifname = os_strdup(ifprop);
+ printf("Using interface '%s'\n", ifname ? ifname : "N/A");
+ }
+#else /* ANDROID */
#ifdef CONFIG_CTRL_IFACE_UNIX
struct dirent *dent;
DIR *dir = opendir(ctrl_iface_dir);
if (!dir) {
-#ifdef ANDROID
- char ifprop[PROPERTY_VALUE_MAX];
- if (property_get("wifi.interface", ifprop, NULL) != 0) {
- ifname = os_strdup(ifprop);
- printf("Using interface '%s'\n", ifname);
- return ifname;
- }
-#endif /* ANDROID */
return NULL;
}
while ((dent = readdir(dir))) {
@@ -3941,6 +4248,7 @@ static char * wpa_cli_get_default_ifname(void)
}
wpa_ctrl_close(ctrl);
#endif /* CONFIG_CTRL_IFACE_NAMED_PIPE */
+#endif /* ANDROID */
return ifname;
}
@@ -3957,7 +4265,7 @@ int main(int argc, char *argv[])
return -1;
for (;;) {
- c = getopt(argc, argv, "a:Bg:G:hi:p:P:v");
+ c = getopt(argc, argv, "a:Bg:G:hi:p:P:s:v");
if (c < 0)
break;
switch (c) {
@@ -3989,6 +4297,9 @@ int main(int argc, char *argv[])
case 'P':
pid_file = optarg;
break;
+ case 's':
+ client_socket_dir = optarg;
+ break;
default:
usage();
return -1;
diff --git a/wpa_supplicant/wpa_gui-qt4/addinterface.cpp b/wpa_supplicant/wpa_gui-qt4/addinterface.cpp
index 27cbdd6..7d92f63 100644
--- a/wpa_supplicant/wpa_gui-qt4/addinterface.cpp
+++ b/wpa_supplicant/wpa_gui-qt4/addinterface.cpp
@@ -41,8 +41,8 @@ AddInterface::AddInterface(WpaGui *_wpagui, QWidget *parent)
interfaceWidget->headerItem()->setText(0, tr("driver"));
interfaceWidget->headerItem()->setText(1, tr("interface"));
interfaceWidget->headerItem()->setText(2, tr("description"));
- interfaceWidget->setItemsExpandable(FALSE);
- interfaceWidget->setRootIsDecorated(FALSE);
+ interfaceWidget->setItemsExpandable(false);
+ interfaceWidget->setRootIsDecorated(false);
vboxLayout->addWidget(interfaceWidget);
connect(interfaceWidget,
@@ -196,9 +196,9 @@ void AddInterface::interfaceSelected(QTreeWidgetItem *sel)
*/
snprintf(cmd, sizeof(cmd),
"INTERFACE_ADD %s\t%s\t%s\t%s\t%s\t%s",
- sel->text(1).toAscii().constData(),
+ sel->text(1).toLocal8Bit().constData(),
"default",
- sel->text(0).toAscii().constData(),
+ sel->text(0).toLocal8Bit().constData(),
"yes", "", "");
cmd[sizeof(cmd) - 1] = '\0';
diff --git a/wpa_supplicant/wpa_gui-qt4/addinterface.h b/wpa_supplicant/wpa_gui-qt4/addinterface.h
index 1b4c98d..332fc71 100644
--- a/wpa_supplicant/wpa_gui-qt4/addinterface.h
+++ b/wpa_supplicant/wpa_gui-qt4/addinterface.h
@@ -11,9 +11,9 @@
#include <QObject>
-#include <QtGui/QDialog>
-#include <QtGui/QTreeWidget>
-#include <QtGui/QVBoxLayout>
+#include <QDialog>
+#include <QTreeWidget>
+#include <QVBoxLayout>
class WpaGui;
diff --git a/wpa_supplicant/wpa_gui-qt4/eventhistory.cpp b/wpa_supplicant/wpa_gui-qt4/eventhistory.cpp
index a36085d..09145cd 100644
--- a/wpa_supplicant/wpa_gui-qt4/eventhistory.cpp
+++ b/wpa_supplicant/wpa_gui-qt4/eventhistory.cpp
@@ -73,15 +73,15 @@ void EventListModel::addEvent(QString time, QString msg)
}
-EventHistory::EventHistory(QWidget *parent, const char *, bool, Qt::WFlags)
+EventHistory::EventHistory(QWidget *parent, const char *, bool, Qt::WindowFlags)
: QDialog(parent)
{
setupUi(this);
connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
- eventListView->setItemsExpandable(FALSE);
- eventListView->setRootIsDecorated(FALSE);
+ eventListView->setItemsExpandable(false);
+ eventListView->setRootIsDecorated(false);
elm = new EventListModel(parent);
eventListView->setModel(elm);
}
diff --git a/wpa_supplicant/wpa_gui-qt4/eventhistory.h b/wpa_supplicant/wpa_gui-qt4/eventhistory.h
index 3c01aa8..afd7b63 100644
--- a/wpa_supplicant/wpa_gui-qt4/eventhistory.h
+++ b/wpa_supplicant/wpa_gui-qt4/eventhistory.h
@@ -40,7 +40,7 @@ class EventHistory : public QDialog, public Ui::EventHistory
public:
EventHistory(QWidget *parent = 0, const char *name = 0,
- bool modal = false, Qt::WFlags fl = 0);
+ bool modal = false, Qt::WindowFlags fl = 0);
~EventHistory();
public slots:
diff --git a/wpa_supplicant/wpa_gui-qt4/main.cpp b/wpa_supplicant/wpa_gui-qt4/main.cpp
index 73d677c..bbd45c6 100644
--- a/wpa_supplicant/wpa_gui-qt4/main.cpp
+++ b/wpa_supplicant/wpa_gui-qt4/main.cpp
@@ -14,24 +14,15 @@
#include <QtCore/QTranslator>
#include "wpagui.h"
-
-class WpaGuiApp : public QApplication
-{
-public:
- WpaGuiApp(int &argc, char **argv);
-
-#ifndef QT_NO_SESSIONMANAGER
- virtual void saveState(QSessionManager &manager);
-#endif
-
- WpaGui *w;
-};
-
-WpaGuiApp::WpaGuiApp(int &argc, char **argv) : QApplication(argc, argv)
+WpaGuiApp::WpaGuiApp(int &argc, char **argv) :
+ QApplication(argc, argv),
+ argc(argc),
+ argv(argv)
{
+ w = NULL;
}
-#ifndef QT_NO_SESSIONMANAGER
+#if !defined(QT_NO_SESSIONMANAGER) && QT_VERSION < 0x050000
void WpaGuiApp::saveState(QSessionManager &manager)
{
QApplication::saveState(manager);
diff --git a/wpa_supplicant/wpa_gui-qt4/networkconfig.cpp b/wpa_supplicant/wpa_gui-qt4/networkconfig.cpp
index 737c41c..2727318 100644
--- a/wpa_supplicant/wpa_gui-qt4/networkconfig.cpp
+++ b/wpa_supplicant/wpa_gui-qt4/networkconfig.cpp
@@ -26,7 +26,8 @@ enum {
#define WPA_GUI_KEY_DATA "[key is configured]"
-NetworkConfig::NetworkConfig(QWidget *parent, const char *, bool, Qt::WFlags)
+NetworkConfig::NetworkConfig(QWidget *parent, const char *, bool,
+ Qt::WindowFlags)
: QDialog(parent)
{
setupUi(this);
@@ -237,7 +238,7 @@ void NetworkConfig::addNetwork()
} else
id = edit_network_id;
- setNetworkParam(id, "ssid", ssidEdit->text().toAscii().constData(),
+ setNetworkParam(id, "ssid", ssidEdit->text().toLocal8Bit().constData(),
true);
const char *key_mgmt = NULL, *proto = NULL, *pairwise = NULL;
@@ -291,14 +292,14 @@ void NetworkConfig::addNetwork()
setNetworkParam(id, "group", "TKIP CCMP WEP104 WEP40", false);
}
if (pskEdit->isEnabled() &&
- strcmp(pskEdit->text().toAscii().constData(),
+ strcmp(pskEdit->text().toLocal8Bit().constData(),
WPA_GUI_KEY_DATA) != 0)
setNetworkParam(id, "psk",
- pskEdit->text().toAscii().constData(),
+ pskEdit->text().toLocal8Bit().constData(),
psklen != 64);
if (eapSelect->isEnabled()) {
const char *eap =
- eapSelect->currentText().toAscii().constData();
+ eapSelect->currentText().toLocal8Bit().constData();
setNetworkParam(id, "eap", eap, false);
if (strcmp(eap, "SIM") == 0 || strcmp(eap, "AKA") == 0)
setNetworkParam(id, "pcsc", "", true);
@@ -314,21 +315,21 @@ void NetworkConfig::addNetwork()
if (inner.startsWith("EAP-"))
snprintf(phase2, sizeof(phase2), "auth=%s",
inner.right(inner.size() - 4).
- toAscii().constData());
+ toLocal8Bit().constData());
} else if (eap.compare("TTLS") == 0) {
if (inner.startsWith("EAP-"))
snprintf(phase2, sizeof(phase2), "autheap=%s",
inner.right(inner.size() - 4).
- toAscii().constData());
+ toLocal8Bit().constData());
else
snprintf(phase2, sizeof(phase2), "auth=%s",
- inner.toAscii().constData());
+ inner.toLocal8Bit().constData());
} else if (eap.compare("FAST") == 0) {
const char *provisioning = NULL;
if (inner.startsWith("EAP-")) {
snprintf(phase2, sizeof(phase2), "auth=%s",
inner.right(inner.size() - 4).
- toAscii().constData());
+ toLocal8Bit().constData());
provisioning = "fast_provisioning=2";
} else if (inner.compare("GTC(auth) + MSCHAPv2(prov)")
== 0) {
@@ -354,21 +355,21 @@ void NetworkConfig::addNetwork()
setNetworkParam(id, "phase2", "NULL", false);
if (identityEdit->isEnabled() && identityEdit->text().length() > 0)
setNetworkParam(id, "identity",
- identityEdit->text().toAscii().constData(),
+ identityEdit->text().toLocal8Bit().constData(),
true);
else
setNetworkParam(id, "identity", "NULL", false);
if (passwordEdit->isEnabled() && passwordEdit->text().length() > 0 &&
- strcmp(passwordEdit->text().toAscii().constData(),
+ strcmp(passwordEdit->text().toLocal8Bit().constData(),
WPA_GUI_KEY_DATA) != 0)
setNetworkParam(id, "password",
- passwordEdit->text().toAscii().constData(),
+ passwordEdit->text().toLocal8Bit().constData(),
true);
else if (passwordEdit->text().length() == 0)
setNetworkParam(id, "password", "NULL", false);
if (cacertEdit->isEnabled() && cacertEdit->text().length() > 0)
setNetworkParam(id, "ca_cert",
- cacertEdit->text().toAscii().constData(),
+ cacertEdit->text().toLocal8Bit().constData(),
true);
else
setNetworkParam(id, "ca_cert", "NULL", false);
@@ -388,7 +389,7 @@ void NetworkConfig::addNetwork()
if (idstrEdit->isEnabled() && idstrEdit->text().length() > 0)
setNetworkParam(id, "id_str",
- idstrEdit->text().toAscii().constData(),
+ idstrEdit->text().toLocal8Bit().constData(),
true);
else
setNetworkParam(id, "id_str", "NULL", false);
@@ -396,7 +397,7 @@ void NetworkConfig::addNetwork()
if (prioritySpinBox->isEnabled()) {
QString prio;
prio = prio.setNum(prioritySpinBox->value());
- setNetworkParam(id, "priority", prio.toAscii().constData(),
+ setNetworkParam(id, "priority", prio.toLocal8Bit().constData(),
false);
}
@@ -468,7 +469,7 @@ void NetworkConfig::writeWepKey(int network_id, QLineEdit *edit, int id)
* Assume hex key if only hex characters are present and length matches
* with 40, 104, or 128-bit key
*/
- txt = edit->text().toAscii().constData();
+ txt = edit->text().toLocal8Bit().constData();
if (strcmp(txt, WPA_GUI_KEY_DATA) == 0)
return;
len = strlen(txt);
diff --git a/wpa_supplicant/wpa_gui-qt4/networkconfig.h b/wpa_supplicant/wpa_gui-qt4/networkconfig.h
index 429b648..fd09dec 100644
--- a/wpa_supplicant/wpa_gui-qt4/networkconfig.h
+++ b/wpa_supplicant/wpa_gui-qt4/networkconfig.h
@@ -20,7 +20,7 @@ class NetworkConfig : public QDialog, public Ui::NetworkConfig
public:
NetworkConfig(QWidget *parent = 0, const char *name = 0,
- bool modal = false, Qt::WFlags fl = 0);
+ bool modal = false, Qt::WindowFlags fl = 0);
~NetworkConfig();
virtual void paramsFromScanResults(QTreeWidgetItem *sel);
diff --git a/wpa_supplicant/wpa_gui-qt4/peers.cpp b/wpa_supplicant/wpa_gui-qt4/peers.cpp
index f5aa9f7..3bcf2f5 100644
--- a/wpa_supplicant/wpa_gui-qt4/peers.cpp
+++ b/wpa_supplicant/wpa_gui-qt4/peers.cpp
@@ -62,7 +62,7 @@ enum peer_type {
};
-Peers::Peers(QWidget *parent, const char *, bool, Qt::WFlags)
+Peers::Peers(QWidget *parent, const char *, bool, Qt::WindowFlags)
: QDialog(parent)
{
setupUi(this);
@@ -323,13 +323,13 @@ void Peers::enter_pin()
if (peer_type == PEER_TYPE_WPS_ER_ENROLLEE) {
snprintf(cmd, sizeof(cmd), "WPS_ER_PIN %s %s %s",
- uuid.toAscii().constData(),
- input.get_string().toAscii().constData(),
- addr.toAscii().constData());
+ uuid.toLocal8Bit().constData(),
+ input.get_string().toLocal8Bit().constData(),
+ addr.toLocal8Bit().constData());
} else {
snprintf(cmd, sizeof(cmd), "WPS_PIN %s %s",
- addr.toAscii().constData(),
- input.get_string().toAscii().constData());
+ addr.toLocal8Bit().constData(),
+ input.get_string().toLocal8Bit().constData());
}
reply_len = sizeof(reply) - 1;
if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0) {
@@ -868,7 +868,7 @@ void Peers::event_notify(WpaMsg msg)
QStandardItem *item = find_addr(addr);
if (item == NULL || item->data(peer_role_type).toInt() !=
PEER_TYPE_ASSOCIATED_STATION)
- add_single_station(addr.toAscii().constData());
+ add_single_station(addr.toLocal8Bit().constData());
return;
}
@@ -1350,8 +1350,8 @@ void Peers::ctx_p2p_connect()
char reply[100];
size_t reply_len;
snprintf(cmd, sizeof(cmd), "P2P_CONNECT %s %s display",
- addr.toAscii().constData(),
- arg.toAscii().constData());
+ addr.toLocal8Bit().constData(),
+ arg.toLocal8Bit().constData());
reply_len = sizeof(reply) - 1;
if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0) {
QMessageBox msg;
@@ -1384,8 +1384,8 @@ void Peers::ctx_p2p_connect()
char reply[100];
size_t reply_len;
snprintf(cmd, sizeof(cmd), "P2P_CONNECT %s %s",
- addr.toAscii().constData(),
- arg.toAscii().constData());
+ addr.toLocal8Bit().constData(),
+ arg.toLocal8Bit().constData());
reply_len = sizeof(reply) - 1;
if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0) {
QMessageBox msg;
@@ -1408,7 +1408,7 @@ void Peers::ctx_p2p_req_pin()
char reply[100];
size_t reply_len;
snprintf(cmd, sizeof(cmd), "P2P_PROV_DISC %s display",
- addr.toAscii().constData());
+ addr.toLocal8Bit().constData());
reply_len = sizeof(reply) - 1;
if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0) {
QMessageBox msg;
@@ -1431,7 +1431,7 @@ void Peers::ctx_p2p_show_pin()
char reply[100];
size_t reply_len;
snprintf(cmd, sizeof(cmd), "P2P_PROV_DISC %s keypad",
- addr.toAscii().constData());
+ addr.toLocal8Bit().constData());
reply_len = sizeof(reply) - 1;
if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0) {
QMessageBox msg;
@@ -1452,7 +1452,7 @@ void Peers::ctx_p2p_display_pin()
char reply[100];
size_t reply_len;
snprintf(cmd, sizeof(cmd), "P2P_CONNECT %s pin",
- addr.toAscii().constData());
+ addr.toLocal8Bit().constData());
reply_len = sizeof(reply) - 1;
if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0) {
QMessageBox msg;
@@ -1480,8 +1480,8 @@ void Peers::ctx_p2p_display_pin_pd()
char reply[100];
size_t reply_len;
snprintf(cmd, sizeof(cmd), "P2P_CONNECT %s %s display",
- addr.toAscii().constData(),
- arg.toAscii().constData());
+ addr.toLocal8Bit().constData(),
+ arg.toLocal8Bit().constData());
reply_len = sizeof(reply) - 1;
if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0) {
QMessageBox msg;
@@ -1515,8 +1515,8 @@ void Peers::ctx_p2p_enter_pin()
char reply[100];
size_t reply_len;
snprintf(cmd, sizeof(cmd), "P2P_CONNECT %s %s keypad",
- addr.toAscii().constData(),
- arg.toAscii().constData());
+ addr.toLocal8Bit().constData(),
+ arg.toLocal8Bit().constData());
reply_len = sizeof(reply) - 1;
if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0) {
QMessageBox msg;
@@ -1535,7 +1535,7 @@ void Peers::ctx_p2p_remove_group()
char reply[100];
size_t reply_len;
snprintf(cmd, sizeof(cmd), "P2P_GROUP_REMOVE %s",
- ctx_item->data(peer_role_ifname).toString().toAscii().
+ ctx_item->data(peer_role_ifname).toString().toLocal8Bit().
constData());
reply_len = sizeof(reply) - 1;
if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0) {
@@ -1713,13 +1713,13 @@ void Peers::connect_pbc()
int peer_type = ctx_item->data(peer_role_type).toInt();
if (peer_type == PEER_TYPE_WPS_ER_ENROLLEE) {
snprintf(cmd, sizeof(cmd), "WPS_ER_PBC %s",
- ctx_item->data(peer_role_uuid).toString().toAscii().
+ ctx_item->data(peer_role_uuid).toString().toLocal8Bit().
constData());
} else if (peer_type == PEER_TYPE_P2P ||
peer_type == PEER_TYPE_P2P_CLIENT) {
snprintf(cmd, sizeof(cmd), "P2P_CONNECT %s pbc",
ctx_item->data(peer_role_address).toString().
- toAscii().constData());
+ toLocal8Bit().constData());
} else {
snprintf(cmd, sizeof(cmd), "WPS_PBC");
}
@@ -1750,8 +1750,8 @@ void Peers::learn_ap_config()
size_t reply_len;
snprintf(cmd, sizeof(cmd), "WPS_ER_LEARN %s %s",
- uuid.toAscii().constData(),
- input.get_string().toAscii().constData());
+ uuid.toLocal8Bit().constData(),
+ input.get_string().toLocal8Bit().constData());
reply_len = sizeof(reply) - 1;
if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0) {
QMessageBox msg;
diff --git a/wpa_supplicant/wpa_gui-qt4/peers.h b/wpa_supplicant/wpa_gui-qt4/peers.h
index bac77dc..bb73737 100644
--- a/wpa_supplicant/wpa_gui-qt4/peers.h
+++ b/wpa_supplicant/wpa_gui-qt4/peers.h
@@ -22,7 +22,7 @@ class Peers : public QDialog, public Ui::Peers
public:
Peers(QWidget *parent = 0, const char *name = 0,
- bool modal = false, Qt::WFlags fl = 0);
+ bool modal = false, Qt::WindowFlags fl = 0);
~Peers();
void setWpaGui(WpaGui *_wpagui);
void event_notify(WpaMsg msg);
diff --git a/wpa_supplicant/wpa_gui-qt4/scanresults.cpp b/wpa_supplicant/wpa_gui-qt4/scanresults.cpp
index ae0c240..a2e3072 100644
--- a/wpa_supplicant/wpa_gui-qt4/scanresults.cpp
+++ b/wpa_supplicant/wpa_gui-qt4/scanresults.cpp
@@ -15,7 +15,7 @@
#include "scanresultsitem.h"
-ScanResults::ScanResults(QWidget *parent, const char *, bool, Qt::WFlags)
+ScanResults::ScanResults(QWidget *parent, const char *, bool, Qt::WindowFlags)
: QDialog(parent)
{
setupUi(this);
@@ -27,8 +27,8 @@ ScanResults::ScanResults(QWidget *parent, const char *, bool, Qt::WFlags)
SLOT(bssSelected(QTreeWidgetItem *)));
wpagui = NULL;
- scanResultsWidget->setItemsExpandable(FALSE);
- scanResultsWidget->setRootIsDecorated(FALSE);
+ scanResultsWidget->setItemsExpandable(false);
+ scanResultsWidget->setRootIsDecorated(false);
scanResultsWidget->setItemDelegate(new SignalBar(scanResultsWidget));
}
diff --git a/wpa_supplicant/wpa_gui-qt4/scanresults.h b/wpa_supplicant/wpa_gui-qt4/scanresults.h
index 4a5842c..2cddd13 100644
--- a/wpa_supplicant/wpa_gui-qt4/scanresults.h
+++ b/wpa_supplicant/wpa_gui-qt4/scanresults.h
@@ -20,7 +20,7 @@ class ScanResults : public QDialog, public Ui::ScanResults
public:
ScanResults(QWidget *parent = 0, const char *name = 0,
- bool modal = false, Qt::WFlags fl = 0);
+ bool modal = false, Qt::WindowFlags fl = 0);
~ScanResults();
public slots:
diff --git a/wpa_supplicant/wpa_gui-qt4/scanresultsitem.h b/wpa_supplicant/wpa_gui-qt4/scanresultsitem.h
index 835b7c0..74887ee 100644
--- a/wpa_supplicant/wpa_gui-qt4/scanresultsitem.h
+++ b/wpa_supplicant/wpa_gui-qt4/scanresultsitem.h
@@ -9,7 +9,7 @@
#ifndef SCANRESULTSITEM_H
#define SCANRESULTSITEM_H
-#include <QtGui>
+#include <QTreeWidgetItem>
class ScanResultsItem : public QTreeWidgetItem
{
diff --git a/wpa_supplicant/wpa_gui-qt4/userdatarequest.cpp b/wpa_supplicant/wpa_gui-qt4/userdatarequest.cpp
index ba4c9f4..9d933b0 100644
--- a/wpa_supplicant/wpa_gui-qt4/userdatarequest.cpp
+++ b/wpa_supplicant/wpa_gui-qt4/userdatarequest.cpp
@@ -12,7 +12,7 @@
UserDataRequest::UserDataRequest(QWidget *parent, const char *, bool,
- Qt::WFlags)
+ Qt::WindowFlags)
: QDialog(parent)
{
setupUi(this);
@@ -89,6 +89,6 @@ void UserDataRequest::sendReply()
QString cmd = QString(WPA_CTRL_RSP) + field + '-' +
QString::number(networkid) + ':' +
queryEdit->text();
- wpagui->ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
+ wpagui->ctrlRequest(cmd.toLocal8Bit().constData(), reply, &reply_len);
accept();
}
diff --git a/wpa_supplicant/wpa_gui-qt4/userdatarequest.h b/wpa_supplicant/wpa_gui-qt4/userdatarequest.h
index 0d9dbfc..b6d1ad2 100644
--- a/wpa_supplicant/wpa_gui-qt4/userdatarequest.h
+++ b/wpa_supplicant/wpa_gui-qt4/userdatarequest.h
@@ -20,7 +20,7 @@ class UserDataRequest : public QDialog, public Ui::UserDataRequest
public:
UserDataRequest(QWidget *parent = 0, const char *name = 0,
- bool modal = false, Qt::WFlags fl = 0);
+ bool modal = false, Qt::WindowFlags fl = 0);
~UserDataRequest();
int setParams(WpaGui *_wpagui, const char *reqMsg);
diff --git a/wpa_supplicant/wpa_gui-qt4/wpa_gui.pro b/wpa_supplicant/wpa_gui-qt4/wpa_gui.pro
index 69bc0f6..3fa734b 100644
--- a/wpa_supplicant/wpa_gui-qt4/wpa_gui.pro
+++ b/wpa_supplicant/wpa_gui-qt4/wpa_gui.pro
@@ -1,6 +1,7 @@
TEMPLATE = app
LANGUAGE = C++
TRANSLATIONS = lang/wpa_gui_de.ts
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += qt warn_on release
diff --git a/wpa_supplicant/wpa_gui-qt4/wpagui.cpp b/wpa_supplicant/wpa_gui-qt4/wpagui.cpp
index bc6fa7f..a0aa05e 100644
--- a/wpa_supplicant/wpa_gui-qt4/wpagui.cpp
+++ b/wpa_supplicant/wpa_gui-qt4/wpagui.cpp
@@ -31,7 +31,8 @@
#endif
-WpaGui::WpaGui(QApplication *_app, QWidget *parent, const char *, Qt::WFlags)
+WpaGui::WpaGui(QApplication *_app, QWidget *parent, const char *,
+ Qt::WindowFlags)
: QMainWindow(parent), app(_app)
{
setupUi(this);
@@ -135,6 +136,7 @@ WpaGui::WpaGui(QApplication *_app, QWidget *parent, const char *, Qt::WFlags)
monitor_conn = NULL;
msgNotifier = NULL;
ctrl_iface_dir = strdup("/var/run/wpa_supplicant");
+ signalMeterInterval = 0;
parse_argv();
@@ -158,9 +160,13 @@ WpaGui::WpaGui(QApplication *_app, QWidget *parent, const char *, Qt::WFlags)
textStatus->setText(tr("connecting to wpa_supplicant"));
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), SLOT(ping()));
- timer->setSingleShot(FALSE);
+ timer->setSingleShot(false);
timer->start(1000);
+ signalMeterTimer = new QTimer(this);
+ signalMeterTimer->setInterval(signalMeterInterval);
+ connect(signalMeterTimer, SIGNAL(timeout()), SLOT(signalMeterUpdate()));
+
if (openCtrlConnection(ctrl_iface) < 0) {
debug("Failed to open control connection to "
"wpa_supplicant.");
@@ -233,8 +239,9 @@ void WpaGui::languageChange()
void WpaGui::parse_argv()
{
int c;
+ WpaGuiApp *app = qobject_cast<WpaGuiApp*>(qApp);
for (;;) {
- c = getopt(qApp->argc(), qApp->argv(), "i:p:tq");
+ c = getopt(app->argc, app->argv, "i:m:p:tq");
if (c < 0)
break;
switch (c) {
@@ -242,6 +249,9 @@ void WpaGui::parse_argv()
free(ctrl_iface);
ctrl_iface = strdup(optarg);
break;
+ case 'm':
+ signalMeterInterval = atoi(optarg) * 1000;
+ break;
case 'p':
free(ctrl_iface_dir);
ctrl_iface_dir = strdup(optarg);
@@ -496,6 +506,8 @@ void WpaGui::updateStatus()
textBssid->clear();
textIpAddress->clear();
updateTrayToolTip(tr("no status information"));
+ updateTrayIcon(TrayIconOffline);
+ signalMeterTimer->stop();
#ifdef CONFIG_NATIVE_WINDOWS
static bool first = true;
@@ -544,6 +556,11 @@ void WpaGui::updateStatus()
ssid_updated = true;
textSsid->setText(pos);
updateTrayToolTip(pos + tr(" (associated)"));
+ if (!signalMeterInterval) {
+ /* if signal meter is not enabled show
+ * full signal strength */
+ updateTrayIcon(TrayIconSignalExcellent);
+ }
} else if (strcmp(start, "ip_address") == 0) {
ipaddr_updated = true;
textIpAddress->setText(pos);
@@ -587,6 +604,23 @@ void WpaGui::updateStatus()
} else
textEncryption->clear();
+ if (signalMeterInterval) {
+ /*
+ * Handle signal meter service. When network is not associated,
+ * deactivate timer, otherwise keep it going. Tray icon has to
+ * be initialized here, because of the initial delay of the
+ * timer.
+ */
+ if (ssid_updated) {
+ if (!signalMeterTimer->isActive()) {
+ updateTrayIcon(TrayIconConnected);
+ signalMeterTimer->start();
+ }
+ } else {
+ signalMeterTimer->stop();
+ }
+ }
+
if (!status_updated)
textStatus->clear();
if (!auth_updated)
@@ -594,6 +628,7 @@ void WpaGui::updateStatus()
if (!ssid_updated) {
textSsid->clear();
updateTrayToolTip(tr("(not-associated)"));
+ updateTrayIcon(TrayIconOffline);
}
if (!bssid_updated)
textBssid->clear();
@@ -604,7 +639,7 @@ void WpaGui::updateStatus()
void WpaGui::updateNetworks()
{
- char buf[2048], *start, *end, *id, *ssid, *bssid, *flags;
+ char buf[4096], *start, *end, *id, *ssid, *bssid, *flags;
size_t len;
int first_active = -1;
int was_selected = -1;
@@ -717,7 +752,7 @@ void WpaGui::helpContents()
void WpaGui::helpAbout()
{
QMessageBox::about(this, "wpa_gui for wpa_supplicant",
- "Copyright (c) 2003-2013,\n"
+ "Copyright (c) 2003-2015,\n"
"Jouni Malinen <j@w1.fi>\n"
"and contributors.\n"
"\n"
@@ -828,6 +863,53 @@ void WpaGui::ping()
}
+void WpaGui::signalMeterUpdate()
+{
+ char reply[128];
+ size_t reply_len = sizeof(reply);
+ char *rssi;
+ int rssi_value;
+
+ ctrlRequest("SIGNAL_POLL", reply, &reply_len);
+
+ /* In order to eliminate signal strength fluctuations, try
+ * to obtain averaged RSSI value in the first place. */
+ if ((rssi = strstr(reply, "AVG_RSSI=")) != NULL)
+ rssi_value = atoi(&rssi[sizeof("AVG_RSSI")]);
+ else if ((rssi = strstr(reply, "RSSI=")) != NULL)
+ rssi_value = atoi(&rssi[sizeof("RSSI")]);
+ else {
+ debug("Failed to get RSSI value");
+ updateTrayIcon(TrayIconSignalNone);
+ return;
+ }
+
+ debug("RSSI value: %d", rssi_value);
+
+ /*
+ * NOTE: The code below assumes, that the unit of the value returned
+ * by the SIGNAL POLL request is dBm. It might not be true for all
+ * wpa_supplicant drivers.
+ */
+
+ /*
+ * Calibration is based on "various Internet sources". Nonetheless,
+ * it seems to be compatible with the Windows 8.1 strength meter -
+ * tested on Intel Centrino Advanced-N 6235.
+ */
+ if (rssi_value >= -60)
+ updateTrayIcon(TrayIconSignalExcellent);
+ else if (rssi_value >= -68)
+ updateTrayIcon(TrayIconSignalGood);
+ else if (rssi_value >= -76)
+ updateTrayIcon(TrayIconSignalOk);
+ else if (rssi_value >= -84)
+ updateTrayIcon(TrayIconSignalWeak);
+ else
+ updateTrayIcon(TrayIconSignalNone);
+}
+
+
static int str_match(const char *a, const char *b)
{
return strncmp(a, b, strlen(b)) == 0;
@@ -986,7 +1068,7 @@ void WpaGui::selectNetwork( const QString &sel )
else
cmd = "any";
cmd.prepend("SELECT_NETWORK ");
- ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
+ ctrlRequest(cmd.toLocal8Bit().constData(), reply, &reply_len);
triggerUpdate();
stopWpsRun(false);
}
@@ -1002,11 +1084,11 @@ void WpaGui::enableNetwork(const QString &sel)
cmd.truncate(cmd.indexOf(':'));
else if (!cmd.startsWith("all")) {
debug("Invalid editNetwork '%s'",
- cmd.toAscii().constData());
+ cmd.toLocal8Bit().constData());
return;
}
cmd.prepend("ENABLE_NETWORK ");
- ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
+ ctrlRequest(cmd.toLocal8Bit().constData(), reply, &reply_len);
triggerUpdate();
}
@@ -1021,11 +1103,11 @@ void WpaGui::disableNetwork(const QString &sel)
cmd.truncate(cmd.indexOf(':'));
else if (!cmd.startsWith("all")) {
debug("Invalid editNetwork '%s'",
- cmd.toAscii().constData());
+ cmd.toLocal8Bit().constData());
return;
}
cmd.prepend("DISABLE_NETWORK ");
- ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
+ ctrlRequest(cmd.toLocal8Bit().constData(), reply, &reply_len);
triggerUpdate();
}
@@ -1111,11 +1193,11 @@ void WpaGui::removeNetwork(const QString &sel)
cmd.truncate(cmd.indexOf(':'));
else if (!cmd.startsWith("all")) {
debug("Invalid editNetwork '%s'",
- cmd.toAscii().constData());
+ cmd.toLocal8Bit().constData());
return;
}
cmd.prepend("REMOVE_NETWORK ");
- ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
+ ctrlRequest(cmd.toLocal8Bit().constData(), reply, &reply_len);
triggerUpdate();
}
@@ -1175,14 +1257,14 @@ int WpaGui::getNetworkDisabled(const QString &sel)
int pos = cmd.indexOf(':');
if (pos < 0) {
debug("Invalid getNetworkDisabled '%s'",
- cmd.toAscii().constData());
+ cmd.toLocal8Bit().constData());
return -1;
}
cmd.truncate(pos);
cmd.prepend("GET_NETWORK ");
cmd.append(" disabled");
- if (ctrlRequest(cmd.toAscii().constData(), reply, &reply_len) >= 0
+ if (ctrlRequest(cmd.toLocal8Bit().constData(), reply, &reply_len) >= 0
&& reply_len >= 1) {
reply[reply_len] = '\0';
if (!str_match(reply, "FAIL"))
@@ -1265,7 +1347,7 @@ void WpaGui::saveConfig()
void WpaGui::selectAdapter( const QString & sel )
{
- if (openCtrlConnection(sel.toAscii().constData()) < 0)
+ if (openCtrlConnection(sel.toLocal8Bit().constData()) < 0)
debug("Failed to open control connection to "
"wpa_supplicant.");
updateStatus();
@@ -1278,10 +1360,7 @@ void WpaGui::createTrayIcon(bool trayOnly)
QApplication::setQuitOnLastWindowClosed(false);
tray_icon = new QSystemTrayIcon(this);
- if (QImageReader::supportedImageFormats().contains(QByteArray("svg")))
- tray_icon->setIcon(QIcon(":/icons/wpa_gui.svg"));
- else
- tray_icon->setIcon(QIcon(":/icons/wpa_gui.png"));
+ updateTrayIcon(TrayIconOffline);
connect(tray_icon,
SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
@@ -1421,6 +1500,77 @@ void WpaGui::updateTrayToolTip(const QString &msg)
}
+void WpaGui::updateTrayIcon(TrayIconType type)
+{
+ if (!tray_icon || currentIconType == type)
+ return;
+
+ QIcon fallback_icon;
+ QStringList names;
+
+ if (QImageReader::supportedImageFormats().contains(QByteArray("svg")))
+ fallback_icon = QIcon(":/icons/wpa_gui.svg");
+ else
+ fallback_icon = QIcon(":/icons/wpa_gui.png");
+
+ switch (type) {
+ case TrayIconOffline:
+ names << "network-wireless-offline-symbolic"
+ << "network-wireless-offline"
+ << "network-wireless-signal-none-symbolic"
+ << "network-wireless-signal-none";
+ break;
+ case TrayIconAcquiring:
+ names << "network-wireless-acquiring-symbolic"
+ << "network-wireless-acquiring";
+ break;
+ case TrayIconConnected:
+ names << "network-wireless-connected-symbolic"
+ << "network-wireless-connected";
+ break;
+ case TrayIconSignalNone:
+ names << "network-wireless-signal-none-symbolic"
+ << "network-wireless-signal-none";
+ break;
+ case TrayIconSignalWeak:
+ names << "network-wireless-signal-weak-symbolic"
+ << "network-wireless-signal-weak";
+ break;
+ case TrayIconSignalOk:
+ names << "network-wireless-signal-ok-symbolic"
+ << "network-wireless-signal-ok";
+ break;
+ case TrayIconSignalGood:
+ names << "network-wireless-signal-good-symbolic"
+ << "network-wireless-signal-good";
+ break;
+ case TrayIconSignalExcellent:
+ names << "network-wireless-signal-excellent-symbolic"
+ << "network-wireless-signal-excellent";
+ break;
+ }
+
+ currentIconType = type;
+ tray_icon->setIcon(loadThemedIcon(names, fallback_icon));
+}
+
+
+QIcon WpaGui::loadThemedIcon(const QStringList &names,
+ const QIcon &fallback)
+{
+ QIcon icon;
+
+ for (QStringList::ConstIterator it = names.begin();
+ it != names.end(); it++) {
+ icon = QIcon::fromTheme(*it);
+ if (!icon.isNull())
+ return icon;
+ }
+
+ return fallback;
+}
+
+
void WpaGui::closeEvent(QCloseEvent *event)
{
if (eh) {
@@ -1571,7 +1721,7 @@ void WpaGui::wpsApPin()
size_t reply_len = sizeof(reply);
QString cmd("WPS_REG " + bssFromScan + " " + wpsApPinEdit->text());
- if (ctrlRequest(cmd.toAscii().constData(), reply, &reply_len) < 0)
+ if (ctrlRequest(cmd.toLocal8Bit().constData(), reply, &reply_len) < 0)
return;
wpsStatusText->setText(tr("Waiting for AP/Enrollee"));
diff --git a/wpa_supplicant/wpa_gui-qt4/wpagui.h b/wpa_supplicant/wpa_gui-qt4/wpagui.h
index 026eacb..f0a34c9 100644
--- a/wpa_supplicant/wpa_gui-qt4/wpagui.h
+++ b/wpa_supplicant/wpa_gui-qt4/wpagui.h
@@ -16,14 +16,40 @@
class UserDataRequest;
+class WpaGuiApp : public QApplication
+{
+ Q_OBJECT
+public:
+ WpaGuiApp(int &argc, char **argv);
+
+#if !defined(QT_NO_SESSIONMANAGER) && QT_VERSION < 0x050000
+ virtual void saveState(QSessionManager &manager);
+#endif
+
+ WpaGui *w;
+ int argc;
+ char **argv;
+};
class WpaGui : public QMainWindow, public Ui::WpaGui
{
Q_OBJECT
public:
+
+ enum TrayIconType {
+ TrayIconOffline = 0,
+ TrayIconAcquiring,
+ TrayIconConnected,
+ TrayIconSignalNone,
+ TrayIconSignalWeak,
+ TrayIconSignalOk,
+ TrayIconSignalGood,
+ TrayIconSignalExcellent,
+ };
+
WpaGui(QApplication *app, QWidget *parent = 0, const char *name = 0,
- Qt::WFlags fl = 0);
+ Qt::WindowFlags fl = 0);
~WpaGui();
virtual int ctrlRequest(const char *cmd, char *buf, size_t *buflen);
@@ -49,6 +75,7 @@ public slots:
virtual void scan();
virtual void eventHistory();
virtual void ping();
+ virtual void signalMeterUpdate();
virtual void processMsg(char *msg);
virtual void processCtrlReq(const char *req);
virtual void receiveMsgs();
@@ -70,7 +97,10 @@ public slots:
virtual void showTrayMessage(QSystemTrayIcon::MessageIcon type,
int sec, const QString &msg);
virtual void showTrayStatus();
+ virtual void updateTrayIcon(TrayIconType type);
virtual void updateTrayToolTip(const QString &msg);
+ virtual QIcon loadThemedIcon(const QStringList &names,
+ const QIcon &fallback);
virtual void wpsDialog();
virtual void peersDialog();
virtual void tabChanged(int index);
@@ -113,6 +143,7 @@ private:
QAction *quitAction;
QMenu *tray_menu;
QSystemTrayIcon *tray_icon;
+ TrayIconType currentIconType;
QString wpaStateTranslate(char *state);
void createTrayIcon(bool);
bool ackTrayIcon;
@@ -127,6 +158,9 @@ private:
void stopWpsRun(bool success);
+ QTimer *signalMeterTimer;
+ int signalMeterInterval;
+
#ifdef CONFIG_NATIVE_WINDOWS
QAction *fileStartServiceAction;
QAction *fileStopServiceAction;
diff --git a/wpa_supplicant/wpa_priv.c b/wpa_supplicant/wpa_priv.c
index ac38d69..850ec40 100644
--- a/wpa_supplicant/wpa_priv.c
+++ b/wpa_supplicant/wpa_priv.c
@@ -29,8 +29,9 @@ struct wpa_priv_interface {
char *sock_name;
int fd;
- struct wpa_driver_ops *driver;
+ const struct wpa_driver_ops *driver;
void *drv_priv;
+ void *drv_global_priv;
struct sockaddr_un drv_addr;
int wpas_registered;
@@ -48,6 +49,10 @@ static void wpa_priv_cmd_register(struct wpa_priv_interface *iface,
if (iface->driver->deinit)
iface->driver->deinit(iface->drv_priv);
iface->drv_priv = NULL;
+ if (iface->drv_global_priv) {
+ iface->driver->global_deinit(iface->drv_global_priv);
+ iface->drv_global_priv = NULL;
+ }
iface->wpas_registered = 0;
}
@@ -58,10 +63,24 @@ static void wpa_priv_cmd_register(struct wpa_priv_interface *iface,
iface->l2 = NULL;
}
- if (iface->driver->init == NULL)
+ if (iface->driver->init2) {
+ if (iface->driver->global_init) {
+ iface->drv_global_priv = iface->driver->global_init();
+ if (!iface->drv_global_priv) {
+ wpa_printf(MSG_INFO,
+ "Failed to initialize driver global context");
+ return;
+ }
+ } else {
+ iface->drv_global_priv = NULL;
+ }
+ iface->drv_priv = iface->driver->init2(iface, iface->ifname,
+ iface->drv_global_priv);
+ } else if (iface->driver->init) {
+ iface->drv_priv = iface->driver->init(iface, iface->ifname);
+ } else {
return;
-
- iface->drv_priv = iface->driver->init(iface, iface->ifname);
+ }
if (iface->drv_priv == NULL) {
wpa_printf(MSG_DEBUG, "Failed to initialize driver wrapper");
return;
@@ -87,6 +106,10 @@ static void wpa_priv_cmd_unregister(struct wpa_priv_interface *iface,
if (iface->driver->deinit)
iface->driver->deinit(iface->drv_priv);
iface->drv_priv = NULL;
+ if (iface->drv_global_priv) {
+ iface->driver->global_deinit(iface->drv_global_priv);
+ iface->drv_global_priv = NULL;
+ }
iface->wpas_registered = 0;
}
}
@@ -172,6 +195,58 @@ static void wpa_priv_cmd_get_scan_results(struct wpa_priv_interface *iface,
}
+static void wpa_priv_cmd_authenticate(struct wpa_priv_interface *iface,
+ void *buf, size_t len)
+{
+ struct wpa_driver_auth_params params;
+ struct privsep_cmd_authenticate *auth;
+ int res, i;
+
+ if (iface->drv_priv == NULL || iface->driver->authenticate == NULL)
+ return;
+
+ if (len < sizeof(*auth)) {
+ wpa_printf(MSG_DEBUG, "Invalid authentication request");
+ return;
+ }
+
+ auth = buf;
+ if (sizeof(*auth) + auth->ie_len + auth->sae_data_len > len) {
+ wpa_printf(MSG_DEBUG, "Authentication request overflow");
+ return;
+ }
+
+ os_memset(&params, 0, sizeof(params));
+ params.freq = auth->freq;
+ params.bssid = auth->bssid;
+ params.ssid = auth->ssid;
+ if (auth->ssid_len > SSID_MAX_LEN)
+ return;
+ params.ssid_len = auth->ssid_len;
+ params.auth_alg = auth->auth_alg;
+ for (i = 0; i < 4; i++) {
+ if (auth->wep_key_len[i]) {
+ params.wep_key[i] = auth->wep_key[i];
+ params.wep_key_len[i] = auth->wep_key_len[i];
+ }
+ }
+ params.wep_tx_keyidx = auth->wep_tx_keyidx;
+ params.local_state_change = auth->local_state_change;
+ params.p2p = auth->p2p;
+ if (auth->ie_len) {
+ params.ie = (u8 *) (auth + 1);
+ params.ie_len = auth->ie_len;
+ }
+ if (auth->sae_data_len) {
+ params.sae_data = ((u8 *) (auth + 1)) + auth->ie_len;
+ params.sae_data_len = auth->sae_data_len;
+ }
+
+ res = iface->driver->authenticate(iface->drv_priv, &params);
+ wpa_printf(MSG_DEBUG, "drv->authenticate: res=%d", res);
+}
+
+
static void wpa_priv_cmd_associate(struct wpa_priv_interface *iface,
void *buf, size_t len)
{
@@ -199,7 +274,7 @@ static void wpa_priv_cmd_associate(struct wpa_priv_interface *iface,
if (bssid[0] | bssid[1] | bssid[2] | bssid[3] | bssid[4] | bssid[5])
params.bssid = bssid;
params.ssid = assoc->ssid;
- if (assoc->ssid_len > 32)
+ if (assoc->ssid_len > SSID_MAX_LEN)
return;
params.ssid_len = assoc->ssid_len;
params.freq.mode = assoc->hwmode;
@@ -244,7 +319,7 @@ fail:
static void wpa_priv_cmd_get_ssid(struct wpa_priv_interface *iface,
struct sockaddr_un *from)
{
- u8 ssid[sizeof(int) + 32];
+ u8 ssid[sizeof(int) + SSID_MAX_LEN];
int res;
if (iface->drv_priv == NULL)
@@ -254,7 +329,7 @@ static void wpa_priv_cmd_get_ssid(struct wpa_priv_interface *iface,
goto fail;
res = iface->driver->get_ssid(iface->drv_priv, &ssid[sizeof(int)]);
- if (res < 0 || res > 32)
+ if (res < 0 || res > SSID_MAX_LEN)
goto fail;
os_memcpy(ssid, &res, sizeof(int));
@@ -307,6 +382,10 @@ static void wpa_priv_cmd_get_capa(struct wpa_priv_interface *iface,
iface->driver->get_capa(iface->drv_priv, &capa) < 0)
goto fail;
+ /* For now, no support for passing extended_capa pointers */
+ capa.extended_capa = NULL;
+ capa.extended_capa_mask = NULL;
+ capa.extended_capa_len = 0;
sendto(iface->fd, &capa, sizeof(capa), 0, (struct sockaddr *) from,
sizeof(*from));
return;
@@ -356,7 +435,8 @@ static void wpa_priv_cmd_l2_register(struct wpa_priv_interface *iface,
}
proto = reg_cmd[0];
- if (proto != ETH_P_EAPOL && proto != ETH_P_RSN_PREAUTH) {
+ if (proto != ETH_P_EAPOL && proto != ETH_P_RSN_PREAUTH &&
+ proto != ETH_P_80211_ENCAP) {
wpa_printf(MSG_DEBUG, "Refused l2_packet connection for "
"ethertype 0x%x", proto);
return;
@@ -529,6 +609,9 @@ static void wpa_priv_receive(int sock, void *eloop_ctx, void *sock_ctx)
pos[cmd_len] = '\0';
wpa_priv_cmd_set_country(iface, pos);
break;
+ case PRIVSEP_CMD_AUTHENTICATE:
+ wpa_priv_cmd_authenticate(iface, cmd_buf, cmd_len);
+ break;
}
}
@@ -698,6 +781,36 @@ static int wpa_priv_send_event(struct wpa_priv_interface *iface, int event,
}
+static void wpa_priv_send_auth(struct wpa_priv_interface *iface,
+ union wpa_event_data *data)
+{
+ size_t buflen = sizeof(struct privsep_event_auth) + data->auth.ies_len;
+ struct privsep_event_auth *auth;
+ u8 *buf, *pos;
+
+ buf = os_malloc(buflen);
+ if (buf == NULL)
+ return;
+
+ auth = (struct privsep_event_auth *) buf;
+ pos = (u8 *) (auth + 1);
+
+ os_memcpy(auth->peer, data->auth.peer, ETH_ALEN);
+ os_memcpy(auth->bssid, data->auth.bssid, ETH_ALEN);
+ auth->auth_type = data->auth.auth_type;
+ auth->auth_transaction = data->auth.auth_transaction;
+ auth->status_code = data->auth.status_code;
+ if (data->auth.ies) {
+ os_memcpy(pos, data->auth.ies, data->auth.ies_len);
+ auth->ies_len = data->auth.ies_len;
+ }
+
+ wpa_priv_send_event(iface, PRIVSEP_EVENT_AUTH, buf, buflen);
+
+ os_free(buf);
+}
+
+
static void wpa_priv_send_assoc(struct wpa_priv_interface *iface, int event,
union wpa_event_data *data)
{
@@ -851,6 +964,10 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
&data->michael_mic_failure.unicast,
sizeof(int));
break;
+ case EVENT_SCAN_STARTED:
+ wpa_priv_send_event(iface, PRIVSEP_EVENT_SCAN_STARTED, NULL,
+ 0);
+ break;
case EVENT_SCAN_RESULTS:
wpa_priv_send_event(iface, PRIVSEP_EVENT_SCAN_RESULTS, NULL,
0);
@@ -874,9 +991,12 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
case EVENT_FT_RESPONSE:
wpa_priv_send_ft_response(iface, data);
break;
+ case EVENT_AUTH:
+ wpa_priv_send_auth(iface, data);
+ break;
default:
- wpa_printf(MSG_DEBUG, "Unsupported driver event %d - TODO",
- event);
+ wpa_printf(MSG_DEBUG, "Unsupported driver event %d (%s) - TODO",
+ event, event_to_string(event));
break;
}
}
@@ -944,8 +1064,9 @@ static void usage(void)
"contributors\n"
"\n"
"usage:\n"
- " wpa_priv [-Bdd] [-P<pid file>] <driver:ifname> "
- "[driver:ifname ...]\n");
+ " wpa_priv [-Bdd] [-c<ctrl dir>] [-P<pid file>] "
+ "<driver:ifname> \\\n"
+ " [driver:ifname ...]\n");
}
@@ -982,20 +1103,20 @@ int main(int argc, char *argv[])
break;
default:
usage();
- goto out;
+ goto out2;
}
}
if (optind >= argc) {
usage();
- goto out;
+ goto out2;
}
wpa_printf(MSG_DEBUG, "wpa_priv control directory: '%s'", ctrl_dir);
if (eloop_init()) {
wpa_printf(MSG_ERROR, "Failed to initialize event loop");
- goto out;
+ goto out2;
}
for (i = optind; i < argc; i++) {
@@ -1025,7 +1146,9 @@ out:
eloop_destroy();
- os_daemonize_terminate(pid_file);
+out2:
+ if (daemonize)
+ os_daemonize_terminate(pid_file);
os_free(pid_file);
os_program_deinit();
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index 19fb890..ef55fdc 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -35,6 +35,7 @@
#include "common/ieee802_11_defs.h"
#include "common/hw_features_common.h"
#include "p2p/p2p.h"
+#include "fst/fst.h"
#include "blacklist.h"
#include "wpas_glue.h"
#include "wps_supplicant.h"
@@ -55,11 +56,11 @@
#include "wpas_kay.h"
#include "mesh.h"
-const char *wpa_supplicant_version =
+const char *const wpa_supplicant_version =
"wpa_supplicant v" VERSION_STR "\n"
"Copyright (c) 2003-2015, Jouni Malinen <j@w1.fi> and contributors";
-const char *wpa_supplicant_license =
+const char *const wpa_supplicant_license =
"This software may be distributed under the terms of the BSD license.\n"
"See README for more details.\n"
#ifdef EAP_TLS_OPENSSL
@@ -70,16 +71,16 @@ const char *wpa_supplicant_license =
#ifndef CONFIG_NO_STDOUT_DEBUG
/* Long text divided into parts in order to fit in C89 strings size limits. */
-const char *wpa_supplicant_full_license1 =
+const char *const wpa_supplicant_full_license1 =
"";
-const char *wpa_supplicant_full_license2 =
+const char *const wpa_supplicant_full_license2 =
"This software may be distributed under the terms of the BSD license.\n"
"\n"
"Redistribution and use in source and binary forms, with or without\n"
"modification, are permitted provided that the following conditions are\n"
"met:\n"
"\n";
-const char *wpa_supplicant_full_license3 =
+const char *const wpa_supplicant_full_license3 =
"1. Redistributions of source code must retain the above copyright\n"
" notice, this list of conditions and the following disclaimer.\n"
"\n"
@@ -87,7 +88,7 @@ const char *wpa_supplicant_full_license3 =
" notice, this list of conditions and the following disclaimer in the\n"
" documentation and/or other materials provided with the distribution.\n"
"\n";
-const char *wpa_supplicant_full_license4 =
+const char *const wpa_supplicant_full_license4 =
"3. Neither the name(s) of the above-listed copyright holder(s) nor the\n"
" names of its contributors may be used to endorse or promote products\n"
" derived from this software without specific prior written permission.\n"
@@ -96,7 +97,7 @@ const char *wpa_supplicant_full_license4 =
"\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n"
"LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n"
"A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n";
-const char *wpa_supplicant_full_license5 =
+const char *const wpa_supplicant_full_license5 =
"OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n"
"SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n"
"LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n"
@@ -456,6 +457,8 @@ static void wpa_supplicant_cleanup(struct wpa_supplicant *wpa_s)
wpa_s, NULL);
#endif /* CONFIG_DELAYED_MIC_ERROR_REPORT */
+ eloop_cancel_timeout(wpas_network_reenabled, wpa_s, NULL);
+
wpas_wps_deinit(wpa_s);
wpabuf_free(wpa_s->pending_eapol_rx);
@@ -491,6 +494,16 @@ static void wpa_supplicant_cleanup(struct wpa_supplicant *wpa_s)
wpas_mac_addr_rand_scan_clear(wpa_s, MAC_ADDR_RAND_ALL);
+ /*
+ * Need to remove any pending gas-query radio work before the
+ * gas_query_deinit() call because gas_query::work has not yet been set
+ * for works that have not been started. gas_query_free() will be unable
+ * to cancel such pending radio works and once the pending gas-query
+ * radio work eventually gets removed, the deinit notification call to
+ * gas_query_start_cb() would result in dereferencing freed memory.
+ */
+ if (wpa_s->radio)
+ radio_remove_works(wpa_s, "gas-query", 0);
gas_query_deinit(wpa_s->gas);
wpa_s->gas = NULL;
@@ -716,6 +729,30 @@ void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s,
wpa_s->normal_scans = 0;
}
+#ifdef CONFIG_P2P
+ /*
+ * P2PS client has to reply to Probe Request frames received on the
+ * group operating channel. Enable Probe Request frame reporting for
+ * P2P connected client in case p2p_cli_probe configuration property is
+ * set to 1.
+ */
+ if (wpa_s->conf->p2p_cli_probe && wpa_s->current_ssid &&
+ wpa_s->current_ssid->mode == WPAS_MODE_INFRA &&
+ wpa_s->current_ssid->p2p_group) {
+ if (state == WPA_COMPLETED && !wpa_s->p2p_cli_probe) {
+ wpa_dbg(wpa_s, MSG_DEBUG,
+ "P2P: Enable CLI Probe Request RX reporting");
+ wpa_s->p2p_cli_probe =
+ wpa_drv_probe_req_report(wpa_s, 1) >= 0;
+ } else if (state != WPA_COMPLETED && wpa_s->p2p_cli_probe) {
+ wpa_dbg(wpa_s, MSG_DEBUG,
+ "P2P: Disable CLI Probe Request RX reporting");
+ wpa_s->p2p_cli_probe = 0;
+ wpa_drv_probe_req_report(wpa_s, 0);
+ }
+ }
+#endif /* CONFIG_P2P */
+
if (state != WPA_SCANNING)
wpa_supplicant_notify_scanning(wpa_s, 0);
@@ -729,6 +766,7 @@ void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s,
ssid && ssid->id_str ? ssid->id_str : "");
#endif /* CONFIG_CTRL_IFACE || !CONFIG_NO_STDOUT_DEBUG */
wpas_clear_temp_disabled(wpa_s, ssid, 1);
+ wpa_blacklist_clear(wpa_s);
wpa_s->extra_blacklist_count = 0;
wpa_s->new_connection = 0;
wpa_drv_set_operstate(wpa_s, 1);
@@ -870,7 +908,8 @@ int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s)
eapol_sm_invalidate_cached_session(wpa_s->eapol);
if (wpa_s->current_ssid) {
- wpa_s->own_disconnect_req = 1;
+ if (wpa_s->wpa_state >= WPA_AUTHENTICATING)
+ wpa_s->own_disconnect_req = 1;
wpa_supplicant_deauthenticate(wpa_s,
WLAN_REASON_DEAUTH_LEAVING);
}
@@ -1237,7 +1276,12 @@ int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
}
if (wpa_key_mgmt_wpa_psk(ssid->key_mgmt)) {
- wpa_sm_set_pmk(wpa_s->wpa, ssid->psk, PMK_LEN, NULL);
+ int psk_set = 0;
+
+ if (ssid->psk_set) {
+ wpa_sm_set_pmk(wpa_s->wpa, ssid->psk, PMK_LEN, NULL);
+ psk_set = 1;
+ }
#ifndef CONFIG_NO_PBKDF2
if (bss && ssid->bssid_set && ssid->ssid_len == 0 &&
ssid->passphrase) {
@@ -1247,6 +1291,7 @@ int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
wpa_hexdump_key(MSG_MSGDUMP, "PSK (from passphrase)",
psk, PMK_LEN);
wpa_sm_set_pmk(wpa_s->wpa, psk, PMK_LEN, NULL);
+ psk_set = 1;
os_memset(psk, 0, sizeof(psk));
}
#endif /* CONFIG_NO_PBKDF2 */
@@ -1284,6 +1329,7 @@ int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
"external passphrase)",
psk, PMK_LEN);
wpa_sm_set_pmk(wpa_s->wpa, psk, PMK_LEN, NULL);
+ psk_set = 1;
os_memset(psk, 0, sizeof(psk));
} else
#endif /* CONFIG_NO_PBKDF2 */
@@ -1296,6 +1342,7 @@ int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
return -1;
}
wpa_sm_set_pmk(wpa_s->wpa, psk, PMK_LEN, NULL);
+ psk_set = 1;
os_memset(psk, 0, sizeof(psk));
} else {
wpa_msg(wpa_s, MSG_INFO, "EXT PW: No suitable "
@@ -1309,6 +1356,12 @@ int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
ext_password_free(pw);
}
#endif /* CONFIG_EXT_PASSWORD */
+
+ if (!psk_set) {
+ wpa_msg(wpa_s, MSG_INFO,
+ "No PSK available for association");
+ return -1;
+ }
} else
wpa_sm_set_pmk_from_pmksa(wpa_s->wpa);
@@ -1914,7 +1967,8 @@ static void wpas_start_assoc_cb(struct wpa_radio_work *work, int deinit)
wpa_s->connect_work = work;
- if (cwork->bss_removed || !wpas_valid_bss_ssid(wpa_s, bss, ssid)) {
+ if (cwork->bss_removed || !wpas_valid_bss_ssid(wpa_s, bss, ssid) ||
+ wpas_network_disabled(wpa_s, ssid)) {
wpa_dbg(wpa_s, MSG_DEBUG, "BSS/SSID entry for association not valid anymore - drop connection attempt");
wpas_connect_work_done(wpa_s);
return;
@@ -1963,7 +2017,9 @@ static void wpas_start_assoc_cb(struct wpa_radio_work *work, int deinit)
wpa_ssid_txt(ssid->ssid, ssid->ssid_len));
os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
}
- wpa_supplicant_cancel_sched_scan(wpa_s);
+ if (!wpa_s->pno)
+ wpa_supplicant_cancel_sched_scan(wpa_s);
+
wpa_supplicant_cancel_scan(wpa_s);
/* Starting new association, so clear the possibly used WPA IE from the
@@ -2136,6 +2192,18 @@ static void wpas_start_assoc_cb(struct wpa_radio_work *work, int deinit)
}
}
+#ifdef CONFIG_FST
+ if (wpa_s->fst_ies) {
+ int fst_ies_len = wpabuf_len(wpa_s->fst_ies);
+
+ if (wpa_ie_len + fst_ies_len <= sizeof(wpa_ie)) {
+ os_memcpy(wpa_ie + wpa_ie_len,
+ wpabuf_head(wpa_s->fst_ies), fst_ies_len);
+ wpa_ie_len += fst_ies_len;
+ }
+ }
+#endif /* CONFIG_FST */
+
wpa_clear_keys(wpa_s, bss ? bss->bssid : NULL);
use_crypt = 1;
cipher_pairwise = wpa_s->pairwise_cipher;
@@ -2383,7 +2451,8 @@ static void wpas_start_assoc_cb(struct wpa_radio_work *work, int deinit)
}
old_ssid = wpa_s->current_ssid;
wpa_s->current_ssid = ssid;
- wpa_s->current_bss = bss;
+ if (!wpas_driver_bss_selection(wpa_s) || ssid->bssid_set)
+ wpa_s->current_bss = bss;
wpa_supplicant_rsn_supp_set_config(wpa_s, wpa_s->current_ssid);
wpa_supplicant_initiate_eapol(wpa_s);
if (old_ssid != wpa_s->current_ssid)
@@ -2505,15 +2574,20 @@ void wpa_supplicant_enable_network(struct wpa_supplicant *wpa_s,
} else
wpa_supplicant_enable_one_network(wpa_s, ssid);
- if (wpa_s->reassociate && !wpa_s->disconnected) {
+ if (wpa_s->reassociate && !wpa_s->disconnected &&
+ (!wpa_s->current_ssid ||
+ wpa_s->wpa_state == WPA_DISCONNECTED ||
+ wpa_s->wpa_state == WPA_SCANNING)) {
if (wpa_s->sched_scanning) {
wpa_printf(MSG_DEBUG, "Stop ongoing sched_scan to add "
"new network to scan filters");
wpa_supplicant_cancel_sched_scan(wpa_s);
}
- if (wpa_supplicant_fast_associate(wpa_s) != 1)
+ if (wpa_supplicant_fast_associate(wpa_s) != 1) {
+ wpa_s->scan_req = NORMAL_SCAN_REQ;
wpa_supplicant_req_scan(wpa_s, 0, 0);
+ }
}
}
@@ -2586,7 +2660,8 @@ void wpa_supplicant_select_network(struct wpa_supplicant *wpa_s,
int disconnected = 0;
if (ssid && ssid != wpa_s->current_ssid && wpa_s->current_ssid) {
- wpa_s->own_disconnect_req = 1;
+ if (wpa_s->wpa_state >= WPA_AUTHENTICATING)
+ wpa_s->own_disconnect_req = 1;
wpa_supplicant_deauthenticate(
wpa_s, WLAN_REASON_DEAUTH_LEAVING);
disconnected = 1;
@@ -2625,6 +2700,13 @@ void wpa_supplicant_select_network(struct wpa_supplicant *wpa_s,
eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
wpa_s->connect_without_scan =
(ssid->mode == WPAS_MODE_MESH) ? ssid : NULL;
+
+ /*
+ * Don't optimize next scan freqs since a new ESS has been
+ * selected.
+ */
+ os_free(wpa_s->next_scan_freqs);
+ wpa_s->next_scan_freqs = NULL;
} else {
wpa_s->connect_without_scan = NULL;
}
@@ -2633,8 +2715,10 @@ void wpa_supplicant_select_network(struct wpa_supplicant *wpa_s,
wpa_s->reassociate = 1;
if (wpa_s->connect_without_scan ||
- wpa_supplicant_fast_associate(wpa_s) != 1)
+ wpa_supplicant_fast_associate(wpa_s) != 1) {
+ wpa_s->scan_req = NORMAL_SCAN_REQ;
wpa_supplicant_req_scan(wpa_s, 0, disconnected ? 100000 : 0);
+ }
if (ssid)
wpas_notify_network_selected(wpa_s, ssid);
@@ -2709,6 +2793,11 @@ int wpa_supplicant_set_ap_scan(struct wpa_supplicant *wpa_s, int ap_scan)
if (ap_scan < 0 || ap_scan > 2)
return -1;
+ if (ap_scan == 2 && os_strcmp(wpa_s->driver->name, "nl80211") == 0) {
+ wpa_printf(MSG_INFO,
+ "Note: nl80211 driver interface is not designed to be used with ap_scan=2; this can result in connection failures");
+ }
+
#ifdef ANDROID
if (ap_scan == 2 && ap_scan != wpa_s->conf->ap_scan &&
wpa_s->wpa_state >= WPA_ASSOCIATING &&
@@ -2848,7 +2937,7 @@ int wpa_supplicant_set_debug_params(struct wpa_global *global, int debug_level,
struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s)
{
struct wpa_ssid *entry;
- u8 ssid[MAX_SSID_LEN];
+ u8 ssid[SSID_MAX_LEN];
int res;
size_t ssid_len;
u8 bssid[ETH_ALEN];
@@ -3053,12 +3142,36 @@ void wpa_supplicant_rx_eapol(void *ctx, const u8 *src_addr,
(wpa_s->current_ssid == NULL ||
wpa_s->current_ssid->mode != IEEE80211_MODE_IBSS)) {
/* Timeout for completing IEEE 802.1X and WPA authentication */
- wpa_supplicant_req_auth_timeout(
- wpa_s,
- (wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt) ||
- wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA ||
- wpa_s->key_mgmt == WPA_KEY_MGMT_WPS) ?
- 70 : 10, 0);
+ int timeout = 10;
+
+ if (wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt) ||
+ wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA ||
+ wpa_s->key_mgmt == WPA_KEY_MGMT_WPS) {
+ /* Use longer timeout for IEEE 802.1X/EAP */
+ timeout = 70;
+ }
+
+#ifdef CONFIG_WPS
+ if (wpa_s->current_ssid && wpa_s->current_bss &&
+ (wpa_s->current_ssid->key_mgmt & WPA_KEY_MGMT_WPS) &&
+ eap_is_wps_pin_enrollee(&wpa_s->current_ssid->eap)) {
+ /*
+ * Use shorter timeout if going through WPS AP iteration
+ * for PIN config method with an AP that does not
+ * advertise Selected Registrar.
+ */
+ struct wpabuf *wps_ie;
+
+ wps_ie = wpa_bss_get_vendor_ie_multi(
+ wpa_s->current_bss, WPS_IE_VENDOR_TYPE);
+ if (wps_ie &&
+ !wps_is_addr_authorized(wps_ie, wpa_s->own_addr, 1))
+ timeout = 10;
+ wpabuf_free(wps_ie);
+ }
+#endif /* CONFIG_WPS */
+
+ wpa_supplicant_req_auth_timeout(wpa_s, timeout, 0);
}
wpa_s->eapol_received++;
@@ -3190,6 +3303,12 @@ int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s)
}
}
+ if (wpa_s->conf->ap_scan == 2 &&
+ os_strcmp(wpa_s->driver->name, "nl80211") == 0) {
+ wpa_printf(MSG_INFO,
+ "Note: nl80211 driver interface is not designed to be used with ap_scan=2; this can result in connection failures");
+ }
+
wpa_clear_keys(wpa_s, NULL);
/* Make sure that TKIP countermeasures are not left enabled (could
@@ -3615,6 +3734,124 @@ int wpas_init_ext_pw(struct wpa_supplicant *wpa_s)
}
+#ifdef CONFIG_FST
+
+static const u8 * wpas_fst_get_bssid_cb(void *ctx)
+{
+ struct wpa_supplicant *wpa_s = ctx;
+
+ return (is_zero_ether_addr(wpa_s->bssid) ||
+ wpa_s->wpa_state != WPA_COMPLETED) ? NULL : wpa_s->bssid;
+}
+
+
+static void wpas_fst_get_channel_info_cb(void *ctx,
+ enum hostapd_hw_mode *hw_mode,
+ u8 *channel)
+{
+ struct wpa_supplicant *wpa_s = ctx;
+
+ if (wpa_s->current_bss) {
+ *hw_mode = ieee80211_freq_to_chan(wpa_s->current_bss->freq,
+ channel);
+ } else if (wpa_s->hw.num_modes) {
+ *hw_mode = wpa_s->hw.modes[0].mode;
+ } else {
+ WPA_ASSERT(0);
+ *hw_mode = 0;
+ }
+}
+
+
+static int wpas_fst_get_hw_modes(void *ctx, struct hostapd_hw_modes **modes)
+{
+ struct wpa_supplicant *wpa_s = ctx;
+
+ *modes = wpa_s->hw.modes;
+ return wpa_s->hw.num_modes;
+}
+
+
+static void wpas_fst_set_ies_cb(void *ctx, const struct wpabuf *fst_ies)
+{
+ struct wpa_supplicant *wpa_s = ctx;
+
+ wpa_hexdump_buf(MSG_DEBUG, "FST: Set IEs", fst_ies);
+ wpa_s->fst_ies = fst_ies;
+}
+
+
+static int wpas_fst_send_action_cb(void *ctx, const u8 *da, struct wpabuf *data)
+{
+ struct wpa_supplicant *wpa_s = ctx;
+
+ WPA_ASSERT(os_memcmp(wpa_s->bssid, da, ETH_ALEN) == 0);
+ return wpa_drv_send_action(wpa_s, wpa_s->assoc_freq, 0, wpa_s->bssid,
+ wpa_s->own_addr, wpa_s->bssid,
+ wpabuf_head(data), wpabuf_len(data),
+ 0);
+}
+
+
+static const struct wpabuf * wpas_fst_get_mb_ie_cb(void *ctx, const u8 *addr)
+{
+ struct wpa_supplicant *wpa_s = ctx;
+
+ WPA_ASSERT(os_memcmp(wpa_s->bssid, addr, ETH_ALEN) == 0);
+ return wpa_s->received_mb_ies;
+}
+
+
+static void wpas_fst_update_mb_ie_cb(void *ctx, const u8 *addr,
+ const u8 *buf, size_t size)
+{
+ struct wpa_supplicant *wpa_s = ctx;
+ struct mb_ies_info info;
+
+ WPA_ASSERT(os_memcmp(wpa_s->bssid, addr, ETH_ALEN) == 0);
+
+ if (!mb_ies_info_by_ies(&info, buf, size)) {
+ wpabuf_free(wpa_s->received_mb_ies);
+ wpa_s->received_mb_ies = mb_ies_by_info(&info);
+ }
+}
+
+
+const u8 * wpas_fst_get_peer_first(void *ctx, struct fst_get_peer_ctx **get_ctx,
+ Boolean mb_only)
+{
+ struct wpa_supplicant *wpa_s = ctx;
+
+ *get_ctx = NULL;
+ if (!is_zero_ether_addr(wpa_s->bssid))
+ return (wpa_s->received_mb_ies || !mb_only) ?
+ wpa_s->bssid : NULL;
+ return NULL;
+}
+
+
+const u8 * wpas_fst_get_peer_next(void *ctx, struct fst_get_peer_ctx **get_ctx,
+ Boolean mb_only)
+{
+ return NULL;
+}
+
+void fst_wpa_supplicant_fill_iface_obj(struct wpa_supplicant *wpa_s,
+ struct fst_wpa_obj *iface_obj)
+{
+ iface_obj->ctx = wpa_s;
+ iface_obj->get_bssid = wpas_fst_get_bssid_cb;
+ iface_obj->get_channel_info = wpas_fst_get_channel_info_cb;
+ iface_obj->get_hw_modes = wpas_fst_get_hw_modes;
+ iface_obj->set_ies = wpas_fst_set_ies_cb;
+ iface_obj->send_action = wpas_fst_send_action_cb;
+ iface_obj->get_mb_ie = wpas_fst_get_mb_ie_cb;
+ iface_obj->update_mb_ie = wpas_fst_update_mb_ie_cb;
+ iface_obj->get_peer_first = wpas_fst_get_peer_first;
+ iface_obj->get_peer_next = wpas_fst_get_peer_next;
+}
+#endif /* CONFIG_FST */
+
static int wpas_set_wowlan_triggers(struct wpa_supplicant *wpa_s,
const struct wpa_driver_capa *capa)
{
@@ -4153,6 +4390,28 @@ static int wpa_supplicant_init_iface(struct wpa_supplicant *wpa_s,
return -1;
}
+#ifdef CONFIG_FST
+ if (wpa_s->conf->fst_group_id) {
+ struct fst_iface_cfg cfg;
+ struct fst_wpa_obj iface_obj;
+
+ fst_wpa_supplicant_fill_iface_obj(wpa_s, &iface_obj);
+ os_strlcpy(cfg.group_id, wpa_s->conf->fst_group_id,
+ sizeof(cfg.group_id));
+ cfg.priority = wpa_s->conf->fst_priority;
+ cfg.llt = wpa_s->conf->fst_llt;
+
+ wpa_s->fst = fst_attach(wpa_s->ifname, wpa_s->own_addr,
+ &iface_obj, &cfg);
+ if (!wpa_s->fst) {
+ wpa_msg(wpa_s, MSG_ERROR,
+ "FST: Cannot attach iface %s to group %s",
+ wpa_s->ifname, cfg.group_id);
+ return -1;
+ }
+ }
+#endif /* CONFIG_FST */
+
if (wpas_wps_init(wpa_s))
return -1;
@@ -4261,6 +4520,17 @@ static void wpa_supplicant_deinit_iface(struct wpa_supplicant *wpa_s,
wpas_ctrl_radio_work_flush(wpa_s);
radio_remove_interface(wpa_s);
+#ifdef CONFIG_FST
+ if (wpa_s->fst) {
+ fst_detach(wpa_s->fst);
+ wpa_s->fst = NULL;
+ }
+ if (wpa_s->received_mb_ies) {
+ wpabuf_free(wpa_s->received_mb_ies);
+ wpa_s->received_mb_ies = NULL;
+ }
+#endif /* CONFIG_FST */
+
if (wpa_s->drv_priv)
wpa_drv_deinit(wpa_s);
@@ -4287,6 +4557,8 @@ static void wpa_supplicant_deinit_iface(struct wpa_supplicant *wpa_s,
wpa_s->conf = NULL;
}
+ os_free(wpa_s->ssids_from_scan_req);
+
os_free(wpa_s);
}
@@ -4362,8 +4634,10 @@ struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global,
#ifdef CONFIG_P2P
if (wpa_s->global->p2p == NULL &&
+ !wpa_s->global->p2p_disabled && !wpa_s->conf->p2p_disabled &&
(wpa_s->drv_flags & WPA_DRIVER_FLAGS_DEDICATED_P2P_DEVICE) &&
- wpas_p2p_add_p2pdev_interface(wpa_s, iface->conf_p2p_dev) < 0) {
+ wpas_p2p_add_p2pdev_interface(
+ wpa_s, wpa_s->global->params.conf_p2p_dev) < 0) {
wpa_printf(MSG_INFO,
"P2P: Failed to enable P2P Device interface");
/* Try to continue without. P2P will be disabled. */
@@ -4489,6 +4763,33 @@ static const char * wpa_supplicant_msg_ifname_cb(void *ctx)
#endif /* CONFIG_NO_WPA_MSG */
+#ifndef WPA_SUPPLICANT_CLEANUP_INTERVAL
+#define WPA_SUPPLICANT_CLEANUP_INTERVAL 10
+#endif /* WPA_SUPPLICANT_CLEANUP_INTERVAL */
+
+/* Periodic cleanup tasks */
+static void wpas_periodic(void *eloop_ctx, void *timeout_ctx)
+{
+ struct wpa_global *global = eloop_ctx;
+ struct wpa_supplicant *wpa_s;
+
+ eloop_register_timeout(WPA_SUPPLICANT_CLEANUP_INTERVAL, 0,
+ wpas_periodic, global, NULL);
+
+#ifdef CONFIG_P2P
+ if (global->p2p)
+ p2p_expire_peers(global->p2p);
+#endif /* CONFIG_P2P */
+
+ for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
+ wpa_bss_flush_by_age(wpa_s, wpa_s->conf->bss_expiration_age);
+#ifdef CONFIG_AP
+ ap_periodic(wpa_s);
+#endif /* CONFIG_AP */
+ }
+}
+
+
/**
* wpa_supplicant_init - Initialize %wpa_supplicant
* @params: Parameters for %wpa_supplicant
@@ -4563,6 +4864,11 @@ struct wpa_global * wpa_supplicant_init(struct wpa_params *params)
if (params->override_ctrl_interface)
global->params.override_ctrl_interface =
os_strdup(params->override_ctrl_interface);
+#ifdef CONFIG_P2P
+ if (params->conf_p2p_dev)
+ global->params.conf_p2p_dev =
+ os_strdup(params->conf_p2p_dev);
+#endif /* CONFIG_P2P */
wpa_debug_level = global->params.wpa_debug_level =
params->wpa_debug_level;
wpa_debug_show_keys = global->params.wpa_debug_show_keys =
@@ -4612,6 +4918,9 @@ struct wpa_global * wpa_supplicant_init(struct wpa_params *params)
}
#endif /* CONFIG_WIFI_DISPLAY */
+ eloop_register_timeout(WPA_SUPPLICANT_CLEANUP_INTERVAL, 0,
+ wpas_periodic, global, NULL);
+
return global;
}
@@ -4663,6 +4972,8 @@ void wpa_supplicant_deinit(struct wpa_global *global)
if (global == NULL)
return;
+ eloop_cancel_timeout(wpas_periodic, global, NULL);
+
#ifdef CONFIG_WIFI_DISPLAY
wifi_display_deinit(global);
#endif /* CONFIG_WIFI_DISPLAY */
@@ -4699,6 +5010,9 @@ void wpa_supplicant_deinit(struct wpa_global *global)
os_free(global->params.ctrl_interface_group);
os_free(global->params.override_driver);
os_free(global->params.override_ctrl_interface);
+#ifdef CONFIG_P2P
+ os_free(global->params.conf_p2p_dev);
+#endif /* CONFIG_P2P */
os_free(global->p2p_disallow_freq.range);
os_free(global->p2p_go_avoid_freq.range);
@@ -4958,6 +5272,15 @@ int wpa_supplicant_ctrl_iface_ctrl_rsp_handle(struct wpa_supplicant *wpa_s,
str_clear_free(eap->external_sim_resp);
eap->external_sim_resp = os_strdup(value);
break;
+ case WPA_CTRL_REQ_PSK_PASSPHRASE:
+ if (wpa_config_set(ssid, "psk", value, 0) < 0)
+ return -1;
+ ssid->mem_only_psk = 1;
+ if (ssid->passphrase)
+ wpa_config_update_psk(ssid);
+ if (wpa_s->wpa_state == WPA_SCANNING && !wpa_s->scanning)
+ wpa_supplicant_req_scan(wpa_s, 0, 0);
+ break;
default:
wpa_printf(MSG_DEBUG, "CTRL_IFACE: Unknown field '%s'", field);
return -1;
@@ -5005,7 +5328,8 @@ int wpas_network_disabled(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
}
if (wpa_key_mgmt_wpa_psk(ssid->key_mgmt) && !ssid->psk_set &&
- (!ssid->passphrase || ssid->ssid_len != 0) && !ssid->ext_psk)
+ (!ssid->passphrase || ssid->ssid_len != 0) && !ssid->ext_psk &&
+ !ssid->mem_only_psk)
return 1;
return 0;
@@ -5227,7 +5551,8 @@ int get_shared_radio_freqs_data(struct wpa_supplicant *wpa_s,
continue;
if (ifs->current_ssid->mode == WPAS_MODE_AP ||
- ifs->current_ssid->mode == WPAS_MODE_P2P_GO)
+ ifs->current_ssid->mode == WPAS_MODE_P2P_GO ||
+ ifs->current_ssid->mode == WPAS_MODE_MESH)
freq = ifs->current_ssid->frequency;
else if (wpa_drv_get_bssid(ifs, bssid) == 0)
freq = ifs->assoc_freq;
@@ -5243,7 +5568,7 @@ int get_shared_radio_freqs_data(struct wpa_supplicant *wpa_s,
freqs_data[idx++].freq = freq;
if (ifs->current_ssid->mode == WPAS_MODE_INFRA) {
- freqs_data[i].flags = ifs->current_ssid->p2p_group ?
+ freqs_data[i].flags |= ifs->current_ssid->p2p_group ?
WPA_FREQ_USED_BY_P2P_CLIENT :
WPA_FREQ_USED_BY_INFRA_STATION;
}
diff --git a/wpa_supplicant/wpa_supplicant.conf b/wpa_supplicant/wpa_supplicant.conf
index 8964b3f..6fe67e4 100644
--- a/wpa_supplicant/wpa_supplicant.conf
+++ b/wpa_supplicant/wpa_supplicant.conf
@@ -108,6 +108,10 @@ eapol_version=1
# the driver reports successful association; each network block should have
# explicit security policy (i.e., only one option in the lists) for
# key_mgmt, pairwise, group, proto variables
+# Note: ap_scan=2 should not be used with the nl80211 driver interface (the
+# current Linux interface). ap_scan=1 is optimized work working with nl80211.
+# For finding networks using hidden SSID, scan_ssid=1 in the network block can
+# be used with nl80211.
# When using IBSS or AP mode, ap_scan=2 mode can force the new network to be
# created immediately regardless of scan results. ap_scan=1 mode will first try
# to scan for existing networks and only if no matches with the enabled
@@ -268,6 +272,11 @@ fast_reauth=1
#wps_nfc_dh_privkey: Hexdump of DH Private Key
#wps_nfc_dev_pw: Hexdump of Device Password
+# Priority for the networks added through WPS
+# This priority value will be set to each network profile that is added
+# by executing the WPS protocol.
+#wps_priority=0
+
# Maximum number of BSS entries to keep in memory
# Default: 200
# This can be used to limit memory use on the BSS entries (cached scan
@@ -297,6 +306,10 @@ fast_reauth=1
# format: <backend name>[:<optional backend parameters>]
#ext_password_backend=test:pw1=password|pw2=testing
+
+# Disable P2P functionality
+# p2p_disabled=1
+
# Timeout in seconds to detect STA inactivity (default: 300 seconds)
#
# This timeout value is used in P2P GO mode to clean up
@@ -740,6 +753,11 @@ fast_reauth=1
# startup and reconfiguration time can be optimized by generating the PSK only
# only when the passphrase or SSID has actually changed.
#
+# mem_only_psk: Whether to keep PSK/passphrase only in memory
+# 0 = allow psk/passphrase to be stored to the configuration file
+# 1 = do not store psk/passphrase to the configuration file
+#mem_only_psk=0
+#
# eapol_flags: IEEE 802.1X/EAPOL options (bit field)
# Dynamic WEP key required for non-WPA mode
# bit0 (1): require dynamically generated unicast WEP key
@@ -969,9 +987,10 @@ fast_reauth=1
# tls_disable_session_ticket=0 - allow TLS Session Ticket extension to be used
# Note: If not set, this is automatically set to 1 for EAP-TLS/PEAP/TTLS
# as a workaround for broken authentication server implementations unless
-# EAP workarounds are disabled with eap_workarounds=0.
+# EAP workarounds are disabled with eap_workaround=0.
# For EAP-FAST, this must be set to 0 (or left unconfigured for the
# default value to be used automatically).
+# tls_disable_tlsv1_0=1 - disable use of TLSv1.0
# tls_disable_tlsv1_1=1 - disable use of TLSv1.1 (a workaround for AAA servers
# that have issues interoperating with updated TLS version)
# tls_disable_tlsv1_2=1 - disable use of TLSv1.2 (a workaround for AAA servers
@@ -1122,6 +1141,32 @@ fast_reauth=1
# 2: MCS 0-9
# 3: not supported
+##### Fast Session Transfer (FST) support #####################################
+#
+# The options in this section are only available when the build configuration
+# option CONFIG_FST is set while compiling hostapd. They allow this interface
+# to be a part of FST setup.
+#
+# FST is the transfer of a session from a channel to another channel, in the
+# same or different frequency bands.
+#
+# For detals, see IEEE Std 802.11ad-2012.
+
+# Identifier of an FST Group the interface belongs to.
+#fst_group_id=bond0
+
+# Interface priority within the FST Group.
+# Announcing a higher priority for an interface means declaring it more
+# preferable for FST switch.
+# fst_priority is in 1..255 range with 1 being the lowest priority.
+#fst_priority=100
+
+# Default LLT value for this interface in milliseconds. The value used in case
+# no value provided during session setup. Default is 50 msec.
+# fst_llt is in 1..4294967 range (due to spec limitation, see 10.32.2.2
+# Transitioning between states).
+#fst_llt=100
+
# Example blocks:
# Simple case: WPA-PSK, PSK as an ASCII passphrase, allow all valid ciphers
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
index 26ff216..58df48c 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -17,14 +17,14 @@
#include "config_ssid.h"
#include "wmm_ac.h"
-extern const char *wpa_supplicant_version;
-extern const char *wpa_supplicant_license;
+extern const char *const wpa_supplicant_version;
+extern const char *const wpa_supplicant_license;
#ifndef CONFIG_NO_STDOUT_DEBUG
-extern const char *wpa_supplicant_full_license1;
-extern const char *wpa_supplicant_full_license2;
-extern const char *wpa_supplicant_full_license3;
-extern const char *wpa_supplicant_full_license4;
-extern const char *wpa_supplicant_full_license5;
+extern const char *const wpa_supplicant_full_license1;
+extern const char *const wpa_supplicant_full_license2;
+extern const char *const wpa_supplicant_full_license3;
+extern const char *const wpa_supplicant_full_license4;
+extern const char *const wpa_supplicant_full_license5;
#endif /* CONFIG_NO_STDOUT_DEBUG */
struct wpa_sm;
@@ -66,17 +66,6 @@ struct wpa_interface {
*/
const char *confanother;
-#ifdef CONFIG_P2P
- /**
- * conf_p2p_dev - Configuration file used to hold the
- * P2P Device configuration parameters.
- *
- * This can also be %NULL. In such a case, if a P2P Device dedicated
- * interfaces is created, the main configuration file will be used.
- */
- const char *conf_p2p_dev;
-#endif /* CONFIG_P2P */
-
/**
* ctrl_interface - Control interface parameter
*
@@ -227,6 +216,18 @@ struct wpa_params {
* its internal entropy store over restarts.
*/
char *entropy_file;
+
+#ifdef CONFIG_P2P
+ /**
+ * conf_p2p_dev - Configuration file used to hold the
+ * P2P Device configuration parameters.
+ *
+ * This can also be %NULL. In such a case, if a P2P Device dedicated
+ * interfaces is created, the main configuration file will be used.
+ */
+ char *conf_p2p_dev;
+#endif /* CONFIG_P2P */
+
};
struct p2p_srv_bonjour {
@@ -366,10 +367,12 @@ struct wps_ap_info {
} type;
unsigned int tries;
struct os_reltime last_attempt;
+ unsigned int pbc_active;
+ u8 uuid[WPS_UUID_LEN];
};
struct wpa_ssid_value {
- u8 ssid[32];
+ u8 ssid[SSID_MAX_LEN];
size_t ssid_len;
};
@@ -479,7 +482,7 @@ struct wpa_supplicant {
struct wpa_ssid_value *disallow_aps_ssid;
size_t disallow_aps_ssid_count;
- enum { WPA_SETBAND_AUTO, WPA_SETBAND_5G, WPA_SETBAND_2G } setband;
+ enum set_band setband;
/* Preferred network for the next connection attempt */
struct wpa_ssid *next_ssid;
@@ -518,7 +521,7 @@ struct wpa_supplicant {
unsigned int last_scan_res_size;
struct os_reltime last_scan;
- struct wpa_driver_ops *driver;
+ const struct wpa_driver_ops *driver;
int interface_removed; /* whether the network interface has been
* removed */
struct wpa_sm *wpa;
@@ -590,6 +593,8 @@ struct wpa_supplicant {
} scan_req, last_scan_req;
enum wpa_states scan_prev_wpa_state;
struct os_reltime scan_trigger_time, scan_start_time;
+ /* Minimum freshness requirement for connection purposes */
+ struct os_reltime scan_min_time;
int scan_runs; /* number of scan runs since WPS was started */
int *next_scan_freqs;
int *manual_scan_freqs;
@@ -609,6 +614,9 @@ struct wpa_supplicant {
int scan_id[MAX_SCAN_ID];
unsigned int scan_id_count;
+ struct wpa_ssid_value *ssids_from_scan_req;
+ unsigned int num_ssids_from_scan_req;
+
u64 drv_flags;
unsigned int drv_enc;
unsigned int drv_smps_modes;
@@ -639,6 +647,7 @@ struct wpa_supplicant {
int wps_success; /* WPS success event received */
struct wps_er *wps_er;
unsigned int wps_run;
+ struct os_reltime wps_pin_start_time;
int blacklist_cleared;
struct wpabuf *pending_eapol_rx;
@@ -648,6 +657,7 @@ struct wpa_supplicant {
unsigned int eap_expected_failure:1;
unsigned int reattach:1; /* reassociation to the same BSS requested */
unsigned int mac_addr_changed:1;
+ unsigned int added_vif:1;
struct os_reltime last_mac_addr_change;
int last_mac_addr_style;
@@ -661,7 +671,7 @@ struct wpa_supplicant {
#ifdef CONFIG_SME
struct {
- u8 ssid[32];
+ u8 ssid[SSID_MAX_LEN];
size_t ssid_len;
int freq;
u8 assoc_req_ie[200];
@@ -736,7 +746,6 @@ struct wpa_supplicant {
int p2p_mgmt;
#ifdef CONFIG_P2P
- struct wpa_supplicant *p2p_dev;
struct p2p_go_neg_results *go_params;
int create_p2p_iface;
u8 pending_interface_addr[ETH_ALEN];
@@ -767,7 +776,7 @@ struct wpa_supplicant {
u8 pending_join_iface_addr[ETH_ALEN];
u8 pending_join_dev_addr[ETH_ALEN];
int pending_join_wps_method;
- u8 p2p_join_ssid[32];
+ u8 p2p_join_ssid[SSID_MAX_LEN];
size_t p2p_join_ssid_len;
int p2p_join_scan_count;
int auto_pd_scan_retry;
@@ -813,7 +822,8 @@ struct wpa_supplicant {
unsigned int p2p_nfc_tag_enabled:1;
unsigned int p2p_peer_oob_pk_hash_known:1;
unsigned int p2p_disable_ip_addr_req:1;
- unsigned int p2ps_join_addr_valid:1;
+ unsigned int p2ps_method_config_any:1;
+ unsigned int p2p_cli_probe:1;
int p2p_persistent_go_freq;
int p2p_persistent_id;
int p2p_go_intent;
@@ -969,6 +979,12 @@ struct wpa_supplicant {
u8 last_tspecs_count;
struct rrm_data rrm;
+
+#ifdef CONFIG_FST
+ struct fst_iface *fst;
+ const struct wpabuf *fst_ies;
+ struct wpabuf *received_mb_ies;
+#endif /* CONFIG_FST */
};
@@ -1116,13 +1132,13 @@ struct wpa_bss * wpa_supplicant_pick_network(struct wpa_supplicant *wpa_s,
int eap_register_methods(void);
/**
- * Utility method to tell if a given network is a persistent group
+ * Utility method to tell if a given network is for persistent group storage
* @ssid: Network object
* Returns: 1 if network is a persistent group, 0 otherwise
*/
static inline int network_is_persistent_group(struct wpa_ssid *ssid)
{
- return ((ssid->disabled == 2) || ssid->p2p_persistent_group);
+ return ssid->disabled == 2 && ssid->p2p_persistent_group;
}
int wpas_network_disabled(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid);
@@ -1140,4 +1156,15 @@ int get_shared_radio_freqs_data(struct wpa_supplicant *wpa_s,
int get_shared_radio_freqs(struct wpa_supplicant *wpa_s,
int *freq_array, unsigned int len);
+void wpas_network_reenabled(void *eloop_ctx, void *timeout_ctx);
+
+#ifdef CONFIG_FST
+
+struct fst_wpa_obj;
+
+void fst_wpa_supplicant_fill_iface_obj(struct wpa_supplicant *wpa_s,
+ struct fst_wpa_obj *iface_obj);
+
+#endif /* CONFIG_FST */
+
#endif /* WPA_SUPPLICANT_I_H */
diff --git a/wpa_supplicant/wpas_glue.c b/wpa_supplicant/wpas_glue.c
index 1bb82ba..29c22ba 100644
--- a/wpa_supplicant/wpas_glue.c
+++ b/wpa_supplicant/wpas_glue.c
@@ -737,6 +737,8 @@ enum wpa_ctrl_req_type wpa_supplicant_ctrl_req_from_string(const char *field)
return WPA_CTRL_REQ_EAP_PASSPHRASE;
else if (os_strcmp(field, "SIM") == 0)
return WPA_CTRL_REQ_SIM;
+ else if (os_strcmp(field, "PSK_PASSPHRASE") == 0)
+ return WPA_CTRL_REQ_PSK_PASSPHRASE;
return WPA_CTRL_REQ_UNKNOWN;
}
@@ -776,6 +778,10 @@ const char * wpa_supplicant_ctrl_req_to_string(enum wpa_ctrl_req_type field,
case WPA_CTRL_REQ_SIM:
ret = "SIM";
break;
+ case WPA_CTRL_REQ_PSK_PASSPHRASE:
+ *txt = "PSK or passphrase";
+ ret = "PSK_PASSPHRASE";
+ break;
default:
break;
}
@@ -789,6 +795,35 @@ const char * wpa_supplicant_ctrl_req_to_string(enum wpa_ctrl_req_type field,
return ret;
}
+
+void wpas_send_ctrl_req(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
+ const char *field_name, const char *txt)
+{
+ char *buf;
+ size_t buflen;
+ int len;
+
+ buflen = 100 + os_strlen(txt) + ssid->ssid_len;
+ buf = os_malloc(buflen);
+ if (buf == NULL)
+ return;
+ len = os_snprintf(buf, buflen, "%s-%d:%s needed for SSID ",
+ field_name, ssid->id, txt);
+ if (os_snprintf_error(buflen, len)) {
+ os_free(buf);
+ return;
+ }
+ if (ssid->ssid && buflen > len + ssid->ssid_len) {
+ os_memcpy(buf + len, ssid->ssid, ssid->ssid_len);
+ len += ssid->ssid_len;
+ buf[len] = '\0';
+ }
+ buf[buflen - 1] = '\0';
+ wpa_msg(wpa_s, MSG_INFO, WPA_CTRL_REQ "%s", buf);
+ os_free(buf);
+}
+
+
#ifdef IEEE8021X_EAPOL
#if defined(CONFIG_CTRL_IFACE) || !defined(CONFIG_NO_STDOUT_DEBUG)
static void wpa_supplicant_eap_param_needed(void *ctx,
@@ -798,9 +833,6 @@ static void wpa_supplicant_eap_param_needed(void *ctx,
struct wpa_supplicant *wpa_s = ctx;
struct wpa_ssid *ssid = wpa_s->current_ssid;
const char *field_name, *txt = NULL;
- char *buf;
- size_t buflen;
- int len;
if (ssid == NULL)
return;
@@ -817,25 +849,7 @@ static void wpa_supplicant_eap_param_needed(void *ctx,
wpas_notify_eap_status(wpa_s, "eap parameter needed", field_name);
- buflen = 100 + os_strlen(txt) + ssid->ssid_len;
- buf = os_malloc(buflen);
- if (buf == NULL)
- return;
- len = os_snprintf(buf, buflen,
- WPA_CTRL_REQ "%s-%d:%s needed for SSID ",
- field_name, ssid->id, txt);
- if (os_snprintf_error(buflen, len)) {
- os_free(buf);
- return;
- }
- if (ssid->ssid && buflen > len + ssid->ssid_len) {
- os_memcpy(buf + len, ssid->ssid, ssid->ssid_len);
- len += ssid->ssid_len;
- buf[len] = '\0';
- }
- buf[buflen - 1] = '\0';
- wpa_msg(wpa_s, MSG_INFO, "%s", buf);
- os_free(buf);
+ wpas_send_ctrl_req(wpa_s, ssid, field_name, txt);
}
#else /* CONFIG_CTRL_IFACE || !CONFIG_NO_STDOUT_DEBUG */
#define wpa_supplicant_eap_param_needed NULL
@@ -1007,7 +1021,8 @@ static int wpa_supplicant_key_mgmt_set_pmk(void *ctx, const u8 *pmk,
{
struct wpa_supplicant *wpa_s = ctx;
- if (wpa_s->conf->key_mgmt_offload)
+ if (wpa_s->conf->key_mgmt_offload &&
+ (wpa_s->drv_flags & WPA_DRIVER_FLAGS_KEY_MGMT_OFFLOAD))
return wpa_drv_set_key(wpa_s, WPA_ALG_PMK, NULL, 0, 0,
NULL, 0, pmk, pmk_len);
else
diff --git a/wpa_supplicant/wpas_glue.h b/wpa_supplicant/wpas_glue.h
index 9808c22..5585e56 100644
--- a/wpa_supplicant/wpas_glue.h
+++ b/wpa_supplicant/wpas_glue.h
@@ -22,4 +22,7 @@ const char * wpa_supplicant_ctrl_req_to_string(enum wpa_ctrl_req_type field,
enum wpa_ctrl_req_type wpa_supplicant_ctrl_req_from_string(const char *field);
+void wpas_send_ctrl_req(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
+ const char *field_name, const char *txt);
+
#endif /* WPAS_GLUE_H */
diff --git a/wpa_supplicant/wps_supplicant.c b/wpa_supplicant/wps_supplicant.c
index eabe986..60f761c 100644
--- a/wpa_supplicant/wps_supplicant.c
+++ b/wpa_supplicant/wps_supplicant.c
@@ -39,6 +39,14 @@
#define WPS_PIN_SCAN_IGNORE_SEL_REG 3
#endif /* WPS_PIN_SCAN_IGNORE_SEL_REG */
+/*
+ * The minimum time in seconds before trying to associate to a WPS PIN AP that
+ * does not have Selected Registrar TRUE.
+ */
+#ifndef WPS_PIN_TIME_IGNORE_SEL_REG
+#define WPS_PIN_TIME_IGNORE_SEL_REG 5
+#endif /* WPS_PIN_TIME_IGNORE_SEL_REG */
+
static void wpas_wps_timeout(void *eloop_ctx, void *timeout_ctx);
static void wpas_clear_wps(struct wpa_supplicant *wpa_s);
@@ -539,6 +547,7 @@ static int wpa_supplicant_wps_cred(void *ctx,
return -1;
}
}
+ ssid->priority = wpa_s->conf->wps_priority;
wpas_wps_security_workaround(wpa_s, ssid, cred);
@@ -552,6 +561,9 @@ static int wpa_supplicant_wps_cred(void *ctx,
}
#endif /* CONFIG_NO_CONFIG_WRITE */
+ if (ssid->priority)
+ wpa_config_update_prio_list(wpa_s->conf);
+
/*
* Optimize the post-WPS scan based on the channel used during
* the provisioning in case EAP-Failure is not received.
@@ -880,7 +892,8 @@ static int wpa_supplicant_wps_rf_band(void *ctx)
if (!wpa_s->current_ssid || !wpa_s->assoc_freq)
return 0;
- return (wpa_s->assoc_freq > 2484) ? WPS_RF_50GHZ : WPS_RF_24GHZ;
+ return (wpa_s->assoc_freq > 50000) ? WPS_RF_60GHZ :
+ (wpa_s->assoc_freq > 2484) ? WPS_RF_50GHZ : WPS_RF_24GHZ;
}
@@ -942,8 +955,20 @@ static void wpas_clear_wps(struct wpa_supplicant *wpa_s)
static void wpas_wps_timeout(void *eloop_ctx, void *timeout_ctx)
{
struct wpa_supplicant *wpa_s = eloop_ctx;
+ union wps_event_data data;
+
wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_TIMEOUT "Requested operation timed "
"out");
+ os_memset(&data, 0, sizeof(data));
+ data.fail.config_error = WPS_CFG_MSG_TIMEOUT;
+ data.fail.error_indication = WPS_EI_NO_ERROR;
+ /*
+ * Call wpas_notify_wps_event_fail() directly instead of through
+ * wpa_supplicant_wps_event() which would end up registering unnecessary
+ * timeouts (those are only for the case where the failure happens
+ * during an EAP-WSC exchange).
+ */
+ wpas_notify_wps_event_fail(wpa_s, &data.fail);
wpas_clear_wps(wpa_s);
}
@@ -1178,6 +1203,7 @@ static int wpas_wps_start_dev_pw(struct wpa_supplicant *wpa_s,
}
#ifdef CONFIG_P2P
if (p2p_group && wpa_s->go_params && wpa_s->go_params->ssid_len) {
+ os_free(ssid->ssid);
ssid->ssid = os_zalloc(wpa_s->go_params->ssid_len + 1);
if (ssid->ssid) {
ssid->ssid_len = wpa_s->go_params->ssid_len;
@@ -1216,11 +1242,28 @@ static int wpas_wps_start_dev_pw(struct wpa_supplicant *wpa_s,
int wpas_wps_start_pin(struct wpa_supplicant *wpa_s, const u8 *bssid,
const char *pin, int p2p_group, u16 dev_pw_id)
{
+ os_get_reltime(&wpa_s->wps_pin_start_time);
return wpas_wps_start_dev_pw(wpa_s, NULL, bssid, pin, p2p_group,
dev_pw_id, NULL, NULL, 0, 0);
}
+void wpas_wps_pbc_overlap(struct wpa_supplicant *wpa_s)
+{
+ union wps_event_data data;
+
+ os_memset(&data, 0, sizeof(data));
+ data.fail.config_error = WPS_CFG_MULTIPLE_PBC_DETECTED;
+ data.fail.error_indication = WPS_EI_NO_ERROR;
+ /*
+ * Call wpas_notify_wps_event_fail() directly instead of through
+ * wpa_supplicant_wps_event() which would end up registering unnecessary
+ * timeouts (those are only for the case where the failure happens
+ * during an EAP-WSC exchange).
+ */
+ wpas_notify_wps_event_fail(wpa_s, &data.fail);
+}
+
/* Cancel the wps pbc/pin requests */
int wpas_wps_cancel(struct wpa_supplicant *wpa_s)
{
@@ -1487,6 +1530,8 @@ int wpas_wps_init(struct wpa_supplicant *wpa_s)
wps->dev.rf_bands |= WPS_RF_24GHZ;
else if (modes[m].mode == HOSTAPD_MODE_IEEE80211A)
wps->dev.rf_bands |= WPS_RF_50GHZ;
+ else if (modes[m].mode == HOSTAPD_MODE_IEEE80211AD)
+ wps->dev.rf_bands |= WPS_RF_60GHZ;
}
}
if (wps->dev.rf_bands == 0) {
@@ -1609,9 +1654,15 @@ int wpas_wps_ssid_bss_match(struct wpa_supplicant *wpa_s,
* external Registrar.
*/
if (!wps_is_addr_authorized(wps_ie, wpa_s->own_addr, 1)) {
- if (wpa_s->scan_runs < WPS_PIN_SCAN_IGNORE_SEL_REG) {
- wpa_printf(MSG_DEBUG, " skip - WPS AP "
- "without active PIN Registrar");
+ struct os_reltime age;
+
+ os_reltime_age(&wpa_s->wps_pin_start_time, &age);
+
+ if (wpa_s->scan_runs < WPS_PIN_SCAN_IGNORE_SEL_REG ||
+ age.sec < WPS_PIN_TIME_IGNORE_SEL_REG) {
+ wpa_printf(MSG_DEBUG,
+ " skip - WPS AP without active PIN Registrar (scan_runs=%d age=%d)",
+ wpa_s->scan_runs, (int) age.sec);
wpabuf_free(wps_ie);
return 0;
}
@@ -1694,10 +1745,10 @@ int wpas_wps_ssid_wildcard_ok(struct wpa_supplicant *wpa_s,
int wpas_wps_scan_pbc_overlap(struct wpa_supplicant *wpa_s,
struct wpa_bss *selected, struct wpa_ssid *ssid)
{
- const u8 *sel_uuid, *uuid;
+ const u8 *sel_uuid;
struct wpabuf *wps_ie;
int ret = 0;
- struct wpa_bss *bss;
+ size_t i;
if (!eap_is_wps_pbc_enrollee(&ssid->eap))
return 0;
@@ -1718,40 +1769,28 @@ int wpas_wps_scan_pbc_overlap(struct wpa_supplicant *wpa_s,
sel_uuid = NULL;
}
- dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
- struct wpabuf *ie;
- if (bss == selected)
- continue;
- ie = wpa_bss_get_vendor_ie_multi(bss, WPS_IE_VENDOR_TYPE);
- if (!ie)
- continue;
- if (!wps_is_selected_pbc_registrar(ie)) {
- wpabuf_free(ie);
+ for (i = 0; i < wpa_s->num_wps_ap; i++) {
+ struct wps_ap_info *ap = &wpa_s->wps_ap[i];
+
+ if (!ap->pbc_active ||
+ os_memcmp(selected->bssid, ap->bssid, ETH_ALEN) == 0)
continue;
- }
+
wpa_printf(MSG_DEBUG, "WPS: Another BSS in active PBC mode: "
- MACSTR, MAC2STR(bss->bssid));
- uuid = wps_get_uuid_e(ie);
+ MACSTR, MAC2STR(ap->bssid));
wpa_hexdump(MSG_DEBUG, "WPS: UUID of the other BSS",
- uuid, UUID_LEN);
- if (os_memcmp(selected->bssid, bss->bssid, ETH_ALEN) == 0) {
- wpabuf_free(ie);
- continue;
- }
- if (sel_uuid == NULL || uuid == NULL ||
- os_memcmp(sel_uuid, uuid, UUID_LEN) != 0) {
+ ap->uuid, UUID_LEN);
+ if (sel_uuid == NULL ||
+ os_memcmp(sel_uuid, ap->uuid, UUID_LEN) != 0) {
ret = 1; /* PBC overlap */
wpa_msg(wpa_s, MSG_INFO, "WPS: PBC overlap detected: "
MACSTR " and " MACSTR,
MAC2STR(selected->bssid),
- MAC2STR(bss->bssid));
- wpabuf_free(ie);
+ MAC2STR(ap->bssid));
break;
}
/* TODO: verify that this is reasonable dual-band situation */
-
- wpabuf_free(ie);
}
wpabuf_free(wps_ie);
@@ -1910,7 +1949,7 @@ static int wpas_wps_network_to_cred(struct wpa_ssid *ssid,
struct wps_credential *cred)
{
os_memset(cred, 0, sizeof(*cred));
- if (ssid->ssid_len > 32)
+ if (ssid->ssid_len > SSID_MAX_LEN)
return -1;
os_memcpy(cred->ssid, ssid->ssid, ssid->ssid_len);
cred->ssid_len = ssid->ssid_len;
@@ -2582,6 +2621,10 @@ static int wpas_wps_nfc_rx_handover_sel(struct wpa_supplicant *wpa_s,
(attr.rf_bands == NULL ||
*attr.rf_bands & WPS_RF_50GHZ))
freq = 5000 + 5 * chan;
+ else if (chan >= 1 && chan <= 4 &&
+ (attr.rf_bands == NULL ||
+ *attr.rf_bands & WPS_RF_60GHZ))
+ freq = 56160 + 2160 * chan;
if (freq) {
wpa_printf(MSG_DEBUG,
@@ -2771,7 +2814,8 @@ static void wpas_wps_update_ap_info_bss(struct wpa_supplicant *wpa_s,
struct wpabuf *wps;
enum wps_ap_info_type type;
struct wps_ap_info *ap;
- int r;
+ int r, pbc_active;
+ const u8 *uuid;
if (wpa_scan_get_vendor_ie(res, WPS_IE_VENDOR_TYPE) == NULL)
return;
@@ -2788,7 +2832,8 @@ static void wpas_wps_update_ap_info_bss(struct wpa_supplicant *wpa_s,
else
type = WPS_AP_NOT_SEL_REG;
- wpabuf_free(wps);
+ uuid = wps_get_uuid_e(wps);
+ pbc_active = wps_is_selected_pbc_registrar(wps);
ap = wpas_wps_get_ap_info(wpa_s, res->bssid);
if (ap) {
@@ -2800,13 +2845,16 @@ static void wpas_wps_update_ap_info_bss(struct wpa_supplicant *wpa_s,
if (type != WPS_AP_NOT_SEL_REG)
wpa_blacklist_del(wpa_s, ap->bssid);
}
- return;
+ ap->pbc_active = pbc_active;
+ if (uuid)
+ os_memcpy(ap->uuid, uuid, WPS_UUID_LEN);
+ goto out;
}
ap = os_realloc_array(wpa_s->wps_ap, wpa_s->num_wps_ap + 1,
sizeof(struct wps_ap_info));
if (ap == NULL)
- return;
+ goto out;
wpa_s->wps_ap = ap;
ap = &wpa_s->wps_ap[wpa_s->num_wps_ap];
@@ -2815,8 +2863,14 @@ static void wpas_wps_update_ap_info_bss(struct wpa_supplicant *wpa_s,
os_memset(ap, 0, sizeof(*ap));
os_memcpy(ap->bssid, res->bssid, ETH_ALEN);
ap->type = type;
+ ap->pbc_active = pbc_active;
+ if (uuid)
+ os_memcpy(ap->uuid, uuid, WPS_UUID_LEN);
wpa_printf(MSG_DEBUG, "WPS: AP " MACSTR " type %d added",
MAC2STR(ap->bssid), ap->type);
+
+out:
+ wpabuf_free(wps);
}
diff --git a/wpa_supplicant/wps_supplicant.h b/wpa_supplicant/wps_supplicant.h
index 683bd50..3c25ca8 100644
--- a/wpa_supplicant/wps_supplicant.h
+++ b/wpa_supplicant/wps_supplicant.h
@@ -33,6 +33,7 @@ int wpas_wps_start_pbc(struct wpa_supplicant *wpa_s, const u8 *bssid,
int p2p_group);
int wpas_wps_start_pin(struct wpa_supplicant *wpa_s, const u8 *bssid,
const char *pin, int p2p_group, u16 dev_pw_id);
+void wpas_wps_pbc_overlap(struct wpa_supplicant *wpa_s);
int wpas_wps_cancel(struct wpa_supplicant *wpa_s);
int wpas_wps_start_reg(struct wpa_supplicant *wpa_s, const u8 *bssid,
const char *pin, struct wps_new_ap_settings *settings);