From: Rashmi Ramanna Date: Wed, 26 Nov 2014 15:53:55 +0000 (+0530) Subject: P2P: Reinvite with social operation channel if no common channels X-Git-Tag: hostap_2_4~1016 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ac330cfd87397a1a01e697984f3944f427e88dad;p=thirdparty%2Fhostap.git P2P: Reinvite with social operation channel if no common channels If invitation to reinvoke a persistent group from the GO fails with the peer indicating that there are no common channels, there is no defined means for the peer to indicate which channel could have worked. Since this type of issue with available channels changing over time can happen, try to work around this by retrying invitation using one of the social channels as the operating channel unless a specific operating channel was forced for the group. Signed-off-by: Jouni Malinen --- diff --git a/src/p2p/p2p_i.h b/src/p2p/p2p_i.h index 6243d70e2..b36bb91bb 100644 --- a/src/p2p/p2p_i.h +++ b/src/p2p/p2p_i.h @@ -269,6 +269,8 @@ struct p2p_data { u8 invite_go_dev_addr_buf[ETH_ALEN]; int invite_dev_pw_id; + unsigned int retry_invite_req; + /** * sd_peer - Pointer to Service Discovery peer */ diff --git a/src/p2p/p2p_invitation.c b/src/p2p/p2p_invitation.c index bac9041e7..784bfa50f 100644 --- a/src/p2p/p2p_invitation.c +++ b/src/p2p/p2p_invitation.c @@ -446,6 +446,22 @@ void p2p_process_invitation_resp(struct p2p_data *p2p, const u8 *sa, return; } + if (*msg.status == P2P_SC_FAIL_NO_COMMON_CHANNELS && + p2p->retry_invite_req && + p2p_channel_random_social(&p2p->cfg->channels, &p2p->op_reg_class, + &p2p->op_channel) == 0) { + p2p->retry_invite_req = 0; + p2p->cfg->stop_listen(p2p->cfg->cb_ctx); + p2p_set_state(p2p, P2P_INVITE); + p2p_dbg(p2p, "Resend Invitation Request setting op_class %u channel %u as operating channel", + p2p->op_reg_class, p2p->op_channel); + p2p_invite_send(p2p, p2p->invite_peer, p2p->invite_go_dev_addr, + p2p->invite_dev_pw_id); + p2p_parse_free(&msg); + return; + } + p2p->retry_invite_req = 0; + if (!msg.channel_list && *msg.status == P2P_SC_SUCCESS) { p2p_dbg(p2p, "Mandatory Channel List attribute missing in Invitation Response from " MACSTR, MAC2STR(sa)); @@ -607,6 +623,8 @@ int p2p_invite(struct p2p_data *p2p, const u8 *peer, enum p2p_invite_role role, dev_pw_id); } p2p->invite_dev_pw_id = dev_pw_id; + p2p->retry_invite_req = role == P2P_INVITE_ROLE_GO && + persistent_group && !force_freq; dev = p2p_get_device(p2p, peer); if (dev == NULL || (dev->listen_freq <= 0 && dev->oper_freq <= 0 &&