[PATCH v2 11/12] mesh: move mesh freq setting to own function
Markus Theil
markus.theil at tu-ilmenau.de
Tue Jun 30 08:19:06 EDT 2020
Signed-off-by: Markus Theil <markus.theil at tu-ilmenau.de>
---
wpa_supplicant/mesh.c | 63 ++++++++++++++++++++++++++-----------------
1 file changed, 38 insertions(+), 25 deletions(-)
diff --git a/wpa_supplicant/mesh.c b/wpa_supplicant/mesh.c
index 383ec1c7b..f3788bf36 100644
--- a/wpa_supplicant/mesh.c
+++ b/wpa_supplicant/mesh.c
@@ -31,7 +31,7 @@
static void wpa_supplicant_mesh_deinit(struct wpa_supplicant *wpa_s, bool also_clear_hostapd)
{
wpa_supplicant_mesh_iface_deinit(wpa_s, wpa_s->ifmsh, also_clear_hostapd);
-
+
if (also_clear_hostapd) {
wpa_s->ifmsh = NULL;
wpa_s->current_ssid = NULL;
@@ -201,6 +201,40 @@ static int wpas_mesh_init_rsn(struct wpa_supplicant *wpa_s)
return !wpa_s->mesh_rsn ? -1 : 0;
}
+
+static int wpas_mesh_update_freq_params(struct wpa_supplicant *wpa_s)
+{
+ struct wpa_driver_mesh_join_params *params = wpa_s->mesh_params;
+ struct hostapd_iface *ifmsh = wpa_s->ifmsh;
+ struct he_capabilities *he_capab = NULL;
+
+ if (ifmsh->current_mode)
+ he_capab = &ifmsh->current_mode->he_capab[IEEE80211_MODE_MESH];
+
+ if (hostapd_set_freq_params(¶ms->freq,
+ ifmsh->conf->hw_mode,
+ ifmsh->freq,
+ ifmsh->conf->channel,
+ ifmsh->conf->enable_edmg,
+ ifmsh->conf->edmg_channel,
+ ifmsh->conf->ieee80211n,
+ ifmsh->conf->ieee80211ac,
+ ifmsh->conf->ieee80211ax,
+ ifmsh->conf->secondary_channel,
+ hostapd_get_oper_chwidth(ifmsh->conf),
+ hostapd_get_oper_centr_freq_seg0_idx(ifmsh->conf),
+ hostapd_get_oper_centr_freq_seg1_idx(ifmsh->conf),
+ ifmsh->conf->vht_capab,
+ he_capab)) {
+ wpa_printf(MSG_ERROR, "Error updating mesh frequency params.");
+ wpa_supplicant_mesh_deinit(wpa_s, true);
+ return -1;
+ }
+
+ return 0;
+}
+
+
static int wpas_mesh_complete(struct wpa_supplicant *wpa_s)
{
struct hostapd_iface *ifmsh = wpa_s->ifmsh;
@@ -221,30 +255,8 @@ static int wpas_mesh_complete(struct wpa_supplicant *wpa_s)
if (ifmsh->freq > 0 && ifmsh->freq != params->freq.freq) {
wpa_s->assoc_freq = ifmsh->freq;
ssid->frequency = ifmsh->freq;
- struct he_capabilities *he_capab = NULL;
-
- if (ifmsh->current_mode)
- he_capab = &ifmsh->current_mode->he_capab[IEEE80211_MODE_MESH];
-
- if (hostapd_set_freq_params(¶ms->freq,
- ifmsh->conf->hw_mode,
- ifmsh->freq,
- ifmsh->conf->channel,
- ifmsh->conf->enable_edmg,
- ifmsh->conf->edmg_channel,
- ifmsh->conf->ieee80211n,
- ifmsh->conf->ieee80211ac,
- ifmsh->conf->ieee80211ax,
- ifmsh->conf->secondary_channel,
- hostapd_get_oper_chwidth(ifmsh->conf),
- hostapd_get_oper_centr_freq_seg0_idx(ifmsh->conf),
- hostapd_get_oper_centr_freq_seg1_idx(ifmsh->conf),
- ifmsh->conf->vht_capab,
- he_capab)) {
- wpa_printf(MSG_ERROR, "Error updating mesh frequency params.");
- wpa_supplicant_mesh_deinit(wpa_s, true);
+ if (wpas_mesh_update_freq_params(wpa_s) != 0)
return -1;
- }
}
if (ifmsh->mconf->security != MESH_CONF_SEC_NONE &&
@@ -302,7 +314,7 @@ static int wpa_supplicant_mesh_enable_iface_cb(struct hostapd_iface *ifmsh)
struct hostapd_data *bss;
ifmsh->mconf = mesh_config_create(wpa_s, wpa_s->current_ssid);
-
+
bss = ifmsh->bss[0];
bss->msg_ctx = wpa_s;
os_memcpy(bss->own_addr, wpa_s->own_addr, ETH_ALEN);
@@ -518,6 +530,7 @@ static int wpa_supplicant_mesh_init(struct wpa_supplicant *wpa_s,
}
return 0;
+
out_free:
wpa_supplicant_mesh_deinit(wpa_s, true);
return -ENOMEM;
--
2.27.0
More information about the Hostap
mailing list