]> git.ipfire.org Git - thirdparty/iw.git/blobdiff - bitrate.c
add P2P Device handling primitives
[thirdparty/iw.git] / bitrate.c
index 8de8839533bee00656c35434d9a96c4c6ddeabf9..4da246f5ce79721e4cbc775fc3ea7e28ce0d045d 100644 (file)
--- a/bitrate.c
+++ b/bitrate.c
@@ -7,7 +7,8 @@
 static int handle_bitrates(struct nl80211_state *state,
                           struct nl_cb *cb,
                           struct nl_msg *msg,
-                          int argc, char **argv)
+                          int argc, char **argv,
+                          enum id_input id)
 {
        struct nlattr *nl_rates, *nl_band;
        int i;
@@ -17,12 +18,10 @@ static int handle_bitrates(struct nl80211_state *state,
        uint8_t *legacy = NULL;
        int *n_legacy = NULL;
        bool have_mcs_24 = false, have_mcs_5 = false;
-#ifdef NL80211_TXRATE_MCS
        uint8_t mcs_24[77], mcs_5[77];
        int n_mcs_24 = 0, n_mcs_5 = 0;
        uint8_t *mcs = NULL;
        int *n_mcs = NULL;
-#endif
        enum {
                S_NONE,
                S_LEGACY,
@@ -31,10 +30,8 @@ static int handle_bitrates(struct nl80211_state *state,
 
        for (i = 0; i < argc; i++) {
                char *end;
-               float tmpf;
-#ifdef NL80211_TXRATE_MCS
+               double tmpd;
                long tmpl;
-#endif
 
                if (strcmp(argv[i], "legacy-2.4") == 0) {
                        if (have_legacy_24)
@@ -51,7 +48,6 @@ static int handle_bitrates(struct nl80211_state *state,
                        n_legacy = &n_legacy_5;
                        have_legacy_5 = true;
                }
-#ifdef NL80211_TXRATE_MCS
                else if (strcmp(argv[i], "mcs-2.4") == 0) {
                        if (have_mcs_24)
                                return 1;
@@ -67,18 +63,16 @@ static int handle_bitrates(struct nl80211_state *state,
                        n_mcs = &n_mcs_5;
                        have_mcs_5 = true;
                }
-#endif
                else switch (parser_state) {
                case S_LEGACY:
-                       tmpf = strtof(argv[i], &end);
+                       tmpd = strtod(argv[i], &end);
                        if (*end != '\0')
                                return 1;
-                       if (tmpf < 1 || tmpf > 255 * 2)
+                       if (tmpd < 1 || tmpd > 255 * 2)
                                return 1;
-                       legacy[(*n_legacy)++] = tmpf * 2;
+                       legacy[(*n_legacy)++] = tmpd * 2;
                        break;
                case S_MCS:
-#ifdef NL80211_TXRATE_MCS
                        tmpl = strtol(argv[i], &end, 0);
                        if (*end != '\0')
                                return 1;
@@ -86,7 +80,6 @@ static int handle_bitrates(struct nl80211_state *state,
                                return 1;
                        mcs[(*n_mcs)++] = tmpl;
                        break;
-#endif
                default:
                        return 1;
                }
@@ -102,10 +95,8 @@ static int handle_bitrates(struct nl80211_state *state,
                        goto nla_put_failure;
                if (have_legacy_24)
                        nla_put(msg, NL80211_TXRATE_LEGACY, n_legacy_24, legacy_24);
-#ifdef NL80211_TXRATE_MCS
                if (have_mcs_24)
                        nla_put(msg, NL80211_TXRATE_MCS, n_mcs_24, mcs_24);
-#endif
                nla_nest_end(msg, nl_band);
        }
 
@@ -115,10 +106,8 @@ static int handle_bitrates(struct nl80211_state *state,
                        goto nla_put_failure;
                if (have_legacy_5)
                        nla_put(msg, NL80211_TXRATE_LEGACY, n_legacy_5, legacy_5);
-#ifdef NL80211_TXRATE_MCS
                if (have_mcs_5)
                        nla_put(msg, NL80211_TXRATE_MCS, n_mcs_5, mcs_5);
-#endif
                nla_nest_end(msg, nl_band);
        }
 
@@ -130,11 +119,9 @@ static int handle_bitrates(struct nl80211_state *state,
 }
 
 #define DESCR_LEGACY "[legacy-<2.4|5> <legacy rate in Mbps>*]"
-#ifdef NL80211_TXRATE_MCS
 #define DESCR DESCR_LEGACY " [mcs-<2.4|5> <MCS index>*]"
-#else
-#define DESCR DESCR_LEGACY
-#endif
 
-COMMAND(set, bitrates, DESCR, NL80211_CMD_SET_TX_BITRATE_MASK, 0, CIB_NETDEV,
-       handle_bitrates, "Sets up the specified rate masks.");
+COMMAND(set, bitrates, "[legacy-<2.4|5> <legacy rate in Mbps>*] [mcs-<2.4|5> <MCS index>*]",
+       NL80211_CMD_SET_TX_BITRATE_MASK, 0, CIB_NETDEV, handle_bitrates,
+       "Sets up the specified rate masks.\n"
+       "Not passing any arguments would clear the existing mask (if any).");