Lines Matching refs:wpa_s
31 static void wpa_supplicant_mesh_deinit(struct wpa_supplicant *wpa_s, in wpa_supplicant_mesh_deinit() argument
34 wpa_supplicant_mesh_iface_deinit(wpa_s, wpa_s->ifmsh, in wpa_supplicant_mesh_deinit()
38 wpa_s->ifmsh = NULL; in wpa_supplicant_mesh_deinit()
39 wpa_s->current_ssid = NULL; in wpa_supplicant_mesh_deinit()
40 os_free(wpa_s->mesh_params); in wpa_supplicant_mesh_deinit()
41 wpa_s->mesh_params = NULL; in wpa_supplicant_mesh_deinit()
44 os_free(wpa_s->mesh_rsn); in wpa_supplicant_mesh_deinit()
45 wpa_s->mesh_rsn = NULL; in wpa_supplicant_mesh_deinit()
48 wpa_supplicant_leave_mesh(wpa_s, false); in wpa_supplicant_mesh_deinit()
52 void wpa_supplicant_mesh_iface_deinit(struct wpa_supplicant *wpa_s, in wpa_supplicant_mesh_iface_deinit() argument
60 mesh_mpm_deinit(wpa_s, ifmsh); in wpa_supplicant_mesh_iface_deinit()
82 static struct mesh_conf * mesh_config_create(struct wpa_supplicant *wpa_s, in mesh_config_create() argument
102 if (wpa_s->drv_enc & WPA_DRIVER_CAPA_ENC_BIP) in mesh_config_create()
103 conf->ieee80211w = wpa_s->conf->pmf; in mesh_config_create()
113 wpa_msg(wpa_s, MSG_INFO, "mesh: Invalid pairwise cipher"); in mesh_config_create()
122 wpa_msg(wpa_s, MSG_INFO, "mesh: Invalid group cipher"); in mesh_config_create()
153 struct wpa_supplicant *wpa_s) in wpas_mesh_copy_groups() argument
158 for (num_groups = 0; wpa_s->conf->sae_groups[num_groups] > 0; in wpas_mesh_copy_groups()
162 groups_size = (num_groups + 1) * sizeof(wpa_s->conf->sae_groups[0]); in wpas_mesh_copy_groups()
165 os_memcpy(bss->conf->sae_groups, wpa_s->conf->sae_groups, in wpas_mesh_copy_groups()
170 static int wpas_mesh_init_rsn(struct wpa_supplicant *wpa_s) in wpas_mesh_init_rsn() argument
172 struct hostapd_iface *ifmsh = wpa_s->ifmsh; in wpas_mesh_init_rsn()
173 struct wpa_ssid *ssid = wpa_s->current_ssid; in wpas_mesh_init_rsn()
191 if (wpa_s->conf->sae_groups && wpa_s->conf->sae_groups[0] > 0) { in wpas_mesh_init_rsn()
192 wpas_mesh_copy_groups(bss, wpa_s); in wpas_mesh_init_rsn()
203 wpa_s->mesh_rsn = mesh_rsn_auth_init(wpa_s, ifmsh->mconf); in wpas_mesh_init_rsn()
204 return !wpa_s->mesh_rsn ? -1 : 0; in wpas_mesh_init_rsn()
208 static int wpas_mesh_update_freq_params(struct wpa_supplicant *wpa_s) in wpas_mesh_update_freq_params() argument
210 struct wpa_driver_mesh_join_params *params = wpa_s->mesh_params; in wpas_mesh_update_freq_params()
211 struct hostapd_iface *ifmsh = wpa_s->ifmsh; in wpas_mesh_update_freq_params()
234 wpa_supplicant_mesh_deinit(wpa_s, true); in wpas_mesh_update_freq_params()
242 static int wpas_mesh_complete(struct wpa_supplicant *wpa_s) in wpas_mesh_complete() argument
244 struct hostapd_iface *ifmsh = wpa_s->ifmsh; in wpas_mesh_complete()
245 struct wpa_driver_mesh_join_params *params = wpa_s->mesh_params; in wpas_mesh_complete()
246 struct wpa_ssid *ssid = wpa_s->current_ssid; in wpas_mesh_complete()
260 wpa_s->assoc_freq = ifmsh->freq; in wpas_mesh_complete()
262 if (wpas_mesh_update_freq_params(wpa_s) < 0) in wpas_mesh_complete()
267 wpas_mesh_init_rsn(wpa_s)) { in wpas_mesh_complete()
270 wpa_supplicant_mesh_deinit(wpa_s, false); in wpas_mesh_complete()
275 wpa_s->pairwise_cipher = wpa_s->mesh_rsn->pairwise_cipher; in wpas_mesh_complete()
276 wpa_s->group_cipher = wpa_s->mesh_rsn->group_cipher; in wpas_mesh_complete()
277 wpa_s->mgmt_group_cipher = wpa_s->mesh_rsn->mgmt_group_cipher; in wpas_mesh_complete()
286 wpa_msg(wpa_s, MSG_INFO, "joining mesh %s", in wpas_mesh_complete()
288 ret = wpa_drv_join_mesh(wpa_s, params); in wpas_mesh_complete()
290 wpa_msg(wpa_s, MSG_ERROR, "mesh join error=%d", ret); in wpas_mesh_complete()
293 wpa_drv_set_operstate(wpa_s, 1); in wpas_mesh_complete()
296 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED); in wpas_mesh_complete()
298 wpa_msg(wpa_s, MSG_INFO, MESH_GROUP_STARTED "ssid=\"%s\" id=%d", in wpas_mesh_complete()
301 wpas_notify_mesh_group_started(wpa_s, ssid); in wpas_mesh_complete()
310 struct wpa_supplicant *wpa_s = arg; in wpas_mesh_complete_cb() local
312 wpas_mesh_complete(wpa_s); in wpas_mesh_complete_cb()
318 struct wpa_supplicant *wpa_s = ifmsh->owner; in wpa_supplicant_mesh_enable_iface_cb() local
321 ifmsh->mconf = mesh_config_create(wpa_s, wpa_s->current_ssid); in wpa_supplicant_mesh_enable_iface_cb()
324 bss->msg_ctx = wpa_s; in wpa_supplicant_mesh_enable_iface_cb()
325 os_memcpy(bss->own_addr, wpa_s->own_addr, ETH_ALEN); in wpa_supplicant_mesh_enable_iface_cb()
326 bss->driver = wpa_s->driver; in wpa_supplicant_mesh_enable_iface_cb()
327 bss->drv_priv = wpa_s->drv_priv; in wpa_supplicant_mesh_enable_iface_cb()
331 bss->setup_complete_cb_ctx = wpa_s; in wpa_supplicant_mesh_enable_iface_cb()
335 bss->conf->ap_max_inactivity = wpa_s->conf->mesh_max_inactivity; in wpa_supplicant_mesh_enable_iface_cb()
337 if (wpa_drv_init_mesh(wpa_s)) { in wpa_supplicant_mesh_enable_iface_cb()
338 wpa_msg(wpa_s, MSG_ERROR, "Failed to init mesh in driver"); in wpa_supplicant_mesh_enable_iface_cb()
354 struct wpa_supplicant *wpa_s = ifmsh->owner; in wpa_supplicant_mesh_disable_iface_cb() local
357 wpa_supplicant_mesh_deinit(wpa_s, false); in wpa_supplicant_mesh_disable_iface_cb()
379 static int wpa_supplicant_mesh_init(struct wpa_supplicant *wpa_s, in wpa_supplicant_mesh_init() argument
391 if (!wpa_s->conf->user_mpm) { in wpa_supplicant_mesh_init()
393 wpa_msg(wpa_s, MSG_WARNING, in wpa_supplicant_mesh_init()
398 wpa_s->ifmsh = ifmsh = hostapd_alloc_iface(); in wpa_supplicant_mesh_init()
402 ifmsh->owner = wpa_s; in wpa_supplicant_mesh_init()
403 ifmsh->drv_flags = wpa_s->drv_flags; in wpa_supplicant_mesh_init()
404 ifmsh->drv_flags2 = wpa_s->drv_flags2; in wpa_supplicant_mesh_init()
408 ifmsh->bss = os_calloc(wpa_s->ifmsh->num_bss, in wpa_supplicant_mesh_init()
417 ifmsh->bss[0]->msg_ctx = wpa_s; in wpa_supplicant_mesh_init()
418 os_memcpy(bss->own_addr, wpa_s->own_addr, ETH_ALEN); in wpa_supplicant_mesh_init()
419 bss->driver = wpa_s->driver; in wpa_supplicant_mesh_init()
420 bss->drv_priv = wpa_s->drv_priv; in wpa_supplicant_mesh_init()
424 bss->setup_complete_cb_ctx = wpa_s; in wpa_supplicant_mesh_init()
432 wpa_s->assoc_freq = frequency; in wpa_supplicant_mesh_init()
433 wpa_s->current_ssid = ssid; in wpa_supplicant_mesh_init()
443 bss->conf->ap_max_inactivity = wpa_s->conf->mesh_max_inactivity; in wpa_supplicant_mesh_init()
445 if (ieee80211_is_dfs(ssid->frequency, wpa_s->hw.modes, in wpa_supplicant_mesh_init()
446 wpa_s->hw.num_modes) && wpa_s->conf->country[0]) { in wpa_supplicant_mesh_init()
449 conf->country[0] = wpa_s->conf->country[0]; in wpa_supplicant_mesh_init()
450 conf->country[1] = wpa_s->conf->country[1]; in wpa_supplicant_mesh_init()
452 wpa_s->mesh_params->handle_dfs = true; in wpa_supplicant_mesh_init()
458 ifmsh->bss[0]->max_plinks = wpa_s->conf->max_peer_links; in wpa_supplicant_mesh_init()
460 wpa_s->conf->dot11RSNASAERetransPeriod; in wpa_supplicant_mesh_init()
461 os_strlcpy(bss->conf->iface, wpa_s->ifname, sizeof(bss->conf->iface)); in wpa_supplicant_mesh_init()
463 mconf = mesh_config_create(wpa_s, ssid); in wpa_supplicant_mesh_init()
528 wpa_supplicant_conf_ap_ht(wpa_s, ssid, conf); in wpa_supplicant_mesh_init()
530 if (wpa_drv_init_mesh(wpa_s)) { in wpa_supplicant_mesh_init()
531 wpa_msg(wpa_s, MSG_ERROR, "Failed to init mesh in driver"); in wpa_supplicant_mesh_init()
543 wpa_supplicant_mesh_deinit(wpa_s, true); in wpa_supplicant_mesh_init()
548 void wpa_mesh_notify_peer(struct wpa_supplicant *wpa_s, const u8 *addr, in wpa_mesh_notify_peer() argument
553 wpa_msg(wpa_s, MSG_INFO, in wpa_mesh_notify_peer()
557 wpa_msg(wpa_s, MSG_INFO, "Could not parse beacon from " MACSTR, in wpa_mesh_notify_peer()
561 wpa_mesh_new_mesh_peer(wpa_s, addr, &elems); in wpa_mesh_notify_peer()
565 void wpa_supplicant_mesh_add_scan_ie(struct wpa_supplicant *wpa_s, in wpa_supplicant_mesh_add_scan_ie() argument
578 int wpa_supplicant_join_mesh(struct wpa_supplicant *wpa_s, in wpa_supplicant_join_mesh() argument
591 wpa_supplicant_mesh_deinit(wpa_s, true); in wpa_supplicant_join_mesh()
593 wpa_s->pairwise_cipher = WPA_CIPHER_NONE; in wpa_supplicant_join_mesh()
594 wpa_s->group_cipher = WPA_CIPHER_NONE; in wpa_supplicant_join_mesh()
595 wpa_s->mgmt_group_cipher = 0; in wpa_supplicant_join_mesh()
599 ibss_mesh_setup_freq(wpa_s, ssid, ¶ms->freq); in wpa_supplicant_join_mesh()
600 wpa_s->mesh_ht_enabled = !!params->freq.ht_enabled; in wpa_supplicant_join_mesh()
601 wpa_s->mesh_vht_enabled = !!params->freq.vht_enabled; in wpa_supplicant_join_mesh()
602 wpa_s->mesh_he_enabled = !!params->freq.he_enabled; in wpa_supplicant_join_mesh()
606 if (wpa_s->mesh_vht_enabled) { in wpa_supplicant_join_mesh()
627 if (wpa_s->mesh_he_enabled) in wpa_supplicant_join_mesh()
631 else if (wpa_s->conf->beacon_int > 0) in wpa_supplicant_join_mesh()
632 params->beacon_int = wpa_s->conf->beacon_int; in wpa_supplicant_join_mesh()
635 else if (wpa_s->conf->dtim_period > 0) in wpa_supplicant_join_mesh()
636 params->dtim_period = wpa_s->conf->dtim_period; in wpa_supplicant_join_mesh()
637 params->conf.max_peer_links = wpa_s->conf->max_peer_links; in wpa_supplicant_join_mesh()
646 wpa_s->conf->user_mpm = 1; in wpa_supplicant_join_mesh()
649 if (wpa_s->conf->user_mpm) { in wpa_supplicant_join_mesh()
656 params->conf.peer_link_timeout = wpa_s->conf->mesh_max_inactivity; in wpa_supplicant_join_mesh()
658 os_free(wpa_s->mesh_params); in wpa_supplicant_join_mesh()
659 wpa_s->mesh_params = params; in wpa_supplicant_join_mesh()
660 if (wpa_supplicant_mesh_init(wpa_s, ssid, ¶ms->freq)) { in wpa_supplicant_join_mesh()
661 wpa_msg(wpa_s, MSG_ERROR, "Failed to init mesh"); in wpa_supplicant_join_mesh()
662 wpa_supplicant_leave_mesh(wpa_s, true); in wpa_supplicant_join_mesh()
672 int wpa_supplicant_leave_mesh(struct wpa_supplicant *wpa_s, bool need_deinit) in wpa_supplicant_leave_mesh() argument
676 wpa_msg(wpa_s, MSG_INFO, "leaving mesh"); in wpa_supplicant_leave_mesh()
680 wpa_supplicant_mesh_deinit(wpa_s, true); in wpa_supplicant_leave_mesh()
682 ret = wpa_drv_leave_mesh(wpa_s); in wpa_supplicant_leave_mesh()
684 wpa_msg(wpa_s, MSG_ERROR, "mesh leave error=%d", ret); in wpa_supplicant_leave_mesh()
686 wpa_drv_set_operstate(wpa_s, 1); in wpa_supplicant_leave_mesh()
787 static int wpas_mesh_get_ifname(struct wpa_supplicant *wpa_s, char *ifname, in wpas_mesh_get_ifname() argument
790 char *ifname_ptr = wpa_s->ifname; in wpas_mesh_get_ifname()
794 wpa_s->mesh_if_idx); in wpas_mesh_get_ifname()
797 os_strlen(wpa_s->ifname) < IFNAMSIZ)) { in wpas_mesh_get_ifname()
799 res = os_snprintf(ifname, len, "mesh-%d", wpa_s->mesh_if_idx); in wpas_mesh_get_ifname()
803 wpa_s->mesh_if_idx++; in wpas_mesh_get_ifname()
808 int wpas_mesh_add_interface(struct wpa_supplicant *wpa_s, char *ifname, in wpas_mesh_add_interface() argument
815 if (ifname[0] == '\0' && wpas_mesh_get_ifname(wpa_s, ifname, len) < 0) in wpas_mesh_add_interface()
818 if (wpa_drv_if_add(wpa_s, WPA_IF_MESH, ifname, NULL, NULL, NULL, addr, in wpas_mesh_add_interface()
829 iface.driver = wpa_s->driver->name; in wpas_mesh_add_interface()
830 iface.driver_param = wpa_s->conf->driver_param; in wpas_mesh_add_interface()
831 iface.ctrl_interface = wpa_s->conf->ctrl_interface; in wpas_mesh_add_interface()
833 mesh_wpa_s = wpa_supplicant_add_iface(wpa_s->global, &iface, wpa_s); in wpas_mesh_add_interface()
837 wpa_drv_if_remove(wpa_s, WPA_IF_MESH, ifname); in wpas_mesh_add_interface()
845 int wpas_mesh_peer_remove(struct wpa_supplicant *wpa_s, const u8 *addr) in wpas_mesh_peer_remove() argument
847 return mesh_mpm_close_peer(wpa_s, addr); in wpas_mesh_peer_remove()
851 int wpas_mesh_peer_add(struct wpa_supplicant *wpa_s, const u8 *addr, in wpas_mesh_peer_add() argument
854 return mesh_mpm_connect_peer(wpa_s, addr, duration); in wpas_mesh_peer_add()