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