]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Do not expire peer entry if we are connected to the peer
authorJouni Malinen <jouni@qca.qualcomm.com>
Wed, 25 Jan 2012 15:27:47 +0000 (17:27 +0200)
committerJouni Malinen <j@w1.fi>
Wed, 25 Jan 2012 15:27:47 +0000 (17:27 +0200)
Even though we may not update P2P peer entry while connected to the
peer as a P2P client, we should not be expiring a P2P peer entry while
that peer is the GO in a group where we are connected as a P2P client.

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

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

index 42376571318a2abd83772da55b6fd3063e6a6ef0..2f4c1147ca37b944b9de12c4744be6016f97eec9 100644 (file)
@@ -62,6 +62,18 @@ static void p2p_expire_peers(struct p2p_data *p2p)
        dl_list_for_each_safe(dev, n, &p2p->devices, struct p2p_device, list) {
                if (dev->last_seen.sec + P2P_PEER_EXPIRATION_AGE >= now.sec)
                        continue;
+
+               if (p2p->cfg->go_connected &&
+                   p2p->cfg->go_connected(p2p->cfg->cb_ctx,
+                                          dev->info.p2p_device_addr)) {
+                       /*
+                        * We are connected as a client to a group in which the
+                        * peer is the GO, so do not expire the peer entry.
+                        */
+                       os_get_time(&dev->last_seen);
+                       continue;
+               }
+
                for (i = 0; i < p2p->num_groups; i++) {
                        if (p2p_group_is_client_connected(
                                    p2p->groups[i], dev->info.p2p_device_addr))
index d929c5084c8f25b89aa02a51f91ee90990bddaa3..0924db5ccff1b0acacb532841a9034f787bbde15 100644 (file)
@@ -706,6 +706,15 @@ struct p2p_config {
         * local failure in transmitting the Invitation Request.
         */
        void (*invitation_result)(void *ctx, int status, const u8 *bssid);
+
+       /**
+        * go_connected - Check whether we are connected to a GO
+        * @ctx: Callback context from cb_ctx
+        * @dev_addr: P2P Device Address of a GO
+        * Returns: 1 if we are connected as a P2P client to the specified GO
+        * or 0 if not.
+        */
+       int (*go_connected)(void *ctx, const u8 *dev_addr);
 };
 
 
index 523a2467d054599419121e886bd18c826722d2a7..9bc298a1cd6fba04124ddedd1dc376c9837e22ce 100644 (file)
@@ -125,6 +125,9 @@ void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s)
        bssid_changed = !is_zero_ether_addr(wpa_s->bssid);
        os_memset(wpa_s->bssid, 0, ETH_ALEN);
        os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
+#ifdef CONFIG_P2P
+       os_memset(wpa_s->go_dev_addr, 0, ETH_ALEN);
+#endif /* CONFIG_P2P */
        wpa_s->current_bss = NULL;
        wpa_s->assoc_freq = 0;
 #ifdef CONFIG_IEEE80211R
index e8834ef0766446f3c9659c24a3152589ed7e0833..4c271e1e42c95c3e8637f1b195fa63cf7fd7c520 100644 (file)
@@ -2207,6 +2207,26 @@ static int wpas_get_noa(void *ctx, const u8 *interface_addr, u8 *buf,
 }
 
 
+static int wpas_go_connected(void *ctx, const u8 *dev_addr)
+{
+       struct wpa_supplicant *wpa_s = ctx;
+
+       for (wpa_s = wpa_s->global->ifaces; wpa_s; wpa_s = wpa_s->next) {
+               struct wpa_ssid *ssid = wpa_s->current_ssid;
+               if (ssid == NULL)
+                       continue;
+               if (ssid->mode != WPAS_MODE_INFRA)
+                       continue;
+               if (wpa_s->wpa_state != WPA_COMPLETED)
+                       continue;
+               if (os_memcmp(wpa_s->go_dev_addr, dev_addr, ETH_ALEN) == 0)
+                       return 1;
+       }
+
+       return 0;
+}
+
+
 /**
  * wpas_p2p_init - Initialize P2P module for %wpa_supplicant
  * @global: Pointer to global data from wpa_supplicant_init()
@@ -2266,6 +2286,7 @@ int wpas_p2p_init(struct wpa_global *global, struct wpa_supplicant *wpa_s)
        p2p.invitation_received = wpas_invitation_received;
        p2p.invitation_result = wpas_invitation_result;
        p2p.get_noa = wpas_get_noa;
+       p2p.go_connected = wpas_go_connected;
 
        os_memcpy(wpa_s->global->p2p_dev_addr, wpa_s->own_addr, ETH_ALEN);
        os_memcpy(p2p.dev_addr, wpa_s->global->p2p_dev_addr, ETH_ALEN);