mesh: Use ieee80211w profile parameter
[mech_eap.git] / wpa_supplicant / mesh.c
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;
37         /* TODO: leave mesh (stop beacon). This will happen on link down
38          * anyway, so it's not urgent */
39 }
40
41
42 void wpa_supplicant_mesh_iface_deinit(struct wpa_supplicant *wpa_s,
43                                       struct hostapd_iface *ifmsh)
44 {
45         if (!ifmsh)
46                 return;
47
48         if (ifmsh->mconf) {
49                 mesh_mpm_deinit(wpa_s, ifmsh);
50                 if (ifmsh->mconf->rsn_ie) {
51                         ifmsh->mconf->rsn_ie = NULL;
52                         /* We cannot free this struct
53                          * because wpa_authenticator on
54                          * hostapd side is also using it
55                          * for now just set to NULL and
56                          * let hostapd code free it.
57                          */
58                 }
59                 os_free(ifmsh->mconf);
60                 ifmsh->mconf = NULL;
61         }
62
63         /* take care of shared data */
64         hostapd_interface_deinit(ifmsh);
65         hostapd_interface_free(ifmsh);
66 }
67
68
69 static struct mesh_conf * mesh_config_create(struct wpa_supplicant *wpa_s,
70                                              struct wpa_ssid *ssid)
71 {
72         struct mesh_conf *conf;
73
74         conf = os_zalloc(sizeof(struct mesh_conf));
75         if (!conf)
76                 return NULL;
77
78         os_memcpy(conf->meshid, ssid->ssid, ssid->ssid_len);
79         conf->meshid_len = ssid->ssid_len;
80
81         if (ssid->key_mgmt & WPA_KEY_MGMT_SAE)
82                 conf->security |= MESH_CONF_SEC_AUTH |
83                         MESH_CONF_SEC_AMPE;
84         else
85                 conf->security |= MESH_CONF_SEC_NONE;
86         conf->ieee80211w = ssid->ieee80211w;
87         if (conf->ieee80211w == MGMT_FRAME_PROTECTION_DEFAULT) {
88                 if (wpa_s->drv_enc & WPA_DRIVER_CAPA_ENC_BIP)
89                         conf->ieee80211w = wpa_s->conf->pmf;
90                 else
91                         conf->ieee80211w = NO_MGMT_FRAME_PROTECTION;
92         }
93
94         /* defaults */
95         conf->mesh_pp_id = MESH_PATH_PROTOCOL_HWMP;
96         conf->mesh_pm_id = MESH_PATH_METRIC_AIRTIME;
97         conf->mesh_cc_id = 0;
98         conf->mesh_sp_id = MESH_SYNC_METHOD_NEIGHBOR_OFFSET;
99         conf->mesh_auth_id = (conf->security & MESH_CONF_SEC_AUTH) ? 1 : 0;
100         conf->dot11MeshMaxRetries = ssid->dot11MeshMaxRetries;
101         conf->dot11MeshRetryTimeout = ssid->dot11MeshRetryTimeout;
102         conf->dot11MeshConfirmTimeout = ssid->dot11MeshConfirmTimeout;
103         conf->dot11MeshHoldingTimeout = ssid->dot11MeshHoldingTimeout;
104
105         return conf;
106 }
107
108
109 static void wpas_mesh_copy_groups(struct hostapd_data *bss,
110                                   struct wpa_supplicant *wpa_s)
111 {
112         int num_groups;
113         size_t groups_size;
114
115         for (num_groups = 0; wpa_s->conf->sae_groups[num_groups] > 0;
116              num_groups++)
117                 ;
118
119         groups_size = (num_groups + 1) * sizeof(wpa_s->conf->sae_groups[0]);
120         bss->conf->sae_groups = os_malloc(groups_size);
121         if (bss->conf->sae_groups)
122                 os_memcpy(bss->conf->sae_groups, wpa_s->conf->sae_groups,
123                           groups_size);
124 }
125
126
127 static int wpa_supplicant_mesh_init(struct wpa_supplicant *wpa_s,
128                                     struct wpa_ssid *ssid)
129 {
130         struct hostapd_iface *ifmsh;
131         struct hostapd_data *bss;
132         struct hostapd_config *conf;
133         struct mesh_conf *mconf;
134         int basic_rates_erp[] = { 10, 20, 55, 60, 110, 120, 240, -1 };
135         static int default_groups[] = { 19, 20, 21, 25, 26, -1 };
136         size_t len;
137         int rate_len;
138
139         if (!wpa_s->conf->user_mpm) {
140                 /* not much for us to do here */
141                 wpa_msg(wpa_s, MSG_WARNING,
142                         "user_mpm is not enabled in configuration");
143                 return 0;
144         }
145
146         wpa_s->ifmsh = ifmsh = os_zalloc(sizeof(*wpa_s->ifmsh));
147         if (!ifmsh)
148                 return -ENOMEM;
149
150         ifmsh->drv_flags = wpa_s->drv_flags;
151         ifmsh->num_bss = 1;
152         ifmsh->bss = os_calloc(wpa_s->ifmsh->num_bss,
153                                sizeof(struct hostapd_data *));
154         if (!ifmsh->bss)
155                 goto out_free;
156
157         ifmsh->bss[0] = bss = os_zalloc(sizeof(struct hostapd_data));
158         if (!bss)
159                 goto out_free;
160
161         os_memcpy(bss->own_addr, wpa_s->own_addr, ETH_ALEN);
162         bss->driver = wpa_s->driver;
163         bss->drv_priv = wpa_s->drv_priv;
164         bss->iface = ifmsh;
165         bss->mesh_sta_free_cb = mesh_mpm_free_sta;
166         wpa_s->assoc_freq = ssid->frequency;
167         wpa_s->current_ssid = ssid;
168
169         /* setup an AP config for auth processing */
170         conf = hostapd_config_defaults();
171         if (!conf)
172                 goto out_free;
173
174         bss->conf = *conf->bss;
175         bss->conf->start_disabled = 1;
176         bss->conf->mesh = MESH_ENABLED;
177         bss->conf->ap_max_inactivity = wpa_s->conf->mesh_max_inactivity;
178         bss->iconf = conf;
179         ifmsh->conf = conf;
180
181         ifmsh->bss[0]->max_plinks = wpa_s->conf->max_peer_links;
182         ifmsh->bss[0]->dot11RSNASAERetransPeriod =
183                 wpa_s->conf->dot11RSNASAERetransPeriod;
184         os_strlcpy(bss->conf->iface, wpa_s->ifname, sizeof(bss->conf->iface));
185
186         mconf = mesh_config_create(wpa_s, ssid);
187         if (!mconf)
188                 goto out_free;
189         ifmsh->mconf = mconf;
190
191         /* need conf->hw_mode for supported rates. */
192         conf->hw_mode = ieee80211_freq_to_chan(ssid->frequency, &conf->channel);
193         if (conf->hw_mode == NUM_HOSTAPD_MODES) {
194                 wpa_printf(MSG_ERROR, "Unsupported mesh mode frequency: %d MHz",
195                            ssid->frequency);
196                 goto out_free;
197         }
198         if (ssid->ht40)
199                 conf->secondary_channel = ssid->ht40;
200         if (conf->hw_mode == HOSTAPD_MODE_IEEE80211A && ssid->vht) {
201                 conf->vht_oper_chwidth = ssid->max_oper_chwidth;
202                 switch (conf->vht_oper_chwidth) {
203                 case VHT_CHANWIDTH_80MHZ:
204                 case VHT_CHANWIDTH_80P80MHZ:
205                         ieee80211_freq_to_chan(
206                                 ssid->frequency,
207                                 &conf->vht_oper_centr_freq_seg0_idx);
208                         conf->vht_oper_centr_freq_seg0_idx += ssid->ht40 * 2;
209                         break;
210                 case VHT_CHANWIDTH_160MHZ:
211                         ieee80211_freq_to_chan(
212                                 ssid->frequency,
213                                 &conf->vht_oper_centr_freq_seg0_idx);
214                         conf->vht_oper_centr_freq_seg0_idx += ssid->ht40 * 2;
215                         conf->vht_oper_centr_freq_seg0_idx += 40 / 5;
216                         break;
217                 }
218                 ieee80211_freq_to_chan(ssid->vht_center_freq2,
219                                        &conf->vht_oper_centr_freq_seg1_idx);
220         }
221
222         if (ssid->mesh_basic_rates == NULL) {
223                 /*
224                  * XXX: Hack! This is so an MPM which correctly sets the ERP
225                  * mandatory rates as BSSBasicRateSet doesn't reject us. We
226                  * could add a new hw_mode HOSTAPD_MODE_IEEE80211G_ERP, but
227                  * this is way easier. This also makes our BSSBasicRateSet
228                  * advertised in beacons match the one in peering frames, sigh.
229                  */
230                 if (conf->hw_mode == HOSTAPD_MODE_IEEE80211G) {
231                         conf->basic_rates = os_malloc(sizeof(basic_rates_erp));
232                         if (!conf->basic_rates)
233                                 goto out_free;
234                         os_memcpy(conf->basic_rates, basic_rates_erp,
235                                   sizeof(basic_rates_erp));
236                 }
237         } else {
238                 rate_len = 0;
239                 while (1) {
240                         if (ssid->mesh_basic_rates[rate_len] < 1)
241                                 break;
242                         rate_len++;
243                 }
244                 conf->basic_rates = os_calloc(rate_len + 1, sizeof(int));
245                 if (conf->basic_rates == NULL)
246                         goto out_free;
247                 os_memcpy(conf->basic_rates, ssid->mesh_basic_rates,
248                           rate_len * sizeof(int));
249                 conf->basic_rates[rate_len] = -1;
250         }
251
252         if (hostapd_setup_interface(ifmsh)) {
253                 wpa_printf(MSG_ERROR,
254                            "Failed to initialize hostapd interface for mesh");
255                 return -1;
256         }
257
258         if (wpa_drv_init_mesh(wpa_s)) {
259                 wpa_msg(wpa_s, MSG_ERROR, "Failed to init mesh in driver");
260                 return -1;
261         }
262
263         if (mconf->security != MESH_CONF_SEC_NONE) {
264                 if (ssid->passphrase == NULL) {
265                         wpa_printf(MSG_ERROR,
266                                    "mesh: Passphrase for SAE not configured");
267                         goto out_free;
268                 }
269
270                 bss->conf->wpa = ssid->proto;
271                 bss->conf->wpa_key_mgmt = ssid->key_mgmt;
272
273                 if (wpa_s->conf->sae_groups &&
274                     wpa_s->conf->sae_groups[0] > 0) {
275                         wpas_mesh_copy_groups(bss, wpa_s);
276                 } else {
277                         bss->conf->sae_groups =
278                                 os_malloc(sizeof(default_groups));
279                         if (!bss->conf->sae_groups)
280                                 goto out_free;
281                         os_memcpy(bss->conf->sae_groups, default_groups,
282                                   sizeof(default_groups));
283                 }
284
285                 len = os_strlen(ssid->passphrase);
286                 bss->conf->ssid.wpa_passphrase =
287                         dup_binstr(ssid->passphrase, len);
288
289                 wpa_s->mesh_rsn = mesh_rsn_auth_init(wpa_s, mconf);
290                 if (!wpa_s->mesh_rsn)
291                         goto out_free;
292         }
293
294         wpa_supplicant_conf_ap_ht(wpa_s, ssid, conf);
295
296         return 0;
297 out_free:
298         wpa_supplicant_mesh_deinit(wpa_s);
299         return -ENOMEM;
300 }
301
302
303 void wpa_mesh_notify_peer(struct wpa_supplicant *wpa_s, const u8 *addr,
304                           const u8 *ies, size_t ie_len)
305 {
306         struct ieee802_11_elems elems;
307
308         wpa_msg(wpa_s, MSG_INFO,
309                 "new peer notification for " MACSTR, MAC2STR(addr));
310
311         if (ieee802_11_parse_elems(ies, ie_len, &elems, 0) == ParseFailed) {
312                 wpa_msg(wpa_s, MSG_INFO, "Could not parse beacon from " MACSTR,
313                         MAC2STR(addr));
314                 return;
315         }
316         wpa_mesh_new_mesh_peer(wpa_s, addr, &elems);
317 }
318
319
320 void wpa_supplicant_mesh_add_scan_ie(struct wpa_supplicant *wpa_s,
321                                      struct wpabuf **extra_ie)
322 {
323         /* EID + 0-length (wildcard) mesh-id */
324         size_t ielen = 2;
325
326         if (wpabuf_resize(extra_ie, ielen) == 0) {
327                 wpabuf_put_u8(*extra_ie, WLAN_EID_MESH_ID);
328                 wpabuf_put_u8(*extra_ie, 0);
329         }
330 }
331
332
333 int wpa_supplicant_join_mesh(struct wpa_supplicant *wpa_s,
334                              struct wpa_ssid *ssid)
335 {
336         struct wpa_driver_mesh_join_params params;
337         int ret = 0;
338
339         if (!ssid || !ssid->ssid || !ssid->ssid_len || !ssid->frequency) {
340                 ret = -ENOENT;
341                 goto out;
342         }
343
344         wpa_supplicant_mesh_deinit(wpa_s);
345
346         if (ssid->key_mgmt & WPA_KEY_MGMT_SAE) {
347                 wpa_s->pairwise_cipher = WPA_CIPHER_CCMP;
348                 wpa_s->group_cipher = WPA_CIPHER_CCMP;
349                 wpa_s->mgmt_group_cipher = 0;
350         } else {
351                 wpa_s->pairwise_cipher = WPA_CIPHER_NONE;
352                 wpa_s->group_cipher = WPA_CIPHER_NONE;
353                 wpa_s->mgmt_group_cipher = 0;
354         }
355
356         os_memset(&params, 0, sizeof(params));
357         params.meshid = ssid->ssid;
358         params.meshid_len = ssid->ssid_len;
359         ibss_mesh_setup_freq(wpa_s, ssid, &params.freq);
360         wpa_s->mesh_ht_enabled = !!params.freq.ht_enabled;
361         wpa_s->mesh_vht_enabled = !!params.freq.vht_enabled;
362         if (params.freq.ht_enabled && params.freq.sec_channel_offset)
363                 ssid->ht40 = params.freq.sec_channel_offset;
364         if (wpa_s->mesh_vht_enabled) {
365                 ssid->vht = 1;
366                 switch (params.freq.bandwidth) {
367                 case 80:
368                         if (params.freq.center_freq2) {
369                                 ssid->max_oper_chwidth = VHT_CHANWIDTH_80P80MHZ;
370                                 ssid->vht_center_freq2 =
371                                         params.freq.center_freq2;
372                         } else {
373                                 ssid->max_oper_chwidth = VHT_CHANWIDTH_80MHZ;
374                         }
375                         break;
376                 case 160:
377                         ssid->max_oper_chwidth = VHT_CHANWIDTH_160MHZ;
378                         break;
379                 default:
380                         ssid->max_oper_chwidth = VHT_CHANWIDTH_USE_HT;
381                         break;
382                 }
383         }
384         if (ssid->beacon_int > 0)
385                 params.beacon_int = ssid->beacon_int;
386         else if (wpa_s->conf->beacon_int > 0)
387                 params.beacon_int = wpa_s->conf->beacon_int;
388         params.max_peer_links = wpa_s->conf->max_peer_links;
389
390         if (ssid->key_mgmt & WPA_KEY_MGMT_SAE) {
391                 params.flags |= WPA_DRIVER_MESH_FLAG_SAE_AUTH;
392                 params.flags |= WPA_DRIVER_MESH_FLAG_AMPE;
393                 wpa_s->conf->user_mpm = 1;
394         }
395
396         if (wpa_s->conf->user_mpm) {
397                 params.flags |= WPA_DRIVER_MESH_FLAG_USER_MPM;
398                 params.conf.flags &= ~WPA_DRIVER_MESH_CONF_FLAG_AUTO_PLINKS;
399         } else {
400                 params.flags |= WPA_DRIVER_MESH_FLAG_DRIVER_MPM;
401                 params.conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_AUTO_PLINKS;
402         }
403         params.conf.peer_link_timeout = wpa_s->conf->mesh_max_inactivity;
404
405         if (wpa_supplicant_mesh_init(wpa_s, ssid)) {
406                 wpa_msg(wpa_s, MSG_ERROR, "Failed to init mesh");
407                 wpa_drv_leave_mesh(wpa_s);
408                 ret = -1;
409                 goto out;
410         }
411
412         if (wpa_s->ifmsh) {
413                 params.ies = wpa_s->ifmsh->mconf->rsn_ie;
414                 params.ie_len = wpa_s->ifmsh->mconf->rsn_ie_len;
415                 params.basic_rates = wpa_s->ifmsh->basic_rates;
416         }
417
418         wpa_msg(wpa_s, MSG_INFO, "joining mesh %s",
419                 wpa_ssid_txt(ssid->ssid, ssid->ssid_len));
420         ret = wpa_drv_join_mesh(wpa_s, &params);
421         if (ret)
422                 wpa_msg(wpa_s, MSG_ERROR, "mesh join error=%d", ret);
423
424         /* hostapd sets the interface down until we associate */
425         wpa_drv_set_operstate(wpa_s, 1);
426
427 out:
428         return ret;
429 }
430
431
432 int wpa_supplicant_leave_mesh(struct wpa_supplicant *wpa_s)
433 {
434         int ret = 0;
435
436         wpa_msg(wpa_s, MSG_INFO, "leaving mesh");
437
438         /* Need to send peering close messages first */
439         wpa_supplicant_mesh_deinit(wpa_s);
440
441         ret = wpa_drv_leave_mesh(wpa_s);
442         if (ret)
443                 wpa_msg(wpa_s, MSG_ERROR, "mesh leave error=%d", ret);
444
445         wpa_drv_set_operstate(wpa_s, 1);
446
447         return ret;
448 }
449
450
451 static int mesh_attr_text(const u8 *ies, size_t ies_len, char *buf, char *end)
452 {
453         struct ieee802_11_elems elems;
454         char *mesh_id, *pos = buf;
455         u8 *bss_basic_rate_set;
456         int bss_basic_rate_set_len, ret, i;
457
458         if (ieee802_11_parse_elems(ies, ies_len, &elems, 0) == ParseFailed)
459                 return -1;
460
461         if (elems.mesh_id_len < 1)
462                 return 0;
463
464         mesh_id = os_malloc(elems.mesh_id_len + 1);
465         if (mesh_id == NULL)
466                 return -1;
467
468         os_memcpy(mesh_id, elems.mesh_id, elems.mesh_id_len);
469         mesh_id[elems.mesh_id_len] = '\0';
470         ret = os_snprintf(pos, end - pos, "mesh_id=%s\n", mesh_id);
471         os_free(mesh_id);
472         if (os_snprintf_error(end - pos, ret))
473                 return pos - buf;
474         pos += ret;
475
476         if (elems.mesh_config_len > 6) {
477                 ret = os_snprintf(pos, end - pos,
478                                   "active_path_selection_protocol_id=0x%02x\n"
479                                   "active_path_selection_metric_id=0x%02x\n"
480                                   "congestion_control_mode_id=0x%02x\n"
481                                   "synchronization_method_id=0x%02x\n"
482                                   "authentication_protocol_id=0x%02x\n"
483                                   "mesh_formation_info=0x%02x\n"
484                                   "mesh_capability=0x%02x\n",
485                                   elems.mesh_config[0], elems.mesh_config[1],
486                                   elems.mesh_config[2], elems.mesh_config[3],
487                                   elems.mesh_config[4], elems.mesh_config[5],
488                                   elems.mesh_config[6]);
489                 if (os_snprintf_error(end - pos, ret))
490                         return pos - buf;
491                 pos += ret;
492         }
493
494         bss_basic_rate_set = os_malloc(elems.supp_rates_len +
495                 elems.ext_supp_rates_len);
496         if (bss_basic_rate_set == NULL)
497                 return -1;
498
499         bss_basic_rate_set_len = 0;
500         for (i = 0; i < elems.supp_rates_len; i++) {
501                 if (elems.supp_rates[i] & 0x80) {
502                         bss_basic_rate_set[bss_basic_rate_set_len++] =
503                                 (elems.supp_rates[i] & 0x7f) * 5;
504                 }
505         }
506         for (i = 0; i < elems.ext_supp_rates_len; i++) {
507                 if (elems.ext_supp_rates[i] & 0x80) {
508                         bss_basic_rate_set[bss_basic_rate_set_len++] =
509                                 (elems.ext_supp_rates[i] & 0x7f) * 5;
510                 }
511         }
512         if (bss_basic_rate_set_len > 0) {
513                 ret = os_snprintf(pos, end - pos, "bss_basic_rate_set=%d",
514                                   bss_basic_rate_set[0]);
515                 if (os_snprintf_error(end - pos, ret))
516                         goto fail;
517                 pos += ret;
518
519                 for (i = 1; i < bss_basic_rate_set_len; i++) {
520                         ret = os_snprintf(pos, end - pos, " %d",
521                                           bss_basic_rate_set[i]);
522                         if (os_snprintf_error(end - pos, ret))
523                                 goto fail;
524                         pos += ret;
525                 }
526
527                 ret = os_snprintf(pos, end - pos, "\n");
528                 if (os_snprintf_error(end - pos, ret))
529                         goto fail;
530                 pos += ret;
531         }
532 fail:
533         os_free(bss_basic_rate_set);
534
535         return pos - buf;
536 }
537
538
539 int wpas_mesh_scan_result_text(const u8 *ies, size_t ies_len, char *buf,
540                                char *end)
541 {
542         return mesh_attr_text(ies, ies_len, buf, end);
543 }
544
545
546 static int wpas_mesh_get_ifname(struct wpa_supplicant *wpa_s, char *ifname,
547                                 size_t len)
548 {
549         char *ifname_ptr = wpa_s->ifname;
550         int res;
551
552         res = os_snprintf(ifname, len, "mesh-%s-%d", ifname_ptr,
553                           wpa_s->mesh_if_idx);
554         if (os_snprintf_error(len, res) ||
555             (os_strlen(ifname) >= IFNAMSIZ &&
556              os_strlen(wpa_s->ifname) < IFNAMSIZ)) {
557                 /* Try to avoid going over the IFNAMSIZ length limit */
558                 res = os_snprintf(ifname, len, "mesh-%d", wpa_s->mesh_if_idx);
559                 if (os_snprintf_error(len, res))
560                         return -1;
561         }
562         wpa_s->mesh_if_idx++;
563         return 0;
564 }
565
566
567 int wpas_mesh_add_interface(struct wpa_supplicant *wpa_s, char *ifname,
568                             size_t len)
569 {
570         struct wpa_interface iface;
571         struct wpa_supplicant *mesh_wpa_s;
572         u8 addr[ETH_ALEN];
573
574         if (ifname[0] == '\0' && wpas_mesh_get_ifname(wpa_s, ifname, len) < 0)
575                 return -1;
576
577         if (wpa_drv_if_add(wpa_s, WPA_IF_MESH, ifname, NULL, NULL, NULL, addr,
578                            NULL) < 0) {
579                 wpa_printf(MSG_ERROR,
580                            "mesh: Failed to create new mesh interface");
581                 return -1;
582         }
583         wpa_printf(MSG_INFO, "mesh: Created virtual interface %s addr "
584                    MACSTR, ifname, MAC2STR(addr));
585
586         os_memset(&iface, 0, sizeof(iface));
587         iface.ifname = ifname;
588         iface.driver = wpa_s->driver->name;
589         iface.driver_param = wpa_s->conf->driver_param;
590         iface.ctrl_interface = wpa_s->conf->ctrl_interface;
591
592         mesh_wpa_s = wpa_supplicant_add_iface(wpa_s->global, &iface, wpa_s);
593         if (!mesh_wpa_s) {
594                 wpa_printf(MSG_ERROR,
595                            "mesh: Failed to create new wpa_supplicant interface");
596                 wpa_drv_if_remove(wpa_s, WPA_IF_MESH, ifname);
597                 return -1;
598         }
599         mesh_wpa_s->mesh_if_created = 1;
600         return 0;
601 }
602
603
604 int wpas_mesh_peer_remove(struct wpa_supplicant *wpa_s, const u8 *addr)
605 {
606         return mesh_mpm_close_peer(wpa_s, addr);
607 }
608
609
610 int wpas_mesh_peer_add(struct wpa_supplicant *wpa_s, const u8 *addr,
611                        int duration)
612 {
613         return mesh_mpm_connect_peer(wpa_s, addr, duration);
614 }