From 7475d299abd623e0759a527be23552d639013ea1 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Wed, 22 Oct 2014 20:02:48 +0300 Subject: [PATCH] P2P: Search all 2.4 GHz social channels regardless of disallow_freq Commit 1595eb93aee0239de51f1090d4528e4b2cfe3add ('P2P: Add support for 60 GHz social channel') had an unintended change to how P2P search scans 2.4 GHz social channels. Use of p2p_supported_freq() to filter the list of social channels ended up using the disallow_freq setting to remove social channels from the P2P search scans. This is not desired since peers need to be found on any of the social channels even if those channels have been disabled from P2P operating channel use. Restore the previous behavior by included all the 2.4 GHz social channels in P2P search scans if the driver indicated support for the 2.4 GHz band. Signed-off-by: Jouni Malinen --- wpa_supplicant/p2p_supplicant.c | 28 ++++++++++++++++++++++++---- wpa_supplicant/wpa_supplicant_i.h | 1 + 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index d0e9e05dd..8cd43df19 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -279,6 +279,22 @@ static void wpas_p2p_trigger_scan_cb(struct wpa_radio_work *work, int deinit) } +static int wpas_p2p_search_social_channel(struct wpa_supplicant *wpa_s, + int freq) +{ + if (wpa_s->global->p2p_24ghz_social_channels && + (freq == 2412 || freq == 2437 || freq == 2462)) { + /* + * Search all social channels regardless of whether these have + * been disabled for P2P operating channel use to avoid missing + * peers. + */ + return 1; + } + return p2p_supported_freq(wpa_s->global->p2p, freq); +} + + static int wpas_p2p_scan(void *ctx, enum p2p_scan_type type, int freq, unsigned int num_req_dev_types, const u8 *req_dev_types, const u8 *dev_id, u16 pw_id) @@ -348,8 +364,8 @@ static int wpas_p2p_scan(void *ctx, enum p2p_scan_type type, int freq, if (params->freqs == NULL) goto fail; for (i = 0; i < ARRAY_SIZE(social_channels_freq); i++) { - if (p2p_supported_freq(wpa_s->global->p2p, - social_channels_freq[i])) + if (wpas_p2p_search_social_channel( + wpa_s, social_channels_freq[i])) params->freqs[num_channels++] = social_channels_freq[i]; } @@ -363,8 +379,8 @@ static int wpas_p2p_scan(void *ctx, enum p2p_scan_type type, int freq, if (params->freqs == NULL) goto fail; for (i = 0; i < ARRAY_SIZE(social_channels_freq); i++) { - if (p2p_supported_freq(wpa_s->global->p2p, - social_channels_freq[i])) + if (wpas_p2p_search_social_channel( + wpa_s, social_channels_freq[i])) params->freqs[num_channels++] = social_channels_freq[i]; } @@ -3416,6 +3432,8 @@ static int wpas_p2p_default_channels(struct wpa_supplicant *wpa_s, { int i, cla = 0; + wpa_s->global->p2p_24ghz_social_channels = 1; + os_memset(cli_chan, 0, sizeof(*cli_chan)); wpa_printf(MSG_DEBUG, "P2P: Enable operating classes for 2.4 GHz " @@ -3669,6 +3687,8 @@ static int wpas_p2p_setup_channels(struct wpa_supplicant *wpa_s, mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes, o->mode); if (mode == NULL) continue; + if (mode->mode == HOSTAPD_MODE_IEEE80211G) + wpa_s->global->p2p_24ghz_social_channels = 1; for (ch = o->min_chan; ch <= o->max_chan; ch += o->inc) { enum chan_allowed res; res = wpas_p2p_verify_channel(wpa_s, mode, ch, o->bw); diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index 5ad283d7b..0adbeb062 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -273,6 +273,7 @@ struct wpa_global { } conc_pref; unsigned int p2p_per_sta_psk:1; unsigned int p2p_fail_on_wps_complete:1; + unsigned int p2p_24ghz_social_channels:1; #ifdef CONFIG_WIFI_DISPLAY int wifi_display;