#
-# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2006-2011 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
include $(TOPDIR)/rules.mk
PKG_NAME:=hostapd
-PKG_VERSION:=20110527
+PKG_VERSION:=20111103
PKG_RELEASE:=1
-PKG_REV:=ceb34f250af7a7082f18c1e0451dc7fbc0f000f3
+PKG_REV:=6caaae1e48da247b21b54ea6001646597e35d9b1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=git://w1.fi/srv/git/hostap.git
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_VERSION:=$(PKG_REV)
PKG_SOURCE_PROTO:=git
-PKG_MIRROR_MD5SUM:=4b98902d782813b41aca1faff613f677
+PKG_MIRROR_MD5SUM:=2650d83c1d4649a5df9fe265f8a5775f
PKG_BUILD_DEPENDS:= \
PACKAGE_kmod-madwifi:madwifi \
hostapd_set_bss_options() {
local var="$1"
local vif="$2"
- local enc wpa_group_rekey wps_possible
+ local enc wep_rekey wpa_group_rekey wpa_pair_rekey wpa_master_rekey wps_possible
config_get enc "$vif" encryption
- config_get wpa_group_rekey "$vif" wpa_group_rekey
+ config_get wep_rekey "$vif" wep_rekey # 300
+ config_get wpa_group_rekey "$vif" wpa_group_rekey # 300
+ config_get wpa_pair_rekey "$vif" wpa_pair_rekey # 300
+ config_get wpa_master_rekey "$vif" wpa_master_rekey # 640
config_get_bool ap_isolate "$vif" isolate 0
config_get device "$vif" device
append "$var" "wpa_passphrase=$psk" "$N"
fi
wps_possible=1
+ [ -n "$wpa_group_rekey" ] && append "$var" "wpa_group_rekey=$wpa_group_rekey" "$N"
+ [ -n "$wpa_pair_rekey" ] && append "$var" "wpa_ptk_rekey=$wpa_pair_rekey" "$N"
+ [ -n "$wpa_master_rekey" ] && append "$var" "wpa_gmk_rekey=$wpa_master_rekey" "$N"
;;
*wpa*)
# required fields? formats?
config_get nasid "$vif" nasid
append "$var" "nas_identifier=$nasid" "$N"
append "$var" "eapol_key_index_workaround=1" "$N"
- append "$var" "radius_acct_interim_interval=300" "$N"
append "$var" "ieee8021x=1" "$N"
append "$var" "wpa_key_mgmt=WPA-EAP" "$N"
- append "$var" "wpa_group_rekey=300" "$N"
- append "$var" "wpa_gmk_rekey=640" "$N"
+ [ -n "$wpa_group_rekey" ] && append "$var" "wpa_group_rekey=$wpa_group_rekey" "$N"
+ [ -n "$wpa_pair_rekey" ] && append "$var" "wpa_ptk_rekey=$wpa_pair_rekey" "$N"
+ [ -n "$wpa_master_rekey" ] && append "$var" "wpa_gmk_rekey=$wpa_master_rekey" "$N"
;;
*wep*)
config_get key "$vif" key
*)
append "$var" "wep_key0=$(prepare_key_wep "$key")" "$N"
append "$var" "wep_default_key=0" "$N"
+ [ -n "$wep_rekey" ] && append "$var" "wep_rekey_period=$wep_rekey" "$N"
;;
esac
case "$enc" in
--- /dev/null
+--- a/src/ap/ieee802_11.c
++++ b/src/ap/ieee802_11.c
+@@ -1471,13 +1471,6 @@ static void handle_assoc_cb(struct hosta
+ int new_assoc = 1;
+ struct ieee80211_ht_capabilities ht_cap;
+
+- if (!ok) {
+- hostapd_logger(hapd, mgmt->da, HOSTAPD_MODULE_IEEE80211,
+- HOSTAPD_LEVEL_DEBUG,
+- "did not acknowledge association response");
+- return;
+- }
+-
+ if (len < IEEE80211_HDRLEN + (reassoc ? sizeof(mgmt->u.reassoc_resp) :
+ sizeof(mgmt->u.assoc_resp))) {
+ printf("handle_assoc_cb(reassoc=%d) - too short payload "
+@@ -1485,11 +1478,6 @@ static void handle_assoc_cb(struct hosta
+ return;
+ }
+
+- if (reassoc)
+- status = le_to_host16(mgmt->u.reassoc_resp.status_code);
+- else
+- status = le_to_host16(mgmt->u.assoc_resp.status_code);
+-
+ sta = ap_get_sta(hapd, mgmt->da);
+ if (!sta) {
+ printf("handle_assoc_cb: STA " MACSTR " not found\n",
+@@ -1497,6 +1485,19 @@ static void handle_assoc_cb(struct hosta
+ return;
+ }
+
++ if (!ok) {
++ hostapd_logger(hapd, mgmt->da, HOSTAPD_MODULE_IEEE80211,
++ HOSTAPD_LEVEL_DEBUG,
++ "did not acknowledge association response");
++ sta->flags &= ~WLAN_STA_ASSOC_REQ_OK;
++ return;
++ }
++
++ if (reassoc)
++ status = le_to_host16(mgmt->u.reassoc_resp.status_code);
++ else
++ status = le_to_host16(mgmt->u.assoc_resp.status_code);
++
+ if (status != WLAN_STATUS_SUCCESS)
+ goto fail;
+
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -181,6 +181,7 @@ struct i802_bss {
+ struct wpa_driver_nl80211_data *drv;
+ struct i802_bss *next;
+ int ifindex;
++ u8 addr[ETH_ALEN];
+ char ifname[IFNAMSIZ + 1];
+ char brname[IFNAMSIZ];
+ unsigned int beacon_set:1;
+@@ -191,7 +192,6 @@ struct i802_bss {
+ struct wpa_driver_nl80211_data {
+ struct nl80211_global *global;
+ struct dl_list list;
+- u8 addr[ETH_ALEN];
+ char phyname[32];
+ void *ctx;
+ int ifindex;
+@@ -2482,7 +2482,7 @@ wpa_driver_nl80211_finish_drv_init(struc
+ return -1;
+
+ if (linux_get_ifhwaddr(drv->global->ioctl_sock, bss->ifname,
+- drv->addr))
++ bss->addr))
+ return -1;
+
+ if (nl80211_register_action_frames(drv) < 0) {
+@@ -5176,8 +5176,8 @@ static int wpa_driver_nl80211_hapd_send_
+ pos = (u8 *) (hdr + 1);
+
+ if (qos) {
+- /* add an empty QoS header if needed */
+- pos[0] = 0;
++ /* Set highest priority in QoS header */
++ pos[0] = 7;
+ pos[1] = 0;
+ pos += 2;
+ }
+@@ -6407,7 +6407,7 @@ static int i802_set_wds_sta(void *priv,
+ if (!if_nametoindex(name)) {
+ if (nl80211_create_iface(drv, name,
+ NL80211_IFTYPE_AP_VLAN,
+- NULL, 1) < 0)
++ bss->addr, 1) < 0)
+ return -1;
+ if (bridge_ifname &&
+ linux_br_add_if(drv->global->ioctl_sock,
+@@ -6417,6 +6417,10 @@ static int i802_set_wds_sta(void *priv,
+ linux_set_iface_flags(drv->global->ioctl_sock, name, 1);
+ return i802_set_sta_vlan(priv, addr, name, 0);
+ } else {
++ if (bridge_ifname)
++ linux_br_del_if(drv->global->ioctl_sock, bridge_ifname,
++ name);
++
+ i802_set_sta_vlan(priv, addr, bss->ifname, 0);
+ return wpa_driver_nl80211_if_remove(priv, WPA_IF_AP_VLAN,
+ name);
+@@ -6625,7 +6629,7 @@ static int nl80211_addr_in_use(struct nl
+ struct wpa_driver_nl80211_data *drv;
+ dl_list_for_each(drv, &global->interfaces,
+ struct wpa_driver_nl80211_data, list) {
+- if (os_memcmp(addr, drv->addr, ETH_ALEN) == 0)
++ if (os_memcmp(addr, drv->first_bss.addr, ETH_ALEN) == 0)
+ return 1;
+ }
+ return 0;
+@@ -6640,9 +6644,9 @@ static int nl80211_p2p_interface_addr(st
+ if (!drv->global)
+ return -1;
+
+- os_memcpy(new_addr, drv->addr, ETH_ALEN);
++ os_memcpy(new_addr, drv->first_bss.addr, ETH_ALEN);
+ for (idx = 0; idx < 64; idx++) {
+- new_addr[0] = drv->addr[0] | 0x02;
++ new_addr[0] = drv->first_bss.addr[0] | 0x02;
+ new_addr[0] ^= idx << 2;
+ if (!nl80211_addr_in_use(drv->global, new_addr))
+ break;
+@@ -6745,6 +6749,7 @@ static int wpa_driver_nl80211_if_add(voi
+ os_free(new_bss);
+ return -1;
+ }
++ memcpy(new_bss->addr, addr ? addr : if_addr, ETH_ALEN);
+ os_strlcpy(new_bss->ifname, ifname, IFNAMSIZ);
+ new_bss->ifindex = ifidx;
+ new_bss->drv = drv;
+@@ -6775,7 +6780,12 @@ static int wpa_driver_nl80211_if_remove(
+ if (ifindex <= 0)
+ return -1;
+
++ nl80211_remove_iface(drv, ifindex);
++
+ #ifdef HOSTAPD
++ if (type != WPA_IF_AP_BSS)
++ return 0;
++
+ if (bss->added_if_into_bridge) {
+ if (linux_br_del_if(drv->global->ioctl_sock, bss->brname,
+ bss->ifname) < 0)
+@@ -6789,13 +6799,6 @@ static int wpa_driver_nl80211_if_remove(
+ "bridge %s: %s",
+ bss->brname, strerror(errno));
+ }
+-#endif /* HOSTAPD */
+-
+- nl80211_remove_iface(drv, ifindex);
+-
+-#ifdef HOSTAPD
+- if (type != WPA_IF_AP_BSS)
+- return 0;
+
+ if (bss != &drv->first_bss) {
+ struct i802_bss *tbss;
--- a/wpa_supplicant/scan.c
+++ b/wpa_supplicant/scan.c
-@@ -251,6 +251,7 @@ static void wpa_supplicant_scan(void *el
- enum wps_request_type req_type = WPS_REQ_ENROLLEE_INFO;
- #endif /* CONFIG_WPS */
+@@ -423,6 +423,7 @@ static void wpa_supplicant_scan(void *el
+ int scan_req = 0, ret;
+ struct wpabuf *extra_ie;
struct wpa_driver_scan_params params;
+ int scan_ssid_all = 1;
size_t max_ssids;
enum wpa_states prev_state;
-@@ -307,6 +308,16 @@ static void wpa_supplicant_scan(void *el
- wpa_s->wpa_state == WPA_INACTIVE)
- wpa_supplicant_set_state(wpa_s, WPA_SCANNING);
+@@ -502,6 +503,16 @@ static void wpa_supplicant_scan(void *el
+ }
+ }
+ /* check if all configured ssids should be scanned directly */
+ ssid = wpa_s->conf->ssid;
/* Find the starting point from which to continue scanning */
ssid = wpa_s->conf->ssid;
if (wpa_s->prev_scan_ssid != WILDCARD_SSID_SCAN) {
-@@ -370,6 +381,9 @@ static void wpa_supplicant_scan(void *el
+@@ -564,6 +575,9 @@ static void wpa_supplicant_scan(void *el
int_array_sort_unique(params.freqs);
}
f = fopen(buf, "r");
if (!f) {
-@@ -757,7 +758,7 @@ static int madwifi_receive_probe_req(str
+@@ -759,7 +760,7 @@ static int madwifi_receive_probe_req(str
if (ret)
return ret;
madwifi_raw_receive, drv, 1);
if (drv->sock_raw == NULL)
return -1;
-@@ -1017,7 +1018,7 @@ madwifi_get_we_version(struct madwifi_dr
+@@ -812,7 +813,7 @@ static int madwifi_set_freq(void *priv,
+ struct iwreq iwr;
+
+ os_memset(&iwr, 0, sizeof(iwr));
+- os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
++ os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
+ iwr.u.freq.m = freq->channel;
+ iwr.u.freq.e = 0;
+
+@@ -1037,7 +1038,7 @@ madwifi_get_we_version(struct madwifi_dr
return -1;
memset(&iwr, 0, sizeof(iwr));
iwr.u.data.pointer = (caddr_t) range;
iwr.u.data.length = buflen;
-@@ -1134,17 +1135,17 @@ madwifi_init(struct hostapd_data *hapd,
+@@ -1154,17 +1155,17 @@ madwifi_init(struct hostapd_data *hapd,
perror("socket[PF_INET,SOCK_DGRAM]");
goto bad;
}
handle_read, drv, 1);
if (drv->sock_xmit == NULL)
goto bad;
-@@ -1158,7 +1159,7 @@ madwifi_init(struct hostapd_data *hapd,
+@@ -1178,7 +1179,7 @@ madwifi_init(struct hostapd_data *hapd,
1);
if (drv->sock_recv == NULL)
goto bad;
wpa_printf(MSG_DEBUG, "Interface in bridge %s; configure for "
"EAPOL receive", brname);
drv->sock_recv = l2_packet_init(brname, NULL, ETH_P_EAPOL,
-@@ -1169,7 +1170,7 @@ madwifi_init(struct hostapd_data *hapd,
+@@ -1189,7 +1190,7 @@ madwifi_init(struct hostapd_data *hapd,
drv->sock_recv = drv->sock_xmit;
memset(&iwr, 0, sizeof(iwr));
iwr.u.mode = IW_MODE_MASTER;
-@@ -1180,7 +1181,7 @@ madwifi_init(struct hostapd_data *hapd,
+@@ -1200,7 +1201,7 @@ madwifi_init(struct hostapd_data *hapd,
}
/* mark down during setup */
madwifi_set_privacy(drv, 0); /* default to no privacy */
madwifi_receive_probe_req(drv);
-@@ -1206,7 +1207,7 @@ madwifi_deinit(void *priv)
+@@ -1226,7 +1227,7 @@ madwifi_deinit(void *priv)
struct madwifi_driver_data *drv = priv;
netlink_deinit(drv->netlink);
if (drv->ioctl_sock >= 0)
close(drv->ioctl_sock);
if (drv->sock_recv != NULL && drv->sock_recv != drv->sock_xmit)
-@@ -1225,7 +1226,7 @@ madwifi_set_ssid(void *priv, const u8 *b
+@@ -1245,7 +1246,7 @@ madwifi_set_ssid(void *priv, const u8 *b
struct iwreq iwr;
memset(&iwr, 0, sizeof(iwr));
iwr.u.essid.flags = 1; /* SSID active */
iwr.u.essid.pointer = (caddr_t) buf;
iwr.u.essid.length = len + 1;
-@@ -1246,7 +1247,7 @@ madwifi_get_ssid(void *priv, u8 *buf, in
+@@ -1266,7 +1267,7 @@ madwifi_get_ssid(void *priv, u8 *buf, in
int ret = 0;
memset(&iwr, 0, sizeof(iwr));
iwr.u.essid.pointer = (caddr_t) buf;
iwr.u.essid.length = len;
-@@ -1271,140 +1272,19 @@ static int
+@@ -1291,140 +1292,19 @@ static int
madwifi_commit(void *priv)
{
struct madwifi_driver_data *drv = priv;
- return 0;
-}
-
--static int
+ static int
-set80211param(struct wpa_driver_madwifi_data *drv, int op, int arg,
- int show_err)
-{
- return 0;
-}
-
- static int
+-static int
-wpa_driver_madwifi_set_wpa_ie(struct wpa_driver_madwifi_data *drv,
+wpa_driver_madwifi_set_wpa_ie(struct madwifi_driver_data *drv,
const u8 *wpa_ie, size_t wpa_ie_len)
{
struct iwreq iwr;
-@@ -1415,7 +1295,7 @@ wpa_driver_madwifi_set_wpa_ie(struct wpa
+@@ -1435,7 +1315,7 @@ wpa_driver_madwifi_set_wpa_ie(struct wpa
iwr.u.data.pointer = (void *) wpa_ie;
iwr.u.data.length = wpa_ie_len;
perror("ioctl[IEEE80211_IOCTL_SETOPTIE]");
return -1;
}
-@@ -1423,157 +1303,51 @@ wpa_driver_madwifi_set_wpa_ie(struct wpa
+@@ -1443,157 +1323,51 @@ wpa_driver_madwifi_set_wpa_ie(struct wpa
}
static int
ret = -1;
if (wpa_driver_madwifi_set_auth_alg(drv, params->auth_alg) < 0)
ret = -1;
-@@ -1596,12 +1370,12 @@ wpa_driver_madwifi_associate(void *priv,
+@@ -1616,12 +1390,12 @@ wpa_driver_madwifi_associate(void *priv,
params->wpa_ie_len == 0)
privacy = 0;
ret = -1;
if (params->bssid == NULL) {
-@@ -1609,14 +1383,14 @@ wpa_driver_madwifi_associate(void *priv,
+@@ -1629,14 +1403,14 @@ wpa_driver_madwifi_associate(void *priv,
* roaming */
/* FIX: this does not seem to work; would probably need to
* change something in the driver */
ret = -1;
if (wpa_driver_wext_set_ssid(drv->wext, params->ssid,
params->ssid_len) < 0)
-@@ -1625,7 +1399,7 @@ wpa_driver_madwifi_associate(void *priv,
+@@ -1645,7 +1419,7 @@ wpa_driver_madwifi_associate(void *priv,
mlme.im_op = IEEE80211_MLME_ASSOC;
os_memcpy(mlme.im_macaddr, params->bssid, IEEE80211_ADDR_LEN);
if (set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme,
wpa_printf(MSG_DEBUG, "%s: SETMLME[ASSOC] failed",
__func__);
ret = -1;
-@@ -1638,7 +1412,7 @@ wpa_driver_madwifi_associate(void *priv,
+@@ -1658,7 +1432,7 @@ wpa_driver_madwifi_associate(void *priv,
static int
wpa_driver_madwifi_set_auth_alg(void *priv, int auth_alg)
{
int authmode;
if ((auth_alg & WPA_AUTH_ALG_OPEN) &&
-@@ -1649,13 +1423,13 @@ wpa_driver_madwifi_set_auth_alg(void *pr
+@@ -1669,13 +1443,13 @@ wpa_driver_madwifi_set_auth_alg(void *pr
else
authmode = IEEE80211_AUTH_OPEN;
struct iwreq iwr;
int ret = 0;
const u8 *ssid = params->ssids[0].ssid;
-@@ -1673,7 +1447,7 @@ wpa_driver_madwifi_scan(void *priv, stru
+@@ -1693,7 +1467,7 @@ wpa_driver_madwifi_scan(void *priv, stru
if (wpa_driver_wext_set_ssid(drv->wext, ssid, ssid_len) < 0)
ret = -1;
perror("ioctl[SIOCSIWSCAN]");
ret = -1;
}
-@@ -1695,14 +1469,14 @@ wpa_driver_madwifi_scan(void *priv, stru
+@@ -1715,14 +1489,14 @@ wpa_driver_madwifi_scan(void *priv, stru
static int wpa_driver_madwifi_get_bssid(void *priv, u8 *bssid)
{
return wpa_driver_wext_get_ssid(drv->wext, ssid);
}
-@@ -1710,14 +1484,16 @@ static int wpa_driver_madwifi_get_ssid(v
+@@ -1730,14 +1504,16 @@ static int wpa_driver_madwifi_get_ssid(v
static struct wpa_scan_results *
wpa_driver_madwifi_get_scan_results(void *priv)
{
return wpa_driver_wext_set_operstate(drv->wext, state);
}
-@@ -1738,7 +1514,7 @@ static int wpa_driver_madwifi_set_probe_
+@@ -1758,7 +1534,7 @@ static int wpa_driver_madwifi_set_probe_
ret = set80211priv(priv, IEEE80211_IOCTL_SET_APPIEBUF, probe_req_ie,
sizeof(struct ieee80211req_getset_appiebuf) +
os_free(probe_req_ie);
-@@ -1748,7 +1524,7 @@ static int wpa_driver_madwifi_set_probe_
+@@ -1768,7 +1544,7 @@ static int wpa_driver_madwifi_set_probe_
static void * wpa_driver_madwifi_init(void *ctx, const char *ifname)
{
drv = os_zalloc(sizeof(*drv));
if (drv == NULL)
-@@ -1759,17 +1535,17 @@ static void * wpa_driver_madwifi_init(vo
+@@ -1779,17 +1555,17 @@ static void * wpa_driver_madwifi_init(vo
drv->ctx = ctx;
os_strlcpy(drv->ifname, ifname, sizeof(drv->ifname));
wpa_printf(MSG_DEBUG, "%s: failed to enable WPA support",
__FUNCTION__);
goto fail3;
-@@ -1778,7 +1554,7 @@ static void * wpa_driver_madwifi_init(vo
+@@ -1798,7 +1574,7 @@ static void * wpa_driver_madwifi_init(vo
return drv;
fail3:
fail2:
wpa_driver_wext_deinit(drv->wext);
fail:
-@@ -1789,38 +1565,37 @@ fail:
+@@ -1809,38 +1585,37 @@ fail:
static void wpa_driver_madwifi_deinit(void *priv)
{
#ifdef HOSTAPD
.hapd_init = madwifi_init,
.hapd_deinit = madwifi_deinit,
-@@ -1840,7 +1615,8 @@ const struct wpa_driver_ops wpa_driver_m
- .sta_clear_stats = madwifi_sta_clear_stats,
+@@ -1861,7 +1636,8 @@ const struct wpa_driver_ops wpa_driver_m
.commit = madwifi_commit,
.set_ap_wps_ie = madwifi_set_ap_wps_ie,
+ .set_freq = madwifi_set_freq,
-#else /* HOSTAPD */
+#endif /* HOSTAPD */
+#if !defined(NO_SUPPLICANT)
.get_bssid = wpa_driver_madwifi_get_bssid,
.get_ssid = wpa_driver_madwifi_get_ssid,
.init = wpa_driver_madwifi_init,
-@@ -1852,5 +1628,5 @@ const struct wpa_driver_ops wpa_driver_m
+@@ -1873,5 +1649,5 @@ const struct wpa_driver_ops wpa_driver_m
.disassociate = wpa_driver_madwifi_disassociate,
.associate = wpa_driver_madwifi_associate,
.set_operstate = wpa_driver_madwifi_set_operstate,
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
-@@ -1890,6 +1890,7 @@ static void * wpa_driver_nl80211_init(vo
+@@ -2289,6 +2289,7 @@ static void * wpa_driver_nl80211_init(vo
drv->monitor_ifidx = -1;
drv->monitor_sock = -1;
- drv->ioctl_sock = -1;
+ drv->ap_scan_as_station = NL80211_IFTYPE_UNSPECIFIED;
+ drv->nlmode = NL80211_IFTYPE_STATION;
if (wpa_driver_nl80211_init_nl(drv)) {
os_free(drv);
-@@ -2056,29 +2057,29 @@ wpa_driver_nl80211_finish_drv_init(struc
+@@ -2446,37 +2447,37 @@ 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 "
+- /*
+- * Make sure the interface starts up in station mode unless this is a
+- * dynamically added interface (e.g., P2P) that was already configured
+- * with proper iftype.
+- */
+- if ((drv->global == NULL ||
+- drv->ifindex != drv->global->if_add_ifindex) &&
+- wpa_driver_nl80211_set_mode(bss, NL80211_IFTYPE_STATION) < 0) {
+- wpa_printf(MSG_ERROR, "nl80211: Could not configure driver to "
- "use managed mode");
+- return -1;
- }
-+ if (drv->nlmode == NL80211_IFTYPE_STATION) {
-+ if (wpa_driver_nl80211_set_mode(bss, IEEE80211_MODE_INFRA) < 0) {
-+ wpa_printf(MSG_DEBUG, "nl80211: Could not configure driver to "
-+ "use managed mode");
-+ }
-
-- if (linux_set_iface_flags(drv->ioctl_sock, bss->ifname, 1)) {
+-
+- if (linux_set_iface_flags(drv->global->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",
- } 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 (drv->nlmode == NL80211_IFTYPE_STATION) {
++ /*
++ * Make sure the interface starts up in station mode unless this is a
++ * dynamically added interface (e.g., P2P) that was already configured
++ * with proper iftype.
++ */
++ if ((drv->global == NULL ||
++ drv->ifindex != drv->global->if_add_ifindex) &&
++ wpa_driver_nl80211_set_mode(bss, NL80211_IFTYPE_STATION) < 0) {
++ wpa_printf(MSG_ERROR, "nl80211: Could not configure driver to "
++ "use managed mode");
+ return -1;
+ }
+- }
+
+- netlink_send_oper_ifla(drv->global->netlink, drv->ifindex,
+- 1, IF_OPER_DORMANT);
+-#endif /* HOSTAPD */
++ if (linux_set_iface_flags(drv->global->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",
+ "interface '%s' UP", bss->ifname);
+ 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);
++ }
++
++ netlink_send_oper_ifla(drv->global->netlink, drv->ifindex,
++ 1, IF_OPER_DORMANT);
+ }
if (wpa_driver_nl80211_capa(drv))
return -1;
-@@ -3849,7 +3850,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();
-@@ -3922,7 +3924,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 &&
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
-@@ -475,6 +475,10 @@ static void wpa_driver_nl80211_event_rtm
+@@ -600,6 +600,10 @@ static void wpa_driver_nl80211_event_rtm
return;
}
wpa_printf(MSG_DEBUG, "RTM_NEWLINK: operstate=%d ifi_flags=0x%x "
"(%s%s%s%s)",
drv->operstate, ifi->ifi_flags,
-@@ -546,6 +550,10 @@ static void wpa_driver_nl80211_event_rtm
+@@ -692,6 +696,10 @@ static void wpa_driver_nl80211_event_rtm
attrlen = len;
attr = (struct rtattr *) buf;
rta_len = RTA_ALIGN(sizeof(struct rtattr));
while (RTA_OK(attr, attrlen)) {
if (attr->rta_type == IFLA_IFNAME) {
-@@ -1679,6 +1687,11 @@ static int wpa_driver_nl80211_capa(struc
- drv->capa.flags |= WPA_DRIVER_FLAGS_EAPOL_TX_STATUS;
- drv->capa.max_remain_on_chan = info.max_remain_on_chan;
+@@ -2291,6 +2299,11 @@ static void * wpa_driver_nl80211_init(vo
+ drv->ap_scan_as_station = NL80211_IFTYPE_UNSPECIFIED;
+ drv->nlmode = NL80211_IFTYPE_STATION;
+#ifdef HOSTAPD
+ drv->num_if_indices = sizeof(drv->default_if_indices) / sizeof(int);
+ drv->if_indices = drv->default_if_indices;
+#endif
+
- return 0;
- }
-
-@@ -5715,8 +5728,6 @@ static void *i802_init(struct hostapd_da
+ if (wpa_driver_nl80211_init_nl(drv)) {
+ os_free(drv);
+ return NULL;
+@@ -6531,8 +6544,6 @@ static void *i802_init(struct hostapd_da
br_ifindex = 0;
}
#include <net/if_arp.h>
#include <netpacket/packet.h>
-@@ -42,10 +39,16 @@
+@@ -43,10 +40,16 @@
static const u8 rfc1042_header[6] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
struct hostap_driver_data {
int ioctl_sock; /* socket for ioctl() use */
struct netlink_data *netlink;
-@@ -55,9 +58,11 @@ struct hostap_driver_data {
+@@ -56,9 +59,11 @@ struct hostap_driver_data {
size_t generic_ie_len;
u8 *wps_ie;
size_t wps_ie_len;
static int hostapd_ioctl(void *priv, struct prism2_hostapd_param *param,
int len);
static int hostap_set_iface_flags(void *priv, int dev_up);
-@@ -400,65 +405,6 @@ static int hostapd_ioctl(void *priv, str
+@@ -399,65 +404,6 @@ static int hostapd_ioctl(void *priv, str
}
static int hostap_get_seqnum(const char *ifname, void *priv, const u8 *addr,
int idx, u8 *seq)
{
-@@ -1126,21 +1072,9 @@ static struct hostapd_hw_modes * hostap_
- return mode;
+@@ -1171,21 +1117,9 @@ static void wpa_driver_hostap_poll_clien
+ hostap_send_mlme(priv, (u8 *)&hdr, sizeof(hdr));
}
-#else /* HOSTAPD */
struct prism2_hostapd_param *param,
int len, int show_err)
{
-@@ -1162,7 +1096,12 @@ static int hostapd_ioctl(struct wpa_driv
+@@ -1207,7 +1141,12 @@ static int hostapd_ioctl(struct wpa_driv
}
const u8 *wpa_ie, size_t wpa_ie_len)
{
struct prism2_hostapd_param *param;
-@@ -1178,7 +1117,7 @@ static int wpa_driver_hostap_set_wpa_ie(
+@@ -1223,7 +1162,7 @@ static int wpa_driver_hostap_set_wpa_ie(
param->cmd = PRISM2_HOSTAPD_SET_GENERIC_ELEMENT;
param->u.generic_elem.len = wpa_ie_len;
os_memcpy(param->u.generic_elem.data, wpa_ie, wpa_ie_len);
os_free(param);
-@@ -1186,7 +1125,7 @@ static int wpa_driver_hostap_set_wpa_ie(
+@@ -1231,7 +1170,7 @@ static int wpa_driver_hostap_set_wpa_ie(
}
int value)
{
struct iwreq iwr;
-@@ -1208,7 +1147,7 @@ static int prism2param(struct wpa_driver
+@@ -1253,7 +1192,7 @@ static int prism2param(struct wpa_driver
static int wpa_driver_hostap_set_wpa(void *priv, int enabled)
{
int ret = 0;
wpa_printf(MSG_DEBUG, "%s: enabled=%d", __FUNCTION__, enabled);
-@@ -1224,125 +1163,15 @@ static int wpa_driver_hostap_set_wpa(voi
+@@ -1269,125 +1208,15 @@ static int wpa_driver_hostap_set_wpa(voi
}
int type)
{
struct iwreq iwr;
-@@ -1363,7 +1192,7 @@ static int wpa_driver_hostap_reset(struc
+@@ -1408,7 +1237,7 @@ static int wpa_driver_hostap_reset(struc
}
const u8 *addr, int cmd, int reason_code)
{
struct prism2_hostapd_param param;
-@@ -1378,7 +1207,7 @@ static int wpa_driver_hostap_mlme(struct
+@@ -1423,7 +1252,7 @@ static int wpa_driver_hostap_mlme(struct
os_memcpy(param.sta_addr, addr, ETH_ALEN);
param.u.mlme.cmd = cmd;
param.u.mlme.reason_code = reason_code;
if (ret == 0) {
os_sleep(0, 100000);
ret = wpa_driver_hostap_reset(drv, 2);
-@@ -1390,7 +1219,7 @@ static int wpa_driver_hostap_mlme(struct
+@@ -1435,7 +1264,7 @@ static int wpa_driver_hostap_mlme(struct
static int wpa_driver_hostap_deauthenticate(void *priv, const u8 *addr,
int reason_code)
{
wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
return wpa_driver_hostap_mlme(drv, addr, MLME_STA_DEAUTH,
reason_code);
-@@ -1400,7 +1229,7 @@ static int wpa_driver_hostap_deauthentic
+@@ -1445,7 +1274,7 @@ static int wpa_driver_hostap_deauthentic
static int wpa_driver_hostap_disassociate(void *priv, const u8 *addr,
int reason_code)
{
wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
return wpa_driver_hostap_mlme(drv, addr, MLME_STA_DISASSOC,
reason_code);
-@@ -1411,7 +1240,7 @@ static int
+@@ -1456,7 +1285,7 @@ static int
wpa_driver_hostap_associate(void *priv,
struct wpa_driver_associate_params *params)
{
int ret = 0;
int allow_unencrypted_eapol;
-@@ -1475,7 +1304,7 @@ wpa_driver_hostap_associate(void *priv,
+@@ -1520,7 +1349,7 @@ wpa_driver_hostap_associate(void *priv,
static int wpa_driver_hostap_scan(void *priv,
struct wpa_driver_scan_params *params)
{
struct prism2_hostapd_param param;
int ret;
const u8 *ssid = params->ssids[0].ssid;
-@@ -1496,7 +1325,7 @@ static int wpa_driver_hostap_scan(void *
+@@ -1541,7 +1370,7 @@ static int wpa_driver_hostap_scan(void *
param.cmd = PRISM2_HOSTAPD_SCAN_REQ;
param.u.scan_req.ssid_len = ssid_len;
os_memcpy(param.u.scan_req.ssid, ssid, ssid_len);
/* Not all drivers generate "scan completed" wireless event, so try to
* read results after a timeout. */
-@@ -1511,7 +1340,7 @@ static int wpa_driver_hostap_scan(void *
+@@ -1556,7 +1385,7 @@ static int wpa_driver_hostap_scan(void *
static int wpa_driver_hostap_set_auth_alg(void *priv, int auth_alg)
{
int algs = 0;
if (auth_alg & WPA_AUTH_ALG_OPEN)
-@@ -1529,35 +1358,35 @@ static int wpa_driver_hostap_set_auth_al
+@@ -1574,35 +1403,35 @@ static int wpa_driver_hostap_set_auth_al
static int wpa_driver_hostap_get_bssid(void *priv, u8 *bssid)
{
drv = os_zalloc(sizeof(*drv));
if (drv == NULL)
-@@ -1597,14 +1426,120 @@ static void * wpa_driver_hostap_init(voi
+@@ -1642,14 +1471,120 @@ static void * wpa_driver_hostap_init(voi
static void wpa_driver_hostap_deinit(void *priv)
{
const struct wpa_driver_ops wpa_driver_hostap_ops = {
-@@ -1632,7 +1567,8 @@ const struct wpa_driver_ops wpa_driver_h
- .sta_clear_stats = hostap_sta_clear_stats,
- .get_hw_feature_data = hostap_get_hw_feature_data,
+@@ -1679,7 +1614,8 @@ const struct wpa_driver_ops wpa_driver_h
.set_ap_wps_ie = hostap_set_ap_wps_ie,
+ .set_freq = hostap_set_freq,
+ .poll_client = wpa_driver_hostap_poll_client,
-#else /* HOSTAPD */
+#endif /* HOSTAPD */
+#if !defined(NO_SUPPLICANT)
.get_bssid = wpa_driver_hostap_get_bssid,
.get_ssid = wpa_driver_hostap_get_ssid,
.set_countermeasures = wpa_driver_hostap_set_countermeasures,
-@@ -1644,5 +1580,5 @@ const struct wpa_driver_ops wpa_driver_h
+@@ -1691,5 +1627,5 @@ const struct wpa_driver_ops wpa_driver_h
.init = wpa_driver_hostap_init,
.deinit = wpa_driver_hostap_deinit,
.set_operstate = wpa_driver_hostap_set_operstate,
--- /dev/null
+--- a/wpa_supplicant/ctrl_iface.c
++++ b/wpa_supplicant/ctrl_iface.c
+@@ -685,6 +685,7 @@ static int wpa_supplicant_ctrl_iface_ibs
+ #endif /* CONFIG_IBSS_RSN */
+
+
++#ifdef IEEE8021X_EAPOL
+ int wpa_supplicant_ctrl_iface_ctrl_rsp_handle(struct wpa_supplicant *wpa_s,
+ struct wpa_ssid *ssid,
+ const char *field,
+@@ -750,6 +751,7 @@ int wpa_supplicant_ctrl_iface_ctrl_rsp_h
+
+ return 0;
+ }
++#endif
+
+
+ static int wpa_supplicant_ctrl_iface_ctrl_rsp(struct wpa_supplicant *wpa_s,
--- a/src/ap/hostapd.h
+++ b/src/ap/hostapd.h
-@@ -229,6 +229,7 @@ struct hostapd_iface {
+@@ -235,6 +235,7 @@ struct hostapd_iface {
int (*for_each_interface)(struct hapd_interfaces *interfaces,
int (*cb)(struct hostapd_iface *iface,
void *ctx), void *ctx);
/* hostapd.c */
--- a/src/ap/hostapd.c
+++ b/src/ap/hostapd.c
-@@ -807,6 +807,9 @@ int hostapd_setup_interface_complete(str
+@@ -804,6 +804,9 @@ int hostapd_setup_interface_complete(str
wpa_printf(MSG_DEBUG, "%s: Setup of interface done.",
iface->bss[0]->conf->iface);
+static int daemonize = 0;
+static char *pid_file = NULL;
+ extern struct wpa_driver_ops *wpa_drivers[];
- struct hapd_interfaces {
-@@ -163,6 +165,16 @@ static void hostapd_logger_cb(void *ctx,
+@@ -173,6 +175,16 @@ static void hostapd_logger_cb(void *ctx,
}
#endif /* CONFIG_NO_HOSTAPD_LOGGER */
/**
* hostapd_init - Allocate and initialize per-interface data
-@@ -184,6 +196,7 @@ static struct hostapd_iface * hostapd_in
+@@ -194,6 +206,7 @@ static struct hostapd_iface * hostapd_in
if (hapd_iface == NULL)
goto fail;
hapd_iface->reload_config = hostapd_reload_config;
hapd_iface->config_read_cb = hostapd_config_read;
hapd_iface->config_fname = os_strdup(config_file);
-@@ -399,7 +412,7 @@ static int hostapd_global_init(struct ha
+@@ -442,7 +455,7 @@ static int hostapd_global_init(struct ha
}
-static void hostapd_global_deinit(const char *pid_file)
+static void hostapd_global_deinit(void)
{
- #ifdef EAP_SERVER_TNC
- tncs_global_deinit();
-@@ -419,8 +432,7 @@ static void hostapd_global_deinit(const
+ int i;
+
+@@ -472,8 +485,7 @@ static void hostapd_global_deinit(const
}
{
#ifdef EAP_SERVER_TNC
int tnc = 0;
-@@ -441,11 +453,6 @@ static int hostapd_global_run(struct hap
+@@ -494,11 +506,6 @@ static int hostapd_global_run(struct hap
}
#endif /* EAP_SERVER_TNC */
eloop_run();
return 0;
-@@ -501,8 +508,7 @@ int main(int argc, char *argv[])
+@@ -555,8 +562,7 @@ int main(int argc, char *argv[])
struct hapd_interfaces interfaces;
int ret = 1;
size_t i;
- char *pid_file = NULL;
+ int c, debug = 0;
const char *log_file = NULL;
+ const char *entropy_file = NULL;
- if (os_program_init())
-@@ -576,7 +582,7 @@ int main(int argc, char *argv[])
+@@ -634,7 +640,7 @@ int main(int argc, char *argv[])
goto out;
}
goto out;
ret = 0;
-@@ -587,7 +593,7 @@ int main(int argc, char *argv[])
+@@ -645,7 +651,7 @@ int main(int argc, char *argv[])
hostapd_interface_deinit_free(interfaces.iface[i]);
os_free(interfaces.iface);
if (log_file)
--- a/hostapd/config_file.c
+++ b/hostapd/config_file.c
-@@ -1891,6 +1891,8 @@ struct hostapd_config * hostapd_config_r
+@@ -1925,6 +1925,8 @@ struct hostapd_config * hostapd_config_r
}
#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
-@@ -390,6 +390,7 @@ struct hostapd_config {
+@@ -412,6 +412,7 @@ struct hostapd_config {
int ht_op_mode_fixed;
u16 ht_capab;
int require_ht;
--- a/src/ap/hw_features.c
+++ b/src/ap/hw_features.c
-@@ -463,7 +463,7 @@ static int ieee80211n_check_40mhz(struct
+@@ -449,7 +449,7 @@ static int ieee80211n_check_40mhz(struct
{
struct wpa_driver_scan_params params;
ifndef CONFIG_OS
ifdef CONFIG_NATIVE_WINDOWS
-@@ -159,10 +160,14 @@ ifdef CONFIG_IEEE80211N
+@@ -168,10 +169,14 @@ ifdef CONFIG_IEEE80211N
CFLAGS += -DCONFIG_IEEE80211N
endif
LIBS += $(DRV_AP_LIBS)
ifdef CONFIG_L2_PACKET
-@@ -780,6 +785,12 @@ install: all
+@@ -799,6 +804,12 @@ install: all
BCHECK=../src/drivers/build.hostapd
hostapd: $(BCHECK) $(OBJS)
$(Q)$(CC) $(LDFLAGS) -o hostapd $(OBJS) $(LIBS)
@$(E) " LD " $@
-@@ -820,6 +831,12 @@ HOBJS += ../src/crypto/aes-internal.o
+@@ -837,6 +848,12 @@ HOBJS += ../src/crypto/aes-internal.o
HOBJS += ../src/crypto/aes-internal-enc.o
endif
@$(E) " LD " $@
--- a/wpa_supplicant/Makefile
+++ b/wpa_supplicant/Makefile
-@@ -53,6 +53,7 @@ OBJS_c = wpa_cli.o ../src/common/wpa_ctr
- OBJS_c += ../src/utils/wpa_debug.o
+@@ -14,6 +14,7 @@ CFLAGS += -I../src
+ CFLAGS += -I../src/utils
-include .config
+-include $(if $(MULTICALL),../hostapd/.config)
- ifndef CONFIG_OS
- ifdef CONFIG_NATIVE_WINDOWS
-@@ -634,6 +635,10 @@ ifdef CONFIG_DYNAMIC_EAP_METHODS
+ ALL=wpa_supplicant wpa_cli
+
+@@ -663,6 +664,10 @@ ifdef CONFIG_DYNAMIC_EAP_METHODS
CFLAGS += -DCONFIG_DYNAMIC_EAP_METHODS
LIBS += -ldl -rdynamic
endif
endif
ifdef CONFIG_AP
-@@ -642,9 +647,11 @@ NEED_EAP_COMMON=y
+@@ -671,9 +676,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
-@@ -688,10 +695,18 @@ CFLAGS += -DEAP_SERVER_WSC
+@@ -718,10 +725,18 @@ CFLAGS += -DEAP_SERVER_WSC
OBJS += ../src/ap/wps_hostapd.o
OBJS += ../src/eap_server/eap_server_wsc.o
endif
NEED_AES_WRAP=y
OBJS += ../src/ap/wpa_auth.o
OBJS += ../src/ap/wpa_auth_ie.o
-@@ -1352,6 +1367,12 @@ wpa_priv: $(BCHECK) $(OBJS_priv)
+@@ -1397,6 +1412,12 @@ wpa_priv: $(BCHECK) $(OBJS_priv)
$(Q)$(LDO) $(LDFLAGS) -o wpa_priv $(OBJS_priv) $(LIBS)
@$(E) " LD " $@
wpa_supplicant: .config $(BCHECK) $(OBJS) $(EXTRA_progs)
$(Q)$(LDO) $(LDFLAGS) -o wpa_supplicant $(OBJS) $(LIBS) $(EXTRALIBS)
@$(E) " LD " $@
-@@ -1412,6 +1433,12 @@ eap_ikev2.so: ../src/eap_peer/eap_ikev2.
- $(Q)$(CC) -c -o $@ $(CFLAGS) $<
- @$(E) " CC " $<
+@@ -1460,6 +1481,12 @@ eap_ikev2.so: ../src/eap_peer/eap_ikev2.
+ %.service: %.service.in
+ sed -e 's|\@BINDIR\@|$(BINDIR)|g' $< >$@
+dump_cflags:
+ @echo -n $(CFLAGS) " "
wpa_cli.exe: wpa_cli
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
-@@ -3199,8 +3199,8 @@ union wpa_event_data {
+@@ -3452,8 +3452,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
-@@ -448,8 +448,8 @@ static void hostapd_event_eapol_rx(struc
+@@ -467,8 +467,8 @@ static void hostapd_event_eapol_rx(struc
}
}
--void wpa_supplicant_event(void *ctx, wpa_event_type event,
+-void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
- union wpa_event_data *data)
-+static void supplicant_event(void *ctx, wpa_event_type event,
++static void supplicant_event(void *ctx, enum wpa_event_type event,
+ union wpa_event_data *data)
{
struct wpa_priv_interface *iface = ctx;
for (;;) {
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
-@@ -1746,8 +1746,8 @@ static void wpa_supplicant_event_unprot_
+@@ -1936,8 +1936,8 @@ static void wnm_action_rx(struct wpa_sup
}
u16 reason_code = 0;
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
-@@ -2314,6 +2314,9 @@ static void wpa_supplicant_deinit_iface(
+@@ -2412,6 +2412,9 @@ static void wpa_supplicant_deinit_iface(
wpa_drv_deinit(wpa_s);
}
/**
* wpa_supplicant_add_iface - Add a new network interface
-@@ -2497,6 +2500,7 @@ struct wpa_global * wpa_supplicant_init(
+@@ -2602,6 +2605,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 const char * hostapd_msg_ifname_c
+@@ -556,6 +556,9 @@ static const char * hostapd_msg_ifname_c
return NULL;
}
int main(int argc, char *argv[])
{
-@@ -514,6 +517,7 @@ int main(int argc, char *argv[])
+@@ -569,6 +572,7 @@ int main(int argc, char *argv[])
if (os_program_init())
return -1;
+ wpa_supplicant_event = hostapd_wpa_event;
for (;;) {
- c = getopt(argc, argv, "Bdf:hKP:tv");
+ c = getopt(argc, argv, "Bde:f:hKP:tv");
if (c < 0)
--- a/src/drivers/drivers.c
+++ b/src/drivers/drivers.c
--- a/src/tls/x509v3.c
+++ b/src/tls/x509v3.c
-@@ -1854,8 +1854,11 @@ int x509_certificate_chain_validate(stru
+@@ -1854,6 +1854,9 @@ int x509_certificate_chain_validate(stru
if (chain_trusted)
continue;
-- if ((unsigned long) now.sec <
-+ if (
-+#ifndef NO_TIMESTAMP_CHECK
-+ (unsigned long) now.sec <
- (unsigned long) cert->not_before ||
++#ifdef NO_TIMESTAMP_CHECK
++ disable_time_checks = 1;
+#endif
- (unsigned long) now.sec >
- (unsigned long) cert->not_after) {
- wpa_printf(MSG_INFO, "X509: Certificate not valid "
+ if (!disable_time_checks &&
+ ((unsigned long) now.sec <
+ (unsigned long) cert->not_before ||
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
-@@ -2070,7 +2070,7 @@ static struct wpa_supplicant * wpa_suppl
+@@ -2157,7 +2157,7 @@ static struct wpa_supplicant * wpa_suppl
if (wpa_s == NULL)
return NULL;
wpa_s->scan_req = 1;
+ wpa_s->scan_interval = 1;
wpa_s->new_connection = 1;
wpa_s->parent = wpa_s;
-
+ wpa_s->sched_scanning = 0;
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
-@@ -129,7 +129,9 @@ struct wpa_driver_nl80211_data {
- int ifindex;
+@@ -198,7 +198,9 @@ struct wpa_driver_nl80211_data {
int if_removed;
int if_disabled;
+ int ignore_if_down_event;
+#ifdef CONFIG_RFKILL
struct rfkill_data *rfkill;
+#endif
struct wpa_driver_capa capa;
int has_capability;
-@@ -1819,7 +1821,7 @@ err1:
+@@ -2203,7 +2205,7 @@ err3:
return -1;
}
static void wpa_driver_nl80211_rfkill_blocked(void *ctx)
{
wpa_printf(MSG_DEBUG, "nl80211: RFKILL blocked");
-@@ -1841,6 +1843,7 @@ static void wpa_driver_nl80211_rfkill_un
+@@ -2226,6 +2228,7 @@ static void wpa_driver_nl80211_rfkill_un
}
/* rtnetlink ifup handler will report interface as enabled */
}
static void nl80211_get_phy_name(struct wpa_driver_nl80211_data *drv)
-@@ -1889,7 +1892,9 @@ static void * wpa_driver_nl80211_init(vo
+@@ -2283,7 +2286,9 @@ static void * wpa_driver_nl80211_init(vo
+ void *global_priv)
{
struct wpa_driver_nl80211_data *drv;
- struct netlink_config *cfg;
+#ifdef CONFIG_RFKILL
struct rfkill_config *rcfg;
+#endif
struct i802_bss *bss;
drv = os_zalloc(sizeof(*drv));
-@@ -1930,6 +1935,7 @@ static void * wpa_driver_nl80211_init(vo
- goto failed;
- }
+@@ -2311,6 +2316,7 @@ static void * wpa_driver_nl80211_init(vo
+
+ nl80211_get_phy_name(drv);
+#ifdef CONFIG_RFKILL
rcfg = os_zalloc(sizeof(*rcfg));
if (rcfg == NULL)
goto failed;
-@@ -1942,6 +1948,7 @@ static void * wpa_driver_nl80211_init(vo
+@@ -2323,6 +2329,7 @@ static void * wpa_driver_nl80211_init(vo
wpa_printf(MSG_DEBUG, "nl80211: RFKILL status not available");
os_free(rcfg);
}
if (wpa_driver_nl80211_finish_drv_init(drv))
goto failed;
-@@ -1952,7 +1959,9 @@ static void * wpa_driver_nl80211_init(vo
- return bss;
-
- failed:
-+#ifdef CONFIG_RFKILL
- rfkill_deinit(drv->rfkill);
-+#endif
- netlink_deinit(drv->netlink);
- if (drv->ioctl_sock >= 0)
- close(drv->ioctl_sock);
-@@ -2055,10 +2064,12 @@ static int nl80211_register_action_frame
+@@ -2445,10 +2452,12 @@ static int nl80211_register_action_frame
}
static int
-@@ -2077,13 +2088,16 @@ wpa_driver_nl80211_finish_drv_init(struc
+@@ -2475,13 +2484,16 @@ wpa_driver_nl80211_finish_drv_init(struc
}
- if (linux_set_iface_flags(drv->ioctl_sock, bss->ifname, 1)) {
+ if (linux_set_iface_flags(drv->global->ioctl_sock, bss->ifname, 1)) {
+#ifdef CONFIG_RFKILL
if (rfkill_is_blocked(drv->rfkill)) {
wpa_printf(MSG_DEBUG, "nl80211: Could not yet enable "
wpa_printf(MSG_ERROR, "nl80211: Could not set "
"interface '%s' UP", bss->ifname);
return -1;
-@@ -2111,8 +2125,10 @@ wpa_driver_nl80211_finish_drv_init(struc
+@@ -2510,8 +2522,10 @@ wpa_driver_nl80211_finish_drv_init(struc
}
if (send_rfkill_event) {
}
return 0;
-@@ -2193,7 +2209,9 @@ static void wpa_driver_nl80211_deinit(vo
+@@ -2596,7 +2610,9 @@ static void wpa_driver_nl80211_deinit(vo
- netlink_send_oper_ifla(drv->netlink, drv->ifindex, 0, IF_OPER_UP);
- netlink_deinit(drv->netlink);
+ netlink_send_oper_ifla(drv->global->netlink, drv->ifindex, 0,
+ IF_OPER_UP);
+#ifdef CONFIG_RFKILL
rfkill_deinit(drv->rfkill);
+#endif
eloop_cancel_timeout(wpa_driver_nl80211_scan_timeout, drv, drv->ctx);
-@@ -5785,7 +5803,9 @@ static void *i802_init(struct hostapd_da
-
- failed:
- nl80211_remove_monitor_interface(drv);
-+#ifdef CONFIG_RFKILL
- rfkill_deinit(drv->rfkill);
-+#endif
- netlink_deinit(drv->netlink);
- if (drv->ioctl_sock >= 0)
- close(drv->ioctl_sock);
--- a/src/drivers/driver_wext.c
+++ b/src/drivers/driver_wext.c
@@ -702,7 +702,7 @@ static void wpa_driver_wext_event_rtm_de
--- a/src/ap/hostapd.c
+++ b/src/ap/hostapd.c
-@@ -120,6 +120,10 @@ int hostapd_reload_config(struct hostapd
+@@ -124,6 +124,10 @@ int hostapd_reload_config(struct hostapd
oldconf = hapd->iconf;
iface->conf = newconf;
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
-@@ -2135,23 +2135,43 @@ wpa_driver_nl80211_finish_drv_init(struc
+@@ -2532,22 +2532,41 @@ wpa_driver_nl80211_finish_drv_init(struc
}
struct nl_msg *msg;
+ bss->beacon_set = 0;
-+
msg = nlmsg_alloc();
if (!msg)
return -ENOMEM;
- genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
- 0, NL80211_CMD_DEL_BEACON, 0);
+ nl80211_cmd(drv, msg, 0, NL80211_CMD_DEL_BEACON);
- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, drv->ifindex);
+ NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, bss->ifindex);
/**
* wpa_driver_nl80211_deinit - Deinitialize nl80211 driver interface
-@@ -6658,4 +6678,5 @@ const struct wpa_driver_ops wpa_driver_n
- .set_intra_bss = nl80211_set_intra_bss,
- .set_param = nl80211_set_param,
- .get_radio_name = nl80211_get_radio_name,
+@@ -7654,4 +7673,5 @@ const struct wpa_driver_ops wpa_driver_n
+ .send_tdls_mgmt = nl80211_send_tdls_mgmt,
+ .tdls_oper = nl80211_tdls_oper,
+ #endif /* CONFIG_TDLS */
+ .stop_ap = wpa_driver_nl80211_stop_ap,
};
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
-@@ -2253,6 +2253,8 @@ struct wpa_driver_ops {
- * implementation, there is no need to implement this function.
+@@ -2452,6 +2452,8 @@ struct wpa_driver_ops {
*/
- int (*set_authmode)(void *priv, int authmode);
+ void (*poll_client)(void *priv, const u8 *own_addr,
+ const u8 *addr, int qos);
+
+ int (*stop_ap)(void *priv);
};
#ifdef CONFIG_IEEE80211W
#ifdef NEED_AP_MLME
-@@ -822,6 +884,10 @@ static void hostapd_ctrl_iface_receive(i
+@@ -873,6 +935,10 @@ static void hostapd_ctrl_iface_receive(i
reply_len += res;
}
#endif /* CONFIG_NO_RADIUS */
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
-@@ -99,6 +99,8 @@ struct wpa_interface {
+@@ -100,6 +100,8 @@ struct wpa_interface {
* receiving of EAPOL frames from an additional interface.
*/
const char *bridge_ifname;
};
/**
-@@ -337,6 +339,8 @@ struct wpa_supplicant {
+@@ -260,6 +262,8 @@ struct wpa_supplicant {
#endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
char bridge_ifname[16];
int countermeasures;
--- a/wpa_supplicant/Makefile
+++ b/wpa_supplicant/Makefile
-@@ -52,6 +52,11 @@ OBJS_p += ../src/utils/wpabuf.o
- OBJS_c = wpa_cli.o ../src/common/wpa_ctrl.o
- OBJS_c += ../src/utils/wpa_debug.o
+@@ -13,6 +13,10 @@ PKG_CONFIG ?= pkg-config
+ CFLAGS += -I../src
+ CFLAGS += -I../src/utils
+ifdef MULTICALL
-+OBJS += ../src/common/wpa_ctrl.o
+CFLAGS += -DMULTICALL
+endif
+
-include .config
-include $(if $(MULTICALL),../hostapd/.config)
+@@ -69,6 +73,10 @@ OBJS_c = wpa_cli.o ../src/common/wpa_ctr
+ OBJS_c += ../src/utils/wpa_debug.o
+ OBJS_c += ../src/utils/common.o
+
++ifdef MULTICALL
++OBJS += ../src/common/wpa_ctrl.o
++endif
++
+ ifndef CONFIG_OS
+ ifdef CONFIG_NATIVE_WINDOWS
+ CONFIG_OS=win32
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
-@@ -123,6 +123,55 @@ extern int wpa_debug_show_keys;
+@@ -125,6 +125,55 @@ extern int wpa_debug_show_keys;
extern int wpa_debug_timestamp;
extern struct wpa_driver_ops *wpa_drivers[];
/* Configure default/group WEP keys for static WEP */
int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
{
-@@ -598,8 +647,16 @@ void wpa_supplicant_set_state(struct wpa
+@@ -632,8 +681,16 @@ void wpa_supplicant_set_state(struct wpa
#ifdef CONFIG_P2P
wpas_p2p_completed(wpa_s);
#endif /* CONFIG_P2P */
wpa_s->new_connection = 1;
wpa_drv_set_operstate(wpa_s, 0);
#ifndef IEEE8021X_EAPOL
-@@ -2157,6 +2214,21 @@ static int wpa_supplicant_init_iface(str
+@@ -2245,6 +2302,21 @@ static int wpa_supplicant_init_iface(str
os_strlcpy(wpa_s->bridge_ifname, iface->bridge_ifname,
sizeof(wpa_s->bridge_ifname));
}
#include "drivers/driver.h"
#include "wpa_supplicant_i.h"
#include "config.h"
-@@ -70,6 +71,8 @@ struct wpa_bss * wpa_bss_get(struct wpa_
+@@ -79,6 +80,8 @@ struct wpa_bss * wpa_bss_get(struct wpa_
static void wpa_bss_copy_res(struct wpa_bss *dst, struct wpa_scan_res *src)
{
os_time_t usec;
dst->flags = src->flags;
-@@ -82,6 +85,12 @@ static void wpa_bss_copy_res(struct wpa_
+@@ -91,6 +94,12 @@ static void wpa_bss_copy_res(struct wpa_
dst->level = src->level;
dst->tsf = src->tsf;
usec = (src->age % 1000) * 1000;
--- a/wpa_supplicant/bss.h
+++ b/wpa_supplicant/bss.h
-@@ -56,6 +56,7 @@ struct wpa_bss {
+@@ -57,6 +57,7 @@ struct wpa_bss {
unsigned int flags;
u8 bssid[ETH_ALEN];
u8 ssid[32];
- " -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] "
+ " -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] [-H<hostapd path>]"
"[-p<driver_param>] \\\n"
- " [-b<br_ifname>] [-f<debug file>] \\\n"
- " [-o<override driver>] [-O<override ctrl>] \\\n"
-@@ -67,6 +67,7 @@ static void usage(void)
+ " [-b<br_ifname>] [-f<debug file>] [-e<entropy file>] "
+ "\\\n"
+@@ -69,6 +69,7 @@ static void usage(void)
#endif /* CONFIG_DEBUG_SYSLOG */
printf(" -t = include timestamp in debug messages\n"
" -h = show this help text\n"
" -L = show license (GPL and BSD)\n"
" -o = override driver parameter for new interfaces\n"
" -O = override ctrl_interface parameter for new interfaces\n"
-@@ -143,7 +144,7 @@ int main(int argc, char *argv[])
+@@ -145,7 +146,7 @@ int main(int argc, char *argv[])
wpa_supplicant_fd_workaround();
for (;;) {
-- c = getopt(argc, argv, "b:Bc:C:D:df:g:hi:KLNo:O:p:P:qstuvW");
-+ c = getopt(argc, argv, "b:Bc:C:D:df:g:hH:i:KLNo:O:p:P:qstuvW");
+- c = getopt(argc, argv, "b:Bc:C:D:de:f:g:hi:KLNo:O:p:P:qstuvW");
++ c = getopt(argc, argv, "b:Bc:C:D:de:f:g:hH:i:KLNo:O:p:P:qstuvW");
if (c < 0)
break;
switch (c) {
-@@ -184,6 +185,9 @@ int main(int argc, char *argv[])
+@@ -189,6 +190,9 @@ int main(int argc, char *argv[])
usage();
exitcode = 0;
goto out;
--- a/hostapd/Makefile
+++ b/hostapd/Makefile
-@@ -119,6 +119,9 @@ endif
+@@ -128,6 +128,9 @@ endif
ifdef CONFIG_NO_CTRL_IFACE
CFLAGS += -DCONFIG_NO_CTRL_IFACE
else
endif
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
-@@ -855,6 +855,7 @@ static void hostapd_ctrl_iface_receive(i
+@@ -906,6 +906,7 @@ static void hostapd_ctrl_iface_receive(i
} else if (os_strncmp(buf, "RELOG", 5) == 0) {
if (wpa_debug_reopen_file() < 0)
reply_len = -1;
} else if (os_strcmp(buf, "MIB") == 0) {
reply_len = ieee802_11_get_mib(hapd, reply, reply_size);
if (reply_len >= 0) {
-@@ -884,10 +885,12 @@ static void hostapd_ctrl_iface_receive(i
+@@ -935,10 +936,12 @@ static void hostapd_ctrl_iface_receive(i
reply_len += res;
}
#endif /* CONFIG_NO_RADIUS */
} else if (os_strcmp(buf, "STA-FIRST") == 0) {
reply_len = hostapd_ctrl_iface_sta_first(hapd, reply,
reply_size);
-@@ -897,6 +900,7 @@ static void hostapd_ctrl_iface_receive(i
+@@ -948,6 +951,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
-@@ -675,6 +675,9 @@ ifdef CONFIG_IEEE80211N
+@@ -709,6 +709,9 @@ ifdef CONFIG_IEEE80211N
OBJS += ../src/ap/ieee802_11_ht.o
endif
ifdef CONFIG_CTRL_IFACE
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
-@@ -2929,6 +2929,7 @@ char * wpa_supplicant_ctrl_iface_process
+@@ -3231,6 +3231,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) {
-@@ -2940,6 +2941,7 @@ char * wpa_supplicant_ctrl_iface_process
+@@ -3242,6 +3243,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);
-@@ -3245,6 +3247,7 @@ char * wpa_supplicant_ctrl_iface_process
+@@ -3570,6 +3572,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) {
-@@ -3253,6 +3256,7 @@ char * wpa_supplicant_ctrl_iface_process
+@@ -3578,6 +3581,7 @@ char * wpa_supplicant_ctrl_iface_process
} else if (os_strncmp(buf, "STA-NEXT ", 9) == 0) {
reply_len = ap_ctrl_iface_sta_next(wpa_s, buf + 9, reply,
reply_size);
+#endif
--- a/src/ap/ieee802_1x.c
+++ b/src/ap/ieee802_1x.c
-@@ -1896,6 +1896,7 @@ static const char * bool_txt(Boolean boo
+@@ -1926,6 +1926,7 @@ static const char * bool_txt(Boolean boo
return bool ? "TRUE" : "FALSE";
}
int ieee802_1x_get_mib(struct hostapd_data *hapd, char *buf, size_t buflen)
{
-@@ -2047,6 +2048,7 @@ int ieee802_1x_get_mib_sta(struct hostap
+@@ -2078,6 +2079,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
-@@ -2491,6 +2491,7 @@ static int wpa_cipher_bits(int cipher)
+@@ -2534,6 +2534,7 @@ static int wpa_cipher_bits(int cipher)
}
}
#define RSN_SUITE "%02x-%02x-%02x-%d"
#define RSN_SUITE_ARG(s) \
-@@ -2654,7 +2655,7 @@ int wpa_get_mib_sta(struct wpa_state_mac
+@@ -2697,7 +2698,7 @@ int wpa_get_mib_sta(struct wpa_state_mac
return len;
}
{
--- a/src/rsn_supp/wpa.c
+++ b/src/rsn_supp/wpa.c
-@@ -1913,6 +1913,8 @@ static u32 wpa_cipher_suite(struct wpa_s
+@@ -1919,6 +1919,8 @@ static u32 wpa_cipher_suite(struct wpa_s
}
#define RSN_SUITE "%02x-%02x-%02x-%d"
#define RSN_SUITE_ARG(s) \
((s) >> 24) & 0xff, ((s) >> 16) & 0xff, ((s) >> 8) & 0xff, (s) & 0xff
-@@ -1992,6 +1994,7 @@ int wpa_sm_get_mib(struct wpa_sm *sm, ch
+@@ -1998,6 +2000,7 @@ int wpa_sm_get_mib(struct wpa_sm *sm, ch
return (int) len;
}
--- a/src/common/wpa_common.c
+++ b/src/common/wpa_common.c
-@@ -811,6 +811,31 @@ const char * wpa_key_mgmt_txt(int key_mg
+@@ -959,6 +959,31 @@ const char * wpa_key_mgmt_txt(int key_mg
}
int wpa_compare_rsn_ie(int ft_initial_assoc,
const u8 *ie1, size_t ie1len,
const u8 *ie2, size_t ie2len)
-@@ -818,8 +843,19 @@ int wpa_compare_rsn_ie(int ft_initial_as
+@@ -966,8 +991,19 @@ int wpa_compare_rsn_ie(int ft_initial_as
if (ie1 == NULL || ie2 == NULL)
return -1;
--- a/src/ap/hostapd.c
+++ b/src/ap/hostapd.c
-@@ -723,11 +723,8 @@ int hostapd_setup_interface_complete(str
+@@ -720,11 +720,8 @@ int hostapd_setup_interface_complete(str
size_t j;
u8 *prev_addr;
wpa_printf(MSG_DEBUG, "Completing interface initialization");
if (hapd->iconf->channel) {
-@@ -743,7 +740,7 @@ int hostapd_setup_interface_complete(str
+@@ -740,7 +737,7 @@ int hostapd_setup_interface_complete(str
hapd->iconf->secondary_channel)) {
wpa_printf(MSG_ERROR, "Could not set channel for "
"kernel driver");
}
}
-@@ -754,7 +751,7 @@ int hostapd_setup_interface_complete(str
+@@ -751,7 +748,7 @@ int hostapd_setup_interface_complete(str
hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211,
HOSTAPD_LEVEL_WARNING,
"Failed to prepare rates table.");
}
}
-@@ -762,14 +759,14 @@ int hostapd_setup_interface_complete(str
+@@ -759,14 +756,14 @@ int hostapd_setup_interface_complete(str
hostapd_set_rts(hapd, hapd->iconf->rts_threshold)) {
wpa_printf(MSG_ERROR, "Could not set RTS threshold for "
"kernel driver");
}
prev_addr = hapd->own_addr;
-@@ -779,7 +776,7 @@ int hostapd_setup_interface_complete(str
+@@ -776,7 +773,7 @@ int hostapd_setup_interface_complete(str
if (j)
os_memcpy(hapd->own_addr, prev_addr, ETH_ALEN);
if (hostapd_setup_bss(hapd, j == 0))
if (hostapd_mac_comp_empty(hapd->conf->bssid) == 0)
prev_addr = hapd->own_addr;
}
-@@ -791,7 +788,7 @@ int hostapd_setup_interface_complete(str
+@@ -788,7 +785,7 @@ int hostapd_setup_interface_complete(str
if (hostapd_driver_commit(hapd) < 0) {
wpa_printf(MSG_ERROR, "%s: Failed to commit driver "
"configuration", __func__);
}
/*
-@@ -815,6 +812,11 @@ int hostapd_setup_interface_complete(str
+@@ -812,6 +809,11 @@ int hostapd_setup_interface_complete(str
iface->init_complete(iface);
return 0;
static u32 pool[POOL_WORDS];
static unsigned int input_rotate = 0;
static unsigned int pool_pos = 0;
-@@ -122,7 +126,7 @@ static void random_extract(u8 *out)
+@@ -128,7 +132,7 @@ static void random_extract(u8 *out)
}
{
struct os_time t;
static unsigned int count = 0;
-@@ -191,16 +195,22 @@ int random_get_bytes(void *buf, size_t l
+@@ -197,16 +201,22 @@ int random_get_bytes(void *buf, size_t l
int random_pool_ready(void)
{
#ifdef __linux__
/*
* Try to fetch some more data from the kernel high quality
-@@ -232,8 +242,10 @@ int random_pool_ready(void)
- dummy_key_avail += res;
- close(fd);
-
-- if (dummy_key_avail == sizeof(dummy_key))
-+ if (dummy_key_avail == sizeof(dummy_key)) {
+@@ -241,6 +251,7 @@ int random_pool_ready(void)
+ if (dummy_key_avail == sizeof(dummy_key)) {
+ if (own_pool_ready < MIN_READY_MARK)
+ own_pool_ready = MIN_READY_MARK;
+ random_mark_pool_ready();
+ random_write_entropy();
return 1;
-+ }
-
- wpa_printf(MSG_INFO, "random: Only %u/%u bytes of strong "
- "random data available from /dev/random",
-@@ -243,6 +255,7 @@ int random_pool_ready(void)
+ }
+@@ -253,6 +264,7 @@ int random_pool_ready(void)
total_collected + 10 * own_pool_ready > MIN_COLLECT_ENTROPY) {
wpa_printf(MSG_INFO, "random: Allow operation to proceed "
"based on internal entropy");
return 1;
}
-@@ -258,9 +271,15 @@ int random_pool_ready(void)
+@@ -268,10 +280,16 @@ int random_pool_ready(void)
void random_mark_pool_ready(void)
{
own_pool_ready++;
wpa_printf(MSG_DEBUG, "random: Mark internal entropy pool to be "
"ready (count=%u/%u)", own_pool_ready, MIN_READY_MARK);
+ random_write_entropy();
+
+ fd = open(RANDOM_STAMPFILE, O_CREAT | O_WRONLY | O_EXCL | O_NOFOLLOW, 0600);
+ if (fd >= 0)
}
-@@ -335,3 +354,22 @@ void random_deinit(void)
- random_close_fd();
- #endif /* __linux__ */
+@@ -428,3 +446,22 @@ void random_deinit(void)
+ os_free(random_entropy_file);
+ random_entropy_file = NULL;
}
+
+#endif /* CONFIG_NO_RANDOM_POOL */
+ random_pool_add_randomness(buf, len);
+#endif
+}
---- a/hostapd/Makefile
-+++ b/hostapd/Makefile
-@@ -698,11 +698,11 @@ endif
- ifdef CONFIG_NO_RANDOM_POOL
- CFLAGS += -DCONFIG_NO_RANDOM_POOL
- else
--OBJS += ../src/crypto/random.o
--HOBJS += ../src/crypto/random.o
- HOBJS += $(SHA1OBJS)
- HOBJS += ../src/crypto/md5.o
- endif
-+OBJS += ../src/crypto/random.o
-+HOBJS += ../src/crypto/random.o
-
- ifdef CONFIG_RADIUS_SERVER
- CFLAGS += -DRADIUS_SERVER
--- a/wpa_supplicant/Makefile
+++ b/wpa_supplicant/Makefile
-@@ -1101,9 +1101,8 @@ endif
+@@ -1137,9 +1137,8 @@ endif
ifdef CONFIG_NO_RANDOM_POOL
CFLAGS += -DCONFIG_NO_RANDOM_POOL
ifeq ($(CONFIG_CTRL_IFACE), y)
--- a/wpa_supplicant/Android.mk
+++ b/wpa_supplicant/Android.mk
-@@ -1109,9 +1109,8 @@ endif
+@@ -1132,9 +1132,8 @@ endif
ifdef CONFIG_NO_RANDOM_POOL
L_CFLAGS += -DCONFIG_NO_RANDOM_POOL
ifeq ($(CONFIG_CTRL_IFACE), y)
--- a/hostapd/Android.mk
+++ b/hostapd/Android.mk
-@@ -717,11 +717,11 @@ endif
+@@ -720,11 +720,11 @@ endif
ifdef CONFIG_NO_RANDOM_POOL
L_CFLAGS += -DCONFIG_NO_RANDOM_POOL
else
ifdef CONFIG_RADIUS_SERVER
L_CFLAGS += -DRADIUS_SERVER
---- a/src/crypto/random.h
-+++ b/src/crypto/random.h
-@@ -18,17 +18,16 @@
- #ifdef CONFIG_NO_RANDOM_POOL
- #define random_init() do { } while (0)
- #define random_deinit() do { } while (0)
--#define random_add_randomness(b, l) do { } while (0)
- #define random_get_bytes(b, l) os_get_random((b), (l))
- #define random_pool_ready() 1
- #define random_mark_pool_ready() do { } while (0)
- #else /* CONFIG_NO_RANDOM_POOL */
- void random_init(void);
- void random_deinit(void);
--void random_add_randomness(const void *buf, size_t len);
- int random_get_bytes(void *buf, size_t len);
- int random_pool_ready(void);
- void random_mark_pool_ready(void);
- #endif /* CONFIG_NO_RANDOM_POOL */
-+void random_add_randomness(const void *buf, size_t len);
-
- #endif /* RANDOM_H */
+--- a/hostapd/Makefile
++++ b/hostapd/Makefile
+@@ -707,12 +707,12 @@ endif
+ ifdef CONFIG_NO_RANDOM_POOL
+ CFLAGS += -DCONFIG_NO_RANDOM_POOL
+ else
+-OBJS += ../src/crypto/random.o
+-HOBJS += ../src/crypto/random.o
+ HOBJS += ../src/utils/eloop.o
+ HOBJS += $(SHA1OBJS)
+ HOBJS += ../src/crypto/md5.o
+ endif
++OBJS += ../src/crypto/random.o
++HOBJS += ../src/crypto/random.o
+
+ ifdef CONFIG_RADIUS_SERVER
+ CFLAGS += -DRADIUS_SERVER
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
-@@ -5005,9 +5005,6 @@ static int wpa_driver_nl80211_set_mode(v
- /* Try to set the mode again while the interface is
- * down */
+@@ -5867,8 +5867,6 @@ static int wpa_driver_nl80211_set_mode(s
ret = nl80211_set_mode(drv, drv->ifindex, nlmode);
-- if (linux_set_iface_flags(drv->ioctl_sock, bss->ifname,
-- 1))
-- ret = -1;
- if (!ret)
+ if (ret == -EACCES)
break;
- } else
-@@ -5020,6 +5017,8 @@ static int wpa_driver_nl80211_set_mode(v
- wpa_printf(MSG_DEBUG, "nl80211: Mode change succeeded while "
+- res = linux_set_iface_flags(drv->global->ioctl_sock,
+- bss->ifname, 1);
+ if (res && !ret)
+ ret = -1;
+ else if (ret != -EBUSY)
+@@ -5884,6 +5882,7 @@ static int wpa_driver_nl80211_set_mode(s
"interface is down");
drv->nlmode = nlmode;
-+ if (linux_set_iface_flags(drv->ioctl_sock, bss->ifname, 1))
-+ ret = -1;
+ drv->ignore_if_down_event = 1;
++ linux_set_iface_flags(drv->global->ioctl_sock, bss->ifname, 1);
}
done:
+++ /dev/null
---- a/src/drivers/driver_nl80211.c
-+++ b/src/drivers/driver_nl80211.c
-@@ -5660,6 +5660,9 @@ static int i802_set_wds_sta(void *priv,
- linux_set_iface_flags(drv->ioctl_sock, name, 1);
- return i802_set_sta_vlan(priv, addr, name, 0);
- } else {
-+ if (bridge_ifname)
-+ linux_br_del_if(drv->ioctl_sock, bridge_ifname, name);
-+
- i802_set_sta_vlan(priv, addr, bss->ifname, 0);
- return wpa_driver_nl80211_if_remove(priv, WPA_IF_AP_VLAN,
- name);
-@@ -6021,14 +6024,14 @@ static int wpa_driver_nl80211_if_remove(
- return -1;
-
- #ifdef HOSTAPD
-- if (bss->added_if_into_bridge) {
-+ if (type == WPA_IF_AP_BSS && bss->added_if_into_bridge) {
- if (linux_br_del_if(drv->ioctl_sock, bss->brname, bss->ifname)
- < 0)
- wpa_printf(MSG_INFO, "nl80211: Failed to remove "
- "interface %s from bridge %s: %s",
- bss->ifname, bss->brname, strerror(errno));
- }
-- if (bss->added_bridge) {
-+ if (type == WPA_IF_AP_BSS && bss->added_bridge) {
- if (linux_br_del(drv->ioctl_sock, bss->brname) < 0)
- wpa_printf(MSG_INFO, "nl80211: Failed to remove "
- "bridge %s: %s",
--- /dev/null
+--- a/src/ap/wps_hostapd.c
++++ b/src/ap/wps_hostapd.c
+@@ -799,11 +799,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)
+@@ -811,7 +809,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/ap/wpa_auth.c
++++ b/src/ap/wpa_auth.c
+@@ -1330,7 +1330,7 @@ static void wpa_send_eapol(struct wpa_au
+ keyidx, encr, 0);
+
+ ctr = pairwise ? sm->TimeoutCtr : sm->GTimeoutCtr;
+- if (ctr == 1 && wpa_auth->conf.tx_status)
++ if (ctr == 1 && wpa_auth->conf.tx_status && pairwise)
+ timeout_ms = eapol_key_timeout_first;
+ else
+ timeout_ms = eapol_key_timeout_subseq;
+++ /dev/null
---- a/src/ap/ieee802_11.c
-+++ b/src/ap/ieee802_11.c
-@@ -1629,13 +1629,6 @@ static void handle_assoc_cb(struct hosta
- int new_assoc = 1;
- struct ieee80211_ht_capabilities ht_cap;
-
-- if (!ok) {
-- hostapd_logger(hapd, mgmt->da, HOSTAPD_MODULE_IEEE80211,
-- HOSTAPD_LEVEL_DEBUG,
-- "did not acknowledge association response");
-- return;
-- }
--
- if (len < IEEE80211_HDRLEN + (reassoc ? sizeof(mgmt->u.reassoc_resp) :
- sizeof(mgmt->u.assoc_resp))) {
- printf("handle_assoc_cb(reassoc=%d) - too short payload "
-@@ -1643,11 +1636,6 @@ static void handle_assoc_cb(struct hosta
- return;
- }
-
-- if (reassoc)
-- status = le_to_host16(mgmt->u.reassoc_resp.status_code);
-- else
-- status = le_to_host16(mgmt->u.assoc_resp.status_code);
--
- sta = ap_get_sta(hapd, mgmt->da);
- if (!sta) {
- printf("handle_assoc_cb: STA " MACSTR " not found\n",
-@@ -1655,6 +1643,19 @@ static void handle_assoc_cb(struct hosta
- return;
- }
-
-+ if (!ok) {
-+ hostapd_logger(hapd, mgmt->da, HOSTAPD_MODULE_IEEE80211,
-+ HOSTAPD_LEVEL_DEBUG,
-+ "did not acknowledge association response");
-+ sta->flags &= ~WLAN_STA_ASSOC_REQ_OK;
-+ return;
-+ }
-+
-+ if (reassoc)
-+ status = le_to_host16(mgmt->u.reassoc_resp.status_code);
-+ else
-+ status = le_to_host16(mgmt->u.assoc_resp.status_code);
-+
- if (status != WLAN_STATUS_SUCCESS)
- goto fail;
-
--- /dev/null
+--- a/hostapd/config_file.c
++++ b/hostapd/config_file.c
+@@ -1935,6 +1935,10 @@ struct hostapd_config * hostapd_config_r
+ "ht_capab", line);
+ errors++;
+ }
++ } else if (os_strcmp(buf, "dynamic_ht40") == 0) {
++ conf->dynamic_ht40 = atoi(pos);
++ if (conf->dynamic_ht40 == 1)
++ conf->dynamic_ht40 = 1500;
+ } else if (os_strcmp(buf, "require_ht") == 0) {
+ conf->require_ht = atoi(pos);
+ #endif /* CONFIG_IEEE80211N */
+--- a/src/ap/ap_config.h
++++ b/src/ap/ap_config.h
+@@ -416,6 +416,7 @@ struct hostapd_config {
+ int ieee80211n;
+ int secondary_channel;
+ int require_ht;
++ int dynamic_ht40;
+ };
+
+
+--- a/src/ap/hostapd.c
++++ b/src/ap/hostapd.c
+@@ -27,6 +27,7 @@
+ #include "beacon.h"
+ #include "iapp.h"
+ #include "ieee802_1x.h"
++#include "ieee802_11.h"
+ #include "ieee802_11_auth.h"
+ #include "vlan_init.h"
+ #include "wpa_auth.h"
+@@ -291,6 +292,7 @@ static void hostapd_cleanup_iface_pre(st
+ */
+ static void hostapd_cleanup_iface(struct hostapd_iface *iface)
+ {
++ hostapd_deinit_ht(iface);
+ hostapd_free_hw_features(iface->hw_features, iface->num_hw_features);
+ iface->hw_features = NULL;
+ os_free(iface->current_rates);
+--- a/src/ap/hostapd.h
++++ b/src/ap/hostapd.h
+@@ -226,6 +226,9 @@ struct hostapd_iface {
+ /* Overlapping BSS information */
+ int olbc_ht;
+
++ int force_20mhz;
++ struct os_time last_20mhz_trigger;
++
+ u16 ht_op_mode;
+ void (*scan_cb)(struct hostapd_iface *iface);
+
+--- a/src/ap/ieee802_11.c
++++ b/src/ap/ieee802_11.c
+@@ -1193,6 +1193,9 @@ static void handle_beacon(struct hostapd
+ sizeof(mgmt->u.beacon)), &elems,
+ 0);
+
++ if (!elems.ht_capabilities)
++ hostapd_trigger_20mhz(hapd->iface);
++
+ ap_list_process_beacon(hapd->iface, mgmt, &elems, fi);
+ }
+
+--- a/src/ap/ieee802_11.h
++++ b/src/ap/ieee802_11.h
+@@ -77,4 +77,17 @@ u8 * hostapd_eid_time_zone(struct hostap
+ int hostapd_update_time_adv(struct hostapd_data *hapd);
+ void hostapd_client_poll_ok(struct hostapd_data *hapd, const u8 *addr);
+
++#ifdef CONFIG_IEEE80211N
++void hostapd_trigger_20mhz(struct hostapd_iface *iface);
++void hostapd_deinit_ht(struct hostapd_iface *iface);
++
++#else
++static inline void hostapd_deinit_ht(struct hostapd_iface *iface)
++{
++}
++static inline void hostapd_trigger_20mhz(struct hostapd_iface *iface)
++{
++}
++#endif /* CONFIG_IEEE80211N */
++
+ #endif /* IEEE802_11_H */
+--- a/src/ap/ieee802_11_ht.c
++++ b/src/ap/ieee802_11_ht.c
+@@ -20,9 +20,11 @@
+ #include "drivers/driver.h"
+ #include "hostapd.h"
+ #include "ap_config.h"
++#include "ap_drv_ops.h"
+ #include "sta_info.h"
+ #include "beacon.h"
+ #include "ieee802_11.h"
++#include "utils/eloop.h"
+
+
+ u8 * hostapd_eid_ht_capabilities(struct hostapd_data *hapd, u8 *eid)
+@@ -70,12 +72,15 @@ u8 * hostapd_eid_ht_operation(struct hos
+
+ oper->control_chan = hapd->iconf->channel;
+ oper->operation_mode = host_to_le16(hapd->iface->ht_op_mode);
+- if (hapd->iconf->secondary_channel == 1)
+- oper->ht_param |= HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE |
+- HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH;
+- if (hapd->iconf->secondary_channel == -1)
+- oper->ht_param |= HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW |
+- HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH;
++
++ if (!hapd->iface->force_20mhz) {
++ if (hapd->iconf->secondary_channel == 1)
++ oper->ht_param |= HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE |
++ HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH;
++ if (hapd->iconf->secondary_channel == -1)
++ oper->ht_param |= HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW |
++ HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH;
++ }
+
+ pos += sizeof(*oper);
+
+@@ -271,3 +276,80 @@ void hostapd_get_ht_capab(struct hostapd
+
+ neg_ht_cap->ht_capabilities_info = host_to_le16(cap);
+ }
++
++static void hostapd_set_force_20mhz(struct hostapd_iface *iface);
++
++static void hostapd_restore_40mhz(void *eloop_data, void *user_ctx)
++{
++ struct hostapd_iface *iface = eloop_data;
++ struct os_time time;
++ int timeout;
++
++ if (!iface->last_20mhz_trigger.sec)
++ return;
++
++ os_get_time(&time);
++ timeout = iface->last_20mhz_trigger.sec + iface->conf->dynamic_ht40 -
++ time.sec;
++
++ if (timeout > 0) {
++ eloop_register_timeout(timeout, 0, hostapd_restore_40mhz,
++ iface, NULL);
++ return;
++ }
++
++ iface->last_20mhz_trigger.sec = 0;
++ iface->last_20mhz_trigger.usec = 0;
++
++ iface->force_20mhz = 0;
++ hostapd_set_force_20mhz(iface);
++}
++
++static void hostapd_set_force_20mhz(struct hostapd_iface *iface)
++{
++ int secondary_channel;
++ int i;
++
++ ieee802_11_set_beacons(iface);
++
++ for (i = 0; i < iface->num_bss; i++) {
++ struct hostapd_data *hapd = iface->bss[i];
++
++ if (iface->force_20mhz)
++ secondary_channel = 0;
++ else
++ secondary_channel = hapd->iconf->secondary_channel;
++
++ if (hostapd_set_freq(hapd, hapd->iconf->hw_mode, iface->freq,
++ hapd->iconf->channel,
++ hapd->iconf->ieee80211n,
++ secondary_channel)) {
++ wpa_printf(MSG_ERROR, "Could not set channel for "
++ "kernel driver");
++ }
++ }
++}
++
++void hostapd_deinit_ht(struct hostapd_iface *iface)
++{
++ eloop_cancel_timeout(hostapd_restore_40mhz, iface, NULL);
++}
++
++void hostapd_trigger_20mhz(struct hostapd_iface *iface)
++{
++ if (!iface->conf->dynamic_ht40)
++ return;
++
++ if (!iface->force_20mhz) {
++ iface->force_20mhz = 1;
++ hostapd_set_force_20mhz(iface);
++ }
++
++ if (!iface->last_20mhz_trigger.sec) {
++ eloop_cancel_timeout(hostapd_restore_40mhz, iface, NULL);
++ eloop_register_timeout(iface->conf->dynamic_ht40, 0,
++ hostapd_restore_40mhz, iface, NULL);
++ }
++
++ os_get_time(&iface->last_20mhz_trigger);
++}
+++ /dev/null
---- a/src/ap/wps_hostapd.c
-+++ b/src/ap/wps_hostapd.c
-@@ -773,11 +773,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)
-@@ -785,7 +783,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
-@@ -4413,8 +4413,8 @@ static int wpa_driver_nl80211_hapd_send_
- pos = (u8 *) (hdr + 1);
-
- if (qos) {
-- /* add an empty QoS header if needed */
-- pos[0] = 0;
-+ /* Set highest priority in QoS header */
-+ pos[0] = 7;
- pos[1] = 0;
- pos += 2;
- }
+++ /dev/null
---- a/src/ap/wpa_auth.c
-+++ b/src/ap/wpa_auth.c
-@@ -1288,7 +1288,7 @@ static void wpa_send_eapol(struct wpa_au
- keyidx, encr, 0);
-
- ctr = pairwise ? sm->TimeoutCtr : sm->GTimeoutCtr;
-- if (ctr == 1 && wpa_auth->conf.tx_status)
-+ if (ctr == 1 && wpa_auth->conf.tx_status && pairwise)
- timeout_ms = eapol_key_timeout_first;
- else
- timeout_ms = eapol_key_timeout_subseq;
+++ /dev/null
---- a/src/drivers/driver_nl80211.c
-+++ b/src/drivers/driver_nl80211.c
-@@ -111,6 +111,7 @@ struct i802_bss {
- struct wpa_driver_nl80211_data *drv;
- struct i802_bss *next;
- int ifindex;
-+ u8 addr[ETH_ALEN];
- char ifname[IFNAMSIZ + 1];
- char brname[IFNAMSIZ];
- unsigned int beacon_set:1;
-@@ -121,7 +122,6 @@ struct i802_bss {
- struct wpa_driver_nl80211_data {
- struct nl80211_global *global;
- struct dl_list list;
-- u8 addr[ETH_ALEN];
- char phyname[32];
- void *ctx;
- struct netlink_data *netlink;
-@@ -2111,7 +2111,7 @@ wpa_driver_nl80211_finish_drv_init(struc
- if (wpa_driver_nl80211_capa(drv))
- return -1;
-
-- if (linux_get_ifhwaddr(drv->ioctl_sock, bss->ifname, drv->addr))
-+ if (linux_get_ifhwaddr(drv->ioctl_sock, bss->ifname, bss->addr))
- return -1;
-
- if (nl80211_register_action_frames(drv) < 0) {
-@@ -5650,7 +5650,7 @@ static int i802_set_wds_sta(void *priv,
- if (!if_nametoindex(name)) {
- if (nl80211_create_iface(drv, name,
- NL80211_IFTYPE_AP_VLAN,
-- NULL, 1) < 0)
-+ bss->addr, 1) < 0)
- return -1;
- if (bridge_ifname &&
- linux_br_add_if(drv->ioctl_sock, bridge_ifname,
-@@ -5878,7 +5878,7 @@ static int nl80211_addr_in_use(struct nl
- struct wpa_driver_nl80211_data *drv;
- dl_list_for_each(drv, &global->interfaces,
- struct wpa_driver_nl80211_data, list) {
-- if (os_memcmp(addr, drv->addr, ETH_ALEN) == 0)
-+ if (os_memcmp(addr, drv->first_bss.addr, ETH_ALEN) == 0)
- return 1;
- }
- return 0;
-@@ -5893,9 +5893,9 @@ static int nl80211_p2p_interface_addr(st
- if (!drv->global)
- return -1;
-
-- os_memcpy(new_addr, drv->addr, ETH_ALEN);
-+ os_memcpy(new_addr, drv->first_bss.addr, ETH_ALEN);
- for (idx = 0; idx < 64; idx++) {
-- new_addr[0] = drv->addr[0] | 0x02;
-+ new_addr[0] = drv->first_bss.addr[0] | 0x02;
- new_addr[0] ^= idx << 2;
- if (!nl80211_addr_in_use(drv->global, new_addr))
- break;
-@@ -5996,6 +5996,7 @@ static int wpa_driver_nl80211_if_add(voi
- os_free(new_bss);
- return -1;
- }
-+ memcpy(new_bss->addr, addr ? addr : if_addr, ETH_ALEN);
- os_strlcpy(new_bss->ifname, ifname, IFNAMSIZ);
- new_bss->ifindex = ifidx;
- new_bss->drv = drv;
+++ /dev/null
---- a/hostapd/config_file.c
-+++ b/hostapd/config_file.c
-@@ -1920,6 +1920,10 @@ struct hostapd_config * hostapd_config_r
- "ht_capab", line);
- errors++;
- }
-+ } else if (os_strcmp(buf, "dynamic_ht40") == 0) {
-+ conf->dynamic_ht40 = atoi(pos);
-+ if (conf->dynamic_ht40 == 1)
-+ conf->dynamic_ht40 = 1500;
- } else if (os_strcmp(buf, "require_ht") == 0) {
- conf->require_ht = atoi(pos);
- #endif /* CONFIG_IEEE80211N */
---- a/src/ap/ap_config.h
-+++ b/src/ap/ap_config.h
-@@ -395,6 +395,7 @@ struct hostapd_config {
- int ieee80211n;
- int secondary_channel;
- int require_ht;
-+ int dynamic_ht40;
- };
-
-
---- a/src/ap/hostapd.c
-+++ b/src/ap/hostapd.c
-@@ -27,6 +27,7 @@
- #include "beacon.h"
- #include "iapp.h"
- #include "ieee802_1x.h"
-+#include "ieee802_11.h"
- #include "ieee802_11_auth.h"
- #include "vlan_init.h"
- #include "wpa_auth.h"
-@@ -285,6 +286,7 @@ static void hostapd_cleanup_iface_pre(st
- */
- static void hostapd_cleanup_iface(struct hostapd_iface *iface)
- {
-+ hostapd_deinit_ht(iface);
- hostapd_free_hw_features(iface->hw_features, iface->num_hw_features);
- iface->hw_features = NULL;
- os_free(iface->current_rates);
---- a/src/ap/hostapd.h
-+++ b/src/ap/hostapd.h
-@@ -220,6 +220,9 @@ struct hostapd_iface {
- /* Overlapping BSS information */
- int olbc_ht;
-
-+ int force_20mhz;
-+ struct os_time last_20mhz_trigger;
-+
- u16 ht_op_mode;
- void (*scan_cb)(struct hostapd_iface *iface);
-
---- a/src/ap/ieee802_11.c
-+++ b/src/ap/ieee802_11.c
-@@ -1242,6 +1242,9 @@ static void handle_beacon(struct hostapd
- sizeof(mgmt->u.beacon)), &elems,
- 0);
-
-+ if (!elems.ht_capabilities)
-+ hostapd_trigger_20mhz(hapd->iface);
-+
- ap_list_process_beacon(hapd->iface, mgmt, &elems, fi);
- }
-
---- a/src/ap/ieee802_11.h
-+++ b/src/ap/ieee802_11.h
-@@ -65,4 +65,17 @@ void hostapd_tx_status(struct hostapd_da
- void ieee802_11_rx_from_unknown(struct hostapd_data *hapd, const u8 *src,
- int wds);
-
-+#ifdef CONFIG_IEEE80211N
-+void hostapd_trigger_20mhz(struct hostapd_iface *iface);
-+void hostapd_deinit_ht(struct hostapd_iface *iface);
-+
-+#else
-+static inline void hostapd_deinit_ht(struct hostapd_iface *iface)
-+{
-+}
-+static inline void hostapd_trigger_20mhz(struct hostapd_iface *iface)
-+{
-+}
-+#endif /* CONFIG_IEEE80211N */
-+
- #endif /* IEEE802_11_H */
---- a/src/ap/ieee802_11_ht.c
-+++ b/src/ap/ieee802_11_ht.c
-@@ -20,9 +20,11 @@
- #include "drivers/driver.h"
- #include "hostapd.h"
- #include "ap_config.h"
-+#include "ap_drv_ops.h"
- #include "sta_info.h"
- #include "beacon.h"
- #include "ieee802_11.h"
-+#include "utils/eloop.h"
-
-
- u8 * hostapd_eid_ht_capabilities(struct hostapd_data *hapd, u8 *eid)
-@@ -70,12 +72,15 @@ u8 * hostapd_eid_ht_operation(struct hos
-
- oper->control_chan = hapd->iconf->channel;
- oper->operation_mode = host_to_le16(hapd->iface->ht_op_mode);
-- if (hapd->iconf->secondary_channel == 1)
-- oper->ht_param |= HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE |
-- HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH;
-- if (hapd->iconf->secondary_channel == -1)
-- oper->ht_param |= HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW |
-- HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH;
-+
-+ if (!hapd->iface->force_20mhz) {
-+ if (hapd->iconf->secondary_channel == 1)
-+ oper->ht_param |= HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE |
-+ HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH;
-+ if (hapd->iconf->secondary_channel == -1)
-+ oper->ht_param |= HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW |
-+ HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH;
-+ }
-
- pos += sizeof(*oper);
-
-@@ -265,3 +270,80 @@ void hostapd_get_ht_capab(struct hostapd
-
- neg_ht_cap->ht_capabilities_info = host_to_le16(cap);
- }
-+
-+static void hostapd_set_force_20mhz(struct hostapd_iface *iface);
-+
-+static void hostapd_restore_40mhz(void *eloop_data, void *user_ctx)
-+{
-+ struct hostapd_iface *iface = eloop_data;
-+ struct os_time time;
-+ int timeout;
-+
-+ if (!iface->last_20mhz_trigger.sec)
-+ return;
-+
-+ os_get_time(&time);
-+ timeout = iface->last_20mhz_trigger.sec + iface->conf->dynamic_ht40 -
-+ time.sec;
-+
-+ if (timeout > 0) {
-+ eloop_register_timeout(timeout, 0, hostapd_restore_40mhz,
-+ iface, NULL);
-+ return;
-+ }
-+
-+ iface->last_20mhz_trigger.sec = 0;
-+ iface->last_20mhz_trigger.usec = 0;
-+
-+ iface->force_20mhz = 0;
-+ hostapd_set_force_20mhz(iface);
-+}
-+
-+static void hostapd_set_force_20mhz(struct hostapd_iface *iface)
-+{
-+ int secondary_channel;
-+ int i;
-+
-+ ieee802_11_set_beacons(iface);
-+
-+ for (i = 0; i < iface->num_bss; i++) {
-+ struct hostapd_data *hapd = iface->bss[i];
-+
-+ if (iface->force_20mhz)
-+ secondary_channel = 0;
-+ else
-+ secondary_channel = hapd->iconf->secondary_channel;
-+
-+ if (hostapd_set_freq(hapd, hapd->iconf->hw_mode, iface->freq,
-+ hapd->iconf->channel,
-+ hapd->iconf->ieee80211n,
-+ secondary_channel)) {
-+ wpa_printf(MSG_ERROR, "Could not set channel for "
-+ "kernel driver");
-+ }
-+ }
-+}
-+
-+void hostapd_deinit_ht(struct hostapd_iface *iface)
-+{
-+ eloop_cancel_timeout(hostapd_restore_40mhz, iface, NULL);
-+}
-+
-+void hostapd_trigger_20mhz(struct hostapd_iface *iface)
-+{
-+ if (!iface->conf->dynamic_ht40)
-+ return;
-+
-+ if (!iface->force_20mhz) {
-+ iface->force_20mhz = 1;
-+ hostapd_set_force_20mhz(iface);
-+ }
-+
-+ if (!iface->last_20mhz_trigger.sec) {
-+ eloop_cancel_timeout(hostapd_restore_40mhz, iface, NULL);
-+ eloop_register_timeout(iface->conf->dynamic_ht40, 0,
-+ hostapd_restore_40mhz, iface, NULL);
-+ }
-+
-+ os_get_time(&iface->last_20mhz_trigger);
-+}