Lines Matching refs:p2p

17 #include "p2p.h"
35 int p2p_peer_channels_check(struct p2p_data *p2p, struct p2p_channels *own,
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");
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 (p2p->override_pref_op_class) {
319 p2p_dbg(p2p, "Override operating channel preference");
320 p2p_buf_add_operating_channel(buf, p2p->cfg->country,
321 p2p->override_pref_op_class,
322 p2p->override_pref_channel);
323 } else if (peer && peer->go_state == REMOTE_GO && !p2p->num_pref_freq) {
324 p2p_dbg(p2p, "Omit Operating Channel attribute");
326 p2p_buf_add_operating_channel(buf, p2p->cfg->country,
327 p2p->op_reg_class,
328 p2p->op_channel);
330 p2p_buf_add_intended_addr(buf, p2p->intended_addr);
332 p2p_buf_add_channel_list(buf, p2p->cfg->country,
333 &p2p->channels);
335 p2p_buf_add_channel_list(buf, p2p->cfg->country,
336 &p2p->channels);
339 p2p_channels_intersect(&p2p->channels, &peer->channels,
341 p2p_buf_add_channel_list(buf, p2p->cfg->country, &res);
343 p2p_buf_add_device_info(buf, p2p, peer);
345 p2p_buf_add_group_id(buf, p2p->cfg->dev_addr, p2p->ssid,
346 p2p->ssid_len);
354 if (p2p_build_wps_ie(p2p, buf, pw_id, 0) < 0) {
355 p2p_dbg(p2p, "Failed to build WPS IE for GO Negotiation Response");
361 if (p2p->wfd_ie_go_neg)
362 wpabuf_put_buf(buf, p2p->wfd_ie_go_neg);
365 if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_RESP])
366 wpabuf_put_buf(buf, p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_RESP]);
374 * @p2p: P2P module context from p2p_init()
383 void p2p_reselect_channel(struct p2p_data *p2p,
394 if (p2p->own_freq_preference > 0 &&
395 p2p_freq_to_channel(p2p->own_freq_preference,
398 p2p_dbg(p2p, "Pick own channel preference (reg_class %u channel %u) from intersection",
400 p2p->op_reg_class = op_reg_class;
401 p2p->op_channel = op_channel;
405 if (p2p->best_freq_overall > 0 &&
406 p2p_freq_to_channel(p2p->best_freq_overall,
409 p2p_dbg(p2p, "Pick best overall channel (reg_class %u channel %u) from intersection",
411 p2p->op_reg_class = op_reg_class;
412 p2p->op_channel = op_channel;
417 freq = p2p_channel_to_freq(p2p->op_reg_class, p2p->op_channel);
418 if (freq >= 2400 && freq < 2500 && p2p->best_freq_5 > 0 &&
419 !p2p_channels_includes(intersection, p2p->op_reg_class,
420 p2p->op_channel) &&
421 p2p_freq_to_channel(p2p->best_freq_5,
424 p2p_dbg(p2p, "Pick best 5 GHz channel (reg_class %u channel %u) from intersection",
426 p2p->op_reg_class = op_reg_class;
427 p2p->op_channel = op_channel;
431 if (freq >= 4900 && freq < 6000 && p2p->best_freq_24 > 0 &&
432 !p2p_channels_includes(intersection, p2p->op_reg_class,
433 p2p->op_channel) &&
434 p2p_freq_to_channel(p2p->best_freq_24,
437 p2p_dbg(p2p, "Pick best 2.4 GHz channel (reg_class %u channel %u) from intersection",
439 p2p->op_reg_class = op_reg_class;
440 p2p->op_channel = op_channel;
445 for (i = 0; p2p->cfg->pref_chan && i < p2p->cfg->num_pref_chan; i++) {
447 p2p->cfg->pref_chan[i].op_class,
448 p2p->cfg->pref_chan[i].chan)) {
449 p2p->op_reg_class = p2p->cfg->pref_chan[i].op_class;
450 p2p->op_channel = p2p->cfg->pref_chan[i].chan;
451 p2p_dbg(p2p, "Pick highest preferred channel (op_class %u channel %u) from intersection",
452 p2p->op_reg_class, p2p->op_channel);
459 &p2p->op_reg_class, &p2p->op_channel) == 0) {
460 p2p_dbg(p2p, "Pick possible VHT channel (op_class %u channel %u) from intersection",
461 p2p->op_reg_class, p2p->op_channel);
467 &p2p->op_reg_class, &p2p->op_channel) == 0) {
468 p2p_dbg(p2p, "Pick possible HT40 channel (op_class %u channel %u) from intersection",
469 p2p->op_reg_class, p2p->op_channel);
475 &p2p->op_reg_class, &p2p->op_channel) == 0) {
476 p2p_dbg(p2p, "Pick possible 5 GHz channel (op_class %u channel %u) from intersection",
477 p2p->op_reg_class, p2p->op_channel);
486 if (p2p_channels_includes(intersection, p2p->op_reg_class,
487 p2p->op_channel)) {
488 p2p_dbg(p2p, "Using original operating class and channel (op_class %u channel %u) from intersection",
489 p2p->op_reg_class, p2p->op_channel);
498 p2p_dbg(p2p, "Pick another channel (reg_class %u channel %u) from intersection",
500 p2p->op_reg_class = cl->reg_class;
501 p2p->op_channel = cl->channel[0];
505 int p2p_go_select_channel(struct p2p_data *p2p, struct p2p_device *dev,
510 p2p_channels_dump(p2p, "own channels", &p2p->channels);
511 p2p_channels_dump(p2p, "peer channels", &dev->channels);
512 p2p_channels_intersect(&p2p->channels, &dev->channels, &tmp);
513 p2p_channels_dump(p2p, "intersection", &tmp);
514 p2p_channels_remove_freqs(&tmp, &p2p->no_go_freq);
515 p2p_channels_dump(p2p, "intersection after no-GO removal", &tmp);
516 p2p_channels_intersect(&tmp, &p2p->cfg->channels, &intersection);
517 p2p_channels_dump(p2p, "intersection with local channel list",
522 p2p_dbg(p2p, "No common channels found");
526 if (!p2p_channels_includes(&intersection, p2p->op_reg_class,
527 p2p->op_channel)) {
530 p2p_dbg(p2p, "Peer does not support the forced channel");
534 p2p_dbg(p2p, "Selected operating channel (op_class %u channel %u) not acceptable to the peer",
535 p2p->op_reg_class, p2p->op_channel);
536 p2p_reselect_channel(p2p, &intersection);
538 !p2p->cfg->cfg_op_channel) {
539 p2p_dbg(p2p, "Try to optimize channel selection with peer information received; previously selected op_class %u channel %u",
540 p2p->op_reg_class, p2p->op_channel);
541 p2p_reselect_channel(p2p, &intersection);
544 if (!p2p->ssid_set) {
545 p2p_build_ssid(p2p, p2p->ssid, &p2p->ssid_len);
546 p2p->ssid_set = 1;
553 static void p2p_check_pref_chan_no_recv(struct p2p_data *p2p, int go,
562 p2p_dbg(p2p,
580 p2p->op_reg_class = op_class;
581 p2p->op_channel = op_channel;
582 os_memcpy(&p2p->channels, &p2p->cfg->channels,
590 p2p_dbg(p2p,
594 p2p_dbg(p2p,
600 static void p2p_check_pref_chan_recv(struct p2p_data *p2p, int go,
624 p2p->op_reg_class = op_class;
625 p2p->op_channel = op_channel;
626 os_memcpy(&p2p->channels, &p2p->cfg->channels,
634 p2p_dbg(p2p,
638 p2p_dbg(p2p, "No common preferred channels found!");
643 void p2p_check_pref_chan(struct p2p_data *p2p, int go,
657 if (!p2p->cfg->get_pref_freq_list || p2p->cfg->num_pref_chan ||
658 (dev->flags & P2P_DEV_FORCE_FREQ) || p2p->cfg->cfg_op_channel)
663 if (p2p->cfg->get_pref_freq_list(p2p->cfg->cb_ctx, go, &size,
671 (!p2p_channels_includes(&p2p->cfg->channels,
673 (go || !p2p_channels_includes(&p2p->cfg->cli_channels,
675 p2p_dbg(p2p,
699 p2p_dbg(p2p, "Local driver frequency preference (size=%u):%s",
713 p2p->op_reg_class = op_class;
714 p2p->op_channel = op_channel;
715 os_memcpy(&p2p->channels, &p2p->cfg->channels,
720 p2p_dbg(p2p,
729 p2p_check_pref_chan_no_recv(p2p, go, dev, msg, freq_list, size);
731 p2p_check_pref_chan_recv(p2p, go, dev, msg, freq_list, size);
735 void p2p_process_go_neg_req(struct p2p_data *p2p, const u8 *sa,
745 p2p_dbg(p2p, "Received GO Negotiation Request from " MACSTR "(freq=%d)",
752 p2p_dbg(p2p, "Mandatory Capability attribute missing from GO Negotiation Request");
761 p2p_dbg(p2p, "Mandatory GO Intent attribute missing from GO Negotiation Request");
768 p2p_dbg(p2p, "Mandatory Configuration Timeout attribute missing from GO Negotiation Request");
775 p2p_dbg(p2p, "No Listen Channel attribute received");
779 p2p_dbg(p2p, "No Operating Channel attribute received");
783 p2p_dbg(p2p, "No Channel List attribute received");
787 p2p_dbg(p2p, "No Intended P2P Interface Address attribute received");
791 p2p_dbg(p2p, "No P2P Device Info attribute received");
796 p2p_dbg(p2p, "Unexpected GO Negotiation Request SA=" MACSTR
802 dev = p2p_get_device(p2p, sa);
805 p2p_dbg(p2p, "Unexpected Status attribute (%d) in GO Negotiation Request",
807 if (dev && p2p->go_neg_peer == dev &&
821 p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
822 p2p_go_neg_failed(p2p, *msg.status);
830 dev = p2p_add_dev_from_go_neg_req(p2p, sa, &msg);
833 p2p_add_dev_info(p2p, sa, dev, &msg);
840 p2p_dbg(p2p, "Update peer " MACSTR
843 p2p_add_dev_info(p2p, sa, dev, &msg);
846 if (p2p->go_neg_peer && p2p->go_neg_peer == dev)
847 eloop_cancel_timeout(p2p_go_neg_wait_timeout, p2p, NULL);
850 p2p_dbg(p2p, "User has rejected this peer");
854 (p2p->authorized_oob_dev_pw_id == 0 ||
855 p2p->authorized_oob_dev_pw_id !=
857 p2p_dbg(p2p, "Not ready for GO negotiation with " MACSTR,
860 p2p->cfg->go_neg_req_rx(p2p->cfg->cb_ctx, sa,
864 } else if (p2p->go_neg_peer && p2p->go_neg_peer != dev) {
865 p2p_dbg(p2p, "Already in Group Formation with another peer");
870 if (!p2p->go_neg_peer) {
871 p2p_dbg(p2p, "Starting GO Negotiation with previously authorized peer");
873 p2p_dbg(p2p, "Use default channel settings");
874 p2p->op_reg_class = p2p->cfg->op_reg_class;
875 p2p->op_channel = p2p->cfg->op_channel;
876 os_memcpy(&p2p->channels, &p2p->cfg->channels,
879 p2p_dbg(p2p, "Use previously configured forced channel settings");
886 p2p_dbg(p2p, "No GO Intent attribute received");
890 p2p_dbg(p2p, "Invalid GO Intent value (%u) received",
896 os_memcmp(sa, p2p->cfg->dev_addr, ETH_ALEN) > 0) {
897 p2p_dbg(p2p, "Do not reply since peer has higher address and GO Neg Request already sent");
904 p2p_dbg(p2p,
910 go = p2p_go_det(p2p->go_intent, *msg.go_intent);
912 p2p_dbg(p2p, "Incompatible GO Intent");
917 if (p2p_peer_channels(p2p, dev, msg.channel_list,
919 p2p_dbg(p2p, "No common channels found");
926 p2p_dbg(p2p, "PIN from peer Display");
928 p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
935 p2p_dbg(p2p, "Peer entered PIN on Keypad");
937 p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
944 p2p_dbg(p2p, "Peer using pushbutton");
946 p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
953 p2p_dbg(p2p, "Peer using P2PS pin");
955 p2p_dbg(p2p,
965 p2p_dbg(p2p, "Peer using NFC");
967 p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
976 if (p2p->authorized_oob_dev_pw_id &&
978 p2p->authorized_oob_dev_pw_id) {
979 p2p_dbg(p2p, "Using static handover with our device password from NFC Tag");
981 dev->oob_pw_id = p2p->authorized_oob_dev_pw_id;
985 p2p_dbg(p2p, "Unsupported Device Password ID %d",
991 if (go && p2p_go_select_channel(p2p, dev, &status) < 0)
997 p2p_dbg(p2p, "Peer operating channel preference: %d MHz",
1004 p2p_check_pref_chan(p2p, go, dev, &msg);
1011 p2p_dbg(p2p, "GO Negotiation with " MACSTR, MAC2STR(sa));
1012 if (p2p->state != P2P_IDLE)
1013 p2p_stop_find_for_freq(p2p, rx_freq);
1014 p2p_set_state(p2p, P2P_GO_NEG);
1015 p2p_clear_timeout(p2p);
1018 p2p->go_neg_peer = dev;
1019 eloop_cancel_timeout(p2p_go_neg_wait_timeout, p2p, NULL);
1026 resp = p2p_build_go_neg_resp(p2p, dev, msg.dialog_token, status,
1031 p2p_dbg(p2p, "Sending GO Negotiation Response");
1035 freq = p2p_channel_to_freq(p2p->cfg->reg_class,
1036 p2p->cfg->channel);
1038 p2p_dbg(p2p, "Unknown regulatory class/channel");
1043 p2p->pending_action_state = P2P_PENDING_GO_NEG_RESPONSE;
1045 if (os_memcmp(sa, p2p->cfg->dev_addr, ETH_ALEN) < 0) {
1057 p2p->pending_action_state =
1059 if (p2p_send_action(p2p, freq, sa, p2p->cfg->dev_addr,
1060 p2p->cfg->dev_addr,
1062 p2p_dbg(p2p, "Failed to send Action frame");
1069 static struct wpabuf * p2p_build_go_neg_conf(struct p2p_data *p2p,
1080 p2p_dbg(p2p, "Building GO Negotiation Confirm");
1083 if (p2p->wfd_ie_go_neg)
1084 extra = wpabuf_len(p2p->wfd_ie_go_neg);
1087 if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_CONF])
1088 extra += wpabuf_len(p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_CONF]);
1106 if (p2p->cross_connect)
1108 if (p2p->cfg->p2p_intra_bss)
1111 p2p_buf_add_capability(buf, p2p->dev_capab &
1115 p2p_buf_add_operating_channel(buf, p2p->cfg->country,
1116 p2p->op_reg_class,
1117 p2p->op_channel);
1121 p2p_channels_intersect(&p2p->channels, &peer->channels, &res);
1122 p2p_buf_add_channel_list(buf, p2p->cfg->country, &res);
1124 p2p_buf_add_group_id(buf, p2p->cfg->dev_addr, p2p->ssid,
1125 p2p->ssid_len);
1130 if (p2p->wfd_ie_go_neg)
1131 wpabuf_put_buf(buf, p2p->wfd_ie_go_neg);
1134 if (p2p->vendor_elem && p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_CONF])
1135 wpabuf_put_buf(buf, p2p->vendor_elem[VENDOR_ELEM_P2P_GO_NEG_CONF]);
1141 void p2p_process_go_neg_resp(struct p2p_data *p2p, const u8 *sa,
1150 p2p_dbg(p2p, "Received GO Negotiation Response from " MACSTR
1152 dev = p2p_get_device(p2p, sa);
1154 dev != p2p->go_neg_peer) {
1155 p2p_dbg(p2p, "Not ready for GO negotiation with " MACSTR,
1164 p2p_dbg(p2p, "Was not expecting GO Negotiation Response - ignore");
1171 p2p_dbg(p2p, "Unexpected Dialog Token %u (expected %u)",
1178 p2p_dbg(p2p, "No Status attribute received");
1183 p2p_dbg(p2p, "GO Negotiation rejected: status %d", *msg.status);
1186 p2p_dbg(p2p, "Wait for the peer to become ready for GO Negotiation");
1188 eloop_cancel_timeout(p2p_go_neg_wait_timeout, p2p,
1191 p2p, NULL);
1192 if (p2p->state == P2P_CONNECT_LISTEN)
1193 p2p_set_state(p2p, P2P_WAIT_PEER_CONNECT);
1195 p2p_set_state(p2p, P2P_WAIT_PEER_IDLE);
1196 p2p_set_timeout(p2p, 0, 0);
1198 p2p_dbg(p2p, "Stop GO Negotiation attempt");
1199 p2p_go_neg_failed(p2p, *msg.status);
1201 p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
1207 p2p_dbg(p2p, "Mandatory Capability attribute missing from GO Negotiation Response");
1215 p2p_dbg(p2p, "Mandatory P2P Device Info attribute missing from GO Negotiation Response");
1223 p2p_dbg(p2p, "No Intended P2P Interface Address attribute received");
1229 p2p_dbg(p2p, "No GO Intent attribute received");
1234 p2p_dbg(p2p, "Invalid GO Intent value (%u) received",
1240 go = p2p_go_det(p2p->go_intent, *msg.go_intent);
1242 p2p_dbg(p2p, "Incompatible GO Intent");
1249 p2p->ssid_len = msg.group_id_len - ETH_ALEN;
1250 os_memcpy(p2p->ssid, msg.group_id + ETH_ALEN, p2p->ssid_len);
1252 p2p_dbg(p2p, "Mandatory P2P Group ID attribute missing from GO Negotiation Response");
1253 p2p->ssid_len = 0;
1259 p2p_dbg(p2p, "Mandatory Configuration Timeout attribute missing from GO Negotiation Response");
1279 p2p_dbg(p2p, "No Operating Channel attribute received");
1284 p2p_dbg(p2p, "No Channel List attribute received");
1289 if (p2p_peer_channels(p2p, dev, msg.channel_list,
1291 p2p_dbg(p2p, "No common channels found");
1299 p2p_dbg(p2p, "Peer operating channel preference: %d MHz",
1306 p2p_dbg(p2p, "PIN from peer Display");
1308 p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
1315 p2p_dbg(p2p, "Peer entered PIN on Keypad");
1317 p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
1324 p2p_dbg(p2p, "Peer using pushbutton");
1326 p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
1333 p2p_dbg(p2p, "P2P: Peer using P2PS default pin");
1335 p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
1344 p2p_dbg(p2p, "Peer using NFC");
1346 p2p_dbg(p2p, "We have wps_method=%s -> incompatible",
1353 p2p_dbg(p2p, "Unsupported Device Password ID %d",
1359 if (go && p2p_go_select_channel(p2p, dev, &status) < 0)
1367 p2p_check_pref_chan(p2p, go, dev, &msg);
1369 p2p_set_state(p2p, P2P_GO_NEG);
1370 p2p_clear_timeout(p2p);
1372 p2p_dbg(p2p, "GO Negotiation with " MACSTR, MAC2STR(sa));
1378 dev->go_neg_conf = p2p_build_go_neg_conf(p2p, dev, msg.dialog_token,
1384 p2p_dbg(p2p, "Sending GO Negotiation Confirm");
1386 p2p->pending_action_state = P2P_PENDING_GO_NEG_CONFIRM;
1389 p2p->pending_action_state = P2P_NO_PENDING_ACTION;
1398 if (p2p_send_action(p2p, freq, sa, p2p->cfg->dev_addr, sa,
1401 p2p_dbg(p2p, "Failed to send Action frame");
1402 p2p_go_neg_failed(p2p, -1);
1403 p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
1407 p2p_dbg(p2p, "GO Negotiation failed");
1408 p2p_go_neg_failed(p2p, status);
1413 void p2p_process_go_neg_conf(struct p2p_data *p2p, const u8 *sa,
1419 p2p_dbg(p2p, "Received GO Negotiation Confirm from " MACSTR,
1421 dev = p2p_get_device(p2p, sa);
1423 dev != p2p->go_neg_peer) {
1424 p2p_dbg(p2p, "Not ready for GO negotiation with " MACSTR,
1429 if (p2p->pending_action_state == P2P_PENDING_GO_NEG_RESPONSE) {
1430 p2p_dbg(p2p, "Stopped waiting for TX status on GO Negotiation Response since we already received Confirmation");
1431 p2p->pending_action_state = P2P_NO_PENDING_ACTION;
1438 p2p_dbg(p2p, "Was not expecting GO Negotiation Confirm - ignore");
1443 p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
1446 p2p_dbg(p2p, "Unexpected Dialog Token %u (expected %u)",
1453 p2p_dbg(p2p, "No Status attribute received");
1458 p2p_dbg(p2p, "GO Negotiation rejected: status %d", *msg.status);
1459 p2p_go_neg_failed(p2p, *msg.status);
1466 p2p->ssid_len = msg.group_id_len - ETH_ALEN;
1467 os_memcpy(p2p->ssid, msg.group_id + ETH_ALEN, p2p->ssid_len);
1469 p2p_dbg(p2p, "Mandatory P2P Group ID attribute missing from GO Negotiation Confirmation");
1470 p2p->ssid_len = 0;
1471 p2p_go_neg_failed(p2p, P2P_SC_FAIL_INVALID_PARAMS);
1477 p2p_dbg(p2p, "Mandatory Operating Channel attribute missing from GO Negotiation Confirmation");
1486 p2p_dbg(p2p, "Updated peer (GO) operating channel preference from %d MHz to %d MHz",
1493 p2p_dbg(p2p, "Mandatory Operating Channel attribute missing from GO Negotiation Confirmation");
1507 p2p_dbg(p2p, "Unexpected GO Neg state - do not know which end becomes GO");
1519 p2p_dbg(p2p, "20 ms wait on current channel before starting group");
1522 p2p_go_complete(p2p, dev);