]> git.ipfire.org Git - thirdparty/iw.git/blame - offch.c
iw: separate wait/print when waiting for an event
[thirdparty/iw.git] / offch.c
CommitLineData
6829308d
JB
1#include <errno.h>
2
3#include <netlink/genl/genl.h>
4#include <netlink/genl/family.h>
5#include <netlink/genl/ctrl.h>
6#include <netlink/msg.h>
7#include <netlink/attr.h>
8
9#include "nl80211.h"
10#include "iw.h"
11
34b23014 12static int offchannel(struct nl80211_state *state,
05514f95
JB
13 struct nl_msg *msg, int argc, char **argv,
14 enum id_input id)
6829308d
JB
15{
16 char *end;
17
7082f96f
OO
18 if (argc < 2)
19 return 1;
20
6829308d
JB
21 /* freq */
22 NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ,
23 strtoul(argv[0], &end, 10));
24 if (*end != '\0')
25 return 1;
26 argv++;
27 argc--;
28
29 /* duration */
30 NLA_PUT_U32(msg, NL80211_ATTR_DURATION,
31 strtoul(argv[0], &end, 10));
32 if (*end != '\0')
33 return 1;
34 argv++;
35 argc--;
36
37 if (argc)
38 return 1;
39
40 return 0;
41 nla_put_failure:
42 return -ENOSPC;
43}
44
45TOPLEVEL(offchannel, "<freq> <duration>", NL80211_CMD_REMAIN_ON_CHANNEL, 0,
46 CIB_NETDEV, offchannel,
47 "Leave operating channel and go to the given channel for a while.");