[PATCH] P2P: introduce P2P_AFTER_SCAN_CONTINUE_FIND

Johannes Berg johannes
Thu Nov 25 12:17:18 PST 2010


From: Johannes Berg <johannes.berg at intel.com>

There's an inconsistency in that when a scan
times out, the P2P state machine will only do
p2p_run_after_scan(), and not continue with a
search. Since there's infrastructure for "do
something after scan", use that for the case
of p2p_continue_find().

Signed-off-by: Johannes Berg <johannes.berg at intel.com>
---
 src/p2p/p2p.c   |   21 ++++++++++-----------
 src/p2p/p2p_i.h |    3 ++-
 2 files changed, 12 insertions(+), 12 deletions(-)

--- hostap.orig/src/p2p/p2p.c	2010-11-25 20:39:13.000000000 +0100
+++ hostap/src/p2p/p2p.c	2010-11-25 21:07:20.000000000 +0100
@@ -671,6 +671,7 @@ static void p2p_search(struct p2p_data *
 	} else {
 		wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Running p2p_scan");
 		p2p->p2p_scan_running = 1;
+		p2p->start_after_scan = P2P_AFTER_SCAN_CONTINUE_FIND;
 		eloop_cancel_timeout(p2p_scan_timeout, p2p, NULL);
 		eloop_register_timeout(P2P_SCAN_TIMEOUT, 0, p2p_scan_timeout,
 				       p2p, NULL);
@@ -686,7 +687,7 @@ static void p2p_find_timeout(void *eloop
 }
 
 
-static int p2p_run_after_scan(struct p2p_data *p2p)
+static void p2p_run_after_scan(struct p2p_data *p2p)
 {
 	struct p2p_device *dev;
 	enum p2p_after_scan op;
@@ -707,7 +708,7 @@ static int p2p_run_after_scan(struct p2p
 					    p2p->after_scan_tx->wait_time);
 		os_free(p2p->after_scan_tx);
 		p2p->after_scan_tx = NULL;
-		return 1;
+		return;
 	}
 
 	op = p2p->start_after_scan;
@@ -715,12 +716,15 @@ static int p2p_run_after_scan(struct p2p
 	switch (op) {
 	case P2P_AFTER_SCAN_NOTHING:
 		break;
+	case P2P_AFTER_SCAN_CONTINUE_FIND:
+		p2p_continue_find(p2p);
+		break;
 	case P2P_AFTER_SCAN_LISTEN:
 		wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Start previously "
 			"requested Listen state");
 		p2p_listen(p2p, p2p->pending_listen_sec * 1000 +
 			   p2p->pending_listen_usec / 1000);
-		return 1;
+		break;
 	case P2P_AFTER_SCAN_CONNECT:
 		wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Start previously "
 			"requested connect with " MACSTR,
@@ -732,10 +736,8 @@ static int p2p_run_after_scan(struct p2p
 			break;
 		}
 		p2p_connect_send(p2p, dev);
-		return 1;
+		break;
 	}
-
-	return 0;
 }
 
 
@@ -765,7 +767,7 @@ int p2p_find(struct p2p_data *p2p, unsig
 		wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: p2p_scan is "
 			"already running");
 	}
-	p2p->start_after_scan = P2P_AFTER_SCAN_NOTHING;
+	p2p->start_after_scan = P2P_AFTER_SCAN_CONTINUE_FIND;
 	p2p_clear_timeout(p2p);
 	p2p->cfg->stop_listen(p2p->cfg->cb_ctx);
 	p2p->find_type = type;
@@ -2095,10 +2097,7 @@ void p2p_scan_res_handled(struct p2p_dat
 	p2p->p2p_scan_running = 0;
 	eloop_cancel_timeout(p2p_scan_timeout, p2p, NULL);
 
-	if (p2p_run_after_scan(p2p))
-		return;
-	if (p2p->state == P2P_SEARCH)
-		p2p_continue_find(p2p);
+	p2p_run_after_scan(p2p);
 }
 
 
--- hostap.orig/src/p2p/p2p_i.h	2010-11-25 20:57:16.000000000 +0100
+++ hostap/src/p2p/p2p_i.h	2010-11-25 20:57:48.000000000 +0100
@@ -359,7 +359,8 @@ struct p2p_data {
 	enum p2p_after_scan {
 		P2P_AFTER_SCAN_NOTHING,
 		P2P_AFTER_SCAN_LISTEN,
-		P2P_AFTER_SCAN_CONNECT
+		P2P_AFTER_SCAN_CONNECT,
+		P2P_AFTER_SCAN_CONTINUE_FIND
 	} start_after_scan;
 	u8 after_scan_peer[ETH_ALEN];
 	struct p2p_pending_action_tx *after_scan_tx;





More information about the Hostap mailing list