[PATCH/RFC 13/18] wpa_supplicant: implement mesh scanning
Bob Copeland
me
Sun Jul 13 22:19:18 PDT 2014
From: Jason Abele <jason.abele at 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 at gmail.com>
Signed-hostap: Jason Abele <jason.abele at 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(-)
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 4635b0a..d8b648a 100644
--- a/wpa_supplicant/mesh.c
+++ b/wpa_supplicant/mesh.c
@@ -227,6 +227,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 40eb8d8..74dd6c2 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
--
2.0.0.rc2
More information about the Hostap
mailing list