aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlan Peer <ilan.peer@intel.com>2015-09-24 17:37:56 (GMT)
committerJouni Malinen <j@w1.fi>2015-10-07 14:07:21 (GMT)
commit8d5e73290f44d076634b1eb827d86038206c8112 (patch)
tree22ae88e9057eea993a4cbb95ad2c08a8372d0bd2
parent8cc4b06f751d52f4327b169c3e89de6189c1c108 (diff)
downloadhostap-8d5e73290f44d076634b1eb827d86038206c8112.zip
hostap-8d5e73290f44d076634b1eb827d86038206c8112.tar.gz
hostap-8d5e73290f44d076634b1eb827d86038206c8112.tar.bz2
P2PS: Re-factor wpas_p2p_get_go_group() and wpas_p2p_group_go_ssid()
Re-factor wpas_p2p_get_go_group() to: 1. Skip the dedicated P2P Device management interface if it is used. 2. Instead of iterating all the interface configured networks, only access the current_ssid pointer to check if the current interface is acting as a persistent P2P GO. To avoid code duplication, also re-factor wpas_p2p_group_go_ssid() to call wpas_p2p_get_go_group(). Signed-off-by: Ilan Peer <ilan.peer@intel.com>
-rw-r--r--wpa_supplicant/p2p_supplicant.c54
1 files changed, 27 insertions, 27 deletions
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index d264cb8..371b6e0 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -545,27 +545,39 @@ static unsigned int p2p_group_go_member_count(struct wpa_supplicant *wpa_s)
}
+static unsigned int p2p_is_active_persistent_group(struct wpa_supplicant *wpa_s)
+{
+ return !wpa_s->p2p_mgmt && wpa_s->current_ssid &&
+ !wpa_s->current_ssid->disabled &&
+ wpa_s->current_ssid->p2p_group &&
+ wpa_s->current_ssid->p2p_persistent_group;
+}
+
+
+static unsigned int p2p_is_active_persistent_go(struct wpa_supplicant *wpa_s)
+{
+ return p2p_is_active_persistent_group(wpa_s) &&
+ wpa_s->current_ssid->mode == WPAS_MODE_P2P_GO;
+}
+
+
/* Find an interface for a P2P group where we are the GO */
static struct wpa_supplicant *
wpas_p2p_get_go_group(struct wpa_supplicant *wpa_s)
{
struct wpa_supplicant *save = NULL;
- struct wpa_ssid *s;
if (!wpa_s)
return NULL;
for (wpa_s = wpa_s->global->ifaces; wpa_s; wpa_s = wpa_s->next) {
- for (s = wpa_s->conf->ssid; s; s = s->next) {
- if (s->disabled || !s->p2p_group ||
- s->mode != WPAS_MODE_P2P_GO)
- continue;
+ if (!p2p_is_active_persistent_go(wpa_s))
+ continue;
- /* Prefer a group with connected clients */
- if (p2p_get_group_num_members(wpa_s->p2p_group))
- return wpa_s;
- save = wpa_s;
- }
+ /* Prefer a group with connected clients */
+ if (p2p_get_group_num_members(wpa_s->p2p_group))
+ return wpa_s;
+ save = wpa_s;
}
/* No group with connected clients, so pick the one without (if any) */
@@ -577,25 +589,13 @@ wpas_p2p_get_go_group(struct wpa_supplicant *wpa_s)
static struct wpa_ssid * wpas_p2p_group_go_ssid(struct wpa_supplicant *wpa_s,
u8 *bssid)
{
- struct wpa_ssid *s, *empty = NULL;
-
- if (!wpa_s)
- return 0;
-
- for (wpa_s = wpa_s->global->ifaces; wpa_s; wpa_s = wpa_s->next) {
- for (s = wpa_s->conf->ssid; s; s = s->next) {
- if (s->disabled || !s->p2p_group ||
- s->mode != WPAS_MODE_P2P_GO)
- continue;
+ struct wpa_supplicant *go = wpas_p2p_get_go_group(wpa_s);
- os_memcpy(bssid, wpa_s->own_addr, ETH_ALEN);
- if (p2p_get_group_num_members(wpa_s->p2p_group))
- return s;
- empty = s;
- }
- }
+ if (!go)
+ return NULL;
- return empty;
+ os_memcpy(bssid, go->own_addr, ETH_ALEN);
+ return go->current_ssid;
}