5 #include <netlink/genl/genl.h>
6 #include <netlink/genl/family.h>
7 #include <netlink/genl/ctrl.h>
8 #include <netlink/msg.h>
9 #include <netlink/attr.h>
14 #define VALID_FLAGS "none: no special flags\n"\
15 "fcsfail: show frames with FCS errors\n"\
16 "control: show control frames\n"\
17 "otherbss: show frames from other BSSes\n"\
18 "cook: use cooked mode\n"\
19 "active: use active mode (ACK incoming unicast packets)\n"\
20 "mumimo-groupid <GROUP_ID>: use MUMIMO according to a group id\n"\
21 "mumimo-follow-mac <MAC_ADDRESS>: use MUMIMO according to a MAC address"
25 static char *mntr_flags
[NL80211_MNTR_FLAG_MAX
+ 1] = {
35 static int parse_mumimo_options(int *_argc
, char ***_argv
, struct nl_msg
*msg
)
37 uint8_t mumimo_group
[VHT_MUMIMO_GROUP_LEN
];
38 unsigned char mac_addr
[ETH_ALEN
];
44 if (strcmp(*argv
, "mumimo-groupid") == 0) {
47 if (!argc
|| strlen(*argv
) != VHT_MUMIMO_GROUP_LEN
*2) {
48 fprintf(stderr
, "Invalid groupID: %s\n", *argv
);
52 for (i
= 0; i
< VHT_MUMIMO_GROUP_LEN
; i
++) {
53 if (sscanf((*argv
) + i
*2, "%2x", &val
) != 1) {
54 fprintf(stderr
, "Failed reading groupID\n");
57 mumimo_group
[i
] = val
;
61 NL80211_ATTR_MU_MIMO_GROUP_DATA
,
66 } else if (strcmp(*argv
, "mumimo-follow-mac") == 0) {
69 if (!argc
|| mac_addr_a2n(mac_addr
, *argv
)) {
70 fprintf(stderr
, "Invalid MAC address\n");
73 NLA_PUT(msg
, NL80211_ATTR_MU_MIMO_FOLLOW_MAC_ADDR
,
84 static int parse_mntr_flags(int *_argc
, char ***_argv
,
89 enum nl80211_mntr_flags flag
;
93 flags
= nlmsg_alloc();
100 /* parse MU-MIMO options */
101 err
= parse_mumimo_options(&argc
, &argv
, msg
);
107 /* parse monitor flags */
108 for (flag
= __NL80211_MNTR_FLAG_INVALID
;
109 flag
<= NL80211_MNTR_FLAG_MAX
; flag
++) {
110 if (strcmp(*argv
, mntr_flags
[flag
]) == 0) {
113 * This shouldn't be adding "flag" if that is
114 * zero, but due to a problem in the kernel's
115 * nl80211 code (using NLA_NESTED policy) it
116 * will reject an empty nested attribute but
117 * not one that contains an invalid attribute
119 NLA_PUT_FLAG(flags
, flag
);
131 nla_put_nested(msg
, NL80211_ATTR_MNTR_FLAGS
, flags
);
144 #define IFACE_TYPES "Valid interface types are: managed, ibss, monitor, mesh, wds."
146 /* return 0 if ok, internal error otherwise */
147 static int get_if_type(int *argc
, char ***argv
, enum nl80211_iftype
*type
,
152 if (*argc
< 1 + !!need_type
)
155 if (need_type
&& strcmp((*argv
)[0], "type"))
158 tpstr
= (*argv
)[!!need_type
];
159 *argc
-= 1 + !!need_type
;
160 *argv
+= 1 + !!need_type
;
162 if (strcmp(tpstr
, "adhoc") == 0 ||
163 strcmp(tpstr
, "ibss") == 0) {
164 *type
= NL80211_IFTYPE_ADHOC
;
166 } else if (strcmp(tpstr
, "ocb") == 0) {
167 *type
= NL80211_IFTYPE_OCB
;
169 } else if (strcmp(tpstr
, "monitor") == 0) {
170 *type
= NL80211_IFTYPE_MONITOR
;
172 } else if (strcmp(tpstr
, "master") == 0 ||
173 strcmp(tpstr
, "ap") == 0) {
174 *type
= NL80211_IFTYPE_UNSPECIFIED
;
175 fprintf(stderr
, "You need to run a management daemon, e.g. hostapd,\n");
176 fprintf(stderr
, "see http://wireless.kernel.org/en/users/Documentation/hostapd\n");
177 fprintf(stderr
, "for more information on how to do that.\n");
179 } else if (strcmp(tpstr
, "__ap") == 0) {
180 *type
= NL80211_IFTYPE_AP
;
182 } else if (strcmp(tpstr
, "__ap_vlan") == 0) {
183 *type
= NL80211_IFTYPE_AP_VLAN
;
185 } else if (strcmp(tpstr
, "wds") == 0) {
186 *type
= NL80211_IFTYPE_WDS
;
188 } else if (strcmp(tpstr
, "managed") == 0 ||
189 strcmp(tpstr
, "mgd") == 0 ||
190 strcmp(tpstr
, "station") == 0) {
191 *type
= NL80211_IFTYPE_STATION
;
193 } else if (strcmp(tpstr
, "mp") == 0 ||
194 strcmp(tpstr
, "mesh") == 0) {
195 *type
= NL80211_IFTYPE_MESH_POINT
;
197 } else if (strcmp(tpstr
, "__p2pcl") == 0) {
198 *type
= NL80211_IFTYPE_P2P_CLIENT
;
200 } else if (strcmp(tpstr
, "__p2pdev") == 0) {
201 *type
= NL80211_IFTYPE_P2P_DEVICE
;
203 } else if (strcmp(tpstr
, "__p2pgo") == 0) {
204 *type
= NL80211_IFTYPE_P2P_GO
;
206 } else if (strcmp(tpstr
, "__nan") == 0) {
207 *type
= NL80211_IFTYPE_NAN
;
211 fprintf(stderr
, "invalid interface type %s\n", tpstr
);
215 static int parse_4addr_flag(const char *value
, struct nl_msg
*msg
)
217 if (strcmp(value
, "on") == 0)
218 NLA_PUT_U8(msg
, NL80211_ATTR_4ADDR
, 1);
219 else if (strcmp(value
, "off") == 0)
220 NLA_PUT_U8(msg
, NL80211_ATTR_4ADDR
, 0);
229 static int handle_interface_add(struct nl80211_state
*state
,
231 int argc
, char **argv
,
235 char *mesh_id
= NULL
;
236 enum nl80211_iftype type
;
238 unsigned char mac_addr
[ETH_ALEN
];
248 tpset
= get_if_type(&argc
, &argv
, &type
, true);
254 if (strcmp(argv
[0], "mesh_id") == 0) {
263 } else if (strcmp(argv
[0], "addr") == 0) {
266 if (mac_addr_a2n(mac_addr
, argv
[0])) {
267 fprintf(stderr
, "Invalid MAC address\n");
274 } else if (strcmp(argv
[0], "4addr") == 0) {
277 if (parse_4addr_flag(argv
[0], msg
)) {
278 fprintf(stderr
, "4addr error\n");
283 } else if (strcmp(argv
[0], "flags") == 0) {
286 if (parse_mntr_flags(&argc
, &argv
, msg
)) {
287 fprintf(stderr
, "flags error\n");
298 NLA_PUT_STRING(msg
, NL80211_ATTR_IFNAME
, name
);
299 NLA_PUT_U32(msg
, NL80211_ATTR_IFTYPE
, type
);
301 NLA_PUT(msg
, NL80211_ATTR_MESH_ID
, strlen(mesh_id
), mesh_id
);
303 NLA_PUT(msg
, NL80211_ATTR_MAC
, ETH_ALEN
, mac_addr
);
309 COMMAND(interface
, add
, "<name> type <type> [mesh_id <meshid>] [4addr on|off] [flags <flag>*] [addr <mac-addr>]",
310 NL80211_CMD_NEW_INTERFACE
, 0, CIB_PHY
, handle_interface_add
,
311 "Add a new virtual interface with the given configuration.\n"
313 "The flags are only used for monitor interfaces, valid flags are:\n"
315 "The mesh_id is used only for mesh mode.");
316 COMMAND(interface
, add
, "<name> type <type> [mesh_id <meshid>] [4addr on|off] [flags <flag>*] [addr <mac-addr>]",
317 NL80211_CMD_NEW_INTERFACE
, 0, CIB_NETDEV
, handle_interface_add
, NULL
);
319 static int handle_interface_del(struct nl80211_state
*state
,
321 int argc
, char **argv
,
326 TOPLEVEL(del
, NULL
, NL80211_CMD_DEL_INTERFACE
, 0, CIB_NETDEV
, handle_interface_del
,
327 "Remove this virtual interface");
328 HIDDEN(interface
, del
, NULL
, NL80211_CMD_DEL_INTERFACE
, 0, CIB_NETDEV
, handle_interface_del
);
330 static char *channel_type_name(enum nl80211_channel_type channel_type
)
332 switch (channel_type
) {
333 case NL80211_CHAN_NO_HT
:
335 case NL80211_CHAN_HT20
:
337 case NL80211_CHAN_HT40MINUS
:
339 case NL80211_CHAN_HT40PLUS
:
346 char *channel_width_name(enum nl80211_chan_width width
)
349 case NL80211_CHAN_WIDTH_20_NOHT
:
350 return "20 MHz (no HT)";
351 case NL80211_CHAN_WIDTH_20
:
353 case NL80211_CHAN_WIDTH_40
:
355 case NL80211_CHAN_WIDTH_80
:
357 case NL80211_CHAN_WIDTH_80P80
:
359 case NL80211_CHAN_WIDTH_160
:
361 case NL80211_CHAN_WIDTH_5
:
363 case NL80211_CHAN_WIDTH_10
:
365 case NL80211_CHAN_WIDTH_320
:
372 static void print_channel(struct nlattr
**tb
)
374 uint32_t freq
= nla_get_u32(tb
[NL80211_ATTR_WIPHY_FREQ
]);
376 printf("channel %d (%d MHz)",
377 ieee80211_frequency_to_channel(freq
), freq
);
379 if (tb
[NL80211_ATTR_CHANNEL_WIDTH
]) {
380 printf(", width: %s",
381 channel_width_name(nla_get_u32(tb
[NL80211_ATTR_CHANNEL_WIDTH
])));
382 if (tb
[NL80211_ATTR_CENTER_FREQ1
])
383 printf(", center1: %d MHz",
384 nla_get_u32(tb
[NL80211_ATTR_CENTER_FREQ1
]));
385 if (tb
[NL80211_ATTR_CENTER_FREQ2
])
386 printf(", center2: %d MHz",
387 nla_get_u32(tb
[NL80211_ATTR_CENTER_FREQ2
]));
389 if (tb
[NL80211_ATTR_PUNCT_BITMAP
]) {
390 uint32_t punct
= nla_get_u32(tb
[NL80211_ATTR_PUNCT_BITMAP
]);
393 printf(", punctured: 0x%x", punct
);
395 } else if (tb
[NL80211_ATTR_WIPHY_CHANNEL_TYPE
]) {
396 enum nl80211_channel_type channel_type
;
398 channel_type
= nla_get_u32(tb
[NL80211_ATTR_WIPHY_CHANNEL_TYPE
]);
399 printf(" %s", channel_type_name(channel_type
));
403 static int print_iface_handler(struct nl_msg
*msg
, void *arg
)
405 struct genlmsghdr
*gnlh
= nlmsg_data(nlmsg_hdr(msg
));
406 struct nlattr
*tb_msg
[NL80211_ATTR_MAX
+ 1];
407 unsigned int *wiphy
= arg
;
408 const char *indent
= "";
410 nla_parse(tb_msg
, NL80211_ATTR_MAX
, genlmsg_attrdata(gnlh
, 0),
411 genlmsg_attrlen(gnlh
, 0), NULL
);
413 if (wiphy
&& tb_msg
[NL80211_ATTR_WIPHY
]) {
414 unsigned int thiswiphy
= nla_get_u32(tb_msg
[NL80211_ATTR_WIPHY
]);
416 if (*wiphy
!= thiswiphy
)
417 printf("phy#%d\n", thiswiphy
);
421 if (tb_msg
[NL80211_ATTR_IFNAME
])
422 printf("%sInterface %s\n", indent
, nla_get_string(tb_msg
[NL80211_ATTR_IFNAME
]));
424 printf("%sUnnamed/non-netdev interface\n", indent
);
425 if (tb_msg
[NL80211_ATTR_IFINDEX
])
426 printf("%s\tifindex %d\n", indent
, nla_get_u32(tb_msg
[NL80211_ATTR_IFINDEX
]));
427 if (tb_msg
[NL80211_ATTR_WDEV
])
428 printf("%s\twdev 0x%llx\n", indent
,
429 (unsigned long long)nla_get_u64(tb_msg
[NL80211_ATTR_WDEV
]));
430 if (tb_msg
[NL80211_ATTR_MAC
]) {
432 mac_addr_n2a(mac_addr
, nla_data(tb_msg
[NL80211_ATTR_MAC
]));
433 printf("%s\taddr %s\n", indent
, mac_addr
);
435 if (tb_msg
[NL80211_ATTR_SSID
]) {
436 printf("%s\tssid ", indent
);
437 print_ssid_escaped(nla_len(tb_msg
[NL80211_ATTR_SSID
]),
438 nla_data(tb_msg
[NL80211_ATTR_SSID
]));
441 if (tb_msg
[NL80211_ATTR_IFTYPE
])
442 printf("%s\ttype %s\n", indent
, iftype_name(nla_get_u32(tb_msg
[NL80211_ATTR_IFTYPE
])));
443 if (!wiphy
&& tb_msg
[NL80211_ATTR_WIPHY
])
444 printf("%s\twiphy %d\n", indent
, nla_get_u32(tb_msg
[NL80211_ATTR_WIPHY
]));
445 if (tb_msg
[NL80211_ATTR_WIPHY_FREQ
]) {
446 printf("%s\t", indent
);
447 print_channel(tb_msg
);
451 if (tb_msg
[NL80211_ATTR_WIPHY_TX_POWER_LEVEL
]) {
452 int32_t txp
= nla_get_u32(tb_msg
[NL80211_ATTR_WIPHY_TX_POWER_LEVEL
]);
454 printf("%s\ttxpower %d.%.2d dBm\n",
455 indent
, txp
/ 100, txp
% 100);
458 if (tb_msg
[NL80211_ATTR_TXQ_STATS
]) {
460 parse_txq_stats(buf
, sizeof(buf
), tb_msg
[NL80211_ATTR_TXQ_STATS
], 1, -1, indent
);
461 printf("%s\tmulticast TXQ:%s\n", indent
, buf
);
464 if (tb_msg
[NL80211_ATTR_4ADDR
]) {
465 uint8_t use_4addr
= nla_get_u8(tb_msg
[NL80211_ATTR_4ADDR
]);
467 printf("%s\t4addr: on\n", indent
);
470 if (tb_msg
[NL80211_ATTR_MLO_LINKS
]) {
474 printf("%s\tMLD with links:\n", indent
);
476 nla_for_each_nested(link
, tb_msg
[NL80211_ATTR_MLO_LINKS
], n
) {
477 struct nlattr
*tb
[NL80211_ATTR_MAX
+ 1];
479 nla_parse_nested(tb
, NL80211_ATTR_MAX
, link
, NULL
);
480 printf("%s\t - link", indent
);
481 if (tb
[NL80211_ATTR_MLO_LINK_ID
])
482 printf(" ID %2d", nla_get_u32(tb
[NL80211_ATTR_MLO_LINK_ID
]));
483 if (tb
[NL80211_ATTR_MAC
]) {
486 mac_addr_n2a(buf
, nla_data(tb
[NL80211_ATTR_MAC
]));
487 printf(" link addr %s", buf
);
489 if (tb
[NL80211_ATTR_WIPHY_FREQ
]) {
490 printf("\n%s\t ", indent
);
493 if (tb
[NL80211_ATTR_WIPHY_TX_POWER_LEVEL
]) {
494 int32_t txp
= nla_get_u32(tb
[NL80211_ATTR_WIPHY_TX_POWER_LEVEL
]);
496 printf("\n%s\t txpower %d.%.2d dBm", indent
, txp
/ 100, txp
% 100);
505 static int handle_interface_info(struct nl80211_state
*state
,
507 int argc
, char **argv
,
510 register_handler(print_iface_handler
, NULL
);
513 TOPLEVEL(info
, NULL
, NL80211_CMD_GET_INTERFACE
, 0, CIB_NETDEV
, handle_interface_info
,
514 "Show information for this interface.");
516 static int handle_interface_set(struct nl80211_state
*state
,
518 int argc
, char **argv
,
524 NLA_PUT_U32(msg
, NL80211_ATTR_IFTYPE
, NL80211_IFTYPE_MONITOR
);
526 switch (parse_mntr_flags(&argc
, &argv
, msg
)) {
532 fprintf(stderr
, "failed to allocate flags\n");
535 fprintf(stderr
, "unknown flag %s\n", *argv
);
543 COMMAND(set
, monitor
, "<flag>*",
544 NL80211_CMD_SET_INTERFACE
, 0, CIB_NETDEV
, handle_interface_set
,
545 "Set monitor flags. Valid flags are:\n"
548 static int handle_interface_meshid(struct nl80211_state
*state
,
550 int argc
, char **argv
,
553 char *mesh_id
= NULL
;
560 NLA_PUT(msg
, NL80211_ATTR_MESH_ID
, strlen(mesh_id
), mesh_id
);
566 COMMAND(set
, meshid
, "<meshid>",
567 NL80211_CMD_SET_INTERFACE
, 0, CIB_NETDEV
, handle_interface_meshid
, NULL
);
569 static unsigned int dev_dump_wiphy
;
571 static int handle_dev_dump(struct nl80211_state
*state
,
573 int argc
, char **argv
,
577 register_handler(print_iface_handler
, &dev_dump_wiphy
);
580 TOPLEVEL(dev
, NULL
, NL80211_CMD_GET_INTERFACE
, NLM_F_DUMP
, CIB_NONE
, handle_dev_dump
,
581 "List all network interfaces for wireless hardware.");
583 static int handle_interface_type(struct nl80211_state
*state
,
585 int argc
, char **argv
,
588 enum nl80211_iftype type
;
591 tpset
= get_if_type(&argc
, &argv
, &type
, false);
598 NLA_PUT_U32(msg
, NL80211_ATTR_IFTYPE
, type
);
604 COMMAND(set
, type
, "<type>",
605 NL80211_CMD_SET_INTERFACE
, 0, CIB_NETDEV
, handle_interface_type
,
606 "Set interface type/mode.\n"
609 static int handle_interface_4addr(struct nl80211_state
*state
,
611 int argc
, char **argv
,
616 return parse_4addr_flag(argv
[0], msg
);
618 COMMAND(set
, 4addr
, "<on|off>",
619 NL80211_CMD_SET_INTERFACE
, 0, CIB_NETDEV
, handle_interface_4addr
,
620 "Set interface 4addr (WDS) mode.");
622 static int handle_interface_noack_map(struct nl80211_state
*state
,
624 int argc
, char **argv
,
633 noack_map
= strtoul(argv
[0], &end
, 16);
637 NLA_PUT_U16(msg
, NL80211_ATTR_NOACK_MAP
, noack_map
);
644 COMMAND(set
, noack_map
, "<map>",
645 NL80211_CMD_SET_NOACK_MAP
, 0, CIB_NETDEV
, handle_interface_noack_map
,
646 "Set the NoAck map for the TIDs. (0x0009 = BE, 0x0006 = BK, 0x0030 = VI, 0x00C0 = VO)");
649 static int handle_interface_wds_peer(struct nl80211_state
*state
,
651 int argc
, char **argv
,
654 unsigned char mac_addr
[ETH_ALEN
];
659 if (mac_addr_a2n(mac_addr
, argv
[0])) {
660 fprintf(stderr
, "Invalid MAC address\n");
670 NLA_PUT(msg
, NL80211_ATTR_MAC
, ETH_ALEN
, mac_addr
);
676 COMMAND(set
, peer
, "<MAC address>",
677 NL80211_CMD_SET_WDS_PEER
, 0, CIB_NETDEV
, handle_interface_wds_peer
,
678 "Set interface WDS peer.");
680 static int set_mcast_rate(struct nl80211_state
*state
,
682 int argc
, char **argv
,
691 rate
= strtod(argv
[0], &end
);
695 NLA_PUT_U32(msg
, NL80211_ATTR_MCAST_RATE
, (int)(rate
* 10));
702 COMMAND(set
, mcast_rate
, "<rate in Mbps>",
703 NL80211_CMD_SET_MCAST_RATE
, 0, CIB_NETDEV
, set_mcast_rate
,
704 "Set the multicast bitrate.");
707 static int handle_chanfreq(struct nl80211_state
*state
, struct nl_msg
*msg
,
708 bool chan
, int argc
, char **argv
,
711 struct chandef chandef
;
716 res
= parse_freqchan(&chandef
, chan
, argc
, argv
, &parsed
, false);
724 unsigned int beacons
= 10;
726 if (strcmp(argv
[0], "beacons") == 0) {
730 beacons
= strtol(argv
[1], &end
, 10);
737 NLA_PUT_U32(msg
, NL80211_ATTR_CH_SWITCH_COUNT
, beacons
);
738 } else if (strcmp(argv
[0], "block-tx") == 0) {
742 NLA_PUT_FLAG(msg
, NL80211_ATTR_CH_SWITCH_BLOCK_TX
);
748 return put_chandef(msg
, &chandef
);
754 static int handle_freq(struct nl80211_state
*state
, struct nl_msg
*msg
,
755 int argc
, char **argv
,
758 return handle_chanfreq(state
, msg
, false, argc
, argv
, id
);
761 static int handle_chan(struct nl80211_state
*state
, struct nl_msg
*msg
,
762 int argc
, char **argv
,
765 return handle_chanfreq(state
, msg
, true, argc
, argv
, id
);
769 COMMAND(switch, freq
,
770 "<freq> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz] [beacons <count>] [block-tx]\n"
771 "<control freq> [5|10|20|40|80|80+80|160] [<center1_freq> [<center2_freq>]] [beacons <count>] [block-tx]",
772 NL80211_CMD_CHANNEL_SWITCH
, 0, CIB_NETDEV
, handle_freq
,
773 "Switch the operating channel by sending a channel switch announcement (CSA).");
774 COMMAND(switch, channel
, "<channel> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz] [beacons <count>] [block-tx]",
775 NL80211_CMD_CHANNEL_SWITCH
, 0, CIB_NETDEV
, handle_chan
, NULL
);
778 static int toggle_tid_param(const char *argv0
, const char *argv1
,
779 struct nl_msg
*msg
, uint32_t attr
)
783 if (strcmp(argv1
, "on") == 0) {
784 val
= NL80211_TID_CONFIG_ENABLE
;
785 } else if (strcmp(argv1
, "off") == 0) {
786 val
= NL80211_TID_CONFIG_DISABLE
;
788 fprintf(stderr
, "Invalid %s parameter: %s\n", argv0
, argv1
);
792 NLA_PUT_U8(msg
, attr
, val
);
799 static int handle_tid_config(struct nl80211_state
*state
,
801 int argc
, char **argv
,
804 struct nlattr
*tids_array
= NULL
;
805 struct nlattr
*tids_entry
= NULL
;
806 enum nl80211_tx_rate_setting txrate_type
;
807 unsigned char peer
[ETH_ALEN
];
815 } parse_state
= PS_ADDR
;
819 switch (parse_state
) {
821 if (strcmp(argv
[0], "peer") == 0) {
823 fprintf(stderr
, "Not enough args for %s\n", argv
[0]);
824 return HANDLER_RET_USAGE
;
827 if (mac_addr_a2n(peer
, argv
[1])) {
828 fprintf(stderr
, "Invalid MAC address\n");
832 NLA_PUT(msg
, NL80211_ATTR_MAC
, ETH_ALEN
, peer
);
836 parse_state
= PS_TIDS
;
838 } else if (strcmp(argv
[0], "tids") == 0) {
839 parse_state
= PS_TIDS
;
841 fprintf(stderr
, "Peer MAC address expected\n");
842 return HANDLER_RET_USAGE
;
847 if (strcmp(argv
[0], "tids") == 0) {
849 fprintf(stderr
, "not enough args for %s\n", argv
[0]);
850 return HANDLER_RET_USAGE
;
854 tids_array
= nla_nest_start(msg
, NL80211_ATTR_TID_CONFIG
);
860 nla_nest_end(msg
, tids_entry
);
864 tids_entry
= nla_nest_start(msg
, tids_num
);
868 NLA_PUT_U16(msg
, NL80211_TID_CONFIG_ATTR_TIDS
, strtol(argv
[1], &end
, 0));
870 fprintf(stderr
, "Invalid TID mask value: %s\n", argv
[1]);
876 parse_state
= PS_CONF
;
878 fprintf(stderr
, "TID mask expected\n");
879 return HANDLER_RET_USAGE
;
884 if (strcmp(argv
[0], "tids") == 0) {
885 parse_state
= PS_TIDS
;
886 } else if (strcmp(argv
[0], "override") == 0) {
887 NLA_PUT_FLAG(msg
, NL80211_TID_CONFIG_ATTR_OVERRIDE
);
891 } else if (strcmp(argv
[0], "ampdu") == 0) {
893 fprintf(stderr
, "not enough args for %s\n", argv
[0]);
894 return HANDLER_RET_USAGE
;
897 ret
= toggle_tid_param(argv
[0], argv
[1], msg
,
898 NL80211_TID_CONFIG_ATTR_AMPDU_CTRL
);
904 } else if (strcmp(argv
[0], "amsdu") == 0) {
906 fprintf(stderr
, "not enough args for %s\n", argv
[0]);
907 return HANDLER_RET_USAGE
;
910 ret
= toggle_tid_param(argv
[0], argv
[1], msg
,
911 NL80211_TID_CONFIG_ATTR_AMSDU_CTRL
);
917 } else if (strcmp(argv
[0], "noack") == 0) {
919 fprintf(stderr
, "not enough args for %s\n", argv
[0]);
920 return HANDLER_RET_USAGE
;
923 ret
= toggle_tid_param(argv
[0], argv
[1], msg
,
924 NL80211_TID_CONFIG_ATTR_NOACK
);
930 } else if (strcmp(argv
[0], "rtscts") == 0) {
932 fprintf(stderr
, "not enough args for %s\n", argv
[0]);
933 return HANDLER_RET_USAGE
;
936 ret
= toggle_tid_param(argv
[0], argv
[1], msg
,
937 NL80211_TID_CONFIG_ATTR_RTSCTS_CTRL
);
943 } else if (strcmp(argv
[0], "sretry") == 0) {
945 fprintf(stderr
, "not enough args for %s\n", argv
[0]);
946 return HANDLER_RET_USAGE
;
949 NLA_PUT_U8(msg
, NL80211_TID_CONFIG_ATTR_RETRY_SHORT
, strtol(argv
[1], &end
, 0));
951 fprintf(stderr
, "Invalid short_retry value: %s\n", argv
[1]);
957 } else if (strcmp(argv
[0], "lretry") == 0) {
959 fprintf(stderr
, "not enough args for %s\n", argv
[0]);
960 return HANDLER_RET_USAGE
;
963 NLA_PUT_U8(msg
, NL80211_TID_CONFIG_ATTR_RETRY_LONG
, strtol(argv
[1], &end
, 0));
965 fprintf(stderr
, "Invalid long_retry value: %s\n", argv
[1]);
971 } else if (strcmp(argv
[0], "bitrates") == 0) {
973 fprintf(stderr
, "not enough args for %s\n", argv
[0]);
974 return HANDLER_RET_USAGE
;
976 if (!strcmp(argv
[1], "auto"))
977 txrate_type
= NL80211_TX_RATE_AUTOMATIC
;
978 else if (!strcmp(argv
[1], "fixed"))
979 txrate_type
= NL80211_TX_RATE_FIXED
;
980 else if (!strcmp(argv
[1], "limit"))
981 txrate_type
= NL80211_TX_RATE_LIMITED
;
983 printf("Invalid parameter: %s\n", argv
[0]);
986 NLA_PUT_U8(msg
, NL80211_TID_CONFIG_ATTR_TX_RATE_TYPE
, txrate_type
);
989 if (txrate_type
!= NL80211_TX_RATE_AUTOMATIC
) {
990 attr
= NL80211_TID_CONFIG_ATTR_TX_RATE
;
991 ret
= set_bitrates(msg
, argc
, argv
,
1000 fprintf(stderr
, "Unknown parameter: %s\n", argv
[0]);
1001 return HANDLER_RET_USAGE
;
1006 fprintf(stderr
, "Failed to parse: internal failure\n");
1007 return HANDLER_RET_USAGE
;
1012 nla_nest_end(msg
, tids_entry
);
1015 nla_nest_end(msg
, tids_array
);
1023 COMMAND(set
, tidconf
, "[peer <MAC address>] tids <mask> [override] [sretry <num>] [lretry <num>] "
1024 "[ampdu [on|off]] [amsdu [on|off]] [noack [on|off]] [rtscts [on|off]]"
1025 "[bitrates <type [auto|fixed|limit]> [legacy-<2.4|5> <legacy rate in Mbps>*] [ht-mcs-<2.4|5> <MCS index>*]"
1026 " [vht-mcs-<2.4|5> <NSS:MCSx,MCSy... | NSS:MCSx-MCSy>*] [sgi-2.4|lgi-2.4] [sgi-5|lgi-5]]",
1027 NL80211_CMD_SET_TID_CONFIG
, 0, CIB_NETDEV
, handle_tid_config
,
1028 "Setup per-node TID specific configuration for TIDs selected by bitmask.\n"
1029 "If MAC address is not specified, then supplied TID configuration\n"
1030 "applied to all the peers.\n"
1032 " $ iw dev wlan0 set tidconf tids 0x1 ampdu off\n"
1033 " $ iw dev wlan0 set tidconf tids 0x5 ampdu off amsdu off rtscts on\n"
1034 " $ iw dev wlan0 set tidconf tids 0x3 override ampdu on noack on rtscts on\n"
1035 " $ iw dev wlan0 set tidconf peer xx:xx:xx:xx:xx:xx tids 0x1 ampdu off tids 0x3 amsdu off rtscts on\n"
1036 " $ iw dev wlan0 set tidconf peer xx:xx:xx:xx:xx:xx tids 0x2 bitrates auto\n"
1037 " $ iw dev wlan0 set tidconf peer xx:xx:xx:xx:xx:xx tids 0x2 bitrates limit vht-mcs-5 4:9\n"
1040 static int handle_set_epcs(struct nl80211_state
*state
,
1042 int argc
, char **argv
,
1048 if (strcmp(argv
[0], "enable") == 0)
1049 NLA_PUT_FLAG(msg
, NL80211_ATTR_EPCS
);
1050 else if (strcmp(argv
[0], "disable") != 0)
1059 COMMAND(set
, epcs
, "<enable|disable>",
1060 NL80211_CMD_EPCS_CFG
, 0, CIB_NETDEV
, handle_set_epcs
,
1061 "Enable/Disable EPCS support");