]>
Commit | Line | Data |
---|---|---|
1 | #include <stdbool.h> | |
2 | #include <errno.h> | |
3 | #include <net/if.h> | |
4 | ||
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> | |
10 | ||
11 | #include "nl80211.h" | |
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(", "); | |
20 | printf("%s", name); | |
21 | *open = 1; | |
22 | } | |
23 | ||
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)"; | |
39 | case 0x000fac08: | |
40 | return "GCMP (00-0f-ac:8)"; | |
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 | ||
52 | static int print_phy_handler(struct nl_msg *msg, void *arg) | |
53 | { | |
54 | struct nlattr *tb_msg[NL80211_ATTR_MAX + 1]; | |
55 | struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); | |
56 | ||
57 | struct nlattr *tb_band[NL80211_BAND_ATTR_MAX + 1]; | |
58 | ||
59 | struct nlattr *tb_freq[NL80211_FREQUENCY_ATTR_MAX + 1]; | |
60 | static struct nla_policy freq_policy[NL80211_FREQUENCY_ATTR_MAX + 1] = { | |
61 | [NL80211_FREQUENCY_ATTR_FREQ] = { .type = NLA_U32 }, | |
62 | [NL80211_FREQUENCY_ATTR_DISABLED] = { .type = NLA_FLAG }, | |
63 | [NL80211_FREQUENCY_ATTR_PASSIVE_SCAN] = { .type = NLA_FLAG }, | |
64 | [NL80211_FREQUENCY_ATTR_NO_IBSS] = { .type = NLA_FLAG }, | |
65 | [NL80211_FREQUENCY_ATTR_RADAR] = { .type = NLA_FLAG }, | |
66 | [NL80211_FREQUENCY_ATTR_MAX_TX_POWER] = { .type = NLA_U32 }, | |
67 | }; | |
68 | ||
69 | struct nlattr *tb_rate[NL80211_BITRATE_ATTR_MAX + 1]; | |
70 | static struct nla_policy rate_policy[NL80211_BITRATE_ATTR_MAX + 1] = { | |
71 | [NL80211_BITRATE_ATTR_RATE] = { .type = NLA_U32 }, | |
72 | [NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE] = { .type = NLA_FLAG }, | |
73 | }; | |
74 | ||
75 | struct nlattr *nl_band; | |
76 | struct nlattr *nl_freq; | |
77 | struct nlattr *nl_rate; | |
78 | struct nlattr *nl_mode; | |
79 | struct nlattr *nl_cmd; | |
80 | struct nlattr *nl_if, *nl_ftype; | |
81 | int bandidx = 1; | |
82 | int rem_band, rem_freq, rem_rate, rem_mode, rem_cmd, rem_ftype, rem_if; | |
83 | int open; | |
84 | ||
85 | nla_parse(tb_msg, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), | |
86 | genlmsg_attrlen(gnlh, 0), NULL); | |
87 | ||
88 | if (!tb_msg[NL80211_ATTR_WIPHY_BANDS]) | |
89 | return NL_SKIP; | |
90 | ||
91 | if (tb_msg[NL80211_ATTR_WIPHY_NAME]) | |
92 | printf("Wiphy %s\n", nla_get_string(tb_msg[NL80211_ATTR_WIPHY_NAME])); | |
93 | ||
94 | nla_for_each_nested(nl_band, tb_msg[NL80211_ATTR_WIPHY_BANDS], rem_band) { | |
95 | printf("\tBand %d:\n", bandidx); | |
96 | bandidx++; | |
97 | ||
98 | nla_parse(tb_band, NL80211_BAND_ATTR_MAX, nla_data(nl_band), | |
99 | nla_len(nl_band), NULL); | |
100 | ||
101 | #ifdef NL80211_BAND_ATTR_HT_CAPA | |
102 | if (tb_band[NL80211_BAND_ATTR_HT_CAPA]) { | |
103 | __u16 cap = nla_get_u16(tb_band[NL80211_BAND_ATTR_HT_CAPA]); | |
104 | print_ht_capability(cap); | |
105 | } | |
106 | if (tb_band[NL80211_BAND_ATTR_HT_AMPDU_FACTOR]) { | |
107 | __u8 exponent = nla_get_u8(tb_band[NL80211_BAND_ATTR_HT_AMPDU_FACTOR]); | |
108 | print_ampdu_length(exponent); | |
109 | } | |
110 | if (tb_band[NL80211_BAND_ATTR_HT_AMPDU_DENSITY]) { | |
111 | __u8 spacing = nla_get_u8(tb_band[NL80211_BAND_ATTR_HT_AMPDU_DENSITY]); | |
112 | print_ampdu_spacing(spacing); | |
113 | } | |
114 | if (tb_band[NL80211_BAND_ATTR_HT_MCS_SET] && | |
115 | nla_len(tb_band[NL80211_BAND_ATTR_HT_MCS_SET]) == 16) | |
116 | print_ht_mcs(nla_data(tb_band[NL80211_BAND_ATTR_HT_MCS_SET])); | |
117 | #endif | |
118 | ||
119 | printf("\t\tFrequencies:\n"); | |
120 | ||
121 | nla_for_each_nested(nl_freq, tb_band[NL80211_BAND_ATTR_FREQS], rem_freq) { | |
122 | uint32_t freq; | |
123 | nla_parse(tb_freq, NL80211_FREQUENCY_ATTR_MAX, nla_data(nl_freq), | |
124 | nla_len(nl_freq), freq_policy); | |
125 | if (!tb_freq[NL80211_FREQUENCY_ATTR_FREQ]) | |
126 | continue; | |
127 | freq = nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_FREQ]); | |
128 | printf("\t\t\t* %d MHz [%d]", freq, ieee80211_frequency_to_channel(freq)); | |
129 | ||
130 | if (tb_freq[NL80211_FREQUENCY_ATTR_MAX_TX_POWER] && | |
131 | !tb_freq[NL80211_FREQUENCY_ATTR_DISABLED]) | |
132 | printf(" (%.1f dBm)", 0.01 * nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_MAX_TX_POWER])); | |
133 | ||
134 | open = 0; | |
135 | if (tb_freq[NL80211_FREQUENCY_ATTR_DISABLED]) { | |
136 | print_flag("disabled", &open); | |
137 | goto next; | |
138 | } | |
139 | if (tb_freq[NL80211_FREQUENCY_ATTR_PASSIVE_SCAN]) | |
140 | print_flag("passive scanning", &open); | |
141 | if (tb_freq[NL80211_FREQUENCY_ATTR_NO_IBSS]) | |
142 | print_flag("no IBSS", &open); | |
143 | if (tb_freq[NL80211_FREQUENCY_ATTR_RADAR]) | |
144 | print_flag("radar detection", &open); | |
145 | next: | |
146 | if (open) | |
147 | printf(")"); | |
148 | printf("\n"); | |
149 | } | |
150 | ||
151 | printf("\t\tBitrates (non-HT):\n"); | |
152 | ||
153 | nla_for_each_nested(nl_rate, tb_band[NL80211_BAND_ATTR_RATES], rem_rate) { | |
154 | nla_parse(tb_rate, NL80211_BITRATE_ATTR_MAX, nla_data(nl_rate), | |
155 | nla_len(nl_rate), rate_policy); | |
156 | if (!tb_rate[NL80211_BITRATE_ATTR_RATE]) | |
157 | continue; | |
158 | printf("\t\t\t* %2.1f Mbps", 0.1 * nla_get_u32(tb_rate[NL80211_BITRATE_ATTR_RATE])); | |
159 | open = 0; | |
160 | if (tb_rate[NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE]) | |
161 | print_flag("short preamble supported", &open); | |
162 | if (open) | |
163 | printf(")"); | |
164 | printf("\n"); | |
165 | } | |
166 | } | |
167 | ||
168 | if (tb_msg[NL80211_ATTR_MAX_NUM_SCAN_SSIDS]) | |
169 | printf("\tmax # scan SSIDs: %d\n", | |
170 | nla_get_u8(tb_msg[NL80211_ATTR_MAX_NUM_SCAN_SSIDS])); | |
171 | if (tb_msg[NL80211_ATTR_MAX_SCAN_IE_LEN]) | |
172 | printf("\tmax scan IEs length: %d bytes\n", | |
173 | nla_get_u16(tb_msg[NL80211_ATTR_MAX_SCAN_IE_LEN])); | |
174 | ||
175 | if (tb_msg[NL80211_ATTR_WIPHY_FRAG_THRESHOLD]) { | |
176 | unsigned int frag; | |
177 | ||
178 | frag = nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_FRAG_THRESHOLD]); | |
179 | if (frag != (unsigned int)-1) | |
180 | printf("\tFragmentation threshold: %d\n", frag); | |
181 | } | |
182 | ||
183 | if (tb_msg[NL80211_ATTR_WIPHY_RTS_THRESHOLD]) { | |
184 | unsigned int rts; | |
185 | ||
186 | rts = nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_RTS_THRESHOLD]); | |
187 | if (rts != (unsigned int)-1) | |
188 | printf("\tRTS threshold: %d\n", rts); | |
189 | } | |
190 | ||
191 | if (tb_msg[NL80211_ATTR_WIPHY_COVERAGE_CLASS]) { | |
192 | unsigned char coverage; | |
193 | ||
194 | coverage = nla_get_u8(tb_msg[NL80211_ATTR_WIPHY_COVERAGE_CLASS]); | |
195 | /* See handle_distance() for an explanation where the '450' comes from */ | |
196 | printf("\tCoverage class: %d (up to %dm)\n", coverage, 450 * coverage); | |
197 | } | |
198 | ||
199 | if (tb_msg[NL80211_ATTR_CIPHER_SUITES]) { | |
200 | int num = nla_len(tb_msg[NL80211_ATTR_CIPHER_SUITES]) / sizeof(__u32); | |
201 | int i; | |
202 | __u32 *ciphers = nla_data(tb_msg[NL80211_ATTR_CIPHER_SUITES]); | |
203 | if (num > 0) { | |
204 | printf("\tSupported Ciphers:\n"); | |
205 | for (i = 0; i < num; i++) | |
206 | printf("\t\t* %s\n", | |
207 | cipher_name(ciphers[i])); | |
208 | } | |
209 | } | |
210 | ||
211 | if (tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX] && | |
212 | tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX]) | |
213 | printf("\tAvailable Antennas: TX %#x RX %#x\n", | |
214 | nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX]), | |
215 | nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX])); | |
216 | ||
217 | if (tb_msg[NL80211_ATTR_WIPHY_ANTENNA_TX] && | |
218 | tb_msg[NL80211_ATTR_WIPHY_ANTENNA_RX]) | |
219 | printf("\tConfigured Antennas: TX %#x RX %#x\n", | |
220 | nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_TX]), | |
221 | nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_RX])); | |
222 | ||
223 | if (tb_msg[NL80211_ATTR_SUPPORTED_IFTYPES]) { | |
224 | printf("\tSupported interface modes:\n"); | |
225 | nla_for_each_nested(nl_mode, tb_msg[NL80211_ATTR_SUPPORTED_IFTYPES], rem_mode) | |
226 | printf("\t\t * %s\n", iftype_name(nla_type(nl_mode))); | |
227 | } | |
228 | ||
229 | if (tb_msg[NL80211_ATTR_SOFTWARE_IFTYPES]) { | |
230 | printf("\tsoftware interface modes (can always be added):\n"); | |
231 | nla_for_each_nested(nl_mode, tb_msg[NL80211_ATTR_SOFTWARE_IFTYPES], rem_mode) | |
232 | printf("\t\t * %s\n", iftype_name(nla_type(nl_mode))); | |
233 | } | |
234 | ||
235 | if (tb_msg[NL80211_ATTR_INTERFACE_COMBINATIONS]) { | |
236 | struct nlattr *nl_combi; | |
237 | int rem_combi; | |
238 | bool have_combinations = false; | |
239 | ||
240 | nla_for_each_nested(nl_combi, tb_msg[NL80211_ATTR_INTERFACE_COMBINATIONS], rem_combi) { | |
241 | static struct nla_policy iface_combination_policy[NUM_NL80211_IFACE_COMB] = { | |
242 | [NL80211_IFACE_COMB_LIMITS] = { .type = NLA_NESTED }, | |
243 | [NL80211_IFACE_COMB_MAXNUM] = { .type = NLA_U32 }, | |
244 | [NL80211_IFACE_COMB_STA_AP_BI_MATCH] = { .type = NLA_FLAG }, | |
245 | [NL80211_IFACE_COMB_NUM_CHANNELS] = { .type = NLA_U32 }, | |
246 | }; | |
247 | struct nlattr *tb_comb[NUM_NL80211_IFACE_COMB]; | |
248 | static struct nla_policy iface_limit_policy[NUM_NL80211_IFACE_LIMIT] = { | |
249 | [NL80211_IFACE_LIMIT_TYPES] = { .type = NLA_NESTED }, | |
250 | [NL80211_IFACE_LIMIT_MAX] = { .type = NLA_U32 }, | |
251 | }; | |
252 | struct nlattr *tb_limit[NUM_NL80211_IFACE_LIMIT]; | |
253 | struct nlattr *nl_limit; | |
254 | int err, rem_limit; | |
255 | bool comma = false; | |
256 | ||
257 | if (!have_combinations) { | |
258 | printf("\tvalid interface combinations:\n"); | |
259 | have_combinations = true; | |
260 | } | |
261 | ||
262 | printf("\t\t * "); | |
263 | ||
264 | err = nla_parse_nested(tb_comb, MAX_NL80211_IFACE_COMB, | |
265 | nl_combi, iface_combination_policy); | |
266 | if (err || !tb_comb[NL80211_IFACE_COMB_LIMITS] || | |
267 | !tb_comb[NL80211_IFACE_COMB_MAXNUM] || | |
268 | !tb_comb[NL80211_IFACE_COMB_NUM_CHANNELS]) { | |
269 | printf(" <failed to parse>\n"); | |
270 | goto broken_combination; | |
271 | } | |
272 | ||
273 | nla_for_each_nested(nl_limit, tb_comb[NL80211_IFACE_COMB_LIMITS], rem_limit) { | |
274 | bool ift_comma = false; | |
275 | ||
276 | err = nla_parse_nested(tb_limit, MAX_NL80211_IFACE_LIMIT, | |
277 | nl_limit, iface_limit_policy); | |
278 | if (err || !tb_limit[NL80211_IFACE_LIMIT_TYPES]) { | |
279 | printf("<failed to parse>\n"); | |
280 | goto broken_combination; | |
281 | } | |
282 | ||
283 | if (comma) | |
284 | printf(", "); | |
285 | comma = true; | |
286 | printf("#{"); | |
287 | ||
288 | nla_for_each_nested(nl_mode, tb_limit[NL80211_IFACE_LIMIT_TYPES], rem_mode) { | |
289 | printf("%s %s", ift_comma ? "," : "", | |
290 | iftype_name(nla_type(nl_mode))); | |
291 | ift_comma = true; | |
292 | } | |
293 | printf(" } <= %u", nla_get_u32(tb_limit[NL80211_IFACE_LIMIT_MAX])); | |
294 | } | |
295 | printf(",\n\t\t "); | |
296 | ||
297 | printf("total <= %d, #channels <= %d%s\n", | |
298 | nla_get_u32(tb_comb[NL80211_IFACE_COMB_MAXNUM]), | |
299 | nla_get_u32(tb_comb[NL80211_IFACE_COMB_NUM_CHANNELS]), | |
300 | tb_comb[NL80211_IFACE_COMB_STA_AP_BI_MATCH] ? | |
301 | ", STA/AP BI must match" : ""); | |
302 | broken_combination: | |
303 | ; | |
304 | } | |
305 | ||
306 | if (!have_combinations) | |
307 | printf("\tinterface combinations are not supported\n"); | |
308 | } | |
309 | ||
310 | if (tb_msg[NL80211_ATTR_SUPPORTED_COMMANDS]) { | |
311 | printf("\tSupported commands:\n"); | |
312 | nla_for_each_nested(nl_cmd, tb_msg[NL80211_ATTR_SUPPORTED_COMMANDS], rem_cmd) | |
313 | printf("\t\t * %s\n", command_name(nla_get_u32(nl_cmd))); | |
314 | } | |
315 | ||
316 | if (tb_msg[NL80211_ATTR_TX_FRAME_TYPES]) { | |
317 | printf("\tSupported TX frame types:\n"); | |
318 | nla_for_each_nested(nl_if, tb_msg[NL80211_ATTR_TX_FRAME_TYPES], rem_if) { | |
319 | bool printed = false; | |
320 | nla_for_each_nested(nl_ftype, nl_if, rem_ftype) { | |
321 | if (!printed) | |
322 | printf("\t\t * %s:", iftype_name(nla_type(nl_if))); | |
323 | printed = true; | |
324 | printf(" 0x%.2x", nla_get_u16(nl_ftype)); | |
325 | } | |
326 | if (printed) | |
327 | printf("\n"); | |
328 | } | |
329 | } | |
330 | ||
331 | if (tb_msg[NL80211_ATTR_RX_FRAME_TYPES]) { | |
332 | printf("\tSupported RX frame types:\n"); | |
333 | nla_for_each_nested(nl_if, tb_msg[NL80211_ATTR_RX_FRAME_TYPES], rem_if) { | |
334 | bool printed = false; | |
335 | nla_for_each_nested(nl_ftype, nl_if, rem_ftype) { | |
336 | if (!printed) | |
337 | printf("\t\t * %s:", iftype_name(nla_type(nl_if))); | |
338 | printed = true; | |
339 | printf(" 0x%.2x", nla_get_u16(nl_ftype)); | |
340 | } | |
341 | if (printed) | |
342 | printf("\n"); | |
343 | } | |
344 | } | |
345 | ||
346 | if (tb_msg[NL80211_ATTR_SUPPORT_IBSS_RSN]) | |
347 | printf("\tDevice supports RSN-IBSS.\n"); | |
348 | ||
349 | if (tb_msg[NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED]) { | |
350 | struct nlattr *tb_wowlan[NUM_NL80211_WOWLAN_TRIG]; | |
351 | static struct nla_policy wowlan_policy[NUM_NL80211_WOWLAN_TRIG] = { | |
352 | [NL80211_WOWLAN_TRIG_ANY] = { .type = NLA_FLAG }, | |
353 | [NL80211_WOWLAN_TRIG_DISCONNECT] = { .type = NLA_FLAG }, | |
354 | [NL80211_WOWLAN_TRIG_MAGIC_PKT] = { .type = NLA_FLAG }, | |
355 | [NL80211_WOWLAN_TRIG_PKT_PATTERN] = { | |
356 | .minlen = sizeof(struct nl80211_wowlan_pattern_support), | |
357 | }, | |
358 | [NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED] = { .type = NLA_FLAG }, | |
359 | [NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE] = { .type = NLA_FLAG }, | |
360 | [NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST] = { .type = NLA_FLAG }, | |
361 | [NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE] = { .type = NLA_FLAG }, | |
362 | [NL80211_WOWLAN_TRIG_RFKILL_RELEASE] = { .type = NLA_FLAG }, | |
363 | }; | |
364 | struct nl80211_wowlan_pattern_support *pat; | |
365 | int err; | |
366 | ||
367 | err = nla_parse_nested(tb_wowlan, MAX_NL80211_WOWLAN_TRIG, | |
368 | tb_msg[NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED], | |
369 | wowlan_policy); | |
370 | printf("\tWoWLAN support:"); | |
371 | if (err) { | |
372 | printf(" <failed to parse>\n"); | |
373 | } else { | |
374 | printf("\n"); | |
375 | if (tb_wowlan[NL80211_WOWLAN_TRIG_ANY]) | |
376 | printf("\t\t * wake up on anything (device continues operating normally)\n"); | |
377 | if (tb_wowlan[NL80211_WOWLAN_TRIG_DISCONNECT]) | |
378 | printf("\t\t * wake up on disconnect\n"); | |
379 | if (tb_wowlan[NL80211_WOWLAN_TRIG_MAGIC_PKT]) | |
380 | printf("\t\t * wake up on magic packet\n"); | |
381 | if (tb_wowlan[NL80211_WOWLAN_TRIG_PKT_PATTERN]) { | |
382 | pat = nla_data(tb_wowlan[NL80211_WOWLAN_TRIG_PKT_PATTERN]); | |
383 | printf("\t\t * wake up on pattern match, up to %u patterns of %u-%u bytes\n", | |
384 | pat->max_patterns, pat->min_pattern_len, pat->max_pattern_len); | |
385 | } | |
386 | if (tb_wowlan[NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED]) | |
387 | printf("\t\t * can do GTK rekeying\n"); | |
388 | if (tb_wowlan[NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE]) | |
389 | printf("\t\t * wake up on GTK rekey failure\n"); | |
390 | if (tb_wowlan[NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST]) | |
391 | printf("\t\t * wake up on EAP identity request\n"); | |
392 | if (tb_wowlan[NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE]) | |
393 | printf("\t\t * wake up on 4-way handshake\n"); | |
394 | if (tb_wowlan[NL80211_WOWLAN_TRIG_RFKILL_RELEASE]) | |
395 | printf("\t\t * wake up on rfkill release\n"); | |
396 | } | |
397 | } | |
398 | ||
399 | if (tb_msg[NL80211_ATTR_ROAM_SUPPORT]) | |
400 | printf("\tDevice supports roaming.\n"); | |
401 | ||
402 | if (tb_msg[NL80211_ATTR_SUPPORT_AP_UAPSD]) | |
403 | printf("\tDevice supports AP-side u-APSD.\n"); | |
404 | ||
405 | if (tb_msg[NL80211_ATTR_HT_CAPABILITY_MASK]) { | |
406 | struct ieee80211_ht_cap *cm; | |
407 | printf("\tHT Capability overrides:\n"); | |
408 | if (nla_len(tb_msg[NL80211_ATTR_HT_CAPABILITY_MASK]) >= sizeof(*cm)) { | |
409 | cm = nla_data(tb_msg[NL80211_ATTR_HT_CAPABILITY_MASK]); | |
410 | printf("\t\t * MCS: %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx" | |
411 | " %02hhx %02hhx %02hhx %02hhx\n", | |
412 | cm->mcs.rx_mask[0], cm->mcs.rx_mask[1], | |
413 | cm->mcs.rx_mask[2], cm->mcs.rx_mask[3], | |
414 | cm->mcs.rx_mask[4], cm->mcs.rx_mask[5], | |
415 | cm->mcs.rx_mask[6], cm->mcs.rx_mask[7], | |
416 | cm->mcs.rx_mask[8], cm->mcs.rx_mask[9]); | |
417 | if (cm->cap_info & htole16(IEEE80211_HT_CAP_MAX_AMSDU)) | |
418 | printf("\t\t * maximum A-MSDU length\n"); | |
419 | if (cm->cap_info & htole16(IEEE80211_HT_CAP_SUP_WIDTH_20_40)) | |
420 | printf("\t\t * supported channel width\n"); | |
421 | if (cm->cap_info & htole16(IEEE80211_HT_CAP_SGI_40)) | |
422 | printf("\t\t * short GI for 40 MHz\n"); | |
423 | if (cm->ampdu_params_info & IEEE80211_HT_AMPDU_PARM_FACTOR) | |
424 | printf("\t\t * max A-MPDU length exponent\n"); | |
425 | if (cm->ampdu_params_info & IEEE80211_HT_AMPDU_PARM_DENSITY) | |
426 | printf("\t\t * min MPDU start spacing\n"); | |
427 | } else { | |
428 | printf("\tERROR: capabilities mask is too short, expected: %d, received: %d\n", | |
429 | (int)(sizeof(*cm)), | |
430 | (int)(nla_len(tb_msg[NL80211_ATTR_HT_CAPABILITY_MASK]))); | |
431 | } | |
432 | } | |
433 | ||
434 | if (tb_msg[NL80211_ATTR_FEATURE_FLAGS]) { | |
435 | if (nla_get_u32(tb_msg[NL80211_ATTR_FEATURE_FLAGS]) & | |
436 | NL80211_FEATURE_SK_TX_STATUS) | |
437 | printf("\tDevice supports TX status socket option.\n"); | |
438 | if (nla_get_u32(tb_msg[NL80211_ATTR_FEATURE_FLAGS]) & | |
439 | NL80211_FEATURE_HT_IBSS) | |
440 | printf("\tDevice supports HT-IBSS.\n"); | |
441 | } | |
442 | ||
443 | return NL_SKIP; | |
444 | } | |
445 | ||
446 | static int handle_info(struct nl80211_state *state, | |
447 | struct nl_cb *cb, | |
448 | struct nl_msg *msg, | |
449 | int argc, char **argv) | |
450 | { | |
451 | nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_phy_handler, NULL); | |
452 | ||
453 | return 0; | |
454 | } | |
455 | __COMMAND(NULL, info, "info", NULL, NL80211_CMD_GET_WIPHY, 0, 0, CIB_PHY, handle_info, | |
456 | "Show capabilities for the specified wireless device.", NULL); | |
457 | TOPLEVEL(list, NULL, NL80211_CMD_GET_WIPHY, NLM_F_DUMP, CIB_NONE, handle_info, | |
458 | "List all wireless devices and their capabilities."); | |
459 | TOPLEVEL(phy, NULL, NL80211_CMD_GET_WIPHY, NLM_F_DUMP, CIB_NONE, handle_info, NULL); |