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 | |
Johannes Berg | 79f99b9 | 2008-01-16 00:21:59 +0100 | [diff] [blame] | 66 | static int print_phy_handler(struct nl_msg *msg, void *arg) |
| 67 | { |
| 68 | struct nlattr *tb_msg[NL80211_ATTR_MAX + 1]; |
| 69 | struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); |
| 70 | |
| 71 | struct nlattr *tb_band[NL80211_BAND_ATTR_MAX + 1]; |
| 72 | |
| 73 | struct nlattr *tb_freq[NL80211_FREQUENCY_ATTR_MAX + 1]; |
| 74 | static struct nla_policy freq_policy[NL80211_FREQUENCY_ATTR_MAX + 1] = { |
| 75 | [NL80211_FREQUENCY_ATTR_FREQ] = { .type = NLA_U32 }, |
| 76 | [NL80211_FREQUENCY_ATTR_DISABLED] = { .type = NLA_FLAG }, |
Ilan Peer | f0c48e7 | 2013-11-14 09:15:34 +0200 | [diff] [blame^] | 77 | [NL80211_FREQUENCY_ATTR_NO_IR] = { .type = NLA_FLAG }, |
| 78 | [__NL80211_FREQUENCY_ATTR_NO_IBSS] = { .type = NLA_FLAG }, |
Johannes Berg | 79f99b9 | 2008-01-16 00:21:59 +0100 | [diff] [blame] | 79 | [NL80211_FREQUENCY_ATTR_RADAR] = { .type = NLA_FLAG }, |
Johannes Berg | c1081c2 | 2008-11-23 12:11:26 +0100 | [diff] [blame] | 80 | [NL80211_FREQUENCY_ATTR_MAX_TX_POWER] = { .type = NLA_U32 }, |
Johannes Berg | 79f99b9 | 2008-01-16 00:21:59 +0100 | [diff] [blame] | 81 | }; |
| 82 | |
| 83 | struct nlattr *tb_rate[NL80211_BITRATE_ATTR_MAX + 1]; |
| 84 | static struct nla_policy rate_policy[NL80211_BITRATE_ATTR_MAX + 1] = { |
| 85 | [NL80211_BITRATE_ATTR_RATE] = { .type = NLA_U32 }, |
| 86 | [NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE] = { .type = NLA_FLAG }, |
| 87 | }; |
| 88 | |
| 89 | struct nlattr *nl_band; |
| 90 | struct nlattr *nl_freq; |
| 91 | struct nlattr *nl_rate; |
Johannes Berg | 6367e71 | 2008-09-05 23:01:11 +0200 | [diff] [blame] | 92 | struct nlattr *nl_mode; |
Marcel Holtmann | 9990c1e | 2009-11-14 20:10:21 +0100 | [diff] [blame] | 93 | struct nlattr *nl_cmd; |
Johannes Berg | 9a4a14b | 2010-08-24 12:26:56 +0200 | [diff] [blame] | 94 | struct nlattr *nl_if, *nl_ftype; |
Johannes Berg | 9a4a14b | 2010-08-24 12:26:56 +0200 | [diff] [blame] | 95 | 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] | 96 | int open; |
Johannes Berg | fb70e11 | 2013-02-14 16:32:53 +0100 | [diff] [blame] | 97 | /* |
| 98 | * static variables only work here, other applications need to use the |
| 99 | * callback pointer and store them there so they can be multithreaded |
| 100 | * and/or have multiple netlink sockets, etc. |
| 101 | */ |
| 102 | static int64_t phy_id = -1; |
| 103 | static int last_band = -1; |
| 104 | static bool band_had_freq = false; |
| 105 | bool print_name = true; |
Johannes Berg | 79f99b9 | 2008-01-16 00:21:59 +0100 | [diff] [blame] | 106 | |
| 107 | nla_parse(tb_msg, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), |
| 108 | genlmsg_attrlen(gnlh, 0), NULL); |
| 109 | |
Johannes Berg | fb70e11 | 2013-02-14 16:32:53 +0100 | [diff] [blame] | 110 | if (tb_msg[NL80211_ATTR_WIPHY]) { |
| 111 | if (nla_get_u32(tb_msg[NL80211_ATTR_WIPHY]) == phy_id) |
| 112 | print_name = false; |
| 113 | else |
| 114 | last_band = -1; |
| 115 | phy_id = nla_get_u32(tb_msg[NL80211_ATTR_WIPHY]); |
| 116 | } |
| 117 | if (print_name && tb_msg[NL80211_ATTR_WIPHY_NAME]) |
Johannes Berg | d631650 | 2008-09-16 17:05:33 +0200 | [diff] [blame] | 118 | printf("Wiphy %s\n", nla_get_string(tb_msg[NL80211_ATTR_WIPHY_NAME])); |
| 119 | |
Johannes Berg | fb70e11 | 2013-02-14 16:32:53 +0100 | [diff] [blame] | 120 | /* needed for split dump */ |
| 121 | if (tb_msg[NL80211_ATTR_WIPHY_BANDS]) { |
| 122 | nla_for_each_nested(nl_band, tb_msg[NL80211_ATTR_WIPHY_BANDS], rem_band) { |
| 123 | if (last_band != nl_band->nla_type) { |
| 124 | printf("\tBand %d:\n", nl_band->nla_type + 1); |
| 125 | band_had_freq = false; |
Johannes Berg | ee9cd98 | 2009-01-18 18:13:54 +0100 | [diff] [blame] | 126 | } |
Johannes Berg | fb70e11 | 2013-02-14 16:32:53 +0100 | [diff] [blame] | 127 | last_band = nl_band->nla_type; |
Simon Wunderlich | 48aaf2d | 2013-02-08 18:16:22 +0100 | [diff] [blame] | 128 | |
Johannes Berg | fb70e11 | 2013-02-14 16:32:53 +0100 | [diff] [blame] | 129 | nla_parse(tb_band, NL80211_BAND_ATTR_MAX, nla_data(nl_band), |
| 130 | nla_len(nl_band), NULL); |
Simon Wunderlich | 48aaf2d | 2013-02-08 18:16:22 +0100 | [diff] [blame] | 131 | |
Johannes Berg | fb70e11 | 2013-02-14 16:32:53 +0100 | [diff] [blame] | 132 | if (tb_band[NL80211_BAND_ATTR_HT_CAPA]) { |
| 133 | __u16 cap = nla_get_u16(tb_band[NL80211_BAND_ATTR_HT_CAPA]); |
| 134 | print_ht_capability(cap); |
| 135 | } |
| 136 | if (tb_band[NL80211_BAND_ATTR_HT_AMPDU_FACTOR]) { |
| 137 | __u8 exponent = nla_get_u8(tb_band[NL80211_BAND_ATTR_HT_AMPDU_FACTOR]); |
| 138 | print_ampdu_length(exponent); |
| 139 | } |
| 140 | if (tb_band[NL80211_BAND_ATTR_HT_AMPDU_DENSITY]) { |
| 141 | __u8 spacing = nla_get_u8(tb_band[NL80211_BAND_ATTR_HT_AMPDU_DENSITY]); |
| 142 | print_ampdu_spacing(spacing); |
| 143 | } |
| 144 | if (tb_band[NL80211_BAND_ATTR_HT_MCS_SET] && |
| 145 | nla_len(tb_band[NL80211_BAND_ATTR_HT_MCS_SET]) == 16) |
| 146 | print_ht_mcs(nla_data(tb_band[NL80211_BAND_ATTR_HT_MCS_SET])); |
| 147 | if (tb_band[NL80211_BAND_ATTR_VHT_CAPA] && |
| 148 | tb_band[NL80211_BAND_ATTR_VHT_MCS_SET]) |
| 149 | print_vht_info(nla_get_u32(tb_band[NL80211_BAND_ATTR_VHT_CAPA]), |
| 150 | nla_data(tb_band[NL80211_BAND_ATTR_VHT_MCS_SET])); |
| 151 | |
| 152 | if (tb_band[NL80211_BAND_ATTR_FREQS]) { |
| 153 | if (!band_had_freq) { |
| 154 | printf("\t\tFrequencies:\n"); |
| 155 | band_had_freq = true; |
Simon Wunderlich | 48aaf2d | 2013-02-08 18:16:22 +0100 | [diff] [blame] | 156 | } |
Johannes Berg | fb70e11 | 2013-02-14 16:32:53 +0100 | [diff] [blame] | 157 | nla_for_each_nested(nl_freq, tb_band[NL80211_BAND_ATTR_FREQS], rem_freq) { |
| 158 | uint32_t freq; |
| 159 | nla_parse(tb_freq, NL80211_FREQUENCY_ATTR_MAX, nla_data(nl_freq), |
| 160 | nla_len(nl_freq), freq_policy); |
| 161 | if (!tb_freq[NL80211_FREQUENCY_ATTR_FREQ]) |
| 162 | continue; |
| 163 | freq = nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_FREQ]); |
| 164 | printf("\t\t\t* %d MHz [%d]", freq, ieee80211_frequency_to_channel(freq)); |
| 165 | |
| 166 | if (tb_freq[NL80211_FREQUENCY_ATTR_MAX_TX_POWER] && |
| 167 | !tb_freq[NL80211_FREQUENCY_ATTR_DISABLED]) |
| 168 | printf(" (%.1f dBm)", 0.01 * nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_MAX_TX_POWER])); |
| 169 | |
| 170 | open = 0; |
| 171 | if (tb_freq[NL80211_FREQUENCY_ATTR_DISABLED]) { |
| 172 | print_flag("disabled", &open); |
| 173 | goto next; |
| 174 | } |
Ilan Peer | f0c48e7 | 2013-11-14 09:15:34 +0200 | [diff] [blame^] | 175 | |
| 176 | /* If both flags are set assume an new kernel */ |
| 177 | if (tb_freq[NL80211_FREQUENCY_ATTR_NO_IR] && tb_freq[__NL80211_FREQUENCY_ATTR_NO_IBSS]) { |
| 178 | print_flag("no IR", &open); |
| 179 | } else if (tb_freq[NL80211_FREQUENCY_ATTR_PASSIVE_SCAN]) { |
| 180 | print_flag("passive scan", &open); |
| 181 | } else if (tb_freq[__NL80211_FREQUENCY_ATTR_NO_IBSS]){ |
| 182 | print_flag("no ibss", &open); |
| 183 | } |
| 184 | |
Johannes Berg | fb70e11 | 2013-02-14 16:32:53 +0100 | [diff] [blame] | 185 | if (tb_freq[NL80211_FREQUENCY_ATTR_RADAR]) |
| 186 | print_flag("radar detection", &open); |
| 187 | next: |
| 188 | if (open) |
| 189 | printf(")"); |
| 190 | printf("\n"); |
| 191 | |
Zefir Kurtisi | 4b99e6a | 2013-03-26 12:09:49 +0100 | [diff] [blame] | 192 | if (!tb_freq[NL80211_FREQUENCY_ATTR_DISABLED] && tb_freq[NL80211_FREQUENCY_ATTR_DFS_STATE]) { |
| 193 | enum nl80211_dfs_state state = nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_DFS_STATE]); |
| 194 | unsigned long time; |
Johannes Berg | fb70e11 | 2013-02-14 16:32:53 +0100 | [diff] [blame] | 195 | |
Zefir Kurtisi | 4b99e6a | 2013-03-26 12:09:49 +0100 | [diff] [blame] | 196 | printf("\t\t\t DFS state: %s", dfs_state_name(state)); |
| 197 | if (tb_freq[NL80211_FREQUENCY_ATTR_DFS_TIME]) { |
| 198 | time = nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_DFS_TIME]); |
| 199 | printf(" (for %lu sec)", time/1000); |
| 200 | } |
| 201 | printf("\n"); |
Johannes Berg | fb70e11 | 2013-02-14 16:32:53 +0100 | [diff] [blame] | 202 | } |
Zefir Kurtisi | 4b99e6a | 2013-03-26 12:09:49 +0100 | [diff] [blame] | 203 | |
Johannes Berg | fb70e11 | 2013-02-14 16:32:53 +0100 | [diff] [blame] | 204 | } |
| 205 | } |
| 206 | |
| 207 | if (tb_band[NL80211_BAND_ATTR_RATES]) { |
| 208 | printf("\t\tBitrates (non-HT):\n"); |
| 209 | nla_for_each_nested(nl_rate, tb_band[NL80211_BAND_ATTR_RATES], rem_rate) { |
| 210 | nla_parse(tb_rate, NL80211_BITRATE_ATTR_MAX, nla_data(nl_rate), |
| 211 | nla_len(nl_rate), rate_policy); |
| 212 | if (!tb_rate[NL80211_BITRATE_ATTR_RATE]) |
| 213 | continue; |
| 214 | printf("\t\t\t* %2.1f Mbps", 0.1 * nla_get_u32(tb_rate[NL80211_BITRATE_ATTR_RATE])); |
| 215 | open = 0; |
| 216 | if (tb_rate[NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE]) |
| 217 | print_flag("short preamble supported", &open); |
| 218 | if (open) |
| 219 | printf(")"); |
Simon Wunderlich | 48aaf2d | 2013-02-08 18:16:22 +0100 | [diff] [blame] | 220 | printf("\n"); |
| 221 | } |
Johannes Berg | fb70e11 | 2013-02-14 16:32:53 +0100 | [diff] [blame] | 222 | } |
Johannes Berg | 79f99b9 | 2008-01-16 00:21:59 +0100 | [diff] [blame] | 223 | } |
| 224 | } |
| 225 | |
Johannes Berg | 41be37f | 2008-09-19 17:34:55 +0200 | [diff] [blame] | 226 | if (tb_msg[NL80211_ATTR_MAX_NUM_SCAN_SSIDS]) |
| 227 | printf("\tmax # scan SSIDs: %d\n", |
| 228 | nla_get_u8(tb_msg[NL80211_ATTR_MAX_NUM_SCAN_SSIDS])); |
Johannes Berg | f9c112b | 2010-03-24 23:28:03 -0700 | [diff] [blame] | 229 | if (tb_msg[NL80211_ATTR_MAX_SCAN_IE_LEN]) |
| 230 | printf("\tmax scan IEs length: %d bytes\n", |
Johannes Berg | 8eaa9ee | 2010-09-26 09:12:07 +0200 | [diff] [blame] | 231 | nla_get_u16(tb_msg[NL80211_ATTR_MAX_SCAN_IE_LEN])); |
Johannes Berg | 41be37f | 2008-09-19 17:34:55 +0200 | [diff] [blame] | 232 | |
Johannes Berg | 625aa4a | 2009-08-11 11:26:42 +0200 | [diff] [blame] | 233 | if (tb_msg[NL80211_ATTR_WIPHY_FRAG_THRESHOLD]) { |
| 234 | unsigned int frag; |
| 235 | |
| 236 | frag = nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_FRAG_THRESHOLD]); |
| 237 | if (frag != (unsigned int)-1) |
| 238 | printf("\tFragmentation threshold: %d\n", frag); |
| 239 | } |
| 240 | |
| 241 | if (tb_msg[NL80211_ATTR_WIPHY_RTS_THRESHOLD]) { |
| 242 | unsigned int rts; |
| 243 | |
| 244 | rts = nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_RTS_THRESHOLD]); |
| 245 | if (rts != (unsigned int)-1) |
| 246 | printf("\tRTS threshold: %d\n", rts); |
| 247 | } |
| 248 | |
Lukáš Turek | b2f92dd | 2010-02-17 21:13:23 -0500 | [diff] [blame] | 249 | if (tb_msg[NL80211_ATTR_WIPHY_COVERAGE_CLASS]) { |
| 250 | unsigned char coverage; |
| 251 | |
| 252 | coverage = nla_get_u8(tb_msg[NL80211_ATTR_WIPHY_COVERAGE_CLASS]); |
| 253 | /* See handle_distance() for an explanation where the '450' comes from */ |
| 254 | printf("\tCoverage class: %d (up to %dm)\n", coverage, 450 * coverage); |
| 255 | } |
| 256 | |
Johannes Berg | 810e05c | 2011-10-05 17:38:39 +0200 | [diff] [blame] | 257 | if (tb_msg[NL80211_ATTR_CIPHER_SUITES]) { |
| 258 | int num = nla_len(tb_msg[NL80211_ATTR_CIPHER_SUITES]) / sizeof(__u32); |
| 259 | int i; |
| 260 | __u32 *ciphers = nla_data(tb_msg[NL80211_ATTR_CIPHER_SUITES]); |
| 261 | if (num > 0) { |
| 262 | printf("\tSupported Ciphers:\n"); |
| 263 | for (i = 0; i < num; i++) |
| 264 | printf("\t\t* %s\n", |
| 265 | cipher_name(ciphers[i])); |
| 266 | } |
| 267 | } |
| 268 | |
Bruno Randolf | afce798 | 2010-12-22 10:54:39 +0900 | [diff] [blame] | 269 | if (tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX] && |
| 270 | tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX]) |
| 271 | printf("\tAvailable Antennas: TX %#x RX %#x\n", |
| 272 | nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX]), |
| 273 | nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX])); |
| 274 | |
| 275 | if (tb_msg[NL80211_ATTR_WIPHY_ANTENNA_TX] && |
| 276 | tb_msg[NL80211_ATTR_WIPHY_ANTENNA_RX]) |
| 277 | printf("\tConfigured Antennas: TX %#x RX %#x\n", |
| 278 | nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_TX]), |
| 279 | nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_RX])); |
| 280 | |
Johannes Berg | 9a4a14b | 2010-08-24 12:26:56 +0200 | [diff] [blame] | 281 | if (tb_msg[NL80211_ATTR_SUPPORTED_IFTYPES]) { |
| 282 | printf("\tSupported interface modes:\n"); |
| 283 | 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] | 284 | printf("\t\t * %s\n", iftype_name(nla_type(nl_mode))); |
Johannes Berg | 9a4a14b | 2010-08-24 12:26:56 +0200 | [diff] [blame] | 285 | } |
Johannes Berg | 6367e71 | 2008-09-05 23:01:11 +0200 | [diff] [blame] | 286 | |
Johannes Berg | 1c5b4a8 | 2011-05-13 16:53:51 +0200 | [diff] [blame] | 287 | if (tb_msg[NL80211_ATTR_SOFTWARE_IFTYPES]) { |
| 288 | printf("\tsoftware interface modes (can always be added):\n"); |
| 289 | nla_for_each_nested(nl_mode, tb_msg[NL80211_ATTR_SOFTWARE_IFTYPES], rem_mode) |
| 290 | printf("\t\t * %s\n", iftype_name(nla_type(nl_mode))); |
| 291 | } |
| 292 | |
| 293 | if (tb_msg[NL80211_ATTR_INTERFACE_COMBINATIONS]) { |
| 294 | struct nlattr *nl_combi; |
| 295 | int rem_combi; |
Johannes Berg | f5f6f15 | 2011-06-29 13:20:31 +0200 | [diff] [blame] | 296 | bool have_combinations = false; |
Johannes Berg | 1c5b4a8 | 2011-05-13 16:53:51 +0200 | [diff] [blame] | 297 | |
| 298 | nla_for_each_nested(nl_combi, tb_msg[NL80211_ATTR_INTERFACE_COMBINATIONS], rem_combi) { |
| 299 | static struct nla_policy iface_combination_policy[NUM_NL80211_IFACE_COMB] = { |
| 300 | [NL80211_IFACE_COMB_LIMITS] = { .type = NLA_NESTED }, |
| 301 | [NL80211_IFACE_COMB_MAXNUM] = { .type = NLA_U32 }, |
| 302 | [NL80211_IFACE_COMB_STA_AP_BI_MATCH] = { .type = NLA_FLAG }, |
| 303 | [NL80211_IFACE_COMB_NUM_CHANNELS] = { .type = NLA_U32 }, |
Simon Wunderlich | c5df9eb | 2013-02-08 18:16:21 +0100 | [diff] [blame] | 304 | [NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS] = { .type = NLA_U32 }, |
Johannes Berg | 1c5b4a8 | 2011-05-13 16:53:51 +0200 | [diff] [blame] | 305 | }; |
| 306 | struct nlattr *tb_comb[NUM_NL80211_IFACE_COMB]; |
| 307 | static struct nla_policy iface_limit_policy[NUM_NL80211_IFACE_LIMIT] = { |
| 308 | [NL80211_IFACE_LIMIT_TYPES] = { .type = NLA_NESTED }, |
| 309 | [NL80211_IFACE_LIMIT_MAX] = { .type = NLA_U32 }, |
| 310 | }; |
| 311 | struct nlattr *tb_limit[NUM_NL80211_IFACE_LIMIT]; |
| 312 | struct nlattr *nl_limit; |
| 313 | int err, rem_limit; |
| 314 | bool comma = false; |
| 315 | |
Johannes Berg | f5f6f15 | 2011-06-29 13:20:31 +0200 | [diff] [blame] | 316 | if (!have_combinations) { |
| 317 | printf("\tvalid interface combinations:\n"); |
| 318 | have_combinations = true; |
| 319 | } |
| 320 | |
Johannes Berg | 1c5b4a8 | 2011-05-13 16:53:51 +0200 | [diff] [blame] | 321 | printf("\t\t * "); |
| 322 | |
| 323 | err = nla_parse_nested(tb_comb, MAX_NL80211_IFACE_COMB, |
| 324 | nl_combi, iface_combination_policy); |
| 325 | if (err || !tb_comb[NL80211_IFACE_COMB_LIMITS] || |
| 326 | !tb_comb[NL80211_IFACE_COMB_MAXNUM] || |
| 327 | !tb_comb[NL80211_IFACE_COMB_NUM_CHANNELS]) { |
| 328 | printf(" <failed to parse>\n"); |
| 329 | goto broken_combination; |
| 330 | } |
| 331 | |
| 332 | nla_for_each_nested(nl_limit, tb_comb[NL80211_IFACE_COMB_LIMITS], rem_limit) { |
| 333 | bool ift_comma = false; |
| 334 | |
| 335 | err = nla_parse_nested(tb_limit, MAX_NL80211_IFACE_LIMIT, |
| 336 | nl_limit, iface_limit_policy); |
| 337 | if (err || !tb_limit[NL80211_IFACE_LIMIT_TYPES]) { |
| 338 | printf("<failed to parse>\n"); |
| 339 | goto broken_combination; |
| 340 | } |
| 341 | |
| 342 | if (comma) |
| 343 | printf(", "); |
| 344 | comma = true; |
| 345 | printf("#{"); |
| 346 | |
| 347 | nla_for_each_nested(nl_mode, tb_limit[NL80211_IFACE_LIMIT_TYPES], rem_mode) { |
| 348 | printf("%s %s", ift_comma ? "," : "", |
| 349 | iftype_name(nla_type(nl_mode))); |
| 350 | ift_comma = true; |
| 351 | } |
| 352 | printf(" } <= %u", nla_get_u32(tb_limit[NL80211_IFACE_LIMIT_MAX])); |
| 353 | } |
| 354 | printf(",\n\t\t "); |
| 355 | |
Simon Wunderlich | c5df9eb | 2013-02-08 18:16:21 +0100 | [diff] [blame] | 356 | printf("total <= %d, #channels <= %d%s", |
Johannes Berg | 1c5b4a8 | 2011-05-13 16:53:51 +0200 | [diff] [blame] | 357 | nla_get_u32(tb_comb[NL80211_IFACE_COMB_MAXNUM]), |
| 358 | nla_get_u32(tb_comb[NL80211_IFACE_COMB_NUM_CHANNELS]), |
| 359 | tb_comb[NL80211_IFACE_COMB_STA_AP_BI_MATCH] ? |
| 360 | ", STA/AP BI must match" : ""); |
Simon Wunderlich | c5df9eb | 2013-02-08 18:16:21 +0100 | [diff] [blame] | 361 | if (tb_comb[NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS]) { |
| 362 | unsigned long widths = nla_get_u32(tb_comb[NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS]); |
| 363 | |
| 364 | if (widths) { |
| 365 | int width; |
| 366 | bool first = true; |
| 367 | |
| 368 | printf(", radar detect widths: {"); |
| 369 | for (width = 0; width < 32; width++) |
| 370 | if (widths & (1 << width)) { |
| 371 | printf("%s %s", |
| 372 | first ? "":",", |
| 373 | channel_width_name(width)); |
| 374 | first = false; |
| 375 | } |
| 376 | printf(" }\n"); |
| 377 | } |
| 378 | } |
| 379 | printf("\n"); |
Johannes Berg | 1c5b4a8 | 2011-05-13 16:53:51 +0200 | [diff] [blame] | 380 | broken_combination: |
| 381 | ; |
| 382 | } |
Johannes Berg | f5f6f15 | 2011-06-29 13:20:31 +0200 | [diff] [blame] | 383 | |
| 384 | if (!have_combinations) |
| 385 | printf("\tinterface combinations are not supported\n"); |
Johannes Berg | 1c5b4a8 | 2011-05-13 16:53:51 +0200 | [diff] [blame] | 386 | } |
| 387 | |
Johannes Berg | 9a4a14b | 2010-08-24 12:26:56 +0200 | [diff] [blame] | 388 | if (tb_msg[NL80211_ATTR_SUPPORTED_COMMANDS]) { |
| 389 | printf("\tSupported commands:\n"); |
| 390 | nla_for_each_nested(nl_cmd, tb_msg[NL80211_ATTR_SUPPORTED_COMMANDS], rem_cmd) |
| 391 | printf("\t\t * %s\n", command_name(nla_get_u32(nl_cmd))); |
| 392 | } |
Johannes Berg | 6367e71 | 2008-09-05 23:01:11 +0200 | [diff] [blame] | 393 | |
Johannes Berg | 9a4a14b | 2010-08-24 12:26:56 +0200 | [diff] [blame] | 394 | if (tb_msg[NL80211_ATTR_TX_FRAME_TYPES]) { |
| 395 | printf("\tSupported TX frame types:\n"); |
| 396 | nla_for_each_nested(nl_if, tb_msg[NL80211_ATTR_TX_FRAME_TYPES], rem_if) { |
| 397 | bool printed = false; |
| 398 | nla_for_each_nested(nl_ftype, nl_if, rem_ftype) { |
| 399 | if (!printed) |
| 400 | printf("\t\t * %s:", iftype_name(nla_type(nl_if))); |
| 401 | printed = true; |
Johannes Berg | 58e3434 | 2012-03-13 09:48:23 +0100 | [diff] [blame] | 402 | printf(" 0x%.2x", nla_get_u16(nl_ftype)); |
Johannes Berg | 9a4a14b | 2010-08-24 12:26:56 +0200 | [diff] [blame] | 403 | } |
| 404 | if (printed) |
| 405 | printf("\n"); |
| 406 | } |
| 407 | } |
Marcel Holtmann | 9990c1e | 2009-11-14 20:10:21 +0100 | [diff] [blame] | 408 | |
Johannes Berg | 9a4a14b | 2010-08-24 12:26:56 +0200 | [diff] [blame] | 409 | if (tb_msg[NL80211_ATTR_RX_FRAME_TYPES]) { |
| 410 | printf("\tSupported RX frame types:\n"); |
| 411 | nla_for_each_nested(nl_if, tb_msg[NL80211_ATTR_RX_FRAME_TYPES], rem_if) { |
| 412 | bool printed = false; |
| 413 | nla_for_each_nested(nl_ftype, nl_if, rem_ftype) { |
| 414 | if (!printed) |
| 415 | printf("\t\t * %s:", iftype_name(nla_type(nl_if))); |
| 416 | printed = true; |
Johannes Berg | 58e3434 | 2012-03-13 09:48:23 +0100 | [diff] [blame] | 417 | printf(" 0x%.2x", nla_get_u16(nl_ftype)); |
Johannes Berg | 9a4a14b | 2010-08-24 12:26:56 +0200 | [diff] [blame] | 418 | } |
| 419 | if (printed) |
| 420 | printf("\n"); |
| 421 | } |
| 422 | } |
Marcel Holtmann | 9990c1e | 2009-11-14 20:10:21 +0100 | [diff] [blame] | 423 | |
Johannes Berg | 3ff2456 | 2011-04-12 13:04:50 +0200 | [diff] [blame] | 424 | if (tb_msg[NL80211_ATTR_SUPPORT_IBSS_RSN]) |
Johannes Berg | 83f1016 | 2011-02-24 15:11:57 +0100 | [diff] [blame] | 425 | printf("\tDevice supports RSN-IBSS.\n"); |
Johannes Berg | 3ff2456 | 2011-04-12 13:04:50 +0200 | [diff] [blame] | 426 | |
| 427 | if (tb_msg[NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED]) { |
| 428 | struct nlattr *tb_wowlan[NUM_NL80211_WOWLAN_TRIG]; |
| 429 | static struct nla_policy wowlan_policy[NUM_NL80211_WOWLAN_TRIG] = { |
| 430 | [NL80211_WOWLAN_TRIG_ANY] = { .type = NLA_FLAG }, |
| 431 | [NL80211_WOWLAN_TRIG_DISCONNECT] = { .type = NLA_FLAG }, |
| 432 | [NL80211_WOWLAN_TRIG_MAGIC_PKT] = { .type = NLA_FLAG }, |
Amitkumar Karwar | 1c8f49c | 2013-02-19 16:44:44 -0800 | [diff] [blame] | 433 | [NL80211_WOWLAN_TRIG_PKT_PATTERN] = { .minlen = 12 }, |
Johannes Berg | 3a6636b | 2011-07-12 13:08:37 +0200 | [diff] [blame] | 434 | [NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED] = { .type = NLA_FLAG }, |
| 435 | [NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE] = { .type = NLA_FLAG }, |
| 436 | [NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST] = { .type = NLA_FLAG }, |
| 437 | [NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE] = { .type = NLA_FLAG }, |
| 438 | [NL80211_WOWLAN_TRIG_RFKILL_RELEASE] = { .type = NLA_FLAG }, |
Johannes Berg | 819b78c | 2013-02-19 23:31:27 +0100 | [diff] [blame] | 439 | [NL80211_WOWLAN_TRIG_TCP_CONNECTION] = { .type = NLA_NESTED }, |
Johannes Berg | 3ff2456 | 2011-04-12 13:04:50 +0200 | [diff] [blame] | 440 | }; |
Amitkumar Karwar | c82868d | 2013-06-28 12:53:44 -0700 | [diff] [blame] | 441 | struct nl80211_pattern_support *pat; |
Johannes Berg | 3ff2456 | 2011-04-12 13:04:50 +0200 | [diff] [blame] | 442 | int err; |
| 443 | |
| 444 | err = nla_parse_nested(tb_wowlan, MAX_NL80211_WOWLAN_TRIG, |
| 445 | tb_msg[NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED], |
| 446 | wowlan_policy); |
| 447 | printf("\tWoWLAN support:"); |
| 448 | if (err) { |
| 449 | printf(" <failed to parse>\n"); |
| 450 | } else { |
| 451 | printf("\n"); |
| 452 | if (tb_wowlan[NL80211_WOWLAN_TRIG_ANY]) |
Johannes Berg | 3a6636b | 2011-07-12 13:08:37 +0200 | [diff] [blame] | 453 | printf("\t\t * wake up on anything (device continues operating normally)\n"); |
Johannes Berg | 3ff2456 | 2011-04-12 13:04:50 +0200 | [diff] [blame] | 454 | if (tb_wowlan[NL80211_WOWLAN_TRIG_DISCONNECT]) |
Johannes Berg | 3a6636b | 2011-07-12 13:08:37 +0200 | [diff] [blame] | 455 | printf("\t\t * wake up on disconnect\n"); |
Johannes Berg | 3ff2456 | 2011-04-12 13:04:50 +0200 | [diff] [blame] | 456 | if (tb_wowlan[NL80211_WOWLAN_TRIG_MAGIC_PKT]) |
Johannes Berg | 3a6636b | 2011-07-12 13:08:37 +0200 | [diff] [blame] | 457 | printf("\t\t * wake up on magic packet\n"); |
Johannes Berg | 3ff2456 | 2011-04-12 13:04:50 +0200 | [diff] [blame] | 458 | if (tb_wowlan[NL80211_WOWLAN_TRIG_PKT_PATTERN]) { |
| 459 | pat = nla_data(tb_wowlan[NL80211_WOWLAN_TRIG_PKT_PATTERN]); |
Amitkumar Karwar | 1c8f49c | 2013-02-19 16:44:44 -0800 | [diff] [blame] | 460 | printf("\t\t * wake up on pattern match, up to %u patterns of %u-%u bytes,\n" |
| 461 | "\t\t maximum packet offset %u bytes\n", |
| 462 | pat->max_patterns, pat->min_pattern_len, pat->max_pattern_len, |
| 463 | (nla_len(tb_wowlan[NL80211_WOWLAN_TRIG_PKT_PATTERN]) < |
| 464 | sizeof(*pat)) ? 0 : pat->max_pkt_offset); |
Johannes Berg | 3ff2456 | 2011-04-12 13:04:50 +0200 | [diff] [blame] | 465 | } |
Johannes Berg | 3a6636b | 2011-07-12 13:08:37 +0200 | [diff] [blame] | 466 | if (tb_wowlan[NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED]) |
| 467 | printf("\t\t * can do GTK rekeying\n"); |
| 468 | if (tb_wowlan[NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE]) |
| 469 | printf("\t\t * wake up on GTK rekey failure\n"); |
| 470 | if (tb_wowlan[NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST]) |
| 471 | printf("\t\t * wake up on EAP identity request\n"); |
| 472 | if (tb_wowlan[NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE]) |
| 473 | printf("\t\t * wake up on 4-way handshake\n"); |
| 474 | if (tb_wowlan[NL80211_WOWLAN_TRIG_RFKILL_RELEASE]) |
| 475 | printf("\t\t * wake up on rfkill release\n"); |
Johannes Berg | 819b78c | 2013-02-19 23:31:27 +0100 | [diff] [blame] | 476 | if (tb_wowlan[NL80211_WOWLAN_TRIG_TCP_CONNECTION]) |
| 477 | printf("\t\t * wake up on TCP connection\n"); |
Johannes Berg | 3ff2456 | 2011-04-12 13:04:50 +0200 | [diff] [blame] | 478 | } |
Johannes Berg | 83f1016 | 2011-02-24 15:11:57 +0100 | [diff] [blame] | 479 | } |
| 480 | |
Johannes Berg | 2e4f65c | 2011-10-04 14:00:47 +0200 | [diff] [blame] | 481 | if (tb_msg[NL80211_ATTR_ROAM_SUPPORT]) |
| 482 | printf("\tDevice supports roaming.\n"); |
| 483 | |
Johannes Berg | 8b46999 | 2011-11-04 11:53:18 +0100 | [diff] [blame] | 484 | if (tb_msg[NL80211_ATTR_SUPPORT_AP_UAPSD]) |
| 485 | printf("\tDevice supports AP-side u-APSD.\n"); |
| 486 | |
Ben Greear | a82abc2 | 2011-11-28 10:40:22 -0800 | [diff] [blame] | 487 | if (tb_msg[NL80211_ATTR_HT_CAPABILITY_MASK]) { |
| 488 | struct ieee80211_ht_cap *cm; |
| 489 | printf("\tHT Capability overrides:\n"); |
| 490 | if (nla_len(tb_msg[NL80211_ATTR_HT_CAPABILITY_MASK]) >= sizeof(*cm)) { |
| 491 | cm = nla_data(tb_msg[NL80211_ATTR_HT_CAPABILITY_MASK]); |
| 492 | printf("\t\t * MCS: %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx" |
| 493 | " %02hhx %02hhx %02hhx %02hhx\n", |
| 494 | cm->mcs.rx_mask[0], cm->mcs.rx_mask[1], |
| 495 | cm->mcs.rx_mask[2], cm->mcs.rx_mask[3], |
| 496 | cm->mcs.rx_mask[4], cm->mcs.rx_mask[5], |
| 497 | cm->mcs.rx_mask[6], cm->mcs.rx_mask[7], |
| 498 | cm->mcs.rx_mask[8], cm->mcs.rx_mask[9]); |
| 499 | if (cm->cap_info & htole16(IEEE80211_HT_CAP_MAX_AMSDU)) |
| 500 | printf("\t\t * maximum A-MSDU length\n"); |
| 501 | if (cm->cap_info & htole16(IEEE80211_HT_CAP_SUP_WIDTH_20_40)) |
| 502 | printf("\t\t * supported channel width\n"); |
| 503 | if (cm->cap_info & htole16(IEEE80211_HT_CAP_SGI_40)) |
| 504 | printf("\t\t * short GI for 40 MHz\n"); |
| 505 | if (cm->ampdu_params_info & IEEE80211_HT_AMPDU_PARM_FACTOR) |
| 506 | printf("\t\t * max A-MPDU length exponent\n"); |
| 507 | if (cm->ampdu_params_info & IEEE80211_HT_AMPDU_PARM_DENSITY) |
| 508 | printf("\t\t * min MPDU start spacing\n"); |
| 509 | } else { |
| 510 | printf("\tERROR: capabilities mask is too short, expected: %d, received: %d\n", |
| 511 | (int)(sizeof(*cm)), |
| 512 | (int)(nla_len(tb_msg[NL80211_ATTR_HT_CAPABILITY_MASK]))); |
| 513 | } |
| 514 | } |
| 515 | |
Johannes Berg | 632004a | 2011-12-14 15:08:34 +0100 | [diff] [blame] | 516 | if (tb_msg[NL80211_ATTR_FEATURE_FLAGS]) { |
Johannes Berg | d28df6b | 2012-10-16 20:12:37 +0200 | [diff] [blame] | 517 | unsigned int features = nla_get_u32(tb_msg[NL80211_ATTR_FEATURE_FLAGS]); |
| 518 | |
| 519 | if (features & NL80211_FEATURE_SK_TX_STATUS) |
Johannes Berg | 632004a | 2011-12-14 15:08:34 +0100 | [diff] [blame] | 520 | printf("\tDevice supports TX status socket option.\n"); |
Johannes Berg | d28df6b | 2012-10-16 20:12:37 +0200 | [diff] [blame] | 521 | if (features & NL80211_FEATURE_HT_IBSS) |
Johannes Berg | 632004a | 2011-12-14 15:08:34 +0100 | [diff] [blame] | 522 | printf("\tDevice supports HT-IBSS.\n"); |
Johannes Berg | d28df6b | 2012-10-16 20:12:37 +0200 | [diff] [blame] | 523 | if (features & NL80211_FEATURE_INACTIVITY_TIMER) |
| 524 | printf("\tDevice has client inactivity timer.\n"); |
| 525 | if (features & NL80211_FEATURE_CELL_BASE_REG_HINTS) |
| 526 | printf("\tDevice accepts cell base station regulatory hints.\n"); |
| 527 | if (features & NL80211_FEATURE_P2P_DEVICE_NEEDS_CHANNEL) |
| 528 | printf("\tP2P Device uses a channel (of the concurrent ones)\n"); |
Sam Leffler | fe86223 | 2012-10-17 12:20:04 -0700 | [diff] [blame] | 529 | if (features & NL80211_FEATURE_LOW_PRIORITY_SCAN) |
| 530 | printf("\tDevice supports low priority scan.\n"); |
| 531 | if (features & NL80211_FEATURE_SCAN_FLUSH) |
| 532 | printf("\tDevice supports scan flush.\n"); |
Antonio Quartulli | afa2be2 | 2012-10-26 16:41:47 +0200 | [diff] [blame] | 533 | if (features & NL80211_FEATURE_AP_SCAN) |
| 534 | printf("\tDevice supports AP scan.\n"); |
Johannes Berg | 632004a | 2011-12-14 15:08:34 +0100 | [diff] [blame] | 535 | } |
| 536 | |
Amitkumar Karwar | aa0f5db | 2013-06-28 12:53:45 -0700 | [diff] [blame] | 537 | if (tb_msg[NL80211_ATTR_COALESCE_RULE]) { |
| 538 | struct nl80211_coalesce_rule_support *rule; |
| 539 | struct nl80211_pattern_support *pat; |
| 540 | |
| 541 | printf("\tCoalesce support:\n"); |
| 542 | rule = nla_data(tb_msg[NL80211_ATTR_COALESCE_RULE]); |
| 543 | pat = &rule->pat; |
| 544 | printf("\t\t * Maximum %u coalesce rules supported\n" |
| 545 | "\t\t * Each rule contains upto %u patterns of %u-%u bytes,\n" |
| 546 | "\t\t maximum packet offset %u bytes\n" |
| 547 | "\t\t * Maximum supported coalescing delay %u msecs\n", |
| 548 | rule->max_rules, pat->max_patterns, pat->min_pattern_len, |
| 549 | pat->max_pattern_len, pat->max_pkt_offset, rule->max_delay); |
| 550 | } |
| 551 | |
Johannes Berg | 79f99b9 | 2008-01-16 00:21:59 +0100 | [diff] [blame] | 552 | return NL_SKIP; |
| 553 | } |
| 554 | |
Johannes Berg | c142fa2 | 2013-05-02 09:22:58 +0200 | [diff] [blame] | 555 | static bool nl80211_has_split_wiphy = false; |
| 556 | |
Johannes Berg | 7c37a24 | 2009-04-08 13:13:28 +0200 | [diff] [blame] | 557 | static int handle_info(struct nl80211_state *state, |
| 558 | struct nl_cb *cb, |
Johannes Berg | d631650 | 2008-09-16 17:05:33 +0200 | [diff] [blame] | 559 | struct nl_msg *msg, |
Johannes Berg | 05514f9 | 2012-07-19 11:50:50 +0200 | [diff] [blame] | 560 | int argc, char **argv, |
| 561 | enum id_input id) |
Johannes Berg | 79f99b9 | 2008-01-16 00:21:59 +0100 | [diff] [blame] | 562 | { |
Johannes Berg | c142fa2 | 2013-05-02 09:22:58 +0200 | [diff] [blame] | 563 | char *feat_args[] = { "features", "-q" }; |
| 564 | int err; |
| 565 | |
| 566 | err = handle_cmd(state, CIB_NONE, 2, feat_args); |
| 567 | if (!err && nl80211_has_split_wiphy) { |
| 568 | nla_put_flag(msg, NL80211_ATTR_SPLIT_WIPHY_DUMP); |
| 569 | nlmsg_hdr(msg)->nlmsg_flags |= NLM_F_DUMP; |
| 570 | } |
| 571 | |
Johannes Berg | 79f99b9 | 2008-01-16 00:21:59 +0100 | [diff] [blame] | 572 | 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] | 573 | |
Johannes Berg | 70391cc | 2008-09-16 18:35:06 +0200 | [diff] [blame] | 574 | return 0; |
Johannes Berg | 79f99b9 | 2008-01-16 00:21:59 +0100 | [diff] [blame] | 575 | } |
Johannes Berg | c142fa2 | 2013-05-02 09:22:58 +0200 | [diff] [blame] | 576 | __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] | 577 | "Show capabilities for the specified wireless device.", NULL); |
Johannes Berg | ea35fc0 | 2009-05-05 14:56:21 +0200 | [diff] [blame] | 578 | TOPLEVEL(list, NULL, NL80211_CMD_GET_WIPHY, NLM_F_DUMP, CIB_NONE, handle_info, |
| 579 | "List all wireless devices and their capabilities."); |
Johannes Berg | 01ae06f | 2009-05-05 14:48:16 +0200 | [diff] [blame] | 580 | 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] | 581 | |
| 582 | static int handle_commands(struct nl80211_state *state, |
| 583 | struct nl_cb *cb, struct nl_msg *msg, |
| 584 | int argc, char **argv, enum id_input id) |
| 585 | { |
| 586 | int i; |
| 587 | for (i = 1; i < NL80211_CMD_MAX; i++) |
| 588 | printf("%d (0x%x): %s\n", i, i, command_name(i)); |
| 589 | /* don't send netlink messages */ |
| 590 | return 2; |
| 591 | } |
| 592 | TOPLEVEL(commands, NULL, NL80211_CMD_GET_WIPHY, 0, CIB_NONE, handle_commands, |
| 593 | "list all known commands and their decimal & hex value"); |
Johannes Berg | fb70e11 | 2013-02-14 16:32:53 +0100 | [diff] [blame] | 594 | |
| 595 | static int print_feature_handler(struct nl_msg *msg, void *arg) |
| 596 | { |
| 597 | struct nlattr *tb_msg[NL80211_ATTR_MAX + 1]; |
| 598 | struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); |
Johannes Berg | c142fa2 | 2013-05-02 09:22:58 +0200 | [diff] [blame] | 599 | bool print = (unsigned long)arg; |
| 600 | #define maybe_printf(...) do { if (print) printf(__VA_ARGS__); } while (0) |
Johannes Berg | fb70e11 | 2013-02-14 16:32:53 +0100 | [diff] [blame] | 601 | |
| 602 | nla_parse(tb_msg, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), |
| 603 | genlmsg_attrlen(gnlh, 0), NULL); |
| 604 | |
| 605 | if (tb_msg[NL80211_ATTR_PROTOCOL_FEATURES]) { |
| 606 | uint32_t feat = nla_get_u32(tb_msg[NL80211_ATTR_PROTOCOL_FEATURES]); |
| 607 | |
Johannes Berg | c142fa2 | 2013-05-02 09:22:58 +0200 | [diff] [blame] | 608 | maybe_printf("nl80211 features: 0x%x\n", feat); |
| 609 | if (feat & NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP) { |
| 610 | maybe_printf("\t* split wiphy dump\n"); |
| 611 | nl80211_has_split_wiphy = true; |
| 612 | } |
Johannes Berg | fb70e11 | 2013-02-14 16:32:53 +0100 | [diff] [blame] | 613 | } |
| 614 | |
| 615 | return NL_SKIP; |
| 616 | } |
| 617 | |
| 618 | static int handle_features(struct nl80211_state *state, |
| 619 | struct nl_cb *cb, struct nl_msg *msg, |
| 620 | int argc, char **argv, enum id_input id) |
| 621 | { |
Johannes Berg | c142fa2 | 2013-05-02 09:22:58 +0200 | [diff] [blame] | 622 | unsigned long print = argc == 0 || strcmp(argv[0], "-q"); |
| 623 | 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] | 624 | return 0; |
| 625 | } |
| 626 | |
Johannes Berg | c142fa2 | 2013-05-02 09:22:58 +0200 | [diff] [blame] | 627 | TOPLEVEL(features, "", NL80211_CMD_GET_PROTOCOL_FEATURES, 0, CIB_NONE, |
Johannes Berg | fb70e11 | 2013-02-14 16:32:53 +0100 | [diff] [blame] | 628 | handle_features, ""); |