iw: strip a few more non-essential features from iw-tiny
[openwrt/openwrt.git] / package / network / utils / iw / patches / 200-reduce_size.patch
1 --- a/event.c
2 +++ b/event.c
3 @@ -342,6 +342,7 @@ static int print_event(struct nl_msg *ms
4 }
5
6 switch (gnlh->cmd) {
7 +#ifdef IW_FULL
8 case NL80211_CMD_NEW_WIPHY:
9 printf("renamed to %s\n", nla_get_string(tb[NL80211_ATTR_WIPHY_NAME]));
10 break;
11 @@ -376,6 +377,7 @@ static int print_event(struct nl_msg *ms
12 case NL80211_CMD_SCHED_SCAN_RESULTS:
13 printf("got scheduled scan results\n");
14 break;
15 +#endif
16 case NL80211_CMD_REG_CHANGE:
17 printf("regulatory domain change: ");
18
19 @@ -454,6 +456,7 @@ static int print_event(struct nl_msg *ms
20 mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC]));
21 printf("del station %s\n", macbuf);
22 break;
23 +#ifdef IW_FULL
24 case NL80211_CMD_JOIN_IBSS:
25 mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC]));
26 printf("IBSS %s joined\n", macbuf);
27 @@ -618,9 +621,9 @@ static int print_event(struct nl_msg *ms
28 case NL80211_CMD_DEL_WIPHY:
29 printf("delete wiphy\n");
30 break;
31 +#endif
32 default:
33 - printf("unknown event %d (%s)\n",
34 - gnlh->cmd, command_name(gnlh->cmd));
35 + printf("unknown event %d\n", gnlh->cmd);
36 break;
37 }
38
39 --- a/info.c
40 +++ b/info.c
41 @@ -197,6 +197,7 @@ next:
42 }
43 }
44
45 +#ifdef IW_FULL
46 if (tb_band[NL80211_BAND_ATTR_RATES]) {
47 printf("\t\tBitrates (non-HT):\n");
48 nla_for_each_nested(nl_rate, tb_band[NL80211_BAND_ATTR_RATES], rem_rate) {
49 @@ -213,6 +214,7 @@ next:
50 printf("\n");
51 }
52 }
53 +#endif
54 }
55 }
56
57 @@ -278,6 +280,7 @@ next:
58 printf("\tCoverage class: %d (up to %dm)\n", coverage, 450 * coverage);
59 }
60
61 +#ifdef IW_FULL
62 if (tb_msg[NL80211_ATTR_CIPHER_SUITES]) {
63 int num = nla_len(tb_msg[NL80211_ATTR_CIPHER_SUITES]) / sizeof(__u32);
64 int i;
65 @@ -289,6 +292,7 @@ next:
66 cipher_name(ciphers[i]));
67 }
68 }
69 +#endif
70
71 if (tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX] &&
72 tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX])
73 @@ -308,11 +312,13 @@ next:
74 printf("\t\t * %s\n", iftype_name(nla_type(nl_mode)));
75 }
76
77 +#ifdef IW_FULL
78 if (tb_msg[NL80211_ATTR_SOFTWARE_IFTYPES]) {
79 printf("\tsoftware interface modes (can always be added):\n");
80 nla_for_each_nested(nl_mode, tb_msg[NL80211_ATTR_SOFTWARE_IFTYPES], rem_mode)
81 printf("\t\t * %s\n", iftype_name(nla_type(nl_mode)));
82 }
83 +#endif
84
85 if (tb_msg[NL80211_ATTR_INTERFACE_COMBINATIONS]) {
86 struct nlattr *nl_combi;
87 @@ -409,6 +415,7 @@ broken_combination:
88 printf("\tinterface combinations are not supported\n");
89 }
90
91 +#ifdef IW_FULL
92 if (tb_msg[NL80211_ATTR_SUPPORTED_COMMANDS]) {
93 printf("\tSupported commands:\n");
94 nla_for_each_nested(nl_cmd, tb_msg[NL80211_ATTR_SUPPORTED_COMMANDS], rem_cmd)
95 @@ -506,6 +513,7 @@ broken_combination:
96 printf("\t\t * wake up on TCP connection\n");
97 }
98 }
99 +#endif
100
101 if (tb_msg[NL80211_ATTR_ROAM_SUPPORT])
102 printf("\tDevice supports roaming.\n");
103 @@ -544,6 +552,7 @@ broken_combination:
104 }
105 }
106
107 +#ifdef IW_FULL
108 if (tb_msg[NL80211_ATTR_FEATURE_FLAGS]) {
109 unsigned int features = nla_get_u32(tb_msg[NL80211_ATTR_FEATURE_FLAGS]);
110
111 @@ -602,6 +611,7 @@ broken_combination:
112 if (features & NL80211_FEATURE_TDLS_CHANNEL_SWITCH)
113 printf("\tDevice supports TDLS channel switching\n");
114 }
115 +#endif
116
117 if (tb_msg[NL80211_ATTR_EXT_FEATURES]) {
118 struct nlattr *tb = tb_msg[NL80211_ATTR_EXT_FEATURES];
119 @@ -658,6 +668,7 @@ TOPLEVEL(list, NULL, NL80211_CMD_GET_WIP
120 "List all wireless devices and their capabilities.");
121 TOPLEVEL(phy, NULL, NL80211_CMD_GET_WIPHY, NLM_F_DUMP, CIB_NONE, handle_info, NULL);
122
123 +#ifdef IW_FULL
124 static int handle_commands(struct nl80211_state *state, struct nl_msg *msg,
125 int argc, char **argv, enum id_input id)
126 {
127 @@ -669,6 +680,7 @@ static int handle_commands(struct nl8021
128 }
129 TOPLEVEL(commands, NULL, NL80211_CMD_GET_WIPHY, 0, CIB_NONE, handle_commands,
130 "list all known commands and their decimal & hex value");
131 +#endif
132
133 static int print_feature_handler(struct nl_msg *msg, void *arg)
134 {
135 --- a/scan.c
136 +++ b/scan.c
137 @@ -1170,6 +1170,7 @@ static void print_ht_op(const uint8_t ty
138 printf("\t\t * secondary channel offset: %s\n",
139 ht_secondary_offset[data[1] & 0x3]);
140 printf("\t\t * STA channel width: %s\n", sta_chan_width[(data[1] & 0x4)>>2]);
141 + return;
142 printf("\t\t * RIFS: %d\n", (data[1] & 0x8)>>3);
143 printf("\t\t * HT protection: %s\n", protection[data[2] & 0x3]);
144 printf("\t\t * non-GF present: %d\n", (data[2] & 0x4) >> 2);
145 @@ -1497,6 +1498,14 @@ static void print_ie(const struct ie_pri
146
147 static const struct ie_print ieprinters[] = {
148 [0] = { "SSID", print_ssid, 0, 32, BIT(PRINT_SCAN) | BIT(PRINT_LINK), },
149 + [45] = { "HT capabilities", print_ht_capa, 26, 26, BIT(PRINT_SCAN), },
150 + [48] = { "RSN", print_rsn, 2, 255, BIT(PRINT_SCAN), },
151 + [61] = { "HT operation", print_ht_op, 22, 22, BIT(PRINT_SCAN), },
152 + [62] = { "Secondary Channel Offset", print_secchan_offs, 1, 1, BIT(PRINT_SCAN), },
153 + [114] = { "MESH ID", print_ssid, 0, 32, BIT(PRINT_SCAN) | BIT(PRINT_LINK), },
154 + [191] = { "VHT capabilities", print_vht_capa, 12, 255, BIT(PRINT_SCAN), },
155 + [192] = { "VHT operation", print_vht_oper, 5, 255, BIT(PRINT_SCAN), },
156 +#ifdef IW_FULL
157 [1] = { "Supported rates", print_supprates, 0, 255, BIT(PRINT_SCAN), },
158 [3] = { "DS Parameter set", print_ds, 1, 1, BIT(PRINT_SCAN), },
159 [5] = { "TIM", print_tim, 4, 255, BIT(PRINT_SCAN), },
160 @@ -1506,21 +1515,15 @@ static const struct ie_print ieprinters[
161 [32] = { "Power constraint", print_powerconstraint, 1, 1, BIT(PRINT_SCAN), },
162 [35] = { "TPC report", print_tpcreport, 2, 2, BIT(PRINT_SCAN), },
163 [42] = { "ERP", print_erp, 1, 255, BIT(PRINT_SCAN), },
164 - [45] = { "HT capabilities", print_ht_capa, 26, 26, BIT(PRINT_SCAN), },
165 [47] = { "ERP D4.0", print_erp, 1, 255, BIT(PRINT_SCAN), },
166 [74] = { "Overlapping BSS scan params", print_obss_scan_params, 14, 255, BIT(PRINT_SCAN), },
167 - [61] = { "HT operation", print_ht_op, 22, 22, BIT(PRINT_SCAN), },
168 - [62] = { "Secondary Channel Offset", print_secchan_offs, 1, 1, BIT(PRINT_SCAN), },
169 - [191] = { "VHT capabilities", print_vht_capa, 12, 255, BIT(PRINT_SCAN), },
170 - [192] = { "VHT operation", print_vht_oper, 5, 255, BIT(PRINT_SCAN), },
171 - [48] = { "RSN", print_rsn, 2, 255, BIT(PRINT_SCAN), },
172 [50] = { "Extended supported rates", print_supprates, 0, 255, BIT(PRINT_SCAN), },
173 [113] = { "MESH Configuration", print_mesh_conf, 7, 7, BIT(PRINT_SCAN), },
174 - [114] = { "MESH ID", print_ssid, 0, 32, BIT(PRINT_SCAN) | BIT(PRINT_LINK), },
175 [127] = { "Extended capabilities", print_capabilities, 0, 255, BIT(PRINT_SCAN), },
176 [107] = { "802.11u Interworking", print_interworking, 0, 255, BIT(PRINT_SCAN), },
177 [108] = { "802.11u Advertisement", print_11u_advert, 0, 255, BIT(PRINT_SCAN), },
178 [111] = { "802.11u Roaming Consortium", print_11u_rcon, 0, 255, BIT(PRINT_SCAN), },
179 +#endif
180 };
181
182 static void print_wifi_wpa(const uint8_t type, uint8_t len, const uint8_t *data,
183 @@ -1968,6 +1971,7 @@ void print_ies(unsigned char *ie, int ie
184 ieprinters[ie[0]].flags & BIT(ptype)) {
185 print_ie(&ieprinters[ie[0]],
186 ie[0], ie[1], ie + 2, &ie_buffer);
187 +#ifdef IW_FULL
188 } else if (ie[0] == 221 /* vendor */) {
189 print_vendor(ie[1], ie + 2, unknown, ptype);
190 } else if (unknown) {
191 @@ -1977,6 +1981,7 @@ void print_ies(unsigned char *ie, int ie
192 for (i=0; i<ie[1]; i++)
193 printf(" %.2x", ie[2+i]);
194 printf("\n");
195 +#endif
196 }
197 ielen -= ie[1] + 2;
198 ie += ie[1] + 2;
199 @@ -2017,6 +2022,7 @@ static void print_capa_non_dmg(__u16 cap
200 printf(" ESS");
201 if (capa & WLAN_CAPABILITY_IBSS)
202 printf(" IBSS");
203 +#ifdef IW_FULL
204 if (capa & WLAN_CAPABILITY_CF_POLLABLE)
205 printf(" CfPollable");
206 if (capa & WLAN_CAPABILITY_CF_POLL_REQUEST)
207 @@ -2045,6 +2051,7 @@ static void print_capa_non_dmg(__u16 cap
208 printf(" DelayedBACK");
209 if (capa & WLAN_CAPABILITY_IMM_BACK)
210 printf(" ImmediateBACK");
211 +#endif
212 }
213
214 static int print_bss_handler(struct nl_msg *msg, void *arg)
215 @@ -2129,8 +2136,10 @@ static int print_bss_handler(struct nl_m
216 if (bss[NL80211_BSS_FREQUENCY]) {
217 int freq = nla_get_u32(bss[NL80211_BSS_FREQUENCY]);
218 printf("\tfreq: %d\n", freq);
219 +#ifdef IW_FULL
220 if (freq > 45000)
221 is_dmg = true;
222 +#endif
223 }
224 if (bss[NL80211_BSS_BEACON_INTERVAL])
225 printf("\tbeacon interval: %d TUs\n",
226 @@ -2319,6 +2328,7 @@ static int handle_stop_sched_scan(struct
227 return 0;
228 }
229
230 +#ifdef IW_FULL
231 COMMAND(scan, sched_start,
232 SCHED_SCAN_OPTIONS,
233 NL80211_CMD_START_SCHED_SCAN, 0, CIB_NETDEV, handle_start_sched_scan,
234 @@ -2329,3 +2339,4 @@ COMMAND(scan, sched_start,
235 COMMAND(scan, sched_stop, "",
236 NL80211_CMD_STOP_SCHED_SCAN, 0, CIB_NETDEV, handle_stop_sched_scan,
237 "Stop an ongoing scheduled scan.");
238 +#endif
239 --- a/util.c
240 +++ b/util.c
241 @@ -281,6 +281,7 @@ static const char *commands[NL80211_CMD_
242
243 static char cmdbuf[100];
244
245 +#ifdef IW_FULL
246 const char *command_name(enum nl80211_commands cmd)
247 {
248 if (cmd <= NL80211_CMD_MAX && commands[cmd])
249 @@ -288,6 +289,7 @@ const char *command_name(enum nl80211_co
250 sprintf(cmdbuf, "Unknown command (%d)", cmd);
251 return cmdbuf;
252 }
253 +#endif
254
255 int ieee80211_channel_to_frequency(int chan, enum nl80211_band band)
256 {
257 @@ -426,6 +428,9 @@ int parse_keys(struct nl_msg *msg, char
258 char keybuf[13];
259 int pos = 0;
260
261 +#ifndef IW_FULL
262 + return 1;
263 +#endif
264 if (!argc)
265 return 1;
266
267 --- a/Makefile
268 +++ b/Makefile
269 @@ -25,6 +25,12 @@ OBJS-$(HWSIM) += hwsim.o
270
271 OBJS += $(OBJS-y) $(OBJS-Y)
272
273 +OBJS_FULL = ocb offch cqm wowlan coalesce roc p2p ap mgmt vendor
274 +ifdef IW_FULL
275 + CFLAGS += -DIW_FULL
276 +else
277 + OBJS:=$(filter-out $(patsubst %,%.o,$(OBJS_FULL)),$(OBJS))
278 +endif
279 ALL = iw
280
281 ifeq ($(NO_PKG_CONFIG),)
282 --- a/station.c
283 +++ b/station.c
284 @@ -629,10 +629,12 @@ static int handle_station_set_plink(stru
285 nla_put_failure:
286 return -ENOBUFS;
287 }
288 +#ifdef IW_FULL
289 COMMAND_ALIAS(station, set, "<MAC address> plink_action <open|block>",
290 NL80211_CMD_SET_STATION, 0, CIB_NETDEV, handle_station_set_plink,
291 "Set mesh peer link action for this station (peer).",
292 select_station_cmd, station_set_plink);
293 +#endif
294
295 static int handle_station_set_vlan(struct nl80211_state *state,
296 struct nl_msg *msg,
297 @@ -727,11 +729,13 @@ static int handle_station_set_mesh_power
298 nla_put_failure:
299 return -ENOBUFS;
300 }
301 +#ifdef IW_FULL
302 COMMAND_ALIAS(station, set, "<MAC address> mesh_power_mode "
303 "<active|light|deep>", NL80211_CMD_SET_STATION, 0, CIB_NETDEV,
304 handle_station_set_mesh_power_mode,
305 "Set link-specific mesh power mode for this station",
306 select_station_cmd, station_set_mesh_power_mode);
307 +#endif
308
309 static int handle_station_dump(struct nl80211_state *state,
310 struct nl_msg *msg,
311 --- a/interface.c
312 +++ b/interface.c
313 @@ -615,9 +615,11 @@ static int handle_interface_wds_peer(str
314 nla_put_failure:
315 return -ENOBUFS;
316 }
317 +#ifdef IW_FULL
318 COMMAND(set, peer, "<MAC address>",
319 NL80211_CMD_SET_WDS_PEER, 0, CIB_NETDEV, handle_interface_wds_peer,
320 "Set interface WDS peer.");
321 +#endif
322
323 static int set_mcast_rate(struct nl80211_state *state,
324 struct nl_msg *msg,
325 @@ -707,6 +709,7 @@ static int handle_chan(struct nl80211_st
326 return handle_chanfreq(state, msg, true, argc, argv, id);
327 }
328
329 +#ifdef IW_FULL
330 SECTION(switch);
331 COMMAND(switch, freq,
332 "<freq> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz] [beacons <count>] [block-tx]\n"
333 @@ -715,3 +718,4 @@ COMMAND(switch, freq,
334 "Switch the operating channel by sending a channel switch announcement (CSA).");
335 COMMAND(switch, channel, "<channel> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz] [beacons <count>] [block-tx]",
336 NL80211_CMD_CHANNEL_SWITCH, 0, CIB_NETDEV, handle_chan, NULL);
337 +#endif
338 --- a/phy.c
339 +++ b/phy.c
340 @@ -359,6 +359,7 @@ static int handle_cac(struct nl80211_sta
341
342 return 0;
343 }
344 +#ifdef IW_FULL
345 TOPLEVEL(cac, "channel <channel> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz]\n"
346 "freq <freq> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz]\n"
347 "freq <control freq> [5|10|20|40|80|80+80|160] [<center1_freq> [<center2_freq>]]",
348 @@ -370,6 +371,7 @@ COMMAND(cac, trigger,
349 NL80211_CMD_RADAR_DETECT, 0, CIB_NETDEV, handle_cac_trigger,
350 "Start or trigger a channel availability check (CAC) looking to look for\n"
351 "radars on the given channel.");
352 +#endif
353
354 static int handle_fragmentation(struct nl80211_state *state,
355 struct nl_msg *msg,