aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/mesh.c
diff options
context:
space:
mode:
authorMasashi Honma <masashi.honma@gmail.com>2014-11-15 01:35:23 (GMT)
committerJouni Malinen <j@w1.fi>2014-12-14 21:27:43 (GMT)
commit5b78493f3ba97b015f221b0efc7a858b2372321c (patch)
tree94d7f328d30c04785f96977abd88dbaefe2aadbc /wpa_supplicant/mesh.c
parentbd0b62037120791c7dd72485d89a795c385f2f17 (diff)
downloadhostap-5b78493f3ba97b015f221b0efc7a858b2372321c.zip
hostap-5b78493f3ba97b015f221b0efc7a858b2372321c.tar.gz
hostap-5b78493f3ba97b015f221b0efc7a858b2372321c.tar.bz2
mesh: Add mesh interface creation command for mesh gate
The mesh gate is used to bridge (or route) between mesh network and another network. For example, mesh gate acts as router between mesh network and IEEE 802.11 BSS network. This command makes a virtual mesh interface to be used for mesh gate. This command expects to be used like this. wpa_cli -i wlan0 MESH_INTERFACE_ADD ifname=mesh0 wpa_cli -i mesh0 add_network wpa_cli -i mesh0 set_network 0 ssid '"commell_2X_mmm"' wpa_cli -i mesh0 set_network 0 mode 5 wpa_cli -i mesh0 set_network 0 frequency 2412 wpa_cli -i mesh0 set_network 0 key_mgmt SAE wpa_cli -i mesh0 set_network 0 psk '"01234567"' wpa_cli -i mesh0 mesh_group_add 0 wpa_cli -i wlan0 mesh_group_remove mesh0 Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
Diffstat (limited to 'wpa_supplicant/mesh.c')
-rw-r--r--wpa_supplicant/mesh.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/wpa_supplicant/mesh.c b/wpa_supplicant/mesh.c
index 3f262fb..68187e0 100644
--- a/wpa_supplicant/mesh.c
+++ b/wpa_supplicant/mesh.c
@@ -474,3 +474,62 @@ int wpas_mesh_scan_result_text(const u8 *ies, size_t ies_len, char *buf,
{
return mesh_attr_text(ies, ies_len, buf, end);
}
+
+
+static int wpas_mesh_get_ifname(struct wpa_supplicant *wpa_s, char *ifname,
+ size_t len)
+{
+ char *ifname_ptr = wpa_s->ifname;
+ int res;
+
+ res = os_snprintf(ifname, len, "mesh-%s-%d", ifname_ptr,
+ wpa_s->mesh_if_idx);
+ if (os_snprintf_error(len, res) ||
+ (os_strlen(ifname) >= IFNAMSIZ &&
+ os_strlen(wpa_s->ifname) < IFNAMSIZ)) {
+ /* Try to avoid going over the IFNAMSIZ length limit */
+ res = os_snprintf(ifname, len, "mesh-%d", wpa_s->mesh_if_idx);
+ if (os_snprintf_error(len, res))
+ return -1;
+ }
+ wpa_s->mesh_if_idx++;
+ return 0;
+}
+
+
+int wpas_mesh_add_interface(struct wpa_supplicant *wpa_s, char *ifname,
+ size_t len)
+{
+ struct wpa_interface iface;
+ struct wpa_supplicant *mesh_wpa_s;
+ u8 addr[ETH_ALEN];
+
+ if (ifname[0] == '\0' && wpas_mesh_get_ifname(wpa_s, ifname, len) < 0)
+ return -1;
+
+ 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");
+ return -1;
+ }
+ wpa_printf(MSG_INFO, "mesh: Created virtual interface %s addr "
+ MACSTR, ifname, MAC2STR(addr));
+
+ os_memset(&iface, 0, sizeof(iface));
+ 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;
+
+ mesh_wpa_s = wpa_supplicant_add_iface(wpa_s->global, &iface);
+ if (!mesh_wpa_s) {
+ wpa_printf(MSG_ERROR,
+ "mesh: Failed to create new wpa_supplicant interface");
+ wpa_supplicant_remove_iface(wpa_s->global, wpa_s, 0);
+ return -1;
+ }
+ mesh_wpa_s->mesh_if_created = 1;
+ mesh_wpa_s->parent = wpa_s;
+ return 0;
+}