linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/6] add support for parsing ERP information element
@ 2009-05-04  8:48 Marcel Holtmann
  2009-05-04  8:48 ` [PATCH 2/6] add basic support for parsing country " Marcel Holtmann
  0 siblings, 1 reply; 6+ messages in thread
From: Marcel Holtmann @ 2009-05-04  8:48 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless, Marcel Holtmann

---
 scan.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/scan.c b/scan.c
index 91e94ed..d4a4832 100644
--- a/scan.c
+++ b/scan.c
@@ -80,11 +80,27 @@ static void print_ign(unsigned char type, unsigned char len, unsigned char *data
 	/* ignore for now, not too useful */
 }
 
+static void print_erp(unsigned char type, unsigned char len, unsigned char *data)
+{
+	if (data[0] == 0x00)
+		return;
+
+	printf("\tERP:");
+	if (data[0] & 0x01)
+		printf(" NonERP_Present");
+	if (data[0] & 0x02)
+		printf(" Use_Protection");
+	if (data[0] & 0x04)
+		printf(" Barker_Preamble_Mode");
+	printf("\n");
+}
+
 static const printfn ieprinters[] = {
 	[0] = print_ssid,
 	[1] = print_supprates,
 	[3] = print_ds,
 	[5] = print_ign,
+	[42] = print_erp,
 	[50] = print_supprates,
 };
 
-- 
1.6.0.6


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/6] add basic support for parsing country information element
  2009-05-04  8:48 [PATCH 1/6] add support for parsing ERP information element Marcel Holtmann
@ 2009-05-04  8:48 ` Marcel Holtmann
  2009-05-04  8:48   ` [PATCH 3/6] add support for showing extended capabilities IE Marcel Holtmann
  0 siblings, 1 reply; 6+ messages in thread
From: Marcel Holtmann @ 2009-05-04  8:48 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless, Marcel Holtmann

---
 scan.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/scan.c b/scan.c
index d4a4832..5b5d300 100644
--- a/scan.c
+++ b/scan.c
@@ -80,6 +80,25 @@ static void print_ign(unsigned char type, unsigned char len, unsigned char *data
 	/* ignore for now, not too useful */
 }
 
+static void print_country(unsigned char type, unsigned char len, unsigned char *data)
+{
+	int i;
+
+	printf("\tCountry: %.*s", 2, data);
+	switch (data[2]) {
+	case 'I':
+		printf(" (indoor)");
+		break;
+	case 'O':
+		printf(" (outdoor)");
+		break;
+	}
+	printf(", data:");
+	for(i=0; i<len-3; i++)
+		printf(" %.02x", data[i + 3]);
+	printf("\n");
+}
+
 static void print_erp(unsigned char type, unsigned char len, unsigned char *data)
 {
 	if (data[0] == 0x00)
@@ -100,6 +119,7 @@ static const printfn ieprinters[] = {
 	[1] = print_supprates,
 	[3] = print_ds,
 	[5] = print_ign,
+	[7] = print_country,
 	[42] = print_erp,
 	[50] = print_supprates,
 };
-- 
1.6.0.6


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/6] add support for showing extended capabilities IE
  2009-05-04  8:48 ` [PATCH 2/6] add basic support for parsing country " Marcel Holtmann
@ 2009-05-04  8:48   ` Marcel Holtmann
  2009-05-04  8:48     ` [PATCH 4/6] add human readable decoding for capability information field Marcel Holtmann
  0 siblings, 1 reply; 6+ messages in thread
From: Marcel Holtmann @ 2009-05-04  8:48 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless, Marcel Holtmann

---
 scan.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/scan.c b/scan.c
index 5b5d300..0cd3aa8 100644
--- a/scan.c
+++ b/scan.c
@@ -114,6 +114,16 @@ static void print_erp(unsigned char type, unsigned char len, unsigned char *data
 	printf("\n");
 }
 
