aboutsummaryrefslogtreecommitdiffstats
path: root/package/madwifi/patches/362-rssithr.patch
blob: c1654d59b66cc2a6ad78d9afc5990d3e39c455c8 (plain)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
Add an optional threshold for low-rssi disconnection. This can be useful
when letting wpa_supplicant control roaming.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>

--- a/net80211/ieee80211_ioctl.h
+++ b/net80211/ieee80211_ioctl.h
@@ -647,6 +647,8 @@
 	IEEE80211_PARAM_PROTMODE_RSSI		= 77,	/* RSSI Threshold for enabling protection mode */
 	IEEE80211_PARAM_PROTMODE_TIMEOUT	= 78,	/* Timeout for expiring protection mode */
 	IEEE80211_PARAM_BGSCAN_THRESH		= 79,	/* bg scan rssi threshold */
+	IEEE80211_PARAM_RSSI_DIS_THR	= 80,	/* rssi threshold for disconnection */
+	IEEE80211_PARAM_RSSI_DIS_COUNT	= 81,	/* counter for rssi threshold */
 };
 
 #define	SIOCG80211STATS			(SIOCDEVPRIVATE+2)
--- a/net80211/ieee80211_wireless.c
+++ b/net80211/ieee80211_wireless.c
@@ -2798,6 +2798,12 @@
 	case IEEE80211_PARAM_ROAM_RATE_11G:
 		vap->iv_roam.rate11b = value;
 		break;
+	case IEEE80211_PARAM_RSSI_DIS_THR:
+		vap->iv_rssi_dis_thr = value;
+		break;
+	case IEEE80211_PARAM_RSSI_DIS_COUNT:
+		vap->iv_rssi_dis_max = value;
+		break;
 	case IEEE80211_PARAM_UAPSDINFO:
 		if (vap->iv_opmode == IEEE80211_M_HOSTAP) {
 			if (ic->ic_caps & IEEE80211_C_UAPSD) {
@@ -3183,6 +3189,12 @@
 	case IEEE80211_PARAM_ROAM_RATE_11G:
 		param[0] = vap->iv_roam.rate11b;
 		break;
+	case IEEE80211_PARAM_RSSI_DIS_THR:
+		param[0] = vap->iv_rssi_dis_thr;
+		break;
+	case IEEE80211_PARAM_RSSI_DIS_COUNT:
+		param[0] = vap->iv_rssi_dis_max;
+		break;
 	case IEEE80211_PARAM_UAPSDINFO:
 		if (vap->iv_opmode == IEEE80211_M_HOSTAP) {
 			if (IEEE80211_VAP_UAPSD_ENABLED(vap))
@@ -5732,6 +5744,14 @@
 	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "rate11g" },
 	{ IEEE80211_PARAM_ROAM_RATE_11G,
 	  0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_rate11g" },
+	{ IEEE80211_PARAM_RSSI_DIS_THR,
+	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "rssi_disthr" },
+	{ IEEE80211_PARAM_RSSI_DIS_THR,
+	  0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_rssi_disthr" },
+	{ IEEE80211_PARAM_RSSI_DIS_COUNT,
+	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "rssi_discnt" },
+	{ IEEE80211_PARAM_RSSI_DIS_COUNT,
+	  0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_rssi_discnt" },
 	{ IEEE80211_PARAM_UAPSDINFO,
 	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "uapsd" },
 	{ IEEE80211_PARAM_UAPSDINFO,
--- a/net80211/ieee80211_input.c
+++ b/net80211/ieee80211_input.c
@@ -3261,6 +3261,19 @@
 			memcpy(ni->ni_tstamp.data, scan.tstamp,
 				sizeof(ni->ni_tstamp));
 
+			/* when rssi falls below the disconnection threshold, drop the connection */
+			if ((vap->iv_rssi_dis_thr > 0) && (vap->iv_rssi_dis_max > 0)) {
+				if ((rssi > 0) && (rssi < vap->iv_rssi_dis_thr)) {
+					if (++vap->iv_rssi_dis_trig > vap->iv_rssi_dis_max) {
+						vap->iv_rssi_dis_trig = 0;
+						ieee80211_node_leave(ni);
+						return;
+					}
+				} else {
+					vap->iv_rssi_dis_trig = 0;
+				}
+			}
+
 			/* When rssi is low, start doing bgscans more frequently to allow
 			 * the supplicant to make a better switching decision */
 			if (!(ic->ic_flags & IEEE80211_F_SCAN) && (rssi < vap->iv_bgscanthr) &&
--- a/net80211/ieee80211_var.h
+++ b/net80211/ieee80211_var.h
@@ -223,6 +223,9 @@
 	u_int iv_bgscanintvl;				/* bg scan min interval */
 	u_int iv_bgscanthr;					/* bg scan rssi threshold */
 	u_int iv_bgscantrintvl;				/* bg scan trigger interval */
+	u_int iv_rssi_dis_thr;				/* rssi disassoc threshold */
+	u_int iv_rssi_dis_max;				/* max beacons below disconnect threshold */
+	u_int iv_rssi_dis_trig;				/* rssi disassoc trigger count */
 	unsigned long iv_bgscanthr_next;		/* last trigger for bgscan */
 	unsigned long iv_lastconnect;	/* time of last connect attempt */
 	u_int iv_scanvalid;				/* scan cache valid threshold */