From 2ffd3bb4b6dfd497fa1fb228b2cb4c6dafe37735 Mon Sep 17 00:00:00 2001 From: Sreeramya Soratkal Date: Thu, 29 Oct 2020 19:15:47 +0530 Subject: [PATCH] P2P: Include p2p_6ghz_disable in global configuration Previously, the configuration to disable the 6 GHz band remained local to the P2P interface. With this there is a possibility of 6 GHz channels being included in the channel list when the channel list needs to be updated if the state changes on one of the interfaces. Include the configuration to disable the 6 GHz band for P2P as a global configuration value to prevent the inclusion of 6 GHz channels in the channel list for P2P when the channel list needs to be updated during the state change in one of the interfaces. Signed-off-by: Sreeramya Soratkal --- src/p2p/p2p.c | 8 ++++++++ src/p2p/p2p.h | 7 +++++++ wpa_supplicant/p2p_supplicant.c | 13 ++++++++----- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c index f9ca90301..6b92a6d23 100644 --- a/src/p2p/p2p.c +++ b/src/p2p/p2p.c @@ -2913,6 +2913,14 @@ void p2p_group_formation_failed(struct p2p_data *p2p) } +bool is_p2p_6ghz_disabled(struct p2p_data *p2p) +{ + if (p2p) + return p2p->cfg->p2p_6ghz_disable; + return false; +} + + struct p2p_data * p2p_init(const struct p2p_config *cfg) { struct p2p_data *p2p; diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h index 2dae6c6ec..ed8beab19 100644 --- a/src/p2p/p2p.h +++ b/src/p2p/p2p.h @@ -500,6 +500,11 @@ struct p2p_config { */ struct p2p_channel *pref_chan; + /** + * p2p_6ghz_disable - Disable 6GHz for P2P operations + */ + bool p2p_6ghz_disable; + /** * pri_dev_type - Primary Device Type (see WPS) */ @@ -2100,6 +2105,8 @@ void p2p_update_channel_list(struct p2p_data *p2p, const struct p2p_channels *chan, const struct p2p_channels *cli_chan); +bool is_p2p_6ghz_disabled(struct p2p_data *p2p); + /** * p2p_set_best_channels - Update best channel information * @p2p: P2P module context from p2p_init() diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index 330687b81..75e62a9e9 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -3752,7 +3752,8 @@ static enum chan_allowed wpas_p2p_verify_channel(struct wpa_supplicant *wpa_s, static int wpas_p2p_setup_channels(struct wpa_supplicant *wpa_s, struct p2p_channels *chan, - struct p2p_channels *cli_chan) + struct p2p_channels *cli_chan, + bool p2p_disable_6ghz) { struct hostapd_hw_modes *mode; int cla, op, cli_cla; @@ -3772,8 +3773,7 @@ static int wpas_p2p_setup_channels(struct wpa_supplicant *wpa_s, struct p2p_reg_class *reg = NULL, *cli_reg = NULL; if (o->p2p == NO_P2P_SUPP || - (is_6ghz_op_class(o->op_class) && - wpa_s->conf->p2p_6ghz_disable)) + (is_6ghz_op_class(o->op_class) && p2p_disable_6ghz)) continue; mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes, o->mode, @@ -4669,6 +4669,7 @@ int wpas_p2p_init(struct wpa_global *global, struct wpa_supplicant *wpa_s) p2p.prov_disc_resp_cb = wpas_prov_disc_resp_cb; p2p.p2ps_group_capability = p2ps_group_capability; p2p.get_pref_freq_list = wpas_p2p_get_pref_freq_list; + p2p.p2p_6ghz_disable = wpa_s->conf->p2p_6ghz_disable; os_memcpy(wpa_s->global->p2p_dev_addr, wpa_s->own_addr, ETH_ALEN); os_memcpy(p2p.dev_addr, wpa_s->global->p2p_dev_addr, ETH_ALEN); @@ -4682,7 +4683,8 @@ int wpas_p2p_init(struct wpa_global *global, struct wpa_supplicant *wpa_s) p2p.config_methods = wpa_s->wps->config_methods; } - if (wpas_p2p_setup_channels(wpa_s, &p2p.channels, &p2p.cli_channels)) { + if (wpas_p2p_setup_channels(wpa_s, &p2p.channels, &p2p.cli_channels, + p2p.p2p_6ghz_disable)) { wpa_printf(MSG_ERROR, "P2P: Failed to configure supported channel list"); return -1; @@ -8018,7 +8020,8 @@ void wpas_p2p_update_channel_list(struct wpa_supplicant *wpa_s, os_memset(&chan, 0, sizeof(chan)); os_memset(&cli_chan, 0, sizeof(cli_chan)); - if (wpas_p2p_setup_channels(wpa_s, &chan, &cli_chan)) { + if (wpas_p2p_setup_channels(wpa_s, &chan, &cli_chan, + is_p2p_6ghz_disabled(wpa_s->global->p2p))) { wpa_printf(MSG_ERROR, "P2P: Failed to update supported " "channel list"); return;