]> git.ipfire.org Git - thirdparty/iw.git/blob - cqm.c
info: macro-ify ext_feat_print()
[thirdparty/iw.git] / cqm.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 iw_cqm_rssi(struct nl80211_state *state,
13 struct nl_msg *msg, int argc, char **argv,
14 enum id_input id)
15 {
16 struct nl_msg *cqm = NULL;
17 int thold = 0;
18 int hyst = 0;
19 int ret = -ENOSPC;
20
21 /* get the required args */
22 if (argc < 1 || argc > 2)
23 return 1;
24
25 if (strcmp(argv[0], "off")) {
26 thold = atoi(argv[0]);
27
28 if (thold == 0)
29 return -EINVAL;
30
31 if (argc == 2)
32 hyst = atoi(argv[1]);
33 }
34
35 /* connection quality monitor attributes */
36 cqm = nlmsg_alloc();
37 if (!cqm)
38 return -ENOMEM;
39
40 NLA_PUT_U32(cqm, NL80211_ATTR_CQM_RSSI_THOLD, thold);
41 NLA_PUT_U32(cqm, NL80211_ATTR_CQM_RSSI_HYST, hyst);
42
43 nla_put_nested(msg, NL80211_ATTR_CQM, cqm);
44 ret = 0;
45
46 nla_put_failure:
47 nlmsg_free(cqm);
48 return ret;
49 }
50
51 TOPLEVEL(cqm, "",
52 0, 0, CIB_NETDEV, NULL,
53 "Configure the WLAN connection quality monitor.\n");
54
55 COMMAND(cqm, rssi, "<threshold|off> [<hysteresis>]",
56 NL80211_CMD_SET_CQM, 0, CIB_NETDEV, iw_cqm_rssi,
57 "Set connection quality monitor RSSI threshold.\n");