Use bool for is_6ghz variables and functions
Replace the implicit boolean checks that used int variables with use of a more explicit bool variable type. Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
This commit is contained in:
parent
9a411882bd
commit
6ead8b897f
11 changed files with 28 additions and 27 deletions
|
@ -2245,44 +2245,44 @@ int center_idx_to_bw_6ghz(u8 idx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int is_6ghz_freq(int freq)
|
bool is_6ghz_freq(int freq)
|
||||||
{
|
{
|
||||||
if (freq < 5935 || freq > 7115)
|
if (freq < 5935 || freq > 7115)
|
||||||
return 0;
|
return false;
|
||||||
|
|
||||||
if (freq == 5935)
|
if (freq == 5935)
|
||||||
return 1;
|
return true;
|
||||||
|
|
||||||
if (center_idx_to_bw_6ghz((freq - 5950) / 5) < 0)
|
if (center_idx_to_bw_6ghz((freq - 5950) / 5) < 0)
|
||||||
return 0;
|
return false;
|
||||||
|
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int is_6ghz_op_class(u8 op_class)
|
bool is_6ghz_op_class(u8 op_class)
|
||||||
{
|
{
|
||||||
return op_class >= 131 && op_class <= 136;
|
return op_class >= 131 && op_class <= 136;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int is_6ghz_psc_frequency(int freq)
|
bool is_6ghz_psc_frequency(int freq)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!is_6ghz_freq(freq) || freq == 5935)
|
if (!is_6ghz_freq(freq) || freq == 5935)
|
||||||
return 0;
|
return false;
|
||||||
if ((((freq - 5950) / 5) & 0x3) != 0x1)
|
if ((((freq - 5950) / 5) & 0x3) != 0x1)
|
||||||
return 0;
|
return false;
|
||||||
|
|
||||||
i = (freq - 5950 + 55) % 80;
|
i = (freq - 5950 + 55) % 80;
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
i = (freq - 5950 + 55) / 80;
|
i = (freq - 5950 + 55) / 80;
|
||||||
|
|
||||||
if (i >= 1 && i <= 15)
|
if (i >= 1 && i <= 15)
|
||||||
return 1;
|
return true;
|
||||||
|
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -259,9 +259,9 @@ u8 country_to_global_op_class(const char *country, u8 op_class);
|
||||||
const struct oper_class_map * get_oper_class(const char *country, u8 op_class);
|
const struct oper_class_map * get_oper_class(const char *country, u8 op_class);
|
||||||
int oper_class_bw_to_int(const struct oper_class_map *map);
|
int oper_class_bw_to_int(const struct oper_class_map *map);
|
||||||
int center_idx_to_bw_6ghz(u8 idx);
|
int center_idx_to_bw_6ghz(u8 idx);
|
||||||
int is_6ghz_freq(int freq);
|
bool is_6ghz_freq(int freq);
|
||||||
int is_6ghz_op_class(u8 op_class);
|
bool is_6ghz_op_class(u8 op_class);
|
||||||
int is_6ghz_psc_frequency(int freq);
|
bool is_6ghz_psc_frequency(int freq);
|
||||||
|
|
||||||
int ieee802_11_parse_candidate_list(const char *pos, u8 *nei_rep,
|
int ieee802_11_parse_candidate_list(const char *pos, u8 *nei_rep,
|
||||||
size_t nei_rep_len);
|
size_t nei_rep_len);
|
||||||
|
|
|
@ -3493,7 +3493,7 @@ static void wpas_dpp_chirp_scan_res_handler(struct wpa_supplicant *wpa_s,
|
||||||
|
|
||||||
/* Preferred chirping channels */
|
/* Preferred chirping channels */
|
||||||
mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes,
|
mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes,
|
||||||
HOSTAPD_MODE_IEEE80211G, 0);
|
HOSTAPD_MODE_IEEE80211G, false);
|
||||||
chan6 = mode == NULL;
|
chan6 = mode == NULL;
|
||||||
if (mode) {
|
if (mode) {
|
||||||
for (c = 0; c < mode->num_channels; c++) {
|
for (c = 0; c < mode->num_channels; c++) {
|
||||||
|
@ -3510,7 +3510,7 @@ static void wpas_dpp_chirp_scan_res_handler(struct wpa_supplicant *wpa_s,
|
||||||
int_array_add_unique(&wpa_s->dpp_chirp_freqs, 2437);
|
int_array_add_unique(&wpa_s->dpp_chirp_freqs, 2437);
|
||||||
|
|
||||||
mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes,
|
mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes,
|
||||||
HOSTAPD_MODE_IEEE80211A, 0);
|
HOSTAPD_MODE_IEEE80211A, false);
|
||||||
if (mode) {
|
if (mode) {
|
||||||
int chan44 = 0, chan149 = 0;
|
int chan44 = 0, chan149 = 0;
|
||||||
|
|
||||||
|
@ -3532,7 +3532,7 @@ static void wpas_dpp_chirp_scan_res_handler(struct wpa_supplicant *wpa_s,
|
||||||
}
|
}
|
||||||
|
|
||||||
mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes,
|
mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes,
|
||||||
HOSTAPD_MODE_IEEE80211AD, 0);
|
HOSTAPD_MODE_IEEE80211AD, false);
|
||||||
if (mode) {
|
if (mode) {
|
||||||
for (c = 0; c < mode->num_channels; c++) {
|
for (c = 0; c < mode->num_channels; c++) {
|
||||||
struct hostapd_channel_data *chan = &mode->channels[c];
|
struct hostapd_channel_data *chan = &mode->channels[c];
|
||||||
|
|
|
@ -22,10 +22,10 @@ static enum chan_allowed allow_channel(struct hostapd_hw_modes *mode,
|
||||||
unsigned int *flags)
|
unsigned int *flags)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int is_6ghz = op_class >= 131 && op_class <= 136;
|
bool is_6ghz = op_class >= 131 && op_class <= 136;
|
||||||
|
|
||||||
for (i = 0; i < mode->num_channels; i++) {
|
for (i = 0; i < mode->num_channels; i++) {
|
||||||
int chan_is_6ghz;
|
bool chan_is_6ghz;
|
||||||
|
|
||||||
chan_is_6ghz = mode->channels[i].freq >= 5935 &&
|
chan_is_6ghz = mode->channels[i].freq >= 5935 &&
|
||||||
mode->channels[i].freq <= 7115;
|
mode->channels[i].freq <= 7115;
|
||||||
|
|
|
@ -1921,7 +1921,7 @@ static int wpas_p2p_freq_to_edmg_channel(struct wpa_supplicant *wpa_s,
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
hwmode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes,
|
hwmode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes,
|
||||||
HOSTAPD_MODE_IEEE80211AD, 0);
|
HOSTAPD_MODE_IEEE80211AD, false);
|
||||||
if (!hwmode) {
|
if (!hwmode) {
|
||||||
wpa_printf(MSG_ERROR,
|
wpa_printf(MSG_ERROR,
|
||||||
"Unsupported AP mode: HOSTAPD_MODE_IEEE80211AD");
|
"Unsupported AP mode: HOSTAPD_MODE_IEEE80211AD");
|
||||||
|
|
|
@ -563,7 +563,7 @@ static int * wpas_op_class_freqs(const struct oper_class_map *op,
|
||||||
u8 channels_160mhz_6ghz[] = { 15, 47, 79, 111, 143, 175, 207 };
|
u8 channels_160mhz_6ghz[] = { 15, 47, 79, 111, 143, 175, 207 };
|
||||||
const u8 *channels = NULL;
|
const u8 *channels = NULL;
|
||||||
size_t num_chan = 0;
|
size_t num_chan = 0;
|
||||||
int is_6ghz = is_6ghz_op_class(op->op_class);
|
bool is_6ghz = is_6ghz_op_class(op->op_class);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When adding all channels in the operating class, 80 + 80 MHz
|
* When adding all channels in the operating class, 80 + 80 MHz
|
||||||
|
|
|
@ -672,7 +672,7 @@ static int non_p2p_network_enabled(struct wpa_supplicant *wpa_s)
|
||||||
|
|
||||||
int wpa_add_scan_freqs_list(struct wpa_supplicant *wpa_s,
|
int wpa_add_scan_freqs_list(struct wpa_supplicant *wpa_s,
|
||||||
enum hostapd_hw_mode band,
|
enum hostapd_hw_mode band,
|
||||||
struct wpa_driver_scan_params *params, int is_6ghz)
|
struct wpa_driver_scan_params *params, bool is_6ghz)
|
||||||
{
|
{
|
||||||
/* Include only supported channels for the specified band */
|
/* Include only supported channels for the specified band */
|
||||||
struct hostapd_hw_modes *mode;
|
struct hostapd_hw_modes *mode;
|
||||||
|
|
|
@ -88,6 +88,7 @@ unsigned int wpas_get_est_tpt(const struct wpa_supplicant *wpa_s,
|
||||||
void wpa_supplicant_set_default_scan_ies(struct wpa_supplicant *wpa_s);
|
void wpa_supplicant_set_default_scan_ies(struct wpa_supplicant *wpa_s);
|
||||||
int wpa_add_scan_freqs_list(struct wpa_supplicant *wpa_s,
|
int wpa_add_scan_freqs_list(struct wpa_supplicant *wpa_s,
|
||||||
enum hostapd_hw_mode band,
|
enum hostapd_hw_mode band,
|
||||||
struct wpa_driver_scan_params *params, int is_6ghz);
|
struct wpa_driver_scan_params *params,
|
||||||
|
bool is_6ghz);
|
||||||
|
|
||||||
#endif /* SCAN_H */
|
#endif /* SCAN_H */
|
||||||
|
|
|
@ -2462,7 +2462,7 @@ static void wpa_obss_scan_freqs_list(struct wpa_supplicant *wpa_s,
|
||||||
int start, end;
|
int start, end;
|
||||||
|
|
||||||
mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes,
|
mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes,
|
||||||
HOSTAPD_MODE_IEEE80211G, 0);
|
HOSTAPD_MODE_IEEE80211G, false);
|
||||||
if (mode == NULL) {
|
if (mode == NULL) {
|
||||||
/* No channels supported in this band - use empty list */
|
/* No channels supported in this band - use empty list */
|
||||||
params->freqs = os_zalloc(sizeof(int));
|
params->freqs = os_zalloc(sizeof(int));
|
||||||
|
|
|
@ -3395,7 +3395,7 @@ get_supported_edmg(struct wpa_supplicant *wpa_s,
|
||||||
if (hw_mode == NUM_HOSTAPD_MODES)
|
if (hw_mode == NUM_HOSTAPD_MODES)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes, hw_mode, 0);
|
mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes, hw_mode, false);
|
||||||
if (!mode)
|
if (!mode)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
@ -8055,7 +8055,7 @@ int wpas_vendor_elem_remove(struct wpa_supplicant *wpa_s, int frame,
|
||||||
|
|
||||||
struct hostapd_hw_modes * get_mode(struct hostapd_hw_modes *modes,
|
struct hostapd_hw_modes * get_mode(struct hostapd_hw_modes *modes,
|
||||||
u16 num_modes, enum hostapd_hw_mode mode,
|
u16 num_modes, enum hostapd_hw_mode mode,
|
||||||
int is_6ghz)
|
bool is_6ghz)
|
||||||
{
|
{
|
||||||
u16 i;
|
u16 i;
|
||||||
|
|
||||||
|
|
|
@ -1620,7 +1620,7 @@ int wpas_sched_scan_plans_set(struct wpa_supplicant *wpa_s, const char *cmd);
|
||||||
|
|
||||||
struct hostapd_hw_modes * get_mode(struct hostapd_hw_modes *modes,
|
struct hostapd_hw_modes * get_mode(struct hostapd_hw_modes *modes,
|
||||||
u16 num_modes, enum hostapd_hw_mode mode,
|
u16 num_modes, enum hostapd_hw_mode mode,
|
||||||
int is_6ghz);
|
bool is_6ghz);
|
||||||
|
|
||||||
void wpa_bss_tmp_disallow(struct wpa_supplicant *wpa_s, const u8 *bssid,
|
void wpa_bss_tmp_disallow(struct wpa_supplicant *wpa_s, const u8 *bssid,
|
||||||
unsigned int sec, int rssi_threshold);
|
unsigned int sec, int rssi_threshold);
|
||||||
|
|
Loading…
Reference in a new issue