]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
make event printing more regular
authorJohannes Berg <johannes@sipsolutions.net>
Tue, 5 May 2009 09:50:43 +0000 (11:50 +0200)
committerJohannes Berg <johannes@sipsolutions.net>
Tue, 5 May 2009 09:50:43 +0000 (11:50 +0200)
iw.c

diff --git a/iw.c b/iw.c
index 56c5694e81bb0457834525410f154c578362720e..df69049f3f2f1600a692fa9b59d29ea5b5857f64 100644 (file)
--- a/iw.c
+++ b/iw.c
@@ -338,25 +338,28 @@ static int print_event(struct nl_msg *msg, void *arg)
 
        nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
                  genlmsg_attrlen(gnlh, 0), NULL);
-                          
+
+       if (tb[NL80211_ATTR_IFINDEX] && tb[NL80211_ATTR_WIPHY]) {
+               if_indextoname(nla_get_u32(tb[NL80211_ATTR_IFINDEX]), ifname);
+               printf("%s (phy #%d): ", ifname, nla_get_u32(tb[NL80211_ATTR_WIPHY]));
+       } else if (tb[NL80211_ATTR_IFINDEX]) {
+               if_indextoname(nla_get_u32(tb[NL80211_ATTR_IFINDEX]), ifname);
+               printf("%s: ", ifname);
+       } else if (tb[NL80211_ATTR_WIPHY]) {
+               printf("phy #%d: ", nla_get_u32(tb[NL80211_ATTR_WIPHY]));
+       }
+
        switch (gnlh->cmd) {
        case NL80211_CMD_NEW_WIPHY:
-               printf("wiphy rename: phy #%d to %s\n",
-                      nla_get_u32(tb[NL80211_ATTR_WIPHY]),
-                      nla_get_string(tb[NL80211_ATTR_WIPHY_NAME]));
+               printf("renamed to %s\n", nla_get_string(tb[NL80211_ATTR_WIPHY_NAME]));
                break;
        case NL80211_CMD_NEW_SCAN_RESULTS:
-               if_indextoname(nla_get_u32(tb[NL80211_ATTR_IFINDEX]), ifname);
-               printf("scan finished on %s (phy #%d)\n",
-                      ifname, nla_get_u32(tb[NL80211_ATTR_WIPHY]));
+               printf("scan finished\n");
                break;
        case NL80211_CMD_SCAN_ABORTED:
-               if_indextoname(nla_get_u32(tb[NL80211_ATTR_IFINDEX]), ifname);
-               printf("scan aborted on %s (phy #%d)\n",
-                      ifname, nla_get_u32(tb[NL80211_ATTR_WIPHY]));
+               printf("scan aborted\n");
                break;
        case NL80211_CMD_REG_CHANGE:
-
                printf("regulatory domain change: ");
 
                reg_type = nla_get_u8(tb[NL80211_ATTR_REG_TYPE]);
@@ -392,13 +395,23 @@ static int print_event(struct nl_msg *msg, void *arg)
                printf("\n");
                break;
        case NL80211_CMD_JOIN_IBSS:
-               if_indextoname(nla_get_u32(tb[NL80211_ATTR_IFINDEX]), ifname);
                mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC]));
-               printf("IBSS %s joined on %s (phy #%d)\n",
-                      macbuf, ifname, nla_get_u32(tb[NL80211_ATTR_WIPHY]));
+               printf("IBSS %s joined\n", macbuf);
+               break;
+       case NL80211_CMD_AUTHENTICATE:
+               printf("auth\n");
+               break;
+       case NL80211_CMD_ASSOCIATE:
+               printf("assoc\n");
+               break;
+       case NL80211_CMD_DEAUTHENTICATE:
+               printf("deauth\n");
+               break;
+       case NL80211_CMD_DISASSOCIATE:
+               printf("disassoc\n");
                break;
        default:
-               printf("unknown event: %d\n", gnlh->cmd);
+               printf("unknown event %d\n", gnlh->cmd);
                break;
        }