Lines Matching refs:p2p
2 * Wi-Fi Direct - P2P Group Owner Negotiation
17 #include "p2p.h"
35 int p2p_peer_channels_check(struct p2p_data *p2p, struct p2p_channels *own,
52 wpa_hexdump_ascii(MSG_DEBUG, "P2P: Peer country", pos, 3);
53 if (pos[2] != 0x04 && os_memcmp(pos, p2p->cfg->country, 2) != 0) {
54 p2p_info(p2p, "Mismatching country (ours=%c%c peer's=%c%c)",
55 p2p->cfg->country[0], p2p->cfg->country[1],
66 p2p_info(p2p, "Invalid peer Channel List");
79 p2p_dbg(p2p, "Own reg_classes %d peer reg_classes %d intersection reg_classes %d",
84 p2p_info(p2p, "No common channels found");
91 static int p2p_peer_channels(struct p2p_data *p2p, struct p2p_device *dev,
94 return p2p_peer_channels_check(p2p, &p2p->channels, dev,
137 static struct wpabuf * p2p_build_go_neg_req(struct p2p_data *p2p,
147 if (p2p->wfd_ie_go_neg)
148 extra = wpabuf_len(p2p->wfd_ie_go_neg);
151 if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_REQ])
152 extra += wpabuf_len(p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_REQ]);
167 if (p2p->cross_connect)
169 if (p2p->cfg->p2p_intra_bss)
171 p2p_buf_add_capability(buf, p2p->dev_capab &
174 p2p_buf_add_go_intent(buf, (p2p->go_intent << 1) | peer->tie_breaker);
175 p2p_buf_add_config_timeout(buf, p2p->go_timeout, p2p->client_timeout);
176 p2p_buf_add_listen_channel(buf, p2p->cfg->country, p2p->cfg->reg_class,
177 p2p->cfg->channel);
178 if (p2p->ext_listen_interval)
179 p2p_buf_add_ext_listen_timing(buf, p2p->ext_listen_period,
180 p2p->ext_listen_interval);
181 p2p_buf_add_intended_addr(buf, p2p->intended_addr);
182 p2p_buf_add_channel_list(buf, p2p->cfg->country, &p2p->channels);
183 p2p_buf_add_device_info(buf, p2p, peer);
184 p2p_buf_add_operating_channel(buf, p2p->cfg->country,
185 p2p->op_reg_class, p2p->op_channel);
188 p2p_buf_add_pref_channel_list(buf, p2p->pref_freq_list,
189 p2p->num_pref_freq);
195 if (p2p_build_wps_ie(p2p, buf, pw_id, 0) < 0) {
196 p2p_dbg(p2p, "Failed to build WPS IE for GO Negotiation Request");
202 if (p2p->wfd_ie_go_neg)
203 wpabuf_put_buf(buf, p2p->wfd_ie_go_neg);
206 if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_REQ])
207 wpabuf_put_buf(buf, p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_REQ]);
213 int p2p_connect_send(struct p2p_data *p2p, struct p2p_device *dev)
220 p2p_dbg(p2p, "Use PD-before-GO-Neg workaround for " MACSTR,
232 return p2p_prov_disc_req(p2p, dev->info.p2p_device_addr,
240 p2p_dbg(p2p, "No Listen/Operating frequency known for the peer "
246 req = p2p_build_go_neg_req(p2p, dev);
249 p2p_dbg(p2p, "Sending GO Negotiation Request");
250 p2p_set_state(p2p, P2P_CONNECT);
251 p2p->pending_action_state = P2P_PENDING_GO_NEG_REQUEST;
252 p2p->go_neg_peer = dev;
253 eloop_cancel_timeout(p2p_go_neg_wait_timeout, p2p, NULL);
256 if (p2p_send_action(p2p, freq, dev->info.p2p_device_addr,
257 p2p->cfg->dev_addr, dev->info.p2p_device_addr,
259 p2p_dbg(p2p, "Failed to send Action frame");
260 /* Use P2P find to recover and retry */
261 p2p_set_timeout(p2p, 0, 0);
271 static struct wpabuf * p2p_build_go_neg_resp(struct p2p_data *p2p,
282 p2p_dbg(p2p, "Building GO Negotiation Response");
285 if (p2p->wfd_ie_go_neg)
286 extra = wpabuf_len(p2p->wfd_ie_go_neg);
289 if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_RESP])
290 extra += wpabuf_len(p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_RESP]);
308 if (p2p->cross_connect)
310 if (p2p->cfg->p2p_intra_bss)
313 p2p_buf_add_capability(buf, p2p->dev_capab &
316 p2p_buf_add_go_intent(buf, (p2p->go_intent << 1) | tie_breaker);
317 p2p_buf_add_config_timeout(buf, p2p->go_timeout, p2p->client_timeout);
318 if (peer && peer->go_state == REMOTE_GO && !p2p->num_pref_freq) {
319 p2p_dbg(p2p, "Omit Operating Channel attribute");
321 p2p_buf_add_operating_channel(buf, p2p->cfg->country,
322 p2p->op_reg_class,
323 p2p->op_channel);
325 p2p_buf_add_intended_addr(buf, p2p->intended_addr);
327 p2p_buf_add_channel_list(buf, p2p->cfg->country,
328 &p2p->channels);
330 p2p_buf_add_channel_list(buf, p2p->cfg->country,
331 &p2p->channels);
334 p2p_channels_intersect(&p2p->channels, &peer->channels,
336 p2p_buf_add_channel_list(buf, p2p->cfg->country, &res);
338 p2p_buf_add_device_info(buf, p2p, peer);
340 p2p_buf_add_group_id(buf, p2p->cfg->dev_addr, p2p->ssid,
341 p2p->ssid_len);
349 if (p2p_build_wps_ie(p2p, buf, pw_id, 0) < 0) {
350 p2p_dbg(p2p, "Failed to build WPS IE for GO Negotiation Response");
356 if (p2p->wfd_ie_go_neg)
357 wpabuf_put_buf(buf, p2p->wfd_ie_go_neg);
360 if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_RESP])
361 wpabuf_put_buf(buf, p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_RESP]);
369 * @p2p: P2P module context from p2p_init()
378 void p2p_reselect_channel(struct p2p_data *p2p,
389 if (p2p->own_freq_preference > 0 &&
390 p2p_freq_to_channel(p2p->own_freq_preference,
393 p2p_dbg(p2p, "Pick own channel preference (reg_class %u channel %u) from intersection",
395 p2p->op_reg_class = op_reg_class;
396 p2p->op_channel = op_channel;
400 if (p2p->best_freq_overall > 0 &&
401 p2p_freq_to_channel(p2p->best_freq_overall,
404 p2p_dbg(p2p, "Pick best overall channel (reg_class %u channel %u) from intersection",
406 p2p->op_reg_class = op_reg_class;
407 p2p->op_channel = op_channel;
412 freq = p2p_channel_to_freq(p2p->op_reg_class, p2p->op_channel);
413 if (freq >= 2400 && freq < 2500 && p2p->best_freq_5 > 0 &&
414 !p2p_channels_includes(intersection, p2p->op_reg_class,
415 p2p->op_channel) &&
416 p2p_freq_to_channel(p2p->best_freq_5,
419 p2p_dbg(p2p, "Pick best 5 GHz channel (reg_class %u channel %u) from intersection",
421 p2p->op_reg_class = op_reg_class;
422 p2p->op_channel = op_channel;
426 if (freq >= 4900 && freq < 6000 && p2p->best_freq_24 > 0 &&
427 !p2p_channels_includes(intersection, p2p->op_reg_class,
428 p2p->op_channel) &&
429 p2p_freq_to_channel(p2p->best_freq_24,
432 p2p_dbg(p2p, "Pick best 2.4 GHz channel (reg_class %u channel %u) from intersection",
434 p2p->op_reg_class = op_reg_class;
435 p2p->op_channel = op_channel;
440 for (i = 0; p2p->cfg->pref_chan && i < p2p->cfg->num_pref_chan; i++) {
442 p2p->cfg->pref_chan[i].op_class,
443 p2p->cfg->pref_chan[i].chan)) {
444 p2p->op_reg_class = p2p->cfg->pref_chan[i].op_class;
445 p2p->op_channel = p2p->cfg->pref_chan[i].chan;
446 p2p_dbg(p2p, "Pick highest preferred channel (op_class %u channel %u) from intersection",
447 p2p->op_reg_class, p2p->op_channel);
454 &p2p->op_reg_class, &p2p->op_channel) == 0) {
455 p2p_dbg(p2p, "Pick possible VHT channel (op_class %u channel %u) from intersection",
456 p2p->op_reg_class, p2p->op_channel);
462 &p2p->op_reg_class, &p2p->op_channel) == 0) {
463 p2p_dbg(p2p, "Pick possible HT40 channel (op_class %u channel %u) from intersection",
464 p2p->op_reg_class, p2p->op_channel);
470 &p2p->op_reg_class, &p2p->op_channel) == 0) {
471 p2p_dbg(p2p, "Pick possible 5 GHz channel (op_class %u channel %u) from intersection",
472 p2p->op_reg_class, p2p->op_channel);
481 if (p2p_channels_includes(intersection, p2p->op_reg_class,
482 p2p->op_channel)) {
483 p2p_dbg(p2p, "Using original operating class and channel (op_class %u channel %u) from intersection",
484 p2p->op_reg_class, p2p->op_channel);
493 p2p_dbg(p2p, "Pick another channel (reg_class %u channel %u) from intersection",
495 p2p->op_reg_class = cl->reg_class;
496 p2p->op_channel = cl->channel[0];
500 int p2p_go_select_channel(struct p2p_data *p2p, struct p2p_device *dev,
505 p2p_channels_dump(p2p, "own channels", &p2p->channels);
506 p2p_channels_dump(p2p, "peer channels", &dev->channels);
507 p2p_channels_intersect(&p2p->channels, &dev->channels, &tmp);
508 p2p_channels_dump(p2p, "intersection", &tmp);
509 p2p_channels_remove_freqs(&tmp, &p2p->no_go_freq);
510 p2p_channels_dump(p2p, "intersection after no-GO removal", &tmp);
511 p2p_channels_intersect(&tmp, &p2p->cfg->channels, &intersection);
512 p2p_channels_dump(p2p, "intersection with local channel list",
517 p2p_dbg(p2p, "No common channels found");
521 if (!p2p_channels_includes(&intersection, p2p->op_reg_class,
522 p2p->op_channel)) {
525 p2p_dbg(p2p, "Peer does not support the forced channel");
529 p2p_dbg(p2p, "Selected operating channel (op_class %u channel %u) not acceptable to the peer",
530 p2p->op_reg_class, p2p->op_channel);
531 p2p_reselect_channel(p2p, &intersection);
533 !p2p->cfg->cfg_op_channel) {
534 p2p_dbg(p2p, "Try to optimize channel selection with peer information received; previously selected op_class %u channel %u",
535 p2p->op_reg_class, p2p->op_channel);
536 p2p_reselect_channel(p2p, &intersection);
539 if (!p2p->ssid_set) {
540 p2p_build_ssid(p2p, p2p->ssid, &p2p->ssid_len);
541 p2p->ssid_set = 1;
548 static void p2p_check_pref_chan_no_recv(struct p2p_data *p2p, int go,
557 p2p_dbg(p2p,
568 * 2. Allowed for P2P use.
573 p2p_dbg(p2p, "Unsupported frequency %u MHz", oper_freq);
576 if (!p2p_channels_includes(&p2p->cfg->channels,
578 (go || !p2p_channels_includes(&p2p->cfg->cli_channels,
580 p2p_dbg(p2p,
581 "Freq %u MHz (oper_class %u channel %u) not allowed for P2P",
590 p2p->op_reg_class = op_class;
591 p2p->op_channel = op_channel;
592 os_memcpy(&p2p->channels, &p2p->cfg->channels,
600 p2p_dbg(p2p,
604 p2p_dbg(p2p,
611 static void p2p_check_pref_chan_recv(struct p2p_data *p2p, int go,
636 * 2. Allowed for P2P use.
640 p2p_dbg(p2p, "Unsupported frequency %u MHz",
645 if (!p2p_channels_includes(&p2p->cfg->channels,
648 !p2p_channels_includes(&p2p->cfg->cli_channels,
650 p2p_dbg(p2p,
651 "Freq %u MHz (oper_class %u channel %u) not allowed for P2P",
655 p2p->op_reg_class = op_class;
656 p2p->op_channel = op_channel;
657 os_memcpy(&p2p->channels, &p2p->cfg->channels,
665 p2p_dbg(p2p,
669 p2p_dbg(p2p,
676 void p2p_check_pref_chan(struct p2p_data *p2p, int go,
688 if (!p2p->cfg->get_pref_freq_list || p2p->cfg->num_pref_chan ||
689 (dev->flags & P2P_DEV_FORCE_FREQ) || p2p->cfg->cfg_op_channel)
692 /* Obtain our preferred frequency list from driver based on P2P role. */
694 if (p2p->cfg->get_pref_freq_list(p2p->cfg->cb_ctx, go, &size,
710 p2p_dbg(p2p,
714 p2p->op_reg_class = op_class;
715 p2p->op_channel = op_channel;
716 os_memcpy(&p2p->channels, &p2p->cfg->channels,
722 p2p_dbg(p2p,
731 p2p_check_pref_chan_no_recv(p2p, go, dev, msg, freq_list, size);
733 p2p_check_pref_chan_recv(p2p, go, dev, msg, freq_list, size);
737 void p2p_process_go_neg_req(struct p2p_data *p2p, const u8 *sa,
747 p2p_dbg(p2p, "Received GO Negotiation Request from " MACSTR "(freq=%d)",
754 p2p_dbg(p2p, "Mandatory Capability attribute missing from GO Negotiation Request");
763 p2p_dbg(p2p, "Mandatory GO Intent attribute missing from GO Negotiation Request");
770 p2p_dbg(p2p, "Mandatory Configuration Timeout attribute missing from GO Negotiation Request");
777 p2p_dbg(p2p, "No Listen Channel attribute received");
781 p2p_dbg(p2p, "No Operating Channel attribute received");
785 p2p_dbg(p2p, "No Channel List attribute received");
789 p2p_dbg(p2p, "No Intended P2P Interface Address attribute received");
793 p2p_dbg(p2p, "No P2P Device Info attribute received");
798 p2p_dbg(p2p, "Unexpected GO Negotiation Request SA=" MACSTR
804 dev = p2p_get_device(p2p, sa);
807 p2p_dbg(p2p, "Unexpected Status attribute (%d) in GO Negotiation Request",
809 if (dev && p2p->go_neg_peer == dev &&
813 * Negotiation Request is not compliant with the P2P
817 * status 1. The P2P specification explicitly disallows
823 p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
824 p2p_go_neg_failed(p2p, *msg.status);
832 dev = p2p_add_dev_from_go_neg_req(p2p, sa, &msg);
835 p2p_add_dev_info(p2p, sa, dev, &msg);
842 p2p_dbg(p2p, "Update peer " MACSTR
845 p2p_add_dev_info(p2p, sa, dev, &msg);
848 if (p2p->go_neg_peer && p2p->go_neg_peer == dev)
849 eloop_cancel_timeout(p2p_go_neg_wait_timeout, p2p, NULL);
852 p2p_dbg(p2p, "User has rejected this peer");
856 (p2p->authorized_oob_dev_pw_id == 0 ||
857 p2p->authorized_oob_dev_pw_id !=
859 p2p_dbg(p2p, "Not ready for GO negotiation with " MACSTR,
862 p2p->cfg->go_neg_req_rx(p2p->cfg->cb_ctx, sa,
866 } else if (p2p->go_neg_peer && p2p->go_neg_peer != dev) {
867 p2p_dbg(p2p, "Already in Group Formation with another peer");
872 if (!p2p->go_neg_peer) {
873 p2p_dbg(p2p, "Starting GO Negotiation with previously authorized peer");
875 p2p_dbg(p2p, "Use default channel settings");
876 p2p->op_reg_class = p2p->cfg->op_reg_class;
877 p2p->op_channel = p2p->cfg->op_channel;
878 os_memcpy(&p2p->channels, &p2p->cfg->channels,
881 p2p_dbg(p2p, "Use previously configured forced channel settings");
888 p2p_dbg(p2p, "No GO Intent attribute received");
892 p2p_dbg(p2p, "Invalid GO Intent value (%u) received",
898 os_memcmp(sa, p2p->cfg->dev_addr, ETH_ALEN) > 0) {
899 p2p_dbg(p2p, "Do not reply since peer has higher address and GO Neg Request already sent");
906 p2p_dbg(p2p,
912 go = p2p_go_det(p2p->go_intent, *msg.go_intent);
914 p2p_dbg(p2p, "Incompatible GO Intent");
919 if (p2p_peer_channels(p2p, dev, msg.channel_list,
921 p2p_dbg(p2p, "No common channels found");
928 p2p_dbg(p2p, "PIN from peer Display");
930 p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
937 p2p_dbg(p2p, "Peer entered PIN on Keypad");
939 p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
946 p2p_dbg(p2p, "Peer using pushbutton");
948 p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
955 p2p_dbg(p2p, "Peer using P2PS pin");
957 p2p_dbg(p2p,
967 p2p_dbg(p2p, "Peer using NFC");
969 p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
978 if (p2p->authorized_oob_dev_pw_id &&
980 p2p->authorized_oob_dev_pw_id) {
981 p2p_dbg(p2p, "Using static handover with our device password from NFC Tag");
983 dev->oob_pw_id = p2p->authorized_oob_dev_pw_id;
987 p2p_dbg(p2p, "Unsupported Device Password ID %d",
993 if (go && p2p_go_select_channel(p2p, dev, &status) < 0)
999 p2p_dbg(p2p, "Peer operating channel preference: %d MHz",
1006 p2p_check_pref_chan(p2p, go, dev, &msg);
1013 p2p_dbg(p2p, "GO Negotiation with " MACSTR, MAC2STR(sa));
1014 if (p2p->state != P2P_IDLE)
1015 p2p_stop_find_for_freq(p2p, rx_freq);
1016 p2p_set_state(p2p, P2P_GO_NEG);
1017 p2p_clear_timeout(p2p);
1020 p2p->go_neg_peer = dev;
1021 eloop_cancel_timeout(p2p_go_neg_wait_timeout, p2p, NULL);
1028 resp = p2p_build_go_neg_resp(p2p, dev, msg.dialog_token, status,
1033 p2p_dbg(p2p, "Sending GO Negotiation Response");
1037 freq = p2p_channel_to_freq(p2p->cfg->reg_class,
1038 p2p->cfg->channel);
1040 p2p_dbg(p2p, "Unknown regulatory class/channel");
1045 p2p->pending_action_state = P2P_PENDING_GO_NEG_RESPONSE;
1047 if (os_memcmp(sa, p2p->cfg->dev_addr, ETH_ALEN) < 0) {
1059 p2p->pending_action_state =
1061 if (p2p_send_action(p2p, freq, sa, p2p->cfg->dev_addr,
1062 p2p->cfg->dev_addr,
1064 p2p_dbg(p2p, "Failed to send Action frame");
1071 static struct wpabuf * p2p_build_go_neg_conf(struct p2p_data *p2p,
1082 p2p_dbg(p2p, "Building GO Negotiation Confirm");
1085 if (p2p->wfd_ie_go_neg)
1086 extra = wpabuf_len(p2p->wfd_ie_go_neg);
1089 if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_CONF])
1090 extra += wpabuf_len(p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_CONF]);
1108 if (p2p->cross_connect)
1110 if (p2p->cfg->p2p_intra_bss)
1113 p2p_buf_add_capability(buf, p2p->dev_capab &
1117 p2p_buf_add_operating_channel(buf, p2p->cfg->country,
1118 p2p->op_reg_class,
1119 p2p->op_channel);
1123 p2p_channels_intersect(&p2p->channels, &peer->channels, &res);
1124 p2p_buf_add_channel_list(buf, p2p->cfg->country, &res);
1126 p2p_buf_add_group_id(buf, p2p->cfg->dev_addr, p2p->ssid,
1127 p2p->ssid_len);
1132 if (p2p->wfd_ie_go_neg)
1133 wpabuf_put_buf(buf, p2p->wfd_ie_go_neg);
1136 if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_CONF])
1137 wpabuf_put_buf(buf, p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_CONF]);
1143 void p2p_process_go_neg_resp(struct p2p_data *p2p, const u8 *sa,
1152 p2p_dbg(p2p, "Received GO Negotiation Response from " MACSTR
1154 dev = p2p_get_device(p2p, sa);
1156 dev != p2p->go_neg_peer) {
1157 p2p_dbg(p2p, "Not ready for GO negotiation with " MACSTR,
1166 p2p_dbg(p2p, "Was not expecting GO Negotiation Response - ignore");
1173 p2p_dbg(p2p, "Unexpected Dialog Token %u (expected %u)",
1180 p2p_dbg(p2p, "No Status attribute received");
1185 p2p_dbg(p2p, "GO Negotiation rejected: status %d", *msg.status);
1188 p2p_dbg(p2p, "Wait for the peer to become ready for GO Negotiation");
1190 eloop_cancel_timeout(p2p_go_neg_wait_timeout, p2p,
1193 p2p, NULL);
1194 if (p2p->state == P2P_CONNECT_LISTEN)
1195 p2p_set_state(p2p, P2P_WAIT_PEER_CONNECT);
1197 p2p_set_state(p2p, P2P_WAIT_PEER_IDLE);
1198 p2p_set_timeout(p2p, 0, 0);
1200 p2p_dbg(p2p, "Stop GO Negotiation attempt");
1201 p2p_go_neg_failed(p2p, *msg.status);
1203 p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
1209 p2p_dbg(p2p, "Mandatory Capability attribute missing from GO Negotiation Response");
1217 p2p_dbg(p2p, "Mandatory P2P Device Info attribute missing from GO Negotiation Response");
1225 p2p_dbg(p2p, "No Intended P2P Interface Address attribute received");
1231 p2p_dbg(p2p, "No GO Intent attribute received");
1236 p2p_dbg(p2p, "Invalid GO Intent value (%u) received",
1242 go = p2p_go_det(p2p->go_intent, *msg.go_intent);
1244 p2p_dbg(p2p, "Incompatible GO Intent");
1251 p2p->ssid_len = msg.group_id_len - ETH_ALEN;
1252 os_memcpy(p2p->ssid, msg.group_id + ETH_ALEN, p2p->ssid_len);
1254 p2p_dbg(p2p, "Mandatory P2P Group ID attribute missing from GO Negotiation Response");
1255 p2p->ssid_len = 0;
1261 p2p_dbg(p2p, "Mandatory Configuration Timeout attribute missing from GO Negotiation Response");
1278 * Note: P2P Client may omit Operating Channel attribute to
1281 p2p_dbg(p2p, "No Operating Channel attribute received");
1286 p2p_dbg(p2p, "No Channel List attribute received");
1291 if (p2p_peer_channels(p2p, dev, msg.channel_list,
1293 p2p_dbg(p2p, "No common channels found");
1301 p2p_dbg(p2p, "Peer operating channel preference: %d MHz",
1308 p2p_dbg(p2p, "PIN from peer Display");
1310 p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
1317 p2p_dbg(p2p, "Peer entered PIN on Keypad");
1319 p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
1326 p2p_dbg(p2p, "Peer using pushbutton");
1328 p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
1335 p2p_dbg(p2p, "P2P: Peer using P2PS default pin");
1337 p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
1346 p2p_dbg(p2p, "Peer using NFC");
1348 p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
1355 p2p_dbg(p2p, "Unsupported Device Password ID %d",
1361 if (go && p2p_go_select_channel(p2p, dev, &status) < 0)
1369 p2p_check_pref_chan(p2p, go, dev, &msg);
1371 p2p_set_state(p2p, P2P_GO_NEG);
1372 p2p_clear_timeout(p2p);
1374 p2p_dbg(p2p, "GO Negotiation with " MACSTR, MAC2STR(sa));
1380 dev->go_neg_conf = p2p_build_go_neg_conf(p2p, dev, msg.dialog_token,
1386 p2p_dbg(p2p, "Sending GO Negotiation Confirm");
1388 p2p->pending_action_state = P2P_PENDING_GO_NEG_CONFIRM;
1391 p2p->pending_action_state = P2P_NO_PENDING_ACTION;
1400 if (p2p_send_action(p2p, freq, sa, p2p->cfg->dev_addr, sa,
1403 p2p_dbg(p2p, "Failed to send Action frame");
1404 p2p_go_neg_failed(p2p, -1);
1405 p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
1409 p2p_dbg(p2p, "GO Negotiation failed");
1410 p2p_go_neg_failed(p2p, status);
1415 void p2p_process_go_neg_conf(struct p2p_data *p2p, const u8 *sa,
1421 p2p_dbg(p2p, "Received GO Negotiation Confirm from " MACSTR,
1423 dev = p2p_get_device(p2p, sa);
1425 dev != p2p->go_neg_peer) {
1426 p2p_dbg(p2p, "Not ready for GO negotiation with " MACSTR,
1431 if (p2p->pending_action_state == P2P_PENDING_GO_NEG_RESPONSE) {
1432 p2p_dbg(p2p, "Stopped waiting for TX status on GO Negotiation Response since we already received Confirmation");
1433 p2p->pending_action_state = P2P_NO_PENDING_ACTION;
1440 p2p_dbg(p2p, "Was not expecting GO Negotiation Confirm - ignore");
1445 p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
1448 p2p_dbg(p2p, "Unexpected Dialog Token %u (expected %u)",
1455 p2p_dbg(p2p, "No Status attribute received");
1460 p2p_dbg(p2p, "GO Negotiation rejected: status %d", *msg.status);
1461 p2p_go_neg_failed(p2p, *msg.status);
1468 p2p->ssid_len = msg.group_id_len - ETH_ALEN;
1469 os_memcpy(p2p->ssid, msg.group_id + ETH_ALEN, p2p->ssid_len);
1471 p2p_dbg(p2p, "Mandatory P2P Group ID attribute missing from GO Negotiation Confirmation");
1472 p2p->ssid_len = 0;
1473 p2p_go_neg_failed(p2p, P2P_SC_FAIL_INVALID_PARAMS);
1479 p2p_dbg(p2p, "Mandatory Operating Channel attribute missing from GO Negotiation Confirmation");
1488 p2p_dbg(p2p, "Updated peer (GO) operating channel preference from %d MHz to %d MHz",
1495 p2p_dbg(p2p, "Mandatory Operating Channel attribute missing from GO Negotiation Confirmation");
1509 p2p_dbg(p2p, "Unexpected GO Neg state - do not know which end becomes GO");
1521 p2p_dbg(p2p, "20 ms wait on current channel before starting group");
1524 p2p_go_complete(p2p, dev);