aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/p2p_supplicant.c
diff options
context:
space:
mode:
authorIlan Peer <ilan.peer@intel.com>2015-10-08 09:35:58 (GMT)
committerJouni Malinen <j@w1.fi>2015-10-11 18:42:03 (GMT)
commitebd32943cb986c4864a384ce4b9abf5a7d99bced (patch)
treee855d98ba17250242260d70eb2a69847bf7d36a2 /wpa_supplicant/p2p_supplicant.c
parent4acd5ac67b76d683a944bc03891c52759546841d (diff)
downloadhostap-ebd32943cb986c4864a384ce4b9abf5a7d99bced.zip
hostap-ebd32943cb986c4864a384ce4b9abf5a7d99bced.tar.gz
hostap-ebd32943cb986c4864a384ce4b9abf5a7d99bced.tar.bz2
P2PS: Add channel policy to PD Request
Add operating channel selection and channel list processing similar to that done when building GO Negotiation Request, i.e., consider the currently used channels, configured channels, etc. P2PS introduces a flow where a responder needs to provide channel data without being previously aware of the current constraints, i.e., the channels currently in use by other interfaces. To handle this, extend the get_group_capability() callback to also handle channel selection aspects of group capabilities. In case there is an active P2P GO that is going to be used for the P2PS PD, force its current operating frequency in the PD attributes. Signed-off-by: Ilan Peer <ilan.peer@intel.com>
Diffstat (limited to 'wpa_supplicant/p2p_supplicant.c')
-rw-r--r--wpa_supplicant/p2p_supplicant.c61
1 files changed, 39 insertions, 22 deletions
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index 809c455..fada64a 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -124,6 +124,10 @@ wpas_p2p_get_group_iface(struct wpa_supplicant *wpa_s, int addr_allocated,
int go);
static int wpas_p2p_join_start(struct wpa_supplicant *wpa_s, int freq,
const u8 *ssid, size_t ssid_len);
+static int wpas_p2p_setup_freqs(struct wpa_supplicant *wpa_s, int freq,
+ int *force_freq, int *pref_freq, int go,
+ unsigned int *pref_freq_list,
+ unsigned int *num_pref_freq);
static void wpas_p2p_join_scan_req(struct wpa_supplicant *wpa_s, int freq,
const u8 *ssid, size_t ssid_len);
static void wpas_p2p_join_scan(void *eloop_ctx, void *timeout_ctx);
@@ -605,20 +609,6 @@ wpas_p2p_get_cli_group(struct wpa_supplicant *wpa_s)
}
-/* Find an active P2P group where we are the GO */
-static struct wpa_ssid * wpas_p2p_group_go_ssid(struct wpa_supplicant *wpa_s,
- u8 *bssid)
-{
- struct wpa_supplicant *go = wpas_p2p_get_go_group(wpa_s);
-
- if (!go)
- return NULL;
-
- os_memcpy(bssid, go->own_addr, ETH_ALEN);
- return go->current_ssid;
-}
-
-
/* Find a persistent group where we are the GO */
static struct wpa_ssid *
wpas_p2p_get_persistent_go(struct wpa_supplicant *wpa_s)
@@ -634,7 +624,9 @@ wpas_p2p_get_persistent_go(struct wpa_supplicant *wpa_s)
}
-static u8 p2ps_group_capability(void *ctx, u8 incoming, u8 role)
+static u8 p2ps_group_capability(void *ctx, u8 incoming, u8 role,
+ unsigned int *force_freq,
+ unsigned int *pref_freq)
{
struct wpa_supplicant *wpa_s = ctx;
struct wpa_ssid *s;
@@ -643,9 +635,23 @@ static u8 p2ps_group_capability(void *ctx, u8 incoming, u8 role)
struct wpa_supplicant *go_wpa_s, *cli_wpa_s;
struct wpa_ssid *persistent_go;
int p2p_no_group_iface;
+ unsigned int pref_freq_list[P2P_MAX_PREF_CHANNELS], size;
wpa_printf(MSG_DEBUG, "P2P: Conncap - in:%d role:%d", incoming, role);
+ if (force_freq)
+ *force_freq = 0;
+ if (pref_freq)
+ *pref_freq = 0;
+
+ size = P2P_MAX_PREF_CHANNELS;
+ if (force_freq && pref_freq &&
+ !wpas_p2p_setup_freqs(wpa_s, 0, (int *) force_freq,
+ (int *) pref_freq, 0, pref_freq_list, &size))
+ wpas_p2p_set_own_freq_preference(wpa_s,
+ *force_freq ? *force_freq :
+ *pref_freq);
+
/*
* For non-concurrent capable devices:
* If persistent_go, then no new.
@@ -3685,11 +3691,12 @@ static int wpas_get_persistent_group(void *ctx, const u8 *addr, const u8 *ssid,
static int wpas_get_go_info(void *ctx, u8 *intended_addr,
- u8 *ssid, size_t *ssid_len, int *group_iface)
+ u8 *ssid, size_t *ssid_len, int *group_iface,
+ unsigned int *freq)
{
struct wpa_supplicant *wpa_s = ctx;
+ struct wpa_supplicant *go;
struct wpa_ssid *s;
- u8 bssid[ETH_ALEN];
/*
* group_iface will be set to 1 only if a dedicated interface for P2P
@@ -3699,17 +3706,25 @@ static int wpas_get_go_info(void *ctx, u8 *intended_addr,
* that the pending interface should be used.
*/
*group_iface = 0;
- s = wpas_p2p_group_go_ssid(wpa_s, bssid);
- if (!s) {
+
+ if (freq)
+ *freq = 0;
+
+ go = wpas_p2p_get_go_group(wpa_s);
+ if (!go) {
s = wpas_p2p_get_persistent_go(wpa_s);
*group_iface = wpas_p2p_create_iface(wpa_s);
if (s)
- os_memcpy(bssid, s->bssid, ETH_ALEN);
+ os_memcpy(intended_addr, s->bssid, ETH_ALEN);
else
return 0;
+ } else {
+ s = go->current_ssid;
+ os_memcpy(intended_addr, go->own_addr, ETH_ALEN);
+ if (freq)
+ *freq = go->assoc_freq;
}
- os_memcpy(intended_addr, bssid, ETH_ALEN);
os_memcpy(ssid, s->ssid, s->ssid_len);
*ssid_len = s->ssid_len;
@@ -6235,7 +6250,9 @@ int wpas_p2p_prov_disc(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
wpa_s->pending_pd_use = NORMAL_PD;
if (p2ps_prov && use == WPAS_P2P_PD_FOR_ASP) {
p2ps_prov->conncap = p2ps_group_capability(
- wpa_s, P2PS_SETUP_NONE, p2ps_prov->role);
+ wpa_s, P2PS_SETUP_NONE, p2ps_prov->role,
+ &p2ps_prov->force_freq, &p2ps_prov->pref_freq);
+
wpa_printf(MSG_DEBUG,
"P2P: %s conncap: %d - ASP parsed: %x %x %d %s",
__func__, p2ps_prov->conncap,