diff mbox

[v2,13/20] wpa_supplicant: implement mesh scanning

Message ID 1409545419-2301-14-git-send-email-me@bobcopeland.com
State Accepted
Headers show

Commit Message

Bob Copeland Sept. 1, 2014, 4:23 a.m. UTC
From: Jason Abele <jason.abele@gmail.com>

When mesh is configured in, include the wildcard
mesh id so that mesh networks are returned.  Tag any
returned mesh networks with [MESH].

Signed-off-by: Javier Lopez <jlopex@gmail.com>
Signed-off-by: Jason Abele <jason.abele@gmail.com>
---
 wpa_supplicant/bss.c        |  8 +++++++-
 wpa_supplicant/ctrl_iface.c | 32 +++++++++++++++++++++++++++++---
 wpa_supplicant/mesh.c       | 12 ++++++++++++
 wpa_supplicant/mesh.h       |  2 ++
 wpa_supplicant/scan.c       |  5 +++++
 5 files changed, 55 insertions(+), 4 deletions(-)

Comments

Jouni Malinen Dec. 16, 2014, 6:04 p.m. UTC | #1
On Mon, Sep 01, 2014 at 12:23:32AM -0400, Bob Copeland wrote:
> When mesh is configured in, include the wildcard
> mesh id so that mesh networks are returned.  Tag any
> returned mesh networks with [MESH].

Somehow I missed that this adds the Mesh ID element unconditionally to
every Probe Request frame:

> +void wpa_supplicant_mesh_add_scan_ie(struct wpa_supplicant *wpa_s,
> +				     struct wpabuf **extra_ie)
> +{
> +	/* EID + 0-length (wildcard) mesh-id */
> +	size_t ielen = 2;
> +
> +	if (wpabuf_resize(extra_ie, ielen) == 0) {
> +		wpabuf_put_u8(*extra_ie, WLAN_EID_MESH_ID);
> +		wpabuf_put_u8(*extra_ie, 0);
> +	}
> +}

> @@ -453,6 +454,10 @@ static struct wpabuf * wpa_supplicant_extra_ies(struct wpa_supplicant *wpa_s)
> +#ifdef CONFIG_MESH
> +	wpa_supplicant_mesh_add_scan_ie(wpa_s, &extra_ie);
> +#endif /* CONFIG_MESH */


This does not look reasonable taken into account that most scans are not
trying to find mesh BSSes, so I'm hoping to add something as a condition
for this addition. Would there be any suggestions on what that condition
would be? An enabled mesh network configured? Something specified with
the SCAN command as an option if no such network is included? Something
else?
Bob Copeland Dec. 17, 2014, 9:23 p.m. UTC | #2
On Tue, Dec 16, 2014 at 08:04:38PM +0200, Jouni Malinen wrote:
> This does not look reasonable taken into account that most scans are not
> trying to find mesh BSSes, so I'm hoping to add something as a condition
> for this addition. Would there be any suggestions on what that condition
> would be? An enabled mesh network configured? Something specified with
> the SCAN command as an option if no such network is included? Something
> else?

I think it would make sense to have an option with the SCAN command so we can
locate mesh networks without having to configure one (since configuring
one is essentially starting one in mesh.)
diff mbox

Patch

