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
70 /*--------------------- Export Classes ----------------------------*/
72 /*--------------------- Export Variables --------------------------*/
74 /*--------------------- Export Types ------------------------------*/
77 // IEEE 802.11 Structures and definitions
80 typedef enum _NDIS_802_11_NETWORK_TYPE
86 Ndis802_11NetworkTypeMax
// not a real type, defined as an upper bound
87 } NDIS_802_11_NETWORK_TYPE
, *PNDIS_802_11_NETWORK_TYPE
;
89 typedef struct tagSERPObject
{
92 } ERPObject
, *PERPObject
;
94 typedef struct tagSRSNCapObject
{
96 unsigned short wRSNCap
;
97 } SRSNCapObject
, *PSRSNCapObject
;
101 typedef struct tagKnownBSS
{
104 unsigned char abyBSSID
[WLAN_BSSID_LEN
];
105 unsigned int uChannel
;
106 unsigned char abySuppRates
[WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1];
107 unsigned char abyExtSuppRates
[WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1];
110 unsigned short wBeaconInterval
;
111 unsigned short wCapInfo
;
112 unsigned char abySSID
[WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1];
113 unsigned char byRxRate
;
115 // unsigned short wATIMWindow;
116 unsigned char byRSSIStatCnt
;
118 long ldBmAverage
[RSSI_STAT_COUNT
];
120 //For any BSSID selection improvment
123 //++ WPA informations
125 unsigned char byGKType
;
126 unsigned char abyPKType
[4];
127 unsigned short wPKCount
;
128 unsigned char abyAuthType
[4];
129 unsigned short wAuthCount
;
130 unsigned char byDefaultK_as_PK
;
131 unsigned char byReplayIdx
;
134 //++ WPA2 informations
136 unsigned char byCSSGK
;
137 unsigned short wCSSPKCount
;
138 unsigned char abyCSSPK
[4];
139 unsigned short wAKMSSAuthCount
;
140 unsigned char abyAKMSSAuthType
[4];
143 unsigned char byWPAIE
[MAX_WPA_IE_LEN
];
144 unsigned char byRSNIE
[MAX_WPA_IE_LEN
];
145 unsigned short wWPALen
;
146 unsigned short wRSNLen
;
149 unsigned int uClearCount
;
150 // unsigned char abyIEs[WLAN_BEACON_FR_MAXLEN];
151 unsigned int uIELength
;
152 QWORD qwBSSTimestamp
;
153 QWORD qwLocalTSF
; // local TSF timer
155 // NDIS_802_11_NETWORK_TYPE NetworkTypeInUse;
156 CARD_PHY_TYPE eNetworkTypeInUse
;
159 SRSNCapObject sRSNCapObj
;
160 unsigned char abyIEs
[1024]; // don't move this field !!
161 } __attribute__ ((__packed__
))
162 KnownBSS
, *PKnownBSS
;
164 //2006-1116-01,<Add> by NomadZhao
167 typedef enum tagNODE_STATE
{
173 } NODE_STATE
, *PNODE_STATE
;
176 typedef struct tagKnownNodeDB
{
179 unsigned char abyMACAddr
[WLAN_ADDR_LEN
];
180 unsigned char abyCurrSuppRates
[WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
];
181 unsigned char abyCurrExtSuppRates
[WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
];
182 unsigned short wTxDataRate
;
186 unsigned int uInActiveCount
;
187 unsigned short wMaxBasicRate
; //Get from byTopOFDMBasicRate or byTopCCKBasicRate which depends on packetTyp.
188 unsigned short wMaxSuppRate
; //Records the highest supported rate getting from SuppRates IE and ExtSuppRates IE in Beacon.
189 unsigned short wSuppRate
;
190 unsigned char byTopOFDMBasicRate
;//Records the highest basic rate in OFDM mode
191 unsigned char byTopCCKBasicRate
; //Records the highest basic rate in CCK mode
194 struct sk_buff_head sTxPSQueue
;
195 unsigned short wCapInfo
;
196 unsigned short wListenInterval
;
198 NODE_STATE eNodeState
;
201 unsigned char byAuthSequence
;
202 unsigned long ulLastRxJiffer
;
203 unsigned char bySuppRate
;
204 unsigned long dwFlags
;
205 unsigned short wEnQueueCnt
;
208 unsigned long long KeyRSC
;
209 unsigned char byKeyIndex
;
210 unsigned long dwKeyIndex
;
211 unsigned char byCipherSuite
;
212 unsigned long dwTSC47_16
;
213 unsigned short wTSC15_0
;
214 unsigned int uWepKeyLength
;
215 unsigned char abyWepKey
[WLAN_WEPMAX_KEYLEN
];
217 // Auto rate fallback vars
219 unsigned int uAverageRSSI
;
220 unsigned int uRateRecoveryTimeout
;
221 unsigned int uRatePollTimeout
;
222 unsigned int uTxFailures
;
223 unsigned int uTxAttempts
;
225 unsigned int uTxRetry
;
226 unsigned int uFailureRatio
;
227 unsigned int uRetryRatio
;
228 unsigned int uTxOk
[MAX_RATE
+1];
229 unsigned int uTxFail
[MAX_RATE
+1];
230 unsigned int uTimeCount
;
231 } KnownNodeDB
, *PKnownNodeDB
;
233 /*--------------------- Export Functions --------------------------*/
237 void *hDeviceContext
,
238 unsigned char *pbyDesireBSSID
,
239 unsigned char *pbyDesireSSID
,
240 CARD_PHY_TYPE ePhyType
245 void *hDeviceContext
,
246 unsigned char *abyBSSID
,
252 void *hDeviceContext
,
258 void *hDeviceContext
,
259 unsigned char *abyBSSIDAddr
,
261 unsigned short wBeaconInterval
,
262 unsigned short wCapInfo
,
263 unsigned char byCurrChannel
,
265 PWLAN_IE_SUPP_RATES pSuppRates
,
266 PWLAN_IE_SUPP_RATES pExtSuppRates
,
269 PWLAN_IE_RSN_EXT pRSNWPA
,
270 PWLAN_IE_COUNTRY pIE_Country
,
271 PWLAN_IE_QUIET pIE_Quiet
,
272 unsigned int uIELength
,
273 unsigned char *pbyIEs
,
274 void *pRxPacketContext
279 void *hDeviceContext
,
281 unsigned short wBeaconInterval
,
282 unsigned short wCapInfo
,
283 unsigned char byCurrChannel
,
286 PWLAN_IE_SUPP_RATES pSuppRates
,
287 PWLAN_IE_SUPP_RATES pExtSuppRates
,
290 PWLAN_IE_RSN_EXT pRSNWPA
,
291 PWLAN_IE_COUNTRY pIE_Country
,
292 PWLAN_IE_QUIET pIE_Quiet
,
294 unsigned int uIELength
,
295 unsigned char *pbyIEs
,
296 void *pRxPacketContext
300 BSSDBbIsSTAInNodeDB(void *hDeviceContext
, unsigned char *abyDstAddr
,
301 unsigned int *puNodeIndex
);
304 BSSvCreateOneNode(void *hDeviceContext
, unsigned int *puNodeIndex
);
308 void *hDeviceContext
,
309 unsigned short *pwCapInfo
,
310 PWLAN_IE_SUPP_RATES pItemRates
,
311 PWLAN_IE_SUPP_RATES pExtSuppRates
320 BSSvUpdateNodeTxCounter(
321 void *hDeviceContext
,
322 unsigned char byTsr0
,
323 unsigned char byTsr1
,
324 unsigned char *pbyBuffer
,
325 unsigned int uFIFOHeaderSize
330 void *hDeviceContext
,
331 unsigned int uNodeIndex
335 BSSvAddMulticastNode(
340 BSSvClearNodeDBTable(
341 void *hDeviceContext
,
342 unsigned int uStartIndex
346 BSSvClearAnyBSSJoinRecord(