iw: update to 3.10, sync with nl80211.h changes in compat-wireless
[openwrt/svn-archive/archive.git] / package / network / utils / iw / patches / 110-per_chain_signal_strength.patch
1 --- a/station.c
2 +++ b/station.c
3 @@ -91,6 +91,33 @@ void parse_bitrate(struct nlattr *bitrat
4 " VHT-NSS %d", nla_get_u8(rinfo[NL80211_RATE_INFO_VHT_NSS]));
5 }
6
7 +static char *get_chain_signal(struct nlattr *attr_list)
8 +{
9 + struct nlattr *attr;
10 + static char buf[64];
11 + char *cur = buf;
12 + int i = 0, rem;
13 + const char *prefix;
14 +
15 + if (!attr_list)
16 + return "";
17 +
18 + nla_for_each_nested(attr, attr_list, rem) {
19 + if (i++ > 0)
20 + prefix = ", ";
21 + else
22 + prefix = "[";
23 +
24 + cur += snprintf(cur, sizeof(buf) - (cur - buf), "%s%d", prefix,
25 + (int8_t) nla_get_u8(attr));
26 + }
27 +
28 + if (i)
29 + snprintf(cur, sizeof(buf) - (cur - buf), "] ");
30 +
31 + return buf;
32 +}
33 +
34 static int print_sta_handler(struct nl_msg *msg, void *arg)
35 {
36 struct nlattr *tb[NL80211_ATTR_MAX + 1];
37 @@ -118,7 +145,10 @@ static int print_sta_handler(struct nl_m
38 [NL80211_STA_INFO_LOCAL_PM] = { .type = NLA_U32},
39 [NL80211_STA_INFO_PEER_PM] = { .type = NLA_U32},
40 [NL80211_STA_INFO_NONPEER_PM] = { .type = NLA_U32},
41 + [NL80211_STA_INFO_CHAIN_SIGNAL] = { .type = NLA_NESTED },
42 + [NL80211_STA_INFO_CHAIN_SIGNAL_AVG] = { .type = NLA_NESTED },
43 };
44 + char *chain;
45
46 nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
47 genlmsg_attrlen(gnlh, 0), NULL);
48 @@ -165,12 +195,19 @@ static int print_sta_handler(struct nl_m
49 if (sinfo[NL80211_STA_INFO_TX_FAILED])
50 printf("\n\ttx failed:\t%u",
51 nla_get_u32(sinfo[NL80211_STA_INFO_TX_FAILED]));
52 +
53 + chain = get_chain_signal(sinfo[NL80211_STA_INFO_CHAIN_SIGNAL]);
54 if (sinfo[NL80211_STA_INFO_SIGNAL])
55 - printf("\n\tsignal: \t%d dBm",
56 - (int8_t)nla_get_u8(sinfo[NL80211_STA_INFO_SIGNAL]));
57 + printf("\n\tsignal: \t%d %sdBm",
58 + (int8_t)nla_get_u8(sinfo[NL80211_STA_INFO_SIGNAL]),
59 + chain);
60 +
61 + chain = get_chain_signal(sinfo[NL80211_STA_INFO_CHAIN_SIGNAL_AVG]);
62 if (sinfo[NL80211_STA_INFO_SIGNAL_AVG])
63 - printf("\n\tsignal avg:\t%d dBm",
64 - (int8_t)nla_get_u8(sinfo[NL80211_STA_INFO_SIGNAL_AVG]));
65 + printf("\n\tsignal avg:\t%d %sdBm",
66 + (int8_t)nla_get_u8(sinfo[NL80211_STA_INFO_SIGNAL_AVG]),
67 + chain);
68 +
69 if (sinfo[NL80211_STA_INFO_T_OFFSET])
70 printf("\n\tToffset:\t%lld us",
71 (unsigned long long)nla_get_u64(sinfo[NL80211_STA_INFO_T_OFFSET]));