[PATCH 2/7] p2p: Add a utility function to retrieve local GO device address

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


Provided the given device address in the parameters belongs to a peer
device. This will be useful in wpa_supplicant part.

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

diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c
index c2f8d9b..7361bac 100644
--- a/src/p2p/p2p.c
+++ b/src/p2p/p2p.c
@@ -4090,6 +4090,24 @@ int p2p_get_dev_addr(struct p2p_data *p2p, const u8 *iface_addr,
 }
 
 
+const u8 *p2p_get_own_go_device_address(struct p2p_data *p2p,
+					const u8 *peer_dev_addr)
+{
+	int i;
+
+	for (i = 0; i < p2p->num_groups; i++) {
+		if (p2p_group_is_client_connected(p2p->groups[i],
+						  peer_dev_addr))
+			break;
+	}
+
+	if (i >= p2p->num_groups)
+		return NULL;
+
+	return p2p_group_get_interface_addr(p2p->groups[i]);
+}
+
+
 void p2p_set_peer_filter(struct p2p_data *p2p, const u8 *addr)
 {
 	os_memcpy(p2p->peer_filter, addr, ETH_ALEN);
diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h
index fa8031d..43ac135 100644
--- a/src/p2p/p2p.h
+++ b/src/p2p/p2p.h
@@ -1678,6 +1678,9 @@ int p2p_get_interface_addr(struct p2p_data *p2p, const u8 *dev_addr,
 int p2p_get_dev_addr(struct p2p_data *p2p, const u8 *iface_addr,
 			   u8 *dev_addr);
 
+const u8 *p2p_get_own_go_device_address(struct p2p_data *p2p,
+					const u8 *peer_dev_addr);
+
 void p2p_set_peer_filter(struct p2p_data *p2p, const u8 *addr);
 
 /**
-- 
1.8.3.2




More information about the Hostap mailing list