2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 * Purpose: Handles the Basic Service Set & Node Database functions
33 #include <linux/skbuff.h>
38 /*--------------------- Export Definitions -------------------------*/
40 #define MAX_NODE_NUM 64
41 #define MAX_BSS_NUM 42
42 #define LOST_BEACON_COUNT 10 // 10 sec, XP defined
43 #define MAX_PS_TX_BUF 32 // sta max power saving tx buf
44 #define ADHOC_LOST_BEACON_COUNT 30 // 30 sec, beacon lost for adhoc only
45 #define MAX_INACTIVE_COUNT 300 // 300 sec, inactive STA node refresh
47 #define USE_PROTECT_PERIOD 10 // 10 sec, Use protect mode check period
48 #define ERP_RECOVER_COUNT 30 // 30 sec, ERP support callback check
49 #define BSS_CLEAR_COUNT 1
51 #define RSSI_STAT_COUNT 10
52 #define MAX_CHECK_RSSI_COUNT 8
55 #define WLAN_STA_AUTH BIT0
56 #define WLAN_STA_ASSOC BIT1
57 #define WLAN_STA_PS BIT2
58 #define WLAN_STA_TIM BIT3
59 // permanent; do not remove entry on expiration
60 #define WLAN_STA_PERM BIT4
61 // If 802.1X is used, this flag is
62 // controlling whether STA is authorized to
63 // send and receive non-IEEE 802.1X frames
64 #define WLAN_STA_AUTHORIZED BIT5
68 #define MAX_WPA_IE_LEN 64
71 /*--------------------- Export Classes ----------------------------*/
73 /*--------------------- Export Variables --------------------------*/
76 /*--------------------- Export Types ------------------------------*/
79 // IEEE 802.11 Structures and definitions
82 typedef enum _NDIS_802_11_NETWORK_TYPE
88 Ndis802_11NetworkTypeMax
// not a real type, defined as an upper bound
89 } NDIS_802_11_NETWORK_TYPE
, *PNDIS_802_11_NETWORK_TYPE
;
92 typedef struct tagSERPObject
{
95 }ERPObject
, *PERPObject
;
98 typedef struct tagSRSNCapObject
{
100 unsigned short wRSNCap
;
101 }SRSNCapObject
, *PSRSNCapObject
;
105 typedef struct tagKnownBSS
{
108 unsigned char abyBSSID
[WLAN_BSSID_LEN
];
109 unsigned int uChannel
;
110 unsigned char abySuppRates
[WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1];
111 unsigned char abyExtSuppRates
[WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1];
114 unsigned short wBeaconInterval
;
115 unsigned short wCapInfo
;
116 unsigned char abySSID
[WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1];
117 unsigned char byRxRate
;
119 // unsigned short wATIMWindow;
120 unsigned char byRSSIStatCnt
;
122 long ldBmAverage
[RSSI_STAT_COUNT
];
124 //For any BSSID selection improvment
127 //++ WPA informations
129 unsigned char byGKType
;
130 unsigned char abyPKType
[4];
131 unsigned short wPKCount
;
132 unsigned char abyAuthType
[4];
133 unsigned short wAuthCount
;
134 unsigned char byDefaultK_as_PK
;
135 unsigned char byReplayIdx
;
138 //++ WPA2 informations
140 unsigned char byCSSGK
;
141 unsigned short wCSSPKCount
;
142 unsigned char abyCSSPK
[4];
143 unsigned short wAKMSSAuthCount
;
144 unsigned char abyAKMSSAuthType
[4];
147 unsigned char byWPAIE
[MAX_WPA_IE_LEN
];
148 unsigned char byRSNIE
[MAX_WPA_IE_LEN
];
149 unsigned short wWPALen
;
150 unsigned short wRSNLen
;
153 unsigned int uClearCount
;
154 // unsigned char abyIEs[WLAN_BEACON_FR_MAXLEN];
155 unsigned int uIELength
;
156 QWORD qwBSSTimestamp
;
157 QWORD qwLocalTSF
; // local TSF timer
159 // NDIS_802_11_NETWORK_TYPE NetworkTypeInUse;
160 CARD_PHY_TYPE eNetworkTypeInUse
;
163 SRSNCapObject sRSNCapObj
;
164 unsigned char abyIEs
[1024]; // don't move this field !!
166 }__attribute__ ((__packed__
))
167 KnownBSS
, *PKnownBSS
;
169 //2006-1116-01,<Add> by NomadZhao
172 typedef enum tagNODE_STATE
{
178 } NODE_STATE
, *PNODE_STATE
;
182 typedef struct tagKnownNodeDB
{
185 unsigned char abyMACAddr
[WLAN_ADDR_LEN
];
186 unsigned char abyCurrSuppRates
[WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
];
187 unsigned char abyCurrExtSuppRates
[WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
];
188 unsigned short wTxDataRate
;
192 unsigned int uInActiveCount
;
193 unsigned short wMaxBasicRate
; //Get from byTopOFDMBasicRate or byTopCCKBasicRate which depends on packetTyp.
194 unsigned short wMaxSuppRate
; //Records the highest supported rate getting from SuppRates IE and ExtSuppRates IE in Beacon.
195 unsigned short wSuppRate
;
196 unsigned char byTopOFDMBasicRate
;//Records the highest basic rate in OFDM mode
197 unsigned char byTopCCKBasicRate
; //Records the highest basic rate in CCK mode
200 struct sk_buff_head sTxPSQueue
;
201 unsigned short wCapInfo
;
202 unsigned short wListenInterval
;
204 NODE_STATE eNodeState
;
207 unsigned char byAuthSequence
;
208 unsigned long ulLastRxJiffer
;
209 unsigned char bySuppRate
;
210 unsigned long dwFlags
;
211 unsigned short wEnQueueCnt
;
214 unsigned long long KeyRSC
;
215 unsigned char byKeyIndex
;
216 unsigned long dwKeyIndex
;
217 unsigned char byCipherSuite
;
218 unsigned long dwTSC47_16
;
219 unsigned short wTSC15_0
;
220 unsigned int uWepKeyLength
;
221 unsigned char abyWepKey
[WLAN_WEPMAX_KEYLEN
];
223 // Auto rate fallback vars
225 unsigned int uAverageRSSI
;
226 unsigned int uRateRecoveryTimeout
;
227 unsigned int uRatePollTimeout
;
228 unsigned int uTxFailures
;
229 unsigned int uTxAttempts
;
231 unsigned int uTxRetry
;
232 unsigned int uFailureRatio
;
233 unsigned int uRetryRatio
;
234 unsigned int uTxOk
[MAX_RATE
+1];
235 unsigned int uTxFail
[MAX_RATE
+1];
236 unsigned int uTimeCount
;
238 } KnownNodeDB
, *PKnownNodeDB
;
241 /*--------------------- Export Functions --------------------------*/
247 void *hDeviceContext
,
248 unsigned char *pbyDesireBSSID
,
249 unsigned char *pbyDesireSSID
,
250 CARD_PHY_TYPE ePhyType
255 void *hDeviceContext
,
256 unsigned char *abyBSSID
,
262 void *hDeviceContext
,
268 void *hDeviceContext
,
269 unsigned char *abyBSSIDAddr
,
271 unsigned short wBeaconInterval
,
272 unsigned short wCapInfo
,
273 unsigned char byCurrChannel
,
275 PWLAN_IE_SUPP_RATES pSuppRates
,
276 PWLAN_IE_SUPP_RATES pExtSuppRates
,
279 PWLAN_IE_RSN_EXT pRSNWPA
,
280 PWLAN_IE_COUNTRY pIE_Country
,
281 PWLAN_IE_QUIET pIE_Quiet
,
282 unsigned int uIELength
,
283 unsigned char *pbyIEs
,
284 void *pRxPacketContext
290 void *hDeviceContext
,
292 unsigned short wBeaconInterval
,
293 unsigned short wCapInfo
,
294 unsigned char byCurrChannel
,
297 PWLAN_IE_SUPP_RATES pSuppRates
,
298 PWLAN_IE_SUPP_RATES pExtSuppRates
,
301 PWLAN_IE_RSN_EXT pRSNWPA
,
302 PWLAN_IE_COUNTRY pIE_Country
,
303 PWLAN_IE_QUIET pIE_Quiet
,
305 unsigned int uIELength
,
306 unsigned char *pbyIEs
,
307 void *pRxPacketContext
312 BSSDBbIsSTAInNodeDB(void *hDeviceContext
, unsigned char *abyDstAddr
,
313 unsigned int *puNodeIndex
);
316 BSSvCreateOneNode(void *hDeviceContext
, unsigned int *puNodeIndex
);
320 void *hDeviceContext
,
321 unsigned short *pwCapInfo
,
322 PWLAN_IE_SUPP_RATES pItemRates
,
323 PWLAN_IE_SUPP_RATES pExtSuppRates
334 BSSvUpdateNodeTxCounter(
335 void *hDeviceContext
,
336 unsigned char byTsr0
,
337 unsigned char byTsr1
,
338 unsigned char *pbyBuffer
,
339 unsigned int uFIFOHeaderSize
344 void *hDeviceContext
,
345 unsigned int uNodeIndex
349 BSSvAddMulticastNode(
355 BSSvClearNodeDBTable(
356 void *hDeviceContext
,
357 unsigned int uStartIndex
361 BSSvClearAnyBSSJoinRecord(