]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Use best-overall channel in p2p_reselect_channel()
authorJouni Malinen <jouni@qca.qualcomm.com>
Thu, 14 Mar 2013 14:05:47 +0000 (16:05 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 14 Mar 2013 14:05:47 +0000 (16:05 +0200)
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 <jouni@qca.qualcomm.com>

src/p2p/p2p_go_neg.c

index 394b3fbde81caed44619232f378674b4c8b85f6b..8a86c544286312be5ac254361088bdeb072e4998 100644 (file)
@@ -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)) {