]>
Commit | Line | Data |
---|---|---|
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 | ||
12 | static int iw_cqm_rssi(struct nl80211_state *state, struct nl_cb *cb, | |
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(); | |
37 | ||
38 | NLA_PUT_U32(cqm, NL80211_ATTR_CQM_RSSI_THOLD, thold); | |
39 | NLA_PUT_U32(cqm, NL80211_ATTR_CQM_RSSI_HYST, hyst); | |
40 | ||
41 | nla_put_nested(msg, NL80211_ATTR_CQM, cqm); | |
42 | ret = 0; | |
43 | ||
44 | nla_put_failure: | |
45 | nlmsg_free(cqm); | |
46 | return ret; | |
47 | } | |
48 | ||
49 | TOPLEVEL(cqm, "", | |
50 | 0, 0, CIB_NETDEV, NULL, | |
51 | "Configure the WLAN connection quality monitor.\n"); | |
52 | ||
53 | COMMAND(cqm, rssi, "<threshold|off> [<hysteresis>]", | |
54 | NL80211_CMD_SET_CQM, 0, CIB_NETDEV, iw_cqm_rssi, | |
55 | "Set connection quality monitor RSSI threshold.\n"); |