[PATCH 2/3] P2P: always re-select oper channel if not hard coded
Arik Nemtsov
arik
Mon Sep 24 07:14:55 PDT 2012
On Tue, Sep 4, 2012 at 8:52 PM, Arik Nemtsov <arik at wizery.com> wrote:
> Since the operating channel is randomly set to 1/6/11 on init, which is
> always in the channel intersection, we were effectively ignoring the set
> of p2p preferred channels.
> Fix this by trying to get the best channel we can, unless the user hard
> coded the operating channel in the configuration file. Fall back to the
> initial randomly selected channel if a better one cannot be chosen.
>
> Signed-hostap: Arik Nemtsov <arik at wizery.com>
> ---
> src/p2p/p2p_go_neg.c | 17 ++++++++++++++++-
> 1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/src/p2p/p2p_go_neg.c b/src/p2p/p2p_go_neg.c
> index 031b3a1..e1ba466 100644
> --- a/src/p2p/p2p_go_neg.c
> +++ b/src/p2p/p2p_go_neg.c
> @@ -391,6 +391,20 @@ static void p2p_reselect_channel(struct p2p_data *p2p,
> }
>
> /*
> + * Try to see if the original channel is in the intersection. If
> + * so, no need to change anything, as it already contains some
> + * randomness.
> + */
> + if (p2p_channels_includes(intersection, p2p->op_reg_class,
> + p2p->op_channel)) {
> + wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
> + "P2P: Using original operating class and channel "
> + "(reg_class %u channel %u) from intersection",
> + p2p->op_reg_class, p2p->op_channel);
> + return;
> + }
> +
> + /*
> * Fall back to whatever is included in the channel intersection since
> * no better options seems to be available.
> */
> @@ -639,7 +653,8 @@ void p2p_process_go_neg_req(struct p2p_data *p2p, const u8 *sa,
> wpa_hexdump(MSG_DEBUG, "P2P: channels",
> c->channel, c->channels);
> }
> - if (!p2p_channels_includes(&intersection,
> + if (!p2p->cfg->cfg_op_channel ||
> + !p2p_channels_includes(&intersection,
There's a similar fix for p2p_process_go_neg_resp() which I forgot
here. But let's see if Jouni is ok with this approach before sending a
v2.
Arik
More information about the Hostap
mailing list