From: Johannes Berg Date: Tue, 16 Sep 2008 15:40:48 +0000 (+0200) Subject: add phy renaming support X-Git-Tag: v0.9~22 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0f55e0b83089718a2610a10f923f4348f87933f6;p=thirdparty%2Fiw.git add phy renaming support --- diff --git a/Makefile b/Makefile index 2ffffd9..1c1c9f7 100644 --- 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 index 0000000..ad7c331 --- /dev/null +++ b/phy.c @@ -0,0 +1,47 @@ +#include +#include +#include + +#include +#include +#include +#include +#include + +#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, "", NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_name);