7 static int handle_bitrates(struct nl80211_state
*state
,
10 int argc
, char **argv
)
12 struct nlattr
*nl_rates
, *nl_band
;
14 bool have_legacy_24
= false, have_legacy_5
= false;
15 uint8_t legacy_24
[32], legacy_5
[32];
16 int n_legacy_24
= 0, n_legacy_5
= 0;
17 uint8_t *legacy
= NULL
;
19 bool have_mcs_24
= false, have_mcs_5
= false;
20 uint8_t mcs_24
[77], mcs_5
[77];
21 int n_mcs_24
= 0, n_mcs_5
= 0;
28 } parser_state
= S_NONE
;
30 for (i
= 0; i
< argc
; i
++) {
35 if (strcmp(argv
[i
], "legacy-2.4") == 0) {
38 parser_state
= S_LEGACY
;
40 n_legacy
= &n_legacy_24
;
41 have_legacy_24
= true;
42 } else if (strcmp(argv
[i
], "legacy-5") == 0) {
45 parser_state
= S_LEGACY
;
47 n_legacy
= &n_legacy_5
;
50 else if (strcmp(argv
[i
], "mcs-2.4") == 0) {
57 } else if (strcmp(argv
[i
], "mcs-5") == 0) {
65 else switch (parser_state
) {
67 tmpd
= strtod(argv
[i
], &end
);
70 if (tmpd
< 1 || tmpd
> 255 * 2)
72 legacy
[(*n_legacy
)++] = tmpd
* 2;
75 tmpl
= strtol(argv
[i
], &end
, 0);
78 if (tmpl
< 0 || tmpl
> 255)
80 mcs
[(*n_mcs
)++] = tmpl
;
87 nl_rates
= nla_nest_start(msg
, NL80211_ATTR_TX_RATES
);
91 if (have_legacy_24
|| have_mcs_24
) {
92 nl_band
= nla_nest_start(msg
, NL80211_BAND_2GHZ
);
96 nla_put(msg
, NL80211_TXRATE_LEGACY
, n_legacy_24
, legacy_24
);
98 nla_put(msg
, NL80211_TXRATE_MCS
, n_mcs_24
, mcs_24
);
99 nla_nest_end(msg
, nl_band
);
102 if (have_legacy_5
|| have_mcs_5
) {
103 nl_band
= nla_nest_start(msg
, NL80211_BAND_5GHZ
);
105 goto nla_put_failure
;
107 nla_put(msg
, NL80211_TXRATE_LEGACY
, n_legacy_5
, legacy_5
);
109 nla_put(msg
, NL80211_TXRATE_MCS
, n_mcs_5
, mcs_5
);
110 nla_nest_end(msg
, nl_band
);
113 nla_nest_end(msg
, nl_rates
);
120 #define DESCR_LEGACY "[legacy-<2.4|5> <legacy rate in Mbps>*]"
121 #define DESCR DESCR_LEGACY " [mcs-<2.4|5> <MCS index>*]"
123 COMMAND(set
, bitrates
, "[legacy-<2.4|5> <legacy rate in Mbps>*] [mcs-<2.4|5> <MCS index>*]",
124 NL80211_CMD_SET_TX_BITRATE_MASK
, 0, CIB_NETDEV
, handle_bitrates
,
125 "Sets up the specified rate masks.\n"
126 "Not passing any arguments would clear the existing mask (if any).");