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

Tomasz Bursztyka tomasz.bursztyka
Mon Jun 2 07:42:07 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 | 15 +++++++++++++++
 src/p2p/p2p.h |  5 +++++
 2 files changed, 20 insertions(+)

diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c
index 1a19041..f280bc9 100644
--- a/src/p2p/p2p.c
+++ b/src/p2p/p2p.c
@@ -4462,6 +4462,21 @@ void p2p_err(struct p2p_data *p2p, const char *fmt, ...)
 }
 
 
+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) {
+		peer_callback(&dev->info, user_data);
+	}
+}
+
 #ifdef CONFIG_WPS_NFC
 
 static struct wpabuf * p2p_build_nfc_handover(struct p2p_data *p2p,
diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h
index 6c399a0..f2e8117 100644
--- a/src/p2p/p2p.h
+++ b/src/p2p/p2p.h
@@ -1971,4 +1971,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.5.5




More information about the Hostap mailing list