88df56b385cd080705eb6a585a0cfece9e447dff
[openwrt/staging/dedeckeh.git] / package / network / utils / iw / patches / 200-reduce_size.patch
1 --- a/event.c
2 +++ b/event.c
3 @@ -971,6 +971,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 @@ -1006,6 +1007,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 @@ -1088,6 +1090,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 @@ -1292,9 +1295,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 @@ -308,6 +308,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 @@ -324,6 +325,7 @@ next:
50 printf("\n");
51 }
52 }
53 +#endif
54 }
55 }
56
57 @@ -389,6 +391,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 @@ -400,6 +403,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 @@ -417,9 +421,11 @@ next:
74 print_iftype_list("\tSupported interface modes", "\t\t",
75 tb_msg[NL80211_ATTR_SUPPORTED_IFTYPES]);
76
77 +#ifdef IW_FULL
78 if (tb_msg[NL80211_ATTR_SOFTWARE_IFTYPES])
79 print_iftype_list("\tsoftware interface modes (can always be added)",
80 "\t\t", tb_msg[NL80211_ATTR_SOFTWARE_IFTYPES]);
81 +#endif
82
83 if (tb_msg[NL80211_ATTR_INTERFACE_COMBINATIONS]) {
84 struct nlattr *nl_combi;
85 @@ -509,6 +515,7 @@ broken_combination:
86 printf("\tinterface combinations are not supported\n");
87 }
88
89 +#ifdef IW_FULL
90 if (tb_msg[NL80211_ATTR_SUPPORTED_COMMANDS]) {
91 printf("\tSupported commands:\n");
92 nla_for_each_nested(nl_cmd, tb_msg[NL80211_ATTR_SUPPORTED_COMMANDS], rem_cmd)
93 @@ -606,6 +613,7 @@ broken_combination:
94 printf("\t\t * wake up on TCP connection\n");
95 }
96 }
97 +#endif
98
99 if (tb_msg[NL80211_ATTR_ROAM_SUPPORT])
100 printf("\tDevice supports roaming.\n");
101 @@ -644,6 +652,7 @@ broken_combination:
102 }
103 }
104
105 +#ifdef IW_FULL
106 if (tb_msg[NL80211_ATTR_FEATURE_FLAGS]) {
107 unsigned int features = nla_get_u32(tb_msg[NL80211_ATTR_FEATURE_FLAGS]);
108
109 @@ -708,6 +717,7 @@ broken_combination:
110 if (features & NL80211_FEATURE_ND_RANDOM_MAC_ADDR)
111 printf("\tDevice supports randomizing MAC-addr in net-detect scans.\n");
112 }
113 +#endif
114
115 if (tb_msg[NL80211_ATTR_TDLS_SUPPORT])
116 printf("\tDevice supports T-DLS.\n");
117 @@ -773,6 +783,7 @@ TOPLEVEL(list, NULL, NL80211_CMD_GET_WIP
118 "List all wireless devices and their capabilities.");
119 TOPLEVEL(phy, NULL, NL80211_CMD_GET_WIPHY, NLM_F_DUMP, CIB_NONE, handle_info, NULL);
120
121 +#ifdef IW_FULL
122 static int handle_commands(struct nl80211_state *state, struct nl_msg *msg,
123 int argc, char **argv, enum id_input id)
124 {
125 @@ -784,6 +795,7 @@ static int handle_commands(struct nl8021
126 }
127 TOPLEVEL(commands, NULL, NL80211_CMD_GET_WIPHY, 0, CIB_NONE, handle_commands,
128 "list all known commands and their decimal & hex value");
129 +#endif
130
131 static int print_feature_handler(struct nl_msg *msg, void *arg)
132 {
133 --- a/scan.c
134 +++ b/scan.c
135 @@ -1306,6 +1306,9 @@ static void print_ht_op(const uint8_t ty
136 printf("\t\t * secondary channel offset: %s\n",
137 ht_secondary_offset[data[1] & 0x3]);
138 printf("\t\t * STA channel width: %s\n", sta_chan_width[(data[1] & 0x4)>>2]);
139 +#ifndef IW_FULL
140 + return;
141 +#endif
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 @@ -1716,6 +1719,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 @@ -1725,26 +1736,20 @@ 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 [51] = { "AP Channel Report", print_ap_channel_report, 1, 255, BIT(PRINT_SCAN), },
167 [59] = { "Supported operating classes", print_supp_op_classes, 1, 255, BIT(PRINT_SCAN), },
168 [66] = { "Measurement Pilot Transmission", print_measurement_pilot_tx, 1, 255, BIT(PRINT_SCAN), },
169 [74] = { "Overlapping BSS scan params", print_obss_scan_params, 14, 255, BIT(PRINT_SCAN), },
170 - [61] = { "HT operation", print_ht_op, 22, 22, BIT(PRINT_SCAN), },
171 - [62] = { "Secondary Channel Offset", print_secchan_offs, 1, 1, BIT(PRINT_SCAN), },
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 - [48] = { "RSN", print_rsn, 2, 255, BIT(PRINT_SCAN), },
175 [50] = { "Extended supported rates", print_supprates, 0, 255, BIT(PRINT_SCAN), },
176 [70] = { "RM enabled capabilities", print_rm_enabled_capabilities, 5, 5, BIT(PRINT_SCAN), },
177 [113] = { "MESH Configuration", print_mesh_conf, 7, 7, BIT(PRINT_SCAN), },
178 - [114] = { "MESH ID", print_ssid, 0, 32, BIT(PRINT_SCAN) | BIT(PRINT_LINK), },
179 [127] = { "Extended capabilities", print_capabilities, 0, 255, BIT(PRINT_SCAN), },
180 [107] = { "802.11u Interworking", print_interworking, 0, 255, BIT(PRINT_SCAN), },
181 [108] = { "802.11u Advertisement", print_11u_advert, 0, 255, BIT(PRINT_SCAN), },
182 [111] = { "802.11u Roaming Consortium", print_11u_rcon, 2, 255, BIT(PRINT_SCAN), },
183 [195] = { "Transmit Power Envelope", print_tx_power_envelope, 2, 5, BIT(PRINT_SCAN), },
184 +#endif
185 };
186
187 static void print_wifi_wpa(const uint8_t type, uint8_t len, const uint8_t *data,
188 @@ -2080,8 +2085,10 @@ static void print_wifi_wps(const uint8_t
189
190 static const struct ie_print wifiprinters[] = {
191 [1] = { "WPA", print_wifi_wpa, 2, 255, BIT(PRINT_SCAN), },
192 +#ifdef IW_FULL
193 [2] = { "WMM", print_wifi_wmm, 1, 255, BIT(PRINT_SCAN), },
194 [4] = { "WPS", print_wifi_wps, 0, 255, BIT(PRINT_SCAN), },
195 +#endif
196 };
197
198 static inline void print_p2p(const uint8_t type, uint8_t len,
199 @@ -2244,6 +2251,10 @@ static void print_vendor(unsigned char l
200 return;
201 }
202
203 +#ifdef IW_FULL
204 + return;
205 +#endif
206 +
207 if (len >= 4 && memcmp(data, wfa_oui, 3) == 0) {
208 if (data[3] < ARRAY_SIZE(wfa_printers) &&
209 wfa_printers[data[3]].name &&
210 @@ -2377,6 +2388,7 @@ static void print_capa_non_dmg(__u16 cap
211 printf(" ESS");
212 if (capa & WLAN_CAPABILITY_IBSS)
213 printf(" IBSS");
214 +#ifdef IW_FULL
215 if (capa & WLAN_CAPABILITY_CF_POLLABLE)
216 printf(" CfPollable");
217 if (capa & WLAN_CAPABILITY_CF_POLL_REQUEST)
218 @@ -2405,6 +2417,7 @@ static void print_capa_non_dmg(__u16 cap
219 printf(" DelayedBACK");
220 if (capa & WLAN_CAPABILITY_IMM_BACK)
221 printf(" ImmediateBACK");
222 +#endif
223 }
224
225 static int print_bss_handler(struct nl_msg *msg, void *arg)
226 @@ -2489,8 +2502,10 @@ static int print_bss_handler(struct nl_m
227 if (bss[NL80211_BSS_FREQUENCY]) {
228 int freq = nla_get_u32(bss[NL80211_BSS_FREQUENCY]);
229 printf("\tfreq: %d\n", freq);
230 +#ifdef IW_FULL
231 if (freq > 45000)
232 is_dmg = true;
233 +#endif
234 }
235 if (bss[NL80211_BSS_BEACON_INTERVAL])
236 printf("\tbeacon interval: %d TUs\n",
237 @@ -2684,6 +2699,7 @@ static int handle_stop_sched_scan(struct
238 return 0;
239 }
240
241 +#ifdef IW_FULL
242 COMMAND(scan, sched_start,
243 SCHED_SCAN_OPTIONS,
244 NL80211_CMD_START_SCHED_SCAN, 0, CIB_NETDEV, handle_start_sched_scan,
245 @@ -2694,3 +2710,4 @@ COMMAND(scan, sched_start,
246 COMMAND(scan, sched_stop, "",
247 NL80211_CMD_STOP_SCHED_SCAN, 0, CIB_NETDEV, handle_stop_sched_scan,
248 "Stop an ongoing scheduled scan.");
249 +#endif
250 --- a/util.c
251 +++ b/util.c
252 @@ -153,6 +153,7 @@ static const char *commands[NL80211_CMD_
253
254 static char cmdbuf[100];
255
256 +#ifdef IW_FULL
257 const char *command_name(enum nl80211_commands cmd)
258 {
259 if (cmd <= NL80211_CMD_MAX && commands[cmd])
260 @@ -160,6 +161,7 @@ const char *command_name(enum nl80211_co
261 sprintf(cmdbuf, "Unknown command (%d)", cmd);
262 return cmdbuf;
263 }
264 +#endif
265
266 int ieee80211_channel_to_frequency(int chan, enum nl80211_band band)
267 {
268 @@ -311,6 +313,9 @@ int parse_keys(struct nl_msg *msg, char
269 char keybuf[13];
270 int pos = 0;
271
272 +#ifndef IW_FULL
273 + return 1;
274 +#endif
275 if (!*argc)
276 return 1;
277
278 --- a/Makefile
279 +++ b/Makefile
280 @@ -23,6 +23,12 @@ _OBJS := $(sort $(patsubst %.c,%.o,$(wil
281 VERSION_OBJS := $(filter-out version.o, $(_OBJS))
282 OBJS := $(VERSION_OBJS) version.o
283
284 +OBJS_FULL = ocb offch cqm wowlan coalesce roc p2p vendor mgmt ap sha256 nan bloom measurements ftm
285 +ifdef IW_FULL
286 + CFLAGS += -DIW_FULL
287 +else
288 + OBJS:=$(filter-out $(patsubst %,%.o,$(OBJS_FULL)),$(OBJS))
289 +endif
290 ALL = iw
291
292 ifeq ($(NO_PKG_CONFIG),)
293 --- a/station.c
294 +++ b/station.c
295 @@ -777,10 +777,12 @@ static int handle_station_set_plink(stru
296 nla_put_failure:
297 return -ENOBUFS;
298 }
299 +#ifdef IW_FULL
300 COMMAND_ALIAS(station, set, "<MAC address> plink_action <open|block>",
301 NL80211_CMD_SET_STATION, 0, CIB_NETDEV, handle_station_set_plink,
302 "Set mesh peer link action for this station (peer).",
303 select_station_cmd, station_set_plink);
304 +#endif
305
306 static int handle_station_set_vlan(struct nl80211_state *state,
307 struct nl_msg *msg,
308 @@ -875,11 +877,13 @@ static int handle_station_set_mesh_power
309 nla_put_failure:
310 return -ENOBUFS;
311 }
312 +#ifdef IW_FULL
313 COMMAND_ALIAS(station, set, "<MAC address> mesh_power_mode "
314 "<active|light|deep>", NL80211_CMD_SET_STATION, 0, CIB_NETDEV,
315 handle_station_set_mesh_power_mode,
316 "Set link-specific mesh power mode for this station",
317 select_station_cmd, station_set_mesh_power_mode);
318 +#endif
319
320 static int handle_station_set_airtime_weight(struct nl80211_state *state,
321 struct nl_msg *msg,
322 --- a/interface.c
323 +++ b/interface.c
324 @@ -627,9 +627,11 @@ static int handle_interface_wds_peer(str
325 nla_put_failure:
326 return -ENOBUFS;
327 }
328 +#ifdef IW_FULL
329 COMMAND(set, peer, "<MAC address>",
330 NL80211_CMD_SET_WDS_PEER, 0, CIB_NETDEV, handle_interface_wds_peer,
331 "Set interface WDS peer.");
332 +#endif
333
334 static int set_mcast_rate(struct nl80211_state *state,
335 struct nl_msg *msg,
336 @@ -719,6 +721,7 @@ static int handle_chan(struct nl80211_st
337 return handle_chanfreq(state, msg, true, argc, argv, id);
338 }
339
340 +#ifdef IW_FULL
341 SECTION(switch);
342 COMMAND(switch, freq,
343 "<freq> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz] [beacons <count>] [block-tx]\n"
344 @@ -990,3 +993,4 @@ COMMAND(set, tidconf, "[peer <MAC addres
345 " $ iw dev wlan0 set tidconf peer xx:xx:xx:xx:xx:xx tids 0x2 bitrates auto\n"
346 " $ iw dev wlan0 set tidconf peer xx:xx:xx:xx:xx:xx tids 0x2 bitrates limit vht-mcs-5 4:9\n"
347 );
348 +#endif
349 --- a/phy.c
350 +++ b/phy.c
351 @@ -369,6 +369,7 @@ err_out:
352 free(cac_trigger_argv);
353 return err;
354 }
355 +#ifdef IW_FULL
356 TOPLEVEL(cac, "channel <channel> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz]\n"
357 "freq <freq> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz]\n"
358 "freq <control freq> [5|10|20|40|80|80+80|160] [<center1_freq> [<center2_freq>]]",
359 @@ -380,6 +381,7 @@ COMMAND(cac, trigger,
360 NL80211_CMD_RADAR_DETECT, 0, CIB_NETDEV, handle_cac_trigger,
361 "Start or trigger a channel availability check (CAC) looking to look for\n"
362 "radars on the given channel.");
363 +#endif
364
365 static int handle_fragmentation(struct nl80211_state *state,
366 struct nl_msg *msg,