Lines Matching refs:p2p

18 static struct wpabuf * p2p_build_invitation_req(struct p2p_data *p2p,  in p2p_build_invitation_req()  argument
29 struct wpabuf *wfd_ie = p2p->wfd_ie_invitation; in p2p_build_invitation_req()
30 if (wfd_ie && p2p->inv_role == P2P_INVITE_ROLE_ACTIVE_GO) { in p2p_build_invitation_req()
32 for (i = 0; i < p2p->num_groups; i++) { in p2p_build_invitation_req()
33 struct p2p_group *g = p2p->groups[i]; in p2p_build_invitation_req()
36 p2p->inv_bssid, ETH_ALEN) != 0) in p2p_build_invitation_req()
49 if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_INV_REQ]) in p2p_build_invitation_req()
50 extra += wpabuf_len(p2p->vendor_elem[VENDOR_ELEM_P2P_INV_REQ]); in p2p_build_invitation_req()
63 if (p2p->inv_role == P2P_INVITE_ROLE_ACTIVE_GO || !p2p->inv_persistent) in p2p_build_invitation_req()
66 p2p_buf_add_config_timeout(buf, p2p->go_timeout, in p2p_build_invitation_req()
67 p2p->client_timeout); in p2p_build_invitation_req()
68 p2p_buf_add_invitation_flags(buf, p2p->inv_persistent ? in p2p_build_invitation_req()
70 if (p2p->inv_role != P2P_INVITE_ROLE_CLIENT || in p2p_build_invitation_req()
72 p2p_buf_add_operating_channel(buf, p2p->cfg->country, in p2p_build_invitation_req()
73 p2p->op_reg_class, in p2p_build_invitation_req()
74 p2p->op_channel); in p2p_build_invitation_req()
75 if (p2p->inv_bssid_set) in p2p_build_invitation_req()
76 p2p_buf_add_group_bssid(buf, p2p->inv_bssid); in p2p_build_invitation_req()
77 p2p_buf_add_channel_list(buf, p2p->cfg->country, &p2p->channels); in p2p_build_invitation_req()
80 else if (p2p->inv_role == P2P_INVITE_ROLE_CLIENT) in p2p_build_invitation_req()
83 dev_addr = p2p->cfg->dev_addr; in p2p_build_invitation_req()
84 p2p_buf_add_group_id(buf, dev_addr, p2p->inv_ssid, p2p->inv_ssid_len); in p2p_build_invitation_req()
85 p2p_buf_add_device_info(buf, p2p, peer); in p2p_build_invitation_req()
88 p2p_buf_add_pref_channel_list(buf, p2p->pref_freq_list, in p2p_build_invitation_req()
89 p2p->num_pref_freq); in p2p_build_invitation_req()
96 if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_INV_REQ]) in p2p_build_invitation_req()
97 wpabuf_put_buf(buf, p2p->vendor_elem[VENDOR_ELEM_P2P_INV_REQ]); in p2p_build_invitation_req()
101 p2p_build_wps_ie(p2p, buf, dev_pw_id, 0); in p2p_build_invitation_req()
108 static struct wpabuf * p2p_build_invitation_resp(struct p2p_data *p2p, in p2p_build_invitation_resp() argument
120 struct wpabuf *wfd_ie = p2p->wfd_ie_invitation; in p2p_build_invitation_resp()
123 for (i = 0; i < p2p->num_groups; i++) { in p2p_build_invitation_resp()
124 struct p2p_group *g = p2p->groups[i]; in p2p_build_invitation_resp()
140 if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_INV_RESP]) in p2p_build_invitation_resp()
141 extra += wpabuf_len(p2p->vendor_elem[VENDOR_ELEM_P2P_INV_RESP]); in p2p_build_invitation_resp()
154 p2p_buf_add_operating_channel(buf, p2p->cfg->country, in p2p_build_invitation_resp()
159 p2p_buf_add_channel_list(buf, p2p->cfg->country, channels); in p2p_build_invitation_resp()
167 if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_INV_RESP]) in p2p_build_invitation_resp()
168 wpabuf_put_buf(buf, p2p->vendor_elem[VENDOR_ELEM_P2P_INV_RESP]); in p2p_build_invitation_resp()
174 void p2p_process_invitation_req(struct p2p_data *p2p, const u8 *sa, in p2p_process_invitation_req() argument
191 p2p_dbg(p2p, "Received Invitation Request from " MACSTR " (freq=%d)", in p2p_process_invitation_req()
197 dev = p2p_get_device(p2p, sa); in p2p_process_invitation_req()
199 p2p_dbg(p2p, "Invitation Request from unknown peer " MACSTR, in p2p_process_invitation_req()
202 if (p2p_add_device(p2p, sa, rx_freq, NULL, 0, data + 1, len - 1, in p2p_process_invitation_req()
204 p2p_dbg(p2p, "Invitation Request add device failed " in p2p_process_invitation_req()
210 dev = p2p_get_device(p2p, sa); in p2p_process_invitation_req()
212 p2p_dbg(p2p, "Reject Invitation Request from unknown peer " in p2p_process_invitation_req()
220 p2p_dbg(p2p, "Mandatory attribute missing in Invitation Request from " in p2p_process_invitation_req()
234 p2p_dbg(p2p, "Mandatory Invitation Flags attribute missing from Invitation Request"); in p2p_process_invitation_req()
238 p2p_channels_union(&p2p->cfg->channels, &p2p->cfg->cli_channels, in p2p_process_invitation_req()
241 if (p2p_peer_channels_check(p2p, &all_channels, dev, in p2p_process_invitation_req()
244 p2p_dbg(p2p, "No common channels found"); in p2p_process_invitation_req()
249 p2p_channels_dump(p2p, "own channels", &p2p->cfg->channels); in p2p_process_invitation_req()
250 p2p_channels_dump(p2p, "own client channels", &all_channels); in p2p_process_invitation_req()
251 p2p_channels_dump(p2p, "peer channels", &dev->channels); in p2p_process_invitation_req()
254 p2p_channels_dump(p2p, "intersection", &intersection); in p2p_process_invitation_req()
256 if (p2p->cfg->invitation_process) { in p2p_process_invitation_req()
257 status = p2p->cfg->invitation_process( in p2p_process_invitation_req()
258 p2p->cfg->cb_ctx, sa, msg.group_bssid, msg.group_id, in p2p_process_invitation_req()
265 p2p_channels_intersect(&p2p->cfg->channels, &dev->channels, in p2p_process_invitation_req()
267 p2p_channels_dump(p2p, "intersection(GO)", &intersection); in p2p_process_invitation_req()
269 p2p_dbg(p2p, "No common channels found (GO)"); in p2p_process_invitation_req()
276 p2p_dbg(p2p, "Invitation processing forced frequency %d MHz", in p2p_process_invitation_req()
279 p2p_dbg(p2p, "Unknown forced freq %d MHz from invitation_process()", in p2p_process_invitation_req()
287 p2p_dbg(p2p, "forced freq %d MHz not in the supported channels intersection", in p2p_process_invitation_req()
296 p2p_dbg(p2p, "No forced channel from invitation processing - figure out best one to use"); in p2p_process_invitation_req()
299 p2p->op_reg_class = p2p->cfg->op_reg_class; in p2p_process_invitation_req()
300 p2p->op_channel = p2p->cfg->op_channel; in p2p_process_invitation_req()
301 p2p_dbg(p2p, "Own default op_class %d channel %d", in p2p_process_invitation_req()
302 p2p->op_reg_class, p2p->op_channel); in p2p_process_invitation_req()
310 p2p_dbg(p2p, "Peer operating channel preference: %d MHz", in p2p_process_invitation_req()
316 p2p->op_reg_class = msg.operating_channel[3]; in p2p_process_invitation_req()
317 p2p->op_channel = msg.operating_channel[4]; in p2p_process_invitation_req()
318 p2p_dbg(p2p, "Use peer preference op_class %d channel %d", in p2p_process_invitation_req()
319 p2p->op_reg_class, p2p->op_channel); in p2p_process_invitation_req()
321 p2p_dbg(p2p, "Cannot use peer channel preference"); in p2p_process_invitation_req()
327 !p2p_channels_includes(&intersection, p2p->op_reg_class, in p2p_process_invitation_req()
328 p2p->op_channel)) { in p2p_process_invitation_req()
329 …p2p_dbg(p2p, "Initially selected channel (op_class %d channel %d) not in channel intersection - tr… in p2p_process_invitation_req()
330 p2p->op_reg_class, p2p->op_channel); in p2p_process_invitation_req()
331 p2p_reselect_channel(p2p, &intersection); in p2p_process_invitation_req()
332 p2p_dbg(p2p, "Re-selection result: op_class %d channel %d", in p2p_process_invitation_req()
333 p2p->op_reg_class, p2p->op_channel); in p2p_process_invitation_req()
335 p2p->op_reg_class, in p2p_process_invitation_req()
336 p2p->op_channel)) { in p2p_process_invitation_req()
337 p2p_dbg(p2p, "Peer does not support selected operating channel (reg_class=%u channel=%u)", in p2p_process_invitation_req()
338 p2p->op_reg_class, p2p->op_channel); in p2p_process_invitation_req()
343 !p2p->cfg->cfg_op_channel) { in p2p_process_invitation_req()
344 …p2p_dbg(p2p, "Try to reselect channel selection with peer information received; previously selecte… in p2p_process_invitation_req()
345 p2p->op_reg_class, p2p->op_channel); in p2p_process_invitation_req()
346 p2p_reselect_channel(p2p, &intersection); in p2p_process_invitation_req()
353 p2p_check_pref_chan(p2p, go, dev, &msg); in p2p_process_invitation_req()
355 op_freq = p2p_channel_to_freq(p2p->op_reg_class, in p2p_process_invitation_req()
356 p2p->op_channel); in p2p_process_invitation_req()
358 p2p_dbg(p2p, "Unknown operational channel (country=%c%c reg_class=%u channel=%u)", in p2p_process_invitation_req()
359 p2p->cfg->country[0], p2p->cfg->country[1], in p2p_process_invitation_req()
360 p2p->op_reg_class, p2p->op_channel); in p2p_process_invitation_req()
364 p2p_dbg(p2p, "Selected operating channel - %d MHz", op_freq); in p2p_process_invitation_req()
367 reg_class = p2p->op_reg_class; in p2p_process_invitation_req()
368 channel = p2p->op_channel; in p2p_process_invitation_req()
378 resp = p2p_build_invitation_resp(p2p, dev, msg.dialog_token, status, in p2p_process_invitation_req()
387 freq = p2p_channel_to_freq(p2p->cfg->reg_class, in p2p_process_invitation_req()
388 p2p->cfg->channel); in p2p_process_invitation_req()
390 p2p_dbg(p2p, "Unknown regulatory class/channel"); in p2p_process_invitation_req()
398 os_memcpy(p2p->inv_sa, sa, ETH_ALEN); in p2p_process_invitation_req()
400 os_memcpy(p2p->inv_group_bssid, msg.group_bssid, ETH_ALEN); in p2p_process_invitation_req()
401 p2p->inv_group_bssid_ptr = p2p->inv_group_bssid; in p2p_process_invitation_req()
403 p2p->inv_group_bssid_ptr = NULL; in p2p_process_invitation_req()
406 os_memcpy(p2p->inv_ssid, msg.group_id + ETH_ALEN, in p2p_process_invitation_req()
408 p2p->inv_ssid_len = msg.group_id_len - ETH_ALEN; in p2p_process_invitation_req()
410 os_memcpy(p2p->inv_go_dev_addr, msg.group_id, ETH_ALEN); in p2p_process_invitation_req()
412 p2p->inv_ssid_len = 0; in p2p_process_invitation_req()
413 os_memset(p2p->inv_go_dev_addr, 0, ETH_ALEN); in p2p_process_invitation_req()
415 p2p->inv_status = status; in p2p_process_invitation_req()
416 p2p->inv_op_freq = op_freq; in p2p_process_invitation_req()
418 p2p->pending_action_state = P2P_PENDING_INVITATION_RESPONSE; in p2p_process_invitation_req()
419 if (p2p_send_action(p2p, freq, sa, p2p->cfg->dev_addr, in p2p_process_invitation_req()
420 p2p->cfg->dev_addr, in p2p_process_invitation_req()
422 p2p_dbg(p2p, "Failed to send Action frame"); in p2p_process_invitation_req()
431 void p2p_process_invitation_resp(struct p2p_data *p2p, const u8 *sa, in p2p_process_invitation_resp() argument
438 p2p_dbg(p2p, "Received Invitation Response from " MACSTR, in p2p_process_invitation_resp()
441 dev = p2p_get_device(p2p, sa); in p2p_process_invitation_resp()
443 p2p_dbg(p2p, "Ignore Invitation Response from unknown peer " in p2p_process_invitation_resp()
445 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_process_invitation_resp()
449 if (dev != p2p->invite_peer) { in p2p_process_invitation_resp()
450 p2p_dbg(p2p, "Ignore unexpected Invitation Response from peer " in p2p_process_invitation_resp()
452 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_process_invitation_resp()
457 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_process_invitation_resp()
462 p2p_dbg(p2p, "Mandatory Status attribute missing in Invitation Response from " in p2p_process_invitation_resp()
465 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_process_invitation_resp()
480 p2p->retry_invite_req_sent && in p2p_process_invitation_resp()
482 p2p_dbg(p2p, "Unexpected Dialog Token %u (expected %u)", in p2p_process_invitation_resp()
489 p2p->retry_invite_req && in p2p_process_invitation_resp()
490 p2p_channel_random_social(&p2p->cfg->channels, &p2p->op_reg_class, in p2p_process_invitation_resp()
491 &p2p->op_channel, NULL, NULL) == 0) { in p2p_process_invitation_resp()
492 p2p->retry_invite_req = 0; in p2p_process_invitation_resp()
493 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_process_invitation_resp()
494 p2p->cfg->stop_listen(p2p->cfg->cb_ctx); in p2p_process_invitation_resp()
495 p2p_set_state(p2p, P2P_INVITE); in p2p_process_invitation_resp()
496 p2p_dbg(p2p, "Resend Invitation Request setting op_class %u channel %u as operating channel", in p2p_process_invitation_resp()
497 p2p->op_reg_class, p2p->op_channel); in p2p_process_invitation_resp()
498 p2p->retry_invite_req_sent = 1; in p2p_process_invitation_resp()
499 p2p_invite_send(p2p, p2p->invite_peer, p2p->invite_go_dev_addr, in p2p_process_invitation_resp()
500 p2p->invite_dev_pw_id); in p2p_process_invitation_resp()
504 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_process_invitation_resp()
505 p2p->retry_invite_req = 0; in p2p_process_invitation_resp()
508 p2p_dbg(p2p, "Mandatory Channel List attribute missing in Invitation Response from " in p2p_process_invitation_resp()
515 channels = &p2p->channels; in p2p_process_invitation_resp()
518 channels = &p2p->channels; in p2p_process_invitation_resp()
519 } else if (p2p_peer_channels_check(p2p, &p2p->channels, dev, in p2p_process_invitation_resp()
522 p2p_dbg(p2p, "No common channels found"); in p2p_process_invitation_resp()
526 p2p_channels_intersect(&p2p->channels, &dev->channels, in p2p_process_invitation_resp()
531 if (p2p->cfg->invitation_result) { in p2p_process_invitation_resp()
533 int freq = p2p_channel_to_freq(p2p->op_reg_class, in p2p_process_invitation_resp()
534 p2p->op_channel); in p2p_process_invitation_resp()
550 p2p_check_pref_chan(p2p, 0, dev, &msg); in p2p_process_invitation_resp()
552 p2p->cfg->invitation_result(p2p->cfg->cb_ctx, *msg.status, in p2p_process_invitation_resp()
559 p2p_clear_timeout(p2p); in p2p_process_invitation_resp()
560 p2p_set_state(p2p, P2P_IDLE); in p2p_process_invitation_resp()
561 p2p->invite_peer = NULL; in p2p_process_invitation_resp()
565 int p2p_invite_send(struct p2p_data *p2p, struct p2p_device *dev, in p2p_invite_send() argument
575 p2p_dbg(p2p, "No Listen/Operating frequency known for the peer " in p2p_invite_send()
581 req = p2p_build_invitation_req(p2p, dev, go_dev_addr, dev_pw_id); in p2p_invite_send()
584 if (p2p->state != P2P_IDLE) in p2p_invite_send()
585 p2p_stop_listen_for_freq(p2p, freq); in p2p_invite_send()
586 p2p_dbg(p2p, "Sending Invitation Request"); in p2p_invite_send()
587 p2p_set_state(p2p, P2P_INVITE); in p2p_invite_send()
588 p2p->pending_action_state = P2P_PENDING_INVITATION_REQUEST; in p2p_invite_send()
589 p2p->invite_peer = dev; in p2p_invite_send()
591 if (p2p_send_action(p2p, freq, dev->info.p2p_device_addr, in p2p_invite_send()
592 p2p->cfg->dev_addr, dev->info.p2p_device_addr, in p2p_invite_send()
594 p2p_dbg(p2p, "Failed to send Action frame"); in p2p_invite_send()
596 p2p_set_timeout(p2p, 0, 0); in p2p_invite_send()
607 void p2p_invitation_req_cb(struct p2p_data *p2p, int success) in p2p_invitation_req_cb() argument
609 p2p_dbg(p2p, "Invitation Request TX callback: success=%d", success); in p2p_invitation_req_cb()
611 if (p2p->invite_peer == NULL) { in p2p_invitation_req_cb()
612 p2p_dbg(p2p, "No pending Invite"); in p2p_invitation_req_cb()
617 p2p->invite_peer->flags &= ~P2P_DEV_WAIT_INV_REQ_ACK; in p2p_invitation_req_cb()
623 p2p_set_state(p2p, P2P_INVITE); in p2p_invitation_req_cb()
624 p2p_set_timeout(p2p, 0, success ? 500000 : 100000); in p2p_invitation_req_cb()
628 void p2p_invitation_resp_cb(struct p2p_data *p2p, int success) in p2p_invitation_resp_cb() argument
630 p2p_dbg(p2p, "Invitation Response TX callback: success=%d", success); in p2p_invitation_resp_cb()
631 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_invitation_resp_cb()
634 …p2p_dbg(p2p, "Assume Invitation Response was actually received by the peer even though Ack was not… in p2p_invitation_resp_cb()
636 if (p2p->cfg->invitation_received) { in p2p_invitation_resp_cb()
637 p2p->cfg->invitation_received(p2p->cfg->cb_ctx, in p2p_invitation_resp_cb()
638 p2p->inv_sa, in p2p_invitation_resp_cb()
639 p2p->inv_group_bssid_ptr, in p2p_invitation_resp_cb()
640 p2p->inv_ssid, p2p->inv_ssid_len, in p2p_invitation_resp_cb()
641 p2p->inv_go_dev_addr, in p2p_invitation_resp_cb()
642 p2p->inv_status, in p2p_invitation_resp_cb()
643 p2p->inv_op_freq); in p2p_invitation_resp_cb()
648 int p2p_invite(struct p2p_data *p2p, const u8 *peer, enum p2p_invite_role role, in p2p_invite() argument
655 p2p_dbg(p2p, "Request to invite peer " MACSTR " role=%d persistent=%d " in p2p_invite()
659 p2p_dbg(p2p, "Invitation for BSSID " MACSTR, MAC2STR(bssid)); in p2p_invite()
661 p2p_dbg(p2p, "Invitation for GO Device Address " MACSTR, in p2p_invite()
663 os_memcpy(p2p->invite_go_dev_addr_buf, go_dev_addr, ETH_ALEN); in p2p_invite()
664 p2p->invite_go_dev_addr = p2p->invite_go_dev_addr_buf; in p2p_invite()
666 p2p->invite_go_dev_addr = NULL; in p2p_invite()
670 p2p_dbg(p2p, "Invitation to use Device Password ID %d", in p2p_invite()
673 p2p->invite_dev_pw_id = dev_pw_id; in p2p_invite()
674 p2p->retry_invite_req = role == P2P_INVITE_ROLE_GO && in p2p_invite()
676 p2p->retry_invite_req_sent = 0; in p2p_invite()
678 dev = p2p_get_device(p2p, peer); in p2p_invite()
681 p2p_dbg(p2p, "Cannot invite unknown P2P Device " MACSTR, in p2p_invite()
686 if (p2p_prepare_channel(p2p, dev, force_freq, pref_freq, in p2p_invite()
699 p2p_dbg(p2p, "Cannot invite a P2P Device " MACSTR in p2p_invite()
708 if (p2p->state != P2P_IDLE) in p2p_invite()
709 p2p_stop_find(p2p); in p2p_invite()
711 p2p->inv_role = role; in p2p_invite()
712 p2p->inv_bssid_set = bssid != NULL; in p2p_invite()
714 os_memcpy(p2p->inv_bssid, bssid, ETH_ALEN); in p2p_invite()
715 os_memcpy(p2p->inv_ssid, ssid, ssid_len); in p2p_invite()
716 p2p->inv_ssid_len = ssid_len; in p2p_invite()
717 p2p->inv_persistent = persistent_group; in p2p_invite()
718 return p2p_invite_send(p2p, dev, go_dev_addr, dev_pw_id); in p2p_invite()