include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=crda
-PKG_RELEASE:=2
-PKG_VERSION:=1.1.0
+PKG_RELEASE:=1
+PKG_VERSION:=1.1.1
PKG_SOURCE_URL:=http://wireless.kernel.org/download/crda
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
-PKG_MD5SUM:=6004584d2e39e899f7642b141dd72028
+PKG_MD5SUM:=5fc77af68b3e21736b8ef2f8b061c810
PKG_BUILD_DEPENDS:=mac80211
PKG_REGULATORY_NAME:=regulatory
-PKG_REGULATORY_VERSION:=2010.11.17
-PKG_REGULATORY_SOURCE_URL:=http://mirror2.openwrt.org/sources
-#PKG_REGULATORY_SOURCE_URL:=http://wireless.kernel.org/download/wireless-regdb/regulatory.bins
+PKG_REGULATORY_VERSION:=2010.11.24
+PKG_REGULATORY_SOURCE_URL:=http://wireless.kernel.org/download/wireless-regdb/regulatory.bins
PKG_REGULATORY_SOURCE:=$(PKG_REGULATORY_VERSION)-$(PKG_REGULATORY_NAME).bin
-PKG_REGULATORY_MD5SUM:=4a497f045d93a8d5b135f4d2816faa83
+PKG_REGULATORY_MD5SUM:=001b69bba19486439031377e09229f9c
include $(INCLUDE_DIR)/package.mk
SECTION:=net
CATEGORY:=Network
TITLE:=Central Regulatory Domain Agent (CRDA)
- DEPENDS:=@LINUX_2_6 +hotplug2 +libnl-tiny
+ DEPENDS:=+libnl-tiny
URL:=http://wireless.kernel.org/en/developers/Regulatory/CRDA
endef
bool "Add rfkill support"
depends PACKAGE_wpa-supplicant || PACKAGE_wpa-supplicant-mini || PACKAGE_wpad || PACKAGE_wpad-mini
default n
+
+
+config DRIVER_WEXT_SUPPORT
+ bool
+ default n
+
+config DRIVER_11N_SUPPORT
+ bool
+ default n
include $(TOPDIR)/rules.mk
PKG_NAME:=hostapd
-PKG_VERSION:=20100705
-PKG_RELEASE:=2
-PKG_REV:=2f1ce78bf78cecd7021385b04a4f55f22e76ab97
+PKG_VERSION:=20110221
+PKG_RELEASE:=1
+PKG_REV:=cd9fc7869aa1e3935c028d4032d15c75e9946410
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=git://w1.fi/srv/git/hostap.git
PKG_SOURCE_SUBDIR:=hostapd-$(PKG_VERSION)
PKG_SOURCE_VERSION:=$(PKG_REV)
PKG_SOURCE_PROTO:=git
+PKG_MIRROR_MD5SUM:=f5f1462884d6e6808413e185b19ea3e3
PKG_BUILD_DEPENDS:= \
PACKAGE_kmod-madwifi:madwifi \
PKG_CONFIG_DEPENDS:= \
CONFIG_WPA_SUPPLICANT_NO_TIMESTAMP_CHECK \
CONFIG_PACKAGE_kmod-ath9k \
- CONFIG_PACKAGE_kmod-rt2800-lib \
CONFIG_PACKAGE_kmod-mac80211 \
CONFIG_PACKAGE_kmod-madwifi \
CONFIG_PACKAGE_hostapd \
CONFIG_PACKAGE_hostapd-mini \
CONFIG_PACKAGE_kmod-hostap \
- CONFIG_WPA_RFKILL_SUPPORT
+ CONFIG_WPA_RFKILL_SUPPORT \
+ CONFIG_DRIVER_WEXT_SUPPORT \
+ CONFIG_DRIVER_11N_SUPPORT
LOCAL_TYPE=$(strip \
$(if $(findstring wpad,$(BUILD_VARIANT)),wpad, \
include $(INCLUDE_DIR)/package.mk
-ifneq ($(CONFIG_PACKAGE_kmod-rt2800-lib),)
- HOSTAPD_IEEE80211N:=y
-endif
-
-ifneq ($(CONFIG_PACKAGE_kmod-ath9k),)
+ifneq ($(CONFIG_DRIVER_11N_SUPPORT),)
HOSTAPD_IEEE80211N:=y
endif
CONFIG_DRIVER_HOSTAP=$(CONFIG_PACKAGE_kmod-hostap) \
CONFIG_IEEE80211N=$(HOSTAPD_IEEE80211N) \
CONFIG_IEEE80211W=$(CONFIG_PACKAGE_kmod-ath9k) \
+ CONFIG_DRIVER_WEXT=$(CONFIG_DRIVER_WEXT_SUPPORT) \
$(if $(CONFIG_WPA_RFKILL_SUPPORT),NEED_RFKILL=y)
ifneq ($(LOCAL_TYPE),hostapd)
-DCONFIG_LIBNL20 \
-D_GNU_SOURCE
+TARGET_CFLAGS += -ffunction-sections -fdata-sections
+TARGET_LDFLAGS += -Wl,--gc-sections
+
ifdef CONFIG_PACKAGE_kmod-mac80211
TARGET_LDFLAGS += -lm -lnl-tiny
endif
NEED_AES_DEC=y
CONFIG_WPS=y
+CONFIG_FULL_DYNAMIC_VLAN=y
+
config_get device "$vif" device
config_get hwmode "$device" hwmode
+ config_get phy "$device" phy
+
+ append "$var" "ctrl_interface=/var/run/hostapd-$phy" "$N"
if [ "$ap_isolate" -gt 0 ]; then
append "$var" "ap_isolate=$ap_isolate" "$N"
config_get iapp_interface "$vif" iapp_interface
config_get_bool wps_pbc "$vif" wps_pushbutton 0
- [ -n "$wps_possible" -a "$wps_pbc" -gt 0 ] && {
+ config_get_bool wps_label "$vif" wps_label 0
+
+ config_get config_methods "$vif" wps_config
+ [ "$wps_pbc" -gt 0 ] && append config_methods push_button
+
+ [ -n "$wps_possible" -a -n "$config_methods" ] && {
+ config_get device_type "$vif" wps_device_type "6-0050F204-1"
+ config_get device_name "$vif" wps_device_name "OpenWrt AP"
+ config_get manufacturer "$vif" wps_manufacturer "openwrt.org"
+
append "$var" "eap_server=1" "$N"
append "$var" "wps_state=2" "$N"
append "$var" "ap_setup_locked=1" "$N"
- append "$var" "config_methods=push_button" "$N"
+ append "$var" "device_type=$device_type" "$N"
+ append "$var" "device_name=$device_name" "$N"
+ append "$var" "manufacturer=$manufacturer" "$N"
+ append "$var" "config_methods=$config_methods" "$N"
}
append "$var" "ssid=$ssid" "$N"
[ -n "$bridge" ] && append "$var" "bridge=$bridge" "$N"
[ -n "$ieee80211d" ] && append "$var" "ieee80211d=$ieee80211d" "$N"
- [ -n "$iapp_interface" ] && append "$var" $(uci_get_state network "$iapp_interface" ifname "$iapp_interface") "$N"
-
- [ "$wpa" -ge "2" ] && config_get ieee80211w "$vif" ieee80211w
- case "$ieee80211w" in
- [012])
- append "$var" "ieee80211w=$ieee80211w" "$N"
- [ "$ieee80211w" -gt "0" ] && {
- config_get ieee80211w_max_timeout "$vif" ieee80211w_max_timeout
- config_get ieee80211w_retry_timeout "$vif" ieee80211w_retry_timeout
- [ -n "$ieee80211w_max_timeout" ] && \
- append "$var" "assoc_sa_query_max_timeout=$ieee80211w_max_timeout" "$N"
- [ -n "$ieee80211w_retry_timeout" ] && \
- append "$var" "assoc_sa_query_retry_timeout=$ieee80211w_retry_timeout" "$N"
- }
- ;;
- esac
+ [ -n "$iapp_interface" ] && append "$var" iapp_interface=$(uci_get_state network "$iapp_interface" ifname "$iapp_interface") "$N"
+
+ if [ "$wpa" -ge "2" ]
+ then
+ # RSN -> allow preauthentication
+ config_get rsn_preauth "$vif" rsn_preauth
+ if [ -n "$bridge" -a "$rsn_preauth" = 1 ]
+ then
+ append "$var" "rsn_preauth=1" "$N"
+ append "$var" "rsn_preauth_interfaces=$bridge" "$N"
+ fi
+
+ # RSN -> allow management frame protection
+ config_get ieee80211w "$vif" ieee80211w
+ case "$ieee80211w" in
+ [012])
+ append "$var" "ieee80211w=$ieee80211w" "$N"
+ [ "$ieee80211w" -gt "0" ] && {
+ config_get ieee80211w_max_timeout "$vif" ieee80211w_max_timeout
+ config_get ieee80211w_retry_timeout "$vif" ieee80211w_retry_timeout
+ [ -n "$ieee80211w_max_timeout" ] && \
+ append "$var" "assoc_sa_query_max_timeout=$ieee80211w_max_timeout" "$N"
+ [ -n "$ieee80211w_retry_timeout" ] && \
+ append "$var" "assoc_sa_query_retry_timeout=$ieee80211w_retry_timeout" "$N"
+ }
+ ;;
+ esac
+ fi
}
hostapd_setup_vif() {
[ "$channel" = auto ] && channel=
[ -n "$channel" -a -z "$hwmode" ] && wifi_fixup_hwmode "$device"
cat > /var/run/hostapd-$ifname.conf <<EOF
-ctrl_interface=/var/run/hostapd-$ifname
driver=$driver
interface=$ifname
${hwmode:+hw_mode=${hwmode#11}}
tls)
pairwise='pairwise=CCMP'
group='group=CCMP'
+ config_get identity "$vif" identity
config_get priv_key "$vif" priv_key
config_get priv_key_pwd "$vif" priv_key_pwd
+ identity="identity=\"$identity\""
priv_key="private_key=\"$priv_key\""
priv_key_pwd="private_key_passwd=\"$priv_key_pwd\""
;;
+++ /dev/null
---- a/src/drivers/nl80211_copy.h
-+++ b/src/drivers/nl80211_copy.h
-@@ -709,6 +709,9 @@ enum nl80211_commands {
- * NL80211_CMD_AUTHENTICATE, NL80211_CMD_DEAUTHENTICATE,
- * NL80211_CMD_DISASSOCIATE.
- *
-+ * @NL80211_ATTR_AP_ISOLATE: (AP mode) Do not forward traffic between stations
-+ * connected to this BSS.
-+ *
- * @NL80211_ATTR_MAX: highest attribute number currently defined
- * @__NL80211_ATTR_AFTER_LAST: internal use
- */
-@@ -864,6 +867,8 @@ enum nl80211_attrs {
-
- NL80211_ATTR_LOCAL_STATE_CHANGE,
-
-+ NL80211_ATTR_AP_ISOLATE,
-+
- /* add attributes here, update the policy in nl80211.c */
-
- __NL80211_ATTR_AFTER_LAST,
+++ /dev/null
---- a/src/drivers/driver_madwifi.c
-+++ b/src/drivers/driver_madwifi.c
-@@ -1177,8 +1177,6 @@ madwifi_init(struct hostapd_data *hapd,
- goto bad;
- }
-
-- /* mark down during setup */
-- linux_set_iface_flags(drv->ioctl_sock, drv->iface, 0);
- madwifi_set_privacy(drv, 0); /* default to no privacy */
-
- madwifi_receive_probe_req(drv);
-@@ -1268,8 +1266,7 @@ madwifi_set_countermeasures(void *priv,
- static int
- madwifi_commit(void *priv)
- {
-- struct madwifi_driver_data *drv = priv;
-- return linux_set_iface_flags(drv->ioctl_sock, drv->iface, 1);
-+ return 0;
- }
-
- #else /* HOSTAPD */
+++ /dev/null
---- a/src/ap/hostapd.c
-+++ b/src/ap/hostapd.c
-@@ -660,7 +660,6 @@ static int setup_interface(struct hostap
- country[3] = '\0';
- if (hostapd_set_country(hapd, country) < 0) {
- wpa_printf(MSG_ERROR, "Failed to set country code");
-- return -1;
- }
- }
-
+++ /dev/null
---- a/src/drivers/driver_nl80211.c
-+++ b/src/drivers/driver_nl80211.c
-@@ -22,6 +22,7 @@
- #include <netlink/genl/genl.h>
- #include <netlink/genl/family.h>
- #include <netlink/genl/ctrl.h>
-+#include <linux/rtnetlink.h>
- #include <netpacket/packet.h>
- #include <linux/filter.h>
- #include "nl80211_copy.h"
---- a/src/drivers/driver_madwifi.c
-+++ b/src/drivers/driver_madwifi.c
-@@ -69,6 +69,7 @@
- #define MADWIFI_NG
- #endif /* IEEE80211_IOCTL_SETWMMPARAMS */
-
-+#define WPA_KEY_RSC_LEN 8
-
- #ifdef HOSTAPD
-
-@@ -1506,7 +1507,6 @@ wpa_driver_madwifi_set_key(const char *i
- wk.ik_keyix = key_idx;
- wk.ik_keylen = key_len;
- #ifdef WORDS_BIGENDIAN
--#define WPA_KEY_RSC_LEN 8
- {
- size_t i;
- u8 tmp[WPA_KEY_RSC_LEN];
+++ /dev/null
---- a/src/ap/hostapd.h
-+++ b/src/ap/hostapd.h
-@@ -245,6 +245,7 @@ struct hostapd_iface {
- int (*for_each_interface)(struct hapd_interfaces *interfaces,
- int (*cb)(struct hostapd_iface *iface,
- void *ctx), void *ctx);
-+ int (*init_complete)(struct hostapd_iface *iface);
- };
-
- /* hostapd.c */
---- a/src/ap/hostapd.c
-+++ b/src/ap/hostapd.c
-@@ -755,6 +755,9 @@ int hostapd_setup_interface_complete(str
- wpa_printf(MSG_DEBUG, "%s: Setup of interface done.",
- iface->bss[0]->conf->iface);
-
-+ if (iface->init_complete)
-+ iface->init_complete(iface);
-+
- return 0;
- }
-
---- a/hostapd/main.c
-+++ b/hostapd/main.c
-@@ -35,6 +35,8 @@
- extern int wpa_debug_level;
- extern int wpa_debug_show_keys;
- extern int wpa_debug_timestamp;
-+static int daemonize = 0;
-+static char *pid_file = NULL;
-
-
- struct hapd_interfaces {
-@@ -162,6 +164,15 @@ static void hostapd_logger_cb(void *ctx,
- }
- #endif /* CONFIG_NO_HOSTAPD_LOGGER */
-
-+static int hostapd_init_complete(struct hostapd_iface *iface)
-+{
-+ if (daemonize && os_daemonize(pid_file)) {
-+ perror("daemon");
-+ return -1;
-+ }
-+ daemonize = 0;
-+}
-+
-
- /**
- * hostapd_init - Allocate and initialize per-interface data
-@@ -183,6 +194,7 @@ static struct hostapd_iface * hostapd_in
- if (hapd_iface == NULL)
- goto fail;
-
-+ hapd_iface->init_complete = hostapd_init_complete;
- hapd_iface->reload_config = hostapd_reload_config;
- hapd_iface->config_read_cb = hostapd_config_read;
- hapd_iface->config_fname = os_strdup(config_file);
-@@ -391,7 +403,7 @@ static int hostapd_global_init(struct ha
- }
-
-
--static void hostapd_global_deinit(const char *pid_file)
-+static void hostapd_global_deinit(void)
- {
- #ifdef EAP_SERVER_TNC
- tncs_global_deinit();
-@@ -409,8 +421,7 @@ static void hostapd_global_deinit(const
- }
-
-
--static int hostapd_global_run(struct hapd_interfaces *ifaces, int daemonize,
-- const char *pid_file)
-+static int hostapd_global_run(struct hapd_interfaces *iface)
- {
- #ifdef EAP_SERVER_TNC
- int tnc = 0;
-@@ -431,11 +442,6 @@ static int hostapd_global_run(struct hap
- }
- #endif /* EAP_SERVER_TNC */
-
-- if (daemonize && os_daemonize(pid_file)) {
-- perror("daemon");
-- return -1;
-- }
--
- eloop_run();
-
- return 0;
-@@ -479,8 +485,7 @@ int main(int argc, char *argv[])
- struct hapd_interfaces interfaces;
- int ret = 1;
- size_t i;
-- int c, debug = 0, daemonize = 0;
-- char *pid_file = NULL;
-+ int c, debug = 0;
-
- if (os_program_init())
- return -1;
-@@ -545,7 +550,7 @@ int main(int argc, char *argv[])
- goto out;
- }
-
-- if (hostapd_global_run(&interfaces, daemonize, pid_file))
-+ if (hostapd_global_run(&interfaces))
- goto out;
-
- ret = 0;
-@@ -556,7 +561,7 @@ int main(int argc, char *argv[])
- hostapd_interface_deinit_free(interfaces.iface[i]);
- os_free(interfaces.iface);
-
-- hostapd_global_deinit(pid_file);
-+ hostapd_global_deinit();
- os_free(pid_file);
-
- os_program_deinit();
---- a/hostapd/config_file.c
-+++ b/hostapd/config_file.c
-@@ -1857,6 +1857,8 @@ struct hostapd_config * hostapd_config_r
- }
- #endif /* CONFIG_IEEE80211W */
- #ifdef CONFIG_IEEE80211N
-+ } else if (os_strcmp(buf, "noscan") == 0) {
-+ conf->noscan = atoi(pos);
- } else if (os_strcmp(buf, "ieee80211n") == 0) {
- conf->ieee80211n = atoi(pos);
- } else if (os_strcmp(buf, "ht_capab") == 0) {
---- a/src/ap/ap_config.h
-+++ b/src/ap/ap_config.h
-@@ -369,6 +369,7 @@ struct hostapd_config {
-
- int ht_op_mode_fixed;
- u16 ht_capab;
-+ int noscan;
- int ieee80211n;
- int secondary_channel;
- };
---- a/src/ap/hw_features.c
-+++ b/src/ap/hw_features.c
-@@ -460,7 +460,7 @@ static int ieee80211n_check_40mhz(struct
- {
- struct wpa_driver_scan_params params;
-
-- if (!iface->conf->secondary_channel)
-+ if (!iface->conf->secondary_channel || iface->conf->noscan)
- return 0; /* HT40 not used */
-
- wpa_printf(MSG_DEBUG, "Scan for neighboring BSSes prior to enabling "
+++ /dev/null
---- a/hostapd/Makefile
-+++ b/hostapd/Makefile
-@@ -14,6 +14,7 @@ CFLAGS += -I../src/utils
- # CFLAGS += -DUSE_KERNEL_HEADERS -I/usr/src/linux/include
-
- -include .config
-+-include $(if $(MULTICALL), ../wpa_supplicant/.config)
-
- ifndef CONFIG_OS
- ifdef CONFIG_NATIVE_WINDOWS
-@@ -157,10 +158,14 @@ ifdef CONFIG_IEEE80211N
- CFLAGS += -DCONFIG_IEEE80211N
- endif
-
-+ifndef MULTICALL
-+CFLAGS += -DNO_SUPPLICANT
-+endif
-+
- include ../src/drivers/drivers.mak
--OBJS += $(DRV_AP_OBJS)
--CFLAGS += $(DRV_AP_CFLAGS)
--LDFLAGS += $(DRV_AP_LDFLAGS)
-+OBJS += $(sort $(DRV_AP_OBJS) $(if $(MULTICALL),$(DRV_WPA_OBJS)))
-+CFLAGS += $(DRV_AP_CFLAGS) $(if $(MULTICALL),$(DRV_WPA_CFLAGS))
-+LDFLAGS += $(DRV_AP_LDFLAGS) $(if $(MULTICALL),$(DRV_WPA_LDFLAGS))
- LIBS += $(DRV_AP_LIBS)
-
- ifdef CONFIG_L2_PACKET
-@@ -739,6 +744,12 @@ install: all
-
- BCHECK=../src/drivers/build.hostapd
-
-+hostapd_multi.a: $(BCHECK) $(OBJS)
-+ $(Q)$(CC) -c -o hostapd_multi.o -Dmain=hostapd_main $(CFLAGS) main.c
-+ @$(E) " CC " $<
-+ @rm -f $@
-+ @$(AR) cr $@ hostapd_multi.o $(OBJS)
-+
- hostapd: $(BCHECK) $(OBJS)
- $(CC) $(LDFLAGS) -o hostapd $(OBJS) $(LIBS)
-
-@@ -777,6 +788,12 @@ HOBJS += ../src/crypto/aes-internal.o
- HOBJS += ../src/crypto/aes-internal-enc.o
- endif
-
-+dump_cflags:
-+ @echo -n $(CFLAGS) " "
-+
-+dump_ldflags:
-+ @echo -n $(LDFLAGS) $(LIBS) $(EXTRALIBS) " "
-+
- nt_password_hash: $(NOBJS)
- $(CC) $(LDFLAGS) -o nt_password_hash $(NOBJS) $(LIBS_n)
-
---- a/wpa_supplicant/Makefile
-+++ b/wpa_supplicant/Makefile
-@@ -52,6 +52,7 @@ OBJS_p += ../src/utils/wpabuf.o
- OBJS_c = wpa_cli.o ../src/common/wpa_ctrl.o
-
- -include .config
-+-include $(if $(MULTICALL),../hostapd/.config)
-
- ifndef CONFIG_OS
- ifdef CONFIG_NATIVE_WINDOWS
-@@ -581,6 +582,10 @@ ifdef CONFIG_DYNAMIC_EAP_METHODS
- CFLAGS += -DCONFIG_DYNAMIC_EAP_METHODS
- LIBS += -ldl -rdynamic
- endif
-+else
-+ ifdef MULTICALL
-+ OBJS += ../src/eap_common/eap_common.o
-+ endif
- endif
-
- ifdef CONFIG_AP
-@@ -635,6 +640,12 @@ CFLAGS += -DEAP_SERVER_WSC
- OBJS += ../src/ap/wps_hostapd.o
- OBJS += ../src/eap_server/eap_server_wsc.o
- endif
-+else
-+ ifdef MULTICALL
-+ OBJS += ../src/eap_server/eap_server.o
-+ OBJS += ../src/eap_server/eap_server_identity.o
-+ OBJS += ../src/eap_server/eap_server_methods.o
-+ endif
- endif
-
- ifdef NEED_RSN_AUTHENTICATOR
-@@ -1270,6 +1281,12 @@ BCHECK=../src/drivers/build.wpa_supplica
- wpa_priv: $(BCHECK) $(OBJS_priv)
- $(LDO) $(LDFLAGS) -o wpa_priv $(OBJS_priv) $(LIBS)
-
-+wpa_supplicant_multi.a: .config $(BCHECK) $(OBJS) $(EXTRA_progs)
-+ $(Q)$(CC) -c -o wpa_supplicant_multi.o -Dmain=wpa_supplicant_main $(CFLAGS) main.c
-+ @$(E) " CC " $<
-+ @rm -f $@
-+ @$(AR) cr $@ wpa_supplicant_multi.o $(OBJS)
-+
- wpa_supplicant: .config $(BCHECK) $(OBJS) $(EXTRA_progs)
- $(LDO) $(LDFLAGS) -o wpa_supplicant $(OBJS) $(LIBS) $(EXTRALIBS)
-
-@@ -1329,6 +1346,12 @@ endif
- $(Q)$(CC) -c -o $@ $(CFLAGS) $<
- @$(E) " CC " $<
-
-+dump_cflags:
-+ @echo -n $(CFLAGS) " "
-+
-+dump_ldflags:
-+ @echo -n $(LDFLAGS) $(LIBS) $(EXTRALIBS) " "
-+
- wpa_supplicant.exe: wpa_supplicant
- mv -f $< $@
- wpa_cli.exe: wpa_cli
---- a/src/drivers/driver.h
-+++ b/src/drivers/driver.h
-@@ -2465,8 +2465,8 @@ union wpa_event_data {
- * Driver wrapper code should call this function whenever an event is received
- * from the driver.
- */
--void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
-- union wpa_event_data *data);
-+extern void (*wpa_supplicant_event)(void *ctx, enum wpa_event_type event,
-+ union wpa_event_data *data);
-
-
- /*
---- a/src/ap/drv_callbacks.c
-+++ b/src/ap/drv_callbacks.c
-@@ -375,8 +375,8 @@ static void hostapd_event_eapol_rx(struc
- }
-
-
--void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
-- union wpa_event_data *data)
-+void hostapd_wpa_event(void *ctx, enum wpa_event_type event,
-+ union wpa_event_data *data)
- {
- struct hostapd_data *hapd = ctx;
-
-@@ -453,5 +453,6 @@ void wpa_supplicant_event(void *ctx, enu
- break;
- }
- }
--
- #endif /* HOSTAPD */
-+
-+
---- a/wpa_supplicant/wpa_priv.c
-+++ b/wpa_supplicant/wpa_priv.c
-@@ -825,8 +825,8 @@ static void wpa_priv_send_ft_response(st
- }
-
-
--void wpa_supplicant_event(void *ctx, wpa_event_type event,
-- union wpa_event_data *data)
-+static void supplicant_event(void *ctx, wpa_event_type event,
-+ union wpa_event_data *data)
- {
- struct wpa_priv_interface *iface = ctx;
-
-@@ -968,6 +968,7 @@ int main(int argc, char *argv[])
- if (os_program_init())
- return -1;
-
-+ wpa_supplicant_event = supplicant_event;
- wpa_priv_fd_workaround();
-
- for (;;) {
---- a/wpa_supplicant/events.c
-+++ b/wpa_supplicant/events.c
-@@ -1582,8 +1582,8 @@ static void ft_rx_action(struct wpa_supp
- #endif /* CONFIG_IEEE80211R */
-
-
--void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
-- union wpa_event_data *data)
-+void supplicant_event(void *ctx, enum wpa_event_type event,
-+ union wpa_event_data *data)
- {
- struct wpa_supplicant *wpa_s = ctx;
- u16 reason_code = 0;
---- a/wpa_supplicant/wpa_supplicant.c
-+++ b/wpa_supplicant/wpa_supplicant.c
-@@ -2228,6 +2228,9 @@ struct wpa_supplicant * wpa_supplicant_g
- return NULL;
- }
-
-+extern void supplicant_event(void *ctx, enum wpa_event_type event,
-+ union wpa_event_data *data);
-+
-
- /**
- * wpa_supplicant_init - Initialize %wpa_supplicant
-@@ -2246,6 +2249,7 @@ struct wpa_global * wpa_supplicant_init(
- if (params == NULL)
- return NULL;
-
-+ wpa_supplicant_event = supplicant_event;
- wpa_debug_open_file(params->wpa_debug_file_path);
- if (params->wpa_debug_syslog)
- wpa_debug_open_syslog();
---- a/hostapd/main.c
-+++ b/hostapd/main.c
-@@ -479,6 +479,9 @@ static void usage(void)
- exit(1);
- }
-
-+void hostapd_wpa_event(void *ctx, enum wpa_event_type event,
-+ union wpa_event_data *data);
-+
-
- int main(int argc, char *argv[])
- {
-@@ -490,6 +493,7 @@ int main(int argc, char *argv[])
- if (os_program_init())
- return -1;
-
-+ wpa_supplicant_event = hostapd_wpa_event;
- for (;;) {
- c = getopt(argc, argv, "BdhKP:tv");
- if (c < 0)
---- a/src/drivers/drivers.c
-+++ b/src/drivers/drivers.c
-@@ -13,7 +13,11 @@
- */
-
- #include "includes.h"
-+#include "common.h"
-+#include "driver.h"
-
-+void (*wpa_supplicant_event)(void *ctx, enum wpa_event_type event,
-+ union wpa_event_data *data);
-
- #ifdef CONFIG_DRIVER_WEXT
- extern struct wpa_driver_ops wpa_driver_wext_ops; /* driver_wext.c */
--- /dev/null
+--- a/wpa_supplicant/scan.c
++++ b/wpa_supplicant/scan.c
+@@ -251,6 +251,7 @@ static void wpa_supplicant_scan(void *el
+ enum wps_request_type req_type = WPS_REQ_ENROLLEE_INFO;
+ #endif /* CONFIG_WPS */
+ struct wpa_driver_scan_params params;
++ int scan_ssid_all = 1;
+ size_t max_ssids;
+ enum wpa_states prev_state;
+
+@@ -307,6 +308,16 @@ static void wpa_supplicant_scan(void *el
+ wpa_s->wpa_state == WPA_INACTIVE)
+ wpa_supplicant_set_state(wpa_s, WPA_SCANNING);
+
++ /* check if all configured ssids should be scanned directly */
++ ssid = wpa_s->conf->ssid;
++ while (ssid) {
++ if (!ssid->scan_ssid) {
++ scan_ssid_all = 0;
++ break;
++ }
++ ssid = ssid->next;
++ }
++
+ /* Find the starting point from which to continue scanning */
+ ssid = wpa_s->conf->ssid;
+ if (wpa_s->prev_scan_ssid != WILDCARD_SSID_SCAN) {
+@@ -370,6 +381,9 @@ static void wpa_supplicant_scan(void *el
+ int_array_sort_unique(params.freqs);
+ }
+
++ if (scan_ssid_all && !ssid)
++ ssid = wpa_s->conf->ssid;
++
+ if (ssid) {
+ wpa_s->prev_scan_ssid = ssid;
+ if (max_ssids > 1) {
+++ /dev/null
---- a/src/tls/x509v3.c
-+++ b/src/tls/x509v3.c
-@@ -1854,8 +1854,11 @@ int x509_certificate_chain_validate(stru
- if (chain_trusted)
- continue;
-
-- if ((unsigned long) now.sec <
-+ if (
-+#ifndef NO_TIMESTAMP_CHECK
-+ (unsigned long) now.sec <
- (unsigned long) cert->not_before ||
-+#endif
- (unsigned long) now.sec >
- (unsigned long) cert->not_after) {
- wpa_printf(MSG_INFO, "X509: Certificate not valid "
--- /dev/null
+--- a/src/drivers/driver_madwifi.c
++++ b/src/drivers/driver_madwifi.c
+@@ -71,7 +71,6 @@
+
+ #define WPA_KEY_RSC_LEN 8
+
+-#ifdef HOSTAPD
+
+ #include "priv_netlink.h"
+ #include "netlink.h"
+@@ -82,17 +81,22 @@
+ struct madwifi_driver_data {
+ struct hostapd_data *hapd; /* back pointer */
+
+- char iface[IFNAMSIZ + 1];
++ void *wext; /* private data for driver_wext */
++ void *ctx;
++ char ifname[IFNAMSIZ + 1];
++ int ioctl_sock; /* socket for ioctl() use */
++
++#ifdef HOSTAPD
+ int ifindex;
+ struct l2_packet_data *sock_xmit; /* raw packet xmit socket */
+ struct l2_packet_data *sock_recv; /* raw packet recv socket */
+- int ioctl_sock; /* socket for ioctl() use */
+ struct netlink_data *netlink;
+ int we_version;
+ u8 acct_mac[ETH_ALEN];
+ struct hostap_sta_driver_data acct_data;
+
+ struct l2_packet_data *sock_raw; /* raw 802.11 management frames */
++#endif
+ };
+
+ static int madwifi_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr,
+@@ -105,7 +109,7 @@ set80211priv(struct madwifi_driver_data
+ int do_inline = len < IFNAMSIZ;
+
+ memset(&iwr, 0, sizeof(iwr));
+- os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
++ os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
+ #ifdef IEEE80211_IOCTL_FILTERFRAME
+ /* FILTERFRAME must be NOT inline, regardless of size. */
+ if (op == IEEE80211_IOCTL_FILTERFRAME)
+@@ -206,7 +210,7 @@ set80211param(struct madwifi_driver_data
+ struct iwreq iwr;
+
+ memset(&iwr, 0, sizeof(iwr));
+- os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
++ os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
+ iwr.u.mode = op;
+ memcpy(iwr.u.name+sizeof(__u32), &arg, sizeof(arg));
+
+@@ -233,6 +237,7 @@ ether_sprintf(const u8 *addr)
+ }
+ #endif /* CONFIG_NO_STDOUT_DEBUG */
+
++#ifdef HOSTAPD
+ /*
+ * Configure WPA parameters.
+ */
+@@ -395,7 +400,7 @@ madwifi_sta_set_flags(void *priv, const
+ return madwifi_set_sta_authorized(priv, addr, 0);
+ return 0;
+ }
+-
++#endif /* HOSTAPD */
+ static int
+ madwifi_del_key(void *priv, const u8 *addr, int key_idx)
+ {
+@@ -407,28 +412,20 @@ madwifi_del_key(void *priv, const u8 *ad
+ __func__, ether_sprintf(addr), key_idx);
+
+ memset(&wk, 0, sizeof(wk));
++ wk.idk_keyix = key_idx;
+ if (addr != NULL) {
+ memcpy(wk.idk_macaddr, addr, IEEE80211_ADDR_LEN);
+- wk.idk_keyix = (u8) IEEE80211_KEYIX_NONE;
+- } else {
+- wk.idk_keyix = key_idx;
+- }
+-
+- ret = set80211priv(drv, IEEE80211_IOCTL_DELKEY, &wk, sizeof(wk));
+- if (ret < 0) {
+- wpa_printf(MSG_DEBUG, "%s: Failed to delete key (addr %s"
+- " key_idx %d)", __func__, ether_sprintf(addr),
+- key_idx);
+ }
+
+- return ret;
++ set80211priv(drv, IEEE80211_IOCTL_DELKEY, &wk, sizeof(wk));
++ return 0;
+ }
+
+ static int
+-wpa_driver_madwifi_set_key(const char *ifname, void *priv, enum wpa_alg alg,
+- const u8 *addr, int key_idx, int set_tx,
+- const u8 *seq, size_t seq_len,
+- const u8 *key, size_t key_len)
++madwifi_set_key(const char *ifname, void *priv, enum wpa_alg alg,
++ const u8 *addr, int key_idx, int set_tx,
++ const u8 *seq, size_t seq_len,
++ const u8 *key, size_t key_len)
+ {
+ struct madwifi_driver_data *drv = priv;
+ struct ieee80211req_key wk;
+@@ -466,6 +463,9 @@ wpa_driver_madwifi_set_key(const char *i
+ memset(wk.ik_macaddr, 0xff, IEEE80211_ADDR_LEN);
+ wk.ik_keyix = key_idx;
+ wk.ik_flags |= IEEE80211_KEY_DEFAULT;
++ } else if (!memcmp(addr, "\xff\xff\xff\xff\xff\xff", ETH_ALEN)) {
++ wk.ik_flags |= IEEE80211_KEY_GROUP;
++ memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
+ } else {
+ memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
+ wk.ik_keyix = IEEE80211_KEYIX_NONE;
+@@ -485,6 +485,7 @@ wpa_driver_madwifi_set_key(const char *i
+ }
+
+
++#ifdef HOSTAPD
+ static int
+ madwifi_get_seqnum(const char *ifname, void *priv, const u8 *addr, int idx,
+ u8 *seq)
+@@ -591,7 +592,7 @@ madwifi_read_sta_driver_data(void *priv,
+
+ memset(data, 0, sizeof(*data));
+ snprintf(buf, sizeof(buf), "/proc/net/madwifi/%s/" MACSTR,
+- drv->iface, MAC2STR(addr));
++ drv->ifname, MAC2STR(addr));
+
+ f = fopen(buf, "r");
+ if (!f) {
+@@ -757,7 +758,7 @@ static int madwifi_receive_probe_req(str
+ if (ret)
+ return ret;
+
+- drv->sock_raw = l2_packet_init(drv->iface, NULL, ETH_P_80211_RAW,
++ drv->sock_raw = l2_packet_init(drv->ifname, NULL, ETH_P_80211_RAW,
+ madwifi_raw_receive, drv, 1);
+ if (drv->sock_raw == NULL)
+ return -1;
+@@ -1017,7 +1018,7 @@ madwifi_get_we_version(struct madwifi_dr
+ return -1;
+
+ memset(&iwr, 0, sizeof(iwr));
+- os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
++ os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
+ iwr.u.data.pointer = (caddr_t) range;
+ iwr.u.data.length = buflen;
+
+@@ -1134,17 +1135,17 @@ madwifi_init(struct hostapd_data *hapd,
+ perror("socket[PF_INET,SOCK_DGRAM]");
+ goto bad;
+ }
+- memcpy(drv->iface, params->ifname, sizeof(drv->iface));
++ memcpy(drv->ifname, params->ifname, sizeof(drv->ifname));
+
+ memset(&ifr, 0, sizeof(ifr));
+- os_strlcpy(ifr.ifr_name, drv->iface, sizeof(ifr.ifr_name));
++ os_strlcpy(ifr.ifr_name, drv->ifname, sizeof(ifr.ifr_name));
+ if (ioctl(drv->ioctl_sock, SIOCGIFINDEX, &ifr) != 0) {
+ perror("ioctl(SIOCGIFINDEX)");
+ goto bad;
+ }
+ drv->ifindex = ifr.ifr_ifindex;
+
+- drv->sock_xmit = l2_packet_init(drv->iface, NULL, ETH_P_EAPOL,
++ drv->sock_xmit = l2_packet_init(drv->ifname, NULL, ETH_P_EAPOL,
+ handle_read, drv, 1);
+ if (drv->sock_xmit == NULL)
+ goto bad;
+@@ -1158,7 +1159,7 @@ madwifi_init(struct hostapd_data *hapd,
+ 1);
+ if (drv->sock_recv == NULL)
+ goto bad;
+- } else if (linux_br_get(brname, drv->iface) == 0) {
++ } else if (linux_br_get(brname, drv->ifname) == 0) {
+ wpa_printf(MSG_DEBUG, "Interface in bridge %s; configure for "
+ "EAPOL receive", brname);
+ drv->sock_recv = l2_packet_init(brname, NULL, ETH_P_EAPOL,
+@@ -1169,7 +1170,7 @@ madwifi_init(struct hostapd_data *hapd,
+ drv->sock_recv = drv->sock_xmit;
+
+ memset(&iwr, 0, sizeof(iwr));
+- os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
++ os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
+
+ iwr.u.mode = IW_MODE_MASTER;
+
+@@ -1180,7 +1181,7 @@ madwifi_init(struct hostapd_data *hapd,
+ }
+
+ /* mark down during setup */
+- linux_set_iface_flags(drv->ioctl_sock, drv->iface, 0);
++ linux_set_iface_flags(drv->ioctl_sock, drv->ifname, 0);
+ madwifi_set_privacy(drv, 0); /* default to no privacy */
+
+ madwifi_receive_probe_req(drv);
+@@ -1206,7 +1207,7 @@ madwifi_deinit(void *priv)
+ struct madwifi_driver_data *drv = priv;
+
+ netlink_deinit(drv->netlink);
+- (void) linux_set_iface_flags(drv->ioctl_sock, drv->iface, 0);
++ (void) linux_set_iface_flags(drv->ioctl_sock, drv->ifname, 0);
+ if (drv->ioctl_sock >= 0)
+ close(drv->ioctl_sock);
+ if (drv->sock_recv != NULL && drv->sock_recv != drv->sock_xmit)
+@@ -1225,7 +1226,7 @@ madwifi_set_ssid(void *priv, const u8 *b
+ struct iwreq iwr;
+
+ memset(&iwr, 0, sizeof(iwr));
+- os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
++ os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
+ iwr.u.essid.flags = 1; /* SSID active */
+ iwr.u.essid.pointer = (caddr_t) buf;
+ iwr.u.essid.length = len + 1;
+@@ -1246,7 +1247,7 @@ madwifi_get_ssid(void *priv, u8 *buf, in
+ int ret = 0;
+
+ memset(&iwr, 0, sizeof(iwr));
+- os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
++ os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
+ iwr.u.essid.pointer = (caddr_t) buf;
+ iwr.u.essid.length = len;
+
+@@ -1271,140 +1272,19 @@ static int
+ madwifi_commit(void *priv)
+ {
+ struct madwifi_driver_data *drv = priv;
+- return linux_set_iface_flags(drv->ioctl_sock, drv->iface, 1);
++ return linux_set_iface_flags(drv->ioctl_sock, drv->ifname, 1);
+ }
+
+-#else /* HOSTAPD */
++#endif /* HOSTAPD */
+
+-struct wpa_driver_madwifi_data {
+- void *wext; /* private data for driver_wext */
+- void *ctx;
+- char ifname[IFNAMSIZ + 1];
+- int sock;
+-};
++#if !defined(NO_SUPPLICANT)
+
+ static int wpa_driver_madwifi_set_auth_alg(void *priv, int auth_alg);
+ static int wpa_driver_madwifi_set_probe_req_ie(void *priv, const u8 *ies,
+ size_t ies_len);
+
+-
+-static int
+-set80211priv(struct wpa_driver_madwifi_data *drv, int op, void *data, int len,
+- int show_err)
+-{
+- struct iwreq iwr;
+-
+- os_memset(&iwr, 0, sizeof(iwr));
+- os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
+- if (len < IFNAMSIZ &&
+- op != IEEE80211_IOCTL_SET_APPIEBUF) {
+- /*
+- * Argument data fits inline; put it there.
+- */
+- os_memcpy(iwr.u.name, data, len);
+- } else {
+- /*
+- * Argument data too big for inline transfer; setup a
+- * parameter block instead; the kernel will transfer
+- * the data for the driver.
+- */
+- iwr.u.data.pointer = data;
+- iwr.u.data.length = len;
+- }
+-
+- if (ioctl(drv->sock, op, &iwr) < 0) {
+- if (show_err) {
+-#ifdef MADWIFI_NG
+- int first = IEEE80211_IOCTL_SETPARAM;
+- int last = IEEE80211_IOCTL_KICKMAC;
+- static const char *opnames[] = {
+- "ioctl[IEEE80211_IOCTL_SETPARAM]",
+- "ioctl[IEEE80211_IOCTL_GETPARAM]",
+- "ioctl[IEEE80211_IOCTL_SETMODE]",
+- "ioctl[IEEE80211_IOCTL_GETMODE]",
+- "ioctl[IEEE80211_IOCTL_SETWMMPARAMS]",
+- "ioctl[IEEE80211_IOCTL_GETWMMPARAMS]",
+- "ioctl[IEEE80211_IOCTL_SETCHANLIST]",
+- "ioctl[IEEE80211_IOCTL_GETCHANLIST]",
+- "ioctl[IEEE80211_IOCTL_CHANSWITCH]",
+- NULL,
+- "ioctl[IEEE80211_IOCTL_SET_APPIEBUF]",
+- "ioctl[IEEE80211_IOCTL_GETSCANRESULTS]",
+- NULL,
+- "ioctl[IEEE80211_IOCTL_GETCHANINFO]",
+- "ioctl[IEEE80211_IOCTL_SETOPTIE]",
+- "ioctl[IEEE80211_IOCTL_GETOPTIE]",
+- "ioctl[IEEE80211_IOCTL_SETMLME]",
+- NULL,
+- "ioctl[IEEE80211_IOCTL_SETKEY]",
+- NULL,
+- "ioctl[IEEE80211_IOCTL_DELKEY]",
+- NULL,
+- "ioctl[IEEE80211_IOCTL_ADDMAC]",
+- NULL,
+- "ioctl[IEEE80211_IOCTL_DELMAC]",
+- NULL,
+- "ioctl[IEEE80211_IOCTL_WDSMAC]",
+- NULL,
+- "ioctl[IEEE80211_IOCTL_WDSDELMAC]",
+- NULL,
+- "ioctl[IEEE80211_IOCTL_KICKMAC]",
+- };
+-#else /* MADWIFI_NG */
+- int first = IEEE80211_IOCTL_SETPARAM;
+- int last = IEEE80211_IOCTL_CHANLIST;
+- static const char *opnames[] = {
+- "ioctl[IEEE80211_IOCTL_SETPARAM]",
+- "ioctl[IEEE80211_IOCTL_GETPARAM]",
+- "ioctl[IEEE80211_IOCTL_SETKEY]",
+- "ioctl[IEEE80211_IOCTL_GETKEY]",
+- "ioctl[IEEE80211_IOCTL_DELKEY]",
+- NULL,
+- "ioctl[IEEE80211_IOCTL_SETMLME]",
+- NULL,
+- "ioctl[IEEE80211_IOCTL_SETOPTIE]",
+- "ioctl[IEEE80211_IOCTL_GETOPTIE]",
+- "ioctl[IEEE80211_IOCTL_ADDMAC]",
+- NULL,
+- "ioctl[IEEE80211_IOCTL_DELMAC]",
+- NULL,
+- "ioctl[IEEE80211_IOCTL_CHANLIST]",
+- };
+-#endif /* MADWIFI_NG */
+- int idx = op - first;
+- if (first <= op && op <= last &&
+- idx < (int) (sizeof(opnames) / sizeof(opnames[0]))
+- && opnames[idx])
+- perror(opnames[idx]);
+- else
+- perror("ioctl[unknown???]");
+- }
+- return -1;
+- }
+- return 0;
+-}
+-
+-static int
+-set80211param(struct wpa_driver_madwifi_data *drv, int op, int arg,
+- int show_err)
+-{
+- struct iwreq iwr;
+-
+- os_memset(&iwr, 0, sizeof(iwr));
+- os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
+- iwr.u.mode = op;
+- os_memcpy(iwr.u.name+sizeof(u32), &arg, sizeof(arg));
+-
+- if (ioctl(drv->sock, IEEE80211_IOCTL_SETPARAM, &iwr) < 0) {
+- if (show_err)
+- perror("ioctl[IEEE80211_IOCTL_SETPARAM]");
+- return -1;
+- }
+- return 0;
+-}
+-
+ static int
+-wpa_driver_madwifi_set_wpa_ie(struct wpa_driver_madwifi_data *drv,
++wpa_driver_madwifi_set_wpa_ie(struct madwifi_driver_data *drv,
+ const u8 *wpa_ie, size_t wpa_ie_len)
+ {
+ struct iwreq iwr;
+@@ -1415,7 +1295,7 @@ wpa_driver_madwifi_set_wpa_ie(struct wpa
+ iwr.u.data.pointer = (void *) wpa_ie;
+ iwr.u.data.length = wpa_ie_len;
+
+- if (ioctl(drv->sock, IEEE80211_IOCTL_SETOPTIE, &iwr) < 0) {
++ if (ioctl(drv->ioctl_sock, IEEE80211_IOCTL_SETOPTIE, &iwr) < 0) {
+ perror("ioctl[IEEE80211_IOCTL_SETOPTIE]");
+ return -1;
+ }
+@@ -1423,157 +1303,51 @@ wpa_driver_madwifi_set_wpa_ie(struct wpa
+ }
+
+ static int
+-wpa_driver_madwifi_del_key(struct wpa_driver_madwifi_data *drv, int key_idx,
+- const u8 *addr)
+-{
+- struct ieee80211req_del_key wk;
+-
+- wpa_printf(MSG_DEBUG, "%s: keyidx=%d", __FUNCTION__, key_idx);
+- os_memset(&wk, 0, sizeof(wk));
+- wk.idk_keyix = key_idx;
+- if (addr != NULL)
+- os_memcpy(wk.idk_macaddr, addr, IEEE80211_ADDR_LEN);
+-
+- return set80211priv(drv, IEEE80211_IOCTL_DELKEY, &wk, sizeof(wk), 1);
+-}
+-
+-static int
+-wpa_driver_madwifi_set_key(const char *ifname, void *priv, enum wpa_alg alg,
+- const u8 *addr, int key_idx, int set_tx,
+- const u8 *seq, size_t seq_len,
+- const u8 *key, size_t key_len)
+-{
+- struct wpa_driver_madwifi_data *drv = priv;
+- struct ieee80211req_key wk;
+- char *alg_name;
+- u_int8_t cipher;
+-
+- if (alg == WPA_ALG_NONE)
+- return wpa_driver_madwifi_del_key(drv, key_idx, addr);
+-
+- switch (alg) {
+- case WPA_ALG_WEP:
+- if (addr == NULL || os_memcmp(addr, "\xff\xff\xff\xff\xff\xff",
+- ETH_ALEN) == 0) {
+- /*
+- * madwifi did not seem to like static WEP key
+- * configuration with IEEE80211_IOCTL_SETKEY, so use
+- * Linux wireless extensions ioctl for this.
+- */
+- return wpa_driver_wext_set_key(ifname, drv->wext, alg,
+- addr, key_idx, set_tx,
+- seq, seq_len,
+- key, key_len);
+- }
+- alg_name = "WEP";
+- cipher = IEEE80211_CIPHER_WEP;
+- break;
+- case WPA_ALG_TKIP:
+- alg_name = "TKIP";
+- cipher = IEEE80211_CIPHER_TKIP;
+- break;
+- case WPA_ALG_CCMP:
+- alg_name = "CCMP";
+- cipher = IEEE80211_CIPHER_AES_CCM;
+- break;
+- default:
+- wpa_printf(MSG_DEBUG, "%s: unknown/unsupported algorithm %d",
+- __FUNCTION__, alg);
+- return -1;
+- }
+-
+- wpa_printf(MSG_DEBUG, "%s: alg=%s key_idx=%d set_tx=%d seq_len=%lu "
+- "key_len=%lu", __FUNCTION__, alg_name, key_idx, set_tx,
+- (unsigned long) seq_len, (unsigned long) key_len);
+-
+- if (seq_len > sizeof(u_int64_t)) {
+- wpa_printf(MSG_DEBUG, "%s: seq_len %lu too big",
+- __FUNCTION__, (unsigned long) seq_len);
+- return -2;
+- }
+- if (key_len > sizeof(wk.ik_keydata)) {
+- wpa_printf(MSG_DEBUG, "%s: key length %lu too big",
+- __FUNCTION__, (unsigned long) key_len);
+- return -3;
+- }
+-
+- os_memset(&wk, 0, sizeof(wk));
+- wk.ik_type = cipher;
+- wk.ik_flags = IEEE80211_KEY_RECV;
+- if (addr == NULL ||
+- os_memcmp(addr, "\xff\xff\xff\xff\xff\xff", ETH_ALEN) == 0)
+- wk.ik_flags |= IEEE80211_KEY_GROUP;
+- if (set_tx) {
+- wk.ik_flags |= IEEE80211_KEY_XMIT | IEEE80211_KEY_DEFAULT;
+- os_memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
+- } else
+- os_memset(wk.ik_macaddr, 0, IEEE80211_ADDR_LEN);
+- wk.ik_keyix = key_idx;
+- wk.ik_keylen = key_len;
+-#ifdef WORDS_BIGENDIAN
+- if (seq) {
+- size_t i;
+- u8 tmp[WPA_KEY_RSC_LEN];
+- os_memset(tmp, 0, sizeof(tmp));
+- for (i = 0; i < seq_len; i++)
+- tmp[WPA_KEY_RSC_LEN - i - 1] = seq[i];
+- os_memcpy(&wk.ik_keyrsc, tmp, WPA_KEY_RSC_LEN);
+- }
+-#else /* WORDS_BIGENDIAN */
+- if (seq)
+- os_memcpy(&wk.ik_keyrsc, seq, seq_len);
+-#endif /* WORDS_BIGENDIAN */
+- os_memcpy(wk.ik_keydata, key, key_len);
+-
+- return set80211priv(drv, IEEE80211_IOCTL_SETKEY, &wk, sizeof(wk), 1);
+-}
+-
+-static int
+ wpa_driver_madwifi_set_countermeasures(void *priv, int enabled)
+ {
+- struct wpa_driver_madwifi_data *drv = priv;
++ struct madwifi_driver_data *drv = priv;
+ wpa_printf(MSG_DEBUG, "%s: enabled=%d", __FUNCTION__, enabled);
+- return set80211param(drv, IEEE80211_PARAM_COUNTERMEASURES, enabled, 1);
++ return set80211param(drv, IEEE80211_PARAM_COUNTERMEASURES, enabled);
+ }
+
+ static int
+ wpa_driver_madwifi_deauthenticate(void *priv, const u8 *addr, int reason_code)
+ {
+- struct wpa_driver_madwifi_data *drv = priv;
++ struct madwifi_driver_data *drv = priv;
+ struct ieee80211req_mlme mlme;
+
+ wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
+ mlme.im_op = IEEE80211_MLME_DEAUTH;
+ mlme.im_reason = reason_code;
+ os_memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
+- return set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme), 1);
++ return set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme));
+ }
+
+ static int
+ wpa_driver_madwifi_disassociate(void *priv, const u8 *addr, int reason_code)
+ {
+- struct wpa_driver_madwifi_data *drv = priv;
++ struct madwifi_driver_data *drv = priv;
+ struct ieee80211req_mlme mlme;
+
+ wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
+ mlme.im_op = IEEE80211_MLME_DISASSOC;
+ mlme.im_reason = reason_code;
+ os_memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
+- return set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme), 1);
++ return set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme));
+ }
+
+ static int
+ wpa_driver_madwifi_associate(void *priv,
+ struct wpa_driver_associate_params *params)
+ {
+- struct wpa_driver_madwifi_data *drv = priv;
++ struct madwifi_driver_data *drv = priv;
+ struct ieee80211req_mlme mlme;
+ int ret = 0, privacy = 1;
+
+ wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
+
+ if (set80211param(drv, IEEE80211_PARAM_DROPUNENCRYPTED,
+- params->drop_unencrypted, 1) < 0)
++ params->drop_unencrypted) < 0)
+ ret = -1;
+ if (wpa_driver_madwifi_set_auth_alg(drv, params->auth_alg) < 0)
+ ret = -1;
+@@ -1596,12 +1370,12 @@ wpa_driver_madwifi_associate(void *priv,
+ params->wpa_ie_len == 0)
+ privacy = 0;
+
+- if (set80211param(drv, IEEE80211_PARAM_PRIVACY, privacy, 1) < 0)
++ if (set80211param(drv, IEEE80211_PARAM_PRIVACY, privacy) < 0)
+ ret = -1;
+
+ if (params->wpa_ie_len &&
+ set80211param(drv, IEEE80211_PARAM_WPA,
+- params->wpa_ie[0] == WLAN_EID_RSN ? 2 : 1, 1) < 0)
++ params->wpa_ie[0] == WLAN_EID_RSN ? 2 : 1) < 0)
+ ret = -1;
+
+ if (params->bssid == NULL) {
+@@ -1609,14 +1383,14 @@ wpa_driver_madwifi_associate(void *priv,
+ * roaming */
+ /* FIX: this does not seem to work; would probably need to
+ * change something in the driver */
+- if (set80211param(drv, IEEE80211_PARAM_ROAMING, 0, 1) < 0)
++ if (set80211param(drv, IEEE80211_PARAM_ROAMING, 0) < 0)
+ ret = -1;
+
+ if (wpa_driver_wext_set_ssid(drv->wext, params->ssid,
+ params->ssid_len) < 0)
+ ret = -1;
+ } else {
+- if (set80211param(drv, IEEE80211_PARAM_ROAMING, 2, 1) < 0)
++ if (set80211param(drv, IEEE80211_PARAM_ROAMING, 2) < 0)
+ ret = -1;
+ if (wpa_driver_wext_set_ssid(drv->wext, params->ssid,
+ params->ssid_len) < 0)
+@@ -1625,7 +1399,7 @@ wpa_driver_madwifi_associate(void *priv,
+ mlme.im_op = IEEE80211_MLME_ASSOC;
+ os_memcpy(mlme.im_macaddr, params->bssid, IEEE80211_ADDR_LEN);
+ if (set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme,
+- sizeof(mlme), 1) < 0) {
++ sizeof(mlme)) < 0) {
+ wpa_printf(MSG_DEBUG, "%s: SETMLME[ASSOC] failed",
+ __func__);
+ ret = -1;
+@@ -1638,7 +1412,7 @@ wpa_driver_madwifi_associate(void *priv,
+ static int
+ wpa_driver_madwifi_set_auth_alg(void *priv, int auth_alg)
+ {
+- struct wpa_driver_madwifi_data *drv = priv;
++ struct madwifi_driver_data *drv = priv;
+ int authmode;
+
+ if ((auth_alg & WPA_AUTH_ALG_OPEN) &&
+@@ -1649,13 +1423,13 @@ wpa_driver_madwifi_set_auth_alg(void *pr
+ else
+ authmode = IEEE80211_AUTH_OPEN;
+
+- return set80211param(drv, IEEE80211_PARAM_AUTHMODE, authmode, 1);
++ return set80211param(drv, IEEE80211_PARAM_AUTHMODE, authmode);
+ }
+
+ static int
+ wpa_driver_madwifi_scan(void *priv, struct wpa_driver_scan_params *params)
+ {
+- struct wpa_driver_madwifi_data *drv = priv;
++ struct madwifi_driver_data *drv = priv;
+ struct iwreq iwr;
+ int ret = 0;
+ const u8 *ssid = params->ssids[0].ssid;
+@@ -1673,7 +1447,7 @@ wpa_driver_madwifi_scan(void *priv, stru
+ if (wpa_driver_wext_set_ssid(drv->wext, ssid, ssid_len) < 0)
+ ret = -1;
+
+- if (ioctl(drv->sock, SIOCSIWSCAN, &iwr) < 0) {
++ if (ioctl(drv->ioctl_sock, SIOCSIWSCAN, &iwr) < 0) {
+ perror("ioctl[SIOCSIWSCAN]");
+ ret = -1;
+ }
+@@ -1695,14 +1469,14 @@ wpa_driver_madwifi_scan(void *priv, stru
+
+ static int wpa_driver_madwifi_get_bssid(void *priv, u8 *bssid)
+ {
+- struct wpa_driver_madwifi_data *drv = priv;
++ struct madwifi_driver_data *drv = priv;
+ return wpa_driver_wext_get_bssid(drv->wext, bssid);
+ }
+
+
+ static int wpa_driver_madwifi_get_ssid(void *priv, u8 *ssid)
+ {
+- struct wpa_driver_madwifi_data *drv = priv;
++ struct madwifi_driver_data *drv = priv;
+ return wpa_driver_wext_get_ssid(drv->wext, ssid);
+ }
+
+@@ -1710,14 +1484,16 @@ static int wpa_driver_madwifi_get_ssid(v
+ static struct wpa_scan_results *
+ wpa_driver_madwifi_get_scan_results(void *priv)
+ {
+- struct wpa_driver_madwifi_data *drv = priv;
++ struct madwifi_driver_data *drv = priv;
+ return wpa_driver_wext_get_scan_results(drv->wext);
+ }
+
+
+ static int wpa_driver_madwifi_set_operstate(void *priv, int state)
+ {
+- struct wpa_driver_madwifi_data *drv = priv;
++ struct madwifi_driver_data *drv = priv;
++ if (!drv->wext)
++ return 0;
+ return wpa_driver_wext_set_operstate(drv->wext, state);
+ }
+
+@@ -1738,7 +1514,7 @@ static int wpa_driver_madwifi_set_probe_
+
+ ret = set80211priv(priv, IEEE80211_IOCTL_SET_APPIEBUF, probe_req_ie,
+ sizeof(struct ieee80211req_getset_appiebuf) +
+- ies_len, 1);
++ ies_len);
+
+ os_free(probe_req_ie);
+
+@@ -1748,7 +1524,7 @@ static int wpa_driver_madwifi_set_probe_
+
+ static void * wpa_driver_madwifi_init(void *ctx, const char *ifname)
+ {
+- struct wpa_driver_madwifi_data *drv;
++ struct madwifi_driver_data *drv;
+
+ drv = os_zalloc(sizeof(*drv));
+ if (drv == NULL)
+@@ -1759,17 +1535,17 @@ static void * wpa_driver_madwifi_init(vo
+
+ drv->ctx = ctx;
+ os_strlcpy(drv->ifname, ifname, sizeof(drv->ifname));
+- drv->sock = socket(PF_INET, SOCK_DGRAM, 0);
+- if (drv->sock < 0)
++ drv->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0);
++ if (drv->ioctl_sock < 0)
+ goto fail2;
+
+- if (set80211param(drv, IEEE80211_PARAM_ROAMING, 2, 1) < 0) {
++ if (set80211param(drv, IEEE80211_PARAM_ROAMING, 2) < 0) {
+ wpa_printf(MSG_DEBUG, "%s: failed to set wpa_supplicant-based "
+ "roaming", __FUNCTION__);
+ goto fail3;
+ }
+
+- if (set80211param(drv, IEEE80211_PARAM_WPA, 3, 1) < 0) {
++ if (set80211param(drv, IEEE80211_PARAM_WPA, 3) < 0) {
+ wpa_printf(MSG_DEBUG, "%s: failed to enable WPA support",
+ __FUNCTION__);
+ goto fail3;
+@@ -1778,7 +1554,7 @@ static void * wpa_driver_madwifi_init(vo
+ return drv;
+
+ fail3:
+- close(drv->sock);
++ close(drv->ioctl_sock);
+ fail2:
+ wpa_driver_wext_deinit(drv->wext);
+ fail:
+@@ -1789,38 +1565,37 @@ fail:
+
+ static void wpa_driver_madwifi_deinit(void *priv)
+ {
+- struct wpa_driver_madwifi_data *drv = priv;
++ struct madwifi_driver_data *drv = priv;
+
+ if (wpa_driver_madwifi_set_wpa_ie(drv, NULL, 0) < 0) {
+ wpa_printf(MSG_DEBUG, "%s: failed to clear WPA IE",
+ __FUNCTION__);
+ }
+- if (set80211param(drv, IEEE80211_PARAM_ROAMING, 0, 1) < 0) {
++ if (set80211param(drv, IEEE80211_PARAM_ROAMING, 0) < 0) {
+ wpa_printf(MSG_DEBUG, "%s: failed to enable driver-based "
+ "roaming", __FUNCTION__);
+ }
+- if (set80211param(drv, IEEE80211_PARAM_PRIVACY, 0, 1) < 0) {
++ if (set80211param(drv, IEEE80211_PARAM_PRIVACY, 0) < 0) {
+ wpa_printf(MSG_DEBUG, "%s: failed to disable forced Privacy "
+ "flag", __FUNCTION__);
+ }
+- if (set80211param(drv, IEEE80211_PARAM_WPA, 0, 1) < 0) {
++ if (set80211param(drv, IEEE80211_PARAM_WPA, 0) < 0) {
+ wpa_printf(MSG_DEBUG, "%s: failed to disable WPA",
+ __FUNCTION__);
+ }
+
+ wpa_driver_wext_deinit(drv->wext);
+
+- close(drv->sock);
++ close(drv->ioctl_sock);
+ os_free(drv);
+ }
+
+-#endif /* HOSTAPD */
+-
++#endif
+
+ const struct wpa_driver_ops wpa_driver_madwifi_ops = {
+ .name = "madwifi",
+ .desc = "MADWIFI 802.11 support (Atheros, etc.)",
+- .set_key = wpa_driver_madwifi_set_key,
++ .set_key = madwifi_set_key,
+ #ifdef HOSTAPD
+ .hapd_init = madwifi_init,
+ .hapd_deinit = madwifi_deinit,
+@@ -1840,7 +1615,8 @@ const struct wpa_driver_ops wpa_driver_m
+ .sta_clear_stats = madwifi_sta_clear_stats,
+ .commit = madwifi_commit,
+ .set_ap_wps_ie = madwifi_set_ap_wps_ie,
+-#else /* HOSTAPD */
++#endif /* HOSTAPD */
++#if !defined(NO_SUPPLICANT)
+ .get_bssid = wpa_driver_madwifi_get_bssid,
+ .get_ssid = wpa_driver_madwifi_get_ssid,
+ .init = wpa_driver_madwifi_init,
+@@ -1852,5 +1628,5 @@ const struct wpa_driver_ops wpa_driver_m
+ .disassociate = wpa_driver_madwifi_disassociate,
+ .associate = wpa_driver_madwifi_associate,
+ .set_operstate = wpa_driver_madwifi_set_operstate,
+-#endif /* HOSTAPD */
++#endif
+ };
+--- a/src/drivers/drivers.mak
++++ b/src/drivers/drivers.mak
+@@ -144,8 +144,8 @@ DRV_WPA_OBJS += ../src/drivers/driver_ro
+ endif
+
+ ifdef CONFIG_WIRELESS_EXTENSION
+-DRV_WPA_CFLAGS += -DCONFIG_WIRELESS_EXTENSION
+-DRV_WPA_OBJS += ../src/drivers/driver_wext.o
++DRV_CFLAGS += -DCONFIG_WIRELESS_EXTENSION
++DRV_OBJS += ../src/drivers/driver_wext.o
+ NEED_RFKILL=y
+ endif
+
+++ /dev/null
---- a/wpa_supplicant/scan.c
-+++ b/wpa_supplicant/scan.c
-@@ -248,6 +248,7 @@ static void wpa_supplicant_scan(void *el
- enum wps_request_type req_type = WPS_REQ_ENROLLEE_INFO;
- #endif /* CONFIG_WPS */
- struct wpa_driver_scan_params params;
-+ int scan_ssid_all = 1;
- size_t max_ssids;
- enum wpa_states prev_state;
-
-@@ -316,6 +317,16 @@ static void wpa_supplicant_scan(void *el
- wpa_s->wpa_state == WPA_INACTIVE)
- wpa_supplicant_set_state(wpa_s, WPA_SCANNING);
-
-+ /* check if all configured ssids should be scanned directly */
-+ ssid = wpa_s->conf->ssid;
-+ while (ssid) {
-+ if (!ssid->scan_ssid) {
-+ scan_ssid_all = 0;
-+ break;
-+ }
-+ ssid = ssid->next;
-+ }
-+
- /* Find the starting point from which to continue scanning */
- ssid = wpa_s->conf->ssid;
- if (wpa_s->prev_scan_ssid != WILDCARD_SSID_SCAN) {
-@@ -379,6 +390,9 @@ static void wpa_supplicant_scan(void *el
- int_array_sort_unique(params.freqs);
- }
-
-+ if (scan_ssid_all && !ssid)
-+ ssid = wpa_s->conf->ssid;
-+
- if (ssid) {
- wpa_s->prev_scan_ssid = ssid;
- if (max_ssids > 1) {
--- /dev/null
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -1468,7 +1468,6 @@ nla_put_failure:
+ }
+
+
+-#ifndef HOSTAPD
+ struct wiphy_info_data {
+ int max_scan_ssids;
+ int ap_supported;
+@@ -1613,7 +1612,6 @@ static int wpa_driver_nl80211_capa(struc
+
+ return 0;
+ }
+-#endif /* HOSTAPD */
+
+
+ static int wpa_driver_nl80211_init_nl(struct wpa_driver_nl80211_data *drv)
+@@ -1825,6 +1823,7 @@ static void * wpa_driver_nl80211_init(vo
+ drv->monitor_ifidx = -1;
+ drv->monitor_sock = -1;
+ drv->ioctl_sock = -1;
++ drv->nlmode = NL80211_IFTYPE_STATION;
+
+ if (wpa_driver_nl80211_init_nl(drv)) {
+ os_free(drv);
+@@ -1988,32 +1987,32 @@ wpa_driver_nl80211_finish_drv_init(struc
+ drv->ifindex = if_nametoindex(bss->ifname);
+ drv->first_bss.ifindex = drv->ifindex;
+
+-#ifndef HOSTAPD
+- if (wpa_driver_nl80211_set_mode(bss, IEEE80211_MODE_INFRA) < 0) {
+- wpa_printf(MSG_DEBUG, "nl80211: Could not configure driver to "
+- "use managed mode");
+- }
+-
+- if (linux_set_iface_flags(drv->ioctl_sock, bss->ifname, 1)) {
+- if (rfkill_is_blocked(drv->rfkill)) {
+- wpa_printf(MSG_DEBUG, "nl80211: Could not yet enable "
+- "interface '%s' due to rfkill",
+- bss->ifname);
+- drv->if_disabled = 1;
+- send_rfkill_event = 1;
+- } else {
+- wpa_printf(MSG_ERROR, "nl80211: Could not set "
+- "interface '%s' UP", bss->ifname);
+- return -1;
++ if (drv->nlmode == NL80211_IFTYPE_STATION) {
++ if (wpa_driver_nl80211_set_mode(bss, IEEE80211_MODE_INFRA) < 0) {
++ wpa_printf(MSG_DEBUG, "nl80211: Could not configure driver to "
++ "use managed mode");
++ }
++
++ if (linux_set_iface_flags(drv->ioctl_sock, bss->ifname, 1)) {
++ if (rfkill_is_blocked(drv->rfkill)) {
++ wpa_printf(MSG_DEBUG, "nl80211: Could not yet enable "
++ "interface '%s' due to rfkill",
++ bss->ifname);
++ drv->if_disabled = 1;
++ send_rfkill_event = 1;
++ } else {
++ wpa_printf(MSG_ERROR, "nl80211: Could not set "
++ "interface '%s' UP", bss->ifname);
++ return -1;
++ }
+ }
+- }
+
+- if (wpa_driver_nl80211_capa(drv))
+- return -1;
++ if (wpa_driver_nl80211_capa(drv))
++ return -1;
+
+- netlink_send_oper_ifla(drv->netlink, drv->ifindex,
+- 1, IF_OPER_DORMANT);
+-#endif /* HOSTAPD */
++ netlink_send_oper_ifla(drv->netlink, drv->ifindex,
++ 1, IF_OPER_DORMANT);
++ }
+
+ if (linux_get_ifhwaddr(drv->ioctl_sock, bss->ifname, drv->addr))
+ return -1;
+@@ -3738,7 +3737,8 @@ static void nl80211_remove_iface(struct
+
+ #ifdef HOSTAPD
+ /* stop listening for EAPOL on this interface */
+- del_ifidx(drv, ifidx);
++ if (drv->nlmode == NL80211_IFTYPE_AP)
++ del_ifidx(drv, ifidx);
+ #endif /* HOSTAPD */
+
+ msg = nlmsg_alloc();
+@@ -3811,7 +3811,8 @@ static int nl80211_create_iface_once(str
+
+ #ifdef HOSTAPD
+ /* start listening for EAPOL on this interface */
+- add_ifidx(drv, ifidx);
++ if (drv->nlmode == NL80211_IFTYPE_AP)
++ add_ifidx(drv, ifidx);
+ #endif /* HOSTAPD */
+
+ if (addr && iftype != NL80211_IFTYPE_MONITOR &&
+++ /dev/null
---- a/wpa_supplicant/events.c
-+++ b/wpa_supplicant/events.c
-@@ -963,7 +963,7 @@ static void wpa_supplicant_event_scan_re
- wpa_printf(MSG_DEBUG, "Setup a new network");
- wpa_supplicant_associate(wpa_s, NULL, ssid);
- } else {
-- int timeout_sec = 5;
-+ int timeout_sec = 0;
- int timeout_usec = 0;
- wpa_supplicant_req_new_scan(wpa_s, timeout_sec,
- timeout_usec);
+++ /dev/null
---- a/src/drivers/driver_madwifi.c
-+++ b/src/drivers/driver_madwifi.c
-@@ -71,7 +71,6 @@
-
- #define WPA_KEY_RSC_LEN 8
-
--#ifdef HOSTAPD
-
- #include "priv_netlink.h"
- #include "netlink.h"
-@@ -82,17 +81,22 @@
- struct madwifi_driver_data {
- struct hostapd_data *hapd; /* back pointer */
-
-- char iface[IFNAMSIZ + 1];
-+ void *wext; /* private data for driver_wext */
-+ void *ctx;
-+ char ifname[IFNAMSIZ + 1];
-+ int ioctl_sock; /* socket for ioctl() use */
-+
-+#ifdef HOSTAPD
- int ifindex;
- struct l2_packet_data *sock_xmit; /* raw packet xmit socket */
- struct l2_packet_data *sock_recv; /* raw packet recv socket */
-- int ioctl_sock; /* socket for ioctl() use */
- struct netlink_data *netlink;
- int we_version;
- u8 acct_mac[ETH_ALEN];
- struct hostap_sta_driver_data acct_data;
-
- struct l2_packet_data *sock_raw; /* raw 802.11 management frames */
-+#endif
- };
-
- static int madwifi_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr,
-@@ -105,7 +109,7 @@ set80211priv(struct madwifi_driver_data
- int do_inline = len < IFNAMSIZ;
-
- memset(&iwr, 0, sizeof(iwr));
-- os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
-+ os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
- #ifdef IEEE80211_IOCTL_FILTERFRAME
- /* FILTERFRAME must be NOT inline, regardless of size. */
- if (op == IEEE80211_IOCTL_FILTERFRAME)
-@@ -206,7 +210,7 @@ set80211param(struct madwifi_driver_data
- struct iwreq iwr;
-
- memset(&iwr, 0, sizeof(iwr));
-- os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
-+ os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
- iwr.u.mode = op;
- memcpy(iwr.u.name+sizeof(__u32), &arg, sizeof(arg));
-
-@@ -233,6 +237,7 @@ ether_sprintf(const u8 *addr)
- }
- #endif /* CONFIG_NO_STDOUT_DEBUG */
-
-+#ifdef HOSTAPD
- /*
- * Configure WPA parameters.
- */
-@@ -395,7 +400,7 @@ madwifi_sta_set_flags(void *priv, const
- return madwifi_set_sta_authorized(priv, addr, 0);
- return 0;
- }
--
-+#endif /* HOSTAPD */
- static int
- madwifi_del_key(void *priv, const u8 *addr, int key_idx)
- {
-@@ -407,28 +412,20 @@ madwifi_del_key(void *priv, const u8 *ad
- __func__, ether_sprintf(addr), key_idx);
-
- memset(&wk, 0, sizeof(wk));
-+ wk.idk_keyix = key_idx;
- if (addr != NULL) {
- memcpy(wk.idk_macaddr, addr, IEEE80211_ADDR_LEN);
-- wk.idk_keyix = (u8) IEEE80211_KEYIX_NONE;
-- } else {
-- wk.idk_keyix = key_idx;
-- }
--
-- ret = set80211priv(drv, IEEE80211_IOCTL_DELKEY, &wk, sizeof(wk));
-- if (ret < 0) {
-- wpa_printf(MSG_DEBUG, "%s: Failed to delete key (addr %s"
-- " key_idx %d)", __func__, ether_sprintf(addr),
-- key_idx);
- }
-
-- return ret;
-+ set80211priv(drv, IEEE80211_IOCTL_DELKEY, &wk, sizeof(wk));
-+ return 0;
- }
-
- static int
--wpa_driver_madwifi_set_key(const char *ifname, void *priv, enum wpa_alg alg,
-- const u8 *addr, int key_idx, int set_tx,
-- const u8 *seq, size_t seq_len,
-- const u8 *key, size_t key_len)
-+madwifi_set_key(const char *ifname, void *priv, enum wpa_alg alg,
-+ const u8 *addr, int key_idx, int set_tx,
-+ const u8 *seq, size_t seq_len,
-+ const u8 *key, size_t key_len)
- {
- struct madwifi_driver_data *drv = priv;
- struct ieee80211req_key wk;
-@@ -462,10 +459,14 @@ wpa_driver_madwifi_set_key(const char *i
- memset(&wk, 0, sizeof(wk));
- wk.ik_type = cipher;
- wk.ik_flags = IEEE80211_KEY_RECV | IEEE80211_KEY_XMIT;
-+
- if (addr == NULL) {
- memset(wk.ik_macaddr, 0xff, IEEE80211_ADDR_LEN);
- wk.ik_keyix = key_idx;
- wk.ik_flags |= IEEE80211_KEY_DEFAULT;
-+ } else if (!memcmp(addr, "\xff\xff\xff\xff\xff\xff", ETH_ALEN)) {
-+ wk.ik_flags |= IEEE80211_KEY_GROUP;
-+ memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
- } else {
- memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
- wk.ik_keyix = IEEE80211_KEYIX_NONE;
-@@ -485,6 +486,7 @@ wpa_driver_madwifi_set_key(const char *i
- }
-
-
-+#ifdef HOSTAPD
- static int
- madwifi_get_seqnum(const char *ifname, void *priv, const u8 *addr, int idx,
- u8 *seq)
-@@ -591,7 +593,7 @@ madwifi_read_sta_driver_data(void *priv,
-
- memset(data, 0, sizeof(*data));
- snprintf(buf, sizeof(buf), "/proc/net/madwifi/%s/" MACSTR,
-- drv->iface, MAC2STR(addr));
-+ drv->ifname, MAC2STR(addr));
-
- f = fopen(buf, "r");
- if (!f) {
-@@ -757,7 +759,7 @@ static int madwifi_receive_probe_req(str
- if (ret)
- return ret;
-
-- drv->sock_raw = l2_packet_init(drv->iface, NULL, ETH_P_80211_RAW,
-+ drv->sock_raw = l2_packet_init(drv->ifname, NULL, ETH_P_80211_RAW,
- madwifi_raw_receive, drv, 1);
- if (drv->sock_raw == NULL)
- return -1;
-@@ -1016,7 +1018,7 @@ madwifi_get_we_version(struct madwifi_dr
- return -1;
-
- memset(&iwr, 0, sizeof(iwr));
-- os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
-+ os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
- iwr.u.data.pointer = (caddr_t) range;
- iwr.u.data.length = buflen;
-
-@@ -1133,17 +1135,17 @@ madwifi_init(struct hostapd_data *hapd,
- perror("socket[PF_INET,SOCK_DGRAM]");
- goto bad;
- }
-- memcpy(drv->iface, params->ifname, sizeof(drv->iface));
-+ memcpy(drv->ifname, params->ifname, sizeof(drv->ifname));
-
- memset(&ifr, 0, sizeof(ifr));
-- os_strlcpy(ifr.ifr_name, drv->iface, sizeof(ifr.ifr_name));
-+ os_strlcpy(ifr.ifr_name, drv->ifname, sizeof(ifr.ifr_name));
- if (ioctl(drv->ioctl_sock, SIOCGIFINDEX, &ifr) != 0) {
- perror("ioctl(SIOCGIFINDEX)");
- goto bad;
- }
- drv->ifindex = ifr.ifr_ifindex;
-
-- drv->sock_xmit = l2_packet_init(drv->iface, NULL, ETH_P_EAPOL,
-+ drv->sock_xmit = l2_packet_init(drv->ifname, NULL, ETH_P_EAPOL,
- handle_read, drv, 1);
- if (drv->sock_xmit == NULL)
- goto bad;
-@@ -1157,7 +1159,7 @@ madwifi_init(struct hostapd_data *hapd,
- 1);
- if (drv->sock_recv == NULL)
- goto bad;
-- } else if (linux_br_get(brname, drv->iface) == 0) {
-+ } else if (linux_br_get(brname, drv->ifname) == 0) {
- wpa_printf(MSG_DEBUG, "Interface in bridge %s; configure for "
- "EAPOL receive", brname);
- drv->sock_recv = l2_packet_init(brname, NULL, ETH_P_EAPOL,
-@@ -1168,7 +1170,7 @@ madwifi_init(struct hostapd_data *hapd,
- drv->sock_recv = drv->sock_xmit;
-
- memset(&iwr, 0, sizeof(iwr));
-- os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
-+ os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
-
- iwr.u.mode = IW_MODE_MASTER;
-
-@@ -1203,7 +1205,7 @@ madwifi_deinit(void *priv)
- struct madwifi_driver_data *drv = priv;
-
- netlink_deinit(drv->netlink);
-- (void) linux_set_iface_flags(drv->ioctl_sock, drv->iface, 0);
-+ (void) linux_set_iface_flags(drv->ioctl_sock, drv->ifname, 0);
- if (drv->ioctl_sock >= 0)
- close(drv->ioctl_sock);
- if (drv->sock_recv != NULL && drv->sock_recv != drv->sock_xmit)
-@@ -1222,7 +1224,7 @@ madwifi_set_ssid(void *priv, const u8 *b
- struct iwreq iwr;
-
- memset(&iwr, 0, sizeof(iwr));
-- os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
-+ os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
- iwr.u.essid.flags = 1; /* SSID active */
- iwr.u.essid.pointer = (caddr_t) buf;
- iwr.u.essid.length = len + 1;
-@@ -1243,7 +1245,7 @@ madwifi_get_ssid(void *priv, u8 *buf, in
- int ret = 0;
-
- memset(&iwr, 0, sizeof(iwr));
-- os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
-+ os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
- iwr.u.essid.pointer = (caddr_t) buf;
- iwr.u.essid.length = len;
-
-@@ -1270,137 +1272,16 @@ madwifi_commit(void *priv)
- return 0;
- }
-
--#else /* HOSTAPD */
-+#endif /* HOSTAPD */
-
--struct wpa_driver_madwifi_data {
-- void *wext; /* private data for driver_wext */
-- void *ctx;
-- char ifname[IFNAMSIZ + 1];
-- int sock;
--};
-+#if !defined(NO_SUPPLICANT)
-
- static int wpa_driver_madwifi_set_auth_alg(void *priv, int auth_alg);
- static int wpa_driver_madwifi_set_probe_req_ie(void *priv, const u8 *ies,
- size_t ies_len);
-
--
--static int
--set80211priv(struct wpa_driver_madwifi_data *drv, int op, void *data, int len,
-- int show_err)
--{
-- struct iwreq iwr;
--
-- os_memset(&iwr, 0, sizeof(iwr));
-- os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
-- if (len < IFNAMSIZ &&
-- op != IEEE80211_IOCTL_SET_APPIEBUF) {
-- /*
-- * Argument data fits inline; put it there.
-- */
-- os_memcpy(iwr.u.name, data, len);
-- } else {
-- /*
-- * Argument data too big for inline transfer; setup a
-- * parameter block instead; the kernel will transfer
-- * the data for the driver.
-- */
-- iwr.u.data.pointer = data;
-- iwr.u.data.length = len;
-- }
--
-- if (ioctl(drv->sock, op, &iwr) < 0) {
-- if (show_err) {
--#ifdef MADWIFI_NG
-- int first = IEEE80211_IOCTL_SETPARAM;
-- int last = IEEE80211_IOCTL_KICKMAC;
-- static const char *opnames[] = {
-- "ioctl[IEEE80211_IOCTL_SETPARAM]",
-- "ioctl[IEEE80211_IOCTL_GETPARAM]",
-- "ioctl[IEEE80211_IOCTL_SETMODE]",
-- "ioctl[IEEE80211_IOCTL_GETMODE]",
-- "ioctl[IEEE80211_IOCTL_SETWMMPARAMS]",
-- "ioctl[IEEE80211_IOCTL_GETWMMPARAMS]",
-- "ioctl[IEEE80211_IOCTL_SETCHANLIST]",
-- "ioctl[IEEE80211_IOCTL_GETCHANLIST]",
-- "ioctl[IEEE80211_IOCTL_CHANSWITCH]",
-- NULL,
-- "ioctl[IEEE80211_IOCTL_SET_APPIEBUF]",
-- "ioctl[IEEE80211_IOCTL_GETSCANRESULTS]",
-- NULL,
-- "ioctl[IEEE80211_IOCTL_GETCHANINFO]",
-- "ioctl[IEEE80211_IOCTL_SETOPTIE]",
-- "ioctl[IEEE80211_IOCTL_GETOPTIE]",
-- "ioctl[IEEE80211_IOCTL_SETMLME]",
-- NULL,
-- "ioctl[IEEE80211_IOCTL_SETKEY]",
-- NULL,
-- "ioctl[IEEE80211_IOCTL_DELKEY]",
-- NULL,
-- "ioctl[IEEE80211_IOCTL_ADDMAC]",
-- NULL,
-- "ioctl[IEEE80211_IOCTL_DELMAC]",
-- NULL,
-- "ioctl[IEEE80211_IOCTL_WDSMAC]",
-- NULL,
-- "ioctl[IEEE80211_IOCTL_WDSDELMAC]",
-- NULL,
-- "ioctl[IEEE80211_IOCTL_KICKMAC]",
-- };
--#else /* MADWIFI_NG */
-- int first = IEEE80211_IOCTL_SETPARAM;
-- int last = IEEE80211_IOCTL_CHANLIST;
-- static const char *opnames[] = {
-- "ioctl[IEEE80211_IOCTL_SETPARAM]",
-- "ioctl[IEEE80211_IOCTL_GETPARAM]",
-- "ioctl[IEEE80211_IOCTL_SETKEY]",
-- "ioctl[IEEE80211_IOCTL_GETKEY]",
-- "ioctl[IEEE80211_IOCTL_DELKEY]",
-- NULL,
-- "ioctl[IEEE80211_IOCTL_SETMLME]",
-- NULL,
-- "ioctl[IEEE80211_IOCTL_SETOPTIE]",
-- "ioctl[IEEE80211_IOCTL_GETOPTIE]",
-- "ioctl[IEEE80211_IOCTL_ADDMAC]",
-- NULL,
-- "ioctl[IEEE80211_IOCTL_DELMAC]",
-- NULL,
-- "ioctl[IEEE80211_IOCTL_CHANLIST]",
-- };
--#endif /* MADWIFI_NG */
-- int idx = op - first;
-- if (first <= op && op <= last &&
-- idx < (int) (sizeof(opnames) / sizeof(opnames[0]))
-- && opnames[idx])
-- perror(opnames[idx]);
-- else
-- perror("ioctl[unknown???]");
-- }
-- return -1;
-- }
-- return 0;
--}
--
--static int
--set80211param(struct wpa_driver_madwifi_data *drv, int op, int arg,
-- int show_err)
--{
-- struct iwreq iwr;
--
-- os_memset(&iwr, 0, sizeof(iwr));
-- os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
-- iwr.u.mode = op;
-- os_memcpy(iwr.u.name+sizeof(u32), &arg, sizeof(arg));
--
-- if (ioctl(drv->sock, IEEE80211_IOCTL_SETPARAM, &iwr) < 0) {
-- if (show_err)
-- perror("ioctl[IEEE80211_IOCTL_SETPARAM]");
-- return -1;
-- }
-- return 0;
--}
--
- static int
--wpa_driver_madwifi_set_wpa_ie(struct wpa_driver_madwifi_data *drv,
-+wpa_driver_madwifi_set_wpa_ie(struct madwifi_driver_data *drv,
- const u8 *wpa_ie, size_t wpa_ie_len)
- {
- struct iwreq iwr;
-@@ -1411,7 +1292,7 @@ wpa_driver_madwifi_set_wpa_ie(struct wpa
- iwr.u.data.pointer = (void *) wpa_ie;
- iwr.u.data.length = wpa_ie_len;
-
-- if (ioctl(drv->sock, IEEE80211_IOCTL_SETOPTIE, &iwr) < 0) {
-+ if (ioctl(drv->ioctl_sock, IEEE80211_IOCTL_SETOPTIE, &iwr) < 0) {
- perror("ioctl[IEEE80211_IOCTL_SETOPTIE]");
- return -1;
- }
-@@ -1419,156 +1300,51 @@ wpa_driver_madwifi_set_wpa_ie(struct wpa
- }
-
- static int
--wpa_driver_madwifi_del_key(struct wpa_driver_madwifi_data *drv, int key_idx,
-- const u8 *addr)
--{
-- struct ieee80211req_del_key wk;
--
-- wpa_printf(MSG_DEBUG, "%s: keyidx=%d", __FUNCTION__, key_idx);
-- os_memset(&wk, 0, sizeof(wk));
-- wk.idk_keyix = key_idx;
-- if (addr != NULL)
-- os_memcpy(wk.idk_macaddr, addr, IEEE80211_ADDR_LEN);
--
-- return set80211priv(drv, IEEE80211_IOCTL_DELKEY, &wk, sizeof(wk), 1);
--}
--
--static int
--wpa_driver_madwifi_set_key(const char *ifname, void *priv, enum wpa_alg alg,
-- const u8 *addr, int key_idx, int set_tx,
-- const u8 *seq, size_t seq_len,
-- const u8 *key, size_t key_len)
--{
-- struct wpa_driver_madwifi_data *drv = priv;
-- struct ieee80211req_key wk;
-- char *alg_name;
-- u_int8_t cipher;
--
-- if (alg == WPA_ALG_NONE)
-- return wpa_driver_madwifi_del_key(drv, key_idx, addr);
--
-- switch (alg) {
-- case WPA_ALG_WEP:
-- if (addr == NULL || os_memcmp(addr, "\xff\xff\xff\xff\xff\xff",
-- ETH_ALEN) == 0) {
-- /*
-- * madwifi did not seem to like static WEP key
-- * configuration with IEEE80211_IOCTL_SETKEY, so use
-- * Linux wireless extensions ioctl for this.
-- */
-- return wpa_driver_wext_set_key(ifname, drv->wext, alg,
-- addr, key_idx, set_tx,
-- seq, seq_len,
-- key, key_len);
-- }
-- alg_name = "WEP";
-- cipher = IEEE80211_CIPHER_WEP;
-- break;
-- case WPA_ALG_TKIP:
-- alg_name = "TKIP";
-- cipher = IEEE80211_CIPHER_TKIP;
-- break;
-- case WPA_ALG_CCMP:
-- alg_name = "CCMP";
-- cipher = IEEE80211_CIPHER_AES_CCM;
-- break;
-- default:
-- wpa_printf(MSG_DEBUG, "%s: unknown/unsupported algorithm %d",
-- __FUNCTION__, alg);
-- return -1;
-- }
--
-- wpa_printf(MSG_DEBUG, "%s: alg=%s key_idx=%d set_tx=%d seq_len=%lu "
-- "key_len=%lu", __FUNCTION__, alg_name, key_idx, set_tx,
-- (unsigned long) seq_len, (unsigned long) key_len);
--
-- if (seq_len > sizeof(u_int64_t)) {
-- wpa_printf(MSG_DEBUG, "%s: seq_len %lu too big",
-- __FUNCTION__, (unsigned long) seq_len);
-- return -2;
-- }
-- if (key_len > sizeof(wk.ik_keydata)) {
-- wpa_printf(MSG_DEBUG, "%s: key length %lu too big",
-- __FUNCTION__, (unsigned long) key_len);
-- return -3;
-- }
--
-- os_memset(&wk, 0, sizeof(wk));
-- wk.ik_type = cipher;
-- wk.ik_flags = IEEE80211_KEY_RECV;
-- if (addr == NULL ||
-- os_memcmp(addr, "\xff\xff\xff\xff\xff\xff", ETH_ALEN) == 0)
-- wk.ik_flags |= IEEE80211_KEY_GROUP;
-- if (set_tx) {
-- wk.ik_flags |= IEEE80211_KEY_XMIT | IEEE80211_KEY_DEFAULT;
-- os_memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
-- } else
-- os_memset(wk.ik_macaddr, 0, IEEE80211_ADDR_LEN);
-- wk.ik_keyix = key_idx;
-- wk.ik_keylen = key_len;
--#ifdef WORDS_BIGENDIAN
-- {
-- size_t i;
-- u8 tmp[WPA_KEY_RSC_LEN];
-- os_memset(tmp, 0, sizeof(tmp));
-- for (i = 0; i < seq_len; i++)
-- tmp[WPA_KEY_RSC_LEN - i - 1] = seq[i];
-- os_memcpy(&wk.ik_keyrsc, tmp, WPA_KEY_RSC_LEN);
-- }
--#else /* WORDS_BIGENDIAN */
-- os_memcpy(&wk.ik_keyrsc, seq, seq_len);
--#endif /* WORDS_BIGENDIAN */
-- os_memcpy(wk.ik_keydata, key, key_len);
--
-- return set80211priv(drv, IEEE80211_IOCTL_SETKEY, &wk, sizeof(wk), 1);
--}
--
--static int
- wpa_driver_madwifi_set_countermeasures(void *priv, int enabled)
- {
-- struct wpa_driver_madwifi_data *drv = priv;
-+ struct madwifi_driver_data *drv = priv;
- wpa_printf(MSG_DEBUG, "%s: enabled=%d", __FUNCTION__, enabled);
-- return set80211param(drv, IEEE80211_PARAM_COUNTERMEASURES, enabled, 1);
-+ return set80211param(drv, IEEE80211_PARAM_COUNTERMEASURES, enabled);
- }
-
- static int
- wpa_driver_madwifi_deauthenticate(void *priv, const u8 *addr, int reason_code)
- {
-- struct wpa_driver_madwifi_data *drv = priv;
-+ struct madwifi_driver_data *drv = priv;
- struct ieee80211req_mlme mlme;
-
- wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
- mlme.im_op = IEEE80211_MLME_DEAUTH;
- mlme.im_reason = reason_code;
- os_memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
-- return set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme), 1);
-+ return set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme));
- }
-
- static int
- wpa_driver_madwifi_disassociate(void *priv, const u8 *addr, int reason_code)
- {
-- struct wpa_driver_madwifi_data *drv = priv;
-+ struct madwifi_driver_data *drv = priv;
- struct ieee80211req_mlme mlme;
-
- wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
- mlme.im_op = IEEE80211_MLME_DISASSOC;
- mlme.im_reason = reason_code;
- os_memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
-- return set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme), 1);
-+ return set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme));
- }
-
- static int
- wpa_driver_madwifi_associate(void *priv,
- struct wpa_driver_associate_params *params)
- {
-- struct wpa_driver_madwifi_data *drv = priv;
-+ struct madwifi_driver_data *drv = priv;
- struct ieee80211req_mlme mlme;
- int ret = 0, privacy = 1;
-
- wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
-
- if (set80211param(drv, IEEE80211_PARAM_DROPUNENCRYPTED,
-- params->drop_unencrypted, 1) < 0)
-+ params->drop_unencrypted) < 0)
- ret = -1;
- if (wpa_driver_madwifi_set_auth_alg(drv, params->auth_alg) < 0)
- ret = -1;
-@@ -1591,12 +1367,12 @@ wpa_driver_madwifi_associate(void *priv,
- params->wpa_ie_len == 0)
- privacy = 0;
-
-- if (set80211param(drv, IEEE80211_PARAM_PRIVACY, privacy, 1) < 0)
-+ if (set80211param(drv, IEEE80211_PARAM_PRIVACY, privacy) < 0)
- ret = -1;
-
- if (params->wpa_ie_len &&
- set80211param(drv, IEEE80211_PARAM_WPA,
-- params->wpa_ie[0] == WLAN_EID_RSN ? 2 : 1, 1) < 0)
-+ params->wpa_ie[0] == WLAN_EID_RSN ? 2 : 1) < 0)
- ret = -1;
-
- if (params->bssid == NULL) {
-@@ -1604,14 +1380,14 @@ wpa_driver_madwifi_associate(void *priv,
- * roaming */
- /* FIX: this does not seem to work; would probably need to
- * change something in the driver */
-- if (set80211param(drv, IEEE80211_PARAM_ROAMING, 0, 1) < 0)
-+ if (set80211param(drv, IEEE80211_PARAM_ROAMING, 0) < 0)
- ret = -1;
-
- if (wpa_driver_wext_set_ssid(drv->wext, params->ssid,
- params->ssid_len) < 0)
- ret = -1;
- } else {
-- if (set80211param(drv, IEEE80211_PARAM_ROAMING, 2, 1) < 0)
-+ if (set80211param(drv, IEEE80211_PARAM_ROAMING, 2) < 0)
- ret = -1;
- if (wpa_driver_wext_set_ssid(drv->wext, params->ssid,
- params->ssid_len) < 0)
-@@ -1620,7 +1396,7 @@ wpa_driver_madwifi_associate(void *priv,
- mlme.im_op = IEEE80211_MLME_ASSOC;
- os_memcpy(mlme.im_macaddr, params->bssid, IEEE80211_ADDR_LEN);
- if (set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme,
-- sizeof(mlme), 1) < 0) {
-+ sizeof(mlme)) < 0) {
- wpa_printf(MSG_DEBUG, "%s: SETMLME[ASSOC] failed",
- __func__);
- ret = -1;
-@@ -1633,7 +1409,7 @@ wpa_driver_madwifi_associate(void *priv,
- static int
- wpa_driver_madwifi_set_auth_alg(void *priv, int auth_alg)
- {
-- struct wpa_driver_madwifi_data *drv = priv;
-+ struct madwifi_driver_data *drv = priv;
- int authmode;
-
- if ((auth_alg & WPA_AUTH_ALG_OPEN) &&
-@@ -1644,13 +1420,13 @@ wpa_driver_madwifi_set_auth_alg(void *pr
- else
- authmode = IEEE80211_AUTH_OPEN;
-
-- return set80211param(drv, IEEE80211_PARAM_AUTHMODE, authmode, 1);
-+ return set80211param(drv, IEEE80211_PARAM_AUTHMODE, authmode);
- }
-
- static int
- wpa_driver_madwifi_scan(void *priv, struct wpa_driver_scan_params *params)
- {
-- struct wpa_driver_madwifi_data *drv = priv;
-+ struct madwifi_driver_data *drv = priv;
- struct iwreq iwr;
- int ret = 0;
- const u8 *ssid = params->ssids[0].ssid;
-@@ -1668,7 +1444,7 @@ wpa_driver_madwifi_scan(void *priv, stru
- if (wpa_driver_wext_set_ssid(drv->wext, ssid, ssid_len) < 0)
- ret = -1;
-
-- if (ioctl(drv->sock, SIOCSIWSCAN, &iwr) < 0) {
-+ if (ioctl(drv->ioctl_sock, SIOCSIWSCAN, &iwr) < 0) {
- perror("ioctl[SIOCSIWSCAN]");
- ret = -1;
- }
-@@ -1690,14 +1466,14 @@ wpa_driver_madwifi_scan(void *priv, stru
-
- static int wpa_driver_madwifi_get_bssid(void *priv, u8 *bssid)
- {
-- struct wpa_driver_madwifi_data *drv = priv;
-+ struct madwifi_driver_data *drv = priv;
- return wpa_driver_wext_get_bssid(drv->wext, bssid);
- }
-
-
- static int wpa_driver_madwifi_get_ssid(void *priv, u8 *ssid)
- {
-- struct wpa_driver_madwifi_data *drv = priv;
-+ struct madwifi_driver_data *drv = priv;
- return wpa_driver_wext_get_ssid(drv->wext, ssid);
- }
-
-@@ -1705,14 +1481,16 @@ static int wpa_driver_madwifi_get_ssid(v
- static struct wpa_scan_results *
- wpa_driver_madwifi_get_scan_results(void *priv)
- {
-- struct wpa_driver_madwifi_data *drv = priv;
-+ struct madwifi_driver_data *drv = priv;
- return wpa_driver_wext_get_scan_results(drv->wext);
- }
-
-
- static int wpa_driver_madwifi_set_operstate(void *priv, int state)
- {
-- struct wpa_driver_madwifi_data *drv = priv;
-+ struct madwifi_driver_data *drv = priv;
-+ if (!drv->wext)
-+ return 0;
- return wpa_driver_wext_set_operstate(drv->wext, state);
- }
-
-@@ -1733,7 +1511,7 @@ static int wpa_driver_madwifi_set_probe_
-
- ret = set80211priv(priv, IEEE80211_IOCTL_SET_APPIEBUF, probe_req_ie,
- sizeof(struct ieee80211req_getset_appiebuf) +
-- ies_len, 1);
-+ ies_len);
-
- os_free(probe_req_ie);
-
-@@ -1743,7 +1521,7 @@ static int wpa_driver_madwifi_set_probe_
-
- static void * wpa_driver_madwifi_init(void *ctx, const char *ifname)
- {
-- struct wpa_driver_madwifi_data *drv;
-+ struct madwifi_driver_data *drv;
-
- drv = os_zalloc(sizeof(*drv));
- if (drv == NULL)
-@@ -1754,17 +1532,17 @@ static void * wpa_driver_madwifi_init(vo
-
- drv->ctx = ctx;
- os_strlcpy(drv->ifname, ifname, sizeof(drv->ifname));
-- drv->sock = socket(PF_INET, SOCK_DGRAM, 0);
-- if (drv->sock < 0)
-+ drv->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0);
-+ if (drv->ioctl_sock < 0)
- goto fail2;
-
-- if (set80211param(drv, IEEE80211_PARAM_ROAMING, 2, 1) < 0) {
-+ if (set80211param(drv, IEEE80211_PARAM_ROAMING, 2) < 0) {
- wpa_printf(MSG_DEBUG, "%s: failed to set wpa_supplicant-based "
- "roaming", __FUNCTION__);
- goto fail3;
- }
-
-- if (set80211param(drv, IEEE80211_PARAM_WPA, 3, 1) < 0) {
-+ if (set80211param(drv, IEEE80211_PARAM_WPA, 3) < 0) {
- wpa_printf(MSG_DEBUG, "%s: failed to enable WPA support",
- __FUNCTION__);
- goto fail3;
-@@ -1773,7 +1551,7 @@ static void * wpa_driver_madwifi_init(vo
- return drv;
-
- fail3:
-- close(drv->sock);
-+ close(drv->ioctl_sock);
- fail2:
- wpa_driver_wext_deinit(drv->wext);
- fail:
-@@ -1784,38 +1562,37 @@ fail:
-
- static void wpa_driver_madwifi_deinit(void *priv)
- {
-- struct wpa_driver_madwifi_data *drv = priv;
-+ struct madwifi_driver_data *drv = priv;
-
- if (wpa_driver_madwifi_set_wpa_ie(drv, NULL, 0) < 0) {
- wpa_printf(MSG_DEBUG, "%s: failed to clear WPA IE",
- __FUNCTION__);
- }
-- if (set80211param(drv, IEEE80211_PARAM_ROAMING, 0, 1) < 0) {
-+ if (set80211param(drv, IEEE80211_PARAM_ROAMING, 0) < 0) {
- wpa_printf(MSG_DEBUG, "%s: failed to enable driver-based "
- "roaming", __FUNCTION__);
- }
-- if (set80211param(drv, IEEE80211_PARAM_PRIVACY, 0, 1) < 0) {
-+ if (set80211param(drv, IEEE80211_PARAM_PRIVACY, 0) < 0) {
- wpa_printf(MSG_DEBUG, "%s: failed to disable forced Privacy "
- "flag", __FUNCTION__);
- }
-- if (set80211param(drv, IEEE80211_PARAM_WPA, 0, 1) < 0) {
-+ if (set80211param(drv, IEEE80211_PARAM_WPA, 0) < 0) {
- wpa_printf(MSG_DEBUG, "%s: failed to disable WPA",
- __FUNCTION__);
- }
-
- wpa_driver_wext_deinit(drv->wext);
-
-- close(drv->sock);
-+ close(drv->ioctl_sock);
- os_free(drv);
- }
-
--#endif /* HOSTAPD */
--
-+#endif
-
- const struct wpa_driver_ops wpa_driver_madwifi_ops = {
- .name = "madwifi",
- .desc = "MADWIFI 802.11 support (Atheros, etc.)",
-- .set_key = wpa_driver_madwifi_set_key,
-+ .set_key = madwifi_set_key,
- #ifdef HOSTAPD
- .hapd_init = madwifi_init,
- .hapd_deinit = madwifi_deinit,
-@@ -1835,7 +1612,8 @@ const struct wpa_driver_ops wpa_driver_m
- .sta_clear_stats = madwifi_sta_clear_stats,
- .commit = madwifi_commit,
- .set_ap_wps_ie = madwifi_set_ap_wps_ie,
--#else /* HOSTAPD */
-+#endif /* HOSTAPD */
-+#if !defined(NO_SUPPLICANT)
- .get_bssid = wpa_driver_madwifi_get_bssid,
- .get_ssid = wpa_driver_madwifi_get_ssid,
- .init = wpa_driver_madwifi_init,
-@@ -1847,5 +1625,5 @@ const struct wpa_driver_ops wpa_driver_m
- .disassociate = wpa_driver_madwifi_disassociate,
- .associate = wpa_driver_madwifi_associate,
- .set_operstate = wpa_driver_madwifi_set_operstate,
--#endif /* HOSTAPD */
-+#endif
- };
--- /dev/null
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -464,6 +464,10 @@ static void wpa_driver_nl80211_event_rtm
+ return;
+ }
+
++ if (ifi->ifi_family == AF_BRIDGE &&
++ drv->nlmode != NL80211_IFTYPE_AP)
++ return;
++
+ wpa_printf(MSG_DEBUG, "RTM_NEWLINK: operstate=%d ifi_flags=0x%x "
+ "(%s%s%s%s)",
+ drv->operstate, ifi->ifi_flags,
+@@ -535,6 +539,10 @@ static void wpa_driver_nl80211_event_rtm
+ attrlen = len;
+ attr = (struct rtattr *) buf;
+
++ if (ifi->ifi_family == AF_BRIDGE &&
++ drv->nlmode != NL80211_IFTYPE_AP)
++ return;
++
+ rta_len = RTA_ALIGN(sizeof(struct rtattr));
+ while (RTA_OK(attr, attrlen)) {
+ if (attr->rta_type == IFLA_IFNAME) {
+@@ -1610,6 +1618,11 @@ static int wpa_driver_nl80211_capa(struc
+ drv->capa.flags |= WPA_DRIVER_FLAGS_P2P_CAPABLE;
+ drv->capa.max_remain_on_chan = info.max_remain_on_chan;
+
++#ifdef HOSTAPD
++ drv->num_if_indices = sizeof(drv->default_if_indices) / sizeof(int);
++ drv->if_indices = drv->default_if_indices;
++#endif
++
+ return 0;
+ }
+
+@@ -5602,8 +5615,6 @@ static void *i802_init(struct hostapd_da
+ br_ifindex = 0;
+ }
+
+- drv->num_if_indices = sizeof(drv->default_if_indices) / sizeof(int);
+- drv->if_indices = drv->default_if_indices;
+ for (i = 0; i < params->num_bridge; i++) {
+ if (params->bridge[i]) {
+ ifindex = if_nametoindex(params->bridge[i]);
--- /dev/null
+--- a/src/drivers/driver_madwifi.c
++++ b/src/drivers/driver_madwifi.c
+@@ -439,7 +439,11 @@ madwifi_set_key(const char *ifname, void
+ __func__, alg, ether_sprintf(addr), key_idx);
+
+ if (alg == WPA_ALG_WEP)
++ {
+ cipher = IEEE80211_CIPHER_WEP;
++ if ((!addr || !memcmp(addr, "\xff\xff\xff\xff\xff\xff", ETH_ALEN)) && drv->wext)
++ return wpa_driver_wext_set_key(ifname, drv->wext, alg, addr, key_idx, set_tx, seq, seq_len, key, key_len);
++ }
+ else if (alg == WPA_ALG_TKIP)
+ cipher = IEEE80211_CIPHER_TKIP;
+ else if (alg == WPA_ALG_CCMP)
+@@ -458,20 +462,45 @@ madwifi_set_key(const char *ifname, void
+
+ memset(&wk, 0, sizeof(wk));
+ wk.ik_type = cipher;
+- wk.ik_flags = IEEE80211_KEY_RECV | IEEE80211_KEY_XMIT;
+- if (addr == NULL || is_broadcast_ether_addr(addr)) {
+- memset(wk.ik_macaddr, 0xff, IEEE80211_ADDR_LEN);
++ wk.ik_flags = IEEE80211_KEY_RECV;
++ if (set_tx)
++ wk.ik_flags |= IEEE80211_KEY_XMIT;
++ if (addr == NULL) {
++ os_memset(wk.ik_macaddr, 0xff, IEEE80211_ADDR_LEN);
+ wk.ik_keyix = key_idx;
+- wk.ik_flags |= IEEE80211_KEY_DEFAULT;
+- } else if (!memcmp(addr, "\xff\xff\xff\xff\xff\xff", ETH_ALEN)) {
+- wk.ik_flags |= IEEE80211_KEY_GROUP;
+- memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
+ } else {
+- memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
+- wk.ik_keyix = IEEE80211_KEYIX_NONE;
++ os_memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
++ /*
++ * Deduce whether group/global or unicast key by checking
++ * the address (yech). Note also that we can only mark global
++ * keys default; doing this for a unicast key is an error.
++ */
++ if (os_memcmp(addr, "\xff\xff\xff\xff\xff\xff",
++ IEEE80211_ADDR_LEN) == 0) {
++ wk.ik_flags |= IEEE80211_KEY_GROUP;
++ wk.ik_keyix = key_idx;
++ } else {
++ wk.ik_keyix = key_idx == 0 ? IEEE80211_KEYIX_NONE :
++ key_idx;
++ }
+ }
++ if (wk.ik_keyix != IEEE80211_KEYIX_NONE && set_tx)
++ wk.ik_flags |= IEEE80211_KEY_DEFAULT;
+ wk.ik_keylen = key_len;
+ memcpy(wk.ik_keydata, key, key_len);
++#ifdef WORDS_BIGENDIAN
++#define WPA_KEY_RSC_LEN 8
++ {
++ size_t i;
++ u8 tmp[WPA_KEY_RSC_LEN];
++ os_memset(tmp, 0, sizeof(tmp));
++ for (i = 0; i < seq_len; i++)
++ tmp[WPA_KEY_RSC_LEN - i - 1] = seq[i];
++ os_memcpy(&wk.ik_keyrsc, tmp, WPA_KEY_RSC_LEN);
++ }
++#else /* WORDS_BIGENDIAN */
++ os_memcpy(&wk.ik_keyrsc, seq, seq_len);
++#endif /* WORDS_BIGENDIAN */
+
+ ret = set80211priv(drv, IEEE80211_IOCTL_SETKEY, &wk, sizeof(wk));
+ if (ret < 0) {
+++ /dev/null
---- a/src/drivers/driver_roboswitch.c
-+++ b/src/drivers/driver_roboswitch.c
-@@ -14,10 +14,10 @@
-
- #include "includes.h"
- #include <sys/ioctl.h>
--#include <linux/if.h>
- #include <linux/sockios.h>
- #include <linux/if_ether.h>
- #include <linux/mii.h>
-+#include <net/if.h>
-
- #include "common.h"
- #include "driver.h"
--- /dev/null
+--- a/src/drivers/driver_hostap.c
++++ b/src/drivers/driver_hostap.c
+@@ -22,9 +22,6 @@
+ #include "eloop.h"
+ #include "driver_hostap.h"
+
+-
+-#ifdef HOSTAPD
+-
+ #include <net/if_arp.h>
+ #include <netpacket/packet.h>
+
+@@ -42,10 +39,16 @@
+ static const u8 rfc1042_header[6] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
+
+ struct hostap_driver_data {
++ void *wext; /* private data for driver_wext */
++ void *ctx;
++ char ifname[IFNAMSIZ + 1];
++ int sock;
++ int current_mode; /* infra/adhoc */
++
++#ifdef HOSTAPD
+ struct hostapd_data *hapd;
+
+ char iface[IFNAMSIZ + 1];
+- int sock; /* raw packet socket for driver access */
+ int ioctl_sock; /* socket for ioctl() use */
+ struct netlink_data *netlink;
+
+@@ -55,9 +58,11 @@ struct hostap_driver_data {
+ size_t generic_ie_len;
+ u8 *wps_ie;
+ size_t wps_ie_len;
++#endif
+ };
+
+
++#ifdef HOSTAPD
+ static int hostapd_ioctl(void *priv, struct prism2_hostapd_param *param,
+ int len);
+ static int hostap_set_iface_flags(void *priv, int dev_up);
+@@ -399,65 +404,6 @@ static int hostapd_ioctl(void *priv, str
+ }
+
+
+-static int wpa_driver_hostap_set_key(const char *ifname, void *priv,
+- enum wpa_alg alg, const u8 *addr,
+- int key_idx, int set_tx,
+- const u8 *seq, size_t seq_len,
+- const u8 *key, size_t key_len)
+-{
+- struct hostap_driver_data *drv = priv;
+- struct prism2_hostapd_param *param;
+- u8 *buf;
+- size_t blen;
+- int ret = 0;
+-
+- blen = sizeof(*param) + key_len;
+- buf = os_zalloc(blen);
+- if (buf == NULL)
+- return -1;
+-
+- param = (struct prism2_hostapd_param *) buf;
+- param->cmd = PRISM2_SET_ENCRYPTION;
+- if (addr == NULL)
+- memset(param->sta_addr, 0xff, ETH_ALEN);
+- else
+- memcpy(param->sta_addr, addr, ETH_ALEN);
+- switch (alg) {
+- case WPA_ALG_NONE:
+- os_strlcpy((char *) param->u.crypt.alg, "NONE",
+- HOSTAP_CRYPT_ALG_NAME_LEN);
+- break;
+- case WPA_ALG_WEP:
+- os_strlcpy((char *) param->u.crypt.alg, "WEP",
+- HOSTAP_CRYPT_ALG_NAME_LEN);
+- break;
+- case WPA_ALG_TKIP:
+- os_strlcpy((char *) param->u.crypt.alg, "TKIP",
+- HOSTAP_CRYPT_ALG_NAME_LEN);
+- break;
+- case WPA_ALG_CCMP:
+- os_strlcpy((char *) param->u.crypt.alg, "CCMP",
+- HOSTAP_CRYPT_ALG_NAME_LEN);
+- break;
+- default:
+- os_free(buf);
+- return -1;
+- }
+- param->u.crypt.flags = set_tx ? HOSTAP_CRYPT_FLAG_SET_TX_KEY : 0;
+- param->u.crypt.idx = key_idx;
+- param->u.crypt.key_len = key_len;
+- memcpy((u8 *) (param + 1), key, key_len);
+-
+- if (hostapd_ioctl(drv, param, blen)) {
+- printf("Failed to set encryption.\n");
+- ret = -1;
+- }
+- free(buf);
+-
+- return ret;
+-}
+-
+-
+ static int hostap_get_seqnum(const char *ifname, void *priv, const u8 *addr,
+ int idx, u8 *seq)
+ {
+@@ -1125,21 +1071,9 @@ static struct hostapd_hw_modes * hostap_
+ return mode;
+ }
+
+-#else /* HOSTAPD */
+-
+-struct wpa_driver_hostap_data {
+- void *wext; /* private data for driver_wext */
+- void *ctx;
+- char ifname[IFNAMSIZ + 1];
+- int sock;
+- int current_mode; /* infra/adhoc */
+-};
+-
+-
+-static int wpa_driver_hostap_set_auth_alg(void *priv, int auth_alg);
+-
++#endif /* HOSTAPD */
+
+-static int hostapd_ioctl(struct wpa_driver_hostap_data *drv,
++static int wpa_hostapd_ioctl(struct hostap_driver_data *drv,
+ struct prism2_hostapd_param *param,
+ int len, int show_err)
+ {
+@@ -1161,7 +1095,12 @@ static int hostapd_ioctl(struct wpa_driv
+ }
+
+
+-static int wpa_driver_hostap_set_wpa_ie(struct wpa_driver_hostap_data *drv,
++#if !defined(NO_SUPPLICANT)
++
++static int wpa_driver_hostap_set_auth_alg(void *priv, int auth_alg);
++
++
++static int wpa_driver_hostap_set_wpa_ie(struct hostap_driver_data *drv,
+ const u8 *wpa_ie, size_t wpa_ie_len)
+ {
+ struct prism2_hostapd_param *param;
+@@ -1177,7 +1116,7 @@ static int wpa_driver_hostap_set_wpa_ie(
+ param->cmd = PRISM2_HOSTAPD_SET_GENERIC_ELEMENT;
+ param->u.generic_elem.len = wpa_ie_len;
+ os_memcpy(param->u.generic_elem.data, wpa_ie, wpa_ie_len);
+- res = hostapd_ioctl(drv, param, blen, 1);
++ res = wpa_hostapd_ioctl(drv, param, blen, 1);
+
+ os_free(param);
+
+@@ -1185,7 +1124,7 @@ static int wpa_driver_hostap_set_wpa_ie(
+ }
+
+
+-static int prism2param(struct wpa_driver_hostap_data *drv, int param,
++static int prism2param(struct hostap_driver_data *drv, int param,
+ int value)
+ {
+ struct iwreq iwr;
+@@ -1207,7 +1146,7 @@ static int prism2param(struct wpa_driver
+
+ static int wpa_driver_hostap_set_wpa(void *priv, int enabled)
+ {
+- struct wpa_driver_hostap_data *drv = priv;
++ struct hostap_driver_data *drv = priv;
+ int ret = 0;
+
+ wpa_printf(MSG_DEBUG, "%s: enabled=%d", __FUNCTION__, enabled);
+@@ -1223,125 +1162,15 @@ static int wpa_driver_hostap_set_wpa(voi
+ }
+
+
+-static void show_set_key_error(struct prism2_hostapd_param *param)
+-{
+- switch (param->u.crypt.err) {
+- case HOSTAP_CRYPT_ERR_UNKNOWN_ALG:
+- wpa_printf(MSG_INFO, "Unknown algorithm '%s'.",
+- param->u.crypt.alg);
+- wpa_printf(MSG_INFO, "You may need to load kernel module to "
+- "register that algorithm.");
+- wpa_printf(MSG_INFO, "E.g., 'modprobe hostap_crypt_wep' for "
+- "WEP.");
+- break;
+- case HOSTAP_CRYPT_ERR_UNKNOWN_ADDR:
+- wpa_printf(MSG_INFO, "Unknown address " MACSTR ".",
+- MAC2STR(param->sta_addr));
+- break;
+- case HOSTAP_CRYPT_ERR_CRYPT_INIT_FAILED:
+- wpa_printf(MSG_INFO, "Crypt algorithm initialization failed.");
+- break;
+- case HOSTAP_CRYPT_ERR_KEY_SET_FAILED:
+- wpa_printf(MSG_INFO, "Key setting failed.");
+- break;
+- case HOSTAP_CRYPT_ERR_TX_KEY_SET_FAILED:
+- wpa_printf(MSG_INFO, "TX key index setting failed.");
+- break;
+- case HOSTAP_CRYPT_ERR_CARD_CONF_FAILED:
+- wpa_printf(MSG_INFO, "Card configuration failed.");
+- break;
+- }
+-}
+-
+-
+-static int wpa_driver_hostap_set_key(const char *ifname, void *priv,
+- enum wpa_alg alg, const u8 *addr,
+- int key_idx, int set_tx,
+- const u8 *seq, size_t seq_len,
+- const u8 *key, size_t key_len)
+-{
+- struct wpa_driver_hostap_data *drv = priv;
+- struct prism2_hostapd_param *param;
+- u8 *buf;
+- size_t blen;
+- int ret = 0;
+- char *alg_name;
+-
+- switch (alg) {
+- case WPA_ALG_NONE:
+- alg_name = "none";
+- break;
+- case WPA_ALG_WEP:
+- alg_name = "WEP";
+- break;
+- case WPA_ALG_TKIP:
+- alg_name = "TKIP";
+- break;
+- case WPA_ALG_CCMP:
+- alg_name = "CCMP";
+- break;
+- default:
+- return -1;
+- }
+-
+- wpa_printf(MSG_DEBUG, "%s: alg=%s key_idx=%d set_tx=%d seq_len=%lu "
+- "key_len=%lu", __FUNCTION__, alg_name, key_idx, set_tx,
+- (unsigned long) seq_len, (unsigned long) key_len);
+-
+- if (seq_len > 8)
+- return -2;
+-
+- blen = sizeof(*param) + key_len;
+- buf = os_zalloc(blen);
+- if (buf == NULL)
+- return -1;
+-
+- param = (struct prism2_hostapd_param *) buf;
+- param->cmd = PRISM2_SET_ENCRYPTION;
+- /* TODO: In theory, STA in client mode can use five keys; four default
+- * keys for receiving (with keyidx 0..3) and one individual key for
+- * both transmitting and receiving (keyidx 0) _unicast_ packets. Now,
+- * keyidx 0 is reserved for this unicast use and default keys can only
+- * use keyidx 1..3 (i.e., default key with keyidx 0 is not supported).
+- * This should be fine for more or less all cases, but for completeness
+- * sake, the driver could be enhanced to support the missing key. */
+-#if 0
+- if (addr == NULL)
+- os_memset(param->sta_addr, 0xff, ETH_ALEN);
+- else
+- os_memcpy(param->sta_addr, addr, ETH_ALEN);
+-#else
+- os_memset(param->sta_addr, 0xff, ETH_ALEN);
+-#endif
+- os_strlcpy((char *) param->u.crypt.alg, alg_name,
+- HOSTAP_CRYPT_ALG_NAME_LEN);
+- param->u.crypt.flags = set_tx ? HOSTAP_CRYPT_FLAG_SET_TX_KEY : 0;
+- param->u.crypt.idx = key_idx;
+- if (seq)
+- os_memcpy(param->u.crypt.seq, seq, seq_len);
+- param->u.crypt.key_len = key_len;
+- os_memcpy((u8 *) (param + 1), key, key_len);
+-
+- if (hostapd_ioctl(drv, param, blen, 1)) {
+- wpa_printf(MSG_WARNING, "Failed to set encryption.");
+- show_set_key_error(param);
+- ret = -1;
+- }
+- os_free(buf);
+-
+- return ret;
+-}
+-
+-
+ static int wpa_driver_hostap_set_countermeasures(void *priv, int enabled)
+ {
+- struct wpa_driver_hostap_data *drv = priv;
++ struct hostap_driver_data *drv = priv;
+ wpa_printf(MSG_DEBUG, "%s: enabled=%d", __FUNCTION__, enabled);
+ return prism2param(drv, PRISM2_PARAM_TKIP_COUNTERMEASURES, enabled);
+ }
+
+
+-static int wpa_driver_hostap_reset(struct wpa_driver_hostap_data *drv,
++static int wpa_driver_hostap_reset(struct hostap_driver_data *drv,
+ int type)
+ {
+ struct iwreq iwr;
+@@ -1362,7 +1191,7 @@ static int wpa_driver_hostap_reset(struc
+ }
+
+
+-static int wpa_driver_hostap_mlme(struct wpa_driver_hostap_data *drv,
++static int wpa_driver_hostap_mlme(struct hostap_driver_data *drv,
+ const u8 *addr, int cmd, int reason_code)
+ {
+ struct prism2_hostapd_param param;
+@@ -1377,7 +1206,7 @@ static int wpa_driver_hostap_mlme(struct
+ os_memcpy(param.sta_addr, addr, ETH_ALEN);
+ param.u.mlme.cmd = cmd;
+ param.u.mlme.reason_code = reason_code;
+- ret = hostapd_ioctl(drv, ¶m, sizeof(param), 1);
++ ret = wpa_hostapd_ioctl(drv, ¶m, sizeof(param), 1);
+ if (ret == 0) {
+ os_sleep(0, 100000);
+ ret = wpa_driver_hostap_reset(drv, 2);
+@@ -1389,7 +1218,7 @@ static int wpa_driver_hostap_mlme(struct
+ static int wpa_driver_hostap_deauthenticate(void *priv, const u8 *addr,
+ int reason_code)
+ {
+- struct wpa_driver_hostap_data *drv = priv;
++ struct hostap_driver_data *drv = priv;
+ wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
+ return wpa_driver_hostap_mlme(drv, addr, MLME_STA_DEAUTH,
+ reason_code);
+@@ -1399,7 +1228,7 @@ static int wpa_driver_hostap_deauthentic
+ static int wpa_driver_hostap_disassociate(void *priv, const u8 *addr,
+ int reason_code)
+ {
+- struct wpa_driver_hostap_data *drv = priv;
++ struct hostap_driver_data *drv = priv;
+ wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
+ return wpa_driver_hostap_mlme(drv, addr, MLME_STA_DISASSOC,
+ reason_code);
+@@ -1410,7 +1239,7 @@ static int
+ wpa_driver_hostap_associate(void *priv,
+ struct wpa_driver_associate_params *params)
+ {
+- struct wpa_driver_hostap_data *drv = priv;
++ struct hostap_driver_data *drv = priv;
+ int ret = 0;
+ int allow_unencrypted_eapol;
+
+@@ -1474,7 +1303,7 @@ wpa_driver_hostap_associate(void *priv,
+ static int wpa_driver_hostap_scan(void *priv,
+ struct wpa_driver_scan_params *params)
+ {
+- struct wpa_driver_hostap_data *drv = priv;
++ struct hostap_driver_data *drv = priv;
+ struct prism2_hostapd_param param;
+ int ret;
+ const u8 *ssid = params->ssids[0].ssid;
+@@ -1495,7 +1324,7 @@ static int wpa_driver_hostap_scan(void *
+ param.cmd = PRISM2_HOSTAPD_SCAN_REQ;
+ param.u.scan_req.ssid_len = ssid_len;
+ os_memcpy(param.u.scan_req.ssid, ssid, ssid_len);
+- ret = hostapd_ioctl(drv, ¶m, sizeof(param), 1);
++ ret = wpa_hostapd_ioctl(drv, ¶m, sizeof(param), 1);
+
+ /* Not all drivers generate "scan completed" wireless event, so try to
+ * read results after a timeout. */
+@@ -1510,7 +1339,7 @@ static int wpa_driver_hostap_scan(void *
+
+ static int wpa_driver_hostap_set_auth_alg(void *priv, int auth_alg)
+ {
+- struct wpa_driver_hostap_data *drv = priv;
++ struct hostap_driver_data *drv = priv;
+ int algs = 0;
+
+ if (auth_alg & WPA_AUTH_ALG_OPEN)
+@@ -1528,35 +1357,35 @@ static int wpa_driver_hostap_set_auth_al
+
+ static int wpa_driver_hostap_get_bssid(void *priv, u8 *bssid)
+ {
+- struct wpa_driver_hostap_data *drv = priv;
++ struct hostap_driver_data *drv = priv;
+ return wpa_driver_wext_get_bssid(drv->wext, bssid);
+ }
+
+
+ static int wpa_driver_hostap_get_ssid(void *priv, u8 *ssid)
+ {
+- struct wpa_driver_hostap_data *drv = priv;
++ struct hostap_driver_data *drv = priv;
+ return wpa_driver_wext_get_ssid(drv->wext, ssid);
+ }
+
+
+ static struct wpa_scan_results * wpa_driver_hostap_get_scan_results(void *priv)
+ {
+- struct wpa_driver_hostap_data *drv = priv;
++ struct hostap_driver_data *drv = priv;
+ return wpa_driver_wext_get_scan_results(drv->wext);
+ }
+
+
+ static int wpa_driver_hostap_set_operstate(void *priv, int state)
+ {
+- struct wpa_driver_hostap_data *drv = priv;
++ struct hostap_driver_data *drv = priv;
+ return wpa_driver_wext_set_operstate(drv->wext, state);
+ }
+
+
+ static void * wpa_driver_hostap_init(void *ctx, const char *ifname)
+ {
+- struct wpa_driver_hostap_data *drv;
++ struct hostap_driver_data *drv;
+
+ drv = os_zalloc(sizeof(*drv));
+ if (drv == NULL)
+@@ -1596,14 +1425,120 @@ static void * wpa_driver_hostap_init(voi
+
+ static void wpa_driver_hostap_deinit(void *priv)
+ {
+- struct wpa_driver_hostap_data *drv = priv;
++ struct hostap_driver_data *drv = priv;
+ wpa_driver_hostap_set_wpa(drv, 0);
+ wpa_driver_wext_deinit(drv->wext);
+ close(drv->sock);
+ os_free(drv);
+ }
+
+-#endif /* HOSTAPD */
++#endif
++
++
++static void show_set_key_error(struct prism2_hostapd_param *param)
++{
++ switch (param->u.crypt.err) {
++ case HOSTAP_CRYPT_ERR_UNKNOWN_ALG:
++ wpa_printf(MSG_INFO, "Unknown algorithm '%s'.",
++ param->u.crypt.alg);
++ wpa_printf(MSG_INFO, "You may need to load kernel module to "
++ "register that algorithm.");
++ wpa_printf(MSG_INFO, "E.g., 'modprobe hostap_crypt_wep' for "
++ "WEP.");
++ break;
++ case HOSTAP_CRYPT_ERR_UNKNOWN_ADDR:
++ wpa_printf(MSG_INFO, "Unknown address " MACSTR ".",
++ MAC2STR(param->sta_addr));
++ break;
++ case HOSTAP_CRYPT_ERR_CRYPT_INIT_FAILED:
++ wpa_printf(MSG_INFO, "Crypt algorithm initialization failed.");
++ break;
++ case HOSTAP_CRYPT_ERR_KEY_SET_FAILED:
++ wpa_printf(MSG_INFO, "Key setting failed.");
++ break;
++ case HOSTAP_CRYPT_ERR_TX_KEY_SET_FAILED:
++ wpa_printf(MSG_INFO, "TX key index setting failed.");
++ break;
++ case HOSTAP_CRYPT_ERR_CARD_CONF_FAILED:
++ wpa_printf(MSG_INFO, "Card configuration failed.");
++ break;
++ }
++}
++
++
++static int wpa_driver_hostap_set_key(const char *ifname, void *priv,
++ enum wpa_alg alg, const u8 *addr,
++ int key_idx, int set_tx,
++ const u8 *seq, size_t seq_len,
++ const u8 *key, size_t key_len)
++{
++ struct hostap_driver_data *drv = priv;
++ struct prism2_hostapd_param *param;
++ u8 *buf;
++ size_t blen;
++ int ret = 0;
++ char *alg_name;
++
++ switch (alg) {
++ case WPA_ALG_NONE:
++ alg_name = "none";
++ break;
++ case WPA_ALG_WEP:
++ alg_name = "WEP";
++ break;
++ case WPA_ALG_TKIP:
++ alg_name = "TKIP";
++ break;
++ case WPA_ALG_CCMP:
++ alg_name = "CCMP";
++ break;
++ default:
++ return -1;
++ }
++
++ wpa_printf(MSG_DEBUG, "%s: alg=%s key_idx=%d set_tx=%d seq_len=%lu "
++ "key_len=%lu", __FUNCTION__, alg_name, key_idx, set_tx,
++ (unsigned long) seq_len, (unsigned long) key_len);
++
++ if (seq_len > 8)
++ return -2;
++
++ blen = sizeof(*param) + key_len;
++ buf = os_zalloc(blen);
++ if (buf == NULL)
++ return -1;
++
++ param = (struct prism2_hostapd_param *) buf;
++ param->cmd = PRISM2_SET_ENCRYPTION;
++ /* TODO: In theory, STA in client mode can use five keys; four default
++ * keys for receiving (with keyidx 0..3) and one individual key for
++ * both transmitting and receiving (keyidx 0) _unicast_ packets. Now,
++ * keyidx 0 is reserved for this unicast use and default keys can only
++ * use keyidx 1..3 (i.e., default key with keyidx 0 is not supported).
++ * This should be fine for more or less all cases, but for completeness
++ * sake, the driver could be enhanced to support the missing key. */
++ if (addr == NULL)
++ os_memset(param->sta_addr, 0xff, ETH_ALEN);
++ else
++ os_memcpy(param->sta_addr, addr, ETH_ALEN);
++ os_strlcpy((char *) param->u.crypt.alg, alg_name,
++ HOSTAP_CRYPT_ALG_NAME_LEN);
++ param->u.crypt.flags = set_tx ? HOSTAP_CRYPT_FLAG_SET_TX_KEY : 0;
++ param->u.crypt.idx = key_idx;
++ if (seq)
++ os_memcpy(param->u.crypt.seq, seq, seq_len);
++ param->u.crypt.key_len = key_len;
++ os_memcpy((u8 *) (param + 1), key, key_len);
++
++ if (wpa_hostapd_ioctl(drv, param, blen, 1)) {
++ wpa_printf(MSG_WARNING, "Failed to set encryption.");
++ show_set_key_error(param);
++ ret = -1;
++ }
++ os_free(buf);
++
++ return ret;
++}
+
+
+ const struct wpa_driver_ops wpa_driver_hostap_ops = {
+@@ -1631,7 +1566,8 @@ const struct wpa_driver_ops wpa_driver_h
+ .sta_clear_stats = hostap_sta_clear_stats,
+ .get_hw_feature_data = hostap_get_hw_feature_data,
+ .set_ap_wps_ie = hostap_set_ap_wps_ie,
+-#else /* HOSTAPD */
++#endif /* HOSTAPD */
++#if !defined(NO_SUPPLICANT)
+ .get_bssid = wpa_driver_hostap_get_bssid,
+ .get_ssid = wpa_driver_hostap_get_ssid,
+ .set_countermeasures = wpa_driver_hostap_set_countermeasures,
+@@ -1643,5 +1579,5 @@ const struct wpa_driver_ops wpa_driver_h
+ .init = wpa_driver_hostap_init,
+ .deinit = wpa_driver_hostap_deinit,
+ .set_operstate = wpa_driver_hostap_set_operstate,
+-#endif /* HOSTAPD */
++#endif
+ };
+++ /dev/null
---- a/src/drivers/driver_nl80211.c
-+++ b/src/drivers/driver_nl80211.c
-@@ -4652,9 +4652,11 @@ static int i802_set_wds_sta(void *priv,
- wpa_printf(MSG_DEBUG, "nl80211: Set WDS STA addr=" MACSTR
- " aid=%d val=%d name=%s", MAC2STR(addr), aid, val, name);
- if (val) {
-- if (nl80211_create_iface(drv, name, NL80211_IFTYPE_AP_VLAN,
-+ if (!if_nametoindex(name)) {
-+ if (nl80211_create_iface(drv, name, NL80211_IFTYPE_AP_VLAN,
- NULL, 1) < 0)
-- return -1;
-+ return -1;
-+ }
- linux_set_iface_flags(drv->ioctl_sock, name, 1);
- return i802_set_sta_vlan(priv, addr, name, 0);
- } else {
---- a/src/ap/ieee802_11.c
-+++ b/src/ap/ieee802_11.c
-@@ -1627,6 +1627,9 @@ static void handle_assoc_cb(struct hosta
- "Could not add STA to kernel driver");
- }
-
-+ if (sta->flags & WLAN_STA_WDS)
-+ hapd->drv.set_wds_sta(hapd, sta->addr, sta->aid, 1);
-+
- if (sta->eapol_sm == NULL) {
- /*
- * This STA does not use RADIUS server for EAP authentication,
+++ /dev/null
---- a/src/ap/ap_config.h
-+++ b/src/ap/ap_config.h
-@@ -148,6 +148,7 @@ struct hostapd_wmm_ac_params {
- struct hostapd_bss_config {
- char iface[IFNAMSIZ + 1];
- char bridge[IFNAMSIZ + 1];
-+ char wds_bridge[IFNAMSIZ + 1];
-
- enum hostapd_logger_level logger_syslog_level, logger_stdout_level;
-
---- a/hostapd/config_file.c
-+++ b/hostapd/config_file.c
-@@ -1193,6 +1193,8 @@ struct hostapd_config * hostapd_config_r
- sizeof(conf->bss[0].iface));
- } else if (os_strcmp(buf, "bridge") == 0) {
- os_strlcpy(bss->bridge, pos, sizeof(bss->bridge));
-+ } else if (os_strcmp(buf, "wds_bridge") == 0) {
-+ os_strlcpy(bss->wds_bridge, pos, sizeof(bss->wds_bridge));
- } else if (os_strcmp(buf, "driver") == 0) {
- int j;
- /* clear to get error below if setting is invalid */
---- a/src/drivers/driver_nl80211.c
-+++ b/src/drivers/driver_nl80211.c
-@@ -4642,7 +4642,8 @@ static int i802_set_sta_vlan(void *priv,
- }
-
-
--static int i802_set_wds_sta(void *priv, const u8 *addr, int aid, int val)
-+static int i802_set_wds_sta(void *priv, const u8 *addr, int aid, int val,
-+ const char *bridge_ifname)
- {
- struct i802_bss *bss = priv;
- struct wpa_driver_nl80211_data *drv = bss->drv;
-@@ -4656,6 +4657,10 @@ static int i802_set_wds_sta(void *priv,
- if (nl80211_create_iface(drv, name, NL80211_IFTYPE_AP_VLAN,
- NULL, 1) < 0)
- return -1;
-+ if (bridge_ifname) {
-+ if (linux_br_add_if(drv->ioctl_sock, bridge_ifname, name) < 0)
-+ return -1;
-+ }
- }
- linux_set_iface_flags(drv->ioctl_sock, name, 1);
- return i802_set_sta_vlan(priv, addr, name, 0);
---- a/src/ap/ap_drv_ops.c
-+++ b/src/ap/ap_drv_ops.c
-@@ -265,9 +265,15 @@ static int hostapd_vlan_if_remove(struct
- static int hostapd_set_wds_sta(struct hostapd_data *hapd, const u8 *addr,
- int aid, int val)
- {
-+ const char *bridge = NULL;
-+
- if (hapd->driver == NULL || hapd->driver->set_wds_sta == NULL)
- return 0;
-- return hapd->driver->set_wds_sta(hapd->drv_priv, addr, aid, val);
-+ if (hapd->conf->wds_bridge[0])
-+ bridge = hapd->conf->wds_bridge;
-+ else if (hapd->conf->bridge[0])
-+ bridge = hapd->conf->bridge;
-+ return hapd->driver->set_wds_sta(hapd->drv_priv, addr, aid, val, bridge);
- }
-
-
---- a/src/drivers/driver.h
-+++ b/src/drivers/driver.h
-@@ -1622,7 +1622,8 @@ struct wpa_driver_ops {
- * @val: 1 = bind to 4-address WDS; 0 = unbind
- * Returns: 0 on success, -1 on failure
- */
-- int (*set_wds_sta)(void *priv, const u8 *addr, int aid, int val);
-+ int (*set_wds_sta)(void *priv, const u8 *addr, int aid, int val,
-+ const char *bridge_ifname);
-
- /**
- * send_action - Transmit an Action frame
+++ /dev/null
---- a/src/ap/hostapd.c
-+++ b/src/ap/hostapd.c
-@@ -716,6 +716,16 @@ int hostapd_setup_interface_complete(str
- }
- }
-
-+ if (iface->current_mode) {
-+ if (hostapd_prepare_rates(hapd, iface->current_mode)) {
-+ wpa_printf(MSG_ERROR, "Failed to prepare rates table.");
-+ hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211,
-+ HOSTAPD_LEVEL_WARNING,
-+ "Failed to prepare rates table.");
-+ return -1;
-+ }
-+ }
-+
- if (hapd->iconf->rts_threshold > -1 &&
- hostapd_set_rts(hapd, hapd->iconf->rts_threshold)) {
- wpa_printf(MSG_ERROR, "Could not set RTS threshold for "
---- a/src/ap/hw_features.c
-+++ b/src/ap/hw_features.c
-@@ -101,8 +101,8 @@ int hostapd_get_hw_features(struct hosta
- }
-
-
--static int hostapd_prepare_rates(struct hostapd_data *hapd,
-- struct hostapd_hw_modes *mode)
-+int hostapd_prepare_rates(struct hostapd_data *hapd,
-+ struct hostapd_hw_modes *mode)
- {
- int i, num_basic_rates = 0;
- int basic_rates_a[] = { 60, 120, 240, -1 };
-@@ -668,14 +668,6 @@ int hostapd_select_hw_mode(struct hostap
- return -1;
- }
-
-- if (hostapd_prepare_rates(iface->bss[0], iface->current_mode)) {
-- wpa_printf(MSG_ERROR, "Failed to prepare rates table.");
-- hostapd_logger(iface->bss[0], NULL, HOSTAPD_MODULE_IEEE80211,
-- HOSTAPD_LEVEL_WARNING,
-- "Failed to prepare rates table.");
-- return -1;
-- }
--
- return 0;
- }
-
---- a/src/ap/hw_features.h
-+++ b/src/ap/hw_features.h
-@@ -25,6 +25,8 @@ const char * hostapd_hw_mode_txt(int mod
- int hostapd_hw_get_freq(struct hostapd_data *hapd, int chan);
- int hostapd_hw_get_channel(struct hostapd_data *hapd, int freq);
- int hostapd_check_ht_capab(struct hostapd_iface *iface);
-+int hostapd_prepare_rates(struct hostapd_data *hapd,
-+ struct hostapd_hw_modes *mode);
- #else /* NEED_AP_MLME */
- static inline void
- hostapd_free_hw_features(struct hostapd_hw_modes *hw_features,
-@@ -56,6 +58,11 @@ static inline int hostapd_check_ht_capab
- {
- return 0;
- }
-+static inline int hostapd_prepare_rates(struct hostapd_data *hapd,
-+ struct hostapd_hw_modes *mode)
-+{
-+ return 0;
-+}
-
- #endif /* NEED_AP_MLME */
-
+++ /dev/null
---- a/hostapd/config_file.c
-+++ b/hostapd/config_file.c
-@@ -1266,6 +1266,8 @@ struct hostapd_config * hostapd_config_r
- }
- } else if (os_strcmp(buf, "wds_sta") == 0) {
- bss->wds_sta = atoi(pos);
-+ } else if (os_strcmp(buf, "ap_isolate") == 0) {
-+ bss->isolate = atoi(pos);
- } else if (os_strcmp(buf, "ap_max_inactivity") == 0) {
- bss->ap_max_inactivity = atoi(pos);
- } else if (os_strcmp(buf, "country_code") == 0) {
---- a/src/ap/ap_config.h
-+++ b/src/ap/ap_config.h
-@@ -199,6 +199,7 @@ struct hostapd_bss_config {
- struct mac_acl_entry *deny_mac;
- int num_deny_mac;
- int wds_sta;
-+ int isolate;
-
- int auth_algs; /* bitfield of allowed IEEE 802.11 authentication
- * algorithms, WPA_AUTH_ALG_{OPEN,SHARED,LEAP} */
---- a/src/drivers/driver.h
-+++ b/src/drivers/driver.h
-@@ -1626,6 +1626,14 @@ struct wpa_driver_ops {
- const char *bridge_ifname);
-
- /**
-+ * set_ap_isolate - Enable/disable AP isolation
-+ * @priv: private driver interface data
-+ * @val: 1 = enabled; 0 = disabled
-+ * Returns: 0 on success, -1 on failure
-+ */
-+ int (*set_ap_isolate)(void *priv, int val);
-+
-+ /**
- * send_action - Transmit an Action frame
- * @priv: Private driver interface data
- * @freq: Frequency (in MHz) of the channel
---- a/src/drivers/driver_nl80211.c
-+++ b/src/drivers/driver_nl80211.c
-@@ -4339,6 +4339,29 @@ static int i802_set_rate_sets(void *priv
- return -ENOBUFS;
- }
-
-+static int i802_set_ap_isolate(void *priv, int val)
-+{
-+ struct i802_bss *bss = priv;
-+ struct wpa_driver_nl80211_data *drv = bss->drv;
-+ struct nl_msg *msg;
-+ int i;
-+
-+ msg = nlmsg_alloc();
-+ if (!msg)
-+ return -ENOMEM;
-+
-+ genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0, 0,
-+ NL80211_CMD_SET_BSS, 0);
-+
-+ NLA_PUT_U8(msg, NL80211_ATTR_AP_ISOLATE, !!val);
-+
-+ NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(bss->ifname));
-+
-+ return send_and_recv_msgs(drv, msg, NULL, NULL);
-+ nla_put_failure:
-+ return -ENOBUFS;
-+}
-+
- #endif /* HOSTAPD */
-
-
-@@ -5448,6 +5471,7 @@ const struct wpa_driver_ops wpa_driver_n
- .set_tx_queue_params = i802_set_tx_queue_params,
- .set_sta_vlan = i802_set_sta_vlan,
- .set_wds_sta = i802_set_wds_sta,
-+ .set_ap_isolate = i802_set_ap_isolate,
- #endif /* HOSTAPD */
- .set_freq = i802_set_freq,
- .send_action = wpa_driver_nl80211_send_action,
---- a/src/ap/ap_drv_ops.c
-+++ b/src/ap/ap_drv_ops.c
-@@ -180,6 +180,14 @@ static int hostapd_set_radius_acl_expire
- }
-
-
-+static int hostapd_set_ap_isolate(struct hostapd_data *hapd, int value)
-+{
-+ if (hapd->driver == NULL || hapd->driver->set_ap_isolate == NULL)
-+ return 0;
-+ hapd->driver->set_ap_isolate(hapd->drv_priv, value);
-+}
-+
-+
- static int hostapd_set_bss_params(struct hostapd_data *hapd,
- int use_protection)
- {
-@@ -229,6 +237,12 @@ static int hostapd_set_bss_params(struct
- "driver");
- ret = -1;
- }
-+ if (hostapd_set_ap_isolate(hapd, hapd->conf->isolate) &&
-+ !hapd->conf->isolate) {
-+ wpa_printf(MSG_ERROR, "Could not enable AP isolation in "
-+ "kernel driver");
-+ ret = -1;
-+ }
-
- return ret;
- }
+++ /dev/null
---- a/src/drivers/driver_nl80211.c
-+++ b/src/drivers/driver_nl80211.c
-@@ -1135,7 +1135,6 @@ nla_put_failure:
- }
-
-
--#ifndef HOSTAPD
- struct wiphy_info_data {
- int max_scan_ssids;
- int ap_supported;
-@@ -1247,7 +1246,6 @@ static int wpa_driver_nl80211_capa(struc
-
- return 0;
- }
--#endif /* HOSTAPD */
-
-
- static int wpa_driver_nl80211_init_nl(struct wpa_driver_nl80211_data *drv,
-@@ -1411,6 +1409,7 @@ static void * wpa_driver_nl80211_init(vo
- drv->monitor_ifidx = -1;
- drv->monitor_sock = -1;
- drv->ioctl_sock = -1;
-+ drv->nlmode = NL80211_IFTYPE_STATION;
-
- if (wpa_driver_nl80211_init_nl(drv, ctx)) {
- os_free(drv);
-@@ -1530,32 +1529,32 @@ wpa_driver_nl80211_finish_drv_init(struc
- drv->ifindex = if_nametoindex(bss->ifname);
- drv->first_bss.ifindex = drv->ifindex;
-
--#ifndef HOSTAPD
-- if (wpa_driver_nl80211_set_mode(bss, IEEE80211_MODE_INFRA) < 0) {
-- wpa_printf(MSG_DEBUG, "nl80211: Could not configure driver to "
-- "use managed mode");
-- }
-+ if (drv->nlmode == NL80211_IFTYPE_STATION) {
-+ if (wpa_driver_nl80211_set_mode(bss, IEEE80211_MODE_INFRA) < 0) {
-+ wpa_printf(MSG_DEBUG, "nl80211: Could not configure driver to "
-+ "use managed mode");
-+ }
-
-- if (linux_set_iface_flags(drv->ioctl_sock, bss->ifname, 1)) {
-- if (rfkill_is_blocked(drv->rfkill)) {
-- wpa_printf(MSG_DEBUG, "nl80211: Could not yet enable "
-- "interface '%s' due to rfkill",
-- bss->ifname);
-- drv->if_disabled = 1;
-- send_rfkill_event = 1;
-- } else {
-- wpa_printf(MSG_ERROR, "nl80211: Could not set "
-- "interface '%s' UP", bss->ifname);
-- return -1;
-+ if (linux_set_iface_flags(drv->ioctl_sock, bss->ifname, 1)) {
-+ if (rfkill_is_blocked(drv->rfkill)) {
-+ wpa_printf(MSG_DEBUG, "nl80211: Could not yet enable "
-+ "interface '%s' due to rfkill",
-+ bss->ifname);
-+ drv->if_disabled = 1;
-+ send_rfkill_event = 1;
-+ } else {
-+ wpa_printf(MSG_ERROR, "nl80211: Could not set "
-+ "interface '%s' UP", bss->ifname);
-+ return -1;
-+ }
- }
-- }
-
-- if (wpa_driver_nl80211_capa(drv))
-- return -1;
-+ if (wpa_driver_nl80211_capa(drv))
-+ return -1;
-
-- netlink_send_oper_ifla(drv->netlink, drv->ifindex,
-- 1, IF_OPER_DORMANT);
--#endif /* HOSTAPD */
-+ netlink_send_oper_ifla(drv->netlink, drv->ifindex,
-+ 1, IF_OPER_DORMANT);
-+ }
-
- if (nl80211_register_action_frames(drv) < 0) {
- wpa_printf(MSG_DEBUG, "nl80211: Failed to register Action "
-@@ -2219,13 +2218,9 @@ static int wpa_driver_nl80211_set_key(co
- */
- if (ret || !set_tx || alg == WPA_ALG_NONE)
- return ret;
--#ifdef HOSTAPD
-- if (addr)
-- return ret;
--#else /* HOSTAPD */
-+
- if (drv->nlmode == NL80211_IFTYPE_AP && addr)
- return ret;
--#endif /* HOSTAPD */
-
- msg = nlmsg_alloc();
- if (!msg)
-@@ -3066,7 +3061,8 @@ static void nl80211_remove_iface(struct
-
- #ifdef HOSTAPD
- /* stop listening for EAPOL on this interface */
-- del_ifidx(drv, ifidx);
-+ if (drv->nlmode == NL80211_IFTYPE_AP)
-+ del_ifidx(drv, ifidx);
- #endif /* HOSTAPD */
-
- msg = nlmsg_alloc();
-@@ -3139,7 +3135,8 @@ static int nl80211_create_iface_once(str
-
- #ifdef HOSTAPD
- /* start listening for EAPOL on this interface */
-- add_ifidx(drv, ifidx);
-+ if (drv->nlmode == NL80211_IFTYPE_AP)
-+ add_ifidx(drv, ifidx);
- #endif /* HOSTAPD */
-
- if (addr && iftype != NL80211_IFTYPE_MONITOR &&
-@@ -4842,6 +4839,7 @@ static void *i802_init(struct hostapd_da
- return NULL;
-
- drv = bss->drv;
-+ drv->nlmode = NL80211_IFTYPE_AP;
- if (linux_br_get(brname, params->ifname) == 0) {
- wpa_printf(MSG_DEBUG, "nl80211: Interface %s is in bridge %s",
- params->ifname, brname);
+++ /dev/null
---- a/wpa_supplicant/wpa_supplicant.c
-+++ b/wpa_supplicant/wpa_supplicant.c
-@@ -545,10 +545,16 @@ void wpa_supplicant_set_state(struct wpa
- wpa_s->reassociated_connection = 1;
- wpa_drv_set_operstate(wpa_s, 1);
- wpa_s->after_wps = 0;
-+#ifndef IEEE8021X_EAPOL
-+ wpa_drv_set_supp_port(wpa_s, 1);
-+#endif
- } else if (state == WPA_DISCONNECTED || state == WPA_ASSOCIATING ||
- state == WPA_ASSOCIATED) {
- wpa_s->new_connection = 1;
- wpa_drv_set_operstate(wpa_s, 0);
-+#ifndef IEEE8021X_EAPOL
-+ wpa_drv_set_supp_port(wpa_s, 0);
-+#endif
- }
- wpa_s->wpa_state = state;
-
+++ /dev/null
---- a/src/drivers/driver_nl80211.c
-+++ b/src/drivers/driver_nl80211.c
-@@ -75,7 +75,9 @@ struct wpa_driver_nl80211_data {
- int ifindex;
- int if_removed;
- int if_disabled;
-+#ifdef CONFIG_RFKILL
- struct rfkill_data *rfkill;
-+#endif
- struct wpa_driver_capa capa;
- int has_capability;
-
-@@ -1361,7 +1363,7 @@ err1:
- return -1;
- }
-
--
-+#ifdef CONFIG_RFKILL
- static void wpa_driver_nl80211_rfkill_blocked(void *ctx)
- {
- wpa_printf(MSG_DEBUG, "nl80211: RFKILL blocked");
-@@ -1383,6 +1385,7 @@ static void wpa_driver_nl80211_rfkill_un
- }
- /* rtnetlink ifup handler will report interface as enabled */
- }
-+#endif /* CONFIG_RFKILL */
-
-
- /**
-@@ -1396,7 +1399,9 @@ static void * wpa_driver_nl80211_init(vo
- {
- struct wpa_driver_nl80211_data *drv;
- struct netlink_config *cfg;
-+#ifdef CONFIG_RFKILL
- struct rfkill_config *rcfg;
-+#endif
- struct i802_bss *bss;
-
- drv = os_zalloc(sizeof(*drv));
-@@ -1434,6 +1439,7 @@ static void * wpa_driver_nl80211_init(vo
- goto failed;
- }
-
-+#ifdef CONFIG_RFKILL
- rcfg = os_zalloc(sizeof(*rcfg));
- if (rcfg == NULL)
- goto failed;
-@@ -1446,6 +1452,7 @@ static void * wpa_driver_nl80211_init(vo
- wpa_printf(MSG_DEBUG, "nl80211: RFKILL status not available");
- os_free(rcfg);
- }
-+#endif /* CONFIG_RFKILL */
-
- if (wpa_driver_nl80211_finish_drv_init(drv))
- goto failed;
-@@ -1453,7 +1460,9 @@ static void * wpa_driver_nl80211_init(vo
- return bss;
-
- failed:
-+#ifdef CONFIG_RFKILL
- rfkill_deinit(drv->rfkill);
-+#endif
- netlink_deinit(drv->netlink);
- if (drv->ioctl_sock >= 0)
- close(drv->ioctl_sock);
-@@ -1514,10 +1523,12 @@ static int nl80211_register_action_frame
- }
-
-
-+#ifdef CONFIG_RFKILL
- static void wpa_driver_nl80211_send_rfkill(void *eloop_ctx, void *timeout_ctx)
- {
- wpa_supplicant_event(timeout_ctx, EVENT_INTERFACE_DISABLED, NULL);
- }
-+#endif /* CONFIG_RFKILL */
-
-
- static int
-@@ -1536,13 +1547,16 @@ wpa_driver_nl80211_finish_drv_init(struc
- }
-
- if (linux_set_iface_flags(drv->ioctl_sock, bss->ifname, 1)) {
-+#ifdef CONFIG_RFKILL
- if (rfkill_is_blocked(drv->rfkill)) {
- wpa_printf(MSG_DEBUG, "nl80211: Could not yet enable "
- "interface '%s' due to rfkill",
- bss->ifname);
- drv->if_disabled = 1;
- send_rfkill_event = 1;
-- } else {
-+ } else
-+#endif
-+ {
- wpa_printf(MSG_ERROR, "nl80211: Could not set "
- "interface '%s' UP", bss->ifname);
- return -1;
-@@ -1567,8 +1581,10 @@ wpa_driver_nl80211_finish_drv_init(struc
- }
-
- if (send_rfkill_event) {
-+#ifdef CONFIG_RFKILL
- eloop_register_timeout(0, 0, wpa_driver_nl80211_send_rfkill,
- drv, drv->ctx);
-+#endif
- }
-
- return 0;
-@@ -1647,7 +1663,9 @@ static void wpa_driver_nl80211_deinit(vo
-
- netlink_send_oper_ifla(drv->netlink, drv->ifindex, 0, IF_OPER_UP);
- netlink_deinit(drv->netlink);
-+#ifdef CONFIG_RFKILL
- rfkill_deinit(drv->rfkill);
-+#endif
-
- eloop_cancel_timeout(wpa_driver_nl80211_scan_timeout, drv, drv->ctx);
-
---- a/src/drivers/driver_wext.c
-+++ b/src/drivers/driver_wext.c
-@@ -700,7 +700,7 @@ static void wpa_driver_wext_event_rtm_de
- }
- }
-
--
-+#ifdef CONFIG_RFKILL
- static void wpa_driver_wext_rfkill_blocked(void *ctx)
- {
- wpa_printf(MSG_DEBUG, "WEXT: RFKILL blocked");
-@@ -722,7 +722,7 @@ static void wpa_driver_wext_rfkill_unblo
- }
- /* rtnetlink ifup handler will report interface as enabled */
- }
--
-+#endif /* CONFIG_RFKILL */
-
- /**
- * wpa_driver_wext_init - Initialize WE driver interface
-@@ -735,7 +735,9 @@ void * wpa_driver_wext_init(void *ctx, c
- {
- struct wpa_driver_wext_data *drv;
- struct netlink_config *cfg;
-+#ifdef CONFIG_RFKILL
- struct rfkill_config *rcfg;
-+#endif
- char path[128];
- struct stat buf;
-
-@@ -769,6 +771,7 @@ void * wpa_driver_wext_init(void *ctx, c
- goto err2;
- }
-
-+#ifdef CONFIG_RFKILL
- rcfg = os_zalloc(sizeof(*rcfg));
- if (rcfg == NULL)
- goto err3;
-@@ -781,6 +784,7 @@ void * wpa_driver_wext_init(void *ctx, c
- wpa_printf(MSG_DEBUG, "WEXT: RFKILL status not available");
- os_free(rcfg);
- }
-+#endif /* CONFIG_RFKILL */
-
- drv->mlme_sock = -1;
-
-@@ -792,7 +796,9 @@ void * wpa_driver_wext_init(void *ctx, c
- return drv;
-
- err3:
-+#ifdef CONFIG_RFKILL
- rfkill_deinit(drv->rfkill);
-+#endif
- netlink_deinit(drv->netlink);
- err2:
- close(drv->ioctl_sock);
-@@ -802,10 +808,12 @@ err1:
- }
-
-
-+#ifdef CONFIG_RFKILL
- static void wpa_driver_wext_send_rfkill(void *eloop_ctx, void *timeout_ctx)
- {
- wpa_supplicant_event(timeout_ctx, EVENT_INTERFACE_DISABLED, NULL);
- }
-+#endif /* CONFIG_RFKILL */
-
-
- static int wpa_driver_wext_finish_drv_init(struct wpa_driver_wext_data *drv)
-@@ -813,13 +821,16 @@ static int wpa_driver_wext_finish_drv_in
- int send_rfkill_event = 0;
-
- if (linux_set_iface_flags(drv->ioctl_sock, drv->ifname, 1) < 0) {
-+#ifdef CONFIG_RFKILL
- if (rfkill_is_blocked(drv->rfkill)) {
- wpa_printf(MSG_DEBUG, "WEXT: Could not yet enable "
- "interface '%s' due to rfkill",
- drv->ifname);
- drv->if_disabled = 1;
- send_rfkill_event = 1;
-- } else {
-+ } else
-+#endif
-+ {
- wpa_printf(MSG_ERROR, "WEXT: Could not set "
- "interface '%s' UP", drv->ifname);
- return -1;
-@@ -867,8 +878,10 @@ static int wpa_driver_wext_finish_drv_in
- 1, IF_OPER_DORMANT);
-
- if (send_rfkill_event) {
-+#ifdef CONFIG_RFKILL
- eloop_register_timeout(0, 0, wpa_driver_wext_send_rfkill,
- drv, drv->ctx);
-+#endif
- }
-
- return 0;
-@@ -898,7 +911,9 @@ void wpa_driver_wext_deinit(void *priv)
-
- netlink_send_oper_ifla(drv->netlink, drv->ifindex, 0, IF_OPER_UP);
- netlink_deinit(drv->netlink);
-+#ifdef CONFIG_RFKILL
- rfkill_deinit(drv->rfkill);
-+#endif
-
- if (drv->mlme_sock >= 0)
- eloop_unregister_read_sock(drv->mlme_sock);
---- a/src/drivers/drivers.mak
-+++ b/src/drivers/drivers.mak
-@@ -31,7 +31,6 @@ NEED_SME=y
- NEED_AP_MLME=y
- NEED_NETLINK=y
- NEED_LINUX_IOCTL=y
--NEED_RFKILL=y
- DRV_LIBS += -lnl
-
- ifdef CONFIG_LIBNL20
-@@ -78,7 +77,6 @@ DRV_WPA_CFLAGS += -DCONFIG_DRIVER_WEXT
- CONFIG_WIRELESS_EXTENSION=y
- NEED_NETLINK=y
- NEED_LINUX_IOCTL=y
--NEED_RFKILL=y
- endif
-
- ifdef CONFIG_DRIVER_HERMES
-@@ -166,6 +164,7 @@ endif
-
- ifdef NEED_RFKILL
- DRV_OBJS += ../src/drivers/rfkill.o
-+DRV_WPA_CFLAGS += -DCONFIG_RFKILL
- endif
-
-
---- a/src/drivers/driver_wext.h
-+++ b/src/drivers/driver_wext.h
-@@ -27,7 +27,9 @@ struct wpa_driver_wext_data {
- int ifindex2;
- int if_removed;
- int if_disabled;
-+#ifdef CONFIG_RFKILL
- struct rfkill_data *rfkill;
-+#endif
- u8 *assoc_req_ies;
- size_t assoc_req_ies_len;
- u8 *assoc_resp_ies;
+++ /dev/null
-From: Helmut Schaa <helmut.schaa@googlemail.com>
-Date: Sat, 28 Aug 2010 09:25:44 +0000 (+0300)
-Subject: hostapd: enable STBC only for STBC capable STAs
-X-Git-Url: http://hostap.epitest.fi/gitweb/gitweb.cgi?p=hostap.git;a=commitdiff_plain;h=36af1c7d31bdc5ba4dacacbf32d3c7585665ae2b
-
-hostapd: enable STBC only for STBC capable STAs
-
-hostapd simply used its own STBC configuration in the STA's HT caps. This
-resulted in TX STBC being used for STAs not supporting RX STBC, which in
-turn resulted in the STA not receiving anything.
-
-Fix this by handling the STBC flags in the same way mac80211 does. Mask
-out RX STBC if we don't support TX STBC and vice versa.
-
-Tested only with the nl80211 driver and a STBC incapable STA.
-
-Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
----
-
---- a/src/ap/ieee802_11_ht.c
-+++ b/src/ap/ieee802_11_ht.c
-@@ -256,7 +256,15 @@ void hostapd_get_ht_capab(struct hostapd
- cap &= hapd->iconf->ht_capab;
- cap |= (hapd->iconf->ht_capab & HT_CAP_INFO_SMPS_DISABLED);
-
-- /* FIXME: Rx STBC needs to be handled specially */
-- cap |= (hapd->iconf->ht_capab & HT_CAP_INFO_RX_STBC_MASK);
-+ /*
-+ * STBC needs to be handled specially
-+ * if we don't support RX STBC, mask out TX STBC in the STA's HT caps
-+ * if we don't support TX STBC, mask out RX STBC in the STA's HT caps
-+ */
-+ if (!(hapd->iconf->ht_capab & HT_CAP_INFO_RX_STBC_MASK))
-+ cap &= ~HT_CAP_INFO_TX_STBC;
-+ if (!(hapd->iconf->ht_capab & HT_CAP_INFO_TX_STBC))
-+ cap &= ~HT_CAP_INFO_RX_STBC_MASK;
-+
- neg_ht_cap->ht_capabilities_info = host_to_le16(cap);
- }
+++ /dev/null
---- a/src/drivers/driver_nl80211.c
-+++ b/src/drivers/driver_nl80211.c
-@@ -410,6 +410,10 @@ static void wpa_driver_nl80211_event_rtm
- return;
- }
-
-+ if (ifi->ifi_family == AF_BRIDGE &&
-+ drv->nlmode != NL80211_IFTYPE_AP)
-+ return;
-+
- wpa_printf(MSG_DEBUG, "RTM_NEWLINK: operstate=%d ifi_flags=0x%x "
- "(%s%s%s%s)",
- drv->operstate, ifi->ifi_flags,
-@@ -481,6 +485,10 @@ static void wpa_driver_nl80211_event_rtm
- attrlen = len;
- attr = (struct rtattr *) buf;
-
-+ if (ifi->ifi_family == AF_BRIDGE &&
-+ drv->nlmode != NL80211_IFTYPE_AP)
-+ return;
-+
- rta_len = RTA_ALIGN(sizeof(struct rtattr));
- while (RTA_OK(attr, attrlen)) {
- if (attr->rta_type == IFLA_IFNAME) {
-@@ -1347,6 +1355,11 @@ static int wpa_driver_nl80211_init_nl(st
- eloop_register_read_sock(nl_socket_get_fd(drv->nl_handle_event),
- wpa_driver_nl80211_event_receive, drv, ctx);
-
-+#ifdef HOSTAPD
-+ drv->num_if_indices = sizeof(drv->default_if_indices) / sizeof(int);
-+ drv->if_indices = drv->default_if_indices;
-+#endif
-+
- return 0;
-
- err4:
-@@ -4867,8 +4880,6 @@ static void *i802_init(struct hostapd_da
- br_ifindex = 0;
- }
-
-- drv->num_if_indices = sizeof(drv->default_if_indices) / sizeof(int);
-- drv->if_indices = drv->default_if_indices;
- for (i = 0; i < params->num_bridge; i++) {
- if (params->bridge[i]) {
- ifindex = if_nametoindex(params->bridge[i]);
+++ /dev/null
---- a/src/ap/hostapd.c
-+++ b/src/ap/hostapd.c
-@@ -42,37 +42,8 @@ static int hostapd_setup_encryption(char
-
- extern int wpa_debug_level;
-
--
--int hostapd_reload_config(struct hostapd_iface *iface)
-+static int hostapd_reload_bss(struct hostapd_data *hapd)
- {
-- struct hostapd_data *hapd = iface->bss[0];
-- struct hostapd_config *newconf, *oldconf;
-- size_t j;
--
-- if (iface->config_read_cb == NULL)
-- return -1;
-- newconf = iface->config_read_cb(iface->config_fname);
-- if (newconf == NULL)
-- return -1;
--
-- /*
-- * Deauthenticate all stations since the new configuration may not
-- * allow them to use the BSS anymore.
-- */
-- for (j = 0; j < iface->num_bss; j++)
-- hostapd_flush_old_stations(iface->bss[j]);
--
--#ifndef CONFIG_NO_RADIUS
-- /* TODO: update dynamic data based on changed configuration
-- * items (e.g., open/close sockets, etc.) */
-- radius_client_flush(hapd->radius, 0);
--#endif /* CONFIG_NO_RADIUS */
--
-- oldconf = hapd->iconf;
-- hapd->iconf = newconf;
-- hapd->conf = &newconf->bss[0];
-- iface->conf = newconf;
--
- if (hostapd_setup_wpa_psk(hapd->conf)) {
- wpa_printf(MSG_ERROR, "Failed to re-configure WPA PSK "
- "after reloading configuration");
-@@ -110,10 +81,46 @@ int hostapd_reload_config(struct hostapd
- wpa_printf(MSG_ERROR, "Could not set SSID for kernel driver");
- /* try to continue */
- }
-+ wpa_printf(MSG_DEBUG, "Reconfigured interface %s", hapd->conf->iface);
-+}
-+
-+int hostapd_reload_config(struct hostapd_iface *iface)
-+{
-+ struct hostapd_data *hapd = iface->bss[0];
-+ struct hostapd_config *newconf, *oldconf;
-+ size_t j;
-+
-+ if (iface->config_read_cb == NULL)
-+ return -1;
-+ newconf = iface->config_read_cb(iface->config_fname);
-+ if (newconf == NULL)
-+ return -1;
-+
-+ /*
-+ * Deauthenticate all stations since the new configuration may not
-+ * allow them to use the BSS anymore.
-+ */
-+ for (j = 0; j < iface->num_bss; j++)
-+ hostapd_flush_old_stations(iface->bss[j]);
-+
-+#ifndef CONFIG_NO_RADIUS
-+ /* TODO: update dynamic data based on changed configuration
-+ * items (e.g., open/close sockets, etc.) */
-+ radius_client_flush(hapd->radius, 0);
-+#endif /* CONFIG_NO_RADIUS */
-+
-+ oldconf = hapd->iconf;
-+ iface->conf = newconf;
-+
-+ for (j = 0; j < iface->num_bss; j++) {
-+ hapd = iface->bss[j];
-+ hapd->iconf = newconf;
-+ hapd->conf = &newconf->bss[j];
-+ hostapd_reload_bss(hapd);
-+ }
-
- hostapd_config_free(oldconf);
-
-- wpa_printf(MSG_DEBUG, "Reconfigured interface %s", hapd->conf->iface);
-
- return 0;
- }
+++ /dev/null
---- a/src/ap/hostapd.c
-+++ b/src/ap/hostapd.c
-@@ -112,6 +112,10 @@ int hostapd_reload_config(struct hostapd
- oldconf = hapd->iconf;
- iface->conf = newconf;
-
-+ iface->freq = hostapd_hw_get_freq(hapd, hapd->iconf->channel);
-+ if (iface->current_mode)
-+ hostapd_prepare_rates(hapd, iface->current_mode);
-+
- for (j = 0; j < iface->num_bss; j++) {
- hapd = iface->bss[j];
- hapd->iconf = newconf;
+++ /dev/null
---- a/src/drivers/driver_nl80211.c
-+++ b/src/drivers/driver_nl80211.c
-@@ -1604,23 +1604,41 @@ wpa_driver_nl80211_finish_drv_init(struc
- }
-
-
--static int wpa_driver_nl80211_del_beacon(struct wpa_driver_nl80211_data *drv)
-+static int wpa_driver_nl80211_del_bss_beacon(struct i802_bss *bss)
- {
-+ struct wpa_driver_nl80211_data *drv = bss->drv;
- struct nl_msg *msg;
-
-+ bss->beacon_set = 0;
-+
- msg = nlmsg_alloc();
- if (!msg)
- return -ENOMEM;
-
- genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
- 0, NL80211_CMD_DEL_BEACON, 0);
-- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, drv->ifindex);
-+ NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, bss->ifindex);
-
- return send_and_recv_msgs(drv, msg, NULL, NULL);
- nla_put_failure:
-+ nlmsg_free(msg);
- return -ENOBUFS;
- }
-
-+static int wpa_driver_nl80211_del_beacon(struct wpa_driver_nl80211_data *drv)
-+{
-+ struct i802_bss *bss;
-+
-+ for (bss = &drv->first_bss; bss; bss = bss->next)
-+ wpa_driver_nl80211_del_bss_beacon(bss);
-+}
-+
-+static int wpa_driver_nl80211_stop_ap(void *priv)
-+{
-+ struct i802_bss *bss = priv;
-+
-+ wpa_driver_nl80211_del_beacon(bss->drv);
-+}
-
- /**
- * wpa_driver_nl80211_deinit - Deinitialize nl80211 driver interface
-@@ -5512,4 +5530,5 @@ const struct wpa_driver_ops wpa_driver_n
- .send_ft_action = nl80211_send_ft_action,
- .signal_monitor = nl80211_signal_monitor,
- .send_frame = nl80211_send_frame,
-+ .stop_ap = wpa_driver_nl80211_stop_ap,
- };
---- a/src/drivers/driver.h
-+++ b/src/drivers/driver.h
-@@ -1774,6 +1774,8 @@ struct wpa_driver_ops {
- */
- int (*send_frame)(void *priv, const u8 *data, size_t data_len,
- int encrypt);
-+
-+ int (*stop_ap)(void *priv);
- };
-
-
+++ /dev/null
---- a/hostapd/ctrl_iface.c
-+++ b/hostapd/ctrl_iface.c
-@@ -35,6 +35,7 @@
- #include "ap/wps_hostapd.h"
- #include "ap/ctrl_iface_ap.h"
- #include "ctrl_iface.h"
-+#include "config_file.h"
-
-
- struct wpa_ctrl_dst {
-@@ -45,6 +46,7 @@ struct wpa_ctrl_dst {
- int errors;
- };
-
-+static char *reload_opts = NULL;
-
- static void hostapd_ctrl_iface_send(struct hostapd_data *hapd, int level,
- const char *buf, size_t len);
-@@ -315,6 +317,66 @@ static int hostapd_ctrl_iface_wps_oob(st
- #endif /* CONFIG_WPS_OOB */
- #endif /* CONFIG_WPS */
-
-+static int hostapd_ctrl_iface_set_down(struct hostapd_data *hapd)
-+{
-+ if (hapd->driver->stop_ap)
-+ hapd->driver->stop_ap(hapd->drv_priv);
-+ return 0;
-+}
-+
-+static char *get_option(char *opt, char *str)
-+{
-+ int len = strlen(str);
-+
-+ if (!strncmp(opt, str, len))
-+ return opt + len;
-+ else
-+ return NULL;
-+}
-+
-+static struct hostapd_config *hostapd_ctrl_iface_config_read(const char *fname)
-+{
-+ struct hostapd_config *conf;
-+ char *opt, *val;
-+
-+ conf = hostapd_config_read(fname);
-+ if (!conf)
-+ return NULL;
-+
-+ for (opt = strtok(reload_opts, " ");
-+ opt;
-+ opt = strtok(NULL, " ")) {
-+
-+ if ((val = get_option(opt, "channel=")))
-+ conf->channel = atoi(val);
-+ else if ((val = get_option(opt, "ht_capab=")))
-+ conf->ht_capab = atoi(val);
-+ else if ((val = get_option(opt, "ht_capab_mask=")))
-+ conf->ht_capab &= atoi(val);
-+ else if ((val = get_option(opt, "sec_chan=")))
-+ conf->secondary_channel = atoi(val);
-+ else if ((val = get_option(opt, "hwmode=")))
-+ conf->hw_mode = atoi(val);
-+ else if ((val = get_option(opt, "ieee80211n=")))
-+ conf->ieee80211n = atoi(val);
-+ else
-+ break;
-+ }
-+
-+ return conf;
-+}
-+
-+static int hostapd_ctrl_iface_reload(struct hostapd_data *hapd, char *txt)
-+{
-+ struct hostapd_iface *iface = hapd->iface;
-+
-+ iface->config_read_cb = hostapd_ctrl_iface_config_read;
-+ reload_opts = txt;
-+
-+ hostapd_reload_config(iface);
-+
-+ iface->config_read_cb = hostapd_config_read;
-+}
-
- static void hostapd_ctrl_iface_receive(int sock, void *eloop_ctx,
- void *sock_ctx)
-@@ -379,6 +441,10 @@ static void hostapd_ctrl_iface_receive(i
- reply_len += res;
- }
- #endif /* CONFIG_NO_RADIUS */
-+ } else if (os_strcmp(buf, "DOWN") == 0) {
-+ hostapd_ctrl_iface_set_down(hapd);
-+ } else if (os_strncmp(buf, "RELOAD ", 7) == 0) {
-+ hostapd_ctrl_iface_reload(hapd, buf + 7);
- } else if (os_strcmp(buf, "STA-FIRST") == 0) {
- reply_len = hostapd_ctrl_iface_sta_first(hapd, reply,
- reply_size);
+++ /dev/null
---- a/wpa_supplicant/wpa_supplicant_i.h
-+++ b/wpa_supplicant/wpa_supplicant_i.h
-@@ -98,6 +98,8 @@ struct wpa_interface {
- * receiving of EAPOL frames from an additional interface.
- */
- const char *bridge_ifname;
-+
-+ const char *hostapd_ctrl;
- };
-
- /**
-@@ -316,6 +318,8 @@ struct wpa_supplicant {
- #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
- char bridge_ifname[16];
-
-+ struct wpa_ctrl *hostapd;
-+
- char *confname;
- struct wpa_config *conf;
- int countermeasures;
---- a/wpa_supplicant/Makefile
-+++ b/wpa_supplicant/Makefile
-@@ -51,6 +51,11 @@ OBJS_p += ../src/utils/wpa_debug.o
- OBJS_p += ../src/utils/wpabuf.o
- OBJS_c = wpa_cli.o ../src/common/wpa_ctrl.o
-
-+ifdef MULTICALL
-+OBJS += ../src/common/wpa_ctrl.o
-+CFLAGS += -DMULTICALL
-+endif
-+
- -include .config
- -include $(if $(MULTICALL),../hostapd/.config)
-
---- a/wpa_supplicant/wpa_supplicant.c
-+++ b/wpa_supplicant/wpa_supplicant.c
-@@ -120,6 +120,55 @@ extern int wpa_debug_show_keys;
- extern int wpa_debug_timestamp;
- extern struct wpa_driver_ops *wpa_drivers[];
-
-+#ifdef MULTICALL
-+static int hostapd_stop(struct wpa_supplicant *wpa_s)
-+{
-+ const char *cmd = "DOWN";
-+ char buf[256];
-+ int len = sizeof(buf);
-+
-+ if (wpa_ctrl_request(wpa_s->hostapd, cmd, os_strlen(cmd), buf, &len, NULL) < 0) {
-+ wpa_printf(MSG_ERROR, "\nFailed to stop hostapd AP interfaces\n");
-+ return -1;
-+ }
-+ return 0;
-+}
-+
-+static int hostapd_reload(struct wpa_supplicant *wpa_s, struct wpa_bss *bss)
-+{
-+ char *cmd = NULL;
-+ char buf[256];
-+ int len = sizeof(buf);
-+ int channel, hw_mode;
-+ int ret;
-+
-+ if (!bss)
-+ return;
-+
-+ if (bss->freq < 4000) {
-+ hw_mode = HOSTAPD_MODE_IEEE80211G;
-+ channel = (bss->freq - 2407) / 5;
-+ } else {
-+ hw_mode = HOSTAPD_MODE_IEEE80211A;
-+ channel = (bss->freq - 5000) / 5;
-+ }
-+
-+ if (asprintf(&cmd, "RELOAD channel=%d sec_chan=0 hw_mode=%d ieee80211n=%d",
-+ channel, hw_mode, !!bss->ht_capab) < 0) {
-+ return -1;
-+ }
-+
-+ ret = wpa_ctrl_request(wpa_s->hostapd, cmd, os_strlen(cmd), buf, &len, NULL);
-+ free(cmd);
-+
-+ if (ret < 0) {
-+ wpa_printf(MSG_ERROR, "\nFailed to reload hostapd AP interfaces\n");
-+ return -1;
-+ }
-+ return 0;
-+}
-+#endif
-+
- /* Configure default/group WEP keys for static WEP */
- int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
- {
-@@ -548,8 +597,16 @@ void wpa_supplicant_set_state(struct wpa
- #ifndef IEEE8021X_EAPOL
- wpa_drv_set_supp_port(wpa_s, 1);
- #endif
-+#ifdef MULTICALL
-+ if (wpa_s->hostapd)
-+ hostapd_reload(wpa_s, wpa_s->current_bss);
-+#endif
- } else if (state == WPA_DISCONNECTED || state == WPA_ASSOCIATING ||
- state == WPA_ASSOCIATED) {
-+#ifdef MULTICALL
-+ if (wpa_s->hostapd)
-+ hostapd_stop(wpa_s);
-+#endif
- wpa_s->new_connection = 1;
- wpa_drv_set_operstate(wpa_s, 0);
- #ifndef IEEE8021X_EAPOL
-@@ -1957,6 +2014,21 @@ static int wpa_supplicant_init_iface(str
- os_strlcpy(wpa_s->bridge_ifname, iface->bridge_ifname,
- sizeof(wpa_s->bridge_ifname));
- }
-+#ifdef MULTICALL
-+ if (iface->hostapd_ctrl) {
-+ char *cmd = "DOWN";
-+ char buf[256];
-+ int len = sizeof(buf);
-+
-+ wpa_s->hostapd = wpa_ctrl_open(iface->hostapd_ctrl);
-+ if (!wpa_s->hostapd) {
-+ wpa_printf(MSG_ERROR, "\nFailed to connect to hostapd\n");
-+ return -1;
-+ }
-+ if (hostapd_stop(wpa_s) < 0)
-+ return -1;
-+ }
-+#endif
-
- /* RSNA Supplicant Key Management - INITIALIZE */
- eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
---- a/wpa_supplicant/bss.c
-+++ b/wpa_supplicant/bss.c
-@@ -17,6 +17,7 @@
- #include "utils/common.h"
- #include "utils/eloop.h"
- #include "common/ieee802_11_defs.h"
-+#include "common/ieee802_11_common.h"
- #include "drivers/driver.h"
- #include "wpa_supplicant_i.h"
- #include "config.h"
-@@ -89,6 +90,8 @@ struct wpa_bss * wpa_bss_get(struct wpa_
-
- static void wpa_bss_copy_res(struct wpa_bss *dst, struct wpa_scan_res *src)
- {
-+ struct ieee80211_ht_capabilities *capab;
-+ struct ieee802_11_elems elems;
- os_time_t usec;
-
- dst->flags = src->flags;
-@@ -101,6 +104,12 @@ static void wpa_bss_copy_res(struct wpa_
- dst->level = src->level;
- dst->tsf = src->tsf;
-
-+ memset(&elems, 0, sizeof(elems));
-+ ieee802_11_parse_elems((u8 *) (src + 1), src->ie_len, &elems, 0);
-+ capab = (struct ieee80211_ht_capabilities *) elems.ht_capabilities;
-+ if (capab)
-+ dst->ht_capab = le_to_host16(capab->ht_capabilities_info);
-+
- os_get_time(&dst->last_update);
- dst->last_update.sec -= src->age / 1000;
- usec = (src->age % 1000) * 1000;
---- a/wpa_supplicant/bss.h
-+++ b/wpa_supplicant/bss.h
-@@ -56,6 +56,7 @@ struct wpa_bss {
- unsigned int flags;
- u8 bssid[ETH_ALEN];
- u8 ssid[32];
-+ u16 ht_capab;
- size_t ssid_len;
- int freq;
- u16 beacon_int;
---- a/wpa_supplicant/main.c
-+++ b/wpa_supplicant/main.c
-@@ -31,7 +31,7 @@ static void usage(void)
- "usage:\n"
- " wpa_supplicant [-BddhKLqqstuvW] [-P<pid file>] "
- "[-g<global ctrl>] \\\n"
-- " -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] "
-+ " -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] [-H<hostapd path>]"
- "[-p<driver_param>] \\\n"
- " [-b<br_ifname>] [-f<debug file>] \\\n"
- " [-o<override driver>] [-O<override ctrl>] \\\n"
-@@ -67,6 +67,7 @@ static void usage(void)
- #endif /* CONFIG_DEBUG_SYSLOG */
- printf(" -t = include timestamp in debug messages\n"
- " -h = show this help text\n"
-+ " -H = connect to a hostapd instance to manage state changes\n"
- " -L = show license (GPL and BSD)\n"
- " -o = override driver parameter for new interfaces\n"
- " -O = override ctrl_interface parameter for new interfaces\n"
-@@ -143,7 +144,7 @@ int main(int argc, char *argv[])
- wpa_supplicant_fd_workaround();
-
- for (;;) {
-- c = getopt(argc, argv, "b:Bc:C:D:df:g:hi:KLNo:O:p:P:qstuvW");
-+ c = getopt(argc, argv, "b:Bc:C:D:df:g:hH:i:KLNo:O:p:P:qstuvW");
- if (c < 0)
- break;
- switch (c) {
-@@ -184,6 +185,9 @@ int main(int argc, char *argv[])
- usage();
- exitcode = 0;
- goto out;
-+ case 'H':
-+ iface->hostapd_ctrl = optarg;
-+ break;
- case 'i':
- iface->ifname = optarg;
- break;
+++ /dev/null
-From: Jouni Malinen <jouni.malinen@atheros.com>
-Date: Tue, 26 Oct 2010 13:30:28 +0000 (+0300)
-Subject: hostapd: Set operstate UP when initializing AP mode
-X-Git-Url: http://w1.fi/gitweb/gitweb.cgi?p=hostap.git;a=commitdiff_plain;h=e11f5a2cbc333113a3a1cc1aeea7f698c3936ca3
-
-hostapd: Set operstate UP when initializing AP mode
-
-This is needed to avoid problems with other applications setting and
-leaving the interface to IF_OPER_DORMANT state. In AP mode, the interface
-is ready immediately after the keys are set, so we better make sure the
-DORMANT state does not prevent normal operations after that.
----
-
---- a/src/ap/hostapd.c
-+++ b/src/ap/hostapd.c
-@@ -622,6 +622,9 @@ static int hostapd_setup_bss(struct host
-
- ieee802_11_set_beacon(hapd);
-
-+ if (hapd->driver && hapd->driver->set_operstate)
-+ hapd->driver->set_operstate(hapd->drv_priv, 1);
-+
- return 0;
- }
-
--- /dev/null
+--- a/src/ap/hostapd.h
++++ b/src/ap/hostapd.h
+@@ -228,6 +228,7 @@ struct hostapd_iface {
+ int (*for_each_interface)(struct hapd_interfaces *interfaces,
+ int (*cb)(struct hostapd_iface *iface,
+ void *ctx), void *ctx);
++ int (*init_complete)(struct hostapd_iface *iface);
+ };
+
+ /* hostapd.c */
+--- a/src/ap/hostapd.c
++++ b/src/ap/hostapd.c
+@@ -790,6 +790,9 @@ int hostapd_setup_interface_complete(str
+ wpa_printf(MSG_DEBUG, "%s: Setup of interface done.",
+ iface->bss[0]->conf->iface);
+
++ if (iface->init_complete)
++ iface->init_complete(iface);
++
+ return 0;
+ }
+
+--- a/hostapd/main.c
++++ b/hostapd/main.c
+@@ -35,6 +35,8 @@
+ extern int wpa_debug_level;
+ extern int wpa_debug_show_keys;
+ extern int wpa_debug_timestamp;
++static int daemonize = 0;
++static char *pid_file = NULL;
+
+
+ struct hapd_interfaces {
+@@ -162,6 +164,15 @@ static void hostapd_logger_cb(void *ctx,
+ }
+ #endif /* CONFIG_NO_HOSTAPD_LOGGER */
+
++static int hostapd_init_complete(struct hostapd_iface *iface)
++{
++ if (daemonize && os_daemonize(pid_file)) {
++ perror("daemon");
++ return -1;
++ }
++ daemonize = 0;
++}
++
+
+ /**
+ * hostapd_init - Allocate and initialize per-interface data
+@@ -183,6 +194,7 @@ static struct hostapd_iface * hostapd_in
+ if (hapd_iface == NULL)
+ goto fail;
+
++ hapd_iface->init_complete = hostapd_init_complete;
+ hapd_iface->reload_config = hostapd_reload_config;
+ hapd_iface->config_read_cb = hostapd_config_read;
+ hapd_iface->config_fname = os_strdup(config_file);
+@@ -391,7 +403,7 @@ static int hostapd_global_init(struct ha
+ }
+
+
+-static void hostapd_global_deinit(const char *pid_file)
++static void hostapd_global_deinit(void)
+ {
+ #ifdef EAP_SERVER_TNC
+ tncs_global_deinit();
+@@ -409,8 +421,7 @@ static void hostapd_global_deinit(const
+ }
+
+
+-static int hostapd_global_run(struct hapd_interfaces *ifaces, int daemonize,
+- const char *pid_file)
++static int hostapd_global_run(struct hapd_interfaces *iface)
+ {
+ #ifdef EAP_SERVER_TNC
+ int tnc = 0;
+@@ -431,11 +442,6 @@ static int hostapd_global_run(struct hap
+ }
+ #endif /* EAP_SERVER_TNC */
+
+- if (daemonize && os_daemonize(pid_file)) {
+- perror("daemon");
+- return -1;
+- }
+-
+ eloop_run();
+
+ return 0;
+@@ -491,8 +497,7 @@ int main(int argc, char *argv[])
+ struct hapd_interfaces interfaces;
+ int ret = 1;
+ size_t i;
+- int c, debug = 0, daemonize = 0;
+- char *pid_file = NULL;
++ int c, debug = 0;
+ const char *log_file = NULL;
+
+ if (os_program_init())
+@@ -566,7 +571,7 @@ int main(int argc, char *argv[])
+ goto out;
+ }
+
+- if (hostapd_global_run(&interfaces, daemonize, pid_file))
++ if (hostapd_global_run(&interfaces))
+ goto out;
+
+ ret = 0;
+@@ -577,7 +582,7 @@ int main(int argc, char *argv[])
+ hostapd_interface_deinit_free(interfaces.iface[i]);
+ os_free(interfaces.iface);
+
+- hostapd_global_deinit(pid_file);
++ hostapd_global_deinit();
+ os_free(pid_file);
+
+ if (log_file)
+--- a/hostapd/config_file.c
++++ b/hostapd/config_file.c
+@@ -1891,6 +1891,8 @@ struct hostapd_config * hostapd_config_r
+ }
+ #endif /* CONFIG_IEEE80211W */
+ #ifdef CONFIG_IEEE80211N
++ } else if (os_strcmp(buf, "noscan") == 0) {
++ conf->noscan = atoi(pos);
+ } else if (os_strcmp(buf, "ieee80211n") == 0) {
+ conf->ieee80211n = atoi(pos);
+ } else if (os_strcmp(buf, "ht_capab") == 0) {
+--- a/src/ap/ap_config.h
++++ b/src/ap/ap_config.h
+@@ -389,6 +389,7 @@ struct hostapd_config {
+
+ int ht_op_mode_fixed;
+ u16 ht_capab;
++ int noscan;
+ int ieee80211n;
+ int secondary_channel;
+ int require_ht;
+--- a/src/ap/hw_features.c
++++ b/src/ap/hw_features.c
+@@ -463,7 +463,7 @@ static int ieee80211n_check_40mhz(struct
+ {
+ struct wpa_driver_scan_params params;
+
+- if (!iface->conf->secondary_channel)
++ if (!iface->conf->secondary_channel || iface->conf->noscan)
+ return 0; /* HT40 not used */
+
+ wpa_printf(MSG_DEBUG, "Scan for neighboring BSSes prior to enabling "
--- /dev/null
+--- a/hostapd/Makefile
++++ b/hostapd/Makefile
+@@ -14,6 +14,7 @@ CFLAGS += -I../src/utils
+ # CFLAGS += -DUSE_KERNEL_HEADERS -I/usr/src/linux/include
+
+ -include .config
++-include $(if $(MULTICALL), ../wpa_supplicant/.config)
+
+ ifndef CONFIG_OS
+ ifdef CONFIG_NATIVE_WINDOWS
+@@ -159,10 +160,14 @@ ifdef CONFIG_IEEE80211N
+ CFLAGS += -DCONFIG_IEEE80211N
+ endif
+
++ifndef MULTICALL
++CFLAGS += -DNO_SUPPLICANT
++endif
++
+ include ../src/drivers/drivers.mak
+-OBJS += $(DRV_AP_OBJS)
+-CFLAGS += $(DRV_AP_CFLAGS)
+-LDFLAGS += $(DRV_AP_LDFLAGS)
++OBJS += $(sort $(DRV_AP_OBJS) $(if $(MULTICALL),$(DRV_WPA_OBJS)))
++CFLAGS += $(DRV_AP_CFLAGS) $(if $(MULTICALL),$(DRV_WPA_CFLAGS))
++LDFLAGS += $(DRV_AP_LDFLAGS) $(if $(MULTICALL),$(DRV_WPA_LDFLAGS))
+ LIBS += $(DRV_AP_LIBS)
+
+ ifdef CONFIG_L2_PACKET
+@@ -780,6 +785,12 @@ install: all
+
+ BCHECK=../src/drivers/build.hostapd
+
++hostapd_multi.a: $(BCHECK) $(OBJS)
++ $(Q)$(CC) -c -o hostapd_multi.o -Dmain=hostapd_main $(CFLAGS) main.c
++ @$(E) " CC " $<
++ @rm -f $@
++ @$(AR) cr $@ hostapd_multi.o $(OBJS)
++
+ hostapd: $(BCHECK) $(OBJS)
+ $(Q)$(CC) $(LDFLAGS) -o hostapd $(OBJS) $(LIBS)
+ @$(E) " LD " $@
+@@ -820,6 +831,12 @@ HOBJS += ../src/crypto/aes-internal.o
+ HOBJS += ../src/crypto/aes-internal-enc.o
+ endif
+
++dump_cflags:
++ @echo -n $(CFLAGS) " "
++
++dump_ldflags:
++ @echo -n $(LDFLAGS) $(LIBS) $(EXTRALIBS) " "
++
+ nt_password_hash: $(NOBJS)
+ $(Q)$(CC) $(LDFLAGS) -o nt_password_hash $(NOBJS) $(LIBS_n)
+ @$(E) " LD " $@
+--- a/wpa_supplicant/Makefile
++++ b/wpa_supplicant/Makefile
+@@ -53,6 +53,7 @@ OBJS_c = wpa_cli.o ../src/common/wpa_ctr
+ OBJS_c += ../src/utils/wpa_debug.o
+
+ -include .config
++-include $(if $(MULTICALL),../hostapd/.config)
+
+ ifndef CONFIG_OS
+ ifdef CONFIG_NATIVE_WINDOWS
+@@ -634,6 +635,10 @@ ifdef CONFIG_DYNAMIC_EAP_METHODS
+ CFLAGS += -DCONFIG_DYNAMIC_EAP_METHODS
+ LIBS += -ldl -rdynamic
+ endif
++else
++ ifdef MULTICALL
++ OBJS += ../src/eap_common/eap_common.o
++ endif
+ endif
+
+ ifdef CONFIG_AP
+@@ -642,9 +647,11 @@ NEED_EAP_COMMON=y
+ NEED_RSN_AUTHENTICATOR=y
+ CFLAGS += -DCONFIG_AP
+ OBJS += ap.o
++ifndef MULTICALL
+ CFLAGS += -DCONFIG_NO_RADIUS
+ CFLAGS += -DCONFIG_NO_ACCOUNTING
+ CFLAGS += -DCONFIG_NO_VLAN
++endif
+ OBJS += ../src/ap/hostapd.o
+ OBJS += ../src/ap/wpa_auth_glue.o
+ OBJS += ../src/ap/utils.o
+@@ -688,10 +695,18 @@ CFLAGS += -DEAP_SERVER_WSC
+ OBJS += ../src/ap/wps_hostapd.o
+ OBJS += ../src/eap_server/eap_server_wsc.o
+ endif
++else
++ ifdef MULTICALL
++ OBJS += ../src/eap_server/eap_server.o
++ OBJS += ../src/eap_server/eap_server_identity.o
++ OBJS += ../src/eap_server/eap_server_methods.o
++ endif
+ endif
+
+ ifdef NEED_RSN_AUTHENTICATOR
++ifndef MULTICALL
+ CFLAGS += -DCONFIG_NO_RADIUS
++endif
+ NEED_AES_WRAP=y
+ OBJS += ../src/ap/wpa_auth.o
+ OBJS += ../src/ap/wpa_auth_ie.o
+@@ -1352,6 +1367,12 @@ wpa_priv: $(BCHECK) $(OBJS_priv)
+ $(Q)$(LDO) $(LDFLAGS) -o wpa_priv $(OBJS_priv) $(LIBS)
+ @$(E) " LD " $@
+
++wpa_supplicant_multi.a: .config $(BCHECK) $(OBJS) $(EXTRA_progs)
++ $(Q)$(CC) -c -o wpa_supplicant_multi.o -Dmain=wpa_supplicant_main $(CFLAGS) main.c
++ @$(E) " CC " $<
++ @rm -f $@
++ @$(AR) cr $@ wpa_supplicant_multi.o $(OBJS)
++
+ wpa_supplicant: .config $(BCHECK) $(OBJS) $(EXTRA_progs)
+ $(Q)$(LDO) $(LDFLAGS) -o wpa_supplicant $(OBJS) $(LIBS) $(EXTRALIBS)
+ @$(E) " LD " $@
+@@ -1412,6 +1433,12 @@ eap_ikev2.so: ../src/eap_peer/eap_ikev2.
+ $(Q)$(CC) -c -o $@ $(CFLAGS) $<
+ @$(E) " CC " $<
+
++dump_cflags:
++ @echo -n $(CFLAGS) " "
++
++dump_ldflags:
++ @echo -n $(LDFLAGS) $(LIBS) $(EXTRALIBS) " "
++
+ wpa_supplicant.exe: wpa_supplicant
+ mv -f $< $@
+ wpa_cli.exe: wpa_cli
+--- a/src/drivers/driver.h
++++ b/src/drivers/driver.h
+@@ -3169,8 +3169,8 @@ union wpa_event_data {
+ * Driver wrapper code should call this function whenever an event is received
+ * from the driver.
+ */
+-void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
+- union wpa_event_data *data);
++extern void (*wpa_supplicant_event)(void *ctx, enum wpa_event_type event,
++ union wpa_event_data *data);
+
+
+ /*
+--- a/src/ap/drv_callbacks.c
++++ b/src/ap/drv_callbacks.c
+@@ -443,8 +443,8 @@ static void hostapd_event_eapol_rx(struc
+ }
+
+
+-void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
+- union wpa_event_data *data)
++void hostapd_wpa_event(void *ctx, enum wpa_event_type event,
++ union wpa_event_data *data)
+ {
+ struct hostapd_data *hapd = ctx;
+
+--- a/wpa_supplicant/wpa_priv.c
++++ b/wpa_supplicant/wpa_priv.c
+@@ -825,8 +825,8 @@ static void wpa_priv_send_ft_response(st
+ }
+
+
+-void wpa_supplicant_event(void *ctx, wpa_event_type event,
+- union wpa_event_data *data)
++static void supplicant_event(void *ctx, wpa_event_type event,
++ union wpa_event_data *data)
+ {
+ struct wpa_priv_interface *iface = ctx;
+
+@@ -968,6 +968,7 @@ int main(int argc, char *argv[])
+ if (os_program_init())
+ return -1;
+
++ wpa_supplicant_event = supplicant_event;
+ wpa_priv_fd_workaround();
+
+ for (;;) {
+--- a/wpa_supplicant/events.c
++++ b/wpa_supplicant/events.c
+@@ -1718,8 +1718,8 @@ static void wpa_supplicant_event_unprot_
+ }
+
+
+-void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
+- union wpa_event_data *data)
++void supplicant_event(void *ctx, enum wpa_event_type event,
++ union wpa_event_data *data)
+ {
+ struct wpa_supplicant *wpa_s = ctx;
+ u16 reason_code = 0;
+--- a/wpa_supplicant/wpa_supplicant.c
++++ b/wpa_supplicant/wpa_supplicant.c
+@@ -2313,6 +2313,9 @@ static void wpa_supplicant_deinit_iface(
+ wpa_drv_deinit(wpa_s);
+ }
+
++extern void supplicant_event(void *ctx, enum wpa_event_type event,
++ union wpa_event_data *data);
++
+
+ /**
+ * wpa_supplicant_add_iface - Add a new network interface
+@@ -2496,6 +2499,7 @@ struct wpa_global * wpa_supplicant_init(
+ wpa_msg_register_ifname_cb(wpa_supplicant_msg_ifname_cb);
+ #endif /* CONFIG_NO_WPA_MSG */
+
++ wpa_supplicant_event = supplicant_event;
+ wpa_debug_open_file(params->wpa_debug_file_path);
+ if (params->wpa_debug_syslog)
+ wpa_debug_open_syslog();
+--- a/hostapd/main.c
++++ b/hostapd/main.c
+@@ -491,6 +491,9 @@ static const char * hostapd_msg_ifname_c
+ return NULL;
+ }
+
++void hostapd_wpa_event(void *ctx, enum wpa_event_type event,
++ union wpa_event_data *data);
++
+
+ int main(int argc, char *argv[])
+ {
+@@ -503,6 +506,7 @@ int main(int argc, char *argv[])
+ if (os_program_init())
+ return -1;
+
++ wpa_supplicant_event = hostapd_wpa_event;
+ for (;;) {
+ c = getopt(argc, argv, "Bdf:hKP:tv");
+ if (c < 0)
+--- a/src/drivers/drivers.c
++++ b/src/drivers/drivers.c
+@@ -13,7 +13,11 @@
+ */
+
+ #include "includes.h"
++#include "common.h"
++#include "driver.h"
+
++void (*wpa_supplicant_event)(void *ctx, enum wpa_event_type event,
++ union wpa_event_data *data);
+
+ #ifdef CONFIG_DRIVER_WEXT
+ extern struct wpa_driver_ops wpa_driver_wext_ops; /* driver_wext.c */
--- /dev/null
+--- a/src/tls/x509v3.c
++++ b/src/tls/x509v3.c
+@@ -1854,8 +1854,11 @@ int x509_certificate_chain_validate(stru
+ if (chain_trusted)
+ continue;
+
+- if ((unsigned long) now.sec <
++ if (
++#ifndef NO_TIMESTAMP_CHECK
++ (unsigned long) now.sec <
+ (unsigned long) cert->not_before ||
++#endif
+ (unsigned long) now.sec >
+ (unsigned long) cert->not_after) {
+ wpa_printf(MSG_INFO, "X509: Certificate not valid "
--- /dev/null
+--- a/wpa_supplicant/events.c
++++ b/wpa_supplicant/events.c
+@@ -953,7 +953,7 @@ static int _wpa_supplicant_event_scan_re
+ wpa_dbg(wpa_s, MSG_DEBUG, "Setup a new network");
+ wpa_supplicant_associate(wpa_s, NULL, ssid);
+ } else {
+- int timeout_sec = 5;
++ int timeout_sec = 0;
+ int timeout_usec = 0;
+ #ifdef CONFIG_P2P
+ if (wpa_s->p2p_in_provisioning) {
--- /dev/null
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -129,7 +129,9 @@ struct wpa_driver_nl80211_data {
+ int ifindex;
+ int if_removed;
+ int if_disabled;
++#ifdef CONFIG_RFKILL
+ struct rfkill_data *rfkill;
++#endif
+ struct wpa_driver_capa capa;
+ int has_capability;
+
+@@ -1750,7 +1752,7 @@ err1:
+ return -1;
+ }
+
+-
++#ifdef CONFIG_RFKILL
+ static void wpa_driver_nl80211_rfkill_blocked(void *ctx)
+ {
+ wpa_printf(MSG_DEBUG, "nl80211: RFKILL blocked");
+@@ -1772,6 +1774,7 @@ static void wpa_driver_nl80211_rfkill_un
+ }
+ /* rtnetlink ifup handler will report interface as enabled */
+ }
++#endif /* CONFIG_RFKILL */
+
+
+ static void nl80211_get_phy_name(struct wpa_driver_nl80211_data *drv)
+@@ -1820,7 +1823,9 @@ static void * wpa_driver_nl80211_init(vo
+ {
+ struct wpa_driver_nl80211_data *drv;
+ struct netlink_config *cfg;
++#ifdef CONFIG_RFKILL
+ struct rfkill_config *rcfg;
++#endif
+ struct i802_bss *bss;
+
+ drv = os_zalloc(sizeof(*drv));
+@@ -1863,6 +1868,7 @@ static void * wpa_driver_nl80211_init(vo
+ goto failed;
+ }
+
++#ifdef CONFIG_RFKILL
+ rcfg = os_zalloc(sizeof(*rcfg));
+ if (rcfg == NULL)
+ goto failed;
+@@ -1875,6 +1881,7 @@ static void * wpa_driver_nl80211_init(vo
+ wpa_printf(MSG_DEBUG, "nl80211: RFKILL status not available");
+ os_free(rcfg);
+ }
++#endif /* CONFIG_RFKILL */
+
+ if (wpa_driver_nl80211_finish_drv_init(drv))
+ goto failed;
+@@ -1882,7 +1889,9 @@ static void * wpa_driver_nl80211_init(vo
+ return bss;
+
+ failed:
++#ifdef CONFIG_RFKILL
+ rfkill_deinit(drv->rfkill);
++#endif
+ netlink_deinit(drv->netlink);
+ if (drv->ioctl_sock >= 0)
+ close(drv->ioctl_sock);
+@@ -1985,10 +1994,12 @@ static int nl80211_register_action_frame
+ }
+
+
++#ifdef CONFIG_RFKILL
+ static void wpa_driver_nl80211_send_rfkill(void *eloop_ctx, void *timeout_ctx)
+ {
+ wpa_supplicant_event(timeout_ctx, EVENT_INTERFACE_DISABLED, NULL);
+ }
++#endif /* CONFIG_RFKILL */
+
+
+ static int
+@@ -2007,13 +2018,16 @@ wpa_driver_nl80211_finish_drv_init(struc
+ }
+
+ if (linux_set_iface_flags(drv->ioctl_sock, bss->ifname, 1)) {
++#ifdef CONFIG_RFKILL
+ if (rfkill_is_blocked(drv->rfkill)) {
+ wpa_printf(MSG_DEBUG, "nl80211: Could not yet enable "
+ "interface '%s' due to rfkill",
+ bss->ifname);
+ drv->if_disabled = 1;
+ send_rfkill_event = 1;
+- } else {
++ } else
++#endif
++ {
+ wpa_printf(MSG_ERROR, "nl80211: Could not set "
+ "interface '%s' UP", bss->ifname);
+ return -1;
+@@ -2041,8 +2055,10 @@ wpa_driver_nl80211_finish_drv_init(struc
+ }
+
+ if (send_rfkill_event) {
++#ifdef CONFIG_RFKILL
+ eloop_register_timeout(0, 0, wpa_driver_nl80211_send_rfkill,
+ drv, drv->ctx);
++#endif
+ }
+
+ return 0;
+@@ -2123,7 +2139,9 @@ static void wpa_driver_nl80211_deinit(vo
+
+ netlink_send_oper_ifla(drv->netlink, drv->ifindex, 0, IF_OPER_UP);
+ netlink_deinit(drv->netlink);
++#ifdef CONFIG_RFKILL
+ rfkill_deinit(drv->rfkill);
++#endif
+
+ eloop_cancel_timeout(wpa_driver_nl80211_scan_timeout, drv, drv->ctx);
+
+@@ -5672,7 +5690,9 @@ static void *i802_init(struct hostapd_da
+
+ failed:
+ nl80211_remove_monitor_interface(drv);
++#ifdef CONFIG_RFKILL
+ rfkill_deinit(drv->rfkill);
++#endif
+ netlink_deinit(drv->netlink);
+ if (drv->ioctl_sock >= 0)
+ close(drv->ioctl_sock);
+--- a/src/drivers/driver_wext.c
++++ b/src/drivers/driver_wext.c
+@@ -702,7 +702,7 @@ static void wpa_driver_wext_event_rtm_de
+ }
+ }
+
+-
++#ifdef CONFIG_RFKILL
+ static void wpa_driver_wext_rfkill_blocked(void *ctx)
+ {
+ wpa_printf(MSG_DEBUG, "WEXT: RFKILL blocked");
+@@ -724,7 +724,7 @@ static void wpa_driver_wext_rfkill_unblo
+ }
+ /* rtnetlink ifup handler will report interface as enabled */
+ }
+-
++#endif /* CONFIG_RFKILL */
+
+ static void wext_get_phy_name(struct wpa_driver_wext_data *drv)
+ {
+@@ -770,7 +770,9 @@ void * wpa_driver_wext_init(void *ctx, c
+ {
+ struct wpa_driver_wext_data *drv;
+ struct netlink_config *cfg;
++#ifdef CONFIG_RFKILL
+ struct rfkill_config *rcfg;
++#endif
+ char path[128];
+ struct stat buf;
+
+@@ -805,6 +807,7 @@ void * wpa_driver_wext_init(void *ctx, c
+ goto err2;
+ }
+
++#ifdef CONFIG_RFKILL
+ rcfg = os_zalloc(sizeof(*rcfg));
+ if (rcfg == NULL)
+ goto err3;
+@@ -817,6 +820,7 @@ void * wpa_driver_wext_init(void *ctx, c
+ wpa_printf(MSG_DEBUG, "WEXT: RFKILL status not available");
+ os_free(rcfg);
+ }
++#endif /* CONFIG_RFKILL */
+
+ drv->mlme_sock = -1;
+
+@@ -828,7 +832,9 @@ void * wpa_driver_wext_init(void *ctx, c
+ return drv;
+
+ err3:
++#ifdef CONFIG_RFKILL
+ rfkill_deinit(drv->rfkill);
++#endif
+ netlink_deinit(drv->netlink);
+ err2:
+ close(drv->ioctl_sock);
+@@ -838,10 +844,12 @@ err1:
+ }
+
+
++#ifdef CONFIG_RFKILL
+ static void wpa_driver_wext_send_rfkill(void *eloop_ctx, void *timeout_ctx)
+ {
+ wpa_supplicant_event(timeout_ctx, EVENT_INTERFACE_DISABLED, NULL);
+ }
++#endif /* CONFIG_RFKILL */
+
+
+ static int wpa_driver_wext_finish_drv_init(struct wpa_driver_wext_data *drv)
+@@ -849,13 +857,16 @@ static int wpa_driver_wext_finish_drv_in
+ int send_rfkill_event = 0;
+
+ if (linux_set_iface_flags(drv->ioctl_sock, drv->ifname, 1) < 0) {
++#ifdef CONFIG_RFKILL
+ if (rfkill_is_blocked(drv->rfkill)) {
+ wpa_printf(MSG_DEBUG, "WEXT: Could not yet enable "
+ "interface '%s' due to rfkill",
+ drv->ifname);
+ drv->if_disabled = 1;
+ send_rfkill_event = 1;
+- } else {
++ } else
++#endif
++ {
+ wpa_printf(MSG_ERROR, "WEXT: Could not set "
+ "interface '%s' UP", drv->ifname);
+ return -1;
+@@ -903,8 +914,10 @@ static int wpa_driver_wext_finish_drv_in
+ 1, IF_OPER_DORMANT);
+
+ if (send_rfkill_event) {
++#ifdef CONFIG_RFKILL
+ eloop_register_timeout(0, 0, wpa_driver_wext_send_rfkill,
+ drv, drv->ctx);
++#endif
+ }
+
+ return 0;
+@@ -934,7 +947,9 @@ void wpa_driver_wext_deinit(void *priv)
+
+ netlink_send_oper_ifla(drv->netlink, drv->ifindex, 0, IF_OPER_UP);
+ netlink_deinit(drv->netlink);
++#ifdef CONFIG_RFKILL
+ rfkill_deinit(drv->rfkill);
++#endif
+
+ if (drv->mlme_sock >= 0)
+ eloop_unregister_read_sock(drv->mlme_sock);
+--- a/src/drivers/drivers.mak
++++ b/src/drivers/drivers.mak
+@@ -43,7 +43,6 @@ NEED_SME=y
+ NEED_AP_MLME=y
+ NEED_NETLINK=y
+ NEED_LINUX_IOCTL=y
+-NEED_RFKILL=y
+ ifdef CONFIG_LIBNL_TINY
+ DRV_LIBS += -lnl-tiny
+ else
+@@ -94,7 +93,6 @@ DRV_WPA_CFLAGS += -DCONFIG_DRIVER_WEXT
+ CONFIG_WIRELESS_EXTENSION=y
+ NEED_NETLINK=y
+ NEED_LINUX_IOCTL=y
+-NEED_RFKILL=y
+ endif
+
+ ifdef CONFIG_DRIVER_RALINK
+@@ -146,7 +144,6 @@ endif
+ ifdef CONFIG_WIRELESS_EXTENSION
+ DRV_CFLAGS += -DCONFIG_WIRELESS_EXTENSION
+ DRV_OBJS += ../src/drivers/driver_wext.o
+-NEED_RFKILL=y
+ endif
+
+ ifdef NEED_NETLINK
+@@ -159,6 +156,7 @@ endif
+
+ ifdef NEED_RFKILL
+ DRV_OBJS += ../src/drivers/rfkill.o
++DRV_WPA_CFLAGS += -DCONFIG_RFKILL
+ endif
+
+
+--- a/src/drivers/driver_wext.h
++++ b/src/drivers/driver_wext.h
+@@ -28,7 +28,9 @@ struct wpa_driver_wext_data {
+ int ifindex2;
+ int if_removed;
+ int if_disabled;
++#ifdef CONFIG_RFKILL
+ struct rfkill_data *rfkill;
++#endif
+ u8 *assoc_req_ies;
+ size_t assoc_req_ies_len;
+ u8 *assoc_resp_ies;
--- /dev/null
+--- a/src/ap/hostapd.c
++++ b/src/ap/hostapd.c
+@@ -120,6 +120,10 @@ int hostapd_reload_config(struct hostapd
+ oldconf = hapd->iconf;
+ iface->conf = newconf;
+
++ iface->freq = hostapd_hw_get_freq(hapd, hapd->iconf->channel);
++ if (iface->current_mode)
++ hostapd_prepare_rates(hapd, iface->current_mode);
++
+ for (j = 0; j < iface->num_bss; j++) {
+ hapd = iface->bss[j];
+ hapd->iconf = newconf;
--- /dev/null
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -2065,23 +2065,41 @@ wpa_driver_nl80211_finish_drv_init(struc
+ }
+
+
+-static int wpa_driver_nl80211_del_beacon(struct wpa_driver_nl80211_data *drv)
++static int wpa_driver_nl80211_del_bss_beacon(struct i802_bss *bss)
+ {
++ struct wpa_driver_nl80211_data *drv = bss->drv;
+ struct nl_msg *msg;
+
++ bss->beacon_set = 0;
++
+ msg = nlmsg_alloc();
+ if (!msg)
+ return -ENOMEM;
+
+ genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
+ 0, NL80211_CMD_DEL_BEACON, 0);
+- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, drv->ifindex);
++ NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, bss->ifindex);
+
+ return send_and_recv_msgs(drv, msg, NULL, NULL);
+ nla_put_failure:
++ nlmsg_free(msg);
+ return -ENOBUFS;
+ }
+
++static int wpa_driver_nl80211_del_beacon(struct wpa_driver_nl80211_data *drv)
++{
++ struct i802_bss *bss;
++
++ for (bss = &drv->first_bss; bss; bss = bss->next)
++ wpa_driver_nl80211_del_bss_beacon(bss);
++}
++
++static int wpa_driver_nl80211_stop_ap(void *priv)
++{
++ struct i802_bss *bss = priv;
++
++ wpa_driver_nl80211_del_beacon(bss->drv);
++}
+
+ /**
+ * wpa_driver_nl80211_deinit - Deinitialize nl80211 driver interface
+@@ -6529,4 +6547,5 @@ const struct wpa_driver_ops wpa_driver_n
+ .set_intra_bss = nl80211_set_intra_bss,
+ .set_param = nl80211_set_param,
+ .get_radio_name = nl80211_get_radio_name,
++ .stop_ap = wpa_driver_nl80211_stop_ap,
+ };
+--- a/src/drivers/driver.h
++++ b/src/drivers/driver.h
+@@ -2217,6 +2217,8 @@ struct wpa_driver_ops {
+ const u8 *buf, size_t len);
+
+ int (*tdls_oper)(void *priv, enum tdls_oper oper, const u8 *peer);
++
++ int (*stop_ap)(void *priv);
+ };
+
+
--- /dev/null
+--- a/hostapd/ctrl_iface.c
++++ b/hostapd/ctrl_iface.c
+@@ -39,6 +39,7 @@
+ #include "wps/wps_defs.h"
+ #include "wps/wps.h"
+ #include "ctrl_iface.h"
++#include "config_file.h"
+
+
+ struct wpa_ctrl_dst {
+@@ -49,6 +50,7 @@ struct wpa_ctrl_dst {
+ int errors;
+ };
+
++static char *reload_opts = NULL;
+
+ static void hostapd_ctrl_iface_send(struct hostapd_data *hapd, int level,
+ const char *buf, size_t len);
+@@ -323,6 +325,66 @@ static int hostapd_ctrl_iface_disassocia
+ return 0;
+ }
+
++static int hostapd_ctrl_iface_set_down(struct hostapd_data *hapd)
++{
++ if (hapd->driver->stop_ap)
++ hapd->driver->stop_ap(hapd->drv_priv);
++ return 0;
++}
++
++static char *get_option(char *opt, char *str)
++{
++ int len = strlen(str);
++
++ if (!strncmp(opt, str, len))
++ return opt + len;
++ else
++ return NULL;
++}
++
++static struct hostapd_config *hostapd_ctrl_iface_config_read(const char *fname)
++{
++ struct hostapd_config *conf;
++ char *opt, *val;
++
++ conf = hostapd_config_read(fname);
++ if (!conf)
++ return NULL;
++
++ for (opt = strtok(reload_opts, " ");
++ opt;
++ opt = strtok(NULL, " ")) {
++
++ if ((val = get_option(opt, "channel=")))
++ conf->channel = atoi(val);
++ else if ((val = get_option(opt, "ht_capab=")))
++ conf->ht_capab = atoi(val);
++ else if ((val = get_option(opt, "ht_capab_mask=")))
++ conf->ht_capab &= atoi(val);
++ else if ((val = get_option(opt, "sec_chan=")))
++ conf->secondary_channel = atoi(val);
++ else if ((val = get_option(opt, "hwmode=")))
++ conf->hw_mode = atoi(val);
++ else if ((val = get_option(opt, "ieee80211n=")))
++ conf->ieee80211n = atoi(val);
++ else
++ break;
++ }
++
++ return conf;
++}
++
++static int hostapd_ctrl_iface_reload(struct hostapd_data *hapd, char *txt)
++{
++ struct hostapd_iface *iface = hapd->iface;
++
++ iface->config_read_cb = hostapd_ctrl_iface_config_read;
++ reload_opts = txt;
++
++ hostapd_reload_config(iface);
++
++ iface->config_read_cb = hostapd_config_read;
++}
+
+ #ifdef CONFIG_IEEE80211W
+ #ifdef NEED_AP_MLME
+@@ -822,6 +884,10 @@ static void hostapd_ctrl_iface_receive(i
+ reply_len += res;
+ }
+ #endif /* CONFIG_NO_RADIUS */
++ } else if (os_strcmp(buf, "DOWN") == 0) {
++ hostapd_ctrl_iface_set_down(hapd);
++ } else if (os_strncmp(buf, "RELOAD ", 7) == 0) {
++ hostapd_ctrl_iface_reload(hapd, buf + 7);
+ } else if (os_strcmp(buf, "STA-FIRST") == 0) {
+ reply_len = hostapd_ctrl_iface_sta_first(hapd, reply,
+ reply_size);
--- /dev/null
+--- a/wpa_supplicant/wpa_supplicant_i.h
++++ b/wpa_supplicant/wpa_supplicant_i.h
+@@ -99,6 +99,8 @@ struct wpa_interface {
+ * receiving of EAPOL frames from an additional interface.
+ */
+ const char *bridge_ifname;
++
++ const char *hostapd_ctrl;
+ };
+
+ /**
+@@ -337,6 +339,8 @@ struct wpa_supplicant {
+ #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
+ char bridge_ifname[16];
+
++ struct wpa_ctrl *hostapd;
++
+ char *confname;
+ struct wpa_config *conf;
+ int countermeasures;
+--- a/wpa_supplicant/Makefile
++++ b/wpa_supplicant/Makefile
+@@ -52,6 +52,11 @@ OBJS_p += ../src/utils/wpabuf.o
+ OBJS_c = wpa_cli.o ../src/common/wpa_ctrl.o
+ OBJS_c += ../src/utils/wpa_debug.o
+
++ifdef MULTICALL
++OBJS += ../src/common/wpa_ctrl.o
++CFLAGS += -DMULTICALL
++endif
++
+ -include .config
+ -include $(if $(MULTICALL),../hostapd/.config)
+
+--- a/wpa_supplicant/wpa_supplicant.c
++++ b/wpa_supplicant/wpa_supplicant.c
+@@ -122,6 +122,55 @@ extern int wpa_debug_show_keys;
+ extern int wpa_debug_timestamp;
+ extern struct wpa_driver_ops *wpa_drivers[];
+
++#ifdef MULTICALL
++static int hostapd_stop(struct wpa_supplicant *wpa_s)
++{
++ const char *cmd = "DOWN";
++ char buf[256];
++ int len = sizeof(buf);
++
++ if (wpa_ctrl_request(wpa_s->hostapd, cmd, os_strlen(cmd), buf, &len, NULL) < 0) {
++ wpa_printf(MSG_ERROR, "\nFailed to stop hostapd AP interfaces\n");
++ return -1;
++ }
++ return 0;
++}
++
++static int hostapd_reload(struct wpa_supplicant *wpa_s, struct wpa_bss *bss)
++{
++ char *cmd = NULL;
++ char buf[256];
++ int len = sizeof(buf);
++ int channel, hw_mode;
++ int ret;
++
++ if (!bss)
++ return;
++
++ if (bss->freq < 4000) {
++ hw_mode = HOSTAPD_MODE_IEEE80211G;
++ channel = (bss->freq - 2407) / 5;
++ } else {
++ hw_mode = HOSTAPD_MODE_IEEE80211A;
++ channel = (bss->freq - 5000) / 5;
++ }
++
++ if (asprintf(&cmd, "RELOAD channel=%d sec_chan=0 hw_mode=%d ieee80211n=%d",
++ channel, hw_mode, !!bss->ht_capab) < 0) {
++ return -1;
++ }
++
++ ret = wpa_ctrl_request(wpa_s->hostapd, cmd, os_strlen(cmd), buf, &len, NULL);
++ free(cmd);
++
++ if (ret < 0) {
++ wpa_printf(MSG_ERROR, "\nFailed to reload hostapd AP interfaces\n");
++ return -1;
++ }
++ return 0;
++}
++#endif
++
+ /* Configure default/group WEP keys for static WEP */
+ int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
+ {
+@@ -597,8 +646,16 @@ void wpa_supplicant_set_state(struct wpa
+ #ifdef CONFIG_P2P
+ wpas_p2p_completed(wpa_s);
+ #endif /* CONFIG_P2P */
++#ifdef MULTICALL
++ if (wpa_s->hostapd)
++ hostapd_reload(wpa_s, wpa_s->current_bss);
++#endif
+ } else if (state == WPA_DISCONNECTED || state == WPA_ASSOCIATING ||
+ state == WPA_ASSOCIATED) {
++#ifdef MULTICALL
++ if (wpa_s->hostapd)
++ hostapd_stop(wpa_s);
++#endif
+ wpa_s->new_connection = 1;
+ wpa_drv_set_operstate(wpa_s, 0);
+ #ifndef IEEE8021X_EAPOL
+@@ -2148,6 +2205,21 @@ static int wpa_supplicant_init_iface(str
+ os_strlcpy(wpa_s->bridge_ifname, iface->bridge_ifname,
+ sizeof(wpa_s->bridge_ifname));
+ }
++#ifdef MULTICALL
++ if (iface->hostapd_ctrl) {
++ char *cmd = "DOWN";
++ char buf[256];
++ int len = sizeof(buf);
++
++ wpa_s->hostapd = wpa_ctrl_open(iface->hostapd_ctrl);
++ if (!wpa_s->hostapd) {
++ wpa_printf(MSG_ERROR, "\nFailed to connect to hostapd\n");
++ return -1;
++ }
++ if (hostapd_stop(wpa_s) < 0)
++ return -1;
++ }
++#endif
+
+ /* RSNA Supplicant Key Management - INITIALIZE */
+ eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
+--- a/wpa_supplicant/bss.c
++++ b/wpa_supplicant/bss.c
+@@ -17,6 +17,7 @@
+ #include "utils/common.h"
+ #include "utils/eloop.h"
+ #include "common/ieee802_11_defs.h"
++#include "common/ieee802_11_common.h"
+ #include "drivers/driver.h"
+ #include "wpa_supplicant_i.h"
+ #include "config.h"
+@@ -70,6 +71,8 @@ struct wpa_bss * wpa_bss_get(struct wpa_
+
+ static void wpa_bss_copy_res(struct wpa_bss *dst, struct wpa_scan_res *src)
+ {
++ struct ieee80211_ht_capabilities *capab;
++ struct ieee802_11_elems elems;
+ os_time_t usec;
+
+ dst->flags = src->flags;
+@@ -82,6 +85,12 @@ static void wpa_bss_copy_res(struct wpa_
+ dst->level = src->level;
+ dst->tsf = src->tsf;
+
++ memset(&elems, 0, sizeof(elems));
++ ieee802_11_parse_elems((u8 *) (src + 1), src->ie_len, &elems, 0);
++ capab = (struct ieee80211_ht_capabilities *) elems.ht_capabilities;
++ if (capab)
++ dst->ht_capab = le_to_host16(capab->ht_capabilities_info);
++
+ os_get_time(&dst->last_update);
+ dst->last_update.sec -= src->age / 1000;
+ usec = (src->age % 1000) * 1000;
+--- a/wpa_supplicant/bss.h
++++ b/wpa_supplicant/bss.h
+@@ -56,6 +56,7 @@ struct wpa_bss {
+ unsigned int flags;
+ u8 bssid[ETH_ALEN];
+ u8 ssid[32];
++ u16 ht_capab;
+ size_t ssid_len;
+ int freq;
+ u16 beacon_int;
+--- a/wpa_supplicant/main.c
++++ b/wpa_supplicant/main.c
+@@ -31,7 +31,7 @@ static void usage(void)
+ "usage:\n"
+ " wpa_supplicant [-BddhKLqqstuvW] [-P<pid file>] "
+ "[-g<global ctrl>] \\\n"
+- " -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] "
++ " -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] [-H<hostapd path>]"
+ "[-p<driver_param>] \\\n"
+ " [-b<br_ifname>] [-f<debug file>] \\\n"
+ " [-o<override driver>] [-O<override ctrl>] \\\n"
+@@ -67,6 +67,7 @@ static void usage(void)
+ #endif /* CONFIG_DEBUG_SYSLOG */
+ printf(" -t = include timestamp in debug messages\n"
+ " -h = show this help text\n"
++ " -H = connect to a hostapd instance to manage state changes\n"
+ " -L = show license (GPL and BSD)\n"
+ " -o = override driver parameter for new interfaces\n"
+ " -O = override ctrl_interface parameter for new interfaces\n"
+@@ -143,7 +144,7 @@ int main(int argc, char *argv[])
+ wpa_supplicant_fd_workaround();
+
+ for (;;) {
+- c = getopt(argc, argv, "b:Bc:C:D:df:g:hi:KLNo:O:p:P:qstuvW");
++ c = getopt(argc, argv, "b:Bc:C:D:df:g:hH:i:KLNo:O:p:P:qstuvW");
+ if (c < 0)
+ break;
+ switch (c) {
+@@ -184,6 +185,9 @@ int main(int argc, char *argv[])
+ usage();
+ exitcode = 0;
+ goto out;
++ case 'H':
++ iface->hostapd_ctrl = optarg;
++ break;
+ case 'i':
+ iface->ifname = optarg;
+ break;
--- /dev/null
+--- a/hostapd/Makefile
++++ b/hostapd/Makefile
+@@ -119,6 +119,9 @@ endif
+ ifdef CONFIG_NO_CTRL_IFACE
+ CFLAGS += -DCONFIG_NO_CTRL_IFACE
+ else
++ifdef CONFIG_CTRL_IFACE_MIB
++CFLAGS += -DCONFIG_CTRL_IFACE_MIB
++endif
+ OBJS += ctrl_iface.o
+ OBJS += ../src/ap/ctrl_iface_ap.o
+ endif
+--- a/hostapd/ctrl_iface.c
++++ b/hostapd/ctrl_iface.c
+@@ -855,6 +855,7 @@ static void hostapd_ctrl_iface_receive(i
+ } else if (os_strncmp(buf, "RELOG", 5) == 0) {
+ if (wpa_debug_reopen_file() < 0)
+ reply_len = -1;
++#ifdef CONFIG_CTRL_IFACE_MIB
+ } else if (os_strcmp(buf, "MIB") == 0) {
+ reply_len = ieee802_11_get_mib(hapd, reply, reply_size);
+ if (reply_len >= 0) {
+@@ -884,10 +885,12 @@ static void hostapd_ctrl_iface_receive(i
+ reply_len += res;
+ }
+ #endif /* CONFIG_NO_RADIUS */
++#endif
+ } else if (os_strcmp(buf, "DOWN") == 0) {
+ hostapd_ctrl_iface_set_down(hapd);
+ } else if (os_strncmp(buf, "RELOAD ", 7) == 0) {
+ hostapd_ctrl_iface_reload(hapd, buf + 7);
++#ifdef CONFIG_CTRL_IFACE_MIB
+ } else if (os_strcmp(buf, "STA-FIRST") == 0) {
+ reply_len = hostapd_ctrl_iface_sta_first(hapd, reply,
+ reply_size);
+@@ -897,6 +900,7 @@ static void hostapd_ctrl_iface_receive(i
+ } else if (os_strncmp(buf, "STA-NEXT ", 9) == 0) {
+ reply_len = hostapd_ctrl_iface_sta_next(hapd, buf + 9, reply,
+ reply_size);
++#endif
+ } else if (os_strcmp(buf, "ATTACH") == 0) {
+ if (hostapd_ctrl_iface_attach(hapd, &from, fromlen))
+ reply_len = -1;
+--- a/wpa_supplicant/Makefile
++++ b/wpa_supplicant/Makefile
+@@ -675,6 +675,9 @@ ifdef CONFIG_IEEE80211N
+ OBJS += ../src/ap/ieee802_11_ht.o
+ endif
+ ifdef CONFIG_CTRL_IFACE
++ifdef CONFIG_CTRL_IFACE_MIB
++CFLAGS += -DCONFIG_CTRL_IFACE_MIB
++endif
+ OBJS += ../src/ap/ctrl_iface_ap.o
+ endif
+
+--- a/wpa_supplicant/ctrl_iface.c
++++ b/wpa_supplicant/ctrl_iface.c
+@@ -2885,6 +2885,7 @@ char * wpa_supplicant_ctrl_iface_process
+ reply_len = -1;
+ } else if (os_strncmp(buf, "NOTE ", 5) == 0) {
+ wpa_printf(MSG_INFO, "NOTE: %s", buf + 5);
++#ifdef CONFIG_CTRL_IFACE_MIB
+ } else if (os_strcmp(buf, "MIB") == 0) {
+ reply_len = wpa_sm_get_mib(wpa_s->wpa, reply, reply_size);
+ if (reply_len >= 0) {
+@@ -2896,6 +2897,7 @@ char * wpa_supplicant_ctrl_iface_process
+ else
+ reply_len += res;
+ }
++#endif
+ } else if (os_strncmp(buf, "STATUS", 6) == 0) {
+ reply_len = wpa_supplicant_ctrl_iface_status(
+ wpa_s, buf + 6, reply, reply_size);
+@@ -3189,6 +3191,7 @@ char * wpa_supplicant_ctrl_iface_process
+ reply_len = wpa_supplicant_ctrl_iface_bss(
+ wpa_s, buf + 4, reply, reply_size);
+ #ifdef CONFIG_AP
++#ifdef CONFIG_CTRL_IFACE_MIB
+ } else if (os_strcmp(buf, "STA-FIRST") == 0) {
+ reply_len = ap_ctrl_iface_sta_first(wpa_s, reply, reply_size);
+ } else if (os_strncmp(buf, "STA ", 4) == 0) {
+@@ -3197,6 +3200,7 @@ char * wpa_supplicant_ctrl_iface_process
+ } else if (os_strncmp(buf, "STA-NEXT ", 9) == 0) {
+ reply_len = ap_ctrl_iface_sta_next(wpa_s, buf + 9, reply,
+ reply_size);
++#endif
+ #endif /* CONFIG_AP */
+ } else if (os_strcmp(buf, "SUSPEND") == 0) {
+ wpas_notify_suspend(wpa_s->global);
+--- a/src/ap/ctrl_iface_ap.c
++++ b/src/ap/ctrl_iface_ap.c
+@@ -24,6 +24,7 @@
+ #include "p2p_hostapd.h"
+ #include "ctrl_iface_ap.h"
+
++#ifdef CONFIG_CTRL_IFACE_MIB
+
+ static int hostapd_ctrl_iface_sta_mib(struct hostapd_data *hapd,
+ struct sta_info *sta,
+@@ -106,3 +107,5 @@ int hostapd_ctrl_iface_sta_next(struct h
+ }
+ return hostapd_ctrl_iface_sta_mib(hapd, sta->next, buf, buflen);
+ }
++
++#endif
+--- a/src/ap/ieee802_1x.c
++++ b/src/ap/ieee802_1x.c
+@@ -1866,6 +1866,7 @@ static const char * bool_txt(Boolean boo
+ return bool ? "TRUE" : "FALSE";
+ }
+
++#ifdef CONFIG_CTRL_IFACE_MIB
+
+ int ieee802_1x_get_mib(struct hostapd_data *hapd, char *buf, size_t buflen)
+ {
+@@ -2017,6 +2018,7 @@ int ieee802_1x_get_mib_sta(struct hostap
+ return len;
+ }
+
++#endif
+
+ static void ieee802_1x_finished(struct hostapd_data *hapd,
+ struct sta_info *sta, int success)
+--- a/src/ap/wpa_auth.c
++++ b/src/ap/wpa_auth.c
+@@ -2470,6 +2470,7 @@ static int wpa_cipher_bits(int cipher)
+ }
+ }
+
++#ifdef CONFIG_CTRL_IFACE_MIB
+
+ #define RSN_SUITE "%02x-%02x-%02x-%d"
+ #define RSN_SUITE_ARG(s) \
+@@ -2633,7 +2634,7 @@ int wpa_get_mib_sta(struct wpa_state_mac
+
+ return len;
+ }
+-
++#endif
+
+ void wpa_auth_countermeasures_start(struct wpa_authenticator *wpa_auth)
+ {
+--- a/src/rsn_supp/wpa.c
++++ b/src/rsn_supp/wpa.c
+@@ -1913,6 +1913,8 @@ static u32 wpa_cipher_suite(struct wpa_s
+ }
+
+
++#ifdef CONFIG_CTRL_IFACE_MIB
++
+ #define RSN_SUITE "%02x-%02x-%02x-%d"
+ #define RSN_SUITE_ARG(s) \
+ ((s) >> 24) & 0xff, ((s) >> 16) & 0xff, ((s) >> 8) & 0xff, (s) & 0xff
+@@ -1992,6 +1994,7 @@ int wpa_sm_get_mib(struct wpa_sm *sm, ch
+
+ return (int) len;
+ }
++#endif
+ #endif /* CONFIG_CTRL_IFACE */
+
+
--- a/src/ap/hostapd.c
+++ b/src/ap/hostapd.c
-@@ -706,11 +706,8 @@ int hostapd_setup_interface_complete(str
+@@ -717,11 +717,8 @@ int hostapd_setup_interface_complete(str
size_t j;
u8 *prev_addr;
wpa_printf(MSG_DEBUG, "Completing interface initialization");
if (hapd->iconf->channel) {
-@@ -726,7 +723,7 @@ int hostapd_setup_interface_complete(str
+@@ -737,7 +734,7 @@ int hostapd_setup_interface_complete(str
hapd->iconf->secondary_channel)) {
wpa_printf(MSG_ERROR, "Could not set channel for "
"kernel driver");
}
}
-@@ -736,7 +733,7 @@ int hostapd_setup_interface_complete(str
+@@ -748,7 +745,7 @@ int hostapd_setup_interface_complete(str
hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211,
- HOSTAPD_LEVEL_WARNING,
- "Failed to prepare rates table.");
+ HOSTAPD_LEVEL_WARNING,
+ "Failed to prepare rates table.");
- return -1;
+ goto error;
}
}
-@@ -744,14 +741,14 @@ int hostapd_setup_interface_complete(str
+@@ -756,14 +753,14 @@ int hostapd_setup_interface_complete(str
hostapd_set_rts(hapd, hapd->iconf->rts_threshold)) {
wpa_printf(MSG_ERROR, "Could not set RTS threshold for "
"kernel driver");
}
prev_addr = hapd->own_addr;
-@@ -761,7 +758,7 @@ int hostapd_setup_interface_complete(str
+@@ -773,7 +770,7 @@ int hostapd_setup_interface_complete(str
if (j)
os_memcpy(hapd->own_addr, prev_addr, ETH_ALEN);
if (hostapd_setup_bss(hapd, j == 0))
if (hostapd_mac_comp_empty(hapd->conf->bssid) == 0)
prev_addr = hapd->own_addr;
}
-@@ -773,7 +770,7 @@ int hostapd_setup_interface_complete(str
+@@ -785,7 +782,7 @@ int hostapd_setup_interface_complete(str
if (hostapd_driver_commit(hapd) < 0) {
wpa_printf(MSG_ERROR, "%s: Failed to commit driver "
"configuration", __func__);
+ goto error;
}
- wpa_printf(MSG_DEBUG, "%s: Setup of interface done.",
-@@ -783,6 +780,11 @@ int hostapd_setup_interface_complete(str
+ if (hapd->setup_complete_cb)
+@@ -798,6 +795,11 @@ int hostapd_setup_interface_complete(str
iface->init_complete(iface);
return 0;
--- /dev/null
+--- a/src/crypto/random.c
++++ b/src/crypto/random.c
+@@ -47,6 +47,8 @@
+ #define EXTRACT_LEN 16
+ #define MIN_READY_MARK 2
+
++#ifndef CONFIG_NO_RANDOM_POOL
++
+ static u32 pool[POOL_WORDS];
+ static unsigned int input_rotate = 0;
+ static unsigned int pool_pos = 0;
+@@ -120,7 +122,7 @@ static void random_extract(u8 *out)
+ }
+
+
+-void random_add_randomness(const void *buf, size_t len)
++static void random_pool_add_randomness(const void *buf, size_t len)
+ {
+ struct os_time t;
+ static unsigned int count = 0;
+@@ -260,3 +262,22 @@ void random_mark_pool_ready(void)
+ wpa_printf(MSG_DEBUG, "random: Mark internal entropy pool to be "
+ "ready (count=%u/%u)", own_pool_ready, MIN_READY_MARK);
+ }
++
++#endif /* CONFIG_NO_RANDOM_POOL */
++
++
++void random_add_randomness(const void *buf, size_t len)
++{
++#ifdef __linux__
++ int fd;
++
++ fd = open("/dev/random", O_RDWR);
++ if (fd >= 0) {
++ write(fd, buf, len);
++ close(fd);
++ }
++#endif
++#ifndef CONFIG_NO_RANDOM_POOL
++ random_pool_add_randomness(buf, len);
++#endif
++}
+--- a/hostapd/Makefile
++++ b/hostapd/Makefile
+@@ -698,11 +698,11 @@ endif
+ ifdef CONFIG_NO_RANDOM_POOL
+ CFLAGS += -DCONFIG_NO_RANDOM_POOL
+ else
+-OBJS += ../src/crypto/random.o
+-HOBJS += ../src/crypto/random.o
+ HOBJS += $(SHA1OBJS)
+ HOBJS += ../src/crypto/md5.o
+ endif
++OBJS += ../src/crypto/random.o
++HOBJS += ../src/crypto/random.o
+
+ ifdef CONFIG_RADIUS_SERVER
+ CFLAGS += -DRADIUS_SERVER
+--- a/wpa_supplicant/Makefile
++++ b/wpa_supplicant/Makefile
+@@ -1101,9 +1101,8 @@ endif
+
+ ifdef CONFIG_NO_RANDOM_POOL
+ CFLAGS += -DCONFIG_NO_RANDOM_POOL
+-else
+-OBJS += ../src/crypto/random.o
+ endif
++OBJS += ../src/crypto/random.o
+
+ ifdef CONFIG_CTRL_IFACE
+ ifeq ($(CONFIG_CTRL_IFACE), y)
+--- a/wpa_supplicant/Android.mk
++++ b/wpa_supplicant/Android.mk
+@@ -1102,9 +1102,8 @@ endif
+
+ ifdef CONFIG_NO_RANDOM_POOL
+ L_CFLAGS += -DCONFIG_NO_RANDOM_POOL
+-else
+-OBJS += src/crypto/random.c
+ endif
++OBJS += src/crypto/random.c
+
+ ifdef CONFIG_CTRL_IFACE
+ ifeq ($(CONFIG_CTRL_IFACE), y)
+--- a/hostapd/Android.mk
++++ b/hostapd/Android.mk
+@@ -717,11 +717,11 @@ endif
+ ifdef CONFIG_NO_RANDOM_POOL
+ L_CFLAGS += -DCONFIG_NO_RANDOM_POOL
+ else
+-OBJS += src/crypto/random.c
+-HOBJS += src/crypto/random.c
+ HOBJS += $(SHA1OBJS)
+ HOBJS += src/crypto/md5.c
+ endif
++OBJS += src/crypto/random.c
++HOBJS += src/crypto/random.c
+
+ ifdef CONFIG_RADIUS_SERVER
+ L_CFLAGS += -DRADIUS_SERVER
+--- a/src/crypto/random.h
++++ b/src/crypto/random.h
+@@ -16,15 +16,14 @@
+ #define RANDOM_H
+
+ #ifdef CONFIG_NO_RANDOM_POOL
+-#define random_add_randomness(b, l) do { } while (0)
+ #define random_get_bytes(b, l) os_get_random((b), (l))
+ #define random_pool_ready() 1
+ #define random_mark_pool_ready() do { } while (0)
+ #else /* CONFIG_NO_RANDOM_POOL */
+-void random_add_randomness(const void *buf, size_t len);
+ int random_get_bytes(void *buf, size_t len);
+ int random_pool_ready(void);
+ void random_mark_pool_ready(void);
+ #endif /* CONFIG_NO_RANDOM_POOL */
++void random_add_randomness(const void *buf, size_t len);
+
+ #endif /* RANDOM_H */
--- /dev/null
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -4883,9 +4883,6 @@ static int wpa_driver_nl80211_set_mode(v
+ /* Try to set the mode again while the interface is
+ * down */
+ ret = nl80211_set_mode(drv, drv->ifindex, nlmode);
+- if (linux_set_iface_flags(drv->ioctl_sock, bss->ifname,
+- 1))
+- ret = -1;
+ if (!ret)
+ break;
+ } else
+@@ -4898,6 +4895,8 @@ static int wpa_driver_nl80211_set_mode(v
+ wpa_printf(MSG_DEBUG, "nl80211: Mode change succeeded while "
+ "interface is down");
+ drv->nlmode = nlmode;
++ if (linux_set_iface_flags(drv->ioctl_sock, bss->ifname, 1))
++ ret = -1;
+ }
+
+ done:
--- /dev/null
+--- a/hostapd/ctrl_iface.c
++++ b/hostapd/ctrl_iface.c
+@@ -514,6 +514,9 @@ static int hostapd_ctrl_iface_wps_ap_pin
+ char *pos;
+ const char *pin_txt;
+
++ if (!hapd->wps)
++ return -1;
++
+ pos = os_strchr(txt, ' ');
+ if (pos)
+ *pos++ = '\0';
--- /dev/null
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -4263,7 +4263,7 @@ static const u8 rfc1042_header[6] = { 0x
+
+ static int wpa_driver_nl80211_hapd_send_eapol(
+ void *priv, const u8 *addr, const u8 *data,
+- size_t data_len, int encrypt, const u8 *own_addr)
++ size_t data_len, int encrypt, const u8 *own_addr, u32 flags)
+ {
+ struct i802_bss *bss = priv;
+ struct wpa_driver_nl80211_data *drv = bss->drv;
+@@ -4271,11 +4271,7 @@ static int wpa_driver_nl80211_hapd_send_
+ size_t len;
+ u8 *pos;
+ int res;
+-#if 0 /* FIX */
+- int qos = sta->flags & WPA_STA_WMM;
+-#else
+- int qos = 0;
+-#endif
++ int qos = flags & WPA_STA_WMM;
+
+ len = sizeof(*hdr) + (qos ? 2 : 0) + sizeof(rfc1042_header) + 2 +
+ data_len;
+@@ -4291,26 +4287,22 @@ static int wpa_driver_nl80211_hapd_send_
+ hdr->frame_control |= host_to_le16(WLAN_FC_FROMDS);
+ if (encrypt)
+ hdr->frame_control |= host_to_le16(WLAN_FC_ISWEP);
+-#if 0 /* To be enabled if qos determination is added above */
+ if (qos) {
+ hdr->frame_control |=
+ host_to_le16(WLAN_FC_STYPE_QOS_DATA << 4);
+ }
+-#endif
+
+ memcpy(hdr->IEEE80211_DA_FROMDS, addr, ETH_ALEN);
+ memcpy(hdr->IEEE80211_BSSID_FROMDS, own_addr, ETH_ALEN);
+ memcpy(hdr->IEEE80211_SA_FROMDS, own_addr, ETH_ALEN);
+ pos = (u8 *) (hdr + 1);
+
+-#if 0 /* To be enabled if qos determination is added above */
+ if (qos) {
+ /* add an empty QoS header if needed */
+ pos[0] = 0;
+ pos[1] = 0;
+ pos += 2;
+ }
+-#endif
+
+ memcpy(pos, rfc1042_header, sizeof(rfc1042_header));
+ pos += sizeof(rfc1042_header);
+--- a/src/drivers/driver.h
++++ b/src/drivers/driver.h
+@@ -1396,7 +1396,7 @@ struct wpa_driver_ops {
+ */
+ int (*hapd_send_eapol)(void *priv, const u8 *addr, const u8 *data,
+ size_t data_len, int encrypt,
+- const u8 *own_addr);
++ const u8 *own_addr, u32 flags);
+
+ /**
+ * sta_deauth - Deauthenticate a station (AP only)
+--- a/src/drivers/driver_madwifi.c
++++ b/src/drivers/driver_madwifi.c
+@@ -1097,7 +1097,7 @@ madwifi_wireless_event_init(struct madwi
+
+ static int
+ madwifi_send_eapol(void *priv, const u8 *addr, const u8 *data, size_t data_len,
+- int encrypt, const u8 *own_addr)
++ int encrypt, const u8 *own_addr, u32 flags)
+ {
+ struct madwifi_driver_data *drv = priv;
+ unsigned char buf[3000];
+--- a/src/drivers/driver_test.c
++++ b/src/drivers/driver_test.c
+@@ -175,7 +175,7 @@ test_driver_get_cli(struct wpa_driver_te
+
+ static int test_driver_send_eapol(void *priv, const u8 *addr, const u8 *data,
+ size_t data_len, int encrypt,
+- const u8 *own_addr)
++ const u8 *own_addr, u32 flags)
+ {
+ struct test_driver_bss *dbss = priv;
+ struct wpa_driver_test_data *drv = dbss->drv;
+--- a/src/drivers/driver_hostap.c
++++ b/src/drivers/driver_hostap.c
+@@ -294,7 +294,8 @@ static int hostap_send_mlme(void *priv,
+
+
+ static int hostap_send_eapol(void *priv, const u8 *addr, const u8 *data,
+- size_t data_len, int encrypt, const u8 *own_addr)
++ size_t data_len, int encrypt, const u8 *own_addr,
++ u32 flags)
+ {
+ struct hostap_driver_data *drv = priv;
+ struct ieee80211_hdr *hdr;
+--- a/src/drivers/driver_atheros.c
++++ b/src/drivers/driver_atheros.c
+@@ -1132,7 +1132,7 @@ atheros_wireless_event_init(struct ather
+
+ static int
+ atheros_send_eapol(void *priv, const u8 *addr, const u8 *data, size_t data_len,
+- int encrypt, const u8 *own_addr)
++ int encrypt, const u8 *own_addr, u32 flags)
+ {
+ struct atheros_driver_data *drv = priv;
+ unsigned char buf[3000];
+--- a/src/drivers/driver_bsd.c
++++ b/src/drivers/driver_bsd.c
+@@ -516,7 +516,7 @@ no_ie:
+
+ static int
+ bsd_send_eapol(void *priv, const u8 *addr, const u8 *data, size_t data_len,
+- int encrypt, const u8 *own_addr)
++ int encrypt, const u8 *own_addr, u32 flags)
+ {
+ struct bsd_driver_data *drv = priv;
+
+--- a/src/ap/ap_drv_ops.h
++++ b/src/ap/ap_drv_ops.h
+@@ -135,13 +135,14 @@ static inline int hostapd_drv_sta_remove
+
+ static inline int hostapd_drv_hapd_send_eapol(struct hostapd_data *hapd,
+ const u8 *addr, const u8 *data,
+- size_t data_len, int encrypt)
++ size_t data_len, int encrypt,
++ u32 flags)
+ {
+ if (hapd->driver == NULL || hapd->driver->hapd_send_eapol == NULL)
+ return 0;
+ return hapd->driver->hapd_send_eapol(hapd->drv_priv, addr, data,
+ data_len, encrypt,
+- hapd->own_addr);
++ hapd->own_addr, flags);
+ }
+
+ static inline int hostapd_drv_read_sta_data(
+--- a/src/ap/ieee802_1x.c
++++ b/src/ap/ieee802_1x.c
+@@ -73,7 +73,7 @@ static void ieee802_1x_send(struct hosta
+ rsn_preauth_send(hapd, sta, buf, len);
+ } else {
+ hostapd_drv_hapd_send_eapol(hapd, sta->addr, buf, len,
+- encrypt);
++ encrypt, sta->flags);
+ }
+
+ os_free(buf);
+--- a/src/ap/wpa_auth_glue.c
++++ b/src/ap/wpa_auth_glue.c
+@@ -243,8 +243,15 @@ static int hostapd_wpa_auth_send_eapol(v
+ int encrypt)
+ {
+ struct hostapd_data *hapd = ctx;
++ struct sta_info *sta;
++ u32 flags = 0;
++
++ sta = ap_get_sta(hapd, addr);
++ if (sta)
++ flags = sta->flags;
++
+ return hostapd_drv_hapd_send_eapol(hapd, addr, data, data_len,
+- encrypt);
++ encrypt, flags);
+ }
+
+
+--- a/wpa_supplicant/driver_i.h
++++ b/wpa_supplicant/driver_i.h
+@@ -351,12 +351,12 @@ static inline int wpa_drv_sta_remove(str
+ static inline int wpa_drv_hapd_send_eapol(struct wpa_supplicant *wpa_s,
+ const u8 *addr, const u8 *data,
+ size_t data_len, int encrypt,
+- const u8 *own_addr)
++ const u8 *own_addr, u32 flags)
+ {
+ if (wpa_s->driver->hapd_send_eapol)
+ return wpa_s->driver->hapd_send_eapol(wpa_s->drv_priv, addr,
+ data, data_len, encrypt,
+- own_addr);
++ own_addr, flags);
+ return -1;
+ }
+
+--- a/src/drivers/driver_wired.c
++++ b/src/drivers/driver_wired.c
+@@ -314,7 +314,7 @@ static int wired_init_sockets(struct wpa
+
+ static int wired_send_eapol(void *priv, const u8 *addr,
+ const u8 *data, size_t data_len, int encrypt,
+- const u8 *own_addr)
++ const u8 *own_addr, u32 flags)
+ {
+ struct wpa_driver_wired_data *drv = priv;
+ struct ieee8023_hdr *hdr;
include $(TOPDIR)/rules.mk
PKG_NAME:=iw
-PKG_VERSION:=0.9.21
+PKG_VERSION:=0.9.22
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=http://wireless.kernel.org/download/iw/
-PKG_MD5SUM:=726db5f1fd6bc316434414770513ef81
+PKG_MD5SUM:=561c2602c5ce7c65a590118286c0892a
PKG_BUILD_DEPENDS:=mac80211
include $(INCLUDE_DIR)/package.mk
--- a/nl80211.h
+++ b/nl80211.h
-@@ -295,7 +295,9 @@
- * auth and assoc steps. For this, you need to specify the SSID in a
- * %NL80211_ATTR_SSID attribute, and can optionally specify the association
- * IEs in %NL80211_ATTR_IE, %NL80211_ATTR_AUTH_TYPE, %NL80211_ATTR_MAC,
-- * %NL80211_ATTR_WIPHY_FREQ and %NL80211_ATTR_CONTROL_PORT.
-+ * %NL80211_ATTR_WIPHY_FREQ, %NL80211_ATTR_CONTROL_PORT,
-+ * %NL80211_ATTR_CONTROL_PORT_ETHERTYPE and
-+ * %NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT.
- * It is also sent as an event, with the BSSID and response IEs when the
- * connection is established or failed to be established. This can be
- * determined by the STATUS_CODE attribute.
-@@ -313,8 +315,8 @@
- * channel for the specified amount of time. This can be used to do
- * off-channel operations like transmit a Public Action frame and wait for
- * a response while being associated to an AP on another channel.
-- * %NL80211_ATTR_WIPHY or %NL80211_ATTR_IFINDEX is used to specify which
-- * radio is used. %NL80211_ATTR_WIPHY_FREQ is used to specify the
-+ * %NL80211_ATTR_IFINDEX is used to specify which interface (and thus
-+ * radio) is used. %NL80211_ATTR_WIPHY_FREQ is used to specify the
- * frequency for the operation and %NL80211_ATTR_WIPHY_CHANNEL_TYPE may be
- * optionally used to specify additional channel parameters.
- * %NL80211_ATTR_DURATION is used to specify the duration in milliseconds
-@@ -385,6 +387,8 @@
- * of any other interfaces, and other interfaces will again take
- * precedence when they are used.
+@@ -148,6 +148,10 @@
+ * @NL80211_CMD_SET_MPATH: Set mesh path attributes for mesh path to
+ * destination %NL80211_ATTR_MAC on the interface identified by
+ * %NL80211_ATTR_IFINDEX.
++ * @NL80211_CMD_NEW_MPATH: Create a new mesh path for the destination given by
++ * %NL80211_ATTR_MAC via %NL80211_ATTR_MPATH_NEXT_HOP.
++ * @NL80211_CMD_DEL_MPATH: Delete a mesh path to the destination given by
++ * %NL80211_ATTR_MAC.
+ * @NL80211_CMD_NEW_PATH: Add a mesh path with given attributes to the
+ * the interface identified by %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_DEL_PATH: Remove a mesh path identified by %NL80211_ATTR_MAC
+@@ -612,7 +616,7 @@ enum nl80211_commands {
+ * consisting of a nested array.
*
-+ * @NL80211_CMD_SET_WDS_PEER: Set the MAC address of the peer on a WDS interface.
-+ *
- * @NL80211_CMD_MAX: highest used command number
- * @__NL80211_CMD_AFTER_LAST: internal use
- */
-@@ -487,6 +491,7 @@ enum nl80211_commands {
- NL80211_CMD_NOTIFY_CQM,
-
- NL80211_CMD_SET_CHANNEL,
-+ NL80211_CMD_SET_WDS_PEER,
-
- /* add new commands above here */
-
-@@ -686,6 +691,15 @@ enum nl80211_commands {
- * request, the driver will assume that the port is unauthorized until
- * authorized by user space. Otherwise, port is marked authorized by
- * default in station mode.
-+ * @NL80211_ATTR_CONTROL_PORT_ETHERTYPE: A 16-bit value indicating the
-+ * ethertype that will be used for key negotiation. It can be
-+ * specified with the associate and connect commands. If it is not
-+ * specified, the value defaults to 0x888E (PAE, 802.1X). This
-+ * attribute is also used as a flag in the wiphy information to
-+ * indicate that protocols other than PAE are supported.
-+ * @NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT: When included along with
-+ * %NL80211_ATTR_CONTROL_PORT_ETHERTYPE, indicates that the custom
-+ * ethertype frames used for key negotiation must not be encrypted.
+ * @NL80211_ATTR_MESH_ID: mesh id (1-32 bytes).
+- * @NL80211_ATTR_PLINK_ACTION: action to perform on the mesh peer link.
++ * @NL80211_ATTR_STA_PLINK_ACTION: action to perform on the mesh peer link.
+ * @NL80211_ATTR_MPATH_NEXT_HOP: MAC address of the next hop for a mesh path.
+ * @NL80211_ATTR_MPATH_INFO: information about a mesh_path, part of mesh path
+ * info given for %NL80211_CMD_GET_MPATH, nested attribute described at
+@@ -879,7 +883,9 @@ enum nl80211_commands {
+ * See &enum nl80211_key_default_types.
*
- * @NL80211_ATTR_TESTDATA: Testmode data blob, passed through to the driver.
- * We recommend using nested, driver-specific attributes within this.
-@@ -787,6 +801,33 @@ enum nl80211_commands {
- * This is used in association with @NL80211_ATTR_WIPHY_TX_POWER_SETTING
- * for non-automatic settings.
+ * @NL80211_ATTR_MESH_SETUP: Optional mesh setup parameters. These cannot be
+- * changed once the mesh is active.
++ * changed once the mesh is active.
++ * @NL80211_ATTR_MESH_CONFIG: Mesh configuration parameters, a nested attribute
++ * containing attributes from &enum nl80211_meshconf_params.
*
-+ * @NL80211_ATTR_SUPPORT_IBSS_RSN: The device supports IBSS RSN, which mostly
-+ * means support for per-station GTKs.
-+ *
-+ * @NL80211_ATTR_WIPHY_ANTENNA_TX: Bitmap of allowed antennas for transmitting.
-+ * This can be used to mask out antennas which are not attached or should
-+ * not be used for transmitting. If an antenna is not selected in this
-+ * bitmap the hardware is not allowed to transmit on this antenna.
-+ *
-+ * Each bit represents one antenna, starting with antenna 1 at the first
-+ * bit. Depending on which antennas are selected in the bitmap, 802.11n
-+ * drivers can derive which chainmasks to use (if all antennas belonging to
-+ * a particular chain are disabled this chain should be disabled) and if
-+ * a chain has diversity antennas wether diversity should be used or not.
-+ * HT capabilities (STBC, TX Beamforming, Antenna selection) can be
-+ * derived from the available chains after applying the antenna mask.
-+ * Non-802.11n drivers can derive wether to use diversity or not.
-+ * Drivers may reject configurations or RX/TX mask combinations they cannot
-+ * support by returning -EINVAL.
-+ *
-+ * @NL80211_ATTR_WIPHY_ANTENNA_RX: Bitmap of allowed antennas for receiving.
-+ * This can be used to mask out antennas which are not attached or should
-+ * not be used for receiving. If an antenna is not selected in this bitmap
-+ * the hardware should not be configured to receive on this antenna.
-+ * For a more detailed descripton see @NL80211_ATTR_WIPHY_ANTENNA_TX.
-+ *
-+ * @NL80211_ATTR_MCAST_RATE: Multicast tx rate (in 100 kbps) for IBSS
-+ *
* @NL80211_ATTR_MAX: highest attribute number currently defined
* @__NL80211_ATTR_AFTER_LAST: internal use
- */
-@@ -951,6 +992,16 @@ enum nl80211_attrs {
- NL80211_ATTR_RX_FRAME_TYPES,
- NL80211_ATTR_FRAME_TYPE,
-
-+ NL80211_ATTR_CONTROL_PORT_ETHERTYPE,
-+ NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT,
-+
-+ NL80211_ATTR_SUPPORT_IBSS_RSN,
-+
-+ NL80211_ATTR_WIPHY_ANTENNA_TX,
-+ NL80211_ATTR_WIPHY_ANTENNA_RX,
-+
-+ NL80211_ATTR_MCAST_RATE,
-+
- /* add attributes here, update the policy in nl80211.c */
-
- __NL80211_ATTR_AFTER_LAST,
-@@ -1006,6 +1057,8 @@ enum nl80211_attrs {
- * @NL80211_IFTYPE_WDS: wireless distribution interface
- * @NL80211_IFTYPE_MONITOR: monitor interface receiving all frames
- * @NL80211_IFTYPE_MESH_POINT: mesh point
-+ * @NL80211_IFTYPE_P2P_CLIENT: P2P client
-+ * @NL80211_IFTYPE_P2P_GO: P2P group owner
- * @NL80211_IFTYPE_MAX: highest interface type number currently defined
- * @NUM_NL80211_IFTYPES: number of defined interface types
- *
-@@ -1022,6 +1075,8 @@ enum nl80211_iftype {
- NL80211_IFTYPE_WDS,
- NL80211_IFTYPE_MONITOR,
- NL80211_IFTYPE_MESH_POINT,
-+ NL80211_IFTYPE_P2P_CLIENT,
-+ NL80211_IFTYPE_P2P_GO,
-
- /* keep last */
- NUM_NL80211_IFTYPES,
-@@ -1111,6 +1166,8 @@ enum nl80211_rate_info {
- * @NL80211_STA_INFO_RX_PACKETS: total received packet (u32, from this station)
- * @NL80211_STA_INFO_TX_PACKETS: total transmitted packets (u32, to this
- * station)
-+ * @NL80211_STA_INFO_TX_RETRIES: total retries (u32, to this station)
-+ * @NL80211_STA_INFO_TX_FAILED: total failed packets (u32, to this station)
+@@ -1225,8 +1231,6 @@ enum nl80211_rate_info {
+ * @NL80211_STA_INFO_INACTIVE_TIME: time since last activity (u32, msecs)
+ * @NL80211_STA_INFO_RX_BYTES: total received bytes (u32, from this station)
+ * @NL80211_STA_INFO_TX_BYTES: total transmitted bytes (u32, to this station)
+- * @__NL80211_STA_INFO_AFTER_LAST: internal
+- * @NL80211_STA_INFO_MAX: highest possible station info attribute
+ * @NL80211_STA_INFO_SIGNAL: signal strength of last received PPDU (u8, dBm)
+ * @NL80211_STA_INFO_TX_BITRATE: current unicast tx rate, nested attribute
+ * containing info as possible, see &enum nl80211_sta_info_txrate.
+@@ -1236,6 +1240,13 @@ enum nl80211_rate_info {
+ * @NL80211_STA_INFO_TX_RETRIES: total retries (u32, to this station)
+ * @NL80211_STA_INFO_TX_FAILED: total failed packets (u32, to this station)
+ * @NL80211_STA_INFO_SIGNAL_AVG: signal strength average (u8, dBm)
++ * @NL80211_STA_INFO_LLID: the station's mesh LLID
++ * @NL80211_STA_INFO_PLID: the station's mesh PLID
++ * @NL80211_STA_INFO_PLINK_STATE: peer link state for the station
++ * @NL80211_STA_INFO_RX_BITRATE: last unicast rx rate, nested attribute
++ * containing info as possible, see &enum nl80211_sta_info_txrate.
++ * @__NL80211_STA_INFO_AFTER_LAST: internal
++ * @NL80211_STA_INFO_MAX: highest possible station info attribute
*/
enum nl80211_sta_info {
__NL80211_STA_INFO_INVALID,
-@@ -1124,6 +1181,8 @@ enum nl80211_sta_info {
- NL80211_STA_INFO_TX_BITRATE,
- NL80211_STA_INFO_RX_PACKETS,
- NL80211_STA_INFO_TX_PACKETS,
-+ NL80211_STA_INFO_TX_RETRIES,
-+ NL80211_STA_INFO_TX_FAILED,
+@@ -1252,6 +1263,7 @@ enum nl80211_sta_info {
+ NL80211_STA_INFO_TX_RETRIES,
+ NL80211_STA_INFO_TX_FAILED,
+ NL80211_STA_INFO_SIGNAL_AVG,
++ NL80211_STA_INFO_RX_BITRATE,
/* keep last */
__NL80211_STA_INFO_AFTER_LAST,
-@@ -1277,7 +1336,11 @@ enum nl80211_bitrate_attr {
- * wireless core it thinks its knows the regulatory domain we should be in.
- * @NL80211_REGDOM_SET_BY_COUNTRY_IE: the wireless core has received an
- * 802.11 country information element with regulatory information it
-- * thinks we should consider.
-+ * thinks we should consider. cfg80211 only processes the country
-+ * code from the IE, and relies on the regulatory domain information
-+ * structure pased by userspace (CRDA) from our wireless-regdb.
-+ * If a channel is enabled but the country code indicates it should
-+ * be disabled we disable the channel and re-enable it upon disassociation.
- */
- enum nl80211_reg_initiator {
- NL80211_REGDOM_SET_BY_CORE,
-@@ -1382,6 +1445,17 @@ enum nl80211_reg_rule_flags {
- * @__NL80211_SURVEY_INFO_INVALID: attribute number 0 is reserved
- * @NL80211_SURVEY_INFO_FREQUENCY: center frequency of channel
- * @NL80211_SURVEY_INFO_NOISE: noise level of channel (u8, dBm)
-+ * @NL80211_SURVEY_INFO_IN_USE: channel is currently being used
-+ * @NL80211_SURVEY_INFO_CHANNEL_TIME: amount of time (in ms) that the radio
-+ * spent on this channel
-+ * @NL80211_SURVEY_INFO_CHANNEL_TIME_BUSY: amount of the time the primary
-+ * channel was sensed busy (either due to activity or energy detect)
-+ * @NL80211_SURVEY_INFO_CHANNEL_TIME_EXT_BUSY: amount of time the extension
-+ * channel was sensed busy
-+ * @NL80211_SURVEY_INFO_CHANNEL_TIME_RX: amount of time the radio spent
-+ * receiving data
-+ * @NL80211_SURVEY_INFO_CHANNEL_TIME_TX: amount of time the radio spent
-+ * transmitting data
- * @NL80211_SURVEY_INFO_MAX: highest survey info attribute number
- * currently defined
- * @__NL80211_SURVEY_INFO_AFTER_LAST: internal use
-@@ -1390,6 +1464,12 @@ enum nl80211_survey_info {
- __NL80211_SURVEY_INFO_INVALID,
- NL80211_SURVEY_INFO_FREQUENCY,
- NL80211_SURVEY_INFO_NOISE,
-+ NL80211_SURVEY_INFO_IN_USE,
-+ NL80211_SURVEY_INFO_CHANNEL_TIME,
-+ NL80211_SURVEY_INFO_CHANNEL_TIME_BUSY,
-+ NL80211_SURVEY_INFO_CHANNEL_TIME_EXT_BUSY,
-+ NL80211_SURVEY_INFO_CHANNEL_TIME_RX,
-+ NL80211_SURVEY_INFO_CHANNEL_TIME_TX,
-
- /* keep last */
- __NL80211_SURVEY_INFO_AFTER_LAST,
-@@ -1636,11 +1716,14 @@ enum nl80211_auth_type {
- * @NL80211_KEYTYPE_GROUP: Group (broadcast/multicast) key
- * @NL80211_KEYTYPE_PAIRWISE: Pairwise (unicast/individual) key
- * @NL80211_KEYTYPE_PEERKEY: PeerKey (DLS)
-+ * @NUM_NL80211_KEYTYPES: number of defined key types
- */
- enum nl80211_key_type {
- NL80211_KEYTYPE_GROUP,
- NL80211_KEYTYPE_PAIRWISE,
- NL80211_KEYTYPE_PEERKEY,
-+
-+ NUM_NL80211_KEYTYPES
- };
-
- /**
-@@ -1671,6 +1754,9 @@ enum nl80211_wpa_versions {
- * CCMP keys, each six bytes in little endian
- * @NL80211_KEY_DEFAULT: flag indicating default key
- * @NL80211_KEY_DEFAULT_MGMT: flag indicating default management key
-+ * @NL80211_KEY_TYPE: the key type from enum nl80211_key_type, if not
-+ * specified the default depends on whether a MAC address was
-+ * given with the command using the key or not (u32)
- * @__NL80211_KEY_AFTER_LAST: internal
- * @NL80211_KEY_MAX: highest key attribute
+@@ -1626,7 +1638,7 @@ enum nl80211_mntr_flags {
+ * @NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME: The interval of time (in TUs)
+ * that it takes for an HWMP information element to propagate across the mesh
+ *
+- * @NL80211_MESHCONF_ROOTMODE: whether root mode is enabled or not
++ * @NL80211_MESHCONF_HWMP_ROOTMODE: whether root mode is enabled or not
+ *
+ * @NL80211_MESHCONF_ELEMENT_TTL: specifies the value of TTL field set at a
+ * source mesh point for path selection elements.
+@@ -1678,6 +1690,7 @@ enum nl80211_meshconf_params {
+ * element that vendors will use to identify the path selection methods and
+ * metrics in use.
+ *
++ * @NL80211_MESH_SETUP_ATTR_MAX: highest possible mesh setup attribute number
+ * @__NL80211_MESH_SETUP_ATTR_AFTER_LAST: Internal use
*/
-@@ -1682,6 +1768,7 @@ enum nl80211_key_attributes {
- NL80211_KEY_SEQ,
- NL80211_KEY_DEFAULT,
- NL80211_KEY_DEFAULT_MGMT,
-+ NL80211_KEY_TYPE,
-
- /* keep last */
- __NL80211_KEY_AFTER_LAST,
+ enum nl80211_mesh_setup_params {
--- /dev/null
+--- a/station.c
++++ b/station.c
+@@ -29,13 +29,43 @@ enum plink_actions {
+ PLINK_ACTION_BLOCK,
+ };
+
++static void print_sta_bitrate(struct nlattr *nla, const char *name)
++{
++ struct nlattr *rinfo[NL80211_RATE_INFO_MAX + 1];
++
++ static struct nla_policy rate_policy[NL80211_RATE_INFO_MAX + 1] = {
++ [NL80211_RATE_INFO_BITRATE] = { .type = NLA_U16 },
++ [NL80211_RATE_INFO_MCS] = { .type = NLA_U8 },
++ [NL80211_RATE_INFO_40_MHZ_WIDTH] = { .type = NLA_FLAG },
++ [NL80211_RATE_INFO_SHORT_GI] = { .type = NLA_FLAG },
++ };
++
++ if (!nla)
++ return;
++
++ if (nla_parse_nested(rinfo, NL80211_RATE_INFO_MAX, nla, rate_policy)) {
++ fprintf(stderr, "failed to parse nested rate attributes!\n");
++ } else {
++ printf("\n\t%s:\t", name);
++ if (rinfo[NL80211_RATE_INFO_BITRATE]) {
++ int rate = nla_get_u16(rinfo[NL80211_RATE_INFO_BITRATE]);
++ printf("%d.%d MBit/s", rate / 10, rate % 10);
++ }
++
++ if (rinfo[NL80211_RATE_INFO_MCS])
++ printf(" MCS %d", nla_get_u8(rinfo[NL80211_RATE_INFO_MCS]));
++ if (rinfo[NL80211_RATE_INFO_40_MHZ_WIDTH])
++ printf(" 40Mhz");
++ if (rinfo[NL80211_RATE_INFO_SHORT_GI])
++ printf(" short GI");
++ }
++}
+
+ static int print_sta_handler(struct nl_msg *msg, void *arg)
+ {
+ struct nlattr *tb[NL80211_ATTR_MAX + 1];
+ struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
+ struct nlattr *sinfo[NL80211_STA_INFO_MAX + 1];
+- struct nlattr *rinfo[NL80211_RATE_INFO_MAX + 1];
+ char mac_addr[20], state_name[10], dev[20];
+ static struct nla_policy stats_policy[NL80211_STA_INFO_MAX + 1] = {
+ [NL80211_STA_INFO_INACTIVE_TIME] = { .type = NLA_U32 },
+@@ -45,6 +75,7 @@ static int print_sta_handler(struct nl_m
+ [NL80211_STA_INFO_TX_PACKETS] = { .type = NLA_U32 },
+ [NL80211_STA_INFO_SIGNAL] = { .type = NLA_U8 },
+ [NL80211_STA_INFO_TX_BITRATE] = { .type = NLA_NESTED },
++ [NL80211_STA_INFO_RX_BITRATE] = { .type = NLA_NESTED },
+ [NL80211_STA_INFO_LLID] = { .type = NLA_U16 },
+ [NL80211_STA_INFO_PLID] = { .type = NLA_U16 },
+ [NL80211_STA_INFO_PLINK_STATE] = { .type = NLA_U8 },
+@@ -52,13 +83,6 @@ static int print_sta_handler(struct nl_m
+ [NL80211_STA_INFO_TX_FAILED] = { .type = NLA_U32 },
+ };
+
+- static struct nla_policy rate_policy[NL80211_RATE_INFO_MAX + 1] = {
+- [NL80211_RATE_INFO_BITRATE] = { .type = NLA_U16 },
+- [NL80211_RATE_INFO_MCS] = { .type = NLA_U8 },
+- [NL80211_RATE_INFO_40_MHZ_WIDTH] = { .type = NLA_FLAG },
+- [NL80211_RATE_INFO_SHORT_GI] = { .type = NLA_FLAG },
+- };
+-
+ nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
+ genlmsg_attrlen(gnlh, 0), NULL);
+
+@@ -111,25 +135,8 @@ static int print_sta_handler(struct nl_m
+ printf("\n\tsignal avg:\t%d dBm",
+ (int8_t)nla_get_u8(sinfo[NL80211_STA_INFO_SIGNAL_AVG]));
+
+- if (sinfo[NL80211_STA_INFO_TX_BITRATE]) {
+- if (nla_parse_nested(rinfo, NL80211_RATE_INFO_MAX,
+- sinfo[NL80211_STA_INFO_TX_BITRATE], rate_policy)) {
+- fprintf(stderr, "failed to parse nested rate attributes!\n");
+- } else {
+- printf("\n\ttx bitrate:\t");
+- if (rinfo[NL80211_RATE_INFO_BITRATE]) {
+- int rate = nla_get_u16(rinfo[NL80211_RATE_INFO_BITRATE]);
+- printf("%d.%d MBit/s", rate / 10, rate % 10);
+- }
+-
+- if (rinfo[NL80211_RATE_INFO_MCS])
+- printf(" MCS %d", nla_get_u8(rinfo[NL80211_RATE_INFO_MCS]));
+- if (rinfo[NL80211_RATE_INFO_40_MHZ_WIDTH])
+- printf(" 40Mhz");
+- if (rinfo[NL80211_RATE_INFO_SHORT_GI])
+- printf(" short GI");
+- }
+- }
++ print_sta_bitrate(sinfo[NL80211_STA_INFO_TX_BITRATE], "tx bitrate");
++ print_sta_bitrate(sinfo[NL80211_STA_INFO_RX_BITRATE], "rx bitrate");
+
+ if (sinfo[NL80211_STA_INFO_LLID])
+ printf("\n\tmesh llid:\t%d",
+++ /dev/null
---- a/survey.c
-+++ b/survey.c
-@@ -44,8 +44,9 @@ static int print_survey_handler(struct n
- }
-
- if (sinfo[NL80211_SURVEY_INFO_FREQUENCY])
-- printf("\tfrequency:\t%u MHz\n",
-- nla_get_u32(sinfo[NL80211_SURVEY_INFO_FREQUENCY]));
-+ printf("\tfrequency:\t%u MHz%s\n",
-+ nla_get_u32(sinfo[NL80211_SURVEY_INFO_FREQUENCY]),
-+ sinfo[NL80211_SURVEY_INFO_IN_USE] ? " [in use]" : "");
- if (sinfo[NL80211_SURVEY_INFO_NOISE])
- printf("\tnoise:\t\t%d dBm\n",
- (int8_t)nla_get_u8(sinfo[NL80211_SURVEY_INFO_NOISE]));
+++ /dev/null
---- a/survey.c
-+++ b/survey.c
-@@ -44,12 +44,27 @@ static int print_survey_handler(struct n
- }
-
- if (sinfo[NL80211_SURVEY_INFO_FREQUENCY])
-- printf("\tfrequency:\t%u MHz%s\n",
-+ printf("\tfrequency:\t\t\t%u MHz%s\n",
- nla_get_u32(sinfo[NL80211_SURVEY_INFO_FREQUENCY]),
- sinfo[NL80211_SURVEY_INFO_IN_USE] ? " [in use]" : "");
- if (sinfo[NL80211_SURVEY_INFO_NOISE])
-- printf("\tnoise:\t\t%d dBm\n",
-+ printf("\tnoise:\t\t\t\t%d dBm\n",
- (int8_t)nla_get_u8(sinfo[NL80211_SURVEY_INFO_NOISE]));
-+ if (sinfo[NL80211_SURVEY_INFO_CHANNEL_TIME])
-+ printf("\tchannel active time:\t\t%lld ms\n",
-+ (int64_t)nla_get_u64(sinfo[NL80211_SURVEY_INFO_CHANNEL_TIME]));
-+ if (sinfo[NL80211_SURVEY_INFO_CHANNEL_TIME_BUSY])
-+ printf("\tchannel busy time:\t\t%lld ms\n",
-+ (int64_t)nla_get_u64(sinfo[NL80211_SURVEY_INFO_CHANNEL_TIME_BUSY]));
-+ if (sinfo[NL80211_SURVEY_INFO_CHANNEL_TIME_EXT_BUSY])
-+ printf("\textension channel busy time:\t%lld ms\n",
-+ (int64_t)nla_get_u64(sinfo[NL80211_SURVEY_INFO_CHANNEL_TIME_EXT_BUSY]));
-+ if (sinfo[NL80211_SURVEY_INFO_CHANNEL_TIME_RX])
-+ printf("\tchannel receive time:\t\t%lld ms\n",
-+ (int64_t)nla_get_u64(sinfo[NL80211_SURVEY_INFO_CHANNEL_TIME_RX]));
-+ if (sinfo[NL80211_SURVEY_INFO_CHANNEL_TIME_TX])
-+ printf("\tchannel transmit time:\t\t%lld ms\n",
-+ (int64_t)nla_get_u64(sinfo[NL80211_SURVEY_INFO_CHANNEL_TIME_TX]));
- return NL_SKIP;
- }
-
+++ /dev/null
---- a/ibss.c
-+++ b/ibss.c
-@@ -83,6 +83,20 @@ static int join_ibss(struct nl80211_stat
- argc--;
- }
-
-+ /* multicast rate */
-+ if (argc > 1 && strcmp(argv[0], "mcast-rate") == 0) {
-+ argv++;
-+ argc--;
-+
-+ rate = strtod(argv[0], &end);
-+ if (*end != '\0')
-+ return 1;
-+
-+ NLA_PUT_U32(msg, NL80211_ATTR_MCAST_RATE, (int) rate * 10);
-+ argv++;
-+ argc--;
-+ }
-+
- if (!argc)
- return 0;
-
-@@ -109,7 +123,7 @@ COMMAND(ibss, leave, NULL,
- "Leave the current IBSS cell.");
- COMMAND(ibss, join,
- "<SSID> <freq in MHz> [fixed-freq] [<fixed bssid>] "
-- "[basic-rates <rate in Mbps,rate2,...>] [key d:0:abcde]",
-+ "[basic-rates <rate in Mbps,rate2,...>] [mcast-rate <rate in Mbps>] [key d:0:abcde]",
- NL80211_CMD_JOIN_IBSS, 0, CIB_NETDEV, join_ibss,
- "Join the IBSS cell with the given SSID, if it doesn't exist create\n"
- "it on the given frequency. When fixed frequency is requested, don't\n"
define KernelPackage/net-airo
SUBMENU:=$(WIRELESS_MENU)
TITLE:=Cisco Aironet driver
- DEPENDS:=@PCI_SUPPORT
+ DEPENDS:=@PCI_SUPPORT +@DRIVER_WEXT_SUPPORT
KCONFIG:=CONFIG_AIRO
FILES:=$(LINUX_DIR)/drivers/net/wireless/airo.$(LINUX_KMOD_SUFFIX)
AUTOLOAD:=$(call AutoLoad,50,airo)
define KernelPackage/net-hermes
SUBMENU:=$(WIRELESS_MENU)
TITLE:=Hermes 802.11b chipset support
- DEPENDS:=@LINUX_2_6 @PCI_SUPPORT||PCMCIA_SUPPORT
+ DEPENDS:=@LINUX_2_6 @PCI_SUPPORT||PCMCIA_SUPPORT +@DRIVER_WEXT_SUPPORT
KCONFIG:=CONFIG_HERMES \
CONFIG_HERMES_CACHE_FW_ON_INIT=n
FILES:= \
define KernelPackage/net-prism54
SUBMENU:=$(WIRELESS_MENU)
TITLE:=Intersil Prism54 support
- DEPENDS:=@PCI_SUPPORT
+ DEPENDS:=@PCI_SUPPORT +@DRIVER_WEXT_SUPPORT
KCONFIG:=CONFIG_PRISM54
FILES:=$(LINUX_DIR)/drivers/net/wireless/prism54/prism54.$(LINUX_KMOD_SUFFIX)
AUTOLOAD:=$(call AutoLoad,60,prism54)
PKG_NAME:=mac80211
-PKG_VERSION:=2011-02-25
+PKG_VERSION:=2011-03-24
PKG_RELEASE:=1
PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources
-PKG_MD5SUM:=c0242cc152a157902ff60fe05d1773b2
+PKG_MD5SUM:=f5713fb3ab59bdd3d0ce931b813ef960
PKG_SOURCE:=compat-wireless-$(PKG_VERSION).tar.bz2
PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/compat-wireless-$(PKG_VERSION)
PKG_BUILD_PARALLEL:=1
+PKG_DRIVERS = \
+ ath5k libertas-usb libertas-sd p54-common p54-pci p54-usb p54-spi \
+ rt2x00-lib rt2x00-pci rt2x00-usb rt2x00-soc rt2800-lib rt2400-pci \
+ rt2500-pci rt2500-usb rt61-pci rt73-usb rt2800-pci rt2800-usb \
+ rtl8180 rtl8187 zd1211rw mac80211-hwsim carl9170 b43 b43legacy \
+ ath9k-common ath9k ath9k-htc ath net-libipw net-ipw2100 net-ipw2200 \
+ mwl8k net-hermes net-hermes-pci net-hermes-plx net-hermes-pcmcia
+
PKG_CONFIG_DEPENDS:= \
CONFIG_PACKAGE_kmod-mac80211 \
+ $(patsubst %,CONFIG_PACKAGE_kmod-%,$(PKG_DRIVERS)) \
CONFIG_PACKAGE_MAC80211_DEBUGFS \
CONFIG_PACKAGE_ATH_DEBUG \
CONFIG_ATH_USER_REGD \
define KernelPackage/rt2800-lib
$(call KernelPackage/rt2x00/Default)
- DEPENDS+= @(PCI_SUPPORT||USB_SUPPORT||TARGET_ramips) +kmod-rt2x00-lib +USB_SUPPORT:kmod-rt2x00-usb +TARGET_ramips:kmod-rt2x00-soc
+ DEPENDS+= @(PCI_SUPPORT||USB_SUPPORT||TARGET_ramips) +kmod-rt2x00-lib +USB_SUPPORT:kmod-rt2x00-usb +TARGET_ramips:kmod-rt2x00-soc +@DRIVER_11N_SUPPORT
TITLE+= (rt2800 LIB)
FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt2800lib.ko
AUTOLOAD:=$(call AutoLoad,27,rt2800lib)
Atheros 5xxx chipset.
endef
-define KernelPackage/ath9k
+define KernelPackage/ath9k-common
$(call KernelPackage/mac80211/Default)
- TITLE:=Atheros 802.11n wireless cards support
+ TITLE:=Atheros 802.11n wireless devices (common code for ath9k and ath9k_htc)
URL:=http://linuxwireless.org/en/users/Drivers/ath9k
- DEPENDS+= @PCI_SUPPORT +kmod-ath
+ DEPENDS+= @PCI_SUPPORT +kmod-ath +@DRIVER_11N_SUPPORT
FILES:= \
$(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath9k/ath9k_common.ko \
- $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath9k/ath9k_hw.ko \
+ $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath9k/ath9k_hw.ko
+ AUTOLOAD:=$(call AutoLoad,27,ath9k_hw ath9k_common)
+endef
+
+define KernelPackage/ath9k
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Atheros 802.11n PCI wireless cards support
+ URL:=http://linuxwireless.org/en/users/Drivers/ath9k
+ DEPENDS+= @PCI_SUPPORT +kmod-ath9k-common
+ FILES:= \
$(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath9k/ath9k.ko
- AUTOLOAD:=$(call AutoLoad,27,ath9k_hw ath9k_common ath9k)
+ AUTOLOAD:=$(call AutoLoad,28,ath9k)
endef
define KernelPackage/ath9k/description
Atheros IEEE 802.11n AR5008 and AR9001 family of chipsets.
endef
+AR7010FW:=ar7010.fw
+AR7010_1_1_FW:=ar7010_1_1.fw
+AR9271FW:=ar9271.fw
+
+define Download/ar9271
+ FILE:=$(AR9271FW)
+ URL:=http://git.kernel.org/?p=linux/kernel/git/dwmw2/linux-firmware.git;a=blob_plain;f=ar9271.fw;h=d0ee74a1c8dccb7cc21f5be90f1d4048fa9dbf9e;hb=HEAD;?
+ MD5SUM:=2e6f5045ec4c5a42bb93ced242bad0ba
+endef
+$(eval $(call Download,ar9271))
+
+define Download/ar7010
+ FILE:=$(AR7010FW)
+ URL:=http://git.kernel.org/?p=linux/kernel/git/dwmw2/linux-firmware.git;a=blob_plain;f=ar7010.fw;h=840005d0f0c81838c581b8cd5d76c8dd3843731c;hb=HEAD;?
+ MD5SUM:=59823b82b1f72bed9b044e8cc78ad65c
+endef
+$(eval $(call Download,ar7010))
+
+define Download/ar7010_1_1
+ FILE:=$(AR7010_1_1_FW)
+ URL:=http://git.kernel.org/?p=linux/kernel/git/dwmw2/linux-firmware.git;a=blob_plain;f=ar7010_1_1.fw;h=684d4cd1a8cac4f58305589e31f9d856d03a8ef0;hb=HEAD;?
+ MD5SUM:=544fcbe5a93cfa53c7e6d3ded2b05347
+endef
+$(eval $(call Download,ar7010_1_1))
+
+define KernelPackage/ath9k-htc
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Atheros 802.11n USB device support
+ URL:=http://linuxwireless.org/en/users/Drivers/ath9k
+ DEPENDS+= @USB_SUPPORT +kmod-ath9k-common +kmod-usb-core
+ FILES:= \
+ $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath9k/ath9k_htc.ko
+ AUTOLOAD:=$(call AutoLoad,28,ath9k_htc)
+endef
+
+define KernelPackage/ath9k-htc/description
+This module adds support for wireless adapters based on
+Atheros USB AR9271 and AR7010 family of chipsets.
+endef
+
define KernelPackage/carl9170
$(call KernelPackage/mac80211/Default)
TITLE:=Driver for Atheros AR9170 USB sticks
- DEPENDS:=@USB_SUPPORT +kmod-mac80211 +kmod-ath +kmod-usb-core
+ DEPENDS:=@USB_SUPPORT +kmod-mac80211 +kmod-ath +kmod-usb-core +@DRIVER_11N_SUPPORT
FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ath/carl9170/carl9170.ko
AUTOLOAD:=$(call AutoLoad,60,carl9170)
endef
define KernelPackage/libertas-sd
$(call KernelPackage/mac80211/Default)
- DEPENDS+= +kmod-mac80211 +kmod-lib80211
+ DEPENDS+= +kmod-mac80211 +kmod-lib80211 +@DRIVER_WEXT_SUPPORT
TITLE:=Marvell 88W8686 Wireless Driver
FILES:= \
$(PKG_BUILD_DIR)/drivers/net/wireless/libertas/libertas.ko \
define KernelPackage/net-hermes
$(call KernelPackage/mac80211/Default)
TITLE:=Hermes 802.11b chipset support
- DEPENDS:=@PCI_SUPPORT||PCMCIA_SUPPORT +kmod-cfg80211
+ DEPENDS:=@PCI_SUPPORT||PCMCIA_SUPPORT +kmod-cfg80211 +@DRIVER_WEXT_SUPPORT
FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/orinoco/orinoco.ko
AUTOLOAD:=$(call AutoLoad,50,orinoco)
endef
CONFIG_ATH5K_PCI=$(if $(CONFIG_TARGET_atheros),,y) \
CONFIG_ATH5K_AHB=$(if $(CONFIG_TARGET_atheros),y) \
CONFIG_ATH9K=$(if $(CONFIG_PACKAGE_kmod-ath9k),m) \
- CONFIG_ATH9K_HW=$(if $(CONFIG_PACKAGE_kmod-ath9k),m) \
- CONFIG_ATH9K_COMMON=$(if $(CONFIG_PACKAGE_kmod-ath9k),m) \
+ CONFIG_ATH9K_HTC=$(if $(CONFIG_PACKAGE_kmod-ath9k-htc),m) \
+ CONFIG_ATH9K_HW=$(if $(CONFIG_PACKAGE_kmod-ath9k-common),m) \
+ CONFIG_ATH9K_COMMON=$(if $(CONFIG_PACKAGE_kmod-ath9k-common),m) \
CONFIG_ATH9K_DEBUGFS=$(if $(CONFIG_PACKAGE_MAC80211_DEBUGFS),y) \
CONFIG_CARL9170=$(if $(CONFIG_PACKAGE_kmod-carl9170),m) \
CONFIG_CARL9170_DEBUGFS=$(if $(CONFIG_PACKAGE_MAC80211_DEBUGFS),y) \
- CONFIG_ZD1211RW=$(if $(CONFIG_PACKAGE_kmod-zd1211rw),m) \
+ CONFIG_COMPAT_ZD1211RW=$(if $(CONFIG_PACKAGE_kmod-zd1211rw),m) \
CONFIG_P54_COMMON=$(if $(CONFIG_PACKAGE_kmod-p54-common),m) \
CONFIG_P54_PCI=$(if $(CONFIG_PACKAGE_kmod-p54-pci),m) \
CONFIG_P54_USB=$(if $(CONFIG_PACKAGE_kmod-p54-usb),m) \
CONFIG_AR9170_USB=$(if $(CONFIG_PACKAGE_kmod-ar9170),m) \
CONFIG_AR9170_LEDS=$(CONFIG_LEDS_TRIGGERS) \
CONFIG_IWM= \
- CONFIG_ATH9K_HTC= \
CONFIG_MAC80211_RC_MINSTREL_HT=y \
MADWIFI= \
OLD_IWL= \
$(INSTALL_DATA) $(DL_DIR)/$(AR9170FW) $(1)/lib/firmware/
endef
+define KernelPackage/ath9k-htc/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(INSTALL_DATA) \
+ $(DL_DIR)/$(AR9271FW) \
+ $(DL_DIR)/$(AR7010FW) \
+ $(DL_DIR)/$(AR7010_1_1_FW) \
+ $(1)/lib/firmware/
+endef
+
define KernelPackage/net-ipw2100/install
$(INSTALL_DIR) $(1)/lib/firmware
$(INSTALL_DATA) $(PKG_BUILD_DIR)/ipw2100-$(IPW2100_VERSION)*.fw $(1)/lib/firmware
$(eval $(call KernelPackage,rtl8187))
$(eval $(call KernelPackage,zd1211rw))
$(eval $(call KernelPackage,mac80211-hwsim))
+$(eval $(call KernelPackage,ath9k-common))
$(eval $(call KernelPackage,ath9k))
+$(eval $(call KernelPackage,ath9k-htc))
$(eval $(call KernelPackage,ath))
$(eval $(call KernelPackage,carl9170))
$(eval $(call KernelPackage,b43))
local ifname="$2"
cfgfile="/var/run/hostapd-$phy.conf"
+ macfile="/var/run/hostapd-$phy.maclist"
+ [ -e "$macfile" ] && rm -f "$macfile"
+
config_get device "$vif" device
config_get country "$device" country
config_get hwmode "$device" hwmode
config_get channel "$device" channel
+ config_get beacon_int "$device" beacon_int
+ config_get basic_rate_list "$device" basic_rate
config_get_bool noscan "$device" noscan
[ -n "$channel" -a -z "$hwmode" ] && wifi_fixup_hwmode "$device"
[ "$channel" = auto ] && channel=
[ -n "$ht_capab" ] && append base_cfg "ht_capab=$ht_capab" "$N"
}
}
- cat > "$cfgfile" <<EOF
+
+ config_get macfilter "$vif" macfilter
+ case "$macfilter" in
+ allow)
+ append base_cfg "macaddr_acl=1" "$N"
+ append base_cfg "accept_mac_file=$macfile" "$N"
+ ;;
+ deny)
+ append base_cfg "macaddr_acl=0" "$N"
+ append base_cfg "deny_mac_file=$macfile" "$N"
+ ;;
+ esac
+ config_get maclist "$vif" maclist
+ [ -n "$maclist" ] && {
+ for mac in $maclist; do
+ echo "$mac" >> $macfile
+ done
+ }
+
+ local br brval brstr
+ [ -n "$basic_rate_list" ] && {
+ for br in $basic_rate_list; do
+ brval="$(($br / 100))"
+ [ -n "$brstr" ] && brstr="$brstr "
+ brstr="$brstr$brval"
+ done
+ }
+
+ cat >> "$cfgfile" <<EOF
ctrl_interface=/var/run/hostapd-$phy
driver=nl80211
wmm_ac_bk_cwmin=4
tx_queue_data0_burst=1.5
${hwmode:+hw_mode=$hwmode}
${channel:+channel=$channel}
+${beacon_int:+beacon_int=$beacon_int}
${country:+country_code=$country}
${noscan:+noscan=$noscan}
+${brstr:+basic_rates=$brstr}
$base_cfg
EOF
config_get_bool wds "$vif" wds 0
[ "$wds" -gt 0 ] && append hostapd_cfg "wds_sta=1" "$N"
+ local macaddr hidden maxassoc wmm
config_get macaddr "$vif" macaddr
- config_get_bool hidden "$vif" hidden 0
config_get maxassoc "$vif" maxassoc
+ config_get dtim_period "$vif" dtim_period
+ config_get max_listen_int "$vif" max_listen_int
+ config_get_bool hidden "$vif" hidden 0
+ config_get_bool wmm "$vif" wmm 1
cat >> /var/run/hostapd-$phy.conf <<EOF
$hostapd_cfg
-wmm_enabled=1
+wmm_enabled=$wmm
bssid=$macaddr
ignore_broadcast_ssid=$hidden
+${dtim_period:+dtim_period=$dtim_period}
+${max_listen_int:+max_listen_interval=$max_listen_int}
${maxassoc:+max_num_sta=$maxassoc}
EOF
}
config_get txpower "$device" txpower
config_get country "$device" country
config_get distance "$device" distance
+ config_get txantenna "$device" txantenna all
+ config_get rxantenna "$device" rxantenna all
config_get frag "$device" frag
config_get rts "$device" rts
find_mac80211_phy "$device" || return 0
fixed=1
}
+ iw phy "$phy" set antenna $txantenna $rxantenna >/dev/null 2>&1
+
[ -n "$distance" ] && iw phy "$phy" set distance "$distance"
[ -n "$frag" ] && iw phy "$phy" set frag "${frag%%.*}"
[ -n "$rts" ] && iw phy "$phy" set rts "${rts%%.*}"
adhoc)
config_get bssid "$vif" bssid
config_get ssid "$vif" ssid
+ config_get beacon_int "$device" beacon_int
+ config_get basic_rate_list "$device" basic_rate
+ config_get encryption "$vif" encryption
+ config_get key "$vif" key 1
config_get mcast_rate "$vif" mcast_rate
+
+ local keyspec=""
+ [ "$encryption" == "wep" ] && {
+ case "$key" in
+ [1234])
+ local idx
+ for idx in 1 2 3 4; do
+ local ikey
+ config_get ikey "$vif" "key$idx"
+
+ [ -n "$ikey" ] && {
+ ikey="$(($idx - 1)):$(prepare_key_wep "$ikey")"
+ [ $idx -eq $key ] && ikey="d:$ikey"
+ append keyspec "$ikey"
+ }
+ done
+ ;;
+ *) append keyspec "d:0:$(prepare_key_wep "$key")" ;;
+ esac
+ }
+
+ local br brval brsub brstr
+ [ -n "$basic_rate_list" ] && {
+ for br in $basic_rate_list; do
+ brval="$(($br / 1000))"
+ brsub="$((($br / 100) % 10))"
+ [ "$brsub" -gt 0 ] && brval="$brval.$brsub"
+ [ -n "$brstr" ] && brstr="$brstr,"
+ brstr="$brstr$brval"
+ done
+ }
+
local mcval=""
[ -n "$mcast_rate" ] && {
mcval="$(($mcast_rate / 1000))"
mcsub="$(( ($mcast_rate / 100) % 10 ))"
[ "$mcsub" -gt 0 ] && mcval="$mcval.$mcsub"
}
- iw dev "$ifname" ibss join "$ssid" $freq ${fixed:+fixed-freq} $bssid ${mcval:+mcast-rate $mcval}
+
+ iw dev "$ifname" ibss join "$ssid" $freq \
+ ${fixed:+fixed-freq} $bssid \
+ ${beacon_int:+beacon-interval $beacon_int} \
+ ${brstr:+basic-rates $brstr} \
+ ${mcval:+mcast-rate $mcval} \
+ ${keyspec:+keys $keyspec}
;;
sta)
if eval "type wpa_supplicant_setup_vif" 2>/dev/null >/dev/null; then
}
-check_device() {
+check_mac80211_device() {
config_get phy "$1" phy
[ -z "$phy" ] && {
find_mac80211_phy "$1" >/dev/null || return 0
done
for dev in $(ls /sys/class/ieee80211); do
found=0
- config_foreach check_device wifi-device
+ config_foreach check_mac80211_device wifi-device
[ "$found" -gt 0 ] && continue
mode_11n=""
+++ /dev/null
---- a/include/linux/compat-2.6.36.h
-+++ b/include/linux/compat-2.6.36.h
-@@ -102,6 +102,8 @@ int no_printk(const char *s, ...) { retu
- #define alloc_workqueue(name, flags, max_active) __create_workqueue(name, flags, max_active, 0)
- #endif
-
-+#define PCI_EEPROM_WIDTH_93C86 8
-+
- #define EXTPROC 0200000
- #define TIOCPKT_IOCTL 64
-
--- /dev/null
+--- a/compat/compat-2.6.39.c
++++ b/compat/compat-2.6.39.c
+@@ -12,6 +12,7 @@
+ #include <linux/tty.h>
+ #include <linux/sched.h>
+
++#ifdef CONFIG_COMPAT_BLUETOOTH
+ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))
+ /*
+ * Termios Helper Methods
+@@ -111,4 +112,4 @@ int tty_set_termios(struct tty_struct *t
+ }
+ EXPORT_SYMBOL_GPL(tty_set_termios);
+ #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) */
+-
++#endif
+++ /dev/null
---- a/compat/compat-2.6.39.c
-+++ b/compat/compat-2.6.39.c
-@@ -10,6 +10,7 @@
-
- #include <linux/compat.h>
- #include <linux/tty.h>
-+#include <linux/sched.h>
-
- /*
- * Termios Helper Methods
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/debug.c
-+++ b/drivers/net/wireless/ath/ath9k/debug.c
-@@ -1091,6 +1091,12 @@ int ath9k_init_debug(struct ath_hw *ah)
- sc->debug.debugfs_phy, &ah->config.cwm_ignore_extcca))
- goto err;
-
-+ debugfs_create_u32("gpio_mask", S_IRUSR | S_IWUSR,
-+ sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask);
-+
-+ debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR,
-+ sc->debug.debugfs_phy, &sc->sc_ah->gpio_val);
-+
- sc->debug.regidx = 0;
- return 0;
- err:
---- a/drivers/net/wireless/ath/ath9k/hw.h
-+++ b/drivers/net/wireless/ath/ath9k/hw.h
-@@ -795,6 +795,8 @@ struct ath_hw {
- int initPDADC;
- int PDADCdelta;
- u8 led_pin;
-+ u32 gpio_mask;
-+ u32 gpio_val;
-
- struct ar5416IniArray iniModes;
- struct ar5416IniArray iniCommon;
---- a/drivers/net/wireless/ath/ath9k/hw.c
-+++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -1212,6 +1212,20 @@ static bool ath9k_hw_channel_change(stru
- return true;
- }
-
-+static void ath9k_hw_apply_gpio_override(struct ath_hw *ah)
-+{
-+ u32 gpio_mask = ah->gpio_mask;
-+ int i;
-+
-+ for (i = 0; gpio_mask; i++, gpio_mask >>= 1) {
-+ if (!(gpio_mask & 1))
-+ continue;
-+
-+ ath9k_hw_cfg_output(ah, i, AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
-+ ath9k_hw_set_gpio(ah, i, !!(ah->gpio_val & BIT(i)));
-+ }
-+}
-+
- bool ath9k_hw_check_alive(struct ath_hw *ah)
- {
- int count = 50;
-@@ -1500,6 +1514,8 @@ int ath9k_hw_reset(struct ath_hw *ah, st
- if (AR_SREV_9300_20_OR_LATER(ah))
- ar9003_hw_bb_watchdog_config(ah);
-
-+ ath9k_hw_apply_gpio_override(ah);
-+
- return 0;
- }
- EXPORT_SYMBOL(ath9k_hw_reset);
--- /dev/null
+--- a/drivers/net/wireless/ath/ath9k/main.c
++++ b/drivers/net/wireless/ath/ath9k/main.c
+@@ -1048,6 +1048,8 @@ static int ath9k_start(struct ieee80211_
+ "Starting driver with initial channel: %d MHz\n",
+ curchan->center_freq);
+
++ ath9k_ps_wakeup(sc);
++
+ mutex_lock(&sc->mutex);
+
+ /* setup initial channel */
+@@ -1143,6 +1145,8 @@ static int ath9k_start(struct ieee80211_
+ mutex_unlock:
+ mutex_unlock(&sc->mutex);
+
++ ath9k_ps_restore(sc);
++
+ return r;
+ }
+
+--- a/net/mac80211/ibss.c
++++ b/net/mac80211/ibss.c
+@@ -661,7 +661,6 @@ static void ieee80211_sta_find_ibss(stru
+ static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata,
+ struct sk_buff *req)
+ {
+- struct ieee80211_rx_status *rx_status = IEEE80211_SKB_RXCB(req);
+ struct ieee80211_mgmt *mgmt = (void *)req->data;
+ struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
+ struct ieee80211_local *local = sdata->local;
+@@ -685,7 +684,7 @@ static void ieee80211_rx_mgmt_probe_req(
+ mgmt->bssid, tx_last_beacon);
+ #endif /* CONFIG_MAC80211_IBSS_DEBUG */
+
+- if (!tx_last_beacon && !(rx_status->rx_flags & IEEE80211_RX_RA_MATCH))
++ if (!tx_last_beacon && is_multicast_ether_addr(mgmt->da))
+ return;
+
+ if (memcmp(mgmt->bssid, ifibss->bssid, ETH_ALEN) != 0 &&
+--- a/net/mac80211/rc80211_minstrel_ht.c
++++ b/net/mac80211/rc80211_minstrel_ht.c
+@@ -659,18 +659,14 @@ minstrel_ht_update_caps(void *priv, stru
+ struct ieee80211_mcs_info *mcs = &sta->ht_cap.mcs;
+ struct ieee80211_local *local = hw_to_local(mp->hw);
+ u16 sta_cap = sta->ht_cap.cap;
++ int n_supported = 0;
+ int ack_dur;
+ int stbc;
+ int i;
+
+ /* fall back to the old minstrel for legacy stations */
+- if (!sta->ht_cap.ht_supported) {
+- msp->is_ht = false;
+- memset(&msp->legacy, 0, sizeof(msp->legacy));
+- msp->legacy.r = msp->ratelist;
+- msp->legacy.sample_table = msp->sample_table;
+- return mac80211_minstrel.rate_init(priv, sband, sta, &msp->legacy);
+- }
++ if (!sta->ht_cap.ht_supported)
++ goto use_legacy;
+
+ BUILD_BUG_ON(ARRAY_SIZE(minstrel_mcs_groups) !=
+ MINSTREL_MAX_STREAMS * MINSTREL_STREAM_GROUPS);
+@@ -725,7 +721,22 @@ minstrel_ht_update_caps(void *priv, stru
+
+ mi->groups[i].supported =
+ mcs->rx_mask[minstrel_mcs_groups[i].streams - 1];
++
++ if (mi->groups[i].supported)
++ n_supported++;
+ }
++
++ if (!n_supported)
++ goto use_legacy;
++
++ return;
++
++use_legacy:
++ msp->is_ht = false;
++ memset(&msp->legacy, 0, sizeof(msp->legacy));
++ msp->legacy.r = msp->ratelist;
++ msp->legacy.sample_table = msp->sample_table;
++ return mac80211_minstrel.rate_init(priv, sband, sta, &msp->legacy);
+ }
+
+ static void
+--- a/net/mac80211/ieee80211_i.h
++++ b/net/mac80211/ieee80211_i.h
+@@ -814,8 +814,8 @@ struct ieee80211_local {
+
+ struct rate_control_ref *rate_ctrl;
+
+- struct crypto_blkcipher *wep_tx_tfm;
+- struct crypto_blkcipher *wep_rx_tfm;
++ struct crypto_cipher *wep_tx_tfm;
++ struct crypto_cipher *wep_rx_tfm;
+ u32 wep_iv;
+
+ /* see iface.c */
+--- a/net/mac80211/tkip.c
++++ b/net/mac80211/tkip.c
+@@ -202,7 +202,7 @@ EXPORT_SYMBOL(ieee80211_get_tkip_key);
+ * @payload_len is the length of payload (_not_ including IV/ICV length).
+ * @ta is the transmitter addresses.
+ */
+-int ieee80211_tkip_encrypt_data(struct crypto_blkcipher *tfm,
++int ieee80211_tkip_encrypt_data(struct crypto_cipher *tfm,
+ struct ieee80211_key *key,
+ u8 *pos, size_t payload_len, u8 *ta)
+ {
+@@ -223,7 +223,7 @@ int ieee80211_tkip_encrypt_data(struct c
+ * beginning of the buffer containing IEEE 802.11 header payload, i.e.,
+ * including IV, Ext. IV, real data, Michael MIC, ICV. @payload_len is the
+ * length of payload, including IV, Ext. IV, MIC, ICV. */
+-int ieee80211_tkip_decrypt_data(struct crypto_blkcipher *tfm,
++int ieee80211_tkip_decrypt_data(struct crypto_cipher *tfm,
+ struct ieee80211_key *key,
+ u8 *payload, size_t payload_len, u8 *ta,
+ u8 *ra, int only_iv, int queue,
+--- a/net/mac80211/tkip.h
++++ b/net/mac80211/tkip.h
+@@ -15,7 +15,7 @@
+
+ u8 *ieee80211_tkip_add_iv(u8 *pos, struct ieee80211_key *key, u16 iv16);
+
+-int ieee80211_tkip_encrypt_data(struct crypto_blkcipher *tfm,
++int ieee80211_tkip_encrypt_data(struct crypto_cipher *tfm,
+ struct ieee80211_key *key,
+ u8 *pos, size_t payload_len, u8 *ta);
+ enum {
+@@ -24,7 +24,7 @@ enum {
+ TKIP_DECRYPT_INVALID_KEYIDX = -2,
+ TKIP_DECRYPT_REPLAY = -3,
+ };
+-int ieee80211_tkip_decrypt_data(struct crypto_blkcipher *tfm,
++int ieee80211_tkip_decrypt_data(struct crypto_cipher *tfm,
+ struct ieee80211_key *key,
+ u8 *payload, size_t payload_len, u8 *ta,
+ u8 *ra, int only_iv, int queue,
+--- a/net/mac80211/wep.c
++++ b/net/mac80211/wep.c
+@@ -30,17 +30,15 @@ int ieee80211_wep_init(struct ieee80211_
+ /* start WEP IV from a random value */
+ get_random_bytes(&local->wep_iv, WEP_IV_LEN);
+
+- local->wep_tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0,
+- CRYPTO_ALG_ASYNC);
++ local->wep_tx_tfm = crypto_alloc_cipher("arc4", 0, CRYPTO_ALG_ASYNC);
+ if (IS_ERR(local->wep_tx_tfm)) {
+ local->wep_rx_tfm = ERR_PTR(-EINVAL);
+ return PTR_ERR(local->wep_tx_tfm);
+ }
+
+- local->wep_rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0,
+- CRYPTO_ALG_ASYNC);
++ local->wep_rx_tfm = crypto_alloc_cipher("arc4", 0, CRYPTO_ALG_ASYNC);
+ if (IS_ERR(local->wep_rx_tfm)) {
+- crypto_free_blkcipher(local->wep_tx_tfm);
++ crypto_free_cipher(local->wep_tx_tfm);
+ local->wep_tx_tfm = ERR_PTR(-EINVAL);
+ return PTR_ERR(local->wep_rx_tfm);
+ }
+@@ -51,9 +49,9 @@ int ieee80211_wep_init(struct ieee80211_
+ void ieee80211_wep_free(struct ieee80211_local *local)
+ {
+ if (!IS_ERR(local->wep_tx_tfm))
+- crypto_free_blkcipher(local->wep_tx_tfm);
++ crypto_free_cipher(local->wep_tx_tfm);
+ if (!IS_ERR(local->wep_rx_tfm))
+- crypto_free_blkcipher(local->wep_rx_tfm);
++ crypto_free_cipher(local->wep_rx_tfm);
+ }
+
+ static inline bool ieee80211_wep_weak_iv(u32 iv, int keylen)
+@@ -127,12 +125,11 @@ static void ieee80211_wep_remove_iv(stru
+ /* Perform WEP encryption using given key. data buffer must have tailroom
+ * for 4-byte ICV. data_len must not include this ICV. Note: this function
+ * does _not_ add IV. data = RC4(data | CRC32(data)) */
+-int ieee80211_wep_encrypt_data(struct crypto_blkcipher *tfm, u8 *rc4key,
++int ieee80211_wep_encrypt_data(struct crypto_cipher *tfm, u8 *rc4key,
+ size_t klen, u8 *data, size_t data_len)
+ {
+- struct blkcipher_desc desc = { .tfm = tfm };
+- struct scatterlist sg;
+ __le32 icv;
++ int i;
+
+ if (IS_ERR(tfm))
+ return -1;
+@@ -140,9 +137,9 @@ int ieee80211_wep_encrypt_data(struct cr
+ icv = cpu_to_le32(~crc32_le(~0, data, data_len));
+ put_unaligned(icv, (__le32 *)(data + data_len));
+
+- crypto_blkcipher_setkey(tfm, rc4key, klen);
+- sg_init_one(&sg, data, data_len + WEP_ICV_LEN);
+- crypto_blkcipher_encrypt(&desc, &sg, &sg, sg.length);
++ crypto_cipher_setkey(tfm, rc4key, klen);
++ for (i = 0; i < data_len + WEP_ICV_LEN; i++)
++ crypto_cipher_encrypt_one(tfm, data + i, data + i);
+
+ return 0;
+ }
+@@ -186,19 +183,18 @@ int ieee80211_wep_encrypt(struct ieee802
+ /* Perform WEP decryption using given key. data buffer includes encrypted
+ * payload, including 4-byte ICV, but _not_ IV. data_len must not include ICV.
+ * Return 0 on success and -1 on ICV mismatch. */
+-int ieee80211_wep_decrypt_data(struct crypto_blkcipher *tfm, u8 *rc4key,
++int ieee80211_wep_decrypt_data(struct crypto_cipher *tfm, u8 *rc4key,
+ size_t klen, u8 *data, size_t data_len)
+ {
+- struct blkcipher_desc desc = { .tfm = tfm };
+- struct scatterlist sg;
+ __le32 crc;
++ int i;
+
+ if (IS_ERR(tfm))
+ return -1;
+
+- crypto_blkcipher_setkey(tfm, rc4key, klen);
+- sg_init_one(&sg, data, data_len + WEP_ICV_LEN);
+- crypto_blkcipher_decrypt(&desc, &sg, &sg, sg.length);
++ crypto_cipher_setkey(tfm, rc4key, klen);
++ for (i = 0; i < data_len + WEP_ICV_LEN; i++)
++ crypto_cipher_decrypt_one(tfm, data + i, data + i);
+
+ crc = cpu_to_le32(~crc32_le(~0, data, data_len));
+ if (memcmp(&crc, data + data_len, WEP_ICV_LEN) != 0)
+--- a/net/mac80211/wep.h
++++ b/net/mac80211/wep.h
+@@ -18,12 +18,12 @@
+
+ int ieee80211_wep_init(struct ieee80211_local *local);
+ void ieee80211_wep_free(struct ieee80211_local *local);
+-int ieee80211_wep_encrypt_data(struct crypto_blkcipher *tfm, u8 *rc4key,
++int ieee80211_wep_encrypt_data(struct crypto_cipher *tfm, u8 *rc4key,
+ size_t klen, u8 *data, size_t data_len);
+ int ieee80211_wep_encrypt(struct ieee80211_local *local,
+ struct sk_buff *skb,
+ const u8 *key, int keylen, int keyidx);
+-int ieee80211_wep_decrypt_data(struct crypto_blkcipher *tfm, u8 *rc4key,
++int ieee80211_wep_decrypt_data(struct crypto_cipher *tfm, u8 *rc4key,
+ size_t klen, u8 *data, size_t data_len);
+ bool ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key);
+
--- a/drivers/net/wireless/ath/ath9k/gpio.c
+++ b/drivers/net/wireless/ath/ath9k/gpio.c
-@@ -120,6 +120,9 @@ static void ath_unregister_led(struct at
-
- void ath_deinit_leds(struct ath_softc *sc)
+@@ -41,6 +41,9 @@ void ath_init_leds(struct ath_softc *sc)
{
-+ if (AR_SREV_9100(sc->sc_ah))
-+ return;
-+
- ath_unregister_led(&sc->assoc_led);
- sc->sc_flags &= ~SC_OP_LED_ASSOCIATED;
- ath_unregister_led(&sc->tx_led);
-@@ -133,6 +136,9 @@ void ath_init_leds(struct ath_softc *sc)
- char *trigger;
int ret;
+ if (AR_SREV_9100(sc->sc_ah))
+ return;
+
- if (AR_SREV_9287(sc->sc_ah))
- sc->sc_ah->led_pin = ATH_LED_PIN_9287;
- else
+ if (sc->sc_ah->led_pin < 0) {
+ if (AR_SREV_9287(sc->sc_ah))
+ sc->sc_ah->led_pin = ATH_LED_PIN_9287;
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
-@@ -33,7 +33,7 @@ int ath9k_modparam_nohwcrypt;
+@@ -34,7 +34,7 @@ int ath9k_modparam_nohwcrypt;
module_param_named(nohwcrypt, ath9k_modparam_nohwcrypt, int, 0444);
MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption");
#include <asm/unaligned.h>
#include "hw.h"
-@@ -431,8 +432,16 @@ static int ath9k_hw_init_macaddr(struct
+@@ -442,8 +443,16 @@ static int ath9k_hw_init_macaddr(struct
common->macaddr[2 * i] = eeval >> 8;
common->macaddr[2 * i + 1] = eeval & 0xff;
}
+++ /dev/null
---- a/include/linux/ath9k_platform.h
-+++ b/include/linux/ath9k_platform.h
-@@ -23,6 +23,7 @@
-
- struct ath9k_platform_data {
- u16 eeprom_data[ATH9K_PLAT_EEP_MAX_WORDS];
-+ u8 *macaddr;
- };
-
- #endif /* _LINUX_ATH9K_PLATFORM_H */
---- a/drivers/net/wireless/ath/ath9k/init.c
-+++ b/drivers/net/wireless/ath/ath9k/init.c
-@@ -15,6 +15,7 @@
- */
-
- #include <linux/slab.h>
-+#include <linux/ath9k_platform.h>
-
- #include "ath9k.h"
-
-@@ -522,6 +523,7 @@ static void ath9k_init_misc(struct ath_s
- static int ath9k_init_softc(u16 devid, struct ath_softc *sc, u16 subsysid,
- const struct ath_bus_ops *bus_ops)
- {
-+ struct ath9k_platform_data *pdata = sc->dev->platform_data;
- struct ath_hw *ah = NULL;
- struct ath_common *common;
- int ret = 0, i;
-@@ -536,7 +538,7 @@ static int ath9k_init_softc(u16 devid, s
- ah->hw_version.subsysid = subsysid;
- sc->sc_ah = ah;
-
-- if (!sc->dev->platform_data)
-+ if (!pdata)
- ah->ah_flags |= AH_USE_EEPROM;
-
- common = ath9k_hw_common(ah);
-@@ -572,6 +574,9 @@ static int ath9k_init_softc(u16 devid, s
- if (ret)
- goto err_hw;
-
-+ if (pdata && pdata->macaddr)
-+ memcpy(common->macaddr, pdata->macaddr, ETH_ALEN);
-+
- ret = ath9k_init_queues(sc);
- if (ret)
- goto err_queues;
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/init.c
-+++ b/drivers/net/wireless/ath/ath9k/init.c
-@@ -538,8 +538,14 @@ static int ath9k_init_softc(u16 devid, s
- ah->hw_version.subsysid = subsysid;
- sc->sc_ah = ah;
-
-- if (!pdata)
-+ if (!pdata) {
- ah->ah_flags |= AH_USE_EEPROM;
-+ sc->sc_ah->led_pin = -1;
-+ } else {
-+ sc->sc_ah->gpio_mask = pdata->gpio_mask;
-+ sc->sc_ah->gpio_val = pdata->gpio_val;
-+ sc->sc_ah->led_pin = pdata->led_pin;
-+ }
-
- common = ath9k_hw_common(ah);
- common->ops = &ath9k_common_ops;
---- a/drivers/net/wireless/ath/ath9k/hw.h
-+++ b/drivers/net/wireless/ath/ath9k/hw.h
-@@ -794,7 +794,7 @@ struct ath_hw {
- u32 originalGain[22];
- int initPDADC;
- int PDADCdelta;
-- u8 led_pin;
-+ int led_pin;
- u32 gpio_mask;
- u32 gpio_val;
-
---- a/drivers/net/wireless/ath/ath9k/gpio.c
-+++ b/drivers/net/wireless/ath/ath9k/gpio.c
-@@ -139,10 +139,12 @@ void ath_init_leds(struct ath_softc *sc)
- if (AR_SREV_9100(sc->sc_ah))
- return;
-
-- if (AR_SREV_9287(sc->sc_ah))
-- sc->sc_ah->led_pin = ATH_LED_PIN_9287;
-- else
-- sc->sc_ah->led_pin = ATH_LED_PIN_DEF;
-+ if (sc->sc_ah->led_pin < 0) {
-+ if (AR_SREV_9287(sc->sc_ah))
-+ sc->sc_ah->led_pin = ATH_LED_PIN_9287;
-+ else
-+ sc->sc_ah->led_pin = ATH_LED_PIN_DEF;
-+ }
-
- /* Configure gpio 1 for output */
- ath9k_hw_cfg_output(sc->sc_ah, sc->sc_ah->led_pin,
---- a/include/linux/ath9k_platform.h
-+++ b/include/linux/ath9k_platform.h
-@@ -24,6 +24,10 @@
- struct ath9k_platform_data {
- u16 eeprom_data[ATH9K_PLAT_EEP_MAX_WORDS];
- u8 *macaddr;
-+
-+ int led_pin;
-+ u32 gpio_mask;
-+ u32 gpio_val;
- };
-
- #endif /* _LINUX_ATH9K_PLATFORM_H */
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
-@@ -1027,6 +1027,53 @@ static const struct file_operations fops
- .llseek = default_llseek,
+@@ -1077,6 +1077,53 @@ static const struct file_operations fops
+ .llseek = default_llseek,/* read accesses f_pos */
};
+static ssize_t read_file_eeprom(struct file *file, char __user *user_buf,
int ath9k_init_debug(struct ath_hw *ah)
{
struct ath_common *common = ath9k_hw_common(ah);
-@@ -1097,6 +1144,10 @@ int ath9k_init_debug(struct ath_hw *ah)
+@@ -1125,6 +1172,9 @@ int ath9k_init_debug(struct ath_hw *ah)
debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR,
sc->debug.debugfs_phy, &sc->sc_ah->gpio_val);
-+ if (!debugfs_create_file("eeprom", S_IRUSR,
-+ sc->debug.debugfs_phy, sc, &fops_eeprom))
-+ goto err;
++ debugfs_create_file("eeprom", S_IRUSR, sc->debug.debugfs_phy, sc,
++ &fops_eeprom);
+
sc->debug.regidx = 0;
return 0;
- err:
+ }
--- /dev/null
+--- a/drivers/net/wireless/ath/ath9k/hw.c
++++ b/drivers/net/wireless/ath/ath9k/hw.c
+@@ -1465,8 +1465,8 @@ int ath9k_hw_reset(struct ath_hw *ah, st
+ REG_WRITE(ah, AR_OBS, 8);
+
+ if (ah->config.rx_intr_mitigation) {
+- REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_LAST, 500);
+- REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_FIRST, 2000);
++ REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_LAST, 250);
++ REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_FIRST, 500);
+ }
+
+ if (ah->config.tx_intr_mitigation) {
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/ath9k.h
-+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
-@@ -449,26 +449,20 @@ void ath9k_btcoex_timer_pause(struct ath
-
- #define ATH_LED_PIN_DEF 1
- #define ATH_LED_PIN_9287 8
--#define ATH_LED_ON_DURATION_IDLE 350 /* in msecs */
--#define ATH_LED_OFF_DURATION_IDLE 250 /* in msecs */
--
--enum ath_led_type {
-- ATH_LED_RADIO,
-- ATH_LED_ASSOC,
-- ATH_LED_TX,
-- ATH_LED_RX
--};
--
--struct ath_led {
-- struct ath_softc *sc;
-- struct led_classdev led_cdev;
-- enum ath_led_type led_type;
-- char name[32];
-- bool registered;
--};
-
-+#ifdef CONFIG_MAC80211_LEDS
- void ath_init_leds(struct ath_softc *sc);
- void ath_deinit_leds(struct ath_softc *sc);
-+#else
-+static inline void ath_init_leds(struct ath_softc *sc)
-+{
-+}
-+
-+static inline void ath_deinit_leds(struct ath_softc *sc)
-+{
-+}
-+#endif
-+
-
- /* Antenna diversity/combining */
- #define ATH_ANT_RX_CURRENT_SHIFT 4
-@@ -620,15 +614,11 @@ struct ath_softc {
- struct ath_beacon beacon;
- struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS];
-
-- struct ath_led radio_led;
-- struct ath_led assoc_led;
-- struct ath_led tx_led;
-- struct ath_led rx_led;
-- struct delayed_work ath_led_blink_work;
-- int led_on_duration;
-- int led_off_duration;
-- int led_on_cnt;
-- int led_off_cnt;
-+#ifdef CONFIG_MAC80211_LEDS
-+ bool led_registered;
-+ char led_name[32];
-+ struct led_classdev led_cdev;
-+#endif
-
- struct ath9k_hw_cal_data caldata;
- int last_rssi;
---- a/drivers/net/wireless/ath/ath9k/gpio.c
-+++ b/drivers/net/wireless/ath/ath9k/gpio.c
-@@ -20,120 +20,25 @@
- /* LED functions */
- /********************************/
-
--static void ath_led_blink_work(struct work_struct *work)
--{
-- struct ath_softc *sc = container_of(work, struct ath_softc,
-- ath_led_blink_work.work);
--
-- if (!(sc->sc_flags & SC_OP_LED_ASSOCIATED))
-- return;
--
-- if ((sc->led_on_duration == ATH_LED_ON_DURATION_IDLE) ||
-- (sc->led_off_duration == ATH_LED_OFF_DURATION_IDLE))
-- ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 0);
-- else
-- ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin,
-- (sc->sc_flags & SC_OP_LED_ON) ? 1 : 0);
--
-- ieee80211_queue_delayed_work(sc->hw,
-- &sc->ath_led_blink_work,
-- (sc->sc_flags & SC_OP_LED_ON) ?
-- msecs_to_jiffies(sc->led_off_duration) :
-- msecs_to_jiffies(sc->led_on_duration));
--
-- sc->led_on_duration = sc->led_on_cnt ?
-- max((ATH_LED_ON_DURATION_IDLE - sc->led_on_cnt), 25) :
-- ATH_LED_ON_DURATION_IDLE;
-- sc->led_off_duration = sc->led_off_cnt ?
-- max((ATH_LED_OFF_DURATION_IDLE - sc->led_off_cnt), 10) :
-- ATH_LED_OFF_DURATION_IDLE;
-- sc->led_on_cnt = sc->led_off_cnt = 0;
-- if (sc->sc_flags & SC_OP_LED_ON)
-- sc->sc_flags &= ~SC_OP_LED_ON;
-- else
-- sc->sc_flags |= SC_OP_LED_ON;
--}
--
-+#ifdef CONFIG_MAC80211_LEDS
- static void ath_led_brightness(struct led_classdev *led_cdev,
- enum led_brightness brightness)
- {
-- struct ath_led *led = container_of(led_cdev, struct ath_led, led_cdev);
-- struct ath_softc *sc = led->sc;
--
-- switch (brightness) {
-- case LED_OFF:
-- if (led->led_type == ATH_LED_ASSOC ||
-- led->led_type == ATH_LED_RADIO) {
-- ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin,
-- (led->led_type == ATH_LED_RADIO));
-- sc->sc_flags &= ~SC_OP_LED_ASSOCIATED;
-- if (led->led_type == ATH_LED_RADIO)
-- sc->sc_flags &= ~SC_OP_LED_ON;
-- } else {
-- sc->led_off_cnt++;
-- }
-- break;
-- case LED_FULL:
-- if (led->led_type == ATH_LED_ASSOC) {
-- sc->sc_flags |= SC_OP_LED_ASSOCIATED;
-- if (led_blink)
-- ieee80211_queue_delayed_work(sc->hw,
-- &sc->ath_led_blink_work, 0);
-- } else if (led->led_type == ATH_LED_RADIO) {
-- ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 0);
-- sc->sc_flags |= SC_OP_LED_ON;
-- } else {
-- sc->led_on_cnt++;
-- }
-- break;
-- default:
-- break;
-- }
--}
--
--static int ath_register_led(struct ath_softc *sc, struct ath_led *led,
-- char *trigger)
--{
-- int ret;
--
-- led->sc = sc;
-- led->led_cdev.name = led->name;
-- led->led_cdev.default_trigger = trigger;
-- led->led_cdev.brightness_set = ath_led_brightness;
--
-- ret = led_classdev_register(wiphy_dev(sc->hw->wiphy), &led->led_cdev);
-- if (ret)
-- ath_err(ath9k_hw_common(sc->sc_ah),
-- "Failed to register led:%s", led->name);
-- else
-- led->registered = 1;
-- return ret;
--}
--
--static void ath_unregister_led(struct ath_led *led)
--{
-- if (led->registered) {
-- led_classdev_unregister(&led->led_cdev);
-- led->registered = 0;
-- }
-+ struct ath_softc *sc = container_of(led_cdev, struct ath_softc, led_cdev);
-+ ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, (brightness == LED_OFF));
- }
-
- void ath_deinit_leds(struct ath_softc *sc)
- {
-- if (AR_SREV_9100(sc->sc_ah))
-+ if (!sc->led_registered)
- return;
-
-- ath_unregister_led(&sc->assoc_led);
-- sc->sc_flags &= ~SC_OP_LED_ASSOCIATED;
-- ath_unregister_led(&sc->tx_led);
-- ath_unregister_led(&sc->rx_led);
-- ath_unregister_led(&sc->radio_led);
-- ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 1);
-+ ath_led_brightness(&sc->led_cdev, LED_OFF);
-+ led_classdev_unregister(&sc->led_cdev);
- }
-
- void ath_init_leds(struct ath_softc *sc)
- {
-- char *trigger;
- int ret;
-
- if (AR_SREV_9100(sc->sc_ah))
-@@ -152,48 +57,22 @@ void ath_init_leds(struct ath_softc *sc)
- /* LED off, active low */
- ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 1);
-
-- if (led_blink)
-- INIT_DELAYED_WORK(&sc->ath_led_blink_work, ath_led_blink_work);
-+ if (!led_blink)
-+ sc->led_cdev.default_trigger =
-+ ieee80211_get_radio_led_name(sc->hw);
-+
-+ snprintf(sc->led_name, sizeof(sc->led_name),
-+ "ath9k-%s", wiphy_name(sc->hw->wiphy));
-+ sc->led_cdev.name = sc->led_name;
-+ sc->led_cdev.brightness_set = ath_led_brightness;
-+
-+ ret = led_classdev_register(wiphy_dev(sc->hw->wiphy), &sc->led_cdev);
-+ if (ret < 0)
-+ return;
-
-- trigger = ieee80211_get_radio_led_name(sc->hw);
-- snprintf(sc->radio_led.name, sizeof(sc->radio_led.name),
-- "ath9k-%s::radio", wiphy_name(sc->hw->wiphy));
-- ret = ath_register_led(sc, &sc->radio_led, trigger);
-- sc->radio_led.led_type = ATH_LED_RADIO;
-- if (ret)
-- goto fail;
--
-- trigger = ieee80211_get_assoc_led_name(sc->hw);
-- snprintf(sc->assoc_led.name, sizeof(sc->assoc_led.name),
-- "ath9k-%s::assoc", wiphy_name(sc->hw->wiphy));
-- ret = ath_register_led(sc, &sc->assoc_led, trigger);
-- sc->assoc_led.led_type = ATH_LED_ASSOC;
-- if (ret)
-- goto fail;
--
-- trigger = ieee80211_get_tx_led_name(sc->hw);
-- snprintf(sc->tx_led.name, sizeof(sc->tx_led.name),
-- "ath9k-%s::tx", wiphy_name(sc->hw->wiphy));
-- ret = ath_register_led(sc, &sc->tx_led, trigger);
-- sc->tx_led.led_type = ATH_LED_TX;
-- if (ret)
-- goto fail;
--
-- trigger = ieee80211_get_rx_led_name(sc->hw);
-- snprintf(sc->rx_led.name, sizeof(sc->rx_led.name),
-- "ath9k-%s::rx", wiphy_name(sc->hw->wiphy));
-- ret = ath_register_led(sc, &sc->rx_led, trigger);
-- sc->rx_led.led_type = ATH_LED_RX;
-- if (ret)
-- goto fail;
--
-- return;
--
--fail:
-- if (led_blink)
-- cancel_delayed_work_sync(&sc->ath_led_blink_work);
-- ath_deinit_leds(sc);
-+ sc->led_registered = true;
- }
-+#endif
-
- /*******************/
- /* Rfkill */
---- a/drivers/net/wireless/ath/ath9k/main.c
-+++ b/drivers/net/wireless/ath/ath9k/main.c
-@@ -1216,9 +1216,6 @@ static void ath9k_stop(struct ieee80211_
-
- mutex_lock(&sc->mutex);
-
-- if (led_blink)
-- cancel_delayed_work_sync(&sc->ath_led_blink_work);
--
- cancel_delayed_work_sync(&sc->tx_complete_work);
- cancel_delayed_work_sync(&sc->hw_pll_work);
- cancel_work_sync(&sc->paprd_work);
---- a/drivers/net/wireless/ath/ath9k/init.c
-+++ b/drivers/net/wireless/ath/ath9k/init.c
-@@ -141,6 +141,21 @@ static struct ieee80211_rate ath9k_legac
- RATE(540, 0x0c, 0),
- };
-
-+#ifdef CONFIG_MAC80211_LEDS
-+static const struct ieee80211_tpt_blink ath9k_tpt_blink[] = {
-+ { .throughput = 0 * 1024, .blink_time = 334 },
-+ { .throughput = 1 * 1024, .blink_time = 260 },
-+ { .throughput = 5 * 1024, .blink_time = 220 },
-+ { .throughput = 10 * 1024, .blink_time = 190 },
-+ { .throughput = 20 * 1024, .blink_time = 170 },
-+ { .throughput = 50 * 1024, .blink_time = 150 },
-+ { .throughput = 70 * 1024, .blink_time = 130 },
-+ { .throughput = 100 * 1024, .blink_time = 110 },
-+ { .throughput = 200 * 1024, .blink_time = 80 },
-+ { .throughput = 300 * 1024, .blink_time = 50 },
-+};
-+#endif
-+
- static void ath9k_deinit_softc(struct ath_softc *sc);
-
- /*
-@@ -742,6 +757,13 @@ int ath9k_init_device(u16 devid, struct
-
- ath9k_init_txpower_limits(sc);
-
-+#ifdef CONFIG_MAC80211_LEDS
-+ /* must be initialized before ieee80211_register_hw */
-+ sc->led_cdev.default_trigger = ieee80211_create_tpt_led_trigger(sc->hw,
-+ IEEE80211_TPT_LEDTRIG_FL_RADIO, ath9k_tpt_blink,
-+ ARRAY_SIZE(ath9k_tpt_blink));
-+#endif
-+
- /* Register with mac80211 */
- error = ieee80211_register_hw(hw);
- if (error)
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/hw.c
-+++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -1466,8 +1466,8 @@ int ath9k_hw_reset(struct ath_hw *ah, st
- REG_WRITE(ah, AR_OBS, 8);
-
- if (ah->config.rx_intr_mitigation) {
-- REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_LAST, 500);
-- REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_FIRST, 2000);
-+ REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_LAST, 250);
-+ REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_FIRST, 500);
- }
-
- if (ah->config.tx_intr_mitigation) {
--- /dev/null
+--- a/include/net/mac80211.h
++++ b/include/net/mac80211.h
+@@ -2216,6 +2216,18 @@ static inline int ieee80211_sta_ps_trans
+ #define IEEE80211_TX_STATUS_HEADROOM 13
+
+ /**
++ * ieee80211_sta_set_tim - set the TIM bit for a sleeping station
++ *
++ * If a driver buffers frames for a powersave station instead of passing
++ * them back to mac80211 for retransmission, the station needs to be told
++ * to wake up using the TIM bitmap in the beacon.
++ *
++ * This function sets the station's TIM bit - it will be cleared when the
++ * station wakes up.
++ */
++void ieee80211_sta_set_tim(struct ieee80211_sta *sta);
++
++/**
+ * ieee80211_tx_status - transmit status callback
+ *
+ * Call this function for all transmitted frames after they have been
+--- a/net/mac80211/sta_info.c
++++ b/net/mac80211/sta_info.c
+@@ -609,7 +609,8 @@ static bool sta_info_cleanup_expire_buff
+ #endif
+ dev_kfree_skb(skb);
+
+- if (skb_queue_empty(&sta->ps_tx_buf))
++ if (skb_queue_empty(&sta->ps_tx_buf) &&
++ !test_sta_flags(sta, WLAN_STA_PS_DRIVER_BUF))
+ sta_info_clear_tim_bit(sta);
+ }
+
+@@ -902,6 +903,7 @@ void ieee80211_sta_ps_deliver_wakeup(str
+ struct ieee80211_local *local = sdata->local;
+ int sent, buffered;
+
++ clear_sta_flags(sta, WLAN_STA_PS_DRIVER_BUF);
+ if (!(local->hw.flags & IEEE80211_HW_AP_LINK_PS))
+ drv_sta_notify(local, sdata, STA_NOTIFY_AWAKE, &sta->sta);
+
+@@ -994,3 +996,12 @@ void ieee80211_sta_block_awake(struct ie
+ ieee80211_queue_work(hw, &sta->drv_unblock_wk);
+ }
+ EXPORT_SYMBOL(ieee80211_sta_block_awake);
++
++void ieee80211_sta_set_tim(struct ieee80211_sta *pubsta)
++{
++ struct sta_info *sta = container_of(pubsta, struct sta_info, sta);
++
++ set_sta_flags(sta, WLAN_STA_PS_DRIVER_BUF);
++ sta_info_set_tim_bit(sta);
++}
++EXPORT_SYMBOL(ieee80211_sta_set_tim);
+--- a/net/mac80211/sta_info.h
++++ b/net/mac80211/sta_info.h
+@@ -43,6 +43,8 @@
+ * be in the queues
+ * @WLAN_STA_PSPOLL: Station sent PS-poll while driver was keeping
+ * station in power-save mode, reply when the driver unblocks.
++ * @WLAN_STA_PS_DRIVER_BUF: Station has frames pending in driver internal
++ * buffers. Automatically cleared on station wake-up.
+ */
+ enum ieee80211_sta_info_flags {
+ WLAN_STA_AUTH = 1<<0,
+@@ -58,6 +60,7 @@ enum ieee80211_sta_info_flags {
+ WLAN_STA_BLOCK_BA = 1<<11,
+ WLAN_STA_PS_DRIVER = 1<<12,
+ WLAN_STA_PSPOLL = 1<<13,
++ WLAN_STA_PS_DRIVER_BUF = 1<<14,
+ };
+
+ #define STA_TID_NUM 16
--- /dev/null
+--- a/drivers/net/wireless/ath/ath9k/ath9k.h
++++ b/drivers/net/wireless/ath/ath9k/ath9k.h
+@@ -202,6 +202,7 @@ struct ath_atx_ac {
+ int sched;
+ struct list_head list;
+ struct list_head tid_q;
++ bool clear_ps_filter;
+ };
+
+ struct ath_frame_info {
+@@ -259,6 +260,8 @@ struct ath_node {
+ struct ath_atx_ac ac[WME_NUM_AC];
+ u16 maxampdu;
+ u8 mpdudensity;
++
++ bool sleeping;
+ };
+
+ #define AGGR_CLEANUP BIT(1)
+@@ -340,6 +343,9 @@ int ath_tx_aggr_start(struct ath_softc *
+ void ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid);
+ void ath_tx_aggr_resume(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid);
+
++void ath_tx_aggr_wakeup(struct ath_softc *sc, struct ath_node *an);
++bool ath_tx_aggr_sleep(struct ath_softc *sc, struct ath_node *an);
++
+ /********/
+ /* VIFs */
+ /********/
+--- a/drivers/net/wireless/ath/ath9k/main.c
++++ b/drivers/net/wireless/ath/ath9k/main.c
+@@ -1795,6 +1795,27 @@ static int ath9k_sta_remove(struct ieee8
+ return 0;
+ }
+
++static void ath9k_sta_notify(struct ieee80211_hw *hw,
++ struct ieee80211_vif *vif,
++ enum sta_notify_cmd cmd,
++ struct ieee80211_sta *sta)
++{
++ struct ath_softc *sc = hw->priv;
++ struct ath_node *an = (struct ath_node *) sta->drv_priv;
++
++ switch (cmd) {
++ case STA_NOTIFY_SLEEP:
++ an->sleeping = true;
++ if (ath_tx_aggr_sleep(sc, an))
++ ieee80211_sta_set_tim(sta);
++ break;
++ case STA_NOTIFY_AWAKE:
++ an->sleeping = false;
++ ath_tx_aggr_wakeup(sc, an);
++ break;
++ }
++}
++
+ static int ath9k_conf_tx(struct ieee80211_hw *hw, u16 queue,
+ const struct ieee80211_tx_queue_params *params)
+ {
+@@ -2197,6 +2218,7 @@ struct ieee80211_ops ath9k_ops = {
+ .configure_filter = ath9k_configure_filter,
+ .sta_add = ath9k_sta_add,
+ .sta_remove = ath9k_sta_remove,
++ .sta_notify = ath9k_sta_notify,
+ .conf_tx = ath9k_conf_tx,
+ .bss_info_changed = ath9k_bss_info_changed,
+ .set_key = ath9k_set_key,
+--- a/drivers/net/wireless/ath/ath9k/xmit.c
++++ b/drivers/net/wireless/ath/ath9k/xmit.c
+@@ -357,6 +357,7 @@ static void ath_tx_complete_aggr(struct
+ struct ath_frame_info *fi;
+ int nframes;
+ u8 tidno;
++ bool clear_filter;
+
+ skb = bf->bf_mpdu;
+ hdr = (struct ieee80211_hdr *)skb->data;
+@@ -442,7 +443,11 @@ static void ath_tx_complete_aggr(struct
+ acked_cnt++;
+ } else {
+ if (!(tid->state & AGGR_CLEANUP) && retry) {
+- if (fi->retries < ATH_MAX_SW_RETRIES) {
++ if (ts->ts_status & ATH9K_TXERR_FILT) {
++ if (!an->sleeping)
++ clear_filter = true;
++ txpending = 1;
++ } else if (fi->retries < ATH_MAX_SW_RETRIES) {
+ ath_tx_set_retry(sc, txq, bf->bf_mpdu);
+ txpending = 1;
+ } else {
+@@ -496,6 +501,7 @@ static void ath_tx_complete_aggr(struct
+ !txfail, sendbar);
+ } else {
+ /* retry the un-acked ones */
++ ath9k_hw_set_clrdmask(sc->sc_ah, bf->bf_desc, false);
+ if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)) {
+ if (bf->bf_next == NULL && bf_last->bf_stale) {
+ struct ath_buf *tbf;
+@@ -546,7 +552,12 @@ static void ath_tx_complete_aggr(struct
+
+ /* prepend un-acked frames to the beginning of the pending frame queue */
+ if (!list_empty(&bf_pending)) {
++ if (an->sleeping)
++ ieee80211_sta_set_tim(sta);
++
+ spin_lock_bh(&txq->axq_lock);
++ if (clear_filter)
++ tid->ac->clear_ps_filter = true;
+ list_splice(&bf_pending, &tid->buf_q);
+ ath_tx_queue_tid(txq, tid);
+ spin_unlock_bh(&txq->axq_lock);
+@@ -816,6 +827,11 @@ static void ath_tx_sched_aggr(struct ath
+ bf = list_first_entry(&bf_q, struct ath_buf, list);
+ bf->bf_lastbf = list_entry(bf_q.prev, struct ath_buf, list);
+
++ if (tid->ac->clear_ps_filter) {
++ tid->ac->clear_ps_filter = false;
++ ath9k_hw_set_clrdmask(sc->sc_ah, bf->bf_desc, true);
++ }
++
+ /* if only one frame, send as non-aggregate */
+ if (bf == bf->bf_lastbf) {
+ fi = get_frame_info(bf->bf_mpdu);
+@@ -896,6 +912,67 @@ void ath_tx_aggr_stop(struct ath_softc *
+ ath_tx_flush_tid(sc, txtid);
+ }
+
++bool ath_tx_aggr_sleep(struct ath_softc *sc, struct ath_node *an)
++{
++ struct ath_atx_tid *tid;
++ struct ath_atx_ac *ac;
++ struct ath_txq *txq;
++ bool buffered = false;
++ int tidno;
++
++ for (tidno = 0, tid = &an->tid[tidno];
++ tidno < WME_NUM_TID; tidno++, tid++) {
++
++ if (!tid->sched)
++ continue;
++
++ ac = tid->ac;
++ txq = ac->txq;
++
++ spin_lock_bh(&txq->axq_lock);
++
++ if (!list_empty(&tid->buf_q))
++ buffered = true;
++
++ tid->sched = false;
++ list_del(&tid->list);
++
++ if (ac->sched) {
++ ac->sched = false;
++ list_del(&ac->list);
++ }
++
++ spin_unlock_bh(&txq->axq_lock);
++ }
++
++ return buffered;
++}
++
++void ath_tx_aggr_wakeup(struct ath_softc *sc, struct ath_node *an)
++{
++ struct ath_atx_tid *tid;
++ struct ath_atx_ac *ac;
++ struct ath_txq *txq;
++ int tidno;
++
++ for (tidno = 0, tid = &an->tid[tidno];
++ tidno < WME_NUM_TID; tidno++, tid++) {
++
++ ac = tid->ac;
++ txq = ac->txq;
++
++ spin_lock_bh(&txq->axq_lock);
++ ac->clear_ps_filter = true;
++
++ if (!list_empty(&tid->buf_q) && !tid->paused) {
++ ath_tx_queue_tid(txq, tid);
++ ath_txq_schedule(sc, txq);
++ }
++
++ spin_unlock_bh(&txq->axq_lock);
++ }
++}
++
+ void ath_tx_aggr_resume(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid)
+ {
+ struct ath_atx_tid *txtid;
+@@ -1491,7 +1568,6 @@ static int setup_tx_flags(struct sk_buff
+ struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
+ int flags = 0;
+
+- flags |= ATH9K_TXDESC_CLRDMASK; /* needed for crypto errors */
+ flags |= ATH9K_TXDESC_INTREQ;
+
+ if (tx_info->flags & IEEE80211_TX_CTL_NO_ACK)
+@@ -1754,6 +1830,9 @@ static void ath_tx_start_dma(struct ath_
+ if (txctl->paprd)
+ bf->bf_state.bfs_paprd_timestamp = jiffies;
+
++ if (tx_info->flags & IEEE80211_TX_CTL_CLEAR_PS_FILT)
++ ath9k_hw_set_clrdmask(sc->sc_ah, bf->bf_desc, true);
++
+ ath_tx_send_normal(sc, txctl->txq, tid, &bf_head);
+ }
+
+--- a/drivers/net/wireless/ath/ath9k/hw-ops.h
++++ b/drivers/net/wireless/ath/ath9k/hw-ops.h
+@@ -128,6 +128,11 @@ static inline void ath9k_hw_set11n_virtu
+ ath9k_hw_ops(ah)->set11n_virtualmorefrag(ah, ds, vmf);
+ }
+
++static inline void ath9k_hw_set_clrdmask(struct ath_hw *ah, void *ds, bool val)
++{
++ ath9k_hw_ops(ah)->set_clrdmask(ah, ds, val);
++}
++
+ /* Private hardware call ops */
+
+ /* PHY ops */
+--- a/drivers/net/wireless/ath/ath9k/hw.h
++++ b/drivers/net/wireless/ath/ath9k/hw.h
+@@ -630,6 +630,7 @@ struct ath_hw_ops {
+ u32 burstDuration);
+ void (*set11n_virtualmorefrag)(struct ath_hw *ah, void *ds,
+ u32 vmf);
++ void (*set_clrdmask)(struct ath_hw *ah, void *ds, bool val);
+ };
+
+ struct ath_nf_limits {
+--- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
++++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
+@@ -290,7 +290,6 @@ static void ar9002_hw_set11n_txdesc(stru
+ | (flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
+ | SM(txPower, AR_XmitPower)
+ | (flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
+- | (flags & ATH9K_TXDESC_CLRDMASK ? AR_ClrDestMask : 0)
+ | (flags & ATH9K_TXDESC_INTREQ ? AR_TxIntrReq : 0)
+ | (keyIx != ATH9K_TXKEYIX_INVALID ? AR_DestIdxValid : 0);
+
+@@ -311,6 +310,16 @@ static void ar9002_hw_set11n_txdesc(stru
+ }
+ }
+
++static void ar9002_hw_set_clrdmask(struct ath_hw *ah, void *ds, bool val)
++{
++ struct ar5416_desc *ads = AR5416DESC(ds);
++
++ if (val)
++ ads->ds_ctl0 |= AR_ClrDestMask;
++ else
++ ads->ds_ctl0 &= ~AR_ClrDestMask;
++}
++
+ static void ar9002_hw_set11n_ratescenario(struct ath_hw *ah, void *ds,
+ void *lastds,
+ u32 durUpdateEn, u32 rtsctsRate,
+@@ -460,4 +469,5 @@ void ar9002_hw_attach_mac_ops(struct ath
+ ops->clr11n_aggr = ar9002_hw_clr11n_aggr;
+ ops->set11n_burstduration = ar9002_hw_set11n_burstduration;
+ ops->set11n_virtualmorefrag = ar9002_hw_set11n_virtualmorefrag;
++ ops->set_clrdmask = ar9002_hw_set_clrdmask;
+ }
+--- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
++++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
+@@ -329,7 +329,6 @@ static void ar9003_hw_set11n_txdesc(stru
+ | (flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
+ | SM(txpower, AR_XmitPower)
+ | (flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
+- | (flags & ATH9K_TXDESC_CLRDMASK ? AR_ClrDestMask : 0)
+ | (keyIx != ATH9K_TXKEYIX_INVALID ? AR_DestIdxValid : 0)
+ | (flags & ATH9K_TXDESC_LOWRXCHAIN ? AR_LowRxChain : 0);
+
+@@ -350,6 +349,16 @@ static void ar9003_hw_set11n_txdesc(stru
+ ads->ctl22 = 0;
+ }
+
++static void ar9003_hw_set_clrdmask(struct ath_hw *ah, void *ds, bool val)
++{
++ struct ar9003_txc *ads = (struct ar9003_txc *) ds;
++
++ if (val)
++ ads->ctl11 |= AR_ClrDestMask;
++ else
++ ads->ctl11 &= ~AR_ClrDestMask;
++}
++
+ static void ar9003_hw_set11n_ratescenario(struct ath_hw *ah, void *ds,
+ void *lastds,
+ u32 durUpdateEn, u32 rtsctsRate,
+@@ -522,6 +531,7 @@ void ar9003_hw_attach_mac_ops(struct ath
+ ops->clr11n_aggr = ar9003_hw_clr11n_aggr;
+ ops->set11n_burstduration = ar9003_hw_set11n_burstduration;
+ ops->set11n_virtualmorefrag = ar9003_hw_set11n_virtualmorefrag;
++ ops->set_clrdmask = ar9003_hw_set_clrdmask;
+ }
+
+ void ath9k_hw_set_rx_bufsize(struct ath_hw *ah, u16 buf_size)
+--- a/drivers/net/wireless/ath/ath9k/mac.h
++++ b/drivers/net/wireless/ath/ath9k/mac.h
+@@ -239,7 +239,6 @@ struct ath_desc {
+ void *ds_vdata;
+ } __packed __aligned(4);
+
+-#define ATH9K_TXDESC_CLRDMASK 0x0001
+ #define ATH9K_TXDESC_NOACK 0x0002
+ #define ATH9K_TXDESC_RTSENA 0x0004
+ #define ATH9K_TXDESC_CTSENA 0x0008
--- /dev/null
+--- a/drivers/net/wireless/ath/ath9k/recv.c
++++ b/drivers/net/wireless/ath/ath9k/recv.c
+@@ -426,9 +426,7 @@ u32 ath_calcrxfilter(struct ath_softc *s
+ else
+ rfilt |= ATH9K_RX_FILTER_BEACON;
+
+- if ((AR_SREV_9280_20_OR_LATER(sc->sc_ah) ||
+- AR_SREV_9285_12_OR_LATER(sc->sc_ah)) &&
+- (sc->sc_ah->opmode == NL80211_IFTYPE_AP) &&
++ if ((sc->sc_ah->opmode == NL80211_IFTYPE_AP) ||
+ (sc->rx.rxfilter & FIF_PSPOLL))
+ rfilt |= ATH9K_RX_FILTER_PSPOLL;
+
+++ /dev/null
---- a/include/net/mac80211.h
-+++ b/include/net/mac80211.h
-@@ -2209,6 +2209,18 @@ static inline int ieee80211_sta_ps_trans
- #define IEEE80211_TX_STATUS_HEADROOM 13
-
- /**
-+ * ieee80211_sta_set_tim - set the TIM bit for a sleeping station
-+ *
-+ * If a driver buffers frames for a powersave station instead of passing
-+ * them back to mac80211 for retransmission, the station needs to be told
-+ * to wake up using the TIM bitmap in the beacon.
-+ *
-+ * This function sets the station's TIM bit - it will be cleared when the
-+ * station wakes up.
-+ */
-+void ieee80211_sta_set_tim(struct ieee80211_sta *sta);
-+
-+/**
- * ieee80211_tx_status - transmit status callback
- *
- * Call this function for all transmitted frames after they have been
---- a/net/mac80211/sta_info.c
-+++ b/net/mac80211/sta_info.c
-@@ -608,7 +608,8 @@ static bool sta_info_cleanup_expire_buff
- #endif
- dev_kfree_skb(skb);
-
-- if (skb_queue_empty(&sta->ps_tx_buf))
-+ if (skb_queue_empty(&sta->ps_tx_buf) &&
-+ !test_sta_flags(sta, WLAN_STA_PS_DRIVER_BUF))
- sta_info_clear_tim_bit(sta);
- }
-
-@@ -899,6 +900,7 @@ void ieee80211_sta_ps_deliver_wakeup(str
- struct ieee80211_local *local = sdata->local;
- int sent, buffered;
-
-+ clear_sta_flags(sta, WLAN_STA_PS_DRIVER_BUF);
- if (!(local->hw.flags & IEEE80211_HW_AP_LINK_PS))
- drv_sta_notify(local, sdata, STA_NOTIFY_AWAKE, &sta->sta);
-
-@@ -991,3 +993,12 @@ void ieee80211_sta_block_awake(struct ie
- ieee80211_queue_work(hw, &sta->drv_unblock_wk);
- }
- EXPORT_SYMBOL(ieee80211_sta_block_awake);
-+
-+void ieee80211_sta_set_tim(struct ieee80211_sta *pubsta)
-+{
-+ struct sta_info *sta = container_of(pubsta, struct sta_info, sta);
-+
-+ set_sta_flags(sta, WLAN_STA_PS_DRIVER_BUF);
-+ sta_info_set_tim_bit(sta);
-+}
-+EXPORT_SYMBOL(ieee80211_sta_set_tim);
---- a/net/mac80211/sta_info.h
-+++ b/net/mac80211/sta_info.h
-@@ -43,6 +43,8 @@
- * be in the queues
- * @WLAN_STA_PSPOLL: Station sent PS-poll while driver was keeping
- * station in power-save mode, reply when the driver unblocks.
-+ * @WLAN_STA_PS_DRIVER_BUF: Station has frames pending in driver internal
-+ * buffers. Automatically cleared on station wake-up.
- */
- enum ieee80211_sta_info_flags {
- WLAN_STA_AUTH = 1<<0,
-@@ -58,6 +60,7 @@ enum ieee80211_sta_info_flags {
- WLAN_STA_BLOCK_BA = 1<<11,
- WLAN_STA_PS_DRIVER = 1<<12,
- WLAN_STA_PSPOLL = 1<<13,
-+ WLAN_STA_PS_DRIVER_BUF = 1<<14,
- };
-
- #define STA_TID_NUM 16
--- /dev/null
+--- a/net/mac80211/rx.c
++++ b/net/mac80211/rx.c
+@@ -1584,7 +1584,7 @@ ieee80211_drop_unencrypted_mgmt(struct i
+ }
+
+ static int
+-__ieee80211_data_to_8023(struct ieee80211_rx_data *rx)
++__ieee80211_data_to_8023(struct ieee80211_rx_data *rx, bool *port_control)
+ {
+ struct ieee80211_sub_if_data *sdata = rx->sdata;
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data;
+@@ -1592,6 +1592,7 @@ __ieee80211_data_to_8023(struct ieee8021
+ struct ethhdr *ehdr;
+ int ret;
+
++ *port_control = false;
+ if (ieee80211_has_a4(hdr->frame_control) &&
+ sdata->vif.type == NL80211_IFTYPE_AP_VLAN && !sdata->u.vlan.sta)
+ return -1;
+@@ -1610,11 +1611,14 @@ __ieee80211_data_to_8023(struct ieee8021
+ return -1;
+
+ ret = ieee80211_data_to_8023(rx->skb, sdata->vif.addr, sdata->vif.type);
+- if (ret < 0 || !check_port_control)
++ if (ret < 0)
+ return ret;
+
+ ehdr = (struct ethhdr *) rx->skb->data;
+- if (ehdr->h_proto != rx->sdata->control_port_protocol)
++ if (ehdr->h_proto == rx->sdata->control_port_protocol)
++ *port_control = true;
++
++ if (check_port_control && !*port_control)
+ return -1;
+
+ return 0;
+@@ -1915,6 +1919,7 @@ ieee80211_rx_h_data(struct ieee80211_rx_
+ struct net_device *dev = sdata->dev;
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data;
+ __le16 fc = hdr->frame_control;
++ bool port_control;
+ int err;
+
+ if (unlikely(!ieee80211_is_data(hdr->frame_control)))
+@@ -1931,13 +1936,21 @@ ieee80211_rx_h_data(struct ieee80211_rx_
+ sdata->vif.type == NL80211_IFTYPE_AP)
+ return RX_DROP_MONITOR;
+
+- err = __ieee80211_data_to_8023(rx);
++ err = __ieee80211_data_to_8023(rx, &port_control);
+ if (unlikely(err))
+ return RX_DROP_UNUSABLE;
+
+ if (!ieee80211_frame_allowed(rx, fc))
+ return RX_DROP_MONITOR;
+
++ if (rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
++ unlikely(port_control) && sdata->bss) {
++ sdata = container_of(sdata->bss, struct ieee80211_sub_if_data,
++ u.ap);
++ dev = sdata->dev;
++ rx->sdata = sdata;
++ }
++
+ rx->skb->dev = dev;
+
+ dev->stats.rx_packets++;
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/ath9k.h
-+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
-@@ -203,6 +203,7 @@ struct ath_atx_ac {
- int sched;
- struct list_head list;
- struct list_head tid_q;
-+ bool clear_ps_filter;
- };
-
- struct ath_frame_info {
-@@ -260,6 +261,8 @@ struct ath_node {
- struct ath_atx_ac ac[WME_NUM_AC];
- u16 maxampdu;
- u8 mpdudensity;
-+
-+ bool sleeping;
- };
-
- #define AGGR_CLEANUP BIT(1)
-@@ -341,6 +344,9 @@ int ath_tx_aggr_start(struct ath_softc *
- void ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid);
- void ath_tx_aggr_resume(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid);
-
-+void ath_tx_aggr_wakeup(struct ath_softc *sc, struct ath_node *an);
-+bool ath_tx_aggr_sleep(struct ath_softc *sc, struct ath_node *an);
-+
- /********/
- /* VIFs */
- /********/
---- a/drivers/net/wireless/ath/ath9k/main.c
-+++ b/drivers/net/wireless/ath/ath9k/main.c
-@@ -1791,6 +1791,27 @@ static int ath9k_sta_remove(struct ieee8
- return 0;
- }
-
-+static void ath9k_sta_notify(struct ieee80211_hw *hw,
-+ struct ieee80211_vif *vif,
-+ enum sta_notify_cmd cmd,
-+ struct ieee80211_sta *sta)
-+{
-+ struct ath_softc *sc = hw->priv;
-+ struct ath_node *an = (struct ath_node *) sta->drv_priv;
-+
-+ switch (cmd) {
-+ case STA_NOTIFY_SLEEP:
-+ an->sleeping = true;
-+ if (ath_tx_aggr_sleep(sc, an))
-+ ieee80211_sta_set_tim(sta);
-+ break;
-+ case STA_NOTIFY_AWAKE:
-+ an->sleeping = false;
-+ ath_tx_aggr_wakeup(sc, an);
-+ break;
-+ }
-+}
-+
- static int ath9k_conf_tx(struct ieee80211_hw *hw, u16 queue,
- const struct ieee80211_tx_queue_params *params)
- {
-@@ -2191,6 +2212,7 @@ struct ieee80211_ops ath9k_ops = {
- .configure_filter = ath9k_configure_filter,
- .sta_add = ath9k_sta_add,
- .sta_remove = ath9k_sta_remove,
-+ .sta_notify = ath9k_sta_notify,
- .conf_tx = ath9k_conf_tx,
- .bss_info_changed = ath9k_bss_info_changed,
- .set_key = ath9k_set_key,
---- a/drivers/net/wireless/ath/ath9k/xmit.c
-+++ b/drivers/net/wireless/ath/ath9k/xmit.c
-@@ -357,6 +357,7 @@ static void ath_tx_complete_aggr(struct
- struct ath_frame_info *fi;
- int nframes;
- u8 tidno;
-+ bool clear_filter;
-
- skb = bf->bf_mpdu;
- hdr = (struct ieee80211_hdr *)skb->data;
-@@ -442,7 +443,11 @@ static void ath_tx_complete_aggr(struct
- acked_cnt++;
- } else {
- if (!(tid->state & AGGR_CLEANUP) && retry) {
-- if (fi->retries < ATH_MAX_SW_RETRIES) {
-+ if (ts->ts_status & ATH9K_TXERR_FILT) {
-+ if (!an->sleeping)
-+ clear_filter = true;
-+ txpending = 1;
-+ } else if (fi->retries < ATH_MAX_SW_RETRIES) {
- ath_tx_set_retry(sc, txq, bf->bf_mpdu);
- txpending = 1;
- } else {
-@@ -496,6 +501,7 @@ static void ath_tx_complete_aggr(struct
- !txfail, sendbar);
- } else {
- /* retry the un-acked ones */
-+ ath9k_hw_set_clrdmask(sc->sc_ah, bf->bf_desc, false);
- if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)) {
- if (bf->bf_next == NULL && bf_last->bf_stale) {
- struct ath_buf *tbf;
-@@ -546,7 +552,12 @@ static void ath_tx_complete_aggr(struct
-
- /* prepend un-acked frames to the beginning of the pending frame queue */
- if (!list_empty(&bf_pending)) {
-+ if (an->sleeping)
-+ ieee80211_sta_set_tim(sta);
-+
- spin_lock_bh(&txq->axq_lock);
-+ if (clear_filter)
-+ tid->ac->clear_ps_filter = true;
- list_splice(&bf_pending, &tid->buf_q);
- ath_tx_queue_tid(txq, tid);
- spin_unlock_bh(&txq->axq_lock);
-@@ -816,6 +827,11 @@ static void ath_tx_sched_aggr(struct ath
- bf = list_first_entry(&bf_q, struct ath_buf, list);
- bf->bf_lastbf = list_entry(bf_q.prev, struct ath_buf, list);
-
-+ if (tid->ac->clear_ps_filter) {
-+ tid->ac->clear_ps_filter = false;
-+ ath9k_hw_set_clrdmask(sc->sc_ah, bf->bf_desc, true);
-+ }
-+
- /* if only one frame, send as non-aggregate */
- if (bf == bf->bf_lastbf) {
- fi = get_frame_info(bf->bf_mpdu);
-@@ -896,6 +912,67 @@ void ath_tx_aggr_stop(struct ath_softc *
- ath_tx_flush_tid(sc, txtid);
- }
-
-+bool ath_tx_aggr_sleep(struct ath_softc *sc, struct ath_node *an)
-+{
-+ struct ath_atx_tid *tid;
-+ struct ath_atx_ac *ac;
-+ struct ath_txq *txq;
-+ bool buffered = false;
-+ int tidno;
-+
-+ for (tidno = 0, tid = &an->tid[tidno];
-+ tidno < WME_NUM_TID; tidno++, tid++) {
-+
-+ if (!tid->sched)
-+ continue;
-+
-+ ac = tid->ac;
-+ txq = ac->txq;
-+
-+ spin_lock_bh(&txq->axq_lock);
-+
-+ if (!list_empty(&tid->buf_q))
-+ buffered = true;
-+
-+ tid->sched = false;
-+ list_del(&tid->list);
-+
-+ if (ac->sched) {
-+ ac->sched = false;
-+ list_del(&ac->list);
-+ }
-+
-+ spin_unlock_bh(&txq->axq_lock);
-+ }
-+
-+ return buffered;
-+}
-+
-+void ath_tx_aggr_wakeup(struct ath_softc *sc, struct ath_node *an)
-+{
-+ struct ath_atx_tid *tid;
-+ struct ath_atx_ac *ac;
-+ struct ath_txq *txq;
-+ int tidno;
-+
-+ for (tidno = 0, tid = &an->tid[tidno];
-+ tidno < WME_NUM_TID; tidno++, tid++) {
-+
-+ ac = tid->ac;
-+ txq = ac->txq;
-+
-+ spin_lock_bh(&txq->axq_lock);
-+ ac->clear_ps_filter = true;
-+
-+ if (!list_empty(&tid->buf_q) && !tid->paused) {
-+ ath_tx_queue_tid(txq, tid);
-+ ath_txq_schedule(sc, txq);
-+ }
-+
-+ spin_unlock_bh(&txq->axq_lock);
-+ }
-+}
-+
- void ath_tx_aggr_resume(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid)
- {
- struct ath_atx_tid *txtid;
-@@ -1493,7 +1570,6 @@ static int setup_tx_flags(struct sk_buff
- struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
- int flags = 0;
-
-- flags |= ATH9K_TXDESC_CLRDMASK; /* needed for crypto errors */
- flags |= ATH9K_TXDESC_INTREQ;
-
- if (tx_info->flags & IEEE80211_TX_CTL_NO_ACK)
-@@ -1756,6 +1832,9 @@ static void ath_tx_start_dma(struct ath_
- if (txctl->paprd)
- bf->bf_state.bfs_paprd_timestamp = jiffies;
-
-+ if (tx_info->flags & IEEE80211_TX_CTL_CLEAR_PS_FILT)
-+ ath9k_hw_set_clrdmask(sc->sc_ah, bf->bf_desc, true);
-+
- ath_tx_send_normal(sc, txctl->txq, tid, &bf_head);
- }
-
---- a/drivers/net/wireless/ath/ath9k/hw-ops.h
-+++ b/drivers/net/wireless/ath/ath9k/hw-ops.h
-@@ -128,6 +128,11 @@ static inline void ath9k_hw_set11n_virtu
- ath9k_hw_ops(ah)->set11n_virtualmorefrag(ah, ds, vmf);
- }
-
-+static inline void ath9k_hw_set_clrdmask(struct ath_hw *ah, void *ds, bool val)
-+{
-+ ath9k_hw_ops(ah)->set_clrdmask(ah, ds, val);
-+}
-+
- /* Private hardware call ops */
-
- /* PHY ops */
---- a/drivers/net/wireless/ath/ath9k/hw.h
-+++ b/drivers/net/wireless/ath/ath9k/hw.h
-@@ -642,6 +642,7 @@ struct ath_hw_ops {
- u32 burstDuration);
- void (*set11n_virtualmorefrag)(struct ath_hw *ah, void *ds,
- u32 vmf);
-+ void (*set_clrdmask)(struct ath_hw *ah, void *ds, bool val);
- };
-
- struct ath_nf_limits {
---- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
-+++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
-@@ -290,7 +290,6 @@ static void ar9002_hw_set11n_txdesc(stru
- | (flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
- | SM(txPower, AR_XmitPower)
- | (flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
-- | (flags & ATH9K_TXDESC_CLRDMASK ? AR_ClrDestMask : 0)
- | (flags & ATH9K_TXDESC_INTREQ ? AR_TxIntrReq : 0)
- | (keyIx != ATH9K_TXKEYIX_INVALID ? AR_DestIdxValid : 0);
-
-@@ -311,6 +310,16 @@ static void ar9002_hw_set11n_txdesc(stru
- }
- }
-
-+static void ar9002_hw_set_clrdmask(struct ath_hw *ah, void *ds, bool val)
-+{
-+ struct ar5416_desc *ads = AR5416DESC(ds);
-+
-+ if (val)
-+ ads->ds_ctl0 |= AR_ClrDestMask;
-+ else
-+ ads->ds_ctl0 &= ~AR_ClrDestMask;
-+}
-+
- static void ar9002_hw_set11n_ratescenario(struct ath_hw *ah, void *ds,
- void *lastds,
- u32 durUpdateEn, u32 rtsctsRate,
-@@ -460,4 +469,5 @@ void ar9002_hw_attach_mac_ops(struct ath
- ops->clr11n_aggr = ar9002_hw_clr11n_aggr;
- ops->set11n_burstduration = ar9002_hw_set11n_burstduration;
- ops->set11n_virtualmorefrag = ar9002_hw_set11n_virtualmorefrag;
-+ ops->set_clrdmask = ar9002_hw_set_clrdmask;
- }
---- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
-+++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
-@@ -329,7 +329,6 @@ static void ar9003_hw_set11n_txdesc(stru
- | (flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
- | SM(txpower, AR_XmitPower)
- | (flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
-- | (flags & ATH9K_TXDESC_CLRDMASK ? AR_ClrDestMask : 0)
- | (keyIx != ATH9K_TXKEYIX_INVALID ? AR_DestIdxValid : 0)
- | (flags & ATH9K_TXDESC_LOWRXCHAIN ? AR_LowRxChain : 0);
-
-@@ -350,6 +349,16 @@ static void ar9003_hw_set11n_txdesc(stru
- ads->ctl22 = 0;
- }
-
-+static void ar9003_hw_set_clrdmask(struct ath_hw *ah, void *ds, bool val)
-+{
-+ struct ar9003_txc *ads = (struct ar9003_txc *) ds;
-+
-+ if (val)
-+ ads->ctl11 |= AR_ClrDestMask;
-+ else
-+ ads->ctl11 &= ~AR_ClrDestMask;
-+}
-+
- static void ar9003_hw_set11n_ratescenario(struct ath_hw *ah, void *ds,
- void *lastds,
- u32 durUpdateEn, u32 rtsctsRate,
-@@ -522,6 +531,7 @@ void ar9003_hw_attach_mac_ops(struct ath
- ops->clr11n_aggr = ar9003_hw_clr11n_aggr;
- ops->set11n_burstduration = ar9003_hw_set11n_burstduration;
- ops->set11n_virtualmorefrag = ar9003_hw_set11n_virtualmorefrag;
-+ ops->set_clrdmask = ar9003_hw_set_clrdmask;
- }
-
- void ath9k_hw_set_rx_bufsize(struct ath_hw *ah, u16 buf_size)
---- a/drivers/net/wireless/ath/ath9k/mac.h
-+++ b/drivers/net/wireless/ath/ath9k/mac.h
-@@ -239,7 +239,6 @@ struct ath_desc {
- void *ds_vdata;
- } __packed __aligned(4);
-
--#define ATH9K_TXDESC_CLRDMASK 0x0001
- #define ATH9K_TXDESC_NOACK 0x0002
- #define ATH9K_TXDESC_RTSENA 0x0004
- #define ATH9K_TXDESC_CTSENA 0x0008
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/recv.c
-+++ b/drivers/net/wireless/ath/ath9k/recv.c
-@@ -426,9 +426,7 @@ u32 ath_calcrxfilter(struct ath_softc *s
- else
- rfilt |= ATH9K_RX_FILTER_BEACON;
-
-- if ((AR_SREV_9280_20_OR_LATER(sc->sc_ah) ||
-- AR_SREV_9285_12_OR_LATER(sc->sc_ah)) &&
-- (sc->sc_ah->opmode == NL80211_IFTYPE_AP) &&
-+ if ((sc->sc_ah->opmode == NL80211_IFTYPE_AP) ||
- (sc->rx.rxfilter & FIF_PSPOLL))
- rfilt |= ATH9K_RX_FILTER_PSPOLL;
-
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/xmit.c
-+++ b/drivers/net/wireless/ath/ath9k/xmit.c
-@@ -2226,33 +2226,6 @@ static void ath_tx_complete_poll_work(st
- } else {
- txq->axq_tx_inprogress = true;
- }
-- } else {
-- /* If the queue has pending buffers, then it
-- * should be doing tx work (and have axq_depth).
-- * Shouldn't get to this state I think..but
-- * we do.
-- */
-- if (!(sc->sc_flags & (SC_OP_OFFCHANNEL)) &&
-- (txq->pending_frames > 0 ||
-- !list_empty(&txq->axq_acq) ||
-- txq->stopped)) {
-- ath_err(ath9k_hw_common(sc->sc_ah),
-- "txq: %p axq_qnum: %u,"
-- " mac80211_qnum: %i"
-- " axq_link: %p"
-- " pending frames: %i"
-- " axq_acq empty: %i"
-- " stopped: %i"
-- " axq_depth: 0 Attempting to"
-- " restart tx logic.\n",
-- txq, txq->axq_qnum,
-- txq->mac80211_qnum,
-- txq->axq_link,
-- txq->pending_frames,
-- list_empty(&txq->axq_acq),
-- txq->stopped);
-- ath_txq_schedule(sc, txq);
-- }
- }
- spin_unlock_bh(&txq->axq_lock);
- }
+++ /dev/null
---- a/include/net/cfg80211.h
-+++ b/include/net/cfg80211.h
-@@ -414,7 +414,7 @@ struct station_parameters {
- * @STATION_INFO_PLID: @plid filled
- * @STATION_INFO_PLINK_STATE: @plink_state filled
- * @STATION_INFO_SIGNAL: @signal filled
-- * @STATION_INFO_TX_BITRATE: @tx_bitrate fields are filled
-+ * @STATION_INFO_TX_BITRATE: @txrate fields are filled
- * (tx_bitrate, tx_bitrate_flags and tx_bitrate_mcs)
- * @STATION_INFO_RX_PACKETS: @rx_packets filled
- * @STATION_INFO_TX_PACKETS: @tx_packets filled
-@@ -422,6 +422,7 @@ struct station_parameters {
- * @STATION_INFO_TX_FAILED: @tx_failed filled
- * @STATION_INFO_RX_DROP_MISC: @rx_dropped_misc filled
- * @STATION_INFO_SIGNAL_AVG: @signal_avg filled
-+ * @STATION_INFO_RX_BITRATE: @rxrate fields are filled
- */
- enum station_info_flags {
- STATION_INFO_INACTIVE_TIME = 1<<0,
-@@ -438,6 +439,7 @@ enum station_info_flags {
- STATION_INFO_TX_FAILED = 1<<11,
- STATION_INFO_RX_DROP_MISC = 1<<12,
- STATION_INFO_SIGNAL_AVG = 1<<13,
-+ STATION_INFO_RX_BITRATE = 1<<14,
- };
-
- /**
-@@ -507,6 +509,7 @@ struct station_info {
- s8 signal;
- s8 signal_avg;
- struct rate_info txrate;
-+ struct rate_info rxrate;
- u32 rx_packets;
- u32 tx_packets;
- u32 tx_retries;
---- a/include/linux/nl80211.h
-+++ b/include/linux/nl80211.h
-@@ -1243,6 +1243,8 @@ enum nl80211_rate_info {
- * @NL80211_STA_INFO_LLID: the station's mesh LLID
- * @NL80211_STA_INFO_PLID: the station's mesh PLID
- * @NL80211_STA_INFO_PLINK_STATE: peer link state for the station
-+ * @NL80211_STA_INFO_RX_BITRATE: last unicast rx rate, nested attribute
-+ * containing info as possible, see &enum nl80211_sta_info_txrate.
- * @__NL80211_STA_INFO_AFTER_LAST: internal
- * @NL80211_STA_INFO_MAX: highest possible station info attribute
- */
-@@ -1261,6 +1263,7 @@ enum nl80211_sta_info {
- NL80211_STA_INFO_TX_RETRIES,
- NL80211_STA_INFO_TX_FAILED,
- NL80211_STA_INFO_SIGNAL_AVG,
-+ NL80211_STA_INFO_RX_BITRATE,
-
- /* keep last */
- __NL80211_STA_INFO_AFTER_LAST,
---- a/net/wireless/nl80211.c
-+++ b/net/wireless/nl80211.c
-@@ -1968,13 +1968,41 @@ static int parse_station_flags(struct ge
- return 0;
- }
-
-+static bool nl80211_put_sta_rate(struct sk_buff *msg, struct rate_info *info,
-+ int attr)
-+{
-+ struct nlattr *rate;
-+ u16 bitrate;
-+
-+ rate = nla_nest_start(msg, attr);
-+ if (!rate)
-+ goto nla_put_failure;
-+
-+ /* cfg80211_calculate_bitrate will return 0 for mcs >= 32 */
-+ bitrate = cfg80211_calculate_bitrate(info);
-+ if (bitrate > 0)
-+ NLA_PUT_U16(msg, NL80211_RATE_INFO_BITRATE, bitrate);
-+
-+ if (info->flags & RATE_INFO_FLAGS_MCS)
-+ NLA_PUT_U8(msg, NL80211_RATE_INFO_MCS, info->mcs);
-+ if (info->flags & RATE_INFO_FLAGS_40_MHZ_WIDTH)
-+ NLA_PUT_FLAG(msg, NL80211_RATE_INFO_40_MHZ_WIDTH);
-+ if (info->flags & RATE_INFO_FLAGS_SHORT_GI)
-+ NLA_PUT_FLAG(msg, NL80211_RATE_INFO_SHORT_GI);
-+
-+ nla_nest_end(msg, rate);
-+ return true;
-+
-+nla_put_failure:
-+ return false;
-+}
-+
- static int nl80211_send_station(struct sk_buff *msg, u32 pid, u32 seq,
- int flags, struct net_device *dev,
- const u8 *mac_addr, struct station_info *sinfo)
- {
- void *hdr;
-- struct nlattr *sinfoattr, *txrate;
-- u16 bitrate;
-+ struct nlattr *sinfoattr;
-
- hdr = nl80211hdr_put(msg, pid, seq, flags, NL80211_CMD_NEW_STATION);
- if (!hdr)
-@@ -2013,24 +2041,14 @@ static int nl80211_send_station(struct s
- NLA_PUT_U8(msg, NL80211_STA_INFO_SIGNAL_AVG,
- sinfo->signal_avg);
- if (sinfo->filled & STATION_INFO_TX_BITRATE) {
-- txrate = nla_nest_start(msg, NL80211_STA_INFO_TX_BITRATE);
-- if (!txrate)
-+ if (!nl80211_put_sta_rate(msg, &sinfo->txrate,
-+ NL80211_STA_INFO_TX_BITRATE))
-+ goto nla_put_failure;
-+ }
-+ if (sinfo->filled & STATION_INFO_RX_BITRATE) {
-+ if (!nl80211_put_sta_rate(msg, &sinfo->rxrate,
-+ NL80211_STA_INFO_RX_BITRATE))
- goto nla_put_failure;
--
-- /* cfg80211_calculate_bitrate will return 0 for mcs >= 32 */
-- bitrate = cfg80211_calculate_bitrate(&sinfo->txrate);
-- if (bitrate > 0)
-- NLA_PUT_U16(msg, NL80211_RATE_INFO_BITRATE, bitrate);
--
-- if (sinfo->txrate.flags & RATE_INFO_FLAGS_MCS)
-- NLA_PUT_U8(msg, NL80211_RATE_INFO_MCS,
-- sinfo->txrate.mcs);
-- if (sinfo->txrate.flags & RATE_INFO_FLAGS_40_MHZ_WIDTH)
-- NLA_PUT_FLAG(msg, NL80211_RATE_INFO_40_MHZ_WIDTH);
-- if (sinfo->txrate.flags & RATE_INFO_FLAGS_SHORT_GI)
-- NLA_PUT_FLAG(msg, NL80211_RATE_INFO_SHORT_GI);
--
-- nla_nest_end(msg, txrate);
- }
- if (sinfo->filled & STATION_INFO_RX_PACKETS)
- NLA_PUT_U32(msg, NL80211_STA_INFO_RX_PACKETS,
---- a/net/mac80211/sta_info.h
-+++ b/net/mac80211/sta_info.h
-@@ -212,6 +212,8 @@ enum plink_state {
- * @rate_ctrl_priv: rate control private per-STA pointer
- * @last_tx_rate: rate used for last transmit, to report to userspace as
- * "the" transmit rate
-+ * @last_rx_rate_idx: rx status rate index of the last data packet
-+ * @last_rx_rate_flag: rx status flag of the last data packet
- * @lock: used for locking all fields that require locking, see comments
- * in the header file.
- * @flaglock: spinlock for flags accesses
-@@ -314,6 +316,8 @@ struct sta_info {
- unsigned long tx_bytes;
- unsigned long tx_fragments;
- struct ieee80211_tx_rate last_tx_rate;
-+ int last_rx_rate_idx;
-+ int last_rx_rate_flag;
- u16 tid_seq[IEEE80211_QOS_CTL_TID_MASK + 1];
-
- /*
---- a/net/mac80211/rx.c
-+++ b/net/mac80211/rx.c
-@@ -1156,14 +1156,23 @@ ieee80211_rx_h_sta_process(struct ieee80
- if (rx->sdata->vif.type == NL80211_IFTYPE_ADHOC) {
- u8 *bssid = ieee80211_get_bssid(hdr, rx->skb->len,
- NL80211_IFTYPE_ADHOC);
-- if (compare_ether_addr(bssid, rx->sdata->u.ibss.bssid) == 0)
-+ if (compare_ether_addr(bssid, rx->sdata->u.ibss.bssid) == 0) {
- sta->last_rx = jiffies;
-+ if (ieee80211_is_data(hdr->frame_control)) {
-+ sta->last_rx_rate_idx = status->rate_idx;
-+ sta->last_rx_rate_flag = status->flag;
-+ }
-+ }
- } else if (!is_multicast_ether_addr(hdr->addr1)) {
- /*
- * Mesh beacons will update last_rx when if they are found to
- * match the current local configuration when processed.
- */
- sta->last_rx = jiffies;
-+ if (ieee80211_is_data(hdr->frame_control)) {
-+ sta->last_rx_rate_idx = status->rate_idx;
-+ sta->last_rx_rate_flag = status->flag;
-+ }
- }
-
- if (!(status->rx_flags & IEEE80211_RX_RA_MATCH))
---- a/net/mac80211/cfg.c
-+++ b/net/mac80211/cfg.c
-@@ -316,6 +316,17 @@ static int ieee80211_config_default_mgmt
- return 0;
- }
-
-+static void rate_idx_to_bitrate(struct rate_info *rate, struct sta_info *sta, int idx)
-+{
-+ if (!(rate->flags & RATE_INFO_FLAGS_MCS)) {
-+ struct ieee80211_supported_band *sband;
-+ sband = sta->local->hw.wiphy->bands[
-+ sta->local->hw.conf.channel->band];
-+ rate->legacy = sband->bitrates[idx].bitrate;
-+ } else
-+ rate->mcs = idx;
-+}
-+
- static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
- {
- struct ieee80211_sub_if_data *sdata = sta->sdata;
-@@ -330,6 +341,7 @@ static void sta_set_sinfo(struct sta_inf
- STATION_INFO_TX_RETRIES |
- STATION_INFO_TX_FAILED |
- STATION_INFO_TX_BITRATE |
-+ STATION_INFO_RX_BITRATE |
- STATION_INFO_RX_DROP_MISC;
-
- sinfo->inactive_time = jiffies_to_msecs(jiffies - sta->last_rx);
-@@ -355,15 +367,16 @@ static void sta_set_sinfo(struct sta_inf
- sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
- if (sta->last_tx_rate.flags & IEEE80211_TX_RC_SHORT_GI)
- sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
-+ rate_idx_to_bitrate(&sinfo->txrate, sta, sta->last_tx_rate.idx);
-
-- if (!(sta->last_tx_rate.flags & IEEE80211_TX_RC_MCS)) {
-- struct ieee80211_supported_band *sband;
-- sband = sta->local->hw.wiphy->bands[
-- sta->local->hw.conf.channel->band];
-- sinfo->txrate.legacy =
-- sband->bitrates[sta->last_tx_rate.idx].bitrate;
-- } else
-- sinfo->txrate.mcs = sta->last_tx_rate.idx;
-+ sinfo->rxrate.flags = 0;
-+ if (sta->last_rx_rate_flag & RX_FLAG_HT)
-+ sinfo->rxrate.flags |= RATE_INFO_FLAGS_MCS;
-+ if (sta->last_rx_rate_flag & RX_FLAG_40MHZ)
-+ sinfo->rxrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
-+ if (sta->last_rx_rate_flag & RX_FLAG_SHORT_GI)
-+ sinfo->rxrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
-+ rate_idx_to_bitrate(&sinfo->rxrate, sta, sta->last_rx_rate_idx);
-
- if (ieee80211_vif_is_mesh(&sdata->vif)) {
- #ifdef CONFIG_MAC80211_MESH
--- /dev/null
+--- a/net/mac80211/rx.c
++++ b/net/mac80211/rx.c
+@@ -613,7 +613,7 @@ static void ieee80211_sta_reorder_releas
+ continue;
+ }
+ if (!time_after(jiffies, tid_agg_rx->reorder_time[j] +
+- HT_RX_REORDER_BUF_TIMEOUT))
++ HT_RX_REORDER_BUF_TIMEOUT) && skipped)
+ goto set_release_timer;
+
+ #ifdef CONFIG_MAC80211_HT_DEBUG
--- /dev/null
+--- a/drivers/net/wireless/ath/ath9k/ath9k.h
++++ b/drivers/net/wireless/ath/ath9k/ath9k.h
+@@ -369,7 +369,7 @@ struct ath_vif {
+ * number of beacon intervals, the game's up.
+ */
+ #define BSTUCK_THRESH 9
+-#define ATH_BCBUF 4
++#define ATH_BCBUF 8
+ #define ATH_DEFAULT_BINTVAL 100 /* TU */
+ #define ATH_DEFAULT_BMISS_LIMIT 10
+ #define IEEE80211_MS_TO_TU(x) (((x) * 1000) / 1024)
+--- a/drivers/net/wireless/ath/ath9k/hw.c
++++ b/drivers/net/wireless/ath/ath9k/hw.c
+@@ -363,8 +363,8 @@ static void ath9k_hw_init_config(struct
+ {
+ int i;
+
+- ah->config.dma_beacon_response_time = 2;
+- ah->config.sw_beacon_response_time = 10;
++ ah->config.dma_beacon_response_time = 1;
++ ah->config.sw_beacon_response_time = 6;
+ ah->config.additional_swba_backoff = 0;
+ ah->config.ack_6mb = 0x0;
+ ah->config.cwm_ignore_extcca = 0;
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/recv.c
-+++ b/drivers/net/wireless/ath/ath9k/recv.c
-@@ -413,9 +413,7 @@ u32 ath_calcrxfilter(struct ath_softc *s
- * mode interface or when in monitor mode. AP mode does not need this
- * since it receives all in-BSS frames anyway.
- */
-- if (((sc->sc_ah->opmode != NL80211_IFTYPE_AP) &&
-- (sc->rx.rxfilter & FIF_PROMISC_IN_BSS)) ||
-- (sc->sc_ah->is_monitoring))
-+ if (sc->sc_ah->is_monitoring)
- rfilt |= ATH9K_RX_FILTER_PROM;
-
- if (sc->rx.rxfilter & FIF_CONTROL)
--- /dev/null
+--- a/drivers/net/wireless/ath/ath9k/recv.c
++++ b/drivers/net/wireless/ath/ath9k/recv.c
+@@ -957,6 +957,9 @@ static int ath9k_rx_skb_preprocess(struc
+ struct ieee80211_rx_status *rx_status,
+ bool *decrypt_error)
+ {
++ struct ath_hw *ah = common->ah;
++ int noise;
++
+ memset(rx_status, 0, sizeof(struct ieee80211_rx_status));
+
+ /*
+@@ -977,7 +980,13 @@ static int ath9k_rx_skb_preprocess(struc
+
+ rx_status->band = hw->conf.channel->band;
+ rx_status->freq = hw->conf.channel->center_freq;
+- rx_status->signal = ATH_DEFAULT_NOISE_FLOOR + rx_stats->rs_rssi;
++
++ if (ah->curchan)
++ noise = ah->curchan->noisefloor;
++ else
++ noise = ATH_DEFAULT_NOISE_FLOOR;
++
++ rx_status->signal = noise + rx_stats->rs_rssi;
+ rx_status->antenna = rx_stats->rs_antenna;
+ rx_status->flag |= RX_FLAG_MACTIME_MPDU;
+
+++ /dev/null
---- a/net/mac80211/rc80211_minstrel_ht.c
-+++ b/net/mac80211/rc80211_minstrel_ht.c
-@@ -415,10 +415,8 @@ minstrel_ht_tx_status(void *priv, struct
- mi->sample_count--;
- }
-
-- if (info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) {
-+ if (info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE)
- mi->sample_packets += info->status.ampdu_len;
-- minstrel_next_sample_idx(mi);
-- }
-
- for (i = 0; !last; i++) {
- last = (i == IEEE80211_TX_MAX_RATES - 1) ||
-@@ -553,13 +551,14 @@ minstrel_get_sample_rate(struct minstrel
- sample_idx = sample_table[mg->column][mg->index];
- mr = &mg->rates[sample_idx];
- sample_idx += mi->sample_group * MCS_GROUP_RATES;
-+ minstrel_next_sample_idx(mi);
-
- /*
- * When not using MRR, do not sample if the probability is already
- * higher than 95% to avoid wasting airtime
- */
- if (!mp->has_mrr && (mr->probability > MINSTREL_FRAC(95, 100)))
-- goto next;
-+ return -1;
-
- /*
- * Make sure that lower rates get sampled only occasionally,
-@@ -568,17 +567,13 @@ minstrel_get_sample_rate(struct minstrel
- if (minstrel_get_duration(sample_idx) >
- minstrel_get_duration(mi->max_tp_rate)) {
- if (mr->sample_skipped < 20)
-- goto next;
-+ return -1;
-
- if (mi->sample_slow++ > 2)
-- goto next;
-+ return -1;
- }
-
- return sample_idx;
--
--next:
-- minstrel_next_sample_idx(mi);
-- return -1;
- }
-
- static void
+++ /dev/null
---- a/net/mac80211/rx.c
-+++ b/net/mac80211/rx.c
-@@ -613,7 +613,7 @@ static void ieee80211_sta_reorder_releas
- continue;
- }
- if (!time_after(jiffies, tid_agg_rx->reorder_time[j] +
-- HT_RX_REORDER_BUF_TIMEOUT))
-+ HT_RX_REORDER_BUF_TIMEOUT) && skipped)
- goto set_release_timer;
-
- #ifdef CONFIG_MAC80211_HT_DEBUG
+++ /dev/null
---- a/net/mac80211/sta_info.c
-+++ b/net/mac80211/sta_info.c
-@@ -243,6 +243,7 @@ struct sta_info *sta_info_alloc(struct i
- memcpy(sta->sta.addr, addr, ETH_ALEN);
- sta->local = local;
- sta->sdata = sdata;
-+ sta->last_rx = jiffies;
-
- ewma_init(&sta->avg_signal, 1024, 8);
-
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/hw.h
-+++ b/drivers/net/wireless/ath/ath9k/hw.h
-@@ -95,9 +95,9 @@
- #define REG_READ_FIELD(_a, _r, _f) \
- (((REG_READ(_a, _r) & _f) >> _f##_S))
- #define REG_SET_BIT(_a, _r, _f) \
-- REG_WRITE(_a, _r, REG_READ(_a, _r) | _f)
-+ REG_WRITE(_a, _r, REG_READ(_a, _r) | (_f))
- #define REG_CLR_BIT(_a, _r, _f) \
-- REG_WRITE(_a, _r, REG_READ(_a, _r) & ~_f)
-+ REG_WRITE(_a, _r, REG_READ(_a, _r) & ~(_f))
-
- #define DO_DELAY(x) do { \
- if ((++(x) % 64) == 0) \
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/xmit.c
-+++ b/drivers/net/wireless/ath/ath9k/xmit.c
-@@ -1271,16 +1271,14 @@ bool ath_drain_all_txq(struct ath_softc
- if (sc->sc_flags & SC_OP_INVALID)
- return true;
-
-- /* Stop beacon queue */
-- ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq);
-+ ath9k_hw_abort_tx_dma(ah);
-
-- /* Stop data queues */
-+ /* Check if any queue remains active */
- for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
-- if (ATH_TXQ_SETUP(sc, i)) {
-- txq = &sc->tx.txq[i];
-- ath9k_hw_stoptxdma(ah, txq->axq_qnum);
-- npend += ath9k_hw_numtxpending(ah, txq->axq_qnum);
-- }
-+ if (!ATH_TXQ_SETUP(sc, i))
-+ continue;
-+
-+ npend += ath9k_hw_numtxpending(ah, sc->tx.txq[i].axq_qnum);
- }
-
- if (npend)
---- a/drivers/net/wireless/ath/ath9k/mac.c
-+++ b/drivers/net/wireless/ath/ath9k/mac.c
-@@ -143,6 +143,33 @@ bool ath9k_hw_updatetxtriglevel(struct a
- }
- EXPORT_SYMBOL(ath9k_hw_updatetxtriglevel);
-
-+void ath9k_hw_abort_tx_dma(struct ath_hw *ah)
-+{
-+ int i, q;
-+
-+ REG_WRITE(ah, AR_Q_TXD, AR_Q_TXD_M);
-+
-+ REG_SET_BIT(ah, AR_PCU_MISC, AR_PCU_FORCE_QUIET_COLL | AR_PCU_CLEAR_VMF);
-+ REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_FORCE_CH_IDLE_HIGH);
-+ REG_SET_BIT(ah, AR_D_GBL_IFS_MISC, AR_D_GBL_IFS_MISC_IGNORE_BACKOFF);
-+
-+ for (q = 0; q < AR_NUM_QCU; q++) {
-+ for (i = 1000; i > 0; i--) {
-+ if (!ath9k_hw_numtxpending(ah, q))
-+ break;
-+
-+ udelay(5);
-+ }
-+ }
-+
-+ REG_CLR_BIT(ah, AR_PCU_MISC, AR_PCU_FORCE_QUIET_COLL | AR_PCU_CLEAR_VMF);
-+ REG_CLR_BIT(ah, AR_DIAG_SW, AR_DIAG_FORCE_CH_IDLE_HIGH);
-+ REG_CLR_BIT(ah, AR_D_GBL_IFS_MISC, AR_D_GBL_IFS_MISC_IGNORE_BACKOFF);
-+
-+ REG_WRITE(ah, AR_Q_TXD, 0);
-+}
-+EXPORT_SYMBOL(ath9k_hw_abort_tx_dma);
-+
- bool ath9k_hw_stoptxdma(struct ath_hw *ah, u32 q)
- {
- #define ATH9K_TX_STOP_DMA_TIMEOUT 4000 /* usec */
---- a/drivers/net/wireless/ath/ath9k/mac.h
-+++ b/drivers/net/wireless/ath/ath9k/mac.h
-@@ -676,6 +676,7 @@ void ath9k_hw_cleartxdesc(struct ath_hw
- u32 ath9k_hw_numtxpending(struct ath_hw *ah, u32 q);
- bool ath9k_hw_updatetxtriglevel(struct ath_hw *ah, bool bIncTrigLevel);
- bool ath9k_hw_stoptxdma(struct ath_hw *ah, u32 q);
-+void ath9k_hw_abort_tx_dma(struct ath_hw *ah);
- void ath9k_hw_gettxintrtxqs(struct ath_hw *ah, u32 *txqs);
- bool ath9k_hw_set_txq_props(struct ath_hw *ah, int q,
- const struct ath9k_tx_queue_info *qinfo);
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/main.c
-+++ b/drivers/net/wireless/ath/ath9k/main.c
-@@ -2149,56 +2149,40 @@ static void ath9k_set_coverage_class(str
-
- static void ath9k_flush(struct ieee80211_hw *hw, bool drop)
- {
--#define ATH_FLUSH_TIMEOUT 60 /* ms */
- struct ath_softc *sc = hw->priv;
-- struct ath_txq *txq = NULL;
-- struct ath_hw *ah = sc->sc_ah;
-- struct ath_common *common = ath9k_hw_common(ah);
-- int i, j, npend = 0;
-+ int timeout = 200; /* ms */
-+ int i, j;
-
-+ ath9k_ps_wakeup(sc);
- mutex_lock(&sc->mutex);
-
- cancel_delayed_work_sync(&sc->tx_complete_work);
-
-- for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
-- if (!ATH_TXQ_SETUP(sc, i))
-- continue;
-- txq = &sc->tx.txq[i];
--
-- if (!drop) {
-- for (j = 0; j < ATH_FLUSH_TIMEOUT; j++) {
-- if (!ath9k_has_pending_frames(sc, txq))
-- break;
-- usleep_range(1000, 2000);
-- }
-- }
-+ if (drop)
-+ timeout = 1;
-
-- if (drop || ath9k_has_pending_frames(sc, txq)) {
-- ath_dbg(common, ATH_DBG_QUEUE, "Drop frames from hw queue:%d\n",
-- txq->axq_qnum);
-- spin_lock_bh(&txq->axq_lock);
-- txq->txq_flush_inprogress = true;
-- spin_unlock_bh(&txq->axq_lock);
--
-- ath9k_ps_wakeup(sc);
-- ath9k_hw_stoptxdma(ah, txq->axq_qnum);
-- npend = ath9k_hw_numtxpending(ah, txq->axq_qnum);
-- ath9k_ps_restore(sc);
-- if (npend)
-- break;
-+ for (j = 0; j < timeout; j++) {
-+ int npend = 0;
-+ for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
-+ if (!ATH_TXQ_SETUP(sc, i))
-+ continue;
-
-- ath_draintxq(sc, txq, false);
-- txq->txq_flush_inprogress = false;
-+ npend += ath9k_has_pending_frames(sc, &sc->tx.txq[i]);
- }
-+
-+ if (!npend)
-+ goto out;
-+
-+ usleep_range(1000, 2000);
- }
-
-- if (npend) {
-+ if (!ath_drain_all_txq(sc, false))
- ath_reset(sc, false);
-- txq->txq_flush_inprogress = false;
-- }
-
-+out:
- ieee80211_queue_delayed_work(hw, &sc->tx_complete_work, 0);
- mutex_unlock(&sc->mutex);
-+ ath9k_ps_restore(sc);
- }
-
- struct ieee80211_ops ath9k_ops = {
---- a/drivers/net/wireless/ath/ath9k/ath9k.h
-+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
-@@ -189,7 +189,6 @@ struct ath_txq {
- u32 axq_ampdu_depth;
- bool stopped;
- bool axq_tx_inprogress;
-- bool txq_flush_inprogress;
- struct list_head axq_acq;
- struct list_head txq_fifo[ATH_TXFIFO_DEPTH];
- struct list_head txq_fifo_pending;
---- a/drivers/net/wireless/ath/ath9k/xmit.c
-+++ b/drivers/net/wireless/ath/ath9k/xmit.c
-@@ -2091,8 +2091,7 @@ static void ath_tx_processq(struct ath_s
- spin_lock_bh(&txq->axq_lock);
- if (list_empty(&txq->axq_q)) {
- txq->axq_link = NULL;
-- if (sc->sc_flags & SC_OP_TXAGGR &&
-- !txq->txq_flush_inprogress)
-+ if (sc->sc_flags & SC_OP_TXAGGR)
- ath_txq_schedule(sc, txq);
- spin_unlock_bh(&txq->axq_lock);
- break;
-@@ -2173,7 +2172,7 @@ static void ath_tx_processq(struct ath_s
-
- spin_lock_bh(&txq->axq_lock);
-
-- if (sc->sc_flags & SC_OP_TXAGGR && !txq->txq_flush_inprogress)
-+ if (sc->sc_flags & SC_OP_TXAGGR)
- ath_txq_schedule(sc, txq);
- spin_unlock_bh(&txq->axq_lock);
- }
-@@ -2317,18 +2316,17 @@ void ath_tx_edma_tasklet(struct ath_soft
-
- spin_lock_bh(&txq->axq_lock);
-
-- if (!txq->txq_flush_inprogress) {
-- if (!list_empty(&txq->txq_fifo_pending)) {
-- INIT_LIST_HEAD(&bf_head);
-- bf = list_first_entry(&txq->txq_fifo_pending,
-- struct ath_buf, list);
-- list_cut_position(&bf_head,
-- &txq->txq_fifo_pending,
-- &bf->bf_lastbf->list);
-- ath_tx_txqaddbuf(sc, txq, &bf_head);
-- } else if (sc->sc_flags & SC_OP_TXAGGR)
-- ath_txq_schedule(sc, txq);
-- }
-+ if (!list_empty(&txq->txq_fifo_pending)) {
-+ INIT_LIST_HEAD(&bf_head);
-+ bf = list_first_entry(&txq->txq_fifo_pending,
-+ struct ath_buf, list);
-+ list_cut_position(&bf_head,
-+ &txq->txq_fifo_pending,
-+ &bf->bf_lastbf->list);
-+ ath_tx_txqaddbuf(sc, txq, &bf_head);
-+ } else if (sc->sc_flags & SC_OP_TXAGGR)
-+ ath_txq_schedule(sc, txq);
-+
- spin_unlock_bh(&txq->axq_lock);
- }
- }
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/mac.c
-+++ b/drivers/net/wireless/ath/ath9k/mac.c
-@@ -170,84 +170,30 @@ void ath9k_hw_abort_tx_dma(struct ath_hw
- }
- EXPORT_SYMBOL(ath9k_hw_abort_tx_dma);
-
--bool ath9k_hw_stoptxdma(struct ath_hw *ah, u32 q)
-+bool ath9k_hw_stop_dma_queue(struct ath_hw *ah, u32 q)
- {
--#define ATH9K_TX_STOP_DMA_TIMEOUT 4000 /* usec */
-+#define ATH9K_TX_STOP_DMA_TIMEOUT 1000 /* usec */
- #define ATH9K_TIME_QUANTUM 100 /* usec */
-- struct ath_common *common = ath9k_hw_common(ah);
-- struct ath9k_hw_capabilities *pCap = &ah->caps;
-- struct ath9k_tx_queue_info *qi;
-- u32 tsfLow, j, wait;
-- u32 wait_time = ATH9K_TX_STOP_DMA_TIMEOUT / ATH9K_TIME_QUANTUM;
--
-- if (q >= pCap->total_queues) {
-- ath_dbg(common, ATH_DBG_QUEUE,
-- "Stopping TX DMA, invalid queue: %u\n", q);
-- return false;
-- }
--
-- qi = &ah->txq[q];
-- if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) {
-- ath_dbg(common, ATH_DBG_QUEUE,
-- "Stopping TX DMA, inactive queue: %u\n", q);
-- return false;
-- }
-+ int wait_time = ATH9K_TX_STOP_DMA_TIMEOUT / ATH9K_TIME_QUANTUM;
-+ int wait;
-
- REG_WRITE(ah, AR_Q_TXD, 1 << q);
-
- for (wait = wait_time; wait != 0; wait--) {
- if (ath9k_hw_numtxpending(ah, q) == 0)
- break;
-- udelay(ATH9K_TIME_QUANTUM);
-- }
-
-- if (ath9k_hw_numtxpending(ah, q)) {
-- ath_dbg(common, ATH_DBG_QUEUE,
-- "%s: Num of pending TX Frames %d on Q %d\n",
-- __func__, ath9k_hw_numtxpending(ah, q), q);
--
-- for (j = 0; j < 2; j++) {
-- tsfLow = REG_READ(ah, AR_TSF_L32);
-- REG_WRITE(ah, AR_QUIET2,
-- SM(10, AR_QUIET2_QUIET_DUR));
-- REG_WRITE(ah, AR_QUIET_PERIOD, 100);
-- REG_WRITE(ah, AR_NEXT_QUIET_TIMER, tsfLow >> 10);
-- REG_SET_BIT(ah, AR_TIMER_MODE,
-- AR_QUIET_TIMER_EN);
--
-- if ((REG_READ(ah, AR_TSF_L32) >> 10) == (tsfLow >> 10))
-- break;
--
-- ath_dbg(common, ATH_DBG_QUEUE,
-- "TSF has moved while trying to set quiet time TSF: 0x%08x\n",
-- tsfLow);
-- }
--
-- REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_FORCE_CH_IDLE_HIGH);
--
-- udelay(200);
-- REG_CLR_BIT(ah, AR_TIMER_MODE, AR_QUIET_TIMER_EN);
--
-- wait = wait_time;
-- while (ath9k_hw_numtxpending(ah, q)) {
-- if ((--wait) == 0) {
-- ath_err(common,
-- "Failed to stop TX DMA in 100 msec after killing last frame\n");
-- break;
-- }
-- udelay(ATH9K_TIME_QUANTUM);
-- }
--
-- REG_CLR_BIT(ah, AR_DIAG_SW, AR_DIAG_FORCE_CH_IDLE_HIGH);
-+ udelay(ATH9K_TIME_QUANTUM);
- }
-
- REG_WRITE(ah, AR_Q_TXD, 0);
-+
- return wait != 0;
-
- #undef ATH9K_TX_STOP_DMA_TIMEOUT
- #undef ATH9K_TIME_QUANTUM
- }
--EXPORT_SYMBOL(ath9k_hw_stoptxdma);
-+EXPORT_SYMBOL(ath9k_hw_stop_dma_queue);
-
- void ath9k_hw_gettxintrtxqs(struct ath_hw *ah, u32 *txqs)
- {
---- a/drivers/net/wireless/ath/ath9k/mac.h
-+++ b/drivers/net/wireless/ath/ath9k/mac.h
-@@ -675,7 +675,7 @@ void ath9k_hw_txstart(struct ath_hw *ah,
- void ath9k_hw_cleartxdesc(struct ath_hw *ah, void *ds);
- u32 ath9k_hw_numtxpending(struct ath_hw *ah, u32 q);
- bool ath9k_hw_updatetxtriglevel(struct ath_hw *ah, bool bIncTrigLevel);
--bool ath9k_hw_stoptxdma(struct ath_hw *ah, u32 q);
-+bool ath9k_hw_stop_dma_queue(struct ath_hw *ah, u32 q);
- void ath9k_hw_abort_tx_dma(struct ath_hw *ah);
- void ath9k_hw_gettxintrtxqs(struct ath_hw *ah, u32 *txqs);
- bool ath9k_hw_set_txq_props(struct ath_hw *ah, int q,
---- a/drivers/net/wireless/ath/ath9k/beacon.c
-+++ b/drivers/net/wireless/ath/ath9k/beacon.c
-@@ -373,6 +373,7 @@ void ath_beacon_tasklet(unsigned long da
- ath_dbg(common, ATH_DBG_BSTUCK,
- "missed %u consecutive beacons\n",
- sc->beacon.bmisscnt);
-+ ath9k_hw_stop_dma_queue(ah, sc->beacon.beaconq);
- ath9k_hw_bstuck_nfcal(ah);
- } else if (sc->beacon.bmisscnt >= BSTUCK_THRESH) {
- ath_dbg(common, ATH_DBG_BSTUCK,
-@@ -450,16 +451,6 @@ void ath_beacon_tasklet(unsigned long da
- sc->beacon.updateslot = OK;
- }
- if (bfaddr != 0) {
-- /*
-- * Stop any current dma and put the new frame(s) on the queue.
-- * This should never fail since we check above that no frames
-- * are still pending on the queue.
-- */
-- if (!ath9k_hw_stoptxdma(ah, sc->beacon.beaconq)) {
-- ath_err(common, "beacon queue %u did not stop?\n",
-- sc->beacon.beaconq);
-- }
--
- /* NB: cabq traffic should already be queued and primed */
- ath9k_hw_puttxbuf(ah, sc->beacon.beaconq, bfaddr);
- ath9k_hw_txstart(ah, sc->beacon.beaconq);
-@@ -780,7 +771,7 @@ void ath9k_set_beaconing_status(struct a
- ah->imask &= ~ATH9K_INT_SWBA;
- ath9k_hw_set_interrupts(ah, ah->imask);
- tasklet_kill(&sc->bcon_tasklet);
-- ath9k_hw_stoptxdma(ah, sc->beacon.beaconq);
-+ ath9k_hw_stop_dma_queue(ah, sc->beacon.beaconq);
- }
- ath9k_ps_restore(sc);
- }
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/hw.c
-+++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -411,6 +411,8 @@ static void ath9k_hw_init_defaults(struc
- ah->sta_id1_defaults =
- AR_STA_ID1_CRPT_MIC_ENABLE |
- AR_STA_ID1_MCAST_KSRCH;
-+ if (AR_SREV_9100(ah))
-+ ah->sta_id1_defaults |= AR_STA_ID1_AR9100_BA_FIX;
- ah->enable_32kHz_clock = DONT_USE_32KHZ;
- ah->slottime = 20;
- ah->globaltxtimeout = (u32) -1;
---- a/drivers/net/wireless/ath/ath9k/reg.h
-+++ b/drivers/net/wireless/ath/ath9k/reg.h
-@@ -1396,6 +1396,7 @@ enum {
- #define AR_STA_ID1_PCF 0x00100000
- #define AR_STA_ID1_USE_DEFANT 0x00200000
- #define AR_STA_ID1_DEFANT_UPDATE 0x00400000
-+#define AR_STA_ID1_AR9100_BA_FIX 0x00400000
- #define AR_STA_ID1_RTS_USE_DEF 0x00800000
- #define AR_STA_ID1_ACKCTS_6MB 0x01000000
- #define AR_STA_ID1_BASE_RATE_11B 0x02000000
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/hw.c
-+++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -1878,6 +1878,8 @@ int ath9k_hw_fill_cap_info(struct ath_hw
- !(AR_SREV_9271(ah)))
- /* CB71: GPIO 0 is pulled down to indicate 3 rx chains */
- pCap->rx_chainmask = ath9k_hw_gpio_get(ah, 0) ? 0x5 : 0x7;
-+ else if (AR_SREV_9100(ah))
-+ pCap->rx_chainmask = 0x7;
- else
- /* Use rx_chainmask from EEPROM. */
- pCap->rx_chainmask = ah->eep_ops->get_eeprom(ah, EEP_RX_MASK);
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/main.c
-+++ b/drivers/net/wireless/ath/ath9k/main.c
-@@ -1048,6 +1048,8 @@ static int ath9k_start(struct ieee80211_
- "Starting driver with initial channel: %d MHz\n",
- curchan->center_freq);
-
-+ ath9k_ps_wakeup(sc);
-+
- mutex_lock(&sc->mutex);
-
- /* setup initial channel */
-@@ -1143,6 +1145,8 @@ static int ath9k_start(struct ieee80211_
- mutex_unlock:
- mutex_unlock(&sc->mutex);
-
-+ ath9k_ps_restore(sc);
-+
- return r;
- }
-
+++ /dev/null
---- a/net/mac80211/rx.c
-+++ b/net/mac80211/rx.c
-@@ -1582,7 +1582,7 @@ ieee80211_drop_unencrypted_mgmt(struct i
- }
-
- static int
--__ieee80211_data_to_8023(struct ieee80211_rx_data *rx)
-+__ieee80211_data_to_8023(struct ieee80211_rx_data *rx, bool *port_control)
- {
- struct ieee80211_sub_if_data *sdata = rx->sdata;
- struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data;
-@@ -1590,6 +1590,7 @@ __ieee80211_data_to_8023(struct ieee8021
- struct ethhdr *ehdr;
- int ret;
-
-+ *port_control = false;
- if (ieee80211_has_a4(hdr->frame_control) &&
- sdata->vif.type == NL80211_IFTYPE_AP_VLAN && !sdata->u.vlan.sta)
- return -1;
-@@ -1608,11 +1609,14 @@ __ieee80211_data_to_8023(struct ieee8021
- return -1;
-
- ret = ieee80211_data_to_8023(rx->skb, sdata->vif.addr, sdata->vif.type);
-- if (ret < 0 || !check_port_control)
-+ if (ret < 0)
- return ret;
-
- ehdr = (struct ethhdr *) rx->skb->data;
-- if (ehdr->h_proto != rx->sdata->control_port_protocol)
-+ if (ehdr->h_proto == rx->sdata->control_port_protocol)
-+ *port_control = true;
-+
-+ if (check_port_control && !*port_control)
- return -1;
-
- return 0;
-@@ -1913,6 +1917,7 @@ ieee80211_rx_h_data(struct ieee80211_rx_
- struct net_device *dev = sdata->dev;
- struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data;
- __le16 fc = hdr->frame_control;
-+ bool port_control;
- int err;
-
- if (unlikely(!ieee80211_is_data(hdr->frame_control)))
-@@ -1929,13 +1934,21 @@ ieee80211_rx_h_data(struct ieee80211_rx_
- sdata->vif.type == NL80211_IFTYPE_AP)
- return RX_DROP_MONITOR;
-
-- err = __ieee80211_data_to_8023(rx);
-+ err = __ieee80211_data_to_8023(rx, &port_control);
- if (unlikely(err))
- return RX_DROP_UNUSABLE;
-
- if (!ieee80211_frame_allowed(rx, fc))
- return RX_DROP_MONITOR;
-
-+ if (rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
-+ unlikely(port_control) && sdata->bss) {
-+ sdata = container_of(sdata->bss, struct ieee80211_sub_if_data,
-+ u.ap);
-+ dev = sdata->dev;
-+ rx->sdata = sdata;
-+ }
-+
- rx->skb->dev = dev;
-
- dev->stats.rx_packets++;
+++ /dev/null
---- a/net/mac80211/chan.c
-+++ b/net/mac80211/chan.c
-@@ -76,6 +76,7 @@ bool ieee80211_set_channel_type(struct i
-
- switch (tmp->vif.bss_conf.channel_type) {
- case NL80211_CHAN_NO_HT:
-+ break;
- case NL80211_CHAN_HT20:
- superchan = tmp->vif.bss_conf.channel_type;
- break;
+++ /dev/null
---- a/net/mac80211/ibss.c
-+++ b/net/mac80211/ibss.c
-@@ -661,7 +661,6 @@ static void ieee80211_sta_find_ibss(stru
- static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata,
- struct sk_buff *req)
- {
-- struct ieee80211_rx_status *rx_status = IEEE80211_SKB_RXCB(req);
- struct ieee80211_mgmt *mgmt = (void *)req->data;
- struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
- struct ieee80211_local *local = sdata->local;
-@@ -685,7 +684,7 @@ static void ieee80211_rx_mgmt_probe_req(
- mgmt->bssid, tx_last_beacon);
- #endif /* CONFIG_MAC80211_IBSS_DEBUG */
-
-- if (!tx_last_beacon && !(rx_status->rx_flags & IEEE80211_RX_RA_MATCH))
-+ if (!tx_last_beacon && is_multicast_ether_addr(mgmt->da))
- return;
-
- if (memcmp(mgmt->bssid, ifibss->bssid, ETH_ALEN) != 0 &&
+++ /dev/null
---- a/net/mac80211/rc80211_minstrel_ht.c
-+++ b/net/mac80211/rc80211_minstrel_ht.c
-@@ -634,18 +634,14 @@ minstrel_ht_update_caps(void *priv, stru
- struct ieee80211_mcs_info *mcs = &sta->ht_cap.mcs;
- struct ieee80211_local *local = hw_to_local(mp->hw);
- u16 sta_cap = sta->ht_cap.cap;
-+ int n_supported = 0;
- int ack_dur;
- int stbc;
- int i;
-
- /* fall back to the old minstrel for legacy stations */
-- if (!sta->ht_cap.ht_supported) {
-- msp->is_ht = false;
-- memset(&msp->legacy, 0, sizeof(msp->legacy));
-- msp->legacy.r = msp->ratelist;
-- msp->legacy.sample_table = msp->sample_table;
-- return mac80211_minstrel.rate_init(priv, sband, sta, &msp->legacy);
-- }
-+ if (!sta->ht_cap.ht_supported)
-+ goto use_legacy;
-
- BUILD_BUG_ON(ARRAY_SIZE(minstrel_mcs_groups) !=
- MINSTREL_MAX_STREAMS * MINSTREL_STREAM_GROUPS);
-@@ -700,7 +696,22 @@ minstrel_ht_update_caps(void *priv, stru
-
- mi->groups[i].supported =
- mcs->rx_mask[minstrel_mcs_groups[i].streams - 1];
-+
-+ if (mi->groups[i].supported)
-+ n_supported++;
- }
-+
-+ if (!n_supported)
-+ goto use_legacy;
-+
-+ return;
-+
-+use_legacy:
-+ msp->is_ht = false;
-+ memset(&msp->legacy, 0, sizeof(msp->legacy));
-+ msp->legacy.r = msp->ratelist;
-+ msp->legacy.sample_table = msp->sample_table;
-+ return mac80211_minstrel.rate_init(priv, sband, sta, &msp->legacy);
- }
-
- static void
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/xmit.c
-+++ b/drivers/net/wireless/ath/ath9k/xmit.c
-@@ -166,7 +166,7 @@ static void ath_tx_flush_tid(struct ath_
- fi = get_frame_info(bf->bf_mpdu);
- if (fi->retries) {
- ath_tx_update_baw(sc, tid, fi->seqno);
-- ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0, 0);
-+ ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0, 1);
- } else {
- ath_tx_send_normal(sc, txq, NULL, &bf_head);
- }
--- a/drivers/net/wireless/mwl8k.c
+++ b/drivers/net/wireless/mwl8k.c
-@@ -4502,6 +4502,7 @@ MODULE_FIRMWARE("mwl8k/fmimage_8366.fw")
+@@ -5111,6 +5111,7 @@ MODULE_FIRMWARE("mwl8k/fmimage_8366.fw")
MODULE_FIRMWARE(MWL8K_8366_AP_FW(MWL8K_8366_AP_FW_API));
static DEFINE_PCI_DEVICE_TABLE(mwl8k_pci_id_table) = {
+++ /dev/null
---- a/drivers/net/wireless/p54/eeprom.c
-+++ b/drivers/net/wireless/p54/eeprom.c
-@@ -524,10 +524,13 @@ err_data:
-
- struct p54_rssi_db_entry *p54_rssi_find(struct p54_common *priv, const u16 freq)
- {
-- struct p54_rssi_db_entry *entry = (void *)(priv->rssi_db->data +
-- priv->rssi_db->offset);
-+ struct p54_rssi_db_entry *entry;
- int i, found = -1;
-
-+ if (!priv->rssi_db)
-+ return &p54_rssi_default;
-+
-+ entry = (void *)(priv->rssi_db->data + priv->rssi_db->offset);
- for (i = 0; i < priv->rssi_db->entries; i++) {
- if (!same_band(freq, entry[i].freq))
- continue;
+++ /dev/null
-Index: compat-wireless-2011-02-25/net/mac80211/main.c
-===================================================================
---- compat-wireless-2011-02-25.orig/net/mac80211/main.c 2011-03-07 12:58:14.996968980 +0100
-+++ compat-wireless-2011-02-25/net/mac80211/main.c 2011-03-07 13:03:26.732273903 +0100
-@@ -384,6 +384,9 @@ void ieee80211_restart_hw(struct ieee802
-
- trace_api_restart_hw(local);
-
-+ wiphy_info(hw->wiphy,
-+ "Hardware restart was requested\n");
-+
- /* use this reason, ieee80211_reconfig will unblock it */
- ieee80211_stop_queues_by_reason(hw,
- IEEE80211_QUEUE_STOP_REASON_SUSPEND);
+++ /dev/null
-Index: compat-wireless-2011-02-25/net/mac80211/scan.c
-===================================================================
---- compat-wireless-2011-02-25.orig/net/mac80211/scan.c 2011-03-07 14:43:55.695666042 +0100
-+++ compat-wireless-2011-02-25/net/mac80211/scan.c 2011-03-07 14:43:57.594439631 +0100
-@@ -258,10 +258,12 @@ static bool ieee80211_prep_hw_scan(struc
- return true;
- }
-
--static bool __ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted,
-+static void __ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted,
- bool was_hw_scan)
- {
- struct ieee80211_local *local = hw_to_local(hw);
-+ bool on_oper_chan;
-+ bool enable_beacons = false;
-
- lockdep_assert_held(&local->mtx);
-
-@@ -275,12 +277,12 @@ static bool __ieee80211_scan_completed(s
- aborted = true;
-
- if (WARN_ON(!local->scan_req))
-- return false;
-+ return;
-
- if (was_hw_scan && !aborted && ieee80211_prep_hw_scan(local)) {
- int rc = drv_hw_scan(local, local->scan_sdata, local->hw_scan_req);
- if (rc == 0)
-- return false;
-+ return;
- }
-
- kfree(local->hw_scan_req);
-@@ -294,26 +296,13 @@ static bool __ieee80211_scan_completed(s
- local->scanning = 0;
- local->scan_channel = NULL;
-
-- return true;
--}
--
--static void __ieee80211_scan_completed_finish(struct ieee80211_hw *hw,
-- bool was_hw_scan)
--{
-- struct ieee80211_local *local = hw_to_local(hw);
-- bool on_oper_chan;
-- bool enable_beacons = false;
--
-- mutex_lock(&local->mtx);
- on_oper_chan = ieee80211_cfg_on_oper_channel(local);
-
- WARN_ON(local->scanning & (SCAN_SW_SCANNING | SCAN_HW_SCANNING));
-
-- if (was_hw_scan || !on_oper_chan) {
-- if (WARN_ON(local->scan_channel))
-- local->scan_channel = NULL;
-+ if (was_hw_scan || !on_oper_chan)
- ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
-- } else
-+ else
- /* Set power back to normal operating levels. */
- ieee80211_hw_config(local, 0);
-
-@@ -331,7 +320,6 @@ static void __ieee80211_scan_completed_f
- }
-
- ieee80211_recalc_idle(local);
-- mutex_unlock(&local->mtx);
-
- ieee80211_mlme_notify_scan_completed(local);
- ieee80211_ibss_notify_scan_completed(local);
-@@ -686,12 +674,14 @@ void ieee80211_scan_work(struct work_str
- {
- struct ieee80211_local *local =
- container_of(work, struct ieee80211_local, scan_work.work);
-- struct ieee80211_sub_if_data *sdata = local->scan_sdata;
-+ struct ieee80211_sub_if_data *sdata;
- unsigned long next_delay = 0;
-- bool aborted, hw_scan, finish;
-+ bool aborted, hw_scan;
-
- mutex_lock(&local->mtx);
-
-+ sdata = local->scan_sdata;
-+
- if (test_and_clear_bit(SCAN_COMPLETED, &local->scanning)) {
- aborted = test_and_clear_bit(SCAN_ABORTED, &local->scanning);
- goto out_complete;
-@@ -755,17 +745,11 @@ void ieee80211_scan_work(struct work_str
- } while (next_delay == 0);
-
- ieee80211_queue_delayed_work(&local->hw, &local->scan_work, next_delay);
-- mutex_unlock(&local->mtx);
-- return;
-+ goto out;
-
- out_complete:
- hw_scan = test_bit(SCAN_HW_SCANNING, &local->scanning);
-- finish = __ieee80211_scan_completed(&local->hw, aborted, hw_scan);
-- mutex_unlock(&local->mtx);
-- if (finish)
-- __ieee80211_scan_completed_finish(&local->hw, hw_scan);
-- return;
--
-+ __ieee80211_scan_completed(&local->hw, aborted, hw_scan);
- out:
- mutex_unlock(&local->mtx);
- }
-@@ -835,7 +819,6 @@ int ieee80211_request_internal_scan(stru
- void ieee80211_scan_cancel(struct ieee80211_local *local)
- {
- bool abortscan;
-- bool finish = false;
-
- /*
- * We are only canceling software scan, or deferred scan that was not
-@@ -855,14 +838,17 @@ void ieee80211_scan_cancel(struct ieee80
-
- mutex_lock(&local->mtx);
- abortscan = local->scan_req && !test_bit(SCAN_HW_SCANNING, &local->scanning);
-- if (abortscan)
-- finish = __ieee80211_scan_completed(&local->hw, true, false);
-- mutex_unlock(&local->mtx);
--
- if (abortscan) {
-- /* The scan is canceled, but stop work from being pending */
-- cancel_delayed_work_sync(&local->scan_work);
-+ /*
-+ * The scan is canceled, but stop work from being pending.
-+ *
-+ * If the work is currently running, it must be blocked on
-+ * the mutex, but we'll set scan_sdata = NULL and it'll
-+ * simply exit once it acquires the mutex.
-+ */
-+ cancel_delayed_work(&local->scan_work);
-+ /* and clean up */
-+ __ieee80211_scan_completed(&local->hw, true, false);
- }
-- if (finish)
-- __ieee80211_scan_completed_finish(&local->hw, false);
-+ mutex_unlock(&local->mtx);
- }