From dae608d5d3373845ad46f84def12364c8a6a4159 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 19 Oct 2010 17:08:20 +0300 Subject: [PATCH] Add max_num_sta config option for wpa_supplicant AP mode This can be used to limit the number of stations allowed to be connected to the AP. --- wpa_supplicant/ap.c | 2 ++ wpa_supplicant/config.c | 4 +++- wpa_supplicant/config.h | 6 ++++++ wpa_supplicant/config_file.c | 2 ++ wpa_supplicant/config_winreg.c | 4 ++++ 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c index ea5754010..a196e2484 100644 --- a/wpa_supplicant/ap.c +++ b/wpa_supplicant/ap.c @@ -178,6 +178,8 @@ static int wpa_supplicant_conf_ap(struct wpa_supplicant *wpa_s, os_memcpy(bss->os_version, wpa_s->conf->os_version, 4); #endif /* CONFIG_WPS */ + bss->max_num_sta = wpa_s->conf->max_num_sta; + return 0; } diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c index 6e03760a9..24bbf0fdf 100644 --- a/wpa_supplicant/config.c +++ b/wpa_supplicant/config.c @@ -2146,6 +2146,7 @@ struct wpa_config * wpa_config_alloc_empty(const char *ctrl_interface, config->p2p_go_intent = DEFAULT_P2P_GO_INTENT; config->p2p_intra_bss = DEFAULT_P2P_INTRA_BSS; config->bss_max_count = DEFAULT_BSS_MAX_COUNT; + config->max_num_sta = DEFAULT_MAX_NUM_STA; if (ctrl_interface) config->ctrl_interface = os_strdup(ctrl_interface); @@ -2405,7 +2406,8 @@ static const struct global_parse_data global_fields[] = { #endif /* CONFIG_P2P */ { FUNC(country), CFG_CHANGED_COUNTRY }, { INT(bss_max_count), 0 }, - { INT_RANGE(filter_ssids, 0, 1), 0 } + { INT_RANGE(filter_ssids, 0, 1), 0 }, + { INT(max_num_sta), 0 } }; #undef FUNC diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h index 246c65fc3..ff4cf22de 100644 --- a/wpa_supplicant/config.h +++ b/wpa_supplicant/config.h @@ -25,6 +25,7 @@ #define DEFAULT_P2P_GO_INTENT 7 #define DEFAULT_P2P_INTRA_BSS 1 #define DEFAULT_BSS_MAX_COUNT 200 +#define DEFAULT_MAX_NUM_STA 128 #include "config_ssid.h" @@ -378,6 +379,11 @@ struct wpa_config { */ int filter_ssids; + /** + * max_num_sta - Maximum number of STAs in an AP/P2P GO + */ + unsigned int max_num_sta; + /** * changed_parameters - Bitmap of changed parameters since last update */ diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c index 0f343fd04..a203e4331 100644 --- a/wpa_supplicant/config_file.c +++ b/wpa_supplicant/config_file.c @@ -685,6 +685,8 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config) fprintf(f, "bss_max_count=%u\n", config->bss_max_count); if (config->filter_ssids) fprintf(f, "filter_ssids=%d\n", config->filter_ssids); + if (config->max_num_sta != DEFAULT_MAX_NUM_STA) + fprintf(f, "max_num_sta=%u\n", config->max_num_sta); } #endif /* CONFIG_NO_CONFIG_WRITE */ diff --git a/wpa_supplicant/config_winreg.c b/wpa_supplicant/config_winreg.c index deebbd948..b2078af4f 100644 --- a/wpa_supplicant/config_winreg.c +++ b/wpa_supplicant/config_winreg.c @@ -265,6 +265,8 @@ static int wpa_config_read_global(struct wpa_config *config, HKEY hk) (int *) &config->bss_max_count); wpa_config_read_reg_dword(hk, TEXT("filter_ssids"), &config->filter_ssids); + wpa_config_read_reg_dword(hk, TEXT("max_num_sta"), + (int *) &config->max_num_sta); return errors ? -1 : 0; } @@ -601,6 +603,8 @@ static int wpa_config_write_global(struct wpa_config *config, HKEY hk) DEFAULT_BSS_MAX_COUNT); wpa_config_write_reg_dword(hk, TEXT("filter_ssids"), config->filter_ssids, 0); + wpa_config_write_reg_dword(hk, TEXT("max_num_sta"), + config->max_num_sta, DEFAULT_MAX_NUM_STA); return 0; }