]>
Commit | Line | Data |
---|---|---|
21878f36 | 1 | #include <stdbool.h> |
2ef1be68 | 2 | |
79f99b9a JB |
3 | #include <netlink/genl/genl.h> |
4 | #include <netlink/genl/family.h> | |
5 | #include <netlink/genl/ctrl.h> | |
6 | #include <netlink/msg.h> | |
7 | #include <netlink/attr.h> | |
79f99b9a | 8 | |
f408e01b | 9 | #include "nl80211.h" |
79f99b9a JB |
10 | #include "iw.h" |
11 | ||
12 | static void print_flag(const char *name, int *open) | |
13 | { | |
14 | if (!*open) | |
15 | printf(" ("); | |
16 | else | |
17 | printf(", "); | |
69283122 | 18 | printf("%s", name); |
79f99b9a JB |
19 | *open = 1; |
20 | } | |
21 | ||
810e05c3 JB |
22 | static char *cipher_name(__u32 c) |
23 | { | |
24 | static char buf[20]; | |
25 | ||
26 | switch (c) { | |
27 | case 0x000fac01: | |
28 | return "WEP40 (00-0f-ac:1)"; | |
29 | case 0x000fac05: | |
30 | return "WEP104 (00-0f-ac:5)"; | |
31 | case 0x000fac02: | |
32 | return "TKIP (00-0f-ac:2)"; | |
33 | case 0x000fac04: | |
b0c5a4a3 | 34 | return "CCMP-128 (00-0f-ac:4)"; |
810e05c3 JB |
35 | case 0x000fac06: |
36 | return "CMAC (00-0f-ac:6)"; | |
a8b3da9d | 37 | case 0x000fac08: |
b0c5a4a3 MM |
38 | return "GCMP-128 (00-0f-ac:8)"; |
39 | case 0x000fac09: | |
40 | return "GCMP-256 (00-0f-ac:9)"; | |
41 | case 0x000fac0a: | |
42 | return "CCMP-256 (00-0f-ac:10)"; | |
43 | case 0x000fac0b: | |
44 | return "GMAC-128 (00-0f-ac:11)"; | |
45 | case 0x000fac0c: | |
46 | return "GMAC-256 (00-0f-ac:12)"; | |
47 | case 0x000fac0d: | |
48 | return "CMAC-256 (00-0f-ac:13)"; | |
810e05c3 JB |
49 | case 0x00147201: |
50 | return "WPI-SMS4 (00-14-72:1)"; | |
51 | default: | |
52 | sprintf(buf, "%.2x-%.2x-%.2x:%d", | |
53 | c >> 24, (c >> 16) & 0xff, | |
54 | (c >> 8) & 0xff, c & 0xff); | |
55 | ||
56 | return buf; | |
57 | } | |
58 | } | |
59 | ||
f0e30bd5 JD |
60 | static int ext_feature_isset(const unsigned char *ext_features, int ext_features_len, |
61 | enum nl80211_ext_feature_index ftidx) | |
62 | { | |
63 | unsigned char ft_byte; | |
64 | ||
65 | if ((int) ftidx / 8 >= ext_features_len) | |
66 | return 0; | |
67 | ||
68 | ft_byte = ext_features[ftidx / 8]; | |
69 | return (ft_byte & BIT(ftidx % 8)) != 0; | |
70 | } | |
71 | ||
02b53ea2 JB |
72 | static void _ext_feat_print(const struct nlattr *tb, |
73 | enum nl80211_ext_feature_index idx, | |
74 | const char *feature_name, const char *feature_desc) | |
c1bdfe6a DL |
75 | { |
76 | if (ext_feature_isset(nla_data(tb), nla_len(tb),idx)) | |
77 | printf("\t\t* [ %s ]: %s\n", feature_name, feature_desc); | |
78 | } | |
02b53ea2 JB |
79 | #define ext_feat_print(tb, name, desc) \ |
80 | _ext_feat_print(tb, NL80211_EXT_FEATURE_##name, #name, desc) | |
c1bdfe6a | 81 | |
79f99b9a JB |
82 | static int print_phy_handler(struct nl_msg *msg, void *arg) |
83 | { | |
84 | struct nlattr *tb_msg[NL80211_ATTR_MAX + 1]; | |
85 | struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); | |
86 | ||
87 | struct nlattr *tb_band[NL80211_BAND_ATTR_MAX + 1]; | |
88 | ||
89 | struct nlattr *tb_freq[NL80211_FREQUENCY_ATTR_MAX + 1]; | |
90 | static struct nla_policy freq_policy[NL80211_FREQUENCY_ATTR_MAX + 1] = { | |
91 | [NL80211_FREQUENCY_ATTR_FREQ] = { .type = NLA_U32 }, | |
92 | [NL80211_FREQUENCY_ATTR_DISABLED] = { .type = NLA_FLAG }, | |
f0c48e7b IP |
93 | [NL80211_FREQUENCY_ATTR_NO_IR] = { .type = NLA_FLAG }, |
94 | [__NL80211_FREQUENCY_ATTR_NO_IBSS] = { .type = NLA_FLAG }, | |
79f99b9a | 95 | [NL80211_FREQUENCY_ATTR_RADAR] = { .type = NLA_FLAG }, |
c1081c20 | 96 | [NL80211_FREQUENCY_ATTR_MAX_TX_POWER] = { .type = NLA_U32 }, |
79f99b9a JB |
97 | }; |
98 | ||
99 | struct nlattr *tb_rate[NL80211_BITRATE_ATTR_MAX + 1]; | |
100 | static struct nla_policy rate_policy[NL80211_BITRATE_ATTR_MAX + 1] = { | |
101 | [NL80211_BITRATE_ATTR_RATE] = { .type = NLA_U32 }, | |
102 | [NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE] = { .type = NLA_FLAG }, | |
103 | }; | |
104 | ||
105 | struct nlattr *nl_band; | |
106 | struct nlattr *nl_freq; | |
107 | struct nlattr *nl_rate; | |
9990c1e9 | 108 | struct nlattr *nl_cmd; |
9a4a14bd | 109 | struct nlattr *nl_if, *nl_ftype; |
a6cedc6d | 110 | int rem_band, rem_freq, rem_rate, rem_cmd, rem_ftype, rem_if; |
79f99b9a | 111 | int open; |
fb70e110 JB |
112 | /* |
113 | * static variables only work here, other applications need to use the | |
114 | * callback pointer and store them there so they can be multithreaded | |
115 | * and/or have multiple netlink sockets, etc. | |
116 | */ | |
117 | static int64_t phy_id = -1; | |
118 | static int last_band = -1; | |
119 | static bool band_had_freq = false; | |
120 | bool print_name = true; | |
79f99b9a JB |
121 | |
122 | nla_parse(tb_msg, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), | |
123 | genlmsg_attrlen(gnlh, 0), NULL); | |
124 | ||
fb70e110 JB |
125 | if (tb_msg[NL80211_ATTR_WIPHY]) { |
126 | if (nla_get_u32(tb_msg[NL80211_ATTR_WIPHY]) == phy_id) | |
127 | print_name = false; | |
128 | else | |
129 | last_band = -1; | |
130 | phy_id = nla_get_u32(tb_msg[NL80211_ATTR_WIPHY]); | |
131 | } | |
132 | if (print_name && tb_msg[NL80211_ATTR_WIPHY_NAME]) | |
d631650b JB |
133 | printf("Wiphy %s\n", nla_get_string(tb_msg[NL80211_ATTR_WIPHY_NAME])); |
134 | ||
11c35aef BN |
135 | if (print_name && tb_msg[NL80211_ATTR_WIPHY]) |
136 | printf("\twiphy index: %u\n", nla_get_u32(tb_msg[NL80211_ATTR_WIPHY])); | |
137 | ||
fb70e110 JB |
138 | /* needed for split dump */ |
139 | if (tb_msg[NL80211_ATTR_WIPHY_BANDS]) { | |
140 | nla_for_each_nested(nl_band, tb_msg[NL80211_ATTR_WIPHY_BANDS], rem_band) { | |
141 | if (last_band != nl_band->nla_type) { | |
142 | printf("\tBand %d:\n", nl_band->nla_type + 1); | |
143 | band_had_freq = false; | |
ee9cd987 | 144 | } |
fb70e110 | 145 | last_band = nl_band->nla_type; |
48aaf2d9 | 146 | |
fb70e110 JB |
147 | nla_parse(tb_band, NL80211_BAND_ATTR_MAX, nla_data(nl_band), |
148 | nla_len(nl_band), NULL); | |
48aaf2d9 | 149 | |
fb70e110 JB |
150 | if (tb_band[NL80211_BAND_ATTR_HT_CAPA]) { |
151 | __u16 cap = nla_get_u16(tb_band[NL80211_BAND_ATTR_HT_CAPA]); | |
152 | print_ht_capability(cap); | |
153 | } | |
154 | if (tb_band[NL80211_BAND_ATTR_HT_AMPDU_FACTOR]) { | |
155 | __u8 exponent = nla_get_u8(tb_band[NL80211_BAND_ATTR_HT_AMPDU_FACTOR]); | |
156 | print_ampdu_length(exponent); | |
157 | } | |
158 | if (tb_band[NL80211_BAND_ATTR_HT_AMPDU_DENSITY]) { | |
159 | __u8 spacing = nla_get_u8(tb_band[NL80211_BAND_ATTR_HT_AMPDU_DENSITY]); | |
160 | print_ampdu_spacing(spacing); | |
161 | } | |
162 | if (tb_band[NL80211_BAND_ATTR_HT_MCS_SET] && | |
163 | nla_len(tb_band[NL80211_BAND_ATTR_HT_MCS_SET]) == 16) | |
164 | print_ht_mcs(nla_data(tb_band[NL80211_BAND_ATTR_HT_MCS_SET])); | |
165 | if (tb_band[NL80211_BAND_ATTR_VHT_CAPA] && | |
166 | tb_band[NL80211_BAND_ATTR_VHT_MCS_SET]) | |
167 | print_vht_info(nla_get_u32(tb_band[NL80211_BAND_ATTR_VHT_CAPA]), | |
168 | nla_data(tb_band[NL80211_BAND_ATTR_VHT_MCS_SET])); | |
c741be9f JC |
169 | if (tb_band[NL80211_BAND_ATTR_IFTYPE_DATA]) { |
170 | struct nlattr *nl_iftype; | |
171 | int rem_band; | |
fb70e110 | 172 | |
5a71b722 IP |
173 | nla_for_each_nested(nl_iftype, |
174 | tb_band[NL80211_BAND_ATTR_IFTYPE_DATA], | |
175 | rem_band) { | |
c741be9f | 176 | print_he_info(nl_iftype); |
5a71b722 IP |
177 | print_eht_info(nl_iftype, last_band); |
178 | } | |
c741be9f | 179 | } |
fb70e110 JB |
180 | if (tb_band[NL80211_BAND_ATTR_FREQS]) { |
181 | if (!band_had_freq) { | |
182 | printf("\t\tFrequencies:\n"); | |
183 | band_had_freq = true; | |
184 | } | |
185 | nla_for_each_nested(nl_freq, tb_band[NL80211_BAND_ATTR_FREQS], rem_freq) { | |
186 | uint32_t freq; | |
187 | nla_parse(tb_freq, NL80211_FREQUENCY_ATTR_MAX, nla_data(nl_freq), | |
188 | nla_len(nl_freq), freq_policy); | |
189 | if (!tb_freq[NL80211_FREQUENCY_ATTR_FREQ]) | |
190 | continue; | |
191 | freq = nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_FREQ]); | |
192 | printf("\t\t\t* %d MHz [%d]", freq, ieee80211_frequency_to_channel(freq)); | |
193 | ||
194 | if (tb_freq[NL80211_FREQUENCY_ATTR_MAX_TX_POWER] && | |
195 | !tb_freq[NL80211_FREQUENCY_ATTR_DISABLED]) | |
196 | printf(" (%.1f dBm)", 0.01 * nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_MAX_TX_POWER])); | |
197 | ||
198 | open = 0; | |
199 | if (tb_freq[NL80211_FREQUENCY_ATTR_DISABLED]) { | |
200 | print_flag("disabled", &open); | |
201 | goto next; | |
202 | } | |
f0c48e7b IP |
203 | |
204 | /* If both flags are set assume an new kernel */ | |
205 | if (tb_freq[NL80211_FREQUENCY_ATTR_NO_IR] && tb_freq[__NL80211_FREQUENCY_ATTR_NO_IBSS]) { | |
206 | print_flag("no IR", &open); | |
207 | } else if (tb_freq[NL80211_FREQUENCY_ATTR_PASSIVE_SCAN]) { | |
208 | print_flag("passive scan", &open); | |
209 | } else if (tb_freq[__NL80211_FREQUENCY_ATTR_NO_IBSS]){ | |
210 | print_flag("no ibss", &open); | |
211 | } | |
212 | ||
fb70e110 JB |
213 | if (tb_freq[NL80211_FREQUENCY_ATTR_RADAR]) |
214 | print_flag("radar detection", &open); | |
215 | next: | |
216 | if (open) | |
217 | printf(")"); | |
218 | printf("\n"); | |
48aaf2d9 | 219 | } |
48aaf2d9 | 220 | } |
79f99b9a | 221 | |
fb70e110 JB |
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(")"); | |
235 | printf("\n"); | |
236 | } | |
237 | } | |
79f99b9a JB |
238 | } |
239 | } | |
240 | ||
41be37f2 JB |
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])); | |
f9c112b6 JB |
244 | if (tb_msg[NL80211_ATTR_MAX_SCAN_IE_LEN]) |
245 | printf("\tmax scan IEs length: %d bytes\n", | |
8eaa9ee5 | 246 | nla_get_u16(tb_msg[NL80211_ATTR_MAX_SCAN_IE_LEN])); |
3fce58aa LC |
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])); | |
9ae0d103 AS |
253 | if (tb_msg[NL80211_ATTR_MAX_NUM_SCHED_SCAN_PLANS]) |
254 | printf("\tmax # scan plans: %d\n", | |
255 | nla_get_u32(tb_msg[NL80211_ATTR_MAX_NUM_SCHED_SCAN_PLANS])); | |
256 | if (tb_msg[NL80211_ATTR_MAX_SCAN_PLAN_INTERVAL]) | |
257 | printf("\tmax scan plan interval: %d\n", | |
258 | nla_get_u32(tb_msg[NL80211_ATTR_MAX_SCAN_PLAN_INTERVAL])); | |
259 | if (tb_msg[NL80211_ATTR_MAX_SCAN_PLAN_ITERATIONS]) | |
260 | printf("\tmax scan plan iterations: %d\n", | |
261 | nla_get_u32(tb_msg[NL80211_ATTR_MAX_SCAN_PLAN_ITERATIONS])); | |
41be37f2 | 262 | |
625aa4ae JB |
263 | if (tb_msg[NL80211_ATTR_WIPHY_FRAG_THRESHOLD]) { |
264 | unsigned int frag; | |
265 | ||
266 | frag = nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_FRAG_THRESHOLD]); | |
267 | if (frag != (unsigned int)-1) | |
268 | printf("\tFragmentation threshold: %d\n", frag); | |
269 | } | |
270 | ||
271 | if (tb_msg[NL80211_ATTR_WIPHY_RTS_THRESHOLD]) { | |
272 | unsigned int rts; | |
273 | ||
274 | rts = nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_RTS_THRESHOLD]); | |
275 | if (rts != (unsigned int)-1) | |
276 | printf("\tRTS threshold: %d\n", rts); | |
277 | } | |
278 | ||
c993e6e7 UR |
279 | if (tb_msg[NL80211_ATTR_WIPHY_RETRY_SHORT] || |
280 | tb_msg[NL80211_ATTR_WIPHY_RETRY_LONG]) { | |
281 | unsigned char retry_short = 0, retry_long = 0; | |
282 | ||
283 | if (tb_msg[NL80211_ATTR_WIPHY_RETRY_SHORT]) | |
284 | retry_short = nla_get_u8(tb_msg[NL80211_ATTR_WIPHY_RETRY_SHORT]); | |
285 | if (tb_msg[NL80211_ATTR_WIPHY_RETRY_LONG]) | |
286 | retry_long = nla_get_u8(tb_msg[NL80211_ATTR_WIPHY_RETRY_LONG]); | |
287 | if (retry_short == retry_long) { | |
288 | printf("\tRetry short long limit: %d\n", retry_short); | |
289 | } else { | |
290 | printf("\tRetry short limit: %d\n", retry_short); | |
291 | printf("\tRetry long limit: %d\n", retry_long); | |
292 | } | |
293 | } | |
294 | ||
b2f92dd0 LT |
295 | if (tb_msg[NL80211_ATTR_WIPHY_COVERAGE_CLASS]) { |
296 | unsigned char coverage; | |
297 | ||
298 | coverage = nla_get_u8(tb_msg[NL80211_ATTR_WIPHY_COVERAGE_CLASS]); | |
299 | /* See handle_distance() for an explanation where the '450' comes from */ | |
300 | printf("\tCoverage class: %d (up to %dm)\n", coverage, 450 * coverage); | |
301 | } | |
302 | ||
810e05c3 JB |
303 | if (tb_msg[NL80211_ATTR_CIPHER_SUITES]) { |
304 | int num = nla_len(tb_msg[NL80211_ATTR_CIPHER_SUITES]) / sizeof(__u32); | |
305 | int i; | |
306 | __u32 *ciphers = nla_data(tb_msg[NL80211_ATTR_CIPHER_SUITES]); | |
307 | if (num > 0) { | |
308 | printf("\tSupported Ciphers:\n"); | |
309 | for (i = 0; i < num; i++) | |
310 | printf("\t\t* %s\n", | |
311 | cipher_name(ciphers[i])); | |
312 | } | |
313 | } | |
314 | ||
afce7986 BR |
315 | if (tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX] && |
316 | tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX]) | |
317 | printf("\tAvailable Antennas: TX %#x RX %#x\n", | |
318 | nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX]), | |
319 | nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX])); | |
320 | ||
321 | if (tb_msg[NL80211_ATTR_WIPHY_ANTENNA_TX] && | |
322 | tb_msg[NL80211_ATTR_WIPHY_ANTENNA_RX]) | |
323 | printf("\tConfigured Antennas: TX %#x RX %#x\n", | |
324 | nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_TX]), | |
325 | nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_RX])); | |
326 | ||
a6cedc6d JB |
327 | if (tb_msg[NL80211_ATTR_SUPPORTED_IFTYPES]) |
328 | print_iftype_list("\tSupported interface modes", "\t\t", | |
329 | tb_msg[NL80211_ATTR_SUPPORTED_IFTYPES]); | |
6367e71a | 330 | |
a6cedc6d JB |
331 | if (tb_msg[NL80211_ATTR_SOFTWARE_IFTYPES]) |
332 | print_iftype_list("\tsoftware interface modes (can always be added)", | |
333 | "\t\t", tb_msg[NL80211_ATTR_SOFTWARE_IFTYPES]); | |
1c5b4a82 JB |
334 | |
335 | if (tb_msg[NL80211_ATTR_INTERFACE_COMBINATIONS]) { | |
336 | struct nlattr *nl_combi; | |
337 | int rem_combi; | |
f5f6f15f | 338 | bool have_combinations = false; |
1c5b4a82 JB |
339 | |
340 | nla_for_each_nested(nl_combi, tb_msg[NL80211_ATTR_INTERFACE_COMBINATIONS], rem_combi) { | |
341 | static struct nla_policy iface_combination_policy[NUM_NL80211_IFACE_COMB] = { | |
342 | [NL80211_IFACE_COMB_LIMITS] = { .type = NLA_NESTED }, | |
343 | [NL80211_IFACE_COMB_MAXNUM] = { .type = NLA_U32 }, | |
344 | [NL80211_IFACE_COMB_STA_AP_BI_MATCH] = { .type = NLA_FLAG }, | |
345 | [NL80211_IFACE_COMB_NUM_CHANNELS] = { .type = NLA_U32 }, | |
c5df9eb6 | 346 | [NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS] = { .type = NLA_U32 }, |
1c5b4a82 JB |
347 | }; |
348 | struct nlattr *tb_comb[NUM_NL80211_IFACE_COMB]; | |
349 | static struct nla_policy iface_limit_policy[NUM_NL80211_IFACE_LIMIT] = { | |
350 | [NL80211_IFACE_LIMIT_TYPES] = { .type = NLA_NESTED }, | |
351 | [NL80211_IFACE_LIMIT_MAX] = { .type = NLA_U32 }, | |
352 | }; | |
353 | struct nlattr *tb_limit[NUM_NL80211_IFACE_LIMIT]; | |
354 | struct nlattr *nl_limit; | |
355 | int err, rem_limit; | |
356 | bool comma = false; | |
357 | ||
f5f6f15f JB |
358 | if (!have_combinations) { |
359 | printf("\tvalid interface combinations:\n"); | |
360 | have_combinations = true; | |
361 | } | |
362 | ||
1c5b4a82 JB |
363 | printf("\t\t * "); |
364 | ||
365 | err = nla_parse_nested(tb_comb, MAX_NL80211_IFACE_COMB, | |
366 | nl_combi, iface_combination_policy); | |
367 | if (err || !tb_comb[NL80211_IFACE_COMB_LIMITS] || | |
368 | !tb_comb[NL80211_IFACE_COMB_MAXNUM] || | |
369 | !tb_comb[NL80211_IFACE_COMB_NUM_CHANNELS]) { | |
370 | printf(" <failed to parse>\n"); | |
371 | goto broken_combination; | |
372 | } | |
373 | ||
374 | nla_for_each_nested(nl_limit, tb_comb[NL80211_IFACE_COMB_LIMITS], rem_limit) { | |
1c5b4a82 JB |
375 | err = nla_parse_nested(tb_limit, MAX_NL80211_IFACE_LIMIT, |
376 | nl_limit, iface_limit_policy); | |
377 | if (err || !tb_limit[NL80211_IFACE_LIMIT_TYPES]) { | |
378 | printf("<failed to parse>\n"); | |
379 | goto broken_combination; | |
380 | } | |
381 | ||
382 | if (comma) | |
383 | printf(", "); | |
384 | comma = true; | |
a6cedc6d JB |
385 | printf("#{ "); |
386 | print_iftype_line(tb_limit[NL80211_IFACE_LIMIT_TYPES]); | |
1c5b4a82 JB |
387 | printf(" } <= %u", nla_get_u32(tb_limit[NL80211_IFACE_LIMIT_MAX])); |
388 | } | |
389 | printf(",\n\t\t "); | |
390 | ||
c5df9eb6 | 391 | printf("total <= %d, #channels <= %d%s", |
1c5b4a82 JB |
392 | nla_get_u32(tb_comb[NL80211_IFACE_COMB_MAXNUM]), |
393 | nla_get_u32(tb_comb[NL80211_IFACE_COMB_NUM_CHANNELS]), | |
394 | tb_comb[NL80211_IFACE_COMB_STA_AP_BI_MATCH] ? | |
395 | ", STA/AP BI must match" : ""); | |
c5df9eb6 SW |
396 | if (tb_comb[NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS]) { |
397 | unsigned long widths = nla_get_u32(tb_comb[NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS]); | |
398 | ||
399 | if (widths) { | |
400 | int width; | |
401 | bool first = true; | |
402 | ||
403 | printf(", radar detect widths: {"); | |
404 | for (width = 0; width < 32; width++) | |
405 | if (widths & (1 << width)) { | |
406 | printf("%s %s", | |
407 | first ? "":",", | |
408 | channel_width_name(width)); | |
409 | first = false; | |
410 | } | |
411 | printf(" }\n"); | |
412 | } | |
413 | } | |
414 | printf("\n"); | |
1c5b4a82 JB |
415 | broken_combination: |
416 | ; | |
417 | } | |
f5f6f15f JB |
418 | |
419 | if (!have_combinations) | |
420 | printf("\tinterface combinations are not supported\n"); | |
1c5b4a82 JB |
421 | } |
422 | ||
9a4a14bd JB |
423 | if (tb_msg[NL80211_ATTR_SUPPORTED_COMMANDS]) { |
424 | printf("\tSupported commands:\n"); | |
425 | nla_for_each_nested(nl_cmd, tb_msg[NL80211_ATTR_SUPPORTED_COMMANDS], rem_cmd) | |
426 | printf("\t\t * %s\n", command_name(nla_get_u32(nl_cmd))); | |
427 | } | |
6367e71a | 428 | |
9a4a14bd JB |
429 | if (tb_msg[NL80211_ATTR_TX_FRAME_TYPES]) { |
430 | printf("\tSupported TX frame types:\n"); | |
431 | nla_for_each_nested(nl_if, tb_msg[NL80211_ATTR_TX_FRAME_TYPES], rem_if) { | |
432 | bool printed = false; | |
433 | nla_for_each_nested(nl_ftype, nl_if, rem_ftype) { | |
434 | if (!printed) | |
435 | printf("\t\t * %s:", iftype_name(nla_type(nl_if))); | |
436 | printed = true; | |
58e34341 | 437 | printf(" 0x%.2x", nla_get_u16(nl_ftype)); |
9a4a14bd JB |
438 | } |
439 | if (printed) | |
440 | printf("\n"); | |
441 | } | |
442 | } | |
9990c1e9 | 443 | |
9a4a14bd JB |
444 | if (tb_msg[NL80211_ATTR_RX_FRAME_TYPES]) { |
445 | printf("\tSupported RX frame types:\n"); | |
446 | nla_for_each_nested(nl_if, tb_msg[NL80211_ATTR_RX_FRAME_TYPES], rem_if) { | |
447 | bool printed = false; | |
448 | nla_for_each_nested(nl_ftype, nl_if, rem_ftype) { | |
449 | if (!printed) | |
450 | printf("\t\t * %s:", iftype_name(nla_type(nl_if))); | |
451 | printed = true; | |
58e34341 | 452 | printf(" 0x%.2x", nla_get_u16(nl_ftype)); |
9a4a14bd JB |
453 | } |
454 | if (printed) | |
455 | printf("\n"); | |
456 | } | |
457 | } | |
9990c1e9 | 458 | |
3ff24563 | 459 | if (tb_msg[NL80211_ATTR_SUPPORT_IBSS_RSN]) |
83f10169 | 460 | printf("\tDevice supports RSN-IBSS.\n"); |
3ff24563 JB |
461 | |
462 | if (tb_msg[NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED]) { | |
463 | struct nlattr *tb_wowlan[NUM_NL80211_WOWLAN_TRIG]; | |
464 | static struct nla_policy wowlan_policy[NUM_NL80211_WOWLAN_TRIG] = { | |
465 | [NL80211_WOWLAN_TRIG_ANY] = { .type = NLA_FLAG }, | |
466 | [NL80211_WOWLAN_TRIG_DISCONNECT] = { .type = NLA_FLAG }, | |
467 | [NL80211_WOWLAN_TRIG_MAGIC_PKT] = { .type = NLA_FLAG }, | |
1c8f49c5 | 468 | [NL80211_WOWLAN_TRIG_PKT_PATTERN] = { .minlen = 12 }, |
3a6636b1 JB |
469 | [NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED] = { .type = NLA_FLAG }, |
470 | [NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE] = { .type = NLA_FLAG }, | |
471 | [NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST] = { .type = NLA_FLAG }, | |
472 | [NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE] = { .type = NLA_FLAG }, | |
473 | [NL80211_WOWLAN_TRIG_RFKILL_RELEASE] = { .type = NLA_FLAG }, | |
4888e6ba | 474 | [NL80211_WOWLAN_TRIG_NET_DETECT] = { .type = NLA_U32 }, |
819b78cc | 475 | [NL80211_WOWLAN_TRIG_TCP_CONNECTION] = { .type = NLA_NESTED }, |
3ff24563 | 476 | }; |
c82868da | 477 | struct nl80211_pattern_support *pat; |
3ff24563 JB |
478 | int err; |
479 | ||
480 | err = nla_parse_nested(tb_wowlan, MAX_NL80211_WOWLAN_TRIG, | |
481 | tb_msg[NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED], | |
482 | wowlan_policy); | |
483 | printf("\tWoWLAN support:"); | |
484 | if (err) { | |
485 | printf(" <failed to parse>\n"); | |
486 | } else { | |
487 | printf("\n"); | |
488 | if (tb_wowlan[NL80211_WOWLAN_TRIG_ANY]) | |
3a6636b1 | 489 | printf("\t\t * wake up on anything (device continues operating normally)\n"); |
3ff24563 | 490 | if (tb_wowlan[NL80211_WOWLAN_TRIG_DISCONNECT]) |
3a6636b1 | 491 | printf("\t\t * wake up on disconnect\n"); |
3ff24563 | 492 | if (tb_wowlan[NL80211_WOWLAN_TRIG_MAGIC_PKT]) |
3a6636b1 | 493 | printf("\t\t * wake up on magic packet\n"); |
3ff24563 | 494 | if (tb_wowlan[NL80211_WOWLAN_TRIG_PKT_PATTERN]) { |
0ee571d5 JB |
495 | unsigned int len = nla_len(tb_wowlan[NL80211_WOWLAN_TRIG_PKT_PATTERN]); |
496 | ||
3ff24563 | 497 | pat = nla_data(tb_wowlan[NL80211_WOWLAN_TRIG_PKT_PATTERN]); |
1c8f49c5 AK |
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, | |
0ee571d5 | 501 | len < sizeof(*pat) ? 0 : pat->max_pkt_offset); |
3ff24563 | 502 | } |
3a6636b1 JB |
503 | if (tb_wowlan[NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED]) |
504 | printf("\t\t * can do GTK rekeying\n"); | |
505 | if (tb_wowlan[NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE]) | |
506 | printf("\t\t * wake up on GTK rekey failure\n"); | |
507 | if (tb_wowlan[NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST]) | |
508 | printf("\t\t * wake up on EAP identity request\n"); | |
509 | if (tb_wowlan[NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE]) | |
510 | printf("\t\t * wake up on 4-way handshake\n"); | |
511 | if (tb_wowlan[NL80211_WOWLAN_TRIG_RFKILL_RELEASE]) | |
512 | printf("\t\t * wake up on rfkill release\n"); | |
d516c5bc | 513 | if (tb_wowlan[NL80211_WOWLAN_TRIG_NET_DETECT]) |
4888e6ba LC |
514 | printf("\t\t * wake up on network detection, up to %d match sets\n", |
515 | nla_get_u32(tb_wowlan[NL80211_WOWLAN_TRIG_NET_DETECT])); | |
819b78cc JB |
516 | if (tb_wowlan[NL80211_WOWLAN_TRIG_TCP_CONNECTION]) |
517 | printf("\t\t * wake up on TCP connection\n"); | |
3ff24563 | 518 | } |
83f10169 JB |
519 | } |
520 | ||
2e4f65ca JB |
521 | if (tb_msg[NL80211_ATTR_ROAM_SUPPORT]) |
522 | printf("\tDevice supports roaming.\n"); | |
523 | ||
8b469995 JB |
524 | if (tb_msg[NL80211_ATTR_SUPPORT_AP_UAPSD]) |
525 | printf("\tDevice supports AP-side u-APSD.\n"); | |
526 | ||
a82abc2c BG |
527 | if (tb_msg[NL80211_ATTR_HT_CAPABILITY_MASK]) { |
528 | struct ieee80211_ht_cap *cm; | |
0ee571d5 JB |
529 | unsigned int len = nla_len(tb_msg[NL80211_ATTR_HT_CAPABILITY_MASK]); |
530 | ||
a82abc2c | 531 | printf("\tHT Capability overrides:\n"); |
0ee571d5 | 532 | if (len >= sizeof(*cm)) { |
a82abc2c BG |
533 | cm = nla_data(tb_msg[NL80211_ATTR_HT_CAPABILITY_MASK]); |
534 | printf("\t\t * MCS: %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx" | |
535 | " %02hhx %02hhx %02hhx %02hhx\n", | |
536 | cm->mcs.rx_mask[0], cm->mcs.rx_mask[1], | |
537 | cm->mcs.rx_mask[2], cm->mcs.rx_mask[3], | |
538 | cm->mcs.rx_mask[4], cm->mcs.rx_mask[5], | |
539 | cm->mcs.rx_mask[6], cm->mcs.rx_mask[7], | |
540 | cm->mcs.rx_mask[8], cm->mcs.rx_mask[9]); | |
541 | if (cm->cap_info & htole16(IEEE80211_HT_CAP_MAX_AMSDU)) | |
542 | printf("\t\t * maximum A-MSDU length\n"); | |
543 | if (cm->cap_info & htole16(IEEE80211_HT_CAP_SUP_WIDTH_20_40)) | |
544 | printf("\t\t * supported channel width\n"); | |
545 | if (cm->cap_info & htole16(IEEE80211_HT_CAP_SGI_40)) | |
546 | printf("\t\t * short GI for 40 MHz\n"); | |
547 | if (cm->ampdu_params_info & IEEE80211_HT_AMPDU_PARM_FACTOR) | |
548 | printf("\t\t * max A-MPDU length exponent\n"); | |
549 | if (cm->ampdu_params_info & IEEE80211_HT_AMPDU_PARM_DENSITY) | |
550 | printf("\t\t * min MPDU start spacing\n"); | |
551 | } else { | |
552 | printf("\tERROR: capabilities mask is too short, expected: %d, received: %d\n", | |
553 | (int)(sizeof(*cm)), | |
554 | (int)(nla_len(tb_msg[NL80211_ATTR_HT_CAPABILITY_MASK]))); | |
555 | } | |
556 | } | |
557 | ||
632004a0 | 558 | if (tb_msg[NL80211_ATTR_FEATURE_FLAGS]) { |
d28df6b4 JB |
559 | unsigned int features = nla_get_u32(tb_msg[NL80211_ATTR_FEATURE_FLAGS]); |
560 | ||
561 | if (features & NL80211_FEATURE_SK_TX_STATUS) | |
632004a0 | 562 | printf("\tDevice supports TX status socket option.\n"); |
d28df6b4 | 563 | if (features & NL80211_FEATURE_HT_IBSS) |
632004a0 | 564 | printf("\tDevice supports HT-IBSS.\n"); |
d28df6b4 JB |
565 | if (features & NL80211_FEATURE_INACTIVITY_TIMER) |
566 | printf("\tDevice has client inactivity timer.\n"); | |
567 | if (features & NL80211_FEATURE_CELL_BASE_REG_HINTS) | |
568 | printf("\tDevice accepts cell base station regulatory hints.\n"); | |
569 | if (features & NL80211_FEATURE_P2P_DEVICE_NEEDS_CHANNEL) | |
570 | printf("\tP2P Device uses a channel (of the concurrent ones)\n"); | |
5973e65b JB |
571 | if (features & NL80211_FEATURE_SAE) |
572 | printf("\tDevice supports SAE with AUTHENTICATE command\n"); | |
fe862239 SL |
573 | if (features & NL80211_FEATURE_LOW_PRIORITY_SCAN) |
574 | printf("\tDevice supports low priority scan.\n"); | |
575 | if (features & NL80211_FEATURE_SCAN_FLUSH) | |
576 | printf("\tDevice supports scan flush.\n"); | |
afa2be2f AQ |
577 | if (features & NL80211_FEATURE_AP_SCAN) |
578 | printf("\tDevice supports AP scan.\n"); | |
5973e65b JB |
579 | if (features & NL80211_FEATURE_VIF_TXPOWER) |
580 | printf("\tDevice supports per-vif TX power setting\n"); | |
581 | if (features & NL80211_FEATURE_NEED_OBSS_SCAN) | |
582 | printf("\tUserspace should do OBSS scan and generate 20/40 coex reports\n"); | |
583 | if (features & NL80211_FEATURE_P2P_GO_CTWIN) | |
584 | printf("\tP2P GO supports CT window setting\n"); | |
585 | if (features & NL80211_FEATURE_P2P_GO_OPPPS) | |
586 | printf("\tP2P GO supports opportunistic powersave setting\n"); | |
587 | if (features & NL80211_FEATURE_FULL_AP_CLIENT_STATE) | |
588 | printf("\tDriver supports full state transitions for AP/GO clients\n"); | |
589 | if (features & NL80211_FEATURE_USERSPACE_MPM) | |
590 | printf("\tDriver supports a userspace MPM\n"); | |
591 | if (features & NL80211_FEATURE_ACTIVE_MONITOR) | |
592 | printf("\tDevice supports active monitor (which will ACK incoming frames)\n"); | |
593 | if (features & NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE) | |
594 | printf("\tDriver/device bandwidth changes during BSS lifetime (AP/GO mode)\n"); | |
595 | if (features & NL80211_FEATURE_DS_PARAM_SET_IE_IN_PROBES) | |
596 | printf("\tDevice adds DS IE to probe requests\n"); | |
597 | if (features & NL80211_FEATURE_WFA_TPC_IE_IN_PROBES) | |
598 | printf("\tDevice adds WFA TPC Report IE to probe requests\n"); | |
599 | if (features & NL80211_FEATURE_QUIET) | |
600 | printf("\tDevice supports quiet requests from AP\n"); | |
601 | if (features & NL80211_FEATURE_TX_POWER_INSERTION) | |
602 | printf("\tDevice can update TPC Report IE\n"); | |
e642142d LB |
603 | if (features & NL80211_FEATURE_ACKTO_ESTIMATION) |
604 | printf("\tDevice supports ACK timeout estimation.\n"); | |
5973e65b JB |
605 | if (features & NL80211_FEATURE_STATIC_SMPS) |
606 | printf("\tDevice supports static SMPS\n"); | |
607 | if (features & NL80211_FEATURE_DYNAMIC_SMPS) | |
608 | printf("\tDevice supports dynamic SMPS\n"); | |
e15ec749 JB |
609 | if (features & NL80211_FEATURE_SUPPORTS_WMM_ADMISSION) |
610 | printf("\tDevice supports WMM-AC admission (TSPECs)\n"); | |
ced5522d BG |
611 | if (features & NL80211_FEATURE_MAC_ON_CREATE) |
612 | printf("\tDevice supports configuring vdev MAC-addr on create.\n"); | |
c2f0d689 AN |
613 | if (features & NL80211_FEATURE_TDLS_CHANNEL_SWITCH) |
614 | printf("\tDevice supports TDLS channel switching\n"); | |
9b2849e0 BN |
615 | if (features & NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR) |
616 | printf("\tDevice supports randomizing MAC-addr in scans.\n"); | |
617 | if (features & NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR) | |
618 | printf("\tDevice supports randomizing MAC-addr in sched scans.\n"); | |
619 | if (features & NL80211_FEATURE_ND_RANDOM_MAC_ADDR) | |
620 | printf("\tDevice supports randomizing MAC-addr in net-detect scans.\n"); | |
632004a0 JB |
621 | } |
622 | ||
c1bdfe6a DL |
623 | if (tb_msg[NL80211_ATTR_TDLS_SUPPORT]) |
624 | printf("\tDevice supports T-DLS.\n"); | |
625 | ||
f0e30bd5 JD |
626 | if (tb_msg[NL80211_ATTR_EXT_FEATURES]) { |
627 | struct nlattr *tb = tb_msg[NL80211_ATTR_EXT_FEATURES]; | |
628 | ||
c1bdfe6a DL |
629 | printf("\tSupported extended features:\n"); |
630 | ||
02b53ea2 JB |
631 | ext_feat_print(tb, VHT_IBSS, "VHT-IBSS"); |
632 | ext_feat_print(tb, RRM, "RRM"); | |
633 | ext_feat_print(tb, MU_MIMO_AIR_SNIFFER, "MU-MIMO sniffer"); | |
634 | ext_feat_print(tb, SCAN_START_TIME, "scan start timestamp"); | |
635 | ext_feat_print(tb, BSS_PARENT_TSF, | |
636 | "BSS last beacon/probe TSF"); | |
637 | ext_feat_print(tb, SET_SCAN_DWELL, "scan dwell setting"); | |
638 | ext_feat_print(tb, BEACON_RATE_LEGACY, | |
639 | "legacy beacon rate setting"); | |
640 | ext_feat_print(tb, BEACON_RATE_HT, "HT beacon rate setting"); | |
641 | ext_feat_print(tb, BEACON_RATE_VHT, "VHT beacon rate setting"); | |
642 | ext_feat_print(tb, FILS_STA, | |
643 | "STA FILS (Fast Initial Link Setup)"); | |
644 | ext_feat_print(tb, MGMT_TX_RANDOM_TA, | |
c1bdfe6a | 645 | "randomized TA while not associated"); |
02b53ea2 | 646 | ext_feat_print(tb, MGMT_TX_RANDOM_TA_CONNECTED, |
c1bdfe6a | 647 | "randomized TA while associated"); |
02b53ea2 | 648 | ext_feat_print(tb, SCHED_SCAN_RELATIVE_RSSI, |
c1bdfe6a | 649 | "sched_scan for BSS with better RSSI report"); |
02b53ea2 | 650 | ext_feat_print(tb, CQM_RSSI_LIST, |
c1bdfe6a | 651 | "multiple CQM_RSSI_THOLD records"); |
02b53ea2 | 652 | ext_feat_print(tb, FILS_SK_OFFLOAD, |
c1bdfe6a | 653 | "FILS shared key authentication offload"); |
02b53ea2 | 654 | ext_feat_print(tb, 4WAY_HANDSHAKE_STA_PSK, |
c1bdfe6a | 655 | "4-way handshake with PSK in station mode"); |
02b53ea2 | 656 | ext_feat_print(tb, 4WAY_HANDSHAKE_STA_1X, |
c1bdfe6a | 657 | "4-way handshake with 802.1X in station mode"); |
02b53ea2 | 658 | ext_feat_print(tb, FILS_MAX_CHANNEL_TIME, |
c1bdfe6a | 659 | "FILS max channel attribute override with dwell time"); |
02b53ea2 | 660 | ext_feat_print(tb, ACCEPT_BCAST_PROBE_RESP, |
c1bdfe6a | 661 | "accepts broadcast probe response"); |
02b53ea2 | 662 | ext_feat_print(tb, OCE_PROBE_REQ_HIGH_TX_RATE, |
c1bdfe6a | 663 | "probe request TX at high rate (at least 5.5Mbps)"); |
02b53ea2 | 664 | ext_feat_print(tb, OCE_PROBE_REQ_DEFERRAL_SUPPRESSION, |
c1bdfe6a | 665 | "probe request tx deferral and suppression"); |
02b53ea2 | 666 | ext_feat_print(tb, MFP_OPTIONAL, |
c1bdfe6a | 667 | "MFP_OPTIONAL value in ATTR_USE_MFP"); |
02b53ea2 JB |
668 | ext_feat_print(tb, LOW_SPAN_SCAN, "low span scan"); |
669 | ext_feat_print(tb, LOW_POWER_SCAN, "low power scan"); | |
670 | ext_feat_print(tb, HIGH_ACCURACY_SCAN, "high accuracy scan"); | |
671 | ext_feat_print(tb, DFS_OFFLOAD, "DFS offload"); | |
672 | ext_feat_print(tb, CONTROL_PORT_OVER_NL80211, | |
c1bdfe6a | 673 | "control port over nl80211"); |
a39d32a4 MT |
674 | ext_feat_print(tb, ACK_SIGNAL_SUPPORT, |
675 | "ack signal level support"); | |
02b53ea2 | 676 | ext_feat_print(tb, TXQS, "FQ-CoDel-enabled intermediate TXQs"); |
a39d32a4 MT |
677 | ext_feat_print(tb, SCAN_RANDOM_SN, |
678 | "use random sequence numbers in scans"); | |
679 | ext_feat_print(tb, SCAN_MIN_PREQ_CONTENT, | |
680 | "use probe request with only rate IEs in scans"); | |
681 | ext_feat_print(tb, CAN_REPLACE_PTK0, | |
682 | "can safely replace PTK 0 when rekeying"); | |
683 | ext_feat_print(tb, ENABLE_FTM_RESPONDER, | |
684 | "enable FTM (Fine Time Measurement) responder"); | |
c95877ca JB |
685 | ext_feat_print(tb, AIRTIME_FAIRNESS, |
686 | "airtime fairness scheduling"); | |
b5c0c336 JB |
687 | ext_feat_print(tb, AP_PMKSA_CACHING, |
688 | "PMKSA caching supported in AP mode"); | |
689 | ext_feat_print(tb, SCHED_SCAN_BAND_SPECIFIC_RSSI_THOLD, | |
690 | "band specific RSSI thresholds for scheduled scan"); | |
05157b13 | 691 | ext_feat_print(tb, EXT_KEY_ID, "Extended Key ID support"); |
b5c0c336 JB |
692 | ext_feat_print(tb, STA_TX_PWR, "TX power control per station"); |
693 | ext_feat_print(tb, SAE_OFFLOAD, "SAE offload support"); | |
b31864bf | 694 | ext_feat_print(tb, VLAN_OFFLOAD, "VLAN offload support"); |
c95877ca JB |
695 | ext_feat_print(tb, AQL, |
696 | "Airtime Queue Limits (AQL)"); | |
ec9f3e7c MT |
697 | ext_feat_print(tb, BEACON_PROTECTION, "beacon protection support"); |
698 | ext_feat_print(tb, CONTROL_PORT_NO_PREAUTH, "disable pre-auth over nl80211 control port support"); | |
699 | ext_feat_print(tb, PROTECTED_TWT, "protected Target Wake Time (TWT) support"); | |
700 | ext_feat_print(tb, DEL_IBSS_STA, "deletion of IBSS station support"); | |
8e7cd59f MT |
701 | ext_feat_print(tb, MULTICAST_REGISTRATIONS, "mgmt frame registration for multicast"); |
702 | ext_feat_print(tb, BEACON_PROTECTION_CLIENT, "beacon prot. for clients support"); | |
703 | ext_feat_print(tb, SCAN_FREQ_KHZ, "scan on kHz frequency support"); | |
704 | ext_feat_print(tb, CONTROL_PORT_OVER_NL80211_TX_STATUS, "tx status for nl80211 control port support"); | |
06e9839f MT |
705 | ext_feat_print(tb, OPERATING_CHANNEL_VALIDATION, "Operating Channel Validation (OCV) support"); |
706 | ext_feat_print(tb, 4WAY_HANDSHAKE_AP_PSK, "AP mode PSK offload support"); | |
c95877ca JB |
707 | ext_feat_print(tb, SAE_OFFLOAD_AP, "AP mode SAE authentication offload support"); |
708 | ext_feat_print(tb, FILS_DISCOVERY, "FILS discovery frame transmission support"); | |
709 | ext_feat_print(tb, UNSOL_BCAST_PROBE_RESP, | |
710 | "unsolicated broadcast probe response transmission support"); | |
711 | ext_feat_print(tb, BEACON_RATE_HE, "HE beacon rate support (AP/mesh)"); | |
712 | ext_feat_print(tb, SECURE_LTF, "secure LTF measurement protocol support"); | |
713 | ext_feat_print(tb, SECURE_RTT, "secure RTT measurement protocol support"); | |
714 | ext_feat_print(tb, PROT_RANGE_NEGO_AND_MEASURE, | |
715 | "support for MFP in range measurement negotiation/procedure"); | |
86146088 | 716 | ext_feat_print(tb, BSS_COLOR, "BSS coloring support"); |
46242202 | 717 | ext_feat_print(tb, FILS_CRYPTO_OFFLOAD, "FILS crypto offload"); |
09009968 | 718 | ext_feat_print(tb, RADAR_BACKGROUND, "Radar background support"); |
f0e30bd5 JD |
719 | } |
720 | ||
aa0f5dbe AK |
721 | if (tb_msg[NL80211_ATTR_COALESCE_RULE]) { |
722 | struct nl80211_coalesce_rule_support *rule; | |
723 | struct nl80211_pattern_support *pat; | |
724 | ||
725 | printf("\tCoalesce support:\n"); | |
726 | rule = nla_data(tb_msg[NL80211_ATTR_COALESCE_RULE]); | |
727 | pat = &rule->pat; | |
728 | printf("\t\t * Maximum %u coalesce rules supported\n" | |
05a52674 | 729 | "\t\t * Each rule contains up to %u patterns of %u-%u bytes,\n" |
aa0f5dbe AK |
730 | "\t\t maximum packet offset %u bytes\n" |
731 | "\t\t * Maximum supported coalescing delay %u msecs\n", | |
732 | rule->max_rules, pat->max_patterns, pat->min_pattern_len, | |
733 | pat->max_pattern_len, pat->max_pkt_offset, rule->max_delay); | |
734 | } | |
735 | ||
10b9b03c PR |
736 | if (tb_msg[NL80211_ATTR_MAX_AP_ASSOC_STA]) |
737 | printf("\tMaximum associated stations in AP mode: %u\n", | |
738 | nla_get_u16(tb_msg[NL80211_ATTR_MAX_AP_ASSOC_STA])); | |
739 | ||
79f99b9a JB |
740 | return NL_SKIP; |
741 | } | |
742 | ||
c142fa28 JB |
743 | static bool nl80211_has_split_wiphy = false; |
744 | ||
7c37a24d | 745 | static int handle_info(struct nl80211_state *state, |
d631650b | 746 | struct nl_msg *msg, |
05514f95 JB |
747 | int argc, char **argv, |
748 | enum id_input id) | |
79f99b9a | 749 | { |
c142fa28 JB |
750 | char *feat_args[] = { "features", "-q" }; |
751 | int err; | |
752 | ||
befb32dc | 753 | err = handle_cmd(state, II_NONE, 2, feat_args); |
c142fa28 JB |
754 | if (!err && nl80211_has_split_wiphy) { |
755 | nla_put_flag(msg, NL80211_ATTR_SPLIT_WIPHY_DUMP); | |
756 | nlmsg_hdr(msg)->nlmsg_flags |= NLM_F_DUMP; | |
757 | } | |
758 | ||
34b23014 | 759 | register_handler(print_phy_handler, NULL); |
79f99b9a | 760 | |
70391ccf | 761 | return 0; |
79f99b9a | 762 | } |
c142fa28 | 763 | __COMMAND(NULL, info, "info", NULL, NL80211_CMD_GET_WIPHY, 0, 0, CIB_PHY, handle_info, |
1633ddf7 | 764 | "Show capabilities for the specified wireless device.", NULL); |
ea35fc0b JB |
765 | TOPLEVEL(list, NULL, NL80211_CMD_GET_WIPHY, NLM_F_DUMP, CIB_NONE, handle_info, |
766 | "List all wireless devices and their capabilities."); | |
01ae06f9 | 767 | TOPLEVEL(phy, NULL, NL80211_CMD_GET_WIPHY, NLM_F_DUMP, CIB_NONE, handle_info, NULL); |
bcdff0b2 | 768 | |
34b23014 | 769 | static int handle_commands(struct nl80211_state *state, struct nl_msg *msg, |
bcdff0b2 JB |
770 | int argc, char **argv, enum id_input id) |
771 | { | |
772 | int i; | |
516ef62a | 773 | for (i = 1; i <= NL80211_CMD_MAX; i++) |
bcdff0b2 JB |
774 | printf("%d (0x%x): %s\n", i, i, command_name(i)); |
775 | /* don't send netlink messages */ | |
776 | return 2; | |
777 | } | |
778 | TOPLEVEL(commands, NULL, NL80211_CMD_GET_WIPHY, 0, CIB_NONE, handle_commands, | |
779 | "list all known commands and their decimal & hex value"); | |
fb70e110 JB |
780 | |
781 | static int print_feature_handler(struct nl_msg *msg, void *arg) | |
782 | { | |
783 | struct nlattr *tb_msg[NL80211_ATTR_MAX + 1]; | |
784 | struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); | |
c142fa28 JB |
785 | bool print = (unsigned long)arg; |
786 | #define maybe_printf(...) do { if (print) printf(__VA_ARGS__); } while (0) | |
fb70e110 JB |
787 | |
788 | nla_parse(tb_msg, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), | |
789 | genlmsg_attrlen(gnlh, 0), NULL); | |
790 | ||
791 | if (tb_msg[NL80211_ATTR_PROTOCOL_FEATURES]) { | |
792 | uint32_t feat = nla_get_u32(tb_msg[NL80211_ATTR_PROTOCOL_FEATURES]); | |
793 | ||
c142fa28 JB |
794 | maybe_printf("nl80211 features: 0x%x\n", feat); |
795 | if (feat & NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP) { | |
796 | maybe_printf("\t* split wiphy dump\n"); | |
797 | nl80211_has_split_wiphy = true; | |
798 | } | |
fb70e110 JB |
799 | } |
800 | ||
801 | return NL_SKIP; | |
802 | } | |
803 | ||
34b23014 | 804 | static int handle_features(struct nl80211_state *state, struct nl_msg *msg, |
fb70e110 JB |
805 | int argc, char **argv, enum id_input id) |
806 | { | |
c142fa28 | 807 | unsigned long print = argc == 0 || strcmp(argv[0], "-q"); |
34b23014 | 808 | register_handler(print_feature_handler, (void *)print); |
fb70e110 JB |
809 | return 0; |
810 | } | |
811 | ||
c142fa28 | 812 | TOPLEVEL(features, "", NL80211_CMD_GET_PROTOCOL_FEATURES, 0, CIB_NONE, |
fb70e110 | 813 | handle_features, ""); |