mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2025-01-18 10:54:03 -05:00
ACS: Simplify code paths
This removes some unnecessarily duplicated return paths and simplifies code paths. Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
9960434dcf
commit
29be2c090e
44
src/ap/acs.c
44
src/ap/acs.c
@ -331,10 +331,8 @@ acs_survey_chan_interference_factor(struct hostapd_iface *iface,
|
|||||||
long double int_factor = 0;
|
long double int_factor = 0;
|
||||||
unsigned count = 0;
|
unsigned count = 0;
|
||||||
|
|
||||||
if (dl_list_empty(&chan->survey_list))
|
if (dl_list_empty(&chan->survey_list) ||
|
||||||
return;
|
(chan->flag & HOSTAPD_CHAN_DISABLED))
|
||||||
|
|
||||||
if (chan->flag & HOSTAPD_CHAN_DISABLED)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
chan->interference_factor = 0;
|
chan->interference_factor = 0;
|
||||||
@ -359,9 +357,8 @@ acs_survey_chan_interference_factor(struct hostapd_iface *iface,
|
|||||||
(unsigned long) survey->channel_time_rx);
|
(unsigned long) survey->channel_time_rx);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!count)
|
if (count)
|
||||||
return;
|
chan->interference_factor /= count;
|
||||||
chan->interference_factor /= count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -450,13 +447,9 @@ static int acs_surveys_are_sufficient(struct hostapd_iface *iface)
|
|||||||
|
|
||||||
for (i = 0; i < iface->current_mode->num_channels; i++) {
|
for (i = 0; i < iface->current_mode->num_channels; i++) {
|
||||||
chan = &iface->current_mode->channels[i];
|
chan = &iface->current_mode->channels[i];
|
||||||
if (chan->flag & HOSTAPD_CHAN_DISABLED)
|
if (!(chan->flag & HOSTAPD_CHAN_DISABLED) &&
|
||||||
continue;
|
acs_survey_list_is_sufficient(chan))
|
||||||
|
valid++;
|
||||||
if (!acs_survey_list_is_sufficient(chan))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
valid++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We need at least survey data for one channel */
|
/* We need at least survey data for one channel */
|
||||||
@ -466,13 +459,9 @@ static int acs_surveys_are_sufficient(struct hostapd_iface *iface)
|
|||||||
|
|
||||||
static int acs_usable_chan(struct hostapd_channel_data *chan)
|
static int acs_usable_chan(struct hostapd_channel_data *chan)
|
||||||
{
|
{
|
||||||
if (dl_list_empty(&chan->survey_list))
|
return !dl_list_empty(&chan->survey_list) &&
|
||||||
return 0;
|
!(chan->flag & HOSTAPD_CHAN_DISABLED) &&
|
||||||
if (chan->flag & HOSTAPD_CHAN_DISABLED)
|
acs_survey_list_is_sufficient(chan);
|
||||||
return 0;
|
|
||||||
if (!acs_survey_list_is_sufficient(chan))
|
|
||||||
return 0;
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -788,10 +777,7 @@ static int acs_study_survey_based(struct hostapd_iface *iface)
|
|||||||
|
|
||||||
static int acs_study_options(struct hostapd_iface *iface)
|
static int acs_study_options(struct hostapd_iface *iface)
|
||||||
{
|
{
|
||||||
int err;
|
if (acs_study_survey_based(iface) == 0)
|
||||||
|
|
||||||
err = acs_study_survey_based(iface);
|
|
||||||
if (err == 0)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* TODO: If no surveys are available/sufficient this is a good
|
/* TODO: If no surveys are available/sufficient this is a good
|
||||||
@ -920,14 +906,11 @@ static int acs_request_scan(struct hostapd_iface *iface)
|
|||||||
|
|
||||||
enum hostapd_chan_status acs_init(struct hostapd_iface *iface)
|
enum hostapd_chan_status acs_init(struct hostapd_iface *iface)
|
||||||
{
|
{
|
||||||
int err;
|
|
||||||
|
|
||||||
wpa_printf(MSG_INFO, "ACS: Automatic channel selection started, this may take a bit");
|
wpa_printf(MSG_INFO, "ACS: Automatic channel selection started, this may take a bit");
|
||||||
|
|
||||||
if (iface->drv_flags & WPA_DRIVER_FLAGS_ACS_OFFLOAD) {
|
if (iface->drv_flags & WPA_DRIVER_FLAGS_ACS_OFFLOAD) {
|
||||||
wpa_printf(MSG_INFO, "ACS: Offloading to driver");
|
wpa_printf(MSG_INFO, "ACS: Offloading to driver");
|
||||||
err = hostapd_drv_do_acs(iface->bss[0]);
|
if (hostapd_drv_do_acs(iface->bss[0]))
|
||||||
if (err)
|
|
||||||
return HOSTAPD_CHAN_INVALID;
|
return HOSTAPD_CHAN_INVALID;
|
||||||
return HOSTAPD_CHAN_ACS;
|
return HOSTAPD_CHAN_ACS;
|
||||||
}
|
}
|
||||||
@ -937,8 +920,7 @@ enum hostapd_chan_status acs_init(struct hostapd_iface *iface)
|
|||||||
|
|
||||||
acs_cleanup(iface);
|
acs_cleanup(iface);
|
||||||
|
|
||||||
err = acs_request_scan(iface);
|
if (acs_request_scan(iface) < 0)
|
||||||
if (err < 0)
|
|
||||||
return HOSTAPD_CHAN_INVALID;
|
return HOSTAPD_CHAN_INVALID;
|
||||||
|
|
||||||
hostapd_set_state(iface, HAPD_IFACE_ACS);
|
hostapd_set_state(iface, HAPD_IFACE_ACS);
|
||||||
|
Loading…
Reference in New Issue
Block a user