Patchwork supplicant: Allow user-defined defaults for Interworking network blocks.

login
register
mail settings
Submitter Ben Greear
Date Sept. 9, 2013, 11:21 p.m.
Message ID <1378768904-30946-1-git-send-email-greearb@candelatech.com>
Download mbox | patch
Permalink /patch/273726/
State New
Headers show

Comments

Ben Greear - Sept. 9, 2013, 11:21 p.m.
From: Ben Greear <greearb@candelatech.com>

This way users can still configure the HT over-rides and some other
constraints that Interworking has no interest or ability to configure.

Example config file (to disable HT-40 on an Interworking/HS20 interface):

ctrl_interface=/var/run/wpa_supplicant
fast_reauth=1

interworking=1
auto_interworking=1
access_network_type=0

hs20=1

bss_max_count=2000
network={
    interworking_defaults=1
    disable_ht=0
    disable_ht40=1
    disable_sgi=0
    ht_mcs=""
    disable_max_amsdu=-1
    ampdu_factor=-1
    ampdu_density=-1

}

cred={
    username="client2"
    password="lanforge"
    ca_cert="/home/lanforge/ca.pem"
    private_key="/home/lanforge/client.p12"
    private_key_passwd="lanforge"
    realm="lanforge.org"
    domain="lanforge.org"
    eap=TLS

}

Signed-hostap: Ben Greear <greearb@candelatech.com>
---
:100644 100644 247b501... 8eb4312... M	wpa_supplicant/config.c
:100644 100644 33634e8... bddb94d... M	wpa_supplicant/config.h
:100644 100644 3a44272... bd3d163... M	wpa_supplicant/config_ssid.h
:100644 100644 38feb12... 82696c4... M	wpa_supplicant/interworking.c
:100644 100644 3e645da... 102261d... M	wpa_supplicant/scan.c
:100644 100644 af94382... 1c91f64... M	wpa_supplicant/scan.h
:100644 100644 d73d371... c555ca6... M	wpa_supplicant/wpa_supplicant.conf
 wpa_supplicant/config.c            |   73 ++++++++++++++++++++++++++++++++++++
 wpa_supplicant/config.h            |    1 +
 wpa_supplicant/config_ssid.h       |    7 +++
 wpa_supplicant/interworking.c      |    3 +
 wpa_supplicant/scan.c              |    5 ++-
 wpa_supplicant/scan.h              |    2 +
 wpa_supplicant/wpa_supplicant.conf |   10 +++++
 7 files changed, 100 insertions(+), 1 deletions(-)

Patch

diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
index 247b501..8eb4312 100644
--- a/wpa_supplicant/config.c
+++ b/wpa_supplicant/config.c
@@ -1628,6 +1628,7 @@  static const struct parse_data ssid_fields[] = {
 	{ INT(ap_max_inactivity) },
 	{ INT(dtim_period) },
 	{ INT(beacon_int) },
+	{ INT_RANGE(interworking_defaults, 0, 1) },
 };
 
 #undef OFFSET
