Lines Matching refs:p2p

36 int p2p_peer_channels_check(struct p2p_data *p2p, struct p2p_channels *own,  in p2p_peer_channels_check()  argument
54 if (pos[2] != 0x04 && os_memcmp(pos, p2p->cfg->country, 2) != 0) { in p2p_peer_channels_check()
55 p2p_info(p2p, "Mismatching country (ours=%c%c peer's=%c%c)", in p2p_peer_channels_check()
56 p2p->cfg->country[0], p2p->cfg->country[1], in p2p_peer_channels_check()
67 p2p_info(p2p, "Invalid peer Channel List"); in p2p_peer_channels_check()
80 p2p_dbg(p2p, "Own reg_classes %d peer reg_classes %d intersection reg_classes %d", in p2p_peer_channels_check()
85 p2p_info(p2p, "No common channels found"); in p2p_peer_channels_check()
92 static int p2p_peer_channels(struct p2p_data *p2p, struct p2p_device *dev, in p2p_peer_channels() argument
95 return p2p_peer_channels_check(p2p, &p2p->channels, dev, in p2p_peer_channels()
138 static struct wpabuf * p2p_build_go_neg_req(struct p2p_data *p2p, in p2p_build_go_neg_req() argument
149 if (p2p->wfd_ie_go_neg) in p2p_build_go_neg_req()
150 extra = wpabuf_len(p2p->wfd_ie_go_neg); in p2p_build_go_neg_req()
153 if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_REQ]) in p2p_build_go_neg_req()
154 extra += wpabuf_len(p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_REQ]); in p2p_build_go_neg_req()
169 if (p2p->cross_connect) in p2p_build_go_neg_req()
171 if (p2p->cfg->p2p_intra_bss) in p2p_build_go_neg_req()
173 p2p_buf_add_capability(buf, p2p->dev_capab & in p2p_build_go_neg_req()
176 p2p_buf_add_go_intent(buf, (p2p->go_intent << 1) | peer->tie_breaker); in p2p_build_go_neg_req()
177 p2p_buf_add_config_timeout(buf, p2p->go_timeout, p2p->client_timeout); in p2p_build_go_neg_req()
178 p2p_buf_add_listen_channel(buf, p2p->cfg->country, p2p->cfg->reg_class, in p2p_build_go_neg_req()
179 p2p->cfg->channel); in p2p_build_go_neg_req()
180 if (p2p->ext_listen_interval) in p2p_build_go_neg_req()
181 p2p_buf_add_ext_listen_timing(buf, p2p->ext_listen_period, in p2p_build_go_neg_req()
182 p2p->ext_listen_interval); in p2p_build_go_neg_req()
183 p2p_buf_add_intended_addr(buf, p2p->intended_addr); in p2p_build_go_neg_req()
184 is_6ghz_capab = is_p2p_6ghz_capable(p2p) && in p2p_build_go_neg_req()
185 p2p_is_peer_6ghz_capab(p2p, peer->info.p2p_device_addr); in p2p_build_go_neg_req()
186 if (p2p->num_pref_freq) { in p2p_build_go_neg_req()
187 bool go = p2p->go_intent == 15; in p2p_build_go_neg_req()
190 p2p_pref_channel_filter(&p2p->channels, p2p->pref_freq_list, in p2p_build_go_neg_req()
191 p2p->num_pref_freq, &pref_chanlist, go); in p2p_build_go_neg_req()
192 p2p_channels_dump(p2p, "channel list after filtering", in p2p_build_go_neg_req()
194 p2p_buf_add_channel_list(buf, p2p->cfg->country, in p2p_build_go_neg_req()
197 p2p_buf_add_channel_list(buf, p2p->cfg->country, in p2p_build_go_neg_req()
198 &p2p->channels, is_6ghz_capab); in p2p_build_go_neg_req()
200 p2p_buf_add_device_info(buf, p2p, peer); in p2p_build_go_neg_req()
201 p2p_buf_add_operating_channel(buf, p2p->cfg->country, in p2p_build_go_neg_req()
202 p2p->op_reg_class, p2p->op_channel); in p2p_build_go_neg_req()
205 p2p_buf_add_pref_channel_list(buf, p2p->pref_freq_list, in p2p_build_go_neg_req()
206 p2p->num_pref_freq); in p2p_build_go_neg_req()
212 if (p2p_build_wps_ie(p2p, buf, pw_id, 0) < 0) { in p2p_build_go_neg_req()
213 p2p_dbg(p2p, "Failed to build WPS IE for GO Negotiation Request"); in p2p_build_go_neg_req()
219 if (p2p->wfd_ie_go_neg) in p2p_build_go_neg_req()
220 wpabuf_put_buf(buf, p2p->wfd_ie_go_neg); in p2p_build_go_neg_req()
223 if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_REQ]) in p2p_build_go_neg_req()
224 wpabuf_put_buf(buf, p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_REQ]); in p2p_build_go_neg_req()
230 int p2p_connect_send(struct p2p_data *p2p, struct p2p_device *dev) in p2p_connect_send() argument
237 p2p_dbg(p2p, "Use PD-before-GO-Neg workaround for " MACSTR, in p2p_connect_send()
249 return p2p_prov_disc_req(p2p, dev->info.p2p_device_addr, in p2p_connect_send()
257 p2p_dbg(p2p, "No Listen/Operating frequency known for the peer " in p2p_connect_send()
263 req = p2p_build_go_neg_req(p2p, dev); in p2p_connect_send()
266 p2p_dbg(p2p, "Sending GO Negotiation Request"); in p2p_connect_send()
267 p2p_set_state(p2p, P2P_CONNECT); in p2p_connect_send()
268 p2p->pending_action_state = P2P_PENDING_GO_NEG_REQUEST; in p2p_connect_send()
269 p2p->go_neg_peer = dev; in p2p_connect_send()
270 eloop_cancel_timeout(p2p_go_neg_wait_timeout, p2p, NULL); in p2p_connect_send()
273 if (p2p_send_action(p2p, freq, dev->info.p2p_device_addr, in p2p_connect_send()
274 p2p->cfg->dev_addr, dev->info.p2p_device_addr, in p2p_connect_send()
276 p2p_dbg(p2p, "Failed to send Action frame"); in p2p_connect_send()
278 p2p_set_timeout(p2p, 0, 0); in p2p_connect_send()
288 static struct wpabuf * p2p_build_go_neg_resp(struct p2p_data *p2p, in p2p_build_go_neg_resp() argument
301 p2p_dbg(p2p, "Building GO Negotiation Response"); in p2p_build_go_neg_resp()
304 if (p2p->wfd_ie_go_neg) in p2p_build_go_neg_resp()
305 extra = wpabuf_len(p2p->wfd_ie_go_neg); in p2p_build_go_neg_resp()
308 if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_RESP]) in p2p_build_go_neg_resp()
309 extra += wpabuf_len(p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_RESP]); in p2p_build_go_neg_resp()
327 if (p2p->cross_connect) in p2p_build_go_neg_resp()
329 if (p2p->cfg->p2p_intra_bss) in p2p_build_go_neg_resp()
332 p2p_buf_add_capability(buf, p2p->dev_capab & in p2p_build_go_neg_resp()
335 p2p_buf_add_go_intent(buf, (p2p->go_intent << 1) | tie_breaker); in p2p_build_go_neg_resp()
336 p2p_buf_add_config_timeout(buf, p2p->go_timeout, p2p->client_timeout); in p2p_build_go_neg_resp()
337 if (p2p->override_pref_op_class) { in p2p_build_go_neg_resp()
338 p2p_dbg(p2p, "Override operating channel preference"); in p2p_build_go_neg_resp()
339 p2p_buf_add_operating_channel(buf, p2p->cfg->country, in p2p_build_go_neg_resp()
340 p2p->override_pref_op_class, in p2p_build_go_neg_resp()
341 p2p->override_pref_channel); in p2p_build_go_neg_resp()
342 } else if (peer && peer->go_state == REMOTE_GO && !p2p->num_pref_freq) { in p2p_build_go_neg_resp()
343 p2p_dbg(p2p, "Omit Operating Channel attribute"); in p2p_build_go_neg_resp()
345 p2p_buf_add_operating_channel(buf, p2p->cfg->country, in p2p_build_go_neg_resp()
346 p2p->op_reg_class, in p2p_build_go_neg_resp()
347 p2p->op_channel); in p2p_build_go_neg_resp()
349 p2p_buf_add_intended_addr(buf, p2p->intended_addr); in p2p_build_go_neg_resp()
350 if (p2p->num_pref_freq) { in p2p_build_go_neg_resp()
352 p2p->go_intent == 15; in p2p_build_go_neg_resp()
354 p2p_pref_channel_filter(&p2p->channels, p2p->pref_freq_list, in p2p_build_go_neg_resp()
355 p2p->num_pref_freq, &pref_chanlist, go); in p2p_build_go_neg_resp()
356 p2p_channels_dump(p2p, "channel list after filtering", in p2p_build_go_neg_resp()
359 p2p_copy_channels(&pref_chanlist, &p2p->channels, in p2p_build_go_neg_resp()
360 p2p->allow_6ghz); in p2p_build_go_neg_resp()
363 p2p_buf_add_channel_list(buf, p2p->cfg->country, in p2p_build_go_neg_resp()
366 is_6ghz_capab = is_p2p_6ghz_capable(p2p) && in p2p_build_go_neg_resp()
367 p2p_is_peer_6ghz_capab(p2p, peer->info.p2p_device_addr); in p2p_build_go_neg_resp()
368 p2p_buf_add_channel_list(buf, p2p->cfg->country, in p2p_build_go_neg_resp()
373 is_6ghz_capab = is_p2p_6ghz_capable(p2p) && in p2p_build_go_neg_resp()
374 p2p_is_peer_6ghz_capab(p2p, peer->info.p2p_device_addr); in p2p_build_go_neg_resp()
377 p2p_buf_add_channel_list(buf, p2p->cfg->country, &res, in p2p_build_go_neg_resp()
380 p2p_buf_add_device_info(buf, p2p, peer); in p2p_build_go_neg_resp()
382 p2p_buf_add_group_id(buf, p2p->cfg->dev_addr, p2p->ssid, in p2p_build_go_neg_resp()
383 p2p->ssid_len); in p2p_build_go_neg_resp()
391 if (p2p_build_wps_ie(p2p, buf, pw_id, 0) < 0) { in p2p_build_go_neg_resp()
392 p2p_dbg(p2p, "Failed to build WPS IE for GO Negotiation Response"); in p2p_build_go_neg_resp()
398 if (p2p->wfd_ie_go_neg) in p2p_build_go_neg_resp()
399 wpabuf_put_buf(buf, p2p->wfd_ie_go_neg); in p2p_build_go_neg_resp()
402 if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_RESP]) in p2p_build_go_neg_resp()
403 wpabuf_put_buf(buf, p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_RESP]); in p2p_build_go_neg_resp()
420 void p2p_reselect_channel(struct p2p_data *p2p, in p2p_reselect_channel() argument
432 if (p2p->own_freq_preference > 0 && in p2p_reselect_channel()
433 p2p_freq_to_channel(p2p->own_freq_preference, in p2p_reselect_channel()
436 p2p_dbg(p2p, "Pick own channel preference (reg_class %u channel %u) from intersection", in p2p_reselect_channel()
438 p2p->op_reg_class = op_reg_class; in p2p_reselect_channel()
439 p2p->op_channel = op_channel; in p2p_reselect_channel()
443 if (p2p->best_freq_overall > 0 && in p2p_reselect_channel()
444 p2p_freq_to_channel(p2p->best_freq_overall, in p2p_reselect_channel()
447 p2p_dbg(p2p, "Pick best overall channel (reg_class %u channel %u) from intersection", in p2p_reselect_channel()
449 p2p->op_reg_class = op_reg_class; in p2p_reselect_channel()
450 p2p->op_channel = op_channel; in p2p_reselect_channel()
455 freq = p2p_channel_to_freq(p2p->op_reg_class, p2p->op_channel); in p2p_reselect_channel()
456 if (freq >= 2400 && freq < 2500 && p2p->best_freq_5 > 0 && in p2p_reselect_channel()
457 !p2p_channels_includes(intersection, p2p->op_reg_class, in p2p_reselect_channel()
458 p2p->op_channel) && in p2p_reselect_channel()
459 p2p_freq_to_channel(p2p->best_freq_5, in p2p_reselect_channel()
462 p2p_dbg(p2p, "Pick best 5 GHz channel (reg_class %u channel %u) from intersection", in p2p_reselect_channel()
464 p2p->op_reg_class = op_reg_class; in p2p_reselect_channel()
465 p2p->op_channel = op_channel; in p2p_reselect_channel()
469 if (freq >= 4900 && freq < 6000 && p2p->best_freq_24 > 0 && in p2p_reselect_channel()
470 !p2p_channels_includes(intersection, p2p->op_reg_class, in p2p_reselect_channel()
471 p2p->op_channel) && in p2p_reselect_channel()
472 p2p_freq_to_channel(p2p->best_freq_24, in p2p_reselect_channel()
475 p2p_dbg(p2p, "Pick best 2.4 GHz channel (reg_class %u channel %u) from intersection", in p2p_reselect_channel()
477 p2p->op_reg_class = op_reg_class; in p2p_reselect_channel()
478 p2p->op_channel = op_channel; in p2p_reselect_channel()
483 for (i = 0; p2p->cfg->pref_chan && i < p2p->cfg->num_pref_chan; i++) { in p2p_reselect_channel()
485 p2p->cfg->pref_chan[i].op_class, in p2p_reselect_channel()
486 p2p->cfg->pref_chan[i].chan)) { in p2p_reselect_channel()
487 p2p->op_reg_class = p2p->cfg->pref_chan[i].op_class; in p2p_reselect_channel()
488 p2p->op_channel = p2p->cfg->pref_chan[i].chan; in p2p_reselect_channel()
489 p2p_dbg(p2p, "Pick highest preferred channel (op_class %u channel %u) from intersection", in p2p_reselect_channel()
490 p2p->op_reg_class, p2p->op_channel); in p2p_reselect_channel()
497 &p2p->op_reg_class, &p2p->op_channel) == 0) { in p2p_reselect_channel()
498 p2p_dbg(p2p, "Pick possible EDMG channel (op_class %u channel %u) from intersection", in p2p_reselect_channel()
499 p2p->op_reg_class, p2p->op_channel); in p2p_reselect_channel()
505 &p2p->op_reg_class, &p2p->op_channel) == 0) { in p2p_reselect_channel()
506 p2p_dbg(p2p, "Pick possible VHT channel (op_class %u channel %u) from intersection", in p2p_reselect_channel()
507 p2p->op_reg_class, p2p->op_channel); in p2p_reselect_channel()
513 &p2p->op_reg_class, &p2p->op_channel) == 0) { in p2p_reselect_channel()
514 p2p_dbg(p2p, "Pick possible HT40 channel (op_class %u channel %u) from intersection", in p2p_reselect_channel()
515 p2p->op_reg_class, p2p->op_channel); in p2p_reselect_channel()
521 &p2p->op_reg_class, &p2p->op_channel) == 0) { in p2p_reselect_channel()
522 p2p_dbg(p2p, "Pick possible 5 GHz channel (op_class %u channel %u) from intersection", in p2p_reselect_channel()
523 p2p->op_reg_class, p2p->op_channel); in p2p_reselect_channel()
532 if (p2p_channels_includes(intersection, p2p->op_reg_class, in p2p_reselect_channel()
533 p2p->op_channel)) { in p2p_reselect_channel()
534 …p2p_dbg(p2p, "Using original operating class and channel (op_class %u channel %u) from intersectio… in p2p_reselect_channel()
535 p2p->op_reg_class, p2p->op_channel); in p2p_reselect_channel()
544 p2p_dbg(p2p, "Pick another channel (reg_class %u channel %u) from intersection", in p2p_reselect_channel()
546 p2p->op_reg_class = cl->reg_class; in p2p_reselect_channel()
547 p2p->op_channel = cl->channel[0]; in p2p_reselect_channel()
551 int p2p_go_select_channel(struct p2p_data *p2p, struct p2p_device *dev, in p2p_go_select_channel() argument
556 p2p_channels_dump(p2p, "own channels", &p2p->channels); in p2p_go_select_channel()
557 p2p_channels_dump(p2p, "peer channels", &dev->channels); in p2p_go_select_channel()
558 p2p_channels_intersect(&p2p->channels, &dev->channels, &tmp); in p2p_go_select_channel()
559 p2p_channels_dump(p2p, "intersection", &tmp); in p2p_go_select_channel()
560 p2p_channels_remove_freqs(&tmp, &p2p->no_go_freq); in p2p_go_select_channel()
561 p2p_channels_dump(p2p, "intersection after no-GO removal", &tmp); in p2p_go_select_channel()
562 p2p_channels_intersect(&tmp, &p2p->cfg->channels, &intersection); in p2p_go_select_channel()
563 p2p_channels_dump(p2p, "intersection with local channel list", in p2p_go_select_channel()
568 p2p_dbg(p2p, "No common channels found"); in p2p_go_select_channel()
572 if (!p2p_channels_includes(&intersection, p2p->op_reg_class, in p2p_go_select_channel()
573 p2p->op_channel)) { in p2p_go_select_channel()
576 p2p_dbg(p2p, "Peer does not support the forced channel"); in p2p_go_select_channel()
580 p2p_dbg(p2p, "Selected operating channel (op_class %u channel %u) not acceptable to the peer", in p2p_go_select_channel()
581 p2p->op_reg_class, p2p->op_channel); in p2p_go_select_channel()
582 p2p_reselect_channel(p2p, &intersection); in p2p_go_select_channel()
584 !p2p->cfg->cfg_op_channel) { in p2p_go_select_channel()
585 …p2p_dbg(p2p, "Try to optimize channel selection with peer information received; previously selecte… in p2p_go_select_channel()
586 p2p->op_reg_class, p2p->op_channel); in p2p_go_select_channel()
587 p2p_reselect_channel(p2p, &intersection); in p2p_go_select_channel()
590 if (!p2p->ssid_set) { in p2p_go_select_channel()
591 p2p_build_ssid(p2p, p2p->ssid, &p2p->ssid_len); in p2p_go_select_channel()
592 p2p->ssid_set = 1; in p2p_go_select_channel()
599 static void p2p_check_pref_chan_no_recv(struct p2p_data *p2p, int go, in p2p_check_pref_chan_no_recv() argument
609 p2p_dbg(p2p, in p2p_check_pref_chan_no_recv()
628 p2p->op_reg_class = op_class; in p2p_check_pref_chan_no_recv()
629 p2p->op_channel = op_channel; in p2p_check_pref_chan_no_recv()
630 os_memcpy(&p2p->channels, &p2p->cfg->channels, in p2p_check_pref_chan_no_recv()
638 p2p_dbg(p2p, in p2p_check_pref_chan_no_recv()
642 p2p_dbg(p2p, in p2p_check_pref_chan_no_recv()
648 static void p2p_check_pref_chan_recv(struct p2p_data *p2p, int go, in p2p_check_pref_chan_recv() argument
675 p2p->op_reg_class = op_class; in p2p_check_pref_chan_recv()
676 p2p->op_channel = op_channel; in p2p_check_pref_chan_recv()
677 os_memcpy(&p2p->channels, &p2p->cfg->channels, in p2p_check_pref_chan_recv()
685 p2p_dbg(p2p, in p2p_check_pref_chan_recv()
689 p2p_dbg(p2p, "No common preferred channels found!"); in p2p_check_pref_chan_recv()
694 void p2p_check_pref_chan(struct p2p_data *p2p, int go, in p2p_check_pref_chan() argument
709 if (!p2p->cfg->get_pref_freq_list || p2p->cfg->num_pref_chan || in p2p_check_pref_chan()
710 (dev->flags & P2P_DEV_FORCE_FREQ) || p2p->cfg->cfg_op_channel) in p2p_check_pref_chan()
715 if (p2p->cfg->get_pref_freq_list(p2p->cfg->cb_ctx, go, in p2p_check_pref_chan()
716 &p2p->num_pref_freq, in p2p_check_pref_chan()
717 p2p->pref_freq_list)) in p2p_check_pref_chan()
719 size = p2p->num_pref_freq; in p2p_check_pref_chan()
723 is_6ghz_capab = is_p2p_6ghz_capable(p2p) && in p2p_check_pref_chan()
724 p2p_is_peer_6ghz_capab(p2p, dev->info.p2p_device_addr); in p2p_check_pref_chan()
727 if (p2p_freq_to_channel(p2p->pref_freq_list[i].freq, in p2p_check_pref_chan()
729 (!p2p_channels_includes(&p2p->cfg->channels, in p2p_check_pref_chan()
731 (go || !p2p_channels_includes(&p2p->cfg->cli_channels, in p2p_check_pref_chan()
733 (is_6ghz_freq(p2p->pref_freq_list[i].freq) && in p2p_check_pref_chan()
735 p2p_dbg(p2p, in p2p_check_pref_chan()
737 p2p->pref_freq_list[i].freq, go); in p2p_check_pref_chan()
739 os_memmove(&p2p->pref_freq_list[i], in p2p_check_pref_chan()
740 &p2p->pref_freq_list[i + 1], in p2p_check_pref_chan()
755 p2p->pref_freq_list[i].freq); in p2p_check_pref_chan()
761 p2p_dbg(p2p, "Local driver frequency preference (size=%u):%s", in p2p_check_pref_chan()
769 if (p2p->pref_freq_list[i].freq == in p2p_check_pref_chan()
771 p2p_pref_freq_allowed(&p2p->pref_freq_list[i], go)) in p2p_check_pref_chan()
775 p2p_freq_to_channel(p2p->pref_freq_list[i].freq, &op_class, in p2p_check_pref_chan()
778 p2p->op_reg_class = op_class; in p2p_check_pref_chan()
779 p2p->op_channel = op_channel; in p2p_check_pref_chan()
780 os_memcpy(&p2p->channels, &p2p->cfg->channels, in p2p_check_pref_chan()
785 p2p_dbg(p2p, in p2p_check_pref_chan()
794 p2p_check_pref_chan_no_recv(p2p, go, dev, msg, in p2p_check_pref_chan()
795 p2p->pref_freq_list, size); in p2p_check_pref_chan()
797 p2p_check_pref_chan_recv(p2p, go, dev, msg, in p2p_check_pref_chan()
798 p2p->pref_freq_list, size); in p2p_check_pref_chan()
802 void p2p_process_go_neg_req(struct p2p_data *p2p, const u8 *sa, in p2p_process_go_neg_req() argument
812 p2p_dbg(p2p, "Received GO Negotiation Request from " MACSTR "(freq=%d)", in p2p_process_go_neg_req()
819 p2p_dbg(p2p, "Mandatory Capability attribute missing from GO Negotiation Request"); in p2p_process_go_neg_req()
828 p2p_dbg(p2p, "Mandatory GO Intent attribute missing from GO Negotiation Request"); in p2p_process_go_neg_req()
835 p2p_dbg(p2p, "Mandatory Configuration Timeout attribute missing from GO Negotiation Request"); in p2p_process_go_neg_req()
842 p2p_dbg(p2p, "No Listen Channel attribute received"); in p2p_process_go_neg_req()
846 p2p_dbg(p2p, "No Operating Channel attribute received"); in p2p_process_go_neg_req()
850 p2p_dbg(p2p, "No Channel List attribute received"); in p2p_process_go_neg_req()
854 p2p_dbg(p2p, "No Intended P2P Interface Address attribute received"); in p2p_process_go_neg_req()
858 p2p_dbg(p2p, "No P2P Device Info attribute received"); in p2p_process_go_neg_req()
863 p2p_dbg(p2p, "Unexpected GO Negotiation Request SA=" MACSTR in p2p_process_go_neg_req()
869 dev = p2p_get_device(p2p, sa); in p2p_process_go_neg_req()
872 p2p_dbg(p2p, "Unexpected Status attribute (%d) in GO Negotiation Request", in p2p_process_go_neg_req()
874 if (dev && p2p->go_neg_peer == dev && in p2p_process_go_neg_req()
888 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_process_go_neg_req()
889 p2p_go_neg_failed(p2p, *msg.status); in p2p_process_go_neg_req()
897 dev = p2p_add_dev_from_go_neg_req(p2p, sa, &msg); in p2p_process_go_neg_req()
900 p2p_add_dev_info(p2p, sa, dev, &msg); in p2p_process_go_neg_req()
907 p2p_dbg(p2p, "Update peer " MACSTR in p2p_process_go_neg_req()
910 p2p_add_dev_info(p2p, sa, dev, &msg); in p2p_process_go_neg_req()
916 if (p2p->go_neg_peer && p2p->go_neg_peer == dev) in p2p_process_go_neg_req()
917 eloop_cancel_timeout(p2p_go_neg_wait_timeout, p2p, NULL); in p2p_process_go_neg_req()
920 p2p_dbg(p2p, "User has rejected this peer"); in p2p_process_go_neg_req()
924 (p2p->authorized_oob_dev_pw_id == 0 || in p2p_process_go_neg_req()
925 p2p->authorized_oob_dev_pw_id != in p2p_process_go_neg_req()
927 p2p_dbg(p2p, "Not ready for GO negotiation with " MACSTR, in p2p_process_go_neg_req()
930 p2p->cfg->go_neg_req_rx(p2p->cfg->cb_ctx, sa, in p2p_process_go_neg_req()
934 } else if (p2p->go_neg_peer && p2p->go_neg_peer != dev) { in p2p_process_go_neg_req()
935 p2p_dbg(p2p, "Already in Group Formation with another peer"); in p2p_process_go_neg_req()
940 if (!p2p->go_neg_peer) { in p2p_process_go_neg_req()
941 p2p_dbg(p2p, "Starting GO Negotiation with previously authorized peer"); in p2p_process_go_neg_req()
943 p2p_dbg(p2p, "Use default channel settings"); in p2p_process_go_neg_req()
944 p2p->op_reg_class = p2p->cfg->op_reg_class; in p2p_process_go_neg_req()
945 p2p->op_channel = p2p->cfg->op_channel; in p2p_process_go_neg_req()
946 os_memcpy(&p2p->channels, &p2p->cfg->channels, in p2p_process_go_neg_req()
949 p2p_dbg(p2p, "Use previously configured forced channel settings"); in p2p_process_go_neg_req()
956 p2p_dbg(p2p, "No GO Intent attribute received"); in p2p_process_go_neg_req()
960 p2p_dbg(p2p, "Invalid GO Intent value (%u) received", in p2p_process_go_neg_req()
966 os_memcmp(sa, p2p->cfg->dev_addr, ETH_ALEN) > 0) { in p2p_process_go_neg_req()
967 p2p_dbg(p2p, "Do not reply since peer has higher address and GO Neg Request already sent"); in p2p_process_go_neg_req()
974 p2p_dbg(p2p, in p2p_process_go_neg_req()
980 go = p2p_go_det(p2p->go_intent, *msg.go_intent); in p2p_process_go_neg_req()
982 p2p_dbg(p2p, "Incompatible GO Intent"); in p2p_process_go_neg_req()
987 if (p2p_peer_channels(p2p, dev, msg.channel_list, in p2p_process_go_neg_req()
989 p2p_dbg(p2p, "No common channels found"); in p2p_process_go_neg_req()
996 p2p_dbg(p2p, "PIN from peer Display"); in p2p_process_go_neg_req()
998 p2p_dbg(p2p, "We have wps_method=%s -> incompatible", in p2p_process_go_neg_req()
1005 p2p_dbg(p2p, "Peer entered PIN on Keypad"); in p2p_process_go_neg_req()
1007 p2p_dbg(p2p, "We have wps_method=%s -> incompatible", in p2p_process_go_neg_req()
1014 p2p_dbg(p2p, "Peer using pushbutton"); in p2p_process_go_neg_req()
1016 p2p_dbg(p2p, "We have wps_method=%s -> incompatible", in p2p_process_go_neg_req()
1023 p2p_dbg(p2p, "Peer using P2PS pin"); in p2p_process_go_neg_req()
1025 p2p_dbg(p2p, in p2p_process_go_neg_req()
1035 p2p_dbg(p2p, "Peer using NFC"); in p2p_process_go_neg_req()
1037 p2p_dbg(p2p, "We have wps_method=%s -> incompatible", in p2p_process_go_neg_req()
1046 if (p2p->authorized_oob_dev_pw_id && in p2p_process_go_neg_req()
1048 p2p->authorized_oob_dev_pw_id) { in p2p_process_go_neg_req()
1049 p2p_dbg(p2p, "Using static handover with our device password from NFC Tag"); in p2p_process_go_neg_req()
1051 dev->oob_pw_id = p2p->authorized_oob_dev_pw_id; in p2p_process_go_neg_req()
1055 p2p_dbg(p2p, "Unsupported Device Password ID %d", in p2p_process_go_neg_req()
1061 if (go && p2p_go_select_channel(p2p, dev, &status) < 0) in p2p_process_go_neg_req()
1067 p2p_dbg(p2p, "Peer operating channel preference: %d MHz", in p2p_process_go_neg_req()
1074 p2p_check_pref_chan(p2p, go, dev, &msg); in p2p_process_go_neg_req()
1081 p2p_dbg(p2p, "GO Negotiation with " MACSTR, MAC2STR(sa)); in p2p_process_go_neg_req()
1082 if (p2p->state != P2P_IDLE) in p2p_process_go_neg_req()
1083 p2p_stop_find_for_freq(p2p, rx_freq); in p2p_process_go_neg_req()
1084 p2p_set_state(p2p, P2P_GO_NEG); in p2p_process_go_neg_req()
1085 p2p_clear_timeout(p2p); in p2p_process_go_neg_req()
1088 p2p->go_neg_peer = dev; in p2p_process_go_neg_req()
1089 eloop_cancel_timeout(p2p_go_neg_wait_timeout, p2p, NULL); in p2p_process_go_neg_req()
1096 resp = p2p_build_go_neg_resp(p2p, dev, msg.dialog_token, status, in p2p_process_go_neg_req()
1101 p2p_dbg(p2p, "Sending GO Negotiation Response"); in p2p_process_go_neg_req()
1105 freq = p2p_channel_to_freq(p2p->cfg->reg_class, in p2p_process_go_neg_req()
1106 p2p->cfg->channel); in p2p_process_go_neg_req()
1108 p2p_dbg(p2p, "Unknown regulatory class/channel"); in p2p_process_go_neg_req()
1113 p2p->pending_action_state = P2P_PENDING_GO_NEG_RESPONSE; in p2p_process_go_neg_req()
1115 if (os_memcmp(sa, p2p->cfg->dev_addr, ETH_ALEN) < 0) { in p2p_process_go_neg_req()
1127 p2p->pending_action_state = in p2p_process_go_neg_req()
1129 if (p2p_send_action(p2p, freq, sa, p2p->cfg->dev_addr, in p2p_process_go_neg_req()
1130 p2p->cfg->dev_addr, in p2p_process_go_neg_req()
1132 p2p_dbg(p2p, "Failed to send Action frame"); in p2p_process_go_neg_req()
1139 static struct wpabuf * p2p_build_go_neg_conf(struct p2p_data *p2p, in p2p_build_go_neg_conf() argument
1151 p2p_dbg(p2p, "Building GO Negotiation Confirm"); in p2p_build_go_neg_conf()
1154 if (p2p->wfd_ie_go_neg) in p2p_build_go_neg_conf()
1155 extra = wpabuf_len(p2p->wfd_ie_go_neg); in p2p_build_go_neg_conf()
1158 if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_CONF]) in p2p_build_go_neg_conf()
1159 extra += wpabuf_len(p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_CONF]); in p2p_build_go_neg_conf()
1177 if (p2p->cross_connect) in p2p_build_go_neg_conf()
1179 if (p2p->cfg->p2p_intra_bss) in p2p_build_go_neg_conf()
1182 p2p_buf_add_capability(buf, p2p->dev_capab & in p2p_build_go_neg_conf()
1186 p2p_buf_add_operating_channel(buf, p2p->cfg->country, in p2p_build_go_neg_conf()
1187 p2p->op_reg_class, in p2p_build_go_neg_conf()
1188 p2p->op_channel); in p2p_build_go_neg_conf()
1192 p2p_channels_intersect(&p2p->channels, &peer->channels, &res); in p2p_build_go_neg_conf()
1193 is_6ghz_capab = is_p2p_6ghz_capable(p2p) && in p2p_build_go_neg_conf()
1194 p2p_is_peer_6ghz_capab(p2p, peer->info.p2p_device_addr); in p2p_build_go_neg_conf()
1195 p2p_buf_add_channel_list(buf, p2p->cfg->country, &res, is_6ghz_capab); in p2p_build_go_neg_conf()
1197 p2p_buf_add_group_id(buf, p2p->cfg->dev_addr, p2p->ssid, in p2p_build_go_neg_conf()
1198 p2p->ssid_len); in p2p_build_go_neg_conf()
1203 if (p2p->wfd_ie_go_neg) in p2p_build_go_neg_conf()
1204 wpabuf_put_buf(buf, p2p->wfd_ie_go_neg); in p2p_build_go_neg_conf()
1207 if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_CONF]) in p2p_build_go_neg_conf()
1208 wpabuf_put_buf(buf, p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_CONF]); in p2p_build_go_neg_conf()
1214 void p2p_process_go_neg_resp(struct p2p_data *p2p, const u8 *sa, in p2p_process_go_neg_resp() argument
1223 p2p_dbg(p2p, "Received GO Negotiation Response from " MACSTR in p2p_process_go_neg_resp()
1225 dev = p2p_get_device(p2p, sa); in p2p_process_go_neg_resp()
1227 dev != p2p->go_neg_peer) { in p2p_process_go_neg_resp()
1228 p2p_dbg(p2p, "Not ready for GO negotiation with " MACSTR, in p2p_process_go_neg_resp()
1237 p2p_dbg(p2p, "Was not expecting GO Negotiation Response - ignore"); in p2p_process_go_neg_resp()
1245 p2p_dbg(p2p, "Unexpected Dialog Token %u (expected %u)", in p2p_process_go_neg_resp()
1252 p2p_dbg(p2p, "No Status attribute received"); in p2p_process_go_neg_resp()
1257 p2p_dbg(p2p, "GO Negotiation rejected: status %d", *msg.status); in p2p_process_go_neg_resp()
1260 p2p_dbg(p2p, "Wait for the peer to become ready for GO Negotiation"); in p2p_process_go_neg_resp()
1262 eloop_cancel_timeout(p2p_go_neg_wait_timeout, p2p, in p2p_process_go_neg_resp()
1265 p2p, NULL); in p2p_process_go_neg_resp()
1266 if (p2p->state == P2P_CONNECT_LISTEN) in p2p_process_go_neg_resp()
1267 p2p_set_state(p2p, P2P_WAIT_PEER_CONNECT); in p2p_process_go_neg_resp()
1269 p2p_set_state(p2p, P2P_WAIT_PEER_IDLE); in p2p_process_go_neg_resp()
1270 p2p_set_timeout(p2p, 0, 0); in p2p_process_go_neg_resp()
1272 p2p_dbg(p2p, "Stop GO Negotiation attempt"); in p2p_process_go_neg_resp()
1273 p2p_go_neg_failed(p2p, *msg.status); in p2p_process_go_neg_resp()
1275 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_process_go_neg_resp()
1281 p2p_dbg(p2p, "Mandatory Capability attribute missing from GO Negotiation Response"); in p2p_process_go_neg_resp()
1289 p2p_dbg(p2p, "Mandatory P2P Device Info attribute missing from GO Negotiation Response"); in p2p_process_go_neg_resp()
1297 p2p_dbg(p2p, "No Intended P2P Interface Address attribute received"); in p2p_process_go_neg_resp()
1303 p2p_dbg(p2p, "No GO Intent attribute received"); in p2p_process_go_neg_resp()
1308 p2p_dbg(p2p, "Invalid GO Intent value (%u) received", in p2p_process_go_neg_resp()
1314 go = p2p_go_det(p2p->go_intent, *msg.go_intent); in p2p_process_go_neg_resp()
1316 p2p_dbg(p2p, "Incompatible GO Intent"); in p2p_process_go_neg_resp()
1323 p2p->ssid_len = msg.group_id_len - ETH_ALEN; in p2p_process_go_neg_resp()
1324 os_memcpy(p2p->ssid, msg.group_id + ETH_ALEN, p2p->ssid_len); in p2p_process_go_neg_resp()
1326 p2p_dbg(p2p, "Mandatory P2P Group ID attribute missing from GO Negotiation Response"); in p2p_process_go_neg_resp()
1327 p2p->ssid_len = 0; in p2p_process_go_neg_resp()
1333 p2p_dbg(p2p, "Mandatory Configuration Timeout attribute missing from GO Negotiation Response"); in p2p_process_go_neg_resp()
1353 p2p_dbg(p2p, "No Operating Channel attribute received"); in p2p_process_go_neg_resp()
1358 p2p_dbg(p2p, "No Channel List attribute received"); in p2p_process_go_neg_resp()
1363 if (p2p_peer_channels(p2p, dev, msg.channel_list, in p2p_process_go_neg_resp()
1365 p2p_dbg(p2p, "No common channels found"); in p2p_process_go_neg_resp()
1373 p2p_dbg(p2p, "Peer operating channel preference: %d MHz", in p2p_process_go_neg_resp()
1380 p2p_dbg(p2p, "PIN from peer Display"); in p2p_process_go_neg_resp()
1382 p2p_dbg(p2p, "We have wps_method=%s -> incompatible", in p2p_process_go_neg_resp()
1389 p2p_dbg(p2p, "Peer entered PIN on Keypad"); in p2p_process_go_neg_resp()
1391 p2p_dbg(p2p, "We have wps_method=%s -> incompatible", in p2p_process_go_neg_resp()
1398 p2p_dbg(p2p, "Peer using pushbutton"); in p2p_process_go_neg_resp()
1400 p2p_dbg(p2p, "We have wps_method=%s -> incompatible", in p2p_process_go_neg_resp()
1407 p2p_dbg(p2p, "P2P: Peer using P2PS default pin"); in p2p_process_go_neg_resp()
1409 p2p_dbg(p2p, "We have wps_method=%s -> incompatible", in p2p_process_go_neg_resp()
1418 p2p_dbg(p2p, "Peer using NFC"); in p2p_process_go_neg_resp()
1420 p2p_dbg(p2p, "We have wps_method=%s -> incompatible", in p2p_process_go_neg_resp()
1427 p2p_dbg(p2p, "Unsupported Device Password ID %d", in p2p_process_go_neg_resp()
1433 if (go && p2p_go_select_channel(p2p, dev, &status) < 0) in p2p_process_go_neg_resp()
1441 p2p_check_pref_chan(p2p, go, dev, &msg); in p2p_process_go_neg_resp()
1443 p2p_set_state(p2p, P2P_GO_NEG); in p2p_process_go_neg_resp()
1444 p2p_clear_timeout(p2p); in p2p_process_go_neg_resp()
1446 p2p_dbg(p2p, "GO Negotiation with " MACSTR, MAC2STR(sa)); in p2p_process_go_neg_resp()
1452 dev->go_neg_conf = p2p_build_go_neg_conf(p2p, dev, msg.dialog_token, in p2p_process_go_neg_resp()
1458 p2p_dbg(p2p, "Sending GO Negotiation Confirm"); in p2p_process_go_neg_resp()
1460 p2p->pending_action_state = P2P_PENDING_GO_NEG_CONFIRM; in p2p_process_go_neg_resp()
1463 p2p->pending_action_state = P2P_NO_PENDING_ACTION; in p2p_process_go_neg_resp()
1472 if (p2p_send_action(p2p, freq, sa, p2p->cfg->dev_addr, sa, in p2p_process_go_neg_resp()
1475 p2p_dbg(p2p, "Failed to send Action frame"); in p2p_process_go_neg_resp()
1476 p2p_go_neg_failed(p2p, -1); in p2p_process_go_neg_resp()
1477 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_process_go_neg_resp()
1481 p2p_dbg(p2p, "GO Negotiation failed"); in p2p_process_go_neg_resp()
1482 p2p_go_neg_failed(p2p, status); in p2p_process_go_neg_resp()
1487 void p2p_process_go_neg_conf(struct p2p_data *p2p, const u8 *sa, in p2p_process_go_neg_conf() argument
1493 p2p_dbg(p2p, "Received GO Negotiation Confirm from " MACSTR, in p2p_process_go_neg_conf()
1495 dev = p2p_get_device(p2p, sa); in p2p_process_go_neg_conf()
1497 dev != p2p->go_neg_peer) { in p2p_process_go_neg_conf()
1498 p2p_dbg(p2p, "Not ready for GO negotiation with " MACSTR, in p2p_process_go_neg_conf()
1503 if (p2p->pending_action_state == P2P_PENDING_GO_NEG_RESPONSE) { in p2p_process_go_neg_conf()
1504 …p2p_dbg(p2p, "Stopped waiting for TX status on GO Negotiation Response since we already received C… in p2p_process_go_neg_conf()
1505 p2p->pending_action_state = P2P_NO_PENDING_ACTION; in p2p_process_go_neg_conf()
1512 p2p_dbg(p2p, "Was not expecting GO Negotiation Confirm - ignore"); in p2p_process_go_neg_conf()
1517 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_process_go_neg_conf()
1520 p2p_dbg(p2p, "Unexpected Dialog Token %u (expected %u)", in p2p_process_go_neg_conf()
1527 p2p_dbg(p2p, "No Status attribute received"); in p2p_process_go_neg_conf()
1532 p2p_dbg(p2p, "GO Negotiation rejected: status %d", *msg.status); in p2p_process_go_neg_conf()
1533 p2p_go_neg_failed(p2p, *msg.status); in p2p_process_go_neg_conf()
1542 p2p->ssid_len = msg.group_id_len - ETH_ALEN; in p2p_process_go_neg_conf()
1543 os_memcpy(p2p->ssid, msg.group_id + ETH_ALEN, p2p->ssid_len); in p2p_process_go_neg_conf()
1545 p2p_dbg(p2p, "Mandatory P2P Group ID attribute missing from GO Negotiation Confirmation"); in p2p_process_go_neg_conf()
1546 p2p->ssid_len = 0; in p2p_process_go_neg_conf()
1547 p2p_go_neg_failed(p2p, P2P_SC_FAIL_INVALID_PARAMS); in p2p_process_go_neg_conf()
1553 p2p_dbg(p2p, "Mandatory Operating Channel attribute missing from GO Negotiation Confirmation"); in p2p_process_go_neg_conf()
1562 p2p_dbg(p2p, "Updated peer (GO) operating channel preference from %d MHz to %d MHz", in p2p_process_go_neg_conf()
1569 p2p_dbg(p2p, "Mandatory Operating Channel attribute missing from GO Negotiation Confirmation"); in p2p_process_go_neg_conf()
1583 p2p_dbg(p2p, "Unexpected GO Neg state - do not know which end becomes GO"); in p2p_process_go_neg_conf()
1595 p2p_dbg(p2p, "20 ms wait on current channel before starting group"); in p2p_process_go_neg_conf()
1598 p2p_go_complete(p2p, dev); in p2p_process_go_neg_conf()