P2P: Add mechanism for timing out idle groups

A new configuration parameter, p2p_group_idle, can now be used to set
idle timeout value for P2P groups in seconds (0 = no timeout). If set,
this values is used to remove P2P group (both GO and P2P client)
interfaces after the group has been idle (no clients/GO seen) for the
configuration duration.

The P2P-GROUP-REMOVED event is now indicating the reason for group
removal when known. For example:
P2P-GROUP-REMOVED wlan0 GO reason=REQUESTED
P2P-GROUP-REMOVED wlan1 client reason=IDLE
This commit is contained in:
Jouni Malinen 2010-10-25 18:24:15 +03:00 committed by Jouni Malinen
parent 1f4c7b6b2a
commit 3071e18109
8 changed files with 114 additions and 3 deletions

View file

@ -1049,6 +1049,13 @@ struct p2p_group_config {
*/
void (*ie_update)(void *ctx, struct wpabuf *beacon_ies,
struct wpabuf *proberesp_ies);
/**
* idle_update - Notification of changes in group idle state
* @ctx: Callback context from cb_ctx
* @idle: Whether the group is idle (no associated stations)
*/
void (*idle_update)(void *ctx, int idle);
};
/**

View file

@ -72,6 +72,7 @@ struct p2p_group * p2p_group_init(struct p2p_data *p2p,
group->group_formation = 1;
group->beacon_update = 1;
p2p_group_update_ies(group);
group->cfg->idle_update(group->cfg->cb_ctx, 1);
return group;
}
@ -338,6 +339,8 @@ int p2p_group_notif_assoc(struct p2p_group *group, const u8 *addr,
if (group->num_members == group->cfg->max_clients)
group->beacon_update = 1;
p2p_group_update_ies(group);
if (group->num_members == 1)
group->cfg->idle_update(group->cfg->cb_ctx, 0);
return 0;
}
@ -396,6 +399,8 @@ void p2p_group_notif_disassoc(struct p2p_group *group, const u8 *addr)
if (group->num_members == group->cfg->max_clients - 1)
group->beacon_update = 1;
p2p_group_update_ies(group);
if (group->num_members == 0)
group->cfg->idle_update(group->cfg->cb_ctx, 1);
}
}