Lines Matching +full:on +full:- +full:the +full:- +full:go

2  * Wi-Fi Direct - P2P module
3 * Copyright (c) 2009-2010, Atheros Communications
5 * This software may be distributed under the terms of the BSD license.
39 * Many drivers are using 30 second timeout on scan results. Allow a bit larger
45 * P2P_PEER_EXPIRATION_AGE - Number of seconds after which inactive peer
60 dl_list_for_each_safe(dev, n, &p2p->devices, struct p2p_device, list) { in p2p_expire_peers()
61 if (dev->last_seen.sec + P2P_PEER_EXPIRATION_AGE >= now.sec) in p2p_expire_peers()
64 if (dev == p2p->go_neg_peer) { in p2p_expire_peers()
66 * GO Negotiation is in progress with the peer, so in p2p_expire_peers()
67 * don't expire the peer entry until GO Negotiation in p2p_expire_peers()
73 if (p2p->cfg->go_connected && in p2p_expire_peers()
74 p2p->cfg->go_connected(p2p->cfg->cb_ctx, in p2p_expire_peers()
75 dev->info.p2p_device_addr)) { in p2p_expire_peers()
77 * We are connected as a client to a group in which the in p2p_expire_peers()
78 * peer is the GO, so do not expire the peer entry. in p2p_expire_peers()
80 os_get_reltime(&dev->last_seen); in p2p_expire_peers()
84 for (i = 0; i < p2p->num_groups; i++) { in p2p_expire_peers()
86 p2p->groups[i], dev->info.p2p_device_addr)) in p2p_expire_peers()
89 if (i < p2p->num_groups) { in p2p_expire_peers()
91 * The peer is connected as a client in a group where in p2p_expire_peers()
92 * we are the GO, so do not expire the peer entry. in p2p_expire_peers()
94 os_get_reltime(&dev->last_seen); in p2p_expire_peers()
99 MAC2STR(dev->info.p2p_device_addr)); in p2p_expire_peers()
100 dl_list_del(&dev->list); in p2p_expire_peers()
143 return p2p_state_txt(p2p->state); in p2p_get_state_txt()
149 return p2p ? p2p->p2ps_adv_list : NULL; in p2p_get_p2ps_adv_list()
156 os_memcpy(p2p->intended_addr, intended_addr, ETH_ALEN); in p2p_set_intended_addr()
169 return dev->wps_prov_info; in p2p_get_provisioning_info()
184 dev->wps_prov_info = 0; in p2p_clear_provisioning_info()
190 p2p_dbg(p2p, "State %s -> %s", in p2p_set_state()
191 p2p_state_txt(p2p->state), p2p_state_txt(new_state)); in p2p_set_state()
192 p2p->state = new_state; in p2p_set_state()
194 if (new_state == P2P_IDLE && p2p->pending_channel) { in p2p_set_state()
196 p2p->cfg->reg_class = p2p->pending_reg_class; in p2p_set_state()
197 p2p->cfg->channel = p2p->pending_channel; in p2p_set_state()
198 p2p->pending_reg_class = 0; in p2p_set_state()
199 p2p->pending_channel = 0; in p2p_set_state()
207 p2p_state_txt(p2p->state), sec, usec); in p2p_set_timeout()
215 p2p_dbg(p2p, "Clear timeout (state=%s)", p2p_state_txt(p2p->state)); in p2p_clear_timeout()
223 struct p2p_device *peer = p2p->go_neg_peer; in p2p_go_neg_failed()
229 if (p2p->state != P2P_SEARCH) { in p2p_go_neg_failed()
231 * Clear timeouts related to GO Negotiation if no new p2p_find in p2p_go_neg_failed()
238 peer->flags &= ~P2P_DEV_PEER_WAITING_RESPONSE; in p2p_go_neg_failed()
239 peer->wps_method = WPS_NOT_READY; in p2p_go_neg_failed()
240 peer->oob_pw_id = 0; in p2p_go_neg_failed()
241 wpabuf_free(peer->go_neg_conf); in p2p_go_neg_failed()
242 peer->go_neg_conf = NULL; in p2p_go_neg_failed()
243 p2p->go_neg_peer = NULL; in p2p_go_neg_failed()
247 os_memcpy(res.peer_device_addr, peer->info.p2p_device_addr, ETH_ALEN); in p2p_go_neg_failed()
248 os_memcpy(res.peer_interface_addr, peer->intended_addr, ETH_ALEN); in p2p_go_neg_failed()
249 p2p->cfg->go_neg_completed(p2p->cfg->cb_ctx, &res); in p2p_go_neg_failed()
260 p2p_state_txt(p2p->state)); in p2p_listen_in_find()
262 if (p2p->pending_listen_freq) { in p2p_listen_in_find()
268 freq = p2p_channel_to_freq(p2p->cfg->reg_class, p2p->cfg->channel); in p2p_listen_in_find()
276 tu = (r % ((p2p->max_disc_int - p2p->min_disc_int) + 1) + in p2p_listen_in_find()
277 p2p->min_disc_int) * 100; in p2p_listen_in_find()
278 if (p2p->max_disc_tu >= 0 && tu > (unsigned int) p2p->max_disc_tu) in p2p_listen_in_find()
279 tu = p2p->max_disc_tu; in p2p_listen_in_find()
281 tu = 100; /* Need to wait in non-device discovery use cases */ in p2p_listen_in_find()
282 if (p2p->cfg->max_listen && 1024 * tu / 1000 > p2p->cfg->max_listen) in p2p_listen_in_find()
283 tu = p2p->cfg->max_listen * 1000 / 1024; in p2p_listen_in_find()
295 p2p->pending_listen_freq = freq; in p2p_listen_in_find()
296 p2p->pending_listen_sec = 0; in p2p_listen_in_find()
297 p2p->pending_listen_usec = 1024 * tu; in p2p_listen_in_find()
299 if (p2p->cfg->start_listen(p2p->cfg->cb_ctx, freq, 1024 * tu / 1000, in p2p_listen_in_find()
302 p2p->pending_listen_freq = 0; in p2p_listen_in_find()
304 p2p->pending_listen_wait_drv = true; in p2p_listen_in_find()
317 if (p2p->pending_listen_freq) { in p2p_listen()
320 return -1; in p2p_listen()
323 freq = p2p_channel_to_freq(p2p->cfg->reg_class, p2p->cfg->channel); in p2p_listen()
326 return -1; in p2p_listen()
329 p2p->pending_listen_sec = timeout / 1000; in p2p_listen()
330 p2p->pending_listen_usec = (timeout % 1000) * 1000; in p2p_listen()
332 if (p2p->p2p_scan_running) { in p2p_listen()
333 if (p2p->start_after_scan == P2P_AFTER_SCAN_CONNECT) { in p2p_listen()
334 p2p_dbg(p2p, "p2p_scan running - connect is already pending - skip listen"); in p2p_listen()
337 p2p_dbg(p2p, "p2p_scan running - delay start of listen state"); in p2p_listen()
338 p2p->start_after_scan = P2P_AFTER_SCAN_LISTEN; in p2p_listen()
344 return -1; in p2p_listen()
346 p2p->pending_listen_freq = freq; in p2p_listen()
348 if (p2p->cfg->start_listen(p2p->cfg->cb_ctx, freq, timeout, ies) < 0) { in p2p_listen()
350 p2p->pending_listen_freq = 0; in p2p_listen()
352 return -1; in p2p_listen()
354 p2p->pending_listen_wait_drv = true; in p2p_listen()
366 dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) { in p2p_device_clear_reported()
367 dev->flags &= ~P2P_DEV_REPORTED; in p2p_device_clear_reported()
368 dev->sd_reqs = 0; in p2p_device_clear_reported()
374 * p2p_get_device - Fetch a peer entry
376 * @addr: P2P Device Address of the peer
377 * Returns: Pointer to the device entry or %NULL if not found
382 dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) { in p2p_get_device()
383 if (ether_addr_equal(dev->info.p2p_device_addr, addr)) in p2p_get_device()
391 * p2p_get_device_interface - Fetch a peer entry based on P2P Interface Address
393 * @addr: P2P Interface Address of the peer
394 * Returns: Pointer to the device entry or %NULL if not found
400 dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) { in p2p_get_device_interface()
401 if (ether_addr_equal(dev->interface_addr, addr)) in p2p_get_device_interface()
409 * p2p_create_device - Create a peer entry
411 * @addr: P2P Device Address of the peer
412 * Returns: Pointer to the device entry or %NULL on failure
414 * If there is already an entry for the peer, it will be returned instead of
427 dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) { in p2p_create_device()
430 os_reltime_before(&dev->last_seen, &oldest->last_seen)) in p2p_create_device()
433 if (count + 1 > p2p->cfg->max_peers && oldest) { in p2p_create_device()
436 MACSTR, MAC2STR(oldest->info.p2p_device_addr)); in p2p_create_device()
437 dl_list_del(&oldest->list); in p2p_create_device()
444 dl_list_add(&p2p->devices, &dev->list); in p2p_create_device()
445 os_memcpy(dev->info.p2p_device_addr, addr, ETH_ALEN); in p2p_create_device()
446 dev->support_6ghz = false; in p2p_create_device()
455 p2p_copy_filter_devname(dev->info.device_name, in p2p_copy_client_info()
456 sizeof(dev->info.device_name), in p2p_copy_client_info()
457 cli->dev_name, cli->dev_name_len); in p2p_copy_client_info()
458 dev->info.dev_capab = cli->dev_capab; in p2p_copy_client_info()
459 dev->info.config_methods = cli->config_methods; in p2p_copy_client_info()
460 os_memcpy(dev->info.pri_dev_type, cli->pri_dev_type, 8); in p2p_copy_client_info()
461 dev->info.wps_sec_dev_type_list_len = 8 * cli->num_sec_dev_types; in p2p_copy_client_info()
462 if (dev->info.wps_sec_dev_type_list_len > WPS_SEC_DEV_TYPE_MAX_LEN) in p2p_copy_client_info()
463 dev->info.wps_sec_dev_type_list_len = WPS_SEC_DEV_TYPE_MAX_LEN; in p2p_copy_client_info()
464 os_memcpy(dev->info.wps_sec_dev_type_list, cli->sec_dev_types, in p2p_copy_client_info()
465 dev->info.wps_sec_dev_type_list_len); in p2p_copy_client_info()
482 return -1; in p2p_add_group_clients()
485 * Clear old data for this group; if the devices are still in the in p2p_add_group_clients()
486 * group, the information will be restored in the loop following this. in p2p_add_group_clients()
488 dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) { in p2p_add_group_clients()
489 if (ether_addr_equal(dev->member_in_go_iface, in p2p_add_group_clients()
491 os_memset(dev->member_in_go_iface, 0, ETH_ALEN); in p2p_add_group_clients()
492 os_memset(dev->member_in_go_dev, 0, ETH_ALEN); in p2p_add_group_clients()
498 if (ether_addr_equal(cli->p2p_device_addr, p2p->cfg->dev_addr)) in p2p_add_group_clients()
500 dev = p2p_get_device(p2p, cli->p2p_device_addr); in p2p_add_group_clients()
502 if (dev->flags & (P2P_DEV_GROUP_CLIENT_ONLY | in p2p_add_group_clients()
506 * received this directly from the client. in p2p_add_group_clients()
515 dev->info.dev_capab &= in p2p_add_group_clients()
517 dev->info.dev_capab |= in p2p_add_group_clients()
518 cli->dev_capab & in p2p_add_group_clients()
521 if (dev->flags & P2P_DEV_PROBE_REQ_ONLY) { in p2p_add_group_clients()
522 dev->flags &= ~P2P_DEV_PROBE_REQ_ONLY; in p2p_add_group_clients()
525 dev = p2p_create_device(p2p, cli->p2p_device_addr); in p2p_add_group_clients()
528 dev->flags |= P2P_DEV_GROUP_CLIENT_ONLY; in p2p_add_group_clients()
530 dev->oper_freq = freq; in p2p_add_group_clients()
531 p2p->cfg->dev_found(p2p->cfg->cb_ctx, in p2p_add_group_clients()
532 dev->info.p2p_device_addr, in p2p_add_group_clients()
533 &dev->info, 1); in p2p_add_group_clients()
534 dev->flags |= P2P_DEV_REPORTED | P2P_DEV_REPORTED_ONCE; in p2p_add_group_clients()
537 os_memcpy(dev->interface_addr, cli->p2p_interface_addr, in p2p_add_group_clients()
539 os_memcpy(&dev->last_seen, rx_time, sizeof(struct os_reltime)); in p2p_add_group_clients()
540 os_memcpy(dev->member_in_go_dev, go_dev_addr, ETH_ALEN); in p2p_add_group_clients()
541 os_memcpy(dev->member_in_go_iface, go_interface_addr, in p2p_add_group_clients()
543 dev->flags |= P2P_DEV_LAST_SEEN_AS_GROUP_CLIENT; in p2p_add_group_clients()
553 os_memcpy(dev->info.device_name, msg->device_name, in p2p_copy_wps_info()
554 sizeof(dev->info.device_name)); in p2p_copy_wps_info()
556 if (msg->manufacturer && in p2p_copy_wps_info()
557 msg->manufacturer_len < sizeof(dev->info.manufacturer)) { in p2p_copy_wps_info()
558 os_memset(dev->info.manufacturer, 0, in p2p_copy_wps_info()
559 sizeof(dev->info.manufacturer)); in p2p_copy_wps_info()
560 os_memcpy(dev->info.manufacturer, msg->manufacturer, in p2p_copy_wps_info()
561 msg->manufacturer_len); in p2p_copy_wps_info()
564 if (msg->model_name && in p2p_copy_wps_info()
565 msg->model_name_len < sizeof(dev->info.model_name)) { in p2p_copy_wps_info()
566 os_memset(dev->info.model_name, 0, in p2p_copy_wps_info()
567 sizeof(dev->info.model_name)); in p2p_copy_wps_info()
568 os_memcpy(dev->info.model_name, msg->model_name, in p2p_copy_wps_info()
569 msg->model_name_len); in p2p_copy_wps_info()
572 if (msg->model_number && in p2p_copy_wps_info()
573 msg->model_number_len < sizeof(dev->info.model_number)) { in p2p_copy_wps_info()
574 os_memset(dev->info.model_number, 0, in p2p_copy_wps_info()
575 sizeof(dev->info.model_number)); in p2p_copy_wps_info()
576 os_memcpy(dev->info.model_number, msg->model_number, in p2p_copy_wps_info()
577 msg->model_number_len); in p2p_copy_wps_info()
580 if (msg->serial_number && in p2p_copy_wps_info()
581 msg->serial_number_len < sizeof(dev->info.serial_number)) { in p2p_copy_wps_info()
582 os_memset(dev->info.serial_number, 0, in p2p_copy_wps_info()
583 sizeof(dev->info.serial_number)); in p2p_copy_wps_info()
584 os_memcpy(dev->info.serial_number, msg->serial_number, in p2p_copy_wps_info()
585 msg->serial_number_len); in p2p_copy_wps_info()
588 if (msg->pri_dev_type) in p2p_copy_wps_info()
589 os_memcpy(dev->info.pri_dev_type, msg->pri_dev_type, in p2p_copy_wps_info()
590 sizeof(dev->info.pri_dev_type)); in p2p_copy_wps_info()
591 else if (msg->wps_pri_dev_type) in p2p_copy_wps_info()
592 os_memcpy(dev->info.pri_dev_type, msg->wps_pri_dev_type, in p2p_copy_wps_info()
593 sizeof(dev->info.pri_dev_type)); in p2p_copy_wps_info()
595 if (msg->wps_sec_dev_type_list) { in p2p_copy_wps_info()
596 os_memcpy(dev->info.wps_sec_dev_type_list, in p2p_copy_wps_info()
597 msg->wps_sec_dev_type_list, in p2p_copy_wps_info()
598 msg->wps_sec_dev_type_list_len); in p2p_copy_wps_info()
599 dev->info.wps_sec_dev_type_list_len = in p2p_copy_wps_info()
600 msg->wps_sec_dev_type_list_len; in p2p_copy_wps_info()
603 if (msg->capability) { in p2p_copy_wps_info()
608 dev->info.dev_capab &= P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY; in p2p_copy_wps_info()
609 dev->info.dev_capab |= msg->capability[0] & in p2p_copy_wps_info()
611 dev->info.group_capab = msg->capability[1]; in p2p_copy_wps_info()
616 if (msg->ext_listen_timing) { in p2p_copy_wps_info()
617 dev->ext_listen_period = WPA_GET_LE16(msg->ext_listen_timing); in p2p_copy_wps_info()
618 dev->ext_listen_interval = in p2p_copy_wps_info()
619 WPA_GET_LE16(msg->ext_listen_timing + 2); in p2p_copy_wps_info()
624 new_config_methods = msg->config_methods ? in p2p_copy_wps_info()
625 msg->config_methods : msg->wps_config_methods; in p2p_copy_wps_info()
627 dev->info.config_methods != new_config_methods) { in p2p_copy_wps_info()
629 " config_methods 0x%x -> 0x%x", in p2p_copy_wps_info()
630 MAC2STR(dev->info.p2p_device_addr), in p2p_copy_wps_info()
631 dev->info.config_methods, in p2p_copy_wps_info()
633 dev->info.config_methods = new_config_methods; in p2p_copy_wps_info()
642 if (msg->capability && in p2p_update_peer_6ghz_capab()
643 (msg->capability[0] & P2P_DEV_CAPAB_6GHZ_BAND_CAPABLE)) in p2p_update_peer_6ghz_capab()
644 dev->support_6ghz = true; in p2p_update_peer_6ghz_capab()
654 wpabuf_free(dev->info.vendor_elems); in p2p_update_peer_vendor_elems()
655 dev->info.vendor_elems = NULL; in p2p_update_peer_vendor_elems()
659 for (pos = ies; end - pos > 1; pos += len) { in p2p_update_peer_vendor_elems()
663 if (len > end - pos) in p2p_update_peer_vendor_elems()
680 /* Unknown vendor element - make raw IE data available */ in p2p_update_peer_vendor_elems()
681 if (wpabuf_resize(&dev->info.vendor_elems, 2 + len) < 0) in p2p_update_peer_vendor_elems()
683 wpabuf_put_data(dev->info.vendor_elems, pos - 2, 2 + len); in p2p_update_peer_vendor_elems()
684 if (wpabuf_size(dev->info.vendor_elems) > 2000) in p2p_update_peer_vendor_elems()
693 if (dev->info.wfd_subelems && msg->wfd_subelems) { in p2p_compare_wfd_info()
694 if (dev->info.wfd_subelems->used != msg->wfd_subelems->used) in p2p_compare_wfd_info()
697 return os_memcmp(dev->info.wfd_subelems->buf, in p2p_compare_wfd_info()
698 msg->wfd_subelems->buf, in p2p_compare_wfd_info()
699 dev->info.wfd_subelems->used); in p2p_compare_wfd_info()
701 if (dev->info.wfd_subelems || msg->wfd_subelems) in p2p_compare_wfd_info()
709 * p2p_add_device - Add peer entries based on scan results or P2P frames
713 * @level: Signal level (signal strength of the received frame from the peer)
714 * @freq: Frequency on which the Beacon or Probe Response frame was received
715 * @rx_time: Time when the result was received
716 * @ies: IEs from the Beacon or Probe Response frame
718 * @scan_res: Whether this was based on scan results
719 * Returns: 0 on success, -1 on failure
721 * If the scan result is for a GO, the clients in the group will also be added
722 * to the peer table. This function can also be used with some other frames
742 return -1; in p2p_add_device()
752 return -1; in p2p_add_device()
755 if (!is_zero_ether_addr(p2p->peer_filter) && in p2p_add_device()
756 !ether_addr_equal(p2p_dev_addr, p2p->peer_filter)) { in p2p_add_device()
766 return -1; in p2p_add_device()
775 * Update the device entry only if the new peer in p2p_add_device()
776 * entry is newer than the one previously stored, or if in p2p_add_device()
777 * the device was previously seen as a P2P Client in a group in p2p_add_device()
778 * and the new entry isn't older than a threshold. in p2p_add_device()
780 if (dev->last_seen.sec > 0 && in p2p_add_device()
781 os_reltime_before(rx_time, &dev->last_seen) && in p2p_add_device()
782 (!(dev->flags & P2P_DEV_LAST_SEEN_AS_GROUP_CLIENT) || in p2p_add_device()
783 os_reltime_expired(&dev->last_seen, rx_time, in p2p_add_device()
786 "Do not update peer entry based on old frame (rx_time=%u.%06u last_seen=%u.%06u flags=0x%x)", in p2p_add_device()
787 (unsigned int) rx_time->sec, in p2p_add_device()
788 (unsigned int) rx_time->usec, in p2p_add_device()
789 (unsigned int) dev->last_seen.sec, in p2p_add_device()
790 (unsigned int) dev->last_seen.usec, in p2p_add_device()
791 dev->flags); in p2p_add_device()
793 return -1; in p2p_add_device()
796 os_memcpy(&dev->last_seen, rx_time, sizeof(struct os_reltime)); in p2p_add_device()
798 dev->flags &= ~(P2P_DEV_PROBE_REQ_ONLY | P2P_DEV_GROUP_CLIENT_ONLY | in p2p_add_device()
802 os_memcpy(dev->interface_addr, addr, ETH_ALEN); in p2p_add_device()
804 msg.ssid[1] <= sizeof(dev->oper_ssid) && in p2p_add_device()
808 os_memcpy(dev->oper_ssid, msg.ssid + 2, msg.ssid[1]); in p2p_add_device()
809 dev->oper_ssid_len = msg.ssid[1]; in p2p_add_device()
812 wpabuf_free(dev->info.p2ps_instance); in p2p_add_device()
813 dev->info.p2ps_instance = NULL; in p2p_add_device()
815 dev->info.p2ps_instance = wpabuf_alloc_copy( in p2p_add_device()
826 p2p_dbg(p2p, "Update Listen frequency based on DS Parameter Set IE: %d -> %d MHz", in p2p_add_device()
832 if (dev->listen_freq && dev->listen_freq != freq && scan_res) { in p2p_add_device()
833 p2p_dbg(p2p, "Update Listen frequency based on scan results (" in p2p_add_device()
834 MACSTR " %d -> %d MHz (DS param %d)", in p2p_add_device()
835 MAC2STR(dev->info.p2p_device_addr), dev->listen_freq, in p2p_add_device()
836 freq, msg.ds_params ? *msg.ds_params : -1); in p2p_add_device()
839 dev->listen_freq = freq; in p2p_add_device()
841 dev->oper_freq = freq; in p2p_add_device()
843 dev->info.level = level; in p2p_add_device()
845 dev_name_changed = os_strncmp(dev->info.device_name, msg.device_name, in p2p_add_device()
851 wpabuf_free(dev->info.wps_vendor_ext[i]); in p2p_add_device()
852 dev->info.wps_vendor_ext[i] = NULL; in p2p_add_device()
858 dev->info.wps_vendor_ext[i] = wpabuf_alloc_copy( in p2p_add_device()
860 if (dev->info.wps_vendor_ext[i] == NULL) in p2p_add_device()
867 wpabuf_free(dev->info.wfd_subelems); in p2p_add_device()
869 dev->info.wfd_subelems = wpabuf_dup(msg.wfd_subelems); in p2p_add_device()
871 dev->info.wfd_subelems = NULL; in p2p_add_device()
884 if (dev->flags & P2P_DEV_REPORTED && !wfd_changed && in p2p_add_device()
887 (dev->flags & P2P_DEV_P2PS_REPORTED))) in p2p_add_device()
891 freq, (unsigned int) rx_time->sec, in p2p_add_device()
892 (unsigned int) rx_time->usec); in p2p_add_device()
893 if (dev->flags & P2P_DEV_USER_REJECTED) { in p2p_add_device()
898 if (dev->info.config_methods == 0 && in p2p_add_device()
901 * If we have only seen a Beacon frame from a GO, we do not yet in p2p_add_device()
903 * applications use config_methods value from P2P-DEVICE-FOUND in p2p_add_device()
907 * At least for now, do this only if the peer was detected on in p2p_add_device()
908 * one of the social channels since that peer can be easily be in p2p_add_device()
910 * passive scan on this channels, so this can be done through in p2p_add_device()
911 * Probe Response frame that includes the config_methods in p2p_add_device()
919 p2p->cfg->dev_found(p2p->cfg->cb_ctx, addr, &dev->info, in p2p_add_device()
920 !(dev->flags & P2P_DEV_REPORTED_ONCE)); in p2p_add_device()
921 dev->flags |= P2P_DEV_REPORTED | P2P_DEV_REPORTED_ONCE; in p2p_add_device()
924 dev->flags |= P2P_DEV_P2PS_REPORTED; in p2p_add_device()
934 if (p2p->go_neg_peer == dev) { in p2p_device_free()
936 * If GO Negotiation is in progress, report that it has failed. in p2p_device_free()
938 p2p_go_neg_failed(p2p, -1); in p2p_device_free()
940 if (p2p->invite_peer == dev) in p2p_device_free()
941 p2p->invite_peer = NULL; in p2p_device_free()
942 if (p2p->sd_peer == dev) in p2p_device_free()
943 p2p->sd_peer = NULL; in p2p_device_free()
944 if (p2p->pending_client_disc_go == dev) in p2p_device_free()
945 p2p->pending_client_disc_go = NULL; in p2p_device_free()
948 if (dev->flags & P2P_DEV_REPORTED_ONCE) in p2p_device_free()
949 p2p->cfg->dev_lost(p2p->cfg->cb_ctx, in p2p_device_free()
950 dev->info.p2p_device_addr); in p2p_device_free()
953 wpabuf_free(dev->info.wps_vendor_ext[i]); in p2p_device_free()
954 dev->info.wps_vendor_ext[i] = NULL; in p2p_device_free()
957 wpabuf_free(dev->info.wfd_subelems); in p2p_device_free()
958 wpabuf_free(dev->info.vendor_elems); in p2p_device_free()
959 wpabuf_free(dev->go_neg_conf); in p2p_device_free()
960 wpabuf_free(dev->info.p2ps_instance); in p2p_device_free()
976 c = &p2p->cfg->channels; in p2p_get_next_prog_freq()
977 for (cl = 0; cl < c->reg_classes; cl++) { in p2p_get_next_prog_freq()
978 cla = &c->reg_class[cl]; in p2p_get_next_prog_freq()
979 if (cla->reg_class != p2p->last_prog_scan_class) in p2p_get_next_prog_freq()
981 for (ch = 0; ch < cla->channels; ch++) { in p2p_get_next_prog_freq()
982 if (cla->channel[ch] == p2p->last_prog_scan_chan) { in p2p_get_next_prog_freq()
993 reg_class = c->reg_class[0].reg_class; in p2p_get_next_prog_freq()
994 channel = c->reg_class[0].channel[0]; in p2p_get_next_prog_freq()
996 /* Pick the next channel */ in p2p_get_next_prog_freq()
998 if (ch == cla->channels) { in p2p_get_next_prog_freq()
1000 if (cl == c->reg_classes) in p2p_get_next_prog_freq()
1004 reg_class = c->reg_class[cl].reg_class; in p2p_get_next_prog_freq()
1005 channel = c->reg_class[cl].channel[ch]; in p2p_get_next_prog_freq()
1009 p2p_dbg(p2p, "Next progressive search channel: reg_class %u channel %u -> %d MHz", in p2p_get_next_prog_freq()
1011 p2p->last_prog_scan_class = reg_class; in p2p_get_next_prog_freq()
1012 p2p->last_prog_scan_chan = channel; in p2p_get_next_prog_freq()
1027 if (p2p->drv_in_listen) { in p2p_search()
1028 p2p_dbg(p2p, "Driver is still in Listen state - wait for it to end before continuing"); in p2p_search()
1031 p2p->cfg->stop_listen(p2p->cfg->cb_ctx); in p2p_search()
1032 p2p->pending_listen_wait_drv = false; in p2p_search()
1034 if (p2p->find_pending_full && in p2p_search()
1035 (p2p->find_type == P2P_FIND_PROGRESSIVE || in p2p_search()
1036 p2p->find_type == P2P_FIND_START_WITH_FULL)) { in p2p_search()
1039 p2p->find_pending_full = 0; in p2p_search()
1040 } else if ((p2p->find_type == P2P_FIND_PROGRESSIVE && in p2p_search()
1042 (p2p->find_type == P2P_FIND_START_WITH_FULL && in p2p_search()
1043 (freq = p2p->find_specified_freq) > 0)) { in p2p_search()
1051 res = p2p->cfg->p2p_scan(p2p->cfg->cb_ctx, type, freq, in p2p_search()
1052 p2p->num_req_dev_types, p2p->req_dev_types, in p2p_search()
1053 p2p->find_dev_id, pw_id, p2p->include_6ghz); in p2p_search()
1064 p2p_dbg(p2p, "Find timeout -> stop"); in p2p_find_timeout()
1073 /* Do continue find even for the first p2p_find_scan */ in p2p_notify_scan_trigger_status()
1077 p2p->p2p_scan_running = 1; in p2p_notify_scan_trigger_status()
1090 op = p2p->start_after_scan; in p2p_run_after_scan()
1091 p2p->start_after_scan = P2P_AFTER_SCAN_NOTHING; in p2p_run_after_scan()
1097 p2p_listen(p2p, p2p->pending_listen_sec * 1000 + in p2p_run_after_scan()
1098 p2p->pending_listen_usec / 1000); in p2p_run_after_scan()
1102 MAC2STR(p2p->after_scan_peer)); in p2p_run_after_scan()
1103 dev = p2p_get_device(p2p, p2p->after_scan_peer); in p2p_run_after_scan()
1120 p2p_dbg(p2p, "p2p_scan timeout (running=%d)", p2p->p2p_scan_running); in p2p_scan_timeout()
1121 running = p2p->p2p_scan_running; in p2p_scan_timeout()
1123 p2p->p2p_scan_running = 0; in p2p_scan_timeout()
1132 p2p->num_req_dev_types = 0; in p2p_free_req_dev_types()
1133 os_free(p2p->req_dev_types); in p2p_free_req_dev_types()
1134 p2p->req_dev_types = NULL; in p2p_free_req_dev_types()
1149 os_memcpy(hash, p2p->wild_card_hash, P2PS_HASH_LEN); in p2ps_gen_hash()
1160 str_buf[i] = str[i] - 'A' + 'a'; in p2ps_gen_hash()
1183 if (p2p->p2p_scan_running) { in p2p_find()
1189 p2p->req_dev_types = os_memdup(req_dev_types, in p2p_find()
1192 if (p2p->req_dev_types == NULL) in p2p_find()
1193 return -1; in p2p_find()
1194 p2p->num_req_dev_types = num_req_dev_types; in p2p_find()
1198 os_memcpy(p2p->find_dev_id_buf, dev_id, ETH_ALEN); in p2p_find()
1199 p2p->find_dev_id = p2p->find_dev_id_buf; in p2p_find()
1201 p2p->find_dev_id = NULL; in p2p_find()
1202 p2p->include_6ghz = p2p_wfd_enabled(p2p) && include_6ghz; in p2p_find()
1205 p2p->p2ps_seek = 0; in p2p_find()
1212 p2p->p2ps_seek_count = 0; in p2p_find()
1213 p2p->p2ps_seek = 1; in p2p_find()
1224 os_memcpy(&p2p->p2ps_seek_hash[count * P2PS_HASH_LEN], in p2p_find()
1229 p2p->p2ps_seek_count = count; in p2p_find()
1230 p2p->p2ps_seek = 1; in p2p_find()
1232 p2p->p2ps_seek_count = 0; in p2p_find()
1233 p2p->p2ps_seek = 1; in p2p_find()
1237 if (p2p->p2ps_seek_count == 0 && p2p->p2ps_seek) { in p2p_find()
1238 p2p->p2ps_seek_count = 1; in p2p_find()
1239 os_memcpy(&p2p->p2ps_seek_hash, p2p->wild_card_hash, in p2p_find()
1243 p2p->start_after_scan = P2P_AFTER_SCAN_NOTHING; in p2p_find()
1245 if (p2p->pending_listen_freq) { in p2p_find()
1247 p2p->pending_listen_freq = 0; in p2p_find()
1249 p2p->cfg->stop_listen(p2p->cfg->cb_ctx); in p2p_find()
1250 p2p->pending_listen_wait_drv = false; in p2p_find()
1251 p2p->find_pending_full = 0; in p2p_find()
1252 p2p->find_type = type; in p2p_find()
1254 p2p->find_specified_freq = freq; in p2p_find()
1256 p2p->find_specified_freq = 0; in p2p_find()
1258 os_memset(p2p->sd_query_no_ack, 0, ETH_ALEN); in p2p_find()
1260 p2p->search_delay = search_delay; in p2p_find()
1261 p2p->in_search_delay = 0; in p2p_find()
1263 p2p->last_p2p_find_timeout = timeout; in p2p_find()
1272 * Start with the specified channel and then move to in p2p_find()
1275 res = p2p->cfg->p2p_scan(p2p->cfg->cb_ctx, in p2p_find()
1277 p2p->num_req_dev_types, in p2p_find()
1278 p2p->req_dev_types, dev_id, in p2p_find()
1280 p2p->include_6ghz); in p2p_find()
1285 res = p2p->cfg->p2p_scan(p2p->cfg->cb_ctx, P2P_SCAN_FULL, 0, in p2p_find()
1286 p2p->num_req_dev_types, in p2p_find()
1287 p2p->req_dev_types, dev_id, in p2p_find()
1288 DEV_PW_DEFAULT, p2p->include_6ghz); in p2p_find()
1291 res = p2p->cfg->p2p_scan(p2p->cfg->cb_ctx, P2P_SCAN_SOCIAL, 0, in p2p_find()
1292 p2p->num_req_dev_types, in p2p_find()
1293 p2p->req_dev_types, dev_id, in p2p_find()
1294 DEV_PW_DEFAULT, p2p->include_6ghz); in p2p_find()
1297 return -1; in p2p_find()
1301 p2p->find_start = start; in p2p_find()
1303 if (res != 0 && p2p->p2p_scan_running) { in p2p_find()
1304 p2p_dbg(p2p, "Failed to start p2p_scan - another p2p_scan was already running"); in p2p_find()
1305 /* wait for the previous p2p_scan to complete */ in p2p_find()
1308 p2p->find_pending_full = 1; in p2p_find()
1325 if (p2p->state == P2P_SEARCH || p2p->state == P2P_SD_DURING_FIND) in p2p_stop_find_for_freq()
1326 p2p->cfg->find_stopped(p2p->cfg->cb_ctx); in p2p_stop_find_for_freq()
1328 p2p->p2ps_seek_count = 0; in p2p_stop_find_for_freq()
1332 p2p->start_after_scan = P2P_AFTER_SCAN_NOTHING; in p2p_stop_find_for_freq()
1333 if (p2p->go_neg_peer) in p2p_stop_find_for_freq()
1334 p2p->go_neg_peer->flags &= ~P2P_DEV_PEER_WAITING_RESPONSE; in p2p_stop_find_for_freq()
1335 p2p->go_neg_peer = NULL; in p2p_stop_find_for_freq()
1336 p2p->sd_peer = NULL; in p2p_stop_find_for_freq()
1337 p2p->invite_peer = NULL; in p2p_stop_find_for_freq()
1339 p2p->send_action_in_progress = 0; in p2p_stop_find_for_freq()
1347 __func__, freq, p2p->pending_listen_freq, p2p->in_listen, in p2p_stop_listen_for_freq()
1348 p2p->drv_in_listen); in p2p_stop_listen_for_freq()
1350 ((p2p->drv_in_listen == freq && p2p->in_listen) || in p2p_stop_listen_for_freq()
1351 p2p->pending_listen_freq == (unsigned int) freq)) { in p2p_stop_listen_for_freq()
1352 p2p_dbg(p2p, "Skip stop_listen since we are on correct channel for response"); in p2p_stop_listen_for_freq()
1355 if (p2p->in_listen) { in p2p_stop_listen_for_freq()
1356 p2p->in_listen = 0; in p2p_stop_listen_for_freq()
1359 if (p2p->drv_in_listen) { in p2p_stop_listen_for_freq()
1361 * The driver may not deliver callback to p2p_listen_end() in p2p_stop_listen_for_freq()
1362 * when the operation gets canceled, so clear the internal in p2p_stop_listen_for_freq()
1365 p2p_dbg(p2p, "Clear drv_in_listen (%d)", p2p->drv_in_listen); in p2p_stop_listen_for_freq()
1366 p2p->drv_in_listen = 0; in p2p_stop_listen_for_freq()
1368 if (p2p->pending_listen_freq && in p2p_stop_listen_for_freq()
1369 p2p->pending_listen_freq != (unsigned int) freq && in p2p_stop_listen_for_freq()
1370 !p2p->drv_in_listen && p2p->pending_listen_wait_drv) { in p2p_stop_listen_for_freq()
1372 "Clear pending_listen_freq since the started listen did not complete before being stopped"); in p2p_stop_listen_for_freq()
1373 p2p->pending_listen_freq = 0; in p2p_stop_listen_for_freq()
1375 p2p->cfg->stop_listen(p2p->cfg->cb_ctx); in p2p_stop_listen_for_freq()
1376 p2p->pending_listen_wait_drv = false; in p2p_stop_listen_for_freq()
1382 if (p2p->state != P2P_LISTEN_ONLY) { in p2p_stop_listen()
1394 p2p->pending_listen_freq = 0; in p2p_stop_find()
1401 unsigned int pref_freq, int go) in p2p_prepare_channel_pref() argument
1406 p2p_dbg(p2p, "Prepare channel pref - force_freq=%u pref_freq=%u go=%d", in p2p_prepare_channel_pref()
1407 force_freq, pref_freq, go); in p2p_prepare_channel_pref()
1410 return -1; in p2p_prepare_channel_pref()
1413 if (!p2p_channels_includes(&p2p->cfg->channels, op_class, op_channel) && in p2p_prepare_channel_pref()
1414 (go || !p2p_channels_includes(&p2p->cfg->cli_channels, op_class, in p2p_prepare_channel_pref()
1418 return -1; in p2p_prepare_channel_pref()
1421 p2p->op_reg_class = op_class; in p2p_prepare_channel_pref()
1422 p2p->op_channel = op_channel; in p2p_prepare_channel_pref()
1425 p2p->channels.reg_classes = 1; in p2p_prepare_channel_pref()
1426 p2p->channels.reg_class[0].channels = 1; in p2p_prepare_channel_pref()
1427 p2p->channels.reg_class[0].reg_class = p2p->op_reg_class; in p2p_prepare_channel_pref()
1428 p2p->channels.reg_class[0].channel[0] = p2p->op_channel; in p2p_prepare_channel_pref()
1430 p2p_copy_channels(&p2p->channels, &p2p->cfg->channels, in p2p_prepare_channel_pref()
1431 p2p->allow_6ghz); in p2p_prepare_channel_pref()
1449 if (!p2p->cfg->cfg_op_channel && p2p->best_freq_overall > 0 && in p2p_prepare_channel_best()
1450 p2p_supported_freq(p2p, p2p->best_freq_overall) && in p2p_prepare_channel_best()
1451 p2p_freq_to_channel(p2p->best_freq_overall, &op_class, &op_channel) in p2p_prepare_channel_best()
1454 p2p->op_reg_class = op_class; in p2p_prepare_channel_best()
1455 p2p->op_channel = op_channel; in p2p_prepare_channel_best()
1456 } else if (!p2p->cfg->cfg_op_channel && p2p->best_freq_5 > 0 && in p2p_prepare_channel_best()
1457 p2p_supported_freq(p2p, p2p->best_freq_5) && in p2p_prepare_channel_best()
1458 p2p_freq_to_channel(p2p->best_freq_5, &op_class, &op_channel) in p2p_prepare_channel_best()
1461 p2p->op_reg_class = op_class; in p2p_prepare_channel_best()
1462 p2p->op_channel = op_channel; in p2p_prepare_channel_best()
1463 } else if (!p2p->cfg->cfg_op_channel && p2p->best_freq_24 > 0 && in p2p_prepare_channel_best()
1464 p2p_supported_freq(p2p, p2p->best_freq_24) && in p2p_prepare_channel_best()
1465 p2p_freq_to_channel(p2p->best_freq_24, &op_class, in p2p_prepare_channel_best()
1468 p2p->op_reg_class = op_class; in p2p_prepare_channel_best()
1469 p2p->op_channel = op_channel; in p2p_prepare_channel_best()
1470 } else if (p2p->cfg->num_pref_chan > 0 && in p2p_prepare_channel_best()
1471 p2p_channels_includes(&p2p->cfg->channels, in p2p_prepare_channel_best()
1472 p2p->cfg->pref_chan[0].op_class, in p2p_prepare_channel_best()
1473 p2p->cfg->pref_chan[0].chan)) { in p2p_prepare_channel_best()
1475 p2p->op_reg_class = p2p->cfg->pref_chan[0].op_class; in p2p_prepare_channel_best()
1476 p2p->op_channel = p2p->cfg->pref_chan[0].chan; in p2p_prepare_channel_best()
1477 } else if (p2p_channel_select(&p2p->cfg->channels, op_classes_edmg, in p2p_prepare_channel_best()
1478 &p2p->op_reg_class, &p2p->op_channel) == in p2p_prepare_channel_best()
1481 p2p->op_reg_class, p2p->op_channel); in p2p_prepare_channel_best()
1482 } else if (p2p->allow_6ghz && in p2p_prepare_channel_best()
1483 (p2p_channel_select(&p2p->cfg->channels, op_classes_6ghz, in p2p_prepare_channel_best()
1484 &p2p->op_reg_class, &p2p->op_channel) == in p2p_prepare_channel_best()
1487 p2p->op_reg_class, p2p->op_channel); in p2p_prepare_channel_best()
1488 } else if (p2p_channel_select(&p2p->cfg->channels, op_classes_vht, in p2p_prepare_channel_best()
1489 &p2p->op_reg_class, &p2p->op_channel) == in p2p_prepare_channel_best()
1492 p2p->op_reg_class, p2p->op_channel); in p2p_prepare_channel_best()
1493 } else if (p2p_channel_select(&p2p->cfg->channels, op_classes_ht40, in p2p_prepare_channel_best()
1494 &p2p->op_reg_class, &p2p->op_channel) == in p2p_prepare_channel_best()
1497 p2p->op_reg_class, p2p->op_channel); in p2p_prepare_channel_best()
1498 } else if (p2p_channel_select(&p2p->cfg->channels, op_classes_5ghz, in p2p_prepare_channel_best()
1499 &p2p->op_reg_class, &p2p->op_channel) == in p2p_prepare_channel_best()
1502 p2p->op_reg_class, p2p->op_channel); in p2p_prepare_channel_best()
1503 } else if (p2p_channels_includes(&p2p->cfg->channels, in p2p_prepare_channel_best()
1504 p2p->cfg->op_reg_class, in p2p_prepare_channel_best()
1505 p2p->cfg->op_channel)) { in p2p_prepare_channel_best()
1506 p2p_dbg(p2p, "Select pre-configured channel as operating channel preference"); in p2p_prepare_channel_best()
1507 p2p->op_reg_class = p2p->cfg->op_reg_class; in p2p_prepare_channel_best()
1508 p2p->op_channel = p2p->cfg->op_channel; in p2p_prepare_channel_best()
1509 } else if (p2p_channel_random_social(&p2p->cfg->channels, in p2p_prepare_channel_best()
1510 &p2p->op_reg_class, in p2p_prepare_channel_best()
1511 &p2p->op_channel, in p2p_prepare_channel_best()
1514 p2p->op_reg_class, p2p->op_channel); in p2p_prepare_channel_best()
1516 /* Select any random available channel from the first available in p2p_prepare_channel_best()
1518 if (p2p_channel_select(&p2p->cfg->channels, NULL, in p2p_prepare_channel_best()
1519 &p2p->op_reg_class, in p2p_prepare_channel_best()
1520 &p2p->op_channel) == 0) in p2p_prepare_channel_best()
1523 p2p->op_channel, p2p->op_reg_class); in p2p_prepare_channel_best()
1526 p2p_copy_channels(&p2p->channels, &p2p->cfg->channels, p2p->allow_6ghz); in p2p_prepare_channel_best()
1531 * p2p_prepare_channel - Select operating channel for GO Negotiation or P2PS PD
1536 * @go: Whether the local end will be forced to be GO
1537 * Returns: 0 on success, -1 on failure (channel not supported for P2P)
1539 * This function is used to do initial operating channel selection for GO
1541 * signalling. The selected channel may be further optimized in
1542 * p2p_reselect_channel() once the peer information is available.
1545 unsigned int force_freq, unsigned int pref_freq, int go) in p2p_prepare_channel() argument
1547 p2p_dbg(p2p, "Prepare channel - force_freq=%u pref_freq=%u go=%d", in p2p_prepare_channel()
1548 force_freq, pref_freq, go); in p2p_prepare_channel()
1550 if (p2p_prepare_channel_pref(p2p, force_freq, pref_freq, go) < in p2p_prepare_channel()
1552 return -1; in p2p_prepare_channel()
1556 p2p_channels_dump(p2p, "prepared channels", &p2p->channels); in p2p_prepare_channel()
1557 if (go) in p2p_prepare_channel()
1558 p2p_channels_remove_freqs(&p2p->channels, &p2p->no_go_freq); in p2p_prepare_channel()
1560 p2p_channels_union_inplace(&p2p->channels, in p2p_prepare_channel()
1561 &p2p->cfg->cli_channels); in p2p_prepare_channel()
1562 p2p_channels_dump(p2p, "after go/cli filter/add", &p2p->channels); in p2p_prepare_channel()
1565 p2p->op_reg_class, p2p->op_channel, in p2p_prepare_channel()
1569 dev->flags |= P2P_DEV_FORCE_FREQ; in p2p_prepare_channel()
1571 dev->flags &= ~P2P_DEV_FORCE_FREQ; in p2p_prepare_channel()
1582 dev->flags &= ~(P2P_DEV_PREFER_PERSISTENT_GROUP | in p2p_set_dev_persistent()
1586 dev->flags |= P2P_DEV_PREFER_PERSISTENT_GROUP; in p2p_set_dev_persistent()
1587 dev->flags &= ~P2P_DEV_PREFER_PERSISTENT_RECONN; in p2p_set_dev_persistent()
1590 dev->flags |= P2P_DEV_PREFER_PERSISTENT_GROUP | in p2p_set_dev_persistent()
1606 p2p_dbg(p2p, "Request to start group negotiation - peer=" MACSTR in p2p_connect()
1607 " GO Intent=%d Intended Interface Address=" MACSTR in p2p_connect()
1612 p2p->allow_6ghz); in p2p_connect()
1615 if (dev == NULL || (dev->flags & P2P_DEV_PROBE_REQ_ONLY)) { in p2p_connect()
1618 return -1; in p2p_connect()
1623 return -1; in p2p_connect()
1625 if (dev->flags & P2P_DEV_GROUP_CLIENT_ONLY) { in p2p_connect()
1626 if (!(dev->info.dev_capab & in p2p_connect()
1631 return -1; in p2p_connect()
1633 if (dev->oper_freq <= 0) { in p2p_connect()
1637 return -1; in p2p_connect()
1641 * First, try to connect directly. If the peer does not in p2p_connect()
1643 * discoverability via the GO at that point. in p2p_connect()
1647 p2p->ssid_set = 0; in p2p_connect()
1651 os_memcpy(p2p->ssid, force_ssid, force_ssid_len); in p2p_connect()
1652 p2p->ssid_len = force_ssid_len; in p2p_connect()
1653 p2p->ssid_set = 1; in p2p_connect()
1656 dev->flags &= ~P2P_DEV_NOT_YET_READY; in p2p_connect()
1657 dev->flags &= ~P2P_DEV_USER_REJECTED; in p2p_connect()
1658 dev->flags &= ~P2P_DEV_WAIT_GO_NEG_RESPONSE; in p2p_connect()
1659 dev->flags &= ~P2P_DEV_WAIT_GO_NEG_CONFIRM; in p2p_connect()
1661 dev->flags |= P2P_DEV_PD_BEFORE_GO_NEG; in p2p_connect()
1663 dev->flags &= ~P2P_DEV_PD_BEFORE_GO_NEG; in p2p_connect()
1665 * Assign dialog token and tie breaker here to use the same in p2p_connect()
1666 * values in each retry within the same GO Negotiation exchange. in p2p_connect()
1668 dev->dialog_token++; in p2p_connect()
1669 if (dev->dialog_token == 0) in p2p_connect()
1670 dev->dialog_token = 1; in p2p_connect()
1671 dev->tie_breaker = p2p->next_tie_breaker; in p2p_connect()
1672 p2p->next_tie_breaker = !p2p->next_tie_breaker; in p2p_connect()
1674 dev->connect_reqs = 0; in p2p_connect()
1675 dev->go_neg_req_sent = 0; in p2p_connect()
1676 dev->go_state = UNKNOWN_GO; in p2p_connect()
1678 p2p->go_intent = go_intent; in p2p_connect()
1679 os_memcpy(p2p->intended_addr, own_interface_addr, ETH_ALEN); in p2p_connect()
1681 if (p2p->state != P2P_IDLE) in p2p_connect()
1684 dev->wps_method = wps_method; in p2p_connect()
1685 dev->oob_pw_id = oob_pw_id; in p2p_connect()
1686 dev->status = P2P_SC_SUCCESS; in p2p_connect()
1688 if (p2p->p2p_scan_running) { in p2p_connect()
1689 p2p_dbg(p2p, "p2p_scan running - delay connect send"); in p2p_connect()
1690 p2p->start_after_scan = P2P_AFTER_SCAN_CONNECT; in p2p_connect()
1691 os_memcpy(p2p->after_scan_peer, peer_addr, ETH_ALEN); in p2p_connect()
1708 p2p_dbg(p2p, "Request to authorize group negotiation - peer=" MACSTR in p2p_authorize()
1709 " GO Intent=%d Intended Interface Address=" MACSTR in p2p_authorize()
1712 wps_method, persistent_group, oob_pw_id, p2p->allow_6ghz); in p2p_authorize()
1718 return -1; in p2p_authorize()
1723 return -1; in p2p_authorize()
1725 p2p->ssid_set = 0; in p2p_authorize()
1729 os_memcpy(p2p->ssid, force_ssid, force_ssid_len); in p2p_authorize()
1730 p2p->ssid_len = force_ssid_len; in p2p_authorize()
1731 p2p->ssid_set = 1; in p2p_authorize()
1734 dev->flags &= ~P2P_DEV_NOT_YET_READY; in p2p_authorize()
1735 dev->flags &= ~P2P_DEV_USER_REJECTED; in p2p_authorize()
1736 dev->go_neg_req_sent = 0; in p2p_authorize()
1737 dev->go_state = UNKNOWN_GO; in p2p_authorize()
1739 p2p->go_intent = go_intent; in p2p_authorize()
1740 os_memcpy(p2p->intended_addr, own_interface_addr, ETH_ALEN); in p2p_authorize()
1742 dev->wps_method = wps_method; in p2p_authorize()
1743 dev->oob_pw_id = oob_pw_id; in p2p_authorize()
1744 dev->status = P2P_SC_SUCCESS; in p2p_authorize()
1753 os_get_reltime(&dev->last_seen); in p2p_add_dev_info()
1757 if (msg->listen_channel) { in p2p_add_dev_info()
1759 freq = p2p_channel_to_freq(msg->listen_channel[3], in p2p_add_dev_info()
1760 msg->listen_channel[4]); in p2p_add_dev_info()
1764 msg->listen_channel[0], in p2p_add_dev_info()
1765 msg->listen_channel[1], in p2p_add_dev_info()
1766 msg->listen_channel[2], in p2p_add_dev_info()
1767 msg->listen_channel[3], in p2p_add_dev_info()
1768 msg->listen_channel[4]); in p2p_add_dev_info()
1771 " Listen channel: %u -> %u MHz", in p2p_add_dev_info()
1772 MAC2STR(dev->info.p2p_device_addr), in p2p_add_dev_info()
1773 dev->listen_freq, freq); in p2p_add_dev_info()
1774 dev->listen_freq = freq; in p2p_add_dev_info()
1778 if (msg->wfd_subelems) { in p2p_add_dev_info()
1779 wpabuf_free(dev->info.wfd_subelems); in p2p_add_dev_info()
1780 dev->info.wfd_subelems = wpabuf_dup(msg->wfd_subelems); in p2p_add_dev_info()
1783 if (dev->flags & P2P_DEV_PROBE_REQ_ONLY) { in p2p_add_dev_info()
1784 dev->flags &= ~P2P_DEV_PROBE_REQ_ONLY; in p2p_add_dev_info()
1785 p2p_dbg(p2p, "Completed device entry based on data from GO Negotiation Request"); in p2p_add_dev_info()
1787 p2p_dbg(p2p, "Created device entry based on GO Neg Req: " in p2p_add_dev_info()
1790 MAC2STR(dev->info.p2p_device_addr), in p2p_add_dev_info()
1791 dev->info.dev_capab, dev->info.group_capab, in p2p_add_dev_info()
1792 dev->info.device_name, dev->listen_freq); in p2p_add_dev_info()
1795 dev->flags &= ~P2P_DEV_GROUP_CLIENT_ONLY; in p2p_add_dev_info()
1797 if (dev->flags & P2P_DEV_USER_REJECTED) { in p2p_add_dev_info()
1802 p2p->cfg->dev_found(p2p->cfg->cb_ctx, addr, &dev->info, in p2p_add_dev_info()
1803 !(dev->flags & P2P_DEV_REPORTED_ONCE)); in p2p_add_dev_info()
1804 dev->flags |= P2P_DEV_REPORTED | P2P_DEV_REPORTED_ONCE; in p2p_add_dev_info()
1813 p2p->cfg->ssid_postfix, p2p->cfg->ssid_postfix_len); in p2p_build_ssid()
1814 *ssid_len = P2P_WILDCARD_SSID_LEN + 2 + p2p->cfg->ssid_postfix_len; in p2p_build_ssid()
1820 if (p2p->ssid_set) { in p2p_go_params()
1821 os_memcpy(params->ssid, p2p->ssid, p2p->ssid_len); in p2p_go_params()
1822 params->ssid_len = p2p->ssid_len; in p2p_go_params()
1824 p2p_build_ssid(p2p, params->ssid, &params->ssid_len); in p2p_go_params()
1826 p2p->ssid_set = 0; in p2p_go_params()
1828 p2p_random(params->passphrase, p2p->cfg->passphrase_len); in p2p_go_params()
1829 params->passphrase[p2p->cfg->passphrase_len] = '\0'; in p2p_go_params()
1837 int go = peer->go_state == LOCAL_GO; in p2p_go_complete() local
1840 p2p_dbg(p2p, "GO Negotiation with " MACSTR " completed (%s will be GO)", in p2p_go_complete()
1841 MAC2STR(peer->info.p2p_device_addr), go ? "local end" : "peer"); in p2p_go_complete()
1844 res.role_go = go; in p2p_go_complete()
1845 os_memcpy(res.peer_device_addr, peer->info.p2p_device_addr, ETH_ALEN); in p2p_go_complete()
1846 os_memcpy(res.peer_interface_addr, peer->intended_addr, ETH_ALEN); in p2p_go_complete()
1847 res.wps_method = peer->wps_method; in p2p_go_complete()
1848 if (peer->flags & P2P_DEV_PREFER_PERSISTENT_GROUP) { in p2p_go_complete()
1849 if (peer->flags & P2P_DEV_PREFER_PERSISTENT_RECONN) in p2p_go_complete()
1855 if (go) { in p2p_go_complete()
1857 res.freq = p2p_channel_to_freq(p2p->op_reg_class, in p2p_go_complete()
1858 p2p->op_channel); in p2p_go_complete()
1859 os_memcpy(res.ssid, p2p->ssid, p2p->ssid_len); in p2p_go_complete()
1860 res.ssid_len = p2p->ssid_len; in p2p_go_complete()
1861 p2p_random(res.passphrase, p2p->cfg->passphrase_len); in p2p_go_complete()
1862 res.passphrase[p2p->cfg->passphrase_len] = '\0'; in p2p_go_complete()
1864 res.freq = peer->oper_freq; in p2p_go_complete()
1865 if (p2p->ssid_len) { in p2p_go_complete()
1866 os_memcpy(res.ssid, p2p->ssid, p2p->ssid_len); in p2p_go_complete()
1867 res.ssid_len = p2p->ssid_len; in p2p_go_complete()
1871 p2p_channels_dump(p2p, "own channels", &p2p->channels); in p2p_go_complete()
1872 p2p_channels_dump(p2p, "peer channels", &peer->channels); in p2p_go_complete()
1873 p2p_channels_intersect(&p2p->channels, &peer->channels, in p2p_go_complete()
1875 if (go) { in p2p_go_complete()
1876 p2p_channels_remove_freqs(&intersection, &p2p->no_go_freq); in p2p_go_complete()
1877 p2p_channels_dump(p2p, "intersection after no-GO removal", in p2p_go_complete()
1884 res.peer_config_timeout = go ? peer->client_timeout : peer->go_timeout; in p2p_go_complete()
1887 p2p->ssid_set = 0; in p2p_go_complete()
1888 peer->go_neg_req_sent = 0; in p2p_go_complete()
1889 peer->flags &= ~P2P_DEV_PEER_WAITING_RESPONSE; in p2p_go_complete()
1890 peer->wps_method = WPS_NOT_READY; in p2p_go_complete()
1891 peer->oob_pw_id = 0; in p2p_go_complete()
1892 wpabuf_free(peer->go_neg_conf); in p2p_go_complete()
1893 peer->go_neg_conf = NULL; in p2p_go_complete()
1896 p2p->cfg->go_neg_completed(p2p->cfg->cb_ctx, &res); in p2p_go_complete()
1911 p2p_process_go_neg_req(p2p, sa, data + 1, len - 1, rx_freq); in p2p_rx_p2p_action()
1914 p2p_process_go_neg_resp(p2p, sa, data + 1, len - 1, rx_freq); in p2p_rx_p2p_action()
1917 p2p_process_go_neg_conf(p2p, sa, data + 1, len - 1); in p2p_rx_p2p_action()
1920 p2p_process_invitation_req(p2p, sa, data + 1, len - 1, in p2p_rx_p2p_action()
1924 p2p_process_invitation_resp(p2p, sa, data + 1, len - 1); in p2p_rx_p2p_action()
1927 p2p_process_prov_disc_req(p2p, sa, data + 1, len - 1, rx_freq); in p2p_rx_p2p_action()
1930 p2p_process_prov_disc_resp(p2p, sa, data + 1, len - 1); in p2p_rx_p2p_action()
1933 p2p_process_dev_disc_req(p2p, sa, data + 1, len - 1, rx_freq); in p2p_rx_p2p_action()
1936 p2p_process_dev_disc_resp(p2p, sa, data + 1, len - 1); in p2p_rx_p2p_action()
1956 len--; in p2p_rx_action_public()
1963 len -= 4; in p2p_rx_action_public()
1968 p2p_rx_gas_initial_req(p2p, sa, data + 1, len - 1, freq); in p2p_rx_action_public()
1971 p2p_rx_gas_initial_resp(p2p, sa, data + 1, len - 1, freq); in p2p_rx_action_public()
1974 p2p_rx_gas_comeback_req(p2p, sa, data + 1, len - 1, freq); in p2p_rx_action_public()
1977 p2p_rx_gas_comeback_resp(p2p, sa, data + 1, len - 1, freq); in p2p_rx_action_public()
2001 len -= 4; in p2p_rx_action()
2011 p2p_dbg(p2p, "Received P2P Action - Notice of Absence"); in p2p_rx_action()
2015 p2p_process_presence_req(p2p, da, sa, data + 1, len - 1, freq); in p2p_rx_action()
2018 p2p_process_presence_resp(p2p, da, sa, data + 1, len - 1); in p2p_rx_action()
2021 p2p_process_go_disc_req(p2p, da, sa, data + 1, len - 1, freq); in p2p_rx_action()
2024 p2p_dbg(p2p, "Received P2P Action - unknown type %u", data[0]); in p2p_rx_action()
2033 if (p2p->go_neg_peer == NULL) in p2p_go_neg_start()
2035 if (p2p->pending_listen_freq) { in p2p_go_neg_start()
2037 p2p->pending_listen_freq = 0; in p2p_go_neg_start()
2039 p2p->cfg->stop_listen(p2p->cfg->cb_ctx); in p2p_go_neg_start()
2040 p2p->pending_listen_wait_drv = false; in p2p_go_neg_start()
2041 p2p->go_neg_peer->status = P2P_SC_SUCCESS; in p2p_go_neg_start()
2044 * too quickly while waiting for the GO Negotiation to complete. in p2p_go_neg_start()
2047 p2p_connect_send(p2p, p2p->go_neg_peer); in p2p_go_neg_start()
2054 if (p2p->invite_peer == NULL) in p2p_invite_start()
2056 if (p2p->pending_listen_freq) { in p2p_invite_start()
2058 p2p->pending_listen_freq = 0; in p2p_invite_start()
2060 p2p->cfg->stop_listen(p2p->cfg->cb_ctx); in p2p_invite_start()
2061 p2p->pending_listen_wait_drv = false; in p2p_invite_start()
2062 p2p_invite_send(p2p, p2p->invite_peer, p2p->invite_go_dev_addr, in p2p_invite_start()
2063 p2p->invite_dev_pw_id); in p2p_invite_start()
2083 /* The Probe Request is not part of P2P Device Discovery. It is in p2p_add_dev_from_probe_req()
2084 * not known whether the source address of the frame is the P2P in p2p_add_dev_from_probe_req()
2086 * peer entry based on this frames. in p2p_add_dev_from_probe_req()
2097 if (dev->country[0] == 0) in p2p_add_dev_from_probe_req()
2098 os_memcpy(dev->country, msg.listen_channel, 3); in p2p_add_dev_from_probe_req()
2103 if (freq > 0 && dev->listen_freq != freq) { in p2p_add_dev_from_probe_req()
2105 "Updated peer " MACSTR " Listen channel (Probe Request): %d -> %d MHz", in p2p_add_dev_from_probe_req()
2106 MAC2STR(addr), dev->listen_freq, freq); in p2p_add_dev_from_probe_req()
2107 dev->listen_freq = freq; in p2p_add_dev_from_probe_req()
2112 os_get_reltime(&dev->last_seen); in p2p_add_dev_from_probe_req()
2123 os_get_reltime(&dev->last_seen); in p2p_add_dev_from_probe_req()
2124 dev->flags |= P2P_DEV_PROBE_REQ_ONLY; in p2p_add_dev_from_probe_req()
2127 os_memcpy(dev->country, msg.listen_channel, 3); in p2p_add_dev_from_probe_req()
2128 dev->listen_freq = p2p_channel_to_freq(msg.listen_channel[3], in p2p_add_dev_from_probe_req()
2135 wpabuf_free(dev->info.wfd_subelems); in p2p_add_dev_from_probe_req()
2136 dev->info.wfd_subelems = wpabuf_dup(msg.wfd_subelems); in p2p_add_dev_from_probe_req()
2141 p2p_dbg(p2p, "Created device entry based on Probe Req: " MACSTR in p2p_add_dev_from_probe_req()
2143 MAC2STR(dev->info.p2p_device_addr), dev->info.dev_capab, in p2p_add_dev_from_probe_req()
2144 dev->info.group_capab, dev->info.device_name, in p2p_add_dev_from_probe_req()
2145 dev->listen_freq); in p2p_add_dev_from_probe_req()
2157 os_get_reltime(&dev->last_seen); in p2p_add_dev_from_go_neg_req()
2178 return 1; /* Category match with wildcard OUI/sub-category */ in dev_type_match()
2196 * p2p_match_dev_type - Match local device type with requested type
2199 * Returns: 1 on match, 0 on mismatch
2201 * This function can be used to match the Requested Device Type attribute in
2202 * WPS IE with the local device types for deciding whether to reply to a Probe
2214 return 1; /* no Requested Device Type attributes -> match */ in p2p_match_dev_type()
2216 if (dev_type_list_match(p2p->cfg->pri_dev_type, attr.req_dev_type, in p2p_match_dev_type()
2220 for (i = 0; i < p2p->cfg->num_sec_dev_types; i++) { in p2p_match_dev_type()
2221 if (dev_type_list_match(p2p->cfg->sec_dev_type[i], in p2p_match_dev_type()
2238 int pw_id = -1; in p2p_build_probe_resp_ies()
2242 if (p2p->wfd_ie_probe_resp) in p2p_build_probe_resp_ies()
2243 extra = wpabuf_len(p2p->wfd_ie_probe_resp); in p2p_build_probe_resp_ies()
2246 if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_PROBE_RESP_P2P]) in p2p_build_probe_resp_ies()
2247 extra += wpabuf_len(p2p->vendor_elem[VENDOR_ELEM_PROBE_RESP_P2P]); in p2p_build_probe_resp_ies()
2256 if (p2p->go_neg_peer) { in p2p_build_probe_resp_ies()
2258 pw_id = p2p_wps_method_pw_id(p2p->go_neg_peer->wps_method); in p2p_build_probe_resp_ies()
2268 if (p2p->wfd_ie_probe_resp) in p2p_build_probe_resp_ies()
2269 wpabuf_put_buf(buf, p2p->wfd_ie_probe_resp); in p2p_build_probe_resp_ies()
2272 if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_PROBE_RESP_P2P]) in p2p_build_probe_resp_ies()
2274 p2p->vendor_elem[VENDOR_ELEM_PROBE_RESP_P2P]); in p2p_build_probe_resp_ies()
2278 p2p_buf_add_capability(buf, p2p->dev_capab & in p2p_build_probe_resp_ies()
2280 if (p2p->ext_listen_interval) in p2p_build_probe_resp_ies()
2281 p2p_buf_add_ext_listen_timing(buf, p2p->ext_listen_period, in p2p_build_probe_resp_ies()
2282 p2p->ext_listen_interval); in p2p_build_probe_resp_ies()
2288 p2p->p2ps_adv_list); in p2p_build_probe_resp_ies()
2304 resp->frame_control = host_to_le16((WLAN_FC_TYPE_MGMT << 2) | in p2p_build_probe_resp_buf()
2306 os_memcpy(resp->da, addr, ETH_ALEN); in p2p_build_probe_resp_buf()
2307 os_memcpy(resp->sa, p2p->cfg->dev_addr, ETH_ALEN); in p2p_build_probe_resp_buf()
2308 os_memcpy(resp->bssid, p2p->cfg->dev_addr, ETH_ALEN); in p2p_build_probe_resp_buf()
2309 resp->u.probe_resp.beacon_int = host_to_le16(100); in p2p_build_probe_resp_buf()
2310 /* hardware or low-level driver will setup seq_ctrl and timestamp */ in p2p_build_probe_resp_buf()
2311 resp->u.probe_resp.capab_info = in p2p_build_probe_resp_buf()
2332 channel = p2p->cfg->channel; in p2p_build_probe_resp_buf()
2335 return -1; in p2p_build_probe_resp_buf()
2352 p2p_dbg(p2p, "ASP find - ASP list: %p", p2p->p2ps_adv_list); in p2p_service_find_asp()
2354 /* Wildcard org.wi-fi.wfds matches any WFA spec defined service */ in p2p_service_find_asp()
2355 any_wfa = os_memcmp(hash, p2p->wild_card_hash, P2PS_HASH_LEN) == 0; in p2p_service_find_asp()
2357 adv_data = p2p->p2ps_adv_list; in p2p_service_find_asp()
2359 if (os_memcmp(hash, adv_data->hash, P2PS_HASH_LEN) == 0) in p2p_service_find_asp()
2362 os_strncmp(adv_data->svc_name, P2PS_WILD_HASH_STR, in p2p_service_find_asp()
2365 adv_data = adv_data->next; in p2p_service_find_asp()
2385 p2p_dbg(p2p, "Could not parse Probe Request frame - ignore it"); in p2p_reply_probe()
2390 /* not a P2P probe - ignore it */ in p2p_reply_probe()
2391 p2p_dbg(p2p, "Not a P2P probe - ignore it"); in p2p_reply_probe()
2396 !ether_addr_equal(dst, p2p->cfg->dev_addr)) { in p2p_reply_probe()
2397 /* Not sent to the broadcast address or our P2P Device Address in p2p_reply_probe()
2399 p2p_dbg(p2p, "Probe Req DA " MACSTR " not ours - ignore it", in p2p_reply_probe()
2405 /* Not sent to the Wildcard BSSID */ in p2p_reply_probe()
2406 p2p_dbg(p2p, "Probe Req BSSID " MACSTR " not wildcard - ignore it", in p2p_reply_probe()
2414 /* not using P2P Wildcard SSID - ignore */ in p2p_reply_probe()
2415 p2p_dbg(p2p, "Probe Req not using P2P Wildcard SSID - ignore it"); in p2p_reply_probe()
2421 p2p_dbg(p2p, "Probe Req with 11b rates only supported - ignore it"); in p2p_reply_probe()
2428 p2p_dbg(p2p, "Could not parse P2P attributes in Probe Req - ignore it"); in p2p_reply_probe()
2438 p2p->in_listen, p2p->drv_in_listen, rx_freq, in p2p_reply_probe()
2439 p2p->cfg->channel, p2p->pending_listen_freq); in p2p_reply_probe()
2441 if (!p2p->in_listen && !p2p->drv_in_listen && in p2p_reply_probe()
2442 p2p->pending_listen_freq && rx_freq && in p2p_reply_probe()
2443 rx_freq != p2p->pending_listen_freq) { in p2p_reply_probe()
2444 … not reply to Probe Request frame that was received on %u MHz while waiting to start Listen state in p2p_reply_probe()
2445 rx_freq, p2p->pending_listen_freq); in p2p_reply_probe()
2470 if (!p2p->in_listen || !p2p->drv_in_listen) { in p2p_reply_probe()
2471 /* not in Listen state - ignore Probe Request */ in p2p_reply_probe()
2472 p2p_dbg(p2p, "Not in Listen state (in_listen=%d drv_in_listen=%d) - ignore Probe Request", in p2p_reply_probe()
2473 p2p->in_listen, p2p->drv_in_listen); in p2p_reply_probe()
2480 !ether_addr_equal(msg.device_id, p2p->cfg->dev_addr)) { in p2p_reply_probe()
2482 p2p_dbg(p2p, "Probe Req requested Device ID " MACSTR " did not match - ignore it", in p2p_reply_probe()
2492 p2p_dbg(p2p, "Probe Req requested Device Type did not match - ignore it"); in p2p_reply_probe()
2497 if (!p2p->cfg->send_probe_resp) { in p2p_reply_probe()
2499 p2p_dbg(p2p, "Probe Resp generated elsewhere - do not generate additional response"); in p2p_reply_probe()
2532 p2p->cfg->send_probe_resp(p2p->cfg->cb_ctx, buf, rx_freq); in p2p_reply_probe()
2560 * Activate a pending GO Negotiation/Invite flow if a received Probe in p2p_probe_req_rx()
2561 * Request frame is from an expected peer. Some devices may share the in p2p_probe_req_rx()
2562 * same address for P2P and non-P2P STA running simultaneously. The in p2p_probe_req_rx()
2567 if ((p2p->state == P2P_CONNECT || p2p->state == P2P_CONNECT_LISTEN) && in p2p_probe_req_rx()
2568 p2p->go_neg_peer && in p2p_probe_req_rx()
2569 ether_addr_equal(addr, p2p->go_neg_peer->info.p2p_device_addr) && in p2p_probe_req_rx()
2570 !(p2p->go_neg_peer->flags & P2P_DEV_WAIT_GO_NEG_CONFIRM)) { in p2p_probe_req_rx()
2571 /* Received a Probe Request from GO Negotiation peer */ in p2p_probe_req_rx()
2572 p2p_dbg(p2p, "Found GO Negotiation peer - try to start GO negotiation from timeout"); in p2p_probe_req_rx()
2578 if ((p2p->state == P2P_INVITE || p2p->state == P2P_INVITE_LISTEN) && in p2p_probe_req_rx()
2579 p2p->invite_peer && in p2p_probe_req_rx()
2580 (p2p->invite_peer->flags & P2P_DEV_WAIT_INV_REQ_ACK) && in p2p_probe_req_rx()
2581 ether_addr_equal(addr, p2p->invite_peer->info.p2p_device_addr)) { in p2p_probe_req_rx()
2583 p2p_dbg(p2p, "Found Invite peer - try to start Invite from timeout"); in p2p_probe_req_rx()
2617 * (Re)Association Request - P2P IE in p2p_assoc_req_ie_wlan_ap()
2624 return -1; in p2p_assoc_req_ie_wlan_ap()
2628 if (p2p->num_groups > 0) { in p2p_assoc_req_ie_wlan_ap()
2630 if ((p2p->dev_capab & P2P_DEV_CAPAB_CONCURRENT_OPER) && in p2p_assoc_req_ie_wlan_ap()
2631 (p2p->dev_capab & P2P_DEV_CAPAB_INFRA_MANAGED) && in p2p_assoc_req_ie_wlan_ap()
2632 p2p->cross_connect) in p2p_assoc_req_ie_wlan_ap()
2635 p2p_buf_add_capability(tmp, p2p->dev_capab, group_capab); in p2p_assoc_req_ie_wlan_ap()
2636 if ((p2p->dev_capab & P2P_DEV_CAPAB_CONCURRENT_OPER) && in p2p_assoc_req_ie_wlan_ap()
2637 (p2p->dev_capab & P2P_DEV_CAPAB_INFRA_MANAGED)) in p2p_assoc_req_ie_wlan_ap()
2643 res = -1; in p2p_assoc_req_ie_wlan_ap()
2668 if (p2p->wfd_ie_assoc_req) in p2p_assoc_req_ie()
2669 extra = wpabuf_len(p2p->wfd_ie_assoc_req); in p2p_assoc_req_ie()
2672 if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_ASSOC_REQ]) in p2p_assoc_req_ie()
2673 extra += wpabuf_len(p2p->vendor_elem[VENDOR_ELEM_P2P_ASSOC_REQ]); in p2p_assoc_req_ie()
2676 * (Re)Association Request - P2P IE in p2p_assoc_req_ie()
2683 return -1; in p2p_assoc_req_ie()
2686 if (p2p->wfd_ie_assoc_req) in p2p_assoc_req_ie()
2687 wpabuf_put_buf(tmp, p2p->wfd_ie_assoc_req); in p2p_assoc_req_ie()
2690 if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_ASSOC_REQ]) in p2p_assoc_req_ie()
2692 p2p->vendor_elem[VENDOR_ELEM_P2P_ASSOC_REQ]); in p2p_assoc_req_ie()
2697 p2p_buf_add_capability(tmp, p2p->dev_capab, 0); in p2p_assoc_req_ie()
2698 if (p2p->ext_listen_interval) in p2p_assoc_req_ie()
2699 p2p_buf_add_ext_listen_timing(tmp, p2p->ext_listen_period, in p2p_assoc_req_ie()
2700 p2p->ext_listen_interval); in p2p_assoc_req_ie()
2706 res = -1; in p2p_assoc_req_ie()
2740 adv_data = p2p->p2ps_adv_list; in p2p_service_p2ps_id()
2742 if (adv_data->id == adv_id) in p2p_service_p2ps_id()
2744 adv_data = adv_data->next; in p2p_service_p2ps_id()
2757 return -1; in p2p_service_del_asp()
2759 adv_data = p2p->p2ps_adv_list; in p2p_service_del_asp()
2760 prior = &p2p->p2ps_adv_list; in p2p_service_del_asp()
2762 if (adv_data->id == adv_id) { in p2p_service_del_asp()
2764 *prior = adv_data->next; in p2p_service_del_asp()
2768 prior = &adv_data->next; in p2p_service_del_asp()
2769 adv_data = adv_data->next; in p2p_service_del_asp()
2772 return -1; in p2p_service_del_asp()
2786 return -1; in p2p_service_add_asp()
2788 if (!(config_methods & p2p->cfg->config_methods)) { in p2p_service_add_asp()
2790 config_methods, p2p->cfg->config_methods); in p2p_service_add_asp()
2791 return -1; in p2p_service_add_asp()
2795 return -1; in p2p_service_add_asp()
2805 return -1; in p2p_service_add_asp()
2807 os_memcpy(adv_data->hash, buf, P2PS_HASH_LEN); in p2p_service_add_asp()
2808 adv_data->id = adv_id; in p2p_service_add_asp()
2809 adv_data->state = svc_state; in p2p_service_add_asp()
2810 adv_data->config_methods = config_methods & p2p->cfg->config_methods; in p2p_service_add_asp()
2811 adv_data->auto_accept = (u8) auto_accept; in p2p_service_add_asp()
2812 os_memcpy(adv_data->svc_name, adv_str, adv_len); in p2p_service_add_asp()
2815 adv_data->cpt_priority[i] = cpt_priority[i]; in p2p_service_add_asp()
2816 adv_data->cpt_mask |= cpt_priority[i]; in p2p_service_add_asp()
2820 adv_data->svc_info = &adv_data->svc_name[adv_len + 1]; in p2p_service_add_asp()
2821 os_memcpy(adv_data->svc_info, svc_info, info_len); in p2p_service_add_asp()
2828 tmp = p2p->p2ps_adv_list; in p2p_service_add_asp()
2829 prev = &p2p->p2ps_adv_list; in p2p_service_add_asp()
2831 if (tmp->id == adv_data->id) { in p2p_service_add_asp()
2832 if (os_strcmp(tmp->svc_name, adv_data->svc_name) != 0) { in p2p_service_add_asp()
2834 return -1; in p2p_service_add_asp()
2836 adv_data->next = tmp->next; in p2p_service_add_asp()
2841 if (os_strcmp(tmp->svc_name, adv_data->svc_name) == 0) { in p2p_service_add_asp()
2842 adv_data->next = tmp->next; in p2p_service_add_asp()
2843 tmp->next = adv_data; in p2p_service_add_asp()
2847 prev = &tmp->next; in p2p_service_add_asp()
2848 tmp = tmp->next; in p2p_service_add_asp()
2852 adv_data->next = p2p->p2ps_adv_list; in p2p_service_add_asp()
2853 p2p->p2ps_adv_list = adv_data; in p2p_service_add_asp()
2858 adv_id, adv_data->config_methods, svc_state, adv_str, in p2p_service_add_asp()
2859 adv_data->cpt_mask); in p2p_service_add_asp()
2872 adv = p2p->p2ps_adv_list; in p2p_service_flush_asp()
2875 adv = adv->next; in p2p_service_flush_asp()
2879 p2p->p2ps_adv_list = NULL; in p2p_service_flush_asp()
2891 return -1; in p2p_parse_dev_addr_in_p2p_ie()
2900 return -1; in p2p_parse_dev_addr_in_p2p_ie()
2912 return -1; in p2p_parse_dev_addr()
2921 p2p->go_neg_peer = NULL; in p2p_clear_go_neg()
2929 if (p2p->go_neg_peer == NULL) { in p2p_wps_success_cb()
2930 p2p_dbg(p2p, "No pending Group Formation - ignore WPS registration success notification"); in p2p_wps_success_cb()
2934 if (!ether_addr_equal(mac_addr, p2p->go_neg_peer->intended_addr)) { in p2p_wps_success_cb()
2936 MACSTR " (GO Negotiation peer " MACSTR ")", in p2p_wps_success_cb()
2938 MAC2STR(p2p->go_neg_peer->intended_addr)); in p2p_wps_success_cb()
2951 if (p2p->go_neg_peer == NULL) { in p2p_group_formation_failed()
2952 p2p_dbg(p2p, "No pending Group Formation - ignore group formation failure notification"); in p2p_group_formation_failed()
2957 MAC2STR(p2p->go_neg_peer->intended_addr)); in p2p_group_formation_failed()
2966 return p2p->cfg->p2p_6ghz_disable; in is_p2p_6ghz_disabled()
2975 if (cfg->max_peers < 1 || in p2p_init()
2976 cfg->passphrase_len < 8 || cfg->passphrase_len > 63) in p2p_init()
2982 p2p->cfg = (struct p2p_config *) (p2p + 1); in p2p_init()
2983 os_memcpy(p2p->cfg, cfg, sizeof(*cfg)); in p2p_init()
2984 if (cfg->dev_name) in p2p_init()
2985 p2p->cfg->dev_name = os_strdup(cfg->dev_name); in p2p_init()
2986 if (cfg->manufacturer) in p2p_init()
2987 p2p->cfg->manufacturer = os_strdup(cfg->manufacturer); in p2p_init()
2988 if (cfg->model_name) in p2p_init()
2989 p2p->cfg->model_name = os_strdup(cfg->model_name); in p2p_init()
2990 if (cfg->model_number) in p2p_init()
2991 p2p->cfg->model_number = os_strdup(cfg->model_number); in p2p_init()
2992 if (cfg->serial_number) in p2p_init()
2993 p2p->cfg->serial_number = os_strdup(cfg->serial_number); in p2p_init()
2994 if (cfg->pref_chan) { in p2p_init()
2995 p2p->cfg->pref_chan = os_malloc(cfg->num_pref_chan * in p2p_init()
2997 if (p2p->cfg->pref_chan) { in p2p_init()
2998 os_memcpy(p2p->cfg->pref_chan, cfg->pref_chan, in p2p_init()
2999 cfg->num_pref_chan * in p2p_init()
3002 p2p->cfg->num_pref_chan = 0; in p2p_init()
3005 p2ps_gen_hash(p2p, P2PS_WILD_HASH_STR, p2p->wild_card_hash); in p2p_init()
3007 p2p->min_disc_int = 1; in p2p_init()
3008 p2p->max_disc_int = 3; in p2p_init()
3009 p2p->max_disc_tu = -1; in p2p_init()
3011 if (os_get_random(&p2p->next_tie_breaker, 1) < 0) in p2p_init()
3012 p2p->next_tie_breaker = 0; in p2p_init()
3013 p2p->next_tie_breaker &= 0x01; in p2p_init()
3014 if (cfg->sd_request) in p2p_init()
3015 p2p->dev_capab |= P2P_DEV_CAPAB_SERVICE_DISCOVERY; in p2p_init()
3016 p2p->dev_capab |= P2P_DEV_CAPAB_INVITATION_PROCEDURE; in p2p_init()
3017 if (cfg->concurrent_operations) in p2p_init()
3018 p2p->dev_capab |= P2P_DEV_CAPAB_CONCURRENT_OPER; in p2p_init()
3019 p2p->dev_capab |= P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY; in p2p_init()
3021 dl_list_init(&p2p->devices); in p2p_init()
3023 p2p->go_timeout = 100; in p2p_init()
3024 p2p->client_timeout = 20; in p2p_init()
3025 p2p->num_p2p_sd_queries = 0; in p2p_init()
3028 p2p_channels_dump(p2p, "channels", &p2p->cfg->channels); in p2p_init()
3029 p2p_channels_dump(p2p, "cli_channels", &p2p->cfg->cli_channels); in p2p_init()
3038 wpabuf_free(p2p->wfd_ie_beacon); in p2p_deinit()
3039 wpabuf_free(p2p->wfd_ie_probe_req); in p2p_deinit()
3040 wpabuf_free(p2p->wfd_ie_probe_resp); in p2p_deinit()
3041 wpabuf_free(p2p->wfd_ie_assoc_req); in p2p_deinit()
3042 wpabuf_free(p2p->wfd_ie_invitation); in p2p_deinit()
3043 wpabuf_free(p2p->wfd_ie_prov_disc_req); in p2p_deinit()
3044 wpabuf_free(p2p->wfd_ie_prov_disc_resp); in p2p_deinit()
3045 wpabuf_free(p2p->wfd_ie_go_neg); in p2p_deinit()
3046 wpabuf_free(p2p->wfd_dev_info); in p2p_deinit()
3047 wpabuf_free(p2p->wfd_assoc_bssid); in p2p_deinit()
3048 wpabuf_free(p2p->wfd_coupled_sink_info); in p2p_deinit()
3049 wpabuf_free(p2p->wfd_r2_dev_info); in p2p_deinit()
3057 os_free(p2p->cfg->dev_name); in p2p_deinit()
3058 os_free(p2p->cfg->manufacturer); in p2p_deinit()
3059 os_free(p2p->cfg->model_name); in p2p_deinit()
3060 os_free(p2p->cfg->model_number); in p2p_deinit()
3061 os_free(p2p->cfg->serial_number); in p2p_deinit()
3062 os_free(p2p->cfg->pref_chan); in p2p_deinit()
3063 os_free(p2p->groups); in p2p_deinit()
3065 wpabuf_free(p2p->sd_resp); in p2p_deinit()
3067 os_free(p2p->no_go_freq.range); in p2p_deinit()
3080 dl_list_for_each_safe(dev, prev, &p2p->devices, struct p2p_device, in p2p_flush()
3082 dl_list_del(&dev->list); in p2p_flush()
3086 p2p->ssid_set = 0; in p2p_flush()
3089 p2p->override_pref_op_class = 0; in p2p_flush()
3090 p2p->override_pref_channel = 0; in p2p_flush()
3100 return -1; in p2p_unauthorize()
3104 if (p2p->go_neg_peer == dev) { in p2p_unauthorize()
3106 p2p->go_neg_peer = NULL; in p2p_unauthorize()
3109 dev->wps_method = WPS_NOT_READY; in p2p_unauthorize()
3110 dev->oob_pw_id = 0; in p2p_unauthorize()
3111 dev->flags &= ~P2P_DEV_WAIT_GO_NEG_RESPONSE; in p2p_unauthorize()
3112 dev->flags &= ~P2P_DEV_WAIT_GO_NEG_CONFIRM; in p2p_unauthorize()
3120 os_free(p2p->cfg->dev_name); in p2p_set_dev_name()
3122 p2p->cfg->dev_name = os_strdup(dev_name); in p2p_set_dev_name()
3123 if (p2p->cfg->dev_name == NULL) in p2p_set_dev_name()
3124 return -1; in p2p_set_dev_name()
3126 p2p->cfg->dev_name = NULL; in p2p_set_dev_name()
3133 os_free(p2p->cfg->manufacturer); in p2p_set_manufacturer()
3134 p2p->cfg->manufacturer = NULL; in p2p_set_manufacturer()
3136 p2p->cfg->manufacturer = os_strdup(manufacturer); in p2p_set_manufacturer()
3137 if (p2p->cfg->manufacturer == NULL) in p2p_set_manufacturer()
3138 return -1; in p2p_set_manufacturer()
3147 os_free(p2p->cfg->model_name); in p2p_set_model_name()
3148 p2p->cfg->model_name = NULL; in p2p_set_model_name()
3150 p2p->cfg->model_name = os_strdup(model_name); in p2p_set_model_name()
3151 if (p2p->cfg->model_name == NULL) in p2p_set_model_name()
3152 return -1; in p2p_set_model_name()
3161 os_free(p2p->cfg->model_number); in p2p_set_model_number()
3162 p2p->cfg->model_number = NULL; in p2p_set_model_number()
3164 p2p->cfg->model_number = os_strdup(model_number); in p2p_set_model_number()
3165 if (p2p->cfg->model_number == NULL) in p2p_set_model_number()
3166 return -1; in p2p_set_model_number()
3175 os_free(p2p->cfg->serial_number); in p2p_set_serial_number()
3176 p2p->cfg->serial_number = NULL; in p2p_set_serial_number()
3178 p2p->cfg->serial_number = os_strdup(serial_number); in p2p_set_serial_number()
3179 if (p2p->cfg->serial_number == NULL) in p2p_set_serial_number()
3180 return -1; in p2p_set_serial_number()
3189 p2p->cfg->config_methods = config_methods; in p2p_set_config_methods()
3195 os_memcpy(p2p->cfg->uuid, uuid, 16); in p2p_set_uuid()
3201 os_memcpy(p2p->cfg->pri_dev_type, pri_dev_type, 8); in p2p_set_pri_dev_type()
3211 p2p->cfg->num_sec_dev_types = num_dev_types; in p2p_set_sec_dev_types()
3212 os_memcpy(p2p->cfg->sec_dev_type, dev_types, num_dev_types * 8); in p2p_set_sec_dev_types()
3222 wpabuf_free(p2p->wps_vendor_ext[i]); in p2p_remove_wps_vendor_extensions()
3223 p2p->wps_vendor_ext[i] = NULL; in p2p_remove_wps_vendor_extensions()
3234 return -1; in p2p_add_wps_vendor_extension()
3237 if (p2p->wps_vendor_ext[i] == NULL) in p2p_add_wps_vendor_extension()
3241 return -1; in p2p_add_wps_vendor_extension()
3243 p2p->wps_vendor_ext[i] = wpabuf_dup(vendor_ext); in p2p_add_wps_vendor_extension()
3244 if (p2p->wps_vendor_ext[i] == NULL) in p2p_add_wps_vendor_extension()
3245 return -1; in p2p_add_wps_vendor_extension()
3253 os_memcpy(p2p->cfg->country, country, 3); in p2p_set_country()
3262 if (dev->sd_pending_bcast_queries == 0) { in p2p_pre_find_operation()
3265 dev->sd_pending_bcast_queries = p2p->num_p2p_sd_queries; in p2p_pre_find_operation()
3269 if (res == -2) in p2p_pre_find_operation()
3270 return -2; in p2p_pre_find_operation()
3274 if (dev->req_config_methods && in p2p_pre_find_operation()
3275 !(dev->flags & P2P_DEV_PD_FOR_JOIN)) { in p2p_pre_find_operation()
3278 MAC2STR(dev->info.p2p_device_addr), in p2p_pre_find_operation()
3279 dev->req_config_methods); in p2p_pre_find_operation()
3295 /* Continue from the device following the last iteration */ in p2p_continue_find()
3297 dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) { in p2p_continue_find()
3298 if (dev == p2p->last_p2p_find_oper) { in p2p_continue_find()
3306 p2p->last_p2p_find_oper = dev; in p2p_continue_find()
3309 if (res == -2) in p2p_continue_find()
3314 * Wrap around to the beginning of the list and continue until the last in p2p_continue_find()
3317 dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) { in p2p_continue_find()
3320 p2p->last_p2p_find_oper = dev; in p2p_continue_find()
3323 if (res == -2) in p2p_continue_find()
3325 if (dev == p2p->last_p2p_find_oper) in p2p_continue_find()
3330 os_memset(p2p->sd_query_no_ack, 0, ETH_ALEN); in p2p_continue_find()
3339 p2p->pending_action_state = P2P_NO_PENDING_ACTION; in p2p_sd_query_cb()
3342 if (p2p->sd_peer) { in p2p_sd_query_cb()
3343 if (is_zero_ether_addr(p2p->sd_query_no_ack)) { in p2p_sd_query_cb()
3344 os_memcpy(p2p->sd_query_no_ack, in p2p_sd_query_cb()
3345 p2p->sd_peer->info.p2p_device_addr, in p2p_sd_query_cb()
3348 "First SD Query no-ACK in this search iteration: " in p2p_sd_query_cb()
3349 MACSTR, MAC2STR(p2p->sd_query_no_ack)); in p2p_sd_query_cb()
3351 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_sd_query_cb()
3353 p2p->sd_peer = NULL; in p2p_sd_query_cb()
3354 if (p2p->state != P2P_IDLE) in p2p_sd_query_cb()
3359 if (p2p->sd_peer == NULL) { in p2p_sd_query_cb()
3361 if (p2p->state != P2P_IDLE) in p2p_sd_query_cb()
3366 if (p2p->sd_query && p2p->sd_query->for_all_peers) { in p2p_sd_query_cb()
3367 /* Update the pending broadcast SD query count for this device in p2p_sd_query_cb()
3369 p2p->sd_peer->sd_pending_bcast_queries--; in p2p_sd_query_cb()
3373 * mark it as done (-1). in p2p_sd_query_cb()
3375 if (p2p->sd_peer->sd_pending_bcast_queries == 0) in p2p_sd_query_cb()
3376 p2p->sd_peer->sd_pending_bcast_queries = -1; in p2p_sd_query_cb()
3379 /* Wait for response from the peer */ in p2p_sd_query_cb()
3386 * p2p_retry_pd - Retry any pending provision disc requests in IDLE state
3394 * Retry the prov disc req attempt only for the peer that the user had in p2p_retry_pd()
3398 dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) { in p2p_retry_pd()
3399 if (!ether_addr_equal(p2p->pending_pd_devaddr, in p2p_retry_pd()
3400 dev->info.p2p_device_addr)) in p2p_retry_pd()
3402 if (!dev->req_config_methods) in p2p_retry_pd()
3407 MAC2STR(dev->info.p2p_device_addr), in p2p_retry_pd()
3408 dev->req_config_methods); in p2p_retry_pd()
3410 dev->flags & P2P_DEV_PD_FOR_JOIN, in p2p_retry_pd()
3411 p2p->pd_force_freq); in p2p_retry_pd()
3423 * Postpone resetting the pending action state till after we actually in p2p_prov_disc_cb()
3425 * interested parties about no response to the request. in p2p_prov_disc_cb()
3427 * When the timer (below) goes off we check in IDLE, SEARCH, or in p2p_prov_disc_cb()
3428 * LISTEN_ONLY state, which are the only allowed states to issue a PD in p2p_prov_disc_cb()
3433 p2p->pending_action_state = P2P_NO_PENDING_ACTION; in p2p_prov_disc_cb()
3435 if (p2p->user_initiated_pd && in p2p_prov_disc_cb()
3436 (p2p->state == P2P_SEARCH || p2p->state == P2P_LISTEN_ONLY)) in p2p_prov_disc_cb()
3439 p2p->pending_action_state = P2P_PENDING_PD; in p2p_prov_disc_cb()
3441 } else if (p2p->state != P2P_IDLE) in p2p_prov_disc_cb()
3443 else if (p2p->user_initiated_pd) { in p2p_prov_disc_cb()
3444 p2p->pending_action_state = P2P_PENDING_PD; in p2p_prov_disc_cb()
3451 * If after PD Request the peer doesn't expect to receive PD Response in p2p_prov_disc_cb()
3452 * the PD Request ACK indicates a completion of the current PD. This in p2p_prov_disc_cb()
3453 * happens only on the advertiser side sending the follow-on PD Request in p2p_prov_disc_cb()
3454 * with the status different than 12 (Success: accepted by user). in p2p_prov_disc_cb()
3456 if (p2p->p2ps_prov && !p2p->p2ps_prov->pd_seeker && in p2p_prov_disc_cb()
3457 p2p->p2ps_prov->status != P2P_SC_SUCCESS_DEFERRED) { in p2p_prov_disc_cb()
3458 p2p_dbg(p2p, "P2PS PD completion on Follow-on PD Request ACK"); in p2p_prov_disc_cb()
3460 if (p2p->send_action_in_progress) { in p2p_prov_disc_cb()
3461 p2p->send_action_in_progress = 0; in p2p_prov_disc_cb()
3462 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_prov_disc_cb()
3465 p2p->pending_action_state = P2P_NO_PENDING_ACTION; in p2p_prov_disc_cb()
3467 if (p2p->cfg->p2ps_prov_complete) { in p2p_prov_disc_cb()
3468 p2p->cfg->p2ps_prov_complete( in p2p_prov_disc_cb()
3469 p2p->cfg->cb_ctx, in p2p_prov_disc_cb()
3470 p2p->p2ps_prov->status, in p2p_prov_disc_cb()
3471 p2p->p2ps_prov->adv_mac, in p2p_prov_disc_cb()
3472 p2p->p2ps_prov->adv_mac, in p2p_prov_disc_cb()
3473 p2p->p2ps_prov->session_mac, in p2p_prov_disc_cb()
3474 NULL, p2p->p2ps_prov->adv_id, in p2p_prov_disc_cb()
3475 p2p->p2ps_prov->session_id, in p2p_prov_disc_cb()
3480 if (p2p->user_initiated_pd) in p2p_prov_disc_cb()
3491 if (p2p->user_initiated_pd) in p2p_prov_disc_cb()
3492 p2p->pending_action_state = P2P_PENDING_PD; in p2p_prov_disc_cb()
3494 p2p->pending_action_state = P2P_NO_PENDING_ACTION; in p2p_prov_disc_cb()
3496 /* Wait for response from the peer */ in p2p_prov_disc_cb()
3497 if (p2p->state == P2P_SEARCH) in p2p_prov_disc_cb()
3508 if (p2p->send_action_in_progress) { in p2p_prov_disc_resp_cb()
3509 p2p->send_action_in_progress = 0; in p2p_prov_disc_resp_cb()
3510 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_prov_disc_resp_cb()
3513 p2p->pending_action_state = P2P_NO_PENDING_ACTION; in p2p_prov_disc_resp_cb()
3516 if (p2p->state == P2P_SEARCH) in p2p_prov_disc_resp_cb()
3521 if (!p2p->cfg->prov_disc_resp_cb || in p2p_prov_disc_resp_cb()
3522 p2p->cfg->prov_disc_resp_cb(p2p->cfg->cb_ctx) < 1) { in p2p_prov_disc_resp_cb()
3523 if (p2p->state == P2P_SEARCH) in p2p_prov_disc_resp_cb()
3529 "Post-Provision Discovery operations started - do not try to continue other P2P operations"); in p2p_prov_disc_resp_cb()
3537 if (os_reltime_before(rx_time, &p2p->find_start)) { in p2p_scan_res_handler()
3539 * The driver may have cached (e.g., in cfg80211 BSS table) the in p2p_scan_res_handler()
3541 * stale information, update P2P peers only based on results in p2p_scan_res_handler()
3542 * that have based on frames received after the last p2p_find in p2p_scan_res_handler()
3547 MAC2STR(bssid), (unsigned int) rx_time->sec, in p2p_scan_res_handler()
3548 (unsigned int) rx_time->usec, in p2p_scan_res_handler()
3549 (unsigned int) p2p->find_start.sec, in p2p_scan_res_handler()
3550 (unsigned int) p2p->find_start.usec); in p2p_scan_res_handler()
3562 if (!p2p->p2p_scan_running) { in p2p_scan_res_handled()
3565 p2p->p2p_scan_running = 0; in p2p_scan_res_handled()
3568 if (!p2p->search_delay) in p2p_scan_res_handled()
3569 p2p->search_delay = delay; in p2p_scan_res_handled()
3575 if (p2p->state == P2P_SEARCH) in p2p_scan_res_handled()
3587 if (p2p->wfd_ie_probe_req) in p2p_scan_ie()
3588 wpabuf_put_buf(ies, p2p->wfd_ie_probe_req); in p2p_scan_ie()
3591 if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_PROBE_REQ_P2P]) in p2p_scan_ie()
3593 p2p->vendor_elem[VENDOR_ELEM_PROBE_REQ_P2P]); in p2p_scan_ie()
3597 dev_capab = p2p->dev_capab & ~P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY; in p2p_scan_ie()
3600 if (p2p->p2ps_seek && p2p->p2ps_seek_count) in p2p_scan_ie()
3607 if (p2p->cfg->reg_class && p2p->cfg->channel) in p2p_scan_ie()
3608 p2p_buf_add_listen_channel(ies, p2p->cfg->country, in p2p_scan_ie()
3609 p2p->cfg->reg_class, in p2p_scan_ie()
3610 p2p->cfg->channel); in p2p_scan_ie()
3611 if (p2p->ext_listen_interval) in p2p_scan_ie()
3612 p2p_buf_add_ext_listen_timing(ies, p2p->ext_listen_period, in p2p_scan_ie()
3613 p2p->ext_listen_interval); in p2p_scan_ie()
3618 if (p2p->p2ps_seek && p2p->p2ps_seek_count) in p2p_scan_ie()
3621 /* TODO: p2p_buf_add_operating_channel() if GO */ in p2p_scan_ie()
3631 if (p2p && p2p->wfd_ie_probe_req) in p2p_scan_ie_buf_len()
3632 len += wpabuf_len(p2p->wfd_ie_probe_req); in p2p_scan_ie_buf_len()
3635 if (p2p && p2p->vendor_elem && in p2p_scan_ie_buf_len()
3636 p2p->vendor_elem[VENDOR_ELEM_PROBE_REQ_P2P]) in p2p_scan_ie_buf_len()
3637 len += wpabuf_len(p2p->vendor_elem[VENDOR_ELEM_PROBE_REQ_P2P]); in p2p_scan_ie_buf_len()
3651 struct p2p_device *dev = p2p->go_neg_peer; in p2p_go_neg_req_cb()
3654 p2p_dbg(p2p, "GO Negotiation Request TX callback: success=%d", success); in p2p_go_neg_req_cb()
3657 p2p_dbg(p2p, "No pending GO Negotiation"); in p2p_go_neg_req_cb()
3662 if (dev->flags & P2P_DEV_USER_REJECTED) { in p2p_go_neg_req_cb()
3666 } else if (dev->go_neg_req_sent) { in p2p_go_neg_req_cb()
3667 /* Cancel the increment from p2p_connect_send() on failure */ in p2p_go_neg_req_cb()
3668 dev->go_neg_req_sent--; in p2p_go_neg_req_cb()
3672 (dev->info.dev_capab & P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY) && in p2p_go_neg_req_cb()
3673 !is_zero_ether_addr(dev->member_in_go_dev)) { in p2p_go_neg_req_cb()
3674 …(p2p, "Peer " MACSTR " did not acknowledge request - try to use device discoverability through its… in p2p_go_neg_req_cb()
3675 MAC2STR(dev->info.p2p_device_addr)); in p2p_go_neg_req_cb()
3676 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_go_neg_req_cb()
3682 * Use P2P find, if needed, to find the other device from its listen in p2p_go_neg_req_cb()
3687 if (!success && p2p->go_neg_peer && in p2p_go_neg_req_cb()
3688 (p2p->go_neg_peer->flags & P2P_DEV_PEER_WAITING_RESPONSE)) { in p2p_go_neg_req_cb()
3691 * Peer is expected to wait our response and we will skip the in p2p_go_neg_req_cb()
3692 * listen phase. Add some randomness to the wait time here to in p2p_go_neg_req_cb()
3706 p2p_dbg(p2p, "GO Negotiation Response TX callback: success=%d", in p2p_go_neg_resp_cb()
3708 if (!p2p->go_neg_peer && p2p->state == P2P_PROVISIONING) { in p2p_go_neg_resp_cb()
3709 p2p_dbg(p2p, "Ignore TX callback event - GO Negotiation is not running anymore"); in p2p_go_neg_resp_cb()
3720 p2p_dbg(p2p, "GO Negotiation Response (failure) TX callback: success=%d", success); in p2p_go_neg_resp_failure_cb()
3721 if (p2p->go_neg_peer && p2p->go_neg_peer->status != P2P_SC_SUCCESS) { in p2p_go_neg_resp_failure_cb()
3722 p2p_go_neg_failed(p2p, p2p->go_neg_peer->status); in p2p_go_neg_resp_failure_cb()
3730 dev->status == P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE) in p2p_go_neg_resp_failure_cb()
3731 dev->flags |= P2P_DEV_PEER_WAITING_RESPONSE; in p2p_go_neg_resp_failure_cb()
3734 if (p2p->state == P2P_SEARCH || p2p->state == P2P_SD_DURING_FIND) in p2p_go_neg_resp_failure_cb()
3744 p2p_dbg(p2p, "GO Negotiation Confirm TX callback: result=%d", result); in p2p_go_neg_conf_cb()
3746 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_go_neg_conf_cb()
3747 p2p_go_neg_failed(p2p, -1); in p2p_go_neg_conf_cb()
3751 dev = p2p->go_neg_peer; in p2p_go_neg_conf_cb()
3755 * Retry GO Negotiation Confirmation in p2p_go_neg_conf_cb()
3759 if (dev && dev->go_neg_conf && in p2p_go_neg_conf_cb()
3760 dev->go_neg_conf_sent <= P2P_GO_NEG_CNF_MAX_RETRY_COUNT) { in p2p_go_neg_conf_cb()
3761 p2p_dbg(p2p, "GO Negotiation Confirm retry %d", in p2p_go_neg_conf_cb()
3762 dev->go_neg_conf_sent); in p2p_go_neg_conf_cb()
3763 p2p->pending_action_state = P2P_PENDING_GO_NEG_CONFIRM; in p2p_go_neg_conf_cb()
3764 if (p2p_send_action(p2p, dev->go_neg_conf_freq, in p2p_go_neg_conf_cb()
3765 dev->info.p2p_device_addr, in p2p_go_neg_conf_cb()
3766 p2p->cfg->dev_addr, in p2p_go_neg_conf_cb()
3767 dev->info.p2p_device_addr, in p2p_go_neg_conf_cb()
3768 wpabuf_head(dev->go_neg_conf), in p2p_go_neg_conf_cb()
3769 wpabuf_len(dev->go_neg_conf), 0) >= in p2p_go_neg_conf_cb()
3771 dev->go_neg_conf_sent++; in p2p_go_neg_conf_cb()
3774 p2p_dbg(p2p, "Failed to re-send Action frame"); in p2p_go_neg_conf_cb()
3777 * Continue with the assumption that the first attempt in p2p_go_neg_conf_cb()
3778 * went through and just the ACK frame was lost. in p2p_go_neg_conf_cb()
3783 * It looks like the TX status for GO Negotiation Confirm is in p2p_go_neg_conf_cb()
3784 * often showing failure even when the peer has actually in p2p_go_neg_conf_cb()
3785 * received the frame. Since the peer may change channels in p2p_go_neg_conf_cb()
3786 * immediately after having received the frame, we may not see in p2p_go_neg_conf_cb()
3788 * trigger this. To allow the group formation to succeed if the in p2p_go_neg_conf_cb()
3789 * peer did indeed receive the frame, continue regardless of in p2p_go_neg_conf_cb()
3790 * the TX status. in p2p_go_neg_conf_cb()
3792 …p2p_dbg(p2p, "Assume GO Negotiation Confirm TX was actually received by the peer even though Ack w… in p2p_go_neg_conf_cb()
3795 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_go_neg_conf_cb()
3813 p2p->pending_action_state, freq, MAC2STR(dst), MAC2STR(src), in p2p_send_action_cb()
3814 MAC2STR(bssid), result, p2p_state_txt(p2p->state)); in p2p_send_action_cb()
3816 state = p2p->pending_action_state; in p2p_send_action_cb()
3817 p2p->pending_action_state = P2P_NO_PENDING_ACTION; in p2p_send_action_cb()
3820 if (p2p->send_action_in_progress) { in p2p_send_action_cb()
3821 p2p->send_action_in_progress = 0; in p2p_send_action_cb()
3822 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_send_action_cb()
3868 if (freq == p2p->pending_client_disc_freq) { in p2p_listen_cb()
3869 p2p_dbg(p2p, "Client discoverability remain-awake completed"); in p2p_listen_cb()
3870 p2p->pending_client_disc_freq = 0; in p2p_listen_cb()
3874 if (freq != p2p->pending_listen_freq) { in p2p_listen_cb()
3876 freq, duration, p2p->pending_listen_freq); in p2p_listen_cb()
3880 p2p_dbg(p2p, "Starting Listen timeout(%u,%u) on freq=%u based on callback", in p2p_listen_cb()
3881 p2p->pending_listen_sec, p2p->pending_listen_usec, in p2p_listen_cb()
3882 p2p->pending_listen_freq); in p2p_listen_cb()
3883 p2p->pending_listen_wait_drv = false; in p2p_listen_cb()
3884 p2p->in_listen = 1; in p2p_listen_cb()
3885 p2p->drv_in_listen = freq; in p2p_listen_cb()
3886 if (p2p->pending_listen_sec || p2p->pending_listen_usec) { in p2p_listen_cb()
3889 * remain-on-channel end event, i.e., give driver more time to in p2p_listen_cb()
3890 * complete the operation before our timeout expires. in p2p_listen_cb()
3892 p2p_set_timeout(p2p, p2p->pending_listen_sec, in p2p_listen_cb()
3893 p2p->pending_listen_usec + 20000); in p2p_listen_cb()
3896 p2p->pending_listen_freq = 0; in p2p_listen_cb()
3903 p2p->drv_in_listen = 0; in p2p_listen_end()
3904 if (p2p->in_listen) in p2p_listen_end()
3905 return 0; /* Internal timeout will trigger the next step */ in p2p_listen_end()
3907 if (p2p->state == P2P_WAIT_PEER_CONNECT && p2p->go_neg_peer && in p2p_listen_end()
3908 p2p->pending_listen_freq) { in p2p_listen_end()
3910 * Better wait a bit if the driver is unable to start in p2p_listen_end()
3915 "Listen operation did not seem to start - delay idle phase to avoid busy loop"); in p2p_listen_end()
3920 if (p2p->state == P2P_CONNECT_LISTEN && p2p->go_neg_peer) { in p2p_listen_end()
3921 if (p2p->go_neg_peer->connect_reqs >= 120) { in p2p_listen_end()
3922 p2p_dbg(p2p, "Timeout on sending GO Negotiation Request without getting response"); in p2p_listen_end()
3923 p2p_go_neg_failed(p2p, -1); in p2p_listen_end()
3928 p2p_connect_send(p2p, p2p->go_neg_peer); in p2p_listen_end()
3930 } else if (p2p->state == P2P_SEARCH) { in p2p_listen_end()
3931 if (p2p->p2p_scan_running) { in p2p_listen_end()
3935 * the end of a remain-on-channel operation and the in p2p_listen_end()
3940 p2p_dbg(p2p, "p2p_scan already in progress - do not try to start a new one"); in p2p_listen_end()
3943 if (p2p->pending_listen_freq) { in p2p_listen_end()
3945 * Better wait a bit if the driver is unable to start in p2p_listen_end()
3949 p2p_dbg(p2p, "Listen operation did not seem to start - delay search phase to avoid busy loop"); in p2p_listen_end()
3953 if (p2p->search_delay) { in p2p_listen_end()
3955 p2p->search_delay); in p2p_listen_end()
3956 p2p_set_timeout(p2p, p2p->search_delay / 1000, in p2p_listen_end()
3957 (p2p->search_delay % 1000) * 1000); in p2p_listen_end()
3970 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_timeout_connect()
3971 if (p2p->go_neg_peer && in p2p_timeout_connect()
3972 (p2p->go_neg_peer->flags & P2P_DEV_WAIT_GO_NEG_CONFIRM)) { in p2p_timeout_connect()
3973 p2p_dbg(p2p, "Wait for GO Negotiation Confirm timed out - assume GO Negotiation failed"); in p2p_timeout_connect()
3974 p2p_go_neg_failed(p2p, -1); in p2p_timeout_connect()
3977 if (p2p->go_neg_peer && in p2p_timeout_connect()
3978 (p2p->go_neg_peer->flags & P2P_DEV_PEER_WAITING_RESPONSE) && in p2p_timeout_connect()
3979 p2p->go_neg_peer->connect_reqs < 120) { in p2p_timeout_connect()
3980 p2p_dbg(p2p, "Peer expected to wait our response - skip listen"); in p2p_timeout_connect()
3981 p2p_connect_send(p2p, p2p->go_neg_peer); in p2p_timeout_connect()
3984 if (p2p->go_neg_peer && p2p->go_neg_peer->oob_go_neg_freq > 0) { in p2p_timeout_connect()
3985 p2p_dbg(p2p, "Skip connect-listen since GO Neg channel known (OOB)"); in p2p_timeout_connect()
3997 if (p2p->go_neg_peer) { in p2p_timeout_connect_listen()
3998 if (p2p->drv_in_listen) { in p2p_timeout_connect_listen()
4003 if (p2p->go_neg_peer->connect_reqs >= 120) { in p2p_timeout_connect_listen()
4004 p2p_dbg(p2p, "Timeout on sending GO Negotiation Request without getting response"); in p2p_timeout_connect_listen()
4005 p2p_go_neg_failed(p2p, -1); in p2p_timeout_connect_listen()
4010 p2p_connect_send(p2p, p2p->go_neg_peer); in p2p_timeout_connect_listen()
4020 if (p2p->cfg->is_concurrent_session_active && in p2p_timeout_wait_peer_connect()
4021 p2p->cfg->is_concurrent_session_active(p2p->cfg->cb_ctx)) in p2p_timeout_wait_peer_connect()
4030 struct p2p_device *dev = p2p->go_neg_peer; in p2p_timeout_wait_peer_idle()
4033 p2p_dbg(p2p, "Unknown GO Neg peer - stop GO Neg wait"); in p2p_timeout_wait_peer_idle()
4037 p2p_dbg(p2p, "Go to Listen state while waiting for the peer to become ready for GO Negotiation"); in p2p_timeout_wait_peer_idle()
4038 p2p->cfg->stop_listen(p2p->cfg->cb_ctx); in p2p_timeout_wait_peer_idle()
4039 p2p->pending_listen_wait_drv = false; in p2p_timeout_wait_peer_idle()
4040 if (p2p->pending_listen_freq) { in p2p_timeout_wait_peer_idle()
4042 p2p->pending_listen_freq = 0; in p2p_timeout_wait_peer_idle()
4052 if (p2p->sd_peer) { in p2p_timeout_sd_during_find()
4053 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_timeout_sd_during_find()
4054 p2p->sd_peer = NULL; in p2p_timeout_sd_during_find()
4063 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_timeout_prov_disc_during_find()
4073 p2p->pending_action_state = P2P_NO_PENDING_ACTION; in p2p_timeout_prov_disc_req()
4080 if (!p2p->user_initiated_pd) in p2p_timeout_prov_disc_req()
4085 if (p2p->pd_retries) { in p2p_timeout_prov_disc_req()
4086 p2p->pd_retries--; in p2p_timeout_prov_disc_req()
4092 dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) { in p2p_timeout_prov_disc_req()
4093 if (!ether_addr_equal(p2p->pending_pd_devaddr, in p2p_timeout_prov_disc_req()
4094 dev->info.p2p_device_addr)) in p2p_timeout_prov_disc_req()
4096 if (dev->req_config_methods && in p2p_timeout_prov_disc_req()
4097 (dev->flags & P2P_DEV_PD_FOR_JOIN)) in p2p_timeout_prov_disc_req()
4101 if (p2p->p2ps_prov) { in p2p_timeout_prov_disc_req()
4102 adv_id = p2p->p2ps_prov->adv_id; in p2p_timeout_prov_disc_req()
4103 adv_mac = p2p->p2ps_prov->adv_mac; in p2p_timeout_prov_disc_req()
4106 if (p2p->cfg->prov_disc_fail) in p2p_timeout_prov_disc_req()
4107 p2p->cfg->prov_disc_fail(p2p->cfg->cb_ctx, in p2p_timeout_prov_disc_req()
4108 p2p->pending_pd_devaddr, in p2p_timeout_prov_disc_req()
4120 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_timeout_invite()
4122 if (p2p->inv_role == P2P_INVITE_ROLE_ACTIVE_GO) { in p2p_timeout_invite()
4124 * Better remain on operating channel instead of listen channel in p2p_timeout_invite()
4126 * Wait 120 ms to let the P2P GO to send its beacon on the in p2p_timeout_invite()
4129 p2p_dbg(p2p, "Inviting in active GO role - wait on operating channel"); in p2p_timeout_invite()
4139 if (p2p->invite_peer && p2p->invite_peer->invitation_reqs < 100) { in p2p_timeout_invite_listen()
4141 p2p_invite_send(p2p, p2p->invite_peer, in p2p_timeout_invite_listen()
4142 p2p->invite_go_dev_addr, p2p->invite_dev_pw_id); in p2p_timeout_invite_listen()
4144 if (p2p->invite_peer) { in p2p_timeout_invite_listen()
4146 if (p2p->cfg->invitation_result) in p2p_timeout_invite_listen()
4147 p2p->cfg->invitation_result( in p2p_timeout_invite_listen()
4148 p2p->cfg->cb_ctx, -1, NULL, NULL, in p2p_timeout_invite_listen()
4149 p2p->invite_peer->info.p2p_device_addr, in p2p_timeout_invite_listen()
4161 p2p_dbg(p2p, "Timeout (state=%s)", p2p_state_txt(p2p->state)); in p2p_state_timeout()
4163 p2p->in_listen = 0; in p2p_state_timeout()
4164 if (p2p->drv_in_listen) { in p2p_state_timeout()
4165 p2p_dbg(p2p, "Driver is still in listen state - stop it"); in p2p_state_timeout()
4166 p2p->cfg->stop_listen(p2p->cfg->cb_ctx); in p2p_state_timeout()
4167 p2p->pending_listen_wait_drv = false; in p2p_state_timeout()
4170 switch (p2p->state) { in p2p_state_timeout()
4173 if (p2p->pending_action_state == P2P_PENDING_PD) in p2p_state_timeout()
4178 if (p2p->pending_action_state == P2P_PENDING_PD) in p2p_state_timeout()
4180 if (p2p->search_delay && !p2p->in_search_delay) { in p2p_state_timeout()
4182 p2p->search_delay); in p2p_state_timeout()
4183 p2p->in_search_delay = 1; in p2p_state_timeout()
4184 p2p_set_timeout(p2p, p2p->search_delay / 1000, in p2p_state_timeout()
4185 (p2p->search_delay % 1000) * 1000); in p2p_state_timeout()
4188 p2p->in_search_delay = 0; in p2p_state_timeout()
4201 if (p2p->pending_action_state == P2P_PENDING_PD) in p2p_state_timeout()
4204 if (p2p->ext_listen_only) { in p2p_state_timeout()
4205 p2p_dbg(p2p, "Extended Listen Timing - Listen State completed"); in p2p_state_timeout()
4206 p2p->ext_listen_only = 0; in p2p_state_timeout()
4243 return -1; in p2p_reject()
4245 dev->status = P2P_SC_FAIL_REJECTED_BY_USER; in p2p_reject()
4246 dev->flags |= P2P_DEV_USER_REJECTED; in p2p_reject()
4255 return "not-ready"; in p2p_wps_method_text()
4295 dev = dl_list_first(&p2p->devices, struct p2p_device, list); in p2p_get_peer_info()
4298 dev = dl_list_first(&dev->list, struct p2p_device, list); in p2p_get_peer_info()
4299 if (&dev->list == &p2p->devices) in p2p_get_peer_info()
4306 return &dev->info; in p2p_get_peer_info()
4319 return -1; in p2p_get_peer_info_txt()
4321 dev = (struct p2p_device *) (((u8 *) info) - in p2p_get_peer_info_txt()
4328 res = os_snprintf(pos, end - pos, in p2p_get_peer_info_txt()
4345 (int) (now.sec - dev->last_seen.sec), in p2p_get_peer_info_txt()
4346 dev->listen_freq, in p2p_get_peer_info_txt()
4347 p2p_wps_method_text(dev->wps_method), in p2p_get_peer_info_txt()
4348 MAC2STR(dev->interface_addr), in p2p_get_peer_info_txt()
4349 MAC2STR(dev->member_in_go_dev), in p2p_get_peer_info_txt()
4350 MAC2STR(dev->member_in_go_iface), in p2p_get_peer_info_txt()
4351 dev->go_neg_req_sent, in p2p_get_peer_info_txt()
4352 p2p_go_state_text(dev->go_state), in p2p_get_peer_info_txt()
4353 dev->dialog_token, in p2p_get_peer_info_txt()
4354 MAC2STR(dev->intended_addr), in p2p_get_peer_info_txt()
4355 dev->country[0] ? dev->country[0] : '_', in p2p_get_peer_info_txt()
4356 dev->country[1] ? dev->country[1] : '_', in p2p_get_peer_info_txt()
4357 dev->oper_freq, in p2p_get_peer_info_txt()
4358 dev->req_config_methods, in p2p_get_peer_info_txt()
4359 dev->flags & P2P_DEV_PROBE_REQ_ONLY ? in p2p_get_peer_info_txt()
4361 dev->flags & P2P_DEV_REPORTED ? "[REPORTED]" : "", in p2p_get_peer_info_txt()
4362 dev->flags & P2P_DEV_NOT_YET_READY ? in p2p_get_peer_info_txt()
4364 dev->flags & P2P_DEV_PD_PEER_DISPLAY ? in p2p_get_peer_info_txt()
4366 dev->flags & P2P_DEV_PD_PEER_KEYPAD ? in p2p_get_peer_info_txt()
4368 dev->flags & P2P_DEV_PD_PEER_P2PS ? in p2p_get_peer_info_txt()
4370 dev->flags & P2P_DEV_USER_REJECTED ? in p2p_get_peer_info_txt()
4372 dev->flags & P2P_DEV_PEER_WAITING_RESPONSE ? in p2p_get_peer_info_txt()
4374 dev->flags & P2P_DEV_PREFER_PERSISTENT_GROUP ? in p2p_get_peer_info_txt()
4376 dev->flags & P2P_DEV_WAIT_GO_NEG_RESPONSE ? in p2p_get_peer_info_txt()
4378 dev->flags & P2P_DEV_WAIT_GO_NEG_CONFIRM ? in p2p_get_peer_info_txt()
4380 dev->flags & P2P_DEV_GROUP_CLIENT_ONLY ? in p2p_get_peer_info_txt()
4382 dev->flags & P2P_DEV_FORCE_FREQ ? in p2p_get_peer_info_txt()
4384 dev->flags & P2P_DEV_PD_FOR_JOIN ? in p2p_get_peer_info_txt()
4386 dev->flags & P2P_DEV_LAST_SEEN_AS_GROUP_CLIENT ? in p2p_get_peer_info_txt()
4388 dev->status, in p2p_get_peer_info_txt()
4389 dev->invitation_reqs); in p2p_get_peer_info_txt()
4390 if (os_snprintf_error(end - pos, res)) in p2p_get_peer_info_txt()
4391 return pos - buf; in p2p_get_peer_info_txt()
4394 if (dev->ext_listen_period) { in p2p_get_peer_info_txt()
4395 res = os_snprintf(pos, end - pos, in p2p_get_peer_info_txt()
4398 dev->ext_listen_period, in p2p_get_peer_info_txt()
4399 dev->ext_listen_interval); in p2p_get_peer_info_txt()
4400 if (os_snprintf_error(end - pos, res)) in p2p_get_peer_info_txt()
4401 return pos - buf; in p2p_get_peer_info_txt()
4405 if (dev->oper_ssid_len) { in p2p_get_peer_info_txt()
4406 res = os_snprintf(pos, end - pos, in p2p_get_peer_info_txt()
4408 wpa_ssid_txt(dev->oper_ssid, in p2p_get_peer_info_txt()
4409 dev->oper_ssid_len)); in p2p_get_peer_info_txt()
4410 if (os_snprintf_error(end - pos, res)) in p2p_get_peer_info_txt()
4411 return pos - buf; in p2p_get_peer_info_txt()
4416 if (dev->info.wfd_subelems) { in p2p_get_peer_info_txt()
4417 res = os_snprintf(pos, end - pos, "wfd_subelems="); in p2p_get_peer_info_txt()
4418 if (os_snprintf_error(end - pos, res)) in p2p_get_peer_info_txt()
4419 return pos - buf; in p2p_get_peer_info_txt()
4422 pos += wpa_snprintf_hex(pos, end - pos, in p2p_get_peer_info_txt()
4423 wpabuf_head(dev->info.wfd_subelems), in p2p_get_peer_info_txt()
4424 wpabuf_len(dev->info.wfd_subelems)); in p2p_get_peer_info_txt()
4426 res = os_snprintf(pos, end - pos, "\n"); in p2p_get_peer_info_txt()
4427 if (os_snprintf_error(end - pos, res)) in p2p_get_peer_info_txt()
4428 return pos - buf; in p2p_get_peer_info_txt()
4433 return pos - buf; in p2p_get_peer_info_txt()
4447 p2p->dev_capab |= P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY; in p2p_set_client_discoverability()
4450 p2p->dev_capab &= ~P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY; in p2p_set_client_discoverability()
4498 p2p_dbg(p2p, "Send Presence Request to GO " MACSTR in p2p_presence_req()
4507 return -1; in p2p_presence_req()
4509 p2p->pending_action_state = P2P_NO_PENDING_ACTION; in p2p_presence_req()
4559 p2p_dbg(p2p, "Received P2P Action - P2P Presence Request"); in p2p_process_presence_req()
4561 for (g = 0; g < p2p->num_groups; g++) { in p2p_process_presence_req()
4563 da, p2p_group_get_interface_addr(p2p->groups[g]))) { in p2p_process_presence_req()
4564 group = p2p->groups[g]; in p2p_process_presence_req()
4590 if (p2p->cfg->get_noa) in p2p_process_presence_req()
4591 noa_len = p2p->cfg->get_noa(p2p->cfg->cb_ctx, da, noa, in p2p_process_presence_req()
4594 noa_len = -1; in p2p_process_presence_req()
4603 p2p->pending_action_state = P2P_NO_PENDING_ACTION; in p2p_process_presence_req()
4617 p2p_dbg(p2p, "Received P2P Action - P2P Presence Response"); in p2p_process_presence_resp()
4630 if (p2p->cfg->presence_resp) { in p2p_process_presence_resp()
4631 p2p->cfg->presence_resp(p2p->cfg->cb_ctx, sa, *msg.status, in p2p_process_presence_resp()
4643 wpa_hexdump(MSG_DEBUG, "P2P: P2P Presence Response - NoA", in p2p_process_presence_resp()
4654 if (p2p->ext_listen_interval) { in p2p_ext_listen_timeout()
4656 eloop_register_timeout(p2p->ext_listen_interval_sec, in p2p_ext_listen_timeout()
4657 p2p->ext_listen_interval_usec, in p2p_ext_listen_timeout()
4661 if (p2p->state == P2P_LISTEN_ONLY && p2p->ext_listen_only) { in p2p_ext_listen_timeout()
4663 * This should not really happen, but it looks like the Listen in p2p_ext_listen_timeout()
4668 p2p_dbg(p2p, "Previous Extended Listen operation had not been completed - try again"); in p2p_ext_listen_timeout()
4669 p2p->ext_listen_only = 0; in p2p_ext_listen_timeout()
4673 if ((p2p->cfg->is_p2p_in_progress && in p2p_ext_listen_timeout()
4674 p2p->cfg->is_p2p_in_progress(p2p->cfg->cb_ctx)) || in p2p_ext_listen_timeout()
4675 (p2p->pending_action_state == P2P_PENDING_PD && in p2p_ext_listen_timeout()
4676 p2p->pd_retries > 0)) { in p2p_ext_listen_timeout()
4677 p2p_dbg(p2p, "Operation in progress - skip Extended Listen timeout (%s)", in p2p_ext_listen_timeout()
4678 p2p_state_txt(p2p->state)); in p2p_ext_listen_timeout()
4682 if (p2p->state != P2P_IDLE) { in p2p_ext_listen_timeout()
4683 p2p_dbg(p2p, "Skip Extended Listen timeout in active state (%s)", p2p_state_txt(p2p->state)); in p2p_ext_listen_timeout()
4688 p2p->ext_listen_only = 1; in p2p_ext_listen_timeout()
4689 if (p2p_listen(p2p, p2p->ext_listen_period) < 0) { in p2p_ext_listen_timeout()
4691 p2p->ext_listen_only = 0; in p2p_ext_listen_timeout()
4703 return -1; in p2p_ext_listen()
4710 p2p->ext_listen_period = 0; in p2p_ext_listen()
4711 p2p->ext_listen_interval = 0; in p2p_ext_listen()
4717 p2p->ext_listen_period = period; in p2p_ext_listen()
4718 p2p->ext_listen_interval = interval; in p2p_ext_listen()
4719 p2p->ext_listen_interval_sec = interval / 1000; in p2p_ext_listen()
4720 p2p->ext_listen_interval_usec = (interval % 1000) * 1000; in p2p_ext_listen()
4722 eloop_register_timeout(p2p->ext_listen_interval_sec, in p2p_ext_listen()
4723 p2p->ext_listen_interval_usec, in p2p_ext_listen()
4782 p2p->dev_capab |= P2P_DEV_CAPAB_INFRA_MANAGED; in p2p_set_managed_oper()
4785 p2p->dev_capab &= ~P2P_DEV_CAPAB_INFRA_MANAGED; in p2p_set_managed_oper()
4795 return p2p_channel_random_social(&p2p->channels, op_class, op_channel, in p2p_config_get_random_social()
4804 return -1; in p2p_set_listen_channel()
4810 if (p2p->cfg->channel_forced && forced == 0) { in p2p_set_listen_channel()
4812 "Listen channel was previously configured - do not override based on optimization"); in p2p_set_listen_channel()
4813 return -1; in p2p_set_listen_channel()
4819 if (p2p->state == P2P_IDLE) { in p2p_set_listen_channel()
4820 p2p->cfg->reg_class = reg_class; in p2p_set_listen_channel()
4821 p2p->cfg->channel = channel; in p2p_set_listen_channel()
4822 p2p->cfg->channel_forced = forced; in p2p_set_listen_channel()
4825 p2p->pending_reg_class = reg_class; in p2p_set_listen_channel()
4826 p2p->pending_channel = channel; in p2p_set_listen_channel()
4827 p2p->pending_channel_forced = forced; in p2p_set_listen_channel()
4836 return p2p->cfg->channel; in p2p_get_listen_channel()
4844 p2p->cfg->ssid_postfix_len = 0; in p2p_set_ssid_postfix()
4847 if (len > sizeof(p2p->cfg->ssid_postfix)) in p2p_set_ssid_postfix()
4848 return -1; in p2p_set_ssid_postfix()
4849 os_memcpy(p2p->cfg->ssid_postfix, postfix, len); in p2p_set_ssid_postfix()
4850 p2p->cfg->ssid_postfix_len = len; in p2p_set_ssid_postfix()
4859 return -1; in p2p_set_oper_channel()
4863 p2p->cfg->op_reg_class = op_reg_class; in p2p_set_oper_channel()
4864 p2p->cfg->op_channel = op_channel; in p2p_set_oper_channel()
4865 p2p->cfg->cfg_op_channel = cfg_op_channel; in p2p_set_oper_channel()
4879 return -1; in p2p_set_pref_chan()
4883 os_free(p2p->cfg->pref_chan); in p2p_set_pref_chan()
4884 p2p->cfg->pref_chan = n; in p2p_set_pref_chan()
4885 p2p->cfg->num_pref_chan = num_pref_chan; in p2p_set_pref_chan()
4896 if (list == NULL || list->num == 0) { in p2p_set_no_go_freq()
4897 os_free(p2p->no_go_freq.range); in p2p_set_no_go_freq()
4898 p2p->no_go_freq.range = NULL; in p2p_set_no_go_freq()
4899 p2p->no_go_freq.num = 0; in p2p_set_no_go_freq()
4903 tmp = os_calloc(list->num, sizeof(struct wpa_freq_range)); in p2p_set_no_go_freq()
4905 return -1; in p2p_set_no_go_freq()
4906 os_memcpy(tmp, list->range, list->num * sizeof(struct wpa_freq_range)); in p2p_set_no_go_freq()
4907 os_free(p2p->no_go_freq.range); in p2p_set_no_go_freq()
4908 p2p->no_go_freq.range = tmp; in p2p_set_no_go_freq()
4909 p2p->no_go_freq.num = list->num; in p2p_set_no_go_freq()
4910 p2p_dbg(p2p, "Updated no GO chan list"); in p2p_set_no_go_freq()
4920 if (dev == NULL || is_zero_ether_addr(dev->interface_addr)) in p2p_get_interface_addr()
4921 return -1; in p2p_get_interface_addr()
4922 os_memcpy(iface_addr, dev->interface_addr, ETH_ALEN); in p2p_get_interface_addr()
4932 return -1; in p2p_get_dev_addr()
4933 os_memcpy(dev_addr, dev->info.p2p_device_addr, ETH_ALEN); in p2p_get_dev_addr()
4940 os_memcpy(p2p->peer_filter, addr, ETH_ALEN); in p2p_set_peer_filter()
4941 if (is_zero_ether_addr(p2p->peer_filter)) in p2p_set_peer_filter()
4945 MAC2STR(p2p->peer_filter)); in p2p_set_peer_filter()
4952 if (p2p->cross_connect == enabled) in p2p_set_cross_connect()
4954 p2p->cross_connect = enabled; in p2p_set_cross_connect()
4955 /* TODO: may need to tear down any action group where we are GO(?) */ in p2p_set_cross_connect()
4963 return -1; in p2p_get_oper_freq()
4964 if (dev->oper_freq <= 0) in p2p_get_oper_freq()
4965 return -1; in p2p_get_oper_freq()
4966 return dev->oper_freq; in p2p_get_oper_freq()
4974 p2p->cfg->p2p_intra_bss = enabled; in p2p_set_intra_bss_dist()
4983 os_memcpy(&p2p->cfg->channels, chan, sizeof(struct p2p_channels)); in p2p_update_channel_list()
4984 p2p_channels_dump(p2p, "channels", &p2p->cfg->channels); in p2p_update_channel_list()
4985 os_memcpy(&p2p->cfg->cli_channels, cli_chan, in p2p_update_channel_list()
4987 p2p_channels_dump(p2p, "cli_channels", &p2p->cfg->cli_channels); in p2p_update_channel_list()
4997 res = p2p->cfg->send_action(p2p->cfg->cb_ctx, freq, dst, src, bssid, in p2p_send_action()
4999 if (res == 0 && scheduled && p2p->in_listen && freq > 0 && in p2p_send_action()
5000 p2p->drv_in_listen > 0 && in p2p_send_action()
5001 (unsigned int) p2p->drv_in_listen != freq) { in p2p_send_action()
5003 "Stop listen on %d MHz to allow a frame to be sent immediately on %d MHz", in p2p_send_action()
5004 p2p->drv_in_listen, freq); in p2p_send_action()
5016 p2p->best_freq_24 = freq_24; in p2p_set_best_channels()
5017 p2p->best_freq_5 = freq_5; in p2p_set_best_channels()
5018 p2p->best_freq_overall = freq_overall; in p2p_set_best_channels()
5025 p2p->own_freq_preference = freq; in p2p_set_own_freq_preference()
5031 if (p2p == NULL || p2p->go_neg_peer == NULL) in p2p_get_go_neg_peer()
5033 return p2p->go_neg_peer->info.p2p_device_addr; in p2p_get_go_neg_peer()
5048 if (dev->flags & P2P_DEV_PROBE_REQ_ONLY) in p2p_get_peer_found()
5051 return &dev->info; in p2p_get_peer_found()
5054 dev = dl_list_first(&dev->list, in p2p_get_peer_found()
5057 if (!dev || &dev->list == &p2p->devices) in p2p_get_peer_found()
5059 } while (dev->flags & P2P_DEV_PROBE_REQ_ONLY); in p2p_get_peer_found()
5062 dev = dl_list_first(&p2p->devices, struct p2p_device, list); in p2p_get_peer_found()
5065 while (dev->flags & P2P_DEV_PROBE_REQ_ONLY) { in p2p_get_peer_found()
5066 dev = dl_list_first(&dev->list, in p2p_get_peer_found()
5069 if (!dev || &dev->list == &p2p->devices) in p2p_get_peer_found()
5074 return &dev->info; in p2p_get_peer_found()
5082 if (p2p->state == P2P_SEARCH) in p2p_in_progress()
5084 return p2p->state != P2P_IDLE && p2p->state != P2P_PROVISIONING; in p2p_in_progress()
5092 p2p->go_timeout = go_timeout; in p2p_set_config_timeout()
5093 p2p->client_timeout = client_timeout; in p2p_set_config_timeout()
5105 for (g = 0; g < p2p->num_groups; g++) { in p2p_update_wfd_ie_groups()
5106 group = p2p->groups[g]; in p2p_update_wfd_ie_groups()
5114 wpabuf_free(p2p->wfd_ie_beacon); in p2p_set_wfd_ie_beacon()
5115 p2p->wfd_ie_beacon = ie; in p2p_set_wfd_ie_beacon()
5123 wpabuf_free(p2p->wfd_ie_probe_req); in p2p_set_wfd_ie_probe_req()
5124 p2p->wfd_ie_probe_req = ie; in p2p_set_wfd_ie_probe_req()
5131 wpabuf_free(p2p->wfd_ie_probe_resp); in p2p_set_wfd_ie_probe_resp()
5132 p2p->wfd_ie_probe_resp = ie; in p2p_set_wfd_ie_probe_resp()
5140 wpabuf_free(p2p->wfd_ie_assoc_req); in p2p_set_wfd_ie_assoc_req()
5141 p2p->wfd_ie_assoc_req = ie; in p2p_set_wfd_ie_assoc_req()
5148 wpabuf_free(p2p->wfd_ie_invitation); in p2p_set_wfd_ie_invitation()
5149 p2p->wfd_ie_invitation = ie; in p2p_set_wfd_ie_invitation()
5156 wpabuf_free(p2p->wfd_ie_prov_disc_req); in p2p_set_wfd_ie_prov_disc_req()
5157 p2p->wfd_ie_prov_disc_req = ie; in p2p_set_wfd_ie_prov_disc_req()
5164 wpabuf_free(p2p->wfd_ie_prov_disc_resp); in p2p_set_wfd_ie_prov_disc_resp()
5165 p2p->wfd_ie_prov_disc_resp = ie; in p2p_set_wfd_ie_prov_disc_resp()
5172 wpabuf_free(p2p->wfd_ie_go_neg); in p2p_set_wfd_ie_go_neg()
5173 p2p->wfd_ie_go_neg = ie; in p2p_set_wfd_ie_go_neg()
5180 wpabuf_free(p2p->wfd_dev_info); in p2p_set_wfd_dev_info()
5182 p2p->wfd_dev_info = wpabuf_dup(elem); in p2p_set_wfd_dev_info()
5183 if (p2p->wfd_dev_info == NULL) in p2p_set_wfd_dev_info()
5184 return -1; in p2p_set_wfd_dev_info()
5186 p2p->wfd_dev_info = NULL; in p2p_set_wfd_dev_info()
5194 wpabuf_free(p2p->wfd_r2_dev_info); in p2p_set_wfd_r2_dev_info()
5196 p2p->wfd_r2_dev_info = wpabuf_dup(elem); in p2p_set_wfd_r2_dev_info()
5197 if (p2p->wfd_r2_dev_info == NULL) in p2p_set_wfd_r2_dev_info()
5198 return -1; in p2p_set_wfd_r2_dev_info()
5200 p2p->wfd_r2_dev_info = NULL; in p2p_set_wfd_r2_dev_info()
5208 wpabuf_free(p2p->wfd_assoc_bssid); in p2p_set_wfd_assoc_bssid()
5210 p2p->wfd_assoc_bssid = wpabuf_dup(elem); in p2p_set_wfd_assoc_bssid()
5211 if (p2p->wfd_assoc_bssid == NULL) in p2p_set_wfd_assoc_bssid()
5212 return -1; in p2p_set_wfd_assoc_bssid()
5214 p2p->wfd_assoc_bssid = NULL; in p2p_set_wfd_assoc_bssid()
5223 wpabuf_free(p2p->wfd_coupled_sink_info); in p2p_set_wfd_coupled_sink_info()
5225 p2p->wfd_coupled_sink_info = wpabuf_dup(elem); in p2p_set_wfd_coupled_sink_info()
5226 if (p2p->wfd_coupled_sink_info == NULL) in p2p_set_wfd_coupled_sink_info()
5227 return -1; in p2p_set_wfd_coupled_sink_info()
5229 p2p->wfd_coupled_sink_info = NULL; in p2p_set_wfd_coupled_sink_info()
5241 return -1; in p2p_set_disc_int()
5243 p2p->min_disc_int = min_disc_int; in p2p_set_disc_int()
5244 p2p->max_disc_int = max_disc_int; in p2p_set_disc_int()
5245 p2p->max_disc_tu = max_disc_tu; in p2p_set_disc_int()
5258 if (!p2p->cfg->debug_print) in p2p_dbg()
5263 buf[sizeof(buf) - 1] = '\0'; in p2p_dbg()
5265 p2p->cfg->debug_print(p2p->cfg->cb_ctx, MSG_DEBUG, buf); in p2p_dbg()
5274 if (!p2p->cfg->debug_print) in p2p_info()
5279 buf[sizeof(buf) - 1] = '\0'; in p2p_info()
5281 p2p->cfg->debug_print(p2p->cfg->cb_ctx, MSG_INFO, buf); in p2p_info()
5290 if (!p2p->cfg->debug_print) in p2p_err()
5295 buf[sizeof(buf) - 1] = '\0'; in p2p_err()
5297 p2p->cfg->debug_print(p2p->cfg->cb_ctx, MSG_ERROR, buf); in p2p_err()
5308 dl_list_for_each_safe(dev, n, &p2p->devices, struct p2p_device, list) { in p2p_loop_on_known_peers()
5309 peer_callback(&dev->info, user_data); in p2p_loop_on_known_peers()
5329 op_class = p2p->cfg->reg_class; in p2p_build_nfc_handover()
5330 channel = p2p->cfg->channel; in p2p_build_nfc_handover()
5332 p2p_buf_add_capability(buf, p2p->dev_capab & in p2p_build_nfc_handover()
5336 if (p2p->num_groups > 0) { in p2p_build_nfc_handover()
5337 int freq = p2p_group_get_freq(p2p->groups[0]); in p2p_build_nfc_handover()
5341 "Unknown GO operating frequency %d MHz for NFC handover", in p2p_build_nfc_handover()
5357 p2p_buf_add_oob_go_neg_channel(buf, p2p->cfg->country, op_class, in p2p_build_nfc_handover()
5360 if (p2p->num_groups > 0) { in p2p_build_nfc_handover()
5362 p2p_buf_add_group_info(p2p->groups[0], buf, 5); in p2p_build_nfc_handover()
5363 p2p_group_buf_add_id(p2p->groups[0], buf); in p2p_build_nfc_handover()
5368 * Add the optional P2P Group ID to indicate in which group this in p2p_build_nfc_handover()
5407 params->next_step = NO_ACTION; in p2p_process_nfc_connection_handover()
5409 if (p2p_parse_ies_separate(params->wsc_attr, params->wsc_len, in p2p_process_nfc_connection_handover()
5410 params->p2p_attr, params->p2p_len, &msg)) { in p2p_process_nfc_connection_handover()
5413 return -1; in p2p_process_nfc_connection_handover()
5423 return -1; in p2p_process_nfc_connection_handover()
5427 os_memcpy(params->oob_dev_pw, msg.oob_dev_password, in p2p_process_nfc_connection_handover()
5429 params->oob_dev_pw_len = msg.oob_dev_password_len; in p2p_process_nfc_connection_handover()
5435 return -1; in p2p_process_nfc_connection_handover()
5438 params->peer = &dev->info; in p2p_process_nfc_connection_handover()
5440 os_get_reltime(&dev->last_seen); in p2p_process_nfc_connection_handover()
5441 dev->flags &= ~(P2P_DEV_PROBE_REQ_ONLY | P2P_DEV_GROUP_CLIENT_ONLY); in p2p_process_nfc_connection_handover()
5445 p2p_dbg(p2p, "OOB GO Negotiation Channel attribute not included"); in p2p_process_nfc_connection_handover()
5447 return -1; in p2p_process_nfc_connection_handover()
5457 p2p_dbg(p2p, "Unknown peer OOB GO Neg channel"); in p2p_process_nfc_connection_handover()
5459 return -1; in p2p_process_nfc_connection_handover()
5464 p2p_dbg(p2p, "Peer OOB GO operating channel: %u MHz", freq); in p2p_process_nfc_connection_handover()
5465 params->go_freq = freq; in p2p_process_nfc_connection_handover()
5467 p2p_dbg(p2p, "Peer (client) OOB GO operating channel: %u MHz", in p2p_process_nfc_connection_handover()
5469 params->go_freq = freq; in p2p_process_nfc_connection_handover()
5471 p2p_dbg(p2p, "Peer OOB GO Neg channel: %u MHz", freq); in p2p_process_nfc_connection_handover()
5472 dev->oob_go_neg_freq = freq; in p2p_process_nfc_connection_handover()
5474 if (!params->sel && role != P2P_GO_IN_A_GROUP) { in p2p_process_nfc_connection_handover()
5475 freq = p2p_channel_to_freq(p2p->cfg->reg_class, in p2p_process_nfc_connection_handover()
5476 p2p->cfg->channel); in p2p_process_nfc_connection_handover()
5480 return -1; in p2p_process_nfc_connection_handover()
5482 p2p_dbg(p2p, "Use own Listen channel as OOB GO Neg channel: %u MHz", freq); in p2p_process_nfc_connection_handover()
5483 dev->oob_go_neg_freq = freq; in p2p_process_nfc_connection_handover()
5487 os_memcpy(params->go_dev_addr, msg.group_id, ETH_ALEN); in p2p_process_nfc_connection_handover()
5488 params->go_ssid_len = msg.group_id_len - ETH_ALEN; in p2p_process_nfc_connection_handover()
5489 os_memcpy(params->go_ssid, msg.group_id + ETH_ALEN, in p2p_process_nfc_connection_handover()
5490 params->go_ssid_len); in p2p_process_nfc_connection_handover()
5493 if (dev->flags & P2P_DEV_USER_REJECTED) { in p2p_process_nfc_connection_handover()
5499 if (!(dev->flags & P2P_DEV_REPORTED)) { in p2p_process_nfc_connection_handover()
5500 p2p->cfg->dev_found(p2p->cfg->cb_ctx, p2p_dev_addr, &dev->info, in p2p_process_nfc_connection_handover()
5501 !(dev->flags & P2P_DEV_REPORTED_ONCE)); in p2p_process_nfc_connection_handover()
5502 dev->flags |= P2P_DEV_REPORTED | P2P_DEV_REPORTED_ONCE; in p2p_process_nfc_connection_handover()
5506 if (role == P2P_GO_IN_A_GROUP && p2p->num_groups > 0) in p2p_process_nfc_connection_handover()
5507 params->next_step = BOTH_GO; in p2p_process_nfc_connection_handover()
5509 params->next_step = JOIN_GROUP; in p2p_process_nfc_connection_handover()
5511 dev->flags |= P2P_DEV_GROUP_CLIENT_ONLY; in p2p_process_nfc_connection_handover()
5512 params->next_step = PEER_CLIENT; in p2p_process_nfc_connection_handover()
5513 } else if (p2p->num_groups > 0) in p2p_process_nfc_connection_handover()
5514 params->next_step = AUTH_JOIN; in p2p_process_nfc_connection_handover()
5515 else if (params->sel) in p2p_process_nfc_connection_handover()
5516 params->next_step = INIT_GO_NEG; in p2p_process_nfc_connection_handover()
5518 params->next_step = RESP_GO_NEG; in p2p_process_nfc_connection_handover()
5529 p2p->authorized_oob_dev_pw_id = dev_pw_id; in p2p_set_authorized_oob_dev_pw_id()
5538 p2p->go_intent = go_intent; in p2p_set_authorized_oob_dev_pw_id()
5539 os_memcpy(p2p->intended_addr, own_interface_addr, ETH_ALEN); in p2p_set_authorized_oob_dev_pw_id()
5548 return -1; in p2p_set_passphrase_len()
5549 p2p->cfg->passphrase_len = len; in p2p_set_passphrase_len()
5556 p2p->vendor_elem = vendor_elem; in p2p_set_vendor_elems()
5565 "Timeout on waiting peer to become ready for GO Negotiation"); in p2p_go_neg_wait_timeout()
5566 p2p_go_neg_failed(p2p, -1); in p2p_go_neg_wait_timeout()
5578 p2p->num_pref_freq = size; in p2p_set_own_pref_freq_list()
5579 os_memcpy(p2p->pref_freq_list, pref_freq_list, in p2p_set_own_pref_freq_list()
5583 i, p2p->pref_freq_list[i].freq); in p2p_set_own_pref_freq_list()
5591 p2p->override_pref_op_class = op_class; in p2p_set_override_pref_op_chan()
5592 p2p->override_pref_channel = chan; in p2p_set_override_pref_op_chan()
5635 return dev->support_6ghz; in p2p_is_peer_6ghz_capab()
5641 p2p->p2p_6ghz_capable = allow_6ghz; in p2p_set_6ghz_dev_capab()
5642 p2p->allow_6ghz = allow_6ghz; in p2p_set_6ghz_dev_capab()
5646 p2p->dev_capab |= P2P_DEV_CAPAB_6GHZ_BAND_CAPABLE; in p2p_set_6ghz_dev_capab()
5648 p2p->dev_capab &= ~P2P_DEV_CAPAB_6GHZ_BAND_CAPABLE; in p2p_set_6ghz_dev_capab()
5654 return p2p->p2p_6ghz_capable; in is_p2p_6ghz_capable()
5661 return p2p->wfd_ie_probe_req != NULL; in p2p_wfd_enabled()
5674 return dev && dev->info.wfd_subelems != NULL; in p2p_peer_wfd_enabled()
5683 return p2p->allow_6ghz; in is_p2p_allow_6ghz()
5689 p2p->allow_6ghz = value; in set_p2p_allow_6ghz()