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