P2P: Add utility functions to get GO/client interface

This will be useful for a peer to know if it is part of a group either
as a client of our local GO or as the peer GO.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
Tomasz Bursztyka 2014-06-02 17:42:04 +03:00 committed by Jouni Malinen
parent c6386e5c71
commit 6f04642fe3
2 changed files with 38 additions and 5 deletions

View File

@ -3684,10 +3684,31 @@ static int wpas_get_noa(void *ctx, const u8 *interface_addr, u8 *buf,
}
static int wpas_go_connected(void *ctx, const u8 *dev_addr)
struct wpa_supplicant * wpas_get_p2p_go_iface(struct wpa_supplicant *wpa_s,
const u8 *ssid, size_t ssid_len)
{
struct wpa_supplicant *wpa_s = ctx;
for (wpa_s = wpa_s->global->ifaces; wpa_s; wpa_s = wpa_s->next) {
struct wpa_ssid *s = wpa_s->current_ssid;
if (s == NULL)
continue;
if (s->mode != WPAS_MODE_P2P_GO &&
s->mode != WPAS_MODE_AP &&
s->mode != WPAS_MODE_P2P_GROUP_FORMATION)
continue;
if (s->ssid_len != ssid_len ||
os_memcmp(s, s->ssid, ssid_len) != 0)
continue;
return wpa_s;
}
return NULL;
}
struct wpa_supplicant * wpas_get_p2p_client_iface(struct wpa_supplicant *wpa_s,
const u8 *peer_dev_addr)
{
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)
@ -3697,11 +3718,19 @@ static int wpas_go_connected(void *ctx, const u8 *dev_addr)
if (wpa_s->wpa_state != WPA_COMPLETED &&
wpa_s->wpa_state != WPA_GROUP_HANDSHAKE)
continue;
if (os_memcmp(wpa_s->go_dev_addr, dev_addr, ETH_ALEN) == 0)
return 1;
if (os_memcmp(wpa_s->go_dev_addr, peer_dev_addr, ETH_ALEN) == 0)
return wpa_s;
}
return 0;
return NULL;
}
static int wpas_go_connected(void *ctx, const u8 *dev_addr)
{
struct wpa_supplicant *wpa_s = ctx;
return wpas_get_p2p_client_iface(wpa_s, dev_addr) != NULL;
}

View File

@ -17,6 +17,10 @@ struct p2p_channels;
struct wps_event_fail;
int wpas_p2p_add_p2pdev_interface(struct wpa_supplicant *wpa_s);
struct wpa_supplicant * wpas_get_p2p_go_iface(struct wpa_supplicant *wpa_s,
const u8 *ssid, size_t ssid_len);
struct wpa_supplicant * wpas_get_p2p_client_iface(struct wpa_supplicant *wpa_s,
const u8 *peer_dev_addr);
int wpas_p2p_connect(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
const char *pin, enum p2p_wps_method wps_method,
int persistent_group, int auto_join, int join,