]> git.ipfire.org Git - thirdparty/iw.git/blame - phy.c
clean up error handling
[thirdparty/iw.git] / phy.c
CommitLineData
0f55e0b8
JB
1#include <errno.h>
2#include <linux/nl80211.h>
3#include <net/if.h>
4
5#include <netlink/genl/genl.h>
6#include <netlink/genl/family.h>
7#include <netlink/genl/ctrl.h>
8#include <netlink/msg.h>
9#include <netlink/attr.h>
10
11#include "iw.h"
12
13static int handle_name(struct nl80211_state *state,
14 struct nl_msg *msg,
15 int argc, char **argv)
16{
5e75fd04 17 int err = -ENOMEM;
0f55e0b8
JB
18 struct nl_cb *cb;
19
20 if (argc != 1)
5e75fd04 21 return 1;
0f55e0b8
JB
22
23 NLA_PUT_STRING(msg, NL80211_ATTR_WIPHY_NAME, *argv);
24
25 cb = nl_cb_alloc(NL_CB_CUSTOM);
26 if (!cb)
27 goto out;
28
5e75fd04 29 if ((err = nl_send_auto_complete(state->nl_handle, msg)) < 0)
0f55e0b8
JB
30 goto out;
31
b6f1378d 32 err = nl_wait_for_ack(state->nl_handle);
0f55e0b8
JB
33
34 out:
35 nl_cb_put(cb);
36 nla_put_failure:
0f55e0b8
JB
37 return err;
38}
39COMMAND(set, name, "<new name>", NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_name);