iw: strip a few more non-essential features from iw-tiny
[openwrt/openwrt.git] / package / network / utils / iw / patches / 200-reduce_size.patch
index 36fe0ff7461272adaf126f88f5d211b5745c7ac6..5f4bce6a8bc1c598da2d21986281f489a88f02a9 100644 (file)
@@ -4,7 +4,7 @@
        }
  
        switch (gnlh->cmd) {
-+#if 0
++#ifdef IW_FULL
        case NL80211_CMD_NEW_WIPHY:
                printf("renamed to %s\n", nla_get_string(tb[NL80211_ATTR_WIPHY_NAME]));
                break;
@@ -20,7 +20,7 @@
                mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC]));
                printf("del station %s\n", macbuf);
                break;
-+#if 0
++#ifdef IW_FULL
        case NL80211_CMD_JOIN_IBSS:
                mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC]));
                printf("IBSS %s joined\n", macbuf);
@@ -42,7 +42,7 @@
                                }
                        }
  
-+#if 0
++#ifdef IW_FULL
                        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) {
@@ -58,7 +58,7 @@
                printf("\tCoverage class: %d (up to %dm)\n", coverage, 450 * coverage);
        }
  
-+#if 0
++#ifdef IW_FULL
        if (tb_msg[NL80211_ATTR_CIPHER_SUITES]) {
                int num = nla_len(tb_msg[NL80211_ATTR_CIPHER_SUITES]) / sizeof(__u32);
                int i;
@@ -74,7 +74,7 @@
                        printf("\t\t * %s\n", iftype_name(nla_type(nl_mode)));
        }
  
-+#if 0
++#ifdef IW_FULL
        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)
@@ -88,7 +88,7 @@
                        printf("\tinterface combinations are not supported\n");
        }
  
-+#if 0
++#ifdef IW_FULL
        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)
                }
        }
  
-+#if 0
++#ifdef IW_FULL
        if (tb_msg[NL80211_ATTR_FEATURE_FLAGS]) {
                unsigned int features = nla_get_u32(tb_msg[NL80211_ATTR_FEATURE_FLAGS]);
  
         "List all wireless devices and their capabilities.");
  TOPLEVEL(phy, NULL, NL80211_CMD_GET_WIPHY, NLM_F_DUMP, CIB_NONE, handle_info, NULL);
  
