]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
print status
authorJohannes Berg <johannes@sipsolutions.net>
Tue, 5 May 2009 10:39:30 +0000 (12:39 +0200)
committerJohannes Berg <johannes@sipsolutions.net>
Tue, 5 May 2009 10:39:30 +0000 (12:39 +0200)
Makefile
iw.c
iw.h
status.c [new file with mode: 0644]

index b1669c8e16aada8ccbdba0be908582f523e8de4f..3ad5bfc30ce14f1735fa5c3bff5656b02ea38fc8 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -13,7 +13,7 @@ CC ?= "gcc"
 CFLAGS ?= -O2 -g
 CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration
 
-OBJS = iw.o genl.o info.o phy.o interface.o ibss.o station.o util.o mesh.o mpath.o scan.o reg.o version.o reason.o
+OBJS = iw.o genl.o info.o phy.o interface.o ibss.o station.o util.o mesh.o mpath.o scan.o reg.o version.o reason.o status.o
 ALL = iw
 
 NL1FOUND := $(shell pkg-config --atleast-version=1 libnl-1 && echo Y)
diff --git a/iw.c b/iw.c
index 17b2d4c7b3f22941032c4d8011df25d031029a20..1100e80279b58a4662bbfccc067d00214f4de77f 100644 (file)
--- a/iw.c
+++ b/iw.c
@@ -333,13 +333,13 @@ struct print_event_args {
        bool frame;
 };
 
