]> git.ipfire.org Git - thirdparty/iw.git/blobdiff - link.c
iw: support setting vif MAC during creation
[thirdparty/iw.git] / link.c
diff --git a/link.c b/link.c
index 3470c4da2b53be38ff971d517ac0c8bfe89abb37..f7818f5fc296098f67e020988453e2fc8d5f1e9d 100644 (file)
--- a/link.c
+++ b/link.c
@@ -115,7 +115,6 @@ static int print_link_sta(struct nl_msg *msg, void *arg)
        struct nlattr *tb[NL80211_ATTR_MAX + 1];
        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 },
@@ -129,14 +128,6 @@ static int print_link_sta(struct nl_msg *msg, void *arg)
                [NL80211_STA_INFO_PLID] = { .type = NLA_U16 },
                [NL80211_STA_INFO_PLINK_STATE] = { .type = NLA_U8 },
        };
-
-       static struct nla_policy rate_policy[NL80211_RATE_INFO_MAX + 1] = {
-               [NL80211_RATE_INFO_BITRATE] = { .type = NLA_U16 },
-               [NL80211_RATE_INFO_BITRATE32] = { .type = NLA_U32 },
-               [NL80211_RATE_INFO_MCS] = { .type = NLA_U8 },
-               [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 },
@@ -172,27 +163,10 @@ static int print_link_sta(struct nl_msg *msg, void *arg)
                        (int8_t)nla_get_u8(sinfo[NL80211_STA_INFO_SIGNAL]));
 
        if (sinfo[NL80211_STA_INFO_TX_BITRATE]) {
-               if (nla_parse_nested(rinfo, NL80211_RATE_INFO_MAX,
-                                    sinfo[NL80211_STA_INFO_TX_BITRATE], rate_policy)) {
-                       fprintf(stderr, "failed to parse nested rate attributes!\n");
-               } else {
-                       int rate = 0;
-                       printf("\ttx bitrate: ");
-                       if (rinfo[NL80211_RATE_INFO_BITRATE32])
-                               rate = nla_get_u32(rinfo[NL80211_RATE_INFO_BITRATE32]);
-                       else if (rinfo[NL80211_RATE_INFO_BITRATE])
-                               rate = nla_get_u16(rinfo[NL80211_RATE_INFO_BITRATE]);
-                       if (rate > 0)
-                               printf("%d.%d MBit/s", rate / 10, rate % 10);
-
-                       if (rinfo[NL80211_RATE_INFO_MCS])
-                               printf(" MCS %d", nla_get_u8(rinfo[NL80211_RATE_INFO_MCS]));
-                       if (rinfo[NL80211_RATE_INFO_40_MHZ_WIDTH])
-                               printf(" 40Mhz");
-                       if (rinfo[NL80211_RATE_INFO_SHORT_GI])
-                               printf(" short GI");
-                       printf("\n");
-               }
+               char buf[100];
+
+               parse_bitrate(sinfo[NL80211_STA_INFO_TX_BITRATE], buf, sizeof(buf));
+               printf("\ttx bitrate: %s\n", buf);
        }
 
        if (sinfo[NL80211_STA_INFO_BSS_PARAM]) {