iw: enable print wpa ie for scan
[openwrt/staging/ldir.git] / package / network / utils / iw / patches / 200-reduce_size.patch
1 --- a/event.c
2 +++ b/event.c
3 @@ -956,6 +956,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 @@ -991,6 +992,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 @@ -1073,6 +1075,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 @@ -1271,9 +1274,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 @@ -216,6 +216,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 @@ -232,6 +233,7 @@ next:
50 printf("\n");
51 }
52 }
53 +#endif
54 }
55 }
56
57 @@ -297,6 +299,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 @@ -308,6 +311,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 @@ -327,11 +331,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 @@ -428,6 +434,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 @@ -525,6 +532,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 @@ -563,6 +571,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 @@ -627,6 +636,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 @@ -762,6 +772,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 @@ -773,6 +784,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 @@ -1306,6 +1306,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 @@ -1716,6 +1719,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 @@ -1725,26 +1736,20 @@ 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 [51] = { "AP Channel Report", print_ap_channel_report, 1, 255, BIT(PRINT_SCAN), },
169 [59] = { "Supported operating classes", print_supp_op_classes, 1, 255, BIT(PRINT_SCAN), },
170 [66] = { "Measurement Pilot Transmission", print_measurement_pilot_tx, 1, 255, BIT(PRINT_SCAN), },
171 [74] = { "Overlapping BSS scan params", print_obss_scan_params, 14, 255, BIT(PRINT_SCAN), },
172 - [61] = { "HT operation", print_ht_op, 22, 22, BIT(PRINT_SCAN), },
173 - [62] = { "Secondary Channel Offset", print_secchan_offs, 1, 1, BIT(PRINT_SCAN), },
174 - [191] = { "VHT capabilities", print_vht_capa, 12, 255, BIT(PRINT_SCAN), },
175 - [192] = { "VHT operation", print_vht_oper, 5, 255, BIT(PRINT_SCAN), },
176 - [48] = { "RSN", print_rsn, 2, 255, BIT(PRINT_SCAN), },
177 [50] = { "Extended supported rates", print_supprates, 0, 255, BIT(PRINT_SCAN), },
178 [70] = { "RM enabled capabilities", print_rm_enabled_capabilities, 5, 5, BIT(PRINT_SCAN), },
179 [113] = { "MESH Configuration", print_mesh_conf, 7, 7, BIT(PRINT_SCAN), },
180 - [114] = { "MESH ID", print_ssid, 0, 32, BIT(PRINT_SCAN) | BIT(PRINT_LINK), },
181 [127] = { "Extended capabilities", print_capabilities, 0, 255, BIT(PRINT_SCAN), },
182 [107] = { "802.11u Interworking", print_interworking, 0, 255, BIT(PRINT_SCAN), },
183 [108] = { "802.11u Advertisement", print_11u_advert, 0, 255, BIT(PRINT_SCAN), },
184 [111] = { "802.11u Roaming Consortium", print_11u_rcon, 2, 255, BIT(PRINT_SCAN), },
185 [195] = { "Transmit Power Envelope", print_tx_power_envelope, 2, 5, BIT(PRINT_SCAN), },
186 +#endif
187 };
188
189 static void print_wifi_wpa(const uint8_t type, uint8_t len, const uint8_t *data,
190 @@ -2080,8 +2085,10 @@ static void print_wifi_wps(const uint8_t
191
192 static const struct ie_print wifiprinters[] = {
193 [1] = { "WPA", print_wifi_wpa, 2, 255, BIT(PRINT_SCAN), },
194 +#ifdef IW_FULL
195 [2] = { "WMM", print_wifi_wmm, 1, 255, BIT(PRINT_SCAN), },
196 [4] = { "WPS", print_wifi_wps, 0, 255, BIT(PRINT_SCAN), },
197 +#endif
198 };
199
200 static inline void print_p2p(const uint8_t type, uint8_t len,
201 @@ -2244,6 +2251,10 @@ static void print_vendor(unsigned char l
202 return;
203 }
204
205 +#ifdef IW_FULL
206 + return;
207 +#endif
208 +
209 if (len >= 4 && memcmp(data, wfa_oui, 3) == 0) {
210 if (data[3] < ARRAY_SIZE(wfa_printers) &&
211 wfa_printers[data[3]].name &&
212 @@ -2377,6 +2388,7 @@ static void print_capa_non_dmg(__u16 cap
213 printf(" ESS");
214 if (capa & WLAN_CAPABILITY_IBSS)
215 printf(" IBSS");
216 +#ifdef IW_FULL
217 if (capa & WLAN_CAPABILITY_CF_POLLABLE)
218 printf(" CfPollable");
219 if (capa & WLAN_CAPABILITY_CF_POLL_REQUEST)
220 @@ -2405,6 +2417,7 @@ static void print_capa_non_dmg(__u16 cap
221 printf(" DelayedBACK");
222 if (capa & WLAN_CAPABILITY_IMM_BACK)
223 printf(" ImmediateBACK");
224 +#endif
225 }
226
227 static int print_bss_handler(struct nl_msg *msg, void *arg)
228 @@ -2489,8 +2502,10 @@ static int print_bss_handler(struct nl_m
229 if (bss[NL80211_BSS_FREQUENCY]) {
230 int freq = nla_get_u32(bss[NL80211_BSS_FREQUENCY]);
231 printf("\tfreq: %d\n", freq);
232 +#ifdef IW_FULL
233 if (freq > 45000)
234 is_dmg = true;
235 +#endif
236 }
237 if (bss[NL80211_BSS_BEACON_INTERVAL])
238 printf("\tbeacon interval: %d TUs\n",
239 @@ -2684,6 +2699,7 @@ static int handle_stop_sched_scan(struct
240 return 0;
241 }
242
243 +#ifdef IW_FULL
244 COMMAND(scan, sched_start,
245 SCHED_SCAN_OPTIONS,
246 NL80211_CMD_START_SCHED_SCAN, 0, CIB_NETDEV, handle_start_sched_scan,
247 @@ -2694,3 +2710,4 @@ COMMAND(scan, sched_start,
248 COMMAND(scan, sched_stop, "",
249 NL80211_CMD_STOP_SCHED_SCAN, 0, CIB_NETDEV, handle_stop_sched_scan,
250 "Stop an ongoing scheduled scan.");
251 +#endif
252 --- a/util.c
253 +++ b/util.c
254 @@ -153,6 +153,7 @@ static const char *commands[NL80211_CMD_
255
256 static char cmdbuf[100];
257
258 +#ifdef IW_FULL
259 const char *command_name(enum nl80211_commands cmd)
260 {
261 if (cmd <= NL80211_CMD_MAX && commands[cmd])
262 @@ -160,6 +161,7 @@ const char *command_name(enum nl80211_co
263 sprintf(cmdbuf, "Unknown command (%d)", cmd);
264 return cmdbuf;
265 }
266 +#endif
267
268 int ieee80211_channel_to_frequency(int chan, enum nl80211_band band)
269 {
270 @@ -311,6 +313,9 @@ int parse_keys(struct nl_msg *msg, char
271 char keybuf[13];
272 int pos = 0;
273
274 +#ifndef IW_FULL
275 + return 1;
276 +#endif
277 if (!*argc)
278 return 1;
279
280 --- a/Makefile
281 +++ b/Makefile
282 @@ -23,6 +23,12 @@ _OBJS := $(sort $(patsubst %.c,%.o,$(wil
283 VERSION_OBJS := $(filter-out version.o, $(_OBJS))
284 OBJS := $(VERSION_OBJS) version.o
285
286 +OBJS_FULL = ocb offch cqm wowlan coalesce roc p2p vendor mgmt ap sha256 nan bloom measurements ftm
287 +ifdef IW_FULL
288 + CFLAGS += -DIW_FULL
289 +else
290 + OBJS:=$(filter-out $(patsubst %,%.o,$(OBJS_FULL)),$(OBJS))
291 +endif
292 ALL = iw
293
294 ifeq ($(NO_PKG_CONFIG),)
295 --- a/station.c
296 +++ b/station.c
297 @@ -777,10 +777,12 @@ static int handle_station_set_plink(stru
298 nla_put_failure:
299 return -ENOBUFS;
300 }
301 +#ifdef IW_FULL
302 COMMAND_ALIAS(station, set, "<MAC address> plink_action <open|block>",
303 NL80211_CMD_SET_STATION, 0, CIB_NETDEV, handle_station_set_plink,
304 "Set mesh peer link action for this station (peer).",
305 select_station_cmd, station_set_plink);
306 +#endif
307
308 static int handle_station_set_vlan(struct nl80211_state *state,
309 struct nl_msg *msg,
310 @@ -875,11 +877,13 @@ static int handle_station_set_mesh_power
311 nla_put_failure:
312 return -ENOBUFS;
313 }
314 +#ifdef IW_FULL
315 COMMAND_ALIAS(station, set, "<MAC address> mesh_power_mode "
316 "<active|light|deep>", NL80211_CMD_SET_STATION, 0, CIB_NETDEV,
317 handle_station_set_mesh_power_mode,
318 "Set link-specific mesh power mode for this station",
319 select_station_cmd, station_set_mesh_power_mode);
320 +#endif
321
322 static int handle_station_set_airtime_weight(struct nl80211_state *state,
323 struct nl_msg *msg,
324 --- a/interface.c
325 +++ b/interface.c
326 @@ -627,9 +627,11 @@ static int handle_interface_wds_peer(str
327 nla_put_failure:
328 return -ENOBUFS;
329 }
330 +#ifdef IW_FULL
331 COMMAND(set, peer, "<MAC address>",
332 NL80211_CMD_SET_WDS_PEER, 0, CIB_NETDEV, handle_interface_wds_peer,
333 "Set interface WDS peer.");
334 +#endif
335
336 static int set_mcast_rate(struct nl80211_state *state,
337 struct nl_msg *msg,
338 @@ -719,6 +721,7 @@ static int handle_chan(struct nl80211_st
339 return handle_chanfreq(state, msg, true, argc, argv, id);
340 }
341
342 +#ifdef IW_FULL
343 SECTION(switch);
344 COMMAND(switch, freq,
345 "<freq> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz] [beacons <count>] [block-tx]\n"
346 @@ -990,3 +993,4 @@ COMMAND(set, tidconf, "[peer <MAC addres
347 " $ iw dev wlan0 set tidconf peer xx:xx:xx:xx:xx:xx tids 0x2 bitrates auto\n"
348 " $ iw dev wlan0 set tidconf peer xx:xx:xx:xx:xx:xx tids 0x2 bitrates limit vht-mcs-5 4:9\n"
349 );
350 +#endif
351 --- a/phy.c
352 +++ b/phy.c
353 @@ -369,6 +369,7 @@ err_out:
354 free(cac_trigger_argv);
355 return err;
356 }
357 +#ifdef IW_FULL
358 TOPLEVEL(cac, "channel <channel> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz]\n"
359 "freq <freq> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz]\n"
360 "freq <control freq> [5|10|20|40|80|80+80|160] [<center1_freq> [<center2_freq>]]",
361 @@ -380,6 +381,7 @@ COMMAND(cac, trigger,
362 NL80211_CMD_RADAR_DETECT, 0, CIB_NETDEV, handle_cac_trigger,
363 "Start or trigger a channel availability check (CAC) looking to look for\n"
364 "radars on the given channel.");
365 +#endif
366
367 static int handle_fragmentation(struct nl80211_state *state,
368 struct nl_msg *msg,