iw: Update to version 5.8
[openwrt/openwrt.git] / package / network / utils / iw / patches / 200-reduce_size.patch
1 --- a/event.c
2 +++ b/event.c
3 @@ -944,6 +944,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 @@ -979,6 +980,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_WIPHY_REG_CHANGE:
17 case NL80211_CMD_REG_CHANGE:
18 if (gnlh->cmd == NL80211_CMD_WIPHY_REG_CHANGE)
19 @@ -1061,6 +1063,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 @@ -1254,9 +1257,9 @@ static int print_event(struct nl_msg *ms
28 case NL80211_CMD_CH_SWITCH_NOTIFY:
29 parse_ch_switch_notify(tb, gnlh->cmd);
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 @@ -167,6 +167,7 @@ static int print_phy_handler(struct nl_m
42 tb_band[NL80211_BAND_ATTR_VHT_MCS_SET])
43 print_vht_info(nla_get_u32(tb_band[NL80211_BAND_ATTR_VHT_CAPA]),
44 nla_data(tb_band[NL80211_BAND_ATTR_VHT_MCS_SET]));
45 +#ifdef IW_FULL
46 if (tb_band[NL80211_BAND_ATTR_IFTYPE_DATA]) {
47 struct nlattr *nl_iftype;
48 int rem_band;
49 @@ -174,6 +175,7 @@ static int print_phy_handler(struct nl_m
50 nla_for_each_nested(nl_iftype, tb_band[NL80211_BAND_ATTR_IFTYPE_DATA], rem_band)
51 print_he_info(nl_iftype);
52 }
53 +#endif
54 if (tb_band[NL80211_BAND_ATTR_FREQS]) {
55 if (!band_had_freq) {
56 printf("\t\tFrequencies:\n");
57 @@ -216,6 +218,7 @@ next:
58 }
59 }
60
61 +#ifdef IW_FULL
62 if (tb_band[NL80211_BAND_ATTR_RATES]) {
63 printf("\t\tBitrates (non-HT):\n");
64 nla_for_each_nested(nl_rate, tb_band[NL80211_BAND_ATTR_RATES], rem_rate) {
65 @@ -232,6 +235,7 @@ next:
66 printf("\n");
67 }
68 }
69 +#endif
70 }
71 }
72
73 @@ -297,6 +301,7 @@ next:
74 printf("\tCoverage class: %d (up to %dm)\n", coverage, 450 * coverage);
75 }
76
77 +#ifdef IW_FULL
78 if (tb_msg[NL80211_ATTR_CIPHER_SUITES]) {
79 int num = nla_len(tb_msg[NL80211_ATTR_CIPHER_SUITES]) / sizeof(__u32);
80 int i;
81 @@ -308,6 +313,7 @@ next:
82 cipher_name(ciphers[i]));
83 }
84 }
85 +#endif
86
87 if (tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX] &&
88 tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX])
89 @@ -327,11 +333,13 @@ next:
90 printf("\t\t * %s\n", iftype_name(nla_type(nl_mode)));
91 }
92
93 +#ifdef IW_FULL
94 if (tb_msg[NL80211_ATTR_SOFTWARE_IFTYPES]) {
95 printf("\tsoftware interface modes (can always be added):\n");
96 nla_for_each_nested(nl_mode, tb_msg[NL80211_ATTR_SOFTWARE_IFTYPES], rem_mode)
97 printf("\t\t * %s\n", iftype_name(nla_type(nl_mode)));
98 }
99 +#endif
100
101 if (tb_msg[NL80211_ATTR_INTERFACE_COMBINATIONS]) {
102 struct nlattr *nl_combi;
103 @@ -428,6 +436,7 @@ broken_combination:
104 printf("\tinterface combinations are not supported\n");
105 }
106
107 +#ifdef IW_FULL
108 if (tb_msg[NL80211_ATTR_SUPPORTED_COMMANDS]) {
109 printf("\tSupported commands:\n");
110 nla_for_each_nested(nl_cmd, tb_msg[NL80211_ATTR_SUPPORTED_COMMANDS], rem_cmd)
111 @@ -525,6 +534,7 @@ broken_combination:
112 printf("\t\t * wake up on TCP connection\n");
113 }
114 }
115 +#endif
116
117 if (tb_msg[NL80211_ATTR_ROAM_SUPPORT])
118 printf("\tDevice supports roaming.\n");
119 @@ -563,6 +573,7 @@ broken_combination:
120 }
121 }
122
123 +#ifdef IW_FULL
124 if (tb_msg[NL80211_ATTR_FEATURE_FLAGS]) {
125 unsigned int features = nla_get_u32(tb_msg[NL80211_ATTR_FEATURE_FLAGS]);
126
127 @@ -627,6 +638,7 @@ broken_combination:
128 if (features & NL80211_FEATURE_ND_RANDOM_MAC_ADDR)
129 printf("\tDevice supports randomizing MAC-addr in net-detect scans.\n");
130 }
131 +#endif
132
133 if (tb_msg[NL80211_ATTR_TDLS_SUPPORT])
134 printf("\tDevice supports T-DLS.\n");
135 @@ -762,6 +774,7 @@ TOPLEVEL(list, NULL, NL80211_CMD_GET_WIP
136 "List all wireless devices and their capabilities.");
137 TOPLEVEL(phy, NULL, NL80211_CMD_GET_WIPHY, NLM_F_DUMP, CIB_NONE, handle_info, NULL);
138
139 +#ifdef IW_FULL
140 static int handle_commands(struct nl80211_state *state, struct nl_msg *msg,
141 int argc, char **argv, enum id_input id)
142 {
143 @@ -773,6 +786,7 @@ static int handle_commands(struct nl8021
144 }
145 TOPLEVEL(commands, NULL, NL80211_CMD_GET_WIPHY, 0, CIB_NONE, handle_commands,
146 "list all known commands and their decimal & hex value");
147 +#endif
148
149 static int print_feature_handler(struct nl_msg *msg, void *arg)
150 {
151 --- a/scan.c
152 +++ b/scan.c
153 @@ -1297,6 +1297,9 @@ static void print_ht_op(const uint8_t ty
154 printf("\t\t * secondary channel offset: %s\n",
155 ht_secondary_offset[data[1] & 0x3]);
156 printf("\t\t * STA channel width: %s\n", sta_chan_width[(data[1] & 0x4)>>2]);
157 +#ifndef IW_FULL
158 + return;
159 +#endif
160 printf("\t\t * RIFS: %d\n", (data[1] & 0x8)>>3);
161 printf("\t\t * HT protection: %s\n", protection[data[2] & 0x3]);
162 printf("\t\t * non-GF present: %d\n", (data[2] & 0x4) >> 2);
163 @@ -1707,6 +1710,14 @@ static void print_ie(const struct ie_pri
164
165 static const struct ie_print ieprinters[] = {
166 [0] = { "SSID", print_ssid, 0, 32, BIT(PRINT_SCAN) | BIT(PRINT_LINK), },
167 + [45] = { "HT capabilities", print_ht_capa, 26, 26, BIT(PRINT_SCAN), },
168 + [48] = { "RSN", print_rsn, 2, 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 + [114] = { "MESH ID", print_ssid, 0, 32, BIT(PRINT_SCAN) | BIT(PRINT_LINK), },
172 + [191] = { "VHT capabilities", print_vht_capa, 12, 255, BIT(PRINT_SCAN), },
173 + [192] = { "VHT operation", print_vht_oper, 5, 255, BIT(PRINT_SCAN), },
174 +#ifdef IW_FULL
175 [1] = { "Supported rates", print_supprates, 0, 255, BIT(PRINT_SCAN), },
176 [3] = { "DS Parameter set", print_ds, 1, 1, BIT(PRINT_SCAN), },
177 [5] = { "TIM", print_tim, 4, 255, BIT(PRINT_SCAN), },
178 @@ -1716,26 +1727,20 @@ static const struct ie_print ieprinters[
179 [32] = { "Power constraint", print_powerconstraint, 1, 1, BIT(PRINT_SCAN), },
180 [35] = { "TPC report", print_tpcreport, 2, 2, BIT(PRINT_SCAN), },
181 [42] = { "ERP", print_erp, 1, 255, BIT(PRINT_SCAN), },
182 - [45] = { "HT capabilities", print_ht_capa, 26, 26, BIT(PRINT_SCAN), },
183 [47] = { "ERP D4.0", print_erp, 1, 255, BIT(PRINT_SCAN), },
184 [51] = { "AP Channel Report", print_ap_channel_report, 1, 255, BIT(PRINT_SCAN), },
185 [59] = { "Supported operating classes", print_supp_op_classes, 1, 255, BIT(PRINT_SCAN), },
186 [66] = { "Measurement Pilot Transmission", print_measurement_pilot_tx, 1, 255, BIT(PRINT_SCAN), },
187 [74] = { "Overlapping BSS scan params", print_obss_scan_params, 14, 255, BIT(PRINT_SCAN), },
188 - [61] = { "HT operation", print_ht_op, 22, 22, BIT(PRINT_SCAN), },
189 - [62] = { "Secondary Channel Offset", print_secchan_offs, 1, 1, BIT(PRINT_SCAN), },
190 - [191] = { "VHT capabilities", print_vht_capa, 12, 255, BIT(PRINT_SCAN), },
191 - [192] = { "VHT operation", print_vht_oper, 5, 255, BIT(PRINT_SCAN), },
192 - [48] = { "RSN", print_rsn, 2, 255, BIT(PRINT_SCAN), },
193 [50] = { "Extended supported rates", print_supprates, 0, 255, BIT(PRINT_SCAN), },
194 [70] = { "RM enabled capabilities", print_rm_enabled_capabilities, 5, 5, BIT(PRINT_SCAN), },
195 [113] = { "MESH Configuration", print_mesh_conf, 7, 7, BIT(PRINT_SCAN), },
196 - [114] = { "MESH ID", print_ssid, 0, 32, BIT(PRINT_SCAN) | BIT(PRINT_LINK), },
197 [127] = { "Extended capabilities", print_capabilities, 0, 255, BIT(PRINT_SCAN), },
198 [107] = { "802.11u Interworking", print_interworking, 0, 255, BIT(PRINT_SCAN), },
199 [108] = { "802.11u Advertisement", print_11u_advert, 0, 255, BIT(PRINT_SCAN), },
200 [111] = { "802.11u Roaming Consortium", print_11u_rcon, 2, 255, BIT(PRINT_SCAN), },
201 [195] = { "Transmit Power Envelope", print_tx_power_envelope, 2, 5, BIT(PRINT_SCAN), },
202 +#endif
203 };
204
205 static void print_wifi_wpa(const uint8_t type, uint8_t len, const uint8_t *data,
206 @@ -2279,6 +2284,7 @@ void print_ies(unsigned char *ie, int ie
207 ieprinters[ie[0]].flags & BIT(ptype)) {
208 print_ie(&ieprinters[ie[0]],
209 ie[0], ie[1], ie + 2, &ie_buffer);
210 +#ifdef IW_FULL
211 } else if (ie[0] == 221 /* vendor */) {
212 print_vendor(ie[1], ie + 2, unknown, ptype);
213 } else if (unknown) {
214 @@ -2288,6 +2294,7 @@ void print_ies(unsigned char *ie, int ie
215 for (i=0; i<ie[1]; i++)
216 printf(" %.2x", ie[2+i]);
217 printf("\n");
218 +#endif
219 }
220 ielen -= ie[1] + 2;
221 ie += ie[1] + 2;
222 @@ -2328,6 +2335,7 @@ static void print_capa_non_dmg(__u16 cap
223 printf(" ESS");
224 if (capa & WLAN_CAPABILITY_IBSS)
225 printf(" IBSS");
226 +#ifdef IW_FULL
227 if (capa & WLAN_CAPABILITY_CF_POLLABLE)
228 printf(" CfPollable");
229 if (capa & WLAN_CAPABILITY_CF_POLL_REQUEST)
230 @@ -2356,6 +2364,7 @@ static void print_capa_non_dmg(__u16 cap
231 printf(" DelayedBACK");
232 if (capa & WLAN_CAPABILITY_IMM_BACK)
233 printf(" ImmediateBACK");
234 +#endif
235 }
236
237 static int print_bss_handler(struct nl_msg *msg, void *arg)
238 @@ -2440,8 +2449,10 @@ static int print_bss_handler(struct nl_m
239 if (bss[NL80211_BSS_FREQUENCY]) {
240 int freq = nla_get_u32(bss[NL80211_BSS_FREQUENCY]);
241 printf("\tfreq: %d\n", freq);
242 +#ifdef IW_FULL
243 if (freq > 45000)
244 is_dmg = true;
245 +#endif
246 }
247 if (bss[NL80211_BSS_BEACON_INTERVAL])
248 printf("\tbeacon interval: %d TUs\n",
249 @@ -2635,6 +2646,7 @@ static int handle_stop_sched_scan(struct
250 return 0;
251 }
252
253 +#ifdef IW_FULL
254 COMMAND(scan, sched_start,
255 SCHED_SCAN_OPTIONS,
256 NL80211_CMD_START_SCHED_SCAN, 0, CIB_NETDEV, handle_start_sched_scan,
257 @@ -2645,3 +2657,4 @@ COMMAND(scan, sched_start,
258 COMMAND(scan, sched_stop, "",
259 NL80211_CMD_STOP_SCHED_SCAN, 0, CIB_NETDEV, handle_stop_sched_scan,
260 "Stop an ongoing scheduled scan.");
261 +#endif
262 --- a/util.c
263 +++ b/util.c
264 @@ -153,6 +153,7 @@ static const char *commands[NL80211_CMD_
265
266 static char cmdbuf[100];
267
268 +#ifdef IW_FULL
269 const char *command_name(enum nl80211_commands cmd)
270 {
271 if (cmd <= NL80211_CMD_MAX && commands[cmd])
272 @@ -160,6 +161,7 @@ const char *command_name(enum nl80211_co
273 sprintf(cmdbuf, "Unknown command (%d)", cmd);
274 return cmdbuf;
275 }
276 +#endif
277
278 int ieee80211_channel_to_frequency(int chan, enum nl80211_band band)
279 {
280 @@ -311,6 +313,9 @@ int parse_keys(struct nl_msg *msg, char
281 char keybuf[13];
282 int pos = 0;
283
284 +#ifndef IW_FULL
285 + return 1;
286 +#endif
287 if (!*argc)
288 return 1;
289
290 --- a/Makefile
291 +++ b/Makefile
292 @@ -23,6 +23,12 @@ _OBJS := $(sort $(patsubst %.c,%.o,$(wil
293 VERSION_OBJS := $(filter-out version.o, $(_OBJS))
294 OBJS := $(VERSION_OBJS) version.o
295
296 +OBJS_FULL = ocb offch cqm wowlan coalesce roc p2p vendor mgmt ap sha256 nan bloom measurements ftm
297 +ifdef IW_FULL
298 + CFLAGS += -DIW_FULL
299 +else
300 + OBJS:=$(filter-out $(patsubst %,%.o,$(OBJS_FULL)),$(OBJS))
301 +endif
302 ALL = iw
303
304 ifeq ($(NO_PKG_CONFIG),)
305 --- a/station.c
306 +++ b/station.c
307 @@ -777,10 +777,12 @@ static int handle_station_set_plink(stru
308 nla_put_failure:
309 return -ENOBUFS;
310 }
311 +#ifdef IW_FULL
312 COMMAND_ALIAS(station, set, "<MAC address> plink_action <open|block>",
313 NL80211_CMD_SET_STATION, 0, CIB_NETDEV, handle_station_set_plink,
314 "Set mesh peer link action for this station (peer).",
315 select_station_cmd, station_set_plink);
316 +#endif
317
318 static int handle_station_set_vlan(struct nl80211_state *state,
319 struct nl_msg *msg,
320 @@ -875,11 +877,13 @@ static int handle_station_set_mesh_power
321 nla_put_failure:
322 return -ENOBUFS;
323 }
324 +#ifdef IW_FULL
325 COMMAND_ALIAS(station, set, "<MAC address> mesh_power_mode "
326 "<active|light|deep>", NL80211_CMD_SET_STATION, 0, CIB_NETDEV,
327 handle_station_set_mesh_power_mode,
328 "Set link-specific mesh power mode for this station",
329 select_station_cmd, station_set_mesh_power_mode);
330 +#endif
331
332 static int handle_station_set_airtime_weight(struct nl80211_state *state,
333 struct nl_msg *msg,
334 --- a/interface.c
335 +++ b/interface.c
336 @@ -627,9 +627,11 @@ static int handle_interface_wds_peer(str
337 nla_put_failure:
338 return -ENOBUFS;
339 }
340 +#ifdef IW_FULL
341 COMMAND(set, peer, "<MAC address>",
342 NL80211_CMD_SET_WDS_PEER, 0, CIB_NETDEV, handle_interface_wds_peer,
343 "Set interface WDS peer.");
344 +#endif
345
346 static int set_mcast_rate(struct nl80211_state *state,
347 struct nl_msg *msg,
348 @@ -719,6 +721,7 @@ static int handle_chan(struct nl80211_st
349 return handle_chanfreq(state, msg, true, argc, argv, id);
350 }
351
352 +#ifdef IW_FULL
353 SECTION(switch);
354 COMMAND(switch, freq,
355 "<freq> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz] [beacons <count>] [block-tx]\n"
356 @@ -956,3 +959,4 @@ COMMAND(set, tidconf, "[peer <MAC addres
357 " $ iw dev wlan0 tids 0x3 override ampdu on noack on rtscts on\n"
358 " $ iw dev wlan0 peer xx:xx:xx:xx:xx:xx tids 0x1 ampdu off tids 0x3 amsdu off rtscts on\n"
359 );
360 +#endif
361 --- a/phy.c
362 +++ b/phy.c
363 @@ -369,6 +369,7 @@ err_out:
364 free(cac_trigger_argv);
365 return err;
366 }
367 +#ifdef IW_FULL
368 TOPLEVEL(cac, "channel <channel> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz]\n"
369 "freq <freq> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz]\n"
370 "freq <control freq> [5|10|20|40|80|80+80|160] [<center1_freq> [<center2_freq>]]",
371 @@ -380,6 +381,7 @@ COMMAND(cac, trigger,
372 NL80211_CMD_RADAR_DETECT, 0, CIB_NETDEV, handle_cac_trigger,
373 "Start or trigger a channel availability check (CAC) looking to look for\n"
374 "radars on the given channel.");
375 +#endif
376
377 static int handle_fragmentation(struct nl80211_state *state,
378 struct nl_msg *msg,