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 #ifdef NL80211_TXRATE_MCS
21 uint8_t mcs_24
[77], mcs_5
[77];
22 int n_mcs_24
= 0, n_mcs_5
= 0;
30 } parser_state
= S_NONE
;
32 for (i
= 0; i
< argc
; i
++) {
35 #ifdef NL80211_TXRATE_MCS
39 if (strcmp(argv
[i
], "legacy-2.4") == 0) {
42 parser_state
= S_LEGACY
;
44 n_legacy
= &n_legacy_24
;
45 have_legacy_24
= true;
46 } else if (strcmp(argv
[i
], "legacy-5") == 0) {
49 parser_state
= S_LEGACY
;
51 n_legacy
= &n_legacy_5
;
54 #ifdef NL80211_TXRATE_MCS
55 else if (strcmp(argv
[i
], "mcs-2.4") == 0) {
62 } else if (strcmp(argv
[i
], "mcs-5") == 0) {
71 else switch (parser_state
) {
73 tmpd
= strtod(argv
[i
], &end
);
76 if (tmpd
< 1 || tmpd
> 255 * 2)
78 legacy
[(*n_legacy
)++] = tmpd
* 2;
81 #ifdef NL80211_TXRATE_MCS
82 tmpl
= strtol(argv
[i
], &end
, 0);
85 if (tmpl
< 0 || tmpl
> 255)
87 mcs
[(*n_mcs
)++] = tmpl
;
95 nl_rates
= nla_nest_start(msg
, NL80211_ATTR_TX_RATES
);
99 if (have_legacy_24
|| have_mcs_24
) {
100 nl_band
= nla_nest_start(msg
, NL80211_BAND_2GHZ
);
102 goto nla_put_failure
;
104 nla_put(msg
, NL80211_TXRATE_LEGACY
, n_legacy_24
, legacy_24
);
105 #ifdef NL80211_TXRATE_MCS
107 nla_put(msg
, NL80211_TXRATE_MCS
, n_mcs_24
, mcs_24
);
109 nla_nest_end(msg
, nl_band
);
112 if (have_legacy_5
|| have_mcs_5
) {
113 nl_band
= nla_nest_start(msg
, NL80211_BAND_5GHZ
);
115 goto nla_put_failure
;
117 nla_put(msg
, NL80211_TXRATE_LEGACY
, n_legacy_5
, legacy_5
);
118 #ifdef NL80211_TXRATE_MCS
120 nla_put(msg
, NL80211_TXRATE_MCS
, n_mcs_5
, mcs_5
);
122 nla_nest_end(msg
, nl_band
);
125 nla_nest_end(msg
, nl_rates
);
132 #define DESCR_LEGACY "[legacy-<2.4|5> <legacy rate in Mbps>*]"
133 #ifdef NL80211_TXRATE_MCS
134 #define DESCR DESCR_LEGACY " [mcs-<2.4|5> <MCS index>*]"
136 #define DESCR DESCR_LEGACY
139 COMMAND(set
, bitrates
, DESCR
, NL80211_CMD_SET_TX_BITRATE_MASK
, 0, CIB_NETDEV
,
141 "Sets up the specified rate masks.\n"
142 "Not passing any arguments would clear the existing mask (if any).");