include $(TOPDIR)/rules.mk
PKG_NAME:=hostapd
-PKG_VERSION:=2014-06-03.1
+PKG_VERSION:=2014-10-25
PKG_RELEASE:=1
-PKG_REV:=84df167554569af8c87f0a8ac1fb508192417d8e
+PKG_REV:=01e2231fdc4fbec61fbc382238e3606a1d2826e4
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=git://w1.fi/srv/git/hostap.git
+++ /dev/null
-From 9c829900bb01d6fb22e78ba78195c78de39f64b9 Mon Sep 17 00:00:00 2001
-From: Jouni Malinen <j@w1.fi>
-Date: Sat, 04 Oct 2014 19:11:00 +0000
-Subject: Fix authenticator OKC fetch from PMKSA cache to avoid infinite loop
-
-If the first entry in the PMKSA cache did not match the station's MAC
-address, an infinite loop could be reached in pmksa_cache_get_okc() when
-trying to find a PMKSA cache entry for opportunistic key caching cases.
-This would only happen if OKC is enabled (okc=1 included in the
-configuration file).
-
-Signed-off-by: Jouni Malinen <j@w1.fi>
----
---- a/src/ap/pmksa_cache_auth.c
-+++ b/src/ap/pmksa_cache_auth.c
-@@ -394,15 +394,13 @@ struct rsn_pmksa_cache_entry * pmksa_cac
- struct rsn_pmksa_cache_entry *entry;
- u8 new_pmkid[PMKID_LEN];
-
-- entry = pmksa->pmksa;
-- while (entry) {
-+ for (entry = pmksa->pmksa; entry; entry = entry->next) {
- if (os_memcmp(entry->spa, spa, ETH_ALEN) != 0)
- continue;
- rsn_pmkid(entry->pmk, entry->pmk_len, aa, spa, new_pmkid,
- wpa_key_mgmt_sha256(entry->akmp));
- if (os_memcmp(new_pmkid, pmkid, PMKID_LEN) == 0)
- return entry;
-- entry = entry->next;
- }
- return NULL;
- }
+++ /dev/null
-From 89de07a9442072f88d49869d8ecd8d42bae050a0 Mon Sep 17 00:00:00 2001
-From: Jouni Malinen <jouni@qca.qualcomm.com>
-Date: Mon, 6 Oct 2014 16:27:44 +0300
-Subject: [PATCH 1/3] Add os_exec() helper to run external programs
-
-Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
----
- src/utils/os.h | 9 +++++++++
- src/utils/os_unix.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/utils/os_win32.c | 6 ++++++
- 3 files changed, 70 insertions(+)
-
---- a/src/utils/os.h
-+++ b/src/utils/os.h
-@@ -584,6 +584,15 @@ static inline void os_remove_in_array(vo
- */
- size_t os_strlcpy(char *dest, const char *src, size_t siz);
-
-+/**
-+ * os_exec - Execute an external program
-+ * @program: Path to the program
-+ * @arg: Command line argument string
-+ * @wait_completion: Whether to wait until the program execution completes
-+ * Returns: 0 on success, -1 on error
-+ */
-+int os_exec(const char *program, const char *arg, int wait_completion);
-+
-
- #ifdef OS_REJECT_C_LIB_FUNCTIONS
- #define malloc OS_DO_NOT_USE_malloc
---- a/src/utils/os_unix.c
-+++ b/src/utils/os_unix.c
-@@ -9,6 +9,7 @@
- #include "includes.h"
-
- #include <time.h>
-+#include <sys/wait.h>
-
- #ifdef ANDROID
- #include <sys/capability.h>
-@@ -540,3 +541,57 @@ char * os_strdup(const char *s)
- }
-
- #endif /* WPA_TRACE */
-+
-+
-+int os_exec(const char *program, const char *arg, int wait_completion)
-+{
-+ pid_t pid;
-+ int pid_status;
-+
-+ pid = fork();
-+ if (pid < 0) {
-+ perror("fork");
-+ return -1;
-+ }
-+
-+ if (pid == 0) {
-+ /* run the external command in the child process */
-+ const int MAX_ARG = 30;
-+ char *_program, *_arg, *pos;
-+ char *argv[MAX_ARG + 1];
-+ int i;
-+
-+ _program = os_strdup(program);
-+ _arg = os_strdup(arg);
-+
-+ argv[0] = _program;
-+
-+ i = 1;
-+ pos = _arg;
-+ while (i < MAX_ARG && pos && *pos) {
-+ while (*pos == ' ')
-+ pos++;
-+ if (*pos == '\0')
-+ break;
-+ argv[i++] = pos;
-+ pos = os_strchr(pos, ' ');
-+ if (pos)
-+ *pos++ = '\0';
-+ }
-+ argv[i] = NULL;
-+
-+ execv(program, argv);
-+ perror("execv");
-+ os_free(_program);
-+ os_free(_arg);
-+ exit(0);
-+ return -1;
-+ }
-+
-+ if (wait_completion) {
-+ /* wait for the child process to complete in the parent */
-+ waitpid(pid, &pid_status, 0);
-+ }
-+
-+ return 0;
-+}
---- a/src/utils/os_win32.c
-+++ b/src/utils/os_win32.c
-@@ -244,3 +244,9 @@ size_t os_strlcpy(char *dest, const char
-
- return s - src - 1;
- }
-+
-+
-+int os_exec(const char *program, const char *arg, int wait_completion)
-+{
-+ return -1;
-+}
+++ /dev/null
-From c5f258de76dbb67fb64beab39a99e5c5711f41fe Mon Sep 17 00:00:00 2001
-From: Jouni Malinen <jouni@qca.qualcomm.com>
-Date: Mon, 6 Oct 2014 17:25:52 +0300
-Subject: [PATCH 2/3] wpa_cli: Use os_exec() for action script execution
-
-Use os_exec() to run the action script operations to avoid undesired
-command line processing for control interface event strings. Previously,
-it could have been possible for some of the event strings to include
-unsanitized data which is not suitable for system() use. (CVE-2014-3686)
-
-Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
----
- wpa_supplicant/wpa_cli.c | 25 ++++++++-----------------
- 1 file changed, 8 insertions(+), 17 deletions(-)
-
---- a/wpa_supplicant/wpa_cli.c
-+++ b/wpa_supplicant/wpa_cli.c
-@@ -3149,28 +3149,19 @@ static int str_match(const char *a, cons
- static int wpa_cli_exec(const char *program, const char *arg1,
- const char *arg2)
- {
-- char *cmd;
-+ char *arg;
- size_t len;
- int res;
-- int ret = 0;
-
-- len = os_strlen(program) + os_strlen(arg1) + os_strlen(arg2) + 3;
-- cmd = os_malloc(len);
-- if (cmd == NULL)
-+ len = os_strlen(arg1) + os_strlen(arg2) + 2;
-+ arg = os_malloc(len);
-+ if (arg == NULL)
- return -1;
-- res = os_snprintf(cmd, len, "%s %s %s", program, arg1, arg2);
-- if (res < 0 || (size_t) res >= len) {
-- os_free(cmd);
-- return -1;
-- }
-- cmd[len - 1] = '\0';
--#ifndef _WIN32_WCE
-- if (system(cmd) < 0)
-- ret = -1;
--#endif /* _WIN32_WCE */
-- os_free(cmd);
-+ os_snprintf(arg, len, "%s %s", arg1, arg2);
-+ res = os_exec(program, arg, 1);
-+ os_free(arg);
-
-- return ret;
-+ return res;
- }
-
-
+++ /dev/null
-From 5d4fa2a29bef013e61185beb21a3ec110885eb9a Mon Sep 17 00:00:00 2001
-From: Jouni Malinen <jouni@qca.qualcomm.com>
-Date: Mon, 6 Oct 2014 18:49:01 +0300
-Subject: [PATCH 3/3] hostapd_cli: Use os_exec() for action script execution
-
-Use os_exec() to run the action script operations to avoid undesired
-command line processing for control interface event strings. Previously,
-it could have been possible for some of the event strings to include
-unsanitized data which is not suitable for system() use. (CVE-2014-3686)
-
-Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
----
- hostapd/hostapd_cli.c | 25 ++++++++-----------------
- 1 file changed, 8 insertions(+), 17 deletions(-)
-
---- a/hostapd/hostapd_cli.c
-+++ b/hostapd/hostapd_cli.c
-@@ -238,28 +238,19 @@ static int hostapd_cli_cmd_mib(struct wp
- static int hostapd_cli_exec(const char *program, const char *arg1,
- const char *arg2)
- {
-- char *cmd;
-+ char *arg;
- size_t len;
- int res;
-- int ret = 0;
-
-- len = os_strlen(program) + os_strlen(arg1) + os_strlen(arg2) + 3;
-- cmd = os_malloc(len);
-- if (cmd == NULL)
-+ len = os_strlen(arg1) + os_strlen(arg2) + 2;
-+ arg = os_malloc(len);
-+ if (arg == NULL)
- return -1;
-- res = os_snprintf(cmd, len, "%s %s %s", program, arg1, arg2);
-- if (res < 0 || (size_t) res >= len) {
-- os_free(cmd);
-- return -1;
-- }
-- cmd[len - 1] = '\0';
--#ifndef _WIN32_WCE
-- if (system(cmd) < 0)
-- ret = -1;
--#endif /* _WIN32_WCE */
-- os_free(cmd);
-+ os_snprintf(arg, len, "%s %s", arg1, arg2);
-+ res = os_exec(program, arg, 1);
-+ os_free(arg);
-
-- return ret;
-+ return res;
- }
-
-
--- a/src/ap/ieee802_1x.c
+++ b/src/ap/ieee802_1x.c
-@@ -2119,9 +2119,9 @@ void ieee802_1x_notify_pre_auth(struct e
+@@ -2232,9 +2232,9 @@ void ieee802_1x_notify_pre_auth(struct e
}
#ifdef ANDROID
#include <sys/capability.h>
-@@ -155,59 +156,46 @@ int os_gmtime(os_time_t t, struct os_tm
+@@ -155,59 +156,46 @@ int os_gmtime(os_time_t t, struct os_tm
return 0;
}
ifdef CONFIG_TESTING_OPTIONS
CFLAGS += -DCONFIG_TESTING_OPTIONS
-@@ -223,10 +224,14 @@ ifdef CONFIG_IEEE80211AC
+@@ -224,10 +225,14 @@ ifdef CONFIG_IEEE80211AC
CFLAGS += -DCONFIG_IEEE80211AC
endif
LIBS += $(DRV_AP_LIBS)
ifdef CONFIG_L2_PACKET
-@@ -913,6 +918,12 @@ install: all
+@@ -914,6 +919,12 @@ install: all
BCHECK=../src/drivers/build.hostapd
hostapd: $(BCHECK) $(OBJS)
$(Q)$(CC) $(LDFLAGS) -o hostapd $(OBJS) $(LIBS)
@$(E) " LD " $@
-@@ -951,6 +962,12 @@ HOBJS += ../src/crypto/aes-internal.o
+@@ -952,6 +963,12 @@ HOBJS += ../src/crypto/aes-internal.o
HOBJS += ../src/crypto/aes-internal-enc.o
endif
ifdef CONFIG_TESTING_OPTIONS
CFLAGS += -DCONFIG_TESTING_OPTIONS
-@@ -741,6 +742,10 @@ ifdef CONFIG_DYNAMIC_EAP_METHODS
+@@ -745,6 +746,10 @@ ifdef CONFIG_DYNAMIC_EAP_METHODS
CFLAGS += -DCONFIG_DYNAMIC_EAP_METHODS
LIBS += -ldl -rdynamic
endif
endif
ifdef CONFIG_MACSEC
-@@ -762,9 +767,11 @@ NEED_EAP_COMMON=y
+@@ -765,9 +770,11 @@ NEED_EAP_COMMON=y
NEED_RSN_AUTHENTICATOR=y
CFLAGS += -DCONFIG_AP
OBJS += ap.o
OBJS += ../src/ap/hostapd.o
OBJS += ../src/ap/wpa_auth_glue.o
OBJS += ../src/ap/utils.o
-@@ -826,10 +833,18 @@ endif
+@@ -830,10 +837,18 @@ endif
ifdef CONFIG_HS20
OBJS += ../src/ap/hs20.o
endif
NEED_AES_WRAP=y
OBJS += ../src/ap/wpa_auth.o
OBJS += ../src/ap/wpa_auth_ie.o
-@@ -1602,6 +1617,12 @@ wpa_priv: $(BCHECK) $(OBJS_priv)
+@@ -1589,6 +1604,12 @@ wpa_priv: $(BCHECK) $(OBJS_priv)
$(OBJS_c) $(OBJS_t) $(OBJS_t2) $(OBJS) $(BCHECK) $(EXTRA_progs): .config
wpa_supplicant: $(BCHECK) $(OBJS) $(EXTRA_progs)
$(Q)$(LDO) $(LDFLAGS) -o wpa_supplicant $(OBJS) $(LIBS) $(EXTRALIBS)
@$(E) " LD " $@
-@@ -1682,6 +1703,12 @@ endif
+@@ -1669,6 +1690,12 @@ endif
%@.service: %.service.arg.in
sed -e 's|\@BINDIR\@|$(BINDIR)|g' $< >$@
wpa_cli.exe: wpa_cli
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
-@@ -4117,8 +4117,8 @@ union wpa_event_data {
+@@ -4294,8 +4294,8 @@ union wpa_event_data {
* Driver wrapper code should call this function whenever an event is received
* from the driver.
*/
/*
--- a/src/ap/drv_callbacks.c
+++ b/src/ap/drv_callbacks.c
-@@ -926,8 +926,8 @@ static void hostapd_event_dfs_nop_finish
+@@ -989,8 +989,8 @@ static void hostapd_event_dfs_nop_finish
#endif /* NEED_AP_MLME */
for (;;) {
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
-@@ -2919,8 +2919,8 @@ static void wpa_supplicant_notify_avoid_
+@@ -2924,8 +2924,8 @@ static void wpa_supplicant_event_assoc_a
}
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
-@@ -3811,6 +3811,9 @@ static void wpa_supplicant_deinit_iface(
+@@ -3980,6 +3980,9 @@ static void wpa_supplicant_deinit_iface(
os_free(wpa_s);
}
/**
* wpa_supplicant_add_iface - Add a new network interface
-@@ -4002,6 +4005,7 @@ struct wpa_global * wpa_supplicant_init(
+@@ -4181,6 +4184,7 @@ struct wpa_global * wpa_supplicant_init(
wpa_msg_register_ifname_cb(wpa_supplicant_msg_ifname_cb);
#endif /* CONFIG_NO_WPA_MSG */
wpa_debug_open_syslog();
--- a/hostapd/main.c
+++ b/hostapd/main.c
-@@ -502,6 +502,9 @@ static int hostapd_get_ctrl_iface_group(
+@@ -504,6 +504,9 @@ static int hostapd_get_ctrl_iface_group(
return 0;
}
#ifdef CONFIG_WPS
static int gen_uuid(const char *txt_addr)
-@@ -553,6 +556,7 @@ int main(int argc, char *argv[])
+@@ -555,6 +558,7 @@ int main(int argc, char *argv[])
interfaces.global_iface_name = NULL;
interfaces.global_ctrl_sock = -1;
struct wpa_driver_ops *wpa_drivers[] = { NULL };
-@@ -1185,6 +1189,8 @@ static void usage(void)
+@@ -1194,6 +1198,8 @@ static void usage(void)
"option several times.\n");
}
int main(int argc, char *argv[])
{
-@@ -1203,6 +1209,7 @@ int main(int argc, char *argv[])
+@@ -1212,6 +1218,7 @@ int main(int argc, char *argv[])
if (os_program_init())
return -1;
--- a/hostapd/config_file.c
+++ b/hostapd/config_file.c
-@@ -2639,6 +2639,8 @@ static int hostapd_config_fill(struct ho
+@@ -2651,6 +2651,8 @@ static int hostapd_config_fill(struct ho
}
#endif /* CONFIG_IEEE80211W */
#ifdef CONFIG_IEEE80211N
} else if (os_strcmp(buf, "ht_capab") == 0) {
--- a/src/ap/ap_config.h
+++ b/src/ap/ap_config.h
-@@ -576,6 +576,7 @@ struct hostapd_config {
+@@ -605,6 +605,7 @@ struct hostapd_config {
int ht_op_mode_fixed;
u16 ht_capab;
hostapd_set_state(iface, HAPD_IFACE_HT_SCAN);
--- a/src/ap/ieee802_11_ht.c
+++ b/src/ap/ieee802_11_ht.c
-@@ -221,6 +221,9 @@ void hostapd_2040_coex_action(struct hos
+@@ -220,6 +220,9 @@ void hostapd_2040_coex_action(struct hos
if (!(iface->conf->ht_capab & HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET))
return;
+ if (iface->conf->noscan)
+ return;
+
- hdr_len = data - (u8 *) mgmt;
- if (hdr_len > len)
+ if (len < IEEE80211_HDRLEN + 1)
return;
-@@ -319,6 +322,9 @@ void ht40_intolerant_add(struct hostapd_
+ data++;
+@@ -317,6 +320,9 @@ void ht40_intolerant_add(struct hostapd_
if (iface->current_mode->mode != HOSTAPD_MODE_IEEE80211G)
return;
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
-@@ -2752,7 +2752,7 @@ static struct wpa_supplicant * wpa_suppl
+@@ -2914,7 +2914,7 @@ static struct wpa_supplicant * wpa_suppl
if (wpa_s == NULL)
return NULL;
wpa_s->scan_req = INITIAL_SCAN_REQ;
ifdef CONFIG_LIBNL32
DRV_LIBS += -lnl-3
-@@ -114,7 +113,6 @@ DRV_WPA_CFLAGS += -DCONFIG_DRIVER_WEXT
+@@ -115,7 +114,6 @@ DRV_WPA_CFLAGS += -DCONFIG_DRIVER_WEXT
CONFIG_WIRELESS_EXTENSION=y
NEED_NETLINK=y
NEED_LINUX_IOCTL=y
endif
ifdef CONFIG_DRIVER_NDIS
-@@ -140,7 +138,6 @@ endif
+@@ -141,7 +139,6 @@ endif
ifdef CONFIG_WIRELESS_EXTENSION
DRV_WPA_CFLAGS += -DCONFIG_WIRELESS_EXTENSION
DRV_WPA_OBJS += ../src/drivers/driver_wext.o
endif
ifdef NEED_NETLINK
-@@ -153,6 +150,7 @@ endif
+@@ -154,6 +151,7 @@ endif
ifdef NEED_RFKILL
DRV_OBJS += ../src/drivers/rfkill.o
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
-@@ -7488,7 +7488,7 @@ static int nl80211_set_channel(struct i8
+@@ -7840,7 +7840,7 @@ static int nl80211_set_channel(struct i8
nl80211_cmd(drv, msg, 0, set_chan ? NL80211_CMD_SET_CHANNEL :
NL80211_CMD_SET_WIPHY);
if (nl80211_put_freq_params(msg, freq) < 0)
goto nla_put_failure;
-@@ -12047,7 +12047,7 @@ static int nl80211_switch_channel(void *
- return -ENOMEM;
-
- nl80211_cmd(drv, msg, 0, NL80211_CMD_CHANNEL_SWITCH);
-- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, drv->ifindex);
-+ NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, bss->ifindex);
- NLA_PUT_U32(msg, NL80211_ATTR_CH_SWITCH_COUNT, settings->cs_count);
- ret = nl80211_put_freq_params(msg, &settings->freq_params);
- if (ret)
--- a/src/ap/hostapd.c
+++ b/src/ap/hostapd.c
-@@ -70,6 +70,16 @@ static void hostapd_reload_bss(struct ho
+@@ -71,6 +71,16 @@ static void hostapd_reload_bss(struct ho
#endif /* CONFIG_NO_RADIUS */
ssid = &hapd->conf->ssid;
if (!ssid->wpa_psk_set && ssid->wpa_psk && !ssid->wpa_psk->next &&
ssid->wpa_passphrase_set && ssid->wpa_passphrase) {
/*
-@@ -170,20 +180,12 @@ int hostapd_reload_config(struct hostapd
+@@ -171,20 +181,12 @@ int hostapd_reload_config(struct hostapd
oldconf = hapd->iconf;
iface->conf = newconf;
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
-@@ -4817,18 +4817,20 @@ wpa_driver_nl80211_finish_drv_init(struc
+@@ -5083,18 +5083,20 @@ wpa_driver_nl80211_finish_drv_init(struc
}
return send_and_recv_msgs(drv, msg, NULL, NULL);
nla_put_failure:
-@@ -4836,6 +4838,15 @@ static int wpa_driver_nl80211_del_beacon
+@@ -5102,6 +5104,15 @@ static int wpa_driver_nl80211_del_beacon
return -ENOBUFS;
}
/**
* wpa_driver_nl80211_deinit - Deinitialize nl80211 driver interface
-@@ -10617,7 +10628,6 @@ static int wpa_driver_nl80211_stop_ap(vo
+@@ -11147,7 +11158,6 @@ static int wpa_driver_nl80211_stop_ap(vo
if (!is_ap_interface(drv->nlmode))
return -1;
wpa_driver_nl80211_del_beacon(drv);
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
-@@ -37,6 +37,7 @@
+@@ -43,6 +43,7 @@
#include "wps/wps.h"
#include "config_file.h"
#include "ctrl_iface.h"
struct wpa_ctrl_dst {
-@@ -47,6 +48,7 @@ struct wpa_ctrl_dst {
+@@ -53,6 +54,7 @@ struct wpa_ctrl_dst {
int errors;
};
static void hostapd_ctrl_iface_send(struct hostapd_data *hapd, int level,
const char *buf, size_t len);
-@@ -156,6 +158,68 @@ static int hostapd_ctrl_iface_new_sta(st
+@@ -162,6 +164,68 @@ static int hostapd_ctrl_iface_new_sta(st
return 0;
}
#ifdef CONFIG_IEEE80211W
#ifdef NEED_AP_MLME
-@@ -1546,6 +1610,10 @@ static void hostapd_ctrl_iface_receive(i
+@@ -1761,6 +1825,10 @@ static void hostapd_ctrl_iface_receive(i
} else if (os_strncmp(buf, "VENDOR ", 7) == 0) {
reply_len = hostapd_ctrl_iface_vendor(hapd, buf + 7, reply,
reply_size);
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
-@@ -108,6 +108,11 @@ struct wpa_interface {
+@@ -109,6 +109,11 @@ struct wpa_interface {
const char *ifname;
/**
* bridge_ifname - Optional bridge interface name
*
* If the driver interface (ifname) is included in a Linux bridge
-@@ -395,6 +400,8 @@ struct wpa_supplicant {
+@@ -406,6 +411,8 @@ struct wpa_supplicant {
#endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
char bridge_ifname[16];
/* Configure default/group WEP keys for static WEP */
int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
{
-@@ -711,8 +760,12 @@ void wpa_supplicant_set_state(struct wpa
- #endif /* CONFIG_P2P */
+@@ -731,8 +780,12 @@ void wpa_supplicant_set_state(struct wpa
+ wpas_p2p_completed(wpa_s);
sme_sched_obss_scan(wpa_s, 1);
+ if (wpa_s->hostapd)
wpa_s->new_connection = 1;
wpa_drv_set_operstate(wpa_s, 0);
#ifndef IEEE8021X_EAPOL
-@@ -3595,6 +3648,20 @@ static int wpa_supplicant_init_iface(str
+@@ -3753,6 +3806,20 @@ static int wpa_supplicant_init_iface(str
sizeof(wpa_s->bridge_ifname));
}
/* RSNA Supplicant Key Management - INITIALIZE */
eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
eapol_sm_notify_portValid(wpa_s->eapol, FALSE);
-@@ -3798,6 +3865,11 @@ static void wpa_supplicant_deinit_iface(
+@@ -3967,6 +4034,11 @@ static void wpa_supplicant_deinit_iface(
if (terminate)
wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_TERMINATING);
#include "drivers/driver.h"
#include "wpa_supplicant_i.h"
#include "config.h"
-@@ -247,6 +248,10 @@ static void calculate_update_time(const
+@@ -247,6 +248,10 @@ static void calculate_update_time(const
static void wpa_bss_copy_res(struct wpa_bss *dst, struct wpa_scan_res *src,
struct os_reltime *fetch_time)
{
--- a/hostapd/Makefile
+++ b/hostapd/Makefile
-@@ -163,6 +163,9 @@ endif
+@@ -164,6 +164,9 @@ endif
ifdef CONFIG_NO_CTRL_IFACE
CFLAGS += -DCONFIG_NO_CTRL_IFACE
else
endif
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
-@@ -1447,6 +1447,7 @@ static void hostapd_ctrl_iface_receive(i
+@@ -1653,6 +1653,7 @@ static void hostapd_ctrl_iface_receive(i
reply_size);
} else if (os_strcmp(buf, "STATUS-DRIVER") == 0) {
reply_len = hostapd_drv_status(hapd, reply, reply_size);
} else if (os_strcmp(buf, "MIB") == 0) {
reply_len = ieee802_11_get_mib(hapd, reply, reply_size);
if (reply_len >= 0) {
-@@ -1488,6 +1489,7 @@ static void hostapd_ctrl_iface_receive(i
+@@ -1694,6 +1695,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);
reply_len = -1;
--- a/wpa_supplicant/Makefile
+++ b/wpa_supplicant/Makefile
-@@ -805,6 +805,9 @@ ifdef CONFIG_WNM
+@@ -809,6 +809,9 @@ ifdef CONFIG_WNM
OBJS += ../src/ap/wnm_ap.o
endif
ifdef CONFIG_CTRL_IFACE
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
-@@ -1602,7 +1602,7 @@ static int wpa_supplicant_ctrl_iface_sta
+@@ -1628,7 +1628,7 @@ static int wpa_supplicant_ctrl_iface_sta
pos += ret;
}
if (wpa_s->ap_iface) {
pos += ap_ctrl_iface_wpa_get_status(wpa_s, pos,
end - pos,
-@@ -6243,6 +6243,7 @@ char * wpa_supplicant_ctrl_iface_process
+@@ -6720,6 +6720,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);
} else if (os_strcmp(buf, "MIB") == 0) {
reply_len = wpa_sm_get_mib(wpa_s->wpa, reply, reply_size);
if (reply_len >= 0) {
-@@ -6254,6 +6255,7 @@ char * wpa_supplicant_ctrl_iface_process
+@@ -6731,6 +6732,7 @@ char * wpa_supplicant_ctrl_iface_process
else
reply_len += res;
}
} else if (os_strncmp(buf, "STATUS", 6) == 0) {
reply_len = wpa_supplicant_ctrl_iface_status(
wpa_s, buf + 6, reply, reply_size);
-@@ -6661,6 +6663,7 @@ char * wpa_supplicant_ctrl_iface_process
+@@ -7140,6 +7142,7 @@ char * wpa_supplicant_ctrl_iface_process
reply_len = wpa_supplicant_ctrl_iface_bss(
wpa_s, buf + 4, reply, reply_size);
#ifdef CONFIG_AP
} 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) {
-@@ -6669,12 +6672,15 @@ char * wpa_supplicant_ctrl_iface_process
+@@ -7148,12 +7151,15 @@ 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);
#ifdef CONFIG_P2P_MANAGER
static int p2p_manager_disconnect(struct hostapd_data *hapd, u16 stype,
-@@ -526,3 +528,4 @@ int hostapd_parse_csa_settings(const cha
+@@ -527,3 +529,4 @@ int hostapd_parse_csa_settings(const cha
return 0;
}
+
--- a/src/ap/ieee802_1x.c
+++ b/src/ap/ieee802_1x.c
-@@ -2124,6 +2124,7 @@ static const char * bool_txt(Boolean boo
+@@ -2237,6 +2237,7 @@ static const char * bool_txt(Boolean boo
return bool_val ? "TRUE" : "FALSE";
}
int ieee802_1x_get_mib(struct hostapd_data *hapd, char *buf, size_t buflen)
{
-@@ -2291,6 +2292,7 @@ int ieee802_1x_get_mib_sta(struct hostap
+@@ -2404,6 +2405,7 @@ int ieee802_1x_get_mib_sta(struct hostap
return len;
}
struct sta_info *sta, int success,
--- a/src/ap/wpa_auth.c
+++ b/src/ap/wpa_auth.c
-@@ -2832,6 +2832,7 @@ static const char * wpa_bool_txt(int boo
+@@ -2835,6 +2835,7 @@ static const char * wpa_bool_txt(int boo
return bool ? "TRUE" : "FALSE";
}
#define RSN_SUITE "%02x-%02x-%02x-%d"
#define RSN_SUITE_ARG(s) \
-@@ -2976,7 +2977,7 @@ int wpa_get_mib_sta(struct wpa_state_mac
+@@ -2979,7 +2980,7 @@ int wpa_get_mib_sta(struct wpa_state_mac
return len;
}
{
--- a/src/rsn_supp/wpa.c
+++ b/src/rsn_supp/wpa.c
-@@ -1911,6 +1911,8 @@ static u32 wpa_key_mgmt_suite(struct wpa
+@@ -1928,6 +1928,8 @@ static u32 wpa_key_mgmt_suite(struct wpa
}
#define RSN_SUITE "%02x-%02x-%02x-%d"
#define RSN_SUITE_ARG(s) \
((s) >> 24) & 0xff, ((s) >> 16) & 0xff, ((s) >> 8) & 0xff, (s) & 0xff
-@@ -1994,6 +1996,7 @@ int wpa_sm_get_mib(struct wpa_sm *sm, ch
+@@ -2011,6 +2013,7 @@ int wpa_sm_get_mib(struct wpa_sm *sm, ch
return (int) len;
}
--- a/wpa_supplicant/ap.c
+++ b/wpa_supplicant/ap.c
-@@ -984,7 +984,7 @@ int wpas_ap_wps_nfc_report_handover(stru
+@@ -975,7 +975,7 @@ int wpas_ap_wps_nfc_report_handover(stru
#endif /* CONFIG_WPS */
--- a/src/common/wpa_common.c
+++ b/src/common/wpa_common.c
-@@ -1002,6 +1002,31 @@ const char * wpa_key_mgmt_txt(int key_mg
+@@ -1026,6 +1026,31 @@ u32 wpa_akm_to_suite(int akm)
}
int wpa_compare_rsn_ie(int ft_initial_assoc,
const u8 *ie1, size_t ie1len,
const u8 *ie2, size_t ie2len)
-@@ -1009,8 +1034,19 @@ int wpa_compare_rsn_ie(int ft_initial_as
+@@ -1033,8 +1058,19 @@ int wpa_compare_rsn_ie(int ft_initial_as
if (ie1 == NULL || ie2 == NULL)
return -1;
--- /dev/null
+--- a/src/ap/wps_hostapd.c
++++ b/src/ap/wps_hostapd.c
+@@ -1051,11 +1051,9 @@ int hostapd_init_wps(struct hostapd_data
+
+ if (conf->rsn_pairwise & WPA_CIPHER_CCMP)
+ wps->encr_types |= WPS_ENCR_AES;
+- if (conf->rsn_pairwise & WPA_CIPHER_TKIP)
++ else if (conf->rsn_pairwise & WPA_CIPHER_TKIP)
+ wps->encr_types |= WPS_ENCR_TKIP;
+- }
+-
+- if (conf->wpa & WPA_PROTO_WPA) {
++ } else if (conf->wpa & WPA_PROTO_WPA) {
+ if (conf->wpa_key_mgmt & WPA_KEY_MGMT_PSK)
+ wps->auth_types |= WPS_AUTH_WPAPSK;
+ if (conf->wpa_key_mgmt & WPA_KEY_MGMT_IEEE8021X)
+@@ -1063,7 +1061,7 @@ int hostapd_init_wps(struct hostapd_data
+
+ if (conf->wpa_pairwise & WPA_CIPHER_CCMP)
+ wps->encr_types |= WPS_ENCR_AES;
+- if (conf->wpa_pairwise & WPA_CIPHER_TKIP)
++ else if (conf->wpa_pairwise & WPA_CIPHER_TKIP)
+ wps->encr_types |= WPS_ENCR_TKIP;
+ }
+
+++ /dev/null
---- a/src/drivers/driver_nl80211.c
-+++ b/src/drivers/driver_nl80211.c
-@@ -9070,12 +9070,7 @@ static int wpa_driver_nl80211_set_mode(s
- /* Try to set the mode again while the interface is
- * down */
- ret = nl80211_set_mode(drv, drv->ifindex, nlmode);
-- if (ret == -EACCES)
-- break;
-- res = i802_set_iface_flags(bss, 1);
-- if (res && !ret)
-- ret = -1;
-- else if (ret != -EBUSY)
-+ if (ret != -EBUSY)
- break;
- } else
- wpa_printf(MSG_DEBUG, "nl80211: Failed to set "
-@@ -9088,6 +9083,8 @@ static int wpa_driver_nl80211_set_mode(s
- "interface is down");
- drv->nlmode = nlmode;
- drv->ignore_if_down_event = 1;
-+ if (i802_set_iface_flags(bss, 1))
-+ ret = -1;
- }
-
- done:
--- /dev/null
+--- a/src/utils/wpa_debug.c
++++ b/src/utils/wpa_debug.c
+@@ -201,7 +201,7 @@ void wpa_debug_close_linux_tracing(void)
+ *
+ * Note: New line '\n' is added to the end of the text when printing to stdout.
+ */
+-void wpa_printf(int level, const char *fmt, ...)
++void _wpa_printf(int level, const char *fmt, ...)
+ {
+ va_list ap;
+
+@@ -248,8 +248,8 @@ void wpa_printf(int level, const char *f
+ }
+
+
+-static void _wpa_hexdump(int level, const char *title, const u8 *buf,
+- size_t len, int show)
++void _wpa_hexdump(int level, const char *title, const u8 *buf,
++ size_t len, int show)
+ {
+ size_t i;
+
+@@ -375,20 +375,8 @@ static void _wpa_hexdump(int level, cons
+ #endif /* CONFIG_ANDROID_LOG */
+ }
+
+-void wpa_hexdump(int level, const char *title, const void *buf, size_t len)
+-{
+- _wpa_hexdump(level, title, buf, len, 1);
+-}
+-
+-
+-void wpa_hexdump_key(int level, const char *title, const void *buf, size_t len)
+-{
+- _wpa_hexdump(level, title, buf, len, wpa_debug_show_keys);
+-}
+-
+-
+-static void _wpa_hexdump_ascii(int level, const char *title, const void *buf,
+- size_t len, int show)
++void _wpa_hexdump_ascii(int level, const char *title, const void *buf,
++ size_t len, int show)
+ {
+ size_t i, llen;
+ const u8 *pos = buf;
+@@ -495,20 +483,6 @@ static void _wpa_hexdump_ascii(int level
+ }
+
+
+-void wpa_hexdump_ascii(int level, const char *title, const void *buf,
+- size_t len)
+-{
+- _wpa_hexdump_ascii(level, title, buf, len, 1);
+-}
+-
+-
+-void wpa_hexdump_ascii_key(int level, const char *title, const void *buf,
+- size_t len)
+-{
+- _wpa_hexdump_ascii(level, title, buf, len, wpa_debug_show_keys);
+-}
+-
+-
+ #ifdef CONFIG_DEBUG_FILE
+ static char *last_path = NULL;
+ #endif /* CONFIG_DEBUG_FILE */
+@@ -594,7 +568,7 @@ void wpa_msg_register_ifname_cb(wpa_msg_
+ }
+
+
+-void wpa_msg(void *ctx, int level, const char *fmt, ...)
++void _wpa_msg(void *ctx, int level, const char *fmt, ...)
+ {
+ va_list ap;
+ char *buf;
+@@ -632,7 +606,7 @@ void wpa_msg(void *ctx, int level, const
+ }
+
+
+-void wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
++void _wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
+ {
+ va_list ap;
+ char *buf;
+--- a/src/utils/wpa_debug.h
++++ b/src/utils/wpa_debug.h
+@@ -47,6 +47,17 @@ int wpa_debug_open_file(const char *path
+ int wpa_debug_reopen_file(void);
+ void wpa_debug_close_file(void);
+
++/* internal */
++void _wpa_hexdump(int level, const char *title, const u8 *buf,
++ size_t len, int show);
++void _wpa_hexdump_ascii(int level, const char *title, const void *buf,
++ size_t len, int show);
++extern int wpa_debug_show_keys;
++
++#ifndef CONFIG_MSG_MIN_PRIORITY
++#define CONFIG_MSG_MIN_PRIORITY 0
++#endif
++
+ /**
+ * wpa_debug_printf_timestamp - Print timestamp for debug output
+ *
+@@ -67,9 +78,15 @@ void wpa_debug_print_timestamp(void);
+ *
+ * Note: New line '\n' is added to the end of the text when printing to stdout.
+ */
+-void wpa_printf(int level, const char *fmt, ...)
++void _wpa_printf(int level, const char *fmt, ...)
+ PRINTF_FORMAT(2, 3);
+
++#define wpa_printf(level, ...) \
++ do { \
++ if (level >= CONFIG_MSG_MIN_PRIORITY) \
++ _wpa_printf(level, __VA_ARGS__); \
++ } while(0)
++
+ /**
+ * wpa_hexdump - conditional hex dump
+ * @level: priority level (MSG_*) of the message
+@@ -81,7 +98,13 @@ PRINTF_FORMAT(2, 3);
+ * output may be directed to stdout, stderr, and/or syslog based on
+ * configuration. The contents of buf is printed out has hex dump.
+ */
+-void wpa_hexdump(int level, const char *title, const void *buf, size_t len);
++static inline void wpa_hexdump(int level, const char *title, const u8 *buf, size_t len)
++{
++ if (level < CONFIG_MSG_MIN_PRIORITY)
++ return;
++
++ _wpa_hexdump(level, title, buf, len, 1);
++}
+
+ static inline void wpa_hexdump_buf(int level, const char *title,
+ const struct wpabuf *buf)
+@@ -103,7 +126,13 @@ static inline void wpa_hexdump_buf(int l
+ * like wpa_hexdump(), but by default, does not include secret keys (passwords,
+ * etc.) in debug output.
+ */
+-void wpa_hexdump_key(int level, const char *title, const void *buf, size_t len);
++static inline void wpa_hexdump_key(int level, const char *title, const u8 *buf, size_t len)
++{
++ if (level < CONFIG_MSG_MIN_PRIORITY)
++ return;
++
++ _wpa_hexdump(level, title, buf, len, wpa_debug_show_keys);
++}
+
+ static inline void wpa_hexdump_buf_key(int level, const char *title,
+ const struct wpabuf *buf)
+@@ -125,8 +154,14 @@ static inline void wpa_hexdump_buf_key(i
+ * the hex numbers and ASCII characters (for printable range) are shown. 16
+ * bytes per line will be shown.
+ */
+-void wpa_hexdump_ascii(int level, const char *title, const void *buf,
+- size_t len);
++static inline void wpa_hexdump_ascii(int level, const char *title,
++ const u8 *buf, size_t len)
++{
++ if (level < CONFIG_MSG_MIN_PRIORITY)
++ return;
++
++ _wpa_hexdump_ascii(level, title, buf, len, 1);
++}
+
+ /**
+ * wpa_hexdump_ascii_key - conditional hex dump, hide keys
+@@ -142,8 +177,14 @@ void wpa_hexdump_ascii(int level, const
+ * bytes per line will be shown. This works like wpa_hexdump_ascii(), but by
+ * default, does not include secret keys (passwords, etc.) in debug output.
+ */
+-void wpa_hexdump_ascii_key(int level, const char *title, const void *buf,
+- size_t len);
++static inline void wpa_hexdump_ascii_key(int level, const char *title,
++ const u8 *buf, size_t len)
++{
++ if (level < CONFIG_MSG_MIN_PRIORITY)
++ return;
++
++ _wpa_hexdump_ascii(level, title, buf, len, wpa_debug_show_keys);
++}
+
+ /*
+ * wpa_dbg() behaves like wpa_msg(), but it can be removed from build to reduce
+@@ -179,7 +220,12 @@ void wpa_hexdump_ascii_key(int level, co
+ *
+ * Note: New line '\n' is added to the end of the text when printing to stdout.
+ */
+-void wpa_msg(void *ctx, int level, const char *fmt, ...) PRINTF_FORMAT(3, 4);
++void _wpa_msg(void *ctx, int level, const char *fmt, ...) PRINTF_FORMAT(3, 4);
++#define wpa_msg(ctx, level, ...) \
++ do { \
++ if (level >= CONFIG_MSG_MIN_PRIORITY) \
++ _wpa_msg(ctx, level, __VA_ARGS__); \
++ } while(0)
+
+ /**
+ * wpa_msg_ctrl - Conditional printf for ctrl_iface monitors
+@@ -193,8 +239,13 @@ void wpa_msg(void *ctx, int level, const
+ * attached ctrl_iface monitors. In other words, it can be used for frequent
+ * events that do not need to be sent to syslog.
+ */
+-void wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
++void _wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
+ PRINTF_FORMAT(3, 4);
++#define wpa_msg_ctrl(ctx, level, ...) \
++ do { \
++ if (level >= CONFIG_MSG_MIN_PRIORITY) \
++ _wpa_msg_ctrl(ctx, level, __VA_ARGS__); \
++ } while(0)
+
+ /**
+ * wpa_msg_global - Global printf for ctrl_iface monitors
+++ /dev/null
---- a/hostapd/ctrl_iface.c
-+++ b/hostapd/ctrl_iface.c
-@@ -540,6 +540,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/hostapd/main.c
++++ b/hostapd/main.c
+@@ -15,6 +15,7 @@
+ #include "utils/common.h"
+ #include "utils/eloop.h"
+ #include "utils/uuid.h"
++#include "utils/build_features.h"
+ #include "crypto/random.h"
+ #include "crypto/tls.h"
+ #include "common/version.h"
+@@ -560,7 +561,7 @@ int main(int argc, char *argv[])
+
+ wpa_supplicant_event = hostapd_wpa_event;
+ for (;;) {
+- c = getopt(argc, argv, "b:Bde:f:hKP:Ttu:vg:G:");
++ c = getopt(argc, argv, "b:Bde:f:hKP:Ttu:g:G:v::");
+ if (c < 0)
+ break;
+ switch (c) {
+@@ -597,6 +598,8 @@ int main(int argc, char *argv[])
+ break;
+ #endif /* CONFIG_DEBUG_LINUX_TRACING */
+ case 'v':
++ if (optarg)
++ exit(!has_feature(optarg));
+ show_version();
+ exit(1);
+ break;
+--- a/wpa_supplicant/main.c
++++ b/wpa_supplicant/main.c
+@@ -12,6 +12,7 @@
+ #endif /* __linux__ */
+
+ #include "common.h"
++#include "build_features.h"
+ #include "wpa_supplicant_i.h"
+ #include "driver_i.h"
+ #include "p2p_supplicant.h"
+@@ -176,7 +177,7 @@ int main(int argc, char *argv[])
+
+ for (;;) {
+ c = getopt(argc, argv,
+- "b:Bc:C:D:de:f:g:G:hH:i:I:KLm:No:O:p:P:qsTtuvW");
++ "b:Bc:C:D:de:f:g:G:hH:i:I:KLm:No:O:p:P:qsTtuv::W");
+ if (c < 0)
+ break;
+ switch (c) {
+@@ -279,8 +280,12 @@ int main(int argc, char *argv[])
+ break;
+ #endif /* CONFIG_DBUS */
+ case 'v':
+- printf("%s\n", wpa_supplicant_version);
+- exitcode = 0;
++ if (optarg) {
++ exitcode = !has_feature(optarg);
++ } else {
++ printf("%s\n", wpa_supplicant_version);
++ exitcode = 0;
++ }
+ goto out;
+ case 'W':
+ params.wait_for_monitor++;
+--- /dev/null
++++ b/src/utils/build_features.h
+@@ -0,0 +1,17 @@
++#ifndef BUILD_FEATURES_H
++#define BUILD_FEATURES_H
++
++static inline int has_feature(const char *feat)
++{
++#ifdef IEEE8021X_EAPOL
++ if (!strcmp(feat, "eap"))
++ return 1;
++#endif
++#ifdef IEEE80211N
++ if (!strcmp(feat, "11n"))
++ return 1;
++#endif
++ return 0;
++}
++
++#endif /* BUILD_FEATURES_H */
--- /dev/null
+--- a/hostapd/hostapd_cli.c
++++ b/hostapd/hostapd_cli.c
+@@ -67,7 +67,6 @@ static const char *commands_help =
+ #ifdef CONFIG_IEEE80211W
+ " sa_query <addr> send SA Query to a station\n"
+ #endif /* CONFIG_IEEE80211W */
+-#ifdef CONFIG_WPS
+ " wps_pin <uuid> <pin> [timeout] [addr] add WPS Enrollee PIN\n"
+ " wps_check_pin <PIN> verify PIN checksum\n"
+ " wps_pbc indicate button pushed to initiate PBC\n"
+@@ -80,7 +79,6 @@ static const char *commands_help =
+ " wps_ap_pin <cmd> [params..] enable/disable AP PIN\n"
+ " wps_config <SSID> <auth> <encr> <key> configure AP\n"
+ " wps_get_status show current WPS status\n"
+-#endif /* CONFIG_WPS */
+ " get_config show current configuration\n"
+ " help show this usage help\n"
+ " interface [ifname] show interfaces/select interface\n"
+@@ -353,7 +351,6 @@ static int hostapd_cli_cmd_sa_query(stru
+ #endif /* CONFIG_IEEE80211W */
+
+
+-#ifdef CONFIG_WPS
+ static int hostapd_cli_cmd_wps_pin(struct wpa_ctrl *ctrl, int argc,
+ char *argv[])
+ {
+@@ -579,7 +576,6 @@ static int hostapd_cli_cmd_wps_config(st
+ ssid_hex, argv[1]);
+ return wpa_ctrl_command(ctrl, buf);
+ }
+-#endif /* CONFIG_WPS */
+
+
+ static int hostapd_cli_cmd_disassoc_imminent(struct wpa_ctrl *ctrl, int argc,
+@@ -993,7 +989,6 @@ static struct hostapd_cli_cmd hostapd_cl
+ #ifdef CONFIG_IEEE80211W
+ { "sa_query", hostapd_cli_cmd_sa_query },
+ #endif /* CONFIG_IEEE80211W */
+-#ifdef CONFIG_WPS
+ { "wps_pin", hostapd_cli_cmd_wps_pin },
+ { "wps_check_pin", hostapd_cli_cmd_wps_check_pin },
+ { "wps_pbc", hostapd_cli_cmd_wps_pbc },
+@@ -1007,7 +1002,6 @@ static struct hostapd_cli_cmd hostapd_cl
+ { "wps_ap_pin", hostapd_cli_cmd_wps_ap_pin },
+ { "wps_config", hostapd_cli_cmd_wps_config },
+ { "wps_get_status", hostapd_cli_cmd_wps_get_status },
+-#endif /* CONFIG_WPS */
+ { "disassoc_imminent", hostapd_cli_cmd_disassoc_imminent },
+ { "ess_disassoc", hostapd_cli_cmd_ess_disassoc },
+ { "get_config", hostapd_cli_cmd_get_config },
+++ /dev/null
---- a/src/ap/wps_hostapd.c
-+++ b/src/ap/wps_hostapd.c
-@@ -1051,11 +1051,9 @@ int hostapd_init_wps(struct hostapd_data
-
- if (conf->rsn_pairwise & WPA_CIPHER_CCMP)
- wps->encr_types |= WPS_ENCR_AES;
-- if (conf->rsn_pairwise & WPA_CIPHER_TKIP)
-+ else if (conf->rsn_pairwise & WPA_CIPHER_TKIP)
- wps->encr_types |= WPS_ENCR_TKIP;
-- }
--
-- if (conf->wpa & WPA_PROTO_WPA) {
-+ } else if (conf->wpa & WPA_PROTO_WPA) {
- if (conf->wpa_key_mgmt & WPA_KEY_MGMT_PSK)
- wps->auth_types |= WPS_AUTH_WPAPSK;
- if (conf->wpa_key_mgmt & WPA_KEY_MGMT_IEEE8021X)
-@@ -1063,7 +1061,7 @@ int hostapd_init_wps(struct hostapd_data
-
- if (conf->wpa_pairwise & WPA_CIPHER_CCMP)
- wps->encr_types |= WPS_ENCR_AES;
-- if (conf->wpa_pairwise & WPA_CIPHER_TKIP)
-+ else if (conf->wpa_pairwise & WPA_CIPHER_TKIP)
- wps->encr_types |= WPS_ENCR_TKIP;
- }
-
--- /dev/null
+--- a/wpa_supplicant/wpa_cli.c
++++ b/wpa_supplicant/wpa_cli.c
+@@ -26,6 +26,10 @@
+ #endif /* ANDROID */
+
+
++#ifndef CONFIG_P2P
++#define CONFIG_P2P
++#endif
++
+ static const char *wpa_cli_version =
+ "wpa_cli v" VERSION_STR "\n"
+ "Copyright (c) 2004-2014, Jouni Malinen <j@w1.fi> and contributors";
--- /dev/null
+--- a/src/ap/beacon.c
++++ b/src/ap/beacon.c
+@@ -614,6 +614,10 @@ void handle_probe_req(struct hostapd_dat
+ return;
+ }
+
++ if (!sta && hapd->num_sta >= hapd->conf->max_num_sta)
++ wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR " ignored,"
++ " too many connected stations.", MAC2STR(mgmt->sa));
++
+ #ifdef CONFIG_INTERWORKING
+ if (hapd->conf->interworking &&
+ elems.interworking && elems.interworking_len >= 1) {
+++ /dev/null
---- a/src/utils/wpa_debug.c
-+++ b/src/utils/wpa_debug.c
-@@ -201,7 +201,7 @@ void wpa_debug_close_linux_tracing(void)
- *
- * Note: New line '\n' is added to the end of the text when printing to stdout.
- */
--void wpa_printf(int level, const char *fmt, ...)
-+void _wpa_printf(int level, const char *fmt, ...)
- {
- va_list ap;
-
-@@ -248,8 +248,8 @@ void wpa_printf(int level, const char *f
- }
-
-
--static void _wpa_hexdump(int level, const char *title, const u8 *buf,
-- size_t len, int show)
-+void _wpa_hexdump(int level, const char *title, const u8 *buf,
-+ size_t len, int show)
- {
- size_t i;
-
-@@ -375,20 +375,8 @@ static void _wpa_hexdump(int level, cons
- #endif /* CONFIG_ANDROID_LOG */
- }
-
--void wpa_hexdump(int level, const char *title, const void *buf, size_t len)
--{
-- _wpa_hexdump(level, title, buf, len, 1);
--}
--
--
--void wpa_hexdump_key(int level, const char *title, const void *buf, size_t len)
--{
-- _wpa_hexdump(level, title, buf, len, wpa_debug_show_keys);
--}
--
--
--static void _wpa_hexdump_ascii(int level, const char *title, const void *buf,
-- size_t len, int show)
-+void _wpa_hexdump_ascii(int level, const char *title, const void *buf,
-+ size_t len, int show)
- {
- size_t i, llen;
- const u8 *pos = buf;
-@@ -495,20 +483,6 @@ static void _wpa_hexdump_ascii(int level
- }
-
-
--void wpa_hexdump_ascii(int level, const char *title, const void *buf,
-- size_t len)
--{
-- _wpa_hexdump_ascii(level, title, buf, len, 1);
--}
--
--
--void wpa_hexdump_ascii_key(int level, const char *title, const void *buf,
-- size_t len)
--{
-- _wpa_hexdump_ascii(level, title, buf, len, wpa_debug_show_keys);
--}
--
--
- #ifdef CONFIG_DEBUG_FILE
- static char *last_path = NULL;
- #endif /* CONFIG_DEBUG_FILE */
-@@ -592,7 +566,7 @@ void wpa_msg_register_ifname_cb(wpa_msg_
- }
-
-
--void wpa_msg(void *ctx, int level, const char *fmt, ...)
-+void _wpa_msg(void *ctx, int level, const char *fmt, ...)
- {
- va_list ap;
- char *buf;
-@@ -630,7 +604,7 @@ void wpa_msg(void *ctx, int level, const
- }
-
-
--void wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
-+void _wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
- {
- va_list ap;
- char *buf;
---- a/src/utils/wpa_debug.h
-+++ b/src/utils/wpa_debug.h
-@@ -47,6 +47,17 @@ int wpa_debug_open_file(const char *path
- int wpa_debug_reopen_file(void);
- void wpa_debug_close_file(void);
-
-+/* internal */
-+void _wpa_hexdump(int level, const char *title, const u8 *buf,
-+ size_t len, int show);
-+void _wpa_hexdump_ascii(int level, const char *title, const void *buf,
-+ size_t len, int show);
-+extern int wpa_debug_show_keys;
-+
-+#ifndef CONFIG_MSG_MIN_PRIORITY
-+#define CONFIG_MSG_MIN_PRIORITY 0
-+#endif
-+
- /**
- * wpa_debug_printf_timestamp - Print timestamp for debug output
- *
-@@ -67,9 +78,15 @@ void wpa_debug_print_timestamp(void);
- *
- * Note: New line '\n' is added to the end of the text when printing to stdout.
- */
--void wpa_printf(int level, const char *fmt, ...)
-+void _wpa_printf(int level, const char *fmt, ...)
- PRINTF_FORMAT(2, 3);
-
-+#define wpa_printf(level, ...) \
-+ do { \
-+ if (level >= CONFIG_MSG_MIN_PRIORITY) \
-+ _wpa_printf(level, __VA_ARGS__); \
-+ } while(0)
-+
- /**
- * wpa_hexdump - conditional hex dump
- * @level: priority level (MSG_*) of the message
-@@ -81,7 +98,13 @@ PRINTF_FORMAT(2, 3);
- * output may be directed to stdout, stderr, and/or syslog based on
- * configuration. The contents of buf is printed out has hex dump.
- */
--void wpa_hexdump(int level, const char *title, const void *buf, size_t len);
-+static inline void wpa_hexdump(int level, const char *title, const u8 *buf, size_t len)
-+{
-+ if (level < CONFIG_MSG_MIN_PRIORITY)
-+ return;
-+
-+ _wpa_hexdump(level, title, buf, len, 1);
-+}
-
- static inline void wpa_hexdump_buf(int level, const char *title,
- const struct wpabuf *buf)
-@@ -103,7 +126,13 @@ static inline void wpa_hexdump_buf(int l
- * like wpa_hexdump(), but by default, does not include secret keys (passwords,
- * etc.) in debug output.
- */
--void wpa_hexdump_key(int level, const char *title, const void *buf, size_t len);
-+static inline void wpa_hexdump_key(int level, const char *title, const u8 *buf, size_t len)
-+{
-+ if (level < CONFIG_MSG_MIN_PRIORITY)
-+ return;
-+
-+ _wpa_hexdump(level, title, buf, len, wpa_debug_show_keys);
-+}
-
- static inline void wpa_hexdump_buf_key(int level, const char *title,
- const struct wpabuf *buf)
-@@ -125,8 +154,14 @@ static inline void wpa_hexdump_buf_key(i
- * the hex numbers and ASCII characters (for printable range) are shown. 16
- * bytes per line will be shown.
- */
--void wpa_hexdump_ascii(int level, const char *title, const void *buf,
-- size_t len);
-+static inline void wpa_hexdump_ascii(int level, const char *title,
-+ const u8 *buf, size_t len)
-+{
-+ if (level < CONFIG_MSG_MIN_PRIORITY)
-+ return;
-+
-+ _wpa_hexdump_ascii(level, title, buf, len, 1);
-+}
-
- /**
- * wpa_hexdump_ascii_key - conditional hex dump, hide keys
-@@ -142,8 +177,14 @@ void wpa_hexdump_ascii(int level, const
- * bytes per line will be shown. This works like wpa_hexdump_ascii(), but by
- * default, does not include secret keys (passwords, etc.) in debug output.
- */
--void wpa_hexdump_ascii_key(int level, const char *title, const void *buf,
-- size_t len);
-+static inline void wpa_hexdump_ascii_key(int level, const char *title,
-+ const u8 *buf, size_t len)
-+{
-+ if (level < CONFIG_MSG_MIN_PRIORITY)
-+ return;
-+
-+ _wpa_hexdump_ascii(level, title, buf, len, wpa_debug_show_keys);
-+}
-
- /*
- * wpa_dbg() behaves like wpa_msg(), but it can be removed from build to reduce
-@@ -178,7 +219,12 @@ void wpa_hexdump_ascii_key(int level, co
- *
- * Note: New line '\n' is added to the end of the text when printing to stdout.
- */
--void wpa_msg(void *ctx, int level, const char *fmt, ...) PRINTF_FORMAT(3, 4);
-+void _wpa_msg(void *ctx, int level, const char *fmt, ...) PRINTF_FORMAT(3, 4);
-+#define wpa_msg(ctx, level, ...) \
-+ do { \
-+ if (level >= CONFIG_MSG_MIN_PRIORITY) \
-+ _wpa_msg(ctx, level, __VA_ARGS__); \
-+ } while(0)
-
- /**
- * wpa_msg_ctrl - Conditional printf for ctrl_iface monitors
-@@ -192,8 +238,13 @@ void wpa_msg(void *ctx, int level, const
- * attached ctrl_iface monitors. In other words, it can be used for frequent
- * events that do not need to be sent to syslog.
- */
--void wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
-+void _wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
- PRINTF_FORMAT(3, 4);
-+#define wpa_msg_ctrl(ctx, level, ...) \
-+ do { \
-+ if (level >= CONFIG_MSG_MIN_PRIORITY) \
-+ _wpa_msg_ctrl(ctx, level, __VA_ARGS__); \
-+ } while(0)
-
- /**
- * wpa_msg_global - Global printf for ctrl_iface monitors
--- /dev/null
+--- a/hostapd/main.c
++++ b/hostapd/main.c
+@@ -36,6 +36,8 @@ struct hapd_global {
+ };
+
+ static struct hapd_global global;
++static int daemonize = 0;
++static char *pid_file = NULL;
+
+
+ #ifndef CONFIG_NO_HOSTAPD_LOGGER
+@@ -142,6 +144,14 @@ static void hostapd_logger_cb(void *ctx,
+ }
+ #endif /* CONFIG_NO_HOSTAPD_LOGGER */
+
++static void hostapd_setup_complete_cb(void *ctx)
++{
++ if (daemonize && os_daemonize(pid_file)) {
++ perror("daemon");
++ return;
++ }
++ daemonize = 0;
++}
+
+ /**
+ * hostapd_driver_init - Preparate driver interface
+@@ -160,6 +170,8 @@ static int hostapd_driver_init(struct ho
+ return -1;
+ }
+
++ hapd->setup_complete_cb = hostapd_setup_complete_cb;
++
+ /* Initialize the driver interface */
+ if (!(b[0] | b[1] | b[2] | b[3] | b[4] | b[5]))
+ b = NULL;
+@@ -374,8 +386,6 @@ static void hostapd_global_deinit(const
+ #endif /* CONFIG_NATIVE_WINDOWS */
+
+ eap_server_unregister_methods();
+-
+- os_daemonize_terminate(pid_file);
+ }
+
+
+@@ -401,11 +411,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;
+@@ -535,8 +540,7 @@ int main(int argc, char *argv[])
+ struct hapd_interfaces interfaces;
+ int ret = 1;
+ size_t i, j;
+- int c, debug = 0, daemonize = 0;
+- char *pid_file = NULL;
++ int c, debug = 0;
+ const char *log_file = NULL;
+ const char *entropy_file = NULL;
+ char **bss_config = NULL, **tmp_bss;
+++ /dev/null
---- a/hostapd/main.c
-+++ b/hostapd/main.c
-@@ -15,6 +15,7 @@
- #include "utils/common.h"
- #include "utils/eloop.h"
- #include "utils/uuid.h"
-+#include "utils/build_features.h"
- #include "crypto/random.h"
- #include "crypto/tls.h"
- #include "common/version.h"
-@@ -558,7 +559,7 @@ int main(int argc, char *argv[])
-
- wpa_supplicant_event = hostapd_wpa_event;
- for (;;) {
-- c = getopt(argc, argv, "b:Bde:f:hKP:Ttu:vg:G:");
-+ c = getopt(argc, argv, "b:Bde:f:hKP:Ttu:g:G:v::");
- if (c < 0)
- break;
- switch (c) {
-@@ -595,6 +596,8 @@ int main(int argc, char *argv[])
- break;
- #endif /* CONFIG_DEBUG_LINUX_TRACING */
- case 'v':
-+ if (optarg)
-+ exit(!has_feature(optarg));
- show_version();
- exit(1);
- break;
---- a/wpa_supplicant/main.c
-+++ b/wpa_supplicant/main.c
-@@ -12,6 +12,7 @@
- #endif /* __linux__ */
-
- #include "common.h"
-+#include "build_features.h"
- #include "wpa_supplicant_i.h"
- #include "driver_i.h"
- #include "p2p_supplicant.h"
-@@ -176,7 +177,7 @@ int main(int argc, char *argv[])
-
- for (;;) {
- c = getopt(argc, argv,
-- "b:Bc:C:D:de:f:g:G:hH:i:I:KLm:No:O:p:P:qsTtuvW");
-+ "b:Bc:C:D:de:f:g:G:hH:i:I:KLm:No:O:p:P:qsTtuv::W");
- if (c < 0)
- break;
- switch (c) {
-@@ -279,8 +280,12 @@ int main(int argc, char *argv[])
- break;
- #endif /* CONFIG_DBUS */
- case 'v':
-- printf("%s\n", wpa_supplicant_version);
-- exitcode = 0;
-+ if (optarg) {
-+ exitcode = !has_feature(optarg);
-+ } else {
-+ printf("%s\n", wpa_supplicant_version);
-+ exitcode = 0;
-+ }
- goto out;
- case 'W':
- params.wait_for_monitor++;
---- /dev/null
-+++ b/src/utils/build_features.h
-@@ -0,0 +1,17 @@
-+#ifndef BUILD_FEATURES_H
-+#define BUILD_FEATURES_H
-+
-+static inline int has_feature(const char *feat)
-+{
-+#ifdef IEEE8021X_EAPOL
-+ if (!strcmp(feat, "eap"))
-+ return 1;
-+#endif
-+#ifdef IEEE80211N
-+ if (!strcmp(feat, "11n"))
-+ return 1;
-+#endif
-+ return 0;
-+}
-+
-+#endif /* BUILD_FEATURES_H */
--- /dev/null
+From 4bb69d15477e0f2b00e166845341dc933de47c58 Mon Sep 17 00:00:00 2001
+From: Antonio Quartulli <ordex@autistici.org>
+Date: Sun, 3 Jun 2012 18:22:56 +0200
+Subject: [PATCHv2 601/602] wpa_supplicant: add new config params to be used
+ with the ibss join command
+
+Signed-hostap: Antonio Quartulli <ordex@autistici.org>
+---
+ src/drivers/driver.h | 6 +++
+ wpa_supplicant/config.c | 96 +++++++++++++++++++++++++++++++++++++++
+ wpa_supplicant/config_ssid.h | 6 +++
+ wpa_supplicant/wpa_supplicant.c | 23 +++++++---
+ 4 files changed, 124 insertions(+), 7 deletions(-)
+
+--- a/src/drivers/driver.h
++++ b/src/drivers/driver.h
+@@ -19,6 +19,7 @@
+
+ #define WPA_SUPPLICANT_DRIVER_VERSION 4
+
++#include "drivers/nl80211_copy.h"
+ #include "common/defs.h"
+ #include "utils/list.h"
+
+@@ -442,6 +443,11 @@ struct wpa_driver_associate_params {
+ * responsible for selecting with which BSS to associate. */
+ const u8 *bssid;
+
++ int beacon_interval;
++ int fixed_freq;
++ unsigned char rates[NL80211_MAX_SUPP_RATES];
++ int mcast_rate;
++
+ /**
+ * bssid_hint - BSSID of a proposed AP
+ *
+--- a/wpa_supplicant/config.c
++++ b/wpa_supplicant/config.c
+@@ -15,6 +15,7 @@
+ #include "rsn_supp/wpa.h"
+ #include "eap_peer/eap.h"
+ #include "p2p/p2p.h"
++#include "drivers/nl80211_copy.h"
+ #include "config.h"
+
+
+@@ -1576,6 +1577,97 @@ static char * wpa_config_write_psk_list(
+
+ #endif /* CONFIG_P2P */
+
++static int wpa_config_parse_mcast_rate(const struct parse_data *data,
++ struct wpa_ssid *ssid, int line,
++ const char *value)
++{
++ ssid->mcast_rate = (int)(strtod(value, NULL) * 10);
++
++ return 0;
++}
++
++#ifndef NO_CONFIG_WRITE
++static char * wpa_config_write_mcast_rate(const struct parse_data *data,
++ struct wpa_ssid *ssid)
++{
++ char *value;
++ int res;
++
++ if (!ssid->mcast_rate == 0)
++ return NULL;
++
++ value = os_malloc(6); /* longest: 300.0 */
++ if (value == NULL)
++ return NULL;
++ res = os_snprintf(value, 5, "%.1f", (double)ssid->mcast_rate / 10);
++ if (res < 0) {
++ os_free(value);
++ return NULL;
++ }
++ return value;
++}
++#endif /* NO_CONFIG_WRITE */
++
++static int wpa_config_parse_rates(const struct parse_data *data,
++ struct wpa_ssid *ssid, int line,
++ const char *value)
++{
++ int i;
++ char *pos, *r, *sptr, *end;
++ double rate;
++
++ pos = (char *)value;
++ r = strtok_r(pos, ",", &sptr);
++ i = 0;
++ while (pos && i < NL80211_MAX_SUPP_RATES) {
++ rate = 0.0;
++ if (r)
++ rate = strtod(r, &end);
++ ssid->rates[i] = rate * 2;
++ if (*end != '\0' || rate * 2 != ssid->rates[i])
++ return 1;
++
++ i++;
++ r = strtok_r(NULL, ",", &sptr);
++ }
++
++ return 0;
++}
++
++#ifndef NO_CONFIG_WRITE
++static char * wpa_config_write_rates(const struct parse_data *data,
++ struct wpa_ssid *ssid)
++{
++ char *value, *pos;
++ int res, i;
++
++ if (ssid->rates[0] <= 0)
++ return NULL;
++
++ value = os_malloc(6 * NL80211_MAX_SUPP_RATES + 1);
++ if (value == NULL)
++ return NULL;
++ pos = value;
++ for (i = 0; i < NL80211_MAX_SUPP_RATES - 1; i++) {
++ res = os_snprintf(pos, 6, "%.1f,", (double)ssid->rates[i] / 2);
++ if (res < 0) {
++ os_free(value);
++ return NULL;
++ }
++ pos += res;
++ }
++ res = os_snprintf(pos, 6, "%.1f",
++ (double)ssid->rates[NL80211_MAX_SUPP_RATES - 1] / 2);
++ if (res < 0) {
++ os_free(value);
++ return NULL;
++ }
++
++ value[6 * NL80211_MAX_SUPP_RATES] = '\0';
++ return value;
++}
++#endif /* NO_CONFIG_WRITE */
++
+ /* Helper macros for network block parser */
+
+ #ifdef OFFSET
+@@ -1788,6 +1880,9 @@ static const struct parse_data ssid_fiel
+ { INT(ap_max_inactivity) },
+ { INT(dtim_period) },
+ { INT(beacon_int) },
++ { INT_RANGE(fixed_freq, 0, 1) },
++ { FUNC(rates) },
++ { FUNC(mcast_rate) },
+ #ifdef CONFIG_MACSEC
+ { INT_RANGE(macsec_policy, 0, 1) },
+ #endif /* CONFIG_MACSEC */
+--- a/wpa_supplicant/config_ssid.h
++++ b/wpa_supplicant/config_ssid.h
+@@ -12,6 +12,7 @@
+ #include "common/defs.h"
+ #include "utils/list.h"
+ #include "eap_peer/eap_config.h"
++#include "drivers/nl80211_copy.h"
+
+ #define MAX_SSID_LEN 32
+
+@@ -640,6 +641,10 @@ struct wpa_ssid {
+ */
+ void *parent_cred;
+
++ int fixed_freq;
++ unsigned char rates[NL80211_MAX_SUPP_RATES];
++ double mcast_rate;
++
+ #ifdef CONFIG_MACSEC
+ /**
+ * macsec_policy - Determines the policy for MACsec secure session
+--- a/wpa_supplicant/wpa_supplicant.c
++++ b/wpa_supplicant/wpa_supplicant.c
+@@ -1949,6 +1949,13 @@ static void wpas_start_assoc_cb(struct w
+ params.beacon_int = ssid->beacon_int;
+ else
+ params.beacon_int = wpa_s->conf->beacon_int;
++ params.fixed_freq = ssid->fixed_freq;
++ i = 0;
++ while (i < NL80211_MAX_SUPP_RATES) {
++ params.rates[i] = ssid->rates[i];
++ i++;
++ }
++ params.mcast_rate = ssid->mcast_rate;
+ }
+
+ params.wpa_ie = wpa_ie;
--- /dev/null
+From ffc4445958a3ed4064f2e1bf73fa478a61c5cf7b Mon Sep 17 00:00:00 2001
+From: Antonio Quartulli <ordex@autistici.org>
+Date: Sun, 3 Jun 2012 18:42:25 +0200
+Subject: [PATCHv2 602/602] driver_nl80211: use new parameters during ibss join
+
+Signed-hostap: Antonio Quartulli <ordex@autistici.org>
+---
+ src/drivers/driver_nl80211.c | 33 ++++++++++++++++++++++++++++++++-
+ 1 file changed, 32 insertions(+), 1 deletion(-)
+
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -9023,7 +9023,7 @@ static int wpa_driver_nl80211_ibss(struc
+ struct wpa_driver_associate_params *params)
+ {
+ struct nl_msg *msg;
+- int ret = -1;
++ int ret = -1, i;
+ int count = 0;
+
+ wpa_printf(MSG_DEBUG, "nl80211: Join IBSS (ifindex=%d)", drv->ifindex);
+@@ -9069,6 +9069,37 @@ retry:
+ params->beacon_int);
+ }
+
++ if (params->fixed_freq) {
++ wpa_printf(MSG_DEBUG, " * fixed_freq");
++ NLA_PUT_FLAG(msg, NL80211_ATTR_FREQ_FIXED);
++ }
++
++ if (params->beacon_interval > 0) {
++ wpa_printf(MSG_DEBUG, " * beacon_interval=%d",
++ params->beacon_interval);
++ NLA_PUT_U32(msg, NL80211_ATTR_BEACON_INTERVAL,
++ params->beacon_interval);
++ }
++
++ if (params->rates[0] > 0) {
++ wpa_printf(MSG_DEBUG, " * basic_rates:");
++ i = 0;
++ while (i < NL80211_MAX_SUPP_RATES &&
++ params->rates[i] > 0) {
++ wpa_printf(MSG_DEBUG, " %.1f",
++ (double)params->rates[i] / 2);
++ i++;
++ }
++ NLA_PUT(msg, NL80211_ATTR_BSS_BASIC_RATES, i,
++ params->rates);
++ }
++
++ if (params->mcast_rate > 0) {
++ wpa_printf(MSG_DEBUG, " * mcast_rates=%.1f",
++ (double)params->mcast_rate / 10);
++ NLA_PUT_U32(msg, NL80211_ATTR_MCAST_RATE, params->mcast_rate);
++ }
++
+ ret = nl80211_set_conn_keys(params, msg);
+ if (ret)
+ goto nla_put_failure;
--- /dev/null
+From b9329c5dfeed7d5c55d2117d8dfe326fc40c8fb1 Mon Sep 17 00:00:00 2001
+From: Antonio Quartulli <ordex@autistici.org>
+Date: Tue, 3 Jul 2012 00:36:24 +0200
+Subject: [PATCH] wpa_s: support htmode param
+
+possible values are HT20, HT40-, HT40+ and NOHT
+
+Signed-off-by: Antonio Quartulli <ordex@autistici.org>
+---
+ src/drivers/driver.h | 2 ++
+ src/drivers/driver_nl80211.c | 16 ++++++++++
+ wpa_supplicant/config.c | 66 +++++++++++++++++++++++++++++++++++++++
+ wpa_supplicant/config_ssid.h | 2 ++
+ wpa_supplicant/wpa_supplicant.c | 2 ++
+ 5 files changed, 88 insertions(+)
+
+--- a/src/drivers/driver.h
++++ b/src/drivers/driver.h
+@@ -447,6 +447,8 @@ struct wpa_driver_associate_params {
+ int fixed_freq;
+ unsigned char rates[NL80211_MAX_SUPP_RATES];
+ int mcast_rate;
++ int ht_set;
++ unsigned int htmode;
+
+ /**
+ * bssid_hint - BSSID of a proposed AP
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -9100,6 +9100,22 @@ retry:
+ NLA_PUT_U32(msg, NL80211_ATTR_MCAST_RATE, params->mcast_rate);
+ }
+
++ if (params->ht_set) {
++ switch(params->htmode) {
++ case NL80211_CHAN_HT20:
++ wpa_printf(MSG_DEBUG, " * ht=HT20");
++ break;
++ case NL80211_CHAN_HT40PLUS:
++ wpa_printf(MSG_DEBUG, " * ht=HT40+");
++ break;
++ case NL80211_CHAN_HT40MINUS:
++ wpa_printf(MSG_DEBUG, " * ht=HT40-");
++ break;
++ }
++ NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE,
++ params->htmode);
++ }
++
+ ret = nl80211_set_conn_keys(params, msg);
+ if (ret)
+ goto nla_put_failure;
+--- a/wpa_supplicant/config.c
++++ b/wpa_supplicant/config.c
+@@ -1608,6 +1608,71 @@ static char * wpa_config_write_mcast_rat
+ }
+ #endif /* NO_CONFIG_WRITE */
+
++static int wpa_config_parse_htmode(const struct parse_data *data,
++ struct wpa_ssid *ssid, int line,
++ const char *value)
++{
++ int i;
++ static const struct {
++ const char *name;
++ unsigned int val;
++ } htmap[] = {
++ { .name = "HT20", .val = NL80211_CHAN_HT20, },
++ { .name = "HT40+", .val = NL80211_CHAN_HT40PLUS, },
++ { .name = "HT40-", .val = NL80211_CHAN_HT40MINUS, },
++ { .name = "NOHT", .val = NL80211_CHAN_NO_HT, },
++ };
++ ssid->ht_set = 0;;
++ for (i = 0; i < 4; i++) {
++ if (strcasecmp(htmap[i].name, value) == 0) {
++ ssid->htmode = htmap[i].val;
++ ssid->ht_set = 1;
++ break;
++ }
++ }
++
++ return 0;
++}
++
++#ifndef NO_CONFIG_WRITE
++static char * wpa_config_write_htmode(const struct parse_data *data,
++ struct wpa_ssid *ssid)
++{
++ char *value;
++ int res;
++
++ value = os_malloc(6); /* longest: HT40+ */
++ if (value == NULL)
++ return NULL;
++
++ switch(ssid->htmode) {
++ case NL80211_CHAN_HT20:
++ res = os_snprintf(value, 4, "HT20");
++ break;
++ case NL80211_CHAN_HT40PLUS:
++ res = os_snprintf(value, 5, "HT40+");
++ break;
++ case NL80211_CHAN_HT40MINUS:
++ res = os_snprintf(value, 5, "HT40-");
++ break;
++ case NL80211_CHAN_NO_HT:
++ res = os_snprintf(value, 4, "NOHT");
++ break;
++ default:
++ os_free(value);
++ return NULL;
++ }
++
++ if (res < 0) {
++ os_free(value);
++ return NULL;
++ }
++
++ return value;
++}
++#endif /* NO_CONFIG_WRITE */
++
++
+ static int wpa_config_parse_rates(const struct parse_data *data,
+ struct wpa_ssid *ssid, int line,
+ const char *value)
+@@ -1883,6 +1948,7 @@ static const struct parse_data ssid_fiel
+ { INT_RANGE(fixed_freq, 0, 1) },
+ { FUNC(rates) },
+ { FUNC(mcast_rate) },
++ { FUNC(htmode) },
+ #ifdef CONFIG_MACSEC
+ { INT_RANGE(macsec_policy, 0, 1) },
+ #endif /* CONFIG_MACSEC */
+--- a/wpa_supplicant/config_ssid.h
++++ b/wpa_supplicant/config_ssid.h
+@@ -644,6 +644,8 @@ struct wpa_ssid {
+ int fixed_freq;
+ unsigned char rates[NL80211_MAX_SUPP_RATES];
+ double mcast_rate;
++ int ht_set;
++ unsigned int htmode;
+
+ #ifdef CONFIG_MACSEC
+ /**
+--- a/wpa_supplicant/wpa_supplicant.c
++++ b/wpa_supplicant/wpa_supplicant.c
+@@ -1956,6 +1956,8 @@ static void wpas_start_assoc_cb(struct w
+ i++;
+ }
+ params.mcast_rate = ssid->mcast_rate;
++ params.ht_set = ssid->ht_set;
++ params.htmode = ssid->htmode;
+ }
+
+ params.wpa_ie = wpa_ie;
+++ /dev/null
---- a/hostapd/hostapd_cli.c
-+++ b/hostapd/hostapd_cli.c
-@@ -67,7 +67,6 @@ static const char *commands_help =
- #ifdef CONFIG_IEEE80211W
- " sa_query <addr> send SA Query to a station\n"
- #endif /* CONFIG_IEEE80211W */
--#ifdef CONFIG_WPS
- " wps_pin <uuid> <pin> [timeout] [addr] add WPS Enrollee PIN\n"
- " wps_check_pin <PIN> verify PIN checksum\n"
- " wps_pbc indicate button pushed to initiate PBC\n"
-@@ -80,7 +79,6 @@ static const char *commands_help =
- " wps_ap_pin <cmd> [params..] enable/disable AP PIN\n"
- " wps_config <SSID> <auth> <encr> <key> configure AP\n"
- " wps_get_status show current WPS status\n"
--#endif /* CONFIG_WPS */
- " get_config show current configuration\n"
- " help show this usage help\n"
- " interface [ifname] show interfaces/select interface\n"
-@@ -353,7 +351,6 @@ static int hostapd_cli_cmd_sa_query(stru
- #endif /* CONFIG_IEEE80211W */
-
-
--#ifdef CONFIG_WPS
- static int hostapd_cli_cmd_wps_pin(struct wpa_ctrl *ctrl, int argc,
- char *argv[])
- {
-@@ -579,7 +576,6 @@ static int hostapd_cli_cmd_wps_config(st
- ssid_hex, argv[1]);
- return wpa_ctrl_command(ctrl, buf);
- }
--#endif /* CONFIG_WPS */
-
-
- static int hostapd_cli_cmd_disassoc_imminent(struct wpa_ctrl *ctrl, int argc,
-@@ -970,7 +966,6 @@ static struct hostapd_cli_cmd hostapd_cl
- #ifdef CONFIG_IEEE80211W
- { "sa_query", hostapd_cli_cmd_sa_query },
- #endif /* CONFIG_IEEE80211W */
--#ifdef CONFIG_WPS
- { "wps_pin", hostapd_cli_cmd_wps_pin },
- { "wps_check_pin", hostapd_cli_cmd_wps_check_pin },
- { "wps_pbc", hostapd_cli_cmd_wps_pbc },
-@@ -984,7 +979,6 @@ static struct hostapd_cli_cmd hostapd_cl
- { "wps_ap_pin", hostapd_cli_cmd_wps_ap_pin },
- { "wps_config", hostapd_cli_cmd_wps_config },
- { "wps_get_status", hostapd_cli_cmd_wps_get_status },
--#endif /* CONFIG_WPS */
- { "disassoc_imminent", hostapd_cli_cmd_disassoc_imminent },
- { "ess_disassoc", hostapd_cli_cmd_ess_disassoc },
- { "get_config", hostapd_cli_cmd_get_config },
+++ /dev/null
---- a/wpa_supplicant/wpa_cli.c
-+++ b/wpa_supplicant/wpa_cli.c
-@@ -26,6 +26,10 @@
- #endif /* ANDROID */
-
-
-+#ifndef CONFIG_P2P
-+#define CONFIG_P2P
-+#endif
-+
- static const char *wpa_cli_version =
- "wpa_cli v" VERSION_STR "\n"
- "Copyright (c) 2004-2014, Jouni Malinen <j@w1.fi> and contributors";
+++ /dev/null
---- a/src/ap/beacon.c
-+++ b/src/ap/beacon.c
-@@ -599,6 +599,10 @@ void handle_probe_req(struct hostapd_dat
- return;
- }
-
-+ if (!sta && hapd->num_sta >= hapd->conf->max_num_sta)
-+ wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR " ignored,"
-+ " too many connected stations.", MAC2STR(mgmt->sa));
-+
- #ifdef CONFIG_INTERWORKING
- if (hapd->conf->interworking &&
- elems.interworking && elems.interworking_len >= 1) {
+++ /dev/null
---- a/hostapd/main.c
-+++ b/hostapd/main.c
-@@ -36,6 +36,8 @@ struct hapd_global {
- };
-
- static struct hapd_global global;
-+static int daemonize = 0;
-+static char *pid_file = NULL;
-
-
- #ifndef CONFIG_NO_HOSTAPD_LOGGER
-@@ -141,6 +143,14 @@ static void hostapd_logger_cb(void *ctx,
- }
- #endif /* CONFIG_NO_HOSTAPD_LOGGER */
-
-+static void hostapd_setup_complete_cb(void *ctx)
-+{
-+ if (daemonize && os_daemonize(pid_file)) {
-+ perror("daemon");
-+ return;
-+ }
-+ daemonize = 0;
-+}
-
- /**
- * hostapd_driver_init - Preparate driver interface
-@@ -159,6 +169,8 @@ static int hostapd_driver_init(struct ho
- return -1;
- }
-
-+ hapd->setup_complete_cb = hostapd_setup_complete_cb;
-+
- /* Initialize the driver interface */
- if (!(b[0] | b[1] | b[2] | b[3] | b[4] | b[5]))
- b = NULL;
-@@ -372,8 +384,6 @@ static void hostapd_global_deinit(const
- #endif /* CONFIG_NATIVE_WINDOWS */
-
- eap_server_unregister_methods();
--
-- os_daemonize_terminate(pid_file);
- }
-
-
-@@ -399,11 +409,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;
-@@ -533,8 +538,7 @@ int main(int argc, char *argv[])
- struct hapd_interfaces interfaces;
- int ret = 1;
- size_t i, j;
-- int c, debug = 0, daemonize = 0;
-- char *pid_file = NULL;
-+ int c, debug = 0;
- const char *log_file = NULL;
- const char *entropy_file = NULL;
- char **bss_config = NULL, **tmp_bss;
+++ /dev/null
-From 4bb69d15477e0f2b00e166845341dc933de47c58 Mon Sep 17 00:00:00 2001
-From: Antonio Quartulli <ordex@autistici.org>
-Date: Sun, 3 Jun 2012 18:22:56 +0200
-Subject: [PATCHv2 601/602] wpa_supplicant: add new config params to be used
- with the ibss join command
-
-Signed-hostap: Antonio Quartulli <ordex@autistici.org>
----
- src/drivers/driver.h | 6 +++
- wpa_supplicant/config.c | 96 +++++++++++++++++++++++++++++++++++++++
- wpa_supplicant/config_ssid.h | 6 +++
- wpa_supplicant/wpa_supplicant.c | 23 +++++++---
- 4 files changed, 124 insertions(+), 7 deletions(-)
-
---- a/src/drivers/driver.h
-+++ b/src/drivers/driver.h
-@@ -19,6 +19,7 @@
-
- #define WPA_SUPPLICANT_DRIVER_VERSION 4
-
-+#include "drivers/nl80211_copy.h"
- #include "common/defs.h"
- #include "utils/list.h"
-
-@@ -414,6 +415,11 @@ struct wpa_driver_associate_params {
- * responsible for selecting with which BSS to associate. */
- const u8 *bssid;
-
-+ int beacon_interval;
-+ int fixed_freq;
-+ unsigned char rates[NL80211_MAX_SUPP_RATES];
-+ int mcast_rate;
-+
- /**
- * bssid_hint - BSSID of a proposed AP
- *
---- a/wpa_supplicant/config.c
-+++ b/wpa_supplicant/config.c
-@@ -15,6 +15,7 @@
- #include "rsn_supp/wpa.h"
- #include "eap_peer/eap.h"
- #include "p2p/p2p.h"
-+#include "drivers/nl80211_copy.h"
- #include "config.h"
-
-
-@@ -1527,6 +1528,97 @@ static char * wpa_config_write_psk_list(
-
- #endif /* CONFIG_P2P */
-
-+static int wpa_config_parse_mcast_rate(const struct parse_data *data,
-+ struct wpa_ssid *ssid, int line,
-+ const char *value)
-+{
-+ ssid->mcast_rate = (int)(strtod(value, NULL) * 10);
-+
-+ return 0;
-+}
-+
-+#ifndef NO_CONFIG_WRITE
-+static char * wpa_config_write_mcast_rate(const struct parse_data *data,
-+ struct wpa_ssid *ssid)
-+{
-+ char *value;
-+ int res;
-+
-+ if (!ssid->mcast_rate == 0)
-+ return NULL;
-+
-+ value = os_malloc(6); /* longest: 300.0 */
-+ if (value == NULL)
-+ return NULL;
-+ res = os_snprintf(value, 5, "%.1f", (double)ssid->mcast_rate / 10);
-+ if (res < 0) {
-+ os_free(value);
-+ return NULL;
-+ }
-+ return value;
-+}
-+#endif /* NO_CONFIG_WRITE */
-+
-+static int wpa_config_parse_rates(const struct parse_data *data,
-+ struct wpa_ssid *ssid, int line,
-+ const char *value)
-+{
-+ int i;
-+ char *pos, *r, *sptr, *end;
-+ double rate;
-+
-+ pos = (char *)value;
-+ r = strtok_r(pos, ",", &sptr);
-+ i = 0;
-+ while (pos && i < NL80211_MAX_SUPP_RATES) {
-+ rate = 0.0;
-+ if (r)
-+ rate = strtod(r, &end);
-+ ssid->rates[i] = rate * 2;
-+ if (*end != '\0' || rate * 2 != ssid->rates[i])
-+ return 1;
-+
-+ i++;
-+ r = strtok_r(NULL, ",", &sptr);
-+ }
-+
-+ return 0;
-+}
-+
-+#ifndef NO_CONFIG_WRITE
-+static char * wpa_config_write_rates(const struct parse_data *data,
-+ struct wpa_ssid *ssid)
-+{
-+ char *value, *pos;
-+ int res, i;
-+
-+ if (ssid->rates[0] <= 0)
-+ return NULL;
-+
-+ value = os_malloc(6 * NL80211_MAX_SUPP_RATES + 1);
-+ if (value == NULL)
-+ return NULL;
-+ pos = value;
-+ for (i = 0; i < NL80211_MAX_SUPP_RATES - 1; i++) {
-+ res = os_snprintf(pos, 6, "%.1f,", (double)ssid->rates[i] / 2);
-+ if (res < 0) {
-+ os_free(value);
-+ return NULL;
-+ }
-+ pos += res;
-+ }
-+ res = os_snprintf(pos, 6, "%.1f",
-+ (double)ssid->rates[NL80211_MAX_SUPP_RATES - 1] / 2);
-+ if (res < 0) {
-+ os_free(value);
-+ return NULL;
-+ }
-+
-+ value[6 * NL80211_MAX_SUPP_RATES] = '\0';
-+ return value;
-+}
-+#endif /* NO_CONFIG_WRITE */
-+
- /* Helper macros for network block parser */
-
- #ifdef OFFSET
-@@ -1733,6 +1825,9 @@ static const struct parse_data ssid_fiel
- { INT(ap_max_inactivity) },
- { INT(dtim_period) },
- { INT(beacon_int) },
-+ { INT_RANGE(fixed_freq, 0, 1) },
-+ { FUNC(rates) },
-+ { FUNC(mcast_rate) },
- #ifdef CONFIG_MACSEC
- { INT_RANGE(macsec_policy, 0, 1) },
- #endif /* CONFIG_MACSEC */
---- a/wpa_supplicant/config_ssid.h
-+++ b/wpa_supplicant/config_ssid.h
-@@ -12,6 +12,7 @@
- #include "common/defs.h"
- #include "utils/list.h"
- #include "eap_peer/eap_config.h"
-+#include "drivers/nl80211_copy.h"
-
- #define MAX_SSID_LEN 32
-
-@@ -637,6 +638,10 @@ struct wpa_ssid {
- */
- void *parent_cred;
-
-+ int fixed_freq;
-+ unsigned char rates[NL80211_MAX_SUPP_RATES];
-+ double mcast_rate;
-+
- #ifdef CONFIG_MACSEC
- /**
- * macsec_policy - Determines the policy for MACsec secure session
---- a/wpa_supplicant/wpa_supplicant.c
-+++ b/wpa_supplicant/wpa_supplicant.c
-@@ -1806,6 +1806,13 @@ static void wpas_start_assoc_cb(struct w
- params.beacon_int = ssid->beacon_int;
- else
- params.beacon_int = wpa_s->conf->beacon_int;
-+ params.fixed_freq = ssid->fixed_freq;
-+ i = 0;
-+ while (i < NL80211_MAX_SUPP_RATES) {
-+ params.rates[i] = ssid->rates[i];
-+ i++;
-+ }
-+ params.mcast_rate = ssid->mcast_rate;
- }
-
- params.wpa_ie = wpa_ie;
+++ /dev/null
-From ffc4445958a3ed4064f2e1bf73fa478a61c5cf7b Mon Sep 17 00:00:00 2001
-From: Antonio Quartulli <ordex@autistici.org>
-Date: Sun, 3 Jun 2012 18:42:25 +0200
-Subject: [PATCHv2 602/602] driver_nl80211: use new parameters during ibss join
-
-Signed-hostap: Antonio Quartulli <ordex@autistici.org>
----
- src/drivers/driver_nl80211.c | 33 ++++++++++++++++++++++++++++++++-
- 1 file changed, 32 insertions(+), 1 deletion(-)
-
---- a/src/drivers/driver_nl80211.c
-+++ b/src/drivers/driver_nl80211.c
-@@ -8581,7 +8581,7 @@ static int wpa_driver_nl80211_ibss(struc
- struct wpa_driver_associate_params *params)
- {
- struct nl_msg *msg;
-- int ret = -1;
-+ int ret = -1, i;
- int count = 0;
-
- wpa_printf(MSG_DEBUG, "nl80211: Join IBSS (ifindex=%d)", drv->ifindex);
-@@ -8620,6 +8620,37 @@ retry:
- params->beacon_int);
- }
-
-+ if (params->fixed_freq) {
-+ wpa_printf(MSG_DEBUG, " * fixed_freq");
-+ NLA_PUT_FLAG(msg, NL80211_ATTR_FREQ_FIXED);
-+ }
-+
-+ if (params->beacon_interval > 0) {
-+ wpa_printf(MSG_DEBUG, " * beacon_interval=%d",
-+ params->beacon_interval);
-+ NLA_PUT_U32(msg, NL80211_ATTR_BEACON_INTERVAL,
-+ params->beacon_interval);
-+ }
-+
-+ if (params->rates[0] > 0) {
-+ wpa_printf(MSG_DEBUG, " * basic_rates:");
-+ i = 0;
-+ while (i < NL80211_MAX_SUPP_RATES &&
-+ params->rates[i] > 0) {
-+ wpa_printf(MSG_DEBUG, " %.1f",
-+ (double)params->rates[i] / 2);
-+ i++;
-+ }
-+ NLA_PUT(msg, NL80211_ATTR_BSS_BASIC_RATES, i,
-+ params->rates);
-+ }
-+
-+ if (params->mcast_rate > 0) {
-+ wpa_printf(MSG_DEBUG, " * mcast_rates=%.1f",
-+ (double)params->mcast_rate / 10);
-+ NLA_PUT_U32(msg, NL80211_ATTR_MCAST_RATE, params->mcast_rate);
-+ }
-+
- ret = nl80211_set_conn_keys(params, msg);
- if (ret)
- goto nla_put_failure;
+++ /dev/null
-From b9329c5dfeed7d5c55d2117d8dfe326fc40c8fb1 Mon Sep 17 00:00:00 2001
-From: Antonio Quartulli <ordex@autistici.org>
-Date: Tue, 3 Jul 2012 00:36:24 +0200
-Subject: [PATCH] wpa_s: support htmode param
-
-possible values are HT20, HT40-, HT40+ and NOHT
-
-Signed-off-by: Antonio Quartulli <ordex@autistici.org>
----
- src/drivers/driver.h | 2 ++
- src/drivers/driver_nl80211.c | 16 ++++++++++
- wpa_supplicant/config.c | 66 +++++++++++++++++++++++++++++++++++++++
- wpa_supplicant/config_ssid.h | 2 ++
- wpa_supplicant/wpa_supplicant.c | 2 ++
- 5 files changed, 88 insertions(+)
-
---- a/src/drivers/driver.h
-+++ b/src/drivers/driver.h
-@@ -419,6 +419,8 @@ struct wpa_driver_associate_params {
- int fixed_freq;
- unsigned char rates[NL80211_MAX_SUPP_RATES];
- int mcast_rate;
-+ int ht_set;
-+ unsigned int htmode;
-
- /**
- * bssid_hint - BSSID of a proposed AP
---- a/src/drivers/driver_nl80211.c
-+++ b/src/drivers/driver_nl80211.c
-@@ -8651,6 +8651,22 @@ retry:
- NLA_PUT_U32(msg, NL80211_ATTR_MCAST_RATE, params->mcast_rate);
- }
-
-+ if (params->ht_set) {
-+ switch(params->htmode) {
-+ case NL80211_CHAN_HT20:
-+ wpa_printf(MSG_DEBUG, " * ht=HT20");
-+ break;
-+ case NL80211_CHAN_HT40PLUS:
-+ wpa_printf(MSG_DEBUG, " * ht=HT40+");
-+ break;
-+ case NL80211_CHAN_HT40MINUS:
-+ wpa_printf(MSG_DEBUG, " * ht=HT40-");
-+ break;
-+ }
-+ NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE,
-+ params->htmode);
-+ }
-+
- ret = nl80211_set_conn_keys(params, msg);
- if (ret)
- goto nla_put_failure;
---- a/wpa_supplicant/config.c
-+++ b/wpa_supplicant/config.c
-@@ -1559,6 +1559,71 @@ static char * wpa_config_write_mcast_rat
- }
- #endif /* NO_CONFIG_WRITE */
-
-+static int wpa_config_parse_htmode(const struct parse_data *data,
-+ struct wpa_ssid *ssid, int line,
-+ const char *value)
-+{
-+ int i;
-+ static const struct {
-+ const char *name;
-+ unsigned int val;
-+ } htmap[] = {
-+ { .name = "HT20", .val = NL80211_CHAN_HT20, },
-+ { .name = "HT40+", .val = NL80211_CHAN_HT40PLUS, },
-+ { .name = "HT40-", .val = NL80211_CHAN_HT40MINUS, },
-+ { .name = "NOHT", .val = NL80211_CHAN_NO_HT, },
-+ };
-+ ssid->ht_set = 0;;
-+ for (i = 0; i < 4; i++) {
-+ if (strcasecmp(htmap[i].name, value) == 0) {
-+ ssid->htmode = htmap[i].val;
-+ ssid->ht_set = 1;
-+ break;
-+ }
-+ }
-+
-+ return 0;
-+}
-+
-+#ifndef NO_CONFIG_WRITE
-+static char * wpa_config_write_htmode(const struct parse_data *data,
-+ struct wpa_ssid *ssid)
-+{
-+ char *value;
-+ int res;
-+
-+ value = os_malloc(6); /* longest: HT40+ */
-+ if (value == NULL)
-+ return NULL;
-+
-+ switch(ssid->htmode) {
-+ case NL80211_CHAN_HT20:
-+ res = os_snprintf(value, 4, "HT20");
-+ break;
-+ case NL80211_CHAN_HT40PLUS:
-+ res = os_snprintf(value, 5, "HT40+");
-+ break;
-+ case NL80211_CHAN_HT40MINUS:
-+ res = os_snprintf(value, 5, "HT40-");
-+ break;
-+ case NL80211_CHAN_NO_HT:
-+ res = os_snprintf(value, 4, "NOHT");
-+ break;
-+ default:
-+ os_free(value);
-+ return NULL;
-+ }
-+
-+ if (res < 0) {
-+ os_free(value);
-+ return NULL;
-+ }
-+
-+ return value;
-+}
-+#endif /* NO_CONFIG_WRITE */
-+
-+
- static int wpa_config_parse_rates(const struct parse_data *data,
- struct wpa_ssid *ssid, int line,
- const char *value)
-@@ -1828,6 +1893,7 @@ static const struct parse_data ssid_fiel
- { INT_RANGE(fixed_freq, 0, 1) },
- { FUNC(rates) },
- { FUNC(mcast_rate) },
-+ { FUNC(htmode) },
- #ifdef CONFIG_MACSEC
- { INT_RANGE(macsec_policy, 0, 1) },
- #endif /* CONFIG_MACSEC */
---- a/wpa_supplicant/config_ssid.h
-+++ b/wpa_supplicant/config_ssid.h
-@@ -641,6 +641,8 @@ struct wpa_ssid {
- int fixed_freq;
- unsigned char rates[NL80211_MAX_SUPP_RATES];
- double mcast_rate;
-+ int ht_set;
-+ unsigned int htmode;
-
- #ifdef CONFIG_MACSEC
- /**
---- a/wpa_supplicant/wpa_supplicant.c
-+++ b/wpa_supplicant/wpa_supplicant.c
-@@ -1813,6 +1813,8 @@ static void wpas_start_assoc_cb(struct w
- i++;
- }
- params.mcast_rate = ssid->mcast_rate;
-+ params.ht_set = ssid->ht_set;
-+ params.htmode = ssid->htmode;
- }
-
- params.wpa_ie = wpa_ie;
--- a/hostapd/Makefile
+++ b/hostapd/Makefile
-@@ -116,6 +116,11 @@ OBJS += ../src/common/wpa_common.o
+@@ -117,6 +117,11 @@ OBJS += ../src/common/wpa_common.o
OBJS += ../src/eapol_auth/eapol_auth_sm.o
struct wpa_ctrl_dst;
struct radius_server_data;
-@@ -99,6 +100,7 @@ struct hostapd_data {
+@@ -102,6 +103,7 @@ struct hostapd_data {
struct hostapd_iface *iface;
struct hostapd_config *iconf;
struct hostapd_bss_config *conf;
int interface_added; /* virtual interface added for this BSS */
unsigned int started:1;
-@@ -254,6 +256,8 @@ struct hostapd_iface {
+@@ -275,6 +277,8 @@ struct hostapd_iface {
struct hostapd_config *conf;
char phy[16]; /* Name of the PHY (radio) */
+#endif
--- a/src/ap/hostapd.c
+++ b/src/ap/hostapd.c
-@@ -262,6 +262,7 @@ static void hostapd_free_hapd_data(struc
+@@ -263,6 +263,7 @@ static void hostapd_free_hapd_data(struc
hapd->started = 0;
wpa_printf(MSG_DEBUG, "%s(%s)", __func__, hapd->conf->iface);
iapp_deinit(hapd->iapp);
hapd->iapp = NULL;
accounting_deinit(hapd);
-@@ -890,6 +891,8 @@ static int hostapd_setup_bss(struct host
+@@ -907,6 +908,8 @@ static int hostapd_setup_bss(struct host
if (hapd->driver && hapd->driver->set_operstate)
hapd->driver->set_operstate(hapd->drv_priv, 1);
return 0;
}
-@@ -1180,6 +1183,7 @@ int hostapd_setup_interface_complete(str
+@@ -1192,6 +1195,7 @@ int hostapd_setup_interface_complete(str
if (err)
goto fail;
wpa_printf(MSG_DEBUG, "Completing interface initialization");
if (iface->conf->channel) {
#ifdef NEED_AP_MLME
-@@ -1297,6 +1301,7 @@ int hostapd_setup_interface_complete(str
+@@ -1322,6 +1326,7 @@ int hostapd_setup_interface_complete(str
fail:
wpa_printf(MSG_ERROR, "Interface initialization failed");
hostapd_set_state(iface, HAPD_IFACE_DISABLED);
wpa_msg(hapd->msg_ctx, MSG_INFO, AP_EVENT_DISABLED);
if (iface->interfaces && iface->interfaces->terminate_on_error)
-@@ -1623,6 +1628,7 @@ void hostapd_interface_deinit_free(struc
+@@ -1648,6 +1653,7 @@ void hostapd_interface_deinit_free(struc
(unsigned int) iface->conf->num_bss);
driver = iface->bss[0]->driver;
drv_priv = iface->bss[0]->drv_priv;
__func__, driver, drv_priv);
--- a/src/ap/ieee802_11.c
+++ b/src/ap/ieee802_11.c
-@@ -540,7 +540,8 @@ failed:
+@@ -545,7 +545,8 @@ failed:
static void handle_auth(struct hostapd_data *hapd,
{
u16 auth_alg, auth_transaction, status_code;
u16 resp = WLAN_STATUS_SUCCESS;
-@@ -555,6 +556,11 @@ static void handle_auth(struct hostapd_d
+@@ -560,6 +561,11 @@ static void handle_auth(struct hostapd_d
size_t resp_ies_len = 0;
char *identity = NULL;
char *radius_cui = NULL;
if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.auth)) {
wpa_printf(MSG_INFO, "handle_auth - too short payload (len=%lu)",
-@@ -638,6 +644,14 @@ static void handle_auth(struct hostapd_d
+@@ -643,6 +649,14 @@ static void handle_auth(struct hostapd_d
resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
goto fail;
}
if (res == HOSTAPD_ACL_PENDING) {
wpa_printf(MSG_DEBUG, "Authentication frame from " MACSTR
" waiting for an external authentication",
-@@ -1272,13 +1286,18 @@ static void send_assoc_resp(struct hosta
+@@ -1289,13 +1303,18 @@ static void send_assoc_resp(struct hosta
static void handle_assoc(struct hostapd_data *hapd,
const struct ieee80211_mgmt *mgmt, size_t len,
if (len < IEEE80211_HDRLEN + (reassoc ? sizeof(mgmt->u.reassoc_req) :
sizeof(mgmt->u.assoc_req))) {
-@@ -1377,6 +1396,13 @@ static void handle_assoc(struct hostapd_
+@@ -1394,6 +1413,13 @@ static void handle_assoc(struct hostapd_
goto fail;
}
sta->capability = capab_info;
sta->listen_interval = listen_interval;
-@@ -1765,7 +1791,7 @@ int ieee802_11_mgmt(struct hostapd_data
+@@ -1785,7 +1811,7 @@ int ieee802_11_mgmt(struct hostapd_data
if (stype == WLAN_FC_STYPE_PROBE_REQ) {
return 1;
}
-@@ -1780,17 +1806,17 @@ int ieee802_11_mgmt(struct hostapd_data
+@@ -1800,17 +1826,17 @@ int ieee802_11_mgmt(struct hostapd_data
switch (stype) {
case WLAN_FC_STYPE_AUTH:
wpa_printf(MSG_DEBUG, "mgmt::auth");
case WLAN_FC_STYPE_DISASSOC:
--- a/src/ap/beacon.c
+++ b/src/ap/beacon.c
-@@ -498,7 +498,7 @@ static enum ssid_match_result ssid_match
+@@ -513,7 +513,7 @@ static enum ssid_match_result ssid_match
void handle_probe_req(struct hostapd_data *hapd,
const struct ieee80211_mgmt *mgmt, size_t len,
{
u8 *resp;
struct ieee802_11_elems elems;
-@@ -506,8 +506,14 @@ void handle_probe_req(struct hostapd_dat
+@@ -521,8 +521,14 @@ void handle_probe_req(struct hostapd_dat
size_t ie_len;
struct sta_info *sta = NULL;
size_t i, resp_len;
ie = mgmt->u.probe_req.variable;
if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.probe_req))
-@@ -645,6 +651,12 @@ void handle_probe_req(struct hostapd_dat
+@@ -660,6 +666,12 @@ void handle_probe_req(struct hostapd_dat
}
#endif /* CONFIG_P2P */