diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c index b2636092d..b2a0093dc 100644 --- a/src/p2p/p2p.c +++ b/src/p2p/p2p.c @@ -3275,7 +3275,8 @@ static void p2p_timeout_invite_listen(struct p2p_data *p2p) if (p2p->cfg->invitation_result) p2p->cfg->invitation_result( p2p->cfg->cb_ctx, -1, NULL, NULL, - p2p->invite_peer->info.p2p_device_addr); + p2p->invite_peer->info.p2p_device_addr, + 0); } p2p_set_state(p2p, P2P_IDLE); } diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h index 6e4a850b5..22d0c5807 100644 --- a/src/p2p/p2p.h +++ b/src/p2p/p2p.h @@ -758,6 +758,7 @@ struct p2p_config { * @bssid: P2P Group BSSID or %NULL if not received * @channels: Available operating channels for the group * @addr: Peer address + * @freq: Frequency (in MHz) indicated during invitation or 0 * * This callback is used to indicate result of an Invitation procedure * started with a call to p2p_invite(). The indicated status code is @@ -767,7 +768,7 @@ struct p2p_config { */ void (*invitation_result)(void *ctx, int status, const u8 *bssid, const struct p2p_channels *channels, - const u8 *addr); + const u8 *addr, int freq); /** * go_connected - Check whether we are connected to a GO diff --git a/src/p2p/p2p_invitation.c b/src/p2p/p2p_invitation.c index 203445bab..2734386e3 100644 --- a/src/p2p/p2p_invitation.c +++ b/src/p2p/p2p_invitation.c @@ -431,9 +431,15 @@ void p2p_process_invitation_resp(struct p2p_data *p2p, const u8 *sa, channels = &intersection; } - if (p2p->cfg->invitation_result) + if (p2p->cfg->invitation_result) { + int freq = p2p_channel_to_freq(p2p->op_reg_class, + p2p->op_channel); + if (freq < 0) + freq = 0; p2p->cfg->invitation_result(p2p->cfg->cb_ctx, *msg.status, - msg.group_bssid, channels, sa); + msg.group_bssid, channels, sa, + freq); + } p2p_parse_free(&msg); diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index 226acd691..dda2148bb 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -2846,10 +2846,11 @@ static void wpas_remove_persistent_client(struct wpa_supplicant *wpa_s, static void wpas_invitation_result(void *ctx, int status, const u8 *bssid, const struct p2p_channels *channels, - const u8 *peer) + const u8 *peer, int neg_freq) { struct wpa_supplicant *wpa_s = ctx; struct wpa_ssid *ssid; + int freq; if (bssid) { wpa_msg_global(wpa_s, MSG_INFO, P2P_EVENT_INVITATION_RESULT @@ -2905,9 +2906,17 @@ static void wpas_invitation_result(void *ctx, int status, const u8 *bssid, "starting persistent group"); os_sleep(0, 50000); + freq = wpa_s->p2p_persistent_go_freq; + if (neg_freq > 0 && ssid->mode == WPAS_MODE_P2P_GO && + freq_included(channels, neg_freq)) { + wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Use frequence %d MHz from invitation for GO mode", + neg_freq); + freq = neg_freq; + } + wpas_p2p_group_add_persistent(wpa_s, ssid, ssid->mode == WPAS_MODE_P2P_GO, - wpa_s->p2p_persistent_go_freq, + freq, wpa_s->p2p_go_ht40, wpa_s->p2p_go_vht, channels, ssid->mode == WPAS_MODE_P2P_GO ?