]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
iw: add support to set/get retry limit
authorUjjal Roy <royujjal@gmail.com>
Fri, 7 Mar 2014 06:53:38 +0000 (12:23 +0530)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 28 Mar 2014 08:55:46 +0000 (09:55 +0100)
Show the retry limit in phy details and also configure the
retry limit.

Signed-off-by: Ujjal Roy <royujjal@gmail.com>
info.c
phy.c

diff --git a/info.c b/info.c
index a6965035d1da9273810dc968497a587b1a2c46a0..001b31786102e09b34d56e7f4cbc1bac67dc5bd5 100644 (file)
--- a/info.c
+++ b/info.c
@@ -246,6 +246,22 @@ next:
                        printf("\tRTS threshold: %d\n", rts);
        }
 
+       if (tb_msg[NL80211_ATTR_WIPHY_RETRY_SHORT] ||
+           tb_msg[NL80211_ATTR_WIPHY_RETRY_LONG]) {
+               unsigned char retry_short = 0, retry_long = 0;
+
+               if (tb_msg[NL80211_ATTR_WIPHY_RETRY_SHORT])
+                       retry_short = nla_get_u8(tb_msg[NL80211_ATTR_WIPHY_RETRY_SHORT]);
+               if (tb_msg[NL80211_ATTR_WIPHY_RETRY_LONG])
+                       retry_long = nla_get_u8(tb_msg[NL80211_ATTR_WIPHY_RETRY_LONG]);
+               if (retry_short == retry_long) {
+                       printf("\tRetry short long limit: %d\n", retry_short);
+               } else {
+                       printf("\tRetry short limit: %d\n", retry_short);
+                       printf("\tRetry long limit: %d\n", retry_long);
+               }
+       }
+
        if (tb_msg[NL80211_ATTR_WIPHY_COVERAGE_CLASS]) {
                unsigned char coverage;
 
diff --git a/phy.c b/phy.c
index 68f40f6faefcc1f59591b2f764c699582940f1ab..517d20339357a887966b836b82084daac2f01978 100644 (file)
--- a/phy.c
+++ b/phy.c
@@ -232,6 +232,70 @@ COMMAND(set, rts, "<rts threshold|off>",
        NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_rts,
        "Set rts threshold.");
 
+static int handle_retry(struct nl80211_state *state,
+                       struct nl_cb *cb, struct nl_msg *msg,
+                       int argc, char **argv, enum id_input id)
+{
+       unsigned int retry_short = 0, retry_long = 0;
+       bool have_retry_s = false, have_retry_l = false;
+       int i;
+       enum {
+               S_NONE,
+               S_SHORT,
+               S_LONG,
+       } parser_state = S_NONE;
+
+       if (!argc || (argc != 2 && argc != 4))
+               return 1;
+
+       for (i = 0; i < argc; i++) {
+               char *end;
+               unsigned int tmpul;
+
+               if (strcmp(argv[i], "short") == 0) {
+                       if (have_retry_s)
+                               return 1;
+                       parser_state = S_SHORT;
+                       have_retry_s = true;
+               } else if (strcmp(argv[i], "long") == 0) {
+                       if (have_retry_l)
+                               return 1;
+                       parser_state = S_LONG;
+                       have_retry_l = true;
+               } else {
+                       tmpul = strtoul(argv[i], &end, 10);
+                       if (*end != '\0')
+                               return 1;
+                       if (!tmpul || tmpul > 255)
+                               return -EINVAL;
+                       switch (parser_state) {
+                       case S_SHORT:
+                               retry_short = tmpul;
+                               break;
+                       case S_LONG:
+                               retry_long = tmpul;
+                               break;
+                       default:
+                               return 1;
+                       }
+               }
+       }
+
+       if (!have_retry_s && !have_retry_l)
+               return 1;
+       if (have_retry_s)
+               NLA_PUT_U8(msg, NL80211_ATTR_WIPHY_RETRY_SHORT, retry_short);
+       if (have_retry_l)
+               NLA_PUT_U8(msg, NL80211_ATTR_WIPHY_RETRY_LONG, retry_long);
+
+       return 0;
+ nla_put_failure:
+       return -ENOBUFS;
+}
+COMMAND(set, retry, "[short <limit>] [long <limit>]",
+       NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_retry,
+       "Set retry limit.");
+
 static int handle_netns(struct nl80211_state *state,
                        struct nl_cb *cb,
                        struct nl_msg *msg,