diff --git a/wpa_supplicant/bss.c b/wpa_supplicant/bss.c index d5bb04046..e2ac23072 100644 --- a/wpa_supplicant/bss.c +++ b/wpa_supplicant/bss.c @@ -19,15 +19,12 @@ #include "common/ieee802_11_defs.h" #include "drivers/driver.h" #include "wpa_supplicant_i.h" +#include "config.h" #include "notify.h" #include "scan.h" #include "bss.h" -#ifndef WPA_BSS_MAX_COUNT -#define WPA_BSS_MAX_COUNT 200 -#endif /* WPA_BSS_MAX_COUNT */ - /** * WPA_BSS_EXPIRATION_PERIOD - Period of expiration run in seconds */ @@ -139,7 +136,7 @@ static void wpa_bss_add(struct wpa_supplicant *wpa_s, wpa_printf(MSG_DEBUG, "BSS: Add new id %u BSSID " MACSTR " SSID '%s'", bss->id, MAC2STR(bss->bssid), wpa_ssid_txt(ssid, ssid_len)); wpas_notify_bss_added(wpa_s, bss->bssid, bss->id); - if (wpa_s->num_bss > WPA_BSS_MAX_COUNT) { + if (wpa_s->num_bss > wpa_s->conf->bss_max_count) { /* Remove the oldest entry */ wpa_bss_remove(wpa_s, dl_list_first(&wpa_s->bss, struct wpa_bss, list)); diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c index da56dc8e3..68c6b6eab 100644 --- a/wpa_supplicant/config.c +++ b/wpa_supplicant/config.c @@ -2086,6 +2086,7 @@ struct wpa_config * wpa_config_alloc_empty(const char *ctrl_interface, config->eapol_version = DEFAULT_EAPOL_VERSION; config->ap_scan = DEFAULT_AP_SCAN; config->fast_reauth = DEFAULT_FAST_REAUTH; + config->bss_max_count = DEFAULT_BSS_MAX_COUNT; if (ctrl_interface) config->ctrl_interface = os_strdup(ctrl_interface); diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h index bdc3553c8..cdf3d4080 100644 --- a/wpa_supplicant/config.h +++ b/wpa_supplicant/config.h @@ -22,6 +22,7 @@ #define DEFAULT_AP_SCAN 1 #endif /* CONFIG_NO_SCAN_PROCESSING */ #define DEFAULT_FAST_REAUTH 1 +#define DEFAULT_BSS_MAX_COUNT 200 #include "config_ssid.h" @@ -331,6 +332,11 @@ struct wpa_config { * ctrl_iface to external program(s) */ int wps_cred_processing; + + /** + * bss_max_count - Maximum number of BSS entries to keep in memory + */ + unsigned int bss_max_count; }; diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c index 5b6233e63..fa477fa49 100644 --- a/wpa_supplicant/config_file.c +++ b/wpa_supplicant/config_file.c @@ -457,7 +457,8 @@ static const struct global_parse_data global_fields[] = { { STR(config_methods) }, { INT_RANGE(wps_cred_processing, 0, 2) }, #endif /* CONFIG_WPS */ - { FUNC(country) } + { FUNC(country) }, + { INT(bss_max_count) } }; #undef FUNC @@ -889,6 +890,8 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config) fprintf(f, "country=%c%c\n", config->country[0], config->country[1]); } + if (config->bss_max_count != DEFAULT_BSS_MAX_COUNT) + fprintf(f, "bss_max_count=%u\n", config->bss_max_count); } #endif /* CONFIG_NO_CONFIG_WRITE */ diff --git a/wpa_supplicant/config_winreg.c b/wpa_supplicant/config_winreg.c index 6bd003b6b..6c2507325 100644 --- a/wpa_supplicant/config_winreg.c +++ b/wpa_supplicant/config_winreg.c @@ -257,6 +257,9 @@ static int wpa_config_read_global(struct wpa_config *config, HKEY hk) &config->wps_cred_processing); #endif /* CONFIG_WPS */ + wpa_config_read_reg_dword(hk, TEXT("bss_max_count"), + &config->bss_max_count); + return errors ? -1 : 0; } @@ -583,6 +586,10 @@ static int wpa_config_write_global(struct wpa_config *config, HKEY hk) config->wps_cred_processing, 0); #endif /* CONFIG_WPS */ + wpa_config_write_reg_dword(hk, TEXT("bss_max_count"), + config->bss_max_count, + DEFAULT_BSS_MAX_COUNT); + return 0; } diff --git a/wpa_supplicant/wpa_supplicant.conf b/wpa_supplicant/wpa_supplicant.conf index 4866ae41f..070abcf29 100644 --- a/wpa_supplicant/wpa_supplicant.conf +++ b/wpa_supplicant/wpa_supplicant.conf @@ -210,6 +210,14 @@ fast_reauth=1 # to external program(s) #wps_cred_processing=0 +# Maximum number of BSS entries to keep in memory +# Default: 200 +# This can be used to limit memory use on the BSS entries (cached scan +# results). A larger value may be needed in environments that have huge number +# of APs when using ap_scan=1 mode. +#bss_max_count=200 + + # network block # # Each network (usually AP's sharing the same SSID) is configured as a separate