]> git.ipfire.org Git - thirdparty/iw.git/blame - cqm.c
info: macro-ify ext_feat_print()
[thirdparty/iw.git] / cqm.c
CommitLineData
7988b229
JO
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 iw_cqm_rssi(struct nl80211_state *state,
05514f95
JB
13 struct nl_msg *msg, int argc, char **argv,
14 enum id_input id)
7988b229
JO
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();
8b80a2b3
AK
37 if (!cqm)
38 return -ENOMEM;
7988b229
JO
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
51TOPLEVEL(cqm, "",
52 0, 0, CIB_NETDEV, NULL,
53 "Configure the WLAN connection quality monitor.\n");
54
55COMMAND(cqm, rssi, "<threshold|off> [<hysteresis>]",
56 NL80211_CMD_SET_CQM, 0, CIB_NETDEV, iw_cqm_rssi,
57 "Set connection quality monitor RSSI threshold.\n");