iw: update to 5.0.1
[openwrt/openwrt.git] / package / network / utils / iw / patches / 200-reduce_size.patch
1 --- a/event.c
2 +++ b/event.c
3 @@ -699,6 +699,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 @@ -734,6 +735,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 @@ -812,6 +814,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 @@ -989,9 +992,9 @@ static int print_event(struct nl_msg *ms
28 parse_nan_match(tb);
29 break;
30 }
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 @@ -205,6 +205,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 @@ -221,6 +222,7 @@ next:
50 printf("\n");
51 }
52 }
53 +#endif
54 }
55 }
56
57 @@ -286,6 +288,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 @@ -297,6 +300,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 @@ -316,11 +320,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 @@ -417,6 +423,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 @@ -514,6 +521,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 @@ -552,6 +560,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 @@ -616,6 +625,7 @@ broken_combination:
112 if (features & NL80211_FEATURE_ND_RANDOM_MAC_ADDR)
113 printf("\tDevice supports randomizing MAC-addr in net-detect scans.\n");
114 }
115 +#endif
116
117 if (tb_msg[NL80211_ATTR_TDLS_SUPPORT])
118 printf("\tDevice supports T-DLS.\n");
119 @@ -740,6 +750,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 @@ -751,6 +762,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 @@ -1197,6 +1197,9 @@ 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 +#ifndef IW_FULL
142 + return;
143 +#endif
144 printf("\t\t * RIFS: %d\n", (data[1] & 0x8)>>3);
145 printf("\t\t * HT protection: %s\n", protection[data[2] & 0x3]);
146 printf("\t\t * non-GF present: %d\n", (data[2] & 0x4) >> 2);
147 @@ -1524,6 +1527,14 @@ static void print_ie(const struct ie_pri
148
149 static const struct ie_print ieprinters[] = {
150 [0] = { "SSID", print_ssid, 0, 32, BIT(PRINT_SCAN) | BIT(PRINT_LINK), },
151 + [45] = { "HT capabilities", print_ht_capa, 26, 26, BIT(PRINT_SCAN), },
152 + [48] = { "RSN", print_rsn, 2, 255, BIT(PRINT_SCAN), },
153 + [61] = { "HT operation", print_ht_op, 22, 22, BIT(PRINT_SCAN), },
154 + [62] = { "Secondary Channel Offset", print_secchan_offs, 1, 1, BIT(PRINT_SCAN), },
155 + [114] = { "MESH ID", print_ssid, 0, 32, BIT(PRINT_SCAN) | BIT(PRINT_LINK), },
156 + [191] = { "VHT capabilities", print_vht_capa, 12, 255, BIT(PRINT_SCAN), },
157 + [192] = { "VHT operation", print_vht_oper, 5, 255, BIT(PRINT_SCAN), },
158 +#ifdef IW_FULL
159 [1] = { "Supported rates", print_supprates, 0, 255, BIT(PRINT_SCAN), },
160 [3] = { "DS Parameter set", print_ds, 1, 1, BIT(PRINT_SCAN), },
161 [5] = { "TIM", print_tim, 4, 255, BIT(PRINT_SCAN), },
162 @@ -1533,21 +1544,15 @@ static const struct ie_print ieprinters[
163 [32] = { "Power constraint", print_powerconstraint, 1, 1, BIT(PRINT_SCAN), },
164 [35] = { "TPC report", print_tpcreport, 2, 2, BIT(PRINT_SCAN), },
165 [42] = { "ERP", print_erp, 1, 255, BIT(PRINT_SCAN), },
166 - [45] = { "HT capabilities", print_ht_capa, 26, 26, BIT(PRINT_SCAN), },
167 [47] = { "ERP D4.0", print_erp, 1, 255, BIT(PRINT_SCAN), },
168 [74] = { "Overlapping BSS scan params", print_obss_scan_params, 14, 255, BIT(PRINT_SCAN), },
169 - [61] = { "HT operation", print_ht_op, 22, 22, BIT(PRINT_SCAN), },
170 - [62] = { "Secondary Channel Offset", print_secchan_offs, 1, 1, BIT(PRINT_SCAN), },
171 - [191] = { "VHT capabilities", print_vht_capa, 12, 255, BIT(PRINT_SCAN), },
172 - [192] = { "VHT operation", print_vht_oper, 5, 255, BIT(PRINT_SCAN), },
173 - [48] = { "RSN", print_rsn, 2, 255, BIT(PRINT_SCAN), },
174 [50] = { "Extended supported rates", print_supprates, 0, 255, BIT(PRINT_SCAN), },
175 [113] = { "MESH Configuration", print_mesh_conf, 7, 7, BIT(PRINT_SCAN), },
176 - [114] = { "MESH ID", print_ssid, 0, 32, BIT(PRINT_SCAN) | BIT(PRINT_LINK), },
177 [127] = { "Extended capabilities", print_capabilities, 0, 255, BIT(PRINT_SCAN), },
178 [107] = { "802.11u Interworking", print_interworking, 0, 255, BIT(PRINT_SCAN), },
179 [108] = { "802.11u Advertisement", print_11u_advert, 0, 255, BIT(PRINT_SCAN), },
180 [111] = { "802.11u Roaming Consortium", print_11u_rcon, 0, 255, BIT(PRINT_SCAN), },
181 +#endif
182 };
183
184 static void print_wifi_wpa(const uint8_t type, uint8_t len, const uint8_t *data,
185 @@ -2026,6 +2031,7 @@ void print_ies(unsigned char *ie, int ie
186 ieprinters[ie[0]].flags & BIT(ptype)) {
187 print_ie(&ieprinters[ie[0]],
188 ie[0], ie[1], ie + 2, &ie_buffer);
189 +#ifdef IW_FULL
190 } else if (ie[0] == 221 /* vendor */) {
191 print_vendor(ie[1], ie + 2, unknown, ptype);
192 } else if (unknown) {
193 @@ -2035,6 +2041,7 @@ void print_ies(unsigned char *ie, int ie
194 for (i=0; i<ie[1]; i++)
195 printf(" %.2x", ie[2+i]);
196 printf("\n");
197 +#endif
198 }
199 ielen -= ie[1] + 2;
200 ie += ie[1] + 2;
201 @@ -2075,6 +2082,7 @@ static void print_capa_non_dmg(__u16 cap
202 printf(" ESS");
203 if (capa & WLAN_CAPABILITY_IBSS)
204 printf(" IBSS");
205 +#ifdef IW_FULL
206 if (capa & WLAN_CAPABILITY_CF_POLLABLE)
207 printf(" CfPollable");
208 if (capa & WLAN_CAPABILITY_CF_POLL_REQUEST)
209 @@ -2103,6 +2111,7 @@ static void print_capa_non_dmg(__u16 cap
210 printf(" DelayedBACK");
211 if (capa & WLAN_CAPABILITY_IMM_BACK)
212 printf(" ImmediateBACK");
213 +#endif
214 }
215
216 static int print_bss_handler(struct nl_msg *msg, void *arg)
217 @@ -2187,8 +2196,10 @@ static int print_bss_handler(struct nl_m
218 if (bss[NL80211_BSS_FREQUENCY]) {
219 int freq = nla_get_u32(bss[NL80211_BSS_FREQUENCY]);
220 printf("\tfreq: %d\n", freq);
221 +#ifdef IW_FULL
222 if (freq > 45000)
223 is_dmg = true;
224 +#endif
225 }
226 if (bss[NL80211_BSS_BEACON_INTERVAL])
227 printf("\tbeacon interval: %d TUs\n",
228 @@ -2382,6 +2393,7 @@ static int handle_stop_sched_scan(struct
229 return 0;
230 }
231
232 +#ifdef IW_FULL
233 COMMAND(scan, sched_start,
234 SCHED_SCAN_OPTIONS,
235 NL80211_CMD_START_SCHED_SCAN, 0, CIB_NETDEV, handle_start_sched_scan,
236 @@ -2392,3 +2404,4 @@ COMMAND(scan, sched_start,
237 COMMAND(scan, sched_stop, "",
238 NL80211_CMD_STOP_SCHED_SCAN, 0, CIB_NETDEV, handle_stop_sched_scan,
239 "Stop an ongoing scheduled scan.");
240 +#endif
241 --- a/util.c
242 +++ b/util.c
243 @@ -289,6 +289,7 @@ static const char *commands[NL80211_CMD_
244
245 static char cmdbuf[100];
246
247 +#ifdef IW_FULL
248 const char *command_name(enum nl80211_commands cmd)
249 {
250 if (cmd <= NL80211_CMD_MAX && commands[cmd])
251 @@ -296,6 +297,7 @@ const char *command_name(enum nl80211_co
252 sprintf(cmdbuf, "Unknown command (%d)", cmd);
253 return cmdbuf;
254 }
255 +#endif
256
257 int ieee80211_channel_to_frequency(int chan, enum nl80211_band band)
258 {
259 @@ -434,6 +436,9 @@ int parse_keys(struct nl_msg *msg, char
260 char keybuf[13];
261 int pos = 0;
262
263 +#ifndef IW_FULL
264 + return 1;
265 +#endif
266 if (!*argc)
267 return 1;
268
269 --- a/Makefile
270 +++ b/Makefile
271 @@ -31,6 +31,12 @@ OBJS-$(HWSIM) += hwsim.o
272
273 OBJS += $(OBJS-y) $(OBJS-Y)
274
275 +OBJS_FULL = ocb offch cqm wowlan coalesce roc p2p vendor mgmt ap sha256 nan bloom measurements ftm
276 +ifdef IW_FULL
277 + CFLAGS += -DIW_FULL
278 +else
279 + OBJS:=$(filter-out $(patsubst %,%.o,$(OBJS_FULL)),$(OBJS))
280 +endif
281 ALL = iw
282
283 ifeq ($(NO_PKG_CONFIG),)
284 --- a/station.c
285 +++ b/station.c
286 @@ -709,10 +709,12 @@ static int handle_station_set_plink(stru
287 nla_put_failure:
288 return -ENOBUFS;
289 }
290 +#ifdef IW_FULL
291 COMMAND_ALIAS(station, set, "<MAC address> plink_action <open|block>",
292 NL80211_CMD_SET_STATION, 0, CIB_NETDEV, handle_station_set_plink,
293 "Set mesh peer link action for this station (peer).",
294 select_station_cmd, station_set_plink);
295 +#endif
296
297 static int handle_station_set_vlan(struct nl80211_state *state,
298 struct nl_msg *msg,
299 @@ -807,11 +809,13 @@ static int handle_station_set_mesh_power
300 nla_put_failure:
301 return -ENOBUFS;
302 }
303 +#ifdef IW_FULL
304 COMMAND_ALIAS(station, set, "<MAC address> mesh_power_mode "
305 "<active|light|deep>", NL80211_CMD_SET_STATION, 0, CIB_NETDEV,
306 handle_station_set_mesh_power_mode,
307 "Set link-specific mesh power mode for this station",
308 select_station_cmd, station_set_mesh_power_mode);
309 +#endif
310
311 static int handle_station_dump(struct nl80211_state *state,
312 struct nl_msg *msg,
313 --- a/interface.c
314 +++ b/interface.c
315 @@ -621,9 +621,11 @@ static int handle_interface_wds_peer(str
316 nla_put_failure:
317 return -ENOBUFS;
318 }
319 +#ifdef IW_FULL
320 COMMAND(set, peer, "<MAC address>",
321 NL80211_CMD_SET_WDS_PEER, 0, CIB_NETDEV, handle_interface_wds_peer,
322 "Set interface WDS peer.");
323 +#endif
324
325 static int set_mcast_rate(struct nl80211_state *state,
326 struct nl_msg *msg,
327 @@ -713,6 +715,7 @@ static int handle_chan(struct nl80211_st
328 return handle_chanfreq(state, msg, true, argc, argv, id);
329 }
330
331 +#ifdef IW_FULL
332 SECTION(switch);
333 COMMAND(switch, freq,
334 "<freq> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz] [beacons <count>] [block-tx]\n"
335 @@ -721,3 +724,4 @@ COMMAND(switch, freq,
336 "Switch the operating channel by sending a channel switch announcement (CSA).");
337 COMMAND(switch, channel, "<channel> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz] [beacons <count>] [block-tx]",
338 NL80211_CMD_CHANNEL_SWITCH, 0, CIB_NETDEV, handle_chan, NULL);
339 +#endif
340 --- a/phy.c
341 +++ b/phy.c
342 @@ -359,6 +359,7 @@ static int handle_cac(struct nl80211_sta
343
344 return 0;
345 }
346 +#ifdef IW_FULL
347 TOPLEVEL(cac, "channel <channel> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz]\n"
348 "freq <freq> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz]\n"
349 "freq <control freq> [5|10|20|40|80|80+80|160] [<center1_freq> [<center2_freq>]]",
350 @@ -370,6 +371,7 @@ COMMAND(cac, trigger,
351 NL80211_CMD_RADAR_DETECT, 0, CIB_NETDEV, handle_cac_trigger,
352 "Start or trigger a channel availability check (CAC) looking to look for\n"
353 "radars on the given channel.");
354 +#endif
355
356 static int handle_fragmentation(struct nl80211_state *state,
357 struct nl_msg *msg,