blob: 093b744baba501c3bba645720eca1a826462d4b9 [file] [log] [blame]
Juuso Oikarinen7988b222010-03-26 07:46:19 +02001#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
Sunil Ravi44e0e582022-03-05 11:09:09 -080012static int iw_cqm_rssi(struct nl80211_state *state,
Johannes Berg05514f92012-07-19 11:50:50 +020013 struct nl_msg *msg, int argc, char **argv,
14 enum id_input id)
Juuso Oikarinen7988b222010-03-26 07:46:19 +020015{
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();
Sunil Ravi44e0e582022-03-05 11:09:09 -080037 if (!cqm)
38 return -ENOMEM;
Juuso Oikarinen7988b222010-03-26 07:46:19 +020039
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");