[PATCH 3/7] wpas: Add p2p utility function to get go iface from a peer dev address
Tomasz Bursztyka
tomasz.bursztyka
Tue May 20 04:51:10 PDT 2014
This will be useful for a peer to know if it is part of a group, what is
its interface and thus its dbus object path.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka at linux.intel.com>
---
wpa_supplicant/p2p_supplicant.c | 36 ++++++++++++++++++++++++++++++------
wpa_supplicant/p2p_supplicant.h | 4 ++++
2 files changed, 34 insertions(+), 6 deletions(-)
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index bbe15d8..56cf798 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -3632,11 +3632,9 @@ static int wpas_get_noa(void *ctx, const u8 *interface_addr, u8 *buf,
return wpa_drv_get_noa(wpa_s, buf, buf_len);
}
-
-static int wpas_go_connected(void *ctx, const u8 *dev_addr)
+struct wpa_supplicant *wpas_get_go_p2p_client(struct wpa_supplicant *wpa_s,
+ const u8 *dev_addr)
{
- struct wpa_supplicant *wpa_s = ctx;
-
for (wpa_s = wpa_s->global->ifaces; wpa_s; wpa_s = wpa_s->next) {
struct wpa_ssid *ssid = wpa_s->current_ssid;
if (ssid == NULL)
@@ -3647,12 +3645,38 @@ static int wpas_go_connected(void *ctx, const u8 *dev_addr)
wpa_s->wpa_state != WPA_GROUP_HANDSHAKE)
continue;
if (os_memcmp(wpa_s->go_dev_addr, dev_addr, ETH_ALEN) == 0)
- return 1;
+ return wpa_s;
}
- return 0;
+ return NULL;
+}
+
+struct wpa_supplicant *wpas_get_go_p2p_go(struct wpa_supplicant *wpa_s,
+ const u8 *dev_addr)
+{
+ const u8 *go_dev_addr;
+
+ go_dev_addr = p2p_get_own_go_device_address(wpa_s->global->p2p,
+ dev_addr);
+ if (go_dev_addr == NULL)
+ return NULL;
+
+ for (wpa_s = wpa_s->global->ifaces; wpa_s; wpa_s = wpa_s->next) {
+ if (os_memcmp(wpa_s->go_dev_addr, go_dev_addr, ETH_ALEN) == 0)
+ return wpa_s;
+ }
+
+ return NULL;
}
+static int wpas_go_connected(void *ctx, const u8 *dev_addr)
+{
+ struct wpa_supplicant *wpa_s = ctx;
+
+ if (wpas_get_go_p2p_client(wpa_s, dev_addr) != NULL)
+ return 1;
+ return 0;
+}
static int wpas_is_concurrent_session_active(void *ctx)
{
diff --git a/wpa_supplicant/p2p_supplicant.h b/wpa_supplicant/p2p_supplicant.h
index 0bf3ca9..4044cec 100644
--- a/wpa_supplicant/p2p_supplicant.h
+++ b/wpa_supplicant/p2p_supplicant.h
@@ -142,6 +142,10 @@ int wpas_p2p_get_ht40_mode(struct wpa_supplicant *wpa_s,
struct hostapd_hw_modes *mode, u8 channel);
int wpas_p2p_get_vht80_center(struct wpa_supplicant *wpa_s,
struct hostapd_hw_modes *mode, u8 channel);
+struct wpa_supplicant *wpas_get_go_p2p_client(struct wpa_supplicant *wpa_s,
+ const u8 *dev_addr);
+struct wpa_supplicant *wpas_get_go_p2p_go(struct wpa_supplicant *wpa_s,
+ const u8 *dev_addr);
unsigned int wpas_p2p_search_delay(struct wpa_supplicant *wpa_s);
void wpas_p2p_new_psk_cb(struct wpa_supplicant *wpa_s, const u8 *mac_addr,
const u8 *p2p_dev_addr,
--
1.8.3.2
More information about the Hostap
mailing list