blob: c0599c9a7c16c08b20fcd0562c801be1c4b60bf4 [file] [log] [blame]
Johannes Berg748f8482009-05-24 16:48:17 +02001#include <ctype.h>
Johannes Berg51e9bd82009-07-08 00:44:25 +02002#include <netlink/attr.h>
3#include <errno.h>
4#include <stdbool.h>
Luis Carlos Cobo3d1e8702008-04-01 12:03:41 -07005#include "iw.h"
Johannes Bergf5f7b1d2009-04-08 13:01:18 +02006#include "nl80211.h"
Luis Carlos Cobo3d1e8702008-04-01 12:03:41 -07007
Johannes Bergfebeb0c2009-07-25 17:31:08 +02008void mac_addr_n2a(char *mac_addr, unsigned char *arg)
Luis Carlos Cobo3d1e8702008-04-01 12:03:41 -07009{
Johannes Berg53e5ce72008-04-02 16:49:50 +020010 int i, l;
Luis Carlos Cobo3d1e8702008-04-01 12:03:41 -070011
12 l = 0;
13 for (i = 0; i < ETH_ALEN ; i++) {
14 if (i == 0) {
Johannes Berg53e5ce72008-04-02 16:49:50 +020015 sprintf(mac_addr+l, "%02x", arg[i]);
Luis Carlos Cobo3d1e8702008-04-01 12:03:41 -070016 l += 2;
17 } else {
Johannes Berg53e5ce72008-04-02 16:49:50 +020018 sprintf(mac_addr+l, ":%02x", arg[i]);
Luis Carlos Cobo3d1e8702008-04-01 12:03:41 -070019 l += 3;
20 }
21 }
Luis Carlos Cobo3d1e8702008-04-01 12:03:41 -070022}
23
24int mac_addr_a2n(unsigned char *mac_addr, char *arg)
25{
26 int i;
27
28 for (i = 0; i < ETH_ALEN ; i++) {
29 int temp;
30 char *cp = strchr(arg, ':');
31 if (cp) {
32 *cp = 0;
33 cp++;
34 }
35 if (sscanf(arg, "%x", &temp) != 1)
36 return -1;
37 if (temp < 0 || temp > 255)
38 return -1;
39
40 mac_addr[i] = temp;
41 if (!cp)
42 break;
43 arg = cp;
44 }
45 if (i < ETH_ALEN - 1)
46 return -1;
47
48 return 0;
49}
Johannes Berg541ef422008-09-16 14:50:11 +020050
Johannes Berg3ff24562011-04-12 13:04:50 +020051int parse_hex_mask(char *hexmask, unsigned char **result, size_t *result_len,
52 unsigned char **mask)
Johannes Berg236d4192010-03-24 23:38:15 -070053{
Johannes Berg3ff24562011-04-12 13:04:50 +020054 size_t len = strlen(hexmask) / 2;
55 unsigned char *result_val;
56 unsigned char *result_mask = NULL;
57
Johannes Berg236d4192010-03-24 23:38:15 -070058 int pos = 0;
59
Johannes Berg3ff24562011-04-12 13:04:50 +020060 *result_len = 0;
Johannes Berg236d4192010-03-24 23:38:15 -070061
Johannes Berg3ff24562011-04-12 13:04:50 +020062 result_val = calloc(len + 2, 1);
63 if (!result_val)
64 goto error;
65 *result = result_val;
66 if (mask) {
67 result_mask = calloc(DIV_ROUND_UP(len, 8) + 2, 1);
68 if (!result_mask)
69 goto error;
70 *mask = result_mask;
71 }
Johannes Berg236d4192010-03-24 23:38:15 -070072
73 while (1) {
Johannes Berg3ff24562011-04-12 13:04:50 +020074 char *cp = strchr(hexmask, ':');
Johannes Berg236d4192010-03-24 23:38:15 -070075 if (cp) {
76 *cp = 0;
77 cp++;
78 }
Johannes Berg236d4192010-03-24 23:38:15 -070079
Johannes Berg3ff24562011-04-12 13:04:50 +020080 if (result_mask && (strcmp(hexmask, "-") == 0 ||
81 strcmp(hexmask, "xx") == 0 ||
82 strcmp(hexmask, "--") == 0)) {
83 /* skip this byte and leave mask bit unset */
84 } else {
85 int temp, mask_pos;
86 char *end;
Johannes Berg236d4192010-03-24 23:38:15 -070087
Johannes Berg3ff24562011-04-12 13:04:50 +020088 temp = strtoul(hexmask, &end, 16);
89 if (*end)
90 goto error;
91 if (temp < 0 || temp > 255)
92 goto error;
93 result_val[pos] = temp;
94
95 mask_pos = pos / 8;
96 if (result_mask)
97 result_mask[mask_pos] |= 1 << (pos % 8);
98 }
99
100 (*result_len)++;
101 pos++;
102
Johannes Berg236d4192010-03-24 23:38:15 -0700103 if (!cp)
104 break;
Johannes Berg3ff24562011-04-12 13:04:50 +0200105 hexmask = cp;
Johannes Berg236d4192010-03-24 23:38:15 -0700106 }
107
Johannes Berg3ff24562011-04-12 13:04:50 +0200108 return 0;
Johannes Berg236d4192010-03-24 23:38:15 -0700109 error:
Johannes Berg3ff24562011-04-12 13:04:50 +0200110 free(result_val);
111 free(result_mask);
112 return -1;
113}
114
115unsigned char *parse_hex(char *hex, size_t *outlen)
116{
117 unsigned char *result;
118
119 if (parse_hex_mask(hex, &result, outlen, NULL))
120 return NULL;
121 return result;
Johannes Berg236d4192010-03-24 23:38:15 -0700122}
123
Johannes Berg541ef422008-09-16 14:50:11 +0200124static const char *ifmodes[NL80211_IFTYPE_MAX + 1] = {
125 "unspecified",
126 "IBSS",
Johannes Berg34e78ed2009-04-19 15:47:18 +0200127 "managed",
Johannes Berg541ef422008-09-16 14:50:11 +0200128 "AP",
Johannes Berg34e78ed2009-04-19 15:47:18 +0200129 "AP/VLAN",
Johannes Berg541ef422008-09-16 14:50:11 +0200130 "WDS",
Johannes Berg34e78ed2009-04-19 15:47:18 +0200131 "monitor",
Johannes Berga4464242010-09-29 14:45:28 +0200132 "mesh point",
133 "P2P-client",
134 "P2P-GO",
Johannes Berg541ef422008-09-16 14:50:11 +0200135};
136
137static char modebuf[100];
138
139const char *iftype_name(enum nl80211_iftype iftype)
140{
141 if (iftype <= NL80211_IFTYPE_MAX)
142 return ifmodes[iftype];
143 sprintf(modebuf, "Unknown mode (%d)", iftype);
144 return modebuf;
145}
Johannes Berg379f8392008-12-08 12:53:58 +0100146
Marcel Holtmann9990c1e2009-11-14 20:10:21 +0100147static const char *commands[NL80211_CMD_MAX + 1] = {
Johannes Berg06339492010-02-18 11:54:53 +0100148 [NL80211_CMD_GET_WIPHY] = "get_wiphy",
149 [NL80211_CMD_SET_WIPHY] = "set_wiphy",
150 [NL80211_CMD_NEW_WIPHY] = "new_wiphy",
151 [NL80211_CMD_DEL_WIPHY] = "del_wiphy",
152 [NL80211_CMD_GET_INTERFACE] = "get_interface",
153 [NL80211_CMD_SET_INTERFACE] = "set_interface",
154 [NL80211_CMD_NEW_INTERFACE] = "new_interface",
155 [NL80211_CMD_DEL_INTERFACE] = "del_interface",
156 [NL80211_CMD_GET_KEY] = "get_key",
157 [NL80211_CMD_SET_KEY] = "set_key",
158 [NL80211_CMD_NEW_KEY] = "new_key",
159 [NL80211_CMD_DEL_KEY] = "del_key",
160 [NL80211_CMD_GET_BEACON] = "get_beacon",
161 [NL80211_CMD_SET_BEACON] = "set_beacon",
162 [NL80211_CMD_NEW_BEACON] = "new_beacon",
163 [NL80211_CMD_DEL_BEACON] = "del_beacon",
164 [NL80211_CMD_GET_STATION] = "get_station",
165 [NL80211_CMD_SET_STATION] = "set_station",
166 [NL80211_CMD_NEW_STATION] = "new_station",
167 [NL80211_CMD_DEL_STATION] = "del_station",
168 [NL80211_CMD_GET_MPATH] = "get_mpath",
169 [NL80211_CMD_SET_MPATH] = "set_mpath",
170 [NL80211_CMD_NEW_MPATH] = "new_mpath",
171 [NL80211_CMD_DEL_MPATH] = "del_mpath",
172 [NL80211_CMD_SET_BSS] = "set_bss",
173 [NL80211_CMD_SET_REG] = "set_reg",
174 [NL80211_CMD_REQ_SET_REG] = "reg_set_reg",
175 [NL80211_CMD_GET_MESH_PARAMS] = "get_mesh_params",
176 [NL80211_CMD_SET_MESH_PARAMS] = "set_mesh_params",
177 [NL80211_CMD_SET_MGMT_EXTRA_IE] = "set_mgmt_extra_ie",
178 [NL80211_CMD_GET_REG] = "get_reg",
179 [NL80211_CMD_GET_SCAN] = "get_scan",
180 [NL80211_CMD_TRIGGER_SCAN] = "trigger_scan",
181 [NL80211_CMD_NEW_SCAN_RESULTS] = "new_scan_results",
182 [NL80211_CMD_SCAN_ABORTED] = "scan_aborted",
183 [NL80211_CMD_REG_CHANGE] = "reg_change",
184 [NL80211_CMD_AUTHENTICATE] = "authenticate",
185 [NL80211_CMD_ASSOCIATE] = "associate",
186 [NL80211_CMD_DEAUTHENTICATE] = "deauthenticate",
187 [NL80211_CMD_DISASSOCIATE] = "disassociate",
188 [NL80211_CMD_MICHAEL_MIC_FAILURE] = "michael_mic_failure",
189 [NL80211_CMD_REG_BEACON_HINT] = "reg_beacon_hint",
190 [NL80211_CMD_JOIN_IBSS] = "join_ibss",
191 [NL80211_CMD_LEAVE_IBSS] = "leave_ibss",
192 [NL80211_CMD_TESTMODE] = "testmode",
193 [NL80211_CMD_CONNECT] = "connect",
194 [NL80211_CMD_ROAM] = "roam",
195 [NL80211_CMD_DISCONNECT] = "disconnect",
196 [NL80211_CMD_SET_WIPHY_NETNS] = "set_wiphy_netns",
197 [NL80211_CMD_GET_SURVEY] = "get_survey",
198 [NL80211_CMD_SET_PMKSA] = "set_pmksa",
199 [NL80211_CMD_DEL_PMKSA] = "del_pmksa",
200 [NL80211_CMD_FLUSH_PMKSA] = "flush_pmksa",
201 [NL80211_CMD_REMAIN_ON_CHANNEL] = "remain_on_channel",
202 [NL80211_CMD_CANCEL_REMAIN_ON_CHANNEL] = "cancel_remain_on_channel",
203 [NL80211_CMD_SET_TX_BITRATE_MASK] = "set_tx_bitrate_mask",
204 [NL80211_CMD_REGISTER_ACTION] = "register_action",
205 [NL80211_CMD_ACTION] = "action",
Bruno Randolf7b96e9e2010-05-12 17:27:41 +0900206 [NL80211_CMD_SET_CHANNEL] = "set_channel",
Johannes Bergdcf57032011-01-17 16:46:03 +0100207 [NL80211_CMD_SET_WDS_PEER] = "set_wds_peer",
208 [NL80211_CMD_FRAME_WAIT_CANCEL] = "frame_wait_cancel",
209 [NL80211_CMD_JOIN_MESH] = "join_mesh",
210 [NL80211_CMD_LEAVE_MESH] = "leave_mesh",
Marcel Holtmann9990c1e2009-11-14 20:10:21 +0100211};
212
213static char cmdbuf[100];
214
215const char *command_name(enum nl80211_commands cmd)
216{
Johannes Berg73780392010-01-29 14:48:54 +0100217 if (cmd <= NL80211_CMD_MAX && commands[cmd])
Marcel Holtmann9990c1e2009-11-14 20:10:21 +0100218 return commands[cmd];
219 sprintf(cmdbuf, "Unknown command (%d)", cmd);
220 return cmdbuf;
221}
222
Johannes Berg379f8392008-12-08 12:53:58 +0100223int ieee80211_channel_to_frequency(int chan)
224{
225 if (chan < 14)
226 return 2407 + chan * 5;
227
228 if (chan == 14)
229 return 2484;
230
231 /* FIXME: dot11ChannelStartingFactor (802.11-2007 17.3.8.3.2) */
232 return (chan + 1000) * 5;
233}
234
235int ieee80211_frequency_to_channel(int freq)
236{
237 if (freq == 2484)
238 return 14;
239
240 if (freq < 2484)
241 return (freq - 2407) / 5;
242
243 /* FIXME: dot11ChannelStartingFactor (802.11-2007 17.3.8.3.2) */
244 return freq/5 - 1000;
245}
Johannes Berg748f8482009-05-24 16:48:17 +0200246
247void print_ssid_escaped(const uint8_t len, const uint8_t *data)
248{
249 int i;
250
251 for (i = 0; i < len; i++) {
252 if (isprint(data[i]))
253 printf("%c", data[i]);
254 else
255 printf("\\x%.2x", data[i]);
256 }
257}
Johannes Berg51e9bd82009-07-08 00:44:25 +0200258
259static int hex2num(char digit)
260{
261 if (!isxdigit(digit))
262 return -1;
263 if (isdigit(digit))
264 return digit - '0';
265 return tolower(digit) - 'a' + 10;
266}
267
268static int hex2byte(char *hex)
269{
270 int d1, d2;
271
272 d1 = hex2num(hex[0]);
273 if (d1 < 0)
274 return -1;
275 d2 = hex2num(hex[1]);
276 if (d2 < 0)
277 return -1;
278 return (d1 << 4) | d2;
279}
280
281static char *hex2bin(char *hex, char *buf)
282{
283 char *result = buf;
284 int d;
285
286 while (hex[0]) {
287 d = hex2byte(hex);
288 if (d < 0)
289 return NULL;
290 buf[0] = d;
291 buf++;
292 hex += 2;
293 }
294
295 return result;
296}
297
298int parse_keys(struct nl_msg *msg, char **argv, int argc)
299{
300 struct nlattr *keys;
301 int i = 0;
Johannes Berg041581c2009-08-16 15:17:38 +0200302 bool have_default = false;
Johannes Berg51e9bd82009-07-08 00:44:25 +0200303 char keybuf[13];
304
305 if (!argc)
306 return 1;
307
308 NLA_PUT_FLAG(msg, NL80211_ATTR_PRIVACY);
309
310 keys = nla_nest_start(msg, NL80211_ATTR_KEYS);
311 if (!keys)
312 return -ENOBUFS;
313
314 do {
315 char *arg = *argv;
316 int pos = 0, keylen;
317 struct nlattr *key = nla_nest_start(msg, ++i);
318 char *keydata;
319
320 if (!key)
321 return -ENOBUFS;
322
323 if (arg[pos] == 'd') {
324 NLA_PUT_FLAG(msg, NL80211_KEY_DEFAULT);
325 pos++;
326 if (arg[pos] == ':')
327 pos++;
Johannes Berg041581c2009-08-16 15:17:38 +0200328 have_default = true;
Johannes Berg51e9bd82009-07-08 00:44:25 +0200329 }
330
331 if (!isdigit(arg[pos]))
332 goto explain;
333 NLA_PUT_U8(msg, NL80211_KEY_IDX, arg[pos++] - '0');
334 if (arg[pos++] != ':')
335 goto explain;
336 keydata = arg + pos;
337 switch (strlen(keydata)) {
338 case 10:
339 keydata = hex2bin(keydata, keybuf);
340 case 5:
341 NLA_PUT_U32(msg, NL80211_KEY_CIPHER, 0x000FAC01);
342 keylen = 5;
343 break;
344 case 26:
345 keydata = hex2bin(keydata, keybuf);
346 case 13:
347 NLA_PUT_U32(msg, NL80211_KEY_CIPHER, 0x000FAC05);
348 keylen = 13;
349 break;
350 default:
351 goto explain;
352 }
353
354 if (!keydata)
355 goto explain;
356
357 NLA_PUT(msg, NL80211_KEY_DATA, keylen, keydata);
358
Johannes Berg51e9bd82009-07-08 00:44:25 +0200359 argv++;
360 argc--;
Johannes Berg041581c2009-08-16 15:17:38 +0200361
362 /* one key should be TX key */
363 if (!have_default && !argc)
364 NLA_PUT_FLAG(msg, NL80211_KEY_DEFAULT);
365
366 nla_nest_end(msg, key);
Johannes Berg51e9bd82009-07-08 00:44:25 +0200367 } while (argc);
368
369 nla_nest_end(msg, keys);
370
371 return 0;
372 nla_put_failure:
373 return -ENOBUFS;
374 explain:
375 fprintf(stderr, "key must be [d:]index:data where\n"
376 " 'd:' means default (transmit) key\n"
377 " 'index:' is a single digit (0-3)\n"
378 " 'data' must be 5 or 13 ascii chars\n"
379 " or 10 or 26 hex digits\n"
380 "for example: d:2:6162636465 is the same as d:2:abcde\n");
381 return 2;
382}
Luis R. Rodriguezdeb35012009-12-07 21:13:56 -0500383
Johannes Berg7ddfb672009-12-08 10:11:22 +0100384static void print_mcs_index(const __u8 *mcs)
Luis R. Rodriguezdeb35012009-12-07 21:13:56 -0500385{
Johannes Berg04953e92009-12-08 09:58:20 +0100386 unsigned int mcs_bit, prev_bit = -2, prev_cont = 0;
Luis R. Rodriguezdeb35012009-12-07 21:13:56 -0500387
Johannes Berg04953e92009-12-08 09:58:20 +0100388 for (mcs_bit = 0; mcs_bit <= 76; mcs_bit++) {
389 unsigned int mcs_octet = mcs_bit/8;
390 unsigned int MCS_RATE_BIT = 1 << mcs_bit % 8;
391 bool mcs_rate_idx_set;
392
393 mcs_rate_idx_set = !!(mcs[mcs_octet] & MCS_RATE_BIT);
394
395 if (!mcs_rate_idx_set)
396 continue;
397
398 if (prev_bit != mcs_bit - 1) {
399 if (prev_bit != -2)
400 printf("%d, ", prev_bit);
401 else
402 printf(" ");
403 printf("%d", mcs_bit);
404 prev_cont = 0;
405 } else if (!prev_cont) {
406 printf("-");
407 prev_cont = 1;
408 }
409
410 prev_bit = mcs_bit;
411 }
412
413 if (prev_cont)
414 printf("%d", prev_bit);
415 printf("\n");
Luis R. Rodriguezdeb35012009-12-07 21:13:56 -0500416}
Luis R. Rodriguez09509932009-12-07 22:05:18 -0500417
418/*
419 * There are only 4 possible values, we just use a case instead of computing it,
420 * but technically this can also be computed through the formula:
421 *
422 * Max AMPDU length = (2 ^ (13 + exponent)) - 1 bytes
423 */
424static __u32 compute_ampdu_length(__u8 exponent)
425{
426 switch (exponent) {
427 case 0: return 8191; /* (2 ^(13 + 0)) -1 */
428 case 1: return 16383; /* (2 ^(13 + 1)) -1 */
429 case 2: return 32767; /* (2 ^(13 + 2)) -1 */
430 case 3: return 65535; /* (2 ^(13 + 3)) -1 */
431 default: return 0;
432 }
433}
434
435static const char *print_ampdu_space(__u8 space)
436{
437 switch (space) {
438 case 0: return "No restriction";
439 case 1: return "1/4 usec";
440 case 2: return "1/2 usec";
441 case 3: return "1 usec";
442 case 4: return "2 usec";
443 case 5: return "4 usec";
444 case 6: return "8 usec";
445 case 7: return "16 usec";
446 default:
Johannes Berg7ae93cd2009-12-08 10:19:51 +0100447 return "BUG (spacing more than 3 bits!)";
Luis R. Rodriguez09509932009-12-07 22:05:18 -0500448 }
449}
450
451void print_ampdu_length(__u8 exponent)
452{
Johannes Berg04953e92009-12-08 09:58:20 +0100453 __u32 max_ampdu_length;
Luis R. Rodriguez09509932009-12-07 22:05:18 -0500454
455 max_ampdu_length = compute_ampdu_length(exponent);
456
457 if (max_ampdu_length) {
458 printf("\t\tMaximum RX AMPDU length %d bytes (exponent: 0x0%02x)\n",
459 max_ampdu_length, exponent);
460 } else {
461 printf("\t\tMaximum RX AMPDU length: unrecognized bytes "
462 "(exponent: %d)\n", exponent);
463 }
464}
465
466void print_ampdu_spacing(__u8 spacing)
467{
468 printf("\t\tMinimum RX AMPDU time spacing: %s (0x%02x)\n",
469 print_ampdu_space(spacing), spacing);
470}
Luis R. Rodriguez357c1a52009-12-07 22:05:42 -0500471
472void print_ht_capability(__u16 cap)
473{
474#define PRINT_HT_CAP(_cond, _str) \
475 do { \
476 if (_cond) \
477 printf("\t\t\t" _str "\n"); \
478 } while (0)
479
480 printf("\t\tCapabilities: 0x%02x\n", cap);
481
Luis R. Rodriguez028c0de2010-04-08 16:10:25 -0400482 PRINT_HT_CAP((cap & BIT(0)), "RX LDPC");
Luis R. Rodriguez357c1a52009-12-07 22:05:42 -0500483 PRINT_HT_CAP((cap & BIT(1)), "HT20/HT40");
484 PRINT_HT_CAP(!(cap & BIT(1)), "HT20");
485
486 PRINT_HT_CAP(((cap >> 2) & 0x3) == 0, "Static SM Power Save");
487 PRINT_HT_CAP(((cap >> 2) & 0x3) == 1, "Dynamic SM Power Save");
488 PRINT_HT_CAP(((cap >> 2) & 0x3) == 3, "SM Power Save disabled");
489
490 PRINT_HT_CAP((cap & BIT(4)), "RX Greenfield");
491 PRINT_HT_CAP((cap & BIT(5)), "RX HT20 SGI");
492 PRINT_HT_CAP((cap & BIT(6)), "RX HT40 SGI");
493 PRINT_HT_CAP((cap & BIT(7)), "TX STBC");
494
495 PRINT_HT_CAP(((cap >> 8) & 0x3) == 0, "No RX STBC");
496 PRINT_HT_CAP(((cap >> 8) & 0x3) == 1, "RX STBC 1-stream");
497 PRINT_HT_CAP(((cap >> 8) & 0x3) == 2, "RX STBC 2-streams");
498 PRINT_HT_CAP(((cap >> 8) & 0x3) == 3, "RX STBC 3-streams");
499
500 PRINT_HT_CAP((cap & BIT(10)), "HT Delayed Block Ack");
501
Christian Lamparterc79c7462010-06-27 00:51:23 +0200502 PRINT_HT_CAP(!(cap & BIT(11)), "Max AMSDU length: 3839 bytes");
503 PRINT_HT_CAP((cap & BIT(11)), "Max AMSDU length: 7935 bytes");
Luis R. Rodriguez357c1a52009-12-07 22:05:42 -0500504
505 /*
506 * For beacons and probe response this would mean the BSS
507 * does or does not allow the usage of DSSS/CCK HT40.
508 * Otherwise it means the STA does or does not use
509 * DSSS/CCK HT40.
510 */
511 PRINT_HT_CAP((cap & BIT(12)), "DSSS/CCK HT40");
512 PRINT_HT_CAP(!(cap & BIT(12)), "No DSSS/CCK HT40");
513
514 /* BIT(13) is reserved */
515
516 PRINT_HT_CAP((cap & BIT(14)), "40 MHz Intolerant");
517
518 PRINT_HT_CAP((cap & BIT(15)), "L-SIG TXOP protection");
519#undef PRINT_HT_CAP
520}
Johannes Berg7ddfb672009-12-08 10:11:22 +0100521
522void print_ht_mcs(const __u8 *mcs)
523{
524 /* As defined in 7.3.2.57.4 Supported MCS Set field */
525 unsigned int tx_max_num_spatial_streams, max_rx_supp_data_rate;
526 bool tx_mcs_set_defined, tx_mcs_set_equal, tx_unequal_modulation;
527
528 max_rx_supp_data_rate = ((mcs[10] >> 8) & ((mcs[11] & 0x3) << 8));
529 tx_mcs_set_defined = !!(mcs[12] & (1 << 0));
530 tx_mcs_set_equal = !(mcs[12] & (1 << 1));
531 tx_max_num_spatial_streams = ((mcs[12] >> 2) & 3) + 1;
532 tx_unequal_modulation = !!(mcs[12] & (1 << 4));
533
534 if (max_rx_supp_data_rate)
535 printf("\t\tHT Max RX data rate: %d Mbps\n", max_rx_supp_data_rate);
536 /* XXX: else see 9.6.0e.5.3 how to get this I think */
537
538 if (tx_mcs_set_defined) {
539 if (tx_mcs_set_equal) {
Johannes Berg2a79feb2009-12-08 17:17:19 +0100540 printf("\t\tHT TX/RX MCS rate indexes supported:");
Johannes Berg7ddfb672009-12-08 10:11:22 +0100541 print_mcs_index(mcs);
542 } else {
543 printf("\t\tHT RX MCS rate indexes supported:");
544 print_mcs_index(mcs);
545
546 if (tx_unequal_modulation)
547 printf("\t\tTX unequal modulation supported\n");
548 else
549 printf("\t\tTX unequal modulation not supported\n");
550
551 printf("\t\tHT TX Max spatial streams: %d\n",
552 tx_max_num_spatial_streams);
553
554 printf("\t\tHT TX MCS rate indexes supported may differ\n");
555 }
556 } else {
557 printf("\t\tHT RX MCS rate indexes supported:");
558 print_mcs_index(mcs);
Johannes Berg089bb352009-12-08 17:59:07 +0100559 printf("\t\tHT TX MCS rate indexes are undefined\n");
Johannes Berg7ddfb672009-12-08 10:11:22 +0100560 }
561}