Home | History | Annotate | Download | only in p2p

Lines Matching refs:p2p

2  * Wi-Fi Direct - P2P Invitation procedure
14 #include "p2p.h"
17 static struct wpabuf * p2p_build_invitation_req(struct p2p_data *p2p,
27 struct wpabuf *wfd_ie = p2p->wfd_ie_invitation;
28 if (wfd_ie && p2p->inv_role == P2P_INVITE_ROLE_ACTIVE_GO) {
30 for (i = 0; i < p2p->num_groups; i++) {
31 struct p2p_group *g = p2p->groups[i];
34 p2p->inv_bssid, ETH_ALEN) != 0)
58 if (p2p->inv_role == P2P_INVITE_ROLE_ACTIVE_GO || !p2p->inv_persistent)
61 p2p_buf_add_config_timeout(buf, p2p->go_timeout,
62 p2p->client_timeout);
63 p2p_buf_add_invitation_flags(buf, p2p->inv_persistent ?
65 if (p2p->inv_role != P2P_INVITE_ROLE_CLIENT ||
67 p2p_buf_add_operating_channel(buf, p2p->cfg->country,
68 p2p->op_reg_class,
69 p2p->op_channel);
70 if (p2p->inv_bssid_set)
71 p2p_buf_add_group_bssid(buf, p2p->inv_bssid);
72 p2p_buf_add_channel_list(buf, p2p->cfg->country, &p2p->channels);
75 else if (p2p->inv_role == P2P_INVITE_ROLE_CLIENT)
78 dev_addr = p2p->cfg->dev_addr;
79 p2p_buf_add_group_id(buf, dev_addr, p2p->inv_ssid, p2p->inv_ssid_len);
80 p2p_buf_add_device_info(buf, p2p, peer);
92 static struct wpabuf * p2p_build_invitation_resp(struct p2p_data *p2p,
104 struct wpabuf *wfd_ie = p2p->wfd_ie_invitation;
107 for (i = 0; i < p2p->num_groups; i++) {
108 struct p2p_group *g = p2p->groups[i];
135 p2p_buf_add_operating_channel(buf, p2p->cfg->country,
140 p2p_buf_add_channel_list(buf, p2p->cfg->country, channels);
152 void p2p_process_invitation_req(struct p2p_data *p2p, const u8 *sa,
169 p2p_dbg(p2p, "Received Invitation Request from " MACSTR " (freq=%d)",
175 dev = p2p_get_device(p2p, sa);
177 p2p_dbg(p2p, "Invitation Request from unknown peer " MACSTR,
180 if (p2p_add_device(p2p, sa, rx_freq, NULL, 0, data + 1, len - 1,
182 p2p_dbg(p2p, "Invitation Request add device failed "
188 dev = p2p_get_device(p2p, sa);
190 p2p_dbg(p2p, "Reject Invitation Request from unknown peer "
198 p2p_dbg(p2p, "Mandatory attribute missing in Invitation Request from "
207 /* Invitation Flags is a mandatory attribute starting from P2P
212 p2p_dbg(p2p, "Mandatory Invitation Flags attribute missing from Invitation Request");
216 if (p2p_peer_channels_check(p2p, &p2p->cfg->channels, dev,
219 p2p_dbg(p2p, "No common channels found");
224 p2p_channels_intersect(&p2p->cfg->channels, &dev->channels,
227 if (p2p->cfg->invitation_process) {
228 status = p2p->cfg->invitation_process(
229 p2p->cfg->cb_ctx, sa, msg.group_bssid, msg.group_id,
235 p2p_dbg(p2p, "Invitation processing forced frequency %d MHz",
238 p2p_dbg(p2p, "Unknown forced freq %d MHz from invitation_process()",
246 p2p_dbg(p2p, "forced freq %d MHz not in the supported channels interaction",
255 p2p_dbg(p2p, "No forced channel from invitation processing - figure out best one to use");
258 p2p->op_reg_class = p2p->cfg->op_reg_class;
259 p2p->op_channel = p2p->cfg->op_channel;
260 p2p_dbg(p2p, "Own default op_class %d channel %d",
261 p2p->op_reg_class, p2p->op_channel);
269 p2p_dbg(p2p, "Peer operating channel preference: %d MHz",
275 p2p->op_reg_class = msg.operating_channel[3];
276 p2p->op_channel = msg.operating_channel[4];
277 p2p_dbg(p2p, "Use peer preference op_class %d channel %d",
278 p2p->op_reg_class, p2p->op_channel);
280 p2p_dbg(p2p, "Cannot use peer channel preference");
284 if (!p2p_channels_includes(&intersection, p2p->op_reg_class,
285 p2p->op_channel)) {
286 p2p_dbg(p2p, "Initially selected channel (op_class %d channel %d) not in channel intersection - try to reselect",
287 p2p->op_reg_class, p2p->op_channel);
288 p2p_reselect_channel(p2p, &intersection);
289 p2p_dbg(p2p, "Re-selection result: op_class %d channel %d",
290 p2p->op_reg_class, p2p->op_channel);
292 p2p->op_reg_class,
293 p2p->op_channel)) {
294 p2p_dbg(p2p, "Peer does not support selected operating channel (reg_class=%u channel=%u)",
295 p2p->op_reg_class, p2p->op_channel);
300 !p2p->cfg->cfg_op_channel) {
301 p2p_dbg(p2p, "Try to reselect channel selection with peer information received; previously selected op_class %u channel %u",
302 p2p->op_reg_class, p2p->op_channel);
303 p2p_reselect_channel(p2p, &intersection);
306 op_freq = p2p_channel_to_freq(p2p->op_reg_class,
307 p2p->op_channel);
309 p2p_dbg(p2p, "Unknown operational channel (country=%c%c reg_class=%u channel=%u)",
310 p2p->cfg->country[0], p2p->cfg->country[1],
311 p2p->op_reg_class, p2p->op_channel);
315 p2p_dbg(p2p, "Selected operating channel - %d MHz", op_freq);
318 reg_class = p2p->op_reg_class;
319 channel = p2p->op_channel;
329 resp = p2p_build_invitation_resp(p2p, dev, msg.dialog_token, status,
338 freq = p2p_channel_to_freq(p2p->cfg->reg_class,
339 p2p->cfg->channel);
341 p2p_dbg(p2p, "Unknown regulatory class/channel");
349 os_memcpy(p2p->inv_sa, sa, ETH_ALEN);
351 os_memcpy(p2p->inv_group_bssid, msg.group_bssid, ETH_ALEN);
352 p2p->inv_group_bssid_ptr = p2p->inv_group_bssid;
354 p2p->inv_group_bssid_ptr = NULL;
356 os_memcpy(p2p->inv_ssid, msg.group_id + ETH_ALEN,
358 p2p->inv_ssid_len = msg.group_id_len - ETH_ALEN;
360 os_memcpy(p2p->inv_go_dev_addr, msg.group_id, ETH_ALEN);
361 p2p->inv_status = status;
362 p2p->inv_op_freq = op_freq;
364 p2p->pending_action_state = P2P_PENDING_INVITATION_RESPONSE;
365 if (p2p_send_action(p2p, freq, sa, p2p->cfg->dev_addr,
366 p2p->cfg->dev_addr,
368 p2p_dbg(p2p, "Failed to send Action frame");
377 void p2p_process_invitation_resp(struct p2p_data *p2p, const u8 *sa,
384 p2p_dbg(p2p, "Received Invitation Response from " MACSTR,
387 dev = p2p_get_device(p2p, sa);
389 p2p_dbg(p2p, "Ignore Invitation Response from unknown peer "
394 if (dev != p2p->invite_peer) {
395 p2p_dbg(p2p, "Ignore unexpected Invitation Response from peer "
404 p2p_dbg(p2p, "Mandatory Status attribute missing in Invitation Response from "
411 p2p_dbg(p2p, "Mandatory Channel List attribute missing in Invitation Response from "
418 channels = &p2p->channels;
419 } else if (p2p_peer_channels_check(p2p, &p2p->channels, dev,
422 p2p_dbg(p2p, "No common channels found");
426 p2p_channels_intersect(&p2p->channels, &dev->channels,
431 if (p2p->cfg->invitation_result)
432 p2p->cfg->invitation_result(p2p->cfg->cb_ctx, *msg.status,
437 p2p_clear_timeout(p2p);
438 p2p_set_state(p2p, P2P_IDLE);
439 p2p->invite_peer = NULL;
443 int p2p_invite_send(struct p2p_data *p2p, struct p2p_device *dev,
451 p2p_dbg(p2p, "No Listen/Operating frequency known for the peer "
457 req = p2p_build_invitation_req(p2p, dev, go_dev_addr);
460 if (p2p->state != P2P_IDLE)
461 p2p_stop_listen_for_freq(p2p, freq);
462 p2p_dbg(p2p, "Sending Invitation Request");
463 p2p_set_state(p2p, P2P_INVITE);
464 p2p->pending_action_state = P2P_PENDING_INVITATION_REQUEST;
465 p2p->invite_peer = dev;
467 if (p2p_send_action(p2p, freq, dev->info.p2p_device_addr,
468 p2p->cfg->dev_addr, dev->info.p2p_device_addr,
470 p2p_dbg(p2p, "Failed to send Action frame");
471 /* Use P2P find to recover and retry */
472 p2p_set_timeout(p2p, 0, 0);
481 void p2p_invitation_req_cb(struct p2p_data *p2p, int success)
483 p2p_dbg(p2p, "Invitation Request TX callback: success=%d", success);
485 if (p2p->invite_peer == NULL) {
486 p2p_dbg(p2p, "No pending Invite");
491 * Use P2P find, if needed, to find the other device from its listen
494 p2p_set_state(p2p, P2P_INVITE);
495 p2p_set_timeout(p2p, 0, success ? 350000 : 100000);
499 void p2p_invitation_resp_cb(struct p2p_data *p2p, int success)
501 p2p_dbg(p2p, "Invitation Response TX callback: success=%d", success);
502 p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
505 p2p_dbg(p2p, "Assume Invitation Response was actually received by the peer even though Ack was not reported");
507 if (p2p->cfg->invitation_received) {
508 p2p->cfg->invitation_received(p2p->cfg->cb_ctx,
509 p2p->inv_sa,
510 p2p->inv_group_bssid_ptr,
511 p2p->inv_ssid, p2p->inv_ssid_len,
512 p2p->inv_go_dev_addr,
513 p2p->inv_status,
514 p2p->inv_op_freq);
519 int p2p_invite(struct p2p_data *p2p, const u8 *peer, enum p2p_invite_role role,
526 p2p_dbg(p2p, "Request to invite peer " MACSTR " role=%d persistent=%d "
530 p2p_dbg(p2p, "Invitation for BSSID " MACSTR, MAC2STR(bssid));
532 p2p_dbg(p2p, "Invitation for GO Device Address " MACSTR,
534 os_memcpy(p2p->invite_go_dev_addr_buf, go_dev_addr, ETH_ALEN);
535 p2p->invite_go_dev_addr = p2p->invite_go_dev_addr_buf;
537 p2p->invite_go_dev_addr = NULL;
541 dev = p2p_get_device(p2p, peer);
543 p2p_dbg(p2p, "Cannot invite unknown P2P Device " MACSTR,
548 if (p2p_prepare_channel(p2p, dev, force_freq, pref_freq) < 0)
560 p2p_dbg(p2p, "Cannot invite a P2P Device " MACSTR
569 if (p2p->state != P2P_IDLE)
570 p2p_stop_find(p2p);
572 p2p->inv_role = role;
573 p2p->inv_bssid_set = bssid != NULL;
575 os_memcpy(p2p
576 os_memcpy(p2p->inv_ssid, ssid, ssid_len);
577 p2p->inv_ssid_len = ssid_len;
578 p2p->inv_persistent = persistent_group;
579 return p2p_invite_send(p2p, dev, go_dev_addr);