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