@@ -2015,6 +2016,77 @@  int wpa_config_remove_network(struct wpa_config *config, int id)
 
 
 /**
+ * wpa_set_user_network_defalts - Configure ssid with network defaults.
+ * @config: Configuration data from wpa_config_read()
+ * @ssid: The SSID to configure.
+ * Looks for first wpa_ssid that has interworking_defaults=1.  If found,
+ * select values are applied to the ssid.  In this way one may configure
+ * options not explicitly dealt with by interworking, such as
+ *   disable_ht=0
+ *   disable_ht40=0
+ *   etc.
+ * If no ssid is found, no action is taken.
+ */
+void wpa_config_set_user_network_defaults(struct wpa_config *config, struct wpa_ssid *ssid)
+{
+	struct wpa_ssid *s = config->ssid;
+	int i;
+
+	while (s) {
+		if (s->interworking_defaults) {
+			os_free(ssid->scan_freq);
+			ssid->scan_freq = NULL;
+			int_array_concat(&ssid->scan_freq, s->scan_freq);
+
+			os_free(ssid->freq_list);
+			ssid->freq_list = NULL;
+			int_array_concat(&ssid->freq_list, s->freq_list);
+
+			ssid->bg_scan_period = s->bg_scan_period;
+#ifdef CONFIG_HT_OVERRIDES
+			ssid->disable_ht = s->disable_ht;
+			ssid->disable_ht40 = s->disable_ht40;
+			ssid->disable_sgi = s->disable_sgi;
+			ssid->disable_max_amsdu = s->disable_max_amsdu;
+			ssid->ampdu_factor = s->ampdu_factor;
+			ssid->ampdu_density = s->ampdu_density;
+
+			os_free(ssid->ht_mcs);
+			ssid->ht_mcs = NULL;
+			if (s->ht_mcs) {
+				ssid->ht_mcs = strdup(s->ht_mcs);
+			}
+#endif
+#ifdef CONFIG_VHT_OVERRIDES
+			ssid->disable_vht = s->disable_vht;
+			ssid->vht_capa = s->vht_capa;
+			ssid->vht_capa_mask = s->vht_capa_mask;
+			ssid->vht_rx_mcs_nss_1 = s->vht_rx_mcs_nss_1;
+			ssid->vht_rx_mcs_nss_2 = s->vht_rx_mcs_nss_2;
+			ssid->vht_rx_mcs_nss_3 = s->vht_rx_mcs_nss_3;
+			ssid->vht_rx_mcs_nss_4 = s->vht_rx_mcs_nss_4;
+			ssid->vht_rx_mcs_nss_5 = s->vht_rx_mcs_nss_5;
+			ssid->vht_rx_mcs_nss_6 = s->vht_rx_mcs_nss_6;
+			ssid->vht_rx_mcs_nss_7 = s->vht_rx_mcs_nss_7;
+			ssid->vht_rx_mcs_nss_8 = s->vht_rx_mcs_nss_8;
+			ssid->vht_tx_mcs_nss_1 = s->vht_tx_mcs_nss_1;
+			ssid->vht_tx_mcs_nss_2 = s->vht_tx_mcs_nss_2;
+			ssid->vht_tx_mcs_nss_3 = s->vht_tx_mcs_nss_3;
+			ssid->vht_tx_mcs_nss_4 = s->vht_tx_mcs_nss_4;
+			ssid->vht_tx_mcs_nss_5 = s->vht_tx_mcs_nss_5;
+			ssid->vht_tx_mcs_nss_6 = s->vht_tx_mcs_nss_6;
+			ssid->vht_tx_mcs_nss_7 = s->vht_tx_mcs_nss_7;
+			ssid->vht_tx_mcs_nss_8 = s->vht_tx_mcs_nss_8;
+#endif /* CONFIG_VHT_OVERRIDES */	
+			return;
+		}
+		else {
+			ssid = ssid->next;
+		}
+	}
+} /* wpa_set_user_network_defaults */
+
+/**
  * wpa_config_set_network_defaults - Set network default values
  * @ssid: Pointer to network configuration data
  */
@@ -2060,6 +2132,7 @@  void wpa_config_set_network_defaults(struct wpa_ssid *ssid)
 #ifdef CONFIG_IEEE80211W
 	ssid->ieee80211w = MGMT_FRAME_PROTECTION_DEFAULT;
 #endif /* CONFIG_IEEE80211W */
+	ssid->interworking_defaults = DEFAULT_INTERWORKING_DEFAULTS;
 }
 
 
diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h
index 33634e8..bddb94d 100644
--- a/wpa_supplicant/config.h
+++ b/wpa_supplicant/config.h
@@ -908,6 +908,7 @@  struct wpa_ssid * wpa_config_get_network(struct wpa_config *config, int id);
 struct wpa_ssid * wpa_config_add_network(struct wpa_config *config);
 int wpa_config_remove_network(struct wpa_config *config, int id);
 void wpa_config_set_network_defaults(struct wpa_ssid *ssid);
