P2P: Do not expire peer entry if peer is connected as a client

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>
This commit is contained in:
Jouni Malinen 2012-01-25 17:00:59 +02:00 committed by Jouni Malinen
parent d8d6b32eec
commit 1d277f0260
3 changed files with 36 additions and 0 deletions

View 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);

View 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()

View 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;
}