diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c index 09ee51089..88cdd4eab 100644 --- a/src/p2p/p2p.c +++ b/src/p2p/p2p.c @@ -1397,8 +1397,8 @@ static int p2p_prepare_channel_pref(struct p2p_data *p2p, p2p->channels.reg_class[0].reg_class = p2p->op_reg_class; p2p->channels.reg_class[0].channel[0] = p2p->op_channel; } else { - os_memcpy(&p2p->channels, &p2p->cfg->channels, - sizeof(struct p2p_channels)); + p2p_copy_channels(&p2p->channels, &p2p->cfg->channels, + p2p->allow_6ghz); } return 0; @@ -1485,8 +1485,7 @@ static void p2p_prepare_channel_best(struct p2p_data *p2p) p2p->op_channel, p2p->op_reg_class); } - os_memcpy(&p2p->channels, &p2p->cfg->channels, - sizeof(struct p2p_channels)); + p2p_copy_channels(&p2p->channels, &p2p->cfg->channels, p2p->allow_6ghz); } @@ -5593,6 +5592,7 @@ bool p2p_is_peer_6ghz_capab(struct p2p_data *p2p, const u8 *addr) void p2p_set_6ghz_dev_capab(struct p2p_data *p2p, bool allow_6ghz) { p2p->p2p_6ghz_capable = allow_6ghz; + p2p->allow_6ghz = allow_6ghz; p2p_dbg(p2p, "Set 6 GHz capability to %d", allow_6ghz); if (allow_6ghz) @@ -5629,3 +5629,15 @@ bool p2p_peer_wfd_enabled(struct p2p_data *p2p, const u8 *peer_addr) return false; #endif /* CONFIG_WIFI_DISPLAY */ } + + +bool is_p2p_allow_6ghz(struct p2p_data *p2p) +{ + return p2p->allow_6ghz; +} + + +void set_p2p_allow_6ghz(struct p2p_data *p2p, bool value) +{ + p2p->allow_6ghz = value; +} diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h index 17809a661..4c6e8afef 100644 --- a/src/p2p/p2p.h +++ b/src/p2p/p2p.h @@ -2420,5 +2420,7 @@ bool is_p2p_6ghz_capable(struct p2p_data *p2p); bool p2p_is_peer_6ghz_capab(struct p2p_data *p2p, const u8 *addr); bool p2p_peer_wfd_enabled(struct p2p_data *p2p, const u8 *peer_addr); bool p2p_wfd_enabled(struct p2p_data *p2p); +bool is_p2p_allow_6ghz(struct p2p_data *p2p); +void set_p2p_allow_6ghz(struct p2p_data *p2p, bool value); #endif /* P2P_H */ diff --git a/src/p2p/p2p_i.h b/src/p2p/p2p_i.h index b778efad8..8220e8550 100644 --- a/src/p2p/p2p_i.h +++ b/src/p2p/p2p_i.h @@ -550,6 +550,7 @@ struct p2p_data { u8 override_pref_channel; bool p2p_6ghz_capable; bool include_6ghz; + bool allow_6ghz; }; /** @@ -700,6 +701,8 @@ int p2p_channel_random_social(struct p2p_channels *chans, u8 *op_class, u8 *op_channel, struct wpa_freq_range_list *avoid_list, struct wpa_freq_range_list *disallow_list); +void p2p_copy_channels(struct p2p_channels *dst, const struct p2p_channels *src, + bool allow_6ghz); /* p2p_parse.c */ void p2p_copy_filter_devname(char *dst, size_t dst_len, diff --git a/src/p2p/p2p_utils.c b/src/p2p/p2p_utils.c index 1a62a44a2..06ab79920 100644 --- a/src/p2p/p2p_utils.c +++ b/src/p2p/p2p_utils.c @@ -496,3 +496,24 @@ int p2p_channels_to_freqs(const struct p2p_channels *channels, int *freq_list, return idx; } + + +void p2p_copy_channels(struct p2p_channels *dst, + const struct p2p_channels *src, bool allow_6ghz) +{ + size_t i, j; + + if (allow_6ghz) { + os_memcpy(dst, src, sizeof(struct p2p_channels)); + return; + } + + for (i = 0, j = 0; i < P2P_MAX_REG_CLASSES; i++) { + if (is_6ghz_op_class(src->reg_class[i].reg_class)) + continue; + os_memcpy(&dst->reg_class[j], &src->reg_class[i], + sizeof(struct p2p_reg_class)); + j++; + } + dst->reg_classes = j; +}