Lines Matching +full:switch +full:- +full:freq +full:- +full:select
2 * wpa_supplicant - P2P
3 * Copyright (c) 2009-2010, Atheros Communications
4 * Copyright (c) 2010-2014, Jouni Malinen <j@w1.fi>
58 * channel (and if the driver supports channel switch).
73 * How many seconds to wait for initial 4-way handshake to get completed after
74 * WPS provisioning step or after the re-invocation of a persistent group on a
82 * How many seconds to wait for initial 4-way handshake to get completed after
92 * How many seconds to wait for initial 4-way handshake to get completed after
93 * re-invocation of a persistent group on the GO when the client is expected
99 #define P2P_MGMT_DEVICE_PREFIX "p2p-dev-"
102 * How many seconds to wait to re-attempt to move GOs, in case previous attempt
125 static int wpas_p2p_join_start(struct wpa_supplicant *wpa_s, int freq,
127 static int wpas_p2p_setup_freqs(struct wpa_supplicant *wpa_s, int freq,
131 static void wpas_p2p_join_scan_req(struct wpa_supplicant *wpa_s, int freq,
136 int auto_join, int freq,
159 static int wpas_p2p_go_is_peer_freq(struct wpa_supplicant *wpa_s, int freq);
166 unsigned int freq);
174 he_capab = mode->he_capab[WPAS_MODE_INFRA].phy_cap[ in wpas_get_6ghz_he_chwidth_capab()
189 freqs = os_calloc(wpa_s->num_multichan_concurrent, sizeof(int)); in wpas_p2p_num_unused_channels()
191 return -1; in wpas_p2p_num_unused_channels()
194 wpa_s->num_multichan_concurrent, false); in wpas_p2p_num_unused_channels()
197 unused = wpa_s->num_multichan_concurrent - num; in wpas_p2p_num_unused_channels()
215 freqs = os_calloc(wpa_s->num_multichan_concurrent, in wpas_p2p_valid_oper_freqs()
221 wpa_s->num_multichan_concurrent, in wpas_p2p_valid_oper_freqs()
227 if (p2p_supported_freq(wpa_s->global->p2p, freqs[i].freq)) in wpas_p2p_valid_oper_freqs()
240 int freq) in wpas_p2p_set_own_freq_preference() argument
242 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL) in wpas_p2p_set_own_freq_preference()
246 wpa_s = wpa_s->global->p2p_init_wpa_s; in wpas_p2p_set_own_freq_preference()
248 if (wpa_s->conf->p2p_ignore_shared_freq && in wpas_p2p_set_own_freq_preference()
249 freq > 0 && wpa_s->num_multichan_concurrent > 1 && in wpas_p2p_set_own_freq_preference()
252 freq); in wpas_p2p_set_own_freq_preference()
253 freq = 0; in wpas_p2p_set_own_freq_preference()
255 p2p_set_own_freq_preference(wpa_s->global->p2p, freq); in wpas_p2p_set_own_freq_preference()
264 if (external_scan_running(wpa_s->radio)) { in wpas_p2p_scan_res_handled()
265 delay = wpa_s->conf->p2p_search_delay; in wpas_p2p_scan_res_handled()
271 p2p_scan_res_handled(wpa_s->global->p2p, delay); in wpas_p2p_scan_res_handled()
280 if (wpa_s->p2p_scan_work) { in wpas_p2p_scan_res_handler()
281 struct wpa_radio_work *work = wpa_s->p2p_scan_work; in wpas_p2p_scan_res_handler()
282 wpa_s->p2p_scan_work = NULL; in wpas_p2p_scan_res_handler()
286 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL) in wpas_p2p_scan_res_handler()
290 (int) scan_res->num); in wpas_p2p_scan_res_handler()
292 for (i = 0; i < scan_res->num; i++) { in wpas_p2p_scan_res_handler()
293 struct wpa_scan_res *bss = scan_res->res[i]; in wpas_p2p_scan_res_handler()
298 time_tmp_age.sec = bss->age / 1000; in wpas_p2p_scan_res_handler()
299 time_tmp_age.usec = (bss->age % 1000) * 1000; in wpas_p2p_scan_res_handler()
300 os_reltime_sub(&scan_res->fetch_time, &time_tmp_age, &entry_ts); in wpas_p2p_scan_res_handler()
303 ies_len = bss->ie_len; in wpas_p2p_scan_res_handler()
304 if (bss->beacon_ie_len > 0 && in wpas_p2p_scan_res_handler()
308 MACSTR, MAC2STR(bss->bssid)); in wpas_p2p_scan_res_handler()
310 ies_len = bss->beacon_ie_len; in wpas_p2p_scan_res_handler()
314 if (p2p_scan_res_handler(wpa_s->global->p2p, bss->bssid, in wpas_p2p_scan_res_handler()
315 bss->freq, &entry_ts, bss->level, in wpas_p2p_scan_res_handler()
326 if (wpa_s->p2p_scan_work) { in wpas_p2p_scan_res_fail_handler()
327 struct wpa_radio_work *work = wpa_s->p2p_scan_work; in wpas_p2p_scan_res_fail_handler()
329 wpa_s->p2p_scan_work = NULL; in wpas_p2p_scan_res_fail_handler()
333 if (wpa_s->global->p2p_disabled || !wpa_s->global->p2p) in wpas_p2p_scan_res_fail_handler()
337 "P2P: Failed to get scan results - try to continue"); in wpas_p2p_scan_res_fail_handler()
352 if (!wpa_s->conf->p2p_6ghz_disable && in wpas_p2p_scan_freqs()
353 is_p2p_allow_6ghz(wpa_s->global->p2p) && include_6ghz) in wpas_p2p_scan_freqs()
361 struct wpa_supplicant *wpa_s = work->wpa_s; in wpas_p2p_trigger_scan_cb()
362 struct wpa_driver_scan_params *params = work->ctx; in wpas_p2p_trigger_scan_cb()
366 if (!work->started) { in wpas_p2p_trigger_scan_cb()
371 wpa_s->p2p_scan_work = NULL; in wpas_p2p_trigger_scan_cb()
375 if (wpa_s->clear_driver_scan_cache) { in wpas_p2p_trigger_scan_cb()
378 params->only_new_results = 1; in wpas_p2p_trigger_scan_cb()
381 if (!params->freqs) in wpas_p2p_trigger_scan_cb()
382 wpas_p2p_scan_freqs(wpa_s, params, params->p2p_include_6ghz); in wpas_p2p_trigger_scan_cb()
386 wpa_s->curr_scan_cookie = params->scan_cookie; in wpas_p2p_trigger_scan_cb()
388 work->ctx = NULL; in wpas_p2p_trigger_scan_cb()
391 p2p_notify_scan_trigger_status(wpa_s->global->p2p, ret); in wpas_p2p_trigger_scan_cb()
395 p2p_notify_scan_trigger_status(wpa_s->global->p2p, ret); in wpas_p2p_trigger_scan_cb()
396 os_get_reltime(&wpa_s->scan_trigger_time); in wpas_p2p_trigger_scan_cb()
397 wpa_s->scan_res_handler = wpas_p2p_scan_res_handler; in wpas_p2p_trigger_scan_cb()
398 wpa_s->scan_res_fail_handler = wpas_p2p_scan_res_fail_handler; in wpas_p2p_trigger_scan_cb()
399 wpa_s->own_scan_requested = 1; in wpas_p2p_trigger_scan_cb()
400 wpa_s->clear_driver_scan_cache = 0; in wpas_p2p_trigger_scan_cb()
401 wpa_s->p2p_scan_work = work; in wpas_p2p_trigger_scan_cb()
406 int freq) in wpas_p2p_search_social_channel() argument
408 if (wpa_s->global->p2p_24ghz_social_channels && in wpas_p2p_search_social_channel()
409 (freq == 2412 || freq == 2437 || freq == 2462)) { in wpas_p2p_search_social_channel()
417 return p2p_supported_freq(wpa_s->global->p2p, freq); in wpas_p2p_search_social_channel()
421 static int wpas_p2p_scan(void *ctx, enum p2p_scan_type type, int freq, in wpas_p2p_scan() argument
435 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL) in wpas_p2p_scan()
436 return -1; in wpas_p2p_scan()
438 if (wpa_s->p2p_scan_work) { in wpas_p2p_scan()
440 return -1; in wpas_p2p_scan()
445 return -1; in wpas_p2p_scan()
448 params->num_ssids = 1; in wpas_p2p_scan()
453 params->ssids[0].ssid = n; in wpas_p2p_scan()
454 params->ssids[0].ssid_len = P2P_WILDCARD_SSID_LEN; in wpas_p2p_scan()
456 wpa_s->wps->dev.p2p = 1; in wpas_p2p_scan()
457 wps_ie = wps_build_probe_req_ie(pw_id, &wpa_s->wps->dev, in wpas_p2p_scan()
458 wpa_s->wps->uuid, WPS_REQ_ENROLLEE, in wpas_p2p_scan()
469 if (!wpa_s->conf->p2p_6ghz_disable) in wpas_p2p_scan()
470 params->p2p_include_6ghz = include_6ghz; in wpas_p2p_scan()
471 switch (type) { in wpas_p2p_scan()
473 params->freqs = os_calloc(ARRAY_SIZE(social_channels_freq) + 1, in wpas_p2p_scan()
475 if (params->freqs == NULL) in wpas_p2p_scan()
480 params->freqs[num_channels++] = in wpas_p2p_scan()
483 params->freqs[num_channels++] = 0; in wpas_p2p_scan()
488 params->freqs = os_calloc(2, sizeof(int)); in wpas_p2p_scan()
489 if (params->freqs == NULL) in wpas_p2p_scan()
491 params->freqs[0] = freq; in wpas_p2p_scan()
492 params->freqs[1] = 0; in wpas_p2p_scan()
495 params->freqs = os_calloc(ARRAY_SIZE(social_channels_freq) + 2, in wpas_p2p_scan()
497 if (params->freqs == NULL) in wpas_p2p_scan()
502 params->freqs[num_channels++] = in wpas_p2p_scan()
505 if (p2p_supported_freq(wpa_s->global->p2p, freq)) in wpas_p2p_scan()
506 params->freqs[num_channels++] = freq; in wpas_p2p_scan()
507 params->freqs[num_channels++] = 0; in wpas_p2p_scan()
511 ielen = p2p_scan_ie_buf_len(wpa_s->global->p2p); in wpas_p2p_scan()
520 bands = wpas_get_bands(wpa_s, params->freqs); in wpas_p2p_scan()
521 p2p_scan_ie(wpa_s->global->p2p, ies, dev_id, bands); in wpas_p2p_scan()
523 params->p2p_probe = 1; in wpas_p2p_scan()
530 params->extra_ies = n; in wpas_p2p_scan()
531 params->extra_ies_len = wpabuf_len(ies); in wpas_p2p_scan()
534 radio_remove_works(wpa_s, "p2p-scan", 0); in wpas_p2p_scan()
535 if (radio_add_work(wpa_s, 0, "p2p-scan", 0, wpas_p2p_trigger_scan_cb, in wpas_p2p_scan()
542 return -1; in wpas_p2p_scan()
548 switch (p2p_group_interface) { in wpas_p2p_if_type()
567 for (wpa_s = wpa_s->global->ifaces; wpa_s; wpa_s = wpa_s->next) { in wpas_get_p2p_group()
568 for (s = wpa_s->conf->ssid; s; s = s->next) { in wpas_get_p2p_group()
569 if (s->disabled != 0 || !s->p2p_group || in wpas_get_p2p_group()
570 s->ssid_len != ssid_len || in wpas_get_p2p_group()
571 os_memcmp(ssid, s->ssid, ssid_len) != 0) in wpas_get_p2p_group()
573 if (s->mode == WPAS_MODE_P2P_GO && in wpas_get_p2p_group()
574 s != wpa_s->current_ssid) in wpas_get_p2p_group()
577 *go = s->mode == WPAS_MODE_P2P_GO; in wpas_get_p2p_group()
591 wpa_s->ifname); in run_wpas_p2p_disconnect()
600 wpa_s->p2p_group_interface != NOT_P2P_GROUP_INTERFACE) { in wpas_p2p_disconnect_safely()
605 * control interface responses on the per-interface socket. in wpas_p2p_disconnect_safely()
609 return -1; in wpas_p2p_disconnect_safely()
623 for (wpa_s = wpa_s->global->ifaces; wpa_s; wpa_s = wpa_s->next) { in p2p_group_go_member_count()
624 for (s = wpa_s->conf->ssid; s; s = s->next) { in p2p_group_go_member_count()
627 wpa_s, s, s->disabled, s->p2p_group, in p2p_group_go_member_count()
628 s->mode); in p2p_group_go_member_count()
629 if (!s->disabled && s->p2p_group && in p2p_group_go_member_count()
630 s->mode == WPAS_MODE_P2P_GO) { in p2p_group_go_member_count()
632 wpa_s->p2p_group); in p2p_group_go_member_count()
643 return !wpa_s->p2p_mgmt && wpa_s->current_ssid && in p2p_is_active_persistent_group()
644 !wpa_s->current_ssid->disabled && in p2p_is_active_persistent_group()
645 wpa_s->current_ssid->p2p_group && in p2p_is_active_persistent_group()
646 wpa_s->current_ssid->p2p_persistent_group; in p2p_is_active_persistent_group()
653 wpa_s->current_ssid->mode == WPAS_MODE_P2P_GO; in p2p_is_active_persistent_go()
666 for (wpa_s = wpa_s->global->ifaces; wpa_s; wpa_s = wpa_s->next) { in wpas_p2p_get_go_group()
671 if (p2p_get_group_num_members(wpa_s->p2p_group)) in wpas_p2p_get_go_group()
684 wpa_s->current_ssid->mode == WPAS_MODE_INFRA; in p2p_is_active_persistent_cli()
692 for (wpa_s = wpa_s->global->ifaces; wpa_s; wpa_s = wpa_s->next) { in wpas_p2p_get_cli_group()
707 for (s = wpa_s->conf->ssid; s; s = s->next) { in wpas_p2p_get_persistent_go()
708 if (s->disabled == 2 && s->mode == WPAS_MODE_P2P_GO) in wpas_p2p_get_persistent_go()
730 wpa_printf(MSG_DEBUG, "P2P: Conncap - in:%d role:%d", incoming, role); in p2ps_group_capability()
746 * For non-concurrent capable devices: in p2ps_group_capability()
753 owned_members = p2p_get_group_num_members(go_wpa_s->p2p_group); in p2ps_group_capability()
772 p2p_client_limit_reached(go_wpa_s->p2p_group)) in p2ps_group_capability()
797 switch (incoming) { in p2ps_group_capability()
817 * Must be a complimentary role - cannot be a client to in p2ps_group_capability()
842 * negotiation, but rather try to re-use the existing groups. in p2ps_group_capability()
844 switch (incoming) { in p2ps_group_capability()
888 if (go_wpa_s && p2p_client_limit_reached(go_wpa_s->p2p_group)) in p2ps_group_capability()
893 p2p_set_intended_addr(wpa_s->global->p2p, in p2ps_group_capability()
894 wpa_s->p2p_mgmt ? in p2ps_group_capability()
895 wpa_s->parent->own_addr : in p2ps_group_capability()
896 wpa_s->own_addr); in p2ps_group_capability()
904 wpa_s->global->pending_group_iface_for_p2ps = 1; in p2ps_group_capability()
905 p2p_set_intended_addr(wpa_s->global->p2p, in p2ps_group_capability()
906 wpa_s->pending_interface_addr); in p2ps_group_capability()
921 ssid = wpa_s->current_ssid; in wpas_p2p_group_delete()
928 ssid = wpa_s->conf->ssid; in wpas_p2p_group_delete()
930 if (ssid->p2p_group && ssid->disabled != 2) in wpas_p2p_group_delete()
932 ssid = ssid->next; in wpas_p2p_group_delete()
935 wpa_s->p2p_group_interface == NOT_P2P_GROUP_INTERFACE) in wpas_p2p_group_delete()
939 return -1; in wpas_p2p_group_delete()
942 if (wpa_s->p2p_group_interface == P2P_GROUP_INTERFACE_GO) in wpas_p2p_group_delete()
944 else if (wpa_s->p2p_group_interface == P2P_GROUP_INTERFACE_CLIENT || in wpas_p2p_group_delete()
945 (ssid && ssid->mode == WPAS_MODE_INFRA)) { in wpas_p2p_group_delete()
946 wpa_s->reassociate = 0; in wpas_p2p_group_delete()
947 wpa_s->disconnected = 1; in wpas_p2p_group_delete()
967 if (wpa_s->cross_connect_in_use) { in wpas_p2p_group_delete()
968 wpa_s->cross_connect_in_use = 0; in wpas_p2p_group_delete()
969 wpa_msg_global(wpa_s->p2pdev, MSG_INFO, in wpas_p2p_group_delete()
971 wpa_s->ifname, wpa_s->cross_connect_uplink); in wpas_p2p_group_delete()
973 switch (removal_reason) { in wpas_p2p_group_delete()
1000 wpa_msg_global(wpa_s->p2pdev, MSG_INFO, in wpas_p2p_group_delete()
1002 wpa_s->ifname, gtype, reason); in wpas_p2p_group_delete()
1010 wpa_s->p2pdev, NULL) > 0) { in wpas_p2p_group_delete()
1013 wpa_s->p2p_in_provisioning = 0; in wpas_p2p_group_delete()
1017 wpa_s->p2p_in_invitation = 0; in wpas_p2p_group_delete()
1018 wpa_s->p2p_retry_limit = 0; in wpas_p2p_group_delete()
1026 wpa_s->global->p2p_go_wait_client.sec = 0; in wpas_p2p_group_delete()
1028 if (wpa_s->p2p_group_interface != NOT_P2P_GROUP_INTERFACE) { in wpas_p2p_group_delete()
1033 wpa_s->ifname); in wpas_p2p_group_delete()
1034 global = wpa_s->global; in wpas_p2p_group_delete()
1035 ifname = os_strdup(wpa_s->ifname); in wpas_p2p_group_delete()
1036 type = wpas_p2p_if_type(wpa_s->p2p_group_interface); in wpas_p2p_group_delete()
1038 wpa_supplicant_remove_iface(wpa_s->global, wpa_s, 0); in wpas_p2p_group_delete()
1039 wpa_s = global->ifaces; in wpas_p2p_group_delete()
1050 wpa_s->p2pdev = wpa_s->parent; in wpas_p2p_group_delete()
1052 if (!wpa_s->p2p_go_group_formation_completed) { in wpas_p2p_group_delete()
1053 wpa_s->global->p2p_group_formation = NULL; in wpas_p2p_group_delete()
1054 wpa_s->p2p_in_provisioning = 0; in wpas_p2p_group_delete()
1057 wpa_s->show_group_started = 0; in wpas_p2p_group_delete()
1058 os_free(wpa_s->go_params); in wpas_p2p_group_delete()
1059 wpa_s->go_params = NULL; in wpas_p2p_group_delete()
1061 os_free(wpa_s->p2p_group_common_freqs); in wpas_p2p_group_delete()
1062 wpa_s->p2p_group_common_freqs = NULL; in wpas_p2p_group_delete()
1063 wpa_s->p2p_group_common_freqs_num = 0; in wpas_p2p_group_delete()
1064 wpa_s->p2p_go_do_acs = 0; in wpas_p2p_group_delete()
1065 wpa_s->p2p_go_allow_dfs = 0; in wpas_p2p_group_delete()
1067 wpa_s->waiting_presence_resp = 0; in wpas_p2p_group_delete()
1070 if (ssid && (ssid->p2p_group || in wpas_p2p_group_delete()
1071 ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION || in wpas_p2p_group_delete()
1072 (ssid->key_mgmt & WPA_KEY_MGMT_WPS))) { in wpas_p2p_group_delete()
1073 int id = ssid->id; in wpas_p2p_group_delete()
1074 if (ssid == wpa_s->current_ssid) { in wpas_p2p_group_delete()
1075 wpa_sm_set_config(wpa_s->wpa, NULL); in wpas_p2p_group_delete()
1076 eapol_sm_notify_config(wpa_s->eapol, NULL, NULL); in wpas_p2p_group_delete()
1077 wpa_s->current_ssid = NULL; in wpas_p2p_group_delete()
1081 * exposed out as they might/will confuse certain non-P2P aware in wpas_p2p_group_delete()
1089 wpa_config_remove_network(wpa_s->conf, id); in wpas_p2p_group_delete()
1096 if (wpa_s->ap_iface) in wpas_p2p_group_delete()
1101 os_memset(wpa_s->go_dev_addr, 0, ETH_ALEN); in wpas_p2p_group_delete()
1103 wpa_s->p2p_go_no_pri_sec_switch = 0; in wpas_p2p_group_delete()
1119 if (wpa_s->go_params) in wpas_p2p_persistent_group()
1120 bssid = wpa_s->go_params->peer_interface_addr; in wpas_p2p_persistent_group()
1122 bssid = wpa_s->bssid; in wpas_p2p_persistent_group()
1125 if (bss == NULL && wpa_s->go_params && in wpas_p2p_persistent_group()
1126 !is_zero_ether_addr(wpa_s->go_params->peer_device_addr)) in wpas_p2p_persistent_group()
1128 wpa_s, wpa_s->go_params->peer_device_addr); in wpas_p2p_persistent_group()
1131 if (p2p_get_interface_addr(wpa_s->global->p2p, bssid, in wpas_p2p_persistent_group()
1137 "group is persistent - BSS " MACSTR " not found", in wpas_p2p_persistent_group()
1148 "group is persistent - BSS " MACSTR in wpas_p2p_persistent_group()
1151 wpa_bss_ie_ptr(bss), bss->ie_len); in wpas_p2p_persistent_group()
1153 wpa_bss_ie_ptr(bss) + bss->ie_len, in wpas_p2p_persistent_group()
1154 bss->beacon_ie_len); in wpas_p2p_persistent_group()
1187 for (s = wpa_s->conf->ssid; s; s = s->next) { in wpas_p2p_store_persistent_group()
1188 if (s->disabled == 2 && in wpas_p2p_store_persistent_group()
1189 ether_addr_equal(go_dev_addr, s->bssid) && in wpas_p2p_store_persistent_group()
1190 s->ssid_len == ssid->ssid_len && in wpas_p2p_store_persistent_group()
1191 os_memcmp(ssid->ssid, s->ssid, ssid->ssid_len) == 0) in wpas_p2p_store_persistent_group()
1198 if (ssid->passphrase && !s->passphrase) in wpas_p2p_store_persistent_group()
1200 else if (ssid->passphrase && s->passphrase && in wpas_p2p_store_persistent_group()
1201 os_strcmp(ssid->passphrase, s->passphrase) != 0) in wpas_p2p_store_persistent_group()
1207 s = wpa_config_add_network(wpa_s->conf); in wpas_p2p_store_persistent_group()
1209 return -1; in wpas_p2p_store_persistent_group()
1217 s->p2p_group = 1; in wpas_p2p_store_persistent_group()
1218 s->p2p_persistent_group = 1; in wpas_p2p_store_persistent_group()
1223 s->p2p_group = 1; in wpas_p2p_store_persistent_group()
1224 s->p2p_persistent_group = 1; in wpas_p2p_store_persistent_group()
1225 s->disabled = 2; in wpas_p2p_store_persistent_group()
1226 s->bssid_set = 1; in wpas_p2p_store_persistent_group()
1227 os_memcpy(s->bssid, go_dev_addr, ETH_ALEN); in wpas_p2p_store_persistent_group()
1228 s->mode = ssid->mode; in wpas_p2p_store_persistent_group()
1229 s->auth_alg = WPA_AUTH_ALG_OPEN; in wpas_p2p_store_persistent_group()
1230 s->key_mgmt = WPA_KEY_MGMT_PSK; in wpas_p2p_store_persistent_group()
1231 s->proto = WPA_PROTO_RSN; in wpas_p2p_store_persistent_group()
1232 s->pbss = ssid->pbss; in wpas_p2p_store_persistent_group()
1233 s->pairwise_cipher = ssid->pbss ? WPA_CIPHER_GCMP : WPA_CIPHER_CCMP; in wpas_p2p_store_persistent_group()
1234 s->export_keys = 1; in wpas_p2p_store_persistent_group()
1235 if (ssid->passphrase) { in wpas_p2p_store_persistent_group()
1236 os_free(s->passphrase); in wpas_p2p_store_persistent_group()
1237 s->passphrase = os_strdup(ssid->passphrase); in wpas_p2p_store_persistent_group()
1239 if (ssid->psk_set) { in wpas_p2p_store_persistent_group()
1240 s->psk_set = 1; in wpas_p2p_store_persistent_group()
1241 os_memcpy(s->psk, ssid->psk, 32); in wpas_p2p_store_persistent_group()
1243 if (s->passphrase && !s->psk_set) in wpas_p2p_store_persistent_group()
1245 if (s->ssid == NULL || s->ssid_len < ssid->ssid_len) { in wpas_p2p_store_persistent_group()
1246 os_free(s->ssid); in wpas_p2p_store_persistent_group()
1247 s->ssid = os_malloc(ssid->ssid_len); in wpas_p2p_store_persistent_group()
1249 if (s->ssid) { in wpas_p2p_store_persistent_group()
1250 s->ssid_len = ssid->ssid_len; in wpas_p2p_store_persistent_group()
1251 os_memcpy(s->ssid, ssid->ssid, s->ssid_len); in wpas_p2p_store_persistent_group()
1253 if (ssid->mode == WPAS_MODE_P2P_GO && wpa_s->global->add_psk) { in wpas_p2p_store_persistent_group()
1254 dl_list_add(&s->psk_list, &wpa_s->global->add_psk->list); in wpas_p2p_store_persistent_group()
1255 wpa_s->global->add_psk = NULL; in wpas_p2p_store_persistent_group()
1259 if (changed && wpa_s->conf->update_config && in wpas_p2p_store_persistent_group()
1260 wpa_config_write(wpa_s->confname, wpa_s->conf)) { in wpas_p2p_store_persistent_group()
1264 return s->id; in wpas_p2p_store_persistent_group()
1275 struct wpa_supplicant *p2p_wpa_s = wpa_s->global->p2p_init_wpa_s; in wpas_p2p_add_persistent_group_client()
1277 ssid = wpa_s->current_ssid; in wpas_p2p_add_persistent_group_client()
1278 if (ssid == NULL || ssid->mode != WPAS_MODE_P2P_GO || in wpas_p2p_add_persistent_group_client()
1279 !ssid->p2p_persistent_group) in wpas_p2p_add_persistent_group_client()
1282 for (s = p2p_wpa_s->conf->ssid; s; s = s->next) { in wpas_p2p_add_persistent_group_client()
1283 if (s->disabled != 2 || s->mode != WPAS_MODE_P2P_GO) in wpas_p2p_add_persistent_group_client()
1286 if (s->ssid_len == ssid->ssid_len && in wpas_p2p_add_persistent_group_client()
1287 os_memcmp(s->ssid, ssid->ssid, s->ssid_len) == 0) in wpas_p2p_add_persistent_group_client()
1294 for (i = 0; s->p2p_client_list && i < s->num_p2p_clients; i++) { in wpas_p2p_add_persistent_group_client()
1295 if (!ether_addr_equal(s->p2p_client_list + i * 2 * ETH_ALEN, in wpas_p2p_add_persistent_group_client()
1299 if (i == s->num_p2p_clients - 1) in wpas_p2p_add_persistent_group_client()
1303 os_memmove(s->p2p_client_list + i * 2 * ETH_ALEN, in wpas_p2p_add_persistent_group_client()
1304 s->p2p_client_list + (i + 1) * 2 * ETH_ALEN, in wpas_p2p_add_persistent_group_client()
1305 (s->num_p2p_clients - i - 1) * 2 * ETH_ALEN); in wpas_p2p_add_persistent_group_client()
1306 os_memcpy(s->p2p_client_list + in wpas_p2p_add_persistent_group_client()
1307 (s->num_p2p_clients - 1) * 2 * ETH_ALEN, addr, in wpas_p2p_add_persistent_group_client()
1309 os_memset(s->p2p_client_list + in wpas_p2p_add_persistent_group_client()
1310 (s->num_p2p_clients - 1) * 2 * ETH_ALEN + ETH_ALEN, in wpas_p2p_add_persistent_group_client()
1316 if (!found && s->num_p2p_clients < P2P_MAX_STORED_CLIENTS) { in wpas_p2p_add_persistent_group_client()
1317 n = os_realloc_array(s->p2p_client_list, in wpas_p2p_add_persistent_group_client()
1318 s->num_p2p_clients + 1, 2 * ETH_ALEN); in wpas_p2p_add_persistent_group_client()
1321 os_memcpy(n + s->num_p2p_clients * 2 * ETH_ALEN, addr, in wpas_p2p_add_persistent_group_client()
1323 os_memset(n + s->num_p2p_clients * 2 * ETH_ALEN + ETH_ALEN, in wpas_p2p_add_persistent_group_client()
1325 s->p2p_client_list = n; in wpas_p2p_add_persistent_group_client()
1326 s->num_p2p_clients++; in wpas_p2p_add_persistent_group_client()
1327 } else if (!found && s->p2p_client_list) { in wpas_p2p_add_persistent_group_client()
1328 /* Not enough room for an additional entry - drop the oldest in wpas_p2p_add_persistent_group_client()
1330 os_memmove(s->p2p_client_list, in wpas_p2p_add_persistent_group_client()
1331 s->p2p_client_list + 2 * ETH_ALEN, in wpas_p2p_add_persistent_group_client()
1332 (s->num_p2p_clients - 1) * 2 * ETH_ALEN); in wpas_p2p_add_persistent_group_client()
1333 os_memcpy(s->p2p_client_list + in wpas_p2p_add_persistent_group_client()
1334 (s->num_p2p_clients - 1) * 2 * ETH_ALEN, in wpas_p2p_add_persistent_group_client()
1336 os_memset(s->p2p_client_list + in wpas_p2p_add_persistent_group_client()
1337 (s->num_p2p_clients - 1) * 2 * ETH_ALEN + ETH_ALEN, in wpas_p2p_add_persistent_group_client()
1341 if (p2p_wpa_s->conf->update_config && in wpas_p2p_add_persistent_group_client()
1342 wpa_config_write(p2p_wpa_s->confname, p2p_wpa_s->conf)) in wpas_p2p_add_persistent_group_client()
1348 int go, struct wpa_ssid *ssid, int freq, in wpas_p2p_group_started() argument
1362 ssid_txt = wpa_ssid_txt(ssid->ssid, ssid->ssid_len); in wpas_p2p_group_started()
1373 wpa_msg_global_ctrl(wpa_s->p2pdev, MSG_INFO, in wpas_p2p_group_started()
1375 "%s %s ssid=\"%s\" freq=%d%s%s%s%s%s go_dev_addr=" in wpas_p2p_group_started()
1377 wpa_s->ifname, go ? "GO" : "client", ssid_txt, freq, in wpas_p2p_group_started()
1385 "%s %s ssid=\"%s\" freq=%d go_dev_addr=" MACSTR "%s%s", in wpas_p2p_group_started()
1386 wpa_s->ifname, go ? "GO" : "client", ssid_txt, freq, in wpas_p2p_group_started()
1405 if (wpa_s->global->p2p_group_formation) in wpas_group_formation_completed()
1406 wpa_s = wpa_s->global->p2p_group_formation; in wpas_group_formation_completed()
1407 if (wpa_s->p2p_go_group_formation_completed) { in wpas_group_formation_completed()
1408 wpa_s->global->p2p_group_formation = NULL; in wpas_group_formation_completed()
1409 wpa_s->p2p_in_provisioning = 0; in wpas_group_formation_completed()
1410 } else if (wpa_s->p2p_in_provisioning && !success) { in wpas_group_formation_completed()
1413 wpa_s->p2p_in_provisioning = 0; in wpas_group_formation_completed()
1415 wpa_s->p2p_in_invitation = 0; in wpas_group_formation_completed()
1416 wpa_s->p2p_retry_limit = 0; in wpas_group_formation_completed()
1417 wpa_s->group_formation_reported = 1; in wpas_group_formation_completed()
1420 wpa_msg_global(wpa_s->p2pdev, MSG_INFO, in wpas_group_formation_completed()
1430 wpa_msg_global(wpa_s->p2pdev, MSG_INFO, in wpas_group_formation_completed()
1433 ssid = wpa_s->current_ssid; in wpas_group_formation_completed()
1434 if (ssid && ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION) { in wpas_group_formation_completed()
1435 ssid->mode = WPAS_MODE_P2P_GO; in wpas_group_formation_completed()
1436 p2p_group_notif_formation_done(wpa_s->p2p_group); in wpas_group_formation_completed()
1442 client = ssid->mode == WPAS_MODE_INFRA; in wpas_group_formation_completed()
1443 if (ssid->mode == WPAS_MODE_P2P_GO) { in wpas_group_formation_completed()
1444 persistent = ssid->p2p_persistent_group; in wpas_group_formation_completed()
1445 os_memcpy(go_dev_addr, wpa_s->global->p2p_dev_addr, in wpas_group_formation_completed()
1450 ssid->ssid, in wpas_group_formation_completed()
1451 ssid->ssid_len); in wpas_group_formation_completed()
1453 client = wpa_s->p2p_group_interface == in wpas_group_formation_completed()
1458 wpa_s->show_group_started = 0; in wpas_group_formation_completed()
1461 * Indicate event only after successfully completed 4-way in wpas_group_formation_completed()
1465 wpa_s->show_group_started = 1; in wpas_group_formation_completed()
1468 ssid ? ssid->frequency : 0, in wpas_group_formation_completed()
1469 ssid && ssid->passphrase == NULL && in wpas_group_formation_completed()
1470 ssid->psk_set ? ssid->psk : NULL, in wpas_group_formation_completed()
1471 ssid ? ssid->passphrase : NULL, in wpas_group_formation_completed()
1478 wpas_p2p_store_persistent_group(wpa_s->p2pdev, in wpas_group_formation_completed()
1481 os_free(wpa_s->global->add_psk); in wpas_group_formation_completed()
1482 wpa_s->global->add_psk = NULL; in wpas_group_formation_completed()
1487 os_get_reltime(&wpa_s->global->p2p_go_wait_client); in wpas_group_formation_completed()
1493 unsigned int freq; member
1505 struct send_action_work *awork = wpa_s->p2p_send_action_work->ctx; in wpas_p2p_free_send_action_work()
1508 "P2P: Free Action frame radio work @%p (freq=%u dst=" in wpas_p2p_free_send_action_work()
1510 wpa_s->p2p_send_action_work, awork->freq, in wpas_p2p_free_send_action_work()
1511 MAC2STR(awork->dst), MAC2STR(awork->src), in wpas_p2p_free_send_action_work()
1512 MAC2STR(awork->bssid), awork->wait_time); in wpas_p2p_free_send_action_work()
1514 awork->buf, awork->len); in wpas_p2p_free_send_action_work()
1516 wpa_s->p2p_send_action_work->ctx = NULL; in wpas_p2p_free_send_action_work()
1517 radio_work_done(wpa_s->p2p_send_action_work); in wpas_p2p_free_send_action_work()
1518 wpa_s->p2p_send_action_work = NULL; in wpas_p2p_free_send_action_work()
1527 if (!wpa_s->p2p_send_action_work) in wpas_p2p_send_action_work_timeout()
1537 if (wpa_s->p2p_send_action_work) { in wpas_p2p_action_tx_clear()
1540 awork = wpa_s->p2p_send_action_work->ctx; in wpas_p2p_action_tx_clear()
1543 wpa_s->p2p_send_action_work, awork->wait_time); in wpas_p2p_action_tx_clear()
1544 if (awork->wait_time == 0) { in wpas_p2p_action_tx_clear()
1549 * places in the P2P code is still using non-zero wait in wpas_p2p_action_tx_clear()
1556 0, awork->wait_time * 1000, in wpas_p2p_action_tx_clear()
1565 unsigned int freq, in wpas_p2p_send_action_tx_status() argument
1576 if (wpa_s->global->p2p == NULL || wpa_s->global->p2p_disabled) in wpas_p2p_send_action_tx_status()
1579 switch (result) { in wpas_p2p_send_action_tx_status()
1591 p2p_send_action_cb(wpa_s->global->p2p, freq, dst, src, bssid, res); in wpas_p2p_send_action_tx_status()
1594 wpa_s->pending_pd_before_join && in wpas_p2p_send_action_tx_status()
1595 (ether_addr_equal(dst, wpa_s->pending_join_dev_addr) || in wpas_p2p_send_action_tx_status()
1596 ether_addr_equal(dst, wpa_s->pending_join_iface_addr)) && in wpas_p2p_send_action_tx_status()
1597 wpa_s->p2p_fallback_to_go_neg) { in wpas_p2p_send_action_tx_status()
1598 wpa_s->pending_pd_before_join = 0; in wpas_p2p_send_action_tx_status()
1600 "during p2p_connect-auto"); in wpas_p2p_send_action_tx_status()
1601 wpa_msg_global(wpa_s->p2pdev, MSG_INFO, in wpas_p2p_send_action_tx_status()
1603 "reason=no-ACK-to-PD-Req"); in wpas_p2p_send_action_tx_status()
1612 struct wpa_supplicant *wpa_s = work->wpa_s; in wpas_send_action_cb()
1613 struct send_action_work *awork = work->ctx; in wpas_send_action_cb()
1616 if (work->started) { in wpas_send_action_cb()
1619 wpa_s->p2p_send_action_work = NULL; in wpas_send_action_cb()
1626 if (offchannel_send_action(wpa_s, awork->freq, awork->dst, awork->src, in wpas_send_action_cb()
1627 awork->bssid, awork->buf, awork->len, in wpas_send_action_cb()
1628 awork->wait_time, in wpas_send_action_cb()
1634 wpa_s->p2p_send_action_work = work; in wpas_send_action_cb()
1639 unsigned int freq, const u8 *dst, in wpas_send_action_work() argument
1645 if (radio_work_pending(wpa_s, "p2p-send-action")) { in wpas_send_action_work()
1646 …wpa_printf(MSG_DEBUG, "P2P: Cannot schedule new p2p-send-action work since one is already pending"… in wpas_send_action_work()
1647 return -1; in wpas_send_action_work()
1652 return -1; in wpas_send_action_work()
1654 awork->freq = freq; in wpas_send_action_work()
1655 os_memcpy(awork->dst, dst, ETH_ALEN); in wpas_send_action_work()
1656 os_memcpy(awork->src, src, ETH_ALEN); in wpas_send_action_work()
1657 os_memcpy(awork->bssid, bssid, ETH_ALEN); in wpas_send_action_work()
1658 awork->len = len; in wpas_send_action_work()
1659 awork->wait_time = wait_time; in wpas_send_action_work()
1660 os_memcpy(awork->buf, buf, len); in wpas_send_action_work()
1662 if (radio_add_work(wpa_s, freq, "p2p-send-action", 1, in wpas_send_action_work()
1665 return -1; in wpas_send_action_work()
1672 static int wpas_send_action(void *ctx, unsigned int freq, const u8 *dst, in wpas_send_action() argument
1677 int listen_freq = -1, send_freq = -1; in wpas_send_action()
1681 if (wpa_s->p2p_listen_work) in wpas_send_action()
1682 listen_freq = wpa_s->p2p_listen_work->freq; in wpas_send_action()
1683 if (wpa_s->p2p_send_action_work) in wpas_send_action()
1684 send_freq = wpa_s->p2p_send_action_work->freq; in wpas_send_action()
1685 if (listen_freq != (int) freq && send_freq != (int) freq) { in wpas_send_action()
1688 …SG_DEBUG, "P2P: Schedule new radio work for Action frame TX (listen_freq=%d send_freq=%d freq=%u)", in wpas_send_action()
1689 listen_freq, send_freq, freq); in wpas_send_action()
1690 res = wpas_send_action_work(wpa_s, freq, dst, src, bssid, buf, in wpas_send_action()
1698 return offchannel_send_action(wpa_s, freq, dst, src, bssid, buf, len, in wpas_send_action()
1708 if (wpa_s->p2p_send_action_work) { in wpas_send_action_done()
1711 os_free(wpa_s->p2p_send_action_work->ctx); in wpas_send_action_done()
1712 radio_work_done(wpa_s->p2p_send_action_work); in wpas_send_action_done()
1713 wpa_s->p2p_send_action_work = NULL; in wpas_send_action_done()
1723 if (wpa_s->go_params == NULL) { in wpas_copy_go_neg_results()
1724 wpa_s->go_params = os_malloc(sizeof(*params)); in wpas_copy_go_neg_results()
1725 if (wpa_s->go_params == NULL) in wpas_copy_go_neg_results()
1726 return -1; in wpas_copy_go_neg_results()
1728 os_memcpy(wpa_s->go_params, params, sizeof(*params)); in wpas_copy_go_neg_results()
1736 wpa_s->group_formation_reported = 0; in wpas_start_wps_enrollee()
1739 MAC2STR(res->peer_interface_addr), in wpas_start_wps_enrollee()
1740 MAC2STR(res->peer_device_addr), res->wps_method); in wpas_start_wps_enrollee()
1742 res->ssid, res->ssid_len); in wpas_start_wps_enrollee()
1745 if (res->wps_method == WPS_PBC) { in wpas_start_wps_enrollee()
1746 wpas_wps_start_pbc(wpa_s, res->peer_interface_addr, 1, 0); in wpas_start_wps_enrollee()
1748 } else if (res->wps_method == WPS_NFC) { in wpas_start_wps_enrollee()
1749 wpas_wps_start_nfc(wpa_s, res->peer_device_addr, in wpas_start_wps_enrollee()
1750 res->peer_interface_addr, in wpas_start_wps_enrollee()
1751 wpa_s->p2pdev->p2p_oob_dev_pw, in wpas_start_wps_enrollee()
1752 wpa_s->p2pdev->p2p_oob_dev_pw_id, 1, in wpas_start_wps_enrollee()
1753 wpa_s->p2pdev->p2p_oob_dev_pw_id == in wpas_start_wps_enrollee()
1755 wpa_s->p2pdev->p2p_peer_oob_pubkey_hash : in wpas_start_wps_enrollee()
1761 if (wpa_s->p2p_wps_method == WPS_P2PS) in wpas_start_wps_enrollee()
1763 if (wpa_s->p2p_wps_method == WPS_PIN_KEYPAD) in wpas_start_wps_enrollee()
1765 wpas_wps_start_pin(wpa_s, res->peer_interface_addr, in wpas_start_wps_enrollee()
1766 wpa_s->p2p_pin, 1, dev_pw_id); in wpas_start_wps_enrollee()
1778 if (!wpa_s->ap_iface) in wpas_p2p_add_psk_list()
1781 persistent = wpas_p2p_get_persistent(wpa_s->p2pdev, NULL, ssid->ssid, in wpas_p2p_add_psk_list()
1782 ssid->ssid_len); in wpas_p2p_add_psk_list()
1786 hapd = wpa_s->ap_iface->bss[0]; in wpas_p2p_add_psk_list()
1788 dl_list_for_each(psk, &persistent->psk_list, struct psk_list_entry, in wpas_p2p_add_psk_list()
1794 MAC2STR(psk->addr), psk->p2p); in wpas_p2p_add_psk_list()
1798 os_memcpy(hpsk->psk, psk->psk, PMK_LEN); in wpas_p2p_add_psk_list()
1799 if (psk->p2p) in wpas_p2p_add_psk_list()
1800 os_memcpy(hpsk->p2p_dev_addr, psk->addr, ETH_ALEN); in wpas_p2p_add_psk_list()
1802 os_memcpy(hpsk->addr, psk->addr, ETH_ALEN); in wpas_p2p_add_psk_list()
1803 hpsk->next = hapd->conf->ssid.wpa_psk; in wpas_p2p_add_psk_list()
1804 hapd->conf->ssid.wpa_psk = hpsk; in wpas_p2p_add_psk_list()
1818 for (i = 0; i < wpa_s->p2p_group_common_freqs_num; i++) { in p2p_go_dump_common_freqs()
1819 res = os_snprintf(pos, end - pos, " %d", in p2p_go_dump_common_freqs()
1820 wpa_s->p2p_group_common_freqs[i]); in p2p_go_dump_common_freqs()
1821 if (os_snprintf_error(end - pos, res)) in p2p_go_dump_common_freqs()
1834 unsigned int i, len = int_array_len(wpa_s->go_params->freq_list); in p2p_go_save_group_common_freqs()
1836 wpa_s->p2p_group_common_freqs_num = 0; in p2p_go_save_group_common_freqs()
1837 os_free(wpa_s->p2p_group_common_freqs); in p2p_go_save_group_common_freqs()
1838 wpa_s->p2p_group_common_freqs = os_calloc(len, sizeof(int)); in p2p_go_save_group_common_freqs()
1839 if (!wpa_s->p2p_group_common_freqs) in p2p_go_save_group_common_freqs()
1843 if (!wpa_s->go_params->freq_list[i]) in p2p_go_save_group_common_freqs()
1845 wpa_s->p2p_group_common_freqs[i] = in p2p_go_save_group_common_freqs()
1846 wpa_s->go_params->freq_list[i]; in p2p_go_save_group_common_freqs()
1848 wpa_s->p2p_group_common_freqs_num = i; in p2p_go_save_group_common_freqs()
1855 if (wpa_s->p2pdev->conf->update_config && in p2p_config_write()
1856 wpa_config_write(wpa_s->p2pdev->confname, wpa_s->p2pdev->conf)) in p2p_config_write()
1868 wpa_s->ap_configured_cb = NULL; in p2p_go_configured()
1869 wpa_s->ap_configured_cb_ctx = NULL; in p2p_go_configured()
1870 wpa_s->ap_configured_cb_data = NULL; in p2p_go_configured()
1871 if (!wpa_s->go_params) { in p2p_go_configured()
1873 "P2P: p2p_go_configured() called with wpa_s->go_params == NULL"); in p2p_go_configured()
1880 ssid = wpa_s->current_ssid; in p2p_go_configured()
1881 if (ssid && ssid->mode == WPAS_MODE_P2P_GO) { in p2p_go_configured()
1883 if (wpa_s->global->p2p_group_formation == wpa_s) in p2p_go_configured()
1884 wpa_s->global->p2p_group_formation = NULL; in p2p_go_configured()
1885 wpas_p2p_group_started(wpa_s, 1, ssid, ssid->frequency, in p2p_go_configured()
1886 params->passphrase[0] == '\0' ? in p2p_go_configured()
1887 params->psk : NULL, in p2p_go_configured()
1888 params->passphrase, in p2p_go_configured()
1889 wpa_s->global->p2p_dev_addr, in p2p_go_configured()
1890 params->persistent_group, ""); in p2p_go_configured()
1891 wpa_s->group_formation_reported = 1; in p2p_go_configured()
1893 if (wpa_s->p2pdev->p2ps_method_config_any) { in p2p_go_configured()
1894 if (is_zero_ether_addr(wpa_s->p2pdev->p2ps_join_addr)) { in p2p_go_configured()
1903 MAC2STR(wpa_s->p2pdev->p2ps_join_addr)); in p2p_go_configured()
1905 wpa_s, wpa_s->p2pdev->p2ps_join_addr, in p2p_go_configured()
1908 wpa_s->p2pdev->p2ps_method_config_any = 0; in p2p_go_configured()
1911 os_get_reltime(&wpa_s->global->p2p_go_wait_client); in p2p_go_configured()
1912 if (params->persistent_group) { in p2p_go_configured()
1914 wpa_s->p2pdev, ssid, in p2p_go_configured()
1915 wpa_s->global->p2p_dev_addr); in p2p_go_configured()
1920 params->persistent_group, 0, in p2p_go_configured()
1925 if (wpa_s->p2p_first_connection_timeout) { in p2p_go_configured()
1928 wpa_s->p2p_first_connection_timeout); in p2p_go_configured()
1929 wpa_s->p2p_go_group_formation_completed = 0; in p2p_go_configured()
1930 wpa_s->global->p2p_group_formation = wpa_s; in p2p_go_configured()
1932 wpa_s->p2pdev, NULL); in p2p_go_configured()
1934 wpa_s->p2p_first_connection_timeout, 0, in p2p_go_configured()
1936 wpa_s->p2pdev, NULL); in p2p_go_configured()
1944 params->peer_interface_addr)) { in p2p_go_configured()
1949 if (params->wps_method == WPS_PBC) { in p2p_go_configured()
1950 wpa_supplicant_ap_wps_pbc(wpa_s, params->peer_interface_addr, in p2p_go_configured()
1951 params->peer_device_addr); in p2p_go_configured()
1953 } else if (params->wps_method == WPS_NFC) { in p2p_go_configured()
1954 if (wpa_s->p2pdev->p2p_oob_dev_pw_id != in p2p_go_configured()
1956 !wpa_s->p2pdev->p2p_oob_dev_pw) { in p2p_go_configured()
1961 wpa_s, wpa_s->p2pdev->p2p_oob_dev_pw_id, in p2p_go_configured()
1962 wpa_s->p2pdev->p2p_oob_dev_pw, in p2p_go_configured()
1963 wpa_s->p2pdev->p2p_peer_oob_pk_hash_known ? in p2p_go_configured()
1964 wpa_s->p2pdev->p2p_peer_oob_pubkey_hash : NULL); in p2p_go_configured()
1966 } else if (wpa_s->p2p_pin[0]) in p2p_go_configured()
1967 wpa_supplicant_ap_wps_pin(wpa_s, params->peer_interface_addr, in p2p_go_configured()
1968 wpa_s->p2p_pin, NULL, 0, 0); in p2p_go_configured()
1969 os_free(wpa_s->go_params); in p2p_go_configured()
1970 wpa_s->go_params = NULL; in p2p_go_configured()
1975 * wpas_p2p_freq_to_edmg_channel - Convert frequency into EDMG channel
1976 * @freq: Frequency (MHz) to convert
1979 * Returns: 0 on success, -1 on failure
1985 unsigned int freq, in wpas_p2p_freq_to_edmg_channel() argument
1997 if (!wpa_s->hw.modes) in wpas_p2p_freq_to_edmg_channel()
1998 return -1; in wpas_p2p_freq_to_edmg_channel()
2000 hwmode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes, in wpas_p2p_freq_to_edmg_channel()
2005 return -1; in wpas_p2p_freq_to_edmg_channel()
2010 if (ieee80211_chaninfo_to_channel(freq, chanwidth[i], 0, in wpas_p2p_freq_to_edmg_channel()
2017 ieee802_edmg_is_allowed(hwmode->edmg, edmg)) { in wpas_p2p_freq_to_edmg_channel()
2019 "Freq %u to EDMG channel %u at opclass %u", in wpas_p2p_freq_to_edmg_channel()
2020 freq, *op_edmg_channel, *op_class); in wpas_p2p_freq_to_edmg_channel()
2025 return -1; in wpas_p2p_freq_to_edmg_channel()
2033 int freq; in wpas_p2p_try_edmg_channel() local
2036 freq = (!params->freq) ? 58320 + 1 * 2160 : params->freq; in wpas_p2p_try_edmg_channel()
2038 if (wpas_p2p_freq_to_edmg_channel(wpa_s, freq, &op_class, in wpas_p2p_try_edmg_channel()
2041 "Freq %d will be used to set an EDMG connection (channel=%u opclass=%u)", in wpas_p2p_try_edmg_channel()
2042 freq, op_channel, op_class); in wpas_p2p_try_edmg_channel()
2043 params->freq = freq; in wpas_p2p_try_edmg_channel()
2047 return -1; in wpas_p2p_try_edmg_channel()
2064 ssid = wpa_config_add_network(wpa_s->conf); in wpas_start_wps_go()
2070 wpa_s->show_group_started = 0; in wpas_start_wps_go()
2071 wpa_s->p2p_go_group_formation_completed = 0; in wpas_start_wps_go()
2072 wpa_s->group_formation_reported = 0; in wpas_start_wps_go()
2073 os_memset(wpa_s->go_dev_addr, 0, ETH_ALEN); in wpas_start_wps_go()
2076 ssid->temporary = 1; in wpas_start_wps_go()
2077 ssid->p2p_group = 1; in wpas_start_wps_go()
2078 ssid->p2p_persistent_group = !!params->persistent_group; in wpas_start_wps_go()
2079 ssid->mode = group_formation ? WPAS_MODE_P2P_GROUP_FORMATION : in wpas_start_wps_go()
2081 ssid->frequency = params->freq; in wpas_start_wps_go()
2082 ssid->ht40 = params->ht40; in wpas_start_wps_go()
2083 ssid->vht = params->vht; in wpas_start_wps_go()
2084 ssid->max_oper_chwidth = params->max_oper_chwidth; in wpas_start_wps_go()
2085 ssid->vht_center_freq2 = params->vht_center_freq2; in wpas_start_wps_go()
2086 ssid->he = params->he; in wpas_start_wps_go()
2087 if (params->edmg) { in wpas_start_wps_go()
2090 if (!wpas_p2p_freq_to_edmg_channel(wpa_s, params->freq, in wpas_start_wps_go()
2092 ssid->edmg_channel = op_channel; in wpas_start_wps_go()
2093 ssid->enable_edmg = params->edmg; in wpas_start_wps_go()
2096 "P2P: Could not match EDMG channel, freq %d, for GO", in wpas_start_wps_go()
2097 params->freq); in wpas_start_wps_go()
2101 ssid->ssid = os_zalloc(params->ssid_len + 1); in wpas_start_wps_go()
2102 if (ssid->ssid) { in wpas_start_wps_go()
2103 os_memcpy(ssid->ssid, params->ssid, params->ssid_len); in wpas_start_wps_go()
2104 ssid->ssid_len = params->ssid_len; in wpas_start_wps_go()
2106 ssid->auth_alg = WPA_AUTH_ALG_OPEN; in wpas_start_wps_go()
2107 ssid->key_mgmt = WPA_KEY_MGMT_PSK; in wpas_start_wps_go()
2108 if (is_6ghz_freq(ssid->frequency) && in wpas_start_wps_go()
2109 is_p2p_6ghz_capable(wpa_s->global->p2p)) { in wpas_start_wps_go()
2110 ssid->auth_alg |= WPA_AUTH_ALG_SAE; in wpas_start_wps_go()
2111 ssid->key_mgmt = WPA_KEY_MGMT_SAE; in wpas_start_wps_go()
2112 ssid->ieee80211w = MGMT_FRAME_PROTECTION_REQUIRED; in wpas_start_wps_go()
2113 ssid->sae_pwe = SAE_PWE_HASH_TO_ELEMENT; in wpas_start_wps_go()
2116 p2p_set_6ghz_dev_capab(wpa_s->global->p2p, false); in wpas_start_wps_go()
2118 ssid->proto = WPA_PROTO_RSN; in wpas_start_wps_go()
2119 ssid->pairwise_cipher = WPA_CIPHER_CCMP; in wpas_start_wps_go()
2120 ssid->group_cipher = WPA_CIPHER_CCMP; in wpas_start_wps_go()
2121 if (params->freq > 56160) { in wpas_start_wps_go()
2126 ssid->pairwise_cipher = WPA_CIPHER_GCMP; in wpas_start_wps_go()
2127 ssid->group_cipher = WPA_CIPHER_GCMP; in wpas_start_wps_go()
2129 ssid->pbss = 1; in wpas_start_wps_go()
2131 if (os_strlen(params->passphrase) > 0) { in wpas_start_wps_go()
2132 ssid->passphrase = os_strdup(params->passphrase); in wpas_start_wps_go()
2133 if (ssid->passphrase == NULL) { in wpas_start_wps_go()
2136 wpa_config_remove_network(wpa_s->conf, ssid->id); in wpas_start_wps_go()
2140 ssid->passphrase = NULL; in wpas_start_wps_go()
2141 ssid->psk_set = params->psk_set; in wpas_start_wps_go()
2142 if (ssid->psk_set) in wpas_start_wps_go()
2143 os_memcpy(ssid->psk, params->psk, sizeof(ssid->psk)); in wpas_start_wps_go()
2144 else if (ssid->passphrase) in wpas_start_wps_go()
2146 ssid->ap_max_inactivity = wpa_s->p2pdev->conf->p2p_go_max_inactivity; in wpas_start_wps_go()
2148 wpa_s->ap_configured_cb = p2p_go_configured; in wpas_start_wps_go()
2149 wpa_s->ap_configured_cb_ctx = wpa_s; in wpas_start_wps_go()
2150 wpa_s->ap_configured_cb_data = wpa_s->go_params; in wpas_start_wps_go()
2151 wpa_s->scan_req = NORMAL_SCAN_REQ; in wpas_start_wps_go()
2152 wpa_s->connect_without_scan = ssid; in wpas_start_wps_go()
2153 wpa_s->reassociate = 1; in wpas_start_wps_go()
2154 wpa_s->disconnected = 0; in wpas_start_wps_go()
2167 d = dst->conf; in wpas_p2p_clone_config()
2168 s = src->conf; in wpas_p2p_clone_config()
2172 if (s->n && !d->n) \ in wpas_p2p_clone_config()
2173 d->n = os_strdup(s->n); \ in wpas_p2p_clone_config()
2184 os_memcpy(d->device_type, s->device_type, WPS_DEV_TYPE_LEN); in wpas_p2p_clone_config()
2185 os_memcpy(d->sec_device_type, s->sec_device_type, in wpas_p2p_clone_config()
2186 sizeof(d->sec_device_type)); in wpas_p2p_clone_config()
2187 d->num_sec_device_types = s->num_sec_device_types; in wpas_p2p_clone_config()
2189 d->p2p_group_idle = s->p2p_group_idle; in wpas_p2p_clone_config()
2190 d->p2p_go_freq_change_policy = s->p2p_go_freq_change_policy; in wpas_p2p_clone_config()
2191 d->p2p_intra_bss = s->p2p_intra_bss; in wpas_p2p_clone_config()
2192 d->persistent_reconnect = s->persistent_reconnect; in wpas_p2p_clone_config()
2193 d->max_num_sta = s->max_num_sta; in wpas_p2p_clone_config()
2194 d->pbc_in_m1 = s->pbc_in_m1; in wpas_p2p_clone_config()
2195 d->ignore_old_scan_res = s->ignore_old_scan_res; in wpas_p2p_clone_config()
2196 d->beacon_int = s->beacon_int; in wpas_p2p_clone_config()
2197 d->dtim_period = s->dtim_period; in wpas_p2p_clone_config()
2198 d->p2p_go_ctwindow = s->p2p_go_ctwindow; in wpas_p2p_clone_config()
2199 d->disassoc_low_ack = s->disassoc_low_ack; in wpas_p2p_clone_config()
2200 d->disable_scan_offload = s->disable_scan_offload; in wpas_p2p_clone_config()
2201 d->passive_scan = s->passive_scan; in wpas_p2p_clone_config()
2202 d->pmf = s->pmf; in wpas_p2p_clone_config()
2203 d->p2p_6ghz_disable = s->p2p_6ghz_disable; in wpas_p2p_clone_config()
2204 d->sae_pwe = s->sae_pwe; in wpas_p2p_clone_config()
2206 if (s->wps_nfc_dh_privkey && s->wps_nfc_dh_pubkey && in wpas_p2p_clone_config()
2207 !d->wps_nfc_pw_from_config) { in wpas_p2p_clone_config()
2208 wpabuf_free(d->wps_nfc_dh_privkey); in wpas_p2p_clone_config()
2209 wpabuf_free(d->wps_nfc_dh_pubkey); in wpas_p2p_clone_config()
2210 d->wps_nfc_dh_privkey = wpabuf_dup(s->wps_nfc_dh_privkey); in wpas_p2p_clone_config()
2211 d->wps_nfc_dh_pubkey = wpabuf_dup(s->wps_nfc_dh_pubkey); in wpas_p2p_clone_config()
2213 d->p2p_cli_probe = s->p2p_cli_probe; in wpas_p2p_clone_config()
2214 d->go_interworking = s->go_interworking; in wpas_p2p_clone_config()
2215 d->go_access_network_type = s->go_access_network_type; in wpas_p2p_clone_config()
2216 d->go_internet = s->go_internet; in wpas_p2p_clone_config()
2217 d->go_venue_group = s->go_venue_group; in wpas_p2p_clone_config()
2218 d->go_venue_type = s->go_venue_type; in wpas_p2p_clone_config()
2219 d->p2p_add_cli_chan = s->p2p_add_cli_chan; in wpas_p2p_clone_config()
2226 char *ifname_ptr = wpa_s->ifname; in wpas_p2p_get_group_ifname()
2228 if (os_strncmp(wpa_s->ifname, P2P_MGMT_DEVICE_PREFIX, in wpas_p2p_get_group_ifname()
2230 ifname_ptr = os_strrchr(wpa_s->ifname, '-') + 1; in wpas_p2p_get_group_ifname()
2233 os_snprintf(ifname, len, "p2p-%s-%d", ifname_ptr, wpa_s->p2p_group_idx); in wpas_p2p_get_group_ifname()
2235 os_strlen(wpa_s->ifname) < IFNAMSIZ) { in wpas_p2p_get_group_ifname()
2239 res = os_snprintf(ifname, len, "p2p-%d", wpa_s->p2p_group_idx); in wpas_p2p_get_group_ifname()
2241 ifname[len - 1] = '\0'; in wpas_p2p_get_group_ifname()
2251 if (wpa_s->pending_interface_name[0]) { in wpas_p2p_add_group_interface()
2253 "- skip creation of a new one"); in wpas_p2p_add_group_interface()
2254 if (is_zero_ether_addr(wpa_s->pending_interface_addr)) { in wpas_p2p_add_group_interface()
2257 wpa_s->pending_interface_name); in wpas_p2p_add_group_interface()
2258 return -1; in wpas_p2p_add_group_interface()
2268 wpa_s->p2p_group_idx++; in wpas_p2p_add_group_interface()
2270 wpa_s->pending_interface_type = type; in wpas_p2p_add_group_interface()
2272 wpa_s->pending_interface_addr, NULL) < 0) { in wpas_p2p_add_group_interface()
2275 return -1; in wpas_p2p_add_group_interface()
2278 if (wpa_s->conf->p2p_interface_random_mac_addr) { in wpas_p2p_add_group_interface()
2279 random_mac_addr(wpa_s->pending_interface_addr); in wpas_p2p_add_group_interface()
2282 MAC2STR(wpa_s->pending_interface_addr)); in wpas_p2p_add_group_interface()
2288 os_strlcpy(wpa_s->pending_interface_name, force_ifname, in wpas_p2p_add_group_interface()
2289 sizeof(wpa_s->pending_interface_name)); in wpas_p2p_add_group_interface()
2291 os_strlcpy(wpa_s->pending_interface_name, ifname, in wpas_p2p_add_group_interface()
2292 sizeof(wpa_s->pending_interface_name)); in wpas_p2p_add_group_interface()
2294 MACSTR, wpa_s->pending_interface_name, in wpas_p2p_add_group_interface()
2295 MAC2STR(wpa_s->pending_interface_addr)); in wpas_p2p_add_group_interface()
2304 if (!wpa_s->pending_interface_name[0] || in wpas_p2p_remove_pending_group_interface()
2305 is_zero_ether_addr(wpa_s->pending_interface_addr)) in wpas_p2p_remove_pending_group_interface()
2309 wpa_s->pending_interface_name); in wpas_p2p_remove_pending_group_interface()
2310 wpa_drv_if_remove(wpa_s, wpa_s->pending_interface_type, in wpas_p2p_remove_pending_group_interface()
2311 wpa_s->pending_interface_name); in wpas_p2p_remove_pending_group_interface()
2312 os_memset(wpa_s->pending_interface_addr, 0, ETH_ALEN); in wpas_p2p_remove_pending_group_interface()
2313 wpa_s->pending_interface_name[0] = '\0'; in wpas_p2p_remove_pending_group_interface()
2314 wpa_s->global->pending_group_iface_for_p2ps = 0; in wpas_p2p_remove_pending_group_interface()
2324 if (!wpa_s->pending_interface_name[0]) { in wpas_p2p_init_group_interface()
2339 iface.ifname = wpa_s->pending_interface_name; in wpas_p2p_init_group_interface()
2340 iface.driver = wpa_s->driver->name; in wpas_p2p_init_group_interface()
2341 if (wpa_s->conf->ctrl_interface == NULL && in wpas_p2p_init_group_interface()
2342 wpa_s->parent != wpa_s && in wpas_p2p_init_group_interface()
2343 wpa_s->p2p_mgmt && in wpas_p2p_init_group_interface()
2344 (wpa_s->drv_flags & WPA_DRIVER_FLAGS_DEDICATED_P2P_DEVICE)) in wpas_p2p_init_group_interface()
2345 iface.ctrl_interface = wpa_s->parent->conf->ctrl_interface; in wpas_p2p_init_group_interface()
2347 iface.ctrl_interface = wpa_s->conf->ctrl_interface; in wpas_p2p_init_group_interface()
2348 iface.driver_param = wpa_s->conf->driver_param; in wpas_p2p_init_group_interface()
2349 group_wpa_s = wpa_supplicant_add_iface(wpa_s->global, &iface, wpa_s); in wpas_p2p_init_group_interface()
2355 wpa_s->pending_interface_name[0] = '\0'; in wpas_p2p_init_group_interface()
2356 group_wpa_s->p2p_group_interface = go ? P2P_GROUP_INTERFACE_GO : in wpas_p2p_init_group_interface()
2358 wpa_s->global->p2p_group_formation = group_wpa_s; in wpas_p2p_init_group_interface()
2359 wpa_s->global->pending_group_iface_for_p2ps = 0; in wpas_p2p_init_group_interface()
2363 if (wpa_s->conf->p2p_interface_random_mac_addr) { in wpas_p2p_init_group_interface()
2365 wpa_s->pending_interface_addr) < 0) { in wpas_p2p_init_group_interface()
2368 wpa_supplicant_remove_iface(wpa_s->global, group_wpa_s, in wpas_p2p_init_group_interface()
2376 wpa_supplicant_remove_iface(wpa_s->global, group_wpa_s, in wpas_p2p_init_group_interface()
2383 MAC2STR(wpa_s->pending_interface_addr)); in wpas_p2p_init_group_interface()
2403 wpa_s->p2pdev, NULL); in wpas_p2p_group_formation_failed()
2404 if (wpa_s->global->p2p) in wpas_p2p_group_formation_failed()
2405 p2p_group_formation_failed(wpa_s->global->p2p); in wpas_p2p_group_formation_failed()
2414 wpa_s->p2pdev, NULL); in wpas_p2p_grpform_fail_after_wps()
2416 wpa_s->p2pdev, NULL); in wpas_p2p_grpform_fail_after_wps()
2417 wpa_s->global->p2p_fail_on_wps_complete = 0; in wpas_p2p_grpform_fail_after_wps()
2423 if (wpa_s->global->p2p_group_formation != wpa_s) in wpas_p2p_ap_setup_failed()
2427 wpa_s->p2pdev, NULL); in wpas_p2p_ap_setup_failed()
2429 wpa_s->p2pdev, NULL); in wpas_p2p_ap_setup_failed()
2435 if (!wpa_s->p2p_in_invitation || !wpa_s->p2p_retry_limit || in wpas_p2p_retry_limit_exceeded()
2436 wpa_s->p2p_in_invitation <= wpa_s->p2p_retry_limit) in wpas_p2p_retry_limit_exceeded()
2441 wpa_s->p2pdev, NULL); in wpas_p2p_retry_limit_exceeded()
2443 wpa_s->p2pdev, NULL); in wpas_p2p_retry_limit_exceeded()
2453 if (wpa_s->off_channel_freq || wpa_s->roc_waiting_drv_freq) { in wpas_go_neg_completed()
2455 wpa_s->off_channel_freq = 0; in wpas_go_neg_completed()
2456 wpa_s->roc_waiting_drv_freq = 0; in wpas_go_neg_completed()
2459 if (res->status) { in wpas_go_neg_completed()
2462 res->status); in wpas_go_neg_completed()
2468 if (!res->role_go) { in wpas_go_neg_completed()
2470 wpa_drv_set_prob_oper_freq(wpa_s, res->freq); in wpas_go_neg_completed()
2473 if (wpa_s->p2p_go_ht40) in wpas_go_neg_completed()
2474 res->ht40 = 1; in wpas_go_neg_completed()
2475 if (wpa_s->p2p_go_vht) in wpas_go_neg_completed()
2476 res->vht = 1; in wpas_go_neg_completed()
2477 if (wpa_s->p2p_go_he) in wpas_go_neg_completed()
2478 res->he = 1; in wpas_go_neg_completed()
2479 if (wpa_s->p2p_go_edmg) in wpas_go_neg_completed()
2480 res->edmg = 1; in wpas_go_neg_completed()
2481 res->max_oper_chwidth = wpa_s->p2p_go_max_oper_chwidth; in wpas_go_neg_completed()
2482 res->vht_center_freq2 = wpa_s->p2p_go_vht_center_freq2; in wpas_go_neg_completed()
2485 "freq=%d ht40=%d peer_dev=" MACSTR " peer_iface=" MACSTR in wpas_go_neg_completed()
2487 res->role_go ? "GO" : "client", res->freq, res->ht40, in wpas_go_neg_completed()
2488 MAC2STR(res->peer_device_addr), in wpas_go_neg_completed()
2489 MAC2STR(res->peer_interface_addr), in wpas_go_neg_completed()
2490 p2p_wps_method_text(res->wps_method)); in wpas_go_neg_completed()
2493 if (res->role_go && wpa_s->p2p_persistent_id >= 0) { in wpas_go_neg_completed()
2495 ssid = wpa_config_get_network(wpa_s->conf, in wpas_go_neg_completed()
2496 wpa_s->p2p_persistent_id); in wpas_go_neg_completed()
2497 if (ssid && ssid->disabled == 2 && in wpas_go_neg_completed()
2498 ssid->mode == WPAS_MODE_P2P_GO && ssid->passphrase) { in wpas_go_neg_completed()
2499 size_t len = os_strlen(ssid->passphrase); in wpas_go_neg_completed()
2502 os_memcpy(res->passphrase, ssid->passphrase, len); in wpas_go_neg_completed()
2503 res->passphrase[len] = '\0'; in wpas_go_neg_completed()
2507 if (wpa_s->create_p2p_iface) { in wpas_go_neg_completed()
2509 wpas_p2p_init_group_interface(wpa_s, res->role_go); in wpas_go_neg_completed()
2517 os_memset(wpa_s->pending_interface_addr, 0, ETH_ALEN); in wpas_go_neg_completed()
2518 wpa_s->pending_interface_name[0] = '\0'; in wpas_go_neg_completed()
2520 group_wpa_s = wpa_s->parent; in wpas_go_neg_completed()
2521 wpa_s->global->p2p_group_formation = group_wpa_s; in wpas_go_neg_completed()
2526 group_wpa_s->p2p_in_provisioning = 1; in wpas_go_neg_completed()
2527 group_wpa_s->p2pdev = wpa_s; in wpas_go_neg_completed()
2529 os_memcpy(group_wpa_s->p2p_pin, wpa_s->p2p_pin, in wpas_go_neg_completed()
2530 sizeof(group_wpa_s->p2p_pin)); in wpas_go_neg_completed()
2531 group_wpa_s->p2p_wps_method = wpa_s->p2p_wps_method; in wpas_go_neg_completed()
2533 if (res->role_go) { in wpas_go_neg_completed()
2536 os_get_reltime(&group_wpa_s->scan_min_time); in wpas_go_neg_completed()
2540 wpa_s->global->p2p_long_listen = 0; in wpas_go_neg_completed()
2544 eloop_register_timeout(15 + res->peer_config_timeout / 100, in wpas_go_neg_completed()
2545 (res->peer_config_timeout % 100) * 10000, in wpas_go_neg_completed()
2572 wfd_dev_info_hex = wifi_display_subelem_hex(info->wfd_subelems, in wpas_dev_found()
2576 if (info->p2ps_instance) { in wpas_dev_found()
2578 const u8 *buf = wpabuf_head(info->p2ps_instance); in wpas_dev_found()
2579 size_t len = wpabuf_len(info->p2ps_instance); in wpas_dev_found()
2593 if (str_len > len - 4 - 2 - 1) in wpas_dev_found()
2598 len -= str_len + sizeof(u32) + sizeof(u16) + sizeof(u8); in wpas_dev_found()
2609 MAC2STR(info->p2p_device_addr), in wpas_dev_found()
2611 info->pri_dev_type, in wpas_dev_found()
2613 info->device_name, methods, in wpas_dev_found()
2614 info->dev_capab, info->group_capab, in wpas_dev_found()
2616 info->vendor_elems ? in wpas_dev_found()
2626 MAC2STR(addr), MAC2STR(info->p2p_device_addr), in wpas_dev_found()
2627 wps_dev_type_bin2str(info->pri_dev_type, devtype, in wpas_dev_found()
2629 info->device_name, info->config_methods, in wpas_dev_found()
2630 info->dev_capab, info->group_capab, in wpas_dev_found()
2633 info->vendor_elems ? " vendor_elems=1" : "", in wpas_dev_found()
2640 wpas_notify_p2p_device_found(ctx, info->p2p_device_addr, new_device); in wpas_dev_found()
2659 if (wpa_s->p2p_scan_work && wpas_abort_ongoing_scan(wpa_s) < 0) in wpas_find_stopped()
2668 unsigned int freq; member
2678 wpabuf_free(lwork->probe_resp_ie); in wpas_p2p_listen_work_free()
2687 if (!wpa_s->p2p_listen_work) in wpas_p2p_listen_work_done()
2690 lwork = wpa_s->p2p_listen_work->ctx; in wpas_p2p_listen_work_done()
2692 radio_work_done(wpa_s->p2p_listen_work); in wpas_p2p_listen_work_done()
2693 wpa_s->p2p_listen_work = NULL; in wpas_p2p_listen_work_done()
2699 struct wpa_supplicant *wpa_s = work->wpa_s; in wpas_start_listen_cb()
2700 struct wpas_p2p_listen_work *lwork = work->ctx; in wpas_start_listen_cb()
2704 if (work->started) { in wpas_start_listen_cb()
2705 wpa_s->p2p_listen_work = NULL; in wpas_start_listen_cb()
2712 wpa_s->p2p_listen_work = work; in wpas_start_listen_cb()
2714 wpa_drv_set_ap_wps_ie(wpa_s, NULL, lwork->probe_resp_ie, NULL); in wpas_start_listen_cb()
2723 wpa_s->pending_listen_freq = lwork->freq; in wpas_start_listen_cb()
2724 wpa_s->pending_listen_duration = lwork->duration; in wpas_start_listen_cb()
2726 duration = lwork->duration; in wpas_start_listen_cb()
2728 if (wpa_s->extra_roc_dur) { in wpas_start_listen_cb()
2729 wpa_printf(MSG_DEBUG, "TESTING: Increase ROC duration %u -> %u", in wpas_start_listen_cb()
2730 duration, duration + wpa_s->extra_roc_dur); in wpas_start_listen_cb()
2731 duration += wpa_s->extra_roc_dur; in wpas_start_listen_cb()
2735 if (wpa_drv_remain_on_channel(wpa_s, lwork->freq, duration) < 0) { in wpas_start_listen_cb()
2738 "state", lwork->freq); in wpas_start_listen_cb()
2740 wpa_s->pending_listen_freq = 0; in wpas_start_listen_cb()
2743 wpa_s->off_channel_freq = 0; in wpas_start_listen_cb()
2744 wpa_s->roc_waiting_drv_freq = lwork->freq; in wpas_start_listen_cb()
2748 static int wpas_start_listen(void *ctx, unsigned int freq, in wpas_start_listen() argument
2755 if (wpa_s->p2p_listen_work) { in wpas_start_listen()
2757 return -1; in wpas_start_listen()
2762 return -1; in wpas_start_listen()
2763 lwork->freq = freq; in wpas_start_listen()
2764 lwork->duration = duration; in wpas_start_listen()
2766 lwork->probe_resp_ie = wpabuf_dup(probe_resp_ie); in wpas_start_listen()
2767 if (lwork->probe_resp_ie == NULL) { in wpas_start_listen()
2769 return -1; in wpas_start_listen()
2773 if (radio_add_work(wpa_s, freq, "p2p-listen", 0, wpas_start_listen_cb, in wpas_start_listen()
2776 return -1; in wpas_start_listen()
2786 if (wpa_s->off_channel_freq || wpa_s->roc_waiting_drv_freq) { in wpas_stop_listen()
2788 wpa_s->off_channel_freq = 0; in wpas_stop_listen()
2789 wpa_s->roc_waiting_drv_freq = 0; in wpas_stop_listen()
2797 if (!wpa_s->p2p_cli_probe) in wpas_stop_listen()
2802 if (radio_work_pending(wpa_s, "p2p-listen")) { in wpas_stop_listen()
2804 "P2P: p2p-listen is still pending - remove it"); in wpas_stop_listen()
2805 radio_remove_works(wpa_s, "p2p-listen", 0); in wpas_stop_listen()
2811 unsigned int freq) in wpas_send_probe_resp() argument
2815 freq, 0); in wpas_send_probe_resp()
2851 for (group = wpa_s->global->ifaces; group; group = group->next) in wpas_prov_disc_req()
2853 struct wpa_ssid *s = group->current_ssid; in wpas_prov_disc_req()
2855 s->mode == WPAS_MODE_P2P_GO && in wpas_prov_disc_req()
2856 group_id_len - ETH_ALEN == s->ssid_len && in wpas_prov_disc_req()
2857 os_memcmp(group_id + ETH_ALEN, s->ssid, in wpas_prov_disc_req()
2858 s->ssid_len) == 0) in wpas_prov_disc_req()
2875 group ? group->ifname : ""); in wpas_prov_disc_req()
2878 params[sizeof(params) - 1] = '\0'; in wpas_prov_disc_req()
2908 if (wpa_s->pending_pd_before_join && in wpas_prov_disc_resp()
2909 (ether_addr_equal(peer, wpa_s->pending_join_dev_addr) || in wpas_prov_disc_resp()
2910 ether_addr_equal(peer, wpa_s->pending_join_iface_addr))) { in wpas_prov_disc_resp()
2911 wpa_s->pending_pd_before_join = 0; in wpas_prov_disc_resp()
2913 "join-existing-group operation"); in wpas_prov_disc_resp()
2918 if (wpa_s->pending_pd_use == AUTO_PD_JOIN || in wpas_prov_disc_resp()
2919 wpa_s->pending_pd_use == AUTO_PD_GO_NEG) { in wpas_prov_disc_resp()
2923 wpa_s->pending_pd_use == AUTO_PD_JOIN); in wpas_prov_disc_resp()
2925 params[sizeof(params) - 1] = '\0'; in wpas_prov_disc_resp()
2958 if (wpa_s->p2p_fallback_to_go_neg) { in wpas_prov_disc_fail()
2959 wpa_dbg(wpa_s, MSG_DEBUG, "P2P: PD for p2p_connect-auto " in wpas_prov_disc_fail()
2960 "failed - fall back to GO Negotiation"); in wpas_prov_disc_fail()
2961 wpa_msg_global(wpa_s->p2pdev, MSG_INFO, in wpas_prov_disc_fail()
2963 "reason=PD-failed"); in wpas_prov_disc_fail()
2969 wpa_s->pending_pd_before_join = 0; in wpas_prov_disc_fail()
2971 "join-existing-group operation (no ACK for PD " in wpas_prov_disc_fail()
3000 unsigned int freq) in freq_included() argument
3002 if ((channels == NULL || p2p_channels_includes_freq(channels, freq)) && in freq_included()
3003 wpas_p2p_go_is_peer_freq(wpa_s, freq)) in freq_included()
3020 ret = p2p_group_get_common_freqs(wpa_s->p2p_group, common_freqs, &num); in wpas_p2p_go_update_common_freqs()
3028 os_free(wpa_s->p2p_group_common_freqs); in wpas_p2p_go_update_common_freqs()
3029 wpa_s->p2p_group_common_freqs = common_freqs; in wpas_p2p_go_update_common_freqs()
3030 wpa_s->p2p_group_common_freqs_num = num; in wpas_p2p_go_update_common_freqs()
3039 static int wpas_p2p_go_is_peer_freq(struct wpa_supplicant *wpa_s, int freq) in wpas_p2p_go_is_peer_freq() argument
3046 if (!wpa_s->p2p_group_common_freqs_num) in wpas_p2p_go_is_peer_freq()
3049 for (i = 0; i < wpa_s->p2p_group_common_freqs_num; i++) { in wpas_p2p_go_is_peer_freq()
3050 if (wpa_s->p2p_group_common_freqs[i] == freq) in wpas_p2p_go_is_peer_freq()
3062 *ecsa_support &= sta->ecsa_supported; in wpas_sta_check_ecsa()
3073 ap_for_each_sta(wpa_s->ap_iface->bss[0], wpas_sta_check_ecsa, in wpas_p2p_go_clients_support_ecsa()
3089 /* find a candidate freq that is supported by P2P */ in wpas_p2p_pick_best_used_freq()
3091 if (p2p_supported_freq(wpa_s->global->p2p, freqs[c].freq)) in wpas_p2p_pick_best_used_freq()
3099 if (!p2p_supported_freq(wpa_s->global->p2p, freqs[i].freq)) in wpas_p2p_pick_best_used_freq()
3115 return freqs[c].freq; in wpas_p2p_pick_best_used_freq()
3123 * - input: the max size of pref_freq_list,
3124 * - output: the valid size of pref_freq_list filled with data.
3145 if (!res && !is_p2p_allow_6ghz(wpa_s->global->p2p)) in wpas_p2p_pick_best_pref_freq()
3157 (!p2p_supported_freq(wpa_s->global->p2p, in wpas_p2p_pick_best_pref_freq()
3158 pref_freq_list[i].freq) || in wpas_p2p_pick_best_pref_freq()
3159 wpas_p2p_disallowed_freq(wpa_s->global, in wpas_p2p_pick_best_pref_freq()
3160 pref_freq_list[i].freq) || in wpas_p2p_pick_best_pref_freq()
3164 i, pref_freq_list[i].freq); in wpas_p2p_pick_best_pref_freq()
3168 best_freq = pref_freq_list[i].freq; in wpas_p2p_pick_best_pref_freq()
3202 if (!is_zero_ether_addr(wpa_s->p2p_auth_invite) && in wpas_invitation_process()
3203 (ether_addr_equal(go_dev_addr, wpa_s->p2p_auth_invite) || in wpas_invitation_process()
3204 ether_addr_equal(sa, wpa_s->p2p_auth_invite))) { in wpas_invitation_process()
3211 if (dev_pw_id >= 0 && wpa_s->p2p_nfc_tag_enabled && in wpas_invitation_process()
3212 dev_pw_id == wpa_s->p2p_oob_dev_pw_id) { in wpas_invitation_process()
3214 wpa_s->p2p_wps_method = WPS_NFC; in wpas_invitation_process()
3215 wpa_s->pending_join_wps_method = WPS_NFC; in wpas_invitation_process()
3216 os_memcpy(wpa_s->pending_join_dev_addr, in wpas_invitation_process()
3218 os_memcpy(wpa_s->pending_join_iface_addr, in wpas_invitation_process()
3236 os_memcpy(group_bssid, grp->own_addr, ETH_ALEN); in wpas_invitation_process()
3240 if (!is_zero_ether_addr(wpa_s->p2p_auth_invite) && in wpas_invitation_process()
3241 ether_addr_equal(sa, wpa_s->p2p_auth_invite)) { in wpas_invitation_process()
3243 "invitation to re-invoke a persistent group"); in wpas_invitation_process()
3244 os_memset(wpa_s->p2p_auth_invite, 0, ETH_ALEN); in wpas_invitation_process()
3245 } else if (!wpa_s->conf->persistent_reconnect) in wpas_invitation_process()
3248 for (s = wpa_s->conf->ssid; s; s = s->next) { in wpas_invitation_process()
3249 if (s->disabled == 2 && in wpas_invitation_process()
3250 ether_addr_equal(s->bssid, go_dev_addr) && in wpas_invitation_process()
3251 s->ssid_len == ssid_len && in wpas_invitation_process()
3252 os_memcmp(ssid, s->ssid, ssid_len) == 0) in wpas_invitation_process()
3263 if (s->mode == WPAS_MODE_P2P_GO && !wpas_p2p_create_iface(wpa_s)) { in wpas_invitation_process()
3265 if (wpa_s->wpa_state >= WPA_AUTHENTICATING) { in wpas_invitation_process()
3267 "interface is already in use - reject " in wpas_invitation_process()
3271 if (wpa_s->p2p_mgmt) in wpas_invitation_process()
3272 os_memcpy(group_bssid, wpa_s->parent->own_addr, in wpas_invitation_process()
3275 os_memcpy(group_bssid, wpa_s->own_addr, ETH_ALEN); in wpas_invitation_process()
3276 } else if (s->mode == WPAS_MODE_P2P_GO) { in wpas_invitation_process()
3284 os_memcpy(group_bssid, wpa_s->pending_interface_addr, in wpas_invitation_process()
3292 freqs = os_calloc(wpa_s->num_multichan_concurrent, in wpas_invitation_process()
3295 int num_channels = wpa_s->num_multichan_concurrent; in wpas_invitation_process()
3312 if (wpa_s->num_multichan_concurrent < 2 || in wpas_invitation_process()
3314 …wpa_printf(MSG_DEBUG, "P2P: No extra channels available - trying to force channel to match a chann… in wpas_invitation_process()
3319 if (*force_freq > 0 && wpa_s->num_multichan_concurrent > 1 && in wpas_invitation_process()
3330 wpa_printf(MSG_DEBUG, "P2P: Forced GO freq %d MHz not " in wpas_invitation_process()
3350 for (s = wpa_s->conf->ssid; s; s = s->next) { in wpas_invitation_received()
3351 if (s->disabled == 2 && in wpas_invitation_received()
3352 s->ssid_len == ssid_len && in wpas_invitation_received()
3353 os_memcmp(ssid, s->ssid, ssid_len) == 0) in wpas_invitation_received()
3362 int go = s->mode == WPAS_MODE_P2P_GO; in wpas_invitation_received()
3367 " persistent=%d freq=%d", in wpas_invitation_received()
3368 MAC2STR(sa), s->id, op_freq); in wpas_invitation_received()
3374 MAC2STR(sa), s->id); in wpas_invitation_received()
3378 wpa_s->conf->p2p_go_ht40, in wpas_invitation_received()
3379 wpa_s->conf->p2p_go_vht, in wpas_invitation_received()
3381 wpa_s->conf->p2p_go_he, in wpas_invitation_received()
3382 wpa_s->conf->p2p_go_edmg, NULL, in wpas_invitation_received()
3384 1, is_p2p_allow_6ghz(wpa_s->global->p2p), 0, in wpas_invitation_received()
3387 wpa_s->user_initiated_pd = 0; in wpas_invitation_received()
3391 " bssid=" MACSTR " unknown-network", in wpas_invitation_received()
3395 wpa_s->p2p_wps_method, 0, op_freq, in wpas_invitation_received()
3412 " bssid=" MACSTR " unknown-network", in wpas_invitation_received()
3419 " unknown-network", in wpas_invitation_received()
3427 if (s->mode == WPAS_MODE_P2P_GO && op_freq) { in wpas_invitation_received()
3429 "sa=" MACSTR " persistent=%d freq=%d", in wpas_invitation_received()
3430 MAC2STR(sa), s->id, op_freq); in wpas_invitation_received()
3434 MAC2STR(sa), s->id); in wpas_invitation_received()
3437 s->id, op_freq); in wpas_invitation_received()
3446 struct wpa_supplicant *p2p_wpa_s = wpa_s->global->p2p_init_wpa_s; in wpas_remove_persistent_peer()
3451 for (i = 0; ssid->p2p_client_list && i < ssid->num_p2p_clients; i++) { in wpas_remove_persistent_peer()
3452 if (ether_addr_equal(ssid->p2p_client_list + i * 2 * ETH_ALEN, in wpas_remove_persistent_peer()
3456 if (i >= ssid->num_p2p_clients || !ssid->p2p_client_list) { in wpas_remove_persistent_peer()
3457 if (ssid->mode != WPAS_MODE_P2P_GO && in wpas_remove_persistent_peer()
3458 ether_addr_equal(ssid->bssid, peer)) { in wpas_remove_persistent_peer()
3460 "due to invitation result", ssid->id); in wpas_remove_persistent_peer()
3462 wpa_config_remove_network(wpa_s->conf, ssid->id); in wpas_remove_persistent_peer()
3470 MAC2STR(peer), ssid->id, in wpas_remove_persistent_peer()
3472 os_memmove(ssid->p2p_client_list + i * 2 * ETH_ALEN, in wpas_remove_persistent_peer()
3473 ssid->p2p_client_list + (i + 1) * 2 * ETH_ALEN, in wpas_remove_persistent_peer()
3474 (ssid->num_p2p_clients - i - 1) * 2 * ETH_ALEN); in wpas_remove_persistent_peer()
3475 ssid->num_p2p_clients--; in wpas_remove_persistent_peer()
3476 if (p2p_wpa_s->conf->update_config && in wpas_remove_persistent_peer()
3477 wpa_config_write(p2p_wpa_s->confname, p2p_wpa_s->conf)) in wpas_remove_persistent_peer()
3487 wpa_s = wpa_s->global->p2p_invite_group; in wpas_remove_persistent_client()
3490 ssid = wpa_s->current_ssid; in wpas_remove_persistent_client()
3491 if (ssid == NULL || ssid->mode != WPAS_MODE_P2P_GO || in wpas_remove_persistent_client()
3492 !ssid->p2p_persistent_group) in wpas_remove_persistent_client()
3494 ssid = wpas_p2p_get_persistent(wpa_s->p2pdev, peer, in wpas_remove_persistent_client()
3495 ssid->ssid, ssid->ssid_len); in wpas_remove_persistent_client()
3507 int freq; in wpas_invitation_result() local
3519 wpa_printf(MSG_DEBUG, "P2P: Invitation result - status=%d peer=" MACSTR, in wpas_invitation_result()
3521 if (wpa_s->pending_invite_ssid_id == -1) { in wpas_invitation_result()
3523 wpa_s->global->p2p_invite_group; in wpas_invitation_result()
3535 group_if && group_if->current_ssid && in wpas_invitation_result()
3536 group_if->current_ssid->mode == WPAS_MODE_P2P_GO) { in wpas_invitation_result()
3537 os_get_reltime(&wpa_s->global->p2p_go_wait_client); in wpas_invitation_result()
3539 if (group_if->p2p_go_csa_on_inv) { in wpas_invitation_result()
3558 "re-invocation"); in wpas_invitation_result()
3564 wpa_s->conf, wpa_s->pending_invite_ssid_id); in wpas_invitation_result()
3571 ssid = wpa_config_get_network(wpa_s->conf, in wpas_invitation_result()
3572 wpa_s->pending_invite_ssid_id); in wpas_invitation_result()
3591 if (neg_freq > 0 && ssid->mode == WPAS_MODE_P2P_GO && in wpas_invitation_result()
3593 freq = neg_freq; in wpas_invitation_result()
3594 else if (peer_oper_freq > 0 && ssid->mode != WPAS_MODE_P2P_GO && in wpas_invitation_result()
3596 freq = peer_oper_freq; in wpas_invitation_result()
3598 freq = 0; in wpas_invitation_result()
3600 wpa_printf(MSG_DEBUG, "P2P: Persistent group invitation success - op_freq=%d MHz SSID=%s", in wpas_invitation_result()
3601 freq, wpa_ssid_txt(ssid->ssid, ssid->ssid_len)); in wpas_invitation_result()
3603 ssid->mode == WPAS_MODE_P2P_GO, in wpas_invitation_result()
3604 wpa_s->p2p_persistent_go_freq, in wpas_invitation_result()
3605 freq, in wpas_invitation_result()
3606 wpa_s->p2p_go_vht_center_freq2, in wpas_invitation_result()
3607 wpa_s->p2p_go_ht40, wpa_s->p2p_go_vht, in wpas_invitation_result()
3608 wpa_s->p2p_go_max_oper_chwidth, in wpas_invitation_result()
3609 wpa_s->p2p_go_he, in wpas_invitation_result()
3610 wpa_s->p2p_go_edmg, in wpas_invitation_result()
3612 ssid->mode == WPAS_MODE_P2P_GO ? in wpas_invitation_result()
3615 is_p2p_allow_6ghz(wpa_s->global->p2p), 0, in wpas_invitation_result()
3621 unsigned int freq) in wpas_p2p_disallowed_freq() argument
3623 if (freq_range_list_includes(&global->p2p_go_avoid_freq, freq)) in wpas_p2p_disallowed_freq()
3625 return freq_range_list_includes(&global->p2p_disallow_freq, freq); in wpas_p2p_disallowed_freq()
3631 reg->channel[reg->channels] = chan; in wpas_p2p_add_chan()
3632 reg->channels++; in wpas_p2p_add_chan()
3642 wpa_s->global->p2p_24ghz_social_channels = 1; in wpas_p2p_default_channels()
3649 /* Operating class 81 - 2.4 GHz band channels 1..13 */ in wpas_p2p_default_channels()
3650 chan->reg_class[cla].reg_class = 81; in wpas_p2p_default_channels()
3651 chan->reg_class[cla].channels = 0; in wpas_p2p_default_channels()
3653 if (!wpas_p2p_disallowed_freq(wpa_s->global, 2412 + i * 5)) in wpas_p2p_default_channels()
3654 wpas_p2p_add_chan(&chan->reg_class[cla], i + 1); in wpas_p2p_default_channels()
3656 if (chan->reg_class[cla].channels) in wpas_p2p_default_channels()
3662 /* Operating class 115 - 5 GHz, channels 36-48 */ in wpas_p2p_default_channels()
3663 chan->reg_class[cla].reg_class = 115; in wpas_p2p_default_channels()
3664 chan->reg_class[cla].channels = 0; in wpas_p2p_default_channels()
3665 if (!wpas_p2p_disallowed_freq(wpa_s->global, 5000 + 36 * 5)) in wpas_p2p_default_channels()
3666 wpas_p2p_add_chan(&chan->reg_class[cla], 36); in wpas_p2p_default_channels()
3667 if (!wpas_p2p_disallowed_freq(wpa_s->global, 5000 + 40 * 5)) in wpas_p2p_default_channels()
3668 wpas_p2p_add_chan(&chan->reg_class[cla], 40); in wpas_p2p_default_channels()
3669 if (!wpas_p2p_disallowed_freq(wpa_s->global, 5000 + 44 * 5)) in wpas_p2p_default_channels()
3670 wpas_p2p_add_chan(&chan->reg_class[cla], 44); in wpas_p2p_default_channels()
3671 if (!wpas_p2p_disallowed_freq(wpa_s->global, 5000 + 48 * 5)) in wpas_p2p_default_channels()
3672 wpas_p2p_add_chan(&chan->reg_class[cla], 48); in wpas_p2p_default_channels()
3673 if (chan->reg_class[cla].channels) in wpas_p2p_default_channels()
3679 /* Operating class 124 - 5 GHz, channels 149,153,157,161 */ in wpas_p2p_default_channels()
3680 chan->reg_class[cla].reg_class = 124; in wpas_p2p_default_channels()
3681 chan->reg_class[cla].channels = 0; in wpas_p2p_default_channels()
3682 if (!wpas_p2p_disallowed_freq(wpa_s->global, 5000 + 149 * 5)) in wpas_p2p_default_channels()
3683 wpas_p2p_add_chan(&chan->reg_class[cla], 149); in wpas_p2p_default_channels()
3684 if (!wpas_p2p_disallowed_freq(wpa_s->global, 5000 + 153 * 5)) in wpas_p2p_default_channels()
3685 wpas_p2p_add_chan(&chan->reg_class[cla], 153); in wpas_p2p_default_channels()
3686 if (!wpas_p2p_disallowed_freq(wpa_s->global, 5000 + 156 * 5)) in wpas_p2p_default_channels()
3687 wpas_p2p_add_chan(&chan->reg_class[cla], 157); in wpas_p2p_default_channels()
3688 if (!wpas_p2p_disallowed_freq(wpa_s->global, 5000 + 161 * 5)) in wpas_p2p_default_channels()
3689 wpas_p2p_add_chan(&chan->reg_class[cla], 161); in wpas_p2p_default_channels()
3690 if (chan->reg_class[cla].channels) in wpas_p2p_default_channels()
3693 chan->reg_classes = cla; in wpas_p2p_default_channels()
3703 unsigned int freq; in has_channel() local
3705 freq = ieee80211_chan_to_freq(NULL, op_class, chan); in has_channel()
3706 if (wpas_p2p_disallowed_freq(global, freq)) in has_channel()
3709 for (i = 0; i < mode->num_channels; i++) { in has_channel()
3710 if ((unsigned int) mode->channels[i].freq == freq) { in has_channel()
3712 *flags = mode->channels[i].flag; in has_channel()
3713 if (mode->channels[i].flag & HOSTAPD_CHAN_DISABLED) in has_channel()
3715 if (mode->channels[i].flag & HOSTAPD_CHAN_NO_IR) in has_channel()
3717 if (mode->channels[i].flag & HOSTAPD_CHAN_RADAR) in has_channel()
3734 if (mode->mode != HOSTAPD_MODE_IEEE80211A) in wpas_p2p_get_center_80mhz()
3739 * In 80 MHz, the bandwidth "spans" 12 channels (e.g., 36-48), in wpas_p2p_get_center_80mhz()
3742 if (channel >= center_channels[i] - 6 && in wpas_p2p_get_center_80mhz()
3778 if (!wpa_s->p2p_go_allow_dfs && in wpas_p2p_verify_80mhz()
3784 int adj_chan = center_chan - 6 + i * 4; in wpas_p2p_verify_80mhz()
3786 res = has_channel(wpa_s->global, mode, op_class, adj_chan, in wpas_p2p_verify_80mhz()
3815 if (mode->mode != HOSTAPD_MODE_IEEE80211A) in wpas_p2p_get_center_160mhz()
3820 * In 160 MHz, the bandwidth "spans" 28 channels (e.g., 36-64), in wpas_p2p_get_center_160mhz()
3823 if (channel >= center_channels[i] - 14 && in wpas_p2p_get_center_160mhz()
3860 int adj_chan = center_chan - 14 + i * 4; in wpas_p2p_verify_160mhz()
3862 res = has_channel(wpa_s->global, mode, op_class, adj_chan, in wpas_p2p_verify_160mhz()
3894 if (edmg.channels && ieee802_edmg_is_allowed(mode->edmg, edmg)) in wpas_p2p_verify_edmg()
3912 res2 = res = has_channel(wpa_s->global, mode, op_class, channel, &flag); in wpas_p2p_verify_channel()
3916 res2 = has_channel(wpa_s->global, mode, op_class, channel - 4, in wpas_p2p_verify_channel()
3921 res2 = has_channel(wpa_s->global, mode, op_class, channel + 4, in wpas_p2p_verify_channel()
3924 if (mode->mode != HOSTAPD_MODE_IEEE80211A) in wpas_p2p_verify_channel()
3927 res2 = has_channel(wpa_s->global, mode, op_class, in wpas_p2p_verify_channel()
3928 channel - 4, NULL); in wpas_p2p_verify_channel()
3930 res2 = has_channel(wpa_s->global, mode, op_class, in wpas_p2p_verify_channel()
3960 if (wpa_s->hw.modes == NULL) { in wpas_p2p_setup_channels()
3974 if (o->p2p == NO_P2P_SUPP || in wpas_p2p_setup_channels()
3975 (is_6ghz_op_class(o->op_class) && p2p_disable_6ghz)) in wpas_p2p_setup_channels()
3978 mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes, o->mode, in wpas_p2p_setup_channels()
3979 is_6ghz_op_class(o->op_class)); in wpas_p2p_setup_channels()
3982 if (mode->mode == HOSTAPD_MODE_IEEE80211G) in wpas_p2p_setup_channels()
3983 wpa_s->global->p2p_24ghz_social_channels = 1; in wpas_p2p_setup_channels()
3984 for (ch = o->min_chan; ch <= o->max_chan; ch += o->inc) { in wpas_p2p_setup_channels()
3987 /* Check for non-continuous jump in channel index in wpas_p2p_setup_channels()
3989 if ((o->op_class >= 128 && o->op_class <= 130) && in wpas_p2p_setup_channels()
3990 ch < 149 && ch + o->inc > 149) in wpas_p2p_setup_channels()
3993 res = wpas_p2p_verify_channel(wpa_s, mode, o->op_class, in wpas_p2p_setup_channels()
3994 ch, o->bw); in wpas_p2p_setup_channels()
4000 o->op_class); in wpas_p2p_setup_channels()
4001 reg = &chan->reg_class[cla]; in wpas_p2p_setup_channels()
4003 reg->reg_class = o->op_class; in wpas_p2p_setup_channels()
4005 if (reg->channels == P2P_MAX_REG_CLASS_CHANNELS) in wpas_p2p_setup_channels()
4007 reg->channel[reg->channels] = ch; in wpas_p2p_setup_channels()
4008 reg->channels++; in wpas_p2p_setup_channels()
4010 wpa_s->conf->p2p_add_cli_chan) { in wpas_p2p_setup_channels()
4015 o->op_class); in wpas_p2p_setup_channels()
4016 cli_reg = &cli_chan->reg_class[cli_cla]; in wpas_p2p_setup_channels()
4018 cli_reg->reg_class = o->op_class; in wpas_p2p_setup_channels()
4020 if (cli_reg->channels == in wpas_p2p_setup_channels()
4023 cli_reg->channel[cli_reg->channels] = ch; in wpas_p2p_setup_channels()
4024 cli_reg->channels++; in wpas_p2p_setup_channels()
4029 reg->channel, reg->channels); in wpas_p2p_setup_channels()
4033 cli_reg->channel, cli_reg->channels); in wpas_p2p_setup_channels()
4037 chan->reg_classes = cla; in wpas_p2p_setup_channels()
4038 cli_chan->reg_classes = cli_cla; in wpas_p2p_setup_channels()
4057 if ((o->p2p == NO_P2P_SUPP && in wpas_p2p_get_sec_channel_offset_40mhz()
4058 (!is_dfs_global_op_class(o->op_class) || in wpas_p2p_get_sec_channel_offset_40mhz()
4059 !wpa_s->p2p_go_allow_dfs)) || in wpas_p2p_get_sec_channel_offset_40mhz()
4060 (is_6ghz_op_class(o->op_class) && in wpas_p2p_get_sec_channel_offset_40mhz()
4061 wpa_s->conf->p2p_6ghz_disable)) in wpas_p2p_get_sec_channel_offset_40mhz()
4064 /* IEEE Std 802.11ax-2021 26.17.2.3.2: "A 6 GHz-only AP should in wpas_p2p_get_sec_channel_offset_40mhz()
4071 if (is_6ghz_op_class(o->op_class) && o->bw == BW40 && in wpas_p2p_get_sec_channel_offset_40mhz()
4075 for (ch += o->min_chan; ch <= o->max_chan; ch += o->inc) { in wpas_p2p_get_sec_channel_offset_40mhz()
4076 if (o->mode != HOSTAPD_MODE_IEEE80211A || in wpas_p2p_get_sec_channel_offset_40mhz()
4077 (o->bw != BW40PLUS && o->bw != BW40MINUS && in wpas_p2p_get_sec_channel_offset_40mhz()
4078 o->bw != BW40) || in wpas_p2p_get_sec_channel_offset_40mhz()
4081 ret = wpas_p2p_verify_channel(wpa_s, mode, o->op_class, in wpas_p2p_get_sec_channel_offset_40mhz()
4082 ch, o->bw); in wpas_p2p_get_sec_channel_offset_40mhz()
4084 if (is_6ghz_op_class(o->op_class) && in wpas_p2p_get_sec_channel_offset_40mhz()
4085 o->bw == BW40) in wpas_p2p_get_sec_channel_offset_40mhz()
4087 return (o->bw == BW40MINUS) ? -1 : 1; in wpas_p2p_get_sec_channel_offset_40mhz()
4089 if (ret == RADAR && wpa_s->p2p_go_allow_dfs) { in wpas_p2p_get_sec_channel_offset_40mhz()
4092 return (o->bw == BW40MINUS) ? -1 : 1; in wpas_p2p_get_sec_channel_offset_40mhz()
4109 if (!(ret == ALLOWED || (ret == RADAR && wpa_s->p2p_go_allow_dfs))) in wpas_p2p_get_vht80_center()
4133 if (!(ret == ALLOWED || (ret == RADAR && wpa_s->p2p_go_allow_dfs))) in wpas_p2p_get_vht160_center()
4152 for (wpa_s = wpa_s->global->ifaces; wpa_s; wpa_s = wpa_s->next) { in wpas_get_noa()
4153 if (ether_addr_equal(wpa_s->own_addr, interface_addr)) in wpas_get_noa()
4157 return -1; in wpas_get_noa()
4166 for (wpa_s = wpa_s->global->ifaces; wpa_s; wpa_s = wpa_s->next) { in wpas_get_p2p_go_iface()
4167 struct wpa_ssid *s = wpa_s->current_ssid; in wpas_get_p2p_go_iface()
4170 if (s->mode != WPAS_MODE_P2P_GO && in wpas_get_p2p_go_iface()
4171 s->mode != WPAS_MODE_AP && in wpas_get_p2p_go_iface()
4172 s->mode != WPAS_MODE_P2P_GROUP_FORMATION) in wpas_get_p2p_go_iface()
4174 if (s->ssid_len != ssid_len || in wpas_get_p2p_go_iface()
4175 os_memcmp(ssid, s->ssid, ssid_len) != 0) in wpas_get_p2p_go_iface()
4188 for (wpa_s = wpa_s->global->ifaces; wpa_s; wpa_s = wpa_s->next) { in wpas_get_p2p_client_iface()
4189 struct wpa_ssid *ssid = wpa_s->current_ssid; in wpas_get_p2p_client_iface()
4190 if (ssid && (ssid->mode != WPAS_MODE_INFRA || !ssid->p2p_group)) in wpas_get_p2p_client_iface()
4192 if (ether_addr_equal(wpa_s->go_dev_addr, peer_dev_addr)) in wpas_get_p2p_client_iface()
4213 for (ifs = wpa_s->global->ifaces; ifs; ifs = ifs->next) { in wpas_is_concurrent_session_active()
4216 if (ifs->wpa_state > WPA_ASSOCIATED) in wpas_is_concurrent_session_active()
4241 wpa_s->ifname); in wpas_p2p_add_p2pdev_interface()
4243 return -1; in wpas_p2p_add_p2pdev_interface()
4247 ifname[IFNAMSIZ - 1] = '\0'; in wpas_p2p_add_p2pdev_interface()
4249 wpa_s->pending_interface_type = WPA_IF_P2P_DEVICE; in wpas_p2p_add_p2pdev_interface()
4251 if (wpa_s->conf->p2p_device_random_mac_addr == 2 && in wpas_p2p_add_p2pdev_interface()
4252 !is_zero_ether_addr(wpa_s->conf->p2p_device_persistent_mac_addr)) in wpas_p2p_add_p2pdev_interface()
4253 if_addr = wpa_s->conf->p2p_device_persistent_mac_addr; in wpas_p2p_add_p2pdev_interface()
4256 force_name, wpa_s->pending_interface_addr, NULL); in wpas_p2p_add_p2pdev_interface()
4261 os_strlcpy(wpa_s->pending_interface_name, ifname, in wpas_p2p_add_p2pdev_interface()
4262 sizeof(wpa_s->pending_interface_name)); in wpas_p2p_add_p2pdev_interface()
4266 iface.ifname = wpa_s->pending_interface_name; in wpas_p2p_add_p2pdev_interface()
4267 iface.driver = wpa_s->driver->name; in wpas_p2p_add_p2pdev_interface()
4268 iface.driver_param = wpa_s->conf->driver_param; in wpas_p2p_add_p2pdev_interface()
4278 iface.confname = wpa_s->confname; in wpas_p2p_add_p2pdev_interface()
4279 iface.ctrl_interface = wpa_s->conf->ctrl_interface; in wpas_p2p_add_p2pdev_interface()
4282 p2pdev_wpa_s = wpa_supplicant_add_iface(wpa_s->global, &iface, wpa_s); in wpas_p2p_add_p2pdev_interface()
4285 return -1; in wpas_p2p_add_p2pdev_interface()
4288 p2pdev_wpa_s->p2pdev = p2pdev_wpa_s; in wpas_p2p_add_p2pdev_interface()
4289 wpa_s->pending_interface_name[0] = '\0'; in wpas_p2p_add_p2pdev_interface()
4300 for (wpa_s = intf->global->ifaces; wpa_s; wpa_s = wpa_s->next) { in wpas_presence_resp()
4301 if (wpa_s->waiting_presence_resp) in wpas_presence_resp()
4308 wpa_s->waiting_presence_resp = 0; in wpas_presence_resp()
4326 os_memcpy(ret_ssid, s->ssid, s->ssid_len); in wpas_get_persistent_group()
4327 *ret_ssid_len = s->ssid_len; in wpas_get_persistent_group()
4328 os_memcpy(go_dev_addr, s->bssid, ETH_ALEN); in wpas_get_persistent_group()
4330 if (s->mode != WPAS_MODE_P2P_GO) { in wpas_get_persistent_group()
4337 wpa_s->pending_interface_addr, ETH_ALEN); in wpas_get_persistent_group()
4339 os_memcpy(intended_iface_addr, wpa_s->own_addr, in wpas_get_persistent_group()
4351 unsigned int *freq) in wpas_get_go_info() argument
4366 if (freq) in wpas_get_go_info()
4367 *freq = 0; in wpas_get_go_info()
4374 os_memcpy(intended_addr, s->bssid, ETH_ALEN); in wpas_get_go_info()
4378 s = go->current_ssid; in wpas_get_go_info()
4379 os_memcpy(intended_addr, go->own_addr, ETH_ALEN); in wpas_get_go_info()
4380 if (freq) in wpas_get_go_info()
4381 *freq = go->assoc_freq; in wpas_get_go_info()
4384 os_memcpy(ssid, s->ssid, s->ssid_len); in wpas_get_go_info()
4385 *ssid_len = s->ssid_len; in wpas_get_go_info()
4402 s->ssid_len == ssid_len && in wpas_remove_stale_groups()
4403 ether_addr_equal(go, s->bssid) && in wpas_remove_stale_groups()
4404 os_memcmp(ssid, s->ssid, ssid_len) == 0) in wpas_remove_stale_groups()
4408 if (s->mode != WPAS_MODE_P2P_GO || s->num_p2p_clients <= 1) { in wpas_remove_stale_groups()
4411 s->id); in wpas_remove_stale_groups()
4413 wpa_config_remove_network(wpa_s->conf, s->id); in wpas_remove_stale_groups()
4418 for (i = 0; i < s->num_p2p_clients; i++) { in wpas_remove_stale_groups()
4419 if (!ether_addr_equal(s->p2p_client_list + in wpas_remove_stale_groups()
4423 os_memmove(s->p2p_client_list + i * 2 * ETH_ALEN, in wpas_remove_stale_groups()
4424 s->p2p_client_list + (i + 1) * 2 * ETH_ALEN, in wpas_remove_stale_groups()
4425 (s->num_p2p_clients - i - 1) * 2 * ETH_ALEN); in wpas_remove_stale_groups()
4428 s->num_p2p_clients--; in wpas_remove_stale_groups()
4459 ret = wpa_snprintf_hex(&buf[sizeof(pref) - 1], in wpas_p2ps_get_feat_cap_str()
4460 buf_len - sizeof(pref) + 1, in wpas_p2ps_get_feat_cap_str()
4476 unsigned int freq, in wpas_p2ps_prov_complete() argument
4532 wpas_p2p_group_remove(wpa_s, go_wpa_s->ifname); in wpas_p2ps_prov_complete()
4534 if (persistent_go && !persistent_go->num_p2p_clients) { in wpas_p2ps_prov_complete()
4538 persistent_go->id); in wpas_p2ps_prov_complete()
4541 wpa_config_remove_network(wpa_s->conf, in wpas_p2ps_prov_complete()
4542 persistent_go->id); in wpas_p2ps_prov_complete()
4561 if (persist_ssid && s && s->mode != WPAS_MODE_P2P_GO && in wpas_p2ps_prov_complete()
4573 if (s && s->ssid_len == stale->ssid_len && in wpas_p2ps_prov_complete()
4574 ether_addr_equal(stale->bssid, s->bssid) && in wpas_p2ps_prov_complete()
4575 os_memcmp(stale->ssid, s->ssid, s->ssid_len) == 0) in wpas_p2ps_prov_complete()
4579 if (stale->mode != WPAS_MODE_P2P_GO || in wpas_p2ps_prov_complete()
4580 stale->num_p2p_clients <= 1) { in wpas_p2ps_prov_complete()
4583 stale->id); in wpas_p2ps_prov_complete()
4585 wpa_config_remove_network(wpa_s->conf, stale->id); in wpas_p2ps_prov_complete()
4589 for (i = 0; i < stale->num_p2p_clients; i++) { in wpas_p2ps_prov_complete()
4590 if (ether_addr_equal(stale->p2p_client_list + in wpas_p2ps_prov_complete()
4592 os_memmove(stale->p2p_client_list + in wpas_p2ps_prov_complete()
4594 stale->p2p_client_list + in wpas_p2ps_prov_complete()
4596 (stale->num_p2p_clients - in wpas_p2ps_prov_complete()
4597 i - 1) * ETH_ALEN); in wpas_p2ps_prov_complete()
4601 stale->num_p2p_clients--; in wpas_p2ps_prov_complete()
4611 wpas_p2p_group_remove(wpa_s, go_wpa_s->ifname); in wpas_p2ps_prov_complete()
4614 !persistent_go->num_p2p_clients) { in wpas_p2ps_prov_complete()
4618 persistent_go->id); in wpas_p2ps_prov_complete()
4621 wpa_config_remove_network(wpa_s->conf, in wpas_p2ps_prov_complete()
4622 persistent_go->id); in wpas_p2ps_prov_complete()
4634 ses_id, MAC2STR(ses_mac), s->id, feat_cap_str); in wpas_p2ps_prov_complete()
4638 wpa_s->global->pending_p2ps_group = 0; in wpas_p2ps_prov_complete()
4639 wpa_s->global->pending_p2ps_group_freq = 0; in wpas_p2ps_prov_complete()
4652 wpa_s->global->pending_p2ps_group = 1; in wpas_p2ps_prov_complete()
4653 wpa_s->global->pending_p2ps_group_freq = freq; in wpas_p2ps_prov_complete()
4657 os_memcpy(go_ifname, wpa_s->ifname, in wpas_p2ps_prov_complete()
4659 else if (wpa_s->pending_interface_name[0]) in wpas_p2ps_prov_complete()
4661 wpa_s->pending_interface_name, in wpas_p2ps_prov_complete()
4678 0, 0, freq, 0, 0, 0, 0, 0, 0, NULL, in wpas_p2ps_prov_complete()
4679 persistent_go->mode == in wpas_p2ps_prov_complete()
4684 wpas_p2p_group_add(wpa_s, 1, freq, in wpas_p2ps_prov_complete()
4689 os_memcpy(wpa_s->p2ps_join_addr, grp_mac, in wpas_p2ps_prov_complete()
4691 wpa_s->p2ps_method_config_any = 1; in wpas_p2ps_prov_complete()
4694 os_memcpy(go_ifname, go_wpa_s->ifname, in wpas_p2ps_prov_complete()
4699 "P2P: Setting PIN-1 for ANY"); in wpas_p2ps_prov_complete()
4705 "P2P: Setting PIN-1 for " MACSTR, in wpas_p2ps_prov_complete()
4712 os_memcpy(wpa_s->p2ps_join_addr, grp_mac, ETH_ALEN); in wpas_p2ps_prov_complete()
4713 wpa_s->p2ps_method_config_any = 1; in wpas_p2ps_prov_complete()
4730 wpas_p2p_group_remove(wpa_s, go_wpa_s->ifname); in wpas_p2ps_prov_complete()
4732 if (persistent_go && !persistent_go->num_p2p_clients) { in wpas_p2ps_prov_complete()
4736 persistent_go->id); in wpas_p2ps_prov_complete()
4738 wpa_config_remove_network(wpa_s->conf, persistent_go->id); in wpas_p2ps_prov_complete()
4786 unsigned int freq; in wpas_prov_disc_resp_cb() local
4788 if (!wpa_s->global->pending_p2ps_group) in wpas_prov_disc_resp_cb()
4791 freq = wpa_s->global->pending_p2ps_group_freq; in wpas_prov_disc_resp_cb()
4792 wpa_s->global->pending_p2ps_group_freq = 0; in wpas_prov_disc_resp_cb()
4793 wpa_s->global->pending_p2ps_group = 0; in wpas_prov_disc_resp_cb()
4803 persistent_go->mode == WPAS_MODE_P2P_GO ? in wpas_prov_disc_resp_cb()
4805 is_p2p_allow_6ghz(wpa_s->global->p2p), 0, NULL); in wpas_prov_disc_resp_cb()
4807 wpas_p2p_group_add(wpa_s, 1, freq, 0, 0, 0, 0, 0, 0, in wpas_prov_disc_resp_cb()
4808 is_p2p_allow_6ghz(wpa_s->global->p2p)); in wpas_prov_disc_resp_cb()
4830 if (wpa_s->conf->p2p_device_random_mac_addr == 0) in wpas_p2p_mac_setup()
4833 if (wpa_s->conf->p2p_device_random_mac_addr == 2) { in wpas_p2p_mac_setup()
4835 wpa_s->conf->p2p_device_persistent_mac_addr) && in wpas_p2p_mac_setup()
4836 !is_zero_ether_addr(wpa_s->own_addr)) { in wpas_p2p_mac_setup()
4837 os_memcpy(wpa_s->conf->p2p_device_persistent_mac_addr, in wpas_p2p_mac_setup()
4838 wpa_s->own_addr, ETH_ALEN); in wpas_p2p_mac_setup()
4843 if (!wpa_s->conf->ssid) { in wpas_p2p_mac_setup()
4847 return -EINVAL; in wpas_p2p_mac_setup()
4851 os_memcpy(wpa_s->conf->p2p_device_persistent_mac_addr, addr, in wpas_p2p_mac_setup()
4858 wpa_s->conf->p2p_device_persistent_mac_addr)) in wpas_p2p_mac_setup()
4860 os_memcpy(addr, wpa_s->conf->p2p_device_persistent_mac_addr, in wpas_p2p_mac_setup()
4868 return -EINVAL; in wpas_p2p_mac_setup()
4874 return -EINVAL; in wpas_p2p_mac_setup()
4885 * wpas_p2p_init - Initialize P2P module for %wpa_supplicant
4888 * Returns: 0 on success, -1 on failure
4895 if (wpa_s->conf->p2p_disabled) in wpas_p2p_init()
4898 if (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_CAPABLE)) in wpas_p2p_init()
4901 if (global->p2p) in wpas_p2p_init()
4907 return -1; in wpas_p2p_init()
4944 p2p.p2p_6ghz_disable = wpa_s->conf->p2p_6ghz_disable; in wpas_p2p_init()
4946 os_memcpy(wpa_s->global->p2p_dev_addr, wpa_s->own_addr, ETH_ALEN); in wpas_p2p_init()
4947 os_memcpy(p2p.dev_addr, wpa_s->global->p2p_dev_addr, ETH_ALEN); in wpas_p2p_init()
4948 p2p.dev_name = wpa_s->conf->device_name; in wpas_p2p_init()
4949 p2p.manufacturer = wpa_s->conf->manufacturer; in wpas_p2p_init()
4950 p2p.model_name = wpa_s->conf->model_name; in wpas_p2p_init()
4951 p2p.model_number = wpa_s->conf->model_number; in wpas_p2p_init()
4952 p2p.serial_number = wpa_s->conf->serial_number; in wpas_p2p_init()
4953 if (wpa_s->wps) { in wpas_p2p_init()
4954 os_memcpy(p2p.uuid, wpa_s->wps->uuid, 16); in wpas_p2p_init()
4955 p2p.config_methods = wpa_s->wps->config_methods; in wpas_p2p_init()
4962 return -1; in wpas_p2p_init()
4965 if (wpa_s->conf->p2p_listen_reg_class && in wpas_p2p_init()
4966 wpa_s->conf->p2p_listen_channel) { in wpas_p2p_init()
4967 p2p.reg_class = wpa_s->conf->p2p_listen_reg_class; in wpas_p2p_init()
4968 p2p.channel = wpa_s->conf->p2p_listen_channel; in wpas_p2p_init()
4977 &global->p2p_go_avoid_freq, in wpas_p2p_init()
4978 &global->p2p_disallow_freq) != in wpas_p2p_init()
4981 "P2P: No social channels supported by the driver - do not enable P2P"); in wpas_p2p_init()
4989 if (wpa_s->conf->p2p_oper_reg_class && in wpas_p2p_init()
4990 wpa_s->conf->p2p_oper_channel) { in wpas_p2p_init()
4991 p2p.op_reg_class = wpa_s->conf->p2p_oper_reg_class; in wpas_p2p_init()
4992 p2p.op_channel = wpa_s->conf->p2p_oper_channel; in wpas_p2p_init()
5007 "P2P: Failed to select random social channel as operation channel"); in wpas_p2p_init()
5018 if (wpa_s->conf->p2p_pref_chan && wpa_s->conf->num_p2p_pref_chan) { in wpas_p2p_init()
5019 p2p.pref_chan = wpa_s->conf->p2p_pref_chan; in wpas_p2p_init()
5020 p2p.num_pref_chan = wpa_s->conf->num_p2p_pref_chan; in wpas_p2p_init()
5023 if (wpa_s->conf->country[0] && wpa_s->conf->country[1]) { in wpas_p2p_init()
5024 os_memcpy(p2p.country, wpa_s->conf->country, 2); in wpas_p2p_init()
5029 os_memcpy(p2p.pri_dev_type, wpa_s->conf->device_type, in wpas_p2p_init()
5032 p2p.num_sec_dev_types = wpa_s->conf->num_sec_device_types; in wpas_p2p_init()
5033 os_memcpy(p2p.sec_dev_type, wpa_s->conf->sec_device_type, in wpas_p2p_init()
5036 p2p.concurrent_operations = !!(wpa_s->drv_flags & in wpas_p2p_init()
5041 if (wpa_s->conf->p2p_ssid_postfix) { in wpas_p2p_init()
5043 os_strlen(wpa_s->conf->p2p_ssid_postfix); in wpas_p2p_init()
5046 os_memcpy(p2p.ssid_postfix, wpa_s->conf->p2p_ssid_postfix, in wpas_p2p_init()
5050 p2p.p2p_intra_bss = wpa_s->conf->p2p_intra_bss; in wpas_p2p_init()
5052 p2p.max_listen = wpa_s->max_remain_on_chan; in wpas_p2p_init()
5054 if (wpa_s->conf->p2p_passphrase_len >= 8 && in wpas_p2p_init()
5055 wpa_s->conf->p2p_passphrase_len <= 63) in wpas_p2p_init()
5056 p2p.passphrase_len = wpa_s->conf->p2p_passphrase_len; in wpas_p2p_init()
5060 global->p2p = p2p_init(&p2p); in wpas_p2p_init()
5061 if (global->p2p == NULL) in wpas_p2p_init()
5062 return -1; in wpas_p2p_init()
5063 global->p2p_init_wpa_s = wpa_s; in wpas_p2p_init()
5066 if (wpa_s->conf->wps_vendor_ext[i] == NULL) in wpas_p2p_init()
5069 global->p2p, wpa_s->conf->wps_vendor_ext[i]); in wpas_p2p_init()
5072 p2p_set_no_go_freq(global->p2p, &wpa_s->conf->p2p_no_go_freq); in wpas_p2p_init()
5079 * wpas_p2p_deinit - Deinitialize per-interface P2P data
5082 * This function deinitialize per-interface P2P data.
5086 if (wpa_s->driver && wpa_s->drv_priv) in wpas_p2p_deinit()
5089 if (wpa_s->go_params) { in wpas_p2p_deinit()
5092 wpa_s->global->p2p, in wpas_p2p_deinit()
5093 wpa_s->go_params->peer_device_addr); in wpas_p2p_deinit()
5096 os_free(wpa_s->go_params); in wpas_p2p_deinit()
5097 wpa_s->go_params = NULL; in wpas_p2p_deinit()
5101 wpa_s->global->p2p_long_listen = 0; in wpas_p2p_deinit()
5108 if (wpa_s->p2p_send_action_work) { in wpas_p2p_deinit()
5109 os_free(wpa_s->p2p_send_action_work->ctx); in wpas_p2p_deinit()
5110 radio_work_done(wpa_s->p2p_send_action_work); in wpas_p2p_deinit()
5111 wpa_s->p2p_send_action_work = NULL; in wpas_p2p_deinit()
5115 wpabuf_free(wpa_s->p2p_oob_dev_pw); in wpas_p2p_deinit()
5116 wpa_s->p2p_oob_dev_pw = NULL; in wpas_p2p_deinit()
5118 os_free(wpa_s->p2p_group_common_freqs); in wpas_p2p_deinit()
5119 wpa_s->p2p_group_common_freqs = NULL; in wpas_p2p_deinit()
5120 wpa_s->p2p_group_common_freqs_num = 0; in wpas_p2p_deinit()
5128 * wpas_p2p_deinit_global - Deinitialize global P2P module
5137 wpa_s = global->ifaces; in wpas_p2p_deinit_global()
5139 wpas_p2p_service_flush(global->p2p_init_wpa_s); in wpas_p2p_deinit_global()
5142 while (wpa_s && wpa_s->p2p_group_interface != NOT_P2P_GROUP_INTERFACE) in wpas_p2p_deinit_global()
5143 wpa_s = wpa_s->next; in wpas_p2p_deinit_global()
5145 tmp = global->ifaces; in wpas_p2p_deinit_global()
5148 tmp->p2p_group_interface == NOT_P2P_GROUP_INTERFACE)) { in wpas_p2p_deinit_global()
5149 tmp = tmp->next; in wpas_p2p_deinit_global()
5161 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) { in wpas_p2p_deinit_global()
5162 if (wpa_s->ap_iface) in wpas_p2p_deinit_global()
5166 p2p_deinit(global->p2p); in wpas_p2p_deinit_global()
5167 global->p2p = NULL; in wpas_p2p_deinit_global()
5168 global->p2p_init_wpa_s = NULL; in wpas_p2p_deinit_global()
5174 if (wpa_s->conf->p2p_no_group_iface) in wpas_p2p_create_iface()
5176 if (wpa_s->drv_flags & in wpas_p2p_create_iface()
5181 if (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_CONCURRENT)) in wpas_p2p_create_iface()
5183 if (wpa_s->global->ifaces->next) in wpas_p2p_create_iface()
5185 if (wpa_s->wpa_state >= WPA_AUTHENTICATING) in wpas_p2p_create_iface()
5198 if (persistent_group && wpa_s->conf->persistent_reconnect) in wpas_p2p_start_go_neg()
5205 p2p_set_config_timeout(wpa_s->global->p2p, in wpas_p2p_start_go_neg()
5206 wpa_s->p2p_go_ht40 ? 255 : 100, 20); in wpas_p2p_start_go_neg()
5208 return p2p_connect(wpa_s->global->p2p, peer_addr, wps_method, in wpas_p2p_start_go_neg()
5210 persistent_group, ssid ? ssid->ssid : NULL, in wpas_p2p_start_go_neg()
5211 ssid ? ssid->ssid_len : 0, in wpas_p2p_start_go_neg()
5212 wpa_s->p2p_pd_before_go_neg, pref_freq, in wpas_p2p_start_go_neg()
5213 wps_method == WPS_NFC ? wpa_s->p2p_oob_dev_pw_id : in wpas_p2p_start_go_neg()
5225 if (persistent_group && wpa_s->conf->persistent_reconnect) in wpas_p2p_auth_go_neg()
5228 return p2p_authorize(wpa_s->global->p2p, peer_addr, wps_method, in wpas_p2p_auth_go_neg()
5230 persistent_group, ssid ? ssid->ssid : NULL, in wpas_p2p_auth_go_neg()
5231 ssid ? ssid->ssid_len : 0, pref_freq, in wpas_p2p_auth_go_neg()
5232 wps_method == WPS_NFC ? wpa_s->p2p_oob_dev_pw_id : in wpas_p2p_auth_go_neg()
5239 wpa_s->p2p_join_scan_count++; in wpas_p2p_check_join_scan_limit()
5241 wpa_s->p2p_join_scan_count); in wpas_p2p_check_join_scan_limit()
5242 if (wpa_s->p2p_join_scan_count > P2P_MAX_JOIN_SCAN_ATTEMPTS) { in wpas_p2p_check_join_scan_limit()
5244 " for join operationg - stop join attempt", in wpas_p2p_check_join_scan_limit()
5245 MAC2STR(wpa_s->pending_join_iface_addr)); in wpas_p2p_check_join_scan_limit()
5247 if (wpa_s->p2p_auto_pd) { in wpas_p2p_check_join_scan_limit()
5248 wpa_s->p2p_auto_pd = 0; in wpas_p2p_check_join_scan_limit()
5252 MAC2STR(wpa_s->pending_join_dev_addr)); in wpas_p2p_check_join_scan_limit()
5255 if (wpa_s->p2p_fallback_to_go_neg) { in wpas_p2p_check_join_scan_limit()
5257 "P2P: Join operation failed - fall back to GO Negotiation"); in wpas_p2p_check_join_scan_limit()
5258 wpa_msg_global(wpa_s->p2pdev, MSG_INFO, in wpas_p2p_check_join_scan_limit()
5260 "reason=join-failed"); in wpas_p2p_check_join_scan_limit()
5264 wpa_msg_global(wpa_s->p2pdev, MSG_INFO, in wpas_p2p_check_join_scan_limit()
5271 static int wpas_check_freq_conflict(struct wpa_supplicant *wpa_s, int freq) in wpas_check_freq_conflict() argument
5282 freqs = os_calloc(wpa_s->num_multichan_concurrent, in wpas_check_freq_conflict()
5288 wpa_s->num_multichan_concurrent); in wpas_check_freq_conflict()
5291 if (freqs[i].freq == freq) { in wpas_check_freq_conflict()
5293 freq); in wpas_check_freq_conflict()
5316 return -1; in wpas_p2p_peer_go()
5317 if (bss->last_update_idx < wpa_s->bss_update_idx) { in wpas_p2p_peer_go()
5323 updated = os_reltime_before(&wpa_s->p2p_auto_started, in wpas_p2p_peer_go()
5324 &bss->last_update); in wpas_p2p_peer_go()
5327 bss->last_update.sec, bss->last_update.usec, in wpas_p2p_peer_go()
5338 int freq; in wpas_p2p_scan_res_join() local
5343 if (wpa_s->global->p2p_disabled) in wpas_p2p_scan_res_join()
5347 scan_res ? (int) scan_res->num : -1, in wpas_p2p_scan_res_join()
5348 wpa_s->p2p_auto_join ? "auto_" : ""); in wpas_p2p_scan_res_join()
5353 if (wpa_s->p2p_auto_pd) { in wpas_p2p_scan_res_join()
5355 wpa_s->pending_join_dev_addr); in wpas_p2p_scan_res_join()
5357 wpa_s->auto_pd_scan_retry < P2P_AUTO_PD_SCAN_ATTEMPTS) { in wpas_p2p_scan_res_join()
5358 wpa_s->auto_pd_scan_retry++; in wpas_p2p_scan_res_join()
5360 wpa_s, wpa_s->pending_join_dev_addr); in wpas_p2p_scan_res_join()
5362 freq = bss->freq; in wpas_p2p_scan_res_join()
5365 wpa_s->auto_pd_scan_retry, in wpas_p2p_scan_res_join()
5366 MAC2STR(wpa_s-> in wpas_p2p_scan_res_join()
5368 freq); in wpas_p2p_scan_res_join()
5369 wpas_p2p_join_scan_req(wpa_s, freq, NULL, 0); in wpas_p2p_scan_res_join()
5377 wpa_s->p2p_auto_pd = 0; in wpas_p2p_scan_res_join()
5378 wpa_s->pending_pd_use = join ? AUTO_PD_JOIN : AUTO_PD_GO_NEG; in wpas_p2p_scan_res_join()
5380 MAC2STR(wpa_s->pending_join_dev_addr), join); in wpas_p2p_scan_res_join()
5381 if (p2p_prov_disc_req(wpa_s->global->p2p, in wpas_p2p_scan_res_join()
5382 wpa_s->pending_join_dev_addr, NULL, in wpas_p2p_scan_res_join()
5383 wpa_s->pending_pd_config_methods, join, in wpas_p2p_scan_res_join()
5384 0, wpa_s->user_initiated_pd) < 0) { in wpas_p2p_scan_res_join()
5385 wpa_s->p2p_auto_pd = 0; in wpas_p2p_scan_res_join()
5389 MAC2STR(wpa_s->pending_join_dev_addr)); in wpas_p2p_scan_res_join()
5394 if (wpa_s->p2p_auto_join) { in wpas_p2p_scan_res_join()
5396 wpa_s->pending_join_dev_addr); in wpas_p2p_scan_res_join()
5399 "running a GO -> use GO Negotiation"); in wpas_p2p_scan_res_join()
5400 wpa_msg_global(wpa_s->p2pdev, MSG_INFO, in wpas_p2p_scan_res_join()
5402 "reason=peer-not-running-GO"); in wpas_p2p_scan_res_join()
5403 wpas_p2p_connect(wpa_s, wpa_s->pending_join_dev_addr, in wpas_p2p_scan_res_join()
5404 wpa_s->p2p_pin, wpa_s->p2p_wps_method, in wpas_p2p_scan_res_join()
5405 wpa_s->p2p_persistent_group, 0, 0, 0, in wpas_p2p_scan_res_join()
5406 wpa_s->p2p_go_intent, in wpas_p2p_scan_res_join()
5407 wpa_s->p2p_connect_freq, in wpas_p2p_scan_res_join()
5408 wpa_s->p2p_go_vht_center_freq2, in wpas_p2p_scan_res_join()
5409 wpa_s->p2p_persistent_id, in wpas_p2p_scan_res_join()
5410 wpa_s->p2p_pd_before_go_neg, in wpas_p2p_scan_res_join()
5411 wpa_s->p2p_go_ht40, in wpas_p2p_scan_res_join()
5412 wpa_s->p2p_go_vht, in wpas_p2p_scan_res_join()
5413 wpa_s->p2p_go_max_oper_chwidth, in wpas_p2p_scan_res_join()
5414 wpa_s->p2p_go_he, in wpas_p2p_scan_res_join()
5415 wpa_s->p2p_go_edmg, in wpas_p2p_scan_res_join()
5417 is_p2p_allow_6ghz(wpa_s->global->p2p)); in wpas_p2p_scan_res_join()
5421 wpa_printf(MSG_DEBUG, "P2P: Peer was found running GO%s -> " in wpas_p2p_scan_res_join()
5425 wpa_msg_global(wpa_s->p2pdev, MSG_INFO, in wpas_p2p_scan_res_join()
5427 wpa_s->p2p_fallback_to_go_neg = 1; in wpas_p2p_scan_res_join()
5431 freq = p2p_get_oper_freq(wpa_s->global->p2p, in wpas_p2p_scan_res_join()
5432 wpa_s->pending_join_iface_addr); in wpas_p2p_scan_res_join()
5433 if (freq < 0 && in wpas_p2p_scan_res_join()
5434 p2p_get_interface_addr(wpa_s->global->p2p, in wpas_p2p_scan_res_join()
5435 wpa_s->pending_join_dev_addr, in wpas_p2p_scan_res_join()
5437 !ether_addr_equal(iface_addr, wpa_s->pending_join_dev_addr) && in wpas_p2p_scan_res_join()
5438 !wpa_bss_get_bssid(wpa_s, wpa_s->pending_join_iface_addr)) { in wpas_p2p_scan_res_join()
5442 MAC2STR(wpa_s->pending_join_iface_addr), in wpas_p2p_scan_res_join()
5444 os_memcpy(wpa_s->pending_join_iface_addr, iface_addr, in wpas_p2p_scan_res_join()
5447 freq = p2p_get_oper_freq(wpa_s->global->p2p, in wpas_p2p_scan_res_join()
5448 wpa_s->pending_join_iface_addr); in wpas_p2p_scan_res_join()
5450 if (freq >= 0) { in wpas_p2p_scan_res_join()
5452 "from P2P peer table: %d MHz", freq); in wpas_p2p_scan_res_join()
5454 if (wpa_s->p2p_join_ssid_len) { in wpas_p2p_scan_res_join()
5457 MAC2STR(wpa_s->pending_join_iface_addr), in wpas_p2p_scan_res_join()
5458 wpa_ssid_txt(wpa_s->p2p_join_ssid, in wpas_p2p_scan_res_join()
5459 wpa_s->p2p_join_ssid_len)); in wpas_p2p_scan_res_join()
5460 bss = wpa_bss_get(wpa_s, wpa_s->pending_join_iface_addr, in wpas_p2p_scan_res_join()
5461 wpa_s->p2p_join_ssid, in wpas_p2p_scan_res_join()
5462 wpa_s->p2p_join_ssid_len); in wpas_p2p_scan_res_join()
5465 MACSTR, MAC2STR(wpa_s->pending_join_iface_addr)); in wpas_p2p_scan_res_join()
5467 wpa_s->pending_join_iface_addr); in wpas_p2p_scan_res_join()
5472 freq = bss->freq; in wpas_p2p_scan_res_join()
5474 "from BSS table: %d MHz (SSID %s)", freq, in wpas_p2p_scan_res_join()
5475 wpa_ssid_txt(bss->ssid, bss->ssid_len)); in wpas_p2p_scan_res_join()
5476 if (p2p_parse_dev_addr(wpa_bss_ie_ptr(bss), bss->ie_len, in wpas_p2p_scan_res_join()
5478 ether_addr_equal(wpa_s->pending_join_dev_addr, in wpas_p2p_scan_res_join()
5479 wpa_s->pending_join_iface_addr) && in wpas_p2p_scan_res_join()
5480 !ether_addr_equal(dev_addr, wpa_s->pending_join_dev_addr)) { in wpas_p2p_scan_res_join()
5484 MAC2STR(wpa_s->pending_join_dev_addr)); in wpas_p2p_scan_res_join()
5485 os_memcpy(wpa_s->pending_join_dev_addr, dev_addr, in wpas_p2p_scan_res_join()
5489 if (freq > 0) { in wpas_p2p_scan_res_join()
5492 if (wpas_check_freq_conflict(wpa_s, freq) > 0) { in wpas_p2p_scan_res_join()
5493 wpa_msg_global(wpa_s->p2pdev, MSG_INFO, in wpas_p2p_scan_res_join()
5503 " freq=%u MHz)", in wpas_p2p_scan_res_join()
5504 MAC2STR(wpa_s->pending_join_dev_addr), freq); in wpas_p2p_scan_res_join()
5505 wpa_s->pending_pd_before_join = 1; in wpas_p2p_scan_res_join()
5507 switch (wpa_s->pending_join_wps_method) { in wpas_p2p_scan_res_join()
5525 if ((p2p_get_provisioning_info(wpa_s->global->p2p, in wpas_p2p_scan_res_join()
5526 wpa_s->pending_join_dev_addr) == in wpas_p2p_scan_res_join()
5533 "with " MACSTR " already done - proceed to " in wpas_p2p_scan_res_join()
5535 MAC2STR(wpa_s->pending_join_dev_addr)); in wpas_p2p_scan_res_join()
5536 wpa_s->pending_pd_before_join = 0; in wpas_p2p_scan_res_join()
5540 if (p2p_prov_disc_req(wpa_s->global->p2p, in wpas_p2p_scan_res_join()
5541 wpa_s->pending_join_dev_addr, in wpas_p2p_scan_res_join()
5543 freq, wpa_s->user_initiated_pd) < 0) { in wpas_p2p_scan_res_join()
5547 wpa_s->pending_pd_before_join = 0; in wpas_p2p_scan_res_join()
5553 wpa_printf(MSG_DEBUG, "P2P: Failed to find BSS/GO - try again later"); in wpas_p2p_scan_res_join()
5561 wpas_p2p_join_start(wpa_s, 0, wpa_s->p2p_join_ssid, in wpas_p2p_scan_res_join()
5562 wpa_s->p2p_join_ssid_len); in wpas_p2p_scan_res_join()
5566 static void wpas_p2p_join_scan_req(struct wpa_supplicant *wpa_s, int freq, in wpas_p2p_join_scan_req() argument
5583 os_memcpy(wpa_s->p2p_join_ssid, ssid, ssid_len); in wpas_p2p_join_scan_req()
5584 wpa_s->p2p_join_ssid_len = ssid_len; in wpas_p2p_join_scan_req()
5588 wpa_s->p2p_join_ssid_len = 0; in wpas_p2p_join_scan_req()
5591 wpa_s->wps->dev.p2p = 1; in wpas_p2p_join_scan_req()
5592 wps_ie = wps_build_probe_req_ie(DEV_PW_DEFAULT, &wpa_s->wps->dev, in wpas_p2p_join_scan_req()
5593 wpa_s->wps->uuid, WPS_REQ_ENROLLEE, 0, in wpas_p2p_join_scan_req()
5600 if (!freq) { in wpas_p2p_join_scan_req()
5603 * If freq is not provided, check the operating freq of the GO in wpas_p2p_join_scan_req()
5606 oper_freq = p2p_get_oper_freq(wpa_s->global->p2p, in wpas_p2p_join_scan_req()
5607 wpa_s->pending_join_iface_addr); in wpas_p2p_join_scan_req()
5609 freq = oper_freq; in wpas_p2p_join_scan_req()
5611 if (freq > 0) { in wpas_p2p_join_scan_req()
5612 freqs[0] = freq; in wpas_p2p_join_scan_req()
5618 ielen = p2p_scan_ie_buf_len(wpa_s->global->p2p); in wpas_p2p_join_scan_req()
5629 p2p_scan_ie(wpa_s->global->p2p, ies, NULL, bands); in wpas_p2p_join_scan_req()
5635 if (wpa_s->clear_driver_scan_cache) { in wpas_p2p_join_scan_req()
5649 os_get_reltime(&wpa_s->scan_trigger_time); in wpas_p2p_join_scan_req()
5650 wpa_s->scan_res_handler = wpas_p2p_scan_res_join; in wpas_p2p_join_scan_req()
5651 wpa_s->own_scan_requested = 1; in wpas_p2p_join_scan_req()
5652 wpa_s->clear_driver_scan_cache = 0; in wpas_p2p_join_scan_req()
5658 wpa_printf(MSG_DEBUG, "P2P: Failed to start scan for join - " in wpas_p2p_join_scan_req()
5688 wpa_s->p2p_auto_pd = 0; in wpas_p2p_join()
5689 wpa_s->p2p_auto_join = !!auto_join; in wpas_p2p_join()
5690 os_memcpy(wpa_s->pending_join_iface_addr, iface_addr, ETH_ALEN); in wpas_p2p_join()
5691 os_memcpy(wpa_s->pending_join_dev_addr, dev_addr, ETH_ALEN); in wpas_p2p_join()
5692 wpa_s->pending_join_wps_method = wps_method; in wpas_p2p_join()
5697 wpa_s->p2p_join_scan_count = 0; in wpas_p2p_join()
5703 static int wpas_p2p_join_start(struct wpa_supplicant *wpa_s, int freq, in wpas_p2p_join_start() argument
5712 return -1; in wpas_p2p_join_start()
5714 os_memcpy(group->p2p_pin, wpa_s->p2p_pin, in wpas_p2p_join_start()
5715 sizeof(group->p2p_pin)); in wpas_p2p_join_start()
5716 group->p2p_wps_method = wpa_s->p2p_wps_method; in wpas_p2p_join_start()
5722 * to allow p2p_cancel stop a pending p2p_connect-join. in wpas_p2p_join_start()
5726 if (group == wpa_s->parent) in wpas_p2p_join_start()
5727 wpa_s->global->p2p_group_formation = group; in wpas_p2p_join_start()
5729 group->p2p_in_provisioning = 1; in wpas_p2p_join_start()
5730 group->p2p_fallback_to_go_neg = wpa_s->p2p_fallback_to_go_neg; in wpas_p2p_join_start()
5733 os_memcpy(res.peer_device_addr, wpa_s->pending_join_dev_addr, ETH_ALEN); in wpas_p2p_join_start()
5734 os_memcpy(res.peer_interface_addr, wpa_s->pending_join_iface_addr, in wpas_p2p_join_start()
5736 res.wps_method = wpa_s->pending_join_wps_method; in wpas_p2p_join_start()
5737 if (freq && ssid && ssid_len) { in wpas_p2p_join_start()
5738 res.freq = freq; in wpas_p2p_join_start()
5743 bss = wpa_bss_get(wpa_s, wpa_s->pending_join_iface_addr, in wpas_p2p_join_start()
5747 wpa_s, wpa_s->pending_join_iface_addr); in wpas_p2p_join_start()
5750 res.freq = bss->freq; in wpas_p2p_join_start()
5751 res.ssid_len = bss->ssid_len; in wpas_p2p_join_start()
5752 os_memcpy(res.ssid, bss->ssid, bss->ssid_len); in wpas_p2p_join_start()
5754 bss->freq, in wpas_p2p_join_start()
5755 wpa_ssid_txt(bss->ssid, bss->ssid_len)); in wpas_p2p_join_start()
5764 if (wpa_s->off_channel_freq || wpa_s->roc_waiting_drv_freq) { in wpas_p2p_join_start()
5765 wpa_printf(MSG_DEBUG, "P2P: Cancel remain-on-channel prior to " in wpas_p2p_join_start()
5768 wpa_s->off_channel_freq = 0; in wpas_p2p_join_start()
5769 wpa_s->roc_waiting_drv_freq = 0; in wpas_p2p_join_start()
5774 * Allow a longer timeout for join-a-running-group than normal 15 in wpas_p2p_join_start()
5786 static int wpas_p2p_setup_freqs(struct wpa_supplicant *wpa_s, int freq, in wpas_p2p_setup_freqs() argument
5798 freqs = os_calloc(wpa_s->num_multichan_concurrent, in wpas_p2p_setup_freqs()
5801 return -1; in wpas_p2p_setup_freqs()
5804 wpa_s->num_multichan_concurrent); in wpas_p2p_setup_freqs()
5814 "P2P: Setup freqs: freq=%d num_MCC=%d shared_freqs=%u num_unused=%d", in wpas_p2p_setup_freqs()
5815 freq, wpa_s->num_multichan_concurrent, num, num_unused); in wpas_p2p_setup_freqs()
5817 if (freq > 0) { in wpas_p2p_setup_freqs()
5820 ret = p2p_supported_freq(wpa_s->global->p2p, freq); in wpas_p2p_setup_freqs()
5822 ret = p2p_supported_freq_cli(wpa_s->global->p2p, freq); in wpas_p2p_setup_freqs()
5824 if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD) && in wpas_p2p_setup_freqs()
5825 ieee80211_is_dfs(freq, wpa_s->hw.modes, in wpas_p2p_setup_freqs()
5826 wpa_s->hw.num_modes)) { in wpas_p2p_setup_freqs()
5828 * If freq is a DFS channel and DFS is offloaded in wpas_p2p_setup_freqs()
5833 freq); in wpas_p2p_setup_freqs()
5837 freq); in wpas_p2p_setup_freqs()
5838 res = -3; in wpas_p2p_setup_freqs()
5844 if (freqs[i].freq == freq) in wpas_p2p_setup_freqs()
5850 freq); in wpas_p2p_setup_freqs()
5851 res = -2; in wpas_p2p_setup_freqs()
5855 "requested channel (%u MHz)", freq); in wpas_p2p_setup_freqs()
5856 *force_freq = freq; in wpas_p2p_setup_freqs()
5862 if (!wpa_s->conf->num_p2p_pref_chan && *pref_freq == 0) { in wpas_p2p_setup_freqs()
5891 res = -2; in wpas_p2p_setup_freqs()
5906 if (wpa_s->conf->p2p_6ghz_disable || in is_p2p_6ghz_supported()
5907 !get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes, in is_p2p_6ghz_supported()
5911 if (!p2p_wfd_enabled(wpa_s->global->p2p)) in is_p2p_6ghz_supported()
5913 if (peer_addr && !p2p_peer_wfd_enabled(wpa_s->global->p2p, peer_addr)) in is_p2p_6ghz_supported()
5921 const u8 *peer_addr, bool allow_6ghz, int freq) in wpas_p2p_check_6ghz() argument
5926 p2p_set_6ghz_dev_capab(wpa_s->global->p2p, true); in wpas_p2p_check_6ghz()
5928 if (is_6ghz_freq(freq)) in wpas_p2p_check_6ghz()
5929 return -2; in wpas_p2p_check_6ghz()
5930 p2p_set_6ghz_dev_capab(wpa_s->global->p2p, false); in wpas_p2p_check_6ghz()
5938 * wpas_p2p_connect - Request P2P Group Formation to be started
5943 * @auto_join: Whether to select join vs. GO Negotiation automatically
5948 * @go_intent: GO Intent or -1 to use default
5949 * @freq: Frequency for the group or 0 for auto-selection
5952 * parameters or -1 to generate new values (SSID/passphrase)
5962 * Returns: 0 or new PIN (if pin was %NULL) on success, -1 on unspecified
5963 * failure, -2 on failure due to channel not currently available,
5964 * -3 if forced channel is not supported
5969 int go_intent, int freq, unsigned int vht_center_freq2, in wpas_p2p_connect() argument
5983 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL) in wpas_p2p_connect()
5984 return -1; in wpas_p2p_connect()
5987 ssid = wpa_config_get_network(wpa_s->conf, persistent_id); in wpas_p2p_connect()
5988 if (ssid == NULL || ssid->disabled != 2 || in wpas_p2p_connect()
5989 ssid->mode != WPAS_MODE_P2P_GO) in wpas_p2p_connect()
5990 return -1; in wpas_p2p_connect()
5993 if (wpas_p2p_check_6ghz(wpa_s, peer_addr, allow_6ghz, freq)) in wpas_p2p_connect()
5994 return -2; in wpas_p2p_connect()
5996 os_free(wpa_s->global->add_psk); in wpas_p2p_connect()
5997 wpa_s->global->add_psk = NULL; in wpas_p2p_connect()
5999 wpa_s->global->p2p_fail_on_wps_complete = 0; in wpas_p2p_connect()
6000 wpa_s->global->pending_p2ps_group = 0; in wpas_p2p_connect()
6001 wpa_s->global->pending_p2ps_group_freq = 0; in wpas_p2p_connect()
6002 wpa_s->p2ps_method_config_any = 0; in wpas_p2p_connect()
6005 go_intent = wpa_s->conf->p2p_go_intent; in wpas_p2p_connect()
6008 wpa_s->global->p2p_long_listen = 0; in wpas_p2p_connect()
6010 wpa_s->p2p_wps_method = wps_method; in wpas_p2p_connect()
6011 wpa_s->p2p_persistent_group = !!persistent_group; in wpas_p2p_connect()
6012 wpa_s->p2p_persistent_id = persistent_id; in wpas_p2p_connect()
6013 wpa_s->p2p_go_intent = go_intent; in wpas_p2p_connect()
6014 wpa_s->p2p_connect_freq = freq; in wpas_p2p_connect()
6015 wpa_s->p2p_fallback_to_go_neg = 0; in wpas_p2p_connect()
6016 wpa_s->p2p_pd_before_go_neg = !!pd; in wpas_p2p_connect()
6017 wpa_s->p2p_go_ht40 = !!ht40; in wpas_p2p_connect()
6018 wpa_s->p2p_go_vht = !!vht; in wpas_p2p_connect()
6019 wpa_s->p2p_go_vht_center_freq2 = vht_center_freq2; in wpas_p2p_connect()
6020 wpa_s->p2p_go_max_oper_chwidth = vht_chwidth; in wpas_p2p_connect()
6021 wpa_s->p2p_go_he = !!he; in wpas_p2p_connect()
6022 wpa_s->p2p_go_edmg = !!edmg; in wpas_p2p_connect()
6025 os_strlcpy(wpa_s->p2p_pin, pin, sizeof(wpa_s->p2p_pin)); in wpas_p2p_connect()
6028 return -1; in wpas_p2p_connect()
6029 res = os_snprintf(wpa_s->p2p_pin, sizeof(wpa_s->p2p_pin), in wpas_p2p_connect()
6031 if (os_snprintf_error(sizeof(wpa_s->p2p_pin), res)) in wpas_p2p_connect()
6032 wpa_s->p2p_pin[sizeof(wpa_s->p2p_pin) - 1] = '\0'; in wpas_p2p_connect()
6034 wpa_s->p2p_pin); in wpas_p2p_connect()
6037 os_strlcpy(wpa_s->p2p_pin, "12345670", sizeof(wpa_s->p2p_pin)); in wpas_p2p_connect()
6039 wpa_s->p2p_pin[0] = '\0'; in wpas_p2p_connect()
6047 os_memcpy(wpa_s->p2p_auth_invite, peer_addr, ETH_ALEN); in wpas_p2p_connect()
6051 if (p2p_get_interface_addr(wpa_s->global->p2p, peer_addr, in wpas_p2p_connect()
6054 p2p_get_dev_addr(wpa_s->global->p2p, peer_addr, in wpas_p2p_connect()
6058 os_get_reltime(&wpa_s->p2p_auto_started); in wpas_p2p_connect()
6061 wpa_s->p2p_auto_started.sec, in wpas_p2p_connect()
6062 wpa_s->p2p_auto_started.usec); in wpas_p2p_connect()
6064 wpa_s->user_initiated_pd = 1; in wpas_p2p_connect()
6066 auto_join, freq, in wpas_p2p_connect()
6068 return -1; in wpas_p2p_connect()
6073 res = wpas_p2p_setup_freqs(wpa_s, freq, &force_freq, &pref_freq, in wpas_p2p_connect()
6080 p2p_set_own_pref_freq_list(wpa_s->global->p2p, pref_freq_list, size); in wpas_p2p_connect()
6082 wpa_s->create_p2p_iface = wpas_p2p_create_iface(wpa_s); in wpas_p2p_connect()
6084 if (wpa_s->create_p2p_iface) { in wpas_p2p_connect()
6092 return -1; in wpas_p2p_connect()
6095 if_addr = wpa_s->pending_interface_addr; in wpas_p2p_connect()
6097 if (wpa_s->p2p_mgmt) in wpas_p2p_connect()
6098 if_addr = wpa_s->parent->own_addr; in wpas_p2p_connect()
6100 if_addr = wpa_s->own_addr; in wpas_p2p_connect()
6101 os_memset(wpa_s->go_dev_addr, 0, ETH_ALEN); in wpas_p2p_connect()
6109 return -1; in wpas_p2p_connect()
6116 if (wpa_s->create_p2p_iface) in wpas_p2p_connect()
6118 return -1; in wpas_p2p_connect()
6125 * wpas_p2p_remain_on_channel_cb - Indication of remain-on-channel start
6127 * @freq: Frequency of the channel in MHz
6131 * requested remain-on-channel duration.
6134 unsigned int freq, unsigned int duration) in wpas_p2p_remain_on_channel_cb() argument
6136 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL) in wpas_p2p_remain_on_channel_cb()
6138 …printf(MSG_DEBUG, "P2P: remain-on-channel callback (off_channel_freq=%u pending_listen_freq=%d roc… in wpas_p2p_remain_on_channel_cb()
6139 wpa_s->off_channel_freq, wpa_s->pending_listen_freq, in wpas_p2p_remain_on_channel_cb()
6140 wpa_s->roc_waiting_drv_freq, freq, duration); in wpas_p2p_remain_on_channel_cb()
6141 if (wpa_s->off_channel_freq && in wpas_p2p_remain_on_channel_cb()
6142 wpa_s->off_channel_freq == wpa_s->pending_listen_freq) { in wpas_p2p_remain_on_channel_cb()
6143 p2p_listen_cb(wpa_s->global->p2p, wpa_s->pending_listen_freq, in wpas_p2p_remain_on_channel_cb()
6144 wpa_s->pending_listen_duration); in wpas_p2p_remain_on_channel_cb()
6145 wpa_s->pending_listen_freq = 0; in wpas_p2p_remain_on_channel_cb()
6147 …wpa_printf(MSG_DEBUG, "P2P: Ignore remain-on-channel callback (off_channel_freq=%u pending_listen_… in wpas_p2p_remain_on_channel_cb()
6148 wpa_s->off_channel_freq, wpa_s->pending_listen_freq, in wpas_p2p_remain_on_channel_cb()
6149 freq, duration); in wpas_p2p_remain_on_channel_cb()
6157 if (timeout > wpa_s->max_remain_on_chan) in wpas_p2p_listen_start()
6158 timeout = wpa_s->max_remain_on_chan; in wpas_p2p_listen_start()
6160 return p2p_listen(wpa_s->global->p2p, timeout); in wpas_p2p_listen_start()
6165 * wpas_p2p_cancel_remain_on_channel_cb - Remain-on-channel timeout
6167 * @freq: Frequency of the channel in MHz
6169 * This callback is called when the driver indicates that a remain-on-channel
6174 unsigned int freq) in wpas_p2p_cancel_remain_on_channel_cb() argument
6176 wpa_printf(MSG_DEBUG, "P2P: Cancel remain-on-channel callback " in wpas_p2p_cancel_remain_on_channel_cb()
6178 wpa_s->global->p2p_long_listen, in wpas_p2p_cancel_remain_on_channel_cb()
6181 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL) in wpas_p2p_cancel_remain_on_channel_cb()
6183 if (wpa_s->global->p2p_long_listen > 0) in wpas_p2p_cancel_remain_on_channel_cb()
6184 wpa_s->global->p2p_long_listen -= wpa_s->max_remain_on_chan; in wpas_p2p_cancel_remain_on_channel_cb()
6185 if (p2p_listen_end(wpa_s->global->p2p, freq) > 0) in wpas_p2p_cancel_remain_on_channel_cb()
6189 if (wpa_s->global->p2p_long_listen > 0) { in wpas_p2p_cancel_remain_on_channel_cb()
6191 wpas_p2p_listen_start(wpa_s, wpa_s->global->p2p_long_listen); in wpas_p2p_cancel_remain_on_channel_cb()
6197 p2p_stop_listen(wpa_s->global->p2p); in wpas_p2p_cancel_remain_on_channel_cb()
6203 * wpas_p2p_group_remove - Remove a P2P group
6207 * Returns: 0 on success, -1 on failure
6217 struct wpa_global *global = wpa_s->global; in wpas_p2p_group_remove()
6224 wpa_s = global->ifaces; in wpas_p2p_group_remove()
6227 wpa_s = wpa_s->next; in wpas_p2p_group_remove()
6228 if (prev->p2p_group_interface != in wpas_p2p_group_remove()
6230 (prev->current_ssid && in wpas_p2p_group_remove()
6231 prev->current_ssid->p2p_group)) { in wpas_p2p_group_remove()
6239 (calling_wpa_s->p2p_group_interface != in wpas_p2p_group_remove()
6241 (calling_wpa_s->current_ssid && in wpas_p2p_group_remove()
6242 calling_wpa_s->current_ssid->p2p_group))) { in wpas_p2p_group_remove()
6251 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) { in wpas_p2p_group_remove()
6252 if (os_strcmp(wpa_s->ifname, ifname) == 0) in wpas_p2p_group_remove()
6260 static int wpas_p2p_select_go_freq(struct wpa_supplicant *wpa_s, int freq) in wpas_p2p_select_go_freq() argument
6264 if (!wpa_s->conf->num_p2p_pref_chan && !freq) { in wpas_p2p_select_go_freq()
6271 if (!res && size > 0 && !is_p2p_allow_6ghz(wpa_s->global->p2p)) in wpas_p2p_select_go_freq()
6277 (!p2p_supported_freq(wpa_s->global->p2p, in wpas_p2p_select_go_freq()
6278 pref_freq_list[i].freq) || in wpas_p2p_select_go_freq()
6280 wpa_s->global, in wpas_p2p_select_go_freq()
6281 pref_freq_list[i].freq) || in wpas_p2p_select_go_freq()
6286 i, pref_freq_list[i].freq); in wpas_p2p_select_go_freq()
6290 freq = pref_freq_list[i].freq; in wpas_p2p_select_go_freq()
6293 i, freq); in wpas_p2p_select_go_freq()
6304 if (freq == 2) { in wpas_p2p_select_go_freq()
6307 if (wpa_s->best_24_freq > 0 && in wpas_p2p_select_go_freq()
6308 p2p_supported_freq_go(wpa_s->global->p2p, in wpas_p2p_select_go_freq()
6309 wpa_s->best_24_freq)) { in wpas_p2p_select_go_freq()
6310 freq = wpa_s->best_24_freq; in wpas_p2p_select_go_freq()
6312 "channel: %d MHz", freq); in wpas_p2p_select_go_freq()
6315 return -1; in wpas_p2p_select_go_freq()
6316 freq = 2412 + (r % 3) * 25; in wpas_p2p_select_go_freq()
6318 "channel: %d MHz", freq); in wpas_p2p_select_go_freq()
6322 if (freq == 5) { in wpas_p2p_select_go_freq()
6325 if (wpa_s->best_5_freq > 0 && in wpas_p2p_select_go_freq()
6326 p2p_supported_freq_go(wpa_s->global->p2p, in wpas_p2p_select_go_freq()
6327 wpa_s->best_5_freq)) { in wpas_p2p_select_go_freq()
6328 freq = wpa_s->best_5_freq; in wpas_p2p_select_go_freq()
6330 "channel: %d MHz", freq); in wpas_p2p_select_go_freq()
6341 return -1; in wpas_p2p_select_go_freq()
6351 freq = freqs[r % num_freqs]; in wpas_p2p_select_go_freq()
6352 if (p2p_supported_freq_go(wpa_s->global->p2p, in wpas_p2p_select_go_freq()
6353 freq)) in wpas_p2p_select_go_freq()
6358 wpa_printf(MSG_DEBUG, "P2P: Could not select " in wpas_p2p_select_go_freq()
6360 return -1; in wpas_p2p_select_go_freq()
6363 "channel: %d MHz", freq); in wpas_p2p_select_go_freq()
6367 if (freq > 0 && !p2p_supported_freq_go(wpa_s->global->p2p, freq)) { in wpas_p2p_select_go_freq()
6368 if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD) && in wpas_p2p_select_go_freq()
6369 ieee80211_is_dfs(freq, wpa_s->hw.modes, in wpas_p2p_select_go_freq()
6370 wpa_s->hw.num_modes)) { in wpas_p2p_select_go_freq()
6372 * If freq is a DFS channel and DFS is offloaded to the in wpas_p2p_select_go_freq()
6377 __func__, freq); in wpas_p2p_select_go_freq()
6378 return freq; in wpas_p2p_select_go_freq()
6382 freq); in wpas_p2p_select_go_freq()
6383 return -1; in wpas_p2p_select_go_freq()
6386 return freq; in wpas_p2p_select_go_freq()
6392 int freq) in wpas_p2p_supported_freq_go() argument
6394 if (!wpas_p2p_disallowed_freq(wpa_s->global, freq) && in wpas_p2p_supported_freq_go()
6395 p2p_supported_freq_go(wpa_s->global->p2p, freq) && in wpas_p2p_supported_freq_go()
6396 freq_included(wpa_s, channels, freq)) in wpas_p2p_supported_freq_go()
6410 params->freq = 5180 + i * 20; in wpas_p2p_select_go_freq_no_pref()
6411 if (wpas_p2p_supported_freq_go(wpa_s, channels, params->freq)) in wpas_p2p_select_go_freq_no_pref()
6417 params->freq = 5745 + i * 20; in wpas_p2p_select_go_freq_no_pref()
6418 if (wpas_p2p_supported_freq_go(wpa_s, channels, params->freq)) in wpas_p2p_select_go_freq_no_pref()
6423 params->freq = 58320 + 1 * 2160; in wpas_p2p_select_go_freq_no_pref()
6424 if (wpas_p2p_supported_freq_go(wpa_s, channels, params->freq)) in wpas_p2p_select_go_freq_no_pref()
6429 params->freq = 58320 + i * 2160; in wpas_p2p_select_go_freq_no_pref()
6430 if (wpas_p2p_supported_freq_go(wpa_s, channels, params->freq)) in wpas_p2p_select_go_freq_no_pref()
6439 params->freq = 2412 + ((r + i) % 3) * 25; in wpas_p2p_select_go_freq_no_pref()
6440 if (wpas_p2p_supported_freq_go(wpa_s, channels, params->freq)) in wpas_p2p_select_go_freq_no_pref()
6446 params->freq = 2412 + i * 5; in wpas_p2p_select_go_freq_no_pref()
6449 if (params->freq == 2412 || in wpas_p2p_select_go_freq_no_pref()
6450 params->freq == 2437 || in wpas_p2p_select_go_freq_no_pref()
6451 params->freq == 2462) in wpas_p2p_select_go_freq_no_pref()
6454 if (wpas_p2p_supported_freq_go(wpa_s, channels, params->freq)) in wpas_p2p_select_go_freq_no_pref()
6458 params->freq = 0; in wpas_p2p_select_go_freq_no_pref()
6462 wpa_printf(MSG_DEBUG, "P2P: Set GO freq %d MHz (no preference known)", in wpas_p2p_select_go_freq_no_pref()
6463 params->freq); in wpas_p2p_select_go_freq_no_pref()
6482 int freq, int vht_center_freq2, int ht40, in wpas_p2p_init_go_params() argument
6494 params->role_go = 1; in wpas_p2p_init_go_params()
6495 params->ht40 = ht40; in wpas_p2p_init_go_params()
6496 params->vht = vht; in wpas_p2p_init_go_params()
6497 params->he = he; in wpas_p2p_init_go_params()
6498 params->max_oper_chwidth = max_oper_chwidth; in wpas_p2p_init_go_params()
6499 params->vht_center_freq2 = vht_center_freq2; in wpas_p2p_init_go_params()
6500 params->edmg = edmg; in wpas_p2p_init_go_params()
6502 freqs = os_calloc(wpa_s->num_multichan_concurrent, in wpas_p2p_init_go_params()
6505 return -1; in wpas_p2p_init_go_params()
6508 wpa_s->num_multichan_concurrent, in wpas_p2p_init_go_params()
6511 if (wpa_s->current_ssid && in wpas_p2p_init_go_params()
6512 wpa_s->current_ssid->mode == WPAS_MODE_P2P_GO && in wpas_p2p_init_go_params()
6513 wpa_s->wpa_state == WPA_COMPLETED) { in wpas_p2p_init_go_params()
6519 * is not sharing a frequency, allow to select a new frequency in wpas_p2p_init_go_params()
6521 * move the P2P GO so its frequency can be re-used. in wpas_p2p_init_go_params()
6524 if (freqs[i].freq == wpa_s->current_ssid->frequency && in wpas_p2p_init_go_params()
6533 if (params->edmg) { in wpas_p2p_init_go_params()
6536 params->edmg = 0; in wpas_p2p_init_go_params()
6539 /* try using the forced freq */ in wpas_p2p_init_go_params()
6540 if (freq) { in wpas_p2p_init_go_params()
6541 if (wpas_p2p_disallowed_freq(wpa_s->global, freq) || in wpas_p2p_init_go_params()
6542 !freq_included(wpa_s, channels, freq)) { in wpas_p2p_init_go_params()
6544 "P2P: Forced GO freq %d MHz disallowed", in wpas_p2p_init_go_params()
6545 freq); in wpas_p2p_init_go_params()
6548 if (!p2p_supported_freq_go(wpa_s->global->p2p, freq)) { in wpas_p2p_init_go_params()
6549 if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD) && in wpas_p2p_init_go_params()
6550 ieee80211_is_dfs(freq, wpa_s->hw.modes, in wpas_p2p_init_go_params()
6551 wpa_s->hw.num_modes)) { in wpas_p2p_init_go_params()
6553 * If freq is a DFS channel and DFS is offloaded in wpas_p2p_init_go_params()
6558 __func__, freq); in wpas_p2p_init_go_params()
6562 freq); in wpas_p2p_init_go_params()
6568 if (freqs[i].freq == freq) { in wpas_p2p_init_go_params()
6570 "P2P: forced freq (%d MHz) is also shared", in wpas_p2p_init_go_params()
6571 freq); in wpas_p2p_init_go_params()
6572 params->freq = freq; in wpas_p2p_init_go_params()
6579 "P2P: Cannot force GO on freq (%d MHz) as all the channels are in use", in wpas_p2p_init_go_params()
6580 freq); in wpas_p2p_init_go_params()
6585 "P2P: force GO freq (%d MHz) on a free channel", in wpas_p2p_init_go_params()
6586 freq); in wpas_p2p_init_go_params()
6587 params->freq = freq; in wpas_p2p_init_go_params()
6593 (!wpa_s->conf->p2p_ignore_shared_freq || !unused_channels)) { in wpas_p2p_init_go_params()
6597 "P2P: Use shared freq (%d MHz) for GO", in wpas_p2p_init_go_params()
6599 params->freq = cand; in wpas_p2p_init_go_params()
6606 freqs[i].freq)) { in wpas_p2p_init_go_params()
6608 "P2P: Use shared freq (%d MHz) for GO", in wpas_p2p_init_go_params()
6609 freqs[i].freq); in wpas_p2p_init_go_params()
6610 params->freq = freqs[i].freq; in wpas_p2p_init_go_params()
6623 if (wpa_s->conf->p2p_oper_reg_class == 81 && in wpas_p2p_init_go_params()
6624 wpa_s->conf->p2p_oper_channel >= 1 && in wpas_p2p_init_go_params()
6625 wpa_s->conf->p2p_oper_channel <= 11 && in wpas_p2p_init_go_params()
6628 2407 + 5 * wpa_s->conf->p2p_oper_channel)) { in wpas_p2p_init_go_params()
6629 params->freq = 2407 + 5 * wpa_s->conf->p2p_oper_channel; in wpas_p2p_init_go_params()
6630 wpa_printf(MSG_DEBUG, "P2P: Set GO freq based on configured " in wpas_p2p_init_go_params()
6631 "frequency %d MHz", params->freq); in wpas_p2p_init_go_params()
6635 if ((wpa_s->conf->p2p_oper_reg_class == 115 || in wpas_p2p_init_go_params()
6636 wpa_s->conf->p2p_oper_reg_class == 116 || in wpas_p2p_init_go_params()
6637 wpa_s->conf->p2p_oper_reg_class == 117 || in wpas_p2p_init_go_params()
6638 wpa_s->conf->p2p_oper_reg_class == 124 || in wpas_p2p_init_go_params()
6639 wpa_s->conf->p2p_oper_reg_class == 125 || in wpas_p2p_init_go_params()
6640 wpa_s->conf->p2p_oper_reg_class == 126 || in wpas_p2p_init_go_params()
6641 wpa_s->conf->p2p_oper_reg_class == 127) && in wpas_p2p_init_go_params()
6644 5 * wpa_s->conf->p2p_oper_channel)) { in wpas_p2p_init_go_params()
6645 params->freq = 5000 + 5 * wpa_s->conf->p2p_oper_channel; in wpas_p2p_init_go_params()
6646 wpa_printf(MSG_DEBUG, "P2P: Set GO freq based on configured " in wpas_p2p_init_go_params()
6647 "frequency %d MHz", params->freq); in wpas_p2p_init_go_params()
6652 if (wpa_s->conf->p2p_oper_channel == 0 && in wpas_p2p_init_go_params()
6653 wpa_s->best_overall_freq > 0 && in wpas_p2p_init_go_params()
6655 wpa_s->best_overall_freq)) { in wpas_p2p_init_go_params()
6656 params->freq = wpa_s->best_overall_freq; in wpas_p2p_init_go_params()
6657 wpa_printf(MSG_DEBUG, "P2P: Set GO freq based on best overall " in wpas_p2p_init_go_params()
6658 "channel %d MHz", params->freq); in wpas_p2p_init_go_params()
6662 if (wpa_s->conf->p2p_oper_channel == 0 && in wpas_p2p_init_go_params()
6663 wpa_s->best_24_freq > 0 && in wpas_p2p_init_go_params()
6665 wpa_s->best_24_freq)) { in wpas_p2p_init_go_params()
6666 params->freq = wpa_s->best_24_freq; in wpas_p2p_init_go_params()
6667 wpa_printf(MSG_DEBUG, "P2P: Set GO freq based on best 2.4 GHz " in wpas_p2p_init_go_params()
6668 "channel %d MHz", params->freq); in wpas_p2p_init_go_params()
6672 if (wpa_s->conf->p2p_oper_channel == 0 && in wpas_p2p_init_go_params()
6673 wpa_s->best_5_freq > 0 && in wpas_p2p_init_go_params()
6675 wpa_s->best_5_freq)) { in wpas_p2p_init_go_params()
6676 params->freq = wpa_s->best_5_freq; in wpas_p2p_init_go_params()
6677 wpa_printf(MSG_DEBUG, "P2P: Set GO freq based on best 5 GHz " in wpas_p2p_init_go_params()
6678 "channel %d MHz", params->freq); in wpas_p2p_init_go_params()
6683 cand = p2p_get_pref_freq(wpa_s->global->p2p, channels); in wpas_p2p_init_go_params()
6685 params->freq = cand; in wpas_p2p_init_go_params()
6686 wpa_printf(MSG_DEBUG, "P2P: Set GO freq %d MHz from preferred " in wpas_p2p_init_go_params()
6687 "channels", params->freq); in wpas_p2p_init_go_params()
6692 if (wpa_s->hw.modes && wpa_s->p2p_group_common_freqs) { in wpas_p2p_init_go_params()
6693 for (i = 0; i < wpa_s->p2p_group_common_freqs_num; i++) { in wpas_p2p_init_go_params()
6699 cand = wpa_s->p2p_group_common_freqs[i]; in wpas_p2p_init_go_params()
6702 hwmode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes, in wpas_p2p_init_go_params()
6709 params->freq = cand; in wpas_p2p_init_go_params()
6711 "P2P: Use freq %d MHz common with the peer and allowing VHT80", in wpas_p2p_init_go_params()
6712 params->freq); in wpas_p2p_init_go_params()
6720 if (wpa_s->current_ssid && wpa_s->hw.modes && in wpas_p2p_init_go_params()
6721 wpa_s->p2p_group_common_freqs) { in wpas_p2p_init_go_params()
6722 for (i = 0; i < wpa_s->p2p_group_common_freqs_num; i++) { in wpas_p2p_init_go_params()
6729 cand = wpa_s->p2p_group_common_freqs[i]; in wpas_p2p_init_go_params()
6731 hwmode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes, in wpas_p2p_init_go_params()
6733 if (!wpas_same_band(wpa_s->current_ssid->frequency, in wpas_p2p_init_go_params()
6744 cand, -1, CONF_OPER_CHWIDTH_USE_HT, in wpas_p2p_init_go_params()
6764 params->freq = cand; in wpas_p2p_init_go_params()
6766 "P2P: Use freq %d MHz common with the peer, allowing HT40, and maintaining same band", in wpas_p2p_init_go_params()
6767 params->freq); in wpas_p2p_init_go_params()
6775 if (wpa_s->current_ssid && wpa_s->p2p_group_common_freqs) { in wpas_p2p_init_go_params()
6776 for (i = 0; i < wpa_s->p2p_group_common_freqs_num; i++) { in wpas_p2p_init_go_params()
6777 cand = wpa_s->p2p_group_common_freqs[i]; in wpas_p2p_init_go_params()
6778 if (!wpas_same_band(wpa_s->current_ssid->frequency, in wpas_p2p_init_go_params()
6782 params->freq = cand; in wpas_p2p_init_go_params()
6784 "P2P: Use freq %d MHz common with the peer and maintaining same band", in wpas_p2p_init_go_params()
6785 params->freq); in wpas_p2p_init_go_params()
6792 if (wpa_s->p2p_group_common_freqs) { in wpas_p2p_init_go_params()
6793 for (i = 0; i < wpa_s->p2p_group_common_freqs_num; i++) { in wpas_p2p_init_go_params()
6794 cand = wpa_s->p2p_group_common_freqs[i]; in wpas_p2p_init_go_params()
6796 params->freq = cand; in wpas_p2p_init_go_params()
6798 "P2P: Use freq %d MHz common with the peer", in wpas_p2p_init_go_params()
6799 params->freq); in wpas_p2p_init_go_params()
6805 /* no preference, select some channel */ in wpas_p2p_init_go_params()
6808 if (params->freq == 0) { in wpas_p2p_init_go_params()
6809 wpa_printf(MSG_DEBUG, "P2P: did not find a freq for GO use"); in wpas_p2p_init_go_params()
6818 return -1; in wpas_p2p_init_go_params()
6829 if (wpa_s->p2p_mgmt) { in wpas_p2p_get_group_iface()
6835 wpa_s->parent->p2pdev = wpa_s; in wpas_p2p_get_group_iface()
6836 wpa_s = wpa_s->parent; in wpas_p2p_get_group_iface()
6840 wpa_s->p2p_first_connection_timeout = 0; in wpas_p2p_get_group_iface()
6841 if (wpa_s != wpa_s->p2pdev) in wpas_p2p_get_group_iface()
6842 wpas_p2p_clone_config(wpa_s, wpa_s->p2pdev); in wpas_p2p_get_group_iface()
6860 if (go && wpa_s->p2p_go_do_acs) { in wpas_p2p_get_group_iface()
6861 group_wpa_s->p2p_go_do_acs = wpa_s->p2p_go_do_acs; in wpas_p2p_get_group_iface()
6862 group_wpa_s->p2p_go_acs_band = wpa_s->p2p_go_acs_band; in wpas_p2p_get_group_iface()
6863 wpa_s->p2p_go_do_acs = 0; in wpas_p2p_get_group_iface()
6866 if (go && wpa_s->p2p_go_allow_dfs) { in wpas_p2p_get_group_iface()
6867 group_wpa_s->p2p_go_allow_dfs = wpa_s->p2p_go_allow_dfs; in wpas_p2p_get_group_iface()
6868 wpa_s->p2p_go_allow_dfs = 0; in wpas_p2p_get_group_iface()
6872 group_wpa_s->ifname); in wpas_p2p_get_group_iface()
6873 group_wpa_s->p2p_first_connection_timeout = 0; in wpas_p2p_get_group_iface()
6879 * wpas_p2p_group_add - Add a new P2P group with local end as Group Owner
6882 * @freq: Frequency for the group or 0 to indicate no hardcoding
6889 * Returns: 0 on success, -1 on failure
6895 int freq, int vht_center_freq2, int ht40, int vht, in wpas_p2p_group_add() argument
6902 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL) in wpas_p2p_group_add()
6903 return -1; in wpas_p2p_group_add()
6904 if (wpas_p2p_check_6ghz(wpa_s, NULL, allow_6ghz, freq)) in wpas_p2p_group_add()
6905 return -1; in wpas_p2p_group_add()
6907 os_free(wpa_s->global->add_psk); in wpas_p2p_group_add()
6908 wpa_s->global->add_psk = NULL; in wpas_p2p_group_add()
6911 wpa_printf(MSG_DEBUG, "P2P: Stop any on-going P2P FIND"); in wpas_p2p_group_add()
6914 if (!wpa_s->p2p_go_do_acs) { in wpas_p2p_group_add()
6915 selected_freq = wpas_p2p_select_go_freq(wpa_s, freq); in wpas_p2p_group_add()
6917 return -1; in wpas_p2p_group_add()
6924 return -1; in wpas_p2p_group_add()
6926 p2p_go_params(wpa_s->global->p2p, ¶ms); in wpas_p2p_group_add()
6931 return -1; in wpas_p2p_group_add()
6932 if (freq > 0) in wpas_p2p_group_add()
6933 wpa_s->p2p_go_no_pri_sec_switch = 1; in wpas_p2p_group_add()
6942 int freq, int force_scan, int retry_limit, in wpas_start_p2p_client() argument
6951 return -1; in wpas_start_p2p_client()
6953 os_get_reltime(&wpa_s->scan_min_time); in wpas_start_p2p_client()
6954 wpa_s->p2p_last_4way_hs_fail = NULL; in wpas_start_p2p_client()
6958 ssid = wpa_config_add_network(wpa_s->conf); in wpas_start_p2p_client()
6960 return -1; in wpas_start_p2p_client()
6961 os_memset(wpa_s->go_dev_addr, 0, ETH_ALEN); in wpas_start_p2p_client()
6963 ssid->temporary = 1; in wpas_start_p2p_client()
6964 ssid->proto = WPA_PROTO_RSN; in wpas_start_p2p_client()
6965 ssid->pbss = params->pbss; in wpas_start_p2p_client()
6966 ssid->pairwise_cipher = params->pbss ? WPA_CIPHER_GCMP : in wpas_start_p2p_client()
6968 ssid->group_cipher = params->pbss ? WPA_CIPHER_GCMP : WPA_CIPHER_CCMP; in wpas_start_p2p_client()
6969 ssid->key_mgmt = WPA_KEY_MGMT_PSK; in wpas_start_p2p_client()
6970 if (is_6ghz_freq(freq) && in wpas_start_p2p_client()
6971 is_p2p_6ghz_capable(wpa_s->global->p2p)) { in wpas_start_p2p_client()
6972 ssid->auth_alg |= WPA_AUTH_ALG_SAE; in wpas_start_p2p_client()
6973 ssid->key_mgmt |= WPA_KEY_MGMT_SAE; in wpas_start_p2p_client()
6974 ssid->ieee80211w = MGMT_FRAME_PROTECTION_OPTIONAL; in wpas_start_p2p_client()
6975 ssid->sae_pwe = SAE_PWE_HASH_TO_ELEMENT; in wpas_start_p2p_client()
6980 ssid->ssid = os_malloc(params->ssid_len); in wpas_start_p2p_client()
6981 if (ssid->ssid == NULL) { in wpas_start_p2p_client()
6982 wpa_config_remove_network(wpa_s->conf, ssid->id); in wpas_start_p2p_client()
6983 return -1; in wpas_start_p2p_client()
6985 os_memcpy(ssid->ssid, params->ssid, params->ssid_len); in wpas_start_p2p_client()
6986 ssid->ssid_len = params->ssid_len; in wpas_start_p2p_client()
6987 ssid->p2p_group = 1; in wpas_start_p2p_client()
6988 ssid->export_keys = 1; in wpas_start_p2p_client()
6989 if (params->psk_set) { in wpas_start_p2p_client()
6990 os_memcpy(ssid->psk, params->psk, 32); in wpas_start_p2p_client()
6991 ssid->psk_set = 1; in wpas_start_p2p_client()
6993 if (params->passphrase) in wpas_start_p2p_client()
6994 ssid->passphrase = os_strdup(params->passphrase); in wpas_start_p2p_client()
6997 ssid->bssid_set = 1; in wpas_start_p2p_client()
6998 os_memcpy(ssid->bssid, go_bssid, ETH_ALEN); in wpas_start_p2p_client()
7001 wpa_s->show_group_started = 1; in wpas_start_p2p_client()
7002 wpa_s->p2p_in_invitation = 1; in wpas_start_p2p_client()
7003 wpa_s->p2p_retry_limit = retry_limit; in wpas_start_p2p_client()
7004 wpa_s->p2p_invite_go_freq = freq; in wpas_start_p2p_client()
7005 wpa_s->p2p_go_group_formation_completed = 0; in wpas_start_p2p_client()
7006 wpa_s->global->p2p_group_formation = wpa_s; in wpas_start_p2p_client()
7016 dl_list_for_each(ifs, &wpa_s->radio->ifaces, struct wpa_supplicant, in wpas_start_p2p_client()
7020 if (!other_iface_found || os_reltime_before(&wpa_s->last_scan, in wpas_start_p2p_client()
7021 &ifs->last_scan)) { in wpas_start_p2p_client()
7023 wpa_s->last_scan.sec = ifs->last_scan.sec; in wpas_start_p2p_client()
7024 wpa_s->last_scan.usec = ifs->last_scan.usec; in wpas_start_p2p_client()
7028 eloop_cancel_timeout(wpas_p2p_group_formation_timeout, wpa_s->p2pdev, in wpas_start_p2p_client()
7032 wpa_s->p2pdev, NULL); in wpas_start_p2p_client()
7051 int go = 0, freq; in wpas_p2p_group_add_persistent() local
7053 if (ssid->disabled != 2 || ssid->ssid == NULL) in wpas_p2p_group_add_persistent()
7054 return -1; in wpas_p2p_group_add_persistent()
7056 if (wpas_get_p2p_group(wpa_s, ssid->ssid, ssid->ssid_len, &go) && in wpas_p2p_group_add_persistent()
7057 go == (ssid->mode == WPAS_MODE_P2P_GO)) { in wpas_p2p_group_add_persistent()
7062 wpa_s->p2pdev, NULL)) { in wpas_p2p_group_add_persistent()
7075 wpa_s->p2pdev, NULL); in wpas_p2p_group_add_persistent()
7080 os_free(wpa_s->global->add_psk); in wpas_p2p_group_add_persistent()
7081 wpa_s->global->add_psk = NULL; in wpas_p2p_group_add_persistent()
7086 wpa_s->p2p_fallback_to_go_neg = 0; in wpas_p2p_group_add_persistent()
7088 if (ssid->mode == WPAS_MODE_P2P_GO) { in wpas_p2p_group_add_persistent()
7090 freq = wpas_p2p_select_go_freq(wpa_s, force_freq); in wpas_p2p_group_add_persistent()
7091 if (freq < 0) in wpas_p2p_group_add_persistent()
7092 return -1; in wpas_p2p_group_add_persistent()
7093 wpa_s->p2p_go_no_pri_sec_switch = 1; in wpas_p2p_group_add_persistent()
7095 freq = wpas_p2p_select_go_freq(wpa_s, neg_freq); in wpas_p2p_group_add_persistent()
7096 if (freq < 0 || in wpas_p2p_group_add_persistent()
7097 (freq > 0 && !freq_included(wpa_s, channels, freq))) in wpas_p2p_group_add_persistent()
7098 freq = 0; in wpas_p2p_group_add_persistent()
7100 } else if (ssid->mode == WPAS_MODE_INFRA) { in wpas_p2p_group_add_persistent()
7101 freq = neg_freq; in wpas_p2p_group_add_persistent()
7102 if (freq <= 0 || !freq_included(wpa_s, channels, freq)) { in wpas_p2p_group_add_persistent()
7105 wpa_bss_get_p2p_dev_addr(wpa_s, ssid->bssid); in wpas_p2p_group_add_persistent()
7109 !os_reltime_expired(&now, &bss->last_update, 5) && in wpas_p2p_group_add_persistent()
7110 freq_included(wpa_s, channels, bss->freq)) in wpas_p2p_group_add_persistent()
7111 freq = bss->freq; in wpas_p2p_group_add_persistent()
7113 freq = 0; in wpas_p2p_group_add_persistent()
7116 return wpas_start_p2p_client(wpa_s, ssid, addr_allocated, freq, in wpas_p2p_group_add_persistent()
7119 return -1; in wpas_p2p_group_add_persistent()
7122 if (wpas_p2p_init_go_params(wpa_s, ¶ms, freq, vht_center_freq2, in wpas_p2p_group_add_persistent()
7125 return -1; in wpas_p2p_group_add_persistent()
7128 params.psk_set = ssid->psk_set; in wpas_p2p_group_add_persistent()
7130 os_memcpy(params.psk, ssid->psk, sizeof(params.psk)); in wpas_p2p_group_add_persistent()
7131 if (ssid->passphrase) { in wpas_p2p_group_add_persistent()
7132 if (os_strlen(ssid->passphrase) >= sizeof(params.passphrase)) { in wpas_p2p_group_add_persistent()
7135 return -1; in wpas_p2p_group_add_persistent()
7137 os_strlcpy(params.passphrase, ssid->passphrase, in wpas_p2p_group_add_persistent()
7140 os_memcpy(params.ssid, ssid->ssid, ssid->ssid_len); in wpas_p2p_group_add_persistent()
7141 params.ssid_len = ssid->ssid_len; in wpas_p2p_group_add_persistent()
7146 return -1; in wpas_p2p_group_add_persistent()
7150 wpa_s->p2p_first_connection_timeout = connection_timeout; in wpas_p2p_group_add_persistent()
7161 if (wpa_s->ap_iface) { in wpas_p2p_ie_update()
7162 struct hostapd_data *hapd = wpa_s->ap_iface->bss[0]; in wpas_p2p_ie_update()
7163 if (!(hapd->conf->p2p & P2P_GROUP_OWNER)) { in wpas_p2p_ie_update()
7169 wpabuf_free(hapd->p2p_beacon_ie); in wpas_p2p_ie_update()
7170 hapd->p2p_beacon_ie = beacon_ies; in wpas_p2p_ie_update()
7172 wpabuf_free(hapd->p2p_probe_resp_ie); in wpas_p2p_ie_update()
7173 hapd->p2p_probe_resp_ie = proberesp_ies; in wpas_p2p_ie_update()
7185 if (!wpa_s->ap_iface) in wpas_p2p_idle_update()
7187 wpa_printf(MSG_DEBUG, "P2P: GO - group %sidle", idle ? "" : "not "); in wpas_p2p_idle_update()
7189 if (wpa_s->global->p2p_fail_on_wps_complete && in wpas_p2p_idle_update()
7190 wpa_s->p2p_in_provisioning) { in wpas_p2p_idle_update()
7206 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL || in wpas_p2p_group_init()
7207 !ssid->p2p_group) in wpas_p2p_group_init()
7214 if (ssid->p2p_persistent_group && wpa_s->conf->persistent_reconnect) in wpas_p2p_group_init()
7215 cfg->persistent_group = 2; in wpas_p2p_group_init()
7216 else if (ssid->p2p_persistent_group) in wpas_p2p_group_init()
7217 cfg->persistent_group = 1; in wpas_p2p_group_init()
7218 os_memcpy(cfg->interface_addr, wpa_s->own_addr, ETH_ALEN); in wpas_p2p_group_init()
7219 if (wpa_s->max_stations && in wpas_p2p_group_init()
7220 wpa_s->max_stations < wpa_s->conf->max_num_sta) in wpas_p2p_group_init()
7221 cfg->max_clients = wpa_s->max_stations; in wpas_p2p_group_init()
7223 cfg->max_clients = wpa_s->conf->max_num_sta; in wpas_p2p_group_init()
7224 os_memcpy(cfg->ssid, ssid->ssid, ssid->ssid_len); in wpas_p2p_group_init()
7225 cfg->ssid_len = ssid->ssid_len; in wpas_p2p_group_init()
7226 cfg->freq = ssid->frequency; in wpas_p2p_group_init()
7227 cfg->cb_ctx = wpa_s; in wpas_p2p_group_init()
7228 cfg->ie_update = wpas_p2p_ie_update; in wpas_p2p_group_init()
7229 cfg->idle_update = wpas_p2p_idle_update; in wpas_p2p_group_init()
7230 cfg->ip_addr_alloc = WPA_GET_BE32(wpa_s->p2pdev->conf->ip_addr_start) in wpas_p2p_group_init()
7233 group = p2p_group_init(wpa_s->global->p2p, cfg); in wpas_p2p_group_init()
7236 if (ssid->mode != WPAS_MODE_P2P_GROUP_FORMATION) in wpas_p2p_group_init()
7238 wpa_s->p2p_group = group; in wpas_p2p_group_init()
7246 struct wpa_ssid *ssid = wpa_s->current_ssid; in wpas_p2p_wps_success()
7248 if (!wpa_s->p2p_in_provisioning) { in wpas_p2p_wps_success()
7249 wpa_printf(MSG_DEBUG, "P2P: Ignore WPS success event - P2P " in wpas_p2p_wps_success()
7254 if (ssid && ssid->mode == WPAS_MODE_INFRA) { in wpas_p2p_wps_success()
7256 os_memcpy(go_dev_addr, wpa_s->bssid, ETH_ALEN); in wpas_p2p_wps_success()
7257 wpas_p2p_persistent_group(wpa_s, go_dev_addr, ssid->ssid, in wpas_p2p_wps_success()
7258 ssid->ssid_len); in wpas_p2p_wps_success()
7260 p2p_clear_provisioning_info(wpa_s->global->p2p, go_dev_addr); in wpas_p2p_wps_success()
7263 eloop_cancel_timeout(wpas_p2p_group_formation_timeout, wpa_s->p2pdev, in wpas_p2p_wps_success()
7265 wpa_s->p2p_go_group_formation_completed = 1; in wpas_p2p_wps_success()
7266 if (ssid && ssid->mode == WPAS_MODE_INFRA) { in wpas_p2p_wps_success()
7274 "P2P: Re-start group formation timeout (%d seconds) as client for initial connection", in wpas_p2p_wps_success()
7278 wpa_s->p2pdev, NULL); in wpas_p2p_wps_success()
7280 wpa_s->p2p_go_group_formation_completed = 0; in wpas_p2p_wps_success()
7288 "P2P: Re-start group formation timeout (%d seconds) as GO for initial connection", in wpas_p2p_wps_success()
7292 wpa_s->p2pdev, NULL); in wpas_p2p_wps_success()
7296 wpa_s->p2p_go_group_formation_completed = 0; in wpas_p2p_wps_success()
7298 if (wpa_s->global->p2p) in wpas_p2p_wps_success()
7299 p2p_wps_success_cb(wpa_s->global->p2p, peer_addr); in wpas_p2p_wps_success()
7307 if (!wpa_s->p2p_in_provisioning) { in wpas_p2p_wps_failed()
7308 wpa_printf(MSG_DEBUG, "P2P: Ignore WPS fail event - P2P " in wpas_p2p_wps_failed()
7313 if (wpa_s->go_params) { in wpas_p2p_wps_failed()
7315 wpa_s->global->p2p, in wpas_p2p_wps_failed()
7316 wpa_s->go_params->peer_device_addr); in wpas_p2p_wps_failed()
7321 if (wpa_s == wpa_s->global->p2p_group_formation) { in wpas_p2p_wps_failed()
7327 …wpa_printf(MSG_DEBUG, "P2P: WPS step failed during group formation - reject connection from timeou… in wpas_p2p_wps_failed()
7328 wpa_s->global->p2p_fail_on_wps_complete = 1; in wpas_p2p_wps_failed()
7331 wpa_s->p2pdev, NULL); in wpas_p2p_wps_failed()
7338 if (!wpa_s->global->p2p_fail_on_wps_complete || in wpas_p2p_wps_eapol_cb()
7339 !wpa_s->p2p_in_provisioning) in wpas_p2p_wps_eapol_cb()
7355 wpa_s->global->pending_p2ps_group = 0; in wpas_p2p_prov_disc()
7356 wpa_s->global->pending_p2ps_group_freq = 0; in wpas_p2p_prov_disc()
7357 wpa_s->p2p_fallback_to_go_neg = 0; in wpas_p2p_prov_disc()
7358 wpa_s->pending_pd_use = NORMAL_PD; in wpas_p2p_prov_disc()
7360 p2ps_prov->conncap = p2ps_group_capability( in wpas_p2p_prov_disc()
7361 wpa_s, P2PS_SETUP_NONE, p2ps_prov->role, in wpas_p2p_prov_disc()
7362 &p2ps_prov->force_freq, &p2ps_prov->pref_freq); in wpas_p2p_prov_disc()
7365 "P2P: %s conncap: %d - ASP parsed: %x %x %d %s", in wpas_p2p_prov_disc()
7366 __func__, p2ps_prov->conncap, in wpas_p2p_prov_disc()
7367 p2ps_prov->adv_id, p2ps_prov->conncap, in wpas_p2p_prov_disc()
7368 p2ps_prov->status, p2ps_prov->info); in wpas_p2p_prov_disc()
7381 return -1; in wpas_p2p_prov_disc()
7385 os_memcpy(wpa_s->pending_join_dev_addr, peer_addr, ETH_ALEN); in wpas_p2p_prov_disc()
7386 wpa_s->pending_pd_config_methods = config_methods; in wpas_p2p_prov_disc()
7387 wpa_s->p2p_auto_pd = 1; in wpas_p2p_prov_disc()
7388 wpa_s->p2p_auto_join = 0; in wpas_p2p_prov_disc()
7389 wpa_s->pending_pd_before_join = 0; in wpas_p2p_prov_disc()
7390 wpa_s->auto_pd_scan_retry = 0; in wpas_p2p_prov_disc()
7392 wpa_s->p2p_join_scan_count = 0; in wpas_p2p_prov_disc()
7393 os_get_reltime(&wpa_s->p2p_auto_started); in wpas_p2p_prov_disc()
7395 wpa_s->p2p_auto_started.sec, in wpas_p2p_prov_disc()
7396 wpa_s->p2p_auto_started.usec); in wpas_p2p_prov_disc()
7401 if (wpa_s->global->p2p == NULL || wpa_s->global->p2p_disabled) { in wpas_p2p_prov_disc()
7403 return -1; in wpas_p2p_prov_disc()
7406 return p2p_prov_disc_req(wpa_s->global->p2p, peer_addr, p2ps_prov, in wpas_p2p_prov_disc()
7425 if (wpa_s->p2p_send_action_work) { in wpas_p2p_clear_pending_action_tx()
7444 u8 seek_cnt, const char **seek_string, int freq, in wpas_p2p_find() argument
7448 wpa_s->global->p2p_long_listen = 0; in wpas_p2p_find()
7450 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL || in wpas_p2p_find()
7451 wpa_s->p2p_in_provisioning) { in wpas_p2p_find()
7453 (wpa_s->global->p2p_disabled || !wpa_s->global->p2p) ? in wpas_p2p_find()
7455 wpa_s->p2p_in_provisioning ? in wpas_p2p_find()
7457 return -1; in wpas_p2p_find()
7462 return p2p_find(wpa_s->global->p2p, timeout, type, in wpas_p2p_find()
7464 search_delay, seek_cnt, seek_string, freq, in wpas_p2p_find()
7474 if (wpa_s->p2p_scan_work) { in wpas_p2p_scan_res_ignore_search()
7475 struct wpa_radio_work *work = wpa_s->p2p_scan_work; in wpas_p2p_scan_res_ignore_search()
7476 wpa_s->p2p_scan_work = NULL; in wpas_p2p_scan_res_ignore_search()
7480 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL) in wpas_p2p_scan_res_ignore_search()
7494 wpa_s->global->p2p_long_listen = 0; in wpas_p2p_stop_find_oper()
7498 if (wpa_s->global->p2p) in wpas_p2p_stop_find_oper()
7499 p2p_stop_find(wpa_s->global->p2p); in wpas_p2p_stop_find_oper()
7501 if (wpa_s->scan_res_handler == wpas_p2p_scan_res_handler) { in wpas_p2p_stop_find_oper()
7504 wpa_s->scan_res_handler = wpas_p2p_scan_res_ignore_search; in wpas_p2p_stop_find_oper()
7512 if (!wpa_s->global->pending_group_iface_for_p2ps) in wpas_p2p_stop_find()
7520 wpa_s->global->p2p_long_listen = 0; in wpas_p2p_long_listen_timeout()
7528 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL) in wpas_p2p_listen()
7529 return -1; in wpas_p2p_listen()
7531 if (wpa_s->p2p_lo_started) { in wpas_p2p_listen()
7534 return -1; in wpas_p2p_listen()
7549 wpa_s->global->p2p_long_listen = 0; in wpas_p2p_listen()
7553 * remain-on-channel operation while the driver is still running the in wpas_p2p_listen()
7556 if (wpa_s->global->p2p) in wpas_p2p_listen()
7557 p2p_stop_find(wpa_s->global->p2p); in wpas_p2p_listen()
7560 if (res == 0 && timeout * 1000 > wpa_s->max_remain_on_chan) { in wpas_p2p_listen()
7561 wpa_s->global->p2p_long_listen = timeout * 1000; in wpas_p2p_listen()
7577 if (wpa_s->global->p2p_disabled) in wpas_p2p_assoc_req_ie()
7578 return -1; in wpas_p2p_assoc_req_ie()
7583 if (wpa_s->conf->p2p_disabled && p2p_group) in wpas_p2p_assoc_req_ie()
7584 return -1; in wpas_p2p_assoc_req_ie()
7585 if (wpa_s->global->p2p == NULL) in wpas_p2p_assoc_req_ie()
7586 return -1; in wpas_p2p_assoc_req_ie()
7588 return -1; in wpas_p2p_assoc_req_ie()
7591 ret = p2p_assoc_req_ie(wpa_s->global->p2p, bss->bssid, buf, len, in wpas_p2p_assoc_req_ie()
7604 if (wpa_s->global->p2p_disabled) in wpas_p2p_probe_req_rx()
7606 if (wpa_s->global->p2p == NULL) in wpas_p2p_probe_req_rx()
7609 switch (p2p_probe_req_rx(wpa_s->global->p2p, addr, dst, bssid, in wpas_p2p_probe_req_rx()
7610 ie, ie_len, rx_freq, wpa_s->p2p_lo_started)) { in wpas_p2p_probe_req_rx()
7628 u8 category, const u8 *data, size_t len, int freq) in wpas_p2p_rx_action() argument
7630 if (wpa_s->global->p2p_disabled) in wpas_p2p_rx_action()
7632 if (wpa_s->global->p2p == NULL) in wpas_p2p_rx_action()
7635 p2p_rx_action(wpa_s->global->p2p, da, sa, bssid, category, data, len, in wpas_p2p_rx_action()
7636 freq); in wpas_p2p_rx_action()
7644 if (wpa_s->global->p2p_disabled) in wpas_p2p_scan_ie()
7646 if (wpa_s->global->p2p == NULL) in wpas_p2p_scan_ie()
7650 p2p_scan_ie(wpa_s->global->p2p, ies, NULL, bands); in wpas_p2p_scan_ie()
7656 p2p_group_deinit(wpa_s->p2p_group); in wpas_p2p_group_deinit()
7657 wpa_s->p2p_group = NULL; in wpas_p2p_group_deinit()
7659 wpa_s->ap_configured_cb = NULL; in wpas_p2p_group_deinit()
7660 wpa_s->ap_configured_cb_ctx = NULL; in wpas_p2p_group_deinit()
7661 wpa_s->ap_configured_cb_data = NULL; in wpas_p2p_group_deinit()
7662 wpa_s->connect_without_scan = NULL; in wpas_p2p_group_deinit()
7668 wpa_s->global->p2p_long_listen = 0; in wpas_p2p_reject()
7670 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL) in wpas_p2p_reject()
7671 return -1; in wpas_p2p_reject()
7673 return p2p_reject(wpa_s->global->p2p, addr); in wpas_p2p_reject()
7679 struct wpa_ssid *ssid, const u8 *go_dev_addr, int freq, in wpas_p2p_invite() argument
7691 if (wpas_p2p_check_6ghz(wpa_s, NULL, allow_6ghz, freq)) in wpas_p2p_invite()
7692 return -1; in wpas_p2p_invite()
7694 wpa_s->global->p2p_invite_group = NULL; in wpas_p2p_invite()
7696 os_memcpy(wpa_s->p2p_auth_invite, peer_addr, ETH_ALEN); in wpas_p2p_invite()
7698 os_memset(wpa_s->p2p_auth_invite, 0, ETH_ALEN); in wpas_p2p_invite()
7700 wpa_s->p2p_persistent_go_freq = freq; in wpas_p2p_invite()
7701 wpa_s->p2p_go_ht40 = !!ht40; in wpas_p2p_invite()
7702 wpa_s->p2p_go_vht = !!vht; in wpas_p2p_invite()
7703 wpa_s->p2p_go_he = !!he; in wpas_p2p_invite()
7704 wpa_s->p2p_go_max_oper_chwidth = max_chwidth; in wpas_p2p_invite()
7705 wpa_s->p2p_go_vht_center_freq2 = vht_center_freq2; in wpas_p2p_invite()
7706 wpa_s->p2p_go_edmg = !!edmg; in wpas_p2p_invite()
7707 if (ssid->mode == WPAS_MODE_P2P_GO) { in wpas_p2p_invite()
7712 return -1; in wpas_p2p_invite()
7720 return -1; in wpas_p2p_invite()
7722 bssid = wpa_s->pending_interface_addr; in wpas_p2p_invite()
7723 } else if (wpa_s->p2p_mgmt) in wpas_p2p_invite()
7724 bssid = wpa_s->parent->own_addr; in wpas_p2p_invite()
7726 bssid = wpa_s->own_addr; in wpas_p2p_invite()
7729 peer_addr = ssid->bssid; in wpas_p2p_invite()
7731 wpa_s->pending_invite_ssid_id = ssid->id; in wpas_p2p_invite()
7734 res = wpas_p2p_setup_freqs(wpa_s, freq, &force_freq, &pref_freq, in wpas_p2p_invite()
7740 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL) in wpas_p2p_invite()
7741 return -1; in wpas_p2p_invite()
7743 p2p_set_own_pref_freq_list(wpa_s->global->p2p, pref_freq_list, size); in wpas_p2p_invite()
7745 if (wpa_s->parent->conf->p2p_ignore_shared_freq && in wpas_p2p_invite()
7747 wpa_s->num_multichan_concurrent > 1 && in wpas_p2p_invite()
7760 return p2p_invite(wpa_s->global->p2p, peer_addr, role, bssid, in wpas_p2p_invite()
7761 ssid->ssid, ssid->ssid_len, force_freq, go_dev_addr, in wpas_p2p_invite()
7762 1, pref_freq, -1); in wpas_p2p_invite()
7771 struct wpa_global *global = wpa_s->global; in wpas_p2p_invite_group()
7776 int freq = 0, force_freq = 0, pref_freq = 0; in wpas_p2p_invite_group() local
7781 wpa_s->p2p_persistent_go_freq = 0; in wpas_p2p_invite_group()
7782 wpa_s->p2p_go_ht40 = 0; in wpas_p2p_invite_group()
7783 wpa_s->p2p_go_vht = 0; in wpas_p2p_invite_group()
7784 wpa_s->p2p_go_vht_center_freq2 = 0; in wpas_p2p_invite_group()
7785 wpa_s->p2p_go_max_oper_chwidth = 0; in wpas_p2p_invite_group()
7786 wpa_s->p2p_go_edmg = 0; in wpas_p2p_invite_group()
7788 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) { in wpas_p2p_invite_group()
7789 if (os_strcmp(wpa_s->ifname, ifname) == 0) in wpas_p2p_invite_group()
7794 return -1; in wpas_p2p_invite_group()
7797 ssid = wpa_s->current_ssid; in wpas_p2p_invite_group()
7801 return -1; in wpas_p2p_invite_group()
7804 wpa_s->global->p2p_invite_group = wpa_s; in wpas_p2p_invite_group()
7805 persistent = ssid->p2p_persistent_group && in wpas_p2p_invite_group()
7806 wpas_p2p_get_persistent(wpa_s->p2pdev, peer_addr, in wpas_p2p_invite_group()
7807 ssid->ssid, ssid->ssid_len); in wpas_p2p_invite_group()
7809 if (ssid->mode == WPAS_MODE_P2P_GO) { in wpas_p2p_invite_group()
7811 bssid = wpa_s->own_addr; in wpas_p2p_invite_group()
7813 go_dev_addr = wpa_s->global->p2p_dev_addr; in wpas_p2p_invite_group()
7814 freq = ssid->frequency; in wpas_p2p_invite_group()
7817 if (wpa_s->wpa_state < WPA_ASSOCIATED) { in wpas_p2p_invite_group()
7818 wpa_printf(MSG_DEBUG, "P2P: Not associated - cannot " in wpas_p2p_invite_group()
7820 return -1; in wpas_p2p_invite_group()
7822 bssid = wpa_s->bssid; in wpas_p2p_invite_group()
7824 !is_zero_ether_addr(wpa_s->go_dev_addr)) in wpas_p2p_invite_group()
7825 go_dev_addr = wpa_s->go_dev_addr; in wpas_p2p_invite_group()
7826 freq = wpa_s->current_bss ? wpa_s->current_bss->freq : in wpas_p2p_invite_group()
7827 (int) wpa_s->assoc_freq; in wpas_p2p_invite_group()
7829 wpa_s->p2pdev->pending_invite_ssid_id = -1; in wpas_p2p_invite_group()
7831 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL) in wpas_p2p_invite_group()
7832 return -1; in wpas_p2p_invite_group()
7833 if (wpas_p2p_check_6ghz(wpa_s, peer_addr, allow_6ghz, freq)) in wpas_p2p_invite_group()
7834 return -1; in wpas_p2p_invite_group()
7837 res = wpas_p2p_setup_freqs(wpa_s, freq, &force_freq, &pref_freq, in wpas_p2p_invite_group()
7844 return p2p_invite(wpa_s->global->p2p, peer_addr, role, bssid, in wpas_p2p_invite_group()
7845 ssid->ssid, ssid->ssid_len, force_freq, in wpas_p2p_invite_group()
7846 go_dev_addr, persistent, pref_freq, -1); in wpas_p2p_invite_group()
7852 struct wpa_ssid *ssid = wpa_s->current_ssid; in wpas_p2p_completed()
7855 int freq; in wpas_p2p_completed() local
7859 if (ssid == NULL || ssid->mode != WPAS_MODE_P2P_GROUP_FORMATION) { in wpas_p2p_completed()
7861 wpa_s->p2pdev, NULL); in wpas_p2p_completed()
7864 if (!wpa_s->show_group_started || !ssid) in wpas_p2p_completed()
7867 wpa_s->show_group_started = 0; in wpas_p2p_completed()
7868 if (!wpa_s->p2p_go_group_formation_completed && in wpas_p2p_completed()
7869 wpa_s->global->p2p_group_formation == wpa_s) { in wpas_p2p_completed()
7872 wpa_s->p2p_go_group_formation_completed = 1; in wpas_p2p_completed()
7873 wpa_s->global->p2p_group_formation = NULL; in wpas_p2p_completed()
7874 wpa_s->p2p_in_provisioning = 0; in wpas_p2p_completed()
7875 wpa_s->p2p_in_invitation = 0; in wpas_p2p_completed()
7876 wpa_s->p2p_retry_limit = 0; in wpas_p2p_completed()
7880 if (ssid->bssid_set) in wpas_p2p_completed()
7881 os_memcpy(go_dev_addr, ssid->bssid, ETH_ALEN); in wpas_p2p_completed()
7882 persistent = wpas_p2p_persistent_group(wpa_s, go_dev_addr, ssid->ssid, in wpas_p2p_completed()
7883 ssid->ssid_len); in wpas_p2p_completed()
7884 os_memcpy(wpa_s->go_dev_addr, go_dev_addr, ETH_ALEN); in wpas_p2p_completed()
7886 if (wpa_s->global->p2p_group_formation == wpa_s) in wpas_p2p_completed()
7887 wpa_s->global->p2p_group_formation = NULL; in wpas_p2p_completed()
7889 freq = wpa_s->current_bss ? wpa_s->current_bss->freq : in wpas_p2p_completed()
7890 (int) wpa_s->assoc_freq; in wpas_p2p_completed()
7893 if (wpa_sm_get_p2p_ip_addr(wpa_s->wpa, ip) == 0) { in wpas_p2p_completed()
7907 wpas_p2p_group_started(wpa_s, 0, ssid, freq, in wpas_p2p_completed()
7908 ssid->passphrase == NULL && ssid->psk_set ? in wpas_p2p_completed()
7909 ssid->psk : NULL, in wpas_p2p_completed()
7910 ssid->passphrase, go_dev_addr, persistent, in wpas_p2p_completed()
7914 wpas_p2p_store_persistent_group(wpa_s->p2pdev, in wpas_p2p_completed()
7926 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL) in wpas_p2p_presence_req()
7927 return -1; in wpas_p2p_presence_req()
7929 if (wpa_s->wpa_state < WPA_ASSOCIATED || in wpas_p2p_presence_req()
7930 wpa_s->current_ssid == NULL || in wpas_p2p_presence_req()
7931 wpa_s->current_ssid->mode != WPAS_MODE_INFRA) in wpas_p2p_presence_req()
7932 return -1; in wpas_p2p_presence_req()
7934 ret = p2p_presence_req(wpa_s->global->p2p, wpa_s->bssid, in wpas_p2p_presence_req()
7935 wpa_s->own_addr, wpa_s->assoc_freq, in wpas_p2p_presence_req()
7938 wpa_s->waiting_presence_resp = 1; in wpas_p2p_presence_req()
7947 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL) in wpas_p2p_ext_listen()
7948 return -1; in wpas_p2p_ext_listen()
7950 return p2p_ext_listen(wpa_s->global->p2p, period, interval); in wpas_p2p_ext_listen()
7956 if (wpa_s->current_ssid == NULL) { in wpas_p2p_is_client()
7964 return wpa_s->current_ssid->p2p_group && in wpas_p2p_is_client()
7965 wpa_s->current_ssid->mode == WPAS_MODE_INFRA; in wpas_p2p_is_client()
7973 if (wpa_s->conf->p2p_group_idle == 0 && !wpas_p2p_is_client(wpa_s)) { in wpas_p2p_group_idle_timeout()
7974 wpa_printf(MSG_DEBUG, "P2P: Ignore group idle timeout - " in wpas_p2p_group_idle_timeout()
7979 wpa_printf(MSG_DEBUG, "P2P: Group idle timeout reached - terminate " in wpas_p2p_group_idle_timeout()
7992 if (wpa_s->current_ssid == NULL || !wpa_s->current_ssid->p2p_group) in wpas_p2p_set_group_idle_timeout()
7995 timeout = wpa_s->conf->p2p_group_idle; in wpas_p2p_set_group_idle_timeout()
7996 if (wpa_s->current_ssid->mode == WPAS_MODE_INFRA && in wpas_p2p_set_group_idle_timeout()
8004 if (wpa_s->current_ssid->mode == WPAS_MODE_INFRA) in wpas_p2p_set_group_idle_timeout()
8005 timeout = 0; /* special client mode no-timeout */ in wpas_p2p_set_group_idle_timeout()
8010 if (wpa_s->p2p_in_provisioning) { in wpas_p2p_set_group_idle_timeout()
8021 if (wpa_s->show_group_started) { in wpas_p2p_set_group_idle_timeout()
8024 * the provisioning phase and completion of 4-way handshake to in wpas_p2p_set_group_idle_timeout()
8029 "while waiting for initial 4-way handshake to " in wpas_p2p_set_group_idle_timeout()
8046 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL) in wpas_p2p_deauth_notif()
8050 p2p_deauth_notif(wpa_s->global->p2p, bssid, reason_code, ie, in wpas_p2p_deauth_notif()
8054 wpa_s->current_ssid && in wpas_p2p_deauth_notif()
8055 wpa_s->current_ssid->p2p_group && in wpas_p2p_deauth_notif()
8056 wpa_s->current_ssid->mode == WPAS_MODE_INFRA) { in wpas_p2p_deauth_notif()
8073 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL) in wpas_p2p_disassoc_notif()
8077 p2p_disassoc_notif(wpa_s->global->p2p, bssid, reason_code, ie, in wpas_p2p_disassoc_notif()
8084 struct p2p_data *p2p = wpa_s->global->p2p; in wpas_p2p_update_config()
8089 if (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_CAPABLE)) in wpas_p2p_update_config()
8092 if (wpa_s->conf->changed_parameters & CFG_CHANGED_DEVICE_NAME) in wpas_p2p_update_config()
8093 p2p_set_dev_name(p2p, wpa_s->conf->device_name); in wpas_p2p_update_config()
8095 if (wpa_s->conf->changed_parameters & CFG_CHANGED_DEVICE_TYPE) in wpas_p2p_update_config()
8096 p2p_set_pri_dev_type(p2p, wpa_s->conf->device_type); in wpas_p2p_update_config()
8098 if (wpa_s->wps && in wpas_p2p_update_config()
8099 (wpa_s->conf->changed_parameters & CFG_CHANGED_CONFIG_METHODS)) in wpas_p2p_update_config()
8100 p2p_set_config_methods(p2p, wpa_s->wps->config_methods); in wpas_p2p_update_config()
8102 if (wpa_s->wps && (wpa_s->conf->changed_parameters & CFG_CHANGED_UUID)) in wpas_p2p_update_config()
8103 p2p_set_uuid(p2p, wpa_s->wps->uuid); in wpas_p2p_update_config()
8105 if (wpa_s->conf->changed_parameters & CFG_CHANGED_WPS_STRING) { in wpas_p2p_update_config()
8106 p2p_set_manufacturer(p2p, wpa_s->conf->manufacturer); in wpas_p2p_update_config()
8107 p2p_set_model_name(p2p, wpa_s->conf->model_name); in wpas_p2p_update_config()
8108 p2p_set_model_number(p2p, wpa_s->conf->model_number); in wpas_p2p_update_config()
8109 p2p_set_serial_number(p2p, wpa_s->conf->serial_number); in wpas_p2p_update_config()
8112 if (wpa_s->conf->changed_parameters & CFG_CHANGED_SEC_DEVICE_TYPE) in wpas_p2p_update_config()
8114 (void *) wpa_s->conf->sec_device_type, in wpas_p2p_update_config()
8115 wpa_s->conf->num_sec_device_types); in wpas_p2p_update_config()
8117 if (wpa_s->conf->changed_parameters & CFG_CHANGED_VENDOR_EXTENSION) { in wpas_p2p_update_config()
8121 if (wpa_s->conf->wps_vendor_ext[i] == NULL) in wpas_p2p_update_config()
8124 p2p, wpa_s->conf->wps_vendor_ext[i]); in wpas_p2p_update_config()
8128 if ((wpa_s->conf->changed_parameters & CFG_CHANGED_COUNTRY) && in wpas_p2p_update_config()
8129 wpa_s->conf->country[0] && wpa_s->conf->country[1]) { in wpas_p2p_update_config()
8131 country[0] = wpa_s->conf->country[0]; in wpas_p2p_update_config()
8132 country[1] = wpa_s->conf->country[1]; in wpas_p2p_update_config()
8137 if (wpa_s->conf->changed_parameters & CFG_CHANGED_P2P_SSID_POSTFIX) { in wpas_p2p_update_config()
8138 p2p_set_ssid_postfix(p2p, (u8 *) wpa_s->conf->p2p_ssid_postfix, in wpas_p2p_update_config()
8139 wpa_s->conf->p2p_ssid_postfix ? in wpas_p2p_update_config()
8140 os_strlen(wpa_s->conf->p2p_ssid_postfix) : in wpas_p2p_update_config()
8144 if (wpa_s->conf->changed_parameters & CFG_CHANGED_P2P_INTRA_BSS) in wpas_p2p_update_config()
8145 p2p_set_intra_bss_dist(p2p, wpa_s->conf->p2p_intra_bss); in wpas_p2p_update_config()
8147 if (wpa_s->conf->changed_parameters & CFG_CHANGED_P2P_LISTEN_CHANNEL) { in wpas_p2p_update_config()
8153 if (wpa_s->conf->p2p_listen_reg_class && in wpas_p2p_update_config()
8154 wpa_s->conf->p2p_listen_channel) { in wpas_p2p_update_config()
8155 reg_class = wpa_s->conf->p2p_listen_reg_class; in wpas_p2p_update_config()
8156 channel = wpa_s->conf->p2p_listen_channel; in wpas_p2p_update_config()
8176 if (wpa_s->conf->changed_parameters & CFG_CHANGED_P2P_OPER_CHANNEL) { in wpas_p2p_update_config()
8180 if (wpa_s->conf->p2p_oper_reg_class && in wpas_p2p_update_config()
8181 wpa_s->conf->p2p_oper_channel) { in wpas_p2p_update_config()
8182 op_reg_class = wpa_s->conf->p2p_oper_reg_class; in wpas_p2p_update_config()
8183 op_channel = wpa_s->conf->p2p_oper_channel; in wpas_p2p_update_config()
8204 if (wpa_s->conf->changed_parameters & CFG_CHANGED_P2P_PREF_CHAN) { in wpas_p2p_update_config()
8205 if (p2p_set_pref_chan(p2p, wpa_s->conf->num_p2p_pref_chan, in wpas_p2p_update_config()
8206 wpa_s->conf->p2p_pref_chan) < 0) { in wpas_p2p_update_config()
8211 if (p2p_set_no_go_freq(p2p, &wpa_s->conf->p2p_no_go_freq) < 0) { in wpas_p2p_update_config()
8217 if (wpa_s->conf->changed_parameters & CFG_CHANGED_P2P_PASSPHRASE_LEN) in wpas_p2p_update_config()
8218 p2p_set_passphrase_len(p2p, wpa_s->conf->p2p_passphrase_len); in wpas_p2p_update_config()
8225 if (!wpa_s->ap_iface) in wpas_p2p_set_noa()
8226 return -1; in wpas_p2p_set_noa()
8227 return hostapd_p2p_set_noa(wpa_s->ap_iface->bss[0], count, start, in wpas_p2p_set_noa()
8234 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL) in wpas_p2p_set_cross_connect()
8235 return -1; in wpas_p2p_set_cross_connect()
8237 wpa_s->global->cross_connection = enabled; in wpas_p2p_set_cross_connect()
8238 p2p_set_cross_connect(wpa_s->global->p2p, enabled); in wpas_p2p_set_cross_connect()
8243 for (iface = wpa_s->global->ifaces; iface; iface = iface->next) in wpas_p2p_set_cross_connect()
8245 if (iface->cross_connect_enabled == 0) in wpas_p2p_set_cross_connect()
8248 iface->cross_connect_enabled = 0; in wpas_p2p_set_cross_connect()
8249 iface->cross_connect_in_use = 0; in wpas_p2p_set_cross_connect()
8250 wpa_msg_global(iface->p2pdev, MSG_INFO, in wpas_p2p_set_cross_connect()
8252 iface->ifname, in wpas_p2p_set_cross_connect()
8253 iface->cross_connect_uplink); in wpas_p2p_set_cross_connect()
8265 if (!uplink->global->cross_connection) in wpas_p2p_enable_cross_connect()
8268 for (iface = uplink->global->ifaces; iface; iface = iface->next) { in wpas_p2p_enable_cross_connect()
8269 if (!iface->cross_connect_enabled) in wpas_p2p_enable_cross_connect()
8271 if (os_strcmp(uplink->ifname, iface->cross_connect_uplink) != in wpas_p2p_enable_cross_connect()
8274 if (iface->ap_iface == NULL) in wpas_p2p_enable_cross_connect()
8276 if (iface->cross_connect_in_use) in wpas_p2p_enable_cross_connect()
8279 iface->cross_connect_in_use = 1; in wpas_p2p_enable_cross_connect()
8280 wpa_msg_global(iface->p2pdev, MSG_INFO, in wpas_p2p_enable_cross_connect()
8282 iface->ifname, iface->cross_connect_uplink); in wpas_p2p_enable_cross_connect()
8291 for (iface = uplink->global->ifaces; iface; iface = iface->next) { in wpas_p2p_disable_cross_connect()
8292 if (!iface->cross_connect_enabled) in wpas_p2p_disable_cross_connect()
8294 if (os_strcmp(uplink->ifname, iface->cross_connect_uplink) != in wpas_p2p_disable_cross_connect()
8297 if (!iface->cross_connect_in_use) in wpas_p2p_disable_cross_connect()
8300 wpa_msg_global(iface->p2pdev, MSG_INFO, in wpas_p2p_disable_cross_connect()
8302 iface->ifname, iface->cross_connect_uplink); in wpas_p2p_disable_cross_connect()
8303 iface->cross_connect_in_use = 0; in wpas_p2p_disable_cross_connect()
8310 if (wpa_s->ap_iface || wpa_s->current_ssid == NULL || in wpas_p2p_notif_connected()
8311 wpa_s->current_ssid->mode != WPAS_MODE_INFRA || in wpas_p2p_notif_connected()
8312 wpa_s->cross_connect_disallowed) in wpas_p2p_notif_connected()
8316 if (!wpa_s->ap_iface && in wpas_p2p_notif_connected()
8325 if (!wpa_s->ap_iface && in wpas_p2p_notif_disconnected()
8336 if (!wpa_s->global->cross_connection) in wpas_p2p_cross_connect_setup()
8339 for (iface = wpa_s->global->ifaces; iface; iface = iface->next) { in wpas_p2p_cross_connect_setup()
8342 if (iface->drv_flags & in wpas_p2p_cross_connect_setup()
8345 if ((iface->drv_flags & WPA_DRIVER_FLAGS_P2P_CAPABLE) && in wpas_p2p_cross_connect_setup()
8346 iface != wpa_s->parent) in wpas_p2p_cross_connect_setup()
8349 wpa_s->cross_connect_enabled = 1; in wpas_p2p_cross_connect_setup()
8350 os_strlcpy(wpa_s->cross_connect_uplink, iface->ifname, in wpas_p2p_cross_connect_setup()
8351 sizeof(wpa_s->cross_connect_uplink)); in wpas_p2p_cross_connect_setup()
8354 wpa_s->ifname, wpa_s->cross_connect_uplink); in wpas_p2p_cross_connect_setup()
8356 if (iface->ap_iface || iface->current_ssid == NULL || in wpas_p2p_cross_connect_setup()
8357 iface->current_ssid->mode != WPAS_MODE_INFRA || in wpas_p2p_cross_connect_setup()
8358 iface->cross_connect_disallowed || in wpas_p2p_cross_connect_setup()
8359 iface->wpa_state != WPA_COMPLETED) in wpas_p2p_cross_connect_setup()
8362 wpa_s->cross_connect_in_use = 1; in wpas_p2p_cross_connect_setup()
8363 wpa_msg_global(wpa_s->p2pdev, MSG_INFO, in wpas_p2p_cross_connect_setup()
8365 wpa_s->ifname, wpa_s->cross_connect_uplink); in wpas_p2p_cross_connect_setup()
8373 if (wpa_s->p2p_group_interface != P2P_GROUP_INTERFACE_CLIENT && in wpas_p2p_notif_pbc_overlap()
8374 !wpa_s->p2p_in_provisioning) in wpas_p2p_notif_pbc_overlap()
8379 if (wpa_s != wpa_s->p2pdev) in wpas_p2p_notif_pbc_overlap()
8380 wpa_msg_ctrl(wpa_s->p2pdev, MSG_INFO, WPS_EVENT_OVERLAP); in wpas_p2p_notif_pbc_overlap()
8398 unsigned int num = wpa_s->num_multichan_concurrent; in wpas_p2p_update_channel_list()
8400 if (wpa_s->global == NULL || wpa_s->global->p2p == NULL) in wpas_p2p_update_channel_list()
8412 is_p2p_6ghz_disabled(wpa_s->global->p2p))) { in wpas_p2p_update_channel_list()
8418 p2p_update_channel_list(wpa_s->global->p2p, &chan, &cli_chan); in wpas_p2p_update_channel_list()
8443 struct wpa_global *global = wpa_s->global; in wpas_p2p_cancel()
8447 if (global->p2p == NULL) in wpas_p2p_cancel()
8448 return -1; in wpas_p2p_cancel()
8452 if (wpa_s->pending_interface_name[0] && in wpas_p2p_cancel()
8453 !is_zero_ether_addr(wpa_s->pending_interface_addr)) in wpas_p2p_cancel()
8456 peer = p2p_get_go_neg_peer(global->p2p); in wpas_p2p_cancel()
8460 p2p_unauthorize(global->p2p, peer); in wpas_p2p_cancel()
8464 if (wpa_s->scan_res_handler == wpas_p2p_scan_res_join) { in wpas_p2p_cancel()
8466 wpa_s->scan_res_handler = wpas_p2p_scan_res_ignore; in wpas_p2p_cancel()
8470 if (wpa_s->pending_pd_before_join) { in wpas_p2p_cancel()
8472 wpa_s->pending_pd_before_join = 0; in wpas_p2p_cancel()
8478 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) { in wpas_p2p_cancel()
8479 if (wpa_s == global->p2p_group_formation && in wpas_p2p_cancel()
8480 (wpa_s->p2p_in_provisioning || in wpas_p2p_cancel()
8481 wpa_s->parent->pending_interface_type == in wpas_p2p_cancel()
8484 "formation found - cancelling", in wpas_p2p_cancel()
8485 wpa_s->ifname); in wpas_p2p_cancel()
8488 wpa_s->p2pdev, NULL); in wpas_p2p_cancel()
8489 if (wpa_s->p2p_in_provisioning) { in wpas_p2p_cancel()
8496 } else if (wpa_s->p2p_in_invitation) { in wpas_p2p_cancel()
8497 wpa_printf(MSG_DEBUG, "P2P: Interface %s in invitation found - cancelling", in wpas_p2p_cancel()
8498 wpa_s->ifname); in wpas_p2p_cancel()
8507 return -1; in wpas_p2p_cancel()
8516 if (wpa_s->current_ssid == NULL || !wpa_s->current_ssid->p2p_group) in wpas_p2p_interface_unavailable()
8528 struct p2p_data *p2p = wpa_s->global->p2p; in wpas_p2p_update_best_channels()
8538 struct p2p_data *p2p = wpa_s->global->p2p; in wpas_p2p_unauthorize()
8541 return -1; in wpas_p2p_unauthorize()
8544 return -1; in wpas_p2p_unauthorize()
8551 * wpas_p2p_disconnect - Disconnect from a P2P Group
8553 * Returns: 0 on success, -1 on failure
8565 return -1; in wpas_p2p_disconnect()
8568 -1 : 0; in wpas_p2p_disconnect()
8576 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL) in wpas_p2p_in_progress()
8579 ret = p2p_in_progress(wpa_s->global->p2p); in wpas_p2p_in_progress()
8587 if (wpa_s->global->p2p_group_formation && in wpas_p2p_in_progress()
8588 wpa_s->global->p2p_group_formation != wpa_s) { in wpas_p2p_in_progress()
8591 wpa_s->global->p2p_group_formation->ifname); in wpas_p2p_in_progress()
8593 } else if (wpa_s->global->p2p_group_formation == wpa_s) { in wpas_p2p_in_progress()
8600 if (!ret && wpa_s->global->p2p_go_wait_client.sec) { in wpas_p2p_in_progress()
8603 if (os_reltime_expired(&now, &wpa_s->global->p2p_go_wait_client, in wpas_p2p_in_progress()
8606 wpa_s->global->p2p_go_wait_client.sec = 0; in wpas_p2p_in_progress()
8620 if (wpa_s->p2p_in_provisioning && ssid->p2p_group && in wpas_p2p_network_removed()
8622 wpa_s->p2pdev, NULL) > 0) { in wpas_p2p_network_removed()
8634 wpa_s->p2pdev, NULL); in wpas_p2p_network_removed()
8646 for (s = wpa_s->conf->ssid; s; s = s->next) { in wpas_p2p_get_persistent()
8647 if (s->disabled != 2) in wpas_p2p_get_persistent()
8650 (ssid_len != s->ssid_len || in wpas_p2p_get_persistent()
8651 os_memcmp(ssid, s->ssid, ssid_len) != 0)) in wpas_p2p_get_persistent()
8654 if (s->mode == WPAS_MODE_P2P_GO) in wpas_p2p_get_persistent()
8658 if (ether_addr_equal(s->bssid, addr)) in wpas_p2p_get_persistent()
8660 if (s->mode != WPAS_MODE_P2P_GO || s->p2p_client_list == NULL) in wpas_p2p_get_persistent()
8662 for (i = 0; i < s->num_p2p_clients; i++) { in wpas_p2p_get_persistent()
8663 if (ether_addr_equal(s->p2p_client_list + in wpas_p2p_get_persistent()
8678 wpa_s->p2pdev, NULL) > 0) { in wpas_p2p_notify_ap_sta_authorized()
8690 if (!wpa_s->p2p_go_group_formation_completed && in wpas_p2p_notify_ap_sta_authorized()
8691 !wpa_s->group_formation_reported) { in wpas_p2p_notify_ap_sta_authorized()
8699 if (wpa_s->global->p2p) in wpas_p2p_notify_ap_sta_authorized()
8700 p2p_wps_success_cb(wpa_s->global->p2p, addr); in wpas_p2p_notify_ap_sta_authorized()
8704 if (!wpa_s->p2p_go_group_formation_completed) { in wpas_p2p_notify_ap_sta_authorized()
8706 wpa_s->p2p_go_group_formation_completed = 1; in wpas_p2p_notify_ap_sta_authorized()
8707 wpa_s->global->p2p_group_formation = NULL; in wpas_p2p_notify_ap_sta_authorized()
8708 wpa_s->p2p_in_provisioning = 0; in wpas_p2p_notify_ap_sta_authorized()
8709 wpa_s->p2p_in_invitation = 0; in wpas_p2p_notify_ap_sta_authorized()
8710 wpa_s->p2p_retry_limit = 0; in wpas_p2p_notify_ap_sta_authorized()
8712 wpa_s->global->p2p_go_wait_client.sec = 0; in wpas_p2p_notify_ap_sta_authorized()
8725 if (wpa_s->global->p2p_group_formation) in wpas_p2p_fallback_to_go_neg()
8726 group = wpa_s->global->p2p_group_formation; in wpas_p2p_fallback_to_go_neg()
8727 wpa_s = wpa_s->global->p2p_init_wpa_s; in wpas_p2p_fallback_to_go_neg()
8732 wpas_p2p_connect(wpa_s, wpa_s->pending_join_dev_addr, wpa_s->p2p_pin, in wpas_p2p_fallback_to_go_neg()
8733 wpa_s->p2p_wps_method, wpa_s->p2p_persistent_group, 0, in wpas_p2p_fallback_to_go_neg()
8734 0, 0, wpa_s->p2p_go_intent, wpa_s->p2p_connect_freq, in wpas_p2p_fallback_to_go_neg()
8735 wpa_s->p2p_go_vht_center_freq2, in wpas_p2p_fallback_to_go_neg()
8736 wpa_s->p2p_persistent_id, in wpas_p2p_fallback_to_go_neg()
8737 wpa_s->p2p_pd_before_go_neg, in wpas_p2p_fallback_to_go_neg()
8738 wpa_s->p2p_go_ht40, in wpas_p2p_fallback_to_go_neg()
8739 wpa_s->p2p_go_vht, in wpas_p2p_fallback_to_go_neg()
8740 wpa_s->p2p_go_max_oper_chwidth, in wpas_p2p_fallback_to_go_neg()
8741 wpa_s->p2p_go_he, in wpas_p2p_fallback_to_go_neg()
8742 wpa_s->p2p_go_edmg, in wpas_p2p_fallback_to_go_neg()
8743 NULL, 0, is_p2p_allow_6ghz(wpa_s->global->p2p)); in wpas_p2p_fallback_to_go_neg()
8752 if (!wpa_s->p2p_fallback_to_go_neg || in wpas_p2p_scan_no_go_seen()
8753 wpa_s->p2p_in_provisioning <= 5) in wpas_p2p_scan_no_go_seen()
8756 if (wpas_p2p_peer_go(wpa_s, wpa_s->pending_join_dev_addr) > 0) in wpas_p2p_scan_no_go_seen()
8759 wpa_dbg(wpa_s, MSG_DEBUG, "P2P: GO not found for p2p_connect-auto - " in wpas_p2p_scan_no_go_seen()
8761 wpa_msg_global(wpa_s->p2pdev, MSG_INFO, P2P_EVENT_FALLBACK_TO_GO_NEG in wpas_p2p_scan_no_go_seen()
8762 "reason=GO-not-found"); in wpas_p2p_scan_no_go_seen()
8773 if (wpa_s->wpa_state > WPA_SCANNING) { in wpas_p2p_search_delay()
8776 wpa_s->conf->p2p_search_delay); in wpas_p2p_search_delay()
8777 return wpa_s->conf->p2p_search_delay; in wpas_p2p_search_delay()
8780 dl_list_for_each(ifs, &wpa_s->radio->ifaces, struct wpa_supplicant, in wpas_p2p_search_delay()
8782 if (ifs != wpa_s && ifs->wpa_state > WPA_SCANNING) { in wpas_p2p_search_delay()
8786 wpa_s->conf->p2p_search_delay, in wpas_p2p_search_delay()
8787 ifs->ifname); in wpas_p2p_search_delay()
8788 return wpa_s->conf->p2p_search_delay; in wpas_p2p_search_delay()
8803 dl_list_for_each_safe(psk, tmp, &s->psk_list, struct psk_list_entry, in wpas_p2p_remove_psk_entry()
8805 if ((iface_addr && !psk->p2p && in wpas_p2p_remove_psk_entry()
8806 ether_addr_equal(addr, psk->addr)) || in wpas_p2p_remove_psk_entry()
8807 (!iface_addr && psk->p2p && in wpas_p2p_remove_psk_entry()
8808 ether_addr_equal(addr, psk->addr))) { in wpas_p2p_remove_psk_entry()
8812 MAC2STR(psk->addr), psk->p2p); in wpas_p2p_remove_psk_entry()
8813 dl_list_del(&psk->list); in wpas_p2p_remove_psk_entry()
8827 struct wpa_ssid *ssid = wpa_s->current_ssid; in wpas_p2p_new_psk_cb()
8831 if (psk_len != sizeof(p->psk)) in wpas_p2p_new_psk_cb()
8845 if (ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION) { in wpas_p2p_new_psk_cb()
8848 if (wpa_s->global->add_psk == NULL) { in wpas_p2p_new_psk_cb()
8849 wpa_s->global->add_psk = os_zalloc(sizeof(*p)); in wpas_p2p_new_psk_cb()
8850 if (wpa_s->global->add_psk == NULL) in wpas_p2p_new_psk_cb()
8853 p = wpa_s->global->add_psk; in wpas_p2p_new_psk_cb()
8855 p->p2p = 1; in wpas_p2p_new_psk_cb()
8856 os_memcpy(p->addr, p2p_dev_addr, ETH_ALEN); in wpas_p2p_new_psk_cb()
8858 p->p2p = 0; in wpas_p2p_new_psk_cb()
8859 os_memcpy(p->addr, mac_addr, ETH_ALEN); in wpas_p2p_new_psk_cb()
8861 os_memcpy(p->psk, psk, psk_len); in wpas_p2p_new_psk_cb()
8865 if (ssid->mode != WPAS_MODE_P2P_GO || !ssid->p2p_persistent_group) { in wpas_p2p_new_psk_cb()
8866 wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Ignore new_psk_cb on not-persistent GO"); in wpas_p2p_new_psk_cb()
8870 persistent = wpas_p2p_get_persistent(wpa_s->p2pdev, NULL, ssid->ssid, in wpas_p2p_new_psk_cb()
8871 ssid->ssid_len); in wpas_p2p_new_psk_cb()
8881 p->p2p = 1; in wpas_p2p_new_psk_cb()
8882 os_memcpy(p->addr, p2p_dev_addr, ETH_ALEN); in wpas_p2p_new_psk_cb()
8884 p->p2p = 0; in wpas_p2p_new_psk_cb()
8885 os_memcpy(p->addr, mac_addr, ETH_ALEN); in wpas_p2p_new_psk_cb()
8887 os_memcpy(p->psk, psk, psk_len); in wpas_p2p_new_psk_cb()
8889 if (dl_list_len(&persistent->psk_list) > P2P_MAX_STORED_CLIENTS && in wpas_p2p_new_psk_cb()
8890 (last = dl_list_last(&persistent->psk_list, in wpas_p2p_new_psk_cb()
8894 MAC2STR(last->addr), last->p2p); in wpas_p2p_new_psk_cb()
8895 dl_list_del(&last->list); in wpas_p2p_new_psk_cb()
8899 wpas_p2p_remove_psk_entry(wpa_s->p2pdev, persistent, in wpas_p2p_new_psk_cb()
8909 dl_list_add(&persistent->psk_list, &p->list); in wpas_p2p_new_psk_cb()
8911 if (wpa_s->p2pdev->conf->update_config && in wpas_p2p_new_psk_cb()
8912 wpa_config_write(wpa_s->p2pdev->confname, wpa_s->p2pdev->conf)) in wpas_p2p_new_psk_cb()
8924 if (res > 0 && wpa_s->conf->update_config && in wpas_p2p_remove_psk()
8925 wpa_config_write(wpa_s->confname, wpa_s->conf)) in wpas_p2p_remove_psk()
8938 if (wpa_s->ap_iface == NULL || wpa_s->current_ssid == NULL || in wpas_p2p_remove_client_go()
8939 wpa_s->current_ssid->mode != WPAS_MODE_P2P_GO) in wpas_p2p_remove_client_go()
8942 /* Remove per-station PSK entry */ in wpas_p2p_remove_client_go()
8943 hapd = wpa_s->ap_iface->bss[0]; in wpas_p2p_remove_client_go()
8945 psk = hapd->conf->ssid.wpa_psk; in wpas_p2p_remove_client_go()
8947 if ((iface_addr && ether_addr_equal(peer, psk->addr)) || in wpas_p2p_remove_client_go()
8949 ether_addr_equal(peer, psk->p2p_dev_addr))) { in wpas_p2p_remove_client_go()
8954 prev->next = psk->next; in wpas_p2p_remove_client_go()
8956 hapd->conf->ssid.wpa_psk = psk->next; in wpas_p2p_remove_client_go()
8958 psk = psk->next; in wpas_p2p_remove_client_go()
8962 psk = psk->next; in wpas_p2p_remove_client_go()
8975 hostapd_drv_sta_deauth(hapd, sta->addr, in wpas_p2p_remove_client_go()
8987 struct wpa_supplicant *p2p_wpa_s = wpa_s->global->p2p_init_wpa_s; in wpas_p2p_remove_client()
8992 for (s = p2p_wpa_s->conf->ssid; s; s = s->next) { in wpas_p2p_remove_client()
8993 if (s->disabled != 2 || s->mode != WPAS_MODE_P2P_GO) in wpas_p2p_remove_client()
9001 for (w = wpa_s->global->ifaces; w; w = w->next) in wpas_p2p_remove_client()
9017 wpa_printf(MSG_DEBUG, "P2P: Frequency conflict - terminate group"); in wpas_p2p_group_freq_conflict()
9022 int wpas_p2p_handle_frequency_conflicts(struct wpa_supplicant *wpa_s, int freq, in wpas_p2p_handle_frequency_conflicts() argument
9027 for (iface = wpa_s->global->ifaces; iface; iface = iface->next) { in wpas_p2p_handle_frequency_conflicts()
9028 if (!iface->current_ssid || in wpas_p2p_handle_frequency_conflicts()
9029 iface->current_ssid->frequency == freq || in wpas_p2p_handle_frequency_conflicts()
9030 (iface->p2p_group_interface == NOT_P2P_GROUP_INTERFACE && in wpas_p2p_handle_frequency_conflicts()
9031 !iface->current_ssid->p2p_group)) in wpas_p2p_handle_frequency_conflicts()
9045 return -1; in wpas_p2p_handle_frequency_conflicts()
9051 wpa_supplicant_disable_network(wpa_s->global->ifaces, in wpas_p2p_handle_frequency_conflicts()
9053 wpa_msg(wpa_s->global->ifaces, MSG_INFO, in wpas_p2p_handle_frequency_conflicts()
9054 WPA_EVENT_FREQ_CONFLICT " id=%d", ssid->id); in wpas_p2p_handle_frequency_conflicts()
9055 os_memset(wpa_s->global->ifaces->pending_bssid, 0, in wpas_p2p_handle_frequency_conflicts()
9062 return -1; in wpas_p2p_handle_frequency_conflicts()
9072 struct wpa_ssid *ssid = wpa_s->current_ssid; in wpas_p2p_4way_hs_failed()
9074 if (ssid == NULL || !ssid->p2p_group) in wpas_p2p_4way_hs_failed()
9077 if (wpa_s->p2p_last_4way_hs_fail && in wpas_p2p_4way_hs_failed()
9078 wpa_s->p2p_last_4way_hs_fail == ssid) { in wpas_p2p_4way_hs_failed()
9083 ssid->ssid, in wpas_p2p_4way_hs_failed()
9084 ssid->ssid_len) <= 0) { in wpas_p2p_4way_hs_failed()
9085 …wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Could not determine whether 4-way handshake failures were for a pe… in wpas_p2p_4way_hs_failed()
9089 wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Two 4-way handshake failures for a P2P group - go_dev_addr=" in wpas_p2p_4way_hs_failed()
9091 persistent = wpas_p2p_get_persistent(wpa_s->p2pdev, go_dev_addr, in wpas_p2p_4way_hs_failed()
9092 ssid->ssid, in wpas_p2p_4way_hs_failed()
9093 ssid->ssid_len); in wpas_p2p_4way_hs_failed()
9094 if (persistent == NULL || persistent->mode != WPAS_MODE_INFRA) { in wpas_p2p_4way_hs_failed()
9098 wpa_msg_global(wpa_s->p2pdev, MSG_INFO, in wpas_p2p_4way_hs_failed()
9100 persistent->id); in wpas_p2p_4way_hs_failed()
9102 wpa_s->p2p_last_4way_hs_fail = NULL; in wpas_p2p_4way_hs_failed()
9113 wpa_s->p2p_last_4way_hs_fail = ssid; in wpas_p2p_4way_hs_failed()
9175 for (iface = wpa_s->global->ifaces; iface; iface = iface->next) { in wpas_p2p_cli_freq()
9176 if (iface->wpa_state < WPA_ASSOCIATING || in wpas_p2p_cli_freq()
9177 iface->current_ssid == NULL || iface->assoc_freq == 0 || in wpas_p2p_cli_freq()
9178 !iface->current_ssid->p2p_group || in wpas_p2p_cli_freq()
9179 iface->current_ssid->mode != WPAS_MODE_INFRA) in wpas_p2p_cli_freq()
9182 *ssid = iface->current_ssid; in wpas_p2p_cli_freq()
9184 os_memcpy(go_dev_addr, iface->go_dev_addr, ETH_ALEN); in wpas_p2p_cli_freq()
9185 return iface->assoc_freq; in wpas_p2p_cli_freq()
9199 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL) { in wpas_p2p_nfc_handover_req()
9200 wpa_printf(MSG_DEBUG, "P2P: P2P disabled - cannot build handover request"); in wpas_p2p_nfc_handover_req()
9204 if (wpa_s->conf->wps_nfc_dh_pubkey == NULL && in wpas_p2p_nfc_handover_req()
9205 wps_nfc_gen_dh(&wpa_s->conf->wps_nfc_dh_pubkey, in wpas_p2p_nfc_handover_req()
9206 &wpa_s->conf->wps_nfc_dh_privkey) < 0) { in wpas_p2p_nfc_handover_req()
9213 wpa_s->parent->wps, wpa_s->conf->wps_nfc_dh_pubkey); in wpas_p2p_nfc_handover_req()
9216 p2p = p2p_build_nfc_handover_req(wpa_s->global->p2p, cli_freq, in wpas_p2p_nfc_handover_req()
9217 go_dev_addr, ssid ? ssid->ssid : NULL, in wpas_p2p_nfc_handover_req()
9218 ssid ? ssid->ssid_len : 0); in wpas_p2p_nfc_handover_req()
9232 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL) in wpas_p2p_nfc_handover_sel()
9235 if (!tag && wpa_s->conf->wps_nfc_dh_pubkey == NULL && in wpas_p2p_nfc_handover_sel()
9236 wps_nfc_gen_dh(&wpa_s->conf->wps_nfc_dh_pubkey, in wpas_p2p_nfc_handover_sel()
9237 &wpa_s->conf->wps_nfc_dh_privkey) < 0) in wpas_p2p_nfc_handover_sel()
9242 wpa_s->parent->wps, in wpas_p2p_nfc_handover_sel()
9243 tag ? wpa_s->conf->wps_nfc_dev_pw_id : in wpas_p2p_nfc_handover_sel()
9245 wpa_s->conf->wps_nfc_dh_pubkey, in wpas_p2p_nfc_handover_sel()
9246 tag ? wpa_s->conf->wps_nfc_dev_pw : NULL); in wpas_p2p_nfc_handover_sel()
9249 p2p = p2p_build_nfc_handover_sel(wpa_s->global->p2p, cli_freq, in wpas_p2p_nfc_handover_sel()
9250 go_dev_addr, ssid ? ssid->ssid : NULL, in wpas_p2p_nfc_handover_sel()
9251 ssid ? ssid->ssid_len : 0); in wpas_p2p_nfc_handover_sel()
9260 wpa_printf(MSG_DEBUG, "P2P: Initiate join-group based on NFC " in wpas_p2p_nfc_join_group()
9261 "connection handover (freq=%d)", in wpas_p2p_nfc_join_group()
9262 params->go_freq); in wpas_p2p_nfc_join_group()
9264 if (params->go_freq && params->go_ssid_len) { in wpas_p2p_nfc_join_group()
9265 wpa_s->p2p_wps_method = WPS_NFC; in wpas_p2p_nfc_join_group()
9266 wpa_s->pending_join_wps_method = WPS_NFC; in wpas_p2p_nfc_join_group()
9267 os_memset(wpa_s->pending_join_iface_addr, 0, ETH_ALEN); in wpas_p2p_nfc_join_group()
9268 os_memcpy(wpa_s->pending_join_dev_addr, params->go_dev_addr, in wpas_p2p_nfc_join_group()
9270 return wpas_p2p_join_start(wpa_s, params->go_freq, in wpas_p2p_nfc_join_group()
9271 params->go_ssid, in wpas_p2p_nfc_join_group()
9272 params->go_ssid_len); in wpas_p2p_nfc_join_group()
9275 return wpas_p2p_connect(wpa_s, params->peer->p2p_device_addr, NULL, in wpas_p2p_nfc_join_group()
9276 WPS_NFC, 0, 0, 1, 0, wpa_s->conf->p2p_go_intent, in wpas_p2p_nfc_join_group()
9277 params->go_freq, wpa_s->p2p_go_vht_center_freq2, in wpas_p2p_nfc_join_group()
9278 -1, 0, 1, 1, wpa_s->p2p_go_max_oper_chwidth, in wpas_p2p_nfc_join_group()
9279 wpa_s->p2p_go_he, wpa_s->p2p_go_edmg, in wpas_p2p_nfc_join_group()
9280 params->go_ssid_len ? params->go_ssid : NULL, in wpas_p2p_nfc_join_group()
9281 params->go_ssid_len, false); in wpas_p2p_nfc_join_group()
9291 wpa_printf(MSG_DEBUG, "P2P: Authorize join-group based on NFC " in wpas_p2p_nfc_auth_join()
9293 for (wpa_s = wpa_s->global->ifaces; wpa_s; wpa_s = wpa_s->next) { in wpas_p2p_nfc_auth_join()
9294 ssid = wpa_s->current_ssid; in wpas_p2p_nfc_auth_join()
9297 if (ssid->mode != WPAS_MODE_P2P_GO) in wpas_p2p_nfc_auth_join()
9299 if (wpa_s->ap_iface == NULL) in wpas_p2p_nfc_auth_join()
9305 return -1; in wpas_p2p_nfc_auth_join()
9308 if (wpa_s->p2pdev->p2p_oob_dev_pw_id != in wpas_p2p_nfc_auth_join()
9310 !wpa_s->p2pdev->p2p_oob_dev_pw) { in wpas_p2p_nfc_auth_join()
9312 return -1; in wpas_p2p_nfc_auth_join()
9315 wpa_s, wpa_s->p2pdev->p2p_oob_dev_pw_id, in wpas_p2p_nfc_auth_join()
9316 wpa_s->p2pdev->p2p_oob_dev_pw, in wpas_p2p_nfc_auth_join()
9317 wpa_s->p2pdev->p2p_peer_oob_pk_hash_known ? in wpas_p2p_nfc_auth_join()
9318 wpa_s->p2pdev->p2p_peer_oob_pubkey_hash : NULL); in wpas_p2p_nfc_auth_join()
9323 wpa_printf(MSG_DEBUG, "P2P: Negotiated handover - wait for peer to join without invitation"); in wpas_p2p_nfc_auth_join()
9327 if (!params->peer || in wpas_p2p_nfc_auth_join()
9328 !(params->peer->dev_capab & P2P_DEV_CAPAB_INVITATION_PROCEDURE)) in wpas_p2p_nfc_auth_join()
9331 wpa_printf(MSG_DEBUG, "P2P: Static handover - invite peer " MACSTR in wpas_p2p_nfc_auth_join()
9332 " to join", MAC2STR(params->peer->p2p_device_addr)); in wpas_p2p_nfc_auth_join()
9334 wpa_s->global->p2p_invite_group = wpa_s; in wpas_p2p_nfc_auth_join()
9335 persistent = ssid->p2p_persistent_group && in wpas_p2p_nfc_auth_join()
9336 wpas_p2p_get_persistent(wpa_s->p2pdev, in wpas_p2p_nfc_auth_join()
9337 params->peer->p2p_device_addr, in wpas_p2p_nfc_auth_join()
9338 ssid->ssid, ssid->ssid_len); in wpas_p2p_nfc_auth_join()
9339 wpa_s->p2pdev->pending_invite_ssid_id = -1; in wpas_p2p_nfc_auth_join()
9341 return p2p_invite(wpa_s->global->p2p, params->peer->p2p_device_addr, in wpas_p2p_nfc_auth_join()
9342 P2P_INVITE_ROLE_ACTIVE_GO, wpa_s->own_addr, in wpas_p2p_nfc_auth_join()
9343 ssid->ssid, ssid->ssid_len, ssid->frequency, in wpas_p2p_nfc_auth_join()
9344 wpa_s->global->p2p_dev_addr, persistent, 0, in wpas_p2p_nfc_auth_join()
9345 wpa_s->p2pdev->p2p_oob_dev_pw_id); in wpas_p2p_nfc_auth_join()
9355 return wpas_p2p_connect(wpa_s, params->peer->p2p_device_addr, NULL, in wpas_p2p_nfc_init_go_neg()
9356 WPS_NFC, 0, 0, 0, 0, wpa_s->conf->p2p_go_intent, in wpas_p2p_nfc_init_go_neg()
9357 forced_freq, wpa_s->p2p_go_vht_center_freq2, in wpas_p2p_nfc_init_go_neg()
9358 -1, 0, 1, 1, wpa_s->p2p_go_max_oper_chwidth, in wpas_p2p_nfc_init_go_neg()
9359 wpa_s->p2p_go_he, wpa_s->p2p_go_edmg, in wpas_p2p_nfc_init_go_neg()
9372 res = wpas_p2p_connect(wpa_s, params->peer->p2p_device_addr, NULL, in wpas_p2p_nfc_resp_go_neg()
9373 WPS_NFC, 0, 0, 0, 1, wpa_s->conf->p2p_go_intent, in wpas_p2p_nfc_resp_go_neg()
9374 forced_freq, wpa_s->p2p_go_vht_center_freq2, in wpas_p2p_nfc_resp_go_neg()
9375 -1, 0, 1, 1, wpa_s->p2p_go_max_oper_chwidth, in wpas_p2p_nfc_resp_go_neg()
9376 wpa_s->p2p_go_he, wpa_s->p2p_go_edmg, in wpas_p2p_nfc_resp_go_neg()
9383 p2p_unauthorize(wpa_s->global->p2p, in wpas_p2p_nfc_resp_go_neg()
9384 params->peer->p2p_device_addr); in wpas_p2p_nfc_resp_go_neg()
9408 if (end - pos < 2) { in wpas_p2p_nfc_connection_handover()
9411 return -1; in wpas_p2p_nfc_connection_handover()
9415 if (len > end - pos) { in wpas_p2p_nfc_connection_handover()
9418 return -1; in wpas_p2p_nfc_connection_handover()
9424 if (end - pos < 2) { in wpas_p2p_nfc_connection_handover()
9427 return -1; in wpas_p2p_nfc_connection_handover()
9431 if (len > end - pos) { in wpas_p2p_nfc_connection_handover()
9434 return -1; in wpas_p2p_nfc_connection_handover()
9447 pos, end - pos); in wpas_p2p_nfc_connection_handover()
9450 res = p2p_process_nfc_connection_handover(wpa_s->global->p2p, ¶ms); in wpas_p2p_nfc_connection_handover()
9459 MAC2STR(params.peer->p2p_device_addr)); in wpas_p2p_nfc_connection_handover()
9466 "peer=" MACSTR " freq=%d go_dev_addr=" MACSTR in wpas_p2p_nfc_connection_handover()
9468 MAC2STR(params.peer->p2p_device_addr), in wpas_p2p_nfc_connection_handover()
9475 "peer=" MACSTR " freq=%d", in wpas_p2p_nfc_connection_handover()
9476 MAC2STR(params.peer->p2p_device_addr), in wpas_p2p_nfc_connection_handover()
9484 MACSTR, MAC2STR(params.peer->p2p_device_addr)); in wpas_p2p_nfc_connection_handover()
9488 wpabuf_free(wpa_s->p2p_oob_dev_pw); in wpas_p2p_nfc_connection_handover()
9489 wpa_s->p2p_oob_dev_pw = NULL; in wpas_p2p_nfc_connection_handover()
9494 return -1; in wpas_p2p_nfc_connection_handover()
9501 os_memcpy(wpa_s->p2p_peer_oob_pubkey_hash, in wpas_p2p_nfc_connection_handover()
9503 wpa_s->p2p_peer_oob_pk_hash_known = 1; in wpas_p2p_nfc_connection_handover()
9507 wpa_printf(MSG_DEBUG, "P2P: Static handover - invalid " in wpas_p2p_nfc_connection_handover()
9509 return -1; in wpas_p2p_nfc_connection_handover()
9511 wpa_printf(MSG_DEBUG, "P2P: Static handover - use peer OOB " in wpas_p2p_nfc_connection_handover()
9515 params.oob_dev_pw_len - in wpas_p2p_nfc_connection_handover()
9516 WPS_OOB_PUBKEY_HASH_LEN - 2); in wpas_p2p_nfc_connection_handover()
9517 wpa_s->p2p_oob_dev_pw_id = id; in wpas_p2p_nfc_connection_handover()
9518 wpa_s->p2p_oob_dev_pw = wpabuf_alloc_copy( in wpas_p2p_nfc_connection_handover()
9520 params.oob_dev_pw_len - in wpas_p2p_nfc_connection_handover()
9521 WPS_OOB_PUBKEY_HASH_LEN - 2); in wpas_p2p_nfc_connection_handover()
9522 if (wpa_s->p2p_oob_dev_pw == NULL) in wpas_p2p_nfc_connection_handover()
9523 return -1; in wpas_p2p_nfc_connection_handover()
9525 if (wpa_s->conf->wps_nfc_dh_pubkey == NULL && in wpas_p2p_nfc_connection_handover()
9526 wps_nfc_gen_dh(&wpa_s->conf->wps_nfc_dh_pubkey, in wpas_p2p_nfc_connection_handover()
9527 &wpa_s->conf->wps_nfc_dh_privkey) < 0) in wpas_p2p_nfc_connection_handover()
9528 return -1; in wpas_p2p_nfc_connection_handover()
9532 wpa_s->p2p_oob_dev_pw_id = DEV_PW_NFC_CONNECTION_HANDOVER; in wpas_p2p_nfc_connection_handover()
9535 switch (params.next_step) { in wpas_p2p_nfc_connection_handover()
9552 return -1; in wpas_p2p_nfc_connection_handover()
9559 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL) in wpas_p2p_nfc_tag_process()
9560 return -1; in wpas_p2p_nfc_tag_process()
9573 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL) in wpas_p2p_nfc_report_handover()
9574 return -1; in wpas_p2p_nfc_report_handover()
9583 wpa_printf(MSG_DEBUG, "NFC: Forced freq %d", forced_freq); in wpas_p2p_nfc_report_handover()
9587 return -1; in wpas_p2p_nfc_report_handover()
9601 int go_intent = wpa_s->conf->p2p_go_intent; in wpas_p2p_nfc_tag_enabled()
9604 if (wpa_s->global->p2p == NULL) in wpas_p2p_nfc_tag_enabled()
9605 return -1; in wpas_p2p_nfc_tag_enabled()
9609 for (iface = wpa_s->global->ifaces; iface; iface = iface->next) in wpas_p2p_nfc_tag_enabled()
9611 if (!iface->ap_iface) in wpas_p2p_nfc_tag_enabled()
9613 hostapd_wps_nfc_token_disable(iface->ap_iface->bss[0]); in wpas_p2p_nfc_tag_enabled()
9615 p2p_set_authorized_oob_dev_pw_id(wpa_s->global->p2p, 0, in wpas_p2p_nfc_tag_enabled()
9617 if (wpa_s->p2p_nfc_tag_enabled) in wpas_p2p_nfc_tag_enabled()
9619 wpa_s->p2p_nfc_tag_enabled = 0; in wpas_p2p_nfc_tag_enabled()
9623 if (wpa_s->global->p2p_disabled) in wpas_p2p_nfc_tag_enabled()
9624 return -1; in wpas_p2p_nfc_tag_enabled()
9626 if (wpa_s->conf->wps_nfc_dh_pubkey == NULL || in wpas_p2p_nfc_tag_enabled()
9627 wpa_s->conf->wps_nfc_dh_privkey == NULL || in wpas_p2p_nfc_tag_enabled()
9628 wpa_s->conf->wps_nfc_dev_pw == NULL || in wpas_p2p_nfc_tag_enabled()
9629 wpa_s->conf->wps_nfc_dev_pw_id < 0x10) { in wpas_p2p_nfc_tag_enabled()
9632 return -1; in wpas_p2p_nfc_tag_enabled()
9637 wpa_s->p2p_oob_dev_pw_id = wpa_s->conf->wps_nfc_dev_pw_id; in wpas_p2p_nfc_tag_enabled()
9638 wpabuf_free(wpa_s->p2p_oob_dev_pw); in wpas_p2p_nfc_tag_enabled()
9639 wpa_s->p2p_oob_dev_pw = wpabuf_dup(wpa_s->conf->wps_nfc_dev_pw); in wpas_p2p_nfc_tag_enabled()
9640 if (wpa_s->p2p_oob_dev_pw == NULL) in wpas_p2p_nfc_tag_enabled()
9641 return -1; in wpas_p2p_nfc_tag_enabled()
9642 wpa_s->p2p_peer_oob_pk_hash_known = 0; in wpas_p2p_nfc_tag_enabled()
9644 if (wpa_s->p2p_group_interface == P2P_GROUP_INTERFACE_GO || in wpas_p2p_nfc_tag_enabled()
9645 wpa_s->p2p_group_interface == P2P_GROUP_INTERFACE_CLIENT) { in wpas_p2p_nfc_tag_enabled()
9650 wpa_s->create_p2p_iface = 0; in wpas_p2p_nfc_tag_enabled()
9652 wpa_s->create_p2p_iface = wpas_p2p_create_iface(wpa_s); in wpas_p2p_nfc_tag_enabled()
9655 if (wpa_s->create_p2p_iface) { in wpas_p2p_nfc_tag_enabled()
9664 return -1; in wpas_p2p_nfc_tag_enabled()
9667 if_addr = wpa_s->pending_interface_addr; in wpas_p2p_nfc_tag_enabled()
9668 } else if (wpa_s->p2p_mgmt) in wpas_p2p_nfc_tag_enabled()
9669 if_addr = wpa_s->parent->own_addr; in wpas_p2p_nfc_tag_enabled()
9671 if_addr = wpa_s->own_addr; in wpas_p2p_nfc_tag_enabled()
9673 wpa_s->p2p_nfc_tag_enabled = enabled; in wpas_p2p_nfc_tag_enabled()
9675 for (iface = wpa_s->global->ifaces; iface; iface = iface->next) { in wpas_p2p_nfc_tag_enabled()
9677 if (iface->ap_iface == NULL) in wpas_p2p_nfc_tag_enabled()
9679 hapd = iface->ap_iface->bss[0]; in wpas_p2p_nfc_tag_enabled()
9680 wpabuf_free(hapd->conf->wps_nfc_dh_pubkey); in wpas_p2p_nfc_tag_enabled()
9681 hapd->conf->wps_nfc_dh_pubkey = in wpas_p2p_nfc_tag_enabled()
9682 wpabuf_dup(wpa_s->conf->wps_nfc_dh_pubkey); in wpas_p2p_nfc_tag_enabled()
9683 wpabuf_free(hapd->conf->wps_nfc_dh_privkey); in wpas_p2p_nfc_tag_enabled()
9684 hapd->conf->wps_nfc_dh_privkey = in wpas_p2p_nfc_tag_enabled()
9685 wpabuf_dup(wpa_s->conf->wps_nfc_dh_privkey); in wpas_p2p_nfc_tag_enabled()
9686 wpabuf_free(hapd->conf->wps_nfc_dev_pw); in wpas_p2p_nfc_tag_enabled()
9687 hapd->conf->wps_nfc_dev_pw = in wpas_p2p_nfc_tag_enabled()
9688 wpabuf_dup(wpa_s->conf->wps_nfc_dev_pw); in wpas_p2p_nfc_tag_enabled()
9689 hapd->conf->wps_nfc_dev_pw_id = wpa_s->conf->wps_nfc_dev_pw_id; in wpas_p2p_nfc_tag_enabled()
9691 if (hostapd_wps_nfc_token_enable(iface->ap_iface->bss[0]) < 0) { in wpas_p2p_nfc_tag_enabled()
9697 wpa_s->global->p2p, wpa_s->conf->wps_nfc_dev_pw_id, go_intent, in wpas_p2p_nfc_tag_enabled()
9717 if (!wpa_s->conf->p2p_optimize_listen_chan) in wpas_p2p_optimize_listen_channel()
9720 curr_chan = p2p_get_listen_channel(wpa_s->global->p2p); in wpas_p2p_optimize_listen_channel()
9722 ieee80211_freq_to_chan(freqs[i].freq, &chan); in wpas_p2p_optimize_listen_channel()
9736 p2p_set_listen_channel(wpa_s->global->p2p, 81, cand, 0); in wpas_p2p_optimize_listen_channel()
9746 struct wpa_ssid *current_ssid = wpa_s->current_ssid; in wpas_p2p_move_go_csa()
9747 int old_freq = current_ssid->frequency; in wpas_p2p_move_go_csa()
9750 if (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_AP_CSA)) { in wpas_p2p_move_go_csa()
9752 return -1; in wpas_p2p_move_go_csa()
9762 "P2P CSA: Failed to select new frequency for GO"); in wpas_p2p_move_go_csa()
9763 return -1; in wpas_p2p_move_go_csa()
9766 if (current_ssid->frequency == params.freq) { in wpas_p2p_move_go_csa()
9768 "P2P CSA: Selected same frequency - not moving GO"); in wpas_p2p_move_go_csa()
9776 return -1; in wpas_p2p_move_go_csa()
9779 current_ssid->frequency = params.freq; in wpas_p2p_move_go_csa()
9783 ret = -1; in wpas_p2p_move_go_csa()
9787 if (conf->hw_mode != wpa_s->ap_iface->current_mode->mode && in wpas_p2p_move_go_csa()
9788 (wpa_s->ap_iface->current_mode->mode != HOSTAPD_MODE_IEEE80211A || in wpas_p2p_move_go_csa()
9789 is_6ghz_freq(wpa_s->ap_iface->freq) || in wpas_p2p_move_go_csa()
9790 conf->hw_mode != HOSTAPD_MODE_IEEE80211G)) { in wpas_p2p_move_go_csa()
9793 wpa_s->ap_iface->current_mode->mode, in wpas_p2p_move_go_csa()
9794 is_6ghz_freq(wpa_s->ap_iface->freq) ? " (6 GHz)" : "", in wpas_p2p_move_go_csa()
9795 conf->hw_mode); in wpas_p2p_move_go_csa()
9796 ret = -1; in wpas_p2p_move_go_csa()
9803 csa_settings.link_id = -1; in wpas_p2p_move_go_csa()
9804 csa_settings.freq_params.freq = params.freq; in wpas_p2p_move_go_csa()
9805 csa_settings.freq_params.sec_channel_offset = conf->secondary_channel; in wpas_p2p_move_go_csa()
9806 csa_settings.freq_params.ht_enabled = conf->ieee80211n; in wpas_p2p_move_go_csa()
9807 csa_settings.freq_params.bandwidth = conf->secondary_channel ? 40 : 20; in wpas_p2p_move_go_csa()
9809 if (conf->ieee80211ac) { in wpas_p2p_move_go_csa()
9813 if (ieee80211_freq_to_channel_ext(params.freq, in wpas_p2p_move_go_csa()
9814 conf->secondary_channel, in wpas_p2p_move_go_csa()
9815 conf->vht_oper_chwidth, in wpas_p2p_move_go_csa()
9818 wpa_printf(MSG_ERROR, "P2P CSA: Bad freq"); in wpas_p2p_move_go_csa()
9819 ret = -1; in wpas_p2p_move_go_csa()
9823 if (conf->vht_oper_centr_freq_seg0_idx) in wpas_p2p_move_go_csa()
9826 conf->vht_oper_centr_freq_seg0_idx); in wpas_p2p_move_go_csa()
9828 if (conf->vht_oper_centr_freq_seg1_idx) in wpas_p2p_move_go_csa()
9831 conf->vht_oper_centr_freq_seg1_idx); in wpas_p2p_move_go_csa()
9836 ret = -1; in wpas_p2p_move_go_csa()
9840 csa_settings.freq_params.vht_enabled = conf->ieee80211ac; in wpas_p2p_move_go_csa()
9844 switch (conf->vht_oper_chwidth) { in wpas_p2p_move_go_csa()
9859 current_ssid->frequency = old_freq; in wpas_p2p_move_go_csa()
9868 struct wpa_ssid *current_ssid = wpa_s->current_ssid; in wpas_p2p_move_go_no_csa()
9874 wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Move GO from freq=%d MHz", in wpas_p2p_move_go_no_csa()
9875 current_ssid->frequency); in wpas_p2p_move_go_no_csa()
9881 * be preserved, or GROUP-STARTED event would be lost. If this action in wpas_p2p_move_go_no_csa()
9884 ap_configured_cb = wpa_s->ap_configured_cb; in wpas_p2p_move_go_no_csa()
9885 ap_configured_cb_ctx = wpa_s->ap_configured_cb_ctx; in wpas_p2p_move_go_no_csa()
9886 ap_configured_cb_data = wpa_s->ap_configured_cb_data; in wpas_p2p_move_go_no_csa()
9892 wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Failed to reselect freq"); in wpas_p2p_move_go_no_csa()
9897 wpa_dbg(wpa_s, MSG_DEBUG, "P2P: New freq selected for the GO (%u MHz)", in wpas_p2p_move_go_no_csa()
9898 params.freq); in wpas_p2p_move_go_no_csa()
9900 if (params.freq && in wpas_p2p_move_go_no_csa()
9901 !p2p_supported_freq_go(wpa_s->global->p2p, params.freq)) { in wpas_p2p_move_go_no_csa()
9903 "P2P: Selected freq (%u MHz) is not valid for P2P", in wpas_p2p_move_go_no_csa()
9904 params.freq); in wpas_p2p_move_go_no_csa()
9911 wpa_s->ap_configured_cb = ap_configured_cb; in wpas_p2p_move_go_no_csa()
9912 wpa_s->ap_configured_cb_ctx = ap_configured_cb_ctx; in wpas_p2p_move_go_no_csa()
9913 wpa_s->ap_configured_cb_data = ap_configured_cb_data; in wpas_p2p_move_go_no_csa()
9916 current_ssid->frequency = params.freq; in wpas_p2p_move_go_no_csa()
9917 wpa_s->connect_without_scan = current_ssid; in wpas_p2p_move_go_no_csa()
9918 wpa_s->reassociate = 1; in wpas_p2p_move_go_no_csa()
9919 wpa_s->disconnected = 0; in wpas_p2p_move_go_no_csa()
9928 if (!wpa_s->ap_iface || !wpa_s->current_ssid) in wpas_p2p_move_go()
9934 if (hostapd_csa_in_progress(wpa_s->ap_iface)) { in wpas_p2p_move_go()
9936 "P2P: CSA is in progress - not moving GO"); in wpas_p2p_move_go()
9941 * First, try a channel switch flow. If it is not supported or fails, in wpas_p2p_move_go()
9953 unsigned int num = wpa_s->num_multichan_concurrent; in wpas_p2p_reconsider_moving_go()
9961 /* Previous attempt to move a GO was not possible -- try again. */ in wpas_p2p_reconsider_moving_go()
9986 int freq; in wpas_p2p_consider_moving_one_go() local
9991 freq = wpa_s->current_ssid->frequency; in wpas_p2p_consider_moving_one_go()
9992 dfs_offload = (wpa_s->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD) && in wpas_p2p_consider_moving_one_go()
9993 ieee80211_is_dfs(freq, wpa_s->hw.modes, wpa_s->hw.num_modes); in wpas_p2p_consider_moving_one_go()
9995 if (freqs[i].freq == freq) { in wpas_p2p_consider_moving_one_go()
9999 if (!p2p_supported_freq_go(wpa_s->global->p2p, freq) && in wpas_p2p_consider_moving_one_go()
10002 "P2P: Freq=%d MHz no longer valid for GO", in wpas_p2p_consider_moving_one_go()
10003 freq); in wpas_p2p_consider_moving_one_go()
10007 /* Freq is not used by any other station interface */ in wpas_p2p_consider_moving_one_go()
10009 } else if (!p2p_supported_freq(wpa_s->global->p2p, in wpas_p2p_consider_moving_one_go()
10010 freqs[i].freq) && !dfs_offload) { in wpas_p2p_consider_moving_one_go()
10011 /* Freq is not valid for P2P use cases */ in wpas_p2p_consider_moving_one_go()
10013 } else if (wpa_s->conf->p2p_go_freq_change_policy == in wpas_p2p_consider_moving_one_go()
10016 } else if (wpa_s->conf->p2p_go_freq_change_policy == in wpas_p2p_consider_moving_one_go()
10018 wpas_p2p_go_is_peer_freq(wpa_s, freqs[i].freq)) { in wpas_p2p_consider_moving_one_go()
10020 } else if ((wpa_s->conf->p2p_go_freq_change_policy == in wpas_p2p_consider_moving_one_go()
10022 wpas_p2p_go_is_peer_freq(wpa_s, freqs[i].freq)) { in wpas_p2p_consider_moving_one_go()
10023 if (!p2p_get_group_num_members(wpa_s->p2p_group)) { in wpas_p2p_consider_moving_one_go()
10025 } else if ((wpa_s->drv_flags & in wpas_p2p_consider_moving_one_go()
10034 if (wpa_s->ap_iface->current_mode->mode == in wpas_p2p_consider_moving_one_go()
10035 ieee80211_freq_to_chan(freqs[i].freq, in wpas_p2p_consider_moving_one_go()
10052 "P2P: Cancel a GO move from freq=%d MHz", freq); in wpas_p2p_consider_moving_one_go()
10057 "P2P: GO move: policy CS is not allowed - setting timeout to re-consider GO move"); in wpas_p2p_consider_moving_one_go()
10077 if (hostapd_csa_in_progress(wpa_s->ap_iface)) { in wpas_p2p_consider_moving_one_go()
10079 "P2P: Not initiating a GO frequency change - CSA is in progress"); in wpas_p2p_consider_moving_one_go()
10083 if (invalid_freq && !wpas_p2p_disallowed_freq(wpa_s->global, freq)) in wpas_p2p_consider_moving_one_go()
10088 wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Move GO from freq=%d MHz in %d secs", in wpas_p2p_consider_moving_one_go()
10089 freq, timeout); in wpas_p2p_consider_moving_one_go()
10110 dl_list_for_each(ifs, &wpa_s->radio->ifaces, struct wpa_supplicant, in wpas_p2p_consider_moving_gos()
10112 if (ifs->current_ssid == NULL || in wpas_p2p_consider_moving_gos()
10113 ifs->current_ssid->mode != WPAS_MODE_P2P_GO) in wpas_p2p_consider_moving_gos()
10117 * The GO was just started or completed channel switch, no need in wpas_p2p_consider_moving_gos()
10124 "P2P: GO move - schedule re-consideration"); in wpas_p2p_consider_moving_gos()
10138 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL) in wpas_p2p_indicate_state_change()
10148 if (wpa_s == wpa_s->global->p2p_init_wpa_s && wpa_s->global->p2p) { in wpas_p2p_deinit_iface()
10151 wpas_p2p_deinit_global(wpa_s->global); in wpas_p2p_deinit_iface()
10158 if (wpa_s->ap_iface->bss) in wpas_p2p_ap_deinit()
10159 wpa_s->ap_iface->bss[0]->p2p_group = NULL; in wpas_p2p_ap_deinit()
10164 int wpas_p2p_lo_start(struct wpa_supplicant *wpa_s, unsigned int freq, in wpas_p2p_lo_start() argument
10168 struct p2p_data *p2p = wpa_s->global->p2p; in wpas_p2p_lo_start()
10174 if (wpa_s->p2p_lo_started) { in wpas_p2p_lo_start()
10180 if (wpa_s->global->p2p == NULL || in wpas_p2p_lo_start()
10181 !(wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_LISTEN_OFFLOAD)) { in wpas_p2p_lo_start()
10183 return -1; in wpas_p2p_lo_start()
10186 if (!p2p_supported_freq(wpa_s->global->p2p, freq)) { in wpas_p2p_lo_start()
10188 freq); in wpas_p2p_lo_start()
10189 return -1; in wpas_p2p_lo_start()
10193 dev_types_len = (wpa_s->conf->num_sec_device_types + 1) * in wpas_p2p_lo_start()
10197 return -1; in wpas_p2p_lo_start()
10198 os_memcpy(device_types, wpa_s->conf->device_type, WPS_DEV_TYPE_LEN); in wpas_p2p_lo_start()
10199 os_memcpy(&device_types[WPS_DEV_TYPE_LEN], wpa_s->conf->sec_device_type, in wpas_p2p_lo_start()
10200 wpa_s->conf->num_sec_device_types * WPS_DEV_TYPE_LEN); in wpas_p2p_lo_start()
10203 buf = p2p_build_probe_resp_template(p2p, freq); in wpas_p2p_lo_start()
10206 return -1; in wpas_p2p_lo_start()
10209 ret = wpa_drv_p2p_lo_start(wpa_s, freq, period, interval, count, in wpas_p2p_lo_start()
10220 wpa_s->p2p_lo_started = 1; in wpas_p2p_lo_start()
10234 if (!wpa_s->p2p_lo_started) in wpas_p2p_lo_stop()
10242 wpa_s->p2p_lo_started = 0; in wpas_p2p_lo_stop()