blob: 0af42118612218aabe7c7c1794da88e97a3bd32c [file] [log] [blame]
Forest Bond5449c682009-04-25 10:30:44 -04001/*
2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3 * All rights reserved.
4 *
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.
9 *
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.
14 *
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.
18 *
19 *
20 * File: bssdb.h
21 *
22 * Purpose: Handles the Basic Service Set & Node Database functions
23 *
24 * Author: Lyndon Chen
25 *
26 * Date: July 16, 2002
27 *
28 */
29
30#ifndef __BSSDB_H__
31#define __BSSDB_H__
32
Forest Bond5449c682009-04-25 10:30:44 -040033#include <linux/skbuff.h>
Forest Bond5449c682009-04-25 10:30:44 -040034#include "80211hdr.h"
Forest Bond5449c682009-04-25 10:30:44 -040035#include "80211mgr.h"
Forest Bond5449c682009-04-25 10:30:44 -040036#include "card.h"
Forest Bond5449c682009-04-25 10:30:44 -040037
38/*--------------------- Export Definitions -------------------------*/
39
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
46
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
50
51#define RSSI_STAT_COUNT 10
52#define MAX_CHECK_RSSI_COUNT 8
53
54// STA dwflags
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
65
66#define MAX_RATE 12
67
68#define MAX_WPA_IE_LEN 64
69
70
71/*--------------------- Export Classes ----------------------------*/
72
73/*--------------------- Export Variables --------------------------*/
74
75
76/*--------------------- Export Types ------------------------------*/
77
78//
79// IEEE 802.11 Structures and definitions
80//
81
82typedef enum _NDIS_802_11_NETWORK_TYPE
83{
84 Ndis802_11FH,
85 Ndis802_11DS,
86 Ndis802_11OFDM5,
87 Ndis802_11OFDM24,
88 Ndis802_11NetworkTypeMax // not a real type, defined as an upper bound
89} NDIS_802_11_NETWORK_TYPE, *PNDIS_802_11_NETWORK_TYPE;
90
91
92typedef struct tagSERPObject {
Charles Clément7b6a0012010-08-01 17:15:50 +020093 bool bERPExist;
Charles Clément3fc9b582010-06-24 11:02:27 -070094 unsigned char byERP;
Jim Lieba8848472009-08-12 14:54:07 -070095}ERPObject, *PERPObject;
Forest Bond5449c682009-04-25 10:30:44 -040096
97
98typedef struct tagSRSNCapObject {
Charles Clément7b6a0012010-08-01 17:15:50 +020099 bool bRSNCapExist;
Charles Clément2986db52010-06-24 11:02:26 -0700100 unsigned short wRSNCap;
Jim Lieba8848472009-08-12 14:54:07 -0700101}SRSNCapObject, *PSRSNCapObject;
Forest Bond5449c682009-04-25 10:30:44 -0400102
103// BSS info(AP)
104#pragma pack(1)
105typedef struct tagKnownBSS {
106 // BSS info
Charles Clément7b6a0012010-08-01 17:15:50 +0200107 bool bActive;
Charles Clément3fc9b582010-06-24 11:02:27 -0700108 unsigned char abyBSSID[WLAN_BSSID_LEN];
Charles Clémentb6e95cd2010-06-02 09:52:01 -0700109 unsigned int uChannel;
Charles Clément3fc9b582010-06-24 11:02:27 -0700110 unsigned char abySuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
111 unsigned char abyExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
Charles Clémentb6e95cd2010-06-02 09:52:01 -0700112 unsigned int uRSSI;
Charles Clément3fc9b582010-06-24 11:02:27 -0700113 unsigned char bySQ;
Charles Clément2986db52010-06-24 11:02:26 -0700114 unsigned short wBeaconInterval;
115 unsigned short wCapInfo;
Charles Clément3fc9b582010-06-24 11:02:27 -0700116 unsigned char abySSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
117 unsigned char byRxRate;
Jim Lieb612822f2009-08-12 14:54:03 -0700118
Charles Clément2986db52010-06-24 11:02:26 -0700119// unsigned short wATIMWindow;
Charles Clément3fc9b582010-06-24 11:02:27 -0700120 unsigned char byRSSIStatCnt;
Charles Clémentb83cc2ed2010-06-01 12:38:57 -0700121 long ldBmMAX;
122 long ldBmAverage[RSSI_STAT_COUNT];
123 long ldBmAverRange;
Forest Bond5449c682009-04-25 10:30:44 -0400124 //For any BSSID selection improvment
Charles Clément7b6a0012010-08-01 17:15:50 +0200125 bool bSelected;
Forest Bond5449c682009-04-25 10:30:44 -0400126
127 //++ WPA informations
Charles Clément7b6a0012010-08-01 17:15:50 +0200128 bool bWPAValid;
Charles Clément3fc9b582010-06-24 11:02:27 -0700129 unsigned char byGKType;
130 unsigned char abyPKType[4];
Charles Clément2986db52010-06-24 11:02:26 -0700131 unsigned short wPKCount;
Charles Clément3fc9b582010-06-24 11:02:27 -0700132 unsigned char abyAuthType[4];
Charles Clément2986db52010-06-24 11:02:26 -0700133 unsigned short wAuthCount;
Charles Clément3fc9b582010-06-24 11:02:27 -0700134 unsigned char byDefaultK_as_PK;
135 unsigned char byReplayIdx;
Forest Bond5449c682009-04-25 10:30:44 -0400136 //--
137
138 //++ WPA2 informations
Charles Clément7b6a0012010-08-01 17:15:50 +0200139 bool bWPA2Valid;
Charles Clément3fc9b582010-06-24 11:02:27 -0700140 unsigned char byCSSGK;
Charles Clément2986db52010-06-24 11:02:26 -0700141 unsigned short wCSSPKCount;
Charles Clément3fc9b582010-06-24 11:02:27 -0700142 unsigned char abyCSSPK[4];
Charles Clément2986db52010-06-24 11:02:26 -0700143 unsigned short wAKMSSAuthCount;
Charles Clément3fc9b582010-06-24 11:02:27 -0700144 unsigned char abyAKMSSAuthType[4];
Forest Bond5449c682009-04-25 10:30:44 -0400145
146 //++ wpactl
Charles Clément3fc9b582010-06-24 11:02:27 -0700147 unsigned char byWPAIE[MAX_WPA_IE_LEN];
148 unsigned char byRSNIE[MAX_WPA_IE_LEN];
Charles Clément2986db52010-06-24 11:02:26 -0700149 unsigned short wWPALen;
150 unsigned short wRSNLen;
Forest Bond5449c682009-04-25 10:30:44 -0400151
152 // Clear count
Charles Clémentb6e95cd2010-06-02 09:52:01 -0700153 unsigned int uClearCount;
Charles Clément3fc9b582010-06-24 11:02:27 -0700154// unsigned char abyIEs[WLAN_BEACON_FR_MAXLEN];
Charles Clémentb6e95cd2010-06-02 09:52:01 -0700155 unsigned int uIELength;
Forest Bond5449c682009-04-25 10:30:44 -0400156 QWORD qwBSSTimestamp;
157 QWORD qwLocalTSF; // local TSF timer
158
159// NDIS_802_11_NETWORK_TYPE NetworkTypeInUse;
160 CARD_PHY_TYPE eNetworkTypeInUse;
161
162 ERPObject sERP;
163 SRSNCapObject sRSNCapObj;
Charles Clément3fc9b582010-06-24 11:02:27 -0700164 unsigned char abyIEs[1024]; // don't move this field !!
Forest Bond5449c682009-04-25 10:30:44 -0400165
166}__attribute__ ((__packed__))
Jim Lieba8848472009-08-12 14:54:07 -0700167KnownBSS , *PKnownBSS;
Forest Bond5449c682009-04-25 10:30:44 -0400168
169//2006-1116-01,<Add> by NomadZhao
170#pragma pack()
171
172typedef enum tagNODE_STATE {
173 NODE_FREE,
174 NODE_AGED,
175 NODE_KNOWN,
176 NODE_AUTH,
177 NODE_ASSOC
178} NODE_STATE, *PNODE_STATE;
179
180
181// STA node info
182typedef struct tagKnownNodeDB {
183 // STA info
Charles Clément7b6a0012010-08-01 17:15:50 +0200184 bool bActive;
Charles Clément3fc9b582010-06-24 11:02:27 -0700185 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];
Charles Clément2986db52010-06-24 11:02:26 -0700188 unsigned short wTxDataRate;
Charles Clément7b6a0012010-08-01 17:15:50 +0200189 bool bShortPreamble;
190 bool bERPExist;
191 bool bShortSlotTime;
Charles Clémentb6e95cd2010-06-02 09:52:01 -0700192 unsigned int uInActiveCount;
Charles Clément2986db52010-06-24 11:02:26 -0700193 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;
Charles Clément3fc9b582010-06-24 11:02:27 -0700196 unsigned char byTopOFDMBasicRate;//Records the highest basic rate in OFDM mode
197 unsigned char byTopCCKBasicRate; //Records the highest basic rate in CCK mode
Forest Bond5449c682009-04-25 10:30:44 -0400198
199 // For AP mode
200 struct sk_buff_head sTxPSQueue;
Charles Clément2986db52010-06-24 11:02:26 -0700201 unsigned short wCapInfo;
202 unsigned short wListenInterval;
203 unsigned short wAID;
Forest Bond5449c682009-04-25 10:30:44 -0400204 NODE_STATE eNodeState;
Charles Clément7b6a0012010-08-01 17:15:50 +0200205 bool bPSEnable;
206 bool bRxPSPoll;
Charles Clément3fc9b582010-06-24 11:02:27 -0700207 unsigned char byAuthSequence;
Charles Clémente3fd16d2010-06-02 09:52:02 -0700208 unsigned long ulLastRxJiffer;
Charles Clément3fc9b582010-06-24 11:02:27 -0700209 unsigned char bySuppRate;
Charles Clément0f4c60d2010-06-24 11:02:25 -0700210 unsigned long dwFlags;
Charles Clément2986db52010-06-24 11:02:26 -0700211 unsigned short wEnQueueCnt;
Forest Bond5449c682009-04-25 10:30:44 -0400212
Charles Clément7b6a0012010-08-01 17:15:50 +0200213 bool bOnFly;
Charles Clémentb2e876b2010-06-02 09:52:03 -0700214 unsigned long long KeyRSC;
Charles Clément3fc9b582010-06-24 11:02:27 -0700215 unsigned char byKeyIndex;
Charles Clément0f4c60d2010-06-24 11:02:25 -0700216 unsigned long dwKeyIndex;
Charles Clément3fc9b582010-06-24 11:02:27 -0700217 unsigned char byCipherSuite;
Charles Clément0f4c60d2010-06-24 11:02:25 -0700218 unsigned long dwTSC47_16;
Charles Clément2986db52010-06-24 11:02:26 -0700219 unsigned short wTSC15_0;
Charles Clémentb6e95cd2010-06-02 09:52:01 -0700220 unsigned int uWepKeyLength;
Charles Clément3fc9b582010-06-24 11:02:27 -0700221 unsigned char abyWepKey[WLAN_WEPMAX_KEYLEN];
Forest Bond5449c682009-04-25 10:30:44 -0400222 //
223 // Auto rate fallback vars
Charles Clément7b6a0012010-08-01 17:15:50 +0200224 bool bIsInFallback;
Charles Clémentb6e95cd2010-06-02 09:52:01 -0700225 unsigned int uAverageRSSI;
226 unsigned int uRateRecoveryTimeout;
227 unsigned int uRatePollTimeout;
228 unsigned int uTxFailures;
229 unsigned int uTxAttempts;
Forest Bond5449c682009-04-25 10:30:44 -0400230
Charles Clémentb6e95cd2010-06-02 09:52:01 -0700231 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;
Forest Bond5449c682009-04-25 10:30:44 -0400237
Jim Lieba8848472009-08-12 14:54:07 -0700238} KnownNodeDB, *PKnownNodeDB;
Forest Bond5449c682009-04-25 10:30:44 -0400239
240
241/*--------------------- Export Functions --------------------------*/
242
243
244
245PKnownBSS
246BSSpSearchBSSList(
Charles Clément3a215e02010-05-12 20:54:39 -0700247 void *hDeviceContext,
Charles Clément2989e962010-06-05 15:13:47 -0700248 unsigned char *pbyDesireBSSID,
249 unsigned char *pbyDesireSSID,
Charles Clément3a215e02010-05-12 20:54:39 -0700250 CARD_PHY_TYPE ePhyType
Forest Bond5449c682009-04-25 10:30:44 -0400251 );
252
253PKnownBSS
254BSSpAddrIsInBSSList(
Charles Clément3a215e02010-05-12 20:54:39 -0700255 void *hDeviceContext,
Charles Clément2989e962010-06-05 15:13:47 -0700256 unsigned char *abyBSSID,
Charles Clément3a215e02010-05-12 20:54:39 -0700257 PWLAN_IE_SSID pSSID
Forest Bond5449c682009-04-25 10:30:44 -0400258 );
259
Charles Clément6b35b7b2010-05-07 12:30:19 -0700260void
Forest Bond5449c682009-04-25 10:30:44 -0400261BSSvClearBSSList(
Charles Clément3a215e02010-05-12 20:54:39 -0700262 void *hDeviceContext,
Charles Clément7b6a0012010-08-01 17:15:50 +0200263 bool bKeepCurrBSSID
Forest Bond5449c682009-04-25 10:30:44 -0400264 );
265
Charles Clément7b6a0012010-08-01 17:15:50 +0200266bool
Forest Bond5449c682009-04-25 10:30:44 -0400267BSSbInsertToBSSList(
Charles Clément3a215e02010-05-12 20:54:39 -0700268 void *hDeviceContext,
Charles Clément2989e962010-06-05 15:13:47 -0700269 unsigned char *abyBSSIDAddr,
Charles Clément3a215e02010-05-12 20:54:39 -0700270 QWORD qwTimestamp,
Charles Clément2986db52010-06-24 11:02:26 -0700271 unsigned short wBeaconInterval,
272 unsigned short wCapInfo,
Charles Clément3fc9b582010-06-24 11:02:27 -0700273 unsigned char byCurrChannel,
Charles Clément3a215e02010-05-12 20:54:39 -0700274 PWLAN_IE_SSID pSSID,
275 PWLAN_IE_SUPP_RATES pSuppRates,
276 PWLAN_IE_SUPP_RATES pExtSuppRates,
277 PERPObject psERP,
278 PWLAN_IE_RSN pRSN,
279 PWLAN_IE_RSN_EXT pRSNWPA,
280 PWLAN_IE_COUNTRY pIE_Country,
281 PWLAN_IE_QUIET pIE_Quiet,
Charles Clémentb6e95cd2010-06-02 09:52:01 -0700282 unsigned int uIELength,
Charles Clément2989e962010-06-05 15:13:47 -0700283 unsigned char *pbyIEs,
Charles Clément3a215e02010-05-12 20:54:39 -0700284 void *pRxPacketContext
Forest Bond5449c682009-04-25 10:30:44 -0400285 );
286
287
Charles Clément7b6a0012010-08-01 17:15:50 +0200288bool
Forest Bond5449c682009-04-25 10:30:44 -0400289BSSbUpdateToBSSList(
Charles Clément3a215e02010-05-12 20:54:39 -0700290 void *hDeviceContext,
291 QWORD qwTimestamp,
Charles Clément2986db52010-06-24 11:02:26 -0700292 unsigned short wBeaconInterval,
293 unsigned short wCapInfo,
Charles Clément3fc9b582010-06-24 11:02:27 -0700294 unsigned char byCurrChannel,
Charles Clément7b6a0012010-08-01 17:15:50 +0200295 bool bChannelHit,
Charles Clément3a215e02010-05-12 20:54:39 -0700296 PWLAN_IE_SSID pSSID,
297 PWLAN_IE_SUPP_RATES pSuppRates,
298 PWLAN_IE_SUPP_RATES pExtSuppRates,
299 PERPObject psERP,
300 PWLAN_IE_RSN pRSN,
301 PWLAN_IE_RSN_EXT pRSNWPA,
302 PWLAN_IE_COUNTRY pIE_Country,
303 PWLAN_IE_QUIET pIE_Quiet,
304 PKnownBSS pBSSList,
Charles Clémentb6e95cd2010-06-02 09:52:01 -0700305 unsigned int uIELength,
Charles Clément2989e962010-06-05 15:13:47 -0700306 unsigned char *pbyIEs,
Charles Clément3a215e02010-05-12 20:54:39 -0700307 void *pRxPacketContext
Forest Bond5449c682009-04-25 10:30:44 -0400308 );
309
310
Charles Clément7b6a0012010-08-01 17:15:50 +0200311bool
Charles Clémentfe4f34b2010-06-25 10:48:53 -0700312BSSDBbIsSTAInNodeDB(void *hDeviceContext, unsigned char *abyDstAddr,
313 unsigned int *puNodeIndex);
Forest Bond5449c682009-04-25 10:30:44 -0400314
Charles Clément6b35b7b2010-05-07 12:30:19 -0700315void
Charles Clémentfe4f34b2010-06-25 10:48:53 -0700316BSSvCreateOneNode(void *hDeviceContext, unsigned int *puNodeIndex);
Forest Bond5449c682009-04-25 10:30:44 -0400317
Charles Clément6b35b7b2010-05-07 12:30:19 -0700318void
Forest Bond5449c682009-04-25 10:30:44 -0400319BSSvUpdateAPNode(
Charles Clément3a215e02010-05-12 20:54:39 -0700320 void *hDeviceContext,
Charles Clément15df6c22010-06-05 15:13:48 -0700321 unsigned short *pwCapInfo,
Charles Clément3a215e02010-05-12 20:54:39 -0700322 PWLAN_IE_SUPP_RATES pItemRates,
323 PWLAN_IE_SUPP_RATES pExtSuppRates
Forest Bond5449c682009-04-25 10:30:44 -0400324 );
325
326
Charles Clément6b35b7b2010-05-07 12:30:19 -0700327void
Forest Bond5449c682009-04-25 10:30:44 -0400328BSSvSecondCallBack(
Charles Clément3a215e02010-05-12 20:54:39 -0700329 void *hDeviceContext
Forest Bond5449c682009-04-25 10:30:44 -0400330 );
331
Jim Lieb612822f2009-08-12 14:54:03 -0700332
Charles Clément6b35b7b2010-05-07 12:30:19 -0700333void
Forest Bond5449c682009-04-25 10:30:44 -0400334BSSvUpdateNodeTxCounter(
Charles Clément3a215e02010-05-12 20:54:39 -0700335 void *hDeviceContext,
Charles Clément3fc9b582010-06-24 11:02:27 -0700336 unsigned char byTsr0,
337 unsigned char byTsr1,
Charles Clément2989e962010-06-05 15:13:47 -0700338 unsigned char *pbyBuffer,
Charles Clémentb6e95cd2010-06-02 09:52:01 -0700339 unsigned int uFIFOHeaderSize
Forest Bond5449c682009-04-25 10:30:44 -0400340 );
341
Charles Clément6b35b7b2010-05-07 12:30:19 -0700342void
Forest Bond5449c682009-04-25 10:30:44 -0400343BSSvRemoveOneNode(
Charles Clément3a215e02010-05-12 20:54:39 -0700344 void *hDeviceContext,
Charles Clémentb6e95cd2010-06-02 09:52:01 -0700345 unsigned int uNodeIndex
Forest Bond5449c682009-04-25 10:30:44 -0400346 );
347
Charles Clément6b35b7b2010-05-07 12:30:19 -0700348void
Forest Bond5449c682009-04-25 10:30:44 -0400349BSSvAddMulticastNode(
Charles Clément3a215e02010-05-12 20:54:39 -0700350 void *hDeviceContext
Forest Bond5449c682009-04-25 10:30:44 -0400351 );
352
353
Charles Clément6b35b7b2010-05-07 12:30:19 -0700354void
Forest Bond5449c682009-04-25 10:30:44 -0400355BSSvClearNodeDBTable(
Charles Clément3a215e02010-05-12 20:54:39 -0700356 void *hDeviceContext,
Charles Clémentb6e95cd2010-06-02 09:52:01 -0700357 unsigned int uStartIndex
Forest Bond5449c682009-04-25 10:30:44 -0400358 );
359
Charles Clément6b35b7b2010-05-07 12:30:19 -0700360void
Forest Bond5449c682009-04-25 10:30:44 -0400361BSSvClearAnyBSSJoinRecord(
Charles Clément3a215e02010-05-12 20:54:39 -0700362 void *hDeviceContext
Forest Bond5449c682009-04-25 10:30:44 -0400363 );
364
365#endif //__BSSDB_H__