+ }
+
+ if (tb_msg[NL80211_ATTR_MAX_NUM_SCAN_SSIDS])
+ printf("\tmax # scan SSIDs: %d\n",
+ nla_get_u8(tb_msg[NL80211_ATTR_MAX_NUM_SCAN_SSIDS]));
+ if (tb_msg[NL80211_ATTR_MAX_SCAN_IE_LEN])
+ printf("\tmax scan IEs length: %d bytes\n",
+ nla_get_u16(tb_msg[NL80211_ATTR_MAX_SCAN_IE_LEN]));
+
+ if (tb_msg[NL80211_ATTR_WIPHY_FRAG_THRESHOLD]) {
+ unsigned int frag;
+
+ frag = nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_FRAG_THRESHOLD]);
+ if (frag != (unsigned int)-1)
+ printf("\tFragmentation threshold: %d\n", frag);
+ }
+
+ if (tb_msg[NL80211_ATTR_WIPHY_RTS_THRESHOLD]) {
+ unsigned int rts;
+
+ rts = nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_RTS_THRESHOLD]);
+ if (rts != (unsigned int)-1)
+ printf("\tRTS threshold: %d\n", rts);
+ }
+
+ if (tb_msg[NL80211_ATTR_WIPHY_RETRY_SHORT] ||
+ tb_msg[NL80211_ATTR_WIPHY_RETRY_LONG]) {
+ unsigned char retry_short = 0, retry_long = 0;
+
+ if (tb_msg[NL80211_ATTR_WIPHY_RETRY_SHORT])
+ retry_short = nla_get_u8(tb_msg[NL80211_ATTR_WIPHY_RETRY_SHORT]);
+ if (tb_msg[NL80211_ATTR_WIPHY_RETRY_LONG])
+ retry_long = nla_get_u8(tb_msg[NL80211_ATTR_WIPHY_RETRY_LONG]);
+ if (retry_short == retry_long) {
+ printf("\tRetry short long limit: %d\n", retry_short);
+ } else {
+ printf("\tRetry short limit: %d\n", retry_short);
+ printf("\tRetry long limit: %d\n", retry_long);
+ }
+ }
+
+ if (tb_msg[NL80211_ATTR_WIPHY_COVERAGE_CLASS]) {
+ unsigned char coverage;
+
+ coverage = nla_get_u8(tb_msg[NL80211_ATTR_WIPHY_COVERAGE_CLASS]);
+ /* See handle_distance() for an explanation where the '450' comes from */
+ printf("\tCoverage class: %d (up to %dm)\n", coverage, 450 * coverage);
+ }
+
+ if (tb_msg[NL80211_ATTR_CIPHER_SUITES]) {
+ int num = nla_len(tb_msg[NL80211_ATTR_CIPHER_SUITES]) / sizeof(__u32);
+ int i;
+ __u32 *ciphers = nla_data(tb_msg[NL80211_ATTR_CIPHER_SUITES]);
+ if (num > 0) {
+ printf("\tSupported Ciphers:\n");
+ for (i = 0; i < num; i++)
+ printf("\t\t* %s\n",
+ cipher_name(ciphers[i]));
+ }
+ }
+
+ if (tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX] &&
+ tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX])
+ printf("\tAvailable Antennas: TX %#x RX %#x\n",
+ nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX]),
+ nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX]));
+
+ if (tb_msg[NL80211_ATTR_WIPHY_ANTENNA_TX] &&
+ tb_msg[NL80211_ATTR_WIPHY_ANTENNA_RX])
+ printf("\tConfigured Antennas: TX %#x RX %#x\n",
+ nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_TX]),
+ nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_RX]));
+
+ if (tb_msg[NL80211_ATTR_SUPPORTED_IFTYPES]) {
+ printf("\tSupported interface modes:\n");
+ nla_for_each_nested(nl_mode, tb_msg[NL80211_ATTR_SUPPORTED_IFTYPES], rem_mode)
+ printf("\t\t * %s\n", iftype_name(nla_type(nl_mode)));
+ }
+
+ if (tb_msg[NL80211_ATTR_SOFTWARE_IFTYPES]) {
+ printf("\tsoftware interface modes (can always be added):\n");
+ nla_for_each_nested(nl_mode, tb_msg[NL80211_ATTR_SOFTWARE_IFTYPES], rem_mode)
+ printf("\t\t * %s\n", iftype_name(nla_type(nl_mode)));
+ }
+
+ if (tb_msg[NL80211_ATTR_INTERFACE_COMBINATIONS]) {
+ struct nlattr *nl_combi;
+ int rem_combi;
+ bool have_combinations = false;
+
+ nla_for_each_nested(nl_combi, tb_msg[NL80211_ATTR_INTERFACE_COMBINATIONS], rem_combi) {
+ static struct nla_policy iface_combination_policy[NUM_NL80211_IFACE_COMB] = {
+ [NL80211_IFACE_COMB_LIMITS] = { .type = NLA_NESTED },
+ [NL80211_IFACE_COMB_MAXNUM] = { .type = NLA_U32 },
+ [NL80211_IFACE_COMB_STA_AP_BI_MATCH] = { .type = NLA_FLAG },
+ [NL80211_IFACE_COMB_NUM_CHANNELS] = { .type = NLA_U32 },
+ [NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS] = { .type = NLA_U32 },
+ };
+ struct nlattr *tb_comb[NUM_NL80211_IFACE_COMB];
+ static struct nla_policy iface_limit_policy[NUM_NL80211_IFACE_LIMIT] = {
+ [NL80211_IFACE_LIMIT_TYPES] = { .type = NLA_NESTED },
+ [NL80211_IFACE_LIMIT_MAX] = { .type = NLA_U32 },
+ };
+ struct nlattr *tb_limit[NUM_NL80211_IFACE_LIMIT];
+ struct nlattr *nl_limit;
+ int err, rem_limit;
+ bool comma = false;
+
+ if (!have_combinations) {
+ printf("\tvalid interface combinations:\n");
+ have_combinations = true;
+ }
+
+ printf("\t\t * ");
+
+ err = nla_parse_nested(tb_comb, MAX_NL80211_IFACE_COMB,
+ nl_combi, iface_combination_policy);
+ if (err || !tb_comb[NL80211_IFACE_COMB_LIMITS] ||
+ !tb_comb[NL80211_IFACE_COMB_MAXNUM] ||
+ !tb_comb[NL80211_IFACE_COMB_NUM_CHANNELS]) {
+ printf(" <failed to parse>\n");
+ goto broken_combination;
+ }
+
+ nla_for_each_nested(nl_limit, tb_comb[NL80211_IFACE_COMB_LIMITS], rem_limit) {
+ bool ift_comma = false;
+
+ err = nla_parse_nested(tb_limit, MAX_NL80211_IFACE_LIMIT,
+ nl_limit, iface_limit_policy);
+ if (err || !tb_limit[NL80211_IFACE_LIMIT_TYPES]) {
+ printf("<failed to parse>\n");
+ goto broken_combination;
+ }
+
+ if (comma)
+ printf(", ");
+ comma = true;
+ printf("#{");
+
+ nla_for_each_nested(nl_mode, tb_limit[NL80211_IFACE_LIMIT_TYPES], rem_mode) {
+ printf("%s %s", ift_comma ? "," : "",
+ iftype_name(nla_type(nl_mode)));
+ ift_comma = true;
+ }
+ printf(" } <= %u", nla_get_u32(tb_limit[NL80211_IFACE_LIMIT_MAX]));
+ }
+ printf(",\n\t\t ");
+
+ printf("total <= %d, #channels <= %d%s",
+ nla_get_u32(tb_comb[NL80211_IFACE_COMB_MAXNUM]),
+ nla_get_u32(tb_comb[NL80211_IFACE_COMB_NUM_CHANNELS]),
+ tb_comb[NL80211_IFACE_COMB_STA_AP_BI_MATCH] ?
+ ", STA/AP BI must match" : "");
+ if (tb_comb[NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS]) {
+ unsigned long widths = nla_get_u32(tb_comb[NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS]);
+
+ if (widths) {
+ int width;
+ bool first = true;
+
+ printf(", radar detect widths: {");
+ for (width = 0; width < 32; width++)
+ if (widths & (1 << width)) {
+ printf("%s %s",
+ first ? "":",",
+ channel_width_name(width));
+ first = false;
+ }
+ printf(" }\n");
+ }
+ }
+ printf("\n");
+broken_combination:
+ ;