-
Notifications
You must be signed in to change notification settings - Fork 0
/
cqm.c
55 lines (42 loc) · 1.16 KB
/
cqm.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <errno.h>
#include <netlink/genl/genl.h>
#include <netlink/genl/family.h>
#include <netlink/genl/ctrl.h>
#include <netlink/msg.h>
#include <netlink/attr.h>
#include "nl80211.h"
#include "iw.h"
static int iw_cqm_rssi(struct nl80211_state *state, struct nl_cb *cb,
struct nl_msg *msg, int argc, char **argv,
enum id_input id)
{
struct nl_msg *cqm = NULL;
int thold = 0;
int hyst = 0;
int ret = -ENOSPC;
/* get the required args */
if (argc < 1 || argc > 2)
return 1;
if (strcmp(argv[0], "off")) {
thold = atoi(argv[0]);
if (thold == 0)
return -EINVAL;
if (argc == 2)
hyst = atoi(argv[1]);
}
/* connection quality monitor attributes */
cqm = nlmsg_alloc();
NLA_PUT_U32(cqm, NL80211_ATTR_CQM_RSSI_THOLD, thold);
NLA_PUT_U32(cqm, NL80211_ATTR_CQM_RSSI_HYST, hyst);
nla_put_nested(msg, NL80211_ATTR_CQM, cqm);
ret = 0;
nla_put_failure:
nlmsg_free(cqm);
return ret;
}
TOPLEVEL(cqm, "",
0, 0, CIB_NETDEV, NULL,
"Configure the WLAN connection quality monitor.\n");
COMMAND(cqm, rssi, "<threshold|off> [<hysteresis>]",
NL80211_CMD_SET_CQM, 0, CIB_NETDEV, iw_cqm_rssi,
"Set connection quality monitor RSSI threshold.\n");