include $(TOPDIR)/rules.mk
PKG_NAME:=hostapd
-PKG_VERSION:=20101109
+PKG_VERSION:=20101111
PKG_RELEASE:=1
-PKG_REV:=8672562b04a6f51cba5dad19b27a296caa17f0c0
+PKG_REV:=5db8cf314ef169cd256483e32dcc49e31e605121
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=git://w1.fi/srv/git/hostap.git
+++ /dev/null
---- 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
-
-@@ -1510,7 +1511,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/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_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -1380,7 +1380,6 @@ nla_put_failure:
+ }
+
+
+-#ifndef HOSTAPD
+ struct wiphy_info_data {
+ int max_scan_ssids;
+ int ap_supported;
+@@ -1493,7 +1492,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)
+@@ -1667,6 +1665,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);
+@@ -1823,32 +1822,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 "
+@@ -2511,13 +2510,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)
+@@ -3368,7 +3363,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();
+@@ -3441,7 +3437,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 &&
+@@ -5155,6 +5152,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/src/drivers/driver_nl80211.c
-+++ b/src/drivers/driver_nl80211.c
-@@ -4987,9 +4987,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
-@@ -1659,6 +1659,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/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -452,6 +452,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,
+@@ -523,6 +527,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) {
+@@ -1490,6 +1498,11 @@ static int wpa_driver_nl80211_capa(struc
+ drv->capa.flags |= WPA_DRIVER_FLAGS_P2P_CAPABLE;
+ drv->capa.max_remain_on_chan = 5000;
+
++#ifdef HOSTAPD
++ drv->num_if_indices = sizeof(drv->default_if_indices) / sizeof(int);
++ drv->if_indices = drv->default_if_indices;
++#endif
++
+ return 0;
+ }
+
+@@ -5162,8 +5175,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/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
-@@ -1208,6 +1208,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
-@@ -4977,7 +4977,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;
-@@ -4991,6 +4992,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
-@@ -366,9 +366,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
-@@ -1700,7 +1700,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
-@@ -728,6 +728,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/src/drivers/driver_madwifi.c
++++ b/src/drivers/driver_madwifi.c
+@@ -438,9 +438,11 @@ madwifi_set_key(const char *ifname, void
+ wpa_printf(MSG_DEBUG, "%s: alg=%d addr=%s key_idx=%d",
+ __func__, alg, ether_sprintf(addr), key_idx);
+
+- if (alg == WPA_ALG_WEP)
++ if (alg == WPA_ALG_WEP) {
+ cipher = IEEE80211_CIPHER_WEP;
+- else if (alg == WPA_ALG_TKIP)
++ if (!addr || !memcmp(addr, "\xff\xff\xff\xff\xff\xff", ETH_ALEN))
++ 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)
+ cipher = IEEE80211_CIPHER_AES_CCM;
+@@ -464,15 +466,30 @@ madwifi_set_key(const char *ifname, void
+ memset(wk.ik_macaddr, 0xff, IEEE80211_ADDR_LEN);
+ wk.ik_keyix = key_idx;
+ wk.ik_flags |= IEEE80211_KEY_DEFAULT;
++ wk.ik_flags |= IEEE80211_KEY_GROUP;
+ } else if (!memcmp(addr, "\xff\xff\xff\xff\xff\xff", ETH_ALEN)) {
++ wk.ik_keyix = key_idx;
+ wk.ik_flags |= IEEE80211_KEY_GROUP;
+- memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
++ memset(wk.ik_macaddr, 0, IEEE80211_ADDR_LEN);
+ } else {
+ memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
+ wk.ik_keyix = IEEE80211_KEYIX_NONE;
+ }
+ 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/hostapd/config_file.c
-+++ b/hostapd/config_file.c
-@@ -1281,6 +1281,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
-@@ -1704,6 +1704,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
-@@ -4661,6 +4661,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 */
-
-
-@@ -5840,6 +5863,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
-@@ -281,6 +281,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)
- {
-@@ -330,6 +338,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
-@@ -1380,7 +1380,6 @@ nla_put_failure:
- }
-
-
--#ifndef HOSTAPD
- struct wiphy_info_data {
- int max_scan_ssids;
- int ap_supported;
-@@ -1493,7 +1492,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)
-@@ -1667,6 +1665,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);
-@@ -1823,32 +1822,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 "
-@@ -2511,13 +2510,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)
-@@ -3368,7 +3363,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();
-@@ -3441,7 +3437,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 &&
-@@ -5177,6 +5174,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
-@@ -550,6 +550,9 @@ void wpa_supplicant_set_state(struct wpa
- wpa_s->new_connection = 0;
- wpa_s->reassociated_connection = 1;
- wpa_drv_set_operstate(wpa_s, 1);
-+#ifndef IEEE8021X_EAPOL
-+ wpa_drv_set_supp_port(wpa_s, 1);
-+#endif
- wpa_s->after_wps = 0;
- #ifdef CONFIG_P2P
- wpas_p2p_completed(wpa_s);
-@@ -558,6 +561,9 @@ void wpa_supplicant_set_state(struct wpa
- 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
-@@ -452,6 +452,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,
-@@ -523,6 +527,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) {
-@@ -1490,6 +1498,11 @@ static int wpa_driver_nl80211_capa(struc
- drv->capa.flags |= WPA_DRIVER_FLAGS_P2P_CAPABLE;
- drv->capa.max_remain_on_chan = 5000;
-
-+#ifdef HOSTAPD
-+ drv->num_if_indices = sizeof(drv->default_if_indices) / sizeof(int);
-+ drv->if_indices = drv->default_if_indices;
-+#endif
-+
- return 0;
- }
-
-@@ -5184,8 +5197,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
-@@ -43,37 +43,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");
-@@ -111,10 +82,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/drivers/driver_madwifi.c
-+++ b/src/drivers/driver_madwifi.c
-@@ -438,9 +438,11 @@ madwifi_set_key(const char *ifname, void
- wpa_printf(MSG_DEBUG, "%s: alg=%d addr=%s key_idx=%d",
- __func__, alg, ether_sprintf(addr), key_idx);
-
-- if (alg == WPA_ALG_WEP)
-+ if (alg == WPA_ALG_WEP) {
- cipher = IEEE80211_CIPHER_WEP;
-- else if (alg == WPA_ALG_TKIP)
-+ if (!addr || !memcmp(addr, "\xff\xff\xff\xff\xff\xff", ETH_ALEN))
-+ 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)
- cipher = IEEE80211_CIPHER_AES_CCM;
-@@ -464,15 +466,30 @@ madwifi_set_key(const char *ifname, void
- memset(wk.ik_macaddr, 0xff, IEEE80211_ADDR_LEN);
- wk.ik_keyix = key_idx;
- wk.ik_flags |= IEEE80211_KEY_DEFAULT;
-+ wk.ik_flags |= IEEE80211_KEY_GROUP;
- } else if (!memcmp(addr, "\xff\xff\xff\xff\xff\xff", ETH_ALEN)) {
-+ wk.ik_keyix = key_idx;
- wk.ik_flags |= IEEE80211_KEY_GROUP;
-- memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
-+ memset(wk.ik_macaddr, 0, IEEE80211_ADDR_LEN);
- } else {
- memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
- wk.ik_keyix = IEEE80211_KEYIX_NONE;
- }
- 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) {
/* hostapd.c */
--- a/src/ap/hostapd.c
+++ b/src/ap/hostapd.c
-@@ -784,6 +784,9 @@ int hostapd_setup_interface_complete(str
+@@ -787,6 +787,9 @@ int hostapd_setup_interface_complete(str
wpa_printf(MSG_DEBUG, "%s: Setup of interface done.",
iface->bss[0]->conf->iface);
os_program_deinit();
--- a/hostapd/config_file.c
+++ b/hostapd/config_file.c
-@@ -1882,6 +1882,8 @@ struct hostapd_config * hostapd_config_r
+@@ -1890,6 +1890,8 @@ struct hostapd_config * hostapd_config_r
}
#endif /* CONFIG_IEEE80211W */
#ifdef CONFIG_IEEE80211N
wpa_cli.exe: wpa_cli
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
-@@ -2667,8 +2667,8 @@ union wpa_event_data {
+@@ -2684,8 +2684,8 @@ union wpa_event_data {
* Driver wrapper code should call this function whenever an event is received
* from the driver.
*/
u16 reason_code = 0;
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
-@@ -2314,6 +2314,9 @@ struct wpa_supplicant * wpa_supplicant_g
+@@ -2320,6 +2320,9 @@ struct wpa_supplicant * wpa_supplicant_g
return NULL;
}
/**
* wpa_supplicant_init - Initialize %wpa_supplicant
-@@ -2332,6 +2335,7 @@ struct wpa_global * wpa_supplicant_init(
+@@ -2338,6 +2341,7 @@ struct wpa_global * wpa_supplicant_init(
if (params == NULL)
return NULL;
endif
ifdef CONFIG_DRIVER_HERMES
-@@ -183,6 +181,7 @@ endif
+@@ -170,7 +168,6 @@ endif
+ ifdef CONFIG_WIRELESS_EXTENSION
+ DRV_WPA_CFLAGS += -DCONFIG_WIRELESS_EXTENSION
+ DRV_WPA_OBJS += ../src/drivers/driver_wext.o
+-NEED_RFKILL=y
+ endif
+
+ ifdef NEED_NETLINK
+@@ -183,6 +180,7 @@ endif
ifdef NEED_RFKILL
DRV_OBJS += ../src/drivers/rfkill.o
--- a/src/ap/hostapd.c
+++ b/src/ap/hostapd.c
-@@ -113,6 +113,10 @@ int hostapd_reload_config(struct hostapd
+@@ -115,6 +115,10 @@ int hostapd_reload_config(struct hostapd
oldconf = hapd->iconf;
iface->conf = newconf;
/**
* wpa_driver_nl80211_deinit - Deinitialize nl80211 driver interface
-@@ -5905,4 +5923,5 @@ const struct wpa_driver_ops wpa_driver_n
+@@ -5882,4 +5900,5 @@ const struct wpa_driver_ops wpa_driver_n
.signal_monitor = nl80211_signal_monitor,
.send_frame = nl80211_send_frame,
.set_intra_bss = nl80211_set_intra_bss,
};
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
-@@ -1915,6 +1915,8 @@ struct wpa_driver_ops {
+@@ -1909,6 +1909,8 @@ struct wpa_driver_ops {
* set_intra_bss - Enables/Disables intra BSS bridging
*/
int (*set_intra_bss)(void *priv, int enabled);
static void hostapd_ctrl_iface_send(struct hostapd_data *hapd, int level,
const char *buf, size_t len);
-@@ -318,6 +320,66 @@ static int hostapd_ctrl_iface_disassocia
+@@ -322,6 +324,66 @@ static int hostapd_ctrl_iface_disassocia
return 0;
}
#ifdef CONFIG_IEEE80211W
#ifdef NEED_AP_MLME
-@@ -814,6 +876,10 @@ static void hostapd_ctrl_iface_receive(i
+@@ -818,6 +880,10 @@ static void hostapd_ctrl_iface_receive(i
reply_len += res;
}
#endif /* CONFIG_NO_RADIUS */
wpa_s->new_connection = 1;
wpa_drv_set_operstate(wpa_s, 0);
#ifndef IEEE8021X_EAPOL
-@@ -2027,6 +2084,21 @@ static int wpa_supplicant_init_iface(str
+@@ -2033,6 +2090,21 @@ static int wpa_supplicant_init_iface(str
os_strlcpy(wpa_s->bridge_ifname, iface->bridge_ifname,
sizeof(wpa_s->bridge_ifname));
}