+static void print_capabilities(unsigned char type, unsigned char len, unsigned char *data)
+{
+	int i;
+
+	printf("\tExtended capabilties:");
+	for(i=0; i<len; i++)
+		printf(" %.02x", data[i]);
+	printf("\n");
+}
+
 static const printfn ieprinters[] = {
 	[0] = print_ssid,
 	[1] = print_supprates,
@@ -122,6 +132,7 @@ static const printfn ieprinters[] = {
 	[7] = print_country,
 	[42] = print_erp,
 	[50] = print_supprates,
+	[127] = print_capabilities,
 };
 
 static void tab_on_first(bool *first)
-- 
1.6.0.6


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/6] add human readable decoding for capability information field
  2009-05-04  8:48   ` [PATCH 3/6] add support for showing extended capabilities IE Marcel Holtmann
@ 2009-05-04  8:48     ` Marcel Holtmann
  2009-05-04  8:48       ` [PATCH 5/6] add basic support for parsing WMM information element Marcel Holtmann
  0 siblings, 1 reply; 6+ messages in thread
From: Marcel Holtmann @ 2009-05-04  8:48 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless, Marcel Holtmann

---
 scan.c |   44 +++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/scan.c b/scan.c
index 0cd3aa8..8cd1f90 100644
--- a/scan.c
+++ b/scan.c
@@ -13,6 +13,20 @@
 #include "nl80211.h"
 #include "iw.h"
 
+#define WLAN_CAPABILITY_ESS		(1<<0)
+#define WLAN_CAPABILITY_IBSS		(1<<1)
+#define WLAN_CAPABILITY_CF_POLLABLE	(1<<2)
+#define WLAN_CAPABILITY_CF_POLL_REQUEST	(1<<3)
+#define WLAN_CAPABILITY_PRIVACY		(1<<4)
+#define WLAN_CAPABILITY_SHORT_PREAMBLE	(1<<5)
+#define WLAN_CAPABILITY_PBCC		(1<<6)
+#define WLAN_CAPABILITY_CHANNEL_AGILITY	(1<<7)
+#define WLAN_CAPABILITY_SPECTRUM_MGMT	(1<<8)
+#define WLAN_CAPABILITY_QOS		(1<<9)
+#define WLAN_CAPABILITY_SHORT_SLOT_TIME	(1<<10)
+#define WLAN_CAPABILITY_APSD		(1<<11)
+#define WLAN_CAPABILITY_DSSS_OFDM	(1<<13)
+
 struct scan_params {
 	bool unknown;
 };
@@ -333,9 +347,33 @@ static int print_bss_handler(struct nl_msg *msg, void *arg)
 	if (bss[NL80211_BSS_BEACON_INTERVAL])
 		printf("\tbeacon interval: %d\n",
 			nla_get_u16(bss[NL80211_BSS_BEACON_INTERVAL]));
-	if (bss[NL80211_BSS_CAPABILITY])
-		printf("\tcapability: 0x%.4x\n",
-			nla_get_u16(bss[NL80211_BSS_CAPABILITY]));
+	if (bss[NL80211_BSS_CAPABILITY]) {
+		__u16 capa = nla_get_u16(bss[NL80211_BSS_CAPABILITY]);
+		printf("\tcapability:");
+		if (capa & WLAN_CAPABILITY_ESS)
+			printf(" ESS");
+		if (capa & WLAN_CAPABILITY_IBSS)
+			printf(" IBSS");
+		if (capa & WLAN_CAPABILITY_PRIVACY)
+			printf(" Privacy");
+		if (capa & WLAN_CAPABILITY_SHORT_PREAMBLE)
+			printf(" ShortPreamble");
+		if (capa & WLAN_CAPABILITY_PBCC)
+			printf(" PBCC");
+		if (capa & WLAN_CAPABILITY_CHANNEL_AGILITY)
+			printf(" ChannelAgility");
+		if (capa & WLAN_CAPABILITY_SPECTRUM_MGMT)
+			printf(" SpectrumMgmt");
+		if (capa & WLAN_CAPABILITY_QOS)
+			printf(" QoS");
+		if (capa & WLAN_CAPABILITY_SHORT_SLOT_TIME)
+			printf(" ShortSlotTime");
+		if (capa & WLAN_CAPABILITY_APSD)
+			printf(" APSD");
+		if (capa & WLAN_CAPABILITY_DSSS_OFDM)
+			printf(" DSSS-OFDM");
+		printf(" (0x%.4x)\n", capa);
+	}
 	if (bss[NL80211_BSS_SIGNAL_MBM]) {
 		int s = nla_get_u32(bss[NL80211_BSS_SIGNAL_MBM]);
 		printf("\tsignal: %d.%.2d dBm\n", s/100, s%100);
-- 
1.6.0.6


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 5/6] add basic support for parsing WMM information element
  2009-05-04  8:48     ` [PATCH 4/6] add human readable decoding for capability information field Marcel Holtmann
@ 2009-05-04  8:48       ` Marcel Holtmann
  2009-05-04  8:48         ` [PATCH 6/6] add support for parsing WPA and RSN/WPA2 information elements Marcel Holtmann
  0 siblings, 1 reply; 6+ messages in thread
From: Marcel Holtmann @ 2009-05-04  8:48 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless, Marcel Holtmann

---
 scan.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/scan.c b/scan.c
index 8cd1f90..6ff4386 100644
--- a/scan.c
+++ b/scan.c
@@ -157,6 +157,28 @@ static void tab_on_first(bool *first)
 		*first = false;
 }
 
