Patchwork wpa_supplicant: Add a configuration file for P2P_DEVICE

login
register
mail settings
Submitter Ilan Peer
Date Aug. 7, 2013, 10:08 a.m.
Message ID <1375870125-27991-9-git-send-email-ilan.peer@intel.com>
Download mbox | patch
Permalink /patch/265478/
State Superseded
Headers show

Comments

Ilan Peer - Aug. 7, 2013, 10:08 a.m.
If a P2P_DEVICE is supported by the driver, the wpa_supplicant creates
a dedicated P2P Device interface, where the configuration file used for
the main interface is used. As a consequence, if the configuration file
includes network definition etc., the wpa_supplicant will try to perform
station specific flows on the P2P Device interface which will fail. In addition,
if update_config is used, the P2P Device configuration data will override the
main interface configuration data.

To overcome these situations, allow the option to use a specific configuration
file for the P2P Device functionality.

Signed-hostap: Ilan Peer <ilan.peer@intel.com>
---
 wpa_supplicant/README             |    3 ++-
 wpa_supplicant/main.c             |    7 ++++++-
 wpa_supplicant/p2p_supplicant.c   |   11 ++++++++++-
 wpa_supplicant/wpa_supplicant.c   |    5 +++++
 wpa_supplicant/wpa_supplicant_i.h |   11 +++++++++++
 5 files changed, 34 insertions(+), 3 deletions(-)
Jouni Malinen - Aug. 25, 2013, 8:32 a.m.
On Wed, Aug 07, 2013 at 01:08:45PM +0300, Ilan Peer wrote:
> If a P2P_DEVICE is supported by the driver, the wpa_supplicant creates
> a dedicated P2P Device interface, where the configuration file used for
> the main interface is used. As a consequence, if the configuration file
> includes network definition etc., the wpa_supplicant will try to perform
> station specific flows on the P2P Device interface which will fail. In addition,
> if update_config is used, the P2P Device configuration data will override the
> main interface configuration data.
> 
> To overcome these situations, allow the option to use a specific configuration
> file for the P2P Device functionality.

This does not sound desirable direction to me. Whether P2P_DEVICE is
used is supposed to be transparent outside wpa_supplicant and it would
be good to keep the differences minimal. It would sound cleaner to
consider a separate configuration file for P2P parameters that could
then be used either with P2P_DEVICE or any other P2P driver
architecture.
Ilan Peer - Sept. 1, 2013, 7:49 p.m.
> From: hostap-bounces@lists.shmoo.com [mailto:hostap-
> bounces@lists.shmoo.com] On Behalf Of Jouni Malinen
> Sent: Sunday, August 25, 2013 11:32
> To: hostap@lists.shmoo.com
> Subject: Re: [PATCH] wpa_supplicant: Add a configuration file for P2P_DEVICE
> 
> On Wed, Aug 07, 2013 at 01:08:45PM +0300, Ilan Peer wrote:
> > If a P2P_DEVICE is supported by the driver, the wpa_supplicant creates
> > a dedicated P2P Device interface, where the configuration file used
> > for the main interface is used. As a consequence, if the configuration
> > file includes network definition etc., the wpa_supplicant will try to
> > perform station specific flows on the P2P Device interface which will
> > fail. In addition, if update_config is used, the P2P Device
> > configuration data will override the main interface configuration data.
> >
> > To overcome these situations, allow the option to use a specific
> > configuration file for the P2P Device functionality.
> 
> This does not sound desirable direction to me. Whether P2P_DEVICE is used is
> supposed to be transparent outside wpa_supplicant and it would be good to
> keep the differences minimal. It would sound cleaner to consider a separate
> configuration file for P2P parameters that could then be used either with
> P2P_DEVICE or any other P2P driver architecture.
> 

Ok. I'll rewrite the patch.

Thanks,

Ilan.

Patch

