Add max_num_sta config option for wpa_supplicant AP mode
authorJouni Malinen <jouni.malinen@atheros.com>
Tue, 19 Oct 2010 14:08:20 +0000 (17:08 +0300)
committerJouni Malinen <j@w1.fi>
Tue, 19 Oct 2010 14:08:20 +0000 (17:08 +0300)
This can be used to limit the number of stations allowed to be
connected to the AP.

wpa_supplicant/ap.c
wpa_supplicant/config.c
wpa_supplicant/config.h
wpa_supplicant/config_file.c
wpa_supplicant/config_winreg.c

index ea57540..a196e24 100644 (file)
@@ -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;
 }
 
index 6e03760..24bbf0f 100644 (file)
@@ -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
index 246c65f..ff4cf22 100644 (file)
@@ -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"
 
@@ -379,6 +380,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
         */
        unsigned int changed_parameters;
index 0f343fd..a203e43 100644 (file)
@@ -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 */
index deebbd9..b2078af 100644 (file)
@@ -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;
 }