P2P Add a utility to run a callback on all available groups

This will be useful in wpa_supplicant to match group's SSIDs against a
specific one.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
Tomasz Bursztyka 2014-06-02 17:42:03 +03:00 committed by Jouni Malinen
parent 8e76f48abd
commit c6386e5c71
2 changed files with 27 additions and 0 deletions

View file

@ -1816,6 +1816,19 @@ int p2p_group_is_client_connected(struct p2p_group *group, const u8 *dev_addr);
*/
const struct p2p_group_config * p2p_group_get_config(struct p2p_group *group);
/**
* p2p_loop_on_all_groups - Run the given callback on all groups
* @p2p: P2P module context from p2p_init()
* @group_callback: The callback function pointer
* @user_data: Some user data pointer which can be %NULL
*
* The group_callback function can stop the iteration by returning 0.
*/
void p2p_loop_on_all_groups(struct p2p_data *p2p,
int (*group_callback)(struct p2p_group *group,
void *user_data),
void *user_data);
/**
* p2p_get_peer_found - Get P2P peer info structure of a found peer
* @p2p: P2P module context from p2p_init()

View file

@ -1019,3 +1019,17 @@ const struct p2p_group_config * p2p_group_get_config(struct p2p_group *group)
{
return group->cfg;
}
void p2p_loop_on_all_groups(struct p2p_data *p2p,
int (*group_callback)(struct p2p_group *group,
void *user_data),
void *user_data)
{
unsigned int i;
for (i = 0; i < p2p->num_groups; i++) {
if (!group_callback(p2p->groups[i], user_data))
break;
}
}