From 62e10e6e3d720d44df83941b047213e3df17adff Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Thu, 14 Mar 2013 16:05:47 +0200 Subject: [PATCH] P2P: Use best-overall channel in p2p_reselect_channel() Commit 50285f5ca8086cca45afa42cd23c3a3c1cd58f40 ended up forcing channel re-selection in number of cases where the peer would actually have accepted our initial preference. Fix the parts related to best channel information by using best_freq_overall as the highest priority and by skipping the band changes if the peer supports the channel that we picked since these were based on the assumption that p2p_reselect_channel() is called only if the peer could not accept our initial choice which is not the case anymore. Signed-hostap: Jouni Malinen --- src/p2p/p2p_go_neg.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/p2p/p2p_go_neg.c b/src/p2p/p2p_go_neg.c index 394b3fbde..8a86c5442 100644 --- a/src/p2p/p2p_go_neg.c +++ b/src/p2p/p2p_go_neg.c @@ -350,10 +350,24 @@ void p2p_reselect_channel(struct p2p_data *p2p, u8 op_reg_class, op_channel; unsigned int i; + if (p2p->best_freq_overall > 0 && + p2p_freq_to_channel(p2p->cfg->country, p2p->best_freq_overall, + &op_reg_class, &op_channel) == 0 && + p2p_channels_includes(intersection, op_reg_class, op_channel)) { + wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Pick best overall " + "channel (reg_class %u channel %u) from intersection", + op_reg_class, op_channel); + p2p->op_reg_class = op_reg_class; + p2p->op_channel = op_channel; + return; + } + /* First, try to pick the best channel from another band */ freq = p2p_channel_to_freq(p2p->cfg->country, p2p->op_reg_class, p2p->op_channel); if (freq >= 2400 && freq < 2500 && p2p->best_freq_5 > 0 && + !p2p_channels_includes(intersection, p2p->op_reg_class, + p2p->op_channel) && p2p_freq_to_channel(p2p->cfg->country, p2p->best_freq_5, &op_reg_class, &op_channel) == 0 && p2p_channels_includes(intersection, op_reg_class, op_channel)) { @@ -366,6 +380,8 @@ void p2p_reselect_channel(struct p2p_data *p2p, } if (freq >= 4900 && freq < 6000 && p2p->best_freq_24 > 0 && + !p2p_channels_includes(intersection, p2p->op_reg_class, + p2p->op_channel) && p2p_freq_to_channel(p2p->cfg->country, p2p->best_freq_24, &op_reg_class, &op_channel) == 0 && p2p_channels_includes(intersection, op_reg_class, op_channel)) {