p2p_go_neg.c revision 03b5cdf515ae7259d67b33c22d829495ac80e631
1/* 2 * Wi-Fi Direct - P2P Group Owner Negotiation 3 * Copyright (c) 2009-2010, Atheros Communications 4 * 5 * This software may be distributed under the terms of the BSD license. 6 * See README for more details. 7 */ 8 9#include "includes.h" 10 11#include "common.h" 12#include "common/ieee802_11_defs.h" 13#include "wps/wps_defs.h" 14#include "p2p_i.h" 15#include "p2p.h" 16 17 18static int p2p_go_det(u8 own_intent, u8 peer_value) 19{ 20 u8 peer_intent = peer_value >> 1; 21 if (own_intent == peer_intent) { 22 if (own_intent == P2P_MAX_GO_INTENT) 23 return -1; /* both devices want to become GO */ 24 25 /* Use tie breaker bit to determine GO */ 26 return (peer_value & 0x01) ? 0 : 1; 27 } 28 29 return own_intent > peer_intent; 30} 31 32 33int p2p_peer_channels_check(struct p2p_data *p2p, struct p2p_channels *own, 34 struct p2p_device *dev, 35 const u8 *channel_list, size_t channel_list_len) 36{ 37 const u8 *pos, *end; 38 struct p2p_channels *ch; 39 size_t channels; 40 struct p2p_channels intersection; 41 42 ch = &dev->channels; 43 os_memset(ch, 0, sizeof(*ch)); 44 pos = channel_list; 45 end = channel_list + channel_list_len; 46 47 if (end - pos < 3) 48 return -1; 49 os_memcpy(dev->country, pos, 3); 50 wpa_hexdump_ascii(MSG_DEBUG, "P2P: Peer country", pos, 3); 51 if (pos[2] != 0x04 && os_memcmp(pos, p2p->cfg->country, 2) != 0) { 52 p2p_info(p2p, "Mismatching country (ours=%c%c peer's=%c%c)", 53 p2p->cfg->country[0], p2p->cfg->country[1], 54 pos[0], pos[1]); 55 return -1; 56 } 57 pos += 3; 58 59 while (pos + 2 < end) { 60 struct p2p_reg_class *cl = &ch->reg_class[ch->reg_classes]; 61 cl->reg_class = *pos++; 62 if (pos + 1 + pos[0] > end) { 63 p2p_info(p2p, "Invalid peer Channel List"); 64 return -1; 65 } 66 channels = *pos++; 67 cl->channels = channels > P2P_MAX_REG_CLASS_CHANNELS ? 68 P2P_MAX_REG_CLASS_CHANNELS : channels; 69 os_memcpy(cl->channel, pos, cl->channels); 70 pos += channels; 71 ch->reg_classes++; 72 if (ch->reg_classes == P2P_MAX_REG_CLASSES) 73 break; 74 } 75 76 p2p_channels_intersect(own, &dev->channels, &intersection); 77 p2p_dbg(p2p, "Own reg_classes %d peer reg_classes %d intersection reg_classes %d", 78 (int) own->reg_classes, 79 (int) dev->channels.reg_classes, 80 (int) intersection.reg_classes); 81 if (intersection.reg_classes == 0) { 82 p2p_info(p2p, "No common channels found"); 83 return -1; 84 } 85 return 0; 86} 87 88 89static int p2p_peer_channels(struct p2p_data *p2p, struct p2p_device *dev, 90 const u8 *channel_list, size_t channel_list_len) 91{ 92 return p2p_peer_channels_check(p2p, &p2p->channels, dev, 93 channel_list, channel_list_len); 94} 95 96 97u16 p2p_wps_method_pw_id(enum p2p_wps_method wps_method) 98{ 99 switch (wps_method) { 100 case WPS_PIN_DISPLAY: 101 return DEV_PW_REGISTRAR_SPECIFIED; 102 case WPS_PIN_KEYPAD: 103 return DEV_PW_USER_SPECIFIED; 104 case WPS_PBC: 105 return DEV_PW_PUSHBUTTON; 106 default: 107 return DEV_PW_DEFAULT; 108 } 109} 110 111 112static const char * p2p_wps_method_str(enum p2p_wps_method wps_method) 113{ 114 switch (wps_method) { 115 case WPS_PIN_DISPLAY: 116 return "Display"; 117 case WPS_PIN_KEYPAD: 118 return "Keypad"; 119 case WPS_PBC: 120 return "PBC"; 121 default: 122 return "??"; 123 } 124} 125 126 127static struct wpabuf * p2p_build_go_neg_req(struct p2p_data *p2p, 128 struct p2p_device *peer) 129{ 130 struct wpabuf *buf; 131 u8 *len; 132 u8 group_capab; 133 size_t extra = 0; 134 135#ifdef CONFIG_WIFI_DISPLAY 136 if (p2p->wfd_ie_go_neg) 137 extra = wpabuf_len(p2p->wfd_ie_go_neg); 138#endif /* CONFIG_WIFI_DISPLAY */ 139 140 buf = wpabuf_alloc(1000 + extra); 141 if (buf == NULL) 142 return NULL; 143 144 p2p_buf_add_public_action_hdr(buf, P2P_GO_NEG_REQ, peer->dialog_token); 145 146 len = p2p_buf_add_ie_hdr(buf); 147 group_capab = 0; 148 if (peer->flags & P2P_DEV_PREFER_PERSISTENT_GROUP) { 149 group_capab |= P2P_GROUP_CAPAB_PERSISTENT_GROUP; 150 if (peer->flags & P2P_DEV_PREFER_PERSISTENT_RECONN) 151 group_capab |= P2P_GROUP_CAPAB_PERSISTENT_RECONN; 152 } 153 if (p2p->cross_connect) 154 group_capab |= P2P_GROUP_CAPAB_CROSS_CONN; 155 if (p2p->cfg->p2p_intra_bss) 156 group_capab |= P2P_GROUP_CAPAB_INTRA_BSS_DIST; 157 p2p_buf_add_capability(buf, p2p->dev_capab & 158 ~P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY, 159 group_capab); 160 p2p_buf_add_go_intent(buf, (p2p->go_intent << 1) | peer->tie_breaker); 161 p2p_buf_add_config_timeout(buf, p2p->go_timeout, p2p->client_timeout); 162 p2p_buf_add_listen_channel(buf, p2p->cfg->country, p2p->cfg->reg_class, 163 p2p->cfg->channel); 164 if (p2p->ext_listen_interval) 165 p2p_buf_add_ext_listen_timing(buf, p2p->ext_listen_period, 166 p2p->ext_listen_interval); 167 p2p_buf_add_intended_addr(buf, p2p->intended_addr); 168 p2p_buf_add_channel_list(buf, p2p->cfg->country, &p2p->channels); 169 p2p_buf_add_device_info(buf, p2p, peer); 170 p2p_buf_add_operating_channel(buf, p2p->cfg->country, 171 p2p->op_reg_class, p2p->op_channel); 172 p2p_buf_update_ie_hdr(buf, len); 173 174 /* WPS IE with Device Password ID attribute */ 175 p2p_build_wps_ie(p2p, buf, p2p_wps_method_pw_id(peer->wps_method), 0); 176 177#ifdef CONFIG_WIFI_DISPLAY 178 if (p2p->wfd_ie_go_neg) 179 wpabuf_put_buf(buf, p2p->wfd_ie_go_neg); 180#endif /* CONFIG_WIFI_DISPLAY */ 181 182 return buf; 183} 184 185 186int p2p_connect_send(struct p2p_data *p2p, struct p2p_device *dev) 187{ 188 struct wpabuf *req; 189 int freq; 190 191 if (dev->flags & P2P_DEV_PD_BEFORE_GO_NEG) { 192 u16 config_method; 193 p2p_dbg(p2p, "Use PD-before-GO-Neg workaround for " MACSTR, 194 MAC2STR(dev->info.p2p_device_addr)); 195 if (dev->wps_method == WPS_PIN_DISPLAY) 196 config_method = WPS_CONFIG_KEYPAD; 197 else if (dev->wps_method == WPS_PIN_KEYPAD) 198 config_method = WPS_CONFIG_DISPLAY; 199 else if (dev->wps_method == WPS_PBC) 200 config_method = WPS_CONFIG_PUSHBUTTON; 201 else 202 return -1; 203 return p2p_prov_disc_req(p2p, dev->info.p2p_device_addr, 204 config_method, 0, 0, 1); 205 } 206 207 freq = dev->listen_freq > 0 ? dev->listen_freq : dev->oper_freq; 208 if (freq <= 0) { 209 p2p_dbg(p2p, "No Listen/Operating frequency known for the peer " 210 MACSTR " to send GO Negotiation Request", 211 MAC2STR(dev->info.p2p_device_addr)); 212 return -1; 213 } 214 215 req = p2p_build_go_neg_req(p2p, dev); 216 if (req == NULL) 217 return -1; 218 p2p_dbg(p2p, "Sending GO Negotiation Request"); 219 p2p_set_state(p2p, P2P_CONNECT); 220 p2p->pending_action_state = P2P_PENDING_GO_NEG_REQUEST; 221 p2p->go_neg_peer = dev; 222 dev->flags |= P2P_DEV_WAIT_GO_NEG_RESPONSE; 223 dev->connect_reqs++; 224 if (p2p_send_action(p2p, freq, dev->info.p2p_device_addr, 225 p2p->cfg->dev_addr, dev->info.p2p_device_addr, 226 wpabuf_head(req), wpabuf_len(req), 500) < 0) { 227 p2p_dbg(p2p, "Failed to send Action frame"); 228 /* Use P2P find to recover and retry */ 229 p2p_set_timeout(p2p, 0, 0); 230 } else 231 dev->go_neg_req_sent++; 232 233 wpabuf_free(req); 234 235 return 0; 236} 237 238 239static struct wpabuf * p2p_build_go_neg_resp(struct p2p_data *p2p, 240 struct p2p_device *peer, 241 u8 dialog_token, u8 status, 242 u8 tie_breaker) 243{ 244 struct wpabuf *buf; 245 u8 *len; 246 u8 group_capab; 247 size_t extra = 0; 248 249 p2p_dbg(p2p, "Building GO Negotiation Response"); 250 251#ifdef CONFIG_WIFI_DISPLAY 252 if (p2p->wfd_ie_go_neg) 253 extra = wpabuf_len(p2p->wfd_ie_go_neg); 254#endif /* CONFIG_WIFI_DISPLAY */ 255 256 buf = wpabuf_alloc(1000 + extra); 257 if (buf == NULL) 258 return NULL; 259 260 p2p_buf_add_public_action_hdr(buf, P2P_GO_NEG_RESP, dialog_token); 261 262 len = p2p_buf_add_ie_hdr(buf); 263 p2p_buf_add_status(buf, status); 264 group_capab = 0; 265 if (peer && peer->go_state == LOCAL_GO) { 266 if (peer->flags & P2P_DEV_PREFER_PERSISTENT_GROUP) { 267 group_capab |= P2P_GROUP_CAPAB_PERSISTENT_GROUP; 268 if (peer->flags & P2P_DEV_PREFER_PERSISTENT_RECONN) 269 group_capab |= 270 P2P_GROUP_CAPAB_PERSISTENT_RECONN; 271 } 272 if (p2p->cross_connect) 273 group_capab |= P2P_GROUP_CAPAB_CROSS_CONN; 274 if (p2p->cfg->p2p_intra_bss) 275 group_capab |= P2P_GROUP_CAPAB_INTRA_BSS_DIST; 276 } 277 p2p_buf_add_capability(buf, p2p->dev_capab & 278 ~P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY, 279 group_capab); 280 p2p_buf_add_go_intent(buf, (p2p->go_intent << 1) | tie_breaker); 281 p2p_buf_add_config_timeout(buf, p2p->go_timeout, p2p->client_timeout); 282 if (peer && peer->go_state == REMOTE_GO) { 283 p2p_dbg(p2p, "Omit Operating Channel attribute"); 284 } else { 285 p2p_buf_add_operating_channel(buf, p2p->cfg->country, 286 p2p->op_reg_class, 287 p2p->op_channel); 288 } 289 p2p_buf_add_intended_addr(buf, p2p->intended_addr); 290 if (status || peer == NULL) { 291 p2p_buf_add_channel_list(buf, p2p->cfg->country, 292 &p2p->channels); 293 } else if (peer->go_state == REMOTE_GO) { 294 p2p_buf_add_channel_list(buf, p2p->cfg->country, 295 &p2p->channels); 296 } else { 297 struct p2p_channels res; 298 p2p_channels_intersect(&p2p->channels, &peer->channels, 299 &res); 300 p2p_buf_add_channel_list(buf, p2p->cfg->country, &res); 301 } 302 p2p_buf_add_device_info(buf, p2p, peer); 303 if (peer && peer->go_state == LOCAL_GO) { 304 p2p_buf_add_group_id(buf, p2p->cfg->dev_addr, p2p->ssid, 305 p2p->ssid_len); 306 } 307 p2p_buf_update_ie_hdr(buf, len); 308 309 /* WPS IE with Device Password ID attribute */ 310 p2p_build_wps_ie(p2p, buf, 311 p2p_wps_method_pw_id(peer ? peer->wps_method : 312 WPS_NOT_READY), 0); 313 314#ifdef CONFIG_WIFI_DISPLAY 315 if (p2p->wfd_ie_go_neg) 316 wpabuf_put_buf(buf, p2p->wfd_ie_go_neg); 317#endif /* CONFIG_WIFI_DISPLAY */ 318 319 320 return buf; 321} 322 323 324/** 325 * p2p_reselect_channel - Re-select operating channel based on peer information 326 * @p2p: P2P module context from p2p_init() 327 * @intersection: Support channel list intersection from local and peer 328 * 329 * This function is used to re-select the best channel after having received 330 * information from the peer to allow supported channel lists to be intersected. 331 * This can be used to improve initial channel selection done in 332 * p2p_prepare_channel() prior to the start of GO Negotiation. In addition, this 333 * can be used for Invitation case. 334 */ 335void p2p_reselect_channel(struct p2p_data *p2p, 336 struct p2p_channels *intersection) 337{ 338 struct p2p_reg_class *cl; 339 int freq; 340 u8 op_reg_class, op_channel; 341 unsigned int i; 342 343 if (p2p->own_freq_preference > 0 && 344 p2p_freq_to_channel(p2p->own_freq_preference, 345 &op_reg_class, &op_channel) == 0 && 346 p2p_channels_includes(intersection, op_reg_class, op_channel)) { 347 p2p_dbg(p2p, "Pick own channel preference (reg_class %u channel %u) from intersection", 348 op_reg_class, op_channel); 349 p2p->op_reg_class = op_reg_class; 350 p2p->op_channel = op_channel; 351 return; 352 } 353 354 if (p2p->best_freq_overall > 0 && 355 p2p_freq_to_channel(p2p->best_freq_overall, 356 &op_reg_class, &op_channel) == 0 && 357 p2p_channels_includes(intersection, op_reg_class, op_channel)) { 358 p2p_dbg(p2p, "Pick best overall channel (reg_class %u channel %u) from intersection", 359 op_reg_class, op_channel); 360 p2p->op_reg_class = op_reg_class; 361 p2p->op_channel = op_channel; 362 return; 363 } 364 365 /* First, try to pick the best channel from another band */ 366 freq = p2p_channel_to_freq(p2p->op_reg_class, p2p->op_channel); 367 if (freq >= 2400 && freq < 2500 && p2p->best_freq_5 > 0 && 368 !p2p_channels_includes(intersection, p2p->op_reg_class, 369 p2p->op_channel) && 370 p2p_freq_to_channel(p2p->best_freq_5, 371 &op_reg_class, &op_channel) == 0 && 372 p2p_channels_includes(intersection, op_reg_class, op_channel)) { 373 p2p_dbg(p2p, "Pick best 5 GHz channel (reg_class %u channel %u) from intersection", 374 op_reg_class, op_channel); 375 p2p->op_reg_class = op_reg_class; 376 p2p->op_channel = op_channel; 377 return; 378 } 379 380 if (freq >= 4900 && freq < 6000 && p2p->best_freq_24 > 0 && 381 !p2p_channels_includes(intersection, p2p->op_reg_class, 382 p2p->op_channel) && 383 p2p_freq_to_channel(p2p->best_freq_24, 384 &op_reg_class, &op_channel) == 0 && 385 p2p_channels_includes(intersection, op_reg_class, op_channel)) { 386 p2p_dbg(p2p, "Pick best 2.4 GHz channel (reg_class %u channel %u) from intersection", 387 op_reg_class, op_channel); 388 p2p->op_reg_class = op_reg_class; 389 p2p->op_channel = op_channel; 390 return; 391 } 392 393 /* Select channel with highest preference if the peer supports it */ 394 for (i = 0; p2p->cfg->pref_chan && i < p2p->cfg->num_pref_chan; i++) { 395 if (p2p_channels_includes(intersection, 396 p2p->cfg->pref_chan[i].op_class, 397 p2p->cfg->pref_chan[i].chan)) { 398 p2p->op_reg_class = p2p->cfg->pref_chan[i].op_class; 399 p2p->op_channel = p2p->cfg->pref_chan[i].chan; 400 p2p_dbg(p2p, "Pick highest preferred channel (op_class %u channel %u) from intersection", 401 p2p->op_reg_class, p2p->op_channel); 402 return; 403 } 404 } 405 406 /* Try a channel where we might be able to use HT40 */ 407 for (i = 0; i < intersection->reg_classes; i++) { 408 struct p2p_reg_class *c = &intersection->reg_class[i]; 409 if (c->reg_class == 116 || c->reg_class == 117 || 410 c->reg_class == 126 || c->reg_class == 127) { 411 p2p_dbg(p2p, "Pick possible HT40 channel (reg_class %u channel %u) from intersection", 412 c->reg_class, c->channel[0]); 413 p2p->op_reg_class = c->reg_class; 414 p2p->op_channel = c->channel[0]; 415 return; 416 } 417 } 418 419 /* Prefer a 5 GHz channel */ 420 for (i = 0; i < intersection->reg_classes; i++) { 421 struct p2p_reg_class *c = &intersection->reg_class[i]; 422 if ((c->reg_class == 115 || c->reg_class == 124) && 423 c->channels) { 424 unsigned int r; 425 426 /* 427 * Pick one of the available channels in the operating 428 * class at random. 429 */ 430 os_get_random((u8 *) &r, sizeof(r)); 431 r %= c->channels; 432 p2p_dbg(p2p, "Pick possible 5 GHz channel (op_class %u channel %u) from intersection", 433 c->reg_class, c->channel[r]); 434 p2p->op_reg_class = c->reg_class; 435 p2p->op_channel = c->channel[r]; 436 return; 437 } 438 } 439 440 /* 441 * Try to see if the original channel is in the intersection. If 442 * so, no need to change anything, as it already contains some 443 * randomness. 444 */ 445 if (p2p_channels_includes(intersection, p2p->op_reg_class, 446 p2p->op_channel)) { 447 p2p_dbg(p2p, "Using original operating class and channel (op_class %u channel %u) from intersection", 448 p2p->op_reg_class, p2p->op_channel); 449 return; 450 } 451 452 /* 453 * Fall back to whatever is included in the channel intersection since 454 * no better options seems to be available. 455 */ 456 cl = &intersection->reg_class[0]; 457 p2p_dbg(p2p, "Pick another channel (reg_class %u channel %u) from intersection", 458 cl->reg_class, cl->channel[0]); 459 p2p->op_reg_class = cl->reg_class; 460 p2p->op_channel = cl->channel[0]; 461} 462 463 464static int p2p_go_select_channel(struct p2p_data *p2p, struct p2p_device *dev, 465 u8 *status) 466{ 467 struct p2p_channels intersection; 468 size_t i; 469 470 p2p_channels_intersect(&p2p->channels, &dev->channels, &intersection); 471 if (intersection.reg_classes == 0 || 472 intersection.reg_class[0].channels == 0) { 473 *status = P2P_SC_FAIL_NO_COMMON_CHANNELS; 474 p2p_dbg(p2p, "No common channels found"); 475 return -1; 476 } 477 478 for (i = 0; i < intersection.reg_classes; i++) { 479 struct p2p_reg_class *c; 480 c = &intersection.reg_class[i]; 481 p2p_dbg(p2p, "reg_class %u", c->reg_class); 482 wpa_hexdump(MSG_DEBUG, "P2P: channels", 483 c->channel, c->channels); 484 } 485 486 if (!p2p_channels_includes(&intersection, p2p->op_reg_class, 487 p2p->op_channel)) { 488 if (dev->flags & P2P_DEV_FORCE_FREQ) { 489 *status = P2P_SC_FAIL_NO_COMMON_CHANNELS; 490 p2p_dbg(p2p, "Peer does not support the forced channel"); 491 return -1; 492 } 493 494 p2p_dbg(p2p, "Selected operating channel (op_class %u channel %u) not acceptable to the peer", 495 p2p->op_reg_class, p2p->op_channel); 496 p2p_reselect_channel(p2p, &intersection); 497 } else if (!(dev->flags & P2P_DEV_FORCE_FREQ) && 498 !p2p->cfg->cfg_op_channel) { 499 p2p_dbg(p2p, "Try to optimize channel selection with peer information received; previously selected op_class %u channel %u", 500 p2p->op_reg_class, p2p->op_channel); 501 p2p_reselect_channel(p2p, &intersection); 502 } 503 504 if (!p2p->ssid_set) { 505 p2p_build_ssid(p2p, p2p->ssid, &p2p->ssid_len); 506 p2p->ssid_set = 1; 507 } 508 509 return 0; 510} 511 512 513void p2p_process_go_neg_req(struct p2p_data *p2p, const u8 *sa, 514 const u8 *data, size_t len, int rx_freq) 515{ 516 struct p2p_device *dev = NULL; 517 struct wpabuf *resp; 518 struct p2p_message msg; 519 u8 status = P2P_SC_FAIL_INVALID_PARAMS; 520 int tie_breaker = 0; 521 int freq; 522 523 p2p_dbg(p2p, "Received GO Negotiation Request from " MACSTR "(freq=%d)", 524 MAC2STR(sa), rx_freq); 525 526 if (p2p_parse(data, len, &msg)) 527 return; 528 529 if (!msg.capability) { 530 p2p_dbg(p2p, "Mandatory Capability attribute missing from GO Negotiation Request"); 531#ifdef CONFIG_P2P_STRICT 532 goto fail; 533#endif /* CONFIG_P2P_STRICT */ 534 } 535 536 if (msg.go_intent) 537 tie_breaker = *msg.go_intent & 0x01; 538 else { 539 p2p_dbg(p2p, "Mandatory GO Intent attribute missing from GO Negotiation Request"); 540#ifdef CONFIG_P2P_STRICT 541 goto fail; 542#endif /* CONFIG_P2P_STRICT */ 543 } 544 545 if (!msg.config_timeout) { 546 p2p_dbg(p2p, "Mandatory Configuration Timeout attribute missing from GO Negotiation Request"); 547#ifdef CONFIG_P2P_STRICT 548 goto fail; 549#endif /* CONFIG_P2P_STRICT */ 550 } 551 552 if (!msg.listen_channel) { 553 p2p_dbg(p2p, "No Listen Channel attribute received"); 554 goto fail; 555 } 556 if (!msg.operating_channel) { 557 p2p_dbg(p2p, "No Operating Channel attribute received"); 558 goto fail; 559 } 560 if (!msg.channel_list) { 561 p2p_dbg(p2p, "No Channel List attribute received"); 562 goto fail; 563 } 564 if (!msg.intended_addr) { 565 p2p_dbg(p2p, "No Intended P2P Interface Address attribute received"); 566 goto fail; 567 } 568 if (!msg.p2p_device_info) { 569 p2p_dbg(p2p, "No P2P Device Info attribute received"); 570 goto fail; 571 } 572 573 if (os_memcmp(msg.p2p_device_addr, sa, ETH_ALEN) != 0) { 574 p2p_dbg(p2p, "Unexpected GO Negotiation Request SA=" MACSTR 575 " != dev_addr=" MACSTR, 576 MAC2STR(sa), MAC2STR(msg.p2p_device_addr)); 577 goto fail; 578 } 579 580 dev = p2p_get_device(p2p, sa); 581 582 if (msg.status && *msg.status) { 583 p2p_dbg(p2p, "Unexpected Status attribute (%d) in GO Negotiation Request", 584 *msg.status); 585 goto fail; 586 } 587 588 if (dev == NULL) 589 dev = p2p_add_dev_from_go_neg_req(p2p, sa, &msg); 590 else if (dev->flags & P2P_DEV_PROBE_REQ_ONLY) 591 p2p_add_dev_info(p2p, sa, dev, &msg); 592 if (dev && dev->flags & P2P_DEV_USER_REJECTED) { 593 p2p_dbg(p2p, "User has rejected this peer"); 594 status = P2P_SC_FAIL_REJECTED_BY_USER; 595 } else if (dev == NULL || dev->wps_method == WPS_NOT_READY) { 596 p2p_dbg(p2p, "Not ready for GO negotiation with " MACSTR, 597 MAC2STR(sa)); 598 status = P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE; 599 p2p->cfg->go_neg_req_rx(p2p->cfg->cb_ctx, sa, 600 msg.dev_password_id); 601 } else if (p2p->go_neg_peer && p2p->go_neg_peer != dev) { 602 p2p_dbg(p2p, "Already in Group Formation with another peer"); 603 status = P2P_SC_FAIL_UNABLE_TO_ACCOMMODATE; 604 } else { 605 int go; 606 607 if (!p2p->go_neg_peer) { 608 p2p_dbg(p2p, "Starting GO Negotiation with previously authorized peer"); 609 if (!(dev->flags & P2P_DEV_FORCE_FREQ)) { 610 p2p_dbg(p2p, "Use default channel settings"); 611 p2p->op_reg_class = p2p->cfg->op_reg_class; 612 p2p->op_channel = p2p->cfg->op_channel; 613 os_memcpy(&p2p->channels, &p2p->cfg->channels, 614 sizeof(struct p2p_channels)); 615 } else { 616 p2p_dbg(p2p, "Use previously configured forced channel settings"); 617 } 618 } 619 620 dev->flags &= ~P2P_DEV_NOT_YET_READY; 621 622 if (!msg.go_intent) { 623 p2p_dbg(p2p, "No GO Intent attribute received"); 624 goto fail; 625 } 626 if ((*msg.go_intent >> 1) > P2P_MAX_GO_INTENT) { 627 p2p_dbg(p2p, "Invalid GO Intent value (%u) received", 628 *msg.go_intent >> 1); 629 goto fail; 630 } 631 632 if (dev->go_neg_req_sent && 633 os_memcmp(sa, p2p->cfg->dev_addr, ETH_ALEN) > 0) { 634 p2p_dbg(p2p, "Do not reply since peer has higher address and GO Neg Request already sent"); 635 p2p_parse_free(&msg); 636 return; 637 } 638 639 go = p2p_go_det(p2p->go_intent, *msg.go_intent); 640 if (go < 0) { 641 p2p_dbg(p2p, "Incompatible GO Intent"); 642 status = P2P_SC_FAIL_BOTH_GO_INTENT_15; 643 goto fail; 644 } 645 646 if (p2p_peer_channels(p2p, dev, msg.channel_list, 647 msg.channel_list_len) < 0) { 648 p2p_dbg(p2p, "No common channels found"); 649 status = P2P_SC_FAIL_NO_COMMON_CHANNELS; 650 goto fail; 651 } 652 653 switch (msg.dev_password_id) { 654 case DEV_PW_REGISTRAR_SPECIFIED: 655 p2p_dbg(p2p, "PIN from peer Display"); 656 if (dev->wps_method != WPS_PIN_KEYPAD) { 657 p2p_dbg(p2p, "We have wps_method=%s -> incompatible", 658 p2p_wps_method_str(dev->wps_method)); 659 status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD; 660 goto fail; 661 } 662 break; 663 case DEV_PW_USER_SPECIFIED: 664 p2p_dbg(p2p, "Peer entered PIN on Keypad"); 665 if (dev->wps_method != WPS_PIN_DISPLAY) { 666 p2p_dbg(p2p, "We have wps_method=%s -> incompatible", 667 p2p_wps_method_str(dev->wps_method)); 668 status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD; 669 goto fail; 670 } 671 break; 672 case DEV_PW_PUSHBUTTON: 673 p2p_dbg(p2p, "Peer using pushbutton"); 674 if (dev->wps_method != WPS_PBC) { 675 p2p_dbg(p2p, "We have wps_method=%s -> incompatible", 676 p2p_wps_method_str(dev->wps_method)); 677 status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD; 678 goto fail; 679 } 680 break; 681 default: 682 p2p_dbg(p2p, "Unsupported Device Password ID %d", 683 msg.dev_password_id); 684 status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD; 685 goto fail; 686 } 687 688 if (go && p2p_go_select_channel(p2p, dev, &status) < 0) 689 goto fail; 690 691 dev->go_state = go ? LOCAL_GO : REMOTE_GO; 692 dev->oper_freq = p2p_channel_to_freq(msg.operating_channel[3], 693 msg.operating_channel[4]); 694 p2p_dbg(p2p, "Peer operating channel preference: %d MHz", 695 dev->oper_freq); 696 697 if (msg.config_timeout) { 698 dev->go_timeout = msg.config_timeout[0]; 699 dev->client_timeout = msg.config_timeout[1]; 700 } 701 702 p2p_dbg(p2p, "GO Negotiation with " MACSTR, MAC2STR(sa)); 703 if (p2p->state != P2P_IDLE) 704 p2p_stop_find_for_freq(p2p, rx_freq); 705 p2p_set_state(p2p, P2P_GO_NEG); 706 p2p_clear_timeout(p2p); 707 dev->dialog_token = msg.dialog_token; 708 os_memcpy(dev->intended_addr, msg.intended_addr, ETH_ALEN); 709 p2p->go_neg_peer = dev; 710 status = P2P_SC_SUCCESS; 711 } 712 713fail: 714 if (dev) 715 dev->status = status; 716 resp = p2p_build_go_neg_resp(p2p, dev, msg.dialog_token, status, 717 !tie_breaker); 718 p2p_parse_free(&msg); 719 if (resp == NULL) 720 return; 721 p2p_dbg(p2p, "Sending GO Negotiation Response"); 722 if (rx_freq > 0) 723 freq = rx_freq; 724 else 725 freq = p2p_channel_to_freq(p2p->cfg->reg_class, 726 p2p->cfg->channel); 727 if (freq < 0) { 728 p2p_dbg(p2p, "Unknown regulatory class/channel"); 729 wpabuf_free(resp); 730 return; 731 } 732 if (status == P2P_SC_SUCCESS) { 733 p2p->pending_action_state = P2P_PENDING_GO_NEG_RESPONSE; 734 dev->flags |= P2P_DEV_WAIT_GO_NEG_CONFIRM; 735 if (os_memcmp(sa, p2p->cfg->dev_addr, ETH_ALEN) < 0) { 736 /* 737 * Peer has smaller address, so the GO Negotiation 738 * Response from us is expected to complete 739 * negotiation. Ignore a GO Negotiation Response from 740 * the peer if it happens to be received after this 741 * point due to a race condition in GO Negotiation 742 * Request transmission and processing. 743 */ 744 dev->flags &= ~P2P_DEV_WAIT_GO_NEG_RESPONSE; 745 } 746 } else 747 p2p->pending_action_state = 748 P2P_PENDING_GO_NEG_RESPONSE_FAILURE; 749 if (p2p_send_action(p2p, freq, sa, p2p->cfg->dev_addr, 750 p2p->cfg->dev_addr, 751 wpabuf_head(resp), wpabuf_len(resp), 500) < 0) { 752 p2p_dbg(p2p, "Failed to send Action frame"); 753 } 754 755 wpabuf_free(resp); 756} 757 758 759static struct wpabuf * p2p_build_go_neg_conf(struct p2p_data *p2p, 760 struct p2p_device *peer, 761 u8 dialog_token, u8 status, 762 const u8 *resp_chan, int go) 763{ 764 struct wpabuf *buf; 765 u8 *len; 766 struct p2p_channels res; 767 u8 group_capab; 768 size_t extra = 0; 769 770 p2p_dbg(p2p, "Building GO Negotiation Confirm"); 771 772#ifdef CONFIG_WIFI_DISPLAY 773 if (p2p->wfd_ie_go_neg) 774 extra = wpabuf_len(p2p->wfd_ie_go_neg); 775#endif /* CONFIG_WIFI_DISPLAY */ 776 777 buf = wpabuf_alloc(1000 + extra); 778 if (buf == NULL) 779 return NULL; 780 781 p2p_buf_add_public_action_hdr(buf, P2P_GO_NEG_CONF, dialog_token); 782 783 len = p2p_buf_add_ie_hdr(buf); 784 p2p_buf_add_status(buf, status); 785 group_capab = 0; 786 if (peer->go_state == LOCAL_GO) { 787 if (peer->flags & P2P_DEV_PREFER_PERSISTENT_GROUP) { 788 group_capab |= P2P_GROUP_CAPAB_PERSISTENT_GROUP; 789 if (peer->flags & P2P_DEV_PREFER_PERSISTENT_RECONN) 790 group_capab |= 791 P2P_GROUP_CAPAB_PERSISTENT_RECONN; 792 } 793 if (p2p->cross_connect) 794 group_capab |= P2P_GROUP_CAPAB_CROSS_CONN; 795 if (p2p->cfg->p2p_intra_bss) 796 group_capab |= P2P_GROUP_CAPAB_INTRA_BSS_DIST; 797 } 798 p2p_buf_add_capability(buf, p2p->dev_capab & 799 ~P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY, 800 group_capab); 801 if (go || resp_chan == NULL) 802 p2p_buf_add_operating_channel(buf, p2p->cfg->country, 803 p2p->op_reg_class, 804 p2p->op_channel); 805 else 806 p2p_buf_add_operating_channel(buf, (const char *) resp_chan, 807 resp_chan[3], resp_chan[4]); 808 p2p_channels_intersect(&p2p->channels, &peer->channels, &res); 809 p2p_buf_add_channel_list(buf, p2p->cfg->country, &res); 810 if (go) { 811 p2p_buf_add_group_id(buf, p2p->cfg->dev_addr, p2p->ssid, 812 p2p->ssid_len); 813 } 814 p2p_buf_update_ie_hdr(buf, len); 815 816#ifdef CONFIG_WIFI_DISPLAY 817 if (p2p->wfd_ie_go_neg) 818 wpabuf_put_buf(buf, p2p->wfd_ie_go_neg); 819#endif /* CONFIG_WIFI_DISPLAY */ 820 821 return buf; 822} 823 824 825void p2p_process_go_neg_resp(struct p2p_data *p2p, const u8 *sa, 826 const u8 *data, size_t len, int rx_freq) 827{ 828 struct p2p_device *dev; 829 struct wpabuf *conf; 830 int go = -1; 831 struct p2p_message msg; 832 u8 status = P2P_SC_SUCCESS; 833 int freq; 834 835 p2p_dbg(p2p, "Received GO Negotiation Response from " MACSTR 836 " (freq=%d)", MAC2STR(sa), rx_freq); 837 dev = p2p_get_device(p2p, sa); 838 if (dev == NULL || dev->wps_method == WPS_NOT_READY || 839 dev != p2p->go_neg_peer) { 840 p2p_dbg(p2p, "Not ready for GO negotiation with " MACSTR, 841 MAC2STR(sa)); 842 return; 843 } 844 845 if (p2p_parse(data, len, &msg)) 846 return; 847 848 if (!(dev->flags & P2P_DEV_WAIT_GO_NEG_RESPONSE)) { 849 p2p_dbg(p2p, "Was not expecting GO Negotiation Response - ignore"); 850 p2p_parse_free(&msg); 851 return; 852 } 853 dev->flags &= ~P2P_DEV_WAIT_GO_NEG_RESPONSE; 854 855 if (msg.dialog_token != dev->dialog_token) { 856 p2p_dbg(p2p, "Unexpected Dialog Token %u (expected %u)", 857 msg.dialog_token, dev->dialog_token); 858 p2p_parse_free(&msg); 859 return; 860 } 861 862 if (!msg.status) { 863 p2p_dbg(p2p, "No Status attribute received"); 864 status = P2P_SC_FAIL_INVALID_PARAMS; 865 goto fail; 866 } 867 if (*msg.status) { 868 p2p_dbg(p2p, "GO Negotiation rejected: status %d", *msg.status); 869 dev->go_neg_req_sent = 0; 870 if (*msg.status == P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE) { 871 p2p_dbg(p2p, "Wait for the peer to become ready for GO Negotiation"); 872 dev->flags |= P2P_DEV_NOT_YET_READY; 873 dev->wait_count = 0; 874 p2p_set_state(p2p, P2P_WAIT_PEER_IDLE); 875 p2p_set_timeout(p2p, 0, 0); 876 } else { 877 p2p_dbg(p2p, "Stop GO Negotiation attempt"); 878 p2p_go_neg_failed(p2p, dev, *msg.status); 879 } 880 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); 881 p2p_parse_free(&msg); 882 return; 883 } 884 885 if (!msg.capability) { 886 p2p_dbg(p2p, "Mandatory Capability attribute missing from GO Negotiation Response"); 887#ifdef CONFIG_P2P_STRICT 888 status = P2P_SC_FAIL_INVALID_PARAMS; 889 goto fail; 890#endif /* CONFIG_P2P_STRICT */ 891 } 892 893 if (!msg.p2p_device_info) { 894 p2p_dbg(p2p, "Mandatory P2P Device Info attribute missing from GO Negotiation Response"); 895#ifdef CONFIG_P2P_STRICT 896 status = P2P_SC_FAIL_INVALID_PARAMS; 897 goto fail; 898#endif /* CONFIG_P2P_STRICT */ 899 } 900 901 if (!msg.intended_addr) { 902 p2p_dbg(p2p, "No Intended P2P Interface Address attribute received"); 903 status = P2P_SC_FAIL_INVALID_PARAMS; 904 goto fail; 905 } 906 907 if (!msg.go_intent) { 908 p2p_dbg(p2p, "No GO Intent attribute received"); 909 status = P2P_SC_FAIL_INVALID_PARAMS; 910 goto fail; 911 } 912 if ((*msg.go_intent >> 1) > P2P_MAX_GO_INTENT) { 913 p2p_dbg(p2p, "Invalid GO Intent value (%u) received", 914 *msg.go_intent >> 1); 915 status = P2P_SC_FAIL_INVALID_PARAMS; 916 goto fail; 917 } 918 919 go = p2p_go_det(p2p->go_intent, *msg.go_intent); 920 if (go < 0) { 921 p2p_dbg(p2p, "Incompatible GO Intent"); 922 status = P2P_SC_FAIL_INCOMPATIBLE_PARAMS; 923 goto fail; 924 } 925 926 if (!go && msg.group_id) { 927 /* Store SSID for Provisioning step */ 928 p2p->ssid_len = msg.group_id_len - ETH_ALEN; 929 os_memcpy(p2p->ssid, msg.group_id + ETH_ALEN, p2p->ssid_len); 930 } else if (!go) { 931 p2p_dbg(p2p, "Mandatory P2P Group ID attribute missing from GO Negotiation Response"); 932 p2p->ssid_len = 0; 933 status = P2P_SC_FAIL_INVALID_PARAMS; 934 goto fail; 935 } 936 937 if (!msg.config_timeout) { 938 p2p_dbg(p2p, "Mandatory Configuration Timeout attribute missing from GO Negotiation Response"); 939#ifdef CONFIG_P2P_STRICT 940 status = P2P_SC_FAIL_INVALID_PARAMS; 941 goto fail; 942#endif /* CONFIG_P2P_STRICT */ 943 } else { 944 dev->go_timeout = msg.config_timeout[0]; 945 dev->client_timeout = msg.config_timeout[1]; 946 } 947 948 if (!msg.operating_channel && !go) { 949 /* 950 * Note: P2P Client may omit Operating Channel attribute to 951 * indicate it does not have a preference. 952 */ 953 p2p_dbg(p2p, "No Operating Channel attribute received"); 954 status = P2P_SC_FAIL_INVALID_PARAMS; 955 goto fail; 956 } 957 if (!msg.channel_list) { 958 p2p_dbg(p2p, "No Channel List attribute received"); 959 status = P2P_SC_FAIL_INVALID_PARAMS; 960 goto fail; 961 } 962 963 if (p2p_peer_channels(p2p, dev, msg.channel_list, 964 msg.channel_list_len) < 0) { 965 p2p_dbg(p2p, "No common channels found"); 966 status = P2P_SC_FAIL_NO_COMMON_CHANNELS; 967 goto fail; 968 } 969 970 if (msg.operating_channel) { 971 dev->oper_freq = p2p_channel_to_freq(msg.operating_channel[3], 972 msg.operating_channel[4]); 973 p2p_dbg(p2p, "Peer operating channel preference: %d MHz", 974 dev->oper_freq); 975 } else 976 dev->oper_freq = 0; 977 978 switch (msg.dev_password_id) { 979 case DEV_PW_REGISTRAR_SPECIFIED: 980 p2p_dbg(p2p, "PIN from peer Display"); 981 if (dev->wps_method != WPS_PIN_KEYPAD) { 982 p2p_dbg(p2p, "We have wps_method=%s -> incompatible", 983 p2p_wps_method_str(dev->wps_method)); 984 status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD; 985 goto fail; 986 } 987 break; 988 case DEV_PW_USER_SPECIFIED: 989 p2p_dbg(p2p, "Peer entered PIN on Keypad"); 990 if (dev->wps_method != WPS_PIN_DISPLAY) { 991 p2p_dbg(p2p, "We have wps_method=%s -> incompatible", 992 p2p_wps_method_str(dev->wps_method)); 993 status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD; 994 goto fail; 995 } 996 break; 997 case DEV_PW_PUSHBUTTON: 998 p2p_dbg(p2p, "Peer using pushbutton"); 999 if (dev->wps_method != WPS_PBC) { 1000 p2p_dbg(p2p, "We have wps_method=%s -> incompatible", 1001 p2p_wps_method_str(dev->wps_method)); 1002 status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD; 1003 goto fail; 1004 } 1005 break; 1006 default: 1007 p2p_dbg(p2p, "Unsupported Device Password ID %d", 1008 msg.dev_password_id); 1009 status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD; 1010 goto fail; 1011 } 1012 1013 if (go && p2p_go_select_channel(p2p, dev, &status) < 0) 1014 goto fail; 1015 1016 p2p_set_state(p2p, P2P_GO_NEG); 1017 p2p_clear_timeout(p2p); 1018 1019 p2p_dbg(p2p, "GO Negotiation with " MACSTR, MAC2STR(sa)); 1020 os_memcpy(dev->intended_addr, msg.intended_addr, ETH_ALEN); 1021 1022fail: 1023 conf = p2p_build_go_neg_conf(p2p, dev, msg.dialog_token, status, 1024 msg.operating_channel, go); 1025 p2p_parse_free(&msg); 1026 if (conf == NULL) 1027 return; 1028 p2p_dbg(p2p, "Sending GO Negotiation Confirm"); 1029 if (status == P2P_SC_SUCCESS) { 1030 p2p->pending_action_state = P2P_PENDING_GO_NEG_CONFIRM; 1031 dev->go_state = go ? LOCAL_GO : REMOTE_GO; 1032 } else 1033 p2p->pending_action_state = P2P_NO_PENDING_ACTION; 1034 if (rx_freq > 0) 1035 freq = rx_freq; 1036 else 1037 freq = dev->listen_freq; 1038 if (p2p_send_action(p2p, freq, sa, p2p->cfg->dev_addr, sa, 1039 wpabuf_head(conf), wpabuf_len(conf), 0) < 0) { 1040 p2p_dbg(p2p, "Failed to send Action frame"); 1041 p2p_go_neg_failed(p2p, dev, -1); 1042 } 1043 wpabuf_free(conf); 1044 if (status != P2P_SC_SUCCESS) { 1045 p2p_dbg(p2p, "GO Negotiation failed"); 1046 p2p_go_neg_failed(p2p, dev, status); 1047 } 1048} 1049 1050 1051void p2p_process_go_neg_conf(struct p2p_data *p2p, const u8 *sa, 1052 const u8 *data, size_t len) 1053{ 1054 struct p2p_device *dev; 1055 struct p2p_message msg; 1056 1057 p2p_dbg(p2p, "Received GO Negotiation Confirm from " MACSTR, 1058 MAC2STR(sa)); 1059 dev = p2p_get_device(p2p, sa); 1060 if (dev == NULL || dev->wps_method == WPS_NOT_READY || 1061 dev != p2p->go_neg_peer) { 1062 p2p_dbg(p2p, "Not ready for GO negotiation with " MACSTR, 1063 MAC2STR(sa)); 1064 return; 1065 } 1066 1067 if (p2p->pending_action_state == P2P_PENDING_GO_NEG_RESPONSE) { 1068 p2p_dbg(p2p, "Stopped waiting for TX status on GO Negotiation Response since we already received Confirmation"); 1069 p2p->pending_action_state = P2P_NO_PENDING_ACTION; 1070 } 1071 1072 if (p2p_parse(data, len, &msg)) 1073 return; 1074 1075 if (!(dev->flags & P2P_DEV_WAIT_GO_NEG_CONFIRM)) { 1076 p2p_dbg(p2p, "Was not expecting GO Negotiation Confirm - ignore"); 1077 return; 1078 } 1079 dev->flags &= ~P2P_DEV_WAIT_GO_NEG_CONFIRM; 1080 1081 if (msg.dialog_token != dev->dialog_token) { 1082 p2p_dbg(p2p, "Unexpected Dialog Token %u (expected %u)", 1083 msg.dialog_token, dev->dialog_token); 1084 p2p_parse_free(&msg); 1085 return; 1086 } 1087 1088 if (!msg.status) { 1089 p2p_dbg(p2p, "No Status attribute received"); 1090 p2p_parse_free(&msg); 1091 return; 1092 } 1093 if (*msg.status) { 1094 p2p_dbg(p2p, "GO Negotiation rejected: status %d", *msg.status); 1095 p2p_go_neg_failed(p2p, dev, *msg.status); 1096 p2p_parse_free(&msg); 1097 return; 1098 } 1099 1100 if (dev->go_state == REMOTE_GO && msg.group_id) { 1101 /* Store SSID for Provisioning step */ 1102 p2p->ssid_len = msg.group_id_len - ETH_ALEN; 1103 os_memcpy(p2p->ssid, msg.group_id + ETH_ALEN, p2p->ssid_len); 1104 } else if (dev->go_state == REMOTE_GO) { 1105 p2p_dbg(p2p, "Mandatory P2P Group ID attribute missing from GO Negotiation Confirmation"); 1106 p2p->ssid_len = 0; 1107 p2p_go_neg_failed(p2p, dev, P2P_SC_FAIL_INVALID_PARAMS); 1108 p2p_parse_free(&msg); 1109 return; 1110 } 1111 1112 if (!msg.operating_channel) { 1113 p2p_dbg(p2p, "Mandatory Operating Channel attribute missing from GO Negotiation Confirmation"); 1114#ifdef CONFIG_P2P_STRICT 1115 p2p_parse_free(&msg); 1116 return; 1117#endif /* CONFIG_P2P_STRICT */ 1118 } else if (dev->go_state == REMOTE_GO) { 1119 int oper_freq = p2p_channel_to_freq(msg.operating_channel[3], 1120 msg.operating_channel[4]); 1121 if (oper_freq != dev->oper_freq) { 1122 p2p_dbg(p2p, "Updated peer (GO) operating channel preference from %d MHz to %d MHz", 1123 dev->oper_freq, oper_freq); 1124 dev->oper_freq = oper_freq; 1125 } 1126 } 1127 1128#ifdef ANDROID_P2P 1129 if (msg.operating_channel) { 1130 dev->oper_freq = p2p_channel_to_freq(msg.operating_channel[3], 1131 msg.operating_channel[4]); 1132 p2p_dbg(p2p, "P2P: Peer operating channel preference: %d MHz", 1133 dev->oper_freq); 1134 } else 1135 dev->oper_freq = 0; 1136#endif 1137 1138 if (!msg.channel_list) { 1139 p2p_dbg(p2p, "Mandatory Operating Channel attribute missing from GO Negotiation Confirmation"); 1140#ifdef CONFIG_P2P_STRICT 1141 p2p_parse_free(&msg); 1142 return; 1143#endif /* CONFIG_P2P_STRICT */ 1144 } 1145 1146 p2p_parse_free(&msg); 1147 1148 if (dev->go_state == UNKNOWN_GO) { 1149 /* 1150 * This should not happen since GO negotiation has already 1151 * been completed. 1152 */ 1153 p2p_dbg(p2p, "Unexpected GO Neg state - do not know which end becomes GO"); 1154 return; 1155 } 1156 1157 /* 1158 * The peer could have missed our ctrl::ack frame for GO Negotiation 1159 * Confirm and continue retransmitting the frame. To reduce the 1160 * likelihood of the peer not getting successful TX status for the 1161 * GO Negotiation Confirm frame, wait a short time here before starting 1162 * the group so that we will remain on the current channel to 1163 * acknowledge any possible retransmission from the peer. 1164 */ 1165 p2p_dbg(p2p, "20 ms wait on current channel before starting group"); 1166 os_sleep(0, 20000); 1167 1168 p2p_go_complete(p2p, dev); 1169} 1170