7 static int handle_bitrates(struct nl80211_state
*state
,
10 int argc
, char **argv
,
13 struct nlattr
*nl_rates
, *nl_band
;
15 bool have_legacy_24
= false, have_legacy_5
= false;
16 uint8_t legacy_24
[32], legacy_5
[32];
17 int n_legacy_24
= 0, n_legacy_5
= 0;
18 uint8_t *legacy
= NULL
;
20 bool have_mcs_24
= false, have_mcs_5
= false;
21 uint8_t mcs_24
[77], mcs_5
[77];
22 int n_mcs_24
= 0, n_mcs_5
= 0;
29 } parser_state
= S_NONE
;
31 for (i
= 0; i
< argc
; i
++) {
36 if (strcmp(argv
[i
], "legacy-2.4") == 0) {
39 parser_state
= S_LEGACY
;
41 n_legacy
= &n_legacy_24
;
42 have_legacy_24
= true;
43 } else if (strcmp(argv
[i
], "legacy-5") == 0) {
46 parser_state
= S_LEGACY
;
48 n_legacy
= &n_legacy_5
;
51 else if (strcmp(argv
[i
], "mcs-2.4") == 0) {
58 } else if (strcmp(argv
[i
], "mcs-5") == 0) {
66 else switch (parser_state
) {
68 tmpd
= strtod(argv
[i
], &end
);
71 if (tmpd
< 1 || tmpd
> 255 * 2)
73 legacy
[(*n_legacy
)++] = tmpd
* 2;
76 tmpl
= strtol(argv
[i
], &end
, 0);
79 if (tmpl
< 0 || tmpl
> 255)
81 mcs
[(*n_mcs
)++] = tmpl
;
88 nl_rates
= nla_nest_start(msg
, NL80211_ATTR_TX_RATES
);
92 if (have_legacy_24
|| have_mcs_24
) {
93 nl_band
= nla_nest_start(msg
, NL80211_BAND_2GHZ
);
97 nla_put(msg
, NL80211_TXRATE_LEGACY
, n_legacy_24
, legacy_24
);
99 nla_put(msg
, NL80211_TXRATE_MCS
, n_mcs_24
, mcs_24
);
100 nla_nest_end(msg
, nl_band
);
103 if (have_legacy_5
|| have_mcs_5
) {
104 nl_band
= nla_nest_start(msg
, NL80211_BAND_5GHZ
);
106 goto nla_put_failure
;
108 nla_put(msg
, NL80211_TXRATE_LEGACY
, n_legacy_5
, legacy_5
);
110 nla_put(msg
, NL80211_TXRATE_MCS
, n_mcs_5
, mcs_5
);
111 nla_nest_end(msg
, nl_band
);
114 nla_nest_end(msg
, nl_rates
);
121 #define DESCR_LEGACY "[legacy-<2.4|5> <legacy rate in Mbps>*]"
122 #define DESCR DESCR_LEGACY " [mcs-<2.4|5> <MCS index>*]"
124 COMMAND(set
, bitrates
, "[legacy-<2.4|5> <legacy rate in Mbps>*] [mcs-<2.4|5> <MCS index>*]",
125 NL80211_CMD_SET_TX_BITRATE_MASK
, 0, CIB_NETDEV
, handle_bitrates
,
126 "Sets up the specified rate masks.\n"
127 "Not passing any arguments would clear the existing mask (if any).");