[RFC 1/2] wpa_supp: ignore networks config for dedicated P2P management interface

Arend van Spriel arend at broadcom.com
Mon Dec 1 06:57:03 EST 2014


The P2P_DEVICE interface is only used for P2P management operations and
as such should not have enabled networks. When sharing the same config
file as the primary interface, that config may have configured networks.
This patch assures these are ignored for the P2P_DEVICE interface.

Signed-hostap: Arend van Spriel <arend at broadcom.com>
---
 wpa_supplicant/config.h         |  4 +++-
 wpa_supplicant/config_file.c    |  5 ++++-
 wpa_supplicant/config_none.c    |  3 ++-
 wpa_supplicant/config_winreg.c  |  5 +++--
 wpa_supplicant/wpa_supplicant.c | 10 ++++++----
 5 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h
index 2c3d6f5..dad4c2f 100644
--- a/wpa_supplicant/config.h
+++ b/wpa_supplicant/config.h
@@ -1172,6 +1172,7 @@ int wpa_config_process_global(struct wpa_config *config, char *pos, int line);
  * @name: Name of the configuration (e.g., path and file name for the
  * configuration file)
  * @cfgp: Pointer to previously allocated configuration data or %NULL if none
+ * @ignore_networks: Any networks in configuration will be skipped if non-zero
  * Returns: Pointer to allocated configuration data or %NULL on failure
  *
  * This function reads configuration data, parses its contents, and allocates
@@ -1180,7 +1181,8 @@ int wpa_config_process_global(struct wpa_config *config, char *pos, int line);
  *
  * Each configuration backend needs to implement this function.
  */
-struct wpa_config * wpa_config_read(const char *name, struct wpa_config *cfgp);
+struct wpa_config * wpa_config_read(const char *name, struct wpa_config *cfgp,
+				    int ignore_networks);
 
 /**
  * wpa_config_write - Write or update configuration data
diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c
index 4f2b146..a5249d7 100644
--- a/wpa_supplicant/config_file.c
+++ b/wpa_supplicant/config_file.c
@@ -356,7 +356,8 @@ static int wpa_config_process_blob(struct wpa_config *config, FILE *f,
 #endif /* CONFIG_NO_CONFIG_BLOBS */
 
 
-struct wpa_config * wpa_config_read(const char *name, struct wpa_config *cfgp)
+struct wpa_config * wpa_config_read(const char *name, struct wpa_config *cfgp,
+				    int ignore_networks)
 {
 	FILE *f;
 	char buf[512], *pos;
@@ -403,6 +404,8 @@ struct wpa_config * wpa_config_read(const char *name, struct wpa_config *cfgp)
 				errors++;
 				continue;
 			}
+			if (ignore_networks)
+				continue;
 			if (head == NULL) {
 				head = tail = ssid;
 			} else {
diff --git a/wpa_supplicant/config_none.c b/wpa_supplicant/config_none.c
index 2aac28f..8db04e5 100644
--- a/wpa_supplicant/config_none.c
+++ b/wpa_supplicant/config_none.c
@@ -17,7 +17,8 @@
 #include "base64.h"
 
 
-struct wpa_config * wpa_config_read(const char *name, struct wpa_config *cfgp)
+struct wpa_config * wpa_config_read(const char *name, struct wpa_config *cfgp,
+				    int ignore_networks)
 {
 	struct wpa_config *config;
 
diff --git a/wpa_supplicant/config_winreg.c b/wpa_supplicant/config_winreg.c
index 199f04f..547518e 100644
--- a/wpa_supplicant/config_winreg.c
+++ b/wpa_supplicant/config_winreg.c
@@ -435,7 +435,8 @@ static int wpa_config_read_networks(struct wpa_config *config, HKEY hk)
 }
 
 
-struct wpa_config * wpa_config_read(const char *name, struct wpa_config *cfgp)
+struct wpa_config * wpa_config_read(const char *name, struct wpa_config *cfgp,
+				    int ignore_networks)
 {
 	TCHAR buf[256];
 	int errors = 0;
@@ -470,7 +471,7 @@ struct wpa_config * wpa_config_read(const char *name, struct wpa_config *cfgp)
 	if (wpa_config_read_global(config, hk))
 		errors++;
 
-	if (wpa_config_read_networks(config, hk))
+	if (ignore_networks == 0 && wpa_config_read_networks(config, hk))
 		errors++;
 
 	if (wpa_config_read_blobs(config, hk))
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index 5eae00b..1804c03 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -838,13 +838,13 @@ int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s)
 
 	if (wpa_s->confname == NULL)
 		return -1;
-	conf = wpa_config_read(wpa_s->confname, NULL);
+	conf = wpa_config_read(wpa_s->confname, NULL, wpa_s->p2p_mgmt);
 	if (conf == NULL) {
 		wpa_msg(wpa_s, MSG_ERROR, "Failed to parse the configuration "
 			"file '%s' - exiting", wpa_s->confname);
 		return -1;
 	}
-	wpa_config_read(wpa_s->confanother, conf);
+	wpa_config_read(wpa_s->confanother, conf, wpa_s->p2p_mgmt);
 
 	conf->changed_parameters = (unsigned int) -1;
 
@@ -3691,14 +3691,16 @@ static int wpa_supplicant_init_iface(struct wpa_supplicant *wpa_s,
 #else /* CONFIG_BACKEND_FILE */
 		wpa_s->confname = os_strdup(iface->confname);
 #endif /* CONFIG_BACKEND_FILE */
-		wpa_s->conf = wpa_config_read(wpa_s->confname, NULL);
+		wpa_s->conf = wpa_config_read(wpa_s->confname, NULL,
+					      iface->p2p_mgmt);
 		if (wpa_s->conf == NULL) {
 			wpa_printf(MSG_ERROR, "Failed to read or parse "
 				   "configuration '%s'.", wpa_s->confname);
 			return -1;
 		}
 		wpa_s->confanother = os_rel2abs_path(iface->confanother);
-		wpa_config_read(wpa_s->confanother, wpa_s->conf);
+		wpa_config_read(wpa_s->confanother, wpa_s->conf,
+				iface->p2p_mgmt);
 
 		/*
 		 * Override ctrl_interface and driver_param if set on command
-- 
1.9.1



More information about the HostAP mailing list