5 #include <netlink/genl/genl.h>
6 #include <netlink/genl/family.h>
7 #include <netlink/genl/ctrl.h>
8 #include <netlink/msg.h>
9 #include <netlink/attr.h>
14 static void print_flag(const char *name
, int *open
)
24 static char *cipher_name(__u32 c
)
30 return "WEP40 (00-0f-ac:1)";
32 return "WEP104 (00-0f-ac:5)";
34 return "TKIP (00-0f-ac:2)";
36 return "CCMP (00-0f-ac:4)";
38 return "CMAC (00-0f-ac:6)";
40 return "GCMP (00-0f-ac:8)";
42 return "WPI-SMS4 (00-14-72:1)";
44 sprintf(buf
, "%.2x-%.2x-%.2x:%d",
45 c
>> 24, (c
>> 16) & 0xff,
46 (c
>> 8) & 0xff, c
& 0xff);
52 static char *dfs_state_name(enum nl80211_dfs_state state
)
55 case NL80211_DFS_USABLE
:
57 case NL80211_DFS_AVAILABLE
:
59 case NL80211_DFS_UNAVAILABLE
:
66 static int print_phy_handler(struct nl_msg
*msg
, void *arg
)
68 struct nlattr
*tb_msg
[NL80211_ATTR_MAX
+ 1];
69 struct genlmsghdr
*gnlh
= nlmsg_data(nlmsg_hdr(msg
));
71 struct nlattr
*tb_band
[NL80211_BAND_ATTR_MAX
+ 1];
73 struct nlattr
*tb_freq
[NL80211_FREQUENCY_ATTR_MAX
+ 1];
74 static struct nla_policy freq_policy
[NL80211_FREQUENCY_ATTR_MAX
+ 1] = {
75 [NL80211_FREQUENCY_ATTR_FREQ
] = { .type
= NLA_U32
},
76 [NL80211_FREQUENCY_ATTR_DISABLED
] = { .type
= NLA_FLAG
},
77 [NL80211_FREQUENCY_ATTR_PASSIVE_SCAN
] = { .type
= NLA_FLAG
},
78 [NL80211_FREQUENCY_ATTR_NO_IBSS
] = { .type
= NLA_FLAG
},
79 [NL80211_FREQUENCY_ATTR_RADAR
] = { .type
= NLA_FLAG
},
80 [NL80211_FREQUENCY_ATTR_MAX_TX_POWER
] = { .type
= NLA_U32
},
83 struct nlattr
*tb_rate
[NL80211_BITRATE_ATTR_MAX
+ 1];
84 static struct nla_policy rate_policy
[NL80211_BITRATE_ATTR_MAX
+ 1] = {
85 [NL80211_BITRATE_ATTR_RATE
] = { .type
= NLA_U32
},
86 [NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE
] = { .type
= NLA_FLAG
},
89 struct nlattr
*nl_band
;
90 struct nlattr
*nl_freq
;
91 struct nlattr
*nl_rate
;
92 struct nlattr
*nl_mode
;
93 struct nlattr
*nl_cmd
;
94 struct nlattr
*nl_if
, *nl_ftype
;
95 int rem_band
, rem_freq
, rem_rate
, rem_mode
, rem_cmd
, rem_ftype
, rem_if
;
98 * static variables only work here, other applications need to use the
99 * callback pointer and store them there so they can be multithreaded
100 * and/or have multiple netlink sockets, etc.
102 static int64_t phy_id
= -1;
103 static int last_band
= -1;
104 static bool band_had_freq
= false;
105 bool print_name
= true;
107 nla_parse(tb_msg
, NL80211_ATTR_MAX
, genlmsg_attrdata(gnlh
, 0),
108 genlmsg_attrlen(gnlh
, 0), NULL
);
110 if (tb_msg
[NL80211_ATTR_WIPHY
]) {
111 if (nla_get_u32(tb_msg
[NL80211_ATTR_WIPHY
]) == phy_id
)
115 phy_id
= nla_get_u32(tb_msg
[NL80211_ATTR_WIPHY
]);
117 if (print_name
&& tb_msg
[NL80211_ATTR_WIPHY_NAME
])
118 printf("Wiphy %s\n", nla_get_string(tb_msg
[NL80211_ATTR_WIPHY_NAME
]));
120 /* needed for split dump */
121 if (tb_msg
[NL80211_ATTR_WIPHY_BANDS
]) {
122 nla_for_each_nested(nl_band
, tb_msg
[NL80211_ATTR_WIPHY_BANDS
], rem_band
) {
123 if (last_band
!= nl_band
->nla_type
) {
124 printf("\tBand %d:\n", nl_band
->nla_type
+ 1);
125 band_had_freq
= false;
127 last_band
= nl_band
->nla_type
;
129 nla_parse(tb_band
, NL80211_BAND_ATTR_MAX
, nla_data(nl_band
),
130 nla_len(nl_band
), NULL
);
132 if (tb_band
[NL80211_BAND_ATTR_HT_CAPA
]) {
133 __u16 cap
= nla_get_u16(tb_band
[NL80211_BAND_ATTR_HT_CAPA
]);
134 print_ht_capability(cap
);
136 if (tb_band
[NL80211_BAND_ATTR_HT_AMPDU_FACTOR
]) {
137 __u8 exponent
= nla_get_u8(tb_band
[NL80211_BAND_ATTR_HT_AMPDU_FACTOR
]);
138 print_ampdu_length(exponent
);
140 if (tb_band
[NL80211_BAND_ATTR_HT_AMPDU_DENSITY
]) {
141 __u8 spacing
= nla_get_u8(tb_band
[NL80211_BAND_ATTR_HT_AMPDU_DENSITY
]);
142 print_ampdu_spacing(spacing
);
144 if (tb_band
[NL80211_BAND_ATTR_HT_MCS_SET
] &&
145 nla_len(tb_band
[NL80211_BAND_ATTR_HT_MCS_SET
]) == 16)
146 print_ht_mcs(nla_data(tb_band
[NL80211_BAND_ATTR_HT_MCS_SET
]));
147 if (tb_band
[NL80211_BAND_ATTR_VHT_CAPA
] &&
148 tb_band
[NL80211_BAND_ATTR_VHT_MCS_SET
])
149 print_vht_info(nla_get_u32(tb_band
[NL80211_BAND_ATTR_VHT_CAPA
]),
150 nla_data(tb_band
[NL80211_BAND_ATTR_VHT_MCS_SET
]));
152 if (tb_band
[NL80211_BAND_ATTR_FREQS
]) {
153 if (!band_had_freq
) {
154 printf("\t\tFrequencies:\n");
155 band_had_freq
= true;
157 nla_for_each_nested(nl_freq
, tb_band
[NL80211_BAND_ATTR_FREQS
], rem_freq
) {
159 nla_parse(tb_freq
, NL80211_FREQUENCY_ATTR_MAX
, nla_data(nl_freq
),
160 nla_len(nl_freq
), freq_policy
);
161 if (!tb_freq
[NL80211_FREQUENCY_ATTR_FREQ
])
163 freq
= nla_get_u32(tb_freq
[NL80211_FREQUENCY_ATTR_FREQ
]);
164 printf("\t\t\t* %d MHz [%d]", freq
, ieee80211_frequency_to_channel(freq
));
166 if (tb_freq
[NL80211_FREQUENCY_ATTR_MAX_TX_POWER
] &&
167 !tb_freq
[NL80211_FREQUENCY_ATTR_DISABLED
])
168 printf(" (%.1f dBm)", 0.01 * nla_get_u32(tb_freq
[NL80211_FREQUENCY_ATTR_MAX_TX_POWER
]));
171 if (tb_freq
[NL80211_FREQUENCY_ATTR_DISABLED
]) {
172 print_flag("disabled", &open
);
175 if (tb_freq
[NL80211_FREQUENCY_ATTR_PASSIVE_SCAN
])
176 print_flag("passive scanning", &open
);
177 if (tb_freq
[NL80211_FREQUENCY_ATTR_NO_IBSS
])
178 print_flag("no IBSS", &open
);
179 if (tb_freq
[NL80211_FREQUENCY_ATTR_RADAR
])
180 print_flag("radar detection", &open
);
186 if (tb_freq
[NL80211_FREQUENCY_ATTR_DFS_STATE
]) {
187 enum nl80211_dfs_state state
= nla_get_u32(tb_freq
[NL80211_FREQUENCY_ATTR_DFS_STATE
]);
190 printf("\t\t\t DFS state: %s", dfs_state_name(state
));
191 if (tb_freq
[NL80211_FREQUENCY_ATTR_DFS_TIME
]) {
192 time
= nla_get_u32(tb_freq
[NL80211_FREQUENCY_ATTR_DFS_TIME
]);
193 printf(" (for %lu sec)", time
/1000);
200 if (tb_band
[NL80211_BAND_ATTR_RATES
]) {
201 printf("\t\tBitrates (non-HT):\n");
202 nla_for_each_nested(nl_rate
, tb_band
[NL80211_BAND_ATTR_RATES
], rem_rate
) {
203 nla_parse(tb_rate
, NL80211_BITRATE_ATTR_MAX
, nla_data(nl_rate
),
204 nla_len(nl_rate
), rate_policy
);
205 if (!tb_rate
[NL80211_BITRATE_ATTR_RATE
])
207 printf("\t\t\t* %2.1f Mbps", 0.1 * nla_get_u32(tb_rate
[NL80211_BITRATE_ATTR_RATE
]));
209 if (tb_rate
[NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE
])
210 print_flag("short preamble supported", &open
);
219 if (tb_msg
[NL80211_ATTR_MAX_NUM_SCAN_SSIDS
])
220 printf("\tmax # scan SSIDs: %d\n",
221 nla_get_u8(tb_msg
[NL80211_ATTR_MAX_NUM_SCAN_SSIDS
]));
222 if (tb_msg
[NL80211_ATTR_MAX_SCAN_IE_LEN
])
223 printf("\tmax scan IEs length: %d bytes\n",
224 nla_get_u16(tb_msg
[NL80211_ATTR_MAX_SCAN_IE_LEN
]));
226 if (tb_msg
[NL80211_ATTR_WIPHY_FRAG_THRESHOLD
]) {
229 frag
= nla_get_u32(tb_msg
[NL80211_ATTR_WIPHY_FRAG_THRESHOLD
]);
230 if (frag
!= (unsigned int)-1)
231 printf("\tFragmentation threshold: %d\n", frag
);
234 if (tb_msg
[NL80211_ATTR_WIPHY_RTS_THRESHOLD
]) {
237 rts
= nla_get_u32(tb_msg
[NL80211_ATTR_WIPHY_RTS_THRESHOLD
]);
238 if (rts
!= (unsigned int)-1)
239 printf("\tRTS threshold: %d\n", rts
);
242 if (tb_msg
[NL80211_ATTR_WIPHY_COVERAGE_CLASS
]) {
243 unsigned char coverage
;
245 coverage
= nla_get_u8(tb_msg
[NL80211_ATTR_WIPHY_COVERAGE_CLASS
]);
246 /* See handle_distance() for an explanation where the '450' comes from */
247 printf("\tCoverage class: %d (up to %dm)\n", coverage
, 450 * coverage
);
250 if (tb_msg
[NL80211_ATTR_CIPHER_SUITES
]) {
251 int num
= nla_len(tb_msg
[NL80211_ATTR_CIPHER_SUITES
]) / sizeof(__u32
);
253 __u32
*ciphers
= nla_data(tb_msg
[NL80211_ATTR_CIPHER_SUITES
]);
255 printf("\tSupported Ciphers:\n");
256 for (i
= 0; i
< num
; i
++)
258 cipher_name(ciphers
[i
]));
262 if (tb_msg
[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX
] &&
263 tb_msg
[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX
])
264 printf("\tAvailable Antennas: TX %#x RX %#x\n",
265 nla_get_u32(tb_msg
[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX
]),
266 nla_get_u32(tb_msg
[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX
]));
268 if (tb_msg
[NL80211_ATTR_WIPHY_ANTENNA_TX
] &&
269 tb_msg
[NL80211_ATTR_WIPHY_ANTENNA_RX
])
270 printf("\tConfigured Antennas: TX %#x RX %#x\n",
271 nla_get_u32(tb_msg
[NL80211_ATTR_WIPHY_ANTENNA_TX
]),
272 nla_get_u32(tb_msg
[NL80211_ATTR_WIPHY_ANTENNA_RX
]));
274 if (tb_msg
[NL80211_ATTR_SUPPORTED_IFTYPES
]) {
275 printf("\tSupported interface modes:\n");
276 nla_for_each_nested(nl_mode
, tb_msg
[NL80211_ATTR_SUPPORTED_IFTYPES
], rem_mode
)
277 printf("\t\t * %s\n", iftype_name(nla_type(nl_mode
)));
280 if (tb_msg
[NL80211_ATTR_SOFTWARE_IFTYPES
]) {
281 printf("\tsoftware interface modes (can always be added):\n");
282 nla_for_each_nested(nl_mode
, tb_msg
[NL80211_ATTR_SOFTWARE_IFTYPES
], rem_mode
)
283 printf("\t\t * %s\n", iftype_name(nla_type(nl_mode
)));
286 if (tb_msg
[NL80211_ATTR_INTERFACE_COMBINATIONS
]) {
287 struct nlattr
*nl_combi
;
289 bool have_combinations
= false;
291 nla_for_each_nested(nl_combi
, tb_msg
[NL80211_ATTR_INTERFACE_COMBINATIONS
], rem_combi
) {
292 static struct nla_policy iface_combination_policy
[NUM_NL80211_IFACE_COMB
] = {
293 [NL80211_IFACE_COMB_LIMITS
] = { .type
= NLA_NESTED
},
294 [NL80211_IFACE_COMB_MAXNUM
] = { .type
= NLA_U32
},
295 [NL80211_IFACE_COMB_STA_AP_BI_MATCH
] = { .type
= NLA_FLAG
},
296 [NL80211_IFACE_COMB_NUM_CHANNELS
] = { .type
= NLA_U32
},
297 [NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS
] = { .type
= NLA_U32
},
299 struct nlattr
*tb_comb
[NUM_NL80211_IFACE_COMB
];
300 static struct nla_policy iface_limit_policy
[NUM_NL80211_IFACE_LIMIT
] = {
301 [NL80211_IFACE_LIMIT_TYPES
] = { .type
= NLA_NESTED
},
302 [NL80211_IFACE_LIMIT_MAX
] = { .type
= NLA_U32
},
304 struct nlattr
*tb_limit
[NUM_NL80211_IFACE_LIMIT
];
305 struct nlattr
*nl_limit
;
309 if (!have_combinations
) {
310 printf("\tvalid interface combinations:\n");
311 have_combinations
= true;
316 err
= nla_parse_nested(tb_comb
, MAX_NL80211_IFACE_COMB
,
317 nl_combi
, iface_combination_policy
);
318 if (err
|| !tb_comb
[NL80211_IFACE_COMB_LIMITS
] ||
319 !tb_comb
[NL80211_IFACE_COMB_MAXNUM
] ||
320 !tb_comb
[NL80211_IFACE_COMB_NUM_CHANNELS
]) {
321 printf(" <failed to parse>\n");
322 goto broken_combination
;
325 nla_for_each_nested(nl_limit
, tb_comb
[NL80211_IFACE_COMB_LIMITS
], rem_limit
) {
326 bool ift_comma
= false;
328 err
= nla_parse_nested(tb_limit
, MAX_NL80211_IFACE_LIMIT
,
329 nl_limit
, iface_limit_policy
);
330 if (err
|| !tb_limit
[NL80211_IFACE_LIMIT_TYPES
]) {
331 printf("<failed to parse>\n");
332 goto broken_combination
;
340 nla_for_each_nested(nl_mode
, tb_limit
[NL80211_IFACE_LIMIT_TYPES
], rem_mode
) {
341 printf("%s %s", ift_comma
? "," : "",
342 iftype_name(nla_type(nl_mode
)));
345 printf(" } <= %u", nla_get_u32(tb_limit
[NL80211_IFACE_LIMIT_MAX
]));
349 printf("total <= %d, #channels <= %d%s",
350 nla_get_u32(tb_comb
[NL80211_IFACE_COMB_MAXNUM
]),
351 nla_get_u32(tb_comb
[NL80211_IFACE_COMB_NUM_CHANNELS
]),
352 tb_comb
[NL80211_IFACE_COMB_STA_AP_BI_MATCH
] ?
353 ", STA/AP BI must match" : "");
354 if (tb_comb
[NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS
]) {
355 unsigned long widths
= nla_get_u32(tb_comb
[NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS
]);
361 printf(", radar detect widths: {");
362 for (width
= 0; width
< 32; width
++)
363 if (widths
& (1 << width
)) {
366 channel_width_name(width
));
377 if (!have_combinations
)
378 printf("\tinterface combinations are not supported\n");
381 if (tb_msg
[NL80211_ATTR_SUPPORTED_COMMANDS
]) {
382 printf("\tSupported commands:\n");
383 nla_for_each_nested(nl_cmd
, tb_msg
[NL80211_ATTR_SUPPORTED_COMMANDS
], rem_cmd
)
384 printf("\t\t * %s\n", command_name(nla_get_u32(nl_cmd
)));
387 if (tb_msg
[NL80211_ATTR_TX_FRAME_TYPES
]) {
388 printf("\tSupported TX frame types:\n");
389 nla_for_each_nested(nl_if
, tb_msg
[NL80211_ATTR_TX_FRAME_TYPES
], rem_if
) {
390 bool printed
= false;
391 nla_for_each_nested(nl_ftype
, nl_if
, rem_ftype
) {
393 printf("\t\t * %s:", iftype_name(nla_type(nl_if
)));
395 printf(" 0x%.2x", nla_get_u16(nl_ftype
));
402 if (tb_msg
[NL80211_ATTR_RX_FRAME_TYPES
]) {
403 printf("\tSupported RX frame types:\n");
404 nla_for_each_nested(nl_if
, tb_msg
[NL80211_ATTR_RX_FRAME_TYPES
], rem_if
) {
405 bool printed
= false;
406 nla_for_each_nested(nl_ftype
, nl_if
, rem_ftype
) {
408 printf("\t\t * %s:", iftype_name(nla_type(nl_if
)));
410 printf(" 0x%.2x", nla_get_u16(nl_ftype
));
417 if (tb_msg
[NL80211_ATTR_SUPPORT_IBSS_RSN
])
418 printf("\tDevice supports RSN-IBSS.\n");
420 if (tb_msg
[NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED
]) {
421 struct nlattr
*tb_wowlan
[NUM_NL80211_WOWLAN_TRIG
];
422 static struct nla_policy wowlan_policy
[NUM_NL80211_WOWLAN_TRIG
] = {
423 [NL80211_WOWLAN_TRIG_ANY
] = { .type
= NLA_FLAG
},
424 [NL80211_WOWLAN_TRIG_DISCONNECT
] = { .type
= NLA_FLAG
},
425 [NL80211_WOWLAN_TRIG_MAGIC_PKT
] = { .type
= NLA_FLAG
},
426 [NL80211_WOWLAN_TRIG_PKT_PATTERN
] = { .minlen
= 12 },
427 [NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED
] = { .type
= NLA_FLAG
},
428 [NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE
] = { .type
= NLA_FLAG
},
429 [NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST
] = { .type
= NLA_FLAG
},
430 [NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE
] = { .type
= NLA_FLAG
},
431 [NL80211_WOWLAN_TRIG_RFKILL_RELEASE
] = { .type
= NLA_FLAG
},
432 [NL80211_WOWLAN_TRIG_TCP_CONNECTION
] = { .type
= NLA_NESTED
},
434 struct nl80211_wowlan_pattern_support
*pat
;
437 err
= nla_parse_nested(tb_wowlan
, MAX_NL80211_WOWLAN_TRIG
,
438 tb_msg
[NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED
],
440 printf("\tWoWLAN support:");
442 printf(" <failed to parse>\n");
445 if (tb_wowlan
[NL80211_WOWLAN_TRIG_ANY
])
446 printf("\t\t * wake up on anything (device continues operating normally)\n");
447 if (tb_wowlan
[NL80211_WOWLAN_TRIG_DISCONNECT
])
448 printf("\t\t * wake up on disconnect\n");
449 if (tb_wowlan
[NL80211_WOWLAN_TRIG_MAGIC_PKT
])
450 printf("\t\t * wake up on magic packet\n");
451 if (tb_wowlan
[NL80211_WOWLAN_TRIG_PKT_PATTERN
]) {
452 pat
= nla_data(tb_wowlan
[NL80211_WOWLAN_TRIG_PKT_PATTERN
]);
453 printf("\t\t * wake up on pattern match, up to %u patterns of %u-%u bytes,\n"
454 "\t\t maximum packet offset %u bytes\n",
455 pat
->max_patterns
, pat
->min_pattern_len
, pat
->max_pattern_len
,
456 (nla_len(tb_wowlan
[NL80211_WOWLAN_TRIG_PKT_PATTERN
]) <
457 sizeof(*pat
)) ? 0 : pat
->max_pkt_offset
);
459 if (tb_wowlan
[NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED
])
460 printf("\t\t * can do GTK rekeying\n");
461 if (tb_wowlan
[NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE
])
462 printf("\t\t * wake up on GTK rekey failure\n");
463 if (tb_wowlan
[NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST
])
464 printf("\t\t * wake up on EAP identity request\n");
465 if (tb_wowlan
[NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE
])
466 printf("\t\t * wake up on 4-way handshake\n");
467 if (tb_wowlan
[NL80211_WOWLAN_TRIG_RFKILL_RELEASE
])
468 printf("\t\t * wake up on rfkill release\n");
469 if (tb_wowlan
[NL80211_WOWLAN_TRIG_TCP_CONNECTION
])
470 printf("\t\t * wake up on TCP connection\n");
474 if (tb_msg
[NL80211_ATTR_ROAM_SUPPORT
])
475 printf("\tDevice supports roaming.\n");
477 if (tb_msg
[NL80211_ATTR_SUPPORT_AP_UAPSD
])
478 printf("\tDevice supports AP-side u-APSD.\n");
480 if (tb_msg
[NL80211_ATTR_HT_CAPABILITY_MASK
]) {
481 struct ieee80211_ht_cap
*cm
;
482 printf("\tHT Capability overrides:\n");
483 if (nla_len(tb_msg
[NL80211_ATTR_HT_CAPABILITY_MASK
]) >= sizeof(*cm
)) {
484 cm
= nla_data(tb_msg
[NL80211_ATTR_HT_CAPABILITY_MASK
]);
485 printf("\t\t * MCS: %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx"
486 " %02hhx %02hhx %02hhx %02hhx\n",
487 cm
->mcs
.rx_mask
[0], cm
->mcs
.rx_mask
[1],
488 cm
->mcs
.rx_mask
[2], cm
->mcs
.rx_mask
[3],
489 cm
->mcs
.rx_mask
[4], cm
->mcs
.rx_mask
[5],
490 cm
->mcs
.rx_mask
[6], cm
->mcs
.rx_mask
[7],
491 cm
->mcs
.rx_mask
[8], cm
->mcs
.rx_mask
[9]);
492 if (cm
->cap_info
& htole16(IEEE80211_HT_CAP_MAX_AMSDU
))
493 printf("\t\t * maximum A-MSDU length\n");
494 if (cm
->cap_info
& htole16(IEEE80211_HT_CAP_SUP_WIDTH_20_40
))
495 printf("\t\t * supported channel width\n");
496 if (cm
->cap_info
& htole16(IEEE80211_HT_CAP_SGI_40
))
497 printf("\t\t * short GI for 40 MHz\n");
498 if (cm
->ampdu_params_info
& IEEE80211_HT_AMPDU_PARM_FACTOR
)
499 printf("\t\t * max A-MPDU length exponent\n");
500 if (cm
->ampdu_params_info
& IEEE80211_HT_AMPDU_PARM_DENSITY
)
501 printf("\t\t * min MPDU start spacing\n");
503 printf("\tERROR: capabilities mask is too short, expected: %d, received: %d\n",
505 (int)(nla_len(tb_msg
[NL80211_ATTR_HT_CAPABILITY_MASK
])));
509 if (tb_msg
[NL80211_ATTR_FEATURE_FLAGS
]) {
510 unsigned int features
= nla_get_u32(tb_msg
[NL80211_ATTR_FEATURE_FLAGS
]);
512 if (features
& NL80211_FEATURE_SK_TX_STATUS
)
513 printf("\tDevice supports TX status socket option.\n");
514 if (features
& NL80211_FEATURE_HT_IBSS
)
515 printf("\tDevice supports HT-IBSS.\n");
516 if (features
& NL80211_FEATURE_INACTIVITY_TIMER
)
517 printf("\tDevice has client inactivity timer.\n");
518 if (features
& NL80211_FEATURE_CELL_BASE_REG_HINTS
)
519 printf("\tDevice accepts cell base station regulatory hints.\n");
520 if (features
& NL80211_FEATURE_P2P_DEVICE_NEEDS_CHANNEL
)
521 printf("\tP2P Device uses a channel (of the concurrent ones)\n");
522 if (features
& NL80211_FEATURE_LOW_PRIORITY_SCAN
)
523 printf("\tDevice supports low priority scan.\n");
524 if (features
& NL80211_FEATURE_SCAN_FLUSH
)
525 printf("\tDevice supports scan flush.\n");
526 if (features
& NL80211_FEATURE_AP_SCAN
)
527 printf("\tDevice supports AP scan.\n");
533 static int handle_info(struct nl80211_state
*state
,
536 int argc
, char **argv
,
539 nl_cb_set(cb
, NL_CB_VALID
, NL_CB_CUSTOM
, print_phy_handler
, NULL
);
540 /* kernels not supporting it will ignore this */
541 nla_put_flag(msg
, NL80211_ATTR_SPLIT_WIPHY_DUMP
);
545 __COMMAND(NULL
, info
, "info", NULL
, NL80211_CMD_GET_WIPHY
, NLM_F_DUMP
, 0, CIB_PHY
, handle_info
,
546 "Show capabilities for the specified wireless device.", NULL
);
547 TOPLEVEL(list
, NULL
, NL80211_CMD_GET_WIPHY
, NLM_F_DUMP
, CIB_NONE
, handle_info
,
548 "List all wireless devices and their capabilities.");
549 TOPLEVEL(phy
, NULL
, NL80211_CMD_GET_WIPHY
, NLM_F_DUMP
, CIB_NONE
, handle_info
, NULL
);
551 static int handle_commands(struct nl80211_state
*state
,
552 struct nl_cb
*cb
, struct nl_msg
*msg
,
553 int argc
, char **argv
, enum id_input id
)
556 for (i
= 1; i
< NL80211_CMD_MAX
; i
++)
557 printf("%d (0x%x): %s\n", i
, i
, command_name(i
));
558 /* don't send netlink messages */
561 TOPLEVEL(commands
, NULL
, NL80211_CMD_GET_WIPHY
, 0, CIB_NONE
, handle_commands
,
562 "list all known commands and their decimal & hex value");
564 static int print_feature_handler(struct nl_msg
*msg
, void *arg
)
566 struct nlattr
*tb_msg
[NL80211_ATTR_MAX
+ 1];
567 struct genlmsghdr
*gnlh
= nlmsg_data(nlmsg_hdr(msg
));
569 nla_parse(tb_msg
, NL80211_ATTR_MAX
, genlmsg_attrdata(gnlh
, 0),
570 genlmsg_attrlen(gnlh
, 0), NULL
);
572 if (tb_msg
[NL80211_ATTR_PROTOCOL_FEATURES
]) {
573 uint32_t feat
= nla_get_u32(tb_msg
[NL80211_ATTR_PROTOCOL_FEATURES
]);
575 printf("nl80211 features: 0x%x\n", feat
);
576 if (feat
& NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP
)
577 printf("\t* split wiphy dump\n");
583 static int handle_features(struct nl80211_state
*state
,
584 struct nl_cb
*cb
, struct nl_msg
*msg
,
585 int argc
, char **argv
, enum id_input id
)
587 nl_cb_set(cb
, NL_CB_VALID
, NL_CB_CUSTOM
, print_feature_handler
, NULL
);
591 TOPLEVEL(features
, NULL
, NL80211_CMD_GET_PROTOCOL_FEATURES
, 0, CIB_NONE
,
592 handle_features
, "");