diff --git a/wpa_supplicant/bss.c b/wpa_supplicant/bss.c
index f99a8a7..b032adb 100644
--- a/wpa_supplicant/bss.c
+++ b/wpa_supplicant/bss.c
@@ -591,7 +591,7 @@  void wpa_bss_update_scan_res(struct wpa_supplicant *wpa_s,
 			     struct wpa_scan_res *res,
 			     struct os_reltime *fetch_time)
 {
-	const u8 *ssid, *p2p;
+	const u8 *ssid, *p2p, *mesh;
 	struct wpa_bss *bss;
 
 	if (wpa_s->conf->ignore_old_scan_res) {
@@ -641,7 +641,13 @@  void wpa_bss_update_scan_res(struct wpa_supplicant *wpa_s,
 
 	/* TODO: add option for ignoring BSSes we are not interested in
 	 * (to save memory) */
+
+	mesh = wpa_scan_get_ie(res, WLAN_EID_MESH_ID);
+	if (mesh)
+		ssid = mesh;
+
 	bss = wpa_bss_get(wpa_s, res->bssid, ssid + 2, ssid[1]);
+
 	if (bss == NULL)
 		bss = wpa_bss_add(wpa_s, ssid + 2, ssid[1], res, fetch_time);
 	else {
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 9736192..874e0c8 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -2113,6 +2113,23 @@  static char * wpa_supplicant_ie_txt(char *pos, char *end, const char *proto,
 	}
 #endif /* CONFIG_IEEE80211W */
 
+#ifdef CONFIG_MESH
+	if (data.key_mgmt & WPA_KEY_MGMT_SAE) {
+		ret = os_snprintf(pos, end - pos, "%sSAE",
+				  pos == start ? "" : "+");
+		if (ret < 0 || ret >= end - pos)
+			return pos;
+		pos += ret;
+	}
+	if (data.key_mgmt & WPA_KEY_MGMT_FT_SAE) {
+		ret = os_snprintf(pos, end - pos, "%sFT_SAE",
+				  pos == start ? "" : "+");
+		if (ret < 0 || ret >= end - pos)
+			return pos;
+		pos += ret;
+	}
+#endif /* CONFIG_MESH */
+
 	pos = wpa_supplicant_cipher_txt(pos, end, data.pairwise_cipher);
 
 	if (data.capabilities & WPA_CAPABILITY_PREAUTH) {
@@ -2180,8 +2197,9 @@  static int wpa_supplicant_ctrl_iface_scan_result(
 {
 	char *pos, *end;
 	int ret;
-	const u8 *ie, *ie2, *p2p;
+	const u8 *ie, *ie2, *p2p, *mesh;
 
+	mesh = wpa_bss_get_ie(bss, WLAN_EID_MESH_ID);
 	p2p = wpa_bss_get_vendor_ie(bss, P2P_IE_VENDOR_TYPE);
 	if (!p2p)
 		p2p = wpa_bss_get_vendor_ie_beacon(bss, P2P_IE_VENDOR_TYPE);
@@ -2202,8 +2220,10 @@  static int wpa_supplicant_ctrl_iface_scan_result(
 	if (ie)
 		pos = wpa_supplicant_ie_txt(pos, end, "WPA", ie, 2 + ie[1]);
 	ie2 = wpa_bss_get_ie(bss, WLAN_EID_RSN);
-	if (ie2)
-		pos = wpa_supplicant_ie_txt(pos, end, "WPA2", ie2, 2 + ie2[1]);
+	if (ie2) {
+		const char *ie_name = mesh ? "RSN" : "WPA2";
+		pos = wpa_supplicant_ie_txt(pos, end, ie_name, ie2, 2 + ie2[1]);
+	}
 	pos = wpa_supplicant_wps_ie_txt(wpa_s, pos, end, bss);
 	if (!ie && !ie2 && bss->caps & IEEE80211_CAP_PRIVACY) {
 		ret = os_snprintf(pos, end - pos, "[WEP]");
@@ -2211,6 +2231,12 @@  static int wpa_supplicant_ctrl_iface_scan_result(
 			return -1;
 		pos += ret;
 	}
+	if (mesh) {
+		ret = os_snprintf(pos, end - pos, "[MESH]");
+		if (ret < 0 || ret >= end - pos)
+			return -1;
+		pos += ret;
+	}
 	if (bss_is_dmg(bss)) {
 		const char *s;
 		ret = os_snprintf(pos, end - pos, "[DMG]");
diff --git a/wpa_supplicant/mesh.c b/wpa_supplicant/mesh.c
index 74e2b3e..cc329d0 100644
--- a/wpa_supplicant/mesh.c
+++ b/wpa_supplicant/mesh.c
@@ -239,6 +239,18 @@  void wpa_mesh_notify_peer(struct wpa_supplicant *wpa_s, const u8 *addr,
 	wpa_mesh_new_mesh_peer(wpa_s, addr, &elems);
 }
 
+void wpa_supplicant_mesh_add_scan_ie(struct wpa_supplicant *wpa_s,
+				     struct wpabuf **extra_ie)
+{
+	/* EID + 0-length (wildcard) mesh-id */
+	size_t ielen = 2;
+
+	if (wpabuf_resize(extra_ie, ielen) == 0) {
+		wpabuf_put_u8(*extra_ie, WLAN_EID_MESH_ID);
+		wpabuf_put_u8(*extra_ie, 0);
+	}
+}
+
 int wpa_supplicant_join_mesh(struct wpa_supplicant *wpa_s,
 			     struct wpa_ssid *ssid)
 {
diff --git a/wpa_supplicant/mesh.h b/wpa_supplicant/mesh.h
index f08e641..9b14ecf 100644
--- a/wpa_supplicant/mesh.h
+++ b/wpa_supplicant/mesh.h
@@ -31,6 +31,8 @@  int wpa_supplicant_join_mesh(struct wpa_supplicant *wpa_s,
 int wpa_supplicant_leave_mesh(struct wpa_supplicant *wpa_s);
 void wpa_mesh_notify_peer(struct wpa_supplicant *wpa_s, const u8 *addr,
 			  const u8 *ies, int ie_len);
+void wpa_supplicant_mesh_add_scan_ie(struct wpa_supplicant *wpa_s,
+				     struct wpabuf **extra_ie);
 void wpa_supplicant_mesh_iface_deinit(struct wpa_supplicant *wpa_s,
 				      struct hostapd_iface *ifmsh);
 #endif /* MESH_H */
diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c
index ec80877..b03fd38 100644
--- a/wpa_supplicant/scan.c
+++ b/wpa_supplicant/scan.c
@@ -22,6 +22,7 @@ 
 #include "notify.h"
 #include "bss.h"
 #include "scan.h"
+#include "mesh.h"
 
 
 static void wpa_supplicant_gen_assoc_event(struct wpa_supplicant *wpa_s)
@@ -453,6 +454,10 @@  static struct wpabuf * wpa_supplicant_extra_ies(struct wpa_supplicant *wpa_s)
 	}
 #endif /* CONFIG_P2P */
 
+#ifdef CONFIG_MESH
+	wpa_supplicant_mesh_add_scan_ie(wpa_s, &extra_ie);
+#endif /* CONFIG_MESH */
+
 #endif /* CONFIG_WPS */
 
 #ifdef CONFIG_HS20