1 Index: madwifi-trunk-r3776/net80211/ieee80211.c
2 ===================================================================
3 --- madwifi-trunk-r3776.orig/net80211/ieee80211.c 2008-07-17 00:21:29.000000000 +0200
4 +++ madwifi-trunk-r3776/net80211/ieee80211.c 2008-07-17 02:56:18.000000000 +0200
6 IEEE80211_MS_TO_TU(IEEE80211_BMISSTHRESH_DEFAULT_MS),
7 ic->ic_lintval), ic->ic_lintval);
10 + ic->ic_protmode_timeout = IEEE80211_PROTMODE_TIMEOUT;
11 + ic->ic_protmode_rssi = IEEE80211_PROTMODE_RSSITHR;
13 IEEE80211_LOCK_INIT(ic, "ieee80211com");
14 IEEE80211_VAPS_LOCK_INIT(ic, "ieee80211com_vaps");
15 TAILQ_INIT(&ic->ic_vaps);
16 Index: madwifi-trunk-r3776/net80211/ieee80211_input.c
17 ===================================================================
18 --- madwifi-trunk-r3776.orig/net80211/ieee80211_input.c 2008-07-17 02:30:28.000000000 +0200
19 +++ madwifi-trunk-r3776/net80211/ieee80211_input.c 2008-07-17 02:56:18.000000000 +0200
20 @@ -3382,14 +3382,18 @@
21 IEEE80211_IS_CHAN_ANYG(ic->ic_curchan)) {
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;
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;
40 + ic->ic_protmode_lasttrig = jiffies;
44 Index: madwifi-trunk-r3776/net80211/ieee80211_ioctl.h
45 ===================================================================
46 --- madwifi-trunk-r3776.orig/net80211/ieee80211_ioctl.h 2008-07-17 02:25:53.000000000 +0200
47 +++ madwifi-trunk-r3776/net80211/ieee80211_ioctl.h 2008-07-17 02:56:52.000000000 +0200
49 IEEE80211_PARAM_LEAKTXBUFS = 82, /* Leak tx buffers */
50 IEEE80211_PARAM_MAXRATE = 83, /* Maximum rate (by table index) */
51 IEEE80211_PARAM_MINRATE = 84, /* Minimum rate (by table index) */
52 + IEEE80211_PARAM_PROTMODE_RSSI = 85, /* RSSI Threshold for enabling protection mode */
53 + IEEE80211_PARAM_PROTMODE_TIMEOUT = 86, /* Timeout for expiring protection mode */
56 #define SIOCG80211STATS (SIOCDEVPRIVATE+2)
57 Index: madwifi-trunk-r3776/net80211/ieee80211_var.h
58 ===================================================================
59 --- madwifi-trunk-r3776.orig/net80211/ieee80211_var.h 2008-07-17 02:23:00.000000000 +0200
60 +++ madwifi-trunk-r3776/net80211/ieee80211_var.h 2008-07-17 02:56:18.000000000 +0200
63 #define IEEE80211_APPIE_MAX 1024
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 */
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)
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 */
81 Index: madwifi-trunk-r3776/net80211/ieee80211_wireless.c
82 ===================================================================
83 --- madwifi-trunk-r3776.orig/net80211/ieee80211_wireless.c 2008-07-17 02:26:17.000000000 +0200
84 +++ madwifi-trunk-r3776/net80211/ieee80211_wireless.c 2008-07-17 02:56:18.000000000 +0200
85 @@ -2336,6 +2336,12 @@
86 case IEEE80211_PARAM_RSSI_EWMA:
87 ic->ic_rssi_ewma = value;
89 + case IEEE80211_PARAM_PROTMODE_TIMEOUT:
90 + ic->ic_protmode_timeout = value;
92 + case IEEE80211_PARAM_PROTMODE_RSSI:
93 + ic->ic_protmode_rssi = value;
95 case IEEE80211_PARAM_MCASTCIPHER:
96 if ((vap->iv_caps & cipher2cap(value)) == 0 &&
97 !ieee80211_crypto_available(vap, value))
98 @@ -2992,6 +2998,12 @@
99 case IEEE80211_PARAM_RSSI_EWMA:
100 param[0] = ic->ic_rssi_ewma;
102 + case IEEE80211_PARAM_PROTMODE_TIMEOUT:
103 + param[0] = ic->ic_protmode_timeout;
105 + case IEEE80211_PARAM_PROTMODE_RSSI:
106 + param[0] = ic->ic_protmode_rssi;
108 case IEEE80211_PARAM_MCASTCIPHER:
109 param[0] = rsn->rsn_mcastcipher;
111 @@ -5384,6 +5396,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-r3776/net80211/ieee80211_node.c
127 ===================================================================
128 --- madwifi-trunk-r3776.orig/net80211/ieee80211_node.c 2008-07-17 02:20:51.000000000 +0200
129 +++ madwifi-trunk-r3776/net80211/ieee80211_node.c 2008-07-17 02:56:18.000000000 +0200
130 @@ -1591,6 +1591,17 @@
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 <
137 + struct ieee80211vap *tmpvap;
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;
146 mod_timer(&ic->ic_inact, jiffies + IEEE80211_INACT_WAIT * HZ);