From 716ca530e1c4515d8683c9d5be3d56b301758b66 Mon Sep 17 00:00:00 2001 From: James <> Date: Wed, 4 Nov 2015 11:49:21 +0000 Subject: trunk-47381 --- package/network/utils/iw/Makefile | 57 +++++ .../utils/iw/patches/001-nl80211_h_sync.patch | 100 ++++++++ .../utils/iw/patches/120-antenna_gain.patch | 34 +++ .../network/utils/iw/patches/200-reduce_size.patch | 255 +++++++++++++++++++++ 4 files changed, 446 insertions(+) create mode 100644 package/network/utils/iw/Makefile create mode 100644 package/network/utils/iw/patches/001-nl80211_h_sync.patch create mode 100644 package/network/utils/iw/patches/120-antenna_gain.patch create mode 100644 package/network/utils/iw/patches/200-reduce_size.patch (limited to 'package/network/utils/iw') diff --git a/package/network/utils/iw/Makefile b/package/network/utils/iw/Makefile new file mode 100644 index 0000000..53cfee3 --- /dev/null +++ b/package/network/utils/iw/Makefile @@ -0,0 +1,57 @@ +# +# Copyright (C) 2007-2011 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=iw +PKG_VERSION:=4.1 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_URL:=https://www.kernel.org/pub/software/network/iw +PKG_MD5SUM:=3a292dd342bb88e30e74015ae6fe1e54 + +PKG_MAINTAINER:=Felix Fietkau +PKG_LICENSE:=GPL-2.0 + +include $(INCLUDE_DIR)/package.mk + +define Package/iw + SECTION:=net + CATEGORY:=Network + TITLE:=cfg80211 interface configuration utility + URL:=http://wireless.kernel.org/en/users/Documentation/iw + DEPENDS:= +libnl-tiny +endef + +define Build/Configure + echo "const char iw_version[] = \"$(PKG_VERSION)\";" > $(PKG_BUILD_DIR)/version.c + rm -f $(PKG_BUILD_DIR)/version.sh + touch $(PKG_BUILD_DIR)/version.sh + chmod +x $(PKG_BUILD_DIR)/version.sh +endef + +TARGET_CPPFLAGS:= \ + -I$(STAGING_DIR)/usr/include/libnl-tiny \ + $(TARGET_CPPFLAGS) \ + -DCONFIG_LIBNL20 \ + -D_GNU_SOURCE + +MAKE_FLAGS += \ + CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -ffunction-sections -fdata-sections" \ + LDFLAGS="$(TARGET_LDFLAGS) -Wl,--gc-sections" \ + NL1FOUND="" NL2FOUND=Y \ + NLLIBNAME="libnl-tiny" \ + LIBS="-lm -lnl-tiny" \ + V=1 + +define Package/iw/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/iw $(1)/usr/sbin/ +endef + +$(eval $(call BuildPackage,iw)) diff --git a/package/network/utils/iw/patches/001-nl80211_h_sync.patch b/package/network/utils/iw/patches/001-nl80211_h_sync.patch new file mode 100644 index 0000000..afa5506 --- /dev/null +++ b/package/network/utils/iw/patches/001-nl80211_h_sync.patch @@ -0,0 +1,100 @@ +--- a/nl80211.h ++++ b/nl80211.h +@@ -1761,6 +1761,9 @@ enum nl80211_commands { + * @NL80211_ATTR_REG_INDOOR: flag attribute, if set indicates that the device + * is operating in an indoor environment. + * ++ * @NL80211_ATTR_WIPHY_ANTENNA_GAIN: Configured antenna gain. Used to reduce ++ * transmit power to stay within regulatory limits. u32, dBi. ++ * + * @NUM_NL80211_ATTR: total number of nl80211_attrs available + * @NL80211_ATTR_MAX: highest attribute number currently defined + * @__NL80211_ATTR_AFTER_LAST: internal use +@@ -2130,6 +2133,8 @@ enum nl80211_attrs { + + NL80211_ATTR_REG_INDOOR, + ++ NL80211_ATTR_WIPHY_ANTENNA_GAIN, ++ + /* add attributes here, update the policy in nl80211.c */ + + __NL80211_ATTR_AFTER_LAST, +@@ -2620,16 +2625,17 @@ enum nl80211_band_attr { + * an indoor surroundings, i.e., it is connected to AC power (and not + * through portable DC inverters) or is under the control of a master + * that is acting as an AP and is connected to AC power. +- * @NL80211_FREQUENCY_ATTR_GO_CONCURRENT: GO operation is allowed on this ++ * @NL80211_FREQUENCY_ATTR_IR_CONCURRENT: IR operation is allowed on this + * channel if it's connected concurrently to a BSS on the same channel on + * the 2 GHz band or to a channel in the same UNII band (on the 5 GHz +- * band), and IEEE80211_CHAN_RADAR is not set. Instantiating a GO on a +- * channel that has the GO_CONCURRENT attribute set can be done when there +- * is a clear assessment that the device is operating under the guidance of +- * an authorized master, i.e., setting up a GO while the device is also +- * connected to an AP with DFS and radar detection on the UNII band (it is +- * up to user-space, i.e., wpa_supplicant to perform the required +- * verifications) ++ * band), and IEEE80211_CHAN_RADAR is not set. Instantiating a GO or TDLS ++ * off-channel on a channel that has the IR_CONCURRENT attribute set can be ++ * done when there is a clear assessment that the device is operating under ++ * the guidance of an authorized master, i.e., setting up a GO or TDLS ++ * off-channel while the device is also connected to an AP with DFS and ++ * radar detection on the UNII band (it is up to user-space, i.e., ++ * wpa_supplicant to perform the required verifications). Using this ++ * attribute for IR is disallowed for master interfaces (IBSS, AP). + * @NL80211_FREQUENCY_ATTR_NO_20MHZ: 20 MHz operation is not allowed + * on this channel in current regulatory domain. + * @NL80211_FREQUENCY_ATTR_NO_10MHZ: 10 MHz operation is not allowed +@@ -2641,7 +2647,7 @@ enum nl80211_band_attr { + * See https://apps.fcc.gov/eas/comments/GetPublishedDocument.html?id=327&tn=528122 + * for more information on the FCC description of the relaxations allowed + * by NL80211_FREQUENCY_ATTR_INDOOR_ONLY and +- * NL80211_FREQUENCY_ATTR_GO_CONCURRENT. ++ * NL80211_FREQUENCY_ATTR_IR_CONCURRENT. + */ + enum nl80211_frequency_attr { + __NL80211_FREQUENCY_ATTR_INVALID, +@@ -2659,7 +2665,7 @@ enum nl80211_frequency_attr { + NL80211_FREQUENCY_ATTR_NO_160MHZ, + NL80211_FREQUENCY_ATTR_DFS_CAC_TIME, + NL80211_FREQUENCY_ATTR_INDOOR_ONLY, +- NL80211_FREQUENCY_ATTR_GO_CONCURRENT, ++ NL80211_FREQUENCY_ATTR_IR_CONCURRENT, + NL80211_FREQUENCY_ATTR_NO_20MHZ, + NL80211_FREQUENCY_ATTR_NO_10MHZ, + +@@ -2672,6 +2678,8 @@ enum nl80211_frequency_attr { + #define NL80211_FREQUENCY_ATTR_PASSIVE_SCAN NL80211_FREQUENCY_ATTR_NO_IR + #define NL80211_FREQUENCY_ATTR_NO_IBSS NL80211_FREQUENCY_ATTR_NO_IR + #define NL80211_FREQUENCY_ATTR_NO_IR NL80211_FREQUENCY_ATTR_NO_IR ++#define NL80211_FREQUENCY_ATTR_GO_CONCURRENT \ ++ NL80211_FREQUENCY_ATTR_IR_CONCURRENT + + /** + * enum nl80211_bitrate_attr - bitrate attributes +@@ -2830,7 +2838,7 @@ enum nl80211_sched_scan_match_attr { + * @NL80211_RRF_AUTO_BW: maximum available bandwidth should be calculated + * base on contiguous rules and wider channels will be allowed to cross + * multiple contiguous/overlapping frequency ranges. +- * @NL80211_RRF_GO_CONCURRENT: See &NL80211_FREQUENCY_ATTR_GO_CONCURRENT ++ * @NL80211_RRF_IR_CONCURRENT: See &NL80211_FREQUENCY_ATTR_IR_CONCURRENT + * @NL80211_RRF_NO_HT40MINUS: channels can't be used in HT40- operation + * @NL80211_RRF_NO_HT40PLUS: channels can't be used in HT40+ operation + * @NL80211_RRF_NO_80MHZ: 80MHz operation not allowed +@@ -2847,7 +2855,7 @@ enum nl80211_reg_rule_flags { + NL80211_RRF_NO_IR = 1<<7, + __NL80211_RRF_NO_IBSS = 1<<8, + NL80211_RRF_AUTO_BW = 1<<11, +- NL80211_RRF_GO_CONCURRENT = 1<<12, ++ NL80211_RRF_IR_CONCURRENT = 1<<12, + NL80211_RRF_NO_HT40MINUS = 1<<13, + NL80211_RRF_NO_HT40PLUS = 1<<14, + NL80211_RRF_NO_80MHZ = 1<<15, +@@ -2859,6 +2867,7 @@ enum nl80211_reg_rule_flags { + #define NL80211_RRF_NO_IR NL80211_RRF_NO_IR + #define NL80211_RRF_NO_HT40 (NL80211_RRF_NO_HT40MINUS |\ + NL80211_RRF_NO_HT40PLUS) ++#define NL80211_RRF_GO_CONCURRENT NL80211_RRF_IR_CONCURRENT + + /* For backport compatibility with older userspace */ + #define NL80211_RRF_NO_IR_ALL (NL80211_RRF_NO_IR | __NL80211_RRF_NO_IBSS) diff --git a/package/network/utils/iw/patches/120-antenna_gain.patch b/package/network/utils/iw/patches/120-antenna_gain.patch new file mode 100644 index 0000000..8de3df2 --- /dev/null +++ b/package/network/utils/iw/patches/120-antenna_gain.patch @@ -0,0 +1,34 @@ +--- a/phy.c ++++ b/phy.c +@@ -532,3 +532,31 @@ COMMAND(set, antenna, " | all | + NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_antenna, + "Set a bitmap of allowed antennas to use for TX and RX.\n" + "The driver may reject antenna configurations it cannot support."); ++ ++static int handle_antenna_gain(struct nl80211_state *state, ++ struct nl_cb *cb, ++ 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, "", ++ NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_antenna_gain, ++ "Specify antenna gain."); diff --git a/package/network/utils/iw/patches/200-reduce_size.patch b/package/network/utils/iw/patches/200-reduce_size.patch new file mode 100644 index 0000000..3ba4730 --- /dev/null +++ b/package/network/utils/iw/patches/200-reduce_size.patch @@ -0,0 +1,255 @@ +--- a/Makefile ++++ b/Makefile +@@ -15,8 +15,8 @@ CFLAGS += -Wall -Wundef -Wstrict-prototy + OBJS = iw.o genl.o event.o info.o phy.o \ + interface.o ibss.o station.o survey.o util.o ocb.o \ + mesh.o mpath.o mpp.o scan.o reg.o version.o \ +- reason.o status.o connect.o link.o offch.o ps.o cqm.o \ +- bitrate.o wowlan.o coalesce.o roc.o p2p.o vendor.o ++ reason.o status.o link.o offch.o ps.o cqm.o \ ++ bitrate.o vendor.o + OBJS += sections.o + + OBJS-$(HWSIM) += hwsim.o +--- a/info.c ++++ b/info.c +@@ -219,6 +219,7 @@ next: + } + } + ++#if 0 + 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) { +@@ -235,6 +236,7 @@ next: + printf("\n"); + } + } ++#endif + } + } + +@@ -291,6 +293,7 @@ next: + printf("\tCoverage class: %d (up to %dm)\n", coverage, 450 * coverage); + } + ++#if 0 + if (tb_msg[NL80211_ATTR_CIPHER_SUITES]) { + int num = nla_len(tb_msg[NL80211_ATTR_CIPHER_SUITES]) / sizeof(__u32); + int i; +@@ -302,6 +305,7 @@ next: + cipher_name(ciphers[i])); + } + } ++#endif + + if (tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX] && + tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX]) +@@ -321,11 +325,13 @@ next: + printf("\t\t * %s\n", iftype_name(nla_type(nl_mode))); + } + ++#if 0 + 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))); + } ++#endif + + if (tb_msg[NL80211_ATTR_INTERFACE_COMBINATIONS]) { + struct nlattr *nl_combi; +@@ -422,6 +428,7 @@ broken_combination: + printf("\tinterface combinations are not supported\n"); + } + ++#if 0 + 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) +@@ -518,6 +525,7 @@ broken_combination: + printf("\t\t * wake up on TCP connection\n"); + } + } ++#endif + + if (tb_msg[NL80211_ATTR_ROAM_SUPPORT]) + printf("\tDevice supports roaming.\n"); +@@ -554,6 +562,7 @@ broken_combination: + } + } + ++#if 0 + if (tb_msg[NL80211_ATTR_FEATURE_FLAGS]) { + unsigned int features = nla_get_u32(tb_msg[NL80211_ATTR_FEATURE_FLAGS]); + +@@ -612,6 +621,7 @@ broken_combination: + if (features & NL80211_FEATURE_TDLS_CHANNEL_SWITCH) + printf("\tDevice supports TDLS channel switching\n"); + } ++#endif + + if (tb_msg[NL80211_ATTR_EXT_FEATURES]) { + struct nlattr *tb = tb_msg[NL80211_ATTR_EXT_FEATURES]; +@@ -669,6 +679,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); + ++#if 0 + static int handle_commands(struct nl80211_state *state, + struct nl_cb *cb, struct nl_msg *msg, + int argc, char **argv, enum id_input id) +@@ -681,6 +692,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"); ++#endif + + static int print_feature_handler(struct nl_msg *msg, void *arg) + { +--- a/scan.c ++++ b/scan.c +@@ -1080,6 +1080,7 @@ 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]); ++ return; + 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); +@@ -1311,6 +1312,13 @@ 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), }, ++ [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), }, ++ [62] = { "Secondary Channel Offset", print_secchan_offs, 1, 1, BIT(PRINT_SCAN), }, ++ [191] = { "VHT capabilities", print_vht_capa, 12, 255, BIT(PRINT_SCAN), }, ++ [192] = { "VHT operation", print_vht_oper, 5, 255, BIT(PRINT_SCAN), }, ++#if 0 + [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), }, +@@ -1320,14 +1328,8 @@ static const struct ie_print ieprinters[ + [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), }, +- [45] = { "HT capabilities", print_ht_capa, 26, 26, BIT(PRINT_SCAN), }, + [47] = { "ERP D4.0", print_erp, 1, 255, BIT(PRINT_SCAN), }, + [74] = { "Overlapping BSS scan params", print_obss_scan_params, 14, 255, BIT(PRINT_SCAN), }, +- [61] = { "HT operation", print_ht_op, 22, 22, BIT(PRINT_SCAN), }, +- [62] = { "Secondary Channel Offset", print_secchan_offs, 1, 1, BIT(PRINT_SCAN), }, +- [191] = { "VHT capabilities", print_vht_capa, 12, 255, BIT(PRINT_SCAN), }, +- [192] = { "VHT operation", print_vht_oper, 5, 255, BIT(PRINT_SCAN), }, +- [48] = { "RSN", print_rsn, 2, 255, BIT(PRINT_SCAN), }, + [50] = { "Extended supported rates", print_supprates, 0, 255, BIT(PRINT_SCAN), }, + [113] = { "MESH Configuration", print_mesh_conf, 7, 7, BIT(PRINT_SCAN), }, + [114] = { "MESH ID", print_ssid, 0, 32, BIT(PRINT_SCAN) | BIT(PRINT_LINK), }, +@@ -1335,6 +1337,7 @@ static const struct ie_print ieprinters[ + [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, 0, 255, BIT(PRINT_SCAN), }, ++#endif + }; + + static void print_wifi_wpa(const uint8_t type, uint8_t len, const uint8_t *data) +@@ -1766,6 +1769,7 @@ void print_ies(unsigned char *ie, int ie + ieprinters[ie[0]].name && + ieprinters[ie[0]].flags & BIT(ptype)) { + print_ie(&ieprinters[ie[0]], ie[0], ie[1], ie + 2); ++#if 0 + } else if (ie[0] == 221 /* vendor */) { + print_vendor(ie[1], ie + 2, unknown, ptype); + } else if (unknown) { +@@ -1775,6 +1779,7 @@ void print_ies(unsigned char *ie, int ie + for (i=0; i 45000) + is_dmg = true; ++#endif + } + if (bss[NL80211_BSS_BEACON_INTERVAL]) + printf("\tbeacon interval: %d TUs\n", +--- a/util.c ++++ b/util.c +@@ -264,6 +264,7 @@ static const char *commands[NL80211_CMD_ + + static char cmdbuf[100]; + ++#if 0 + const char *command_name(enum nl80211_commands cmd) + { + if (cmd <= NL80211_CMD_MAX && commands[cmd]) +@@ -271,6 +272,7 @@ const char *command_name(enum nl80211_co + sprintf(cmdbuf, "Unknown command (%d)", cmd); + return cmdbuf; + } ++#endif + + int ieee80211_channel_to_frequency(int chan, enum nl80211_band band) + { +--- a/event.c ++++ b/event.c +@@ -334,6 +334,7 @@ static int print_event(struct nl_msg *ms + } + + switch (gnlh->cmd) { ++#if 0 + case NL80211_CMD_NEW_WIPHY: + printf("renamed to %s\n", nla_get_string(tb[NL80211_ATTR_WIPHY_NAME])); + break; +@@ -368,6 +369,7 @@ static int print_event(struct nl_msg *ms + case NL80211_CMD_SCHED_SCAN_RESULTS: + printf("got scheduled scan results\n"); + break; ++#endif + case NL80211_CMD_REG_CHANGE: + printf("regulatory domain change: "); + +@@ -446,6 +448,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; ++#if 0 + case NL80211_CMD_JOIN_IBSS: + mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC])); + printf("IBSS %s joined\n", macbuf); +@@ -599,9 +602,9 @@ static int print_event(struct nl_msg *ms + } + printf("\n"); + break; ++#endif + default: +- printf("unknown event %d (%s)\n", +- gnlh->cmd, command_name(gnlh->cmd)); ++ printf("unknown event %d\n", gnlh->cmd); + break; + } + -- cgit v1.2.3