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
]));
388 } else if (tb
[NL80211_ATTR_WIPHY_CHANNEL_TYPE
]) {
389 enum nl80211_channel_type channel_type
;
391 channel_type
= nla_get_u32(tb
[NL80211_ATTR_WIPHY_CHANNEL_TYPE
]);
392 printf(" %s", channel_type_name(channel_type
));
396 static int print_iface_handler(struct nl_msg
*msg
, void *arg
)
398 struct genlmsghdr
*gnlh
= nlmsg_data(nlmsg_hdr(msg
));
399 struct nlattr
*tb_msg
[NL80211_ATTR_MAX
+ 1];
400 unsigned int *wiphy
= arg
;
401 const char *indent
= "";
403 nla_parse(tb_msg
, NL80211_ATTR_MAX
, genlmsg_attrdata(gnlh
, 0),
404 genlmsg_attrlen(gnlh
, 0), NULL
);
406 if (wiphy
&& tb_msg
[NL80211_ATTR_WIPHY
]) {
407 unsigned int thiswiphy
= nla_get_u32(tb_msg
[NL80211_ATTR_WIPHY
]);
409 if (*wiphy
!= thiswiphy
)
410 printf("phy#%d\n", thiswiphy
);
414 if (tb_msg
[NL80211_ATTR_IFNAME
])
415 printf("%sInterface %s\n", indent
, nla_get_string(tb_msg
[NL80211_ATTR_IFNAME
]));
417 printf("%sUnnamed/non-netdev interface\n", indent
);
418 if (tb_msg
[NL80211_ATTR_IFINDEX
])
419 printf("%s\tifindex %d\n", indent
, nla_get_u32(tb_msg
[NL80211_ATTR_IFINDEX
]));
420 if (tb_msg
[NL80211_ATTR_WDEV
])
421 printf("%s\twdev 0x%llx\n", indent
,
422 (unsigned long long)nla_get_u64(tb_msg
[NL80211_ATTR_WDEV
]));
423 if (tb_msg
[NL80211_ATTR_MAC
]) {
425 mac_addr_n2a(mac_addr
, nla_data(tb_msg
[NL80211_ATTR_MAC
]));
426 printf("%s\taddr %s\n", indent
, mac_addr
);
428 if (tb_msg
[NL80211_ATTR_SSID
]) {
429 printf("%s\tssid ", indent
);
430 print_ssid_escaped(nla_len(tb_msg
[NL80211_ATTR_SSID
]),
431 nla_data(tb_msg
[NL80211_ATTR_SSID
]));
434 if (tb_msg
[NL80211_ATTR_IFTYPE
])
435 printf("%s\ttype %s\n", indent
, iftype_name(nla_get_u32(tb_msg
[NL80211_ATTR_IFTYPE
])));
436 if (!wiphy
&& tb_msg
[NL80211_ATTR_WIPHY
])
437 printf("%s\twiphy %d\n", indent
, nla_get_u32(tb_msg
[NL80211_ATTR_WIPHY
]));
438 if (tb_msg
[NL80211_ATTR_WIPHY_FREQ
]) {
439 printf("%s\t", indent
);
440 print_channel(tb_msg
);
444 if (tb_msg
[NL80211_ATTR_WIPHY_TX_POWER_LEVEL
]) {
445 int32_t txp
= nla_get_u32(tb_msg
[NL80211_ATTR_WIPHY_TX_POWER_LEVEL
]);
447 printf("%s\ttxpower %d.%.2d dBm\n",
448 indent
, txp
/ 100, txp
% 100);
451 if (tb_msg
[NL80211_ATTR_TXQ_STATS
]) {
453 parse_txq_stats(buf
, sizeof(buf
), tb_msg
[NL80211_ATTR_TXQ_STATS
], 1, -1, indent
);
454 printf("%s\tmulticast TXQ:%s\n", indent
, buf
);
457 if (tb_msg
[NL80211_ATTR_4ADDR
]) {
458 uint8_t use_4addr
= nla_get_u8(tb_msg
[NL80211_ATTR_4ADDR
]);
460 printf("%s\t4addr: on\n", indent
);
463 if (tb_msg
[NL80211_ATTR_MLO_LINKS
]) {
467 printf("%s\tMLD with links:\n", indent
);
469 nla_for_each_nested(link
, tb_msg
[NL80211_ATTR_MLO_LINKS
], n
) {
470 struct nlattr
*tb
[NL80211_ATTR_MAX
+ 1];
472 nla_parse_nested(tb
, NL80211_ATTR_MAX
, link
, NULL
);
473 printf("%s\t - link", indent
);
474 if (tb
[NL80211_ATTR_MLO_LINK_ID
])
475 printf(" ID %2d", nla_get_u32(tb
[NL80211_ATTR_MLO_LINK_ID
]));
476 if (tb
[NL80211_ATTR_MAC
]) {
479 mac_addr_n2a(buf
, nla_data(tb
[NL80211_ATTR_MAC
]));
480 printf(" link addr %s", buf
);
482 if (tb
[NL80211_ATTR_WIPHY_FREQ
]) {
483 printf("\n%s\t ", indent
);
493 static int handle_interface_info(struct nl80211_state
*state
,
495 int argc
, char **argv
,
498 register_handler(print_iface_handler
, NULL
);
501 TOPLEVEL(info
, NULL
, NL80211_CMD_GET_INTERFACE
, 0, CIB_NETDEV
, handle_interface_info
,
502 "Show information for this interface.");
504 static int handle_interface_set(struct nl80211_state
*state
,
506 int argc
, char **argv
,
512 NLA_PUT_U32(msg
, NL80211_ATTR_IFTYPE
, NL80211_IFTYPE_MONITOR
);
514 switch (parse_mntr_flags(&argc
, &argv
, msg
)) {
520 fprintf(stderr
, "failed to allocate flags\n");
523 fprintf(stderr
, "unknown flag %s\n", *argv
);
531 COMMAND(set
, monitor
, "<flag>*",
532 NL80211_CMD_SET_INTERFACE
, 0, CIB_NETDEV
, handle_interface_set
,
533 "Set monitor flags. Valid flags are:\n"
536 static int handle_interface_meshid(struct nl80211_state
*state
,
538 int argc
, char **argv
,
541 char *mesh_id
= NULL
;
548 NLA_PUT(msg
, NL80211_ATTR_MESH_ID
, strlen(mesh_id
), mesh_id
);
554 COMMAND(set
, meshid
, "<meshid>",
555 NL80211_CMD_SET_INTERFACE
, 0, CIB_NETDEV
, handle_interface_meshid
, NULL
);
557 static unsigned int dev_dump_wiphy
;
559 static int handle_dev_dump(struct nl80211_state
*state
,
561 int argc
, char **argv
,
565 register_handler(print_iface_handler
, &dev_dump_wiphy
);
568 TOPLEVEL(dev
, NULL
, NL80211_CMD_GET_INTERFACE
, NLM_F_DUMP
, CIB_NONE
, handle_dev_dump
,
569 "List all network interfaces for wireless hardware.");
571 static int handle_interface_type(struct nl80211_state
*state
,
573 int argc
, char **argv
,
576 enum nl80211_iftype type
;
579 tpset
= get_if_type(&argc
, &argv
, &type
, false);
586 NLA_PUT_U32(msg
, NL80211_ATTR_IFTYPE
, type
);
592 COMMAND(set
, type
, "<type>",
593 NL80211_CMD_SET_INTERFACE
, 0, CIB_NETDEV
, handle_interface_type
,
594 "Set interface type/mode.\n"
597 static int handle_interface_4addr(struct nl80211_state
*state
,
599 int argc
, char **argv
,
604 return parse_4addr_flag(argv
[0], msg
);
606 COMMAND(set
, 4addr
, "<on|off>",
607 NL80211_CMD_SET_INTERFACE
, 0, CIB_NETDEV
, handle_interface_4addr
,
608 "Set interface 4addr (WDS) mode.");
610 static int handle_interface_noack_map(struct nl80211_state
*state
,
612 int argc
, char **argv
,
621 noack_map
= strtoul(argv
[0], &end
, 16);
625 NLA_PUT_U16(msg
, NL80211_ATTR_NOACK_MAP
, noack_map
);
632 COMMAND(set
, noack_map
, "<map>",
633 NL80211_CMD_SET_NOACK_MAP
, 0, CIB_NETDEV
, handle_interface_noack_map
,
634 "Set the NoAck map for the TIDs. (0x0009 = BE, 0x0006 = BK, 0x0030 = VI, 0x00C0 = VO)");
637 static int handle_interface_wds_peer(struct nl80211_state
*state
,
639 int argc
, char **argv
,
642 unsigned char mac_addr
[ETH_ALEN
];
647 if (mac_addr_a2n(mac_addr
, argv
[0])) {
648 fprintf(stderr
, "Invalid MAC address\n");
658 NLA_PUT(msg
, NL80211_ATTR_MAC
, ETH_ALEN
, mac_addr
);
664 COMMAND(set
, peer
, "<MAC address>",
665 NL80211_CMD_SET_WDS_PEER
, 0, CIB_NETDEV
, handle_interface_wds_peer
,
666 "Set interface WDS peer.");
668 static int set_mcast_rate(struct nl80211_state
*state
,
670 int argc
, char **argv
,
679 rate
= strtod(argv
[0], &end
);
683 NLA_PUT_U32(msg
, NL80211_ATTR_MCAST_RATE
, (int)(rate
* 10));
690 COMMAND(set
, mcast_rate
, "<rate in Mbps>",
691 NL80211_CMD_SET_MCAST_RATE
, 0, CIB_NETDEV
, set_mcast_rate
,
692 "Set the multicast bitrate.");
695 static int handle_chanfreq(struct nl80211_state
*state
, struct nl_msg
*msg
,
696 bool chan
, int argc
, char **argv
,
699 struct chandef chandef
;
704 res
= parse_freqchan(&chandef
, chan
, argc
, argv
, &parsed
, false);
712 unsigned int beacons
= 10;
714 if (strcmp(argv
[0], "beacons") == 0) {
718 beacons
= strtol(argv
[1], &end
, 10);
725 NLA_PUT_U32(msg
, NL80211_ATTR_CH_SWITCH_COUNT
, beacons
);
726 } else if (strcmp(argv
[0], "block-tx") == 0) {
730 NLA_PUT_FLAG(msg
, NL80211_ATTR_CH_SWITCH_BLOCK_TX
);
736 return put_chandef(msg
, &chandef
);
742 static int handle_freq(struct nl80211_state
*state
, struct nl_msg
*msg
,
743 int argc
, char **argv
,
746 return handle_chanfreq(state
, msg
, false, argc
, argv
, id
);
749 static int handle_chan(struct nl80211_state
*state
, struct nl_msg
*msg
,
750 int argc
, char **argv
,
753 return handle_chanfreq(state
, msg
, true, argc
, argv
, id
);
757 COMMAND(switch, freq
,
758 "<freq> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz] [beacons <count>] [block-tx]\n"
759 "<control freq> [5|10|20|40|80|80+80|160] [<center1_freq> [<center2_freq>]] [beacons <count>] [block-tx]",
760 NL80211_CMD_CHANNEL_SWITCH
, 0, CIB_NETDEV
, handle_freq
,
761 "Switch the operating channel by sending a channel switch announcement (CSA).");
762 COMMAND(switch, channel
, "<channel> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz] [beacons <count>] [block-tx]",
763 NL80211_CMD_CHANNEL_SWITCH
, 0, CIB_NETDEV
, handle_chan
, NULL
);
766 static int toggle_tid_param(const char *argv0
, const char *argv1
,
767 struct nl_msg
*msg
, uint32_t attr
)
771 if (strcmp(argv1
, "on") == 0) {
772 val
= NL80211_TID_CONFIG_ENABLE
;
773 } else if (strcmp(argv1
, "off") == 0) {
774 val
= NL80211_TID_CONFIG_DISABLE
;
776 fprintf(stderr
, "Invalid %s parameter: %s\n", argv0
, argv1
);
780 NLA_PUT_U8(msg
, attr
, val
);
787 static int handle_tid_config(struct nl80211_state
*state
,
789 int argc
, char **argv
,
792 struct nlattr
*tids_array
= NULL
;
793 struct nlattr
*tids_entry
= NULL
;
794 enum nl80211_tx_rate_setting txrate_type
;
795 unsigned char peer
[ETH_ALEN
];
803 } parse_state
= PS_ADDR
;
807 switch (parse_state
) {
809 if (strcmp(argv
[0], "peer") == 0) {
811 fprintf(stderr
, "Not enough args for %s\n", argv
[0]);
812 return HANDLER_RET_USAGE
;
815 if (mac_addr_a2n(peer
, argv
[1])) {
816 fprintf(stderr
, "Invalid MAC address\n");
820 NLA_PUT(msg
, NL80211_ATTR_MAC
, ETH_ALEN
, peer
);
824 parse_state
= PS_TIDS
;
826 } else if (strcmp(argv
[0], "tids") == 0) {
827 parse_state
= PS_TIDS
;
829 fprintf(stderr
, "Peer MAC address expected\n");
830 return HANDLER_RET_USAGE
;
835 if (strcmp(argv
[0], "tids") == 0) {
837 fprintf(stderr
, "not enough args for %s\n", argv
[0]);
838 return HANDLER_RET_USAGE
;
842 tids_array
= nla_nest_start(msg
, NL80211_ATTR_TID_CONFIG
);
848 nla_nest_end(msg
, tids_entry
);
852 tids_entry
= nla_nest_start(msg
, tids_num
);
856 NLA_PUT_U16(msg
, NL80211_TID_CONFIG_ATTR_TIDS
, strtol(argv
[1], &end
, 0));
858 fprintf(stderr
, "Invalid TID mask value: %s\n", argv
[1]);
864 parse_state
= PS_CONF
;
866 fprintf(stderr
, "TID mask expected\n");
867 return HANDLER_RET_USAGE
;
872 if (strcmp(argv
[0], "tids") == 0) {
873 parse_state
= PS_TIDS
;
874 } else if (strcmp(argv
[0], "override") == 0) {
875 NLA_PUT_FLAG(msg
, NL80211_TID_CONFIG_ATTR_OVERRIDE
);
879 } else if (strcmp(argv
[0], "ampdu") == 0) {
881 fprintf(stderr
, "not enough args for %s\n", argv
[0]);
882 return HANDLER_RET_USAGE
;
885 ret
= toggle_tid_param(argv
[0], argv
[1], msg
,
886 NL80211_TID_CONFIG_ATTR_AMPDU_CTRL
);
892 } else if (strcmp(argv
[0], "amsdu") == 0) {
894 fprintf(stderr
, "not enough args for %s\n", argv
[0]);
895 return HANDLER_RET_USAGE
;
898 ret
= toggle_tid_param(argv
[0], argv
[1], msg
,
899 NL80211_TID_CONFIG_ATTR_AMSDU_CTRL
);
905 } else if (strcmp(argv
[0], "noack") == 0) {
907 fprintf(stderr
, "not enough args for %s\n", argv
[0]);
908 return HANDLER_RET_USAGE
;
911 ret
= toggle_tid_param(argv
[0], argv
[1], msg
,
912 NL80211_TID_CONFIG_ATTR_NOACK
);
918 } else if (strcmp(argv
[0], "rtscts") == 0) {
920 fprintf(stderr
, "not enough args for %s\n", argv
[0]);
921 return HANDLER_RET_USAGE
;
924 ret
= toggle_tid_param(argv
[0], argv
[1], msg
,
925 NL80211_TID_CONFIG_ATTR_RTSCTS_CTRL
);
931 } else if (strcmp(argv
[0], "sretry") == 0) {
933 fprintf(stderr
, "not enough args for %s\n", argv
[0]);
934 return HANDLER_RET_USAGE
;
937 NLA_PUT_U8(msg
, NL80211_TID_CONFIG_ATTR_RETRY_SHORT
, strtol(argv
[1], &end
, 0));
939 fprintf(stderr
, "Invalid short_retry value: %s\n", argv
[1]);
945 } else if (strcmp(argv
[0], "lretry") == 0) {
947 fprintf(stderr
, "not enough args for %s\n", argv
[0]);
948 return HANDLER_RET_USAGE
;
951 NLA_PUT_U8(msg
, NL80211_TID_CONFIG_ATTR_RETRY_LONG
, strtol(argv
[1], &end
, 0));
953 fprintf(stderr
, "Invalid long_retry value: %s\n", argv
[1]);
959 } else if (strcmp(argv
[0], "bitrates") == 0) {
961 fprintf(stderr
, "not enough args for %s\n", argv
[0]);
962 return HANDLER_RET_USAGE
;
964 if (!strcmp(argv
[1], "auto"))
965 txrate_type
= NL80211_TX_RATE_AUTOMATIC
;
966 else if (!strcmp(argv
[1], "fixed"))
967 txrate_type
= NL80211_TX_RATE_FIXED
;
968 else if (!strcmp(argv
[1], "limit"))
969 txrate_type
= NL80211_TX_RATE_LIMITED
;
971 printf("Invalid parameter: %s\n", argv
[0]);
974 NLA_PUT_U8(msg
, NL80211_TID_CONFIG_ATTR_TX_RATE_TYPE
, txrate_type
);
977 if (txrate_type
!= NL80211_TX_RATE_AUTOMATIC
) {
978 attr
= NL80211_TID_CONFIG_ATTR_TX_RATE
;
979 ret
= set_bitrates(msg
, argc
, argv
,
988 fprintf(stderr
, "Unknown parameter: %s\n", argv
[0]);
989 return HANDLER_RET_USAGE
;
994 fprintf(stderr
, "Failed to parse: internal failure\n");
995 return HANDLER_RET_USAGE
;
1000 nla_nest_end(msg
, tids_entry
);
1003 nla_nest_end(msg
, tids_array
);
1011 COMMAND(set
, tidconf
, "[peer <MAC address>] tids <mask> [override] [sretry <num>] [lretry <num>] "
1012 "[ampdu [on|off]] [amsdu [on|off]] [noack [on|off]] [rtscts [on|off]]"
1013 "[bitrates <type [auto|fixed|limit]> [legacy-<2.4|5> <legacy rate in Mbps>*] [ht-mcs-<2.4|5> <MCS index>*]"
1014 " [vht-mcs-<2.4|5> <NSS:MCSx,MCSy... | NSS:MCSx-MCSy>*] [sgi-2.4|lgi-2.4] [sgi-5|lgi-5]]",
1015 NL80211_CMD_SET_TID_CONFIG
, 0, CIB_NETDEV
, handle_tid_config
,
1016 "Setup per-node TID specific configuration for TIDs selected by bitmask.\n"
1017 "If MAC address is not specified, then supplied TID configuration\n"
1018 "applied to all the peers.\n"
1020 " $ iw dev wlan0 set tidconf tids 0x1 ampdu off\n"
1021 " $ iw dev wlan0 set tidconf tids 0x5 ampdu off amsdu off rtscts on\n"
1022 " $ iw dev wlan0 set tidconf tids 0x3 override ampdu on noack on rtscts on\n"
1023 " $ iw dev wlan0 set tidconf peer xx:xx:xx:xx:xx:xx tids 0x1 ampdu off tids 0x3 amsdu off rtscts on\n"
1024 " $ iw dev wlan0 set tidconf peer xx:xx:xx:xx:xx:xx tids 0x2 bitrates auto\n"
1025 " $ iw dev wlan0 set tidconf peer xx:xx:xx:xx:xx:xx tids 0x2 bitrates limit vht-mcs-5 4:9\n"