]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
add off-channel command
authorJohannes Berg <johannes@sipsolutions.net>
Tue, 2 Feb 2010 19:51:42 +0000 (20:51 +0100)
committerJohannes Berg <johannes@sipsolutions.net>
Tue, 2 Feb 2010 19:51:42 +0000 (20:51 +0100)
Makefile
event.c
offch.c [new file with mode: 0644]

index 2a6fc9a51599ae4413f46f67f4e63864d2b0bbb5..bae1bfbac88963b6bd4da4c615b4cdd749a89ae1 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -17,7 +17,7 @@ CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing
 OBJS = iw.o genl.o event.o info.o phy.o \
        interface.o ibss.o station.o survey.o util.o \
        mesh.o mpath.o scan.o reg.o version.o \
-       reason.o status.o connect.o link.o
+       reason.o status.o connect.o link.o offch.o
 OBJS += sections.o
 ALL = iw
 
diff --git a/event.c b/event.c
index 445db5f9ddb99ddb804d979ef05e294ab7adb19f..01a325cfb8f46d1d24b6ff6099b5f2100cb60e44 100644 (file)
--- a/event.c
+++ b/event.c
@@ -302,6 +302,17 @@ static int print_event(struct nl_msg *msg, void *arg)
                                get_reason_str(nla_get_u16(tb[NL80211_ATTR_REASON_CODE])));
                printf("\n");
                break;
+       case NL80211_CMD_REMAIN_ON_CHANNEL:
+               printf("remain on freq %d (%dms, cookie %llx)\n",
+                       nla_get_u32(tb[NL80211_ATTR_WIPHY_FREQ]),
+                       nla_get_u32(tb[NL80211_ATTR_DURATION]),
+                       (unsigned long long)nla_get_u64(tb[NL80211_ATTR_COOKIE]));
+               break;
+       case NL80211_CMD_CANCEL_REMAIN_ON_CHANNEL:
+               printf("done with remain on freq %d (cookie %llx)\n",
+                       nla_get_u32(tb[NL80211_ATTR_WIPHY_FREQ]),
+                       (unsigned long long)nla_get_u64(tb[NL80211_ATTR_COOKIE]));
+               break;
        default:
                printf("unknown event %d\n", gnlh->cmd);
                break;
diff --git a/offch.c b/offch.c
new file mode 100644 (file)
index 0000000..b40a523
--- /dev/null
+++ b/offch.c
@@ -0,0 +1,43 @@
+#include <errno.h>
+
+#include <netlink/genl/genl.h>
+#include <netlink/genl/family.h>
+#include <netlink/genl/ctrl.h>
+#include <netlink/msg.h>
+#include <netlink/attr.h>
+
+#include "nl80211.h"
+#include "iw.h"
+
+static int offchannel(struct nl80211_state *state, struct nl_cb *cb,
+                     struct nl_msg *msg, int argc, char **argv)
+{
+       char *end;
+
+       /* freq */
+       NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ,
+                   strtoul(argv[0], &end, 10));
+       if (*end != '\0')
+               return 1;
+       argv++;
+       argc--;
+
+       /* duration */
+       NLA_PUT_U32(msg, NL80211_ATTR_DURATION,
+                   strtoul(argv[0], &end, 10));
+       if (*end != '\0')
+               return 1;
+       argv++;
+       argc--;
+
+       if (argc)
+               return 1;
+
+       return 0;
+ nla_put_failure:
+       return -ENOSPC;
+}
+
+TOPLEVEL(offchannel, "<freq> <duration>", NL80211_CMD_REMAIN_ON_CHANNEL, 0,
+        CIB_NETDEV, offchannel,
+        "Leave operating channel and go to the given channel for a while.");