From 19e20c14fb015d063dc248a0f4ded195ad229df3 Mon Sep 17 00:00:00 2001 From: Danilo Ravotto Date: Thu, 1 Feb 2018 12:09:38 +0100 Subject: [PATCH] Add ap_isolate configuration option for wpa_supplicant AP mode Allow client isolation to be configured with ap_isolate inside wpa_supplicant configuration file. Signed-off-by: Danilo Ravotto --- wpa_supplicant/ap.c | 3 +++ wpa_supplicant/config.c | 2 ++ wpa_supplicant/config.h | 15 +++++++++++++++ wpa_supplicant/config_file.c | 2 ++ wpa_supplicant/config_winreg.c | 2 ++ wpa_supplicant/wpa_cli.c | 4 ++-- 6 files changed, 26 insertions(+), 2 deletions(-) diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c index 939af62ac..679b34600 100644 --- a/wpa_supplicant/ap.c +++ b/wpa_supplicant/ap.c @@ -506,6 +506,9 @@ no_wps: else bss->max_num_sta = wpa_s->conf->max_num_sta; + if (!bss->isolate) + bss->isolate = wpa_s->conf->ap_isolate; + bss->disassoc_low_ack = wpa_s->conf->disassoc_low_ack; if (wpa_s->conf->ap_vendor_elements) { diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c index c13383d80..a0b8cd007 100644 --- a/wpa_supplicant/config.c +++ b/wpa_supplicant/config.c @@ -3899,6 +3899,7 @@ struct wpa_config * wpa_config_alloc_empty(const char *ctrl_interface, config->bss_expiration_age = DEFAULT_BSS_EXPIRATION_AGE; config->bss_expiration_scan_count = DEFAULT_BSS_EXPIRATION_SCAN_COUNT; config->max_num_sta = DEFAULT_MAX_NUM_STA; + config->ap_isolate = DEFAULT_AP_ISOLATE; config->access_network_type = DEFAULT_ACCESS_NETWORK_TYPE; config->scan_cur_freq = DEFAULT_SCAN_CUR_FREQ; config->wmm_ac_params[0] = ac_be; @@ -4578,6 +4579,7 @@ static const struct global_parse_data global_fields[] = { { INT_RANGE(filter_ssids, 0, 1), 0 }, { INT_RANGE(filter_rssi, -100, 0), 0 }, { INT(max_num_sta), 0 }, + { INT_RANGE(ap_isolate, 0, 1), 0 }, { INT_RANGE(disassoc_low_ack, 0, 1), 0 }, #ifdef CONFIG_HS20 { INT_RANGE(hs20, 0, 1), 0 }, diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h index 07b67e6b4..68f90a085 100644 --- a/wpa_supplicant/config.h +++ b/wpa_supplicant/config.h @@ -32,6 +32,7 @@ #define DEFAULT_BSS_EXPIRATION_AGE 180 #define DEFAULT_BSS_EXPIRATION_SCAN_COUNT 2 #define DEFAULT_MAX_NUM_STA 128 +#define DEFAULT_AP_ISOLATE 0 #define DEFAULT_ACCESS_NETWORK_TYPE 15 #define DEFAULT_SCAN_CUR_FREQ 0 #define DEFAULT_P2P_SEARCH_DELAY 500 @@ -842,6 +843,20 @@ struct wpa_config { */ unsigned int max_num_sta; + /** + * ap_isolate - Whether to use client isolation feature + * + * Client isolation can be used to prevent low-level bridging of + * frames between associated stations in the BSS. By default, + * this bridging is allowed (ap_isolate=0); except in P2P GO case, + * where p2p_intra_bss parameter is used to determine whether to allow + * intra-BSS forwarding (ap_isolate = !p2p_intra_bss). + * + * 0 = do not enable AP isolation + * 1 = enable AP isolation + */ + int ap_isolate; + /** * freq_list - Array of allowed scan frequencies or %NULL for all * diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c index aaee97e90..5a7186961 100644 --- a/wpa_supplicant/config_file.c +++ b/wpa_supplicant/config_file.c @@ -1282,6 +1282,8 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config) fprintf(f, "filter_rssi=%d\n", config->filter_rssi); if (config->max_num_sta != DEFAULT_MAX_NUM_STA) fprintf(f, "max_num_sta=%u\n", config->max_num_sta); + if (config->ap_isolate != DEFAULT_AP_ISOLATE) + fprintf(f, "ap_isolate=%u\n", config->ap_isolate); if (config->disassoc_low_ack) fprintf(f, "disassoc_low_ack=%d\n", config->disassoc_low_ack); #ifdef CONFIG_HS20 diff --git a/wpa_supplicant/config_winreg.c b/wpa_supplicant/config_winreg.c index 0ba1aa5e8..8b8992bd7 100644 --- a/wpa_supplicant/config_winreg.c +++ b/wpa_supplicant/config_winreg.c @@ -619,6 +619,8 @@ static int wpa_config_write_global(struct wpa_config *config, HKEY hk) config->filter_ssids, 0); wpa_config_write_reg_dword(hk, TEXT("max_num_sta"), config->max_num_sta, DEFAULT_MAX_NUM_STA); + wpa_config_write_reg_dword(hk, TEXT("ap_isolate"), + config->ap_isolate, DEFAULT_AP_ISOLATE); wpa_config_write_reg_dword(hk, TEXT("disassoc_low_ack"), config->disassoc_low_ack, 0); diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c index 121f831b6..4f60890b3 100644 --- a/wpa_supplicant/wpa_cli.c +++ b/wpa_supplicant/wpa_cli.c @@ -476,7 +476,7 @@ static char ** wpa_cli_complete_set(const char *str, int pos) #endif /* CONFIG_P2P */ "country", "bss_max_count", "bss_expiration_age", "bss_expiration_scan_count", "filter_ssids", "filter_rssi", - "max_num_sta", "disassoc_low_ack", + "max_num_sta", "disassoc_low_ack", "ap_isolate", #ifdef CONFIG_HS20 "hs20", #endif /* CONFIG_HS20 */ @@ -573,7 +573,7 @@ static char ** wpa_cli_complete_get(const char *str, int pos) #endif /* CONFIG_P2P */ "bss_max_count", "bss_expiration_age", "bss_expiration_scan_count", "filter_ssids", "filter_rssi", - "max_num_sta", "disassoc_low_ack", + "max_num_sta", "disassoc_low_ack", "ap_isolate", #ifdef CONFIG_HS20 "hs20", #endif /* CONFIG_HS20 */