Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1 | /* |
| 2 | * WPA Supplicant - Basic mesh mode routines |
| 3 | * Copyright (c) 2013-2014, cozybit, Inc. All rights reserved. |
| 4 | * |
| 5 | * This software may be distributed under the terms of the BSD license. |
| 6 | * See README for more details. |
| 7 | */ |
| 8 | |
| 9 | #include "utils/includes.h" |
| 10 | |
| 11 | #include "utils/common.h" |
| 12 | #include "utils/eloop.h" |
| 13 | #include "utils/uuid.h" |
| 14 | #include "common/ieee802_11_defs.h" |
| 15 | #include "common/wpa_ctrl.h" |
| 16 | #include "ap/sta_info.h" |
| 17 | #include "ap/hostapd.h" |
| 18 | #include "ap/ieee802_11.h" |
| 19 | #include "config_ssid.h" |
| 20 | #include "config.h" |
| 21 | #include "wpa_supplicant_i.h" |
| 22 | #include "driver_i.h" |
| 23 | #include "notify.h" |
| 24 | #include "ap.h" |
| 25 | #include "mesh_mpm.h" |
| 26 | #include "mesh_rsn.h" |
| 27 | #include "mesh.h" |
| 28 | |
| 29 | |
| 30 | static void wpa_supplicant_mesh_deinit(struct wpa_supplicant *wpa_s) |
| 31 | { |
| 32 | wpa_supplicant_mesh_iface_deinit(wpa_s, wpa_s->ifmsh); |
| 33 | wpa_s->ifmsh = NULL; |
| 34 | wpa_s->current_ssid = NULL; |
| 35 | os_free(wpa_s->mesh_rsn); |
| 36 | wpa_s->mesh_rsn = NULL; |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 37 | os_free(wpa_s->mesh_params); |
| 38 | wpa_s->mesh_params = NULL; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 39 | /* TODO: leave mesh (stop beacon). This will happen on link down |
| 40 | * anyway, so it's not urgent */ |
| 41 | } |
| 42 | |
| 43 | |
| 44 | void wpa_supplicant_mesh_iface_deinit(struct wpa_supplicant *wpa_s, |
| 45 | struct hostapd_iface *ifmsh) |
| 46 | { |
| 47 | if (!ifmsh) |
| 48 | return; |
| 49 | |
| 50 | if (ifmsh->mconf) { |
| 51 | mesh_mpm_deinit(wpa_s, ifmsh); |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 52 | if (ifmsh->mconf->rsn_ie) { |
| 53 | ifmsh->mconf->rsn_ie = NULL; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 54 | /* We cannot free this struct |
| 55 | * because wpa_authenticator on |
| 56 | * hostapd side is also using it |
| 57 | * for now just set to NULL and |
| 58 | * let hostapd code free it. |
| 59 | */ |
| 60 | } |
| 61 | os_free(ifmsh->mconf); |
| 62 | ifmsh->mconf = NULL; |
| 63 | } |
| 64 | |
| 65 | /* take care of shared data */ |
| 66 | hostapd_interface_deinit(ifmsh); |
| 67 | hostapd_interface_free(ifmsh); |
| 68 | } |
| 69 | |
| 70 | |
Dmitry Shmidt | d5ab1b5 | 2016-06-21 12:38:41 -0700 | [diff] [blame] | 71 | static struct mesh_conf * mesh_config_create(struct wpa_supplicant *wpa_s, |
| 72 | struct wpa_ssid *ssid) |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 73 | { |
| 74 | struct mesh_conf *conf; |
Dmitry Shmidt | d5ab1b5 | 2016-06-21 12:38:41 -0700 | [diff] [blame] | 75 | int cipher; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 76 | |
| 77 | conf = os_zalloc(sizeof(struct mesh_conf)); |
| 78 | if (!conf) |
| 79 | return NULL; |
| 80 | |
| 81 | os_memcpy(conf->meshid, ssid->ssid, ssid->ssid_len); |
| 82 | conf->meshid_len = ssid->ssid_len; |
| 83 | |
| 84 | if (ssid->key_mgmt & WPA_KEY_MGMT_SAE) |
| 85 | conf->security |= MESH_CONF_SEC_AUTH | |
| 86 | MESH_CONF_SEC_AMPE; |
| 87 | else |
| 88 | conf->security |= MESH_CONF_SEC_NONE; |
Dmitry Shmidt | d5ab1b5 | 2016-06-21 12:38:41 -0700 | [diff] [blame] | 89 | conf->ieee80211w = ssid->ieee80211w; |
| 90 | if (conf->ieee80211w == MGMT_FRAME_PROTECTION_DEFAULT) { |
| 91 | if (wpa_s->drv_enc & WPA_DRIVER_CAPA_ENC_BIP) |
| 92 | conf->ieee80211w = wpa_s->conf->pmf; |
| 93 | else |
| 94 | conf->ieee80211w = NO_MGMT_FRAME_PROTECTION; |
| 95 | } |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 96 | #ifdef CONFIG_OCV |
| 97 | conf->ocv = ssid->ocv; |
| 98 | #endif /* CONFIG_OCV */ |
Dmitry Shmidt | d5ab1b5 | 2016-06-21 12:38:41 -0700 | [diff] [blame] | 99 | |
| 100 | cipher = wpa_pick_pairwise_cipher(ssid->pairwise_cipher, 0); |
| 101 | if (cipher < 0 || cipher == WPA_CIPHER_TKIP) { |
| 102 | wpa_msg(wpa_s, MSG_INFO, "mesh: Invalid pairwise cipher"); |
| 103 | os_free(conf); |
| 104 | return NULL; |
| 105 | } |
| 106 | conf->pairwise_cipher = cipher; |
| 107 | |
| 108 | cipher = wpa_pick_group_cipher(ssid->group_cipher); |
| 109 | if (cipher < 0 || cipher == WPA_CIPHER_TKIP || |
| 110 | cipher == WPA_CIPHER_GTK_NOT_USED) { |
| 111 | wpa_msg(wpa_s, MSG_INFO, "mesh: Invalid group cipher"); |
| 112 | os_free(conf); |
| 113 | return NULL; |
| 114 | } |
| 115 | |
| 116 | conf->group_cipher = cipher; |
Ahmed ElArabawy | 0ff61c5 | 2019-12-26 12:38:39 -0800 | [diff] [blame^] | 117 | if (conf->ieee80211w != NO_MGMT_FRAME_PROTECTION) { |
| 118 | if (ssid->group_mgmt_cipher == WPA_CIPHER_BIP_GMAC_128 || |
| 119 | ssid->group_mgmt_cipher == WPA_CIPHER_BIP_GMAC_256 || |
| 120 | ssid->group_mgmt_cipher == WPA_CIPHER_BIP_CMAC_256) |
| 121 | conf->mgmt_group_cipher = ssid->group_mgmt_cipher; |
| 122 | else |
| 123 | conf->mgmt_group_cipher = WPA_CIPHER_AES_128_CMAC; |
| 124 | } |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 125 | |
| 126 | /* defaults */ |
| 127 | conf->mesh_pp_id = MESH_PATH_PROTOCOL_HWMP; |
| 128 | conf->mesh_pm_id = MESH_PATH_METRIC_AIRTIME; |
| 129 | conf->mesh_cc_id = 0; |
| 130 | conf->mesh_sp_id = MESH_SYNC_METHOD_NEIGHBOR_OFFSET; |
| 131 | conf->mesh_auth_id = (conf->security & MESH_CONF_SEC_AUTH) ? 1 : 0; |
| 132 | conf->dot11MeshMaxRetries = ssid->dot11MeshMaxRetries; |
| 133 | conf->dot11MeshRetryTimeout = ssid->dot11MeshRetryTimeout; |
| 134 | conf->dot11MeshConfirmTimeout = ssid->dot11MeshConfirmTimeout; |
| 135 | conf->dot11MeshHoldingTimeout = ssid->dot11MeshHoldingTimeout; |
| 136 | |
| 137 | return conf; |
| 138 | } |
| 139 | |
| 140 | |
| 141 | static void wpas_mesh_copy_groups(struct hostapd_data *bss, |
| 142 | struct wpa_supplicant *wpa_s) |
| 143 | { |
| 144 | int num_groups; |
| 145 | size_t groups_size; |
| 146 | |
| 147 | for (num_groups = 0; wpa_s->conf->sae_groups[num_groups] > 0; |
| 148 | num_groups++) |
| 149 | ; |
| 150 | |
| 151 | groups_size = (num_groups + 1) * sizeof(wpa_s->conf->sae_groups[0]); |
| 152 | bss->conf->sae_groups = os_malloc(groups_size); |
| 153 | if (bss->conf->sae_groups) |
| 154 | os_memcpy(bss->conf->sae_groups, wpa_s->conf->sae_groups, |
| 155 | groups_size); |
| 156 | } |
| 157 | |
| 158 | |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 159 | static int wpas_mesh_init_rsn(struct wpa_supplicant *wpa_s) |
| 160 | { |
| 161 | struct hostapd_iface *ifmsh = wpa_s->ifmsh; |
| 162 | struct wpa_ssid *ssid = wpa_s->current_ssid; |
| 163 | struct hostapd_data *bss = ifmsh->bss[0]; |
| 164 | static int default_groups[] = { 19, 20, 21, 25, 26, -1 }; |
| 165 | const char *password; |
| 166 | size_t len; |
| 167 | |
| 168 | password = ssid->sae_password; |
| 169 | if (!password) |
| 170 | password = ssid->passphrase; |
| 171 | if (!password) { |
| 172 | wpa_printf(MSG_ERROR, |
| 173 | "mesh: Passphrase for SAE not configured"); |
| 174 | return -1; |
| 175 | } |
| 176 | |
| 177 | bss->conf->wpa = ssid->proto; |
| 178 | bss->conf->wpa_key_mgmt = ssid->key_mgmt; |
| 179 | |
| 180 | if (wpa_s->conf->sae_groups && wpa_s->conf->sae_groups[0] > 0) { |
| 181 | wpas_mesh_copy_groups(bss, wpa_s); |
| 182 | } else { |
| 183 | bss->conf->sae_groups = os_memdup(default_groups, |
| 184 | sizeof(default_groups)); |
| 185 | if (!bss->conf->sae_groups) |
| 186 | return -1; |
| 187 | } |
| 188 | |
| 189 | len = os_strlen(password); |
| 190 | bss->conf->ssid.wpa_passphrase = dup_binstr(password, len); |
| 191 | |
| 192 | wpa_s->mesh_rsn = mesh_rsn_auth_init(wpa_s, ifmsh->mconf); |
| 193 | return !wpa_s->mesh_rsn ? -1 : 0; |
| 194 | } |
| 195 | |
| 196 | |
| 197 | static int wpas_mesh_complete(struct wpa_supplicant *wpa_s) |
| 198 | { |
| 199 | struct hostapd_iface *ifmsh = wpa_s->ifmsh; |
| 200 | struct wpa_driver_mesh_join_params *params = wpa_s->mesh_params; |
| 201 | struct wpa_ssid *ssid = wpa_s->current_ssid; |
| 202 | int ret; |
| 203 | |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 204 | if (!params || !ssid || !ifmsh) { |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 205 | wpa_printf(MSG_ERROR, "mesh: %s called without active mesh", |
| 206 | __func__); |
| 207 | return -1; |
| 208 | } |
| 209 | |
| 210 | if (ifmsh->mconf->security != MESH_CONF_SEC_NONE && |
| 211 | wpas_mesh_init_rsn(wpa_s)) { |
| 212 | wpa_printf(MSG_ERROR, |
| 213 | "mesh: RSN initialization failed - deinit mesh"); |
| 214 | wpa_supplicant_mesh_deinit(wpa_s); |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 215 | wpa_drv_leave_mesh(wpa_s); |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 216 | return -1; |
| 217 | } |
| 218 | |
| 219 | if (ssid->key_mgmt & WPA_KEY_MGMT_SAE) { |
| 220 | wpa_s->pairwise_cipher = wpa_s->mesh_rsn->pairwise_cipher; |
| 221 | wpa_s->group_cipher = wpa_s->mesh_rsn->group_cipher; |
| 222 | wpa_s->mgmt_group_cipher = wpa_s->mesh_rsn->mgmt_group_cipher; |
| 223 | } |
| 224 | |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 225 | params->ies = ifmsh->mconf->rsn_ie; |
| 226 | params->ie_len = ifmsh->mconf->rsn_ie_len; |
| 227 | params->basic_rates = ifmsh->basic_rates; |
| 228 | params->conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_HT_OP_MODE; |
| 229 | params->conf.ht_opmode = ifmsh->bss[0]->iface->ht_op_mode; |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 230 | |
| 231 | wpa_msg(wpa_s, MSG_INFO, "joining mesh %s", |
| 232 | wpa_ssid_txt(ssid->ssid, ssid->ssid_len)); |
| 233 | ret = wpa_drv_join_mesh(wpa_s, params); |
| 234 | if (ret) |
| 235 | wpa_msg(wpa_s, MSG_ERROR, "mesh join error=%d", ret); |
| 236 | |
| 237 | /* hostapd sets the interface down until we associate */ |
| 238 | wpa_drv_set_operstate(wpa_s, 1); |
| 239 | |
| 240 | if (!ret) |
| 241 | wpa_supplicant_set_state(wpa_s, WPA_COMPLETED); |
| 242 | |
| 243 | return ret; |
| 244 | } |
| 245 | |
| 246 | |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 247 | static int wpa_supplicant_mesh_init(struct wpa_supplicant *wpa_s, |
Dmitry Shmidt | 2933359 | 2017-01-09 12:27:11 -0800 | [diff] [blame] | 248 | struct wpa_ssid *ssid, |
| 249 | struct hostapd_freq_params *freq) |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 250 | { |
| 251 | struct hostapd_iface *ifmsh; |
| 252 | struct hostapd_data *bss; |
| 253 | struct hostapd_config *conf; |
| 254 | struct mesh_conf *mconf; |
| 255 | int basic_rates_erp[] = { 10, 20, 55, 60, 110, 120, 240, -1 }; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 256 | int rate_len; |
Dmitry Shmidt | 2933359 | 2017-01-09 12:27:11 -0800 | [diff] [blame] | 257 | int frequency; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 258 | |
| 259 | if (!wpa_s->conf->user_mpm) { |
| 260 | /* not much for us to do here */ |
| 261 | wpa_msg(wpa_s, MSG_WARNING, |
| 262 | "user_mpm is not enabled in configuration"); |
| 263 | return 0; |
| 264 | } |
| 265 | |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 266 | wpa_s->ifmsh = ifmsh = hostapd_alloc_iface(); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 267 | if (!ifmsh) |
| 268 | return -ENOMEM; |
| 269 | |
| 270 | ifmsh->drv_flags = wpa_s->drv_flags; |
| 271 | ifmsh->num_bss = 1; |
| 272 | ifmsh->bss = os_calloc(wpa_s->ifmsh->num_bss, |
| 273 | sizeof(struct hostapd_data *)); |
| 274 | if (!ifmsh->bss) |
| 275 | goto out_free; |
| 276 | |
Dmitry Shmidt | ebd93af | 2017-02-21 13:40:44 -0800 | [diff] [blame] | 277 | ifmsh->bss[0] = bss = hostapd_alloc_bss_data(NULL, NULL, NULL); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 278 | if (!bss) |
| 279 | goto out_free; |
| 280 | |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 281 | ifmsh->bss[0]->msg_ctx = wpa_s; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 282 | os_memcpy(bss->own_addr, wpa_s->own_addr, ETH_ALEN); |
| 283 | bss->driver = wpa_s->driver; |
| 284 | bss->drv_priv = wpa_s->drv_priv; |
| 285 | bss->iface = ifmsh; |
| 286 | bss->mesh_sta_free_cb = mesh_mpm_free_sta; |
Dmitry Shmidt | 2933359 | 2017-01-09 12:27:11 -0800 | [diff] [blame] | 287 | frequency = ssid->frequency; |
| 288 | if (frequency != freq->freq && |
| 289 | frequency == freq->freq + freq->sec_channel_offset * 20) { |
| 290 | wpa_printf(MSG_DEBUG, "mesh: pri/sec channels switched"); |
| 291 | frequency = freq->freq; |
| 292 | } |
| 293 | wpa_s->assoc_freq = frequency; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 294 | wpa_s->current_ssid = ssid; |
| 295 | |
| 296 | /* setup an AP config for auth processing */ |
| 297 | conf = hostapd_config_defaults(); |
| 298 | if (!conf) |
| 299 | goto out_free; |
| 300 | |
| 301 | bss->conf = *conf->bss; |
| 302 | bss->conf->start_disabled = 1; |
| 303 | bss->conf->mesh = MESH_ENABLED; |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 304 | bss->conf->ap_max_inactivity = wpa_s->conf->mesh_max_inactivity; |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 305 | |
| 306 | if (ieee80211_is_dfs(ssid->frequency, wpa_s->hw.modes, |
| 307 | wpa_s->hw.num_modes) && wpa_s->conf->country[0]) { |
| 308 | conf->ieee80211h = 1; |
| 309 | conf->ieee80211d = 1; |
| 310 | conf->country[0] = wpa_s->conf->country[0]; |
| 311 | conf->country[1] = wpa_s->conf->country[1]; |
| 312 | conf->country[2] = ' '; |
| 313 | } |
| 314 | |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 315 | bss->iconf = conf; |
| 316 | ifmsh->conf = conf; |
| 317 | |
| 318 | ifmsh->bss[0]->max_plinks = wpa_s->conf->max_peer_links; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 319 | ifmsh->bss[0]->dot11RSNASAERetransPeriod = |
| 320 | wpa_s->conf->dot11RSNASAERetransPeriod; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 321 | os_strlcpy(bss->conf->iface, wpa_s->ifname, sizeof(bss->conf->iface)); |
| 322 | |
Dmitry Shmidt | d5ab1b5 | 2016-06-21 12:38:41 -0700 | [diff] [blame] | 323 | mconf = mesh_config_create(wpa_s, ssid); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 324 | if (!mconf) |
| 325 | goto out_free; |
| 326 | ifmsh->mconf = mconf; |
| 327 | |
| 328 | /* need conf->hw_mode for supported rates. */ |
Dmitry Shmidt | 2933359 | 2017-01-09 12:27:11 -0800 | [diff] [blame] | 329 | conf->hw_mode = ieee80211_freq_to_chan(frequency, &conf->channel); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 330 | if (conf->hw_mode == NUM_HOSTAPD_MODES) { |
| 331 | wpa_printf(MSG_ERROR, "Unsupported mesh mode frequency: %d MHz", |
Dmitry Shmidt | 2933359 | 2017-01-09 12:27:11 -0800 | [diff] [blame] | 332 | frequency); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 333 | goto out_free; |
| 334 | } |
Dmitry Shmidt | 0e58d9b | 2015-12-22 10:59:44 -0800 | [diff] [blame] | 335 | if (ssid->ht40) |
| 336 | conf->secondary_channel = ssid->ht40; |
| 337 | if (conf->hw_mode == HOSTAPD_MODE_IEEE80211A && ssid->vht) { |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 338 | if (ssid->max_oper_chwidth != DEFAULT_MAX_OPER_CHWIDTH) |
| 339 | conf->vht_oper_chwidth = ssid->max_oper_chwidth; |
Dmitry Shmidt | 0e58d9b | 2015-12-22 10:59:44 -0800 | [diff] [blame] | 340 | switch (conf->vht_oper_chwidth) { |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 341 | case CHANWIDTH_80MHZ: |
| 342 | case CHANWIDTH_80P80MHZ: |
Dmitry Shmidt | 0e58d9b | 2015-12-22 10:59:44 -0800 | [diff] [blame] | 343 | ieee80211_freq_to_chan( |
Dmitry Shmidt | 2933359 | 2017-01-09 12:27:11 -0800 | [diff] [blame] | 344 | frequency, |
Dmitry Shmidt | 0e58d9b | 2015-12-22 10:59:44 -0800 | [diff] [blame] | 345 | &conf->vht_oper_centr_freq_seg0_idx); |
| 346 | conf->vht_oper_centr_freq_seg0_idx += ssid->ht40 * 2; |
| 347 | break; |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 348 | case CHANWIDTH_160MHZ: |
Dmitry Shmidt | 0e58d9b | 2015-12-22 10:59:44 -0800 | [diff] [blame] | 349 | ieee80211_freq_to_chan( |
Dmitry Shmidt | 2933359 | 2017-01-09 12:27:11 -0800 | [diff] [blame] | 350 | frequency, |
Dmitry Shmidt | 0e58d9b | 2015-12-22 10:59:44 -0800 | [diff] [blame] | 351 | &conf->vht_oper_centr_freq_seg0_idx); |
| 352 | conf->vht_oper_centr_freq_seg0_idx += ssid->ht40 * 2; |
| 353 | conf->vht_oper_centr_freq_seg0_idx += 40 / 5; |
| 354 | break; |
| 355 | } |
| 356 | ieee80211_freq_to_chan(ssid->vht_center_freq2, |
| 357 | &conf->vht_oper_centr_freq_seg1_idx); |
| 358 | } |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 359 | |
| 360 | if (ssid->mesh_basic_rates == NULL) { |
| 361 | /* |
| 362 | * XXX: Hack! This is so an MPM which correctly sets the ERP |
| 363 | * mandatory rates as BSSBasicRateSet doesn't reject us. We |
| 364 | * could add a new hw_mode HOSTAPD_MODE_IEEE80211G_ERP, but |
| 365 | * this is way easier. This also makes our BSSBasicRateSet |
| 366 | * advertised in beacons match the one in peering frames, sigh. |
| 367 | */ |
| 368 | if (conf->hw_mode == HOSTAPD_MODE_IEEE80211G) { |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 369 | conf->basic_rates = os_memdup(basic_rates_erp, |
| 370 | sizeof(basic_rates_erp)); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 371 | if (!conf->basic_rates) |
| 372 | goto out_free; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 373 | } |
| 374 | } else { |
| 375 | rate_len = 0; |
| 376 | while (1) { |
| 377 | if (ssid->mesh_basic_rates[rate_len] < 1) |
| 378 | break; |
| 379 | rate_len++; |
| 380 | } |
| 381 | conf->basic_rates = os_calloc(rate_len + 1, sizeof(int)); |
| 382 | if (conf->basic_rates == NULL) |
| 383 | goto out_free; |
| 384 | os_memcpy(conf->basic_rates, ssid->mesh_basic_rates, |
| 385 | rate_len * sizeof(int)); |
| 386 | conf->basic_rates[rate_len] = -1; |
| 387 | } |
| 388 | |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 389 | if (wpa_drv_init_mesh(wpa_s)) { |
| 390 | wpa_msg(wpa_s, MSG_ERROR, "Failed to init mesh in driver"); |
| 391 | return -1; |
| 392 | } |
| 393 | |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 394 | if (hostapd_setup_interface(ifmsh)) { |
| 395 | wpa_printf(MSG_ERROR, |
| 396 | "Failed to initialize hostapd interface for mesh"); |
| 397 | return -1; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 398 | } |
| 399 | |
| 400 | wpa_supplicant_conf_ap_ht(wpa_s, ssid, conf); |
| 401 | |
| 402 | return 0; |
| 403 | out_free: |
| 404 | wpa_supplicant_mesh_deinit(wpa_s); |
| 405 | return -ENOMEM; |
| 406 | } |
| 407 | |
| 408 | |
| 409 | void wpa_mesh_notify_peer(struct wpa_supplicant *wpa_s, const u8 *addr, |
| 410 | const u8 *ies, size_t ie_len) |
| 411 | { |
| 412 | struct ieee802_11_elems elems; |
| 413 | |
| 414 | wpa_msg(wpa_s, MSG_INFO, |
| 415 | "new peer notification for " MACSTR, MAC2STR(addr)); |
| 416 | |
| 417 | if (ieee802_11_parse_elems(ies, ie_len, &elems, 0) == ParseFailed) { |
| 418 | wpa_msg(wpa_s, MSG_INFO, "Could not parse beacon from " MACSTR, |
| 419 | MAC2STR(addr)); |
| 420 | return; |
| 421 | } |
| 422 | wpa_mesh_new_mesh_peer(wpa_s, addr, &elems); |
| 423 | } |
| 424 | |
| 425 | |
| 426 | void wpa_supplicant_mesh_add_scan_ie(struct wpa_supplicant *wpa_s, |
| 427 | struct wpabuf **extra_ie) |
| 428 | { |
| 429 | /* EID + 0-length (wildcard) mesh-id */ |
| 430 | size_t ielen = 2; |
| 431 | |
| 432 | if (wpabuf_resize(extra_ie, ielen) == 0) { |
| 433 | wpabuf_put_u8(*extra_ie, WLAN_EID_MESH_ID); |
| 434 | wpabuf_put_u8(*extra_ie, 0); |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | |
| 439 | int wpa_supplicant_join_mesh(struct wpa_supplicant *wpa_s, |
| 440 | struct wpa_ssid *ssid) |
| 441 | { |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 442 | struct wpa_driver_mesh_join_params *params = os_zalloc(sizeof(*params)); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 443 | int ret = 0; |
| 444 | |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 445 | if (!ssid || !ssid->ssid || !ssid->ssid_len || !ssid->frequency || |
| 446 | !params) { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 447 | ret = -ENOENT; |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 448 | os_free(params); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 449 | goto out; |
| 450 | } |
| 451 | |
| 452 | wpa_supplicant_mesh_deinit(wpa_s); |
| 453 | |
Dmitry Shmidt | d5ab1b5 | 2016-06-21 12:38:41 -0700 | [diff] [blame] | 454 | wpa_s->pairwise_cipher = WPA_CIPHER_NONE; |
| 455 | wpa_s->group_cipher = WPA_CIPHER_NONE; |
| 456 | wpa_s->mgmt_group_cipher = 0; |
Dmitry Shmidt | d7ff03d | 2015-12-04 14:49:35 -0800 | [diff] [blame] | 457 | |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 458 | params->meshid = ssid->ssid; |
| 459 | params->meshid_len = ssid->ssid_len; |
| 460 | ibss_mesh_setup_freq(wpa_s, ssid, ¶ms->freq); |
| 461 | wpa_s->mesh_ht_enabled = !!params->freq.ht_enabled; |
| 462 | wpa_s->mesh_vht_enabled = !!params->freq.vht_enabled; |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 463 | wpa_s->mesh_he_enabled = !!params->freq.he_enabled; |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 464 | if (params->freq.ht_enabled && params->freq.sec_channel_offset) |
| 465 | ssid->ht40 = params->freq.sec_channel_offset; |
| 466 | |
Dmitry Shmidt | 0e58d9b | 2015-12-22 10:59:44 -0800 | [diff] [blame] | 467 | if (wpa_s->mesh_vht_enabled) { |
| 468 | ssid->vht = 1; |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 469 | ssid->vht_center_freq1 = params->freq.center_freq1; |
| 470 | switch (params->freq.bandwidth) { |
Dmitry Shmidt | 0e58d9b | 2015-12-22 10:59:44 -0800 | [diff] [blame] | 471 | case 80: |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 472 | if (params->freq.center_freq2) { |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 473 | ssid->max_oper_chwidth = CHANWIDTH_80P80MHZ; |
Dmitry Shmidt | 0e58d9b | 2015-12-22 10:59:44 -0800 | [diff] [blame] | 474 | ssid->vht_center_freq2 = |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 475 | params->freq.center_freq2; |
Dmitry Shmidt | 0e58d9b | 2015-12-22 10:59:44 -0800 | [diff] [blame] | 476 | } else { |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 477 | ssid->max_oper_chwidth = CHANWIDTH_80MHZ; |
Dmitry Shmidt | 0e58d9b | 2015-12-22 10:59:44 -0800 | [diff] [blame] | 478 | } |
| 479 | break; |
| 480 | case 160: |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 481 | ssid->max_oper_chwidth = CHANWIDTH_160MHZ; |
Dmitry Shmidt | 0e58d9b | 2015-12-22 10:59:44 -0800 | [diff] [blame] | 482 | break; |
| 483 | default: |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 484 | ssid->max_oper_chwidth = CHANWIDTH_USE_HT; |
Dmitry Shmidt | 0e58d9b | 2015-12-22 10:59:44 -0800 | [diff] [blame] | 485 | break; |
| 486 | } |
| 487 | } |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 488 | if (wpa_s->mesh_he_enabled) |
| 489 | ssid->he = 1; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 490 | if (ssid->beacon_int > 0) |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 491 | params->beacon_int = ssid->beacon_int; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 492 | else if (wpa_s->conf->beacon_int > 0) |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 493 | params->beacon_int = wpa_s->conf->beacon_int; |
Dmitry Shmidt | 58d12ad | 2016-07-28 10:07:03 -0700 | [diff] [blame] | 494 | if (ssid->dtim_period > 0) |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 495 | params->dtim_period = ssid->dtim_period; |
Dmitry Shmidt | 58d12ad | 2016-07-28 10:07:03 -0700 | [diff] [blame] | 496 | else if (wpa_s->conf->dtim_period > 0) |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 497 | params->dtim_period = wpa_s->conf->dtim_period; |
| 498 | params->conf.max_peer_links = wpa_s->conf->max_peer_links; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 499 | if (ssid->mesh_rssi_threshold < DEFAULT_MESH_RSSI_THRESHOLD) { |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 500 | params->conf.rssi_threshold = ssid->mesh_rssi_threshold; |
| 501 | params->conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_RSSI_THRESHOLD; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 502 | } |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 503 | |
| 504 | if (ssid->key_mgmt & WPA_KEY_MGMT_SAE) { |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 505 | params->flags |= WPA_DRIVER_MESH_FLAG_SAE_AUTH; |
| 506 | params->flags |= WPA_DRIVER_MESH_FLAG_AMPE; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 507 | wpa_s->conf->user_mpm = 1; |
| 508 | } |
| 509 | |
| 510 | if (wpa_s->conf->user_mpm) { |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 511 | params->flags |= WPA_DRIVER_MESH_FLAG_USER_MPM; |
| 512 | params->conf.auto_plinks = 0; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 513 | } else { |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 514 | params->flags |= WPA_DRIVER_MESH_FLAG_DRIVER_MPM; |
| 515 | params->conf.auto_plinks = 1; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 516 | } |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 517 | params->conf.peer_link_timeout = wpa_s->conf->mesh_max_inactivity; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 518 | |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 519 | os_free(wpa_s->mesh_params); |
| 520 | wpa_s->mesh_params = params; |
| 521 | if (wpa_supplicant_mesh_init(wpa_s, ssid, ¶ms->freq)) { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 522 | wpa_msg(wpa_s, MSG_ERROR, "Failed to init mesh"); |
Dmitry Shmidt | 4dd28dc | 2015-03-10 11:21:43 -0700 | [diff] [blame] | 523 | wpa_drv_leave_mesh(wpa_s); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 524 | ret = -1; |
| 525 | goto out; |
| 526 | } |
| 527 | |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 528 | ret = wpas_mesh_complete(wpa_s); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 529 | out: |
| 530 | return ret; |
| 531 | } |
| 532 | |
| 533 | |
| 534 | int wpa_supplicant_leave_mesh(struct wpa_supplicant *wpa_s) |
| 535 | { |
| 536 | int ret = 0; |
| 537 | |
| 538 | wpa_msg(wpa_s, MSG_INFO, "leaving mesh"); |
| 539 | |
| 540 | /* Need to send peering close messages first */ |
| 541 | wpa_supplicant_mesh_deinit(wpa_s); |
| 542 | |
| 543 | ret = wpa_drv_leave_mesh(wpa_s); |
| 544 | if (ret) |
| 545 | wpa_msg(wpa_s, MSG_ERROR, "mesh leave error=%d", ret); |
| 546 | |
| 547 | wpa_drv_set_operstate(wpa_s, 1); |
| 548 | |
| 549 | return ret; |
| 550 | } |
| 551 | |
| 552 | |
| 553 | static int mesh_attr_text(const u8 *ies, size_t ies_len, char *buf, char *end) |
| 554 | { |
| 555 | struct ieee802_11_elems elems; |
| 556 | char *mesh_id, *pos = buf; |
| 557 | u8 *bss_basic_rate_set; |
| 558 | int bss_basic_rate_set_len, ret, i; |
| 559 | |
| 560 | if (ieee802_11_parse_elems(ies, ies_len, &elems, 0) == ParseFailed) |
| 561 | return -1; |
| 562 | |
| 563 | if (elems.mesh_id_len < 1) |
| 564 | return 0; |
| 565 | |
| 566 | mesh_id = os_malloc(elems.mesh_id_len + 1); |
| 567 | if (mesh_id == NULL) |
| 568 | return -1; |
| 569 | |
| 570 | os_memcpy(mesh_id, elems.mesh_id, elems.mesh_id_len); |
| 571 | mesh_id[elems.mesh_id_len] = '\0'; |
| 572 | ret = os_snprintf(pos, end - pos, "mesh_id=%s\n", mesh_id); |
| 573 | os_free(mesh_id); |
| 574 | if (os_snprintf_error(end - pos, ret)) |
| 575 | return pos - buf; |
| 576 | pos += ret; |
| 577 | |
| 578 | if (elems.mesh_config_len > 6) { |
| 579 | ret = os_snprintf(pos, end - pos, |
| 580 | "active_path_selection_protocol_id=0x%02x\n" |
| 581 | "active_path_selection_metric_id=0x%02x\n" |
| 582 | "congestion_control_mode_id=0x%02x\n" |
| 583 | "synchronization_method_id=0x%02x\n" |
| 584 | "authentication_protocol_id=0x%02x\n" |
| 585 | "mesh_formation_info=0x%02x\n" |
| 586 | "mesh_capability=0x%02x\n", |
| 587 | elems.mesh_config[0], elems.mesh_config[1], |
| 588 | elems.mesh_config[2], elems.mesh_config[3], |
| 589 | elems.mesh_config[4], elems.mesh_config[5], |
| 590 | elems.mesh_config[6]); |
| 591 | if (os_snprintf_error(end - pos, ret)) |
| 592 | return pos - buf; |
| 593 | pos += ret; |
| 594 | } |
| 595 | |
| 596 | bss_basic_rate_set = os_malloc(elems.supp_rates_len + |
| 597 | elems.ext_supp_rates_len); |
| 598 | if (bss_basic_rate_set == NULL) |
| 599 | return -1; |
| 600 | |
| 601 | bss_basic_rate_set_len = 0; |
| 602 | for (i = 0; i < elems.supp_rates_len; i++) { |
| 603 | if (elems.supp_rates[i] & 0x80) { |
| 604 | bss_basic_rate_set[bss_basic_rate_set_len++] = |
| 605 | (elems.supp_rates[i] & 0x7f) * 5; |
| 606 | } |
| 607 | } |
| 608 | for (i = 0; i < elems.ext_supp_rates_len; i++) { |
| 609 | if (elems.ext_supp_rates[i] & 0x80) { |
| 610 | bss_basic_rate_set[bss_basic_rate_set_len++] = |
| 611 | (elems.ext_supp_rates[i] & 0x7f) * 5; |
| 612 | } |
| 613 | } |
| 614 | if (bss_basic_rate_set_len > 0) { |
| 615 | ret = os_snprintf(pos, end - pos, "bss_basic_rate_set=%d", |
| 616 | bss_basic_rate_set[0]); |
| 617 | if (os_snprintf_error(end - pos, ret)) |
Dmitry Shmidt | 9d9e602 | 2015-04-23 10:34:55 -0700 | [diff] [blame] | 618 | goto fail; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 619 | pos += ret; |
| 620 | |
| 621 | for (i = 1; i < bss_basic_rate_set_len; i++) { |
| 622 | ret = os_snprintf(pos, end - pos, " %d", |
| 623 | bss_basic_rate_set[i]); |
| 624 | if (os_snprintf_error(end - pos, ret)) |
Dmitry Shmidt | 9d9e602 | 2015-04-23 10:34:55 -0700 | [diff] [blame] | 625 | goto fail; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 626 | pos += ret; |
| 627 | } |
| 628 | |
| 629 | ret = os_snprintf(pos, end - pos, "\n"); |
| 630 | if (os_snprintf_error(end - pos, ret)) |
Dmitry Shmidt | 9d9e602 | 2015-04-23 10:34:55 -0700 | [diff] [blame] | 631 | goto fail; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 632 | pos += ret; |
| 633 | } |
Dmitry Shmidt | 9d9e602 | 2015-04-23 10:34:55 -0700 | [diff] [blame] | 634 | fail: |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 635 | os_free(bss_basic_rate_set); |
| 636 | |
| 637 | return pos - buf; |
| 638 | } |
| 639 | |
| 640 | |
| 641 | int wpas_mesh_scan_result_text(const u8 *ies, size_t ies_len, char *buf, |
| 642 | char *end) |
| 643 | { |
| 644 | return mesh_attr_text(ies, ies_len, buf, end); |
| 645 | } |
| 646 | |
| 647 | |
| 648 | static int wpas_mesh_get_ifname(struct wpa_supplicant *wpa_s, char *ifname, |
| 649 | size_t len) |
| 650 | { |
| 651 | char *ifname_ptr = wpa_s->ifname; |
| 652 | int res; |
| 653 | |
| 654 | res = os_snprintf(ifname, len, "mesh-%s-%d", ifname_ptr, |
| 655 | wpa_s->mesh_if_idx); |
| 656 | if (os_snprintf_error(len, res) || |
| 657 | (os_strlen(ifname) >= IFNAMSIZ && |
| 658 | os_strlen(wpa_s->ifname) < IFNAMSIZ)) { |
| 659 | /* Try to avoid going over the IFNAMSIZ length limit */ |
| 660 | res = os_snprintf(ifname, len, "mesh-%d", wpa_s->mesh_if_idx); |
| 661 | if (os_snprintf_error(len, res)) |
| 662 | return -1; |
| 663 | } |
| 664 | wpa_s->mesh_if_idx++; |
| 665 | return 0; |
| 666 | } |
| 667 | |
| 668 | |
| 669 | int wpas_mesh_add_interface(struct wpa_supplicant *wpa_s, char *ifname, |
| 670 | size_t len) |
| 671 | { |
| 672 | struct wpa_interface iface; |
| 673 | struct wpa_supplicant *mesh_wpa_s; |
| 674 | u8 addr[ETH_ALEN]; |
| 675 | |
| 676 | if (ifname[0] == '\0' && wpas_mesh_get_ifname(wpa_s, ifname, len) < 0) |
| 677 | return -1; |
| 678 | |
| 679 | if (wpa_drv_if_add(wpa_s, WPA_IF_MESH, ifname, NULL, NULL, NULL, addr, |
| 680 | NULL) < 0) { |
| 681 | wpa_printf(MSG_ERROR, |
| 682 | "mesh: Failed to create new mesh interface"); |
| 683 | return -1; |
| 684 | } |
| 685 | wpa_printf(MSG_INFO, "mesh: Created virtual interface %s addr " |
| 686 | MACSTR, ifname, MAC2STR(addr)); |
| 687 | |
| 688 | os_memset(&iface, 0, sizeof(iface)); |
| 689 | iface.ifname = ifname; |
| 690 | iface.driver = wpa_s->driver->name; |
| 691 | iface.driver_param = wpa_s->conf->driver_param; |
| 692 | iface.ctrl_interface = wpa_s->conf->ctrl_interface; |
| 693 | |
Dmitry Shmidt | 203eadb | 2015-03-05 14:16:04 -0800 | [diff] [blame] | 694 | mesh_wpa_s = wpa_supplicant_add_iface(wpa_s->global, &iface, wpa_s); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 695 | if (!mesh_wpa_s) { |
| 696 | wpa_printf(MSG_ERROR, |
| 697 | "mesh: Failed to create new wpa_supplicant interface"); |
Dmitry Shmidt | d5ab1b5 | 2016-06-21 12:38:41 -0700 | [diff] [blame] | 698 | wpa_drv_if_remove(wpa_s, WPA_IF_MESH, ifname); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 699 | return -1; |
| 700 | } |
| 701 | mesh_wpa_s->mesh_if_created = 1; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 702 | return 0; |
| 703 | } |
Dmitry Shmidt | e466304 | 2016-04-04 10:07:49 -0700 | [diff] [blame] | 704 | |
| 705 | |
| 706 | int wpas_mesh_peer_remove(struct wpa_supplicant *wpa_s, const u8 *addr) |
| 707 | { |
| 708 | return mesh_mpm_close_peer(wpa_s, addr); |
| 709 | } |
| 710 | |
| 711 | |
| 712 | int wpas_mesh_peer_add(struct wpa_supplicant *wpa_s, const u8 *addr, |
| 713 | int duration) |
| 714 | { |
| 715 | return mesh_mpm_connect_peer(wpa_s, addr, duration); |
| 716 | } |