[PATCH v3 08/10] mesh: Add virtual interface on booting

Masashi Honma masashi.honma
Mon Dec 15 19:24:55 PST 2014


I found one mistake about this.

I will send modified patch.


On 2014?12?16? 12:08, Masashi Honma wrote:
> This functionality is used to create mesh gate.
>
> Signed-off-by: Masashi Honma <masashi.honma at gmail.com>
> ---
>  wpa_supplicant/README                          |  4 +++-
>  wpa_supplicant/ctrl_iface.c                    |  2 +-
>  wpa_supplicant/doc/docbook/wpa_supplicant.sgml |  7 +++++++
>  wpa_supplicant/main.c                          | 10 +++++++++-
>  wpa_supplicant/mesh.c                          |  9 ++++++---
>  wpa_supplicant/mesh.h                          |  2 +-
>  wpa_supplicant/wpa_supplicant.c                | 11 +++++++++++
>  wpa_supplicant/wpa_supplicant_i.h              | 11 +++++++++++
>  8 files changed, 49 insertions(+), 7 deletions(-)
>
> diff --git a/wpa_supplicant/README b/wpa_supplicant/README
> index 653848e..b4f8543 100644
> --- a/wpa_supplicant/README
> +++ b/wpa_supplicant/README
> @@ -413,7 +413,8 @@ 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>] [-m<P2P Device config file>] ...
> +        [-p<driver_param>] [-b<br_ifname>] [-m<P2P Device config file>] \
> +        [-n<Mesh Device config file>] ...
>  
>  options:
>    -b = optional bridge interface name
> @@ -439,6 +440,7 @@ options:
>    -W = wait for a control interface monitor before starting
>    -N = start describing new interface
>    -m = Configuration file for the P2P Device
> +  -n = Configuration file for the Mesh Device
>  
>  drivers:
>    nl80211 = Linux nl80211/cfg80211
> diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
> index c9eb56d..ad7978c 100644
> --- a/wpa_supplicant/ctrl_iface.c
> +++ b/wpa_supplicant/ctrl_iface.c
> @@ -2436,7 +2436,7 @@ static int wpa_supplicant_ctrl_iface_mesh_interface_add(
>  		os_strlcpy(ifname, pos, sizeof(ifname));
>  	}
>  
> -	if (wpas_mesh_add_interface(wpa_s, ifname, sizeof(ifname)) < 0)
> +	if (wpas_mesh_add_interface(wpa_s, ifname, sizeof(ifname), NULL) < 0)
>  		return -1;
>  
>  	os_strlcpy(reply, ifname, max_len);
> diff --git a/wpa_supplicant/doc/docbook/wpa_supplicant.sgml b/wpa_supplicant/doc/docbook/wpa_supplicant.sgml
> index 182060d..e1bb7cc 100644
> --- a/wpa_supplicant/doc/docbook/wpa_supplicant.sgml
> +++ b/wpa_supplicant/doc/docbook/wpa_supplicant.sgml
> @@ -493,6 +493,13 @@
>  	  <para>Start describing new interface.</para>
>  	</listitem>
>        </varlistentry>
> +
> +      <varlistentry>
> +	<term>-n</term>
> +	<listitem>
> +	  <para>Configuration file for the Mesh Device interface.</para>
> +	</listitem>
> +      </varlistentry>
>      </variablelist>
>    </refsect1>
>  
> diff --git a/wpa_supplicant/main.c b/wpa_supplicant/main.c
> index 13e9769..a2110e4 100644
> --- a/wpa_supplicant/main.c
> +++ b/wpa_supplicant/main.c
> @@ -98,6 +98,9 @@ static void usage(void)
>  #ifdef CONFIG_P2P
>  	       "  -m = Configuration file for the P2P Device interface\n"
>  #endif /* CONFIG_P2P */
> +#ifdef CONFIG_MESH
> +	       "  -n = Configuration file for the Mesh Device interface\n"
> +#endif /* CONFIG_MESH */
>  	       "  -N = start describing new interface\n");
>  
>  	printf("example:\n"
> @@ -175,7 +178,7 @@ int main(int argc, char *argv[])
>  
>  	for (;;) {
>  		c = getopt(argc, argv,
> -			   "b:Bc:C:D:de:f:g:G:hi:I:KLm:No:O:p:P:qsTtuvW");
> +			   "b:Bc:C:D:de:f:g:G:hi:I:KLmn:No:O:p:P:qsTtuvW");
>  		if (c < 0)
>  			break;
>  		switch (c) {
> @@ -240,6 +243,11 @@ int main(int argc, char *argv[])
>  			iface->conf_p2p_dev = optarg;
>  			break;
>  #endif /* CONFIG_P2P */
> +#ifdef CONFIG_MESH
> +		case 'n':
> +			iface->conf_mesh = optarg;
> +			break;
> +#endif /* CONFIG_MESH */
>  		case 'o':
>  			params.override_driver = optarg;
>  			break;
> diff --git a/wpa_supplicant/mesh.c b/wpa_supplicant/mesh.c
> index 68187e0..a5785f2 100644
> --- a/wpa_supplicant/mesh.c
> +++ b/wpa_supplicant/mesh.c
> @@ -498,7 +498,7 @@ static int wpas_mesh_get_ifname(struct wpa_supplicant *wpa_s, char *ifname,
>  
>  
>  int wpas_mesh_add_interface(struct wpa_supplicant *wpa_s, char *ifname,
> -			    size_t len)
> +			    size_t len, const char *confname)
>  {
>  	struct wpa_interface iface;
>  	struct wpa_supplicant *mesh_wpa_s;
> @@ -510,7 +510,8 @@ int wpas_mesh_add_interface(struct wpa_supplicant *wpa_s, char *ifname,
>  	if (wpa_drv_if_add(wpa_s, WPA_IF_MESH, ifname, NULL, NULL, NULL, addr,
>  			   NULL) < 0) {
>  		wpa_printf(MSG_ERROR,
> -			   "mesh: Failed to create new mesh interface");
> +			   "mesh: Failed to create new mesh interface %s",
> +			   ifname);
>  		return -1;
>  	}
>  	wpa_printf(MSG_INFO, "mesh: Created virtual interface %s addr "
> @@ -520,7 +521,9 @@ int wpas_mesh_add_interface(struct wpa_supplicant *wpa_s, char *ifname,
>  	iface.ifname = ifname;
>  	iface.driver = wpa_s->driver->name;
>  	iface.driver_param = wpa_s->conf->driver_param;
> -	iface.ctrl_interface = wpa_s->conf->ctrl_interface;
> +	iface.confname = confname;
> +	iface.ctrl_interface =
> +		confname == NULL ? wpa_s->conf->ctrl_interface : NULL;
>  
>  	mesh_wpa_s = wpa_supplicant_add_iface(wpa_s->global, &iface);
>  	if (!mesh_wpa_s) {
> diff --git a/wpa_supplicant/mesh.h b/wpa_supplicant/mesh.h
> index 3cb7f1b..bb4d05b 100644
> --- a/wpa_supplicant/mesh.h
> +++ b/wpa_supplicant/mesh.h
> @@ -17,7 +17,7 @@ void wpa_supplicant_mesh_iface_deinit(struct wpa_supplicant *wpa_s,
>  int wpas_mesh_scan_result_text(const u8 *ies, size_t ies_len, char *buf,
>  			       char *end);
>  int wpas_mesh_add_interface(struct wpa_supplicant *wpa_s, char *ifname,
> -			    size_t len);
> +			    size_t len, const char *confname);
>  
>  #ifdef CONFIG_MESH
>  
> diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
> index 8ea023a..16c55ea 100644
> --- a/wpa_supplicant/wpa_supplicant.c
> +++ b/wpa_supplicant/wpa_supplicant.c
> @@ -4006,6 +4006,9 @@ struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global,
>  	struct wpa_supplicant *wpa_s;
>  	struct wpa_interface t_iface;
>  	struct wpa_ssid *ssid;
> +#ifdef CONFIG_MESH
> +	char ifname[IFNAMSIZ + 1];
> +#endif /* CONFIG_MESH */
>  
>  	if (global == NULL || iface == NULL)
>  		return NULL;
> @@ -4064,6 +4067,14 @@ struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global,
>  		/* Try to continue without. P2P will be disabled. */
>  	}
>  #endif /* CONFIG_P2P */
> +#ifdef CONFIG_MESH
> +	if (iface->conf_mesh != NULL &&
> +	    (wpa_s->drv_flags & WPA_DRIVER_FLAGS_MESH)) {
> +		ifname[0] = '\0';
> +		wpas_mesh_add_interface(wpa_s, ifname, sizeof(ifname),
> +					iface->conf_mesh);
> +	}
> +#endif /* CONFIG_MESH */
>  
>  	return wpa_s;
>  }
> diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
> index b0f3866..56aec62 100644
> --- a/wpa_supplicant/wpa_supplicant_i.h
> +++ b/wpa_supplicant/wpa_supplicant_i.h
> @@ -77,6 +77,17 @@ struct wpa_interface {
>  	const char *conf_p2p_dev;
>  #endif /* CONFIG_P2P */
>  
> +#ifdef CONFIG_MESH
> +	/**
> +	 * conf_mesh - Additional configuration file used to hold the mesh
> +	 * network configuration parameters.
> +	 *
> +	 * This can also be %NULL. In such a case, virtual interface for mesh
> +	 * will not be created.
> +	 */
> +	const char *conf_mesh;
> +#endif /* CONFIG_MESH */
> +
>  	/**
>  	 * ctrl_interface - Control interface parameter
>  	 *




More information about the Hostap mailing list