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