P2P: Use the first pref_chan entry as operating channel preference
authorJouni Malinen <jouni@qca.qualcomm.com>
Mon, 26 Aug 2013 11:10:23 +0000 (14:10 +0300)
committerJouni Malinen <j@w1.fi>
Mon, 26 Aug 2013 11:10:23 +0000 (14:10 +0300)
If there are no higher priority preference for the operating channel,
use the first pref_chan entry as the operating channel preference over
the pre-configured channel which is not really a good indication of
preference. This changes the behavior for GO Negotiation Request frame
operating channel preference value in cases where p2p_pref_chan list is
set.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

src/p2p/p2p.c

index 26b86a8..f3414dd 100644 (file)
@@ -1190,6 +1190,13 @@ static void p2p_prepare_channel_best(struct p2p_data *p2p)
                p2p_dbg(p2p, "Select best 2.4 GHz channel as operating channel preference");
                p2p->op_reg_class = op_class;
                p2p->op_channel = op_channel;
+       } else if (p2p->cfg->num_pref_chan > 0 &&
+                  p2p_channels_includes(&p2p->cfg->channels,
+                                        p2p->cfg->pref_chan[0].op_class,
+                                        p2p->cfg->pref_chan[0].chan)) {
+               p2p_dbg(p2p, "Select first pref_chan entry as operating channel preference");
+               p2p->op_reg_class = p2p->cfg->pref_chan[0].op_class;
+               p2p->op_channel = p2p->cfg->pref_chan[0].chan;
        } else {
                p2p_dbg(p2p, "Select pre-configured channel as operating channel preference");
                p2p->op_reg_class = p2p->cfg->op_reg_class;