P2P: Use preferred channel list during GO creation
This extends support for p2p_pref_Chan configuration parameter for autonomous GO creation. Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
parent
6d956c4064
commit
c6ccf12d3f
3 changed files with 43 additions and 0 deletions
|
@ -1631,6 +1631,15 @@ int p2p_channels_includes_freq(const struct p2p_channels *channels,
|
|||
*/
|
||||
int p2p_supported_freq(struct p2p_data *p2p, unsigned int freq);
|
||||
|
||||
/**
|
||||
* p2p_get_pref_freq - Get channel from preferred channel list
|
||||
* @p2p: P2P module context from p2p_init()
|
||||
* @channels: List of channels
|
||||
* Returns: Preferred channel
|
||||
*/
|
||||
unsigned int p2p_get_pref_freq(struct p2p_data *p2p,
|
||||
const struct p2p_channels *channels);
|
||||
|
||||
void p2p_update_channel_list(struct p2p_data *p2p, struct p2p_channels *chan);
|
||||
|
||||
/**
|
||||
|
|
|
@ -243,3 +243,31 @@ int p2p_supported_freq(struct p2p_data *p2p, unsigned int freq)
|
|||
return p2p_channels_includes(&p2p->cfg->channels, op_reg_class,
|
||||
op_channel);
|
||||
}
|
||||
|
||||
|
||||
unsigned int p2p_get_pref_freq(struct p2p_data *p2p,
|
||||
const struct p2p_channels *channels)
|
||||
{
|
||||
unsigned int i;
|
||||
int freq = 0;
|
||||
|
||||
if (channels == NULL) {
|
||||
if (p2p->cfg->num_pref_chan) {
|
||||
freq = p2p_channel_to_freq(
|
||||
p2p->cfg->pref_chan[0].op_class,
|
||||
p2p->cfg->pref_chan[0].chan);
|
||||
if (freq < 0)
|
||||
freq = 0;
|
||||
}
|
||||
return freq;
|
||||
}
|
||||
|
||||
for (i = 0; p2p->cfg->pref_chan && i < p2p->cfg->num_pref_chan; i++) {
|
||||
freq = p2p_channel_to_freq(p2p->cfg->pref_chan[i].op_class,
|
||||
p2p->cfg->pref_chan[i].chan);
|
||||
if (p2p_channels_includes_freq(channels, freq))
|
||||
return freq;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -3993,6 +3993,7 @@ static int wpas_p2p_init_go_params(struct wpa_supplicant *wpa_s,
|
|||
{
|
||||
u8 bssid[ETH_ALEN];
|
||||
int res;
|
||||
unsigned int pref_freq;
|
||||
|
||||
os_memset(params, 0, sizeof(*params));
|
||||
params->role_go = 1;
|
||||
|
@ -4049,6 +4050,11 @@ static int wpas_p2p_init_go_params(struct wpa_supplicant *wpa_s,
|
|||
params->freq = wpa_s->best_5_freq;
|
||||
wpa_printf(MSG_DEBUG, "P2P: Set GO freq based on best 5 GHz "
|
||||
"channel %d MHz", params->freq);
|
||||
} else if ((pref_freq = p2p_get_pref_freq(wpa_s->global->p2p,
|
||||
channels))) {
|
||||
params->freq = pref_freq;
|
||||
wpa_printf(MSG_DEBUG, "P2P: Set GO freq %d MHz from preferred "
|
||||
"channels", params->freq);
|
||||
} else {
|
||||
int chan;
|
||||
for (chan = 0; chan < 11; chan++) {
|
||||
|
|
Loading…
Reference in a new issue