]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
add iw commands for setting fragmentation and rts threshold
authorJohannes Berg <johannes@sipsolutions.net>
Tue, 11 Aug 2009 09:26:42 +0000 (11:26 +0200)
committerJohannes Berg <johannes@sipsolutions.net>
Tue, 11 Aug 2009 09:26:42 +0000 (11:26 +0200)
info.c
phy.c

diff --git a/info.c b/info.c
index 542745b86398a6ffdf1058a2c1df23eb42f7036f..1b5e44315f3606bcef2cb3dda29097d54fe97af6 100644 (file)
--- a/info.c
+++ b/info.c
@@ -247,6 +247,22 @@ static int print_phy_handler(struct nl_msg *msg, void *arg)
                printf("\tmax # scan SSIDs: %d\n",
                       nla_get_u8(tb_msg[NL80211_ATTR_MAX_NUM_SCAN_SSIDS]));
 
+       if (tb_msg[NL80211_ATTR_WIPHY_FRAG_THRESHOLD]) {
+               unsigned int frag;
+
+               frag = nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_FRAG_THRESHOLD]);
+               if (frag != (unsigned int)-1)
+                       printf("\tFragmentation threshold: %d\n", frag);
+       }
+
+       if (tb_msg[NL80211_ATTR_WIPHY_RTS_THRESHOLD]) {
+               unsigned int rts;
+
+               rts = nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_RTS_THRESHOLD]);
+               if (rts != (unsigned int)-1)
+                       printf("\tRTS threshold: %d\n", rts);
+       }
+
        if (!tb_msg[NL80211_ATTR_SUPPORTED_IFTYPES])
                return NL_SKIP;
 
diff --git a/phy.c b/phy.c
index 1c0938a60dc23384d79dc9dce1efff8b1dc09a24..b34f9db856d56a5d9b09b0e3daff6102d76308ab 100644 (file)
--- a/phy.c
+++ b/phy.c
@@ -92,3 +92,51 @@ COMMAND(set, channel, "<channel> [HT20|HT40+|HT40-]",
        NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_chan, NULL);
 COMMAND(set, channel, "<channel> [HT20|HT40+|HT40-]",
        NL80211_CMD_SET_WIPHY, 0, CIB_NETDEV, handle_chan, NULL);
+
+static int handle_fragmentation(struct nl80211_state *state,
+                               struct nl_cb *cb, struct nl_msg *msg,
+                               int argc, char **argv)
+{
+       unsigned int frag;
+
+       if (argc != 1)
+               return 1;
+
+       if (strcmp("off", argv[0]) == 0)
+               frag = -1;
+       else
+               frag = strtoul(argv[0], NULL, 10);
+
+       NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FRAG_THRESHOLD, frag);
+
+       return 0;
+ nla_put_failure:
+       return -ENOBUFS;
+}
+COMMAND(set, frag, "<fragmentation threshold|off>",
+       NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_fragmentation,
+       "Set fragmentation threshold.");
+
+static int handle_rts(struct nl80211_state *state,
+                     struct nl_cb *cb, struct nl_msg *msg,
+                     int argc, char **argv)
+{
+       unsigned int rts;
+
+       if (argc != 1)
+               return 1;
+
+       if (strcmp("off", argv[0]) == 0)
+               rts = -1;
+       else
+               rts = strtoul(argv[0], NULL, 10);
+
+       NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_RTS_THRESHOLD, rts);
+
+       return 0;
+ nla_put_failure:
+       return -ENOBUFS;
+}
+COMMAND(set, rts, "<rts threshold|off>",
+       NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_rts,
+       "Set rts threshold.");