+void wpa_config_set_user_network_defaults(struct wpa_config *config, struct wpa_ssid *ssid);
 int wpa_config_set(struct wpa_ssid *ssid, const char *var, const char *value,
 		   int line);
 int wpa_config_set_quoted(struct wpa_ssid *ssid, const char *var,
diff --git a/wpa_supplicant/config_ssid.h b/wpa_supplicant/config_ssid.h
index 3a44272..bd3d163 100644
--- a/wpa_supplicant/config_ssid.h
+++ b/wpa_supplicant/config_ssid.h
@@ -33,6 +33,7 @@ 
 #define DEFAULT_DISABLE_MAX_AMSDU -1 /* no change */
 #define DEFAULT_AMPDU_FACTOR -1 /* no change */
 #define DEFAULT_AMPDU_DENSITY -1 /* no change */
+#define DEFAULT_INTERWORKING_DEFAULTS 0
 
 struct psk_list_entry {
 	struct dl_list list;
@@ -484,6 +485,12 @@  struct wpa_ssid {
 	int temporary;
 
 	/**
+	 * interworking_defaults - Whether this network block should be used for
+	 *    network defaults when creating temporary interworking network blocks.
+	 */
+	int interworking_defaults;
+	
+	/**
 	 * export_keys - Whether keys may be exported
 	 *
 	 * This attribute will be set when keys are determined through
diff --git a/wpa_supplicant/interworking.c b/wpa_supplicant/interworking.c
index 38feb12..82696c4 100644
--- a/wpa_supplicant/interworking.c
+++ b/wpa_supplicant/interworking.c
@@ -789,6 +789,7 @@  static int interworking_connect_3gpp(struct wpa_supplicant *wpa_s,
 
 	wpas_notify_network_added(wpa_s, ssid);
 	wpa_config_set_network_defaults(ssid);
+	wpa_config_set_user_network_defaults(wpa_s->conf, ssid);
 	ssid->priority = cred->priority;
 	ssid->temporary = 1;
 	ssid->ssid = os_zalloc(ie[1] + 1);
@@ -1119,6 +1120,7 @@  static int interworking_connect_roaming_consortium(
 	ssid->parent_cred = cred;
 	wpas_notify_network_added(wpa_s, ssid);
 	wpa_config_set_network_defaults(ssid);
+	wpa_config_set_user_network_defaults(wpa_s->conf, ssid);
 	ssid->priority = cred->priority;
 	ssid->temporary = 1;
 	ssid->ssid = os_zalloc(ssid_ie[1] + 1);
@@ -1256,6 +1258,7 @@  int interworking_connect(struct wpa_supplicant *wpa_s, struct wpa_bss *bss)
 	ssid->parent_cred = cred;
 	wpas_notify_network_added(wpa_s, ssid);
 	wpa_config_set_network_defaults(ssid);
+	wpa_config_set_user_network_defaults(wpa_s->conf, ssid);
 	ssid->priority = cred->priority;
 	ssid->temporary = 1;
 	ssid->ssid = os_zalloc(ie[1] + 1);
diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c
index 3e645da..102261d 100644
--- a/wpa_supplicant/scan.c
+++ b/wpa_supplicant/scan.c
@@ -150,7 +150,7 @@  static int int_array_len(const int *a)
 }
 
 
-static void int_array_concat(int **res, const int *a)
+void int_array_concat(int **res, const int *a)
 {
 	int reslen, alen, i;
 	int *n;
@@ -158,6 +158,9 @@  static void int_array_concat(int **res, const int *a)
 	reslen = int_array_len(*res);
 	alen = int_array_len(a);
 
+	if (alen == 0)
+		return; /* nothing to concat */
+
 	n = os_realloc_array(*res, reslen + alen + 1, sizeof(int));
 	if (n == NULL) {
 		os_free(*res);
diff --git a/wpa_supplicant/scan.h b/wpa_supplicant/scan.h
index af94382..1c91f64 100644
--- a/wpa_supplicant/scan.h
+++ b/wpa_supplicant/scan.h
@@ -39,4 +39,6 @@  void scan_only_handler(struct wpa_supplicant *wpa_s,
 		       struct wpa_scan_results *scan_res);
 int wpas_scan_scheduled(struct wpa_supplicant *wpa_s);
 
+void int_array_concat(int **res, const int *a);
+
 #endif /* SCAN_H */
diff --git a/wpa_supplicant/wpa_supplicant.conf b/wpa_supplicant/wpa_supplicant.conf
index d73d371..c555ca6 100644
--- a/wpa_supplicant/wpa_supplicant.conf
+++ b/wpa_supplicant/wpa_supplicant.conf
@@ -869,6 +869,16 @@  fast_reauth=1
 # Beacon interval (default: 100 TU)
 #beacon_int=100
 
+# interworking_defaults:  Should this network block's values be used as
+#   defaults for automatically-created interworking network blocks?
+#   Not all values will be propagated, but the HT and VHT overrides,
+#   and a few other values will be.  This will only be used if
+#   Interworking is active.  Only the first interworking_defaults=1
+#   network block will be used, so users should only set this value
+#   in a single network block.
+# 0 = Not used (default)
+# 1 = Use this network block's values.
+
 # disable_ht: Whether HT (802.11n) should be disabled.
 # 0 = HT enabled (if AP supports it)
 # 1 = HT disabled