]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
add phy renaming support
authorJohannes Berg <johannes@sipsolutions.net>
Tue, 16 Sep 2008 15:40:48 +0000 (17:40 +0200)
committerJohannes Berg <johannes@sipsolutions.net>
Tue, 16 Sep 2008 15:40:48 +0000 (17:40 +0200)
Makefile
phy.c [new file with mode: 0644]

index 2ffffd95fc5ad6d99df0182f8ffd9be6ea31f89b..1c1c9f71599b18ccc9c333368274cceeb4381e71 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -8,7 +8,7 @@ CFLAGS += -I/lib/modules/`uname -r`/build/include
 CFLAGS += -O2 -g
 LDFLAGS += -lnl
 
-OBJS = iw.o interface.o info.o station.o util.o mpath.o reg.o
+OBJS = iw.o info.o phy.o interface.o station.o util.o mpath.o reg.o
 ALL = iw
 
 ifeq ($(V),1)
diff --git a/phy.c b/phy.c
new file mode 100644 (file)
index 0000000..ad7c331
--- /dev/null
+++ b/phy.c
@@ -0,0 +1,47 @@
+#include <errno.h>
+#include <linux/nl80211.h>
+#include <net/if.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 "iw.h"
+
+static int handle_name(struct nl80211_state *state,
+                      struct nl_msg *msg,
+                      int argc, char **argv)
+{
+       int err = 1;
+       struct nl_cb *cb;
+
+       if (argc != 1)
+               return -1;
+
+       NLA_PUT_STRING(msg, NL80211_ATTR_WIPHY_NAME, *argv);
+
+       cb = nl_cb_alloc(NL_CB_CUSTOM);
+       if (!cb)
+               goto out;
+
+       if (nl_send_auto_complete(state->nl_handle, msg) < 0)
+               goto out;
+
+       err = nl_recvmsgs(state->nl_handle, cb);
+
+       if (err < 0)
+               goto out;
+       err = 0;
+
+ out:
+       nl_cb_put(cb);
+ nla_put_failure:
+       if (err) {
+               fprintf(stderr, "failed set name: %d\n", err);
+               return 1;
+       }
+       return err;
+}
+COMMAND(set, name, "<new name>", NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_name);