P2P: Add support for preferred channel list

p2p_pref_chan configuration parameter can now be used to set the
list of preferred channel for P2P GO Negotiation. This will be used
in the priority order if the peer does not support the channel we
are trying to use as the GO (configured operating channel or the
best 2.4 GHz/5 GHz channel) for the case where a forced channel is
not used.

p2p_pref_chan=<op class:channel>,...

For example:
p2p_pref_chan=81:1,81:2,81:3,81:4,81:5,81:6

This would configure 2.4 GHz channels 1-6 as the preferred ones with
channel 1 the most preferred option.

These configuration parameters can be set in wpa_supplicant.conf and
dynamically updated with "wpa_cli set <param> <value>".

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Jouni Malinen 2012-03-29 21:28:34 +03:00 committed by Jouni Malinen
parent 564865e1d4
commit 21d996f775
7 changed files with 148 additions and 0 deletions

View file

@ -2212,6 +2212,16 @@ struct p2p_data * p2p_init(const struct p2p_config *cfg)
p2p->cfg->model_number = os_strdup(cfg->model_number);
if (cfg->serial_number)
p2p->cfg->serial_number = os_strdup(cfg->serial_number);
if (cfg->pref_chan) {
p2p->cfg->pref_chan = os_malloc(cfg->num_pref_chan *
sizeof(struct p2p_channel));
if (p2p->cfg->pref_chan) {
os_memcpy(p2p->cfg->pref_chan, cfg->pref_chan,
cfg->num_pref_chan *
sizeof(struct p2p_channel));
} else
p2p->cfg->num_pref_chan = 0;
}
p2p->min_disc_int = 1;
p2p->max_disc_int = 3;
@ -2246,6 +2256,7 @@ void p2p_deinit(struct p2p_data *p2p)
os_free(p2p->cfg->model_name);
os_free(p2p->cfg->model_number);
os_free(p2p->cfg->serial_number);
os_free(p2p->cfg->pref_chan);
os_free(p2p->groups);
wpabuf_free(p2p->sd_resp);
os_free(p2p->after_scan_tx);
@ -3701,6 +3712,28 @@ int p2p_set_oper_channel(struct p2p_data *p2p, u8 op_reg_class, u8 op_channel,
}
int p2p_set_pref_chan(struct p2p_data *p2p, unsigned int num_pref_chan,
const struct p2p_channel *pref_chan)
{
struct p2p_channel *n;
if (pref_chan) {
n = os_malloc(num_pref_chan * sizeof(struct p2p_channel));
if (n == NULL)
return -1;
os_memcpy(n, pref_chan,
num_pref_chan * sizeof(struct p2p_channel));
} else
n = NULL;
os_free(p2p->cfg->pref_chan);
p2p->cfg->pref_chan = n;
p2p->cfg->num_pref_chan = num_pref_chan;
return 0;
}
int p2p_get_interface_addr(struct p2p_data *p2p, const u8 *dev_addr,
u8 *iface_addr)
{