diff mbox series

[v2,11/12] mesh: move mesh freq setting to own function

Message ID 20200630121907.132751-12-markus.theil@tu-ilmenau.de
State New
Headers show
Series mesh: support for DFS | expand

Commit Message

Markus Theil June 30, 2020, 12:19 p.m. UTC
Signed-off-by: Markus Theil <markus.theil@tu-ilmenau.de>
---
 wpa_supplicant/mesh.c | 63 ++++++++++++++++++++++++++-----------------
 1 file changed, 38 insertions(+), 25 deletions(-)
diff mbox series

Patch

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(&params->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(&params->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;