]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
Add station BSS params to iw output
authorPaul Stewart <pstew@google.com>
Thu, 28 Apr 2011 16:38:41 +0000 (18:38 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 28 Apr 2011 16:38:41 +0000 (18:38 +0200)
Signed-off-by: Paul Stewart <pstew@google.com>
link.c

diff --git a/link.c b/link.c
index 297073da15f05cdf3a72962e47f483aa10deb3df..11ee0aa14be474b32cd178350eaf62c96a1b1a90 100644 (file)
--- a/link.c
+++ b/link.c
@@ -115,6 +115,7 @@ static int print_link_sta(struct nl_msg *msg, void *arg)
        struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
        struct nlattr *sinfo[NL80211_STA_INFO_MAX + 1];
        struct nlattr *rinfo[NL80211_RATE_INFO_MAX + 1];
+       struct nlattr *binfo[NL80211_STA_BSS_PARAM_MAX + 1];
        static struct nla_policy stats_policy[NL80211_STA_INFO_MAX + 1] = {
                [NL80211_STA_INFO_INACTIVE_TIME] = { .type = NLA_U32 },
                [NL80211_STA_INFO_RX_BYTES] = { .type = NLA_U32 },
@@ -134,6 +135,13 @@ static int print_link_sta(struct nl_msg *msg, void *arg)
                [NL80211_RATE_INFO_40_MHZ_WIDTH] = { .type = NLA_FLAG },
                [NL80211_RATE_INFO_SHORT_GI] = { .type = NLA_FLAG },
        };
+       static struct nla_policy bss_policy[NL80211_STA_BSS_PARAM_MAX + 1] = {
+               [NL80211_STA_BSS_PARAM_CTS_PROT] = { .type = NLA_FLAG },
+               [NL80211_STA_BSS_PARAM_SHORT_PREAMBLE] = { .type = NLA_FLAG },
+               [NL80211_STA_BSS_PARAM_SHORT_SLOT_TIME] = { .type = NLA_FLAG },
+               [NL80211_STA_BSS_PARAM_DTIM_PERIOD] = { .type = NLA_U8 },
+               [NL80211_STA_BSS_PARAM_BEACON_INTERVAL] = { .type = NLA_U16 },
+       };
 
        nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
                  genlmsg_attrlen(gnlh, 0), NULL);
@@ -182,6 +190,32 @@ static int print_link_sta(struct nl_msg *msg, void *arg)
                }
        }
 
+       if (sinfo[NL80211_STA_INFO_BSS_PARAM]) {
+               if (nla_parse_nested(binfo, NL80211_STA_BSS_PARAM_MAX,
+                                    sinfo[NL80211_STA_INFO_BSS_PARAM],
+                                    bss_policy)) {
+                       fprintf(stderr, "failed to parse nested bss parameters!\n");
+               } else {
+                       char *delim = "";
+                       printf("\n\tbss flags:\t");
+                       if (binfo[NL80211_STA_BSS_PARAM_CTS_PROT]) {
+                               printf("CTS-protection");
+                               delim = " ";
+                       }
+                       if (binfo[NL80211_STA_BSS_PARAM_SHORT_PREAMBLE]) {
+                               printf("%sshort-preamble", delim);
+                               delim = " ";
+                       }
+                       if (binfo[NL80211_STA_BSS_PARAM_SHORT_SLOT_TIME])
+                               printf("%sshort-slot-time", delim);
+                       printf("\n\tdtim period:\t%d",
+                              nla_get_u8(binfo[NL80211_STA_BSS_PARAM_DTIM_PERIOD]));
+                       printf("\n\tbeacon int:\t%d",
+                              nla_get_u16(binfo[NL80211_STA_BSS_PARAM_BEACON_INTERVAL]));
+                       printf("\n");
+               }
+       }
+
        return NL_SKIP;
 }