diff --git a/wpa_supplicant/README b/wpa_supplicant/README
index 78df89e..c215845 100644
--- a/wpa_supplicant/README
+++ b/wpa_supplicant/README
@@ -413,7 +413,7 @@  usage:
         [-G<group>] \
         -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] [-p<driver_param>] \
         [-b<br_ifname> [-N -i<ifname> -c<conf> [-C<ctrl>] [-D<driver>] \
-        [-p<driver_param>] [-b<br_ifname>] ...]
+        [-p<driver_param>] [-b<br_ifname>] [-m<p2p Device config file>] ...
 
 options:
   -b = optional bridge interface name
@@ -438,6 +438,7 @@  options:
   -w = wait for interface to be added, if needed
   -W = wait for a control interface monitor before starting
   -N = start describing new interface
+  -m = Configuration file for the P2P Device
 
 drivers:
   nl80211 = Linux nl80211/cfg80211
diff --git a/wpa_supplicant/main.c b/wpa_supplicant/main.c
index 39b837e..edb26c2 100644
--- a/wpa_supplicant/main.c
+++ b/wpa_supplicant/main.c
@@ -35,6 +35,7 @@  static void usage(void)
 	       "        [-N -i<ifname> -c<conf> [-C<ctrl>] "
 	       "[-D<driver>] \\\n"
 	       "        [-p<driver_param>] [-b<br_ifname>] [-I<config file>] "
+	       "        [-m<P2P Device config file>] "
 	       "...]\n"
 	       "\n"
 	       "drivers:\n",
@@ -83,6 +84,7 @@  static void usage(void)
 #endif /* CONFIG_DBUS */
 	printf("  -v = show version\n"
 	       "  -W = wait for a control interface monitor before starting\n"
+	       "  -m = Configuration file for the P2P Device\n"
 	       "  -N = start describing new interface\n");
 
 	printf("example:\n"
@@ -160,7 +162,7 @@  int main(int argc, char *argv[])
 
 	for (;;) {
 		c = getopt(argc, argv,
-			   "b:Bc:C:D:de:f:g:G:hi:I:KLNo:O:p:P:qsTtuvW");
+			   "b:Bc:C:D:de:f:g:G:hi:I:KLNo:O:p:P:qsTtuvWm:");
 		if (c < 0)
 			break;
 		switch (c) {
@@ -213,6 +215,9 @@  int main(int argc, char *argv[])
 		case 'I':
 			iface->confanother = optarg;
 			break;
+		case 'm':
+			iface->conf_p2p_dev = optarg;
+			break;
 		case 'K':
 			params.wpa_debug_show_keys++;
 			break;
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index 06d331b..4f0e734 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -3070,7 +3070,16 @@  int wpas_p2p_add_p2pdev_interface(struct wpa_supplicant *wpa_s)
 	iface.ifname = wpa_s->pending_interface_name;
 	iface.driver = wpa_s->driver->name;
 	iface.driver_param = wpa_s->conf->driver_param;
-	iface.confname = wpa_s->confname;
+	iface.conf_p2p_dev = wpa_s->conf_p2p_dev;
+
+	if (wpa_s->conf_p2p_dev) {
+		iface.confname = wpa_s->conf_p2p_dev;
+		iface.ctrl_interface = NULL;
+	} else {
+		iface.confname = wpa_s->confname;
+		iface.ctrl_interface = wpa_s->conf->ctrl_interface;
+	}
+
 	p2pdev_wpa_s = wpa_supplicant_add_iface(wpa_s->global, &iface);
 	if (!p2pdev_wpa_s) {
 		wpa_printf(MSG_DEBUG, "P2P: Failed to add P2P Device interface");
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index a18922a..1e0647a 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -404,6 +404,9 @@  static void wpa_supplicant_cleanup(struct wpa_supplicant *wpa_s)
 	os_free(wpa_s->confanother);
 	wpa_s->confanother = NULL;
 
+	os_free(wpa_s->conf_p2p_dev);
+	wpa_s->conf_p2p_dev = NULL;
+
 	wpa_sm_set_eapol(wpa_s->wpa, NULL);
 	eapol_sm_deinit(wpa_s->eapol);
 	wpa_s->eapol = NULL;
@@ -2824,6 +2827,8 @@  static int wpa_supplicant_init_iface(struct wpa_supplicant *wpa_s,
 		wpa_s->confanother = os_rel2abs_path(iface->confanother);
 		wpa_config_read(wpa_s->confanother, wpa_s->conf);
 
+		wpa_s->conf_p2p_dev = os_rel2abs_path(iface->conf_p2p_dev);
+
 		/*
 		 * Override ctrl_interface and driver_param if set on command
 		 * line.
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
index 0858bbc..224ba25 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -64,6 +64,15 @@  struct wpa_interface {
 	const char *confanother;
 
 	/**
+	 * conf_p2p_dev - Additional configuration file used for the P2P Device
+	 * functionality.
+	 *
+	 * This can also be %NULL. In such a case, if a P2P Device dedicated
+	 * interfaces is created, the main configuration file will be used.
+	 */
+	const char *conf_p2p_dev;
+
+	/**
 	 * ctrl_interface - Control interface parameter
 	 *
 	 * If a configuration file is not used, this variable can be used to
@@ -330,6 +339,8 @@  struct wpa_supplicant {
 
 	char *confname;
 	char *confanother;
+	char *conf_p2p_dev;
+
 	struct wpa_config *conf;
 	int countermeasures;
 	os_time_t last_michael_mic_error;