From d3bb082a73d34870e9f2d4993cc56640e707195d Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Mon, 13 Mar 2017 12:50:50 +0200 Subject: [PATCH] P2P: Continue scanning specified channel with P2P_FIND freq argument This makes the "P2P_FIND freq=" operation more robust by continuing to include the specified frequency in the consecutive scan rounds instead of including it only once in the first scan. In other words, the first scan is only for the specified frequency just like the previous behavior, but the following scans include all the social channels and the specified frequency instead of just the previously used social channels. Signed-off-by: Jouni Malinen --- src/p2p/p2p.c | 12 +++++++++--- src/p2p/p2p_i.h | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c index 1374005f9..047e59a7f 100644 --- a/src/p2p/p2p.c +++ b/src/p2p/p2p.c @@ -1010,8 +1010,10 @@ static void p2p_search(struct p2p_data *p2p) } p2p->cfg->stop_listen(p2p->cfg->cb_ctx); - if (p2p->find_type == P2P_FIND_PROGRESSIVE && - (freq = p2p_get_next_prog_freq(p2p)) > 0) { + if ((p2p->find_type == P2P_FIND_PROGRESSIVE && + (freq = p2p_get_next_prog_freq(p2p)) > 0) || + (p2p->find_type == P2P_FIND_START_WITH_FULL && + (freq = p2p->find_specified_freq) > 0)) { type = P2P_SCAN_SOCIAL_PLUS_ONE; p2p_dbg(p2p, "Starting search (+ freq %u)", freq); } else { @@ -1235,6 +1237,10 @@ int p2p_find(struct p2p_data *p2p, unsigned int timeout, } p2p->cfg->stop_listen(p2p->cfg->cb_ctx); p2p->find_type = type; + if (freq != 2412 && freq != 2437 && freq != 2462 && freq != 60480) + p2p->find_specified_freq = freq; + else + p2p->find_specified_freq = 0; p2p_device_clear_reported(p2p); os_memset(p2p->sd_query_no_ack, 0, ETH_ALEN); p2p_set_state(p2p, P2P_SEARCH); @@ -1250,7 +1256,7 @@ int p2p_find(struct p2p_data *p2p, unsigned int timeout, if (freq > 0) { /* * Start with the specified channel and then move to - * social channels only scans. + * scans for social channels and this specific channel. */ res = p2p->cfg->p2p_scan(p2p->cfg->cb_ctx, P2P_SCAN_SPECIFIC, freq, diff --git a/src/p2p/p2p_i.h b/src/p2p/p2p_i.h index 0041d5978..e995c6d94 100644 --- a/src/p2p/p2p_i.h +++ b/src/p2p/p2p_i.h @@ -437,6 +437,7 @@ struct p2p_data { int inv_persistent; enum p2p_discovery_type find_type; + int find_specified_freq; unsigned int last_p2p_find_timeout; u8 last_prog_scan_class; u8 last_prog_scan_chan;