]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Use negotiated channel from invitation for persistent GO
authorVinay Krishna Eranna <c_veran@qti.qualcomm.com>
Mon, 11 Nov 2013 08:03:54 +0000 (13:33 +0530)
committerJouni Malinen <j@w1.fi>
Sat, 16 Nov 2013 16:05:28 +0000 (18:05 +0200)
During persistent group re-invocation, GO may end up using a different
channel as the operation channel compared to what was indicated in the
invitation frames. This may break the connection if the peer device ends
up scanning the GO only on the channel from the invitation frame. Fix
this by using the negotiated channel (if available) on the GO as the
operating channel instead of the channel that was provided in the
p2p_invite command to start negotiation.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

src/p2p/p2p.c
src/p2p/p2p.h
src/p2p/p2p_invitation.c
wpa_supplicant/p2p_supplicant.c

index b2636092d92352743d302451992e4e3faca658a3..b2a0093dcd8592f2557dcb5792d504a7d79b74eb 100644 (file)
@@ -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);
        }
index 6e4a850b5f320eaa0f2d834dc09885443f71bcf8..22d0c58075228e04e7f8614813770a108fb9e72e 100644 (file)
@@ -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
index 203445bab7ac6debec9442bda7a9807f3f0df821..2734386e3e2fe188f56bc8c8b1cf1f8a66428831 100644 (file)
@@ -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);
 
index 226acd691fdb3c93f858ec7610bbd52686751d2c..dda2148bb8073466884b287ed75490ff415b322f 100644 (file)
@@ -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 ?