[PATCH] wpa-cli: Show OSEN scan results properly.

greearb at candelatech.com greearb
Tue Mar 17 13:52:29 PDT 2015


From: Ben Greear <greearb at candelatech.com>

Old code defaulted to WEP.  Show as OSEN instead.
Re-use most of the RSN parsing logic since all but the
header is the same.

Example output:

[root at ath9k-f lanforge]# ./local/bin/wpa_cli -i sta0 scan_results
bssid / frequency / signal level / flags / ssid
00:0e:8e:6f:40:49	2462	-23	[OSEN--CCMP][ESS]	ben-138

Signed-off-by: Ben Greear <greearb at candelatech.com>
---
 src/common/wpa_common.c     | 32 ++++++++++++++++++++++----------
 src/rsn_supp/wpa_ie.c       |  7 +++++++
 wpa_supplicant/ctrl_iface.c |  7 +++++--
 3 files changed, 34 insertions(+), 12 deletions(-)

diff --git a/src/common/wpa_common.c b/src/common/wpa_common.c
index de81d53..07dca2d 100644
--- a/src/common/wpa_common.c
+++ b/src/common/wpa_common.c
@@ -508,7 +508,6 @@ int wpa_cipher_valid_mgmt_group(int cipher)
 int wpa_parse_wpa_ie_rsn(const u8 *rsn_ie, size_t rsn_ie_len,
 			 struct wpa_ie_data *data)
 {
-	const struct rsn_ie_hdr *hdr;
 	const u8 *pos;
 	int left;
 	int i, count;
@@ -538,18 +537,31 @@ int wpa_parse_wpa_ie_rsn(const u8 *rsn_ie, size_t rsn_ie_len,
 		return -1;
 	}
 
-	hdr = (const struct rsn_ie_hdr *) rsn_ie;
+	if (rsn_ie_len >= 6 &&
+	    rsn_ie[0] == WLAN_EID_VENDOR_SPECIFIC &&
+	    rsn_ie[5] == HS20_OSEN_OUI_TYPE) {
+		/* Assume calling code has done more specific checks on
+		   the vendor type */
+		pos = rsn_ie + 6;
+		left = rsn_ie_len - 6;
 
-	if (hdr->elem_id != WLAN_EID_RSN ||
-	    hdr->len != rsn_ie_len - 2 ||
-	    WPA_GET_LE16(hdr->version) != RSN_VERSION) {
-		wpa_printf(MSG_DEBUG, "%s: malformed ie or unknown version",
-			   __func__);
-		return -2;
+		data->proto = WPA_PROTO_OSEN;
 	}
+	else {
+		const struct rsn_ie_hdr *hdr;
+		hdr = (const struct rsn_ie_hdr *) rsn_ie;
+
+		if (hdr->elem_id != WLAN_EID_RSN ||
+		    hdr->len != rsn_ie_len - 2 ||
+		    WPA_GET_LE16(hdr->version) != RSN_VERSION) {
+			wpa_printf(MSG_DEBUG, "%s: malformed ie or unknown version",
+				   __func__);
+			return -2;
+		}
 
-	pos = (const u8 *) (hdr + 1);
-	left = rsn_ie_len - sizeof(*hdr);
+		pos = (const u8 *) (hdr + 1);
+		left = rsn_ie_len - sizeof(*hdr);
+	}
 
 	if (left >= RSN_SELECTOR_LEN) {
 		data->group_cipher = rsn_selector_to_bitfield(pos);
diff --git a/src/rsn_supp/wpa_ie.c b/src/rsn_supp/wpa_ie.c
index cb334df..983306e 100644
--- a/src/rsn_supp/wpa_ie.c
+++ b/src/rsn_supp/wpa_ie.c
@@ -30,6 +30,13 @@ int wpa_parse_wpa_ie(const u8 *wpa_ie, size_t wpa_ie_len,
 {
 	if (wpa_ie_len >= 1 && wpa_ie[0] == WLAN_EID_RSN)
 		return wpa_parse_wpa_ie_rsn(wpa_ie, wpa_ie_len, data);
+	else if (wpa_ie_len >= 6 && wpa_ie[0] == WLAN_EID_VENDOR_SPECIFIC &&
+		 wpa_ie[2] == ((WLAN_AKM_SUITE_OSEN >> 24) & 0xFF) &&
+		 wpa_ie[3] == ((WLAN_AKM_SUITE_OSEN >> 16) & 0xFF) &&
+		 wpa_ie[4] == ((WLAN_AKM_SUITE_OSEN >> 8) & 0xFF) &&
+		 wpa_ie[5] == HS20_OSEN_OUI_TYPE) {
+		return wpa_parse_wpa_ie_rsn(wpa_ie, wpa_ie_len, data);
+	}
 	else
 		return wpa_parse_wpa_ie_wpa(wpa_ie, wpa_ie_len, data);
 }
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index dce4557..4902db4 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -2460,7 +2460,7 @@ static int wpa_supplicant_ctrl_iface_scan_result(
 {
 	char *pos, *end;
 	int ret;
-	const u8 *ie, *ie2, *p2p, *mesh;
+	const u8 *ie, *ie2, *osen_ie, *p2p, *mesh;
 
 	mesh = wpa_bss_get_ie(bss, WLAN_EID_MESH_ID);
 	p2p = wpa_bss_get_vendor_ie(bss, P2P_IE_VENDOR_TYPE);
@@ -2479,7 +2479,10 @@ static int wpa_supplicant_ctrl_iface_scan_result(
 	if (os_snprintf_error(end - pos, ret))
 		return -1;
 	pos += ret;
+	osen_ie = wpa_bss_get_vendor_ie(bss, OSEN_IE_VENDOR_TYPE);
 	ie = wpa_bss_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE);
+	if (osen_ie)
+		pos = wpa_supplicant_ie_txt(pos, end, "OSEN", osen_ie, 2 + osen_ie[1]);
 	if (ie)
 		pos = wpa_supplicant_ie_txt(pos, end, "WPA", ie, 2 + ie[1]);
 	ie2 = wpa_bss_get_ie(bss, WLAN_EID_RSN);
@@ -2488,7 +2491,7 @@ static int wpa_supplicant_ctrl_iface_scan_result(
 					    ie2, 2 + ie2[1]);
 	}
 	pos = wpa_supplicant_wps_ie_txt(wpa_s, pos, end, bss);
-	if (!ie && !ie2 && bss->caps & IEEE80211_CAP_PRIVACY) {
+	if (!ie && !ie2 && !osen_ie && bss->caps & IEEE80211_CAP_PRIVACY) {
 		ret = os_snprintf(pos, end - pos, "[WEP]");
 		if (os_snprintf_error(end - pos, ret))
 			return -1;
-- 
1.7.11.7




More information about the Hostap mailing list