-static void print_frame(struct print_event_args *args, struct nlattr *attr,
-                       bool reason)
+static void print_frame(struct print_event_args *args, struct nlattr *attr)
 {
        uint8_t *frame;
        size_t len;
        int i;
        char macbuf[6*3];
+       uint16_t tmp;
 
        if (!attr)
                printf(" [no frame]");
@@ -347,31 +347,46 @@ static void print_frame(struct print_event_args *args, struct nlattr *attr,
        frame = nla_data(attr);
        len = nla_len(attr);
 
-       if (len >= 16) {
-               mac_addr_n2a(macbuf, frame + 10);
-               printf(" %s -> ", macbuf);
-       } else
-               printf(" ??? -> ");
+       if (len < 26) {
+               printf(" [invalid frame: ");
+               goto print_frame;
+       }
 
-       if (len >= 20) {
-               mac_addr_n2a(macbuf, frame + 4);
-               printf("%s", macbuf);
-       } else
-               printf("???");
-
-       if (reason) {
-               if (len >= 26) {
-                       uint16_t reason = (frame[25] << 8) + frame[24];
-                       printf(" reason %d: %s",
-                              reason, get_reason_str(reason));
-               } else
-                       printf(" reason ?: ???");
+       mac_addr_n2a(macbuf, frame + 10);
+       printf(" %s -> ", macbuf);
+       mac_addr_n2a(macbuf, frame + 4);
+       printf("%s", macbuf);
+
+       switch (frame[0] & 0xfc) {
+       case 0x10: /* assoc resp */
+       case 0x30: /* reassoc resp */
+               /* status */
+               tmp = (frame[27] << 8) + frame[26];
+               printf(" status: %d: %s", tmp, get_status_str(tmp));
+               break;
+       case 0x00: /* assoc req */
+       case 0x20: /* reassoc req */
+               break;
+       case 0xb0: /* auth */
+               /* status */
+               tmp = (frame[29] << 8) + frame[28];
+               printf(" status: %d: %s", tmp, get_status_str(tmp));
+               break;
+               break;
+       case 0xa0: /* disassoc */
+       case 0xc0: /* deauth */
+               /* reason */
+               tmp = (frame[25] << 8) + frame[24];
+               printf(" reason %d: %s", tmp, get_reason_str(tmp));
+               break;
        }
 
        if (!args->frame)
                return;
 
        printf(" [frame:");
+
+ print_frame:
        for (i = 0; i < len; i++)
                printf(" %.02x", frame[i]);
        printf("]");
@@ -450,22 +465,22 @@ static int print_event(struct nl_msg *msg, void *arg)
                break;
        case NL80211_CMD_AUTHENTICATE:
                printf("auth");
-               print_frame(args, tb[NL80211_ATTR_FRAME], false);
+               print_frame(args, tb[NL80211_ATTR_FRAME]);
                printf("\n");
                break;
        case NL80211_CMD_ASSOCIATE:
                printf("assoc");
-               print_frame(args, tb[NL80211_ATTR_FRAME], false);
+               print_frame(args, tb[NL80211_ATTR_FRAME]);
                printf("\n");
                break;
        case NL80211_CMD_DEAUTHENTICATE:
                printf("deauth");
-               print_frame(args, tb[NL80211_ATTR_FRAME], true);
+               print_frame(args, tb[NL80211_ATTR_FRAME]);
                printf("\n");
                break;
        case NL80211_CMD_DISASSOCIATE:
                printf("disassoc");
-               print_frame(args, tb[NL80211_ATTR_FRAME], true);
+               print_frame(args, tb[NL80211_ATTR_FRAME]);
                printf("\n");
                break;
        default:
diff --git a/iw.h b/iw.h
index 68f0e5a9a2a6fd2b6115fac92ea16df61ba31a1a..0736f9c270119478fa3389d359fa9021de845c9b 100644 (file)
--- a/iw.h
+++ b/iw.h
@@ -88,5 +88,6 @@ int nl_get_multicast_id(struct nl_sock *sock, const char *family, const char *gr
 char *reg_initiator_to_string(__u8 initiator);
 
 const char *get_reason_str(uint16_t reason);
+const char *get_status_str(uint16_t status);
 
 #endif /* __IW_H */
diff --git a/status.c b/status.c
new file mode 100644 (file)
index 0000000..731727d
--- /dev/null
+++ b/status.c
@@ -0,0 +1,59 @@
+#include <stdint.h>
+#include "iw.h"
+
+static const char *status_table[] = {
+       [0] = "Successful",
+       [1] = "Unspecified failure",
+       [10] = "Cannot support all requested capabilities in the capability information field",
+       [11] = "Reassociation denied due to inability to confirm that association exists",
+       [12] = "Association denied due to reason outside the scope of this standard",
+       [13] = "Responding station does not support the specified authentication algorithm",
+       [14] = "Received an authentication frame with authentication transaction sequence number out of expected sequence",
+       [15] = "Authentication rejected because of challenge failure",
+       [16] = "Authentication rejected due to timeout waiting for next frame in sequence",
+       [17] = "Association denied because AP is unable to handle additional associated STA",
+       [18] = "Association denied due to requesting station not supporting all of the data rates in the BSSBasicRateSet parameter",
+       [19] = "Association denied due to requesting station not supporting the short preamble option",
+       [20] = "Association denied due to requesting station not supporting the PBCC modulation option",
+       [21] = "Association denied due to requesting station not supporting the channel agility option",
+       [22] = "Association request rejected because Spectrum Management capability is required",
+       [23] = "Association request rejected because the information in the Power Capability element is unacceptable",
+       [24] = "Association request rejected because the information in the Supported Channels element is unacceptable",
+       [25] = "Association request rejected due to requesting station not supporting the short slot time option",
+       [26] = "Association request rejected due to requesting station not supporting the ER-PBCC modulation option",
+       [27] = "Association denied due to requesting STA not supporting HT features",
+       [28] = "R0KH Unreachable",
+       [29] = "Association denied because the requesting STA does not support the PCO transition required by the AP",
+       [30] = "Association request rejected temporarily; try again later",
+       [31] = "Robust Management frame policy violation",
+       [32] = "Unspecified, QoS related failure",
+       [33] = "Association denied due to QAP having insufficient bandwidth to handle another QSTA",
+       [34] = "Association denied due to poor channel conditions",
+       [35] = "Association (with QBSS) denied due to requesting station not supporting the QoS facility",
+       [37] = "The request has been declined",
+       [38] = "The request has not been successful as one or more parameters have invalid values",
+       [39] = "The TS has not been created because the request cannot be honored. However, a suggested Tspec is provided so that the initiating QSTA may attempt to send another TS with the suggested changes to the TSpec",
+       [40] = "Invalid Information Element",
+       [41] = "Group Cipher is not valid",
+       [42] = "Pairwise Cipher is not valid",
+       [43] = "AKMP is not valid",
+       [44] = "Unsupported RSN IE version",
+       [45] = "Invalid RSN IE Capabilities",
+       [46] = "Cipher suite is rejected per security policy",
+       [47] = "The TS has not been created. However, the HC may be capable of creating a TS, in response to a request, after the time indicated in the TS Delay element",
+       [48] = "Direct link is not allowed in the BSS by policy",
+       [49] = "Destination STA is not present within this QBSS",
+       [50] = "The destination STA is not a QSTA",
+       [51] = "Association denied because Listen Interval is too large",
+       [52] = "Invalid Fast BSS Transition Action Frame Count",
+       [53] = "Invalid PMKID",
+       [54] = "Invalid MDIE",
+       [55] = "Invalid FTIE",
+};
+
+const char *get_status_str(uint16_t status)
+{
+       if (status < ARRAY_SIZE(status_table) && status_table[status])
+               return status_table[status];
+       return "<unknown>";
+}