iw: backport he operation scan support

This commit is contained in:
coolsnowwolf 2025-04-05 23:30:40 +08:00
parent 9e70f271da
commit 70bdba2805
10 changed files with 752 additions and 323 deletions

View File

@ -8,15 +8,16 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=iw
PKG_VERSION:=5.19
PKG_RELEASE:=1
PKG_VERSION:=6.9
PKG_RELEASE:=3
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=@KERNEL/software/network/iw
PKG_HASH:=f167bbe947dd53bb9ebc0c1dcef5db6ad73ac1d6084f2c6f9376c5c360cc4d4e
PKG_HASH:=3f2db22ad41c675242b98ae3942dbf3112548c60a42ff739210f2de4e98e4894
PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
PKG_LICENSE:=GPL-2.0
PKG_CPE_ID:=cpe:/a:kernel:iw
PKG_BUILD_FLAGS:=gc-sections lto

View File

@ -1,259 +1,98 @@
--- a/nl80211.h
+++ b/nl80211.h
@@ -324,6 +324,17 @@
*/
/**
+ * DOC: Multi-Link Operation
@@ -2061,6 +2061,10 @@ enum nl80211_commands {
* @NL80211_ATTR_INTERFACE_COMBINATIONS: Nested attribute listing the supported
* interface combinations. In each nested item, it contains attributes
* defined in &enum nl80211_if_combination_attrs.
+ * If the wiphy uses multiple radios (@NL80211_ATTR_WIPHY_RADIOS is set),
+ * this attribute contains the interface combinations of the first radio.
+ * See @NL80211_ATTR_WIPHY_INTERFACE_COMBINATIONS for the global wiphy
+ * combinations for the sum of all radios.
* @NL80211_ATTR_SOFTWARE_IFTYPES: Nested attribute (just like
* %NL80211_ATTR_SUPPORTED_IFTYPES) containing the interface types that
* are managed in software: interfaces of these types aren't subject to
@@ -2856,6 +2860,17 @@ enum nl80211_commands {
* %NL80211_CMD_ASSOCIATE indicating the SPP A-MSDUs
* are used on this connection
*
+ * @NL80211_ATTR_WIPHY_RADIOS: Nested attribute describing physical radios
+ * belonging to this wiphy. See &enum nl80211_wiphy_radio_attrs.
+ *
+ * In Multi-Link Operation, a connection between to MLDs utilizes multiple
+ * links. To use this in nl80211, various commands and responses now need
+ * to or will include the new %NL80211_ATTR_MLO_LINKS attribute.
+ * Additionally, various commands that need to operate on a specific link
+ * now need to be given the %NL80211_ATTR_MLO_LINK_ID attribute, e.g. to
+ * use %NL80211_CMD_START_AP or similar functions.
+ */
+
+/**
* enum nl80211_commands - supported nl80211 commands
*
* @NL80211_CMD_UNSPEC: unspecified command to catch errors
@@ -366,14 +377,22 @@
* the non-transmitting interfaces are deleted as well.
*
* @NL80211_CMD_GET_KEY: Get sequence counter information for a key specified
- * by %NL80211_ATTR_KEY_IDX and/or %NL80211_ATTR_MAC.
+ * by %NL80211_ATTR_KEY_IDX and/or %NL80211_ATTR_MAC. %NL80211_ATTR_MAC
+ * represents peer's MLD address for MLO pairwise key. For MLO group key,
+ * the link is identified by %NL80211_ATTR_MLO_LINK_ID.
* @NL80211_CMD_SET_KEY: Set key attributes %NL80211_ATTR_KEY_DEFAULT,
* %NL80211_ATTR_KEY_DEFAULT_MGMT, or %NL80211_ATTR_KEY_THRESHOLD.
+ * For MLO connection, the link to set default key is identified by
+ * %NL80211_ATTR_MLO_LINK_ID.
* @NL80211_CMD_NEW_KEY: add a key with given %NL80211_ATTR_KEY_DATA,
* %NL80211_ATTR_KEY_IDX, %NL80211_ATTR_MAC, %NL80211_ATTR_KEY_CIPHER,
- * and %NL80211_ATTR_KEY_SEQ attributes.
+ * and %NL80211_ATTR_KEY_SEQ attributes. %NL80211_ATTR_MAC represents
+ * peer's MLD address for MLO pairwise key. The link to add MLO
+ * group key is identified by %NL80211_ATTR_MLO_LINK_ID.
* @NL80211_CMD_DEL_KEY: delete a key identified by %NL80211_ATTR_KEY_IDX
- * or %NL80211_ATTR_MAC.
+ * or %NL80211_ATTR_MAC. %NL80211_ATTR_MAC represents peer's MLD address
+ * for MLO pairwise key. The link to delete group key is identified by
+ * %NL80211_ATTR_MLO_LINK_ID.
*
* @NL80211_CMD_GET_BEACON: (not used)
* @NL80211_CMD_SET_BEACON: change the beacon on an access point interface
@@ -753,6 +772,13 @@
* %NL80211_ATTR_CSA_C_OFFSETS_TX is an array of offsets to CSA
* counters which will be updated to the current value. This attribute
* is used during CSA period.
+ * For TX on an MLD, the frequency can be omitted and the link ID be
+ * specified, or if transmitting to a known peer MLD (with MLD addresses
+ * in the frame) both can be omitted and the link will be selected by
+ * lower layers.
+ * For RX notification, %NL80211_ATTR_RX_HW_TIMESTAMP may be included to
+ * indicate the frame RX timestamp and %NL80211_ATTR_TX_HW_TIMESTAMP may
+ * be included to indicate the ack TX timestamp.
* @NL80211_CMD_FRAME_WAIT_CANCEL: When an off-channel TX was requested, this
* command may be used with the corresponding cookie to cancel the wait
* time if it is known that it is no longer necessary. This command is
@@ -763,7 +789,9 @@
* transmitted with %NL80211_CMD_FRAME. %NL80211_ATTR_COOKIE identifies
* the TX command and %NL80211_ATTR_FRAME includes the contents of the
* frame. %NL80211_ATTR_ACK flag is included if the recipient acknowledged
- * the frame.
+ * the frame. %NL80211_ATTR_TX_HW_TIMESTAMP may be included to indicate the
+ * tx timestamp and %NL80211_ATTR_RX_HW_TIMESTAMP may be included to
+ * indicate the ack RX timestamp.
* @NL80211_CMD_ACTION_TX_STATUS: Alias for @NL80211_CMD_FRAME_TX_STATUS for
* backward compatibility.
*
@@ -1108,6 +1136,12 @@
* has been received. %NL80211_ATTR_FRAME is used to specify the
* frame contents. The frame is the raw EAPoL data, without ethernet or
* 802.11 headers.
+ * For an MLD transmitter, the %NL80211_ATTR_MLO_LINK_ID may be given and
+ * its effect will depend on the destination: If the destination is known
+ * to be an MLD, this will be used as a hint to select the link to transmit
+ * the frame on. If the destination is not an MLD, this will select both
+ * the link to transmit on and the source address will be set to the link
+ * address of that link.
* When used as an event indication %NL80211_ATTR_CONTROL_PORT_ETHERTYPE,
* %NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT and %NL80211_ATTR_MAC are added
* indicating the protocol type of the received frame; whether the frame
@@ -1237,6 +1271,16 @@
* to describe the BSSID address of the AP and %NL80211_ATTR_TIMEOUT to
* specify the timeout value.
*
+ * @NL80211_CMD_ADD_LINK: Add a new link to an interface. The
+ * %NL80211_ATTR_MLO_LINK_ID attribute is used for the new link.
+ * @NL80211_CMD_REMOVE_LINK: Remove a link from an interface. This may come
+ * without %NL80211_ATTR_MLO_LINK_ID as an easy way to remove all links
+ * in preparation for e.g. roaming to a regular (non-MLO) AP.
+ * @NL80211_ATTR_WIPHY_INTERFACE_COMBINATIONS: Nested attribute listing the
+ * supported interface combinations for all radios combined. In each
+ * nested item, it contains attributes defined in
+ * &enum nl80211_if_combination_attrs.
+ *
+ * @NL80211_CMD_ADD_LINK_STA: Add a link to an MLD station
+ * @NL80211_CMD_MODIFY_LINK_STA: Modify a link of an MLD station
+ * @NL80211_CMD_REMOVE_LINK_STA: Remove a link of an MLD station
+ *
* @NL80211_CMD_MAX: highest used command number
* @__NL80211_CMD_AFTER_LAST: internal use
*/
@@ -1481,6 +1525,13 @@ enum nl80211_commands {
NL80211_CMD_ASSOC_COMEBACK,
+ NL80211_CMD_ADD_LINK,
+ NL80211_CMD_REMOVE_LINK,
+
+ NL80211_CMD_ADD_LINK_STA,
+ NL80211_CMD_MODIFY_LINK_STA,
+ NL80211_CMD_REMOVE_LINK_STA,
+
/* add new commands above here */
/* used to define NL80211_CMD_MAX below */
@@ -2340,8 +2391,10 @@ enum nl80211_commands {
*
* @NL80211_ATTR_IFTYPE_EXT_CAPA: Nested attribute of the following attributes:
* %NL80211_ATTR_IFTYPE, %NL80211_ATTR_EXT_CAPA,
- * %NL80211_ATTR_EXT_CAPA_MASK, to specify the extended capabilities per
- * interface type.
+ * %NL80211_ATTR_EXT_CAPA_MASK, to specify the extended capabilities and
+ * other interface-type specific capabilities per interface type. For MLO,
+ * %NL80211_ATTR_EML_CAPABILITY and %NL80211_ATTR_MLD_CAPA_AND_OPS are
+ * present.
*
* @NL80211_ATTR_MU_MIMO_GROUP_DATA: array of 24 bytes that defines a MU-MIMO
* groupID for monitor mode.
@@ -2663,6 +2716,44 @@ enum nl80211_commands {
* association request when used with NL80211_CMD_NEW_STATION). Can be set
* only if %NL80211_STA_FLAG_WME is set.
*
+ * @NL80211_ATTR_MLO_LINK_ID: A (u8) link ID for use with MLO, to be used with
+ * various commands that need a link ID to operate.
+ * @NL80211_ATTR_MLO_LINKS: A nested array of links, each containing some
+ * per-link information and a link ID.
+ * @NL80211_ATTR_MLD_ADDR: An MLD address, used with various commands such as
+ * authenticate/associate.
+ *
+ * @NL80211_ATTR_MLO_SUPPORT: Flag attribute to indicate user space supports MLO
+ * connection. Used with %NL80211_CMD_CONNECT. If this attribute is not
+ * included in NL80211_CMD_CONNECT drivers must not perform MLO connection.
+ *
+ * @NL80211_ATTR_MAX_NUM_AKM_SUITES: U16 attribute. Indicates maximum number of
+ * AKM suites allowed for %NL80211_CMD_CONNECT, %NL80211_CMD_ASSOCIATE and
+ * %NL80211_CMD_START_AP in %NL80211_CMD_GET_WIPHY response. If this
+ * attribute is not present userspace shall consider maximum number of AKM
+ * suites allowed as %NL80211_MAX_NR_AKM_SUITES which is the legacy maximum
+ * number prior to the introduction of this attribute.
+ *
+ * @NL80211_ATTR_EML_CAPABILITY: EML Capability information (u16)
+ * @NL80211_ATTR_MLD_CAPA_AND_OPS: MLD Capabilities and Operations (u16)
+ *
+ * @NL80211_ATTR_TX_HW_TIMESTAMP: Hardware timestamp for TX operation in
+ * nanoseconds (u64). This is the device clock timestamp so it will
+ * probably reset when the device is stopped or the firmware is reset.
+ * When used with %NL80211_CMD_FRAME_TX_STATUS, indicates the frame TX
+ * timestamp. When used with %NL80211_CMD_FRAME RX notification, indicates
+ * the ack TX timestamp.
+ * @NL80211_ATTR_RX_HW_TIMESTAMP: Hardware timestamp for RX operation in
+ * nanoseconds (u64). This is the device clock timestamp so it will
+ * probably reset when the device is stopped or the firmware is reset.
+ * When used with %NL80211_CMD_FRAME_TX_STATUS, indicates the ack RX
+ * timestamp. When used with %NL80211_CMD_FRAME RX notification, indicates
+ * the incoming frame RX timestamp.
+ * @NL80211_ATTR_TD_BITMAP: Transition Disable bitmap, for subsequent
+ * (re)associations.
+ * @NL80211_ATTR_WIPHY_ANTENNA_GAIN: Configured antenna gain. Used to reduce
+ * transmit power to stay within regulatory limits. u32, dBi.
+ * @NL80211_ATTR_VIF_RADIO_MASK: Bitmask of allowed radios (u32).
+ * A value of 0 means all radios.
+ *
* @NUM_NL80211_ATTR: total number of nl80211_attrs available
* @NL80211_ATTR_MAX: highest attribute number currently defined
* @__NL80211_ATTR_AFTER_LAST: internal use
@@ -3177,6 +3268,23 @@ enum nl80211_attrs {
@@ -3401,6 +3416,11 @@ enum nl80211_attrs {
NL80211_ATTR_DISABLE_EHT,
NL80211_ATTR_ASSOC_SPP_AMSDU,
+ NL80211_ATTR_MLO_LINKS,
+ NL80211_ATTR_MLO_LINK_ID,
+ NL80211_ATTR_MLD_ADDR,
+ NL80211_ATTR_WIPHY_RADIOS,
+ NL80211_ATTR_WIPHY_INTERFACE_COMBINATIONS,
+
+ NL80211_ATTR_MLO_SUPPORT,
+
+ NL80211_ATTR_MAX_NUM_AKM_SUITES,
+
+ NL80211_ATTR_EML_CAPABILITY,
+ NL80211_ATTR_MLD_CAPA_AND_OPS,
+
+ NL80211_ATTR_TX_HW_TIMESTAMP,
+ NL80211_ATTR_RX_HW_TIMESTAMP,
+ NL80211_ATTR_TD_BITMAP,
+
+ NL80211_ATTR_WIPHY_ANTENNA_GAIN,
+ NL80211_ATTR_VIF_RADIO_MASK,
+
/* add attributes here, update the policy in nl80211.c */
__NL80211_ATTR_AFTER_LAST,
@@ -3231,6 +3339,11 @@ enum nl80211_attrs {
#define NL80211_HE_MIN_CAPABILITY_LEN 16
#define NL80211_HE_MAX_CAPABILITY_LEN 54
#define NL80211_MAX_NR_CIPHER_SUITES 5
+
+/*
+ * NL80211_MAX_NR_AKM_SUITES is obsolete when %NL80211_ATTR_MAX_NUM_AKM_SUITES
+ * present in %NL80211_CMD_GET_WIPHY response.
+ */
#define NL80211_MAX_NR_AKM_SUITES 2
#define NL80211_EHT_MIN_CAPABILITY_LEN 13
#define NL80211_EHT_MAX_CAPABILITY_LEN 51
@@ -4853,6 +4966,8 @@ enum nl80211_bss_scan_width {
* Contains a nested array of signal strength attributes (u8, dBm),
* using the nesting index as the antenna number.
* @NL80211_BSS_FREQUENCY_OFFSET: frequency offset in KHz
+ * @NL80211_BSS_MLO_LINK_ID: MLO link ID of the BSS (u8).
+ * @NL80211_BSS_MLD_ADDR: MLD address of this BSS if connected to it.
* @__NL80211_BSS_AFTER_LAST: internal
* @NL80211_BSS_MAX: highest BSS attribute
*/
@@ -4878,6 +4993,8 @@ enum nl80211_bss {
NL80211_BSS_PARENT_BSSID,
NL80211_BSS_CHAIN_SIGNAL,
NL80211_BSS_FREQUENCY_OFFSET,
+ NL80211_BSS_MLO_LINK_ID,
+ NL80211_BSS_MLD_ADDR,
@@ -7987,4 +8007,54 @@ enum nl80211_ap_settings_flags {
NL80211_AP_SETTINGS_SA_QUERY_OFFLOAD_SUPPORT = 1 << 1,
};
/* keep last */
__NL80211_BSS_AFTER_LAST,
@@ -5874,7 +5991,7 @@ enum nl80211_ap_sme_features {
* @NL80211_FEATURE_INACTIVITY_TIMER: This driver takes care of freeing up
* the connected inactive stations in AP mode.
* @NL80211_FEATURE_CELL_BASE_REG_HINTS: This driver has been tested
- * to work properly to suppport receiving regulatory hints from
+ * to work properly to support receiving regulatory hints from
* cellular base stations.
* @NL80211_FEATURE_P2P_DEVICE_NEEDS_CHANNEL: (no longer available, only
* here to reserve the value for API/ABI compatibility)
@@ -6174,6 +6291,14 @@ enum nl80211_feature_flags {
* @NL80211_EXT_FEATURE_RADAR_BACKGROUND: Device supports background radar/CAC
* detection.
*
+ * @NL80211_EXT_FEATURE_POWERED_ADDR_CHANGE: Device can perform a MAC address
+ * change without having to bring the underlying network device down
+ * first. For example, in station mode this can be used to vary the
+ * origin MAC address prior to a connection to a new AP for privacy
+ * or other reasons. Note that certain driver specific restrictions
+ * might apply, e.g. no scans in progress, no offchannel operations
+ * in progress, and no active connections.
+/**
+ * enum nl80211_wiphy_radio_attrs - wiphy radio attributes
+ *
* @NUM_NL80211_EXT_FEATURES: number of extended features.
* @MAX_NL80211_EXT_FEATURES: highest extended feature index.
*/
@@ -6241,6 +6366,7 @@ enum nl80211_ext_feature_index {
NL80211_EXT_FEATURE_BSS_COLOR,
NL80211_EXT_FEATURE_FILS_CRYPTO_OFFLOAD,
NL80211_EXT_FEATURE_RADAR_BACKGROUND,
+ NL80211_EXT_FEATURE_POWERED_ADDR_CHANGE,
/* add new features before the definition below */
NUM_NL80211_EXT_FEATURES,
+ * @__NL80211_WIPHY_RADIO_ATTR_INVALID: Invalid
+ *
+ * @NL80211_WIPHY_RADIO_ATTR_INDEX: Index of this radio (u32)
+ * @NL80211_WIPHY_RADIO_ATTR_FREQ_RANGE: Frequency range supported by this
+ * radio. Attribute may be present multiple times.
+ * @NL80211_WIPHY_RADIO_ATTR_INTERFACE_COMBINATION: Supported interface
+ * combination for this radio. Attribute may be present multiple times
+ * and contains attributes defined in &enum nl80211_if_combination_attrs.
+ *
+ * @__NL80211_WIPHY_RADIO_ATTR_LAST: Internal
+ * @NL80211_WIPHY_RADIO_ATTR_MAX: Highest attribute
+ */
+enum nl80211_wiphy_radio_attrs {
+ __NL80211_WIPHY_RADIO_ATTR_INVALID,
+
+ NL80211_WIPHY_RADIO_ATTR_INDEX,
+ NL80211_WIPHY_RADIO_ATTR_FREQ_RANGE,
+ NL80211_WIPHY_RADIO_ATTR_INTERFACE_COMBINATION,
+
+ /* keep last */
+ __NL80211_WIPHY_RADIO_ATTR_LAST,
+ NL80211_WIPHY_RADIO_ATTR_MAX = __NL80211_WIPHY_RADIO_ATTR_LAST - 1,
+};
+
+/**
+ * enum nl80211_wiphy_radio_freq_range - wiphy radio frequency range
+ *
+ * @__NL80211_WIPHY_RADIO_FREQ_ATTR_INVALID: Invalid
+ *
+ * @NL80211_WIPHY_RADIO_FREQ_ATTR_START: Frequency range start (u32).
+ * The unit is kHz.
+ * @NL80211_WIPHY_RADIO_FREQ_ATTR_END: Frequency range end (u32).
+ * The unit is kHz.
+ *
+ * @__NL80211_WIPHY_RADIO_FREQ_ATTR_LAST: Internal
+ * @NL80211_WIPHY_RADIO_FREQ_ATTR_MAX: Highest attribute
+ */
+enum nl80211_wiphy_radio_freq_range {
+ __NL80211_WIPHY_RADIO_FREQ_ATTR_INVALID,
+
+ NL80211_WIPHY_RADIO_FREQ_ATTR_START,
+ NL80211_WIPHY_RADIO_FREQ_ATTR_END,
+
+ __NL80211_WIPHY_RADIO_FREQ_ATTR_LAST,
+ NL80211_WIPHY_RADIO_FREQ_ATTR_MAX = __NL80211_WIPHY_RADIO_FREQ_ATTR_LAST - 1,
+};
+
#endif /* __LINUX_NL80211_H */

View File

@ -16,7 +16,7 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
--- a/Makefile
+++ b/Makefile
@@ -45,30 +45,30 @@ NLLIBNAME = libnl-1
@@ -46,30 +46,30 @@ NLLIBNAME = libnl-1
endif
ifeq ($(NL2FOUND),Y)
@ -55,7 +55,7 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
NLLIBNAME = libnl-3.1
endif
@@ -76,8 +76,8 @@ ifeq ($(NLLIBNAME),)
@@ -77,8 +77,8 @@ ifeq ($(NLLIBNAME),)
$(error Cannot find development files for any supported version of libnl)
endif

View File

@ -0,0 +1,153 @@
From 422419e06d55a7c852d1f6f054a094e285ebaa27 Mon Sep 17 00:00:00 2001
From: Christopher A Wills <christopher.a.wills@intel.com>
Date: Tue, 30 Jul 2024 16:27:36 -0700
Subject: [PATCH] scan: Add printing of HE Operation Element
Signed-off-by: Christopher A Wills <christopher.a.wills@intel.com>
---
iw.h | 1 +
scan.c | 8 +++++
util.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 112 insertions(+)
--- a/iw.h
+++ b/iw.h
@@ -222,6 +222,7 @@ void print_ampdu_spacing(__u8 spacing);
void print_ht_capability(__u16 cap);
void print_vht_info(__u32 capa, const __u8 *mcs);
void print_he_capability(const uint8_t *ie, int len);
+void print_he_operation(const uint8_t *ie, int len);
void print_he_info(struct nlattr *nl_iftype);
void print_eht_info(struct nlattr *nl_iftype, int band);
void print_s1g_capability(const uint8_t *caps);
--- a/scan.c
+++ b/scan.c
@@ -2384,8 +2384,16 @@ static void print_he_capa(const uint8_t
print_he_capability(data, len);
}
+static void print_he_oper(const uint8_t type, uint8_t len, const uint8_t *data,
+ const struct print_ies_data *ie_buffer)
+{
+ printf("\n");
+ print_he_operation(data, len);
+}
+
static const struct ie_print ext_printers[] = {
[35] = { "HE capabilities", print_he_capa, 21, 54, BIT(PRINT_SCAN), },
+ [36] = { "HE Operation", print_he_oper, 6, 15, BIT(PRINT_SCAN), },
};
static void print_extension(unsigned char len, unsigned char *ie,
--- a/util.c
+++ b/util.c
@@ -1733,6 +1733,109 @@ void print_he_capability(const uint8_t *
__print_he_capa(mac_cap, phy_cap - 1, mcs_set, mcs_len, NULL, 0, false);
}
+void print_he_operation(const uint8_t *ie, int len)
+{
+ uint8_t oper_parameters[3] = {ie[0], ie[1], ie[2] };
+ uint8_t bss_color = ie[3];
+ uint16_t nss_mcs_set = *(uint16_t*)(&ie[4]);
+ uint8_t vht_oper_present = oper_parameters[1] & 0x40;
+ uint8_t co_hosted_bss_present = oper_parameters[1] & 0x80;
+ uint8_t uhb_operation_info_present = oper_parameters[2] & 0x02;
+ uint8_t offset = 6;
+
+ printf("\t\tHE Operation Parameters: (0x%02x%02x%02x)\n",
+ oper_parameters[2], oper_parameters[1], oper_parameters[0]);
+ printf("\t\t\tDefault PE Duration: %hhu\n", oper_parameters[0] & 0x07);
+ if (oper_parameters[0] & 0x08)
+ printf("\t\t\tTWT Required\n");
+
+ printf("\t\t\tTXOP Duration RTS Threshold: %hu\n",
+ (*(uint16_t*)(oper_parameters)) >> 4 & 0x03ff);
+ if (oper_parameters[1] & 0x40)
+ printf("\t\t\tVHT Operation Information Present\n");
+
+ if (oper_parameters[1] & 0x80)
+ printf("\t\t\tCo-Hosted BSS\n");
+
+ if (oper_parameters[2] & 0x01)
+ printf("\t\t\tER SU Disable\n");
+
+ if (oper_parameters[2] & 0x02)
+ printf("\t\t\t6 GHz Operation Information Present\n");
+
+ printf("\t\tBSS Color: %hhu\n", bss_color & 0x3F);
+ if (bss_color & 0x40)
+ printf("\t\tPartial BSS Color\n");
+
+ if (bss_color & 0x80)
+ printf("\t\tBSS Color Disabled\n");
+
+ printf("\t\tBasic HE-MCS NSS Set: 0x%04x\n", nss_mcs_set);
+ for (int k = 0; k < 8; k++) {
+ __u16 mcs = nss_mcs_set;
+
+ mcs >>= k * 2;
+ mcs &= 0x3;
+ printf("\t\t\t%d streams: ", k + 1);
+ if (mcs == 3)
+ printf("not supported\n");
+ else
+ printf("MCS 0-%d\n", 7 + (mcs * 2));
+ }
+
+ if (vht_oper_present) {
+ if (len - offset < 3) {
+ printf("\t\tVHT Operation Info: Invalid\n");
+ return;
+ }
+
+ printf("\t\tVHT Operation Info: 0x%02x%02x%02x\n",
+ ie[offset + 2], ie[offset + 1], ie[offset + 0]);
+ offset += 3;
+ }
+
+ if (co_hosted_bss_present) {
+ if (len - offset < 1) {
+ printf("\t\tMax Co-Hosted BSSID: Invalid\n");
+ return;
+ }
+
+ printf("\t\tMax Co-Hosted BSSID: %hhu\n", ie[offset]);
+ offset += 1;
+ }
+
+ if (uhb_operation_info_present) {
+ if (len - offset < 5) {
+ printf("\t\t6 GHz Operation Info: Invalid\n");
+ return;
+ } else {
+ const uint8_t control = ie[offset + 1];
+
+ printf("\t\t6 Ghz Operation Information: 0x");
+ for (uint8_t i = 0; i < 5; i++)
+ printf("%02x", ie[offset + i]);
+
+ printf("\n");
+ printf("\t\t\tPrimary Channel: %hhu\n", ie[offset]);
+ printf("\t\t\tChannel Width: ");
+ switch (control & 0x3) {
+ case 0: printf("20 MHz\n"); break;
+ case 1: printf("40 MHz\n"); break;
+ case 2: printf("80 MHz\n"); break;
+ case 3: printf("80+80 or 160 MHz\n"); break;
+ }
+
+ if (control & 0x4)
+ printf("\t\t\tDuplicate Beacon: True\n");
+
+ printf("\t\t\tRegulatory Info: %hhu\n", (control >> 3) & 0xf);
+ printf("\t\t\tCenter Frequency Segment 0: %hhu\n", ie[offset+2]);
+ printf("\t\t\tCenter Frequency Segment 1: %hhu\n", ie[offset+3]);
+ printf("\t\t\tMinimum Rate: %hhu\n", ie[offset+4]);
+ }
+ }
+}
+
void iw_hexdump(const char *prefix, const __u8 *buf, size_t size)
{
size_t i;

View File

@ -0,0 +1,77 @@
From c41971e27a8359f88122593a2700f270f58cb2fa Mon Sep 17 00:00:00 2001
From: Aleksander Jan Bajkowski <olek2@wp.pl>
Date: Sat, 5 Apr 2025 20:48:05 +0200
Subject: [PATCH 1/2] iw: fix HE capabilities on Big Endian platforms
IE fields are encoded in Little Endian and are not correctly
printed on Big Endian platforms.
Fixes: c741be9f6ca3 ("iw: print HE capabilities")
Signed-off-by: Aleksander Jan Bajkowski <olek2@wp.pl>
Link: https://patch.msgid.link/20250405184807.701728-2-olek2@wp.pl
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
util.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
--- a/util.c
+++ b/util.c
@@ -1245,14 +1245,15 @@ static void __print_he_capa(const __u16
#define PRINT_HE_CAP(_var, _idx, _bit, _str) \
do { \
- if (_var[_idx] & BIT(_bit)) \
+ if (le16toh(_var[_idx]) & BIT(_bit)) \
printf("%s\t\t\t" _str "\n", pre); \
} while (0)
#define PRINT_HE_CAP_MASK(_var, _idx, _shift, _mask, _str) \
do { \
- if ((_var[_idx] >> _shift) & _mask) \
- printf("%s\t\t\t" _str ": %d\n", pre, (_var[_idx] >> _shift) & _mask); \
+ if ((le16toh(_var[_idx]) >> _shift) & _mask) \
+ printf("%s\t\t\t" _str ": %d\n", pre, \
+ (le16toh(_var[_idx]) >> _shift) & _mask); \
} while (0)
#define PRINT_HE_MAC_CAP(...) PRINT_HE_CAP(mac_cap, __VA_ARGS__)
@@ -1263,7 +1264,7 @@ static void __print_he_capa(const __u16
printf("%s\t\tHE MAC Capabilities (0x", pre);
for (i = 0; i < 3; i++)
- printf("%04x", mac_cap[i]);
+ printf("%04x", le16toh(mac_cap[i]));
printf("):\n");
PRINT_HE_MAC_CAP(0, 0, "+HTC HE Supported");
@@ -1377,18 +1378,18 @@ static void __print_he_capa(const __u16
char *bw[] = { "<= 80", "160", "80+80" };
int j;
- if ((phy_cap[0] & (phy_cap_support[i] << 8)) == 0)
+ if ((le16toh(phy_cap[0]) & (phy_cap_support[i] << 8)) == 0)
continue;
/* Supports more, but overflow? Abort. */
- if ((i * 2 + 2) * sizeof(mcs_set[0]) >= mcs_len)
+ if ((i * 2 + 2) * sizeof(le16toh(mcs_set[0])) >= mcs_len)
return;
for (j = 0; j < 2; j++) {
int k;
printf("%s\t\tHE %s MCS and NSS set %s MHz\n", pre, j ? "TX" : "RX", bw[i]);
for (k = 0; k < 8; k++) {
- __u16 mcs = mcs_set[(i * 2) + j];
+ __u16 mcs = le16toh(mcs_set[(i * 2) + j]);
mcs >>= k * 2;
mcs &= 0x3;
printf("%s\t\t\t%d streams: ", pre, k + 1);
@@ -1411,7 +1412,7 @@ static void __print_he_capa(const __u16
ppet_len = 0;
}
- if (ppet_len && (phy_cap[3] & BIT(15))) {
+ if (ppet_len && (le16toh(phy_cap[3]) & BIT(15))) {
printf("%s\t\tPPE Threshold ", pre);
for (i = 0; i < ppet_len; i++)
if (ppet[i])

View File

@ -0,0 +1,36 @@
From 41a07a818090da424ddd24bf07f468cf5725cdc6 Mon Sep 17 00:00:00 2001
From: Aleksander Jan Bajkowski <olek2@wp.pl>
Date: Sat, 5 Apr 2025 20:48:06 +0200
Subject: [PATCH 2/2] iw: fix HE operation on Big Endian platforms
IE fields are encoded in Little Endian and are not correctly
printed on Big Endian platforms.
Fixes: 422419e06d55 ("scan: Add printing of HE Operation Element")
Signed-off-by: Aleksander Jan Bajkowski <olek2@wp.pl>
Link: https://patch.msgid.link/20250405184807.701728-3-olek2@wp.pl
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
util.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/util.c
+++ b/util.c
@@ -1738,7 +1738,7 @@ void print_he_operation(const uint8_t *i
{
uint8_t oper_parameters[3] = {ie[0], ie[1], ie[2] };
uint8_t bss_color = ie[3];
- uint16_t nss_mcs_set = *(uint16_t*)(&ie[4]);
+ uint16_t nss_mcs_set = le16toh(*(uint16_t *)(&ie[4]));
uint8_t vht_oper_present = oper_parameters[1] & 0x40;
uint8_t co_hosted_bss_present = oper_parameters[1] & 0x80;
uint8_t uhb_operation_info_present = oper_parameters[2] & 0x02;
@@ -1751,7 +1751,7 @@ void print_he_operation(const uint8_t *i
printf("\t\t\tTWT Required\n");
printf("\t\t\tTXOP Duration RTS Threshold: %hu\n",
- (*(uint16_t*)(oper_parameters)) >> 4 & 0x03ff);
+ le16toh((*(uint16_t *)(oper_parameters))) >> 4 & 0x03ff);
if (oper_parameters[1] & 0x40)
printf("\t\t\tVHT Operation Information Present\n");

View File

@ -1,33 +0,0 @@
--- a/phy.c
+++ b/phy.c
@@ -855,3 +855,30 @@ static int handle_get_txq(struct nl80211
COMMAND(get, txq, "",
NL80211_CMD_GET_WIPHY, 0, CIB_PHY, handle_get_txq,
"Get TXQ parameters.");
+
+static int handle_antenna_gain(struct nl80211_state *state,
+ struct nl_msg *msg,
+ int argc, char **argv,
+ enum id_input id)
+{
+ char *endptr;
+ int dbm;
+
+ /* get the required args */
+ if (argc != 1)
+ return 1;
+
+ dbm = strtol(argv[0], &endptr, 10);
+ if (*endptr)
+ return 2;
+
+ NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_ANTENNA_GAIN, dbm);
+
+ return 0;
+
+ nla_put_failure:
+ return -ENOBUFS;
+}
+COMMAND(set, antenna_gain, "<antenna gain in dBm>",
+ NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_antenna_gain,
+ "Specify antenna gain.");

View File

@ -1,6 +1,6 @@
--- a/event.c
+++ b/event.c
@@ -971,6 +971,7 @@ static int print_event(struct nl_msg *ms
@@ -973,6 +973,7 @@ static int print_event(struct nl_msg *ms
}
switch (gnlh->cmd) {
@ -8,7 +8,7 @@
case NL80211_CMD_NEW_WIPHY:
printf("renamed to %s\n", nla_get_string(tb[NL80211_ATTR_WIPHY_NAME]));
break;
@@ -1006,6 +1007,7 @@ static int print_event(struct nl_msg *ms
@@ -1008,6 +1009,7 @@ static int print_event(struct nl_msg *ms
case NL80211_CMD_SCHED_SCAN_RESULTS:
printf("got scheduled scan results\n");
break;
@ -16,7 +16,7 @@
case NL80211_CMD_WIPHY_REG_CHANGE:
case NL80211_CMD_REG_CHANGE:
if (gnlh->cmd == NL80211_CMD_WIPHY_REG_CHANGE)
@@ -1088,6 +1090,7 @@ static int print_event(struct nl_msg *ms
@@ -1090,6 +1092,7 @@ static int print_event(struct nl_msg *ms
mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC]));
printf("del station %s\n", macbuf);
break;
@ -24,7 +24,7 @@
case NL80211_CMD_JOIN_IBSS:
mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC]));
printf("IBSS %s joined\n", macbuf);
@@ -1295,9 +1298,9 @@ static int print_event(struct nl_msg *ms
@@ -1297,9 +1300,9 @@ static int print_event(struct nl_msg *ms
case NL80211_CMD_ASSOC_COMEBACK: /* 147 */
parse_assoc_comeback(tb, gnlh->cmd);
break;
@ -38,7 +38,7 @@
--- a/info.c
+++ b/info.c
@@ -309,6 +309,7 @@ next:
@@ -446,6 +446,7 @@ next:
}
}
@ -46,7 +46,7 @@
if (tb_band[NL80211_BAND_ATTR_RATES]) {
printf("\t\tBitrates (non-HT):\n");
nla_for_each_nested(nl_rate, tb_band[NL80211_BAND_ATTR_RATES], rem_rate) {
@@ -325,6 +326,7 @@ next:
@@ -462,6 +463,7 @@ next:
printf("\n");
}
}
@ -54,7 +54,7 @@
}
}
@@ -390,6 +392,7 @@ next:
@@ -527,6 +529,7 @@ next:
printf("\tCoverage class: %d (up to %dm)\n", coverage, 450 * coverage);
}
@ -62,7 +62,7 @@
if (tb_msg[NL80211_ATTR_CIPHER_SUITES]) {
int num = nla_len(tb_msg[NL80211_ATTR_CIPHER_SUITES]) / sizeof(__u32);
int i;
@@ -401,6 +404,7 @@ next:
@@ -538,6 +541,7 @@ next:
cipher_name(ciphers[i]));
}
}
@ -70,7 +70,7 @@
if (tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX] &&
tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX])
@@ -418,9 +422,11 @@ next:
@@ -555,9 +559,11 @@ next:
print_iftype_list("\tSupported interface modes", "\t\t",
tb_msg[NL80211_ATTR_SUPPORTED_IFTYPES]);
@ -82,7 +82,7 @@
if (tb_msg[NL80211_ATTR_INTERFACE_COMBINATIONS]) {
struct nlattr *nl_combi;
@@ -510,6 +516,7 @@ broken_combination:
@@ -647,6 +653,7 @@ broken_combination:
printf("\tinterface combinations are not supported\n");
}
@ -90,7 +90,7 @@
if (tb_msg[NL80211_ATTR_SUPPORTED_COMMANDS]) {
printf("\tSupported commands:\n");
nla_for_each_nested(nl_cmd, tb_msg[NL80211_ATTR_SUPPORTED_COMMANDS], rem_cmd)
@@ -607,6 +614,7 @@ broken_combination:
@@ -744,6 +751,7 @@ broken_combination:
printf("\t\t * wake up on TCP connection\n");
}
}
@ -98,7 +98,7 @@
if (tb_msg[NL80211_ATTR_ROAM_SUPPORT])
printf("\tDevice supports roaming.\n");
@@ -645,6 +653,7 @@ broken_combination:
@@ -782,6 +790,7 @@ broken_combination:
}
}
@ -106,7 +106,7 @@
if (tb_msg[NL80211_ATTR_FEATURE_FLAGS]) {
unsigned int features = nla_get_u32(tb_msg[NL80211_ATTR_FEATURE_FLAGS]);
@@ -709,6 +718,7 @@ broken_combination:
@@ -846,6 +855,7 @@ broken_combination:
if (features & NL80211_FEATURE_ND_RANDOM_MAC_ADDR)
printf("\tDevice supports randomizing MAC-addr in net-detect scans.\n");
}
@ -114,7 +114,7 @@
if (tb_msg[NL80211_ATTR_TDLS_SUPPORT])
printf("\tDevice supports T-DLS.\n");
@@ -774,6 +784,7 @@ TOPLEVEL(list, NULL, NL80211_CMD_GET_WIP
@@ -914,6 +924,7 @@ TOPLEVEL(list, NULL, NL80211_CMD_GET_WIP
"List all wireless devices and their capabilities.");
TOPLEVEL(phy, NULL, NL80211_CMD_GET_WIPHY, NLM_F_DUMP, CIB_NONE, handle_info, NULL);
@ -122,7 +122,7 @@
static int handle_commands(struct nl80211_state *state, struct nl_msg *msg,
int argc, char **argv, enum id_input id)
{
@@ -785,6 +796,7 @@ static int handle_commands(struct nl8021
@@ -925,6 +936,7 @@ static int handle_commands(struct nl8021
}
TOPLEVEL(commands, NULL, NL80211_CMD_GET_WIPHY, 0, CIB_NONE, handle_commands,
"list all known commands and their decimal & hex value");
@ -132,7 +132,7 @@
{
--- a/scan.c
+++ b/scan.c
@@ -1306,6 +1306,9 @@ static void print_ht_op(const uint8_t ty
@@ -1308,6 +1308,9 @@ static void print_ht_op(const uint8_t ty
printf("\t\t * secondary channel offset: %s\n",
ht_secondary_offset[data[1] & 0x3]);
printf("\t\t * STA channel width: %s\n", sta_chan_width[(data[1] & 0x4)>>2]);
@ -142,10 +142,11 @@
printf("\t\t * RIFS: %d\n", (data[1] & 0x8)>>3);
printf("\t\t * HT protection: %s\n", protection[data[2] & 0x3]);
printf("\t\t * non-GF present: %d\n", (data[2] & 0x4) >> 2);
@@ -1716,6 +1719,14 @@ static void print_ie(const struct ie_pri
@@ -1818,30 +1821,31 @@ static void print_ie(const struct ie_pri
static const struct ie_print ieprinters[] = {
[0] = { "SSID", print_ssid, 0, 32, BIT(PRINT_SCAN) | BIT(PRINT_LINK), },
[0] = { "SSID", print_ssid, 0, 32,
BIT(PRINT_SCAN) | BIT(PRINT_LINK) | BIT(PRINT_LINK_MLO_MLD), },
+ [11] = { "BSS Load", print_bss_load, 5, 5, BIT(PRINT_SCAN), },
+ [45] = { "HT capabilities", print_ht_capa, 26, 26, BIT(PRINT_SCAN), },
+ [48] = { "RSN", print_rsn, 2, 255, BIT(PRINT_SCAN), },
+ [61] = { "HT operation", print_ht_op, 22, 22, BIT(PRINT_SCAN), },
@ -157,7 +158,9 @@
[1] = { "Supported rates", print_supprates, 0, 255, BIT(PRINT_SCAN), },
[3] = { "DS Parameter set", print_ds, 1, 1, BIT(PRINT_SCAN), },
[5] = { "TIM", print_tim, 4, 255, BIT(PRINT_SCAN), },
@@ -1725,26 +1736,20 @@ static const struct ie_print ieprinters[
[6] = { "IBSS ATIM window", print_ibssatim, 2, 2, BIT(PRINT_SCAN), },
[7] = { "Country", print_country, 3, 255, BIT(PRINT_SCAN), },
- [11] = { "BSS Load", print_bss_load, 5, 5, BIT(PRINT_SCAN), },
[32] = { "Power constraint", print_powerconstraint, 1, 1, BIT(PRINT_SCAN), },
[35] = { "TPC report", print_tpcreport, 2, 2, BIT(PRINT_SCAN), },
[42] = { "ERP", print_erp, 1, 255, BIT(PRINT_SCAN), },
@ -179,13 +182,15 @@
[127] = { "Extended capabilities", print_capabilities, 0, 255, BIT(PRINT_SCAN), },
[107] = { "802.11u Interworking", print_interworking, 0, 255, BIT(PRINT_SCAN), },
[108] = { "802.11u Advertisement", print_11u_advert, 0, 255, BIT(PRINT_SCAN), },
[111] = { "802.11u Roaming Consortium", print_11u_rcon, 2, 255, BIT(PRINT_SCAN), },
[195] = { "Transmit Power Envelope", print_tx_power_envelope, 2, 5, BIT(PRINT_SCAN), },
@@ -1850,6 +1854,7 @@ static const struct ie_print ieprinters[
[214] = { "Short beacon interval", print_short_beacon_int, 2, 2, BIT(PRINT_SCAN), },
[217] = { "S1G capabilities", print_s1g_capa, 15, 15, BIT(PRINT_SCAN), },
[232] = { "S1G operation", print_s1g_oper, 6, 6, BIT(PRINT_SCAN), },
+#endif
};
static void print_wifi_wpa(const uint8_t type, uint8_t len, const uint8_t *data,
@@ -2080,8 +2085,10 @@ static void print_wifi_wps(const uint8_t
@@ -2185,8 +2190,10 @@ static void print_wifi_wps(const uint8_t
static const struct ie_print wifiprinters[] = {
[1] = { "WPA", print_wifi_wpa, 2, 255, BIT(PRINT_SCAN), },
@ -196,7 +201,7 @@
};
static inline void print_p2p(const uint8_t type, uint8_t len,
@@ -2244,6 +2251,10 @@ static void print_vendor(unsigned char l
@@ -2349,6 +2356,10 @@ static void print_vendor(unsigned char l
return;
}
@ -207,7 +212,7 @@
if (len >= 4 && memcmp(data, wfa_oui, 3) == 0) {
if (data[3] < ARRAY_SIZE(wfa_printers) &&
wfa_printers[data[3]].name &&
@@ -2377,6 +2388,7 @@ static void print_capa_non_dmg(__u16 cap
@@ -2491,6 +2502,7 @@ static void print_capa_non_dmg(__u16 cap
printf(" ESS");
if (capa & WLAN_CAPABILITY_IBSS)
printf(" IBSS");
@ -215,7 +220,7 @@
if (capa & WLAN_CAPABILITY_CF_POLLABLE)
printf(" CfPollable");
if (capa & WLAN_CAPABILITY_CF_POLL_REQUEST)
@@ -2405,6 +2417,7 @@ static void print_capa_non_dmg(__u16 cap
@@ -2519,6 +2531,7 @@ static void print_capa_non_dmg(__u16 cap
printf(" DelayedBACK");
if (capa & WLAN_CAPABILITY_IMM_BACK)
printf(" ImmediateBACK");
@ -223,10 +228,10 @@
}
static int print_bss_handler(struct nl_msg *msg, void *arg)
@@ -2489,8 +2502,10 @@ static int print_bss_handler(struct nl_m
if (bss[NL80211_BSS_FREQUENCY]) {
int freq = nla_get_u32(bss[NL80211_BSS_FREQUENCY]);
printf("\tfreq: %d\n", freq);
@@ -2609,8 +2622,10 @@ static int print_bss_handler(struct nl_m
else
printf("\tfreq: %d\n", freq);
+#ifdef IW_FULL
if (freq > 45000)
is_dmg = true;
@ -234,7 +239,7 @@
}
if (bss[NL80211_BSS_BEACON_INTERVAL])
printf("\tbeacon interval: %d TUs\n",
@@ -2684,6 +2699,7 @@ static int handle_stop_sched_scan(struct
@@ -2804,6 +2819,7 @@ static int handle_stop_sched_scan(struct
return 0;
}
@ -242,7 +247,7 @@
COMMAND(scan, sched_start,
SCHED_SCAN_OPTIONS,
NL80211_CMD_START_SCHED_SCAN, 0, CIB_NETDEV, handle_start_sched_scan,
@@ -2694,3 +2710,4 @@ COMMAND(scan, sched_start,
@@ -2814,3 +2830,4 @@ COMMAND(scan, sched_start,
COMMAND(scan, sched_stop, "",
NL80211_CMD_STOP_SCHED_SCAN, 0, CIB_NETDEV, handle_stop_sched_scan,
"Stop an ongoing scheduled scan.");
@ -265,7 +270,7 @@
int ieee80211_channel_to_frequency(int chan, enum nl80211_band band)
{
@@ -311,6 +313,9 @@ int parse_keys(struct nl_msg *msg, char
@@ -313,6 +315,9 @@ int parse_keys(struct nl_msg *msg, char
char keybuf[13];
int pos = 0;
@ -277,7 +282,7 @@
--- a/Makefile
+++ b/Makefile
@@ -23,6 +23,12 @@ _OBJS := $(sort $(patsubst %.c,%.o,$(wil
@@ -24,6 +24,12 @@ _OBJS := $(sort $(patsubst %.c,%.o,$(wil
VERSION_OBJS := $(filter-out version.o, $(_OBJS))
OBJS := $(VERSION_OBJS) version.o
@ -292,7 +297,7 @@
ifeq ($(NO_PKG_CONFIG),)
--- a/station.c
+++ b/station.c
@@ -791,10 +791,12 @@ static int handle_station_set_plink(stru
@@ -801,10 +801,12 @@ static int handle_station_set_plink(stru
nla_put_failure:
return -ENOBUFS;
}
@ -305,7 +310,7 @@
static int handle_station_set_vlan(struct nl80211_state *state,
struct nl_msg *msg,
@@ -889,11 +891,13 @@ static int handle_station_set_mesh_power
@@ -899,11 +901,13 @@ static int handle_station_set_mesh_power
nla_put_failure:
return -ENOBUFS;
}
@ -321,7 +326,7 @@
struct nl_msg *msg,
--- a/interface.c
+++ b/interface.c
@@ -629,9 +629,11 @@ static int handle_interface_wds_peer(str
@@ -668,9 +668,11 @@ static int handle_interface_wds_peer(str
nla_put_failure:
return -ENOBUFS;
}
@ -333,7 +338,7 @@
static int set_mcast_rate(struct nl80211_state *state,
struct nl_msg *msg,
@@ -721,6 +723,7 @@ static int handle_chan(struct nl80211_st
@@ -760,6 +762,7 @@ static int handle_chan(struct nl80211_st
return handle_chanfreq(state, msg, true, argc, argv, id);
}
@ -341,14 +346,14 @@
SECTION(switch);
COMMAND(switch, freq,
"<freq> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz] [beacons <count>] [block-tx]\n"
@@ -992,3 +995,4 @@ COMMAND(set, tidconf, "[peer <MAC addres
@@ -1031,3 +1034,4 @@ COMMAND(set, tidconf, "[peer <MAC addres
" $ iw dev wlan0 set tidconf peer xx:xx:xx:xx:xx:xx tids 0x2 bitrates auto\n"
" $ iw dev wlan0 set tidconf peer xx:xx:xx:xx:xx:xx tids 0x2 bitrates limit vht-mcs-5 4:9\n"
);
+#endif
--- a/phy.c
+++ b/phy.c
@@ -369,6 +369,7 @@ err_out:
@@ -403,6 +403,7 @@ err_out:
free(cac_trigger_argv);
return err;
}
@ -356,9 +361,9 @@
TOPLEVEL(cac, "channel <channel> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz]\n"
"freq <freq> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz]\n"
"freq <control freq> [5|10|20|40|80|80+80|160] [<center1_freq> [<center2_freq>]]",
@@ -380,6 +381,7 @@ COMMAND(cac, trigger,
NL80211_CMD_RADAR_DETECT, 0, CIB_NETDEV, handle_cac_trigger,
"Start or trigger a channel availability check (CAC) looking to look for\n"
@@ -422,6 +423,7 @@ COMMAND(cac, background,
NL80211_CMD_RADAR_DETECT, 0, CIB_NETDEV, handle_cac_background,
"Start background channel availability check (CAC) looking to look for\n"
"radars on the given channel.");
+#endif

View File

@ -0,0 +1,252 @@
--- a/info.c
+++ b/info.c
@@ -295,6 +295,151 @@ static void print_pmsr_capabilities(stru
}
}
+static void print_interface_combinations(struct nlattr *ifcomb, bool radio)
+{
+ const char *indent = radio ? "\t" : "";
+ struct nlattr *nl_combi;
+ bool have_combinations = false;
+ int rem;
+
+ nla_for_each_nested(nl_combi, ifcomb, rem) {
+ 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 (radio && nla_type(nl_combi) !=
+ NL80211_WIPHY_RADIO_ATTR_INTERFACE_COMBINATION)
+ continue;
+
+ if (!have_combinations) {
+ printf("\t%svalid interface combinations:\n", indent);
+ have_combinations = true;
+ }
+
+ printf("\t\t%s * ", indent);
+
+ 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) {
+ 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("#{ ");
+ print_iftype_line(tb_limit[NL80211_IFACE_LIMIT_TYPES]);
+ printf(" } <= %u", nla_get_u32(tb_limit[NL80211_IFACE_LIMIT_MAX]));
+ }
+ printf(",\n\t\t%s ", indent);
+
+ 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:
+ ;
+ }
+
+ if (!have_combinations)
+ printf("\t%sinterface combinations are not supported\n", indent);
+}
+
+static void print_radio_freq(struct nlattr *freqs)
+{
+ struct nlattr *freq;
+ int rem;
+
+ nla_for_each_nested(freq, freqs, rem) {
+ static struct nla_policy freq_policy[NL80211_WIPHY_RADIO_FREQ_ATTR_MAX + 1] = {
+ [NL80211_WIPHY_RADIO_FREQ_ATTR_START] = { .type = NLA_U32 },
+ [NL80211_WIPHY_RADIO_FREQ_ATTR_END] = { .type = NLA_U32 },
+ };
+ struct nlattr *tb[NL80211_WIPHY_RADIO_FREQ_ATTR_MAX + 1];
+ uint32_t start, end;
+
+ if (nla_type(freq) != NL80211_WIPHY_RADIO_ATTR_FREQ_RANGE)
+ continue;
+
+ if (nla_parse_nested(tb, NL80211_WIPHY_RADIO_ATTR_MAX + 1,
+ freq, freq_policy) ||
+ !tb[NL80211_WIPHY_RADIO_FREQ_ATTR_START] ||
+ !tb[NL80211_WIPHY_RADIO_FREQ_ATTR_END])
+ continue;
+
+ start = nla_get_u32(tb[NL80211_WIPHY_RADIO_FREQ_ATTR_START]);
+ end = nla_get_u32(tb[NL80211_WIPHY_RADIO_FREQ_ATTR_END]);
+
+ printf("\t\tfreq range: %.1f MHz - %.1f MHz\n", (float)start / 1000, (float)end / 1000);
+ }
+}
+
+static void print_radios(struct nlattr *radios)
+{
+ struct nlattr *radio;
+ int rem, idx = 0;
+
+ nla_for_each_nested(radio, radios, rem) {
+ static struct nla_policy radio_policy[NL80211_WIPHY_RADIO_ATTR_MAX + 1] = {
+ [NL80211_WIPHY_RADIO_ATTR_INDEX] = { .type = NLA_U32 },
+ };
+ struct nlattr *tb[NL80211_WIPHY_RADIO_ATTR_MAX + 1];
+
+ if (nla_parse_nested(tb, NL80211_WIPHY_RADIO_ATTR_MAX + 1,
+ radio, radio_policy) ||
+ !tb[NL80211_WIPHY_RADIO_ATTR_INDEX])
+ continue;
+
+ printf("\twiphy radio %d:\n", nla_get_u32(tb[NL80211_WIPHY_RADIO_ATTR_INDEX]));
+ print_radio_freq(radio);
+ print_interface_combinations(radio, true);
+ }
+}
+
static int print_phy_handler(struct nl_msg *msg, void *arg)
{
struct nlattr *tb_msg[NL80211_ATTR_MAX + 1];
@@ -565,93 +710,11 @@ next:
"\t\t", tb_msg[NL80211_ATTR_SOFTWARE_IFTYPES]);
#endif
- 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 * ");
+ if (tb_msg[NL80211_ATTR_INTERFACE_COMBINATIONS])
+ print_interface_combinations(tb_msg[NL80211_ATTR_INTERFACE_COMBINATIONS], false);
- 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) {
- 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("#{ ");
- print_iftype_line(tb_limit[NL80211_IFACE_LIMIT_TYPES]);
- 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:
- ;
- }
-
- if (!have_combinations)
- printf("\tinterface combinations are not supported\n");
- }
+ if (tb_msg[NL80211_ATTR_WIPHY_RADIOS])
+ print_radios(tb_msg[NL80211_ATTR_WIPHY_RADIOS]);
#ifdef IW_FULL
if (tb_msg[NL80211_ATTR_SUPPORTED_COMMANDS]) {

View File

@ -0,0 +1,99 @@
--- a/interface.c
+++ b/interface.c
@@ -226,6 +226,43 @@ nla_put_failure:
return 1;
}
+static int parse_radio_list(char *str, struct nl_msg *msg)
+{
+ unsigned int mask = 0;
+ unsigned long id;
+ char *end;
+
+ if (!str)
+ return 1;
+
+ if (!strcmp(str, "all"))
+ goto out;
+
+ while (1) {
+ if (!*str)
+ return 1;
+
+ id = strtoul(str, &end, 0);
+ if (id > 31)
+ return 1;
+
+ mask |= 1 << id;
+ if (!*end)
+ break;
+
+ if (end == str || *end != ',')
+ return 1;
+
+ str = end + 1;
+ }
+
+out:
+ NLA_PUT_U32(msg, NL80211_ATTR_VIF_RADIO_MASK, mask);
+ return 0;
+nla_put_failure:
+ return 1;
+}
+
static int handle_interface_add(struct nl80211_state *state,
struct nl_msg *msg,
int argc, char **argv,
@@ -287,6 +324,15 @@ try_another:
fprintf(stderr, "flags error\n");
return 2;
}
+ } else if (strcmp(argv[0], "radios") == 0) {
+ argc--;
+ argv++;
+ if (parse_radio_list(argv[0], msg)) {
+ fprintf(stderr, "Invalid radio list\n");
+ return 2;
+ }
+ argc--;
+ argv++;
} else {
return 1;
}
@@ -306,14 +352,14 @@ try_another:
nla_put_failure:
return -ENOBUFS;
}
-COMMAND(interface, add, "<name> type <type> [mesh_id <meshid>] [4addr on|off] [flags <flag>*] [addr <mac-addr>]",
+COMMAND(interface, add, "<name> type <type> [mesh_id <meshid>] [4addr on|off] [flags <flag>*] [addr <mac-addr>] [radios all|<id>[,<id>...]]",
NL80211_CMD_NEW_INTERFACE, 0, CIB_PHY, handle_interface_add,
"Add a new virtual interface with the given configuration.\n"
IFACE_TYPES "\n\n"
"The flags are only used for monitor interfaces, valid flags are:\n"
VALID_FLAGS "\n\n"
"The mesh_id is used only for mesh mode.");
-COMMAND(interface, add, "<name> type <type> [mesh_id <meshid>] [4addr on|off] [flags <flag>*] [addr <mac-addr>]",
+COMMAND(interface, add, "<name> type <type> [mesh_id <meshid>] [4addr on|off] [flags <flag>*] [addr <mac-addr>] [radios all|<id>[,<id>...]]",
NL80211_CMD_NEW_INTERFACE, 0, CIB_NETDEV, handle_interface_add, NULL);
static int handle_interface_del(struct nl80211_state *state,
@@ -493,6 +539,19 @@ static int print_iface_handler(struct nl
printf("\n");
}
}
+
+ if (tb_msg[NL80211_ATTR_VIF_RADIO_MASK]) {
+ uint32_t mask = nla_get_u32(tb_msg[NL80211_ATTR_VIF_RADIO_MASK]);
+ int i;
+
+ if (mask) {
+ printf("%s\tRadios:", indent);
+ for (i = 0; mask; i++, mask >>= 1)
+ if (mask & 1)
+ printf(" %d", i);
+ printf("\n");
+ }
+ }
return NL_SKIP;
}