[PATCH v2 08/10] mesh: Add virtual interface on booting
Masashi Honma
masashi.honma
Fri Nov 14 17:35:30 PST 2014
This functionality is used to create mesh gate.
Signed-off-by: Masashi Honma <masashi.honma at gmail.com>
---
wpa_supplicant/ctrl_iface.c | 2 +-
wpa_supplicant/main.c | 7 ++++++-
wpa_supplicant/mesh.c | 8 +++++---
wpa_supplicant/mesh.h | 2 +-
wpa_supplicant/wpa_supplicant.c | 11 +++++++++++
wpa_supplicant/wpa_supplicant_i.h | 11 +++++++++++
6 files changed, 35 insertions(+), 6 deletions(-)
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index f9463fc..a1b5328 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -2373,7 +2373,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/main.c b/wpa_supplicant/main.c
index 13e9769..3492589 100644
--- a/wpa_supplicant/main.c
+++ b/wpa_supplicant/main.c
@@ -175,7 +175,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 +240,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 5382430..8d99de9 100644
--- a/wpa_supplicant/mesh.c
+++ b/wpa_supplicant/mesh.c
@@ -486,7 +486,7 @@ static void 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;
@@ -498,7 +498,7 @@ 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");
+ "interface %s", ifname);
return -1;
}
wpa_printf(MSG_INFO, "mesh: Created virtual interface %s addr "
@@ -508,7 +508,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 ba7e527..a8e1c72 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -4045,6 +4045,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;
@@ -4101,6 +4104,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 5648222..26b30c2 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -76,6 +76,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
*
--
1.9.1
More information about the Hostap
mailing list