madwifi: clean up scanning code, add support for changing scan lists
[openwrt/svn-archive/archive.git] / package / madwifi / patches / 346-protmode_trig.patch
1 Index: madwifi-trunk-r3314/net80211/ieee80211.c
2 ===================================================================
3 --- madwifi-trunk-r3314.orig/net80211/ieee80211.c 2008-04-23 04:33:06.000000000 +0200
4 +++ madwifi-trunk-r3314/net80211/ieee80211.c 2008-04-23 04:33:17.000000000 +0200
5 @@ -333,7 +333,9 @@
6 IEEE80211_MS_TO_TU(IEEE80211_BMISSTHRESH_DEFAULT_MS),
7 ic->ic_lintval), ic->ic_lintval);
8 }
9 -
10 + ic->ic_protmode_timeout = IEEE80211_PROTMODE_TIMEOUT;
11 + ic->ic_protmode_rssi = IEEE80211_PROTMODE_RSSITHR;
12 +
13 IEEE80211_LOCK_INIT(ic, "ieee80211com");
14 IEEE80211_VAPS_LOCK_INIT(ic, "ieee80211com_vaps");
15 TAILQ_INIT(&ic->ic_vaps);
16 Index: madwifi-trunk-r3314/net80211/ieee80211_input.c
17 ===================================================================
18 --- madwifi-trunk-r3314.orig/net80211/ieee80211_input.c 2008-04-23 04:33:17.000000000 +0200
19 +++ madwifi-trunk-r3314/net80211/ieee80211_input.c 2008-04-23 05:28:00.000000000 +0200
20 @@ -3412,14 +3412,18 @@
21 IEEE80211_IS_CHAN_ANYG(ic->ic_curchan)) {
22
23 /* Assume no ERP IE == 11b AP */
24 - if ((!has_erp || (has_erp && (scan.erp & IEEE80211_ERP_NON_ERP_PRESENT))) &&
25 - !(ic->ic_flags & IEEE80211_F_USEPROT)) {
26 + if ((!has_erp || (has_erp &&
27 + (scan.erp & IEEE80211_ERP_NON_ERP_PRESENT))) &&
28 + (rssi > ic->ic_protmode_rssi)) {
29 struct ieee80211vap *tmpvap;
30
31 - ic->ic_flags |= IEEE80211_F_USEPROT;
32 - TAILQ_FOREACH(tmpvap, &ic->ic_vaps, iv_next) {
33 - tmpvap->iv_flags_ext |= IEEE80211_FEXT_ERPUPDATE;
34 + if (!(ic->ic_flags & IEEE80211_F_USEPROT)) {
35 + ic->ic_flags |= IEEE80211_F_USEPROT;
36 + TAILQ_FOREACH(tmpvap, &ic->ic_vaps, iv_next) {
37 + tmpvap->iv_flags_ext |= IEEE80211_FEXT_ERPUPDATE;
38 + }
39 }
40 + ic->ic_protmode_lasttrig = jiffies;
41 }
42 }
43
44 Index: madwifi-trunk-r3314/net80211/ieee80211_ioctl.h
45 ===================================================================
46 --- madwifi-trunk-r3314.orig/net80211/ieee80211_ioctl.h 2008-04-23 04:33:17.000000000 +0200
47 +++ madwifi-trunk-r3314/net80211/ieee80211_ioctl.h 2008-04-23 04:33:17.000000000 +0200
48 @@ -643,6 +643,8 @@
49 IEEE80211_PARAM_BEACON_MISS_THRESH_MS = 74, /* Beacon miss threshold (in ms) */
50 IEEE80211_PARAM_MAXRATE = 75, /* Maximum rate (by table index) */
51 IEEE80211_PARAM_MINRATE = 76, /* Maximum rate (by table index) */
52 + IEEE80211_PARAM_PROTMODE_RSSI = 77, /* RSSI Threshold for enabling protection mode */
53 + IEEE80211_PARAM_PROTMODE_TIMEOUT = 78, /* Timeout for expiring protection mode */
54 };
55
56 #define SIOCG80211STATS (SIOCDEVPRIVATE+2)
57 Index: madwifi-trunk-r3314/net80211/ieee80211_var.h
58 ===================================================================
59 --- madwifi-trunk-r3314.orig/net80211/ieee80211_var.h 2008-04-23 04:33:17.000000000 +0200
60 +++ madwifi-trunk-r3314/net80211/ieee80211_var.h 2008-04-23 04:33:17.000000000 +0200
61 @@ -128,6 +128,9 @@
62
63 #define IEEE80211_APPIE_MAX 1024
64
65 +#define IEEE80211_PROTMODE_RSSITHR 15 /* default rssi threshold for protection mode trigger */
66 +#define IEEE80211_PROTMODE_TIMEOUT 30 /* timeout for keeping protection mode alive */
67 +
68 #define IEEE80211_PWRCONSTRAINT_VAL(ic) \
69 (((ic)->ic_bsschan->ic_maxregpower > (ic)->ic_curchanmaxpwr) ? \
70 (ic)->ic_bsschan->ic_maxregpower - (ic)->ic_curchanmaxpwr : 0)
71 @@ -324,6 +327,9 @@
72 u_int16_t ic_newtxpowlimit; /* tx power limit to change to (in 0.5 dBm) */
73 u_int16_t ic_uapsdmaxtriggers; /* max triggers that could arrive */
74 u_int8_t ic_coverageclass; /* coverage class */
75 + u_int8_t ic_protmode_rssi; /* rssi threshold for protection mode */
76 + u_int64_t ic_protmode_lasttrig; /* last trigger for protection mode */
77 + u_int16_t ic_protmode_timeout; /* protection mode timeout */
78
79 /* Channel state:
80 *
81 Index: madwifi-trunk-r3314/net80211/ieee80211_wireless.c
82 ===================================================================
83 --- madwifi-trunk-r3314.orig/net80211/ieee80211_wireless.c 2008-04-23 04:33:17.000000000 +0200
84 +++ madwifi-trunk-r3314/net80211/ieee80211_wireless.c 2008-04-23 04:33:17.000000000 +0200
85 @@ -2312,6 +2312,12 @@
86 IEEE80211_IS_CHAN_ANYG(ic->ic_bsschan))
87 retv = ENETRESET;
88 break;
89 + case IEEE80211_PARAM_PROTMODE_TIMEOUT:
90 + ic->ic_protmode_timeout = value;
91 + break;
92 + case IEEE80211_PARAM_PROTMODE_RSSI:
93 + ic->ic_protmode_rssi = value;
94 + break;
95 case IEEE80211_PARAM_MCASTCIPHER:
96 if ((vap->iv_caps & cipher2cap(value)) == 0 &&
97 !ieee80211_crypto_available(vap, value))
98 @@ -2955,6 +2961,12 @@
99 case IEEE80211_PARAM_PROTMODE:
100 param[0] = ic->ic_protmode;
101 break;
102 + case IEEE80211_PARAM_PROTMODE_TIMEOUT:
103 + param[0] = ic->ic_protmode_timeout;
104 + break;
105 + case IEEE80211_PARAM_PROTMODE_RSSI:
106 + param[0] = ic->ic_protmode_rssi;
107 + break;
108 case IEEE80211_PARAM_MCASTCIPHER:
109 param[0] = rsn->rsn_mcastcipher;
110 break;
111 @@ -5346,6 +5358,14 @@
112 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "protmode" },
113 { IEEE80211_PARAM_PROTMODE,
114 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_protmode" },
115 + { IEEE80211_PARAM_PROTMODE_RSSI,
116 + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "protrssi" },
117 + { IEEE80211_PARAM_PROTMODE_RSSI,
118 + 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_protrssi" },
119 + { IEEE80211_PARAM_PROTMODE_TIMEOUT,
120 + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "prottime" },
121 + { IEEE80211_PARAM_PROTMODE_TIMEOUT,
122 + 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_prottime" },
123 { IEEE80211_PARAM_MCASTCIPHER,
124 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "mcastcipher" },
125 { IEEE80211_PARAM_MCASTCIPHER,
126 Index: madwifi-trunk-r3314/net80211/ieee80211_node.c
127 ===================================================================
128 --- madwifi-trunk-r3314.orig/net80211/ieee80211_node.c 2008-04-23 04:33:16.000000000 +0200
129 +++ madwifi-trunk-r3314/net80211/ieee80211_node.c 2008-04-23 05:28:47.000000000 +0200
130 @@ -1877,6 +1877,17 @@
131
132 ieee80211_scan_timeout(ic);
133 ieee80211_timeout_stations(&ic->ic_sta);
134 + if ((ic->ic_flags & IEEE80211_F_USEPROT) &&
135 + (ic->ic_protmode_lasttrig + ic->ic_protmode_timeout * HZ <
136 + jiffies)) {
137 + struct ieee80211vap *tmpvap;
138 +
139 + /* expire protection mode */
140 + ic->ic_flags &= ~IEEE80211_F_USEPROT;
141 + TAILQ_FOREACH(tmpvap, &ic->ic_vaps, iv_next) {
142 + tmpvap->iv_flags_ext |= IEEE80211_FEXT_ERPUPDATE;
143 + }
144 + }
145
146 ic->ic_inact.expires = jiffies + IEEE80211_INACT_WAIT * HZ;
147 add_timer(&ic->ic_inact);