P2P: Try using one of the social channels for GO

In case there is no preference for the GO operating channel,
try using one of 1, 6, 11 (randomly), and only if the random
selection is not suitable traverse all the channels 1..11.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
This commit is contained in:
Ilan Peer 2014-05-19 10:05:38 +03:00 committed by Jouni Malinen
parent 751b00ba28
commit 28812a8983

View file

@ -5014,6 +5014,39 @@ static int wpas_p2p_select_go_freq(struct wpa_supplicant *wpa_s, int freq)
} }
static int wpas_p2p_select_freq_no_pref(struct wpa_supplicant *wpa_s,
struct p2p_go_neg_results *params,
const struct p2p_channels *channels)
{
unsigned int i, r;
/* first try some random selection of the social channels */
os_get_random((u8 *) &r, sizeof(r));
for (i = 0; i < 3; i++) {
params->freq = 2412 + ((r + i) % 3) * 25;
if (!wpas_p2p_disallowed_freq(wpa_s->global, params->freq) &&
freq_included(channels, params->freq))
goto out;
}
/* try all channels in reg. class 81 */
for (i = 0; i < 11; i++) {
params->freq = 2412 + i * 5;
if (!wpas_p2p_disallowed_freq(wpa_s->global, params->freq) &&
freq_included(channels, params->freq))
goto out;
}
wpa_printf(MSG_DEBUG, "P2P: No 2.4 GHz channel allowed");
return -1;
out:
wpa_printf(MSG_DEBUG, "P2P: Set GO freq %d MHz (no preference known)",
params->freq);
return 0;
}
static int wpas_p2p_init_go_params(struct wpa_supplicant *wpa_s, static int wpas_p2p_init_go_params(struct wpa_supplicant *wpa_s,
struct p2p_go_neg_results *params, struct p2p_go_neg_results *params,
int freq, int ht40, int vht, int freq, int ht40, int vht,
@ -5085,22 +5118,10 @@ static int wpas_p2p_init_go_params(struct wpa_supplicant *wpa_s,
wpa_printf(MSG_DEBUG, "P2P: Set GO freq %d MHz from preferred " wpa_printf(MSG_DEBUG, "P2P: Set GO freq %d MHz from preferred "
"channels", params->freq); "channels", params->freq);
} else { } else {
int chan; /* no preference, select some channel */
for (chan = 0; chan < 11; chan++) { if (wpas_p2p_select_freq_no_pref(wpa_s, params, channels) < 0)
params->freq = 2412 + chan * 5;
if (!wpas_p2p_disallowed_freq(wpa_s->global,
params->freq) &&
freq_included(channels, params->freq))
break;
}
if (chan == 11) {
wpa_printf(MSG_DEBUG, "P2P: No 2.4 GHz channel "
"allowed");
return -1; return -1;
} }
wpa_printf(MSG_DEBUG, "P2P: Set GO freq %d MHz (no preference "
"known)", params->freq);
}
freqs = os_calloc(wpa_s->num_multichan_concurrent, freqs = os_calloc(wpa_s->num_multichan_concurrent,
sizeof(struct wpa_used_freq_data)); sizeof(struct wpa_used_freq_data));