aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant
diff options
context:
space:
mode:
authorPeter Oh <peter.oh@bowerswilkins.com>2018-08-27 21:28:35 (GMT)
committerJouni Malinen <j@w1.fi>2019-01-03 10:04:23 (GMT)
commit1877842904fa4089a7816221f5b0530bb6ed2aa7 (patch)
tree1d5822924844898645f16f577e942307cad4707c /wpa_supplicant
parentb9eb717f85fbca320b9782cfbce56ba7af28c5e2 (diff)
downloadhostap-1877842904fa4089a7816221f5b0530bb6ed2aa7.zip
hostap-1877842904fa4089a7816221f5b0530bb6ed2aa7.tar.gz
hostap-1877842904fa4089a7816221f5b0530bb6ed2aa7.tar.bz2
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. This can also get rid of unnecessary indentation by handling the mconf->security != MESH_CONF_SEC_NONE functionality in a helper function. Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
Diffstat (limited to 'wpa_supplicant')
-rw-r--r--wpa_supplicant/mesh.c75
1 files changed, 40 insertions, 35 deletions
diff --git a/wpa_supplicant/mesh.c b/wpa_supplicant/mesh.c
index 3da8b1b..cb995a5 100644
--- a/wpa_supplicant/mesh.c
+++ b/wpa_supplicant/mesh.c
@@ -150,6 +150,44 @@ static void wpas_mesh_copy_groups(struct hostapd_data *bss,
}
+static int wpas_mesh_init_rsn(struct wpa_supplicant *wpa_s)
+{
+ struct hostapd_iface *ifmsh = wpa_s->ifmsh;
+ 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;
+
+ 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, ifmsh->mconf);
+ return !wpa_s->mesh_rsn ? -1 : 0;
+}
+
+
static int wpa_supplicant_mesh_init(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid,
struct hostapd_freq_params *freq)
@@ -159,9 +197,6 @@ static int wpa_supplicant_mesh_init(struct wpa_supplicant *wpa_s,
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;
@@ -295,38 +330,8 @@ static int wpa_supplicant_mesh_init(struct wpa_supplicant *wpa_s,
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 (mconf->security != MESH_CONF_SEC_NONE && wpas_mesh_init_rsn(wpa_s))
+ goto out_free;
wpa_supplicant_conf_ap_ht(wpa_s, ssid, conf);