diff mbox

wpa_supplicant's p2p wouldn't connect to Sony Bravia TV

Message ID 4EF876EA.1040207@gmail.com
State Superseded
Headers show

Commit Message

Vitaly Wool Dec. 26, 2011, 1:30 p.m. UTC
Hi Jouni,

Jouni Malinen skrev 2011-12-18 19:25:

> On Mon, Dec 12, 2011 at 01:15:30PM +0100, Vitaly Wool wrote:
>> so here comes the patch. Or should I post it in a separate thread?
>
> It doesn't need to be a separate thread, but yes, please post this
> separately with a proper commit message explaining what the change fixes
> and a Signed-hostap tag.
>
okay, how about this?

 From 115e721b88a5751ccb14a008b1c12da25a75af68 Mon Sep 17 00:00:00 2001
From: Vitaly Wool<vitalywool@gmail.com>
Date: Mon, 26 Dec 2011 14:06:05 +0100
Subject: [PATCH] Request repeated P2P scan with P2P wildcard SSID

Currently if a P2P connection is initiated but there is no active
session at the moment (e. g. a user haven't pressed the push
button yet), wpa_supplicant will repeat scanning without P2P
wildcard SSID (i. e. do the plain wildcard scan). However,
some devices will not answer to plain scan while connecting,
so even if the button was pressed on the peer device, we would
not know it.

This patch introduces the means to repeat exactly the same scan
as the previous one, by means of providing a new callback for
re-scheduled scan. If this callback is not set, it falls back to
the standard way, so this change is transparent.

Signed-hostap: Vitaly Wool<vitalywool@gmail.com>
---
  wpa_supplicant/events.c           |    5 ++++-
  wpa_supplicant/p2p_supplicant.c   |   10 ++++++++++
  wpa_supplicant/wpa_supplicant_i.h |    2 ++
  3 files changed, 16 insertions(+), 1 deletions(-)
diff mbox

Patch

diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index 7913666..f67a716 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -814,7 +814,10 @@  static void wpa_supplicant_req_new_scan(struct wpa_supplicant *wpa_s,
  		wpa_supplicant_set_state(wpa_s, WPA_INACTIVE);
  		return;
  	}
-	wpa_supplicant_req_scan(wpa_s, timeout_sec, timeout_usec);
+	if (wpa_s->scan_reschedule)
+		(wpa_s->scan_reschedule)(wpa_s, timeout_sec, timeout_usec);
+	else
+		wpa_supplicant_req_scan(wpa_s, timeout_sec, timeout_usec);
  }


diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index 5ff94ef..7b16453 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -2633,6 +2633,15 @@  start:
  	wpas_p2p_join_start(wpa_s);
  }

+static void wpas_p2p_join_scan_reschedule(struct wpa_supplicant *wpa_s,
+					  int sec, int usec)
+{
+	wpa_dbg(wpa_s, MSG_DEBUG, "Setting P2P scan request: %d sec %d usec",
+		sec, usec);
+	eloop_cancel_timeout(wpas_p2p_join_scan, wpa_s, NULL);
+	eloop_register_timeout(sec, usec, wpas_p2p_join_scan, wpa_s, NULL);
+}
+

  static void wpas_p2p_join_scan(void *eloop_ctx, void *timeout_ctx)
  {
@@ -2678,6 +2687,7 @@  static void wpas_p2p_join_scan(void *eloop_ctx, void *timeout_ctx)
  	 * the new scan results become available.
  	 */
  	wpa_s->scan_res_handler = wpas_p2p_scan_res_join;
+	wpa_s->scan_reschedule = wpas_p2p_join_scan_reschedule;
  	ret = wpa_drv_scan(wpa_s,&params);

  	wpabuf_free(ies);
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
index 5469129..29a30db 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -301,6 +301,8 @@  struct wpa_supplicant {

  	void (*scan_res_handler)(struct wpa_supplicant *wpa_s,
  				 struct wpa_scan_results *scan_res);
+	void (*scan_reschedule)(struct wpa_supplicant *wpa_s,
+				int sec, int usec);
  	struct dl_list bss; /* struct wpa_bss::list */
  	struct dl_list bss_id; /* struct wpa_bss::list_id */
  	size_t num_bss;