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

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

src/p2p/p2p.c
src/p2p/p2p.h
src/p2p/p2p_group.c

index 2fcac0ee665217ba256cccd73a25625e68fd65f8..42376571318a2abd83772da55b6fd3063e6a6ef0 100644 (file)
@@ -56,11 +56,26 @@ static void p2p_expire_peers(struct p2p_data *p2p)
 {
        struct p2p_device *dev, *n;
        struct os_time now;
+       size_t i;
 
        os_get_time(&now);
        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;
+               for (i = 0; i < p2p->num_groups; i++) {
+                       if (p2p_group_is_client_connected(
+                                   p2p->groups[i], dev->info.p2p_device_addr))
+                               break;
+               }
+               if (i < p2p->num_groups) {
+                       /*
+                        * The peer is connected as a client in a group where
+                        * we are the GO, so do not expire the peer entry.
+                        */
+                       os_get_time(&dev->last_seen);
+                       continue;
+               }
+
                wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Expiring old peer "
                        "entry " MACSTR, MAC2STR(dev->info.p2p_device_addr));
                dl_list_del(&dev->list);
index ce41ca801cc0eba0846881583733017c94499fd0..d929c5084c8f25b89aa02a51f91ee90990bddaa3 100644 (file)
@@ -1551,6 +1551,14 @@ const u8 * p2p_iterate_group_members(struct p2p_group *group, void **next);
  */
 const u8 * p2p_group_get_dev_addr(struct p2p_group *group, const u8 *addr);
 
+/**
+ * p2p_group_is_client_connected - Check whether a specific client is connected
+ * @group: P2P group context from p2p_group_init()
+ * @addr: P2P Device Address of the client
+ * Returns: 1 if client is connected or 0 if not
+ */
+int p2p_group_is_client_connected(struct p2p_group *group, const u8 *dev_addr);
+
 /**
  * p2p_get_peer_found - Get P2P peer info structure of a found peer
  * @p2p: P2P module context from p2p_init()
index 6fa3e21d87c00290d5e5336322fbf6be34a16bea..e25baaab059e6db0ac8d912b87caba5b7883e3d9 100644 (file)
@@ -724,3 +724,16 @@ const u8 * p2p_iterate_group_members(struct p2p_group *group, void **next)
 
        return iter->addr;
 }
+
+
+int p2p_group_is_client_connected(struct p2p_group *group, const u8 *dev_addr)
+{
+       struct p2p_group_member *m;
+
+       for (m = group->members; m; m = m->next) {
+               if (os_memcmp(m->dev_addr, dev_addr, ETH_ALEN) == 0)
+                       return 1;
+       }
+
+       return 0;
+}