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>
12 static void print_flag(const char *name
, int *open
)
22 static char *cipher_name(__u32 c
)
28 return "WEP40 (00-0f-ac:1)";
30 return "WEP104 (00-0f-ac:5)";
32 return "TKIP (00-0f-ac:2)";
34 return "CCMP-128 (00-0f-ac:4)";
36 return "CMAC (00-0f-ac:6)";
38 return "GCMP-128 (00-0f-ac:8)";
40 return "GCMP-256 (00-0f-ac:9)";
42 return "CCMP-256 (00-0f-ac:10)";
44 return "GMAC-128 (00-0f-ac:11)";
46 return "GMAC-256 (00-0f-ac:12)";
48 return "CMAC-256 (00-0f-ac:13)";
50 return "WPI-SMS4 (00-14-72:1)";
52 sprintf(buf
, "%.2x-%.2x-%.2x:%d",
53 c
>> 24, (c
>> 16) & 0xff,
54 (c
>> 8) & 0xff, c
& 0xff);
60 static int ext_feature_isset(const unsigned char *ext_features
, int ext_features_len
,
61 enum nl80211_ext_feature_index ftidx
)
63 unsigned char ft_byte
;
65 if ((int) ftidx
/ 8 >= ext_features_len
)
68 ft_byte
= ext_features
[ftidx
/ 8];
69 return (ft_byte
& BIT(ftidx
% 8)) != 0;
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
)
76 if (ext_feature_isset(nla_data(tb
), nla_len(tb
),idx
))
77 printf("\t\t* [ %s ]: %s\n", feature_name
, feature_desc
);
79 #define ext_feat_print(tb, name, desc) \
80 _ext_feat_print(tb, NL80211_EXT_FEATURE_##name, #name, desc)
82 static int print_phy_handler(struct nl_msg
*msg
, void *arg
)
84 struct nlattr
*tb_msg
[NL80211_ATTR_MAX
+ 1];
85 struct genlmsghdr
*gnlh
= nlmsg_data(nlmsg_hdr(msg
));
87 struct nlattr
*tb_band
[NL80211_BAND_ATTR_MAX
+ 1];
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
},
93 [NL80211_FREQUENCY_ATTR_NO_IR
] = { .type
= NLA_FLAG
},
94 [__NL80211_FREQUENCY_ATTR_NO_IBSS
] = { .type
= NLA_FLAG
},
95 [NL80211_FREQUENCY_ATTR_RADAR
] = { .type
= NLA_FLAG
},
96 [NL80211_FREQUENCY_ATTR_MAX_TX_POWER
] = { .type
= NLA_U32
},
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
},
105 struct nlattr
*nl_band
;
106 struct nlattr
*nl_freq
;
107 struct nlattr
*nl_rate
;
108 struct nlattr
*nl_mode
;
109 struct nlattr
*nl_cmd
;
110 struct nlattr
*nl_if
, *nl_ftype
;
111 int rem_band
, rem_freq
, rem_rate
, rem_mode
, rem_cmd
, rem_ftype
, rem_if
;
114 * static variables only work here, other applications need to use the
115 * callback pointer and store them there so they can be multithreaded
116 * and/or have multiple netlink sockets, etc.
118 static int64_t phy_id
= -1;
119 static int last_band
= -1;
120 static bool band_had_freq
= false;
121 bool print_name
= true;
123 nla_parse(tb_msg
, NL80211_ATTR_MAX
, genlmsg_attrdata(gnlh
, 0),
124 genlmsg_attrlen(gnlh
, 0), NULL
);
126 if (tb_msg
[NL80211_ATTR_WIPHY
]) {
127 if (nla_get_u32(tb_msg
[NL80211_ATTR_WIPHY
]) == phy_id
)
131 phy_id
= nla_get_u32(tb_msg
[NL80211_ATTR_WIPHY
]);
133 if (print_name
&& tb_msg
[NL80211_ATTR_WIPHY_NAME
])
134 printf("Wiphy %s\n", nla_get_string(tb_msg
[NL80211_ATTR_WIPHY_NAME
]));
136 /* needed for split dump */
137 if (tb_msg
[NL80211_ATTR_WIPHY_BANDS
]) {
138 nla_for_each_nested(nl_band
, tb_msg
[NL80211_ATTR_WIPHY_BANDS
], rem_band
) {
139 if (last_band
!= nl_band
->nla_type
) {
140 printf("\tBand %d:\n", nl_band
->nla_type
+ 1);
141 band_had_freq
= false;
143 last_band
= nl_band
->nla_type
;
145 nla_parse(tb_band
, NL80211_BAND_ATTR_MAX
, nla_data(nl_band
),
146 nla_len(nl_band
), NULL
);
148 if (tb_band
[NL80211_BAND_ATTR_HT_CAPA
]) {
149 __u16 cap
= nla_get_u16(tb_band
[NL80211_BAND_ATTR_HT_CAPA
]);
150 print_ht_capability(cap
);
152 if (tb_band
[NL80211_BAND_ATTR_HT_AMPDU_FACTOR
]) {
153 __u8 exponent
= nla_get_u8(tb_band
[NL80211_BAND_ATTR_HT_AMPDU_FACTOR
]);
154 print_ampdu_length(exponent
);
156 if (tb_band
[NL80211_BAND_ATTR_HT_AMPDU_DENSITY
]) {
157 __u8 spacing
= nla_get_u8(tb_band
[NL80211_BAND_ATTR_HT_AMPDU_DENSITY
]);
158 print_ampdu_spacing(spacing
);
160 if (tb_band
[NL80211_BAND_ATTR_HT_MCS_SET
] &&
161 nla_len(tb_band
[NL80211_BAND_ATTR_HT_MCS_SET
]) == 16)
162 print_ht_mcs(nla_data(tb_band
[NL80211_BAND_ATTR_HT_MCS_SET
]));
163 if (tb_band
[NL80211_BAND_ATTR_VHT_CAPA
] &&
164 tb_band
[NL80211_BAND_ATTR_VHT_MCS_SET
])
165 print_vht_info(nla_get_u32(tb_band
[NL80211_BAND_ATTR_VHT_CAPA
]),
166 nla_data(tb_band
[NL80211_BAND_ATTR_VHT_MCS_SET
]));
167 if (tb_band
[NL80211_BAND_ATTR_IFTYPE_DATA
]) {
168 struct nlattr
*nl_iftype
;
171 nla_for_each_nested(nl_iftype
, tb_band
[NL80211_BAND_ATTR_IFTYPE_DATA
], rem_band
)
172 print_he_info(nl_iftype
);
174 if (tb_band
[NL80211_BAND_ATTR_FREQS
]) {
175 if (!band_had_freq
) {
176 printf("\t\tFrequencies:\n");
177 band_had_freq
= true;
179 nla_for_each_nested(nl_freq
, tb_band
[NL80211_BAND_ATTR_FREQS
], rem_freq
) {
181 nla_parse(tb_freq
, NL80211_FREQUENCY_ATTR_MAX
, nla_data(nl_freq
),
182 nla_len(nl_freq
), freq_policy
);
183 if (!tb_freq
[NL80211_FREQUENCY_ATTR_FREQ
])
185 freq
= nla_get_u32(tb_freq
[NL80211_FREQUENCY_ATTR_FREQ
]);
186 printf("\t\t\t* %d MHz [%d]", freq
, ieee80211_frequency_to_channel(freq
));
188 if (tb_freq
[NL80211_FREQUENCY_ATTR_MAX_TX_POWER
] &&
189 !tb_freq
[NL80211_FREQUENCY_ATTR_DISABLED
])
190 printf(" (%.1f dBm)", 0.01 * nla_get_u32(tb_freq
[NL80211_FREQUENCY_ATTR_MAX_TX_POWER
]));
193 if (tb_freq
[NL80211_FREQUENCY_ATTR_DISABLED
]) {
194 print_flag("disabled", &open
);
198 /* If both flags are set assume an new kernel */
199 if (tb_freq
[NL80211_FREQUENCY_ATTR_NO_IR
] && tb_freq
[__NL80211_FREQUENCY_ATTR_NO_IBSS
]) {
200 print_flag("no IR", &open
);
201 } else if (tb_freq
[NL80211_FREQUENCY_ATTR_PASSIVE_SCAN
]) {
202 print_flag("passive scan", &open
);
203 } else if (tb_freq
[__NL80211_FREQUENCY_ATTR_NO_IBSS
]){
204 print_flag("no ibss", &open
);
207 if (tb_freq
[NL80211_FREQUENCY_ATTR_RADAR
])
208 print_flag("radar detection", &open
);
216 if (tb_band
[NL80211_BAND_ATTR_RATES
]) {
217 printf("\t\tBitrates (non-HT):\n");
218 nla_for_each_nested(nl_rate
, tb_band
[NL80211_BAND_ATTR_RATES
], rem_rate
) {
219 nla_parse(tb_rate
, NL80211_BITRATE_ATTR_MAX
, nla_data(nl_rate
),
220 nla_len(nl_rate
), rate_policy
);
221 if (!tb_rate
[NL80211_BITRATE_ATTR_RATE
])
223 printf("\t\t\t* %2.1f Mbps", 0.1 * nla_get_u32(tb_rate
[NL80211_BITRATE_ATTR_RATE
]));
225 if (tb_rate
[NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE
])
226 print_flag("short preamble supported", &open
);
235 if (tb_msg
[NL80211_ATTR_MAX_NUM_SCAN_SSIDS
])
236 printf("\tmax # scan SSIDs: %d\n",
237 nla_get_u8(tb_msg
[NL80211_ATTR_MAX_NUM_SCAN_SSIDS
]));
238 if (tb_msg
[NL80211_ATTR_MAX_SCAN_IE_LEN
])
239 printf("\tmax scan IEs length: %d bytes\n",
240 nla_get_u16(tb_msg
[NL80211_ATTR_MAX_SCAN_IE_LEN
]));
241 if (tb_msg
[NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS
])
242 printf("\tmax # sched scan SSIDs: %d\n",
243 nla_get_u8(tb_msg
[NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS
]));
244 if (tb_msg
[NL80211_ATTR_MAX_MATCH_SETS
])
245 printf("\tmax # match sets: %d\n",
246 nla_get_u8(tb_msg
[NL80211_ATTR_MAX_MATCH_SETS
]));
247 if (tb_msg
[NL80211_ATTR_MAX_NUM_SCHED_SCAN_PLANS
])
248 printf("\tmax # scan plans: %d\n",
249 nla_get_u32(tb_msg
[NL80211_ATTR_MAX_NUM_SCHED_SCAN_PLANS
]));
250 if (tb_msg
[NL80211_ATTR_MAX_SCAN_PLAN_INTERVAL
])
251 printf("\tmax scan plan interval: %d\n",
252 nla_get_u32(tb_msg
[NL80211_ATTR_MAX_SCAN_PLAN_INTERVAL
]));
253 if (tb_msg
[NL80211_ATTR_MAX_SCAN_PLAN_ITERATIONS
])
254 printf("\tmax scan plan iterations: %d\n",
255 nla_get_u32(tb_msg
[NL80211_ATTR_MAX_SCAN_PLAN_ITERATIONS
]));
257 if (tb_msg
[NL80211_ATTR_WIPHY_FRAG_THRESHOLD
]) {
260 frag
= nla_get_u32(tb_msg
[NL80211_ATTR_WIPHY_FRAG_THRESHOLD
]);
261 if (frag
!= (unsigned int)-1)
262 printf("\tFragmentation threshold: %d\n", frag
);
265 if (tb_msg
[NL80211_ATTR_WIPHY_RTS_THRESHOLD
]) {
268 rts
= nla_get_u32(tb_msg
[NL80211_ATTR_WIPHY_RTS_THRESHOLD
]);
269 if (rts
!= (unsigned int)-1)
270 printf("\tRTS threshold: %d\n", rts
);
273 if (tb_msg
[NL80211_ATTR_WIPHY_RETRY_SHORT
] ||
274 tb_msg
[NL80211_ATTR_WIPHY_RETRY_LONG
]) {
275 unsigned char retry_short
= 0, retry_long
= 0;
277 if (tb_msg
[NL80211_ATTR_WIPHY_RETRY_SHORT
])
278 retry_short
= nla_get_u8(tb_msg
[NL80211_ATTR_WIPHY_RETRY_SHORT
]);
279 if (tb_msg
[NL80211_ATTR_WIPHY_RETRY_LONG
])
280 retry_long
= nla_get_u8(tb_msg
[NL80211_ATTR_WIPHY_RETRY_LONG
]);
281 if (retry_short
== retry_long
) {
282 printf("\tRetry short long limit: %d\n", retry_short
);
284 printf("\tRetry short limit: %d\n", retry_short
);
285 printf("\tRetry long limit: %d\n", retry_long
);
289 if (tb_msg
[NL80211_ATTR_WIPHY_COVERAGE_CLASS
]) {
290 unsigned char coverage
;
292 coverage
= nla_get_u8(tb_msg
[NL80211_ATTR_WIPHY_COVERAGE_CLASS
]);
293 /* See handle_distance() for an explanation where the '450' comes from */
294 printf("\tCoverage class: %d (up to %dm)\n", coverage
, 450 * coverage
);
297 if (tb_msg
[NL80211_ATTR_CIPHER_SUITES
]) {
298 int num
= nla_len(tb_msg
[NL80211_ATTR_CIPHER_SUITES
]) / sizeof(__u32
);
300 __u32
*ciphers
= nla_data(tb_msg
[NL80211_ATTR_CIPHER_SUITES
]);
302 printf("\tSupported Ciphers:\n");
303 for (i
= 0; i
< num
; i
++)
305 cipher_name(ciphers
[i
]));
309 if (tb_msg
[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX
] &&
310 tb_msg
[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX
])
311 printf("\tAvailable Antennas: TX %#x RX %#x\n",
312 nla_get_u32(tb_msg
[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX
]),
313 nla_get_u32(tb_msg
[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX
]));
315 if (tb_msg
[NL80211_ATTR_WIPHY_ANTENNA_TX
] &&
316 tb_msg
[NL80211_ATTR_WIPHY_ANTENNA_RX
])
317 printf("\tConfigured Antennas: TX %#x RX %#x\n",
318 nla_get_u32(tb_msg
[NL80211_ATTR_WIPHY_ANTENNA_TX
]),
319 nla_get_u32(tb_msg
[NL80211_ATTR_WIPHY_ANTENNA_RX
]));
321 if (tb_msg
[NL80211_ATTR_SUPPORTED_IFTYPES
]) {
322 printf("\tSupported interface modes:\n");
323 nla_for_each_nested(nl_mode
, tb_msg
[NL80211_ATTR_SUPPORTED_IFTYPES
], rem_mode
)
324 printf("\t\t * %s\n", iftype_name(nla_type(nl_mode
)));
327 if (tb_msg
[NL80211_ATTR_SOFTWARE_IFTYPES
]) {
328 printf("\tsoftware interface modes (can always be added):\n");
329 nla_for_each_nested(nl_mode
, tb_msg
[NL80211_ATTR_SOFTWARE_IFTYPES
], rem_mode
)
330 printf("\t\t * %s\n", iftype_name(nla_type(nl_mode
)));
333 if (tb_msg
[NL80211_ATTR_INTERFACE_COMBINATIONS
]) {
334 struct nlattr
*nl_combi
;
336 bool have_combinations
= false;
338 nla_for_each_nested(nl_combi
, tb_msg
[NL80211_ATTR_INTERFACE_COMBINATIONS
], rem_combi
) {
339 static struct nla_policy iface_combination_policy
[NUM_NL80211_IFACE_COMB
] = {
340 [NL80211_IFACE_COMB_LIMITS
] = { .type
= NLA_NESTED
},
341 [NL80211_IFACE_COMB_MAXNUM
] = { .type
= NLA_U32
},
342 [NL80211_IFACE_COMB_STA_AP_BI_MATCH
] = { .type
= NLA_FLAG
},
343 [NL80211_IFACE_COMB_NUM_CHANNELS
] = { .type
= NLA_U32
},
344 [NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS
] = { .type
= NLA_U32
},
346 struct nlattr
*tb_comb
[NUM_NL80211_IFACE_COMB
];
347 static struct nla_policy iface_limit_policy
[NUM_NL80211_IFACE_LIMIT
] = {
348 [NL80211_IFACE_LIMIT_TYPES
] = { .type
= NLA_NESTED
},
349 [NL80211_IFACE_LIMIT_MAX
] = { .type
= NLA_U32
},
351 struct nlattr
*tb_limit
[NUM_NL80211_IFACE_LIMIT
];
352 struct nlattr
*nl_limit
;
356 if (!have_combinations
) {
357 printf("\tvalid interface combinations:\n");
358 have_combinations
= true;
363 err
= nla_parse_nested(tb_comb
, MAX_NL80211_IFACE_COMB
,
364 nl_combi
, iface_combination_policy
);
365 if (err
|| !tb_comb
[NL80211_IFACE_COMB_LIMITS
] ||
366 !tb_comb
[NL80211_IFACE_COMB_MAXNUM
] ||
367 !tb_comb
[NL80211_IFACE_COMB_NUM_CHANNELS
]) {
368 printf(" <failed to parse>\n");
369 goto broken_combination
;
372 nla_for_each_nested(nl_limit
, tb_comb
[NL80211_IFACE_COMB_LIMITS
], rem_limit
) {
373 bool ift_comma
= false;
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
;
387 nla_for_each_nested(nl_mode
, tb_limit
[NL80211_IFACE_LIMIT_TYPES
], rem_mode
) {
388 printf("%s %s", ift_comma
? "," : "",
389 iftype_name(nla_type(nl_mode
)));
392 printf(" } <= %u", nla_get_u32(tb_limit
[NL80211_IFACE_LIMIT_MAX
]));
396 printf("total <= %d, #channels <= %d%s",
397 nla_get_u32(tb_comb
[NL80211_IFACE_COMB_MAXNUM
]),
398 nla_get_u32(tb_comb
[NL80211_IFACE_COMB_NUM_CHANNELS
]),
399 tb_comb
[NL80211_IFACE_COMB_STA_AP_BI_MATCH
] ?
400 ", STA/AP BI must match" : "");
401 if (tb_comb
[NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS
]) {
402 unsigned long widths
= nla_get_u32(tb_comb
[NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS
]);
408 printf(", radar detect widths: {");
409 for (width
= 0; width
< 32; width
++)
410 if (widths
& (1 << width
)) {
413 channel_width_name(width
));
424 if (!have_combinations
)
425 printf("\tinterface combinations are not supported\n");
428 if (tb_msg
[NL80211_ATTR_SUPPORTED_COMMANDS
]) {
429 printf("\tSupported commands:\n");
430 nla_for_each_nested(nl_cmd
, tb_msg
[NL80211_ATTR_SUPPORTED_COMMANDS
], rem_cmd
)
431 printf("\t\t * %s\n", command_name(nla_get_u32(nl_cmd
)));
434 if (tb_msg
[NL80211_ATTR_TX_FRAME_TYPES
]) {
435 printf("\tSupported TX frame types:\n");
436 nla_for_each_nested(nl_if
, tb_msg
[NL80211_ATTR_TX_FRAME_TYPES
], rem_if
) {
437 bool printed
= false;
438 nla_for_each_nested(nl_ftype
, nl_if
, rem_ftype
) {
440 printf("\t\t * %s:", iftype_name(nla_type(nl_if
)));
442 printf(" 0x%.2x", nla_get_u16(nl_ftype
));
449 if (tb_msg
[NL80211_ATTR_RX_FRAME_TYPES
]) {
450 printf("\tSupported RX frame types:\n");
451 nla_for_each_nested(nl_if
, tb_msg
[NL80211_ATTR_RX_FRAME_TYPES
], rem_if
) {
452 bool printed
= false;
453 nla_for_each_nested(nl_ftype
, nl_if
, rem_ftype
) {
455 printf("\t\t * %s:", iftype_name(nla_type(nl_if
)));
457 printf(" 0x%.2x", nla_get_u16(nl_ftype
));
464 if (tb_msg
[NL80211_ATTR_SUPPORT_IBSS_RSN
])
465 printf("\tDevice supports RSN-IBSS.\n");
467 if (tb_msg
[NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED
]) {
468 struct nlattr
*tb_wowlan
[NUM_NL80211_WOWLAN_TRIG
];
469 static struct nla_policy wowlan_policy
[NUM_NL80211_WOWLAN_TRIG
] = {
470 [NL80211_WOWLAN_TRIG_ANY
] = { .type
= NLA_FLAG
},
471 [NL80211_WOWLAN_TRIG_DISCONNECT
] = { .type
= NLA_FLAG
},
472 [NL80211_WOWLAN_TRIG_MAGIC_PKT
] = { .type
= NLA_FLAG
},
473 [NL80211_WOWLAN_TRIG_PKT_PATTERN
] = { .minlen
= 12 },
474 [NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED
] = { .type
= NLA_FLAG
},
475 [NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE
] = { .type
= NLA_FLAG
},
476 [NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST
] = { .type
= NLA_FLAG
},
477 [NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE
] = { .type
= NLA_FLAG
},
478 [NL80211_WOWLAN_TRIG_RFKILL_RELEASE
] = { .type
= NLA_FLAG
},
479 [NL80211_WOWLAN_TRIG_NET_DETECT
] = { .type
= NLA_U32
},
480 [NL80211_WOWLAN_TRIG_TCP_CONNECTION
] = { .type
= NLA_NESTED
},
482 struct nl80211_pattern_support
*pat
;
485 err
= nla_parse_nested(tb_wowlan
, MAX_NL80211_WOWLAN_TRIG
,
486 tb_msg
[NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED
],
488 printf("\tWoWLAN support:");
490 printf(" <failed to parse>\n");
493 if (tb_wowlan
[NL80211_WOWLAN_TRIG_ANY
])
494 printf("\t\t * wake up on anything (device continues operating normally)\n");
495 if (tb_wowlan
[NL80211_WOWLAN_TRIG_DISCONNECT
])
496 printf("\t\t * wake up on disconnect\n");
497 if (tb_wowlan
[NL80211_WOWLAN_TRIG_MAGIC_PKT
])
498 printf("\t\t * wake up on magic packet\n");
499 if (tb_wowlan
[NL80211_WOWLAN_TRIG_PKT_PATTERN
]) {
500 unsigned int len
= nla_len(tb_wowlan
[NL80211_WOWLAN_TRIG_PKT_PATTERN
]);
502 pat
= nla_data(tb_wowlan
[NL80211_WOWLAN_TRIG_PKT_PATTERN
]);
503 printf("\t\t * wake up on pattern match, up to %u patterns of %u-%u bytes,\n"
504 "\t\t maximum packet offset %u bytes\n",
505 pat
->max_patterns
, pat
->min_pattern_len
, pat
->max_pattern_len
,
506 len
< sizeof(*pat
) ? 0 : pat
->max_pkt_offset
);
508 if (tb_wowlan
[NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED
])
509 printf("\t\t * can do GTK rekeying\n");
510 if (tb_wowlan
[NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE
])
511 printf("\t\t * wake up on GTK rekey failure\n");
512 if (tb_wowlan
[NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST
])
513 printf("\t\t * wake up on EAP identity request\n");
514 if (tb_wowlan
[NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE
])
515 printf("\t\t * wake up on 4-way handshake\n");
516 if (tb_wowlan
[NL80211_WOWLAN_TRIG_RFKILL_RELEASE
])
517 printf("\t\t * wake up on rfkill release\n");
518 if (tb_wowlan
[NL80211_WOWLAN_TRIG_NET_DETECT
])
519 printf("\t\t * wake up on network detection, up to %d match sets\n",
520 nla_get_u32(tb_wowlan
[NL80211_WOWLAN_TRIG_NET_DETECT
]));
521 if (tb_wowlan
[NL80211_WOWLAN_TRIG_TCP_CONNECTION
])
522 printf("\t\t * wake up on TCP connection\n");
526 if (tb_msg
[NL80211_ATTR_ROAM_SUPPORT
])
527 printf("\tDevice supports roaming.\n");
529 if (tb_msg
[NL80211_ATTR_SUPPORT_AP_UAPSD
])
530 printf("\tDevice supports AP-side u-APSD.\n");
532 if (tb_msg
[NL80211_ATTR_HT_CAPABILITY_MASK
]) {
533 struct ieee80211_ht_cap
*cm
;
534 unsigned int len
= nla_len(tb_msg
[NL80211_ATTR_HT_CAPABILITY_MASK
]);
536 printf("\tHT Capability overrides:\n");
537 if (len
>= sizeof(*cm
)) {
538 cm
= nla_data(tb_msg
[NL80211_ATTR_HT_CAPABILITY_MASK
]);
539 printf("\t\t * MCS: %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx"
540 " %02hhx %02hhx %02hhx %02hhx\n",
541 cm
->mcs
.rx_mask
[0], cm
->mcs
.rx_mask
[1],
542 cm
->mcs
.rx_mask
[2], cm
->mcs
.rx_mask
[3],
543 cm
->mcs
.rx_mask
[4], cm
->mcs
.rx_mask
[5],
544 cm
->mcs
.rx_mask
[6], cm
->mcs
.rx_mask
[7],
545 cm
->mcs
.rx_mask
[8], cm
->mcs
.rx_mask
[9]);
546 if (cm
->cap_info
& htole16(IEEE80211_HT_CAP_MAX_AMSDU
))
547 printf("\t\t * maximum A-MSDU length\n");
548 if (cm
->cap_info
& htole16(IEEE80211_HT_CAP_SUP_WIDTH_20_40
))
549 printf("\t\t * supported channel width\n");
550 if (cm
->cap_info
& htole16(IEEE80211_HT_CAP_SGI_40
))
551 printf("\t\t * short GI for 40 MHz\n");
552 if (cm
->ampdu_params_info
& IEEE80211_HT_AMPDU_PARM_FACTOR
)
553 printf("\t\t * max A-MPDU length exponent\n");
554 if (cm
->ampdu_params_info
& IEEE80211_HT_AMPDU_PARM_DENSITY
)
555 printf("\t\t * min MPDU start spacing\n");
557 printf("\tERROR: capabilities mask is too short, expected: %d, received: %d\n",
559 (int)(nla_len(tb_msg
[NL80211_ATTR_HT_CAPABILITY_MASK
])));
563 if (tb_msg
[NL80211_ATTR_FEATURE_FLAGS
]) {
564 unsigned int features
= nla_get_u32(tb_msg
[NL80211_ATTR_FEATURE_FLAGS
]);
566 if (features
& NL80211_FEATURE_SK_TX_STATUS
)
567 printf("\tDevice supports TX status socket option.\n");
568 if (features
& NL80211_FEATURE_HT_IBSS
)
569 printf("\tDevice supports HT-IBSS.\n");
570 if (features
& NL80211_FEATURE_INACTIVITY_TIMER
)
571 printf("\tDevice has client inactivity timer.\n");
572 if (features
& NL80211_FEATURE_CELL_BASE_REG_HINTS
)
573 printf("\tDevice accepts cell base station regulatory hints.\n");
574 if (features
& NL80211_FEATURE_P2P_DEVICE_NEEDS_CHANNEL
)
575 printf("\tP2P Device uses a channel (of the concurrent ones)\n");
576 if (features
& NL80211_FEATURE_SAE
)
577 printf("\tDevice supports SAE with AUTHENTICATE command\n");
578 if (features
& NL80211_FEATURE_LOW_PRIORITY_SCAN
)
579 printf("\tDevice supports low priority scan.\n");
580 if (features
& NL80211_FEATURE_SCAN_FLUSH
)
581 printf("\tDevice supports scan flush.\n");
582 if (features
& NL80211_FEATURE_AP_SCAN
)
583 printf("\tDevice supports AP scan.\n");
584 if (features
& NL80211_FEATURE_VIF_TXPOWER
)
585 printf("\tDevice supports per-vif TX power setting\n");
586 if (features
& NL80211_FEATURE_NEED_OBSS_SCAN
)
587 printf("\tUserspace should do OBSS scan and generate 20/40 coex reports\n");
588 if (features
& NL80211_FEATURE_P2P_GO_CTWIN
)
589 printf("\tP2P GO supports CT window setting\n");
590 if (features
& NL80211_FEATURE_P2P_GO_OPPPS
)
591 printf("\tP2P GO supports opportunistic powersave setting\n");
592 if (features
& NL80211_FEATURE_FULL_AP_CLIENT_STATE
)
593 printf("\tDriver supports full state transitions for AP/GO clients\n");
594 if (features
& NL80211_FEATURE_USERSPACE_MPM
)
595 printf("\tDriver supports a userspace MPM\n");
596 if (features
& NL80211_FEATURE_ACTIVE_MONITOR
)
597 printf("\tDevice supports active monitor (which will ACK incoming frames)\n");
598 if (features
& NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE
)
599 printf("\tDriver/device bandwidth changes during BSS lifetime (AP/GO mode)\n");
600 if (features
& NL80211_FEATURE_DS_PARAM_SET_IE_IN_PROBES
)
601 printf("\tDevice adds DS IE to probe requests\n");
602 if (features
& NL80211_FEATURE_WFA_TPC_IE_IN_PROBES
)
603 printf("\tDevice adds WFA TPC Report IE to probe requests\n");
604 if (features
& NL80211_FEATURE_QUIET
)
605 printf("\tDevice supports quiet requests from AP\n");
606 if (features
& NL80211_FEATURE_TX_POWER_INSERTION
)
607 printf("\tDevice can update TPC Report IE\n");
608 if (features
& NL80211_FEATURE_ACKTO_ESTIMATION
)
609 printf("\tDevice supports ACK timeout estimation.\n");
610 if (features
& NL80211_FEATURE_STATIC_SMPS
)
611 printf("\tDevice supports static SMPS\n");
612 if (features
& NL80211_FEATURE_DYNAMIC_SMPS
)
613 printf("\tDevice supports dynamic SMPS\n");
614 if (features
& NL80211_FEATURE_SUPPORTS_WMM_ADMISSION
)
615 printf("\tDevice supports WMM-AC admission (TSPECs)\n");
616 if (features
& NL80211_FEATURE_MAC_ON_CREATE
)
617 printf("\tDevice supports configuring vdev MAC-addr on create.\n");
618 if (features
& NL80211_FEATURE_TDLS_CHANNEL_SWITCH
)
619 printf("\tDevice supports TDLS channel switching\n");
620 if (features
& NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR
)
621 printf("\tDevice supports randomizing MAC-addr in scans.\n");
622 if (features
& NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR
)
623 printf("\tDevice supports randomizing MAC-addr in sched scans.\n");
624 if (features
& NL80211_FEATURE_ND_RANDOM_MAC_ADDR
)
625 printf("\tDevice supports randomizing MAC-addr in net-detect scans.\n");
628 if (tb_msg
[NL80211_ATTR_TDLS_SUPPORT
])
629 printf("\tDevice supports T-DLS.\n");
631 if (tb_msg
[NL80211_ATTR_EXT_FEATURES
]) {
632 struct nlattr
*tb
= tb_msg
[NL80211_ATTR_EXT_FEATURES
];
634 printf("\tSupported extended features:\n");
636 ext_feat_print(tb
, VHT_IBSS
, "VHT-IBSS");
637 ext_feat_print(tb
, RRM
, "RRM");
638 ext_feat_print(tb
, MU_MIMO_AIR_SNIFFER
, "MU-MIMO sniffer");
639 ext_feat_print(tb
, SCAN_START_TIME
, "scan start timestamp");
640 ext_feat_print(tb
, BSS_PARENT_TSF
,
641 "BSS last beacon/probe TSF");
642 ext_feat_print(tb
, SET_SCAN_DWELL
, "scan dwell setting");
643 ext_feat_print(tb
, BEACON_RATE_LEGACY
,
644 "legacy beacon rate setting");
645 ext_feat_print(tb
, BEACON_RATE_HT
, "HT beacon rate setting");
646 ext_feat_print(tb
, BEACON_RATE_VHT
, "VHT beacon rate setting");
647 ext_feat_print(tb
, FILS_STA
,
648 "STA FILS (Fast Initial Link Setup)");
649 ext_feat_print(tb
, MGMT_TX_RANDOM_TA
,
650 "randomized TA while not associated");
651 ext_feat_print(tb
, MGMT_TX_RANDOM_TA_CONNECTED
,
652 "randomized TA while associated");
653 ext_feat_print(tb
, SCHED_SCAN_RELATIVE_RSSI
,
654 "sched_scan for BSS with better RSSI report");
655 ext_feat_print(tb
, CQM_RSSI_LIST
,
656 "multiple CQM_RSSI_THOLD records");
657 ext_feat_print(tb
, FILS_SK_OFFLOAD
,
658 "FILS shared key authentication offload");
659 ext_feat_print(tb
, 4WAY_HANDSHAKE_STA_PSK
,
660 "4-way handshake with PSK in station mode");
661 ext_feat_print(tb
, 4WAY_HANDSHAKE_STA_1X
,
662 "4-way handshake with 802.1X in station mode");
663 ext_feat_print(tb
, FILS_MAX_CHANNEL_TIME
,
664 "FILS max channel attribute override with dwell time");
665 ext_feat_print(tb
, ACCEPT_BCAST_PROBE_RESP
,
666 "accepts broadcast probe response");
667 ext_feat_print(tb
, OCE_PROBE_REQ_HIGH_TX_RATE
,
668 "probe request TX at high rate (at least 5.5Mbps)");
669 ext_feat_print(tb
, OCE_PROBE_REQ_DEFERRAL_SUPPRESSION
,
670 "probe request tx deferral and suppression");
671 ext_feat_print(tb
, MFP_OPTIONAL
,
672 "MFP_OPTIONAL value in ATTR_USE_MFP");
673 ext_feat_print(tb
, LOW_SPAN_SCAN
, "low span scan");
674 ext_feat_print(tb
, LOW_POWER_SCAN
, "low power scan");
675 ext_feat_print(tb
, HIGH_ACCURACY_SCAN
, "high accuracy scan");
676 ext_feat_print(tb
, DFS_OFFLOAD
, "DFS offload");
677 ext_feat_print(tb
, CONTROL_PORT_OVER_NL80211
,
678 "control port over nl80211");
679 ext_feat_print(tb
, ACK_SIGNAL_SUPPORT
,
680 "ack signal level support");
681 ext_feat_print(tb
, TXQS
, "FQ-CoDel-enabled intermediate TXQs");
682 ext_feat_print(tb
, AIRTIME_FAIRNESS
,
683 "airtime fairness scheduling");
684 ext_feat_print(tb
, AQL
,
685 "Airtime Queue Limits (AQL)");
686 ext_feat_print(tb
, SCAN_RANDOM_SN
,
687 "use random sequence numbers in scans");
688 ext_feat_print(tb
, SCAN_MIN_PREQ_CONTENT
,
689 "use probe request with only rate IEs in scans");
690 ext_feat_print(tb
, CAN_REPLACE_PTK0
,
691 "can safely replace PTK 0 when rekeying");
692 ext_feat_print(tb
, ENABLE_FTM_RESPONDER
,
693 "enable FTM (Fine Time Measurement) responder");
694 ext_feat_print(tb
, AP_PMKSA_CACHING
,
695 "PMKSA caching supported in AP mode");
696 ext_feat_print(tb
, SCHED_SCAN_BAND_SPECIFIC_RSSI_THOLD
,
697 "band specific RSSI thresholds for scheduled scan");
698 ext_feat_print(tb
, EXT_KEY_ID
, "extended key ID support");
699 ext_feat_print(tb
, STA_TX_PWR
, "TX power control per station");
700 ext_feat_print(tb
, SAE_OFFLOAD
, "SAE offload support");
701 ext_feat_print(tb
, VLAN_OFFLOAD
, "VLAN offload support");
704 if (tb_msg
[NL80211_ATTR_COALESCE_RULE
]) {
705 struct nl80211_coalesce_rule_support
*rule
;
706 struct nl80211_pattern_support
*pat
;
708 printf("\tCoalesce support:\n");
709 rule
= nla_data(tb_msg
[NL80211_ATTR_COALESCE_RULE
]);
711 printf("\t\t * Maximum %u coalesce rules supported\n"
712 "\t\t * Each rule contains upto %u patterns of %u-%u bytes,\n"
713 "\t\t maximum packet offset %u bytes\n"
714 "\t\t * Maximum supported coalescing delay %u msecs\n",
715 rule
->max_rules
, pat
->max_patterns
, pat
->min_pattern_len
,
716 pat
->max_pattern_len
, pat
->max_pkt_offset
, rule
->max_delay
);
722 static bool nl80211_has_split_wiphy
= false;
724 static int handle_info(struct nl80211_state
*state
,
726 int argc
, char **argv
,
729 char *feat_args
[] = { "features", "-q" };
732 err
= handle_cmd(state
, II_NONE
, 2, feat_args
);
733 if (!err
&& nl80211_has_split_wiphy
) {
734 nla_put_flag(msg
, NL80211_ATTR_SPLIT_WIPHY_DUMP
);
735 nlmsg_hdr(msg
)->nlmsg_flags
|= NLM_F_DUMP
;
738 register_handler(print_phy_handler
, NULL
);
742 __COMMAND(NULL
, info
, "info", NULL
, NL80211_CMD_GET_WIPHY
, 0, 0, CIB_PHY
, handle_info
,
743 "Show capabilities for the specified wireless device.", NULL
);
744 TOPLEVEL(list
, NULL
, NL80211_CMD_GET_WIPHY
, NLM_F_DUMP
, CIB_NONE
, handle_info
,
745 "List all wireless devices and their capabilities.");
746 TOPLEVEL(phy
, NULL
, NL80211_CMD_GET_WIPHY
, NLM_F_DUMP
, CIB_NONE
, handle_info
, NULL
);
748 static int handle_commands(struct nl80211_state
*state
, struct nl_msg
*msg
,
749 int argc
, char **argv
, enum id_input id
)
752 for (i
= 1; i
<= NL80211_CMD_MAX
; i
++)
753 printf("%d (0x%x): %s\n", i
, i
, command_name(i
));
754 /* don't send netlink messages */
757 TOPLEVEL(commands
, NULL
, NL80211_CMD_GET_WIPHY
, 0, CIB_NONE
, handle_commands
,
758 "list all known commands and their decimal & hex value");
760 static int print_feature_handler(struct nl_msg
*msg
, void *arg
)
762 struct nlattr
*tb_msg
[NL80211_ATTR_MAX
+ 1];
763 struct genlmsghdr
*gnlh
= nlmsg_data(nlmsg_hdr(msg
));
764 bool print
= (unsigned long)arg
;
765 #define maybe_printf(...) do { if (print) printf(__VA_ARGS__); } while (0)
767 nla_parse(tb_msg
, NL80211_ATTR_MAX
, genlmsg_attrdata(gnlh
, 0),
768 genlmsg_attrlen(gnlh
, 0), NULL
);
770 if (tb_msg
[NL80211_ATTR_PROTOCOL_FEATURES
]) {
771 uint32_t feat
= nla_get_u32(tb_msg
[NL80211_ATTR_PROTOCOL_FEATURES
]);
773 maybe_printf("nl80211 features: 0x%x\n", feat
);
774 if (feat
& NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP
) {
775 maybe_printf("\t* split wiphy dump\n");
776 nl80211_has_split_wiphy
= true;
783 static int handle_features(struct nl80211_state
*state
, struct nl_msg
*msg
,
784 int argc
, char **argv
, enum id_input id
)
786 unsigned long print
= argc
== 0 || strcmp(argv
[0], "-q");
787 register_handler(print_feature_handler
, (void *)print
);
791 TOPLEVEL(features
, "", NL80211_CMD_GET_PROTOCOL_FEATURES
, 0, CIB_NONE
,
792 handle_features
, "");