bssdb.h revision d83ba4a1f39595ca216c2587e0909eff751c55eb
1/*
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
33#include <linux/skbuff.h>
34#include "80211hdr.h"
35#include "80211mgr.h"
36#include "card.h"
37
38#define MAX_NODE_NUM             64
39#define MAX_BSS_NUM              42
40#define LOST_BEACON_COUNT        10   // 10 sec, XP defined
41#define MAX_PS_TX_BUF            32   // sta max power saving tx buf
42#define ADHOC_LOST_BEACON_COUNT  30   // 30 sec, beacon lost for adhoc only
43#define MAX_INACTIVE_COUNT       300  // 300 sec, inactive STA node refresh
44
45#define USE_PROTECT_PERIOD       10   // 10 sec, Use protect mode check period
46#define ERP_RECOVER_COUNT        30   // 30 sec, ERP support callback check
47#define BSS_CLEAR_COUNT           1
48
49#define RSSI_STAT_COUNT          10
50#define MAX_CHECK_RSSI_COUNT     8
51
52// STA dwflags
53#define WLAN_STA_AUTH            BIT0
54#define WLAN_STA_ASSOC           BIT1
55#define WLAN_STA_PS              BIT2
56#define WLAN_STA_TIM             BIT3
57// permanent; do not remove entry on expiration
58#define WLAN_STA_PERM            BIT4
59// If 802.1X is used, this flag is
60// controlling whether STA is authorized to
61// send and receive non-IEEE 802.1X frames
62#define WLAN_STA_AUTHORIZED      BIT5
63
64#define MAX_RATE            12
65
66#define MAX_WPA_IE_LEN      64
67
68//
69// IEEE 802.11 Structures and definitions
70//
71
72typedef enum _NDIS_802_11_NETWORK_TYPE
73{
74	Ndis802_11FH,
75	Ndis802_11DS,
76	Ndis802_11OFDM5,
77	Ndis802_11OFDM24,
78	Ndis802_11NetworkTypeMax    // not a real type, defined as an upper bound
79} NDIS_802_11_NETWORK_TYPE, *PNDIS_802_11_NETWORK_TYPE;
80
81typedef struct tagSERPObject {
82	bool bERPExist;
83	unsigned char byERP;
84} ERPObject, *PERPObject;
85
86typedef struct tagSRSNCapObject {
87	bool bRSNCapExist;
88	unsigned short wRSNCap;
89} SRSNCapObject, *PSRSNCapObject;
90
91// BSS info(AP)
92#pragma pack(1)
93typedef struct tagKnownBSS {
94	bool bActive;
95	unsigned char abyBSSID[WLAN_BSSID_LEN];
96	unsigned int	uChannel;
97	unsigned char abySuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
98	unsigned char abyExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
99	unsigned int	uRSSI;
100	unsigned char bySQ;
101	unsigned short wBeaconInterval;
102	unsigned short wCapInfo;
103	unsigned char abySSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
104	unsigned char byRxRate;
105
106	unsigned char byRSSIStatCnt;
107	long            ldBmMAX;
108	long            ldBmAverage[RSSI_STAT_COUNT];
109	long            ldBmAverRange;
110	bool bSelected;
111
112	bool bWPAValid;
113	unsigned char byGKType;
114	unsigned char abyPKType[4];
115	unsigned short wPKCount;
116	unsigned char abyAuthType[4];
117	unsigned short wAuthCount;
118	unsigned char byDefaultK_as_PK;
119	unsigned char byReplayIdx;
120
121	bool bWPA2Valid;
122	unsigned char byCSSGK;
123	unsigned short wCSSPKCount;
124	unsigned char abyCSSPK[4];
125	unsigned short wAKMSSAuthCount;
126	unsigned char abyAKMSSAuthType[4];
127
128	unsigned char byWPAIE[MAX_WPA_IE_LEN];
129	unsigned char byRSNIE[MAX_WPA_IE_LEN];
130	unsigned short wWPALen;
131	unsigned short wRSNLen;
132
133	unsigned int	uClearCount;
134	unsigned int	uIELength;
135	QWORD           qwBSSTimestamp;
136	QWORD           qwLocalTSF;
137
138	CARD_PHY_TYPE   eNetworkTypeInUse;
139
140	ERPObject       sERP;
141	SRSNCapObject   sRSNCapObj;
142	unsigned char abyIEs[1024];
143} __attribute__ ((__packed__))
144KnownBSS , *PKnownBSS;
145
146#pragma pack()
147
148typedef enum tagNODE_STATE {
149	NODE_FREE,
150	NODE_AGED,
151	NODE_KNOWN,
152	NODE_AUTH,
153	NODE_ASSOC
154} NODE_STATE, *PNODE_STATE;
155
156// STA node info
157typedef struct tagKnownNodeDB {
158	bool bActive;
159	unsigned char abyMACAddr[WLAN_ADDR_LEN];
160	unsigned char abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
161	unsigned char abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
162	unsigned short wTxDataRate;
163	bool bShortPreamble;
164	bool bERPExist;
165	bool bShortSlotTime;
166	unsigned int	uInActiveCount;
167	unsigned short wMaxBasicRate;     //Get from byTopOFDMBasicRate or byTopCCKBasicRate which depends on packetTyp.
168	unsigned short wMaxSuppRate;      //Records the highest supported rate getting from SuppRates IE and ExtSuppRates IE in Beacon.
169	unsigned short wSuppRate;
170	unsigned char byTopOFDMBasicRate;//Records the highest basic rate in OFDM mode
171	unsigned char byTopCCKBasicRate; //Records the highest basic rate in CCK mode
172
173	// For AP mode
174	struct sk_buff_head sTxPSQueue;
175	unsigned short wCapInfo;
176	unsigned short wListenInterval;
177	unsigned short wAID;
178	NODE_STATE      eNodeState;
179	bool bPSEnable;
180	bool bRxPSPoll;
181	unsigned char byAuthSequence;
182	unsigned long ulLastRxJiffer;
183	unsigned char bySuppRate;
184	unsigned long dwFlags;
185	unsigned short wEnQueueCnt;
186
187	bool bOnFly;
188	unsigned long long       KeyRSC;
189	unsigned char byKeyIndex;
190	unsigned long dwKeyIndex;
191	unsigned char byCipherSuite;
192	unsigned long dwTSC47_16;
193	unsigned short wTSC15_0;
194	unsigned int	uWepKeyLength;
195	unsigned char abyWepKey[WLAN_WEPMAX_KEYLEN];
196	// Auto rate fallback vars
197	bool bIsInFallback;
198	unsigned int	uAverageRSSI;
199	unsigned int	uRateRecoveryTimeout;
200	unsigned int	uRatePollTimeout;
201	unsigned int	uTxFailures;
202	unsigned int	uTxAttempts;
203
204	unsigned int	uTxRetry;
205	unsigned int	uFailureRatio;
206	unsigned int	uRetryRatio;
207	unsigned int	uTxOk[MAX_RATE+1];
208	unsigned int	uTxFail[MAX_RATE+1];
209	unsigned int	uTimeCount;
210} KnownNodeDB, *PKnownNodeDB;
211
212PKnownBSS
213BSSpSearchBSSList(
214	void *hDeviceContext,
215	unsigned char *pbyDesireBSSID,
216	unsigned char *pbyDesireSSID,
217	CARD_PHY_TYPE ePhyType
218);
219
220PKnownBSS
221BSSpAddrIsInBSSList(
222	void *hDeviceContext,
223	unsigned char *abyBSSID,
224	PWLAN_IE_SSID pSSID
225);
226
227void
228BSSvClearBSSList(
229	void *hDeviceContext,
230	bool bKeepCurrBSSID
231);
232
233bool
234BSSbInsertToBSSList(
235	void *hDeviceContext,
236	unsigned char *abyBSSIDAddr,
237	QWORD qwTimestamp,
238	unsigned short wBeaconInterval,
239	unsigned short wCapInfo,
240	unsigned char byCurrChannel,
241	PWLAN_IE_SSID pSSID,
242	PWLAN_IE_SUPP_RATES pSuppRates,
243	PWLAN_IE_SUPP_RATES pExtSuppRates,
244	PERPObject psERP,
245	PWLAN_IE_RSN pRSN,
246	PWLAN_IE_RSN_EXT pRSNWPA,
247	PWLAN_IE_COUNTRY pIE_Country,
248	PWLAN_IE_QUIET pIE_Quiet,
249	unsigned int uIELength,
250	unsigned char *pbyIEs,
251	void *pRxPacketContext
252);
253
254bool
255BSSbUpdateToBSSList(
256	void *hDeviceContext,
257	QWORD qwTimestamp,
258	unsigned short wBeaconInterval,
259	unsigned short wCapInfo,
260	unsigned char byCurrChannel,
261	bool bChannelHit,
262	PWLAN_IE_SSID pSSID,
263	PWLAN_IE_SUPP_RATES pSuppRates,
264	PWLAN_IE_SUPP_RATES pExtSuppRates,
265	PERPObject psERP,
266	PWLAN_IE_RSN pRSN,
267	PWLAN_IE_RSN_EXT pRSNWPA,
268	PWLAN_IE_COUNTRY pIE_Country,
269	PWLAN_IE_QUIET pIE_Quiet,
270	PKnownBSS pBSSList,
271	unsigned int uIELength,
272	unsigned char *pbyIEs,
273	void *pRxPacketContext
274);
275
276bool
277BSSDBbIsSTAInNodeDB(void *hDeviceContext, unsigned char *abyDstAddr,
278		    unsigned int *puNodeIndex);
279
280void
281BSSvCreateOneNode(void *hDeviceContext, unsigned int *puNodeIndex);
282
283void
284BSSvUpdateAPNode(
285	void *hDeviceContext,
286	unsigned short *pwCapInfo,
287	PWLAN_IE_SUPP_RATES pItemRates,
288	PWLAN_IE_SUPP_RATES pExtSuppRates
289);
290
291void
292BSSvSecondCallBack(
293	void *hDeviceContext
294);
295
296void
297BSSvUpdateNodeTxCounter(
298	void *hDeviceContext,
299	unsigned char byTsr0,
300	unsigned char byTsr1,
301	unsigned char *pbyBuffer,
302	unsigned int uFIFOHeaderSize
303);
304
305void
306BSSvRemoveOneNode(
307	void *hDeviceContext,
308	unsigned int uNodeIndex
309);
310
311void
312BSSvAddMulticastNode(
313	void *hDeviceContext
314);
315
316void
317BSSvClearNodeDBTable(
318	void *hDeviceContext,
319	unsigned int uStartIndex
320);
321
322void
323BSSvClearAnyBSSJoinRecord(
324	void *hDeviceContext
325);
326
327#endif //__BSSDB_H__
328