[PATCH 6/7] p2p: Add a utility function to run a method on every known peers

Tomasz Bursztyka tomasz.bursztyka
Tue May 20 04:51:13 PDT 2014


This will be useful in wpa_supplicant part to signal if a peer got its
group changed

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka at linux.intel.com>
---
 src/p2p/p2p.c | 18 ++++++++++++++++++
 src/p2p/p2p.h |  5 +++++
 2 files changed, 23 insertions(+)

diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c
index 7361bac..2a0d028 100644
--- a/src/p2p/p2p.c
+++ b/src/p2p/p2p.c
@@ -4692,3 +4692,21 @@ void p2p_set_authorized_oob_dev_pw_id(struct p2p_data *p2p, u16 dev_pw_id,
 }
 
 #endif /* CONFIG_WPS_NFC */
+
+void p2p_loop_on_known_peers(struct p2p_data *p2p,
+			     void (*peer_callback)(struct p2p_peer_info *,
+						   void *),
+			     void *user_data)
+{
+	struct p2p_device *dev, *n;
+
+	if (peer_callback == NULL)
+		return;
+
+	dl_list_for_each_safe(dev, n, &p2p->devices, struct p2p_device, list) {
+		if (dev == p2p->go_neg_peer)
+			continue;
+
+		peer_callback(&dev->info, user_data);
+	}
+}
diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h
index 43ac135..8002050 100644
--- a/src/p2p/p2p.h
+++ b/src/p2p/p2p.h
@@ -1954,4 +1954,9 @@ void p2p_set_authorized_oob_dev_pw_id(struct p2p_data *p2p, u16 dev_pw_id,
 				      int go_intent,
 				      const u8 *own_interface_addr);
 
+void p2p_loop_on_known_peers(struct p2p_data *p2p,
+			     void (*peer_callback)(struct p2p_peer_info *,
+						   void *),
+			     void *user_data);
+
 #endif /* P2P_H */
-- 
1.8.3.2




More information about the Hostap mailing list