+static void print_wifi_wmm(unsigned char type, unsigned char len, unsigned char *data)
+{
+	int i;
+
+	printf("\tWMM ");
+	switch (data[0]) {
+	case 0x00:
+		printf("information:");
+		break;
+	case 0x01:
+		printf("parameter:");
+		break;
+	default:
+		printf("type %d:", data[0]);
+		break;
+	}
+
+	for(i=0; i<len-1; i++)
+		printf(" %.02x", data[i + 1]);
+	printf("\n");
+}
+
 static void print_wifi_wps(unsigned char type, unsigned char len, unsigned char *data)
 {
 	bool first = true;
@@ -238,6 +260,7 @@ static void print_wifi_wps(unsigned char type, unsigned char len, unsigned char
 }
 
 static const printfn wifiprinters[] = {
+	[2] = print_wifi_wmm,
 	[4] = print_wifi_wps,
 };
 
-- 
1.6.0.6


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 6/6] add support for parsing WPA and RSN/WPA2 information elements
  2009-05-04  8:48       ` [PATCH 5/6] add basic support for parsing WMM information element Marcel Holtmann
@ 2009-05-04  8:48         ` Marcel Holtmann
  0 siblings, 0 replies; 6+ messages in thread
From: Marcel Holtmann @ 2009-05-04  8:48 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless, Marcel Holtmann

---
 scan.c |  194 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 187 insertions(+), 7 deletions(-)

diff --git a/scan.c b/scan.c
index 6ff4386..8fb7ac2 100644
--- a/scan.c
+++ b/scan.c
@@ -27,6 +27,9 @@
 #define WLAN_CAPABILITY_APSD		(1<<11)
 #define WLAN_CAPABILITY_DSSS_OFDM	(1<<13)
 
+static unsigned char wifi_oui[3]      = { 0x00, 0x50, 0xf2 };
+static unsigned char ieee80211_oui[3] = { 0x00, 0x0f, 0xac };
+
 struct scan_params {
 	bool unknown;
 };
