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 (00-0f-ac:4)";
36 return "CMAC (00-0f-ac:6)";
38 return "GCMP (00-0f-ac:8)";
40 return "WPI-SMS4 (00-14-72:1)";
42 sprintf(buf
, "%.2x-%.2x-%.2x:%d",
43 c
>> 24, (c
>> 16) & 0xff,
44 (c
>> 8) & 0xff, c
& 0xff);
50 static char *dfs_state_name(enum nl80211_dfs_state state
)
53 case NL80211_DFS_USABLE
:
55 case NL80211_DFS_AVAILABLE
:
57 case NL80211_DFS_UNAVAILABLE
:
64 static int ext_feature_isset(const unsigned char *ext_features
, int ext_features_len
,
65 enum nl80211_ext_feature_index ftidx
)
67 unsigned char ft_byte
;
69 if ((int) ftidx
/ 8 >= ext_features_len
)
72 ft_byte
= ext_features
[ftidx
/ 8];
73 return (ft_byte
& BIT(ftidx
% 8)) != 0;
76 static int print_phy_handler(struct nl_msg
*msg
, void *arg
)
78 struct nlattr
*tb_msg
[NL80211_ATTR_MAX
+ 1];
79 struct genlmsghdr
*gnlh
= nlmsg_data(nlmsg_hdr(msg
));
81 struct nlattr
*tb_band
[NL80211_BAND_ATTR_MAX
+ 1];
83 struct nlattr
*tb_freq
[NL80211_FREQUENCY_ATTR_MAX
+ 1];
84 static struct nla_policy freq_policy
[NL80211_FREQUENCY_ATTR_MAX
+ 1] = {
85 [NL80211_FREQUENCY_ATTR_FREQ
] = { .type
= NLA_U32
},
86 [NL80211_FREQUENCY_ATTR_DISABLED
] = { .type
= NLA_FLAG
},
87 [NL80211_FREQUENCY_ATTR_NO_IR
] = { .type
= NLA_FLAG
},
88 [__NL80211_FREQUENCY_ATTR_NO_IBSS
] = { .type
= NLA_FLAG
},
89 [NL80211_FREQUENCY_ATTR_RADAR
] = { .type
= NLA_FLAG
},
90 [NL80211_FREQUENCY_ATTR_MAX_TX_POWER
] = { .type
= NLA_U32
},
93 struct nlattr
*tb_rate
[NL80211_BITRATE_ATTR_MAX
+ 1];
94 static struct nla_policy rate_policy
[NL80211_BITRATE_ATTR_MAX
+ 1] = {
95 [NL80211_BITRATE_ATTR_RATE
] = { .type
= NLA_U32
},
96 [NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE
] = { .type
= NLA_FLAG
},
99 struct nlattr
*nl_band
;
100 struct nlattr
*nl_freq
;
101 struct nlattr
*nl_rate
;
102 struct nlattr
*nl_mode
;
103 struct nlattr
*nl_cmd
;
104 struct nlattr
*nl_if
, *nl_ftype
;
105 int rem_band
, rem_freq
, rem_rate
, rem_mode
, rem_cmd
, rem_ftype
, rem_if
;
108 * static variables only work here, other applications need to use the
109 * callback pointer and store them there so they can be multithreaded
110 * and/or have multiple netlink sockets, etc.
112 static int64_t phy_id
= -1;
113 static int last_band
= -1;
114 static bool band_had_freq
= false;
115 bool print_name
= true;
117 nla_parse(tb_msg
, NL80211_ATTR_MAX
, genlmsg_attrdata(gnlh
, 0),
118 genlmsg_attrlen(gnlh
, 0), NULL
);
120 if (tb_msg
[NL80211_ATTR_WIPHY
]) {
121 if (nla_get_u32(tb_msg
[NL80211_ATTR_WIPHY
]) == phy_id
)
125 phy_id
= nla_get_u32(tb_msg
[NL80211_ATTR_WIPHY
]);
127 if (print_name
&& tb_msg
[NL80211_ATTR_WIPHY_NAME
])
128 printf("Wiphy %s\n", nla_get_string(tb_msg
[NL80211_ATTR_WIPHY_NAME
]));
130 /* needed for split dump */
131 if (tb_msg
[NL80211_ATTR_WIPHY_BANDS
]) {
132 nla_for_each_nested(nl_band
, tb_msg
[NL80211_ATTR_WIPHY_BANDS
], rem_band
) {
133 if (last_band
!= nl_band
->nla_type
) {
134 printf("\tBand %d:\n", nl_band
->nla_type
+ 1);
135 band_had_freq
= false;
137 last_band
= nl_band
->nla_type
;
139 nla_parse(tb_band
, NL80211_BAND_ATTR_MAX
, nla_data(nl_band
),
140 nla_len(nl_band
), NULL
);
142 if (tb_band
[NL80211_BAND_ATTR_HT_CAPA
]) {
143 __u16 cap
= nla_get_u16(tb_band
[NL80211_BAND_ATTR_HT_CAPA
]);
144 print_ht_capability(cap
);
146 if (tb_band
[NL80211_BAND_ATTR_HT_AMPDU_FACTOR
]) {
147 __u8 exponent
= nla_get_u8(tb_band
[NL80211_BAND_ATTR_HT_AMPDU_FACTOR
]);
148 print_ampdu_length(exponent
);
150 if (tb_band
[NL80211_BAND_ATTR_HT_AMPDU_DENSITY
]) {
151 __u8 spacing
= nla_get_u8(tb_band
[NL80211_BAND_ATTR_HT_AMPDU_DENSITY
]);
152 print_ampdu_spacing(spacing
);
154 if (tb_band
[NL80211_BAND_ATTR_HT_MCS_SET
] &&
155 nla_len(tb_band
[NL80211_BAND_ATTR_HT_MCS_SET
]) == 16)
156 print_ht_mcs(nla_data(tb_band
[NL80211_BAND_ATTR_HT_MCS_SET
]));
157 if (tb_band
[NL80211_BAND_ATTR_VHT_CAPA
] &&
158 tb_band
[NL80211_BAND_ATTR_VHT_MCS_SET
])
159 print_vht_info(nla_get_u32(tb_band
[NL80211_BAND_ATTR_VHT_CAPA
]),
160 nla_data(tb_band
[NL80211_BAND_ATTR_VHT_MCS_SET
]));
162 if (tb_band
[NL80211_BAND_ATTR_FREQS
]) {
163 if (!band_had_freq
) {
164 printf("\t\tFrequencies:\n");
165 band_had_freq
= true;
167 nla_for_each_nested(nl_freq
, tb_band
[NL80211_BAND_ATTR_FREQS
], rem_freq
) {
169 nla_parse(tb_freq
, NL80211_FREQUENCY_ATTR_MAX
, nla_data(nl_freq
),
170 nla_len(nl_freq
), freq_policy
);
171 if (!tb_freq
[NL80211_FREQUENCY_ATTR_FREQ
])
173 freq
= nla_get_u32(tb_freq
[NL80211_FREQUENCY_ATTR_FREQ
]);
174 printf("\t\t\t* %d MHz [%d]", freq
, ieee80211_frequency_to_channel(freq
));
176 if (tb_freq
[NL80211_FREQUENCY_ATTR_MAX_TX_POWER
] &&
177 !tb_freq
[NL80211_FREQUENCY_ATTR_DISABLED
])
178 printf(" (%.1f dBm)", 0.01 * nla_get_u32(tb_freq
[NL80211_FREQUENCY_ATTR_MAX_TX_POWER
]));
181 if (tb_freq
[NL80211_FREQUENCY_ATTR_DISABLED
]) {
182 print_flag("disabled", &open
);
186 /* If both flags are set assume an new kernel */
187 if (tb_freq
[NL80211_FREQUENCY_ATTR_NO_IR
] && tb_freq
[__NL80211_FREQUENCY_ATTR_NO_IBSS
]) {
188 print_flag("no IR", &open
);
189 } else if (tb_freq
[NL80211_FREQUENCY_ATTR_PASSIVE_SCAN
]) {
190 print_flag("passive scan", &open
);
191 } else if (tb_freq
[__NL80211_FREQUENCY_ATTR_NO_IBSS
]){
192 print_flag("no ibss", &open
);
195 if (tb_freq
[NL80211_FREQUENCY_ATTR_RADAR
])
196 print_flag("radar detection", &open
);
202 if (!tb_freq
[NL80211_FREQUENCY_ATTR_DISABLED
] && tb_freq
[NL80211_FREQUENCY_ATTR_DFS_STATE
]) {
203 enum nl80211_dfs_state state
= nla_get_u32(tb_freq
[NL80211_FREQUENCY_ATTR_DFS_STATE
]);
206 printf("\t\t\t DFS state: %s", dfs_state_name(state
));
207 if (tb_freq
[NL80211_FREQUENCY_ATTR_DFS_TIME
]) {
208 time
= nla_get_u32(tb_freq
[NL80211_FREQUENCY_ATTR_DFS_TIME
]);
209 printf(" (for %lu sec)", time
/1000);
212 if (tb_freq
[NL80211_FREQUENCY_ATTR_DFS_CAC_TIME
])
213 printf("\t\t\t DFS CAC time: %u ms\n",
214 nla_get_u32(tb_freq
[NL80211_FREQUENCY_ATTR_DFS_CAC_TIME
]));
220 if (tb_band
[NL80211_BAND_ATTR_RATES
]) {
221 printf("\t\tBitrates (non-HT):\n");
222 nla_for_each_nested(nl_rate
, tb_band
[NL80211_BAND_ATTR_RATES
], rem_rate
) {
223 nla_parse(tb_rate
, NL80211_BITRATE_ATTR_MAX
, nla_data(nl_rate
),
224 nla_len(nl_rate
), rate_policy
);
225 if (!tb_rate
[NL80211_BITRATE_ATTR_RATE
])
227 printf("\t\t\t* %2.1f Mbps", 0.1 * nla_get_u32(tb_rate
[NL80211_BITRATE_ATTR_RATE
]));
229 if (tb_rate
[NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE
])
230 print_flag("short preamble supported", &open
);
239 if (tb_msg
[NL80211_ATTR_MAX_NUM_SCAN_SSIDS
])
240 printf("\tmax # scan SSIDs: %d\n",
241 nla_get_u8(tb_msg
[NL80211_ATTR_MAX_NUM_SCAN_SSIDS
]));
242 if (tb_msg
[NL80211_ATTR_MAX_SCAN_IE_LEN
])
243 printf("\tmax scan IEs length: %d bytes\n",
244 nla_get_u16(tb_msg
[NL80211_ATTR_MAX_SCAN_IE_LEN
]));
245 if (tb_msg
[NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS
])
246 printf("\tmax # sched scan SSIDs: %d\n",
247 nla_get_u8(tb_msg
[NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS
]));
248 if (tb_msg
[NL80211_ATTR_MAX_MATCH_SETS
])
249 printf("\tmax # match sets: %d\n",
250 nla_get_u8(tb_msg
[NL80211_ATTR_MAX_MATCH_SETS
]));
252 if (tb_msg
[NL80211_ATTR_WIPHY_FRAG_THRESHOLD
]) {
255 frag
= nla_get_u32(tb_msg
[NL80211_ATTR_WIPHY_FRAG_THRESHOLD
]);
256 if (frag
!= (unsigned int)-1)
257 printf("\tFragmentation threshold: %d\n", frag
);
260 if (tb_msg
[NL80211_ATTR_WIPHY_RTS_THRESHOLD
]) {
263 rts
= nla_get_u32(tb_msg
[NL80211_ATTR_WIPHY_RTS_THRESHOLD
]);
264 if (rts
!= (unsigned int)-1)
265 printf("\tRTS threshold: %d\n", rts
);
268 if (tb_msg
[NL80211_ATTR_WIPHY_RETRY_SHORT
] ||
269 tb_msg
[NL80211_ATTR_WIPHY_RETRY_LONG
]) {
270 unsigned char retry_short
= 0, retry_long
= 0;
272 if (tb_msg
[NL80211_ATTR_WIPHY_RETRY_SHORT
])
273 retry_short
= nla_get_u8(tb_msg
[NL80211_ATTR_WIPHY_RETRY_SHORT
]);
274 if (tb_msg
[NL80211_ATTR_WIPHY_RETRY_LONG
])
275 retry_long
= nla_get_u8(tb_msg
[NL80211_ATTR_WIPHY_RETRY_LONG
]);
276 if (retry_short
== retry_long
) {
277 printf("\tRetry short long limit: %d\n", retry_short
);
279 printf("\tRetry short limit: %d\n", retry_short
);
280 printf("\tRetry long limit: %d\n", retry_long
);
284 if (tb_msg
[NL80211_ATTR_WIPHY_COVERAGE_CLASS
]) {
285 unsigned char coverage
;
287 coverage
= nla_get_u8(tb_msg
[NL80211_ATTR_WIPHY_COVERAGE_CLASS
]);
288 /* See handle_distance() for an explanation where the '450' comes from */
289 printf("\tCoverage class: %d (up to %dm)\n", coverage
, 450 * coverage
);
292 if (tb_msg
[NL80211_ATTR_CIPHER_SUITES
]) {
293 int num
= nla_len(tb_msg
[NL80211_ATTR_CIPHER_SUITES
]) / sizeof(__u32
);
295 __u32
*ciphers
= nla_data(tb_msg
[NL80211_ATTR_CIPHER_SUITES
]);
297 printf("\tSupported Ciphers:\n");
298 for (i
= 0; i
< num
; i
++)
300 cipher_name(ciphers
[i
]));
304 if (tb_msg
[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX
] &&
305 tb_msg
[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX
])
306 printf("\tAvailable Antennas: TX %#x RX %#x\n",
307 nla_get_u32(tb_msg
[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX
]),
308 nla_get_u32(tb_msg
[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX
]));
310 if (tb_msg
[NL80211_ATTR_WIPHY_ANTENNA_TX
] &&
311 tb_msg
[NL80211_ATTR_WIPHY_ANTENNA_RX
])
312 printf("\tConfigured Antennas: TX %#x RX %#x\n",
313 nla_get_u32(tb_msg
[NL80211_ATTR_WIPHY_ANTENNA_TX
]),
314 nla_get_u32(tb_msg
[NL80211_ATTR_WIPHY_ANTENNA_RX
]));
316 if (tb_msg
[NL80211_ATTR_SUPPORTED_IFTYPES
]) {
317 printf("\tSupported interface modes:\n");
318 nla_for_each_nested(nl_mode
, tb_msg
[NL80211_ATTR_SUPPORTED_IFTYPES
], rem_mode
)
319 printf("\t\t * %s\n", iftype_name(nla_type(nl_mode
)));
322 if (tb_msg
[NL80211_ATTR_SOFTWARE_IFTYPES
]) {
323 printf("\tsoftware interface modes (can always be added):\n");
324 nla_for_each_nested(nl_mode
, tb_msg
[NL80211_ATTR_SOFTWARE_IFTYPES
], rem_mode
)
325 printf("\t\t * %s\n", iftype_name(nla_type(nl_mode
)));
328 if (tb_msg
[NL80211_ATTR_INTERFACE_COMBINATIONS
]) {
329 struct nlattr
*nl_combi
;
331 bool have_combinations
= false;
333 nla_for_each_nested(nl_combi
, tb_msg
[NL80211_ATTR_INTERFACE_COMBINATIONS
], rem_combi
) {
334 static struct nla_policy iface_combination_policy
[NUM_NL80211_IFACE_COMB
] = {
335 [NL80211_IFACE_COMB_LIMITS
] = { .type
= NLA_NESTED
},
336 [NL80211_IFACE_COMB_MAXNUM
] = { .type
= NLA_U32
},
337 [NL80211_IFACE_COMB_STA_AP_BI_MATCH
] = { .type
= NLA_FLAG
},
338 [NL80211_IFACE_COMB_NUM_CHANNELS
] = { .type
= NLA_U32
},
339 [NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS
] = { .type
= NLA_U32
},
341 struct nlattr
*tb_comb
[NUM_NL80211_IFACE_COMB
];
342 static struct nla_policy iface_limit_policy
[NUM_NL80211_IFACE_LIMIT
] = {
343 [NL80211_IFACE_LIMIT_TYPES
] = { .type
= NLA_NESTED
},
344 [NL80211_IFACE_LIMIT_MAX
] = { .type
= NLA_U32
},
346 struct nlattr
*tb_limit
[NUM_NL80211_IFACE_LIMIT
];
347 struct nlattr
*nl_limit
;
351 if (!have_combinations
) {
352 printf("\tvalid interface combinations:\n");
353 have_combinations
= true;
358 err
= nla_parse_nested(tb_comb
, MAX_NL80211_IFACE_COMB
,
359 nl_combi
, iface_combination_policy
);
360 if (err
|| !tb_comb
[NL80211_IFACE_COMB_LIMITS
] ||
361 !tb_comb
[NL80211_IFACE_COMB_MAXNUM
] ||
362 !tb_comb
[NL80211_IFACE_COMB_NUM_CHANNELS
]) {
363 printf(" <failed to parse>\n");
364 goto broken_combination
;
367 nla_for_each_nested(nl_limit
, tb_comb
[NL80211_IFACE_COMB_LIMITS
], rem_limit
) {
368 bool ift_comma
= false;
370 err
= nla_parse_nested(tb_limit
, MAX_NL80211_IFACE_LIMIT
,
371 nl_limit
, iface_limit_policy
);
372 if (err
|| !tb_limit
[NL80211_IFACE_LIMIT_TYPES
]) {
373 printf("<failed to parse>\n");
374 goto broken_combination
;
382 nla_for_each_nested(nl_mode
, tb_limit
[NL80211_IFACE_LIMIT_TYPES
], rem_mode
) {
383 printf("%s %s", ift_comma
? "," : "",
384 iftype_name(nla_type(nl_mode
)));
387 printf(" } <= %u", nla_get_u32(tb_limit
[NL80211_IFACE_LIMIT_MAX
]));
391 printf("total <= %d, #channels <= %d%s",
392 nla_get_u32(tb_comb
[NL80211_IFACE_COMB_MAXNUM
]),
393 nla_get_u32(tb_comb
[NL80211_IFACE_COMB_NUM_CHANNELS
]),
394 tb_comb
[NL80211_IFACE_COMB_STA_AP_BI_MATCH
] ?
395 ", STA/AP BI must match" : "");
396 if (tb_comb
[NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS
]) {
397 unsigned long widths
= nla_get_u32(tb_comb
[NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS
]);
403 printf(", radar detect widths: {");
404 for (width
= 0; width
< 32; width
++)
405 if (widths
& (1 << width
)) {
408 channel_width_name(width
));
419 if (!have_combinations
)
420 printf("\tinterface combinations are not supported\n");
423 if (tb_msg
[NL80211_ATTR_SUPPORTED_COMMANDS
]) {
424 printf("\tSupported commands:\n");
425 nla_for_each_nested(nl_cmd
, tb_msg
[NL80211_ATTR_SUPPORTED_COMMANDS
], rem_cmd
)
426 printf("\t\t * %s\n", command_name(nla_get_u32(nl_cmd
)));
429 if (tb_msg
[NL80211_ATTR_TX_FRAME_TYPES
]) {
430 printf("\tSupported TX frame types:\n");
431 nla_for_each_nested(nl_if
, tb_msg
[NL80211_ATTR_TX_FRAME_TYPES
], rem_if
) {
432 bool printed
= false;
433 nla_for_each_nested(nl_ftype
, nl_if
, rem_ftype
) {
435 printf("\t\t * %s:", iftype_name(nla_type(nl_if
)));
437 printf(" 0x%.2x", nla_get_u16(nl_ftype
));
444 if (tb_msg
[NL80211_ATTR_RX_FRAME_TYPES
]) {
445 printf("\tSupported RX frame types:\n");
446 nla_for_each_nested(nl_if
, tb_msg
[NL80211_ATTR_RX_FRAME_TYPES
], rem_if
) {
447 bool printed
= false;
448 nla_for_each_nested(nl_ftype
, nl_if
, rem_ftype
) {
450 printf("\t\t * %s:", iftype_name(nla_type(nl_if
)));
452 printf(" 0x%.2x", nla_get_u16(nl_ftype
));
459 if (tb_msg
[NL80211_ATTR_SUPPORT_IBSS_RSN
])
460 printf("\tDevice supports RSN-IBSS.\n");
462 if (tb_msg
[NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED
]) {
463 struct nlattr
*tb_wowlan
[NUM_NL80211_WOWLAN_TRIG
];
464 static struct nla_policy wowlan_policy
[NUM_NL80211_WOWLAN_TRIG
] = {
465 [NL80211_WOWLAN_TRIG_ANY
] = { .type
= NLA_FLAG
},
466 [NL80211_WOWLAN_TRIG_DISCONNECT
] = { .type
= NLA_FLAG
},
467 [NL80211_WOWLAN_TRIG_MAGIC_PKT
] = { .type
= NLA_FLAG
},
468 [NL80211_WOWLAN_TRIG_PKT_PATTERN
] = { .minlen
= 12 },
469 [NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED
] = { .type
= NLA_FLAG
},
470 [NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE
] = { .type
= NLA_FLAG
},
471 [NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST
] = { .type
= NLA_FLAG
},
472 [NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE
] = { .type
= NLA_FLAG
},
473 [NL80211_WOWLAN_TRIG_RFKILL_RELEASE
] = { .type
= NLA_FLAG
},
474 [NL80211_WOWLAN_TRIG_NET_DETECT
] = { .type
= NLA_U32
},
475 [NL80211_WOWLAN_TRIG_TCP_CONNECTION
] = { .type
= NLA_NESTED
},
477 struct nl80211_pattern_support
*pat
;
480 err
= nla_parse_nested(tb_wowlan
, MAX_NL80211_WOWLAN_TRIG
,
481 tb_msg
[NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED
],
483 printf("\tWoWLAN support:");
485 printf(" <failed to parse>\n");
488 if (tb_wowlan
[NL80211_WOWLAN_TRIG_ANY
])
489 printf("\t\t * wake up on anything (device continues operating normally)\n");
490 if (tb_wowlan
[NL80211_WOWLAN_TRIG_DISCONNECT
])
491 printf("\t\t * wake up on disconnect\n");
492 if (tb_wowlan
[NL80211_WOWLAN_TRIG_MAGIC_PKT
])
493 printf("\t\t * wake up on magic packet\n");
494 if (tb_wowlan
[NL80211_WOWLAN_TRIG_PKT_PATTERN
]) {
495 unsigned int len
= nla_len(tb_wowlan
[NL80211_WOWLAN_TRIG_PKT_PATTERN
]);
497 pat
= nla_data(tb_wowlan
[NL80211_WOWLAN_TRIG_PKT_PATTERN
]);
498 printf("\t\t * wake up on pattern match, up to %u patterns of %u-%u bytes,\n"
499 "\t\t maximum packet offset %u bytes\n",
500 pat
->max_patterns
, pat
->min_pattern_len
, pat
->max_pattern_len
,
501 len
< sizeof(*pat
) ? 0 : pat
->max_pkt_offset
);
503 if (tb_wowlan
[NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED
])
504 printf("\t\t * can do GTK rekeying\n");
505 if (tb_wowlan
[NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE
])
506 printf("\t\t * wake up on GTK rekey failure\n");
507 if (tb_wowlan
[NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST
])
508 printf("\t\t * wake up on EAP identity request\n");
509 if (tb_wowlan
[NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE
])
510 printf("\t\t * wake up on 4-way handshake\n");
511 if (tb_wowlan
[NL80211_WOWLAN_TRIG_RFKILL_RELEASE
])
512 printf("\t\t * wake up on rfkill release\n");
513 if (tb_wowlan
[NL80211_WOWLAN_TRIG_NET_DETECT
])
514 printf("\t\t * wake up on network detection, up to %d match sets\n",
515 nla_get_u32(tb_wowlan
[NL80211_WOWLAN_TRIG_NET_DETECT
]));
516 if (tb_wowlan
[NL80211_WOWLAN_TRIG_TCP_CONNECTION
])
517 printf("\t\t * wake up on TCP connection\n");
521 if (tb_msg
[NL80211_ATTR_ROAM_SUPPORT
])
522 printf("\tDevice supports roaming.\n");
524 if (tb_msg
[NL80211_ATTR_SUPPORT_AP_UAPSD
])
525 printf("\tDevice supports AP-side u-APSD.\n");
527 if (tb_msg
[NL80211_ATTR_HT_CAPABILITY_MASK
]) {
528 struct ieee80211_ht_cap
*cm
;
529 unsigned int len
= nla_len(tb_msg
[NL80211_ATTR_HT_CAPABILITY_MASK
]);
531 printf("\tHT Capability overrides:\n");
532 if (len
>= sizeof(*cm
)) {
533 cm
= nla_data(tb_msg
[NL80211_ATTR_HT_CAPABILITY_MASK
]);
534 printf("\t\t * MCS: %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx"
535 " %02hhx %02hhx %02hhx %02hhx\n",
536 cm
->mcs
.rx_mask
[0], cm
->mcs
.rx_mask
[1],
537 cm
->mcs
.rx_mask
[2], cm
->mcs
.rx_mask
[3],
538 cm
->mcs
.rx_mask
[4], cm
->mcs
.rx_mask
[5],
539 cm
->mcs
.rx_mask
[6], cm
->mcs
.rx_mask
[7],
540 cm
->mcs
.rx_mask
[8], cm
->mcs
.rx_mask
[9]);
541 if (cm
->cap_info
& htole16(IEEE80211_HT_CAP_MAX_AMSDU
))
542 printf("\t\t * maximum A-MSDU length\n");
543 if (cm
->cap_info
& htole16(IEEE80211_HT_CAP_SUP_WIDTH_20_40
))
544 printf("\t\t * supported channel width\n");
545 if (cm
->cap_info
& htole16(IEEE80211_HT_CAP_SGI_40
))
546 printf("\t\t * short GI for 40 MHz\n");
547 if (cm
->ampdu_params_info
& IEEE80211_HT_AMPDU_PARM_FACTOR
)
548 printf("\t\t * max A-MPDU length exponent\n");
549 if (cm
->ampdu_params_info
& IEEE80211_HT_AMPDU_PARM_DENSITY
)
550 printf("\t\t * min MPDU start spacing\n");
552 printf("\tERROR: capabilities mask is too short, expected: %d, received: %d\n",
554 (int)(nla_len(tb_msg
[NL80211_ATTR_HT_CAPABILITY_MASK
])));
558 if (tb_msg
[NL80211_ATTR_FEATURE_FLAGS
]) {
559 unsigned int features
= nla_get_u32(tb_msg
[NL80211_ATTR_FEATURE_FLAGS
]);
561 if (features
& NL80211_FEATURE_SK_TX_STATUS
)
562 printf("\tDevice supports TX status socket option.\n");
563 if (features
& NL80211_FEATURE_HT_IBSS
)
564 printf("\tDevice supports HT-IBSS.\n");
565 if (features
& NL80211_FEATURE_INACTIVITY_TIMER
)
566 printf("\tDevice has client inactivity timer.\n");
567 if (features
& NL80211_FEATURE_CELL_BASE_REG_HINTS
)
568 printf("\tDevice accepts cell base station regulatory hints.\n");
569 if (features
& NL80211_FEATURE_P2P_DEVICE_NEEDS_CHANNEL
)
570 printf("\tP2P Device uses a channel (of the concurrent ones)\n");
571 if (features
& NL80211_FEATURE_SAE
)
572 printf("\tDevice supports SAE with AUTHENTICATE command\n");
573 if (features
& NL80211_FEATURE_LOW_PRIORITY_SCAN
)
574 printf("\tDevice supports low priority scan.\n");
575 if (features
& NL80211_FEATURE_SCAN_FLUSH
)
576 printf("\tDevice supports scan flush.\n");
577 if (features
& NL80211_FEATURE_AP_SCAN
)
578 printf("\tDevice supports AP scan.\n");
579 if (features
& NL80211_FEATURE_VIF_TXPOWER
)
580 printf("\tDevice supports per-vif TX power setting\n");
581 if (features
& NL80211_FEATURE_NEED_OBSS_SCAN
)
582 printf("\tUserspace should do OBSS scan and generate 20/40 coex reports\n");
583 if (features
& NL80211_FEATURE_P2P_GO_CTWIN
)
584 printf("\tP2P GO supports CT window setting\n");
585 if (features
& NL80211_FEATURE_P2P_GO_OPPPS
)
586 printf("\tP2P GO supports opportunistic powersave setting\n");
587 if (features
& NL80211_FEATURE_FULL_AP_CLIENT_STATE
)
588 printf("\tDriver supports full state transitions for AP/GO clients\n");
589 if (features
& NL80211_FEATURE_USERSPACE_MPM
)
590 printf("\tDriver supports a userspace MPM\n");
591 if (features
& NL80211_FEATURE_ACTIVE_MONITOR
)
592 printf("\tDevice supports active monitor (which will ACK incoming frames)\n");
593 if (features
& NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE
)
594 printf("\tDriver/device bandwidth changes during BSS lifetime (AP/GO mode)\n");
595 if (features
& NL80211_FEATURE_DS_PARAM_SET_IE_IN_PROBES
)
596 printf("\tDevice adds DS IE to probe requests\n");
597 if (features
& NL80211_FEATURE_WFA_TPC_IE_IN_PROBES
)
598 printf("\tDevice adds WFA TPC Report IE to probe requests\n");
599 if (features
& NL80211_FEATURE_QUIET
)
600 printf("\tDevice supports quiet requests from AP\n");
601 if (features
& NL80211_FEATURE_TX_POWER_INSERTION
)
602 printf("\tDevice can update TPC Report IE\n");
603 if (features
& NL80211_FEATURE_ACKTO_ESTIMATION
)
604 printf("\tDevice supports ACK timeout estimation.\n");
605 if (features
& NL80211_FEATURE_STATIC_SMPS
)
606 printf("\tDevice supports static SMPS\n");
607 if (features
& NL80211_FEATURE_DYNAMIC_SMPS
)
608 printf("\tDevice supports dynamic SMPS\n");
609 if (features
& NL80211_FEATURE_SUPPORTS_WMM_ADMISSION
)
610 printf("\tDevice supports WMM-AC admission (TSPECs)\n");
611 if (features
& NL80211_FEATURE_MAC_ON_CREATE
)
612 printf("\tDevice supports configuring vdev MAC-addr on create.\n");
613 if (features
& NL80211_FEATURE_TDLS_CHANNEL_SWITCH
)
614 printf("\tDevice supports TDLS channel switching\n");
617 if (tb_msg
[NL80211_ATTR_EXT_FEATURES
]) {
618 struct nlattr
*tb
= tb_msg
[NL80211_ATTR_EXT_FEATURES
];
620 if (ext_feature_isset(nla_data(tb
), nla_len(tb
),
621 NL80211_EXT_FEATURE_VHT_IBSS
))
622 printf("\tDevice supports VHT-IBSS.\n");
625 if (tb_msg
[NL80211_ATTR_TDLS_SUPPORT
])
626 printf("\tDevice supports T-DLS.\n");
628 if (tb_msg
[NL80211_ATTR_COALESCE_RULE
]) {
629 struct nl80211_coalesce_rule_support
*rule
;
630 struct nl80211_pattern_support
*pat
;
632 printf("\tCoalesce support:\n");
633 rule
= nla_data(tb_msg
[NL80211_ATTR_COALESCE_RULE
]);
635 printf("\t\t * Maximum %u coalesce rules supported\n"
636 "\t\t * Each rule contains upto %u patterns of %u-%u bytes,\n"
637 "\t\t maximum packet offset %u bytes\n"
638 "\t\t * Maximum supported coalescing delay %u msecs\n",
639 rule
->max_rules
, pat
->max_patterns
, pat
->min_pattern_len
,
640 pat
->max_pattern_len
, pat
->max_pkt_offset
, rule
->max_delay
);
646 static bool nl80211_has_split_wiphy
= false;
648 static int handle_info(struct nl80211_state
*state
,
650 int argc
, char **argv
,
653 char *feat_args
[] = { "features", "-q" };
656 err
= handle_cmd(state
, CIB_NONE
, 2, feat_args
);
657 if (!err
&& nl80211_has_split_wiphy
) {
658 nla_put_flag(msg
, NL80211_ATTR_SPLIT_WIPHY_DUMP
);
659 nlmsg_hdr(msg
)->nlmsg_flags
|= NLM_F_DUMP
;
662 register_handler(print_phy_handler
, NULL
);
666 __COMMAND(NULL
, info
, "info", NULL
, NL80211_CMD_GET_WIPHY
, 0, 0, CIB_PHY
, handle_info
,
667 "Show capabilities for the specified wireless device.", NULL
);
668 TOPLEVEL(list
, NULL
, NL80211_CMD_GET_WIPHY
, NLM_F_DUMP
, CIB_NONE
, handle_info
,
669 "List all wireless devices and their capabilities.");
670 TOPLEVEL(phy
, NULL
, NL80211_CMD_GET_WIPHY
, NLM_F_DUMP
, CIB_NONE
, handle_info
, NULL
);
672 static int handle_commands(struct nl80211_state
*state
, struct nl_msg
*msg
,
673 int argc
, char **argv
, enum id_input id
)
676 for (i
= 1; i
<= NL80211_CMD_MAX
; i
++)
677 printf("%d (0x%x): %s\n", i
, i
, command_name(i
));
678 /* don't send netlink messages */
681 TOPLEVEL(commands
, NULL
, NL80211_CMD_GET_WIPHY
, 0, CIB_NONE
, handle_commands
,
682 "list all known commands and their decimal & hex value");
684 static int print_feature_handler(struct nl_msg
*msg
, void *arg
)
686 struct nlattr
*tb_msg
[NL80211_ATTR_MAX
+ 1];
687 struct genlmsghdr
*gnlh
= nlmsg_data(nlmsg_hdr(msg
));
688 bool print
= (unsigned long)arg
;
689 #define maybe_printf(...) do { if (print) printf(__VA_ARGS__); } while (0)
691 nla_parse(tb_msg
, NL80211_ATTR_MAX
, genlmsg_attrdata(gnlh
, 0),
692 genlmsg_attrlen(gnlh
, 0), NULL
);
694 if (tb_msg
[NL80211_ATTR_PROTOCOL_FEATURES
]) {
695 uint32_t feat
= nla_get_u32(tb_msg
[NL80211_ATTR_PROTOCOL_FEATURES
]);
697 maybe_printf("nl80211 features: 0x%x\n", feat
);
698 if (feat
& NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP
) {
699 maybe_printf("\t* split wiphy dump\n");
700 nl80211_has_split_wiphy
= true;
707 static int handle_features(struct nl80211_state
*state
, struct nl_msg
*msg
,
708 int argc
, char **argv
, enum id_input id
)
710 unsigned long print
= argc
== 0 || strcmp(argv
[0], "-q");
711 register_handler(print_feature_handler
, (void *)print
);
715 TOPLEVEL(features
, "", NL80211_CMD_GET_PROTOCOL_FEATURES
, 0, CIB_NONE
,
716 handle_features
, "");