blob: e896eb507b3985963cb0d3dc120682467b46e45b [file] [log] [blame]
Luis R. Rodriguez21878f32009-02-02 15:39:06 -08001#include <stdbool.h>
Johannes Berg79f99b92008-01-16 00:21:59 +01002#include <errno.h>
Johannes Berg2ef1be62008-04-02 17:40:11 +02003#include <net/if.h>
4
Johannes Berg79f99b92008-01-16 00:21:59 +01005#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 Berg79f99b92008-01-16 00:21:59 +010010
Johannes Bergf408e012008-09-18 19:32:11 +020011#include "nl80211.h"
Johannes Berg79f99b92008-01-16 00:21:59 +010012#include "iw.h"
13
14static void print_flag(const char *name, int *open)
15{
16 if (!*open)
17 printf(" (");
18 else
19 printf(", ");
Johannes Berg69283122008-11-23 20:55:23 +010020 printf("%s", name);
Johannes Berg79f99b92008-01-16 00:21:59 +010021 *open = 1;
22}
23
Johannes Berg810e05c2011-10-05 17:38:39 +020024static 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)";
39 case 0x00147201:
40 return "WPI-SMS4 (00-14-72:1)";
41 default:
42 sprintf(buf, "%.2x-%.2x-%.2x:%d",
43 c >> 24, (c >> 16) & 0xff,
44 (c >> 8) & 0xff, c & 0xff);
45
46 return buf;
47 }
48}
49
Johannes Berg79f99b92008-01-16 00:21:59 +010050static int print_phy_handler(struct nl_msg *msg, void *arg)
51{
52 struct nlattr *tb_msg[NL80211_ATTR_MAX + 1];
53 struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
54
55 struct nlattr *tb_band[NL80211_BAND_ATTR_MAX + 1];
56
57 struct nlattr *tb_freq[NL80211_FREQUENCY_ATTR_MAX + 1];
58 static struct nla_policy freq_policy[NL80211_FREQUENCY_ATTR_MAX + 1] = {
59 [NL80211_FREQUENCY_ATTR_FREQ] = { .type = NLA_U32 },
60 [NL80211_FREQUENCY_ATTR_DISABLED] = { .type = NLA_FLAG },
61 [NL80211_FREQUENCY_ATTR_PASSIVE_SCAN] = { .type = NLA_FLAG },
62 [NL80211_FREQUENCY_ATTR_NO_IBSS] = { .type = NLA_FLAG },
63 [NL80211_FREQUENCY_ATTR_RADAR] = { .type = NLA_FLAG },
Johannes Bergc1081c22008-11-23 12:11:26 +010064 [NL80211_FREQUENCY_ATTR_MAX_TX_POWER] = { .type = NLA_U32 },
Johannes Berg79f99b92008-01-16 00:21:59 +010065 };
66
67 struct nlattr *tb_rate[NL80211_BITRATE_ATTR_MAX + 1];
68 static struct nla_policy rate_policy[NL80211_BITRATE_ATTR_MAX + 1] = {
69 [NL80211_BITRATE_ATTR_RATE] = { .type = NLA_U32 },
70 [NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE] = { .type = NLA_FLAG },
71 };
72
73 struct nlattr *nl_band;
74 struct nlattr *nl_freq;
75 struct nlattr *nl_rate;
Johannes Berg6367e712008-09-05 23:01:11 +020076 struct nlattr *nl_mode;
Marcel Holtmann9990c1e2009-11-14 20:10:21 +010077 struct nlattr *nl_cmd;
Johannes Berg9a4a14b2010-08-24 12:26:56 +020078 struct nlattr *nl_if, *nl_ftype;
Johannes Berg79f99b92008-01-16 00:21:59 +010079 int bandidx = 1;
Johannes Berg9a4a14b2010-08-24 12:26:56 +020080 int rem_band, rem_freq, rem_rate, rem_mode, rem_cmd, rem_ftype, rem_if;
Johannes Berg79f99b92008-01-16 00:21:59 +010081 int open;
82
83 nla_parse(tb_msg, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
84 genlmsg_attrlen(gnlh, 0), NULL);
85
86 if (!tb_msg[NL80211_ATTR_WIPHY_BANDS])
87 return NL_SKIP;
88
Johannes Bergd6316502008-09-16 17:05:33 +020089 if (tb_msg[NL80211_ATTR_WIPHY_NAME])
90 printf("Wiphy %s\n", nla_get_string(tb_msg[NL80211_ATTR_WIPHY_NAME]));
91
Johannes Berg79f99b92008-01-16 00:21:59 +010092 nla_for_each_nested(nl_band, tb_msg[NL80211_ATTR_WIPHY_BANDS], rem_band) {
Johannes Bergd6316502008-09-16 17:05:33 +020093 printf("\tBand %d:\n", bandidx);
Johannes Berg79f99b92008-01-16 00:21:59 +010094 bandidx++;
95
96 nla_parse(tb_band, NL80211_BAND_ATTR_MAX, nla_data(nl_band),
97 nla_len(nl_band), NULL);
98
Johannes Berg3dd781c2008-10-14 18:46:23 +020099#ifdef NL80211_BAND_ATTR_HT_CAPA
100 if (tb_band[NL80211_BAND_ATTR_HT_CAPA]) {
Luis R. Rodriguez357c1a52009-12-07 22:05:42 -0500101 __u16 cap = nla_get_u16(tb_band[NL80211_BAND_ATTR_HT_CAPA]);
102 print_ht_capability(cap);
Johannes Berg3dd781c2008-10-14 18:46:23 +0200103 }
104 if (tb_band[NL80211_BAND_ATTR_HT_AMPDU_FACTOR]) {
Luis R. Rodriguez09509932009-12-07 22:05:18 -0500105 __u8 exponent = nla_get_u8(tb_band[NL80211_BAND_ATTR_HT_AMPDU_FACTOR]);
106 print_ampdu_length(exponent);
Johannes Berg3dd781c2008-10-14 18:46:23 +0200107 }
108 if (tb_band[NL80211_BAND_ATTR_HT_AMPDU_DENSITY]) {
Luis R. Rodriguez09509932009-12-07 22:05:18 -0500109 __u8 spacing = nla_get_u8(tb_band[NL80211_BAND_ATTR_HT_AMPDU_DENSITY]);
110 print_ampdu_spacing(spacing);
Johannes Berg3dd781c2008-10-14 18:46:23 +0200111 }
112 if (tb_band[NL80211_BAND_ATTR_HT_MCS_SET] &&
Johannes Berg7ddfb672009-12-08 10:11:22 +0100113 nla_len(tb_band[NL80211_BAND_ATTR_HT_MCS_SET]) == 16)
114 print_ht_mcs(nla_data(tb_band[NL80211_BAND_ATTR_HT_MCS_SET]));
Johannes Berg3dd781c2008-10-14 18:46:23 +0200115#endif
116
Johannes Bergd6316502008-09-16 17:05:33 +0200117 printf("\t\tFrequencies:\n");
Johannes Berg79f99b92008-01-16 00:21:59 +0100118
119 nla_for_each_nested(nl_freq, tb_band[NL80211_BAND_ATTR_FREQS], rem_freq) {
Johannes Berg379f8392008-12-08 12:53:58 +0100120 uint32_t freq;
Johannes Berg79f99b92008-01-16 00:21:59 +0100121 nla_parse(tb_freq, NL80211_FREQUENCY_ATTR_MAX, nla_data(nl_freq),
122 nla_len(nl_freq), freq_policy);
123 if (!tb_freq[NL80211_FREQUENCY_ATTR_FREQ])
124 continue;
Johannes Berg379f8392008-12-08 12:53:58 +0100125 freq = nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_FREQ]);
126 printf("\t\t\t* %d MHz [%d]", freq, ieee80211_frequency_to_channel(freq));
Johannes Bergc1081c22008-11-23 12:11:26 +0100127
Johannes Bergd102c0b2009-03-24 08:41:42 +0100128 if (tb_freq[NL80211_FREQUENCY_ATTR_MAX_TX_POWER] &&
129 !tb_freq[NL80211_FREQUENCY_ATTR_DISABLED])
130 printf(" (%.1f dBm)", 0.01 * nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_MAX_TX_POWER]));
Johannes Bergc1081c22008-11-23 12:11:26 +0100131
Johannes Berg79f99b92008-01-16 00:21:59 +0100132 open = 0;
Johannes Bergee9cd982009-01-18 18:13:54 +0100133 if (tb_freq[NL80211_FREQUENCY_ATTR_DISABLED]) {
Johannes Berg79f99b92008-01-16 00:21:59 +0100134 print_flag("disabled", &open);
Johannes Bergee9cd982009-01-18 18:13:54 +0100135 goto next;
136 }
Johannes Berg79f99b92008-01-16 00:21:59 +0100137 if (tb_freq[NL80211_FREQUENCY_ATTR_PASSIVE_SCAN])
138 print_flag("passive scanning", &open);
139 if (tb_freq[NL80211_FREQUENCY_ATTR_NO_IBSS])
140 print_flag("no IBSS", &open);
141 if (tb_freq[NL80211_FREQUENCY_ATTR_RADAR])
142 print_flag("radar detection", &open);
Johannes Bergee9cd982009-01-18 18:13:54 +0100143 next:
Johannes Berg79f99b92008-01-16 00:21:59 +0100144 if (open)
145 printf(")");
146 printf("\n");
147 }
148
Johannes Berg75dddcc2009-06-30 10:16:43 +0200149 printf("\t\tBitrates (non-HT):\n");
Johannes Berg79f99b92008-01-16 00:21:59 +0100150
151 nla_for_each_nested(nl_rate, tb_band[NL80211_BAND_ATTR_RATES], rem_rate) {
152 nla_parse(tb_rate, NL80211_BITRATE_ATTR_MAX, nla_data(nl_rate),
153 nla_len(nl_rate), rate_policy);
154 if (!tb_rate[NL80211_BITRATE_ATTR_RATE])
155 continue;
Johannes Bergd6316502008-09-16 17:05:33 +0200156 printf("\t\t\t* %2.1f Mbps", 0.1 * nla_get_u32(tb_rate[NL80211_BITRATE_ATTR_RATE]));
Johannes Berg79f99b92008-01-16 00:21:59 +0100157 open = 0;
158 if (tb_rate[NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE])
159 print_flag("short preamble supported", &open);
160 if (open)
161 printf(")");
162 printf("\n");
163 }
164 }
165
Johannes Berg41be37f2008-09-19 17:34:55 +0200166 if (tb_msg[NL80211_ATTR_MAX_NUM_SCAN_SSIDS])
167 printf("\tmax # scan SSIDs: %d\n",
168 nla_get_u8(tb_msg[NL80211_ATTR_MAX_NUM_SCAN_SSIDS]));
Johannes Bergf9c112b2010-03-24 23:28:03 -0700169 if (tb_msg[NL80211_ATTR_MAX_SCAN_IE_LEN])
170 printf("\tmax scan IEs length: %d bytes\n",
Johannes Berg8eaa9ee2010-09-26 09:12:07 +0200171 nla_get_u16(tb_msg[NL80211_ATTR_MAX_SCAN_IE_LEN]));
Johannes Berg41be37f2008-09-19 17:34:55 +0200172
Johannes Berg625aa4a2009-08-11 11:26:42 +0200173 if (tb_msg[NL80211_ATTR_WIPHY_FRAG_THRESHOLD]) {
174 unsigned int frag;
175
176 frag = nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_FRAG_THRESHOLD]);
177 if (frag != (unsigned int)-1)
178 printf("\tFragmentation threshold: %d\n", frag);
179 }
180
181 if (tb_msg[NL80211_ATTR_WIPHY_RTS_THRESHOLD]) {
182 unsigned int rts;
183
184 rts = nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_RTS_THRESHOLD]);
185 if (rts != (unsigned int)-1)
186 printf("\tRTS threshold: %d\n", rts);
187 }
188
Lukáš Turekb2f92dd2010-02-17 21:13:23 -0500189 if (tb_msg[NL80211_ATTR_WIPHY_COVERAGE_CLASS]) {
190 unsigned char coverage;
191
192 coverage = nla_get_u8(tb_msg[NL80211_ATTR_WIPHY_COVERAGE_CLASS]);
193 /* See handle_distance() for an explanation where the '450' comes from */
194 printf("\tCoverage class: %d (up to %dm)\n", coverage, 450 * coverage);
195 }
196
Johannes Berg810e05c2011-10-05 17:38:39 +0200197 if (tb_msg[NL80211_ATTR_CIPHER_SUITES]) {
198 int num = nla_len(tb_msg[NL80211_ATTR_CIPHER_SUITES]) / sizeof(__u32);
199 int i;
200 __u32 *ciphers = nla_data(tb_msg[NL80211_ATTR_CIPHER_SUITES]);
201 if (num > 0) {
202 printf("\tSupported Ciphers:\n");
203 for (i = 0; i < num; i++)
204 printf("\t\t* %s\n",
205 cipher_name(ciphers[i]));
206 }
207 }
208
Bruno Randolfafce7982010-12-22 10:54:39 +0900209 if (tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX] &&
210 tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX])
211 printf("\tAvailable Antennas: TX %#x RX %#x\n",
212 nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX]),
213 nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX]));
214
215 if (tb_msg[NL80211_ATTR_WIPHY_ANTENNA_TX] &&
216 tb_msg[NL80211_ATTR_WIPHY_ANTENNA_RX])
217 printf("\tConfigured Antennas: TX %#x RX %#x\n",
218 nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_TX]),
219 nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_RX]));
220
Johannes Berg9a4a14b2010-08-24 12:26:56 +0200221 if (tb_msg[NL80211_ATTR_SUPPORTED_IFTYPES]) {
222 printf("\tSupported interface modes:\n");
223 nla_for_each_nested(nl_mode, tb_msg[NL80211_ATTR_SUPPORTED_IFTYPES], rem_mode)
Johannes Berg8ef6df42011-02-21 22:12:54 +0100224 printf("\t\t * %s\n", iftype_name(nla_type(nl_mode)));
Johannes Berg9a4a14b2010-08-24 12:26:56 +0200225 }
Johannes Berg6367e712008-09-05 23:01:11 +0200226
Johannes Berg1c5b4a82011-05-13 16:53:51 +0200227 if (tb_msg[NL80211_ATTR_SOFTWARE_IFTYPES]) {
228 printf("\tsoftware interface modes (can always be added):\n");
229 nla_for_each_nested(nl_mode, tb_msg[NL80211_ATTR_SOFTWARE_IFTYPES], rem_mode)
230 printf("\t\t * %s\n", iftype_name(nla_type(nl_mode)));
231 }
232
233 if (tb_msg[NL80211_ATTR_INTERFACE_COMBINATIONS]) {
234 struct nlattr *nl_combi;
235 int rem_combi;
Johannes Bergf5f6f152011-06-29 13:20:31 +0200236 bool have_combinations = false;
Johannes Berg1c5b4a82011-05-13 16:53:51 +0200237
238 nla_for_each_nested(nl_combi, tb_msg[NL80211_ATTR_INTERFACE_COMBINATIONS], rem_combi) {
239 static struct nla_policy iface_combination_policy[NUM_NL80211_IFACE_COMB] = {
240 [NL80211_IFACE_COMB_LIMITS] = { .type = NLA_NESTED },
241 [NL80211_IFACE_COMB_MAXNUM] = { .type = NLA_U32 },
242 [NL80211_IFACE_COMB_STA_AP_BI_MATCH] = { .type = NLA_FLAG },
243 [NL80211_IFACE_COMB_NUM_CHANNELS] = { .type = NLA_U32 },
244 };
245 struct nlattr *tb_comb[NUM_NL80211_IFACE_COMB];
246 static struct nla_policy iface_limit_policy[NUM_NL80211_IFACE_LIMIT] = {
247 [NL80211_IFACE_LIMIT_TYPES] = { .type = NLA_NESTED },
248 [NL80211_IFACE_LIMIT_MAX] = { .type = NLA_U32 },
249 };
250 struct nlattr *tb_limit[NUM_NL80211_IFACE_LIMIT];
251 struct nlattr *nl_limit;
252 int err, rem_limit;
253 bool comma = false;
254
Johannes Bergf5f6f152011-06-29 13:20:31 +0200255 if (!have_combinations) {
256 printf("\tvalid interface combinations:\n");
257 have_combinations = true;
258 }
259
Johannes Berg1c5b4a82011-05-13 16:53:51 +0200260 printf("\t\t * ");
261
262 err = nla_parse_nested(tb_comb, MAX_NL80211_IFACE_COMB,
263 nl_combi, iface_combination_policy);
264 if (err || !tb_comb[NL80211_IFACE_COMB_LIMITS] ||
265 !tb_comb[NL80211_IFACE_COMB_MAXNUM] ||
266 !tb_comb[NL80211_IFACE_COMB_NUM_CHANNELS]) {
267 printf(" <failed to parse>\n");
268 goto broken_combination;
269 }
270
271 nla_for_each_nested(nl_limit, tb_comb[NL80211_IFACE_COMB_LIMITS], rem_limit) {
272 bool ift_comma = false;
273
274 err = nla_parse_nested(tb_limit, MAX_NL80211_IFACE_LIMIT,
275 nl_limit, iface_limit_policy);
276 if (err || !tb_limit[NL80211_IFACE_LIMIT_TYPES]) {
277 printf("<failed to parse>\n");
278 goto broken_combination;
279 }
280
281 if (comma)
282 printf(", ");
283 comma = true;
284 printf("#{");
285
286 nla_for_each_nested(nl_mode, tb_limit[NL80211_IFACE_LIMIT_TYPES], rem_mode) {
287 printf("%s %s", ift_comma ? "," : "",
288 iftype_name(nla_type(nl_mode)));
289 ift_comma = true;
290 }
291 printf(" } <= %u", nla_get_u32(tb_limit[NL80211_IFACE_LIMIT_MAX]));
292 }
293 printf(",\n\t\t ");
294
295 printf("total <= %d, #channels <= %d%s\n",
296 nla_get_u32(tb_comb[NL80211_IFACE_COMB_MAXNUM]),
297 nla_get_u32(tb_comb[NL80211_IFACE_COMB_NUM_CHANNELS]),
298 tb_comb[NL80211_IFACE_COMB_STA_AP_BI_MATCH] ?
299 ", STA/AP BI must match" : "");
300broken_combination:
301 ;
302 }
Johannes Bergf5f6f152011-06-29 13:20:31 +0200303
304 if (!have_combinations)
305 printf("\tinterface combinations are not supported\n");
Johannes Berg1c5b4a82011-05-13 16:53:51 +0200306 }
307
Johannes Berg9a4a14b2010-08-24 12:26:56 +0200308 if (tb_msg[NL80211_ATTR_SUPPORTED_COMMANDS]) {
309 printf("\tSupported commands:\n");
310 nla_for_each_nested(nl_cmd, tb_msg[NL80211_ATTR_SUPPORTED_COMMANDS], rem_cmd)
311 printf("\t\t * %s\n", command_name(nla_get_u32(nl_cmd)));
312 }
Johannes Berg6367e712008-09-05 23:01:11 +0200313
Johannes Berg9a4a14b2010-08-24 12:26:56 +0200314 if (tb_msg[NL80211_ATTR_TX_FRAME_TYPES]) {
315 printf("\tSupported TX frame types:\n");
316 nla_for_each_nested(nl_if, tb_msg[NL80211_ATTR_TX_FRAME_TYPES], rem_if) {
317 bool printed = false;
318 nla_for_each_nested(nl_ftype, nl_if, rem_ftype) {
319 if (!printed)
320 printf("\t\t * %s:", iftype_name(nla_type(nl_if)));
321 printed = true;
Johannes Berg58e34342012-03-13 09:48:23 +0100322 printf(" 0x%.2x", nla_get_u16(nl_ftype));
Johannes Berg9a4a14b2010-08-24 12:26:56 +0200323 }
324 if (printed)
325 printf("\n");
326 }
327 }
Marcel Holtmann9990c1e2009-11-14 20:10:21 +0100328
Johannes Berg9a4a14b2010-08-24 12:26:56 +0200329 if (tb_msg[NL80211_ATTR_RX_FRAME_TYPES]) {
330 printf("\tSupported RX frame types:\n");
331 nla_for_each_nested(nl_if, tb_msg[NL80211_ATTR_RX_FRAME_TYPES], rem_if) {
332 bool printed = false;
333 nla_for_each_nested(nl_ftype, nl_if, rem_ftype) {
334 if (!printed)
335 printf("\t\t * %s:", iftype_name(nla_type(nl_if)));
336 printed = true;
Johannes Berg58e34342012-03-13 09:48:23 +0100337 printf(" 0x%.2x", nla_get_u16(nl_ftype));
Johannes Berg9a4a14b2010-08-24 12:26:56 +0200338 }
339 if (printed)
340 printf("\n");
341 }
342 }
Marcel Holtmann9990c1e2009-11-14 20:10:21 +0100343
Johannes Berg3ff24562011-04-12 13:04:50 +0200344 if (tb_msg[NL80211_ATTR_SUPPORT_IBSS_RSN])
Johannes Berg83f10162011-02-24 15:11:57 +0100345 printf("\tDevice supports RSN-IBSS.\n");
Johannes Berg3ff24562011-04-12 13:04:50 +0200346
347 if (tb_msg[NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED]) {
348 struct nlattr *tb_wowlan[NUM_NL80211_WOWLAN_TRIG];
349 static struct nla_policy wowlan_policy[NUM_NL80211_WOWLAN_TRIG] = {
350 [NL80211_WOWLAN_TRIG_ANY] = { .type = NLA_FLAG },
351 [NL80211_WOWLAN_TRIG_DISCONNECT] = { .type = NLA_FLAG },
352 [NL80211_WOWLAN_TRIG_MAGIC_PKT] = { .type = NLA_FLAG },
353 [NL80211_WOWLAN_TRIG_PKT_PATTERN] = {
354 .minlen = sizeof(struct nl80211_wowlan_pattern_support),
355 },
Johannes Berg3a6636b2011-07-12 13:08:37 +0200356 [NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED] = { .type = NLA_FLAG },
357 [NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE] = { .type = NLA_FLAG },
358 [NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST] = { .type = NLA_FLAG },
359 [NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE] = { .type = NLA_FLAG },
360 [NL80211_WOWLAN_TRIG_RFKILL_RELEASE] = { .type = NLA_FLAG },
Johannes Berg3ff24562011-04-12 13:04:50 +0200361 };
362 struct nl80211_wowlan_pattern_support *pat;
363 int err;
364
365 err = nla_parse_nested(tb_wowlan, MAX_NL80211_WOWLAN_TRIG,
366 tb_msg[NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED],
367 wowlan_policy);
368 printf("\tWoWLAN support:");
369 if (err) {
370 printf(" <failed to parse>\n");
371 } else {
372 printf("\n");
373 if (tb_wowlan[NL80211_WOWLAN_TRIG_ANY])
Johannes Berg3a6636b2011-07-12 13:08:37 +0200374 printf("\t\t * wake up on anything (device continues operating normally)\n");
Johannes Berg3ff24562011-04-12 13:04:50 +0200375 if (tb_wowlan[NL80211_WOWLAN_TRIG_DISCONNECT])
Johannes Berg3a6636b2011-07-12 13:08:37 +0200376 printf("\t\t * wake up on disconnect\n");
Johannes Berg3ff24562011-04-12 13:04:50 +0200377 if (tb_wowlan[NL80211_WOWLAN_TRIG_MAGIC_PKT])
Johannes Berg3a6636b2011-07-12 13:08:37 +0200378 printf("\t\t * wake up on magic packet\n");
Johannes Berg3ff24562011-04-12 13:04:50 +0200379 if (tb_wowlan[NL80211_WOWLAN_TRIG_PKT_PATTERN]) {
380 pat = nla_data(tb_wowlan[NL80211_WOWLAN_TRIG_PKT_PATTERN]);
Johannes Berg3a6636b2011-07-12 13:08:37 +0200381 printf("\t\t * wake up on pattern match, up to %u patterns of %u-%u bytes\n",
Johannes Berg3ff24562011-04-12 13:04:50 +0200382 pat->max_patterns, pat->min_pattern_len, pat->max_pattern_len);
383 }
Johannes Berg3a6636b2011-07-12 13:08:37 +0200384 if (tb_wowlan[NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED])
385 printf("\t\t * can do GTK rekeying\n");
386 if (tb_wowlan[NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE])
387 printf("\t\t * wake up on GTK rekey failure\n");
388 if (tb_wowlan[NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST])
389 printf("\t\t * wake up on EAP identity request\n");
390 if (tb_wowlan[NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE])
391 printf("\t\t * wake up on 4-way handshake\n");
392 if (tb_wowlan[NL80211_WOWLAN_TRIG_RFKILL_RELEASE])
393 printf("\t\t * wake up on rfkill release\n");
Johannes Berg3ff24562011-04-12 13:04:50 +0200394 }
Johannes Berg83f10162011-02-24 15:11:57 +0100395 }
396
Johannes Berg2e4f65c2011-10-04 14:00:47 +0200397 if (tb_msg[NL80211_ATTR_ROAM_SUPPORT])
398 printf("\tDevice supports roaming.\n");
399
Johannes Berg8b469992011-11-04 11:53:18 +0100400 if (tb_msg[NL80211_ATTR_SUPPORT_AP_UAPSD])
401 printf("\tDevice supports AP-side u-APSD.\n");
402
Ben Greeara82abc22011-11-28 10:40:22 -0800403 if (tb_msg[NL80211_ATTR_HT_CAPABILITY_MASK]) {
404 struct ieee80211_ht_cap *cm;
405 printf("\tHT Capability overrides:\n");
406 if (nla_len(tb_msg[NL80211_ATTR_HT_CAPABILITY_MASK]) >= sizeof(*cm)) {
407 cm = nla_data(tb_msg[NL80211_ATTR_HT_CAPABILITY_MASK]);
408 printf("\t\t * MCS: %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx"
409 " %02hhx %02hhx %02hhx %02hhx\n",
410 cm->mcs.rx_mask[0], cm->mcs.rx_mask[1],
411 cm->mcs.rx_mask[2], cm->mcs.rx_mask[3],
412 cm->mcs.rx_mask[4], cm->mcs.rx_mask[5],
413 cm->mcs.rx_mask[6], cm->mcs.rx_mask[7],
414 cm->mcs.rx_mask[8], cm->mcs.rx_mask[9]);
415 if (cm->cap_info & htole16(IEEE80211_HT_CAP_MAX_AMSDU))
416 printf("\t\t * maximum A-MSDU length\n");
417 if (cm->cap_info & htole16(IEEE80211_HT_CAP_SUP_WIDTH_20_40))
418 printf("\t\t * supported channel width\n");
419 if (cm->cap_info & htole16(IEEE80211_HT_CAP_SGI_40))
420 printf("\t\t * short GI for 40 MHz\n");
421 if (cm->ampdu_params_info & IEEE80211_HT_AMPDU_PARM_FACTOR)
422 printf("\t\t * max A-MPDU length exponent\n");
423 if (cm->ampdu_params_info & IEEE80211_HT_AMPDU_PARM_DENSITY)
424 printf("\t\t * min MPDU start spacing\n");
425 } else {
426 printf("\tERROR: capabilities mask is too short, expected: %d, received: %d\n",
427 (int)(sizeof(*cm)),
428 (int)(nla_len(tb_msg[NL80211_ATTR_HT_CAPABILITY_MASK])));
429 }
430 }
431
Johannes Berg632004a2011-12-14 15:08:34 +0100432 if (tb_msg[NL80211_ATTR_FEATURE_FLAGS]) {
433 if (nla_get_u32(tb_msg[NL80211_ATTR_FEATURE_FLAGS]) &
434 NL80211_FEATURE_SK_TX_STATUS)
435 printf("\tDevice supports TX status socket option.\n");
436 if (nla_get_u32(tb_msg[NL80211_ATTR_FEATURE_FLAGS]) &
437 NL80211_FEATURE_HT_IBSS)
438 printf("\tDevice supports HT-IBSS.\n");
439 }
440
Johannes Berg79f99b92008-01-16 00:21:59 +0100441 return NL_SKIP;
442}
443
Johannes Berg7c37a242009-04-08 13:13:28 +0200444static int handle_info(struct nl80211_state *state,
445 struct nl_cb *cb,
Johannes Bergd6316502008-09-16 17:05:33 +0200446 struct nl_msg *msg,
447 int argc, char **argv)
Johannes Berg79f99b92008-01-16 00:21:59 +0100448{
Johannes Berg79f99b92008-01-16 00:21:59 +0100449 nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_phy_handler, NULL);
Johannes Berg79f99b92008-01-16 00:21:59 +0100450
Johannes Berg70391cc2008-09-16 18:35:06 +0200451 return 0;
Johannes Berg79f99b92008-01-16 00:21:59 +0100452}
Johannes Berg4698bfc2009-08-24 12:53:34 +0200453__COMMAND(NULL, info, "info", NULL, NL80211_CMD_GET_WIPHY, 0, 0, CIB_PHY, handle_info,
Johannes Berg1633ddf2010-11-24 08:16:47 +0100454 "Show capabilities for the specified wireless device.", NULL);
Johannes Bergea35fc02009-05-05 14:56:21 +0200455TOPLEVEL(list, NULL, NL80211_CMD_GET_WIPHY, NLM_F_DUMP, CIB_NONE, handle_info,
456 "List all wireless devices and their capabilities.");
Johannes Berg01ae06f2009-05-05 14:48:16 +0200457TOPLEVEL(phy, NULL, NL80211_CMD_GET_WIPHY, NLM_F_DUMP, CIB_NONE, handle_info, NULL);