]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
connect events
authorJohannes Berg <johannes@sipsolutions.net>
Thu, 2 Jul 2009 07:54:02 +0000 (09:54 +0200)
committerJohannes Berg <johannes@sipsolutions.net>
Thu, 2 Jul 2009 07:54:02 +0000 (09:54 +0200)
event.c

diff --git a/event.c b/event.c
index fe202eb8954cbedfb54bbf008263eb452a63950f..c0475420d921fabf1ef49cdb7a42f08160e86fd2 100644 (file)
--- a/event.c
+++ b/event.c
@@ -81,6 +81,7 @@ static int print_event(struct nl_msg *msg, void *arg)
        char macbuf[6*3];
        __u8 reg_type;
        int rem_nst;
+       __u16 status;
 
        if (args->time) {
                struct timeval tv;
@@ -196,6 +197,43 @@ static int print_event(struct nl_msg *msg, void *arg)
                print_frame(args, tb[NL80211_ATTR_FRAME]);
                printf("\n");
                break;
+       case NL80211_CMD_CONNECT:
+               status = 0;
+               if (!tb[NL80211_ATTR_STATUS_CODE])
+                       printf("unknown connect status");
+               else if (nla_get_u16(tb[NL80211_ATTR_STATUS_CODE]) == 0)
+                       printf("connected");
+               else {
+                       status = nla_get_u16(tb[NL80211_ATTR_STATUS_CODE]);
+                       printf("failed to connect");
+               }
+               if (tb[NL80211_ATTR_MAC]) {
+                       mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC]));
+                       printf(" to %s", macbuf);
+               }
+               if (status)
+                       printf(", status: %d: %s", status, get_status_str(status));
+               printf("\n");
+               break;
+       case NL80211_CMD_ROAM:
+               printf("roamed");
+               if (tb[NL80211_ATTR_MAC]) {
+                       mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC]));
+                       printf(" to %s", macbuf);
+               }
+               printf("\n");
+               break;
+       case NL80211_CMD_DISCONNECT:
+               printf("disconnected");
+               if (tb[NL80211_ATTR_DISCONNECTED_BY_AP])
+                       printf(" (by AP)");
+               else
+                       printf(" (local request)");
+               if (tb[NL80211_ATTR_REASON_CODE])
+                       printf(" reason: %d: %s", nla_get_u16(tb[NL80211_ATTR_REASON_CODE]),
+                               get_reason_str(nla_get_u16(tb[NL80211_ATTR_REASON_CODE])));
+               printf("\n");
+               break;
        default:
                printf("unknown event %d\n", gnlh->cmd);
                break;