[PATCH] Add P2P IEs to probe requests only when in P2P
Eyal Shapira
eyal
Mon Aug 13 06:59:44 PDT 2012
The current code caused P2P and consquently WPS IEs to be added
to any probe as the check was for non null global->p2p.
global->p2p gets set whenever P2P is initialized globally
and that occurs on the first interface init.
Fix this by indicating wps is in use only when in active P2P
discovery or connection establishement.
(i.e. not P2P_IDLE - either doing search, neg or provisioning)
Signed-hostap: Eyal Shapira <eyal at wizery.com>
---
src/p2p/p2p.c | 7 +++++++
src/p2p/p2p.h | 9 +++++++++
wpa_supplicant/p2p_supplicant.c | 7 +++++++
wpa_supplicant/p2p_supplicant.h | 1 +
wpa_supplicant/scan.c | 2 +-
5 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c
index 80b345a..0d8fcf4 100644
--- a/src/p2p/p2p.c
+++ b/src/p2p/p2p.c
@@ -3959,3 +3959,10 @@ int p2p_in_progress(struct p2p_data *p2p)
return 0;
return p2p->state != P2P_IDLE && p2p->state != P2P_PROVISIONING;
}
+
+int p2p_non_idle(struct p2p_data *p2p)
+{
+ if (p2p == NULL)
+ return 0;
+ return p2p->state != P2P_IDLE;
+}
diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h
index 7e47270..81f72c4 100644
--- a/src/p2p/p2p.h
+++ b/src/p2p/p2p.h
@@ -1688,6 +1688,15 @@ int p2p_set_pref_chan(struct p2p_data *p2p, unsigned int num_pref_chan,
int p2p_in_progress(struct p2p_data *p2p);
/**
+ * p2p_non_idle - Check whether P2P is not in P2P_IDLE. That
+ * means we're in either search, GO neg or provisioing. Once connected
+ * it's back to idle. p2p_in_progress excludes provisioing.
+ * @p2p: P2P module context from p2p_init()
+ * Returns: 0 if P2P module is idle or 1 if an operation is in progress
+ */
+int p2p_non_idle(struct p2p_data *p2p);
+
+/**
* p2p_other_scan_completed - Notify completion of non-P2P scan
* @p2p: P2P module context from p2p_init()
* Returns: 0 if P2P module is idle or 1 if an operation was started
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index df65de9..adc799c 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -4828,6 +4828,13 @@ int wpas_p2p_in_progress(struct wpa_supplicant *wpa_s)
return p2p_in_progress(wpa_s->global->p2p);
}
+int wpas_p2p_non_idle(struct wpa_supplicant *wpa_s)
+{
+ if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
+ return 0;
+
+ return p2p_non_idle(wpa_s->global->p2p);
+}
void wpas_p2p_network_removed(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid)
diff --git a/wpa_supplicant/p2p_supplicant.h b/wpa_supplicant/p2p_supplicant.h
index e2fe259..dc9f8a9 100644
--- a/wpa_supplicant/p2p_supplicant.h
+++ b/wpa_supplicant/p2p_supplicant.h
@@ -133,6 +133,7 @@ int wpas_p2p_disconnect(struct wpa_supplicant *wpa_s);
void wpas_p2p_wps_failed(struct wpa_supplicant *wpa_s,
struct wps_event_fail *fail);
int wpas_p2p_in_progress(struct wpa_supplicant *wpa_s);
+int wpas_p2p_non_idle(struct wpa_supplicant *wpa_s);
void wpas_p2p_network_removed(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid);
struct wpa_ssid * wpas_p2p_get_persistent(struct wpa_supplicant *wpa_s,
diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c
index 6c3f625..386a3fb 100644
--- a/wpa_supplicant/scan.c
+++ b/wpa_supplicant/scan.c
@@ -66,7 +66,7 @@ static int wpas_wps_in_use(struct wpa_supplicant *wpa_s,
}
#ifdef CONFIG_P2P
- if (!wpa_s->global->p2p_disabled && wpa_s->global->p2p) {
+ if (wpas_p2p_non_idle(wpa_s)) {
wpa_s->wps->dev.p2p = 1;
if (!wps) {
wps = 1;
--
1.7.9.5
More information about the Hostap
mailing list