# wpa_supplicant config
config WPA_SUPPLICANT_NO_TIMESTAMP_CHECK
bool "Disable timestamp check"
- depends on PACKAGE_wpa-supplicant || PACKAGE_wpa-supplicant-mesh || PACKAGE_wpa-supplicant-mini || PACKAGE_wpad || PACKAGE_wpad-mini || PACAKGE_wpad-mesh
+ depends on PACKAGE_wpa-supplicant || PACKAGE_wpa-supplicant-mesh || PACKAGE_wpa-supplicant-mini || PACKAGE_wpad || PACKAGE_wpad-mini || PACKAGE_wpad-mesh
default n
help
This disables the timestamp check for certificates in wpa_supplicant
choice
prompt "Choose TLS provider"
default WPA_SUPPLICANT_INTERNAL
- depends on PACKAGE_wpa-supplicant || PACKAGE_wpad
+ depends on PACKAGE_wpa-supplicant || PACKAGE_wpad || PACKAGE_wpad-mesh
config WPA_SUPPLICANT_INTERNAL
bool "internal"
+ depends on PACKAGE_wpa-supplicant || PACKAGE_wpad
config WPA_SUPPLICANT_OPENSSL
bool "openssl"
select PACKAGE_libopenssl
+config WPA_SUPPLICANT_WOLFSSL
+ bool "wolfssl"
+ select PACKAGE_libwolfssl
+ select WOLFSSL_HAS_AES_CCM
+ select WOLFSSL_HAS_AES_GCM
+ select WOLFSSL_HAS_ARC4
+ select WOLFSSL_HAS_DES3
+ select WOLFSSL_HAS_DH
+ select WOLFSSL_HAS_ECC
+ select WOLFSSL_HAS_OCSP
+ select WOLFSSL_HAS_PSK
+ select WOLFSSL_HAS_SESSION_TICKET
+ select WOLFSSL_HAS_WPAS
+
endchoice
config WPA_RFKILL_SUPPORT
include $(TOPDIR)/rules.mk
PKG_NAME:=hostapd
-PKG_RELEASE:=5
+PKG_RELEASE:=1
PKG_SOURCE_URL:=http://w1.fi/hostap.git
PKG_SOURCE_PROTO:=git
-PKG_SOURCE_DATE:=2018-04-09
-PKG_SOURCE_VERSION:=fa617ee6a0b2d39e6372c93ef9437caa3bd9065a
-PKG_MIRROR_HASH:=5e6f20153c3405ac905f89fea8a614a57e9ba19583b2de2777179381a74aa7b1
+PKG_SOURCE_DATE:=2018-05-21
+PKG_SOURCE_VERSION:=62566bc23d041e88f8e35933d5fd8c2fd0f7cf2a
+PKG_MIRROR_HASH:=f234b24f9471ae9cb34460feec6d6614641691544101535673595272c91448eb
PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
PKG_LICENSE:=BSD-3-Clause
ifeq ($(LOCAL_VARIANT),full)
PKG_CONFIG_DEPENDS += \
CONFIG_WPA_SUPPLICANT_INTERNAL \
- CONFIG_WPA_SUPPLICANT_OPENSSL
+ CONFIG_WPA_SUPPLICANT_OPENSSL \
+ CONFIG_WPA_SUPPLICANT_WOLFSSL
+ endif
+ ifeq ($(LOCAL_VARIANT),mesh)
+ PKG_CONFIG_DEPENDS += \
+ CONFIG_WPA_SUPPLICANT_OPENSSL \
+ CONFIG_WPA_SUPPLICANT_WOLFSSL
endif
endif
TARGET_LDFLAGS += -lcrypto -lssl
endif
endif
+ ifdef CONFIG_WPA_SUPPLICANT_WOLFSSL
+ ifeq ($(LOCAL_VARIANT),full)
+ DRIVER_MAKEOPTS += CONFIG_TLS=wolfssl CONFIG_WPS_NFC=1
+ TARGET_LDFLAGS += -lwolfssl
+ endif
+ endif
+
ifeq ($(LOCAL_VARIANT),mesh)
- DRIVER_MAKEOPTS += CONFIG_TLS=openssl CONFIG_AP=y CONFIG_SAE=y CONFIG_MESH=y
- TARGET_LDFLAGS += -lcrypto -lssl
+ ifndef CONFIG_WPA_SUPPLICANT_WOLFSSL
+ DRIVER_MAKEOPTS += CONFIG_TLS=openssl CONFIG_AP=y CONFIG_SAE=y CONFIG_MESH=y
+ TARGET_LDFLAGS += -lcrypto -lssl
+ else
+ DRIVER_MAKEOPTS += CONFIG_TLS=wolfssl CONFIG_WPS_NFC=1 CONFIG_AP=y CONFIG_SAE=y CONFIG_MESH=y
+ TARGET_LDFLAGS += -lwolfssl
+ endif
endif
+
ifdef CONFIG_WPA_SUPPLICANT_NO_TIMESTAMP_CHECK
TARGET_CFLAGS += -DNO_TIMESTAMP_CHECK
endif
define Package/wpad
$(call Package/wpad/Default)
TITLE+= (full)
- DEPENDS+=+WPA_SUPPLICANT_OPENSSL:libopenssl
+ DEPENDS+=+WPA_SUPPLICANT_OPENSSL:libopenssl +WPA_SUPPLICANT_WOLFSSL:libwolfssl
VARIANT:=wpad-full
endef
define Package/wpad-mesh
$(call Package/wpad/Default)
TITLE+= (with 802.11s mesh and SAE support)
- DEPENDS:=$(DRV_DEPENDS) +libubus +PACKAGE_wpad-mesh:libopenssl @PACKAGE_kmod-cfg80211 @(!TARGET_uml||BROKEN)
+ DEPENDS:=$(DRV_DEPENDS) +libubus +WPA_SUPPLICANT_OPENSSL:libopenssl +WPA_SUPPLICANT_INTERNAL:libopenssl +WPA_SUPPLICANT_WOLFSSL:libwolfssl @PACKAGE_kmod-cfg80211 @(!TARGET_uml||BROKEN)
VARIANT:=wpad-mesh
endef
CATEGORY:=Network
TITLE:=WPA Supplicant
URL:=http://hostap.epitest.fi/wpa_supplicant/
- DEPENDS:=$(DRV_DEPENDS) +WPA_SUPPLICANT_OPENSSL:libopenssl
+ DEPENDS:=$(DRV_DEPENDS) +WPA_SUPPLICANT_OPENSSL:libopenssl +WPA_SUPPLICANT_WOLFSSL:libwolfssl
CONFLICTS:=wpad wpad-mini wpad-mesh
VARIANT:=supplicant-full
endef
define Package/wpa-supplicant-mesh
$(Package/wpa-supplicant)
TITLE:=WPA Supplicant (with 802.11s and SAE)
- DEPENDS:=$(DRV_DEPENDS) +PACKAGE_wpa-supplicant-mesh:libopenssl @PACKAGE_kmod-cfg80211 @(!TARGET_uml||BROKEN)
+ DEPENDS:=$(DRV_DEPENDS) +WPA_SUPPLICANT_OPENSSL:libopenssl +WPA_SUPPLICANT_INTERNAL:libopenssl +WPA_SUPPLICANT_WOLFSSL:libwolfssl @PACKAGE_kmod-cfg80211 @(!TARGET_uml||BROKEN)
CONFLICTS:=wpad wpad-mesh wpad-mesh
VARIANT:=supplicant-mesh
endef
SECTION:=net
CATEGORY:=Network
VARIANT:=supplicant-full
- DEPENDS:=$(DRV_DEPENDS) +WPA_SUPPLICANT_OPENSSL:libopenssl
+ DEPENDS:=$(DRV_DEPENDS) +WPA_SUPPLICANT_OPENSSL:libopenssl +WPA_SUPPLICANT_WOLFSSL:libwolfssl
endef
}
[[ "$_w_mode" = "mesh" ]] && {
- json_get_vars mesh_id mesh_fwding
+ json_get_vars mesh_id mesh_fwding mesh_rssi_threshold
[ -n "$mesh_id" ] && ssid="${mesh_id}"
append network_data "mode=5" "$N$T"
[ -n "$mesh_fwding" ] && append network_data "mesh_fwding=${mesh_fwding}" "$N$T"
+ [ -n "$mesh_rssi_threshold" ] && append network_data "mesh_rssi_threshold=${mesh_rssi_threshold}" "$N$T"
[ -n "$freq" ] && wpa_supplicant_set_fixed_freq "$freq" "$htmode"
[ "$noscan" = "1" ] && append network_data "noscan=1" "$N$T"
append wpa_key_mgmt "SAE"
--- /dev/null
+From 8a6a7112e5b1391018531f6b6c317f8870e0fcb6 Mon Sep 17 00:00:00 2001
+From: Daniel Golle <daniel@makrotopia.org>
+Date: Thu, 3 May 2018 13:12:28 +0200
+Subject: [PATCH 1/2] Revert "wpa_supplicant: Increase authentication timeout
+ if CAC is started"
+
+This reverts commit 37547ad63c9df61ce6899675028594da2527efef.
+---
+ wpa_supplicant/events.c | 95 ++++---------------------------
+ wpa_supplicant/wpa_supplicant.c | 20 -------
+ wpa_supplicant/wpa_supplicant_i.h | 3 -
+ 3 files changed, 10 insertions(+), 108 deletions(-)
+
+--- a/wpa_supplicant/events.c
++++ b/wpa_supplicant/events.c
+@@ -3776,81 +3776,6 @@ static void wpa_supplicant_event_port_au
+ }
+
+
+-static unsigned int wpas_event_cac_ms(const struct wpa_supplicant *wpa_s,
+- int freq)
+-{
+- size_t i;
+- int j;
+-
+- for (i = 0; i < wpa_s->hw.num_modes; i++) {
+- const struct hostapd_hw_modes *mode = &wpa_s->hw.modes[i];
+-
+- for (j = 0; j < mode->num_channels; j++) {
+- const struct hostapd_channel_data *chan;
+-
+- chan = &mode->channels[j];
+- if (chan->freq == freq)
+- return chan->dfs_cac_ms;
+- }
+- }
+-
+- return 0;
+-}
+-
+-
+-static void wpas_event_dfs_cac_started(struct wpa_supplicant *wpa_s,
+- struct dfs_event *radar)
+-{
+-#if defined(NEED_AP_MLME) && defined(CONFIG_AP)
+- if (wpa_s->ap_iface) {
+- wpas_ap_event_dfs_cac_started(wpa_s, radar);
+- } else
+-#endif /* NEED_AP_MLME && CONFIG_AP */
+- {
+- unsigned int cac_time = wpas_event_cac_ms(wpa_s, radar->freq);
+-
+- cac_time /= 1000; /* convert from ms to sec */
+- if (!cac_time)
+- cac_time = 10 * 60; /* max timeout: 10 minutes */
+-
+- /* Restart auth timeout: CAC time added to initial timeout */
+- wpas_auth_timeout_restart(wpa_s, cac_time);
+- }
+-}
+-
+-
+-static void wpas_event_dfs_cac_finished(struct wpa_supplicant *wpa_s,
+- struct dfs_event *radar)
+-{
+-#if defined(NEED_AP_MLME) && defined(CONFIG_AP)
+- if (wpa_s->ap_iface) {
+- wpas_ap_event_dfs_cac_finished(wpa_s, radar);
+- } else
+-#endif /* NEED_AP_MLME && CONFIG_AP */
+- {
+- /* Restart auth timeout with original value after CAC is
+- * finished */
+- wpas_auth_timeout_restart(wpa_s, 0);
+- }
+-}
+-
+-
+-static void wpas_event_dfs_cac_aborted(struct wpa_supplicant *wpa_s,
+- struct dfs_event *radar)
+-{
+-#if defined(NEED_AP_MLME) && defined(CONFIG_AP)
+- if (wpa_s->ap_iface) {
+- wpas_ap_event_dfs_cac_aborted(wpa_s, radar);
+- } else
+-#endif /* NEED_AP_MLME && CONFIG_AP */
+- {
+- /* Restart auth timeout with original value after CAC is
+- * aborted */
+- wpas_auth_timeout_restart(wpa_s, 0);
+- }
+-}
+-
+-
+ static void wpa_supplicant_event_assoc_auth(struct wpa_supplicant *wpa_s,
+ union wpa_event_data *data)
+ {
+@@ -4298,25 +4223,25 @@ void wpa_supplicant_event(void *ctx, enu
+ wpas_ap_event_dfs_radar_detected(wpa_s,
+ &data->dfs_event);
+ break;
+- case EVENT_DFS_NOP_FINISHED:
+- if (data)
+- wpas_ap_event_dfs_cac_nop_finished(wpa_s,
+- &data->dfs_event);
+- break;
+-#endif /* NEED_AP_MLME */
+-#endif /* CONFIG_AP */
+ case EVENT_DFS_CAC_STARTED:
+ if (data)
+- wpas_event_dfs_cac_started(wpa_s, &data->dfs_event);
++ wpas_ap_event_dfs_cac_started(wpa_s, &data->dfs_event);
+ break;
+ case EVENT_DFS_CAC_FINISHED:
+ if (data)
+- wpas_event_dfs_cac_finished(wpa_s, &data->dfs_event);
++ wpas_ap_event_dfs_cac_finished(wpa_s, &data->dfs_event);
+ break;
+ case EVENT_DFS_CAC_ABORTED:
+ if (data)
+- wpas_event_dfs_cac_aborted(wpa_s, &data->dfs_event);
++ wpas_ap_event_dfs_cac_aborted(wpa_s, &data->dfs_event);
++ break;
++ case EVENT_DFS_NOP_FINISHED:
++ if (data)
++ wpas_ap_event_dfs_cac_nop_finished(wpa_s,
++ &data->dfs_event);
+ break;
++#endif /* NEED_AP_MLME */
++#endif /* CONFIG_AP */
+ case EVENT_RX_MGMT: {
+ u16 fc, stype;
+ const struct ieee80211_mgmt *mgmt;
+--- a/wpa_supplicant/wpa_supplicant.c
++++ b/wpa_supplicant/wpa_supplicant.c
+@@ -243,30 +243,10 @@ void wpa_supplicant_req_auth_timeout(str
+ wpa_dbg(wpa_s, MSG_DEBUG, "Setting authentication timeout: %d sec "
+ "%d usec", sec, usec);
+ eloop_cancel_timeout(wpa_supplicant_timeout, wpa_s, NULL);
+- wpa_s->last_auth_timeout_sec = sec;
+ eloop_register_timeout(sec, usec, wpa_supplicant_timeout, wpa_s, NULL);
+ }
+
+
+-/*
+- * wpas_auth_timeout_restart - Restart and change timeout for authentication
+- * @wpa_s: Pointer to wpa_supplicant data
+- * @sec_diff: difference in seconds applied to original timeout value
+- */
+-void wpas_auth_timeout_restart(struct wpa_supplicant *wpa_s, int sec_diff)
+-{
+- int new_sec = wpa_s->last_auth_timeout_sec + sec_diff;
+-
+- if (eloop_is_timeout_registered(wpa_supplicant_timeout, wpa_s, NULL)) {
+- wpa_dbg(wpa_s, MSG_DEBUG,
+- "Authentication timeout restart: %d sec", new_sec);
+- eloop_cancel_timeout(wpa_supplicant_timeout, wpa_s, NULL);
+- eloop_register_timeout(new_sec, 0, wpa_supplicant_timeout,
+- wpa_s, NULL);
+- }
+-}
+-
+-
+ /**
+ * wpa_supplicant_cancel_auth_timeout - Cancel authentication timeout
+ * @wpa_s: Pointer to wpa_supplicant data
+--- a/wpa_supplicant/wpa_supplicant_i.h
++++ b/wpa_supplicant/wpa_supplicant_i.h
+@@ -1182,8 +1182,6 @@ struct wpa_supplicant {
+ /* RIC elements for FT protocol */
+ struct wpabuf *ric_ies;
+
+- int last_auth_timeout_sec;
+-
+ #ifdef CONFIG_DPP
+ struct dl_list dpp_bootstrap; /* struct dpp_bootstrap_info */
+ struct dl_list dpp_configurator; /* struct dpp_configurator */
+@@ -1258,7 +1256,6 @@ void wpa_supplicant_initiate_eapol(struc
+ void wpa_clear_keys(struct wpa_supplicant *wpa_s, const u8 *addr);
+ void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s,
+ int sec, int usec);
+-void wpas_auth_timeout_restart(struct wpa_supplicant *wpa_s, int sec_diff);
+ void wpa_supplicant_reinit_autoscan(struct wpa_supplicant *wpa_s);
+ void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s,
+ enum wpa_states state);
--- /dev/null
+From 0d4900ccd1c7ec5c5ffecf5040f9c07a6a32deef Mon Sep 17 00:00:00 2001
+From: Daniel Golle <daniel@makrotopia.org>
+Date: Thu, 3 May 2018 13:12:35 +0200
+Subject: [PATCH 2/2] Revert "wpa_supplicant: Rename wpas_event_*() to
+ wpas_ap_event_*()"
+
+This reverts commit 2dd5fbbff884af488870a37e339b4817c83954de.
+---
+ wpa_supplicant/ap.c | 20 ++++++++++----------
+ wpa_supplicant/ap.h | 18 +++++++++---------
+ wpa_supplicant/events.c | 13 ++++++-------
+ 3 files changed, 25 insertions(+), 26 deletions(-)
+
+--- a/wpa_supplicant/ap.c
++++ b/wpa_supplicant/ap.c
+@@ -1537,8 +1537,8 @@ int wpas_ap_pmksa_cache_add_external(str
+
+
+ #ifdef NEED_AP_MLME
+-void wpas_ap_event_dfs_radar_detected(struct wpa_supplicant *wpa_s,
+- struct dfs_event *radar)
++void wpas_event_dfs_radar_detected(struct wpa_supplicant *wpa_s,
++ struct dfs_event *radar)
+ {
+ if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0])
+ return;
+@@ -1550,8 +1550,8 @@ void wpas_ap_event_dfs_radar_detected(st
+ }
+
+
+-void wpas_ap_event_dfs_cac_started(struct wpa_supplicant *wpa_s,
+- struct dfs_event *radar)
++void wpas_event_dfs_cac_started(struct wpa_supplicant *wpa_s,
++ struct dfs_event *radar)
+ {
+ if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0])
+ return;
+@@ -1562,8 +1562,8 @@ void wpas_ap_event_dfs_cac_started(struc
+ }
+
+
+-void wpas_ap_event_dfs_cac_finished(struct wpa_supplicant *wpa_s,
+- struct dfs_event *radar)
++void wpas_event_dfs_cac_finished(struct wpa_supplicant *wpa_s,
++ struct dfs_event *radar)
+ {
+ if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0])
+ return;
+@@ -1574,8 +1574,8 @@ void wpas_ap_event_dfs_cac_finished(stru
+ }
+
+
+-void wpas_ap_event_dfs_cac_aborted(struct wpa_supplicant *wpa_s,
+- struct dfs_event *radar)
++void wpas_event_dfs_cac_aborted(struct wpa_supplicant *wpa_s,
++ struct dfs_event *radar)
+ {
+ if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0])
+ return;
+@@ -1586,8 +1586,8 @@ void wpas_ap_event_dfs_cac_aborted(struc
+ }
+
+
+-void wpas_ap_event_dfs_cac_nop_finished(struct wpa_supplicant *wpa_s,
+- struct dfs_event *radar)
++void wpas_event_dfs_cac_nop_finished(struct wpa_supplicant *wpa_s,
++ struct dfs_event *radar)
+ {
+ if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0])
+ return;
+--- a/wpa_supplicant/ap.h
++++ b/wpa_supplicant/ap.h
+@@ -89,16 +89,16 @@ int wpas_ap_pmksa_cache_list_mesh(struct
+ char *buf, size_t len);
+ int wpas_ap_pmksa_cache_add_external(struct wpa_supplicant *wpa_s, char *cmd);
+
+-void wpas_ap_event_dfs_radar_detected(struct wpa_supplicant *wpa_s,
+- struct dfs_event *radar);
+-void wpas_ap_event_dfs_cac_started(struct wpa_supplicant *wpa_s,
++void wpas_event_dfs_radar_detected(struct wpa_supplicant *wpa_s,
+ struct dfs_event *radar);
+-void wpas_ap_event_dfs_cac_finished(struct wpa_supplicant *wpa_s,
+- struct dfs_event *radar);
+-void wpas_ap_event_dfs_cac_aborted(struct wpa_supplicant *wpa_s,
+- struct dfs_event *radar);
+-void wpas_ap_event_dfs_cac_nop_finished(struct wpa_supplicant *wpa_s,
+- struct dfs_event *radar);
++void wpas_event_dfs_cac_started(struct wpa_supplicant *wpa_s,
++ struct dfs_event *radar);
++void wpas_event_dfs_cac_finished(struct wpa_supplicant *wpa_s,
++ struct dfs_event *radar);
++void wpas_event_dfs_cac_aborted(struct wpa_supplicant *wpa_s,
++ struct dfs_event *radar);
++void wpas_event_dfs_cac_nop_finished(struct wpa_supplicant *wpa_s,
++ struct dfs_event *radar);
+
+ void ap_periodic(struct wpa_supplicant *wpa_s);
+
+--- a/wpa_supplicant/events.c
++++ b/wpa_supplicant/events.c
+@@ -4220,25 +4220,24 @@ void wpa_supplicant_event(void *ctx, enu
+ #ifdef NEED_AP_MLME
+ case EVENT_DFS_RADAR_DETECTED:
+ if (data)
+- wpas_ap_event_dfs_radar_detected(wpa_s,
+- &data->dfs_event);
++ wpas_event_dfs_radar_detected(wpa_s, &data->dfs_event);
+ break;
+ case EVENT_DFS_CAC_STARTED:
+ if (data)
+- wpas_ap_event_dfs_cac_started(wpa_s, &data->dfs_event);
++ wpas_event_dfs_cac_started(wpa_s, &data->dfs_event);
+ break;
+ case EVENT_DFS_CAC_FINISHED:
+ if (data)
+- wpas_ap_event_dfs_cac_finished(wpa_s, &data->dfs_event);
++ wpas_event_dfs_cac_finished(wpa_s, &data->dfs_event);
+ break;
+ case EVENT_DFS_CAC_ABORTED:
+ if (data)
+- wpas_ap_event_dfs_cac_aborted(wpa_s, &data->dfs_event);
++ wpas_event_dfs_cac_aborted(wpa_s, &data->dfs_event);
+ break;
+ case EVENT_DFS_NOP_FINISHED:
+ if (data)
+- wpas_ap_event_dfs_cac_nop_finished(wpa_s,
+- &data->dfs_event);
++ wpas_event_dfs_cac_nop_finished(wpa_s,
++ &data->dfs_event);
+ break;
+ #endif /* NEED_AP_MLME */
+ #endif /* CONFIG_AP */
--- /dev/null
+From 032e70833de4b251fc4a159b2cc4ef28d0f1df0d Mon Sep 17 00:00:00 2001
+From: Peter Oh <peter.oh@bowerswilkins.com>
+Date: Tue, 17 Apr 2018 21:54:58 -0700
+Subject: [PATCH 01/16] mesh: factor out mesh join function
+
+mesh join function consitss of 2 parts which are preparing
+configurations and sending join event to driver.
+Since physical mesh join event could happen either right
+after mesh configuration is done or after CAC is done
+in case of DFS channel is used, factor out the function
+into 2 parts to reduce redundant calls.
+
+Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
+---
+ wpa_supplicant/mesh.c | 119 ++++++++++++++++--------------
+ wpa_supplicant/mesh.h | 1 +
+ wpa_supplicant/wpa_supplicant_i.h | 1 +
+ 3 files changed, 67 insertions(+), 54 deletions(-)
+
+--- a/wpa_supplicant/mesh.c
++++ b/wpa_supplicant/mesh.c
+@@ -363,13 +363,48 @@ void wpa_supplicant_mesh_add_scan_ie(str
+ }
+
+
++void wpas_join_mesh(struct wpa_supplicant *wpa_s)
++{
++ struct wpa_driver_mesh_join_params *params = wpa_s->mesh_params;
++ struct wpa_ssid *ssid = wpa_s->current_ssid;
++ int ret = 0;
++
++ if (ssid->key_mgmt & WPA_KEY_MGMT_SAE) {
++ wpa_s->pairwise_cipher = wpa_s->mesh_rsn->pairwise_cipher;
++ wpa_s->group_cipher = wpa_s->mesh_rsn->group_cipher;
++ wpa_s->mgmt_group_cipher = wpa_s->mesh_rsn->mgmt_group_cipher;
++ }
++
++ if (wpa_s->ifmsh) {
++ params->ies = wpa_s->ifmsh->mconf->rsn_ie;
++ params->ie_len = wpa_s->ifmsh->mconf->rsn_ie_len;
++ params->basic_rates = wpa_s->ifmsh->basic_rates;
++ params->conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_HT_OP_MODE;
++ params->conf.ht_opmode = wpa_s->ifmsh->bss[0]->iface->ht_op_mode;
++ }
++
++ ret = wpa_drv_join_mesh(wpa_s, params);
++ if (ret)
++ wpa_msg(wpa_s, MSG_ERROR, "mesh join error=%d\n", ret);
++
++ /* hostapd sets the interface down until we associate */
++ wpa_drv_set_operstate(wpa_s, 1);
++
++ if (!ret)
++ wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
++
++ return;
++}
++
++
+ int wpa_supplicant_join_mesh(struct wpa_supplicant *wpa_s,
+ struct wpa_ssid *ssid)
+ {
+- struct wpa_driver_mesh_join_params params;
++ struct wpa_driver_mesh_join_params *params =
++ os_zalloc(sizeof(struct wpa_driver_mesh_join_params));
+ int ret = 0;
+
+- if (!ssid || !ssid->ssid || !ssid->ssid_len || !ssid->frequency) {
++ if (!ssid || !ssid->ssid || !ssid->ssid_len || !ssid->frequency || !params) {
+ ret = -ENOENT;
+ goto out;
+ }
+@@ -380,22 +415,22 @@ int wpa_supplicant_join_mesh(struct wpa_
+ wpa_s->group_cipher = WPA_CIPHER_NONE;
+ wpa_s->mgmt_group_cipher = 0;
+
+- os_memset(¶ms, 0, sizeof(params));
+- params.meshid = ssid->ssid;
+- params.meshid_len = ssid->ssid_len;
+- ibss_mesh_setup_freq(wpa_s, ssid, ¶ms.freq);
+- wpa_s->mesh_ht_enabled = !!params.freq.ht_enabled;
+- wpa_s->mesh_vht_enabled = !!params.freq.vht_enabled;
+- if (params.freq.ht_enabled && params.freq.sec_channel_offset)
+- ssid->ht40 = params.freq.sec_channel_offset;
++ params->meshid = ssid->ssid;
++ params->meshid_len = ssid->ssid_len;
++ ibss_mesh_setup_freq(wpa_s, ssid, ¶ms->freq);
++ wpa_s->mesh_ht_enabled = !!params->freq.ht_enabled;
++ wpa_s->mesh_vht_enabled = !!params->freq.vht_enabled;
++ if (params->freq.ht_enabled && params->freq.sec_channel_offset)
++ ssid->ht40 = params->freq.sec_channel_offset;
++
+ if (wpa_s->mesh_vht_enabled) {
+ ssid->vht = 1;
+- switch (params.freq.bandwidth) {
++ switch (params->freq.bandwidth) {
+ case 80:
+- if (params.freq.center_freq2) {
++ if (params->freq.center_freq2) {
+ ssid->max_oper_chwidth = VHT_CHANWIDTH_80P80MHZ;
+ ssid->vht_center_freq2 =
+- params.freq.center_freq2;
++ params->freq.center_freq2;
+ } else {
+ ssid->max_oper_chwidth = VHT_CHANWIDTH_80MHZ;
+ }
+@@ -409,67 +444,43 @@ int wpa_supplicant_join_mesh(struct wpa_
+ }
+ }
+ if (ssid->beacon_int > 0)
+- params.beacon_int = ssid->beacon_int;
++ params->beacon_int = ssid->beacon_int;
+ else if (wpa_s->conf->beacon_int > 0)
+- params.beacon_int = wpa_s->conf->beacon_int;
++ params->beacon_int = wpa_s->conf->beacon_int;
+ if (ssid->dtim_period > 0)
+- params.dtim_period = ssid->dtim_period;
++ params->dtim_period = ssid->dtim_period;
+ else if (wpa_s->conf->dtim_period > 0)
+- params.dtim_period = wpa_s->conf->dtim_period;
+- params.conf.max_peer_links = wpa_s->conf->max_peer_links;
++ params->dtim_period = wpa_s->conf->dtim_period;
++ params->conf.max_peer_links = wpa_s->conf->max_peer_links;
+ if (ssid->mesh_rssi_threshold < DEFAULT_MESH_RSSI_THRESHOLD) {
+- params.conf.rssi_threshold = ssid->mesh_rssi_threshold;
+- params.conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_RSSI_THRESHOLD;
++ params->conf.rssi_threshold = ssid->mesh_rssi_threshold;
++ params->conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_RSSI_THRESHOLD;
+ }
+
+ if (ssid->key_mgmt & WPA_KEY_MGMT_SAE) {
+- params.flags |= WPA_DRIVER_MESH_FLAG_SAE_AUTH;
+- params.flags |= WPA_DRIVER_MESH_FLAG_AMPE;
++ params->flags |= WPA_DRIVER_MESH_FLAG_SAE_AUTH;
++ params->flags |= WPA_DRIVER_MESH_FLAG_AMPE;
+ wpa_s->conf->user_mpm = 1;
+ }
+
+ if (wpa_s->conf->user_mpm) {
+- params.flags |= WPA_DRIVER_MESH_FLAG_USER_MPM;
+- params.conf.auto_plinks = 0;
++ params->flags |= WPA_DRIVER_MESH_FLAG_USER_MPM;
++ params->conf.auto_plinks = 0;
+ } else {
+- params.flags |= WPA_DRIVER_MESH_FLAG_DRIVER_MPM;
+- params.conf.auto_plinks = 1;
++ params->flags |= WPA_DRIVER_MESH_FLAG_DRIVER_MPM;
++ params->conf.auto_plinks = 1;
+ }
+- params.conf.peer_link_timeout = wpa_s->conf->mesh_max_inactivity;
++ params->conf.peer_link_timeout = wpa_s->conf->mesh_max_inactivity;
+
+- if (wpa_supplicant_mesh_init(wpa_s, ssid, ¶ms.freq)) {
++ wpa_s->mesh_params = params;
++ if (wpa_supplicant_mesh_init(wpa_s, ssid, ¶ms->freq)) {
+ wpa_msg(wpa_s, MSG_ERROR, "Failed to init mesh");
+ wpa_drv_leave_mesh(wpa_s);
+ ret = -1;
+ goto out;
+ }
+
+- if (ssid->key_mgmt & WPA_KEY_MGMT_SAE) {
+- wpa_s->pairwise_cipher = wpa_s->mesh_rsn->pairwise_cipher;
+- wpa_s->group_cipher = wpa_s->mesh_rsn->group_cipher;
+- wpa_s->mgmt_group_cipher = wpa_s->mesh_rsn->mgmt_group_cipher;
+- }
+-
+- if (wpa_s->ifmsh) {
+- params.ies = wpa_s->ifmsh->mconf->rsn_ie;
+- params.ie_len = wpa_s->ifmsh->mconf->rsn_ie_len;
+- params.basic_rates = wpa_s->ifmsh->basic_rates;
+- params.conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_HT_OP_MODE;
+- params.conf.ht_opmode = wpa_s->ifmsh->bss[0]->iface->ht_op_mode;
+- }
+-
+- wpa_msg(wpa_s, MSG_INFO, "joining mesh %s",
+- wpa_ssid_txt(ssid->ssid, ssid->ssid_len));
+- ret = wpa_drv_join_mesh(wpa_s, ¶ms);
+- if (ret)
+- wpa_msg(wpa_s, MSG_ERROR, "mesh join error=%d", ret);
+-
+- /* hostapd sets the interface down until we associate */
+- wpa_drv_set_operstate(wpa_s, 1);
+-
+- if (!ret)
+- wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
+-
++ wpas_join_mesh(wpa_s);
+ out:
+ return ret;
+ }
+--- a/wpa_supplicant/mesh.h
++++ b/wpa_supplicant/mesh.h
+@@ -21,6 +21,7 @@ int wpas_mesh_add_interface(struct wpa_s
+ int wpas_mesh_peer_remove(struct wpa_supplicant *wpa_s, const u8 *addr);
+ int wpas_mesh_peer_add(struct wpa_supplicant *wpa_s, const u8 *addr,
+ int duration);
++void wpas_join_mesh(struct wpa_supplicant *wpa_s);
+
+ #ifdef CONFIG_MESH
+
+--- a/wpa_supplicant/wpa_supplicant_i.h
++++ b/wpa_supplicant/wpa_supplicant_i.h
+@@ -810,6 +810,7 @@ struct wpa_supplicant {
+ unsigned int mesh_if_created:1;
+ unsigned int mesh_ht_enabled:1;
+ unsigned int mesh_vht_enabled:1;
++ struct wpa_driver_mesh_join_params *mesh_params;
+ #ifdef CONFIG_PMKSA_CACHE_EXTERNAL
+ /* struct external_pmksa_cache::list */
+ struct dl_list mesh_external_pmksa_cache;
--- /dev/null
+From 6da64b1e056e0b1be18b6ab37c820acb4a0f3cf4 Mon Sep 17 00:00:00 2001
+From: Peter Oh <peter.oh@bowerswilkins.com>
+Date: Tue, 17 Apr 2018 21:54:59 -0700
+Subject: [PATCH 02/16] mesh: factor out rsn initialization
+
+RSN initialization can be used in different phases
+if mesh initialization and mesh join don't happen
+in sequence such as DFS CAC is done in between,
+hence factor it out to help convering the case.
+
+Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
+---
+ wpa_supplicant/mesh.c | 84 +++++++++++++++++++++++++------------------
+ wpa_supplicant/mesh.h | 1 +
+ 2 files changed, 50 insertions(+), 35 deletions(-)
+
+--- a/wpa_supplicant/mesh.c
++++ b/wpa_supplicant/mesh.c
+@@ -147,6 +147,53 @@ static void wpas_mesh_copy_groups(struct
+ }
+
+
++int wpas_mesh_init_rsn(struct wpa_supplicant *wpa_s)
++{
++ struct hostapd_iface *ifmsh = wpa_s->ifmsh;
++ struct mesh_conf *mconf = wpa_s->ifmsh->mconf;
++ struct wpa_ssid *ssid = wpa_s->current_ssid;
++ struct hostapd_data *bss = ifmsh->bss[0];
++ static int default_groups[] = { 19, 20, 21, 25, 26, -1 };
++ const char *password;
++ size_t len;
++
++ if (mconf->security != MESH_CONF_SEC_NONE) {
++ password = ssid->sae_password;
++ if (!password)
++ password = ssid->passphrase;
++ if (!password) {
++ wpa_printf(MSG_ERROR,
++ "mesh: Passphrase for SAE not configured");
++ return -1;
++ }
++
++ bss->conf->wpa = ssid->proto;
++ bss->conf->wpa_key_mgmt = ssid->key_mgmt;
++
++ if (wpa_s->conf->sae_groups &&
++ wpa_s->conf->sae_groups[0] > 0) {
++ wpas_mesh_copy_groups(bss, wpa_s);
++ } else {
++ bss->conf->sae_groups =
++ os_memdup(default_groups,
++ sizeof(default_groups));
++ if (!bss->conf->sae_groups)
++ return -1;
++ }
++
++ len = os_strlen(password);
++ bss->conf->ssid.wpa_passphrase =
++ dup_binstr(password, len);
++
++ wpa_s->mesh_rsn = mesh_rsn_auth_init(wpa_s, mconf);
++ if (!wpa_s->mesh_rsn)
++ return -1;
++ }
++
++ return 0;
++}
++
++
+ static int wpa_supplicant_mesh_init(struct wpa_supplicant *wpa_s,
+ struct wpa_ssid *ssid,
+ struct hostapd_freq_params *freq)
+@@ -156,9 +203,6 @@ static int wpa_supplicant_mesh_init(stru
+ struct hostapd_config *conf;
+ struct mesh_conf *mconf;
+ int basic_rates_erp[] = { 10, 20, 55, 60, 110, 120, 240, -1 };
+- static int default_groups[] = { 19, 20, 21, 25, 26, -1 };
+- const char *password;
+- size_t len;
+ int rate_len;
+ int frequency;
+
+@@ -291,38 +335,8 @@ static int wpa_supplicant_mesh_init(stru
+ return -1;
+ }
+
+- if (mconf->security != MESH_CONF_SEC_NONE) {
+- password = ssid->sae_password;
+- if (!password)
+- password = ssid->passphrase;
+- if (!password) {
+- wpa_printf(MSG_ERROR,
+- "mesh: Passphrase for SAE not configured");
+- goto out_free;
+- }
+-
+- bss->conf->wpa = ssid->proto;
+- bss->conf->wpa_key_mgmt = ssid->key_mgmt;
+-
+- if (wpa_s->conf->sae_groups &&
+- wpa_s->conf->sae_groups[0] > 0) {
+- wpas_mesh_copy_groups(bss, wpa_s);
+- } else {
+- bss->conf->sae_groups =
+- os_memdup(default_groups,
+- sizeof(default_groups));
+- if (!bss->conf->sae_groups)
+- goto out_free;
+- }
+-
+- len = os_strlen(password);
+- bss->conf->ssid.wpa_passphrase =
+- dup_binstr(password, len);
+-
+- wpa_s->mesh_rsn = mesh_rsn_auth_init(wpa_s, mconf);
+- if (!wpa_s->mesh_rsn)
+- goto out_free;
+- }
++ if (wpas_mesh_init_rsn(wpa_s))
++ goto out_free;
+
+ wpa_supplicant_conf_ap_ht(wpa_s, ssid, conf);
+
+--- a/wpa_supplicant/mesh.h
++++ b/wpa_supplicant/mesh.h
+@@ -22,6 +22,7 @@ int wpas_mesh_peer_remove(struct wpa_sup
+ int wpas_mesh_peer_add(struct wpa_supplicant *wpa_s, const u8 *addr,
+ int duration);
+ void wpas_join_mesh(struct wpa_supplicant *wpa_s);
++int wpas_mesh_init_rsn(struct wpa_supplicant *wpa_s);
+
+ #ifdef CONFIG_MESH
+
--- /dev/null
+From 95425b5becaeda8a515c942f417696e5df34bbc8 Mon Sep 17 00:00:00 2001
+From: Peter Oh <peter.oh@bowerswilkins.com>
+Date: Tue, 17 Apr 2018 21:55:00 -0700
+Subject: [PATCH 03/16] mesh: relocate RSN init function
+
+RSN init function should work together with mesh join
+when it's used. Since mesh join could be called at different stage
+if DFS channel is used, relocate the function to mesh join.
+It is still the same call flows of mesh join before this changes
+if non-DFS channels are used, hence no side effect will occur.
+
+Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
+---
+ wpa_supplicant/mesh.c | 9 ++++++---
+ 1 file changed, 6 insertions(+), 3 deletions(-)
+
+--- a/wpa_supplicant/mesh.c
++++ b/wpa_supplicant/mesh.c
+@@ -335,9 +335,6 @@ static int wpa_supplicant_mesh_init(stru
+ return -1;
+ }
+
+- if (wpas_mesh_init_rsn(wpa_s))
+- goto out_free;
+-
+ wpa_supplicant_conf_ap_ht(wpa_s, ssid, conf);
+
+ return 0;
+@@ -383,6 +380,12 @@ void wpas_join_mesh(struct wpa_supplican
+ struct wpa_ssid *ssid = wpa_s->current_ssid;
+ int ret = 0;
+
++ if (wpas_mesh_init_rsn(wpa_s)) {
++ wpa_printf(MSG_ERROR, "Init RSN failed. Deinit mesh...");
++ wpa_supplicant_mesh_deinit(wpa_s);
++ return;
++ }
++
+ if (ssid->key_mgmt & WPA_KEY_MGMT_SAE) {
+ wpa_s->pairwise_cipher = wpa_s->mesh_rsn->pairwise_cipher;
+ wpa_s->group_cipher = wpa_s->mesh_rsn->group_cipher;
--- /dev/null
+From 32044a7bb26858bedaf147c77f49f5cef1133de3 Mon Sep 17 00:00:00 2001
+From: Peter Oh <peter.oh@bowerswilkins.com>
+Date: Tue, 17 Apr 2018 21:55:01 -0700
+Subject: [PATCH 04/16] mesh: use setup completion callback to complete mesh
+ join
+
+mesh join function is the last function to be called during
+mesh join process, but it's been called a bit earlier than
+it's supposed to be, so that some mesh parameter values
+such as VHT capabilities not applied correct when mesh join
+is in process. Moreover current design of mesh join that is called
+directly after mesh initialization is not suitable for DFS channels
+to use, since mesh join process should be paused until DFS CAC is
+done and resumed once it's done.
+Using setup completion callback is how AP mode is using for DFS channels
+and mesh can use the same way.
+The callback will be called by hostapd_setup_interface_complete_sync.
+
+Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
+---
+ wpa_supplicant/mesh.c | 7 +++++--
+ wpa_supplicant/mesh.h | 2 +-
+ 2 files changed, 6 insertions(+), 3 deletions(-)
+
+--- a/wpa_supplicant/mesh.c
++++ b/wpa_supplicant/mesh.c
+@@ -217,6 +217,7 @@ static int wpa_supplicant_mesh_init(stru
+ if (!ifmsh)
+ return -ENOMEM;
+
++ ifmsh->owner = wpa_s;
+ ifmsh->drv_flags = wpa_s->drv_flags;
+ ifmsh->num_bss = 1;
+ ifmsh->bss = os_calloc(wpa_s->ifmsh->num_bss,
+@@ -233,6 +234,8 @@ static int wpa_supplicant_mesh_init(stru
+ bss->drv_priv = wpa_s->drv_priv;
+ bss->iface = ifmsh;
+ bss->mesh_sta_free_cb = mesh_mpm_free_sta;
++ bss->setup_complete_cb = wpas_mesh_complete_cb;
++ bss->setup_complete_cb_ctx = wpa_s;
+ frequency = ssid->frequency;
+ if (frequency != freq->freq &&
+ frequency == freq->freq + freq->sec_channel_offset * 20) {
+@@ -374,8 +377,9 @@ void wpa_supplicant_mesh_add_scan_ie(str
+ }
+
+
+-void wpas_join_mesh(struct wpa_supplicant *wpa_s)
++void wpas_mesh_complete_cb(void *ctx)
+ {
++ struct wpa_supplicant *wpa_s = (struct wpa_supplicant *)ctx;
+ struct wpa_driver_mesh_join_params *params = wpa_s->mesh_params;
+ struct wpa_ssid *ssid = wpa_s->current_ssid;
+ int ret = 0;
+@@ -497,7 +501,6 @@ int wpa_supplicant_join_mesh(struct wpa_
+ goto out;
+ }
+
+- wpas_join_mesh(wpa_s);
+ out:
+ return ret;
+ }
+--- a/wpa_supplicant/mesh.h
++++ b/wpa_supplicant/mesh.h
+@@ -21,7 +21,7 @@ int wpas_mesh_add_interface(struct wpa_s
+ int wpas_mesh_peer_remove(struct wpa_supplicant *wpa_s, const u8 *addr);
+ int wpas_mesh_peer_add(struct wpa_supplicant *wpa_s, const u8 *addr,
+ int duration);
+-void wpas_join_mesh(struct wpa_supplicant *wpa_s);
++void wpas_mesh_complete_cb(void *ctx);
+ int wpas_mesh_init_rsn(struct wpa_supplicant *wpa_s);
+
+ #ifdef CONFIG_MESH
--- /dev/null
+From e2f13b1fac9799db83a37fc57df9471d9bb5b711 Mon Sep 17 00:00:00 2001
+From: Peter Oh <peter.oh@bowerswilkins.com>
+Date: Tue, 17 Apr 2018 21:55:02 -0700
+Subject: [PATCH 05/16] mesh: reflect country setting to mesh configuration
+
+wpa_supplicant configuration has country parameter that is
+supposed to be used in AP mode to indicate supporting 802.11h
+and 802.11d. Reflect this configuration to Mesh also since Mesh
+is required to support 802.11h and 802.11d to use DFS channels.
+
+Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
+---
+ wpa_supplicant/mesh.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+--- a/wpa_supplicant/mesh.c
++++ b/wpa_supplicant/mesh.c
+@@ -254,6 +254,15 @@ static int wpa_supplicant_mesh_init(stru
+ bss->conf->start_disabled = 1;
+ bss->conf->mesh = MESH_ENABLED;
+ bss->conf->ap_max_inactivity = wpa_s->conf->mesh_max_inactivity;
++
++ if (ieee80211_is_dfs(ssid->frequency, wpa_s->hw.modes,
++ wpa_s->hw.num_modes) && wpa_s->conf->country[0]) {
++ conf->ieee80211h = 1;
++ conf->ieee80211d = 1;
++ conf->country[0] = wpa_s->conf->country[0];
++ conf->country[1] = wpa_s->conf->country[1];
++ }
++
+ bss->iconf = conf;
+ ifmsh->conf = conf;
+
--- /dev/null
+From 37bf08621eee53f30b464be71876c02e235077ba Mon Sep 17 00:00:00 2001
+From: Peter Oh <peter.oh@bowerswilkins.com>
+Date: Tue, 17 Apr 2018 21:55:03 -0700
+Subject: [PATCH 06/16] mesh: inform kernel driver DFS handler in userspace
+
+NL80211_ATTR_HANDLE_DFS is required by kerenel space
+to enable DFS channels that indicates DFS handler
+resides in userspace.
+
+Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
+---
+ src/drivers/driver.h | 1 +
+ src/drivers/driver_nl80211.c | 3 +++
+ wpa_supplicant/mesh.c | 1 +
+ 3 files changed, 5 insertions(+)
+
+--- a/src/drivers/driver.h
++++ b/src/drivers/driver.h
+@@ -1390,6 +1390,7 @@ struct wpa_driver_mesh_join_params {
+ #define WPA_DRIVER_MESH_FLAG_SAE_AUTH 0x00000004
+ #define WPA_DRIVER_MESH_FLAG_AMPE 0x00000008
+ unsigned int flags;
++ u8 handle_dfs;
+ };
+
+ /**
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -9270,6 +9270,9 @@ static int nl80211_join_mesh(struct i802
+
+ wpa_printf(MSG_DEBUG, " * flags=%08X", params->flags);
+
++ if (params->handle_dfs)
++ if (nla_put_flag(msg, NL80211_ATTR_HANDLE_DFS))
++ goto fail;
+ container = nla_nest_start(msg, NL80211_ATTR_MESH_SETUP);
+ if (!container)
+ goto fail;
+--- a/wpa_supplicant/mesh.c
++++ b/wpa_supplicant/mesh.c
+@@ -261,6 +261,7 @@ static int wpa_supplicant_mesh_init(stru
+ conf->ieee80211d = 1;
+ conf->country[0] = wpa_s->conf->country[0];
+ conf->country[1] = wpa_s->conf->country[1];
++ wpa_s->mesh_params->handle_dfs = 1;
+ }
+
+ bss->iconf = conf;
--- /dev/null
+From 8190aab3344ae9746c897093f88f3679239d135d Mon Sep 17 00:00:00 2001
+From: Peter Oh <peter.oh@bowerswilkins.com>
+Date: Tue, 17 Apr 2018 21:55:04 -0700
+Subject: [PATCH 07/16] mesh: apply channel attributes before running Mesh
+
+This helps mesh interface initializes with correct
+channel parameters.
+
+Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
+---
+ wpa_supplicant/mesh.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/wpa_supplicant/mesh.c
++++ b/wpa_supplicant/mesh.c
+@@ -337,6 +337,8 @@ static int wpa_supplicant_mesh_init(stru
+ conf->basic_rates[rate_len] = -1;
+ }
+
++ wpa_supplicant_conf_ap_ht(wpa_s, ssid, conf);
++
+ if (hostapd_setup_interface(ifmsh)) {
+ wpa_printf(MSG_ERROR,
+ "Failed to initialize hostapd interface for mesh");
+@@ -348,8 +350,6 @@ static int wpa_supplicant_mesh_init(stru
+ return -1;
+ }
+
+- wpa_supplicant_conf_ap_ht(wpa_s, ssid, conf);
+-
+ return 0;
+ out_free:
+ wpa_supplicant_mesh_deinit(wpa_s);
--- /dev/null
+From e001251cb5708c406d477eca6aa912e5692b17fe Mon Sep 17 00:00:00 2001
+From: Peter Oh <peter.oh@bowerswilkins.com>
+Date: Tue, 17 Apr 2018 21:55:05 -0700
+Subject: [PATCH 08/16] mesh: set interface type to mesh before setting
+ interface
+
+Correct interface type is required to start DFS CAC that can be
+triggered during interface setup.
+
+Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
+---
+ wpa_supplicant/mesh.c | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+--- a/wpa_supplicant/mesh.c
++++ b/wpa_supplicant/mesh.c
+@@ -339,14 +339,14 @@ static int wpa_supplicant_mesh_init(stru
+
+ wpa_supplicant_conf_ap_ht(wpa_s, ssid, conf);
+
+- if (hostapd_setup_interface(ifmsh)) {
+- wpa_printf(MSG_ERROR,
+- "Failed to initialize hostapd interface for mesh");
++ if (wpa_drv_init_mesh(wpa_s)) {
++ wpa_msg(wpa_s, MSG_ERROR, "Failed to init mesh in driver");
+ return -1;
+ }
+
+- if (wpa_drv_init_mesh(wpa_s)) {
+- wpa_msg(wpa_s, MSG_ERROR, "Failed to init mesh in driver");
++ if (hostapd_setup_interface(ifmsh)) {
++ wpa_printf(MSG_ERROR,
++ "Failed to initialize hostapd interface for mesh");
+ return -1;
+ }
+
--- /dev/null
+From 3cefd0bf495ad51a860b56281a8cae32bc4bd086 Mon Sep 17 00:00:00 2001
+From: Peter Oh <peter.oh@bowerswilkins.com>
+Date: Tue, 17 Apr 2018 21:55:06 -0700
+Subject: [PATCH 09/16] mesh: set mesh center frequency
+
+vht center frequency value is required to compose the correct channel info.
+
+Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
+---
+ wpa_supplicant/mesh.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/wpa_supplicant/mesh.c
++++ b/wpa_supplicant/mesh.c
+@@ -456,6 +456,7 @@ int wpa_supplicant_join_mesh(struct wpa_
+
+ if (wpa_s->mesh_vht_enabled) {
+ ssid->vht = 1;
++ ssid->vht_center_freq1 = params->freq.center_freq1;
+ switch (params->freq.bandwidth) {
+ case 80:
+ if (params->freq.center_freq2) {
--- /dev/null
+From 90aa570a894a907d11f85ced43a248198e24acc1 Mon Sep 17 00:00:00 2001
+From: Peter Oh <peter.oh@bowerswilkins.com>
+Date: Tue, 17 Apr 2018 21:55:07 -0700
+Subject: [PATCH 10/16] mesh: consider mesh interface on dfs event handler
+
+Once mesh starts supporting DFS channels, it has to handle DFS related events
+from drivers, hence add mesh interface to the check list.
+
+Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
+---
+ wpa_supplicant/ap.c | 71 ++++++++++++++++++++++++++++++-----------
+ wpa_supplicant/events.c | 1 +
+ 2 files changed, 54 insertions(+), 18 deletions(-)
+
+--- a/wpa_supplicant/ap.c
++++ b/wpa_supplicant/ap.c
+@@ -1337,13 +1337,18 @@ int ap_ctrl_iface_chanswitch(struct wpa_
+ void wpas_ap_ch_switch(struct wpa_supplicant *wpa_s, int freq, int ht,
+ int offset, int width, int cf1, int cf2)
+ {
+- if (!wpa_s->ap_iface)
+- return;
++ struct hostapd_iface *iface = wpa_s->ap_iface;
+
++ if (!wpa_s->ap_iface) {
++ if (!wpa_s->ifmsh)
++ return;
++ else
++ iface = wpa_s->ifmsh;
++ }
+ wpa_s->assoc_freq = freq;
+ if (wpa_s->current_ssid)
+ wpa_s->current_ssid->frequency = freq;
+- hostapd_event_ch_switch(wpa_s->ap_iface->bss[0], freq, ht,
++ hostapd_event_ch_switch(iface->bss[0], freq, ht,
+ offset, width, cf1, cf2);
+ }
+
+@@ -1540,10 +1545,16 @@ int wpas_ap_pmksa_cache_add_external(str
+ void wpas_event_dfs_radar_detected(struct wpa_supplicant *wpa_s,
+ struct dfs_event *radar)
+ {
+- if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0])
+- return;
++ struct hostapd_iface *iface = wpa_s->ap_iface;
++
++ if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0]) {
++ if (!wpa_s->ifmsh || !wpa_s->ifmsh->bss[0])
++ return;
++ else
++ iface = wpa_s->ifmsh;
++ }
+ wpa_printf(MSG_DEBUG, "DFS radar detected on %d MHz", radar->freq);
+- hostapd_dfs_radar_detected(wpa_s->ap_iface, radar->freq,
++ hostapd_dfs_radar_detected(iface, radar->freq,
+ radar->ht_enabled, radar->chan_offset,
+ radar->chan_width,
+ radar->cf1, radar->cf2);
+@@ -1553,10 +1564,16 @@ void wpas_event_dfs_radar_detected(struc
+ void wpas_event_dfs_cac_started(struct wpa_supplicant *wpa_s,
+ struct dfs_event *radar)
+ {
+- if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0])
+- return;
++ struct hostapd_iface *iface = wpa_s->ap_iface;
++
++ if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0]) {
++ if (!wpa_s->ifmsh || !wpa_s->ifmsh->bss[0])
++ return;
++ else
++ iface = wpa_s->ifmsh;
++ }
+ wpa_printf(MSG_DEBUG, "DFS CAC started on %d MHz", radar->freq);
+- hostapd_dfs_start_cac(wpa_s->ap_iface, radar->freq,
++ hostapd_dfs_start_cac(iface, radar->freq,
+ radar->ht_enabled, radar->chan_offset,
+ radar->chan_width, radar->cf1, radar->cf2);
+ }
+@@ -1565,10 +1582,16 @@ void wpas_event_dfs_cac_started(struct w
+ void wpas_event_dfs_cac_finished(struct wpa_supplicant *wpa_s,
+ struct dfs_event *radar)
+ {
+- if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0])
+- return;
++ struct hostapd_iface *iface = wpa_s->ap_iface;
++
++ if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0]) {
++ if (!wpa_s->ifmsh || !wpa_s->ifmsh->bss[0])
++ return;
++ else
++ iface = wpa_s->ifmsh;
++ }
+ wpa_printf(MSG_DEBUG, "DFS CAC finished on %d MHz", radar->freq);
+- hostapd_dfs_complete_cac(wpa_s->ap_iface, 1, radar->freq,
++ hostapd_dfs_complete_cac(iface, 1, radar->freq,
+ radar->ht_enabled, radar->chan_offset,
+ radar->chan_width, radar->cf1, radar->cf2);
+ }
+@@ -1577,10 +1600,16 @@ void wpas_event_dfs_cac_finished(struct
+ void wpas_event_dfs_cac_aborted(struct wpa_supplicant *wpa_s,
+ struct dfs_event *radar)
+ {
+- if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0])
+- return;
++ struct hostapd_iface *iface = wpa_s->ap_iface;
++
++ if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0]) {
++ if (!wpa_s->ifmsh || !wpa_s->ifmsh->bss[0])
++ return;
++ else
++ iface = wpa_s->ifmsh;
++ }
+ wpa_printf(MSG_DEBUG, "DFS CAC aborted on %d MHz", radar->freq);
+- hostapd_dfs_complete_cac(wpa_s->ap_iface, 0, radar->freq,
++ hostapd_dfs_complete_cac(iface, 0, radar->freq,
+ radar->ht_enabled, radar->chan_offset,
+ radar->chan_width, radar->cf1, radar->cf2);
+ }
+@@ -1589,10 +1618,16 @@ void wpas_event_dfs_cac_aborted(struct w
+ void wpas_event_dfs_cac_nop_finished(struct wpa_supplicant *wpa_s,
+ struct dfs_event *radar)
+ {
+- if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0])
+- return;
++ struct hostapd_iface *iface = wpa_s->ap_iface;
++
++ if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0]) {
++ if (!wpa_s->ifmsh || !wpa_s->ifmsh->bss[0])
++ return;
++ else
++ iface = wpa_s->ifmsh;
++ }
+ wpa_printf(MSG_DEBUG, "DFS NOP finished on %d MHz", radar->freq);
+- hostapd_dfs_nop_finished(wpa_s->ap_iface, radar->freq,
++ hostapd_dfs_nop_finished(iface, radar->freq,
+ radar->ht_enabled, radar->chan_offset,
+ radar->chan_width, radar->cf1, radar->cf2);
+ }
+--- a/wpa_supplicant/events.c
++++ b/wpa_supplicant/events.c
+@@ -4203,6 +4203,7 @@ void wpa_supplicant_event(void *ctx, enu
+ #ifdef CONFIG_AP
+ if (wpa_s->current_ssid->mode == WPAS_MODE_AP ||
+ wpa_s->current_ssid->mode == WPAS_MODE_P2P_GO ||
++ wpa_s->current_ssid->mode == WPAS_MODE_MESH ||
+ wpa_s->current_ssid->mode ==
+ WPAS_MODE_P2P_GROUP_FORMATION) {
+ wpas_ap_ch_switch(wpa_s, data->ch_switch.freq,
+++ /dev/null
-From 91c0f3f6a9ecae3c9106bef8a8606fab0792dd28 Mon Sep 17 00:00:00 2001
-From: Peter Oh <peter.oh@bowerswilkins.com>
-Date: Thu, 12 Apr 2018 02:48:58 -0700
-Subject: [PATCH 01/15] mesh: factor out mesh join function
-
-mesh join function consitss of 2 parts which are preparing
-configurations and sending join event to driver.
-Since physical mesh join event could happen either right
-after mesh configuration is done or after CAC is done
-in case of DFS channel is used, factor out the function
-into 2 parts to reduce redundant calls.
-
-Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
----
- wpa_supplicant/mesh.c | 120 ++++++++++++++++--------------
- wpa_supplicant/mesh.h | 1 +
- wpa_supplicant/wpa_supplicant_i.h | 1 +
- 3 files changed, 68 insertions(+), 54 deletions(-)
-
---- a/wpa_supplicant/mesh.c
-+++ b/wpa_supplicant/mesh.c
-@@ -25,6 +25,7 @@
- #include "mesh_mpm.h"
- #include "mesh_rsn.h"
- #include "mesh.h"
-+#include "drivers/driver_nl80211.h"
-
-
- static void wpa_supplicant_mesh_deinit(struct wpa_supplicant *wpa_s)
-@@ -359,13 +360,48 @@ void wpa_supplicant_mesh_add_scan_ie(str
- }
-
-
-+void wpas_join_mesh(struct wpa_supplicant *wpa_s)
-+{
-+ struct wpa_driver_mesh_join_params *params = wpa_s->mesh_params;
-+ struct wpa_ssid *ssid = wpa_s->current_ssid;
-+ int ret = 0;
-+
-+ if (ssid->key_mgmt & WPA_KEY_MGMT_SAE) {
-+ wpa_s->pairwise_cipher = wpa_s->mesh_rsn->pairwise_cipher;
-+ wpa_s->group_cipher = wpa_s->mesh_rsn->group_cipher;
-+ wpa_s->mgmt_group_cipher = wpa_s->mesh_rsn->mgmt_group_cipher;
-+ }
-+
-+ if (wpa_s->ifmsh) {
-+ params->ies = wpa_s->ifmsh->mconf->rsn_ie;
-+ params->ie_len = wpa_s->ifmsh->mconf->rsn_ie_len;
-+ params->basic_rates = wpa_s->ifmsh->basic_rates;
-+ params->conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_HT_OP_MODE;
-+ params->conf.ht_opmode = wpa_s->ifmsh->bss[0]->iface->ht_op_mode;
-+ }
-+
-+ ret = wpa_drv_join_mesh(wpa_s, params);
-+ if (ret)
-+ wpa_msg(wpa_s, MSG_ERROR, "mesh join error=%d\n", ret);
-+
-+ /* hostapd sets the interface down until we associate */
-+ wpa_drv_set_operstate(wpa_s, 1);
-+
-+ if (!ret)
-+ wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
-+
-+ return;
-+}
-+
-+
- int wpa_supplicant_join_mesh(struct wpa_supplicant *wpa_s,
- struct wpa_ssid *ssid)
- {
-- struct wpa_driver_mesh_join_params params;
-+ struct wpa_driver_mesh_join_params *params =
-+ os_zalloc(sizeof(struct wpa_driver_mesh_join_params));
- int ret = 0;
-
-- if (!ssid || !ssid->ssid || !ssid->ssid_len || !ssid->frequency) {
-+ if (!ssid || !ssid->ssid || !ssid->ssid_len || !ssid->frequency || !params) {
- ret = -ENOENT;
- goto out;
- }
-@@ -376,22 +412,22 @@ int wpa_supplicant_join_mesh(struct wpa_
- wpa_s->group_cipher = WPA_CIPHER_NONE;
- wpa_s->mgmt_group_cipher = 0;
-
-- os_memset(¶ms, 0, sizeof(params));
-- params.meshid = ssid->ssid;
-- params.meshid_len = ssid->ssid_len;
-- ibss_mesh_setup_freq(wpa_s, ssid, ¶ms.freq);
-- wpa_s->mesh_ht_enabled = !!params.freq.ht_enabled;
-- wpa_s->mesh_vht_enabled = !!params.freq.vht_enabled;
-- if (params.freq.ht_enabled && params.freq.sec_channel_offset)
-- ssid->ht40 = params.freq.sec_channel_offset;
-+ params->meshid = ssid->ssid;
-+ params->meshid_len = ssid->ssid_len;
-+ ibss_mesh_setup_freq(wpa_s, ssid, ¶ms->freq);
-+ wpa_s->mesh_ht_enabled = !!params->freq.ht_enabled;
-+ wpa_s->mesh_vht_enabled = !!params->freq.vht_enabled;
-+ if (params->freq.ht_enabled && params->freq.sec_channel_offset)
-+ ssid->ht40 = params->freq.sec_channel_offset;
-+
- if (wpa_s->mesh_vht_enabled) {
- ssid->vht = 1;
-- switch (params.freq.bandwidth) {
-+ switch (params->freq.bandwidth) {
- case 80:
-- if (params.freq.center_freq2) {
-+ if (params->freq.center_freq2) {
- ssid->max_oper_chwidth = VHT_CHANWIDTH_80P80MHZ;
- ssid->vht_center_freq2 =
-- params.freq.center_freq2;
-+ params->freq.center_freq2;
- } else {
- ssid->max_oper_chwidth = VHT_CHANWIDTH_80MHZ;
- }
-@@ -405,67 +441,43 @@ int wpa_supplicant_join_mesh(struct wpa_
- }
- }
- if (ssid->beacon_int > 0)
-- params.beacon_int = ssid->beacon_int;
-+ params->beacon_int = ssid->beacon_int;
- else if (wpa_s->conf->beacon_int > 0)
-- params.beacon_int = wpa_s->conf->beacon_int;
-+ params->beacon_int = wpa_s->conf->beacon_int;
- if (ssid->dtim_period > 0)
-- params.dtim_period = ssid->dtim_period;
-+ params->dtim_period = ssid->dtim_period;
- else if (wpa_s->conf->dtim_period > 0)
-- params.dtim_period = wpa_s->conf->dtim_period;
-- params.conf.max_peer_links = wpa_s->conf->max_peer_links;
-+ params->dtim_period = wpa_s->conf->dtim_period;
-+ params->conf.max_peer_links = wpa_s->conf->max_peer_links;
- if (ssid->mesh_rssi_threshold < DEFAULT_MESH_RSSI_THRESHOLD) {
-- params.conf.rssi_threshold = ssid->mesh_rssi_threshold;
-- params.conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_RSSI_THRESHOLD;
-+ params->conf.rssi_threshold = ssid->mesh_rssi_threshold;
-+ params->conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_RSSI_THRESHOLD;
- }
-
- if (ssid->key_mgmt & WPA_KEY_MGMT_SAE) {
-- params.flags |= WPA_DRIVER_MESH_FLAG_SAE_AUTH;
-- params.flags |= WPA_DRIVER_MESH_FLAG_AMPE;
-+ params->flags |= WPA_DRIVER_MESH_FLAG_SAE_AUTH;
-+ params->flags |= WPA_DRIVER_MESH_FLAG_AMPE;
- wpa_s->conf->user_mpm = 1;
- }
-
- if (wpa_s->conf->user_mpm) {
-- params.flags |= WPA_DRIVER_MESH_FLAG_USER_MPM;
-- params.conf.auto_plinks = 0;
-+ params->flags |= WPA_DRIVER_MESH_FLAG_USER_MPM;
-+ params->conf.auto_plinks = 0;
- } else {
-- params.flags |= WPA_DRIVER_MESH_FLAG_DRIVER_MPM;
-- params.conf.auto_plinks = 1;
-+ params->flags |= WPA_DRIVER_MESH_FLAG_DRIVER_MPM;
-+ params->conf.auto_plinks = 1;
- }
-- params.conf.peer_link_timeout = wpa_s->conf->mesh_max_inactivity;
-+ params->conf.peer_link_timeout = wpa_s->conf->mesh_max_inactivity;
-
-- if (wpa_supplicant_mesh_init(wpa_s, ssid, ¶ms.freq)) {
-+ wpa_s->mesh_params = params;
-+ if (wpa_supplicant_mesh_init(wpa_s, ssid, ¶ms->freq)) {
- wpa_msg(wpa_s, MSG_ERROR, "Failed to init mesh");
- wpa_drv_leave_mesh(wpa_s);
- ret = -1;
- goto out;
- }
-
-- if (ssid->key_mgmt & WPA_KEY_MGMT_SAE) {
-- wpa_s->pairwise_cipher = wpa_s->mesh_rsn->pairwise_cipher;
-- wpa_s->group_cipher = wpa_s->mesh_rsn->group_cipher;
-- wpa_s->mgmt_group_cipher = wpa_s->mesh_rsn->mgmt_group_cipher;
-- }
--
-- if (wpa_s->ifmsh) {
-- params.ies = wpa_s->ifmsh->mconf->rsn_ie;
-- params.ie_len = wpa_s->ifmsh->mconf->rsn_ie_len;
-- params.basic_rates = wpa_s->ifmsh->basic_rates;
-- params.conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_HT_OP_MODE;
-- params.conf.ht_opmode = wpa_s->ifmsh->bss[0]->iface->ht_op_mode;
-- }
--
-- wpa_msg(wpa_s, MSG_INFO, "joining mesh %s",
-- wpa_ssid_txt(ssid->ssid, ssid->ssid_len));
-- ret = wpa_drv_join_mesh(wpa_s, ¶ms);
-- if (ret)
-- wpa_msg(wpa_s, MSG_ERROR, "mesh join error=%d", ret);
--
-- /* hostapd sets the interface down until we associate */
-- wpa_drv_set_operstate(wpa_s, 1);
--
-- if (!ret)
-- wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
--
-+ wpas_join_mesh(wpa_s);
- out:
- return ret;
- }
---- a/wpa_supplicant/mesh.h
-+++ b/wpa_supplicant/mesh.h
-@@ -21,6 +21,7 @@ int wpas_mesh_add_interface(struct wpa_s
- int wpas_mesh_peer_remove(struct wpa_supplicant *wpa_s, const u8 *addr);
- int wpas_mesh_peer_add(struct wpa_supplicant *wpa_s, const u8 *addr,
- int duration);
-+void wpas_join_mesh(struct wpa_supplicant *wpa_s);
-
- #ifdef CONFIG_MESH
-
---- a/wpa_supplicant/wpa_supplicant_i.h
-+++ b/wpa_supplicant/wpa_supplicant_i.h
-@@ -810,6 +810,7 @@ struct wpa_supplicant {
- unsigned int mesh_if_created:1;
- unsigned int mesh_ht_enabled:1;
- unsigned int mesh_vht_enabled:1;
-+ struct wpa_driver_mesh_join_params *mesh_params;
- #ifdef CONFIG_PMKSA_CACHE_EXTERNAL
- /* struct external_pmksa_cache::list */
- struct dl_list mesh_external_pmksa_cache;
+++ /dev/null
-From 04ebcadc059a6cfd45cd8ec06e6321b69bdb68b8 Mon Sep 17 00:00:00 2001
-From: Peter Oh <peter.oh@bowerswilkins.com>
-Date: Thu, 12 Apr 2018 02:48:59 -0700
-Subject: [PATCH 02/15] mesh: factor out rsn initialization
-
-RSN initialization can be used in different phases
-if mesh initialization and mesh join don't happen
-in sequence such as DFS CAC is done in between,
-hence factor it out to help convering the case.
-
-Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
----
- wpa_supplicant/mesh.c | 73 ++++++++++++++++++++++++++-----------------
- wpa_supplicant/mesh.h | 1 +
- 2 files changed, 45 insertions(+), 29 deletions(-)
-
---- a/wpa_supplicant/mesh.c
-+++ b/wpa_supplicant/mesh.c
-@@ -147,6 +147,48 @@ static void wpas_mesh_copy_groups(struct
- groups_size);
- }
-
-+int wpas_mesh_init_rsn(struct wpa_supplicant *wpa_s)
-+{
-+ struct hostapd_iface *ifmsh = wpa_s->ifmsh;
-+ struct mesh_conf *mconf = wpa_s->ifmsh->mconf;
-+ struct wpa_ssid *ssid = wpa_s->current_ssid;
-+ struct hostapd_data *bss = ifmsh->bss[0];
-+ static int default_groups[] = { 19, 20, 21, 25, 26, -1 };
-+ size_t len;
-+
-+ if (mconf->security != MESH_CONF_SEC_NONE) {
-+ if (ssid->passphrase == NULL) {
-+ wpa_printf(MSG_ERROR,
-+ "mesh: Passphrase for SAE not configured");
-+ return -1;
-+ }
-+
-+ bss->conf->wpa = ssid->proto;
-+ bss->conf->wpa_key_mgmt = ssid->key_mgmt;
-+
-+ if (wpa_s->conf->sae_groups &&
-+ wpa_s->conf->sae_groups[0] > 0) {
-+ wpas_mesh_copy_groups(bss, wpa_s);
-+ } else {
-+ bss->conf->sae_groups =
-+ os_memdup(default_groups,
-+ sizeof(default_groups));
-+ if (!bss->conf->sae_groups)
-+ return -1;
-+ }
-+
-+ len = os_strlen(ssid->passphrase);
-+ bss->conf->ssid.wpa_passphrase =
-+ dup_binstr(ssid->passphrase, len);
-+
-+ wpa_s->mesh_rsn = mesh_rsn_auth_init(wpa_s, mconf);
-+ if (!wpa_s->mesh_rsn)
-+ return -1;
-+ }
-+
-+ return 0;
-+}
-+
-
- static int wpa_supplicant_mesh_init(struct wpa_supplicant *wpa_s,
- struct wpa_ssid *ssid,
-@@ -291,35 +333,8 @@ static int wpa_supplicant_mesh_init(stru
- return -1;
- }
-
-- if (mconf->security != MESH_CONF_SEC_NONE) {
-- if (ssid->passphrase == NULL) {
-- wpa_printf(MSG_ERROR,
-- "mesh: Passphrase for SAE not configured");
-- goto out_free;
-- }
--
-- bss->conf->wpa = ssid->proto;
-- bss->conf->wpa_key_mgmt = ssid->key_mgmt;
--
-- if (wpa_s->conf->sae_groups &&
-- wpa_s->conf->sae_groups[0] > 0) {
-- wpas_mesh_copy_groups(bss, wpa_s);
-- } else {
-- bss->conf->sae_groups =
-- os_memdup(default_groups,
-- sizeof(default_groups));
-- if (!bss->conf->sae_groups)
-- goto out_free;
-- }
--
-- len = os_strlen(ssid->passphrase);
-- bss->conf->ssid.wpa_passphrase =
-- dup_binstr(ssid->passphrase, len);
--
-- wpa_s->mesh_rsn = mesh_rsn_auth_init(wpa_s, mconf);
-- if (!wpa_s->mesh_rsn)
-- goto out_free;
-- }
-+ if (wpas_mesh_init_rsn(wpa_s))
-+ goto out_free;
-
- wpa_supplicant_conf_ap_ht(wpa_s, ssid, conf);
-
---- a/wpa_supplicant/mesh.h
-+++ b/wpa_supplicant/mesh.h
-@@ -22,6 +22,7 @@ int wpas_mesh_peer_remove(struct wpa_sup
- int wpas_mesh_peer_add(struct wpa_supplicant *wpa_s, const u8 *addr,
- int duration);
- void wpas_join_mesh(struct wpa_supplicant *wpa_s);
-+int wpas_mesh_init_rsn(struct wpa_supplicant *wpa_s);
-
- #ifdef CONFIG_MESH
-
+++ /dev/null
-From cbe8b9901f9cc254cbaa1ec1cee1c52af8f828bf Mon Sep 17 00:00:00 2001
-From: Peter Oh <peter.oh@bowerswilkins.com>
-Date: Thu, 12 Apr 2018 02:49:00 -0700
-Subject: [PATCH 03/15] mesh: relocate RSN init function
-
-RSN init function should work together with mesh join
-when it's used. Since mesh join could be called at different stage
-if DFS channel is used, relocate the function to mesh join.
-It is still the same call flows of mesh join before this changes
-if non-DFS channels are used, hence no side effect will occur.
-
-Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
----
- wpa_supplicant/mesh.c | 9 ++++++---
- 1 file changed, 6 insertions(+), 3 deletions(-)
-
---- a/wpa_supplicant/mesh.c
-+++ b/wpa_supplicant/mesh.c
-@@ -333,9 +333,6 @@ static int wpa_supplicant_mesh_init(stru
- return -1;
- }
-
-- if (wpas_mesh_init_rsn(wpa_s))
-- goto out_free;
--
- wpa_supplicant_conf_ap_ht(wpa_s, ssid, conf);
-
- return 0;
-@@ -381,6 +378,12 @@ void wpas_join_mesh(struct wpa_supplican
- struct wpa_ssid *ssid = wpa_s->current_ssid;
- int ret = 0;
-
-+ if (wpas_mesh_init_rsn(wpa_s)) {
-+ wpa_printf(MSG_ERROR, "Init RSN failed. Deinit mesh...");
-+ wpa_supplicant_mesh_deinit(wpa_s);
-+ return;
-+ }
-+
- if (ssid->key_mgmt & WPA_KEY_MGMT_SAE) {
- wpa_s->pairwise_cipher = wpa_s->mesh_rsn->pairwise_cipher;
- wpa_s->group_cipher = wpa_s->mesh_rsn->group_cipher;
+++ /dev/null
-From 8a4ebbb6bbbc1460c1d584d1a710bf1361797ffd Mon Sep 17 00:00:00 2001
-From: Peter Oh <peter.oh@bowerswilkins.com>
-Date: Thu, 12 Apr 2018 02:49:01 -0700
-Subject: [PATCH 04/15] mesh: use setup completion callback to complete mesh
- join
-
-mesh join function is the last function to be called during
-mesh join process, but it's been called a bit earlier than
-it's supposed to be, so that some mesh parameter values
-such as VHT capabilities not applied correct when mesh join
-is in process. Moreover current design of mesh join that is called
-directly after mesh initialization is not suitable for DFS channels
-to use, since mesh join process should be paused until DFS CAC is
-done and resumed once it's done.
-Using setup completion callback is how AP mode is using for DFS channels
-and mesh can use the same way.
-The callback will be called by hostapd_setup_interface_complete_sync.
-
-Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
----
- wpa_supplicant/mesh.c | 7 +++++--
- wpa_supplicant/mesh.h | 2 +-
- 2 files changed, 6 insertions(+), 3 deletions(-)
-
---- a/wpa_supplicant/mesh.c
-+++ b/wpa_supplicant/mesh.c
-@@ -215,6 +215,7 @@ static int wpa_supplicant_mesh_init(stru
- if (!ifmsh)
- return -ENOMEM;
-
-+ ifmsh->owner = wpa_s;
- ifmsh->drv_flags = wpa_s->drv_flags;
- ifmsh->num_bss = 1;
- ifmsh->bss = os_calloc(wpa_s->ifmsh->num_bss,
-@@ -231,6 +232,8 @@ static int wpa_supplicant_mesh_init(stru
- bss->drv_priv = wpa_s->drv_priv;
- bss->iface = ifmsh;
- bss->mesh_sta_free_cb = mesh_mpm_free_sta;
-+ bss->setup_complete_cb = wpas_mesh_complete_cb;
-+ bss->setup_complete_cb_ctx = wpa_s;
- frequency = ssid->frequency;
- if (frequency != freq->freq &&
- frequency == freq->freq + freq->sec_channel_offset * 20) {
-@@ -372,8 +375,9 @@ void wpa_supplicant_mesh_add_scan_ie(str
- }
-
-
--void wpas_join_mesh(struct wpa_supplicant *wpa_s)
-+void wpas_mesh_complete_cb(void *ctx)
- {
-+ struct wpa_supplicant *wpa_s = (struct wpa_supplicant *)ctx;
- struct wpa_driver_mesh_join_params *params = wpa_s->mesh_params;
- struct wpa_ssid *ssid = wpa_s->current_ssid;
- int ret = 0;
-@@ -495,7 +499,6 @@ int wpa_supplicant_join_mesh(struct wpa_
- goto out;
- }
-
-- wpas_join_mesh(wpa_s);
- out:
- return ret;
- }
---- a/wpa_supplicant/mesh.h
-+++ b/wpa_supplicant/mesh.h
-@@ -21,7 +21,7 @@ int wpas_mesh_add_interface(struct wpa_s
- int wpas_mesh_peer_remove(struct wpa_supplicant *wpa_s, const u8 *addr);
- int wpas_mesh_peer_add(struct wpa_supplicant *wpa_s, const u8 *addr,
- int duration);
--void wpas_join_mesh(struct wpa_supplicant *wpa_s);
-+void wpas_mesh_complete_cb(void *ctx);
- int wpas_mesh_init_rsn(struct wpa_supplicant *wpa_s);
-
- #ifdef CONFIG_MESH
+++ /dev/null
-From e223e851cbe776029a2768b56e7aa1a9f2873d09 Mon Sep 17 00:00:00 2001
-From: Peter Oh <peter.oh@bowerswilkins.com>
-Date: Thu, 12 Apr 2018 02:49:02 -0700
-Subject: [PATCH 05/15] mesh: reflect country setting to mesh configuration
-
-wpa_supplicant configuration has country parameter that is
-supposed to be used in AP mode to indicate supporting 802.11h
-and 802.11d. Reflect this configuration to Mesh also since Mesh
-is required to support 802.11h and 802.11d to use DFS channels.
-
-Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
----
- wpa_supplicant/mesh.c | 8 ++++++++
- 1 file changed, 8 insertions(+)
-
---- a/wpa_supplicant/mesh.c
-+++ b/wpa_supplicant/mesh.c
-@@ -252,6 +252,14 @@ static int wpa_supplicant_mesh_init(stru
- bss->conf->start_disabled = 1;
- bss->conf->mesh = MESH_ENABLED;
- bss->conf->ap_max_inactivity = wpa_s->conf->mesh_max_inactivity;
-+
-+ if (ieee80211_is_dfs(ssid->frequency) && wpa_s->conf->country[0]) {
-+ conf->ieee80211h = 1;
-+ conf->ieee80211d = 1;
-+ conf->country[0] = wpa_s->conf->country[0];
-+ conf->country[1] = wpa_s->conf->country[1];
-+ }
-+
- bss->iconf = conf;
- ifmsh->conf = conf;
-
+++ /dev/null
-From c7f107e52205dd5fdb20f7ae13413b3673b0547e Mon Sep 17 00:00:00 2001
-From: Peter Oh <peter.oh@bowerswilkins.com>
-Date: Thu, 12 Apr 2018 02:49:03 -0700
-Subject: [PATCH 06/15] mesh: inform kernel driver DFS handler in userspace
-
-NL80211_ATTR_HANDLE_DFS is required by kerenel space
-to enable DFS channels that indicates DFS handler
-resides in userspace.
-
-Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
----
- src/drivers/driver.h | 1 +
- src/drivers/driver_nl80211.c | 3 +++
- wpa_supplicant/mesh.c | 1 +
- 3 files changed, 5 insertions(+)
-
---- a/src/drivers/driver.h
-+++ b/src/drivers/driver.h
-@@ -1390,6 +1390,7 @@ struct wpa_driver_mesh_join_params {
- #define WPA_DRIVER_MESH_FLAG_SAE_AUTH 0x00000004
- #define WPA_DRIVER_MESH_FLAG_AMPE 0x00000008
- unsigned int flags;
-+ u8 handle_dfs;
- };
-
- /**
---- a/src/drivers/driver_nl80211.c
-+++ b/src/drivers/driver_nl80211.c
-@@ -9244,6 +9244,9 @@ static int nl80211_join_mesh(struct i802
-
- wpa_printf(MSG_DEBUG, " * flags=%08X", params->flags);
-
-+ if (params->handle_dfs)
-+ if (nla_put_flag(msg, NL80211_ATTR_HANDLE_DFS))
-+ goto fail;
- container = nla_nest_start(msg, NL80211_ATTR_MESH_SETUP);
- if (!container)
- goto fail;
---- a/wpa_supplicant/mesh.c
-+++ b/wpa_supplicant/mesh.c
-@@ -258,6 +258,7 @@ static int wpa_supplicant_mesh_init(stru
- conf->ieee80211d = 1;
- conf->country[0] = wpa_s->conf->country[0];
- conf->country[1] = wpa_s->conf->country[1];
-+ wpa_s->mesh_params->handle_dfs = 1;
- }
-
- bss->iconf = conf;
+++ /dev/null
-From a0c5eea22d5d1181dbe0861b24e4b9bb598f4e50 Mon Sep 17 00:00:00 2001
-From: Peter Oh <peter.oh@bowerswilkins.com>
-Date: Thu, 12 Apr 2018 02:49:04 -0700
-Subject: [PATCH 07/15] mesh: apply channel attributes before running Mesh
-
-This helps mesh interface initializes with correct
-channel parameters.
-
-Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
----
- wpa_supplicant/mesh.c | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/wpa_supplicant/mesh.c
-+++ b/wpa_supplicant/mesh.c
-@@ -334,6 +334,8 @@ static int wpa_supplicant_mesh_init(stru
- conf->basic_rates[rate_len] = -1;
- }
-
-+ wpa_supplicant_conf_ap_ht(wpa_s, ssid, conf);
-+
- if (hostapd_setup_interface(ifmsh)) {
- wpa_printf(MSG_ERROR,
- "Failed to initialize hostapd interface for mesh");
-@@ -345,8 +347,6 @@ static int wpa_supplicant_mesh_init(stru
- return -1;
- }
-
-- wpa_supplicant_conf_ap_ht(wpa_s, ssid, conf);
--
- return 0;
- out_free:
- wpa_supplicant_mesh_deinit(wpa_s);
+++ /dev/null
-From 143809f1e60f749a5a5c72735ffa8eb99d602cc1 Mon Sep 17 00:00:00 2001
-From: Peter Oh <peter.oh@bowerswilkins.com>
-Date: Thu, 12 Apr 2018 02:49:05 -0700
-Subject: [PATCH 08/15] mesh: set interface type to mesh before setting
- interface
-
-Correct interface type is required to start DFS CAC that can be
-triggered during interface setup.
-
-Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
----
- wpa_supplicant/mesh.c | 10 +++++-----
- 1 file changed, 5 insertions(+), 5 deletions(-)
-
---- a/wpa_supplicant/mesh.c
-+++ b/wpa_supplicant/mesh.c
-@@ -336,14 +336,14 @@ static int wpa_supplicant_mesh_init(stru
-
- wpa_supplicant_conf_ap_ht(wpa_s, ssid, conf);
-
-- if (hostapd_setup_interface(ifmsh)) {
-- wpa_printf(MSG_ERROR,
-- "Failed to initialize hostapd interface for mesh");
-+ if (wpa_drv_init_mesh(wpa_s)) {
-+ wpa_msg(wpa_s, MSG_ERROR, "Failed to init mesh in driver");
- return -1;
- }
-
-- if (wpa_drv_init_mesh(wpa_s)) {
-- wpa_msg(wpa_s, MSG_ERROR, "Failed to init mesh in driver");
-+ if (hostapd_setup_interface(ifmsh)) {
-+ wpa_printf(MSG_ERROR,
-+ "Failed to initialize hostapd interface for mesh");
- return -1;
- }
-
+++ /dev/null
-From 4347c97600f4484be8df804dfb5ed85b867d3c43 Mon Sep 17 00:00:00 2001
-From: Peter Oh <peter.oh@bowerswilkins.com>
-Date: Thu, 12 Apr 2018 02:49:06 -0700
-Subject: [PATCH 09/15] mesh: set mesh center frequency
-
-vht center frequency value is required to compose the correct channel info.
-
-Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
----
- wpa_supplicant/mesh.c | 1 +
- 1 file changed, 1 insertion(+)
-
---- a/wpa_supplicant/mesh.c
-+++ b/wpa_supplicant/mesh.c
-@@ -453,6 +453,7 @@ int wpa_supplicant_join_mesh(struct wpa_
-
- if (wpa_s->mesh_vht_enabled) {
- ssid->vht = 1;
-+ ssid->vht_center_freq1 = params->freq.center_freq1;
- switch (params->freq.bandwidth) {
- case 80:
- if (params->freq.center_freq2) {
--- /dev/null
+From ce3e491e445ebea9705e76ac7ee3d4841ace1cad Mon Sep 17 00:00:00 2001
+From: Peter Oh <peter.oh@bowerswilkins.com>
+Date: Tue, 17 Apr 2018 21:55:08 -0700
+Subject: [PATCH 11/16] mesh: Allow DFS channels to be selected if dfs is
+ enabled
+
+Note: DFS is assumed to be usable if a country code has been set
+
+Signed-off-by: Benjamin Berg <benjamin@sipsolutions.net>
+Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
+---
+ wpa_supplicant/wpa_supplicant.c | 24 ++++++++++++++++++------
+ 1 file changed, 18 insertions(+), 6 deletions(-)
+
+--- a/wpa_supplicant/wpa_supplicant.c
++++ b/wpa_supplicant/wpa_supplicant.c
+@@ -2033,6 +2033,8 @@ void ibss_mesh_setup_freq(struct wpa_sup
+ struct hostapd_freq_params vht_freq;
+ int chwidth, seg0, seg1;
+ u32 vht_caps = 0;
++ int dfs_enabled = wpa_s->conf->country[0] &&
++ (wpa_s->drv_flags & WPA_DRIVER_FLAGS_RADAR);
+
+ freq->freq = ssid->frequency;
+
+@@ -2109,8 +2111,11 @@ void ibss_mesh_setup_freq(struct wpa_sup
+ return;
+
+ /* Check primary channel flags */
+- if (pri_chan->flag & (HOSTAPD_CHAN_DISABLED | HOSTAPD_CHAN_NO_IR))
++ if (pri_chan->flag & HOSTAPD_CHAN_DISABLED)
+ return;
++ if (pri_chan->flag & (HOSTAPD_CHAN_RADAR | HOSTAPD_CHAN_NO_IR))
++ if (!dfs_enabled)
++ return;
+
+ #ifdef CONFIG_HT_OVERRIDES
+ if (ssid->disable_ht40)
+@@ -2136,8 +2141,11 @@ void ibss_mesh_setup_freq(struct wpa_sup
+ return;
+
+ /* Check secondary channel flags */
+- if (sec_chan->flag & (HOSTAPD_CHAN_DISABLED | HOSTAPD_CHAN_NO_IR))
++ if (sec_chan->flag & HOSTAPD_CHAN_DISABLED)
+ return;
++ if (sec_chan->flag & (HOSTAPD_CHAN_RADAR | HOSTAPD_CHAN_NO_IR))
++ if (!dfs_enabled)
++ return;
+
+ freq->channel = pri_chan->chan;
+
+@@ -2227,8 +2235,11 @@ void ibss_mesh_setup_freq(struct wpa_sup
+ return;
+
+ /* Back to HT configuration if channel not usable */
+- if (chan->flag & (HOSTAPD_CHAN_DISABLED | HOSTAPD_CHAN_NO_IR))
++ if (chan->flag & HOSTAPD_CHAN_DISABLED)
+ return;
++ if (chan->flag & (HOSTAPD_CHAN_RADAR | HOSTAPD_CHAN_NO_IR))
++ if (!dfs_enabled)
++ return;
+ }
+
+ chwidth = VHT_CHANWIDTH_80MHZ;
+@@ -2248,10 +2259,11 @@ void ibss_mesh_setup_freq(struct wpa_sup
+ if (!chan)
+ continue;
+
+- if (chan->flag & (HOSTAPD_CHAN_DISABLED |
+- HOSTAPD_CHAN_NO_IR |
+- HOSTAPD_CHAN_RADAR))
++ if (chan->flag & HOSTAPD_CHAN_DISABLED)
+ continue;
++ if (chan->flag & (HOSTAPD_CHAN_RADAR | HOSTAPD_CHAN_NO_IR))
++ if (!dfs_enabled)
++ continue;
+
+ /* Found a suitable second segment for 80+80 */
+ chwidth = VHT_CHANWIDTH_80P80MHZ;
+++ /dev/null
-From d0a0e1030005834b99225feb64ec3794d31beab0 Mon Sep 17 00:00:00 2001
-From: Peter Oh <peter.oh@bowerswilkins.com>
-Date: Thu, 12 Apr 2018 02:49:07 -0700
-Subject: [PATCH 10/15] mesh: consider mesh interface on dfs event handler
-
-Once mesh starts supporting DFS channels, it has to handle DFS related events
-from drivers, hence add mesh interface to the check list.
-
-Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
----
- wpa_supplicant/ap.c | 55 ++++++++++++++++++++++++++++++++---------
- wpa_supplicant/events.c | 1 +
- 2 files changed, 44 insertions(+), 12 deletions(-)
-
---- a/wpa_supplicant/ap.c
-+++ b/wpa_supplicant/ap.c
-@@ -1328,13 +1328,18 @@ int ap_ctrl_iface_chanswitch(struct wpa_
- void wpas_ap_ch_switch(struct wpa_supplicant *wpa_s, int freq, int ht,
- int offset, int width, int cf1, int cf2)
- {
-+ struct hostapd_iface *iface = wpa_s->ap_iface;
-+
- if (!wpa_s->ap_iface)
-- return;
-+ if (!wpa_s->ifmsh)
-+ return;
-+ else
-+ iface = wpa_s->ifmsh;
-
- wpa_s->assoc_freq = freq;
- if (wpa_s->current_ssid)
- wpa_s->current_ssid->frequency = freq;
-- hostapd_event_ch_switch(wpa_s->ap_iface->bss[0], freq, ht,
-+ hostapd_event_ch_switch(iface->bss[0], freq, ht,
- offset, width, cf1, cf2);
- }
-
-@@ -1531,10 +1536,15 @@ int wpas_ap_pmksa_cache_add_external(str
- void wpas_event_dfs_radar_detected(struct wpa_supplicant *wpa_s,
- struct dfs_event *radar)
- {
-+ struct hostapd_iface *iface = wpa_s->ap_iface;
-+
- if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0])
-- return;
-+ if (!wpa_s->ifmsh || !wpa_s->ifmsh->bss[0])
-+ return;
-+ else
-+ iface = wpa_s->ifmsh;
- wpa_printf(MSG_DEBUG, "DFS radar detected on %d MHz", radar->freq);
-- hostapd_dfs_radar_detected(wpa_s->ap_iface, radar->freq,
-+ hostapd_dfs_radar_detected(iface, radar->freq,
- radar->ht_enabled, radar->chan_offset,
- radar->chan_width,
- radar->cf1, radar->cf2);
-@@ -1544,10 +1554,15 @@ void wpas_event_dfs_radar_detected(struc
- void wpas_event_dfs_cac_started(struct wpa_supplicant *wpa_s,
- struct dfs_event *radar)
- {
-+ struct hostapd_iface *iface = wpa_s->ap_iface;
-+
- if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0])
-- return;
-+ if (!wpa_s->ifmsh || !wpa_s->ifmsh->bss[0])
-+ return;
-+ else
-+ iface = wpa_s->ifmsh;
- wpa_printf(MSG_DEBUG, "DFS CAC started on %d MHz", radar->freq);
-- hostapd_dfs_start_cac(wpa_s->ap_iface, radar->freq,
-+ hostapd_dfs_start_cac(iface, radar->freq,
- radar->ht_enabled, radar->chan_offset,
- radar->chan_width, radar->cf1, radar->cf2);
- }
-@@ -1556,10 +1571,16 @@ void wpas_event_dfs_cac_started(struct w
- void wpas_event_dfs_cac_finished(struct wpa_supplicant *wpa_s,
- struct dfs_event *radar)
- {
-+ struct hostapd_iface *iface = wpa_s->ap_iface;
-+
- if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0])
-- return;
-+ if (!wpa_s->ifmsh || !wpa_s->ifmsh->bss[0])
-+ return;
-+ else
-+ iface = wpa_s->ifmsh;
-+
- wpa_printf(MSG_DEBUG, "DFS CAC finished on %d MHz", radar->freq);
-- hostapd_dfs_complete_cac(wpa_s->ap_iface, 1, radar->freq,
-+ hostapd_dfs_complete_cac(iface, 1, radar->freq,
- radar->ht_enabled, radar->chan_offset,
- radar->chan_width, radar->cf1, radar->cf2);
- }
-@@ -1568,10 +1589,15 @@ void wpas_event_dfs_cac_finished(struct
- void wpas_event_dfs_cac_aborted(struct wpa_supplicant *wpa_s,
- struct dfs_event *radar)
- {
-+ struct hostapd_iface *iface = wpa_s->ap_iface;
-+
- if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0])
-- return;
-+ if (!wpa_s->ifmsh || !wpa_s->ifmsh->bss[0])
-+ return;
-+ else
-+ iface = wpa_s->ifmsh;
- wpa_printf(MSG_DEBUG, "DFS CAC aborted on %d MHz", radar->freq);
-- hostapd_dfs_complete_cac(wpa_s->ap_iface, 0, radar->freq,
-+ hostapd_dfs_complete_cac(iface, 0, radar->freq,
- radar->ht_enabled, radar->chan_offset,
- radar->chan_width, radar->cf1, radar->cf2);
- }
-@@ -1580,10 +1606,15 @@ void wpas_event_dfs_cac_aborted(struct w
- void wpas_event_dfs_cac_nop_finished(struct wpa_supplicant *wpa_s,
- struct dfs_event *radar)
- {
-+ struct hostapd_iface *iface = wpa_s->ap_iface;
-+
- if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0])
-- return;
-+ if (!wpa_s->ifmsh || !wpa_s->ifmsh->bss[0])
-+ return;
-+ else
-+ iface = wpa_s->ifmsh;
- wpa_printf(MSG_DEBUG, "DFS NOP finished on %d MHz", radar->freq);
-- hostapd_dfs_nop_finished(wpa_s->ap_iface, radar->freq,
-+ hostapd_dfs_nop_finished(iface, radar->freq,
- radar->ht_enabled, radar->chan_offset,
- radar->chan_width, radar->cf1, radar->cf2);
- }
---- a/wpa_supplicant/events.c
-+++ b/wpa_supplicant/events.c
-@@ -4168,6 +4168,7 @@ void wpa_supplicant_event(void *ctx, enu
-
- if (wpa_s->current_ssid->mode == WPAS_MODE_AP ||
- wpa_s->current_ssid->mode == WPAS_MODE_P2P_GO ||
-+ wpa_s->current_ssid->mode == WPAS_MODE_MESH ||
- wpa_s->current_ssid->mode ==
- WPAS_MODE_P2P_GROUP_FORMATION) {
- wpas_ap_ch_switch(wpa_s, data->ch_switch.freq,
+++ /dev/null
-From e7fc5d2e6b34102282ff94a6e5255af4b6e9ccb5 Mon Sep 17 00:00:00 2001
-From: Peter Oh <peter.oh@bowerswilkins.com>
-Date: Thu, 12 Apr 2018 02:49:08 -0700
-Subject: [PATCH 11/15] mesh: Allow DFS channels to be selected if dfs is
- enabled
-
-Note: DFS is assumed to be usable if a country code has been set
-
-Signed-off-by: Benjamin Berg <benjamin@sipsolutions.net>
-Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
----
- wpa_supplicant/wpa_supplicant.c | 24 ++++++++++++++++++------
- 1 file changed, 18 insertions(+), 6 deletions(-)
-
---- a/wpa_supplicant/wpa_supplicant.c
-+++ b/wpa_supplicant/wpa_supplicant.c
-@@ -2033,6 +2033,8 @@ void ibss_mesh_setup_freq(struct wpa_sup
- struct hostapd_freq_params vht_freq;
- int chwidth, seg0, seg1;
- u32 vht_caps = 0;
-+ int dfs_enabled = wpa_s->conf->country[0] &&
-+ (wpa_s->drv_flags & WPA_DRIVER_FLAGS_RADAR);
-
- freq->freq = ssid->frequency;
-
-@@ -2109,8 +2111,11 @@ void ibss_mesh_setup_freq(struct wpa_sup
- return;
-
- /* Check primary channel flags */
-- if (pri_chan->flag & (HOSTAPD_CHAN_DISABLED | HOSTAPD_CHAN_NO_IR))
-+ if (pri_chan->flag & HOSTAPD_CHAN_DISABLED)
- return;
-+ if (pri_chan->flag & (HOSTAPD_CHAN_RADAR | HOSTAPD_CHAN_NO_IR))
-+ if (!dfs_enabled)
-+ return;
-
- #ifdef CONFIG_HT_OVERRIDES
- if (ssid->disable_ht40)
-@@ -2136,8 +2141,11 @@ void ibss_mesh_setup_freq(struct wpa_sup
- return;
-
- /* Check secondary channel flags */
-- if (sec_chan->flag & (HOSTAPD_CHAN_DISABLED | HOSTAPD_CHAN_NO_IR))
-+ if (sec_chan->flag & HOSTAPD_CHAN_DISABLED)
- return;
-+ if (sec_chan->flag & (HOSTAPD_CHAN_RADAR | HOSTAPD_CHAN_NO_IR))
-+ if (!dfs_enabled)
-+ return;
-
- freq->channel = pri_chan->chan;
-
-@@ -2227,8 +2235,11 @@ void ibss_mesh_setup_freq(struct wpa_sup
- return;
-
- /* Back to HT configuration if channel not usable */
-- if (chan->flag & (HOSTAPD_CHAN_DISABLED | HOSTAPD_CHAN_NO_IR))
-+ if (chan->flag & HOSTAPD_CHAN_DISABLED)
- return;
-+ if (chan->flag & (HOSTAPD_CHAN_RADAR | HOSTAPD_CHAN_NO_IR))
-+ if (!dfs_enabled)
-+ return;
- }
-
- chwidth = VHT_CHANWIDTH_80MHZ;
-@@ -2248,10 +2259,11 @@ void ibss_mesh_setup_freq(struct wpa_sup
- if (!chan)
- continue;
-
-- if (chan->flag & (HOSTAPD_CHAN_DISABLED |
-- HOSTAPD_CHAN_NO_IR |
-- HOSTAPD_CHAN_RADAR))
-+ if (chan->flag & HOSTAPD_CHAN_DISABLED)
- continue;
-+ if (chan->flag & (HOSTAPD_CHAN_RADAR | HOSTAPD_CHAN_NO_IR))
-+ if (!dfs_enabled)
-+ continue;
-
- /* Found a suitable second segment for 80+80 */
- chwidth = VHT_CHANWIDTH_80P80MHZ;
+++ /dev/null
-From 851f67301a8b9bc96c3d8cce08e355a64d30350d Mon Sep 17 00:00:00 2001
-From: Peter Oh <peter.oh@bowerswilkins.com>
-Date: Thu, 12 Apr 2018 02:49:09 -0700
-Subject: [PATCH 12/15] mesh: allow mesh to send channel switch request
-
-add mesh type to nl80211 channel switch request,
-so mesh is able to send the request to kernel drivers.
-
-Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
----
- src/drivers/driver_nl80211.c | 3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
-
---- a/src/drivers/driver_nl80211.c
-+++ b/src/drivers/driver_nl80211.c
-@@ -8659,7 +8659,8 @@ static int nl80211_switch_channel(void *
- }
-
- if ((drv->nlmode != NL80211_IFTYPE_AP) &&
-- (drv->nlmode != NL80211_IFTYPE_P2P_GO))
-+ (drv->nlmode != NL80211_IFTYPE_P2P_GO) &&
-+ (drv->nlmode != NL80211_IFTYPE_MESH_POINT) )
- return -EOPNOTSUPP;
-
- /*
+++ /dev/null
-From 5fe4fa1c1f426d81496458d2127bfbd7623fe5d5 Mon Sep 17 00:00:00 2001
-From: Peter Oh <peter.oh@bowerswilkins.com>
-Date: Thu, 12 Apr 2018 02:49:10 -0700
-Subject: [PATCH 13/15] mesh: do not allow pri/sec channel switch
-
-We don't want mesh to switch the channel from primary to secondary,
-since mesh points are not able to join each other in that case.
-
-Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
----
- wpa_supplicant/mesh.c | 5 ++++-
- 1 file changed, 4 insertions(+), 1 deletion(-)
-
---- a/wpa_supplicant/mesh.c
-+++ b/wpa_supplicant/mesh.c
-@@ -333,7 +333,10 @@ static int wpa_supplicant_mesh_init(stru
- rate_len * sizeof(int));
- conf->basic_rates[rate_len] = -1;
- }
--
-+ /* Do not allow primary/secondary channel switch in mesh mode,
-+ * since mesh is not able to establish a physical link for it
-+ */
-+ conf->no_pri_sec_switch = 1;
- wpa_supplicant_conf_ap_ht(wpa_s, ssid, conf);
-
- if (wpa_drv_init_mesh(wpa_s)) {
+++ /dev/null
-From fcc5fe675d1155d65df0471aa06f746c28b66b6c Mon Sep 17 00:00:00 2001
-From: Peter Oh <peter.oh@bowerswilkins.com>
-Date: Thu, 12 Apr 2018 02:49:11 -0700
-Subject: [PATCH 14/15] mesh: do not allow scan result to swap pri/sec
-
-Swapping between primary and secondary channel will break
-mesh from joining, hence don't allow it.
-
-Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
----
- wpa_supplicant/wpa_supplicant.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
---- a/wpa_supplicant/wpa_supplicant.c
-+++ b/wpa_supplicant/wpa_supplicant.c
-@@ -2158,7 +2158,7 @@ void ibss_mesh_setup_freq(struct wpa_sup
- }
- freq->sec_channel_offset = ht40;
-
-- if (obss_scan) {
-+ if (ssid->mode != WPAS_MODE_MESH && obss_scan) {
- struct wpa_scan_results *scan_res;
-
- scan_res = wpa_supplicant_get_scan_results(wpa_s, NULL, 0);
+++ /dev/null
-From ab2ba9fd9ac73c83dc15a6d76d93df4434d539d6 Mon Sep 17 00:00:00 2001
-From: Peter Oh <peter.oh@bowerswilkins.com>
-Date: Thu, 12 Apr 2018 02:49:12 -0700
-Subject: [PATCH 15/15] mesh: do not use offchan mgmt tx on DFS
-
-Drivers don't allow mesh to use offchannel on management Tx.
-
-Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
----
- src/drivers/driver_nl80211.c | 5 ++++-
- 1 file changed, 4 insertions(+), 1 deletion(-)
-
---- a/src/drivers/driver_nl80211.c
-+++ b/src/drivers/driver_nl80211.c
-@@ -7148,6 +7148,7 @@ static int wpa_driver_nl80211_send_actio
- struct wpa_driver_nl80211_data *drv = bss->drv;
- int ret = -1;
- u8 *buf;
-+ int offchanok = 1;
- struct ieee80211_hdr *hdr;
-
- wpa_printf(MSG_DEBUG, "nl80211: Send Action frame (ifindex=%d, "
-@@ -7173,6 +7174,8 @@ static int wpa_driver_nl80211_send_actio
- os_memset(bss->rand_addr, 0, ETH_ALEN);
- }
-
-+ if (is_mesh_interface(drv->nlmode) && ieee80211_is_dfs(freq))
-+ offchanok = 0;
- if (is_ap_interface(drv->nlmode) &&
- (!(drv->capa.flags & WPA_DRIVER_FLAGS_OFFCHANNEL_TX) ||
- (int) freq == bss->freq || drv->device_ap_sme ||
-@@ -7184,7 +7187,7 @@ static int wpa_driver_nl80211_send_actio
- ret = nl80211_send_frame_cmd(bss, freq, wait_time, buf,
- 24 + data_len,
- &drv->send_action_cookie,
-- no_cck, 0, 1, NULL, 0);
-+ no_cck, 0, offchanok, NULL, 0);
-
- os_free(buf);
- return ret;
--- /dev/null
+From 912b5c89328f1f9585e64fd13460928c71f28352 Mon Sep 17 00:00:00 2001
+From: Peter Oh <peter.oh@bowerswilkins.com>
+Date: Tue, 17 Apr 2018 21:55:09 -0700
+Subject: [PATCH 12/16] mesh: allow mesh to send channel switch request
+
+add mesh type to nl80211 channel switch request,
+so mesh is able to send the request to kernel drivers.
+
+Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
+---
+ src/drivers/driver_nl80211.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -8685,7 +8685,8 @@ static int nl80211_switch_channel(void *
+ }
+
+ if ((drv->nlmode != NL80211_IFTYPE_AP) &&
+- (drv->nlmode != NL80211_IFTYPE_P2P_GO))
++ (drv->nlmode != NL80211_IFTYPE_P2P_GO) &&
++ (drv->nlmode != NL80211_IFTYPE_MESH_POINT) )
+ return -EOPNOTSUPP;
+
+ /*
--- /dev/null
+From d7ae7271dce4203bfcd79a230acb24f03f38633d Mon Sep 17 00:00:00 2001
+From: Peter Oh <peter.oh@bowerswilkins.com>
+Date: Tue, 17 Apr 2018 21:55:10 -0700
+Subject: [PATCH 13/16] mesh: do not allow pri/sec channel switch
+
+We don't want mesh to switch the channel from primary to secondary,
+since mesh points are not able to join each other in that case.
+
+Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
+---
+ wpa_supplicant/mesh.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+--- a/wpa_supplicant/mesh.c
++++ b/wpa_supplicant/mesh.c
+@@ -336,7 +336,10 @@ static int wpa_supplicant_mesh_init(stru
+ rate_len * sizeof(int));
+ conf->basic_rates[rate_len] = -1;
+ }
+-
++ /* Do not allow primary/secondary channel switch in mesh mode,
++ * since mesh is not able to establish a physical link for it
++ */
++ conf->no_pri_sec_switch = 1;
+ wpa_supplicant_conf_ap_ht(wpa_s, ssid, conf);
+
+ if (wpa_drv_init_mesh(wpa_s)) {
--- /dev/null
+From cf2ba81fb307f3e87e13896f9dbf93c0c2a9eb92 Mon Sep 17 00:00:00 2001
+From: Peter Oh <peter.oh@bowerswilkins.com>
+Date: Tue, 17 Apr 2018 21:55:11 -0700
+Subject: [PATCH 14/16] mesh: do not allow scan result to swap pri/sec
+
+Swapping between primary and secondary channel will break
+mesh from joining, hence don't allow it.
+
+Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
+---
+ wpa_supplicant/wpa_supplicant.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/wpa_supplicant/wpa_supplicant.c
++++ b/wpa_supplicant/wpa_supplicant.c
+@@ -2158,7 +2158,7 @@ void ibss_mesh_setup_freq(struct wpa_sup
+ }
+ freq->sec_channel_offset = ht40;
+
+- if (obss_scan) {
++ if (ssid->mode != WPAS_MODE_MESH && obss_scan) {
+ struct wpa_scan_results *scan_res;
+
+ scan_res = wpa_supplicant_get_scan_results(wpa_s, NULL, 0);
--- /dev/null
+From 48f31256ffebfc43d6b14b93597aa2c7e2975dc4 Mon Sep 17 00:00:00 2001
+From: Peter Oh <peter.oh@bowerswilkins.com>
+Date: Tue, 17 Apr 2018 21:55:12 -0700
+Subject: [PATCH 15/16] mesh: do not use offchan mgmt tx on DFS
+
+Drivers don't allow mesh to use offchannel on management Tx.
+
+Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
+---
+ src/drivers/driver_nl80211.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -7165,6 +7165,10 @@ static int wpa_driver_nl80211_send_actio
+ struct wpa_driver_nl80211_data *drv = bss->drv;
+ int ret = -1;
+ u8 *buf;
++ int offchanok = 1;
++ u16 num_modes, flags;
++ struct hostapd_hw_modes *modes;
++ u8 dfs_domain;
+ struct ieee80211_hdr *hdr;
+
+ wpa_printf(MSG_DEBUG, "nl80211: Send Action frame (ifindex=%d, "
+@@ -7190,6 +7194,12 @@ static int wpa_driver_nl80211_send_actio
+ os_memset(bss->rand_addr, 0, ETH_ALEN);
+ }
+
++ if (is_mesh_interface(drv->nlmode) &&
++ (modes = nl80211_get_hw_feature_data(bss, &num_modes, &flags,
++ &dfs_domain)) &&
++ ieee80211_is_dfs(freq, modes, num_modes))
++ offchanok = 0;
++
+ if (is_ap_interface(drv->nlmode) &&
+ (!(drv->capa.flags & WPA_DRIVER_FLAGS_OFFCHANNEL_TX) ||
+ (int) freq == bss->freq || drv->device_ap_sme ||
+@@ -7201,7 +7211,7 @@ static int wpa_driver_nl80211_send_actio
+ ret = nl80211_send_frame_cmd(bss, freq, wait_time, buf,
+ 24 + data_len,
+ &drv->send_action_cookie,
+- no_cck, 0, 1, NULL, 0);
++ no_cck, 0, offchanok, NULL, 0);
+
+ os_free(buf);
+ return ret;
--- /dev/null
+From 9a01d7f21bd33725dc33325a437c3cc4185ee8bd Mon Sep 17 00:00:00 2001
+From: Daniel Golle <daniel@makrotopia.org>
+Date: Wed, 18 Apr 2018 19:24:31 +0200
+Subject: [PATCH 16/16] mesh: make forwarding configurable
+
+Allow mesh_fwding to be specified in a mesh bss config, pass that
+to the driver (only nl80211 implemented for now) and announce
+forwarding capability accordingly.
+
+Signed-off-by: Daniel Golle <daniel@makrotopia.org>
+---
+ src/ap/ap_config.h | 2 ++
+ src/drivers/driver.h | 2 ++
+ src/drivers/driver_nl80211.c | 3 +++
+ wpa_supplicant/config.c | 4 ++++
+ wpa_supplicant/config.h | 9 +++++++++
+ wpa_supplicant/config_file.c | 4 ++++
+ wpa_supplicant/config_ssid.h | 5 +++++
+ wpa_supplicant/mesh.c | 6 ++++++
+ wpa_supplicant/mesh_mpm.c | 4 ++--
+ wpa_supplicant/wpa_supplicant.conf | 3 +++
+ 10 files changed, 40 insertions(+), 2 deletions(-)
+
+--- a/src/ap/ap_config.h
++++ b/src/ap/ap_config.h
+@@ -49,6 +49,7 @@ struct mesh_conf {
+ int dot11MeshRetryTimeout; /* msec */
+ int dot11MeshConfirmTimeout; /* msec */
+ int dot11MeshHoldingTimeout; /* msec */
++ int mesh_fwding;
+ };
+
+ #define MAX_STA_COUNT 2007
+@@ -618,6 +619,7 @@ struct hostapd_bss_config {
+
+ #define MESH_ENABLED BIT(0)
+ int mesh;
++ int mesh_fwding;
+
+ u8 radio_measurements[RRM_CAPABILITIES_IE_LEN];
+
+--- a/src/drivers/driver.h
++++ b/src/drivers/driver.h
+@@ -1363,6 +1363,7 @@ struct wpa_driver_mesh_bss_params {
+ #define WPA_DRIVER_MESH_CONF_FLAG_MAX_PEER_LINKS 0x00000004
+ #define WPA_DRIVER_MESH_CONF_FLAG_HT_OP_MODE 0x00000008
+ #define WPA_DRIVER_MESH_CONF_FLAG_RSSI_THRESHOLD 0x00000010
++#define WPA_DRIVER_MESH_CONF_FLAG_FORWARDING 0x00000020
+ /*
+ * TODO: Other mesh configuration parameters would go here.
+ * See NL80211_MESHCONF_* for all the mesh config parameters.
+@@ -1372,6 +1373,7 @@ struct wpa_driver_mesh_bss_params {
+ int peer_link_timeout;
+ int max_peer_links;
+ int rssi_threshold;
++ int forwarding;
+ u16 ht_opmode;
+ };
+
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -9230,6 +9230,9 @@ static int nl80211_put_mesh_config(struc
+ if (((params->flags & WPA_DRIVER_MESH_CONF_FLAG_AUTO_PLINKS) &&
+ nla_put_u8(msg, NL80211_MESHCONF_AUTO_OPEN_PLINKS,
+ params->auto_plinks)) ||
++ ((params->flags & WPA_DRIVER_MESH_CONF_FLAG_FORWARDING) &&
++ nla_put_u8(msg, NL80211_MESHCONF_FORWARDING,
++ params->forwarding)) ||
+ ((params->flags & WPA_DRIVER_MESH_CONF_FLAG_MAX_PEER_LINKS) &&
+ nla_put_u16(msg, NL80211_MESHCONF_MAX_PEER_LINKS,
+ params->max_peer_links)) ||
+--- a/wpa_supplicant/config.c
++++ b/wpa_supplicant/config.c
+@@ -2211,6 +2211,7 @@ static const struct parse_data ssid_fiel
+ #ifdef CONFIG_MESH
+ { INT_RANGE(mode, 0, 5) },
+ { INT_RANGE(no_auto_peer, 0, 1) },
++ { INT_RANGE(mesh_fwding, 0, 1) },
+ { INT_RANGE(mesh_rssi_threshold, -255, 1) },
+ #else /* CONFIG_MESH */
+ { INT_RANGE(mode, 0, 4) },
+@@ -2761,6 +2762,7 @@ void wpa_config_set_network_defaults(str
+ ssid->dot11MeshRetryTimeout = DEFAULT_MESH_RETRY_TIMEOUT;
+ ssid->dot11MeshConfirmTimeout = DEFAULT_MESH_CONFIRM_TIMEOUT;
+ ssid->dot11MeshHoldingTimeout = DEFAULT_MESH_HOLDING_TIMEOUT;
++ ssid->mesh_fwding = DEFAULT_MESH_FWDING;
+ ssid->mesh_rssi_threshold = DEFAULT_MESH_RSSI_THRESHOLD;
+ #endif /* CONFIG_MESH */
+ #ifdef CONFIG_HT_OVERRIDES
+@@ -3976,6 +3978,7 @@ struct wpa_config * wpa_config_alloc_emp
+ config->user_mpm = DEFAULT_USER_MPM;
+ config->max_peer_links = DEFAULT_MAX_PEER_LINKS;
+ config->mesh_max_inactivity = DEFAULT_MESH_MAX_INACTIVITY;
++ config->mesh_fwding = DEFAULT_MESH_FWDING;
+ config->dot11RSNASAERetransPeriod =
+ DEFAULT_DOT11_RSNA_SAE_RETRANS_PERIOD;
+ config->fast_reauth = DEFAULT_FAST_REAUTH;
+@@ -4598,6 +4601,7 @@ static const struct global_parse_data gl
+ { INT(user_mpm), 0 },
+ { INT_RANGE(max_peer_links, 0, 255), 0 },
+ { INT(mesh_max_inactivity), 0 },
++ { INT_RANGE(mesh_fwding, 0, 1), 0 },
+ { INT(dot11RSNASAERetransPeriod), 0 },
+ #endif /* CONFIG_MESH */
+ { INT(disable_scan_offload), 0 },
+--- a/wpa_supplicant/config.h
++++ b/wpa_supplicant/config.h
+@@ -18,6 +18,7 @@
+ #define DEFAULT_USER_MPM 1
+ #define DEFAULT_MAX_PEER_LINKS 99
+ #define DEFAULT_MESH_MAX_INACTIVITY 300
++#define DEFAULT_MESH_FWDING 1
+ /*
+ * The default dot11RSNASAERetransPeriod is defined as 40 ms in the standard,
+ * but use 1000 ms in practice to avoid issues on low power CPUs.
+@@ -1306,6 +1307,14 @@ struct wpa_config {
+ int mesh_max_inactivity;
+
+ /**
++ * mesh_fwding - Mesh network layer-2 forwarding
++ *
++ * This controls whether to enable layer-2 forwarding.
++ * By default: 1: enabled
++ */
++ int mesh_fwding;
++
++ /**
+ * dot11RSNASAERetransPeriod - Timeout to retransmit SAE Auth frame
+ *
+ * This timeout value is used in mesh STA to retransmit
+--- a/wpa_supplicant/config_file.c
++++ b/wpa_supplicant/config_file.c
+@@ -817,6 +817,7 @@ static void wpa_config_write_network(FIL
+ #endif /* IEEE8021X_EAPOL */
+ INT(mode);
+ INT(no_auto_peer);
++ INT(mesh_fwding);
+ INT(frequency);
+ INT(fixed_freq);
+ #ifdef CONFIG_ACS
+@@ -1449,6 +1450,9 @@ static void wpa_config_write_global(FILE
+ fprintf(f, "mesh_max_inactivity=%d\n",
+ config->mesh_max_inactivity);
+
++ if (config->mesh_fwding != DEFAULT_MESH_FWDING)
++ fprintf(f, "mesh_fwding=%d\n", config->mesh_fwding);
++
+ if (config->dot11RSNASAERetransPeriod !=
+ DEFAULT_DOT11_RSNA_SAE_RETRANS_PERIOD)
+ fprintf(f, "dot11RSNASAERetransPeriod=%d\n",
+--- a/wpa_supplicant/config_ssid.h
++++ b/wpa_supplicant/config_ssid.h
+@@ -492,6 +492,11 @@ struct wpa_ssid {
+ int dot11MeshConfirmTimeout; /* msec */
+ int dot11MeshHoldingTimeout; /* msec */
+
++ /**
++ * Mesh network layer-2 forwarding
++ */
++ int mesh_fwding;
++
+ int ht;
+ int ht40;
+
+--- a/wpa_supplicant/mesh.c
++++ b/wpa_supplicant/mesh.c
+@@ -120,6 +120,7 @@ static struct mesh_conf * mesh_config_cr
+ conf->mesh_cc_id = 0;
+ conf->mesh_sp_id = MESH_SYNC_METHOD_NEIGHBOR_OFFSET;
+ conf->mesh_auth_id = (conf->security & MESH_CONF_SEC_AUTH) ? 1 : 0;
++ conf->mesh_fwding = ssid->mesh_fwding;
+ conf->dot11MeshMaxRetries = ssid->dot11MeshMaxRetries;
+ conf->dot11MeshRetryTimeout = ssid->dot11MeshRetryTimeout;
+ conf->dot11MeshConfirmTimeout = ssid->dot11MeshConfirmTimeout;
+@@ -254,6 +255,7 @@ static int wpa_supplicant_mesh_init(stru
+ bss->conf->start_disabled = 1;
+ bss->conf->mesh = MESH_ENABLED;
+ bss->conf->ap_max_inactivity = wpa_s->conf->mesh_max_inactivity;
++ bss->conf->mesh_fwding = wpa_s->conf->mesh_fwding;
+
+ if (ieee80211_is_dfs(ssid->frequency, wpa_s->hw.modes,
+ wpa_s->hw.num_modes) && wpa_s->conf->country[0]) {
+@@ -507,6 +509,10 @@ int wpa_supplicant_join_mesh(struct wpa_
+ }
+ params->conf.peer_link_timeout = wpa_s->conf->mesh_max_inactivity;
+
++ /* always explicitely set forwarding to on or off for now */
++ params->conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_FORWARDING;
++ params->conf.forwarding = ssid->mesh_fwding;
++
+ wpa_s->mesh_params = params;
+ if (wpa_supplicant_mesh_init(wpa_s, ssid, ¶ms->freq)) {
+ wpa_msg(wpa_s, MSG_ERROR, "Failed to init mesh");
+--- a/wpa_supplicant/mesh_mpm.c
++++ b/wpa_supplicant/mesh_mpm.c
+@@ -288,9 +288,9 @@ static void mesh_mpm_send_plink_action(s
+ info = (bss->num_plinks > 63 ? 63 : bss->num_plinks) << 1;
+ /* TODO: Add Connected to Mesh Gate/AS subfields */
+ wpabuf_put_u8(buf, info);
+- /* always forwarding & accepting plinks for now */
++ /* set forwarding & always accepting plinks for now */
+ wpabuf_put_u8(buf, MESH_CAP_ACCEPT_ADDITIONAL_PEER |
+- MESH_CAP_FORWARDING);
++ (conf->mesh_fwding ? MESH_CAP_FORWARDING : 0));
+ } else { /* Peer closing frame */
+ /* IE: Mesh ID */
+ wpabuf_put_u8(buf, WLAN_EID_MESH_ID);
+--- a/wpa_supplicant/wpa_supplicant.conf
++++ b/wpa_supplicant/wpa_supplicant.conf
+@@ -153,6 +153,9 @@ ap_scan=1
+ # This timeout value is used in mesh STA to clean up inactive stations.
+ #mesh_max_inactivity=300
+
++# Enable 802.11s layer-2 routing and forwarding
++#mesh_fwding=1
++
+ # cert_in_cb - Whether to include a peer certificate dump in events
+ # This controls whether peer certificates for authentication server and
+ # its certificate chain are included in EAP peer certificate events. This is
+++ /dev/null
-From 30c1693f42326d4f927e76120492bc9593b8f739 Mon Sep 17 00:00:00 2001
-From: Daniel Golle <daniel@makrotopia.org>
-Date: Fri, 13 Apr 2018 00:42:10 +0200
-Subject: [PATCH] mesh: properly handle sae_password
-
-The recently introduced sae_password parameter is only handled properly
-in wpa_supplicant/sme.c while wpa_supplicant/mesh.c assumed that
-ssid->passphrase exclusively holds the secret.
-Import the logic from sme.c to mesh.c to allow having only sae_password
-set which otherwise throws this error:
-AP-ENABLED
-mesh: Passphrase for SAE not configured
-Init RSN failed. Deinit mesh...
-wlan1: interface state ENABLED->DISABLED
-AP-DISABLED
-Segmentation fault
-
-Signed-off-by: Daniel Golle <daniel@makrotopia.org>
----
- wpa_supplicant/mesh.c | 10 +++++++---
- 1 file changed, 7 insertions(+), 3 deletions(-)
-
---- a/wpa_supplicant/mesh.c
-+++ b/wpa_supplicant/mesh.c
-@@ -154,10 +154,14 @@ int wpas_mesh_init_rsn(struct wpa_suppli
- struct wpa_ssid *ssid = wpa_s->current_ssid;
- struct hostapd_data *bss = ifmsh->bss[0];
- static int default_groups[] = { 19, 20, 21, 25, 26, -1 };
-+ const char *password;
- size_t len;
-
- if (mconf->security != MESH_CONF_SEC_NONE) {
-- if (ssid->passphrase == NULL) {
-+ password = ssid->sae_password;
-+ if (!password)
-+ password = ssid->passphrase;
-+ if (!password) {
- wpa_printf(MSG_ERROR,
- "mesh: Passphrase for SAE not configured");
- return -1;
-@@ -177,9 +181,9 @@ int wpas_mesh_init_rsn(struct wpa_suppli
- return -1;
- }
-
-- len = os_strlen(ssid->passphrase);
-+ len = os_strlen(password);
- bss->conf->ssid.wpa_passphrase =
-- dup_binstr(ssid->passphrase, len);
-+ dup_binstr(password, len);
-
- wpa_s->mesh_rsn = mesh_rsn_auth_init(wpa_s, mconf);
- if (!wpa_s->mesh_rsn)
+++ /dev/null
-From d11881c1ad0d6a102962d1a040a398f597256ae0 Mon Sep 17 00:00:00 2001
-From: Daniel Golle <daniel@makrotopia.org>
-Date: Wed, 18 Apr 2018 19:24:31 +0200
-Subject: [PATCH] mesh: make forwarding configurable
-To: hostap@lists.infradead.org
-Cc: Jouni Malinen <j@w1.fi>,
- Johannes Berg <johannes.berg@intel.com>
-
-Allow mesh_fwding to be specified in a mesh bss config, pass that
-to the driver (only nl80211 implemented for now) and announce
-forwarding capability accordingly.
-
-Signed-off-by: Daniel Golle <daniel@makrotopia.org>
----
- src/ap/ap_config.h | 2 ++
- src/drivers/driver.h | 2 ++
- src/drivers/driver_nl80211.c | 3 +++
- wpa_supplicant/config.c | 4 ++++
- wpa_supplicant/config.h | 3 +++
- wpa_supplicant/config_file.c | 4 ++++
- wpa_supplicant/config_ssid.h | 5 +++++
- wpa_supplicant/mesh.c | 6 ++++++
- wpa_supplicant/mesh_mpm.c | 4 ++--
- wpa_supplicant/wpa_supplicant.conf | 6 ++++++
- 10 files changed, 37 insertions(+), 2 deletions(-)
-
---- a/src/ap/ap_config.h
-+++ b/src/ap/ap_config.h
-@@ -49,6 +49,7 @@ struct mesh_conf {
- int dot11MeshRetryTimeout; /* msec */
- int dot11MeshConfirmTimeout; /* msec */
- int dot11MeshHoldingTimeout; /* msec */
-+ int mesh_fwding;
- };
-
- #define MAX_STA_COUNT 2007
-@@ -612,6 +613,7 @@ struct hostapd_bss_config {
-
- #define MESH_ENABLED BIT(0)
- int mesh;
-+ int mesh_fwding;
-
- u8 radio_measurements[RRM_CAPABILITIES_IE_LEN];
-
---- a/src/drivers/driver.h
-+++ b/src/drivers/driver.h
-@@ -1363,6 +1363,7 @@ struct wpa_driver_mesh_bss_params {
- #define WPA_DRIVER_MESH_CONF_FLAG_MAX_PEER_LINKS 0x00000004
- #define WPA_DRIVER_MESH_CONF_FLAG_HT_OP_MODE 0x00000008
- #define WPA_DRIVER_MESH_CONF_FLAG_RSSI_THRESHOLD 0x00000010
-+#define WPA_DRIVER_MESH_CONF_FLAG_FORWARDING 0x00000020
- /*
- * TODO: Other mesh configuration parameters would go here.
- * See NL80211_MESHCONF_* for all the mesh config parameters.
-@@ -1372,6 +1373,7 @@ struct wpa_driver_mesh_bss_params {
- int peer_link_timeout;
- int max_peer_links;
- int rssi_threshold;
-+ int forwarding;
- u16 ht_opmode;
- };
-
---- a/src/drivers/driver_nl80211.c
-+++ b/src/drivers/driver_nl80211.c
-@@ -9197,6 +9197,9 @@ static int nl80211_put_mesh_config(struc
- if (((params->flags & WPA_DRIVER_MESH_CONF_FLAG_AUTO_PLINKS) &&
- nla_put_u8(msg, NL80211_MESHCONF_AUTO_OPEN_PLINKS,
- params->auto_plinks)) ||
-+ ((params->flags & WPA_DRIVER_MESH_CONF_FLAG_FORWARDING) &&
-+ nla_put_u8(msg, NL80211_MESHCONF_FORWARDING,
-+ params->forwarding)) ||
- ((params->flags & WPA_DRIVER_MESH_CONF_FLAG_MAX_PEER_LINKS) &&
- nla_put_u16(msg, NL80211_MESHCONF_MAX_PEER_LINKS,
- params->max_peer_links)) ||
---- a/wpa_supplicant/config.c
-+++ b/wpa_supplicant/config.c
-@@ -2211,6 +2211,7 @@ static const struct parse_data ssid_fiel
- #ifdef CONFIG_MESH
- { INT_RANGE(mode, 0, 5) },
- { INT_RANGE(no_auto_peer, 0, 1) },
-+ { INT_RANGE(mesh_fwding, 0, 1) },
- { INT_RANGE(mesh_rssi_threshold, -255, 1) },
- #else /* CONFIG_MESH */
- { INT_RANGE(mode, 0, 4) },
-@@ -2757,6 +2758,7 @@ void wpa_config_set_network_defaults(str
- ssid->dot11MeshRetryTimeout = DEFAULT_MESH_RETRY_TIMEOUT;
- ssid->dot11MeshConfirmTimeout = DEFAULT_MESH_CONFIRM_TIMEOUT;
- ssid->dot11MeshHoldingTimeout = DEFAULT_MESH_HOLDING_TIMEOUT;
-+ ssid->mesh_fwding = DEFAULT_MESH_FWDING;
- ssid->mesh_rssi_threshold = DEFAULT_MESH_RSSI_THRESHOLD;
- #endif /* CONFIG_MESH */
- #ifdef CONFIG_HT_OVERRIDES
-@@ -3886,6 +3888,7 @@ struct wpa_config * wpa_config_alloc_emp
- config->user_mpm = DEFAULT_USER_MPM;
- config->max_peer_links = DEFAULT_MAX_PEER_LINKS;
- config->mesh_max_inactivity = DEFAULT_MESH_MAX_INACTIVITY;
-+ config->mesh_fwding = DEFAULT_MESH_FWDING;
- config->dot11RSNASAERetransPeriod =
- DEFAULT_DOT11_RSNA_SAE_RETRANS_PERIOD;
- config->fast_reauth = DEFAULT_FAST_REAUTH;
-@@ -4508,6 +4511,7 @@ static const struct global_parse_data gl
- { INT(user_mpm), 0 },
- { INT_RANGE(max_peer_links, 0, 255), 0 },
- { INT(mesh_max_inactivity), 0 },
-+ { INT_RANGE(mesh_fwding, 0, 1), 0 },
- { INT(dot11RSNASAERetransPeriod), 0 },
- #endif /* CONFIG_MESH */
- { INT(disable_scan_offload), 0 },
---- a/wpa_supplicant/config.h
-+++ b/wpa_supplicant/config.h
-@@ -18,6 +18,7 @@
- #define DEFAULT_USER_MPM 1
- #define DEFAULT_MAX_PEER_LINKS 99
- #define DEFAULT_MESH_MAX_INACTIVITY 300
-+#define DEFAULT_MESH_FWDING 1
- /*
- * The default dot11RSNASAERetransPeriod is defined as 40 ms in the standard,
- * but use 1000 ms in practice to avoid issues on low power CPUs.
-@@ -1269,6 +1270,8 @@ struct wpa_config {
- */
- int mesh_max_inactivity;
-
-+ int mesh_fwding;
-+
- /**
- * dot11RSNASAERetransPeriod - Timeout to retransmit SAE Auth frame
- *
---- a/wpa_supplicant/config_file.c
-+++ b/wpa_supplicant/config_file.c
-@@ -816,6 +816,7 @@ static void wpa_config_write_network(FIL
- #endif /* IEEE8021X_EAPOL */
- INT(mode);
- INT(no_auto_peer);
-+ INT(mesh_fwding);
- INT(frequency);
- INT(fixed_freq);
- #ifdef CONFIG_ACS
-@@ -1433,6 +1434,9 @@ static void wpa_config_write_global(FILE
- fprintf(f, "mesh_max_inactivity=%d\n",
- config->mesh_max_inactivity);
-
-+ if (config->mesh_fwding != DEFAULT_MESH_FWDING)
-+ fprintf(f, "mesh_fwding=%d\n", config->mesh_fwding);
-+
- if (config->dot11RSNASAERetransPeriod !=
- DEFAULT_DOT11_RSNA_SAE_RETRANS_PERIOD)
- fprintf(f, "dot11RSNASAERetransPeriod=%d\n",
---- a/wpa_supplicant/config_ssid.h
-+++ b/wpa_supplicant/config_ssid.h
-@@ -492,6 +492,11 @@ struct wpa_ssid {
- int dot11MeshConfirmTimeout; /* msec */
- int dot11MeshHoldingTimeout; /* msec */
-
-+ /**
-+ * Mesh network layer-2 forwarding
-+ */
-+ int mesh_fwding;
-+
- int ht;
- int ht40;
-
---- a/wpa_supplicant/mesh.c
-+++ b/wpa_supplicant/mesh.c
-@@ -121,6 +121,7 @@ static struct mesh_conf * mesh_config_cr
- conf->mesh_cc_id = 0;
- conf->mesh_sp_id = MESH_SYNC_METHOD_NEIGHBOR_OFFSET;
- conf->mesh_auth_id = (conf->security & MESH_CONF_SEC_AUTH) ? 1 : 0;
-+ conf->mesh_fwding = ssid->mesh_fwding;
- conf->dot11MeshMaxRetries = ssid->dot11MeshMaxRetries;
- conf->dot11MeshRetryTimeout = ssid->dot11MeshRetryTimeout;
- conf->dot11MeshConfirmTimeout = ssid->dot11MeshConfirmTimeout;
-@@ -256,6 +257,7 @@ static int wpa_supplicant_mesh_init(stru
- bss->conf->start_disabled = 1;
- bss->conf->mesh = MESH_ENABLED;
- bss->conf->ap_max_inactivity = wpa_s->conf->mesh_max_inactivity;
-+ bss->conf->mesh_fwding = wpa_s->conf->mesh_fwding;
-
- if (ieee80211_is_dfs(ssid->frequency) && wpa_s->conf->country[0]) {
- conf->ieee80211h = 1;
-@@ -508,6 +510,10 @@ int wpa_supplicant_join_mesh(struct wpa_
- }
- params->conf.peer_link_timeout = wpa_s->conf->mesh_max_inactivity;
-
-+ /* always explicitely set forwarding to on or off for now */
-+ params->conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_FORWARDING;
-+ params->conf.forwarding = ssid->mesh_fwding;
-+
- wpa_s->mesh_params = params;
- if (wpa_supplicant_mesh_init(wpa_s, ssid, ¶ms->freq)) {
- wpa_msg(wpa_s, MSG_ERROR, "Failed to init mesh");
---- a/wpa_supplicant/mesh_mpm.c
-+++ b/wpa_supplicant/mesh_mpm.c
-@@ -288,9 +288,9 @@ static void mesh_mpm_send_plink_action(s
- info = (bss->num_plinks > 63 ? 63 : bss->num_plinks) << 1;
- /* TODO: Add Connected to Mesh Gate/AS subfields */
- wpabuf_put_u8(buf, info);
-- /* always forwarding & accepting plinks for now */
-+ /* set forwarding & always accepting plinks for now */
- wpabuf_put_u8(buf, MESH_CAP_ACCEPT_ADDITIONAL_PEER |
-- MESH_CAP_FORWARDING);
-+ (conf->mesh_fwding ? MESH_CAP_FORWARDING : 0));
- } else { /* Peer closing frame */
- /* IE: Mesh ID */
- wpabuf_put_u8(buf, WLAN_EID_MESH_ID);
---- a/wpa_supplicant/wpa_supplicant.conf
-+++ b/wpa_supplicant/wpa_supplicant.conf
-@@ -153,6 +153,12 @@ ap_scan=1
- # This timeout value is used in mesh STA to clean up inactive stations.
- #mesh_max_inactivity=300
-
-+# Enable 802.11s layer-2 routing and forwarding
-+#mesh_fwding=1
-+
-+# Accept additional peer links
-+#mesh_auto_open_plinks=1
-+
- # cert_in_cb - Whether to include a peer certificate dump in events
- # This controls whether peer certificates for authentication server and
- # its certificate chain are included in EAP peer certificate events. This is
--- a/wpa_supplicant/mesh.c
+++ b/wpa_supplicant/mesh.c
-@@ -216,7 +216,7 @@ static int wpa_supplicant_mesh_init(stru
+@@ -214,7 +214,7 @@ static int wpa_supplicant_mesh_init(stru
return 0;
}
+++ /dev/null
---- a/src/rsn_supp/pmksa_cache.h
-+++ b/src/rsn_supp/pmksa_cache.h
-@@ -101,7 +101,7 @@ static inline void pmksa_cache_deinit(st
-
- static inline struct rsn_pmksa_cache_entry *
- pmksa_cache_get(struct rsn_pmksa_cache *pmksa, const u8 *aa, const u8 *pmkid,
-- const void *network_ctx)
-+ const void *network_ctx, int akmp)
- {
- return NULL;
- }
-@@ -148,7 +148,8 @@ static inline int pmksa_cache_set_curren
- const u8 *bssid,
- void *network_ctx,
- int try_opportunistic,
-- const u8 *fils_cache_id)
-+ const u8 *fils_cache_id,
-+ int akmp)
- {
- return -1;
- }
--- a/wpa_supplicant/config.c
+++ b/wpa_supplicant/config.c
-@@ -2796,6 +2796,7 @@ void wpa_config_set_network_defaults(str
+@@ -2800,6 +2800,7 @@ void wpa_config_set_network_defaults(str
ssid->mka_priority = DEFAULT_PRIO_NOT_KEY_SERVER;
#endif /* CONFIG_MACSEC */
ssid->mac_addr = -1;
LIBS += $(DRV_AP_LIBS)
ifdef CONFIG_L2_PACKET
-@@ -1270,6 +1276,12 @@ install: $(addprefix $(DESTDIR)$(BINDIR)
+@@ -1274,6 +1280,12 @@ install: $(addprefix $(DESTDIR)$(BINDIR)
BCHECK=../src/drivers/build.hostapd
hostapd: $(BCHECK) $(OBJS)
$(Q)$(CC) $(LDFLAGS) -o hostapd $(OBJS) $(LIBS)
@$(E) " LD " $@
-@@ -1315,6 +1327,12 @@ ifeq ($(CONFIG_TLS), linux)
+@@ -1316,6 +1328,12 @@ ifeq ($(CONFIG_TLS), linux)
HOBJS += ../src/crypto/crypto_linux.o
endif
NEED_AES_WRAP=y
OBJS += ../src/ap/wpa_auth.o
OBJS += ../src/ap/wpa_auth_ie.o
-@@ -1887,6 +1904,12 @@ wpa_priv: $(BCHECK) $(OBJS_priv)
+@@ -1888,6 +1905,12 @@ wpa_priv: $(BCHECK) $(OBJS_priv)
$(OBJS_c) $(OBJS_t) $(OBJS_t2) $(OBJS) $(BCHECK) $(EXTRA_progs): .config
wpa_supplicant: $(BCHECK) $(OBJS) $(EXTRA_progs)
$(Q)$(LDO) $(LDFLAGS) -o wpa_supplicant $(OBJS) $(LIBS) $(EXTRALIBS)
@$(E) " LD " $@
-@@ -1989,6 +2012,12 @@ endif
+@@ -1990,6 +2013,12 @@ endif
-e 's|\@DBUS_INTERFACE\@|$(DBUS_INTERFACE)|g' $< >$@
@$(E) " sed" $<
wpa_cli.exe: wpa_cli
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
-@@ -5430,8 +5430,8 @@ union wpa_event_data {
+@@ -5449,8 +5449,8 @@ union wpa_event_data {
* Driver wrapper code should call this function whenever an event is received
* from the driver.
*/
/**
* wpa_supplicant_event_global - Report a driver event for wpa_supplicant
-@@ -5443,7 +5443,7 @@ void wpa_supplicant_event(void *ctx, enu
+@@ -5462,7 +5462,7 @@ void wpa_supplicant_event(void *ctx, enu
* Same as wpa_supplicant_event(), but we search for the interface in
* wpa_global.
*/
/*
--- a/src/ap/drv_callbacks.c
+++ b/src/ap/drv_callbacks.c
-@@ -1473,8 +1473,8 @@ static void hostapd_event_dfs_cac_starte
- #endif /* NEED_AP_MLME */
+@@ -1515,8 +1515,8 @@ static void hostapd_event_wds_sta_interf
+ }
-void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
{
struct hostapd_data *hapd = ctx;
#ifndef CONFIG_NO_STDOUT_DEBUG
-@@ -1694,7 +1694,7 @@ void wpa_supplicant_event(void *ctx, enu
+@@ -1742,7 +1742,7 @@ void wpa_supplicant_event(void *ctx, enu
}
os_memset(&global, 0, sizeof(global));
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
-@@ -3812,8 +3812,8 @@ static void wpa_supplicant_event_assoc_a
+@@ -3901,8 +3901,8 @@ static void wpas_event_assoc_reject(stru
}
{
struct wpa_supplicant *wpa_s = ctx;
int resched;
-@@ -4632,7 +4632,7 @@ void wpa_supplicant_event(void *ctx, enu
+@@ -4669,7 +4669,7 @@ void wpa_supplicant_event(void *ctx, enu
}
struct wpa_supplicant *wpa_s;
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
-@@ -5736,7 +5736,6 @@ struct wpa_interface * wpa_supplicant_ma
+@@ -5770,7 +5770,6 @@ struct wpa_interface * wpa_supplicant_ma
return NULL;
}
/**
* wpa_supplicant_match_existing - Match existing interfaces
* @global: Pointer to global data from wpa_supplicant_init()
-@@ -5773,6 +5772,11 @@ static int wpa_supplicant_match_existing
+@@ -5807,6 +5806,11 @@ static int wpa_supplicant_match_existing
#endif /* CONFIG_MATCH_IFACE */
/**
* wpa_supplicant_add_iface - Add a new network interface
-@@ -6029,6 +6033,8 @@ struct wpa_global * wpa_supplicant_init(
+@@ -6063,6 +6067,8 @@ struct wpa_global * wpa_supplicant_init(
#ifndef CONFIG_NO_WPA_MSG
wpa_msg_register_ifname_cb(wpa_supplicant_msg_ifname_cb);
#endif /* CONFIG_NO_WPA_MSG */
--- a/hostapd/config_file.c
+++ b/hostapd/config_file.c
-@@ -3131,6 +3131,10 @@ static int hostapd_config_fill(struct ho
+@@ -3159,6 +3159,10 @@ static int hostapd_config_fill(struct ho
}
#endif /* CONFIG_IEEE80211W */
#ifdef CONFIG_IEEE80211N
} else if (os_strcmp(buf, "ht_capab") == 0) {
--- a/src/ap/ap_config.h
+++ b/src/ap/ap_config.h
-@@ -763,6 +763,8 @@ struct hostapd_config {
+@@ -769,6 +769,8 @@ struct hostapd_config {
int ht_op_mode_fixed;
u16 ht_capab;
{ STR(id_str) },
--- a/wpa_supplicant/config_file.c
+++ b/wpa_supplicant/config_file.c
-@@ -816,6 +816,7 @@ static void wpa_config_write_network(FIL
+@@ -817,6 +817,7 @@ static void wpa_config_write_network(FIL
#endif /* IEEE8021X_EAPOL */
INT(mode);
INT(no_auto_peer);
INT(fixed_freq);
--- a/wpa_supplicant/mesh.c
+++ b/wpa_supplicant/mesh.c
-@@ -287,6 +287,8 @@ static int wpa_supplicant_mesh_init(stru
+@@ -286,6 +286,8 @@ static int wpa_supplicant_mesh_init(stru
frequency);
goto out_free;
}
for (chan_idx = 0; chan_idx < mode->num_channels; chan_idx++) {
--- a/wpa_supplicant/config_ssid.h
+++ b/wpa_supplicant/config_ssid.h
-@@ -835,6 +835,8 @@ struct wpa_ssid {
+@@ -848,6 +848,8 @@ struct wpa_ssid {
*/
int no_auto_peer;
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
-@@ -4187,7 +4187,7 @@ wpa_supplicant_alloc(struct wpa_supplica
+@@ -4221,7 +4221,7 @@ wpa_supplicant_alloc(struct wpa_supplica
if (wpa_s == NULL)
return NULL;
wpa_s->scan_req = INITIAL_SCAN_REQ;
--- a/src/ap/hostapd.c
+++ b/src/ap/hostapd.c
-@@ -90,6 +90,25 @@ static void hostapd_reload_bss(struct ho
+@@ -93,6 +93,25 @@ static void hostapd_reload_bss(struct ho
#endif /* CONFIG_NO_RADIUS */
ssid = &hapd->conf->ssid;
if (!ssid->wpa_psk_set && ssid->wpa_psk && !ssid->wpa_psk->next &&
ssid->wpa_passphrase_set && ssid->wpa_passphrase) {
/*
-@@ -168,6 +187,7 @@ int hostapd_reload_config(struct hostapd
+@@ -171,6 +190,7 @@ int hostapd_reload_config(struct hostapd
struct hostapd_data *hapd = iface->bss[0];
struct hostapd_config *newconf, *oldconf;
size_t j;
if (iface->config_fname == NULL) {
/* Only in-memory config in use - assume it has been updated */
-@@ -189,21 +209,20 @@ int hostapd_reload_config(struct hostapd
+@@ -192,21 +212,20 @@ int hostapd_reload_config(struct hostapd
oldconf = hapd->iconf;
iface->conf = newconf;
}
-@@ -7040,8 +7045,6 @@ static int wpa_driver_nl80211_if_remove(
+@@ -7057,8 +7062,6 @@ static int wpa_driver_nl80211_if_remove(
} else {
wpa_printf(MSG_DEBUG, "nl80211: First BSS - reassign context");
nl80211_teardown_ap(bss);
nl80211_destroy_bss(bss);
if (!bss->added_if)
i802_set_iface_flags(bss, 0);
-@@ -7415,7 +7418,6 @@ static int wpa_driver_nl80211_deinit_ap(
+@@ -7439,7 +7442,6 @@ static int wpa_driver_nl80211_deinit_ap(
if (!is_ap_interface(drv->nlmode))
return -1;
wpa_driver_nl80211_del_beacon(bss);
/*
* If the P2P GO interface was dynamically added, then it is
-@@ -7435,7 +7437,6 @@ static int wpa_driver_nl80211_stop_ap(vo
+@@ -7459,7 +7461,6 @@ static int wpa_driver_nl80211_stop_ap(vo
if (!is_ap_interface(drv->nlmode))
return -1;
wpa_driver_nl80211_del_beacon(bss);
#ifdef CONFIG_IEEE80211W
#ifdef NEED_AP_MLME
-@@ -3026,6 +3083,8 @@ static int hostapd_ctrl_iface_receive_pr
+@@ -3031,6 +3088,8 @@ static int hostapd_ctrl_iface_receive_pr
} else if (os_strncmp(buf, "VENDOR ", 7) == 0) {
reply_len = hostapd_ctrl_iface_vendor(hapd, buf + 7, reply,
reply_size);
#ifdef RADIUS_SERVER
--- a/src/ap/ctrl_iface_ap.c
+++ b/src/ap/ctrl_iface_ap.c
-@@ -857,7 +857,13 @@ int hostapd_parse_csa_settings(const cha
+@@ -864,7 +864,13 @@ int hostapd_parse_csa_settings(const cha
int hostapd_ctrl_iface_stop_ap(struct hostapd_data *hapd)
{
#include "drivers/driver.h"
#include "eap_peer/eap.h"
#include "wpa_supplicant_i.h"
-@@ -290,6 +291,10 @@ void calculate_update_time(const struct
+@@ -292,6 +293,10 @@ void calculate_update_time(const struct
static void wpa_bss_copy_res(struct wpa_bss *dst, struct wpa_scan_res *src,
struct os_reltime *fetch_time)
{
dst->flags = src->flags;
os_memcpy(dst->bssid, src->bssid, ETH_ALEN);
dst->freq = src->freq;
-@@ -302,6 +307,15 @@ static void wpa_bss_copy_res(struct wpa_
+@@ -304,6 +309,15 @@ static void wpa_bss_copy_res(struct wpa_
dst->est_throughput = src->est_throughput;
dst->snr = src->snr;
--- a/wpa_supplicant/bss.h
+++ b/wpa_supplicant/bss.h
-@@ -80,6 +80,10 @@ struct wpa_bss {
+@@ -81,6 +81,10 @@ struct wpa_bss {
u8 ssid[SSID_MAX_LEN];
/** Length of SSID */
size_t ssid_len;
#else /* CONFIG_MESH */
wpa_msg(wpa_s, MSG_ERROR,
"mesh mode support not included in the build");
-@@ -5362,6 +5417,16 @@ static int wpa_supplicant_init_iface(str
+@@ -5396,6 +5451,16 @@ static int wpa_supplicant_init_iface(str
sizeof(wpa_s->bridge_ifname));
}
/* RSNA Supplicant Key Management - INITIALIZE */
eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
eapol_sm_notify_portValid(wpa_s->eapol, FALSE);
-@@ -5683,6 +5748,11 @@ static void wpa_supplicant_deinit_iface(
+@@ -5717,6 +5782,11 @@ static void wpa_supplicant_deinit_iface(
if (terminate)
wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_TERMINATING);
else
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
-@@ -2852,6 +2852,7 @@ static int hostapd_ctrl_iface_receive_pr
+@@ -2857,6 +2857,7 @@ static int hostapd_ctrl_iface_receive_pr
reply_size);
} else if (os_strcmp(buf, "STATUS-DRIVER") == 0) {
reply_len = hostapd_drv_status(hapd, reply, reply_size);
} else if (os_strcmp(buf, "MIB") == 0) {
reply_len = ieee802_11_get_mib(hapd, reply, reply_size);
if (reply_len >= 0) {
-@@ -2893,6 +2894,7 @@ static int hostapd_ctrl_iface_receive_pr
+@@ -2898,6 +2899,7 @@ static int hostapd_ctrl_iface_receive_pr
} else if (os_strncmp(buf, "STA-NEXT ", 9) == 0) {
reply_len = hostapd_ctrl_iface_sta_next(hapd, buf + 9, reply,
reply_size);
if (wpa_s->ap_iface) {
pos += ap_ctrl_iface_wpa_get_status(wpa_s, pos,
end - pos,
-@@ -9809,6 +9809,7 @@ char * wpa_supplicant_ctrl_iface_process
+@@ -9825,6 +9825,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) {
-@@ -9816,6 +9817,7 @@ char * wpa_supplicant_ctrl_iface_process
+@@ -9832,6 +9833,7 @@ char * wpa_supplicant_ctrl_iface_process
reply + reply_len,
reply_size - reply_len);
}
} else if (os_strncmp(buf, "STATUS", 6) == 0) {
reply_len = wpa_supplicant_ctrl_iface_status(
wpa_s, buf + 6, reply, reply_size);
-@@ -10297,6 +10299,7 @@ char * wpa_supplicant_ctrl_iface_process
+@@ -10313,6 +10315,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) {
-@@ -10305,12 +10308,15 @@ char * wpa_supplicant_ctrl_iface_process
+@@ -10321,12 +10324,15 @@ char * wpa_supplicant_ctrl_iface_process
} else if (os_strncmp(buf, "STA-NEXT ", 9) == 0) {
reply_len = ap_ctrl_iface_sta_next(wpa_s, buf + 9, reply,
reply_size);
static size_t hostapd_write_ht_mcs_bitmask(char *buf, size_t buflen,
size_t curr_len, const u8 *mcs_set)
-@@ -408,6 +409,7 @@ int hostapd_ctrl_iface_sta_next(struct h
+@@ -415,6 +416,7 @@ int hostapd_ctrl_iface_sta_next(struct h
return hostapd_ctrl_iface_sta_mib(hapd, sta->next, buf, buflen);
}
#ifdef CONFIG_P2P_MANAGER
static int p2p_manager_disconnect(struct hostapd_data *hapd, u16 stype,
-@@ -746,12 +748,12 @@ int hostapd_ctrl_iface_status(struct hos
+@@ -753,12 +755,12 @@ int hostapd_ctrl_iface_status(struct hos
return len;
len += ret;
}
if (os_snprintf_error(buflen - len, ret))
--- a/src/ap/ieee802_1x.c
+++ b/src/ap/ieee802_1x.c
-@@ -2504,6 +2504,7 @@ static const char * bool_txt(Boolean val
+@@ -2555,6 +2555,7 @@ static const char * bool_txt(Boolean val
return val ? "TRUE" : "FALSE";
}
int ieee802_1x_get_mib(struct hostapd_data *hapd, char *buf, size_t buflen)
{
-@@ -2679,6 +2680,7 @@ int ieee802_1x_get_mib_sta(struct hostap
+@@ -2730,6 +2731,7 @@ int ieee802_1x_get_mib_sta(struct hostap
return len;
}
--- a/wpa_supplicant/ap.c
+++ b/wpa_supplicant/ap.c
-@@ -1170,7 +1170,7 @@ int wpas_ap_wps_nfc_report_handover(stru
+@@ -1179,7 +1179,7 @@ int wpas_ap_wps_nfc_report_handover(stru
#endif /* CONFIG_WPS */
* macsec_policy - Determines the policy for MACsec secure session
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
-@@ -3000,6 +3000,12 @@ static void wpas_start_assoc_cb(struct w
+@@ -3034,6 +3034,12 @@ static void wpas_start_assoc_cb(struct w
params.beacon_int = ssid->beacon_int;
else
params.beacon_int = wpa_s->conf->beacon_int;
/**
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
-@@ -9217,6 +9217,18 @@ static int nl80211_put_mesh_id(struct nl
+@@ -9250,6 +9250,18 @@ static int nl80211_put_mesh_id(struct nl
}
static int nl80211_put_mesh_config(struct nl_msg *msg,
struct wpa_driver_mesh_bss_params *params)
{
-@@ -9278,6 +9290,7 @@ static int nl80211_join_mesh(struct i802
+@@ -9311,6 +9323,7 @@ static int nl80211_join_mesh(struct i802
nl80211_put_basic_rates(msg, params->basic_rates) ||
nl80211_put_mesh_id(msg, params->meshid, params->meshid_len) ||
nl80211_put_beacon_int(msg, params->beacon_int) ||
--- a/wpa_supplicant/mesh.c
+++ b/wpa_supplicant/mesh.c
-@@ -456,6 +456,7 @@ int wpa_supplicant_join_mesh(struct wpa_
+@@ -455,6 +455,7 @@ int wpa_supplicant_join_mesh(struct wpa_
params->meshid = ssid->ssid;
params->meshid_len = ssid->ssid_len;
struct hostapd_iface * hostapd_alloc_iface(void);
--- a/src/ap/hostapd.c
+++ b/src/ap/hostapd.c
-@@ -312,6 +312,7 @@ static void hostapd_free_hapd_data(struc
+@@ -315,6 +315,7 @@ static void hostapd_free_hapd_data(struc
hapd->started = 0;
wpa_printf(MSG_DEBUG, "%s(%s)", __func__, hapd->conf->iface);
iapp_deinit(hapd->iapp);
hapd->iapp = NULL;
accounting_deinit(hapd);
-@@ -1189,6 +1190,8 @@ static int hostapd_setup_bss(struct host
+@@ -1237,6 +1238,8 @@ static int hostapd_setup_bss(struct host
if (hapd->driver && hapd->driver->set_operstate)
hapd->driver->set_operstate(hapd->drv_priv, 1);
return 0;
}
-@@ -1603,7 +1606,7 @@ static enum nr_chan_width hostapd_get_nr
+@@ -1651,7 +1654,7 @@ static enum nr_chan_width hostapd_get_nr
#endif /* NEED_AP_MLME */
{
#ifdef NEED_AP_MLME
u16 capab = hostapd_own_capab_info(hapd);
-@@ -1810,6 +1813,7 @@ static int hostapd_setup_interface_compl
+@@ -1872,6 +1875,7 @@ static int hostapd_setup_interface_compl
if (err)
goto fail;
wpa_printf(MSG_DEBUG, "Completing interface initialization");
if (iface->conf->channel) {
#ifdef NEED_AP_MLME
-@@ -1990,6 +1994,7 @@ dfs_offload:
+@@ -2052,6 +2056,7 @@ dfs_offload:
fail:
wpa_printf(MSG_ERROR, "Interface initialization failed");
hostapd_set_state(iface, HAPD_IFACE_DISABLED);
wpa_msg(hapd->msg_ctx, MSG_INFO, AP_EVENT_DISABLED);
#ifdef CONFIG_FST
-@@ -2444,6 +2449,7 @@ void hostapd_interface_deinit_free(struc
+@@ -2517,6 +2522,7 @@ void hostapd_interface_deinit_free(struc
(unsigned int) iface->conf->num_bss);
driver = iface->bss[0]->driver;
drv_priv = iface->bss[0]->drv_priv;
if (res == HOSTAPD_ACL_PENDING)
return;
-@@ -3129,12 +3142,12 @@ void fils_hlp_timeout(void *eloop_ctx, v
+@@ -3137,12 +3150,12 @@ void fils_hlp_timeout(void *eloop_ctx, v
static void handle_assoc(struct hostapd_data *hapd,
const struct ieee80211_mgmt *mgmt, size_t len,
struct sta_info *sta;
u8 *tmp = NULL;
struct hostapd_sta_wpa_psk_short *psk = NULL;
-@@ -3143,6 +3156,11 @@ static void handle_assoc(struct hostapd_
+@@ -3151,6 +3164,11 @@ static void handle_assoc(struct hostapd_
#ifdef CONFIG_FILS
int delay_assoc = 0;
#endif /* CONFIG_FILS */
if (len < IEEE80211_HDRLEN + (reassoc ? sizeof(mgmt->u.reassoc_req) :
sizeof(mgmt->u.assoc_req))) {
-@@ -3314,6 +3332,14 @@ static void handle_assoc(struct hostapd_
+@@ -3322,6 +3340,14 @@ static void handle_assoc(struct hostapd_
}
#endif /* CONFIG_MBO */
/*
* sta->capability is used in check_assoc_ies() for RRM enabled
* capability element.
-@@ -3527,6 +3553,7 @@ static void handle_disassoc(struct hosta
+@@ -3535,6 +3561,7 @@ static void handle_disassoc(struct hosta
wpa_printf(MSG_DEBUG, "disassocation: STA=" MACSTR " reason_code=%d",
MAC2STR(mgmt->sa),
le_to_host16(mgmt->u.disassoc.reason_code));
sta = ap_get_sta(hapd, mgmt->sa);
if (sta == NULL) {
-@@ -3592,6 +3619,8 @@ static void handle_deauth(struct hostapd
+@@ -3600,6 +3627,8 @@ static void handle_deauth(struct hostapd
" reason_code=%d",
MAC2STR(mgmt->sa), le_to_host16(mgmt->u.deauth.reason_code));
sta = ap_get_sta(hapd, mgmt->sa);
if (sta == NULL) {
wpa_msg(hapd->msg_ctx, MSG_DEBUG, "Station " MACSTR " trying "
-@@ -3911,7 +3940,7 @@ int ieee802_11_mgmt(struct hostapd_data
+@@ -3919,7 +3948,7 @@ int ieee802_11_mgmt(struct hostapd_data
if (stype == WLAN_FC_STYPE_PROBE_REQ) {
return 1;
}
-@@ -3931,17 +3960,17 @@ int ieee802_11_mgmt(struct hostapd_data
+@@ -3939,17 +3968,17 @@ int ieee802_11_mgmt(struct hostapd_data
switch (stype) {
case WLAN_FC_STYPE_AUTH:
wpa_printf(MSG_DEBUG, "mgmt::auth");
wpabuf_free(sta->p2p_ie);
--- a/src/ap/sta_info.c
+++ b/src/ap/sta_info.c
-@@ -412,6 +412,7 @@ void ap_handle_timer(void *eloop_ctx, vo
+@@ -415,6 +415,7 @@ void ap_handle_timer(void *eloop_ctx, vo
HOSTAPD_LEVEL_INFO, "deauthenticated due to "
"local deauth request");
ap_free_sta(hapd, sta);
return;
}
-@@ -559,6 +560,7 @@ skip_poll:
+@@ -562,6 +563,7 @@ skip_poll:
hapd, sta,
WLAN_REASON_PREV_AUTH_NOT_VALID);
ap_free_sta(hapd, sta);
break;
}
}
-@@ -1220,6 +1222,7 @@ void ap_sta_set_authorized(struct hostap
+@@ -1223,6 +1225,7 @@ void ap_sta_set_authorized(struct hostap
buf, ip_addr);
} else {
wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_DISCONNECTED "%s", buf);