]> git.ipfire.org Git - thirdparty/iw.git/blob - offch.c
iw: Support associated-at station statistic.
[thirdparty/iw.git] / offch.c
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
12 static int offchannel(struct nl80211_state *state,
13 struct nl_msg *msg, int argc, char **argv,
14 enum id_input id)
15 {
16 char *end;
17
18 if (argc < 2)
19 return 1;
20
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
45 TOPLEVEL(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.");