mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-25 00:38:24 -05:00
P2P: Always re-select operating channel if not hard coded
Since the operating channel is randomly set to 1/6/11 on init, which is commonly included in the channel intersection, we were effectively ignoring the set of P2P preferred channels when trying to improve channel selection after having received peer information. Fix this by trying to get the best channel we can, unless the user hard coded the operating channel in the configuration file or p2p_connect command. Fall back to the initial randomly selected channel if a better one cannot be chosen. Signed-hostap: Arik Nemtsov <arik@wizery.com>
This commit is contained in:
parent
bd594ea0da
commit
50285f5ca8
@ -344,10 +344,6 @@ void p2p_reselect_channel(struct p2p_data *p2p,
|
||||
u8 op_reg_class, op_channel;
|
||||
unsigned int i;
|
||||
|
||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Selected operating "
|
||||
"channel (reg_class %u channel %u) not acceptable to the "
|
||||
"peer", p2p->op_reg_class, p2p->op_channel);
|
||||
|
||||
/* 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);
|
||||
@ -405,6 +401,20 @@ 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 "
|
||||
"(op_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.
|
||||
@ -449,6 +459,17 @@ static int p2p_go_select_channel(struct p2p_data *p2p, struct p2p_device *dev,
|
||||
"not support the forced channel");
|
||||
return -1;
|
||||
}
|
||||
|
||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Selected operating "
|
||||
"channel (op_class %u channel %u) not acceptable to "
|
||||
"the peer", p2p->op_reg_class, p2p->op_channel);
|
||||
p2p_reselect_channel(p2p, &intersection);
|
||||
} else if (!(dev->flags & P2P_DEV_FORCE_FREQ) &&
|
||||
!p2p->cfg->cfg_op_channel) {
|
||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Try to optimize "
|
||||
"channel selection with peer information received; "
|
||||
"previously selected op_class %u channel %u",
|
||||
p2p->op_reg_class, p2p->op_channel);
|
||||
p2p_reselect_channel(p2p, &intersection);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user