-+#if 0
++#ifdef IW_FULL
  static int handle_commands(struct nl80211_state *state, struct nl_msg *msg,
                           int argc, char **argv, enum id_input id)
  {
 +      [114] = { "MESH ID", print_ssid, 0, 32, BIT(PRINT_SCAN) | BIT(PRINT_LINK), },
 +      [191] = { "VHT capabilities", print_vht_capa, 12, 255, BIT(PRINT_SCAN), },
 +      [192] = { "VHT operation", print_vht_oper, 5, 255, BIT(PRINT_SCAN), },
-+#if 0
++#ifdef IW_FULL
        [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), },
                    ieprinters[ie[0]].flags & BIT(ptype)) {
                        print_ie(&ieprinters[ie[0]],
                                 ie[0], ie[1], ie + 2, &ie_buffer);
-+#if 0
++#ifdef IW_FULL
                } else if (ie[0] == 221 /* vendor */) {
                        print_vendor(ie[1], ie + 2, unknown, ptype);
                } else if (unknown) {
                printf(" ESS");
        if (capa & WLAN_CAPABILITY_IBSS)
                printf(" IBSS");
-+#if 0
++#ifdef IW_FULL
        if (capa & WLAN_CAPABILITY_CF_POLLABLE)
                printf(" CfPollable");
        if (capa & WLAN_CAPABILITY_CF_POLL_REQUEST)
        if (bss[NL80211_BSS_FREQUENCY]) {
                int freq = nla_get_u32(bss[NL80211_BSS_FREQUENCY]);
                printf("\tfreq: %d\n", freq);
-+#if 0
++#ifdef IW_FULL
                if (freq > 45000)
                        is_dmg = true;
 +#endif
        return 0;
  }
  
-+#if 0
++#ifdef IW_FULL
  COMMAND(scan, sched_start,
        SCHED_SCAN_OPTIONS,
        NL80211_CMD_START_SCHED_SCAN, 0, CIB_NETDEV, handle_start_sched_scan,
  
  static char cmdbuf[100];
  
-+#if 0
++#ifdef IW_FULL
  const char *command_name(enum nl80211_commands cmd)
  {
        if (cmd <= NL80211_CMD_MAX && commands[cmd])
  
  int ieee80211_channel_to_frequency(int chan, enum nl80211_band band)
  {
-@@ -426,6 +428,7 @@ int parse_keys(struct nl_msg *msg, char
+@@ -426,6 +428,9 @@ int parse_keys(struct nl_msg *msg, char
        char keybuf[13];
        int pos = 0;
  
++#ifndef IW_FULL
 +      return 1;
++#endif
        if (!argc)
                return 1;
  
 --- a/Makefile
 +++ b/Makefile
-@@ -25,6 +25,8 @@ OBJS-$(HWSIM) += hwsim.o
+@@ -25,6 +25,12 @@ OBJS-$(HWSIM) += hwsim.o
  
  OBJS += $(OBJS-y) $(OBJS-Y)
  
-+OBJS_DISABLED = ocb offch cqm wowlan coalesce roc p2p ap
-+OBJS:=$(filter-out $(patsubst %,%.o,$(OBJS_DISABLED)),$(OBJS))
++OBJS_FULL = ocb offch cqm wowlan coalesce roc p2p ap mgmt vendor
++ifdef IW_FULL
++  CFLAGS += -DIW_FULL
++else
++  OBJS:=$(filter-out $(patsubst %,%.o,$(OBJS_FULL)),$(OBJS))
++endif
  ALL = iw
  
  ifeq ($(NO_PKG_CONFIG),)
   nla_put_failure:
        return -ENOBUFS;
  }
-+#if 0
++#ifdef IW_FULL
  COMMAND_ALIAS(station, set, "<MAC address> plink_action <open|block>",
        NL80211_CMD_SET_STATION, 0, CIB_NETDEV, handle_station_set_plink,
        "Set mesh peer link action for this station (peer).",
  nla_put_failure:
        return -ENOBUFS;
  }
-+#if 0
++#ifdef IW_FULL
  COMMAND_ALIAS(station, set, "<MAC address> mesh_power_mode "
        "<active|light|deep>", NL80211_CMD_SET_STATION, 0, CIB_NETDEV,
        handle_station_set_mesh_power_mode,
  
  static int handle_station_dump(struct nl80211_state *state,
                               struct nl_msg *msg,
+--- a/interface.c
++++ b/interface.c
+@@ -615,9 +615,11 @@ static int handle_interface_wds_peer(str
+  nla_put_failure:
+       return -ENOBUFS;
+ }
++#ifdef IW_FULL
+ COMMAND(set, peer, "<MAC address>",
+       NL80211_CMD_SET_WDS_PEER, 0, CIB_NETDEV, handle_interface_wds_peer,
+       "Set interface WDS peer.");
++#endif
+ static int set_mcast_rate(struct nl80211_state *state,
+                         struct nl_msg *msg,
+@@ -707,6 +709,7 @@ static int handle_chan(struct nl80211_st
+       return handle_chanfreq(state, msg, true, argc, argv, id);
+ }
++#ifdef IW_FULL
+ SECTION(switch);
+ COMMAND(switch, freq,
+       "<freq> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz] [beacons <count>] [block-tx]\n"
+@@ -715,3 +718,4 @@ COMMAND(switch, freq,
+       "Switch the operating channel by sending a channel switch announcement (CSA).");
+ COMMAND(switch, channel, "<channel> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz] [beacons <count>] [block-tx]",
+       NL80211_CMD_CHANNEL_SWITCH, 0, CIB_NETDEV, handle_chan, NULL);
++#endif
+--- a/phy.c
++++ b/phy.c
+@@ -359,6 +359,7 @@ static int handle_cac(struct nl80211_sta
+       return 0;
+ }
++#ifdef IW_FULL
+ 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>]]",
+@@ -370,6 +371,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"
+       "radars on the given channel.");
++#endif
+ static int handle_fragmentation(struct nl80211_state *state,
+                               struct nl_msg *msg,