@@ -55,6 +58,14 @@ COMMAND(scan, trigger, NULL,
 
 typedef void (*printfn)(unsigned char type, unsigned char len, unsigned char *data);
 
+static void tab_on_first(bool *first)
+{
+	if (!*first)
+		printf("\t");
+	else
+		*first = false;
+}
+
 static void print_ssid(unsigned char type, unsigned char len, unsigned char *data)
 {
 	int i;
@@ -128,6 +139,176 @@ static void print_erp(unsigned char type, unsigned char len, unsigned char *data
 	printf("\n");
 }
 
+static void print_cipher(unsigned char *data)
+{
+	if (memcmp(data, wifi_oui, 3) == 0) {
+		switch (data[3]) {
+		case 0x00:
+			printf("Use group cipher suite");
+			break;
+		case 0x01:
+			printf("WEP-40");
+			break;
+		case 0x02:
+			printf("TKIP");
+			break;
+		case 0x04:
+			printf("CCMP");
+			break;
+		case 0x05:
+			printf("WEP-104");
+			break;
+		default:
+			printf("Reserved (%.02x)", data[3]);
+			break;
+		}
+	} else if (memcmp(data, ieee80211_oui, 3) == 0) {
+		switch (data[3]) {
+		case 0x00:
+			printf("Use group cipher suite");
+			break;
+		case 0x01:
+			printf("WEP-40");
+			break;
+		case 0x02:
+			printf("TKIP");
+			break;
+		case 0x04:
+			printf("CCMP");
+			break;
+		case 0x05:
+			printf("WEP-104");
+			break;
+		case 0x06:
+			printf("AES-128-CMAC");
+			break;
+		default:
+			printf("Reserved (%.02x)", data[3]);
+			break;
+		}
+	} else
+		printf("Other");
+}
+
+static void print_auth(unsigned char *data)
+{
+	if (memcmp(data, wifi_oui, 3) == 0) {
+		switch (data[3]) {
+		case 0x01:
+			printf("IEEE 802.1X");
+			break;
+		case 0x02:
+			printf("PSK");
+			break;
+		default:
+			printf("Reserved (%.02x)", data[3]);
+			break;
+		}
+	} else if (memcmp(data, ieee80211_oui, 3) == 0) {
+		switch (data[3]) {
+		case 0x01:
+			printf("IEEE 802.1X");
+			break;
+		case 0x02:
+			printf("PSK");
+			break;
+		default:
+			printf("Reserved (%.02x)", data[3]);
+			break;
+		}
+	} else
+		printf("Other");
+}
+
+static void print_wpa(const char *ie,
+		      const char *defcipher, const char *defauth,
+		      unsigned char len, unsigned char *data)
+{
+	bool first = true;
+	__u16 version, count, capa;
+	int i;
+
+	printf("\t%s:", ie);
+
+	if (len < 2) {
+		printf(" <too short> data:");
+		for(i = 0; i < len; i++)
+			printf(" %.02x", data[i]);
+		printf("\n");
+		return;
+	}
+
+	version = data[0] + (data[1] << 8);
+	tab_on_first(&first);
+	printf("\t * Version: %d\n", version);
+
+	data += 2;
+	len -= 2;
+
+	if (len < 4) {
+		tab_on_first(&first);
+		printf("\t * Group cipher: %s\n", defcipher);
+		printf("\t * Pairwise ciphers: %s\n", defcipher);
+		return;
+	}
+
+	tab_on_first(&first);
+	printf("\t * Group cipher: ");
+	print_cipher(data);
+	printf("\n");
+
+	data += 4;
+	len -= 4;
+
+	if (len < 2) {
+		tab_on_first(&first);
+		printf("\t * Pairwise ciphers: %s\n", defcipher);
+		return;
+	}
+
+	count = data[0] | (data[1] << 8);
+	tab_on_first(&first);
+	printf("\t * Pairwise ciphers:");
+	for (i=0; i<count; i++) {
+		printf(" ");
+		print_cipher(data + 2 + (i * 4));
+	}
+	printf("\n");
+
+	data += 2 + (count * 4);
+	len -= 2 + (count * 4);
+
+	if (len < 2) {
+		tab_on_first(&first);
+		printf("\t * Authentication suites: %s\n", defauth);
+		return;
+	}
+
+	count = data[0] | (data[1] << 8);
+	tab_on_first(&first);
+	printf("\t * Authentication suites:");
+	for (i=0; i<count; i++) {
+		printf(" ");
+		print_auth(data + 2 + (i * 4));
+	}
+	printf("\n");
+
+	data += 2 + (count * 4);
+	len -= 2 + (count * 4);
+
+	if (len < 2)
+		return;
+
+	capa = data[0] | (data[1] << 8);
+	tab_on_first(&first);
+	printf("\t * Capabilities: 0x%.4x\n", capa);
+}
+
+static void print_rsn(unsigned char type, unsigned char len, unsigned char *data)
+{
+	print_wpa("WPA2", "CCMP", "IEEE 802.1X", len, data);
+}
+
 static void print_capabilities(unsigned char type, unsigned char len, unsigned char *data)
 {
 	int i;
@@ -145,16 +326,14 @@ static const printfn ieprinters[] = {
 	[5] = print_ign,
 	[7] = print_country,
 	[42] = print_erp,
+	[48] = print_rsn,
 	[50] = print_supprates,
 	[127] = print_capabilities,
 };
 
-static void tab_on_first(bool *first)
+static void print_wifi_wpa(unsigned char type, unsigned char len, unsigned char *data)
 {
-	if (!*first)
-		printf("\t");
-	else
-		*first = false;
+	print_wpa("WPA", "TKIP", "IEEE 802.1X", len, data);
 }
 
 static void print_wifi_wmm(unsigned char type, unsigned char len, unsigned char *data)
@@ -260,6 +439,7 @@ static void print_wifi_wps(unsigned char type, unsigned char len, unsigned char
 }
 
 static const printfn wifiprinters[] = {
+	[1] = print_wifi_wpa,
 	[2] = print_wifi_wmm,
 	[4] = print_wifi_wps,
 };
@@ -277,12 +457,12 @@ static void print_vendor(unsigned char len, unsigned char *data,
 		return;
 	}
 
-	if (len >= 4 && data[0] == 0x00 && data[1] == 0x50 && data[2] == 0xF2) {
+	if (len >= 4 && memcmp(data, wifi_oui, 3) == 0) {
 		if (data[3] < ARRAY_SIZE(wifiprinters) && wifiprinters[data[3]])
 			return wifiprinters[data[3]](data[3], len - 4, data + 4);
 		if (!params->unknown)
 			return;
-		printf("\tWiFi OUI %#.2x data:", data[3]);
+		printf("\tWiFi OUI %#.2x, data:", data[3]);
 		for(i = 0; i < len - 4; i++)
 			printf(" %.02x", data[i + 4]);
 		printf("\n");
-- 
1.6.0.6


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-05-04  8:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-04  8:48 [PATCH 1/6] add support for parsing ERP information element Marcel Holtmann
2009-05-04  8:48 ` [PATCH 2/6] add basic support for parsing country " Marcel Holtmann
2009-05-04  8:48   ` [PATCH 3/6] add support for showing extended capabilities IE Marcel Holtmann
2009-05-04  8:48     ` [PATCH 4/6] add human readable decoding for capability information field Marcel Holtmann
2009-05-04  8:48       ` [PATCH 5/6] add basic support for parsing WMM information element Marcel Holtmann
2009-05-04  8:48         ` [PATCH 6/6] add support for parsing WPA and RSN/WPA2 information elements Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).