58613d59a0b0088b26fe9acee9e8f7b4a4cc199b
[openwrt/staging/dedeckeh.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 @@ -164,6 +164,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 @@ -171,6 +172,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 @@ -213,6 +215,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 @@ -229,6 +232,7 @@ next:
66 printf("\n");
67 }
68 }
69 +#endif
70 }
71 }
72
73 @@ -294,6 +298,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 @@ -305,6 +310,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 @@ -324,11 +330,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 @@ -425,6 +433,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 @@ -522,6 +531,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 @@ -560,6 +570,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 @@ -624,6 +635,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 @@ -732,6 +744,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 @@ -743,6 +756,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 @@ -1195,6 +1195,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 @@ -1522,6 +1525,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 @@ -1531,21 +1542,15 @@ 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 [74] = { "Overlapping BSS scan params", print_obss_scan_params, 14, 255, BIT(PRINT_SCAN), },
185 - [61] = { "HT operation", print_ht_op, 22, 22, BIT(PRINT_SCAN), },
186 - [62] = { "Secondary Channel Offset", print_secchan_offs, 1, 1, BIT(PRINT_SCAN), },
187 - [191] = { "VHT capabilities", print_vht_capa, 12, 255, BIT(PRINT_SCAN), },
188 - [192] = { "VHT operation", print_vht_oper, 5, 255, BIT(PRINT_SCAN), },
189 - [48] = { "RSN", print_rsn, 2, 255, BIT(PRINT_SCAN), },
190 [50] = { "Extended supported rates", print_supprates, 0, 255, BIT(PRINT_SCAN), },
191 [113] = { "MESH Configuration", print_mesh_conf, 7, 7, BIT(PRINT_SCAN), },
192 - [114] = { "MESH ID", print_ssid, 0, 32, BIT(PRINT_SCAN) | BIT(PRINT_LINK), },
193 [127] = { "Extended capabilities", print_capabilities, 0, 255, BIT(PRINT_SCAN), },
194 [107] = { "802.11u Interworking", print_interworking, 0, 255, BIT(PRINT_SCAN), },
195 [108] = { "802.11u Advertisement", print_11u_advert, 0, 255, BIT(PRINT_SCAN), },
196 [111] = { "802.11u Roaming Consortium", print_11u_rcon, 0, 255, BIT(PRINT_SCAN), },
197 +#endif
198 };
199
200 static void print_wifi_wpa(const uint8_t type, uint8_t len, const uint8_t *data,
201 @@ -2024,6 +2029,7 @@ void print_ies(unsigned char *ie, int ie
202 ieprinters[ie[0]].flags & BIT(ptype)) {
203 print_ie(&ieprinters[ie[0]],
204 ie[0], ie[1], ie + 2, &ie_buffer);
205 +#ifdef IW_FULL
206 } else if (ie[0] == 221 /* vendor */) {
207 print_vendor(ie[1], ie + 2, unknown, ptype);
208 } else if (unknown) {
209 @@ -2033,6 +2039,7 @@ void print_ies(unsigned char *ie, int ie
210 for (i=0; i<ie[1]; i++)
211 printf(" %.2x", ie[2+i]);
212 printf("\n");
213 +#endif
214 }
215 ielen -= ie[1] + 2;
216 ie += ie[1] + 2;
217 @@ -2073,6 +2080,7 @@ static void print_capa_non_dmg(__u16 cap
218 printf(" ESS");
219 if (capa & WLAN_CAPABILITY_IBSS)
220 printf(" IBSS");
221 +#ifdef IW_FULL
222 if (capa & WLAN_CAPABILITY_CF_POLLABLE)
223 printf(" CfPollable");
224 if (capa & WLAN_CAPABILITY_CF_POLL_REQUEST)
225 @@ -2101,6 +2109,7 @@ static void print_capa_non_dmg(__u16 cap
226 printf(" DelayedBACK");
227 if (capa & WLAN_CAPABILITY_IMM_BACK)
228 printf(" ImmediateBACK");
229 +#endif
230 }
231
232 static int print_bss_handler(struct nl_msg *msg, void *arg)
233 @@ -2185,8 +2194,10 @@ static int print_bss_handler(struct nl_m
234 if (bss[NL80211_BSS_FREQUENCY]) {
235 int freq = nla_get_u32(bss[NL80211_BSS_FREQUENCY]);
236 printf("\tfreq: %d\n", freq);
237 +#ifdef IW_FULL
238 if (freq > 45000)
239 is_dmg = true;
240 +#endif
241 }
242 if (bss[NL80211_BSS_BEACON_INTERVAL])
243 printf("\tbeacon interval: %d TUs\n",
244 @@ -2380,6 +2391,7 @@ static int handle_stop_sched_scan(struct
245 return 0;
246 }
247
248 +#ifdef IW_FULL
249 COMMAND(scan, sched_start,
250 SCHED_SCAN_OPTIONS,
251 NL80211_CMD_START_SCHED_SCAN, 0, CIB_NETDEV, handle_start_sched_scan,
252 @@ -2390,3 +2402,4 @@ COMMAND(scan, sched_start,
253 COMMAND(scan, sched_stop, "",
254 NL80211_CMD_STOP_SCHED_SCAN, 0, CIB_NETDEV, handle_stop_sched_scan,
255 "Stop an ongoing scheduled scan.");
256 +#endif
257 --- a/util.c
258 +++ b/util.c
259 @@ -153,6 +153,7 @@ static const char *commands[NL80211_CMD_
260
261 static char cmdbuf[100];
262
263 +#ifdef IW_FULL
264 const char *command_name(enum nl80211_commands cmd)
265 {
266 if (cmd <= NL80211_CMD_MAX && commands[cmd])
267 @@ -160,6 +161,7 @@ const char *command_name(enum nl80211_co
268 sprintf(cmdbuf, "Unknown command (%d)", cmd);
269 return cmdbuf;
270 }
271 +#endif
272
273 int ieee80211_channel_to_frequency(int chan, enum nl80211_band band)
274 {
275 @@ -298,6 +300,9 @@ int parse_keys(struct nl_msg *msg, char
276 char keybuf[13];
277 int pos = 0;
278
279 +#ifndef IW_FULL
280 + return 1;
281 +#endif
282 if (!*argc)
283 return 1;
284
285 --- a/Makefile
286 +++ b/Makefile
287 @@ -22,6 +22,12 @@ _OBJS := $(sort $(patsubst %.c,%.o,$(wil
288 VERSION_OBJS := $(filter-out version.o, $(_OBJS))
289 OBJS := $(VERSION_OBJS) version.o
290
291 +OBJS_FULL = ocb offch cqm wowlan coalesce roc p2p vendor mgmt ap sha256 nan bloom measurements ftm
292 +ifdef IW_FULL
293 + CFLAGS += -DIW_FULL
294 +else
295 + OBJS:=$(filter-out $(patsubst %,%.o,$(OBJS_FULL)),$(OBJS))
296 +endif
297 ALL = iw
298
299 ifeq ($(NO_PKG_CONFIG),)
300 --- a/station.c
301 +++ b/station.c
302 @@ -759,10 +759,12 @@ static int handle_station_set_plink(stru
303 nla_put_failure:
304 return -ENOBUFS;
305 }
306 +#ifdef IW_FULL
307 COMMAND_ALIAS(station, set, "<MAC address> plink_action <open|block>",
308 NL80211_CMD_SET_STATION, 0, CIB_NETDEV, handle_station_set_plink,
309 "Set mesh peer link action for this station (peer).",
310 select_station_cmd, station_set_plink);
311 +#endif
312
313 static int handle_station_set_vlan(struct nl80211_state *state,
314 struct nl_msg *msg,
315 @@ -857,11 +859,13 @@ static int handle_station_set_mesh_power
316 nla_put_failure:
317 return -ENOBUFS;
318 }
319 +#ifdef IW_FULL
320 COMMAND_ALIAS(station, set, "<MAC address> mesh_power_mode "
321 "<active|light|deep>", NL80211_CMD_SET_STATION, 0, CIB_NETDEV,
322 handle_station_set_mesh_power_mode,
323 "Set link-specific mesh power mode for this station",
324 select_station_cmd, station_set_mesh_power_mode);
325 +#endif
326
327 static int handle_station_set_airtime_weight(struct nl80211_state *state,
328 struct nl_msg *msg,
329 --- a/interface.c
330 +++ b/interface.c
331 @@ -627,9 +627,11 @@ static int handle_interface_wds_peer(str
332 nla_put_failure:
333 return -ENOBUFS;
334 }
335 +#ifdef IW_FULL
336 COMMAND(set, peer, "<MAC address>",
337 NL80211_CMD_SET_WDS_PEER, 0, CIB_NETDEV, handle_interface_wds_peer,
338 "Set interface WDS peer.");
339 +#endif
340
341 static int set_mcast_rate(struct nl80211_state *state,
342 struct nl_msg *msg,
343 @@ -719,6 +721,7 @@ static int handle_chan(struct nl80211_st
344 return handle_chanfreq(state, msg, true, argc, argv, id);
345 }
346
347 +#ifdef IW_FULL
348 SECTION(switch);
349 COMMAND(switch, freq,
350 "<freq> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz] [beacons <count>] [block-tx]\n"
351 @@ -727,3 +730,4 @@ COMMAND(switch, freq,
352 "Switch the operating channel by sending a channel switch announcement (CSA).");
353 COMMAND(switch, channel, "<channel> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz] [beacons <count>] [block-tx]",
354 NL80211_CMD_CHANNEL_SWITCH, 0, CIB_NETDEV, handle_chan, NULL);
355 +#endif
356 --- a/phy.c
357 +++ b/phy.c
358 @@ -369,6 +369,7 @@ err_out:
359 free(cac_trigger_argv);
360 return err;
361 }
362 +#ifdef IW_FULL
363 TOPLEVEL(cac, "channel <channel> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz]\n"
364 "freq <freq> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz]\n"
365 "freq <control freq> [5|10|20|40|80|80+80|160] [<center1_freq> [<center2_freq>]]",
366 @@ -380,6 +381,7 @@ COMMAND(cac, trigger,
367 NL80211_CMD_RADAR_DETECT, 0, CIB_NETDEV, handle_cac_trigger,
368 "Start or trigger a channel availability check (CAC) looking to look for\n"
369 "radars on the given channel.");
370 +#endif
371
372 static int handle_fragmentation(struct nl80211_state *state,
373 struct nl_msg *msg,