blob: 5c77677251ed8137b86ae9135068d72ba4baa5c9 [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
Joe Perchese1c77572013-03-18 10:44:39 -070042#define LOST_BEACON_COUNT 10 // 10 sec, XP defined
Forest Bond5449c682009-04-25 10:30:44 -040043#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
Forest Bond5449c682009-04-25 10:30:44 -040070/*--------------------- Export Classes ----------------------------*/
71
72/*--------------------- Export Variables --------------------------*/
73
Forest Bond5449c682009-04-25 10:30:44 -040074/*--------------------- Export Types ------------------------------*/
75
76//
77// IEEE 802.11 Structures and definitions
78//
79
80typedef enum _NDIS_802_11_NETWORK_TYPE
81{
Joe Perchese1c77572013-03-18 10:44:39 -070082 Ndis802_11FH,
83 Ndis802_11DS,
84 Ndis802_11OFDM5,
85 Ndis802_11OFDM24,
86 Ndis802_11NetworkTypeMax // not a real type, defined as an upper bound
Forest Bond5449c682009-04-25 10:30:44 -040087} NDIS_802_11_NETWORK_TYPE, *PNDIS_802_11_NETWORK_TYPE;
88
Forest Bond5449c682009-04-25 10:30:44 -040089typedef struct tagSERPObject {
Joe Perchese1c77572013-03-18 10:44:39 -070090 bool bERPExist;
91 unsigned char byERP;
92} ERPObject, *PERPObject;
Forest Bond5449c682009-04-25 10:30:44 -040093
Forest Bond5449c682009-04-25 10:30:44 -040094typedef struct tagSRSNCapObject {
Joe Perchese1c77572013-03-18 10:44:39 -070095 bool bRSNCapExist;
96 unsigned short wRSNCap;
97} SRSNCapObject, *PSRSNCapObject;
Forest Bond5449c682009-04-25 10:30:44 -040098
99// BSS info(AP)
100#pragma pack(1)
101typedef struct tagKnownBSS {
Joe Perchese1c77572013-03-18 10:44:39 -0700102 // BSS info
103 bool bActive;
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];
108 unsigned int uRSSI;
109 unsigned char bySQ;
110 unsigned short wBeaconInterval;
111 unsigned short wCapInfo;
112 unsigned char abySSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
113 unsigned char byRxRate;
Jim Lieb612822f2009-08-12 14:54:03 -0700114
Charles Clément2986db52010-06-24 11:02:26 -0700115// unsigned short wATIMWindow;
Joe Perchese1c77572013-03-18 10:44:39 -0700116 unsigned char byRSSIStatCnt;
117 long ldBmMAX;
118 long ldBmAverage[RSSI_STAT_COUNT];
119 long ldBmAverRange;
120 //For any BSSID selection improvment
121 bool bSelected;
Forest Bond5449c682009-04-25 10:30:44 -0400122
Joe Perchese1c77572013-03-18 10:44:39 -0700123 //++ WPA informations
124 bool bWPAValid;
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;
132 //--
Forest Bond5449c682009-04-25 10:30:44 -0400133
Joe Perchese1c77572013-03-18 10:44:39 -0700134 //++ WPA2 informations
135 bool bWPA2Valid;
136 unsigned char byCSSGK;
137 unsigned short wCSSPKCount;
138 unsigned char abyCSSPK[4];
139 unsigned short wAKMSSAuthCount;
140 unsigned char abyAKMSSAuthType[4];
Forest Bond5449c682009-04-25 10:30:44 -0400141
Joe Perchese1c77572013-03-18 10:44:39 -0700142 //++ wpactl
143 unsigned char byWPAIE[MAX_WPA_IE_LEN];
144 unsigned char byRSNIE[MAX_WPA_IE_LEN];
145 unsigned short wWPALen;
146 unsigned short wRSNLen;
Forest Bond5449c682009-04-25 10:30:44 -0400147
Joe Perchese1c77572013-03-18 10:44:39 -0700148 // Clear count
149 unsigned int uClearCount;
Charles Clément3fc9b582010-06-24 11:02:27 -0700150// unsigned char abyIEs[WLAN_BEACON_FR_MAXLEN];
Joe Perchese1c77572013-03-18 10:44:39 -0700151 unsigned int uIELength;
152 QWORD qwBSSTimestamp;
153 QWORD qwLocalTSF; // local TSF timer
Forest Bond5449c682009-04-25 10:30:44 -0400154
155// NDIS_802_11_NETWORK_TYPE NetworkTypeInUse;
Joe Perchese1c77572013-03-18 10:44:39 -0700156 CARD_PHY_TYPE eNetworkTypeInUse;
Forest Bond5449c682009-04-25 10:30:44 -0400157
Joe Perchese1c77572013-03-18 10:44:39 -0700158 ERPObject sERP;
159 SRSNCapObject sRSNCapObj;
160 unsigned char abyIEs[1024]; // don't move this field !!
Joe Perchese1c77572013-03-18 10:44:39 -0700161} __attribute__ ((__packed__))
Jim Lieba8848472009-08-12 14:54:07 -0700162KnownBSS , *PKnownBSS;
Forest Bond5449c682009-04-25 10:30:44 -0400163
164//2006-1116-01,<Add> by NomadZhao
165#pragma pack()
166
167typedef enum tagNODE_STATE {
Joe Perchese1c77572013-03-18 10:44:39 -0700168 NODE_FREE,
169 NODE_AGED,
170 NODE_KNOWN,
171 NODE_AUTH,
172 NODE_ASSOC
Forest Bond5449c682009-04-25 10:30:44 -0400173} NODE_STATE, *PNODE_STATE;
174
Forest Bond5449c682009-04-25 10:30:44 -0400175// STA node info
176typedef struct tagKnownNodeDB {
Joe Perchese1c77572013-03-18 10:44:39 -0700177 // STA info
178 bool bActive;
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;
183 bool bShortPreamble;
184 bool bERPExist;
185 bool bShortSlotTime;
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
Forest Bond5449c682009-04-25 10:30:44 -0400192
Joe Perchese1c77572013-03-18 10:44:39 -0700193 // For AP mode
194 struct sk_buff_head sTxPSQueue;
195 unsigned short wCapInfo;
196 unsigned short wListenInterval;
197 unsigned short wAID;
198 NODE_STATE eNodeState;
199 bool bPSEnable;
200 bool bRxPSPoll;
201 unsigned char byAuthSequence;
202 unsigned long ulLastRxJiffer;
203 unsigned char bySuppRate;
204 unsigned long dwFlags;
205 unsigned short wEnQueueCnt;
Forest Bond5449c682009-04-25 10:30:44 -0400206
Joe Perchese1c77572013-03-18 10:44:39 -0700207 bool bOnFly;
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];
216 //
217 // Auto rate fallback vars
218 bool bIsInFallback;
219 unsigned int uAverageRSSI;
220 unsigned int uRateRecoveryTimeout;
221 unsigned int uRatePollTimeout;
222 unsigned int uTxFailures;
223 unsigned int uTxAttempts;
Forest Bond5449c682009-04-25 10:30:44 -0400224
Joe Perchese1c77572013-03-18 10:44:39 -0700225 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;
Jim Lieba8848472009-08-12 14:54:07 -0700231} KnownNodeDB, *PKnownNodeDB;
Forest Bond5449c682009-04-25 10:30:44 -0400232
Forest Bond5449c682009-04-25 10:30:44 -0400233/*--------------------- Export Functions --------------------------*/
234
Forest Bond5449c682009-04-25 10:30:44 -0400235PKnownBSS
236BSSpSearchBSSList(
Joe Perchese1c77572013-03-18 10:44:39 -0700237 void *hDeviceContext,
238 unsigned char *pbyDesireBSSID,
239 unsigned char *pbyDesireSSID,
240 CARD_PHY_TYPE ePhyType
241);
Forest Bond5449c682009-04-25 10:30:44 -0400242
243PKnownBSS
244BSSpAddrIsInBSSList(
Joe Perchese1c77572013-03-18 10:44:39 -0700245 void *hDeviceContext,
246 unsigned char *abyBSSID,
247 PWLAN_IE_SSID pSSID
248);
Forest Bond5449c682009-04-25 10:30:44 -0400249
Charles Clément6b35b7b2010-05-07 12:30:19 -0700250void
Forest Bond5449c682009-04-25 10:30:44 -0400251BSSvClearBSSList(
Joe Perchese1c77572013-03-18 10:44:39 -0700252 void *hDeviceContext,
253 bool bKeepCurrBSSID
254);
Forest Bond5449c682009-04-25 10:30:44 -0400255
Charles Clément7b6a0012010-08-01 17:15:50 +0200256bool
Forest Bond5449c682009-04-25 10:30:44 -0400257BSSbInsertToBSSList(
Joe Perchese1c77572013-03-18 10:44:39 -0700258 void *hDeviceContext,
259 unsigned char *abyBSSIDAddr,
260 QWORD qwTimestamp,
261 unsigned short wBeaconInterval,
262 unsigned short wCapInfo,
263 unsigned char byCurrChannel,
264 PWLAN_IE_SSID pSSID,
265 PWLAN_IE_SUPP_RATES pSuppRates,
266 PWLAN_IE_SUPP_RATES pExtSuppRates,
267 PERPObject psERP,
268 PWLAN_IE_RSN pRSN,
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
275);
Forest Bond5449c682009-04-25 10:30:44 -0400276
Charles Clément7b6a0012010-08-01 17:15:50 +0200277bool
Forest Bond5449c682009-04-25 10:30:44 -0400278BSSbUpdateToBSSList(
Joe Perchese1c77572013-03-18 10:44:39 -0700279 void *hDeviceContext,
280 QWORD qwTimestamp,
281 unsigned short wBeaconInterval,
282 unsigned short wCapInfo,
283 unsigned char byCurrChannel,
284 bool bChannelHit,
285 PWLAN_IE_SSID pSSID,
286 PWLAN_IE_SUPP_RATES pSuppRates,
287 PWLAN_IE_SUPP_RATES pExtSuppRates,
288 PERPObject psERP,
289 PWLAN_IE_RSN pRSN,
290 PWLAN_IE_RSN_EXT pRSNWPA,
291 PWLAN_IE_COUNTRY pIE_Country,
292 PWLAN_IE_QUIET pIE_Quiet,
293 PKnownBSS pBSSList,
294 unsigned int uIELength,
295 unsigned char *pbyIEs,
296 void *pRxPacketContext
297);
Forest Bond5449c682009-04-25 10:30:44 -0400298
Charles Clément7b6a0012010-08-01 17:15:50 +0200299bool
Charles Clémentfe4f34b2010-06-25 10:48:53 -0700300BSSDBbIsSTAInNodeDB(void *hDeviceContext, unsigned char *abyDstAddr,
Joe Perchese1c77572013-03-18 10:44:39 -0700301 unsigned int *puNodeIndex);
Forest Bond5449c682009-04-25 10:30:44 -0400302
Charles Clément6b35b7b2010-05-07 12:30:19 -0700303void
Charles Clémentfe4f34b2010-06-25 10:48:53 -0700304BSSvCreateOneNode(void *hDeviceContext, unsigned int *puNodeIndex);
Forest Bond5449c682009-04-25 10:30:44 -0400305
Charles Clément6b35b7b2010-05-07 12:30:19 -0700306void
Forest Bond5449c682009-04-25 10:30:44 -0400307BSSvUpdateAPNode(
Joe Perchese1c77572013-03-18 10:44:39 -0700308 void *hDeviceContext,
309 unsigned short *pwCapInfo,
310 PWLAN_IE_SUPP_RATES pItemRates,
311 PWLAN_IE_SUPP_RATES pExtSuppRates
312);
Forest Bond5449c682009-04-25 10:30:44 -0400313
Charles Clément6b35b7b2010-05-07 12:30:19 -0700314void
Forest Bond5449c682009-04-25 10:30:44 -0400315BSSvSecondCallBack(
Joe Perchese1c77572013-03-18 10:44:39 -0700316 void *hDeviceContext
317);
Forest Bond5449c682009-04-25 10:30:44 -0400318
Charles Clément6b35b7b2010-05-07 12:30:19 -0700319void
Forest Bond5449c682009-04-25 10:30:44 -0400320BSSvUpdateNodeTxCounter(
Joe Perchese1c77572013-03-18 10:44:39 -0700321 void *hDeviceContext,
322 unsigned char byTsr0,
323 unsigned char byTsr1,
324 unsigned char *pbyBuffer,
325 unsigned int uFIFOHeaderSize
326);
Forest Bond5449c682009-04-25 10:30:44 -0400327
Charles Clément6b35b7b2010-05-07 12:30:19 -0700328void
Forest Bond5449c682009-04-25 10:30:44 -0400329BSSvRemoveOneNode(
Joe Perchese1c77572013-03-18 10:44:39 -0700330 void *hDeviceContext,
331 unsigned int uNodeIndex
332);
Forest Bond5449c682009-04-25 10:30:44 -0400333
Charles Clément6b35b7b2010-05-07 12:30:19 -0700334void
Forest Bond5449c682009-04-25 10:30:44 -0400335BSSvAddMulticastNode(
Joe Perchese1c77572013-03-18 10:44:39 -0700336 void *hDeviceContext
337);
Forest Bond5449c682009-04-25 10:30:44 -0400338
Charles Clément6b35b7b2010-05-07 12:30:19 -0700339void
Forest Bond5449c682009-04-25 10:30:44 -0400340BSSvClearNodeDBTable(
Joe Perchese1c77572013-03-18 10:44:39 -0700341 void *hDeviceContext,
342 unsigned int uStartIndex
343);
Forest Bond5449c682009-04-25 10:30:44 -0400344
Charles Clément6b35b7b2010-05-07 12:30:19 -0700345void
Forest Bond5449c682009-04-25 10:30:44 -0400346BSSvClearAnyBSSJoinRecord(
Joe Perchese1c77572013-03-18 10:44:39 -0700347 void *hDeviceContext
348);
Forest Bond5449c682009-04-25 10:30:44 -0400349
350#endif //__BSSDB_H__