Luis R. Rodriguez | 21878f3 | 2009-02-02 15:39:06 -0800 | [diff] [blame] | 1 | #include <stdbool.h> |
Johannes Berg | 79f99b9 | 2008-01-16 00:21:59 +0100 | [diff] [blame] | 2 | #include <errno.h> |
Johannes Berg | 2ef1be6 | 2008-04-02 17:40:11 +0200 | [diff] [blame] | 3 | #include <net/if.h> |
| 4 | |
Johannes Berg | 79f99b9 | 2008-01-16 00:21:59 +0100 | [diff] [blame] | 5 | #include <netlink/genl/genl.h> |
| 6 | #include <netlink/genl/family.h> |
| 7 | #include <netlink/genl/ctrl.h> |
| 8 | #include <netlink/msg.h> |
| 9 | #include <netlink/attr.h> |
Johannes Berg | 79f99b9 | 2008-01-16 00:21:59 +0100 | [diff] [blame] | 10 | |
Johannes Berg | f408e01 | 2008-09-18 19:32:11 +0200 | [diff] [blame] | 11 | #include "nl80211.h" |
Johannes Berg | 79f99b9 | 2008-01-16 00:21:59 +0100 | [diff] [blame] | 12 | #include "iw.h" |
| 13 | |
| 14 | static void print_flag(const char *name, int *open) |
| 15 | { |
| 16 | if (!*open) |
| 17 | printf(" ("); |
| 18 | else |
| 19 | printf(", "); |
Johannes Berg | 6928312 | 2008-11-23 20:55:23 +0100 | [diff] [blame] | 20 | printf("%s", name); |
Johannes Berg | 79f99b9 | 2008-01-16 00:21:59 +0100 | [diff] [blame] | 21 | *open = 1; |
| 22 | } |
| 23 | |
Johannes Berg | 810e05c | 2011-10-05 17:38:39 +0200 | [diff] [blame] | 24 | static char *cipher_name(__u32 c) |
| 25 | { |
| 26 | static char buf[20]; |
| 27 | |
| 28 | switch (c) { |
| 29 | case 0x000fac01: |
| 30 | return "WEP40 (00-0f-ac:1)"; |
| 31 | case 0x000fac05: |
| 32 | return "WEP104 (00-0f-ac:5)"; |
| 33 | case 0x000fac02: |
| 34 | return "TKIP (00-0f-ac:2)"; |
| 35 | case 0x000fac04: |
| 36 | return "CCMP (00-0f-ac:4)"; |
| 37 | case 0x000fac06: |
| 38 | return "CMAC (00-0f-ac:6)"; |
Vladimir Kondratiev | a8b3da9 | 2012-07-05 14:36:20 +0300 | [diff] [blame] | 39 | case 0x000fac08: |
| 40 | return "GCMP (00-0f-ac:8)"; |
Johannes Berg | 810e05c | 2011-10-05 17:38:39 +0200 | [diff] [blame] | 41 | case 0x00147201: |
| 42 | return "WPI-SMS4 (00-14-72:1)"; |
| 43 | default: |
| 44 | sprintf(buf, "%.2x-%.2x-%.2x:%d", |
| 45 | c >> 24, (c >> 16) & 0xff, |
| 46 | (c >> 8) & 0xff, c & 0xff); |
| 47 | |
| 48 | return buf; |
| 49 | } |
| 50 | } |
| 51 | |
Simon Wunderlich | 48aaf2d | 2013-02-08 18:16:22 +0100 | [diff] [blame] | 52 | static char *dfs_state_name(enum nl80211_dfs_state state) |
| 53 | { |
| 54 | switch (state) { |
| 55 | case NL80211_DFS_USABLE: |
| 56 | return "usable"; |
| 57 | case NL80211_DFS_AVAILABLE: |
| 58 | return "available"; |
| 59 | case NL80211_DFS_UNAVAILABLE: |
| 60 | return "unavailable"; |
| 61 | default: |
| 62 | return "unknown"; |
| 63 | } |
| 64 | } |
| 65 | |
Janusz.Dziedzic@tieto.com | f0e30bd | 2015-03-30 12:56:31 +0200 | [diff] [blame] | 66 | static int ext_feature_isset(const unsigned char *ext_features, int ext_features_len, |
| 67 | enum nl80211_ext_feature_index ftidx) |
| 68 | { |
| 69 | unsigned char ft_byte; |
| 70 | |
| 71 | if ((int) ftidx / 8 >= ext_features_len) |
| 72 | return 0; |
| 73 | |
| 74 | ft_byte = ext_features[ftidx / 8]; |
| 75 | return (ft_byte & BIT(ftidx % 8)) != 0; |
| 76 | } |
| 77 | |
Johannes Berg | 79f99b9 | 2008-01-16 00:21:59 +0100 | [diff] [blame] | 78 | static int print_phy_handler(struct nl_msg *msg, void *arg) |
| 79 | { |
| 80 | struct nlattr *tb_msg[NL80211_ATTR_MAX + 1]; |
| 81 | struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); |
| 82 | |
| 83 | struct nlattr *tb_band[NL80211_BAND_ATTR_MAX + 1]; |
| 84 | |
| 85 | struct nlattr *tb_freq[NL80211_FREQUENCY_ATTR_MAX + 1]; |
| 86 | static struct nla_policy freq_policy[NL80211_FREQUENCY_ATTR_MAX + 1] = { |
| 87 | [NL80211_FREQUENCY_ATTR_FREQ] = { .type = NLA_U32 }, |
| 88 | [NL80211_FREQUENCY_ATTR_DISABLED] = { .type = NLA_FLAG }, |
Ilan Peer | f0c48e7 | 2013-11-14 09:15:34 +0200 | [diff] [blame] | 89 | [NL80211_FREQUENCY_ATTR_NO_IR] = { .type = NLA_FLAG }, |
| 90 | [__NL80211_FREQUENCY_ATTR_NO_IBSS] = { .type = NLA_FLAG }, |
Johannes Berg | 79f99b9 | 2008-01-16 00:21:59 +0100 | [diff] [blame] | 91 | [NL80211_FREQUENCY_ATTR_RADAR] = { .type = NLA_FLAG }, |
Johannes Berg | c1081c2 | 2008-11-23 12:11:26 +0100 | [diff] [blame] | 92 | [NL80211_FREQUENCY_ATTR_MAX_TX_POWER] = { .type = NLA_U32 }, |
Johannes Berg | 79f99b9 | 2008-01-16 00:21:59 +0100 | [diff] [blame] | 93 | }; |
| 94 | |
| 95 | struct nlattr *tb_rate[NL80211_BITRATE_ATTR_MAX + 1]; |
| 96 | static struct nla_policy rate_policy[NL80211_BITRATE_ATTR_MAX + 1] = { |
| 97 | [NL80211_BITRATE_ATTR_RATE] = { .type = NLA_U32 }, |
| 98 | [NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE] = { .type = NLA_FLAG }, |
| 99 | }; |
| 100 | |
| 101 | struct nlattr *nl_band; |
| 102 | struct nlattr *nl_freq; |
| 103 | struct nlattr *nl_rate; |
Johannes Berg | 6367e71 | 2008-09-05 23:01:11 +0200 | [diff] [blame] | 104 | struct nlattr *nl_mode; |
Marcel Holtmann | 9990c1e | 2009-11-14 20:10:21 +0100 | [diff] [blame] | 105 | struct nlattr *nl_cmd; |
Johannes Berg | 9a4a14b | 2010-08-24 12:26:56 +0200 | [diff] [blame] | 106 | struct nlattr *nl_if, *nl_ftype; |
Johannes Berg | 9a4a14b | 2010-08-24 12:26:56 +0200 | [diff] [blame] | 107 | int rem_band, rem_freq, rem_rate, rem_mode, rem_cmd, rem_ftype, rem_if; |
Johannes Berg | 79f99b9 | 2008-01-16 00:21:59 +0100 | [diff] [blame] | 108 | int open; |
Johannes Berg | fb70e11 | 2013-02-14 16:32:53 +0100 | [diff] [blame] | 109 | /* |
| 110 | * static variables only work here, other applications need to use the |
| 111 | * callback pointer and store them there so they can be multithreaded |
| 112 | * and/or have multiple netlink sockets, etc. |
| 113 | */ |
| 114 | static int64_t phy_id = -1; |
| 115 | static int last_band = -1; |
| 116 | static bool band_had_freq = false; |
| 117 | bool print_name = true; |
Johannes Berg | 79f99b9 | 2008-01-16 00:21:59 +0100 | [diff] [blame] | 118 | |
| 119 | nla_parse(tb_msg, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), |
| 120 | genlmsg_attrlen(gnlh, 0), NULL); |
| 121 | |
Johannes Berg | fb70e11 | 2013-02-14 16:32:53 +0100 | [diff] [blame] | 122 | if (tb_msg[NL80211_ATTR_WIPHY]) { |
| 123 | if (nla_get_u32(tb_msg[NL80211_ATTR_WIPHY]) == phy_id) |
| 124 | print_name = false; |
| 125 | else |
| 126 | last_band = -1; |
| 127 | phy_id = nla_get_u32(tb_msg[NL80211_ATTR_WIPHY]); |
| 128 | } |
| 129 | if (print_name && tb_msg[NL80211_ATTR_WIPHY_NAME]) |
Johannes Berg | d631650 | 2008-09-16 17:05:33 +0200 | [diff] [blame] | 130 | printf("Wiphy %s\n", nla_get_string(tb_msg[NL80211_ATTR_WIPHY_NAME])); |
| 131 | |
Johannes Berg | fb70e11 | 2013-02-14 16:32:53 +0100 | [diff] [blame] | 132 | /* needed for split dump */ |
| 133 | if (tb_msg[NL80211_ATTR_WIPHY_BANDS]) { |
| 134 | nla_for_each_nested(nl_band, tb_msg[NL80211_ATTR_WIPHY_BANDS], rem_band) { |
| 135 | if (last_band != nl_band->nla_type) { |
| 136 | printf("\tBand %d:\n", nl_band->nla_type + 1); |
| 137 | band_had_freq = false; |
Johannes Berg | ee9cd98 | 2009-01-18 18:13:54 +0100 | [diff] [blame] | 138 | } |
Johannes Berg | fb70e11 | 2013-02-14 16:32:53 +0100 | [diff] [blame] | 139 | last_band = nl_band->nla_type; |
Simon Wunderlich | 48aaf2d | 2013-02-08 18:16:22 +0100 | [diff] [blame] | 140 | |
Johannes Berg | fb70e11 | 2013-02-14 16:32:53 +0100 | [diff] [blame] | 141 | nla_parse(tb_band, NL80211_BAND_ATTR_MAX, nla_data(nl_band), |
| 142 | nla_len(nl_band), NULL); |
Simon Wunderlich | 48aaf2d | 2013-02-08 18:16:22 +0100 | [diff] [blame] | 143 | |
Johannes Berg | fb70e11 | 2013-02-14 16:32:53 +0100 | [diff] [blame] | 144 | if (tb_band[NL80211_BAND_ATTR_HT_CAPA]) { |
| 145 | __u16 cap = nla_get_u16(tb_band[NL80211_BAND_ATTR_HT_CAPA]); |
| 146 | print_ht_capability(cap); |
| 147 | } |
| 148 | if (tb_band[NL80211_BAND_ATTR_HT_AMPDU_FACTOR]) { |
| 149 | __u8 exponent = nla_get_u8(tb_band[NL80211_BAND_ATTR_HT_AMPDU_FACTOR]); |
| 150 | print_ampdu_length(exponent); |
| 151 | } |
| 152 | if (tb_band[NL80211_BAND_ATTR_HT_AMPDU_DENSITY]) { |
| 153 | __u8 spacing = nla_get_u8(tb_band[NL80211_BAND_ATTR_HT_AMPDU_DENSITY]); |
| 154 | print_ampdu_spacing(spacing); |
| 155 | } |
| 156 | if (tb_band[NL80211_BAND_ATTR_HT_MCS_SET] && |
| 157 | nla_len(tb_band[NL80211_BAND_ATTR_HT_MCS_SET]) == 16) |
| 158 | print_ht_mcs(nla_data(tb_band[NL80211_BAND_ATTR_HT_MCS_SET])); |
| 159 | if (tb_band[NL80211_BAND_ATTR_VHT_CAPA] && |
| 160 | tb_band[NL80211_BAND_ATTR_VHT_MCS_SET]) |
| 161 | print_vht_info(nla_get_u32(tb_band[NL80211_BAND_ATTR_VHT_CAPA]), |
| 162 | nla_data(tb_band[NL80211_BAND_ATTR_VHT_MCS_SET])); |
| 163 | |
| 164 | if (tb_band[NL80211_BAND_ATTR_FREQS]) { |
| 165 | if (!band_had_freq) { |
| 166 | printf("\t\tFrequencies:\n"); |
| 167 | band_had_freq = true; |
Simon Wunderlich | 48aaf2d | 2013-02-08 18:16:22 +0100 | [diff] [blame] | 168 | } |
Johannes Berg | fb70e11 | 2013-02-14 16:32:53 +0100 | [diff] [blame] | 169 | nla_for_each_nested(nl_freq, tb_band[NL80211_BAND_ATTR_FREQS], rem_freq) { |
| 170 | uint32_t freq; |
| 171 | nla_parse(tb_freq, NL80211_FREQUENCY_ATTR_MAX, nla_data(nl_freq), |
| 172 | nla_len(nl_freq), freq_policy); |
| 173 | if (!tb_freq[NL80211_FREQUENCY_ATTR_FREQ]) |
| 174 | continue; |
| 175 | freq = nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_FREQ]); |
| 176 | printf("\t\t\t* %d MHz [%d]", freq, ieee80211_frequency_to_channel(freq)); |
| 177 | |
| 178 | if (tb_freq[NL80211_FREQUENCY_ATTR_MAX_TX_POWER] && |
| 179 | !tb_freq[NL80211_FREQUENCY_ATTR_DISABLED]) |
| 180 | printf(" (%.1f dBm)", 0.01 * nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_MAX_TX_POWER])); |
| 181 | |
| 182 | open = 0; |
| 183 | if (tb_freq[NL80211_FREQUENCY_ATTR_DISABLED]) { |
| 184 | print_flag("disabled", &open); |
| 185 | goto next; |
| 186 | } |
Ilan Peer | f0c48e7 | 2013-11-14 09:15:34 +0200 | [diff] [blame] | 187 | |
| 188 | /* If both flags are set assume an new kernel */ |
| 189 | if (tb_freq[NL80211_FREQUENCY_ATTR_NO_IR] && tb_freq[__NL80211_FREQUENCY_ATTR_NO_IBSS]) { |
| 190 | print_flag("no IR", &open); |
| 191 | } else if (tb_freq[NL80211_FREQUENCY_ATTR_PASSIVE_SCAN]) { |
| 192 | print_flag("passive scan", &open); |
| 193 | } else if (tb_freq[__NL80211_FREQUENCY_ATTR_NO_IBSS]){ |
| 194 | print_flag("no ibss", &open); |
| 195 | } |
| 196 | |
Johannes Berg | fb70e11 | 2013-02-14 16:32:53 +0100 | [diff] [blame] | 197 | if (tb_freq[NL80211_FREQUENCY_ATTR_RADAR]) |
| 198 | print_flag("radar detection", &open); |
| 199 | next: |
| 200 | if (open) |
| 201 | printf(")"); |
| 202 | printf("\n"); |
| 203 | |
Zefir Kurtisi | 4b99e6a | 2013-03-26 12:09:49 +0100 | [diff] [blame] | 204 | if (!tb_freq[NL80211_FREQUENCY_ATTR_DISABLED] && tb_freq[NL80211_FREQUENCY_ATTR_DFS_STATE]) { |
| 205 | enum nl80211_dfs_state state = nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_DFS_STATE]); |
| 206 | unsigned long time; |
Johannes Berg | fb70e11 | 2013-02-14 16:32:53 +0100 | [diff] [blame] | 207 | |
Zefir Kurtisi | 4b99e6a | 2013-03-26 12:09:49 +0100 | [diff] [blame] | 208 | printf("\t\t\t DFS state: %s", dfs_state_name(state)); |
| 209 | if (tb_freq[NL80211_FREQUENCY_ATTR_DFS_TIME]) { |
| 210 | time = nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_DFS_TIME]); |
| 211 | printf(" (for %lu sec)", time/1000); |
| 212 | } |
| 213 | printf("\n"); |
Janusz Dziedzic | 8220747 | 2014-05-09 10:19:55 +0200 | [diff] [blame] | 214 | if (tb_freq[NL80211_FREQUENCY_ATTR_DFS_CAC_TIME]) |
| 215 | printf("\t\t\t DFS CAC time: %u ms\n", |
| 216 | nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_DFS_CAC_TIME])); |
Johannes Berg | fb70e11 | 2013-02-14 16:32:53 +0100 | [diff] [blame] | 217 | } |
Zefir Kurtisi | 4b99e6a | 2013-03-26 12:09:49 +0100 | [diff] [blame] | 218 | |
Johannes Berg | fb70e11 | 2013-02-14 16:32:53 +0100 | [diff] [blame] | 219 | } |
| 220 | } |
| 221 | |
| 222 | if (tb_band[NL80211_BAND_ATTR_RATES]) { |
| 223 | printf("\t\tBitrates (non-HT):\n"); |
| 224 | nla_for_each_nested(nl_rate, tb_band[NL80211_BAND_ATTR_RATES], rem_rate) { |
| 225 | nla_parse(tb_rate, NL80211_BITRATE_ATTR_MAX, nla_data(nl_rate), |
| 226 | nla_len(nl_rate), rate_policy); |
| 227 | if (!tb_rate[NL80211_BITRATE_ATTR_RATE]) |
| 228 | continue; |
| 229 | printf("\t\t\t* %2.1f Mbps", 0.1 * nla_get_u32(tb_rate[NL80211_BITRATE_ATTR_RATE])); |
| 230 | open = 0; |
| 231 | if (tb_rate[NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE]) |
| 232 | print_flag("short preamble supported", &open); |
| 233 | if (open) |
| 234 | printf(")"); |
Simon Wunderlich | 48aaf2d | 2013-02-08 18:16:22 +0100 | [diff] [blame] | 235 | printf("\n"); |
| 236 | } |
Johannes Berg | fb70e11 | 2013-02-14 16:32:53 +0100 | [diff] [blame] | 237 | } |
Johannes Berg | 79f99b9 | 2008-01-16 00:21:59 +0100 | [diff] [blame] | 238 | } |
| 239 | } |
| 240 | |
Johannes Berg | 41be37f | 2008-09-19 17:34:55 +0200 | [diff] [blame] | 241 | if (tb_msg[NL80211_ATTR_MAX_NUM_SCAN_SSIDS]) |
| 242 | printf("\tmax # scan SSIDs: %d\n", |
| 243 | nla_get_u8(tb_msg[NL80211_ATTR_MAX_NUM_SCAN_SSIDS])); |
Johannes Berg | f9c112b | 2010-03-24 23:28:03 -0700 | [diff] [blame] | 244 | if (tb_msg[NL80211_ATTR_MAX_SCAN_IE_LEN]) |
| 245 | printf("\tmax scan IEs length: %d bytes\n", |
Johannes Berg | 8eaa9ee | 2010-09-26 09:12:07 +0200 | [diff] [blame] | 246 | nla_get_u16(tb_msg[NL80211_ATTR_MAX_SCAN_IE_LEN])); |
Luciano Coelho | 3fce58a | 2015-03-17 16:11:48 +0200 | [diff] [blame] | 247 | if (tb_msg[NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS]) |
| 248 | printf("\tmax # sched scan SSIDs: %d\n", |
| 249 | nla_get_u8(tb_msg[NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS])); |
| 250 | if (tb_msg[NL80211_ATTR_MAX_MATCH_SETS]) |
| 251 | printf("\tmax # match sets: %d\n", |
| 252 | nla_get_u8(tb_msg[NL80211_ATTR_MAX_MATCH_SETS])); |
Johannes Berg | 41be37f | 2008-09-19 17:34:55 +0200 | [diff] [blame] | 253 | |
Johannes Berg | 625aa4a | 2009-08-11 11:26:42 +0200 | [diff] [blame] | 254 | if (tb_msg[NL80211_ATTR_WIPHY_FRAG_THRESHOLD]) { |
| 255 | unsigned int frag; |
| 256 | |
| 257 | frag = nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_FRAG_THRESHOLD]); |
| 258 | if (frag != (unsigned int)-1) |
| 259 | printf("\tFragmentation threshold: %d\n", frag); |
| 260 | } |
| 261 | |
| 262 | if (tb_msg[NL80211_ATTR_WIPHY_RTS_THRESHOLD]) { |
| 263 | unsigned int rts; |
| 264 | |
| 265 | rts = nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_RTS_THRESHOLD]); |
| 266 | if (rts != (unsigned int)-1) |
| 267 | printf("\tRTS threshold: %d\n", rts); |
| 268 | } |
| 269 | |
Ujjal Roy | c993e6e | 2014-03-07 12:23:38 +0530 | [diff] [blame] | 270 | if (tb_msg[NL80211_ATTR_WIPHY_RETRY_SHORT] || |
| 271 | tb_msg[NL80211_ATTR_WIPHY_RETRY_LONG]) { |
| 272 | unsigned char retry_short = 0, retry_long = 0; |
| 273 | |
| 274 | if (tb_msg[NL80211_ATTR_WIPHY_RETRY_SHORT]) |
| 275 | retry_short = nla_get_u8(tb_msg[NL80211_ATTR_WIPHY_RETRY_SHORT]); |
| 276 | if (tb_msg[NL80211_ATTR_WIPHY_RETRY_LONG]) |
| 277 | retry_long = nla_get_u8(tb_msg[NL80211_ATTR_WIPHY_RETRY_LONG]); |
| 278 | if (retry_short == retry_long) { |
| 279 | printf("\tRetry short long limit: %d\n", retry_short); |
| 280 | } else { |
| 281 | printf("\tRetry short limit: %d\n", retry_short); |
| 282 | printf("\tRetry long limit: %d\n", retry_long); |
| 283 | } |
| 284 | } |
| 285 | |
Lukáš Turek | b2f92dd | 2010-02-17 21:13:23 -0500 | [diff] [blame] | 286 | if (tb_msg[NL80211_ATTR_WIPHY_COVERAGE_CLASS]) { |
| 287 | unsigned char coverage; |
| 288 | |
| 289 | coverage = nla_get_u8(tb_msg[NL80211_ATTR_WIPHY_COVERAGE_CLASS]); |
| 290 | /* See handle_distance() for an explanation where the '450' comes from */ |
| 291 | printf("\tCoverage class: %d (up to %dm)\n", coverage, 450 * coverage); |
| 292 | } |
| 293 | |
Johannes Berg | 810e05c | 2011-10-05 17:38:39 +0200 | [diff] [blame] | 294 | if (tb_msg[NL80211_ATTR_CIPHER_SUITES]) { |
| 295 | int num = nla_len(tb_msg[NL80211_ATTR_CIPHER_SUITES]) / sizeof(__u32); |
| 296 | int i; |
| 297 | __u32 *ciphers = nla_data(tb_msg[NL80211_ATTR_CIPHER_SUITES]); |
| 298 | if (num > 0) { |
| 299 | printf("\tSupported Ciphers:\n"); |
| 300 | for (i = 0; i < num; i++) |
| 301 | printf("\t\t* %s\n", |
| 302 | cipher_name(ciphers[i])); |
| 303 | } |
| 304 | } |
| 305 | |
Bruno Randolf | afce798 | 2010-12-22 10:54:39 +0900 | [diff] [blame] | 306 | if (tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX] && |
| 307 | tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX]) |
| 308 | printf("\tAvailable Antennas: TX %#x RX %#x\n", |
| 309 | nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX]), |
| 310 | nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX])); |
| 311 | |
| 312 | if (tb_msg[NL80211_ATTR_WIPHY_ANTENNA_TX] && |
| 313 | tb_msg[NL80211_ATTR_WIPHY_ANTENNA_RX]) |
| 314 | printf("\tConfigured Antennas: TX %#x RX %#x\n", |
| 315 | nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_TX]), |
| 316 | nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_RX])); |
| 317 | |
Johannes Berg | 9a4a14b | 2010-08-24 12:26:56 +0200 | [diff] [blame] | 318 | if (tb_msg[NL80211_ATTR_SUPPORTED_IFTYPES]) { |
| 319 | printf("\tSupported interface modes:\n"); |
| 320 | nla_for_each_nested(nl_mode, tb_msg[NL80211_ATTR_SUPPORTED_IFTYPES], rem_mode) |
Johannes Berg | 8ef6df4 | 2011-02-21 22:12:54 +0100 | [diff] [blame] | 321 | printf("\t\t * %s\n", iftype_name(nla_type(nl_mode))); |
Johannes Berg | 9a4a14b | 2010-08-24 12:26:56 +0200 | [diff] [blame] | 322 | } |
Johannes Berg | 6367e71 | 2008-09-05 23:01:11 +0200 | [diff] [blame] | 323 | |
Johannes Berg | 1c5b4a8 | 2011-05-13 16:53:51 +0200 | [diff] [blame] | 324 | if (tb_msg[NL80211_ATTR_SOFTWARE_IFTYPES]) { |
| 325 | printf("\tsoftware interface modes (can always be added):\n"); |
| 326 | nla_for_each_nested(nl_mode, tb_msg[NL80211_ATTR_SOFTWARE_IFTYPES], rem_mode) |
| 327 | printf("\t\t * %s\n", iftype_name(nla_type(nl_mode))); |
| 328 | } |
| 329 | |
| 330 | if (tb_msg[NL80211_ATTR_INTERFACE_COMBINATIONS]) { |
| 331 | struct nlattr *nl_combi; |
| 332 | int rem_combi; |
Johannes Berg | f5f6f15 | 2011-06-29 13:20:31 +0200 | [diff] [blame] | 333 | bool have_combinations = false; |
Johannes Berg | 1c5b4a8 | 2011-05-13 16:53:51 +0200 | [diff] [blame] | 334 | |
| 335 | nla_for_each_nested(nl_combi, tb_msg[NL80211_ATTR_INTERFACE_COMBINATIONS], rem_combi) { |
| 336 | static struct nla_policy iface_combination_policy[NUM_NL80211_IFACE_COMB] = { |
| 337 | [NL80211_IFACE_COMB_LIMITS] = { .type = NLA_NESTED }, |
| 338 | [NL80211_IFACE_COMB_MAXNUM] = { .type = NLA_U32 }, |
| 339 | [NL80211_IFACE_COMB_STA_AP_BI_MATCH] = { .type = NLA_FLAG }, |
| 340 | [NL80211_IFACE_COMB_NUM_CHANNELS] = { .type = NLA_U32 }, |
Simon Wunderlich | c5df9eb | 2013-02-08 18:16:21 +0100 | [diff] [blame] | 341 | [NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS] = { .type = NLA_U32 }, |
Johannes Berg | 1c5b4a8 | 2011-05-13 16:53:51 +0200 | [diff] [blame] | 342 | }; |
| 343 | struct nlattr *tb_comb[NUM_NL80211_IFACE_COMB]; |
| 344 | static struct nla_policy iface_limit_policy[NUM_NL80211_IFACE_LIMIT] = { |
| 345 | [NL80211_IFACE_LIMIT_TYPES] = { .type = NLA_NESTED }, |
| 346 | [NL80211_IFACE_LIMIT_MAX] = { .type = NLA_U32 }, |
| 347 | }; |
| 348 | struct nlattr *tb_limit[NUM_NL80211_IFACE_LIMIT]; |
| 349 | struct nlattr *nl_limit; |
| 350 | int err, rem_limit; |
| 351 | bool comma = false; |
| 352 | |
Johannes Berg | f5f6f15 | 2011-06-29 13:20:31 +0200 | [diff] [blame] | 353 | if (!have_combinations) { |
| 354 | printf("\tvalid interface combinations:\n"); |
| 355 | have_combinations = true; |
| 356 | } |
| 357 | |
Johannes Berg | 1c5b4a8 | 2011-05-13 16:53:51 +0200 | [diff] [blame] | 358 | printf("\t\t * "); |
| 359 | |
| 360 | err = nla_parse_nested(tb_comb, MAX_NL80211_IFACE_COMB, |
| 361 | nl_combi, iface_combination_policy); |
| 362 | if (err || !tb_comb[NL80211_IFACE_COMB_LIMITS] || |
| 363 | !tb_comb[NL80211_IFACE_COMB_MAXNUM] || |
| 364 | !tb_comb[NL80211_IFACE_COMB_NUM_CHANNELS]) { |
| 365 | printf(" <failed to parse>\n"); |
| 366 | goto broken_combination; |
| 367 | } |
| 368 | |
| 369 | nla_for_each_nested(nl_limit, tb_comb[NL80211_IFACE_COMB_LIMITS], rem_limit) { |
| 370 | bool ift_comma = false; |
| 371 | |
| 372 | err = nla_parse_nested(tb_limit, MAX_NL80211_IFACE_LIMIT, |
| 373 | nl_limit, iface_limit_policy); |
| 374 | if (err || !tb_limit[NL80211_IFACE_LIMIT_TYPES]) { |
| 375 | printf("<failed to parse>\n"); |
| 376 | goto broken_combination; |
| 377 | } |
| 378 | |
| 379 | if (comma) |
| 380 | printf(", "); |
| 381 | comma = true; |
| 382 | printf("#{"); |
| 383 | |
| 384 | nla_for_each_nested(nl_mode, tb_limit[NL80211_IFACE_LIMIT_TYPES], rem_mode) { |
| 385 | printf("%s %s", ift_comma ? "," : "", |
| 386 | iftype_name(nla_type(nl_mode))); |
| 387 | ift_comma = true; |
| 388 | } |
| 389 | printf(" } <= %u", nla_get_u32(tb_limit[NL80211_IFACE_LIMIT_MAX])); |
| 390 | } |
| 391 | printf(",\n\t\t "); |
| 392 | |
Simon Wunderlich | c5df9eb | 2013-02-08 18:16:21 +0100 | [diff] [blame] | 393 | printf("total <= %d, #channels <= %d%s", |
Johannes Berg | 1c5b4a8 | 2011-05-13 16:53:51 +0200 | [diff] [blame] | 394 | nla_get_u32(tb_comb[NL80211_IFACE_COMB_MAXNUM]), |
| 395 | nla_get_u32(tb_comb[NL80211_IFACE_COMB_NUM_CHANNELS]), |
| 396 | tb_comb[NL80211_IFACE_COMB_STA_AP_BI_MATCH] ? |
| 397 | ", STA/AP BI must match" : ""); |
Simon Wunderlich | c5df9eb | 2013-02-08 18:16:21 +0100 | [diff] [blame] | 398 | if (tb_comb[NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS]) { |
| 399 | unsigned long widths = nla_get_u32(tb_comb[NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS]); |
| 400 | |
| 401 | if (widths) { |
| 402 | int width; |
| 403 | bool first = true; |
| 404 | |
| 405 | printf(", radar detect widths: {"); |
| 406 | for (width = 0; width < 32; width++) |
| 407 | if (widths & (1 << width)) { |
| 408 | printf("%s %s", |
| 409 | first ? "":",", |
| 410 | channel_width_name(width)); |
| 411 | first = false; |
| 412 | } |
| 413 | printf(" }\n"); |
| 414 | } |
| 415 | } |
| 416 | printf("\n"); |
Johannes Berg | 1c5b4a8 | 2011-05-13 16:53:51 +0200 | [diff] [blame] | 417 | broken_combination: |
| 418 | ; |
| 419 | } |
Johannes Berg | f5f6f15 | 2011-06-29 13:20:31 +0200 | [diff] [blame] | 420 | |
| 421 | if (!have_combinations) |
| 422 | printf("\tinterface combinations are not supported\n"); |
Johannes Berg | 1c5b4a8 | 2011-05-13 16:53:51 +0200 | [diff] [blame] | 423 | } |
| 424 | |
Johannes Berg | 9a4a14b | 2010-08-24 12:26:56 +0200 | [diff] [blame] | 425 | if (tb_msg[NL80211_ATTR_SUPPORTED_COMMANDS]) { |
| 426 | printf("\tSupported commands:\n"); |
| 427 | nla_for_each_nested(nl_cmd, tb_msg[NL80211_ATTR_SUPPORTED_COMMANDS], rem_cmd) |
| 428 | printf("\t\t * %s\n", command_name(nla_get_u32(nl_cmd))); |
| 429 | } |
Johannes Berg | 6367e71 | 2008-09-05 23:01:11 +0200 | [diff] [blame] | 430 | |
Johannes Berg | 9a4a14b | 2010-08-24 12:26:56 +0200 | [diff] [blame] | 431 | if (tb_msg[NL80211_ATTR_TX_FRAME_TYPES]) { |
| 432 | printf("\tSupported TX frame types:\n"); |
| 433 | nla_for_each_nested(nl_if, tb_msg[NL80211_ATTR_TX_FRAME_TYPES], rem_if) { |
| 434 | bool printed = false; |
| 435 | nla_for_each_nested(nl_ftype, nl_if, rem_ftype) { |
| 436 | if (!printed) |
| 437 | printf("\t\t * %s:", iftype_name(nla_type(nl_if))); |
| 438 | printed = true; |
Johannes Berg | 58e3434 | 2012-03-13 09:48:23 +0100 | [diff] [blame] | 439 | printf(" 0x%.2x", nla_get_u16(nl_ftype)); |
Johannes Berg | 9a4a14b | 2010-08-24 12:26:56 +0200 | [diff] [blame] | 440 | } |
| 441 | if (printed) |
| 442 | printf("\n"); |
| 443 | } |
| 444 | } |
Marcel Holtmann | 9990c1e | 2009-11-14 20:10:21 +0100 | [diff] [blame] | 445 | |
Johannes Berg | 9a4a14b | 2010-08-24 12:26:56 +0200 | [diff] [blame] | 446 | if (tb_msg[NL80211_ATTR_RX_FRAME_TYPES]) { |
| 447 | printf("\tSupported RX frame types:\n"); |
| 448 | nla_for_each_nested(nl_if, tb_msg[NL80211_ATTR_RX_FRAME_TYPES], rem_if) { |
| 449 | bool printed = false; |
| 450 | nla_for_each_nested(nl_ftype, nl_if, rem_ftype) { |
| 451 | if (!printed) |
| 452 | printf("\t\t * %s:", iftype_name(nla_type(nl_if))); |
| 453 | printed = true; |
Johannes Berg | 58e3434 | 2012-03-13 09:48:23 +0100 | [diff] [blame] | 454 | printf(" 0x%.2x", nla_get_u16(nl_ftype)); |
Johannes Berg | 9a4a14b | 2010-08-24 12:26:56 +0200 | [diff] [blame] | 455 | } |
| 456 | if (printed) |
| 457 | printf("\n"); |
| 458 | } |
| 459 | } |
Marcel Holtmann | 9990c1e | 2009-11-14 20:10:21 +0100 | [diff] [blame] | 460 | |
Johannes Berg | 3ff2456 | 2011-04-12 13:04:50 +0200 | [diff] [blame] | 461 | if (tb_msg[NL80211_ATTR_SUPPORT_IBSS_RSN]) |
Johannes Berg | 83f1016 | 2011-02-24 15:11:57 +0100 | [diff] [blame] | 462 | printf("\tDevice supports RSN-IBSS.\n"); |
Johannes Berg | 3ff2456 | 2011-04-12 13:04:50 +0200 | [diff] [blame] | 463 | |
| 464 | if (tb_msg[NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED]) { |
| 465 | struct nlattr *tb_wowlan[NUM_NL80211_WOWLAN_TRIG]; |
| 466 | static struct nla_policy wowlan_policy[NUM_NL80211_WOWLAN_TRIG] = { |
| 467 | [NL80211_WOWLAN_TRIG_ANY] = { .type = NLA_FLAG }, |
| 468 | [NL80211_WOWLAN_TRIG_DISCONNECT] = { .type = NLA_FLAG }, |
| 469 | [NL80211_WOWLAN_TRIG_MAGIC_PKT] = { .type = NLA_FLAG }, |
Amitkumar Karwar | 1c8f49c | 2013-02-19 16:44:44 -0800 | [diff] [blame] | 470 | [NL80211_WOWLAN_TRIG_PKT_PATTERN] = { .minlen = 12 }, |
Johannes Berg | 3a6636b | 2011-07-12 13:08:37 +0200 | [diff] [blame] | 471 | [NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED] = { .type = NLA_FLAG }, |
| 472 | [NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE] = { .type = NLA_FLAG }, |
| 473 | [NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST] = { .type = NLA_FLAG }, |
| 474 | [NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE] = { .type = NLA_FLAG }, |
| 475 | [NL80211_WOWLAN_TRIG_RFKILL_RELEASE] = { .type = NLA_FLAG }, |
Luciano Coelho | 4888e6b | 2015-01-13 16:19:15 +0200 | [diff] [blame] | 476 | [NL80211_WOWLAN_TRIG_NET_DETECT] = { .type = NLA_U32 }, |
Johannes Berg | 819b78c | 2013-02-19 23:31:27 +0100 | [diff] [blame] | 477 | [NL80211_WOWLAN_TRIG_TCP_CONNECTION] = { .type = NLA_NESTED }, |
Johannes Berg | 3ff2456 | 2011-04-12 13:04:50 +0200 | [diff] [blame] | 478 | }; |
Amitkumar Karwar | c82868d | 2013-06-28 12:53:44 -0700 | [diff] [blame] | 479 | struct nl80211_pattern_support *pat; |
Johannes Berg | 3ff2456 | 2011-04-12 13:04:50 +0200 | [diff] [blame] | 480 | int err; |
| 481 | |
| 482 | err = nla_parse_nested(tb_wowlan, MAX_NL80211_WOWLAN_TRIG, |
| 483 | tb_msg[NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED], |
| 484 | wowlan_policy); |
| 485 | printf("\tWoWLAN support:"); |
| 486 | if (err) { |
| 487 | printf(" <failed to parse>\n"); |
| 488 | } else { |
| 489 | printf("\n"); |
| 490 | if (tb_wowlan[NL80211_WOWLAN_TRIG_ANY]) |
Johannes Berg | 3a6636b | 2011-07-12 13:08:37 +0200 | [diff] [blame] | 491 | printf("\t\t * wake up on anything (device continues operating normally)\n"); |
Johannes Berg | 3ff2456 | 2011-04-12 13:04:50 +0200 | [diff] [blame] | 492 | if (tb_wowlan[NL80211_WOWLAN_TRIG_DISCONNECT]) |
Johannes Berg | 3a6636b | 2011-07-12 13:08:37 +0200 | [diff] [blame] | 493 | printf("\t\t * wake up on disconnect\n"); |
Johannes Berg | 3ff2456 | 2011-04-12 13:04:50 +0200 | [diff] [blame] | 494 | if (tb_wowlan[NL80211_WOWLAN_TRIG_MAGIC_PKT]) |
Johannes Berg | 3a6636b | 2011-07-12 13:08:37 +0200 | [diff] [blame] | 495 | printf("\t\t * wake up on magic packet\n"); |
Johannes Berg | 3ff2456 | 2011-04-12 13:04:50 +0200 | [diff] [blame] | 496 | if (tb_wowlan[NL80211_WOWLAN_TRIG_PKT_PATTERN]) { |
| 497 | pat = nla_data(tb_wowlan[NL80211_WOWLAN_TRIG_PKT_PATTERN]); |
Amitkumar Karwar | 1c8f49c | 2013-02-19 16:44:44 -0800 | [diff] [blame] | 498 | printf("\t\t * wake up on pattern match, up to %u patterns of %u-%u bytes,\n" |
| 499 | "\t\t maximum packet offset %u bytes\n", |
| 500 | pat->max_patterns, pat->min_pattern_len, pat->max_pattern_len, |
| 501 | (nla_len(tb_wowlan[NL80211_WOWLAN_TRIG_PKT_PATTERN]) < |
| 502 | sizeof(*pat)) ? 0 : pat->max_pkt_offset); |
Johannes Berg | 3ff2456 | 2011-04-12 13:04:50 +0200 | [diff] [blame] | 503 | } |
Johannes Berg | 3a6636b | 2011-07-12 13:08:37 +0200 | [diff] [blame] | 504 | if (tb_wowlan[NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED]) |
| 505 | printf("\t\t * can do GTK rekeying\n"); |
| 506 | if (tb_wowlan[NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE]) |
| 507 | printf("\t\t * wake up on GTK rekey failure\n"); |
| 508 | if (tb_wowlan[NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST]) |
| 509 | printf("\t\t * wake up on EAP identity request\n"); |
| 510 | if (tb_wowlan[NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE]) |
| 511 | printf("\t\t * wake up on 4-way handshake\n"); |
| 512 | if (tb_wowlan[NL80211_WOWLAN_TRIG_RFKILL_RELEASE]) |
| 513 | printf("\t\t * wake up on rfkill release\n"); |
Luciano Coelho | d516c5b | 2014-11-28 23:05:55 +0200 | [diff] [blame] | 514 | if (tb_wowlan[NL80211_WOWLAN_TRIG_NET_DETECT]) |
Luciano Coelho | 4888e6b | 2015-01-13 16:19:15 +0200 | [diff] [blame] | 515 | printf("\t\t * wake up on network detection, up to %d match sets\n", |
| 516 | nla_get_u32(tb_wowlan[NL80211_WOWLAN_TRIG_NET_DETECT])); |
Johannes Berg | 819b78c | 2013-02-19 23:31:27 +0100 | [diff] [blame] | 517 | if (tb_wowlan[NL80211_WOWLAN_TRIG_TCP_CONNECTION]) |
| 518 | printf("\t\t * wake up on TCP connection\n"); |
Johannes Berg | 3ff2456 | 2011-04-12 13:04:50 +0200 | [diff] [blame] | 519 | } |
Johannes Berg | 83f1016 | 2011-02-24 15:11:57 +0100 | [diff] [blame] | 520 | } |
| 521 | |
Johannes Berg | 2e4f65c | 2011-10-04 14:00:47 +0200 | [diff] [blame] | 522 | if (tb_msg[NL80211_ATTR_ROAM_SUPPORT]) |
| 523 | printf("\tDevice supports roaming.\n"); |
| 524 | |
Johannes Berg | 8b46999 | 2011-11-04 11:53:18 +0100 | [diff] [blame] | 525 | if (tb_msg[NL80211_ATTR_SUPPORT_AP_UAPSD]) |
| 526 | printf("\tDevice supports AP-side u-APSD.\n"); |
| 527 | |
Ben Greear | a82abc2 | 2011-11-28 10:40:22 -0800 | [diff] [blame] | 528 | if (tb_msg[NL80211_ATTR_HT_CAPABILITY_MASK]) { |
| 529 | struct ieee80211_ht_cap *cm; |
| 530 | printf("\tHT Capability overrides:\n"); |
| 531 | if (nla_len(tb_msg[NL80211_ATTR_HT_CAPABILITY_MASK]) >= sizeof(*cm)) { |
| 532 | cm = nla_data(tb_msg[NL80211_ATTR_HT_CAPABILITY_MASK]); |
| 533 | printf("\t\t * MCS: %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx" |
| 534 | " %02hhx %02hhx %02hhx %02hhx\n", |
| 535 | cm->mcs.rx_mask[0], cm->mcs.rx_mask[1], |
| 536 | cm->mcs.rx_mask[2], cm->mcs.rx_mask[3], |
| 537 | cm->mcs.rx_mask[4], cm->mcs.rx_mask[5], |
| 538 | cm->mcs.rx_mask[6], cm->mcs.rx_mask[7], |
| 539 | cm->mcs.rx_mask[8], cm->mcs.rx_mask[9]); |
| 540 | if (cm->cap_info & htole16(IEEE80211_HT_CAP_MAX_AMSDU)) |
| 541 | printf("\t\t * maximum A-MSDU length\n"); |
| 542 | if (cm->cap_info & htole16(IEEE80211_HT_CAP_SUP_WIDTH_20_40)) |
| 543 | printf("\t\t * supported channel width\n"); |
| 544 | if (cm->cap_info & htole16(IEEE80211_HT_CAP_SGI_40)) |
| 545 | printf("\t\t * short GI for 40 MHz\n"); |
| 546 | if (cm->ampdu_params_info & IEEE80211_HT_AMPDU_PARM_FACTOR) |
| 547 | printf("\t\t * max A-MPDU length exponent\n"); |
| 548 | if (cm->ampdu_params_info & IEEE80211_HT_AMPDU_PARM_DENSITY) |
| 549 | printf("\t\t * min MPDU start spacing\n"); |
| 550 | } else { |
| 551 | printf("\tERROR: capabilities mask is too short, expected: %d, received: %d\n", |
| 552 | (int)(sizeof(*cm)), |
| 553 | (int)(nla_len(tb_msg[NL80211_ATTR_HT_CAPABILITY_MASK]))); |
| 554 | } |
| 555 | } |
| 556 | |
Johannes Berg | 632004a | 2011-12-14 15:08:34 +0100 | [diff] [blame] | 557 | if (tb_msg[NL80211_ATTR_FEATURE_FLAGS]) { |
Johannes Berg | d28df6b | 2012-10-16 20:12:37 +0200 | [diff] [blame] | 558 | unsigned int features = nla_get_u32(tb_msg[NL80211_ATTR_FEATURE_FLAGS]); |
| 559 | |
| 560 | if (features & NL80211_FEATURE_SK_TX_STATUS) |
Johannes Berg | 632004a | 2011-12-14 15:08:34 +0100 | [diff] [blame] | 561 | printf("\tDevice supports TX status socket option.\n"); |
Johannes Berg | d28df6b | 2012-10-16 20:12:37 +0200 | [diff] [blame] | 562 | if (features & NL80211_FEATURE_HT_IBSS) |
Johannes Berg | 632004a | 2011-12-14 15:08:34 +0100 | [diff] [blame] | 563 | printf("\tDevice supports HT-IBSS.\n"); |
Johannes Berg | d28df6b | 2012-10-16 20:12:37 +0200 | [diff] [blame] | 564 | if (features & NL80211_FEATURE_INACTIVITY_TIMER) |
| 565 | printf("\tDevice has client inactivity timer.\n"); |
| 566 | if (features & NL80211_FEATURE_CELL_BASE_REG_HINTS) |
| 567 | printf("\tDevice accepts cell base station regulatory hints.\n"); |
| 568 | if (features & NL80211_FEATURE_P2P_DEVICE_NEEDS_CHANNEL) |
| 569 | printf("\tP2P Device uses a channel (of the concurrent ones)\n"); |
Johannes Berg | 5973e65 | 2014-10-09 16:30:38 +0200 | [diff] [blame] | 570 | if (features & NL80211_FEATURE_SAE) |
| 571 | printf("\tDevice supports SAE with AUTHENTICATE command\n"); |
Sam Leffler | fe86223 | 2012-10-17 12:20:04 -0700 | [diff] [blame] | 572 | if (features & NL80211_FEATURE_LOW_PRIORITY_SCAN) |
| 573 | printf("\tDevice supports low priority scan.\n"); |
| 574 | if (features & NL80211_FEATURE_SCAN_FLUSH) |
| 575 | printf("\tDevice supports scan flush.\n"); |
Antonio Quartulli | afa2be2 | 2012-10-26 16:41:47 +0200 | [diff] [blame] | 576 | if (features & NL80211_FEATURE_AP_SCAN) |
| 577 | printf("\tDevice supports AP scan.\n"); |
Johannes Berg | 5973e65 | 2014-10-09 16:30:38 +0200 | [diff] [blame] | 578 | if (features & NL80211_FEATURE_VIF_TXPOWER) |
| 579 | printf("\tDevice supports per-vif TX power setting\n"); |
| 580 | if (features & NL80211_FEATURE_NEED_OBSS_SCAN) |
| 581 | printf("\tUserspace should do OBSS scan and generate 20/40 coex reports\n"); |
| 582 | if (features & NL80211_FEATURE_P2P_GO_CTWIN) |
| 583 | printf("\tP2P GO supports CT window setting\n"); |
| 584 | if (features & NL80211_FEATURE_P2P_GO_OPPPS) |
| 585 | printf("\tP2P GO supports opportunistic powersave setting\n"); |
| 586 | if (features & NL80211_FEATURE_FULL_AP_CLIENT_STATE) |
| 587 | printf("\tDriver supports full state transitions for AP/GO clients\n"); |
| 588 | if (features & NL80211_FEATURE_USERSPACE_MPM) |
| 589 | printf("\tDriver supports a userspace MPM\n"); |
| 590 | if (features & NL80211_FEATURE_ACTIVE_MONITOR) |
| 591 | printf("\tDevice supports active monitor (which will ACK incoming frames)\n"); |
| 592 | if (features & NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE) |
| 593 | printf("\tDriver/device bandwidth changes during BSS lifetime (AP/GO mode)\n"); |
| 594 | if (features & NL80211_FEATURE_DS_PARAM_SET_IE_IN_PROBES) |
| 595 | printf("\tDevice adds DS IE to probe requests\n"); |
| 596 | if (features & NL80211_FEATURE_WFA_TPC_IE_IN_PROBES) |
| 597 | printf("\tDevice adds WFA TPC Report IE to probe requests\n"); |
| 598 | if (features & NL80211_FEATURE_QUIET) |
| 599 | printf("\tDevice supports quiet requests from AP\n"); |
| 600 | if (features & NL80211_FEATURE_TX_POWER_INSERTION) |
| 601 | printf("\tDevice can update TPC Report IE\n"); |
Lorenzo Bianconi | e642142 | 2014-09-07 19:32:20 +0200 | [diff] [blame] | 602 | if (features & NL80211_FEATURE_ACKTO_ESTIMATION) |
| 603 | printf("\tDevice supports ACK timeout estimation.\n"); |
Johannes Berg | 5973e65 | 2014-10-09 16:30:38 +0200 | [diff] [blame] | 604 | if (features & NL80211_FEATURE_STATIC_SMPS) |
| 605 | printf("\tDevice supports static SMPS\n"); |
| 606 | if (features & NL80211_FEATURE_DYNAMIC_SMPS) |
| 607 | printf("\tDevice supports dynamic SMPS\n"); |
Johannes Berg | e15ec74 | 2014-10-29 17:10:39 +0100 | [diff] [blame] | 608 | if (features & NL80211_FEATURE_SUPPORTS_WMM_ADMISSION) |
| 609 | printf("\tDevice supports WMM-AC admission (TSPECs)\n"); |
Ben Greear | ced5522 | 2014-10-24 08:35:42 -0700 | [diff] [blame] | 610 | if (features & NL80211_FEATURE_MAC_ON_CREATE) |
| 611 | printf("\tDevice supports configuring vdev MAC-addr on create.\n"); |
Arik Nemtsov | c2f0d68 | 2014-12-01 18:00:22 +0200 | [diff] [blame] | 612 | if (features & NL80211_FEATURE_TDLS_CHANNEL_SWITCH) |
| 613 | printf("\tDevice supports TDLS channel switching\n"); |
Johannes Berg | 632004a | 2011-12-14 15:08:34 +0100 | [diff] [blame] | 614 | } |
| 615 | |
Janusz.Dziedzic@tieto.com | f0e30bd | 2015-03-30 12:56:31 +0200 | [diff] [blame] | 616 | if (tb_msg[NL80211_ATTR_EXT_FEATURES]) { |
| 617 | struct nlattr *tb = tb_msg[NL80211_ATTR_EXT_FEATURES]; |
| 618 | |
| 619 | if (ext_feature_isset(nla_data(tb), nla_len(tb), |
| 620 | NL80211_EXT_FEATURE_VHT_IBSS)) |
| 621 | printf("\tDevice supports VHT-IBSS.\n"); |
| 622 | } |
| 623 | |
Johannes Berg | 9b4a198 | 2014-01-06 17:22:00 +0100 | [diff] [blame] | 624 | if (tb_msg[NL80211_ATTR_TDLS_SUPPORT]) |
| 625 | printf("\tDevice supports T-DLS.\n"); |
| 626 | |
Amitkumar Karwar | aa0f5db | 2013-06-28 12:53:45 -0700 | [diff] [blame] | 627 | if (tb_msg[NL80211_ATTR_COALESCE_RULE]) { |
| 628 | struct nl80211_coalesce_rule_support *rule; |
| 629 | struct nl80211_pattern_support *pat; |
| 630 | |
| 631 | printf("\tCoalesce support:\n"); |
| 632 | rule = nla_data(tb_msg[NL80211_ATTR_COALESCE_RULE]); |
| 633 | pat = &rule->pat; |
| 634 | printf("\t\t * Maximum %u coalesce rules supported\n" |
| 635 | "\t\t * Each rule contains upto %u patterns of %u-%u bytes,\n" |
| 636 | "\t\t maximum packet offset %u bytes\n" |
| 637 | "\t\t * Maximum supported coalescing delay %u msecs\n", |
| 638 | rule->max_rules, pat->max_patterns, pat->min_pattern_len, |
| 639 | pat->max_pattern_len, pat->max_pkt_offset, rule->max_delay); |
| 640 | } |
| 641 | |
Johannes Berg | 79f99b9 | 2008-01-16 00:21:59 +0100 | [diff] [blame] | 642 | return NL_SKIP; |
| 643 | } |
| 644 | |
Johannes Berg | c142fa2 | 2013-05-02 09:22:58 +0200 | [diff] [blame] | 645 | static bool nl80211_has_split_wiphy = false; |
| 646 | |
Johannes Berg | 7c37a24 | 2009-04-08 13:13:28 +0200 | [diff] [blame] | 647 | static int handle_info(struct nl80211_state *state, |
| 648 | struct nl_cb *cb, |
Johannes Berg | d631650 | 2008-09-16 17:05:33 +0200 | [diff] [blame] | 649 | struct nl_msg *msg, |
Johannes Berg | 05514f9 | 2012-07-19 11:50:50 +0200 | [diff] [blame] | 650 | int argc, char **argv, |
| 651 | enum id_input id) |
Johannes Berg | 79f99b9 | 2008-01-16 00:21:59 +0100 | [diff] [blame] | 652 | { |
Johannes Berg | c142fa2 | 2013-05-02 09:22:58 +0200 | [diff] [blame] | 653 | char *feat_args[] = { "features", "-q" }; |
| 654 | int err; |
| 655 | |
| 656 | err = handle_cmd(state, CIB_NONE, 2, feat_args); |
| 657 | if (!err && nl80211_has_split_wiphy) { |
| 658 | nla_put_flag(msg, NL80211_ATTR_SPLIT_WIPHY_DUMP); |
| 659 | nlmsg_hdr(msg)->nlmsg_flags |= NLM_F_DUMP; |
| 660 | } |
| 661 | |
Johannes Berg | 79f99b9 | 2008-01-16 00:21:59 +0100 | [diff] [blame] | 662 | nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_phy_handler, NULL); |
Johannes Berg | 79f99b9 | 2008-01-16 00:21:59 +0100 | [diff] [blame] | 663 | |
Johannes Berg | 70391cc | 2008-09-16 18:35:06 +0200 | [diff] [blame] | 664 | return 0; |
Johannes Berg | 79f99b9 | 2008-01-16 00:21:59 +0100 | [diff] [blame] | 665 | } |
Johannes Berg | c142fa2 | 2013-05-02 09:22:58 +0200 | [diff] [blame] | 666 | __COMMAND(NULL, info, "info", NULL, NL80211_CMD_GET_WIPHY, 0, 0, CIB_PHY, handle_info, |
Johannes Berg | 1633ddf | 2010-11-24 08:16:47 +0100 | [diff] [blame] | 667 | "Show capabilities for the specified wireless device.", NULL); |
Johannes Berg | ea35fc0 | 2009-05-05 14:56:21 +0200 | [diff] [blame] | 668 | TOPLEVEL(list, NULL, NL80211_CMD_GET_WIPHY, NLM_F_DUMP, CIB_NONE, handle_info, |
| 669 | "List all wireless devices and their capabilities."); |
Johannes Berg | 01ae06f | 2009-05-05 14:48:16 +0200 | [diff] [blame] | 670 | TOPLEVEL(phy, NULL, NL80211_CMD_GET_WIPHY, NLM_F_DUMP, CIB_NONE, handle_info, NULL); |
Johannes Berg | bcdff0b | 2012-11-15 15:15:10 +0100 | [diff] [blame] | 671 | |
| 672 | static int handle_commands(struct nl80211_state *state, |
| 673 | struct nl_cb *cb, struct nl_msg *msg, |
| 674 | int argc, char **argv, enum id_input id) |
| 675 | { |
| 676 | int i; |
| 677 | for (i = 1; i < NL80211_CMD_MAX; i++) |
| 678 | printf("%d (0x%x): %s\n", i, i, command_name(i)); |
| 679 | /* don't send netlink messages */ |
| 680 | return 2; |
| 681 | } |
| 682 | TOPLEVEL(commands, NULL, NL80211_CMD_GET_WIPHY, 0, CIB_NONE, handle_commands, |
| 683 | "list all known commands and their decimal & hex value"); |
Johannes Berg | fb70e11 | 2013-02-14 16:32:53 +0100 | [diff] [blame] | 684 | |
| 685 | static int print_feature_handler(struct nl_msg *msg, void *arg) |
| 686 | { |
| 687 | struct nlattr *tb_msg[NL80211_ATTR_MAX + 1]; |
| 688 | struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); |
Johannes Berg | c142fa2 | 2013-05-02 09:22:58 +0200 | [diff] [blame] | 689 | bool print = (unsigned long)arg; |
| 690 | #define maybe_printf(...) do { if (print) printf(__VA_ARGS__); } while (0) |
Johannes Berg | fb70e11 | 2013-02-14 16:32:53 +0100 | [diff] [blame] | 691 | |
| 692 | nla_parse(tb_msg, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), |
| 693 | genlmsg_attrlen(gnlh, 0), NULL); |
| 694 | |
| 695 | if (tb_msg[NL80211_ATTR_PROTOCOL_FEATURES]) { |
| 696 | uint32_t feat = nla_get_u32(tb_msg[NL80211_ATTR_PROTOCOL_FEATURES]); |
| 697 | |
Johannes Berg | c142fa2 | 2013-05-02 09:22:58 +0200 | [diff] [blame] | 698 | maybe_printf("nl80211 features: 0x%x\n", feat); |
| 699 | if (feat & NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP) { |
| 700 | maybe_printf("\t* split wiphy dump\n"); |
| 701 | nl80211_has_split_wiphy = true; |
| 702 | } |
Johannes Berg | fb70e11 | 2013-02-14 16:32:53 +0100 | [diff] [blame] | 703 | } |
| 704 | |
| 705 | return NL_SKIP; |
| 706 | } |
| 707 | |
| 708 | static int handle_features(struct nl80211_state *state, |
| 709 | struct nl_cb *cb, struct nl_msg *msg, |
| 710 | int argc, char **argv, enum id_input id) |
| 711 | { |
Johannes Berg | c142fa2 | 2013-05-02 09:22:58 +0200 | [diff] [blame] | 712 | unsigned long print = argc == 0 || strcmp(argv[0], "-q"); |
| 713 | nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_feature_handler, (void *)print); |
Johannes Berg | fb70e11 | 2013-02-14 16:32:53 +0100 | [diff] [blame] | 714 | return 0; |
| 715 | } |
| 716 | |
Johannes Berg | c142fa2 | 2013-05-02 09:22:58 +0200 | [diff] [blame] | 717 | TOPLEVEL(features, "", NL80211_CMD_GET_PROTOCOL_FEATURES, 0, CIB_NONE, |
Johannes Berg | fb70e11 | 2013-02-14 16:32:53 +0100 | [diff] [blame] | 718 | handle_features, ""); |