From 18206e02c540f0a379db507b4ecc22c8855c7acf Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 1 Mar 2013 20:50:08 +0200 Subject: [PATCH] Allow wpa_supplicant AP mode to configure Beacon interval beacon_int (in TU) can now be used to configure Beacon interval for AP mode operations (including P2P GO) in wpa_supplicant. This can be set either in a network block or as a global parameter in the configuration file (or with "SET beacon_int " control interface command) to apply for all networks that do not include the beacon_int parameter to override the default. In addition, this commits extends the dtim_period parameter to be available as a global parameter to set the default value. dtim_period is now stored in the configuration file, too, if it was set. Signed-hostap: Jouni Malinen --- wpa_supplicant/ap.c | 7 +++++++ wpa_supplicant/config.c | 3 +++ wpa_supplicant/config.h | 16 ++++++++++++++++ wpa_supplicant/config_file.c | 6 ++++++ wpa_supplicant/config_ssid.h | 5 +++++ wpa_supplicant/wpa_supplicant.conf | 9 +++++++++ 6 files changed, 46 insertions(+) diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c index 82b7e193c..720ff7b70 100644 --- a/wpa_supplicant/ap.c +++ b/wpa_supplicant/ap.c @@ -209,6 +209,13 @@ static int wpa_supplicant_conf_ap(struct wpa_supplicant *wpa_s, if (ssid->dtim_period) bss->dtim_period = ssid->dtim_period; + else if (wpa_s->conf->dtim_period) + bss->dtim_period = wpa_s->conf->dtim_period; + + if (ssid->beacon_int) + conf->beacon_int = ssid->beacon_int; + else if (wpa_s->conf->beacon_int) + conf->beacon_int = wpa_s->conf->beacon_int; if ((bss->wpa & 2) && bss->rsn_pairwise == 0) bss->rsn_pairwise = bss->wpa_pairwise; diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c index ee634a5c1..91d82aea8 100644 --- a/wpa_supplicant/config.c +++ b/wpa_supplicant/config.c @@ -1545,6 +1545,7 @@ static const struct parse_data ssid_fields[] = { #endif /* CONFIG_HT_OVERRIDES */ { INT(ap_max_inactivity) }, { INT(dtim_period) }, + { INT(beacon_int) }, }; #undef OFFSET @@ -2991,6 +2992,8 @@ static const struct global_parse_data global_fields[] = { { INT(okc), 0 }, { INT(pmf), 0 }, { FUNC(sae_groups), 0 }, + { INT(dtim_period), 0 }, + { INT(beacon_int), 0 }, }; #undef FUNC diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h index 2b88bb51f..2e3e76bb6 100644 --- a/wpa_supplicant/config.h +++ b/wpa_supplicant/config.h @@ -817,6 +817,22 @@ struct wpa_config { * groups will be tried in the indicated order. */ int *sae_groups; + + /** + * dtim_period - Default DTIM period in Beacon intervals + * + * This parameter can be used to set the default value for network + * blocks that do not specify dtim_period. + */ + int dtim_period; + + /** + * beacon_int - Default Beacon interval in TU + * + * This parameter can be used to set the default value for network + * blocks that do not specify beacon_int. + */ + int beacon_int; }; diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c index f29f7a6b9..ff99cd7b7 100644 --- a/wpa_supplicant/config_file.c +++ b/wpa_supplicant/config_file.c @@ -690,6 +690,8 @@ static void wpa_config_write_network(FILE *f, struct wpa_ssid *ssid) #ifdef CONFIG_P2P write_p2p_client_list(f, ssid); #endif /* CONFIG_P2P */ + INT(dtim_period); + INT(beacon_int); #undef STR #undef INT @@ -974,6 +976,10 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config) fprintf(f, "okc=%d\n", config->okc); if (config->pmf) fprintf(f, "pmf=%d\n", config->pmf); + if (config->dtim_period) + fprintf(f, "dtim_period=%d\n", config->dtim_period); + if (config->beacon_int) + fprintf(f, "beacon_int=%d\n", config->beacon_int); if (config->sae_groups) { int i; diff --git a/wpa_supplicant/config_ssid.h b/wpa_supplicant/config_ssid.h index 9ac67c739..8cab88f30 100644 --- a/wpa_supplicant/config_ssid.h +++ b/wpa_supplicant/config_ssid.h @@ -548,6 +548,11 @@ struct wpa_ssid { */ int dtim_period; + /** + * beacon_int - Beacon interval (default: 100 TU) + */ + int beacon_int; + /** * auth_failures - Number of consecutive authentication failures */ diff --git a/wpa_supplicant/wpa_supplicant.conf b/wpa_supplicant/wpa_supplicant.conf index 18460b89e..c9deb4b8a 100644 --- a/wpa_supplicant/wpa_supplicant.conf +++ b/wpa_supplicant/wpa_supplicant.conf @@ -289,6 +289,12 @@ fast_reauth=1 # http://www.iana.org/assignments/ipsec-registry/ipsec-registry.xml#ipsec-registry-9 #sae_groups=21 20 19 26 25 +# Default value for DTIM period (if not overridden in network block) +#dtim_period=2 + +# Default value for Beacon interval (if not overridden in network block) +#beacon_int=100 + # Interworking (IEEE 802.11u) # Enable Interworking @@ -832,6 +838,9 @@ fast_reauth=1 # DTIM period in Beacon intervals for AP mode (default: 2) #dtim_period=2 +# Beacon interval (default: 100 TU) +#beacon_int=100 + # disable_ht: Whether HT (802.11n) should be disabled. # 0 = HT enabled (if AP supports it) # 1 = HT disabled