]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
iw: bring together common ht capability parsing
authorLuis R. Rodriguez <lrodriguez@atheros.com>
Tue, 8 Dec 2009 03:05:42 +0000 (22:05 -0500)
committerJohannes Berg <johannes@sipsolutions.net>
Tue, 8 Dec 2009 08:31:03 +0000 (09:31 +0100)
Both 'iw list' and 'iw dev wlan0 scan' now share the same
HT capability parsing code making them consistent.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
info.c
iw.h
scan.c
util.c

diff --git a/info.c b/info.c
index d7a7d48d44216836414f5318249ac65f1515c26d..9de7458375319d5447e0918c415aeb886df57573 100644 (file)
--- a/info.c
+++ b/info.c
@@ -89,41 +89,8 @@ static int print_phy_handler(struct nl_msg *msg, void *arg)
 
 #ifdef NL80211_BAND_ATTR_HT_CAPA
                if (tb_band[NL80211_BAND_ATTR_HT_CAPA]) {
-                       unsigned short cap = nla_get_u16(tb_band[NL80211_BAND_ATTR_HT_CAPA]);
-#define PCOM(fmt, args...) do { printf("\t\t\t* " fmt "\n", ##args); } while (0)
-#define PBCOM(bit, args...) if (cap & (bit)) PCOM(args)
-                       printf("\t\tHT capabilities: 0x%.4x\n", cap);
-                       PBCOM(0x0001, "LPDC coding");
-                       if (cap & 0x0002)
-                               PCOM("20/40 MHz operation");
-                       else
-                               PCOM("20 MHz operation");
-                       switch ((cap & 0x000c) >> 2) {
-                       case 0:
-                               PCOM("static SM PS");
-                               break;
-                       case 1:
-                               PCOM("dynamic SM PS");
-                               break;
-                       case 2:
-                               PCOM("reserved SM PS");
-                               break;
-                       case 3:
-                               PCOM("SM PS disabled");
-                               break;
-                       }
-                       PBCOM(0x0010, "HT-greenfield");
-                       PBCOM(0x0020, "20 MHz short GI");
-                       PBCOM(0x0040, "40 MHz short GI");
-                       PBCOM(0x0080, "TX STBC");
-                       if (cap & 0x300)
-                               PCOM("RX STBC %d streams", (cap & 0x0300) >> 8);
-                       PBCOM(0x0400, "HT-delayed block-ack");
-                       PCOM("max A-MSDU len %d", 0xeff + ((cap & 0x0800) << 1));
-                       PBCOM(0x1000, "DSSS/CCK 40 MHz");
-                       PBCOM(0x2000, "PSMP support");
-                       PBCOM(0x4000, "40 MHz intolerant");
-                       PBCOM(0x8000, "L-SIG TXOP protection support");
+                       __u16 cap = nla_get_u16(tb_band[NL80211_BAND_ATTR_HT_CAPA]);
+                       print_ht_capability(cap);
                }
                if (tb_band[NL80211_BAND_ATTR_HT_AMPDU_FACTOR]) {
                        __u8 exponent = nla_get_u8(tb_band[NL80211_BAND_ATTR_HT_AMPDU_FACTOR]);
diff --git a/iw.h b/iw.h
index d3b805a1064c64f19a8cae69119f20adba3a5129..a7545610db1f8ea56f7d55d1b7c0d9a01642f8d4 100644 (file)
--- a/iw.h
+++ b/iw.h
@@ -123,6 +123,7 @@ int parse_keys(struct nl_msg *msg, char **argv, int argc);
 void print_mcs_set(const uint8_t *data);
 void print_ampdu_length(__u8 exponent);
 void print_ampdu_spacing(__u8 spacing);
+void print_ht_capability(__u16 cap);
 
 const char *iftype_name(enum nl80211_iftype iftype);
 const char *command_name(enum nl80211_commands cmd);
diff --git a/scan.c b/scan.c
index 6268f3db28cd7f21a6ad8d8da41308f0498e192d..bf2ec551f0362d6d3e9f686257fb49bc2a4def53 100644 (file)
--- a/scan.c
+++ b/scan.c
@@ -458,45 +458,9 @@ static void print_ht_capa(const uint8_t type, uint8_t len, const uint8_t *data)
 
        memcpy(&ht_cap, data, 26);
 
-       printf("\n\t\tCapabilities: %#.4x\n", htc->cap);
-
-       PRINT_HT_CAP((htc->cap & BIT(0)), "RX LDCP");
-       PRINT_HT_CAP((htc->cap & BIT(1)), "HT20/HT40");
-       PRINT_HT_CAP(!(htc->cap & BIT(1)), "HT20");
-
-       PRINT_HT_CAP(((htc->cap >> 2) & 0x3) == 0, "Static SM Power Save");
-       PRINT_HT_CAP(((htc->cap >> 2) & 0x3) == 1, "Dynamic SM Power Save");
-       PRINT_HT_CAP(((htc->cap >> 2) & 0x3) == 3, "SM Power Save disabled");
-
-       PRINT_HT_CAP((htc->cap & BIT(4)), "RX Greenfield");
-       PRINT_HT_CAP((htc->cap & BIT(5)), "RX HT20 SGI");
-       PRINT_HT_CAP((htc->cap & BIT(6)), "RX HT40 SGI");
-       PRINT_HT_CAP((htc->cap & BIT(7)), "TX STBC");
-
-       PRINT_HT_CAP(((htc->cap >> 8) & 0x3) == 0, "No RX STBC");
-       PRINT_HT_CAP(((htc->cap >> 8) & 0x3) == 1, "RX STBC 1-stream");
-       PRINT_HT_CAP(((htc->cap >> 8) & 0x3) == 2, "RX STBC 2-streams");
-       PRINT_HT_CAP(((htc->cap >> 8) & 0x3) == 3, "RX STBC 3-streams");
-
-       PRINT_HT_CAP((htc->cap & BIT(10)), "HT Delayed Block Ack");
-
-       PRINT_HT_CAP((htc->cap & BIT(11)), "Max AMSDU length: 3839 bytes");
-        PRINT_HT_CAP(!(htc->cap & BIT(11)), "Max AMSDU length: 7935 bytes");
-
-       /*
-        * For beacons and probe response this would mean the BSS
-        * does or does not allow the usage of DSSS/CCK HT40.
-        * Otherwise it means the STA does or does not use
-        * DSSS/CCK HT40.
-        */
-       PRINT_HT_CAP((htc->cap & BIT(12)), "DSSS/CCK HT40");
-       PRINT_HT_CAP(!(htc->cap & BIT(12)), "No DSSS/CCK HT40");
-
-       /* BIT(13) is reserved */
-
-       PRINT_HT_CAP((htc->cap & BIT(14)), "40 MHz Intolerant");
+       printf("\n");
+       print_ht_capability(htc->cap);
 
-       PRINT_HT_CAP((htc->cap & BIT(15)), "L-SIG TXOP protection");
 
        ampdu_exponent = htc->ampdu_params & 0x3;
        print_ampdu_length(ampdu_exponent);
diff --git a/util.c b/util.c
index 1424a5814f14cad9e78ddf457a69043a12bf7278..f017b883834d7844e75d3ae287c07daf72c084c9 100644 (file)
--- a/util.c
+++ b/util.c
@@ -355,3 +355,53 @@ void print_ampdu_spacing(__u8 spacing)
         printf("\t\tMinimum RX AMPDU time spacing: %s (0x%02x)\n",
                print_ampdu_space(spacing), spacing);
 }
+
+void print_ht_capability(__u16 cap)
+{
+#define PRINT_HT_CAP(_cond, _str) \
+       do { \
+               if (_cond) \
+                       printf("\t\t\t" _str "\n"); \
+       } while (0)
+
+       printf("\t\tCapabilities: 0x%02x\n", cap);
+
+       PRINT_HT_CAP((cap & BIT(0)), "RX LDCP");
+       PRINT_HT_CAP((cap & BIT(1)), "HT20/HT40");
+       PRINT_HT_CAP(!(cap & BIT(1)), "HT20");
+
+       PRINT_HT_CAP(((cap >> 2) & 0x3) == 0, "Static SM Power Save");
+       PRINT_HT_CAP(((cap >> 2) & 0x3) == 1, "Dynamic SM Power Save");
+       PRINT_HT_CAP(((cap >> 2) & 0x3) == 3, "SM Power Save disabled");
+
+       PRINT_HT_CAP((cap & BIT(4)), "RX Greenfield");
+       PRINT_HT_CAP((cap & BIT(5)), "RX HT20 SGI");
+       PRINT_HT_CAP((cap & BIT(6)), "RX HT40 SGI");
+       PRINT_HT_CAP((cap & BIT(7)), "TX STBC");
+
+       PRINT_HT_CAP(((cap >> 8) & 0x3) == 0, "No RX STBC");
+       PRINT_HT_CAP(((cap >> 8) & 0x3) == 1, "RX STBC 1-stream");
+       PRINT_HT_CAP(((cap >> 8) & 0x3) == 2, "RX STBC 2-streams");
+       PRINT_HT_CAP(((cap >> 8) & 0x3) == 3, "RX STBC 3-streams");
+
+       PRINT_HT_CAP((cap & BIT(10)), "HT Delayed Block Ack");
+
+       PRINT_HT_CAP((cap & BIT(11)), "Max AMSDU length: 3839 bytes");
+        PRINT_HT_CAP(!(cap & BIT(11)), "Max AMSDU length: 7935 bytes");
+
+       /*
+        * For beacons and probe response this would mean the BSS
+        * does or does not allow the usage of DSSS/CCK HT40.
+        * Otherwise it means the STA does or does not use
+        * DSSS/CCK HT40.
+        */
+       PRINT_HT_CAP((cap & BIT(12)), "DSSS/CCK HT40");
+       PRINT_HT_CAP(!(cap & BIT(12)), "No DSSS/CCK HT40");
+
+       /* BIT(13) is reserved */
+
+       PRINT_HT_CAP((cap & BIT(14)), "40 MHz Intolerant");
+
+       PRINT_HT_CAP((cap & BIT(15)), "L-SIG TXOP protection");
+#undef PRINT_HT_CAP
+}