[RFC 4/4] P2P: allow access to group members

Johannes Berg johannes
Thu Dec 2 13:52:31 PST 2010


From: Johannes Berg <johannes.berg at intel.com>

Some new code will require access to P2P group
members, so add API to retrieve the number of
members and iterate the members themselves.

Signed-off-by: Johannes Berg <johannes.berg at intel.com>
---
 src/p2p/p2p.h       |   16 ++++++++++++++++
 src/p2p/p2p_group.c |   22 ++++++++++++++++++++++
 2 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h
index 417b310..8d32a61 100644
--- a/src/p2p/p2p.h
+++ b/src/p2p/p2p.h
@@ -1336,4 +1336,20 @@ void p2p_set_best_channels(struct p2p_data *p2p, int freq_24, int freq_5,
 const struct p2p_peer_info *
 p2p_get_peer_info_data(struct p2p_data *p2p, const u8 *addr);
 
+/**
+ * p2p_get_group_num_members - get number of members in group
+ * @group: P2P group context from p2p_group_init()
+ */
+unsigned int p2p_get_group_num_members(struct p2p_group *group);
+
+/**
+ * p2p_iterate_group_members - iterate the members belonging to the provided group
+ * @group: P2P group context from p2p_group_init()
+ * @next: iteration pointer, must be a pointer to a void * that is set to %NULL
+ *	on the first call and not modified later
+ * Returns a device address for each call
+ */
+const u8 *p2p_iterate_group_members(struct p2p_group *group,
+				    void **next);
+
 #endif /* P2P_H */
diff --git a/src/p2p/p2p_group.c b/src/p2p/p2p_group.c
index 7d25885..0f5cc94 100644
--- a/src/p2p/p2p_group.c
+++ b/src/p2p/p2p_group.c
@@ -647,3 +647,25 @@ u8 p2p_group_presence_req(struct p2p_group *group,
 
 	return P2P_SC_SUCCESS;
 }
+
+unsigned int p2p_get_group_num_members(struct p2p_group *group)
+{
+	return group->num_members;
+}
+
+const u8 *p2p_iterate_group_members(struct p2p_group *group, void **next)
+{
+	struct p2p_group_member *iter = *next;
+
+	if (!iter)
+		iter = group->members;
+	else
+		iter = iter->next;
+
+	*next = iter;
+
+	if (!iter)
+		return NULL;
+
+	return iter->addr;
+}
-- 
1.7.2.3




More information about the Hostap mailing list