• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
72 typedef enum _NDIS_802_11_NETWORK_TYPE {
73 	Ndis802_11FH,
74 	Ndis802_11DS,
75 	Ndis802_11OFDM5,
76 	Ndis802_11OFDM24,
77 	Ndis802_11NetworkTypeMax    // not a real type, defined as an upper bound
78 } NDIS_802_11_NETWORK_TYPE, *PNDIS_802_11_NETWORK_TYPE;
79 
80 typedef struct tagSERPObject {
81 	bool bERPExist;
82 	unsigned char byERP;
83 } ERPObject, *PERPObject;
84 
85 typedef struct tagSRSNCapObject {
86 	bool bRSNCapExist;
87 	unsigned short wRSNCap;
88 } SRSNCapObject, *PSRSNCapObject;
89 
90 // BSS info(AP)
91 #pragma pack(1)
92 typedef struct tagKnownBSS {
93 	bool bActive;
94 	unsigned char abyBSSID[WLAN_BSSID_LEN];
95 	unsigned int	uChannel;
96 	unsigned char abySuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
97 	unsigned char abyExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
98 	unsigned int	uRSSI;
99 	unsigned char bySQ;
100 	unsigned short wBeaconInterval;
101 	unsigned short wCapInfo;
102 	unsigned char abySSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
103 	unsigned char byRxRate;
104 
105 	unsigned char byRSSIStatCnt;
106 	long            ldBmMAX;
107 	long            ldBmAverage[RSSI_STAT_COUNT];
108 	long            ldBmAverRange;
109 	bool bSelected;
110 
111 	bool bWPAValid;
112 	unsigned char byGKType;
113 	unsigned char abyPKType[4];
114 	unsigned short wPKCount;
115 	unsigned char abyAuthType[4];
116 	unsigned short wAuthCount;
117 	unsigned char byDefaultK_as_PK;
118 	unsigned char byReplayIdx;
119 
120 	bool bWPA2Valid;
121 	unsigned char byCSSGK;
122 	unsigned short wCSSPKCount;
123 	unsigned char abyCSSPK[4];
124 	unsigned short wAKMSSAuthCount;
125 	unsigned char abyAKMSSAuthType[4];
126 
127 	unsigned char byWPAIE[MAX_WPA_IE_LEN];
128 	unsigned char byRSNIE[MAX_WPA_IE_LEN];
129 	unsigned short wWPALen;
130 	unsigned short wRSNLen;
131 
132 	unsigned int	uClearCount;
133 	unsigned int	uIELength;
134 	u64 qwBSSTimestamp;
135 	u64 qwLocalTSF;
136 
137 	CARD_PHY_TYPE   eNetworkTypeInUse;
138 
139 	ERPObject       sERP;
140 	SRSNCapObject   sRSNCapObj;
141 	unsigned char abyIEs[1024];
142 } __attribute__ ((__packed__))
143 KnownBSS , *PKnownBSS;
144 
145 #pragma pack()
146 
147 typedef enum tagNODE_STATE {
148 	NODE_FREE,
149 	NODE_AGED,
150 	NODE_KNOWN,
151 	NODE_AUTH,
152 	NODE_ASSOC
153 } NODE_STATE, *PNODE_STATE;
154 
155 // STA node info
156 typedef struct tagKnownNodeDB {
157 	bool bActive;
158 	unsigned char abyMACAddr[WLAN_ADDR_LEN];
159 	unsigned char abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
160 	unsigned char abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
161 	unsigned short wTxDataRate;
162 	bool bShortPreamble;
163 	bool bERPExist;
164 	bool bShortSlotTime;
165 	unsigned int	uInActiveCount;
166 	unsigned short wMaxBasicRate;     //Get from byTopOFDMBasicRate or byTopCCKBasicRate which depends on packetTyp.
167 	unsigned short wMaxSuppRate;      //Records the highest supported rate getting from SuppRates IE and ExtSuppRates IE in Beacon.
168 	unsigned short wSuppRate;
169 	unsigned char byTopOFDMBasicRate;//Records the highest basic rate in OFDM mode
170 	unsigned char byTopCCKBasicRate; //Records the highest basic rate in CCK mode
171 
172 	// For AP mode
173 	struct sk_buff_head sTxPSQueue;
174 	unsigned short wCapInfo;
175 	unsigned short wListenInterval;
176 	unsigned short wAID;
177 	NODE_STATE      eNodeState;
178 	bool bPSEnable;
179 	bool bRxPSPoll;
180 	unsigned char byAuthSequence;
181 	unsigned long ulLastRxJiffer;
182 	unsigned char bySuppRate;
183 	unsigned long dwFlags;
184 	unsigned short wEnQueueCnt;
185 
186 	bool bOnFly;
187 	unsigned long long       KeyRSC;
188 	unsigned char byKeyIndex;
189 	unsigned long dwKeyIndex;
190 	unsigned char byCipherSuite;
191 	unsigned long dwTSC47_16;
192 	unsigned short wTSC15_0;
193 	unsigned int	uWepKeyLength;
194 	unsigned char abyWepKey[WLAN_WEPMAX_KEYLEN];
195 	// Auto rate fallback vars
196 	bool bIsInFallback;
197 	unsigned int	uAverageRSSI;
198 	unsigned int	uRateRecoveryTimeout;
199 	unsigned int	uRatePollTimeout;
200 	unsigned int	uTxFailures;
201 	unsigned int	uTxAttempts;
202 
203 	unsigned int	uTxRetry;
204 	unsigned int	uFailureRatio;
205 	unsigned int	uRetryRatio;
206 	unsigned int	uTxOk[MAX_RATE+1];
207 	unsigned int	uTxFail[MAX_RATE+1];
208 	unsigned int	uTimeCount;
209 } KnownNodeDB, *PKnownNodeDB;
210 
211 PKnownBSS
212 BSSpSearchBSSList(
213 	void *hDeviceContext,
214 	unsigned char *pbyDesireBSSID,
215 	unsigned char *pbyDesireSSID,
216 	CARD_PHY_TYPE ePhyType
217 );
218 
219 PKnownBSS
220 BSSpAddrIsInBSSList(
221 	void *hDeviceContext,
222 	unsigned char *abyBSSID,
223 	PWLAN_IE_SSID pSSID
224 );
225 
226 void
227 BSSvClearBSSList(
228 	void *hDeviceContext,
229 	bool bKeepCurrBSSID
230 );
231 
232 bool
233 BSSbInsertToBSSList(
234 	void *hDeviceContext,
235 	unsigned char *abyBSSIDAddr,
236 	__le64 qwTimestamp,
237 	unsigned short wBeaconInterval,
238 	unsigned short wCapInfo,
239 	unsigned char byCurrChannel,
240 	PWLAN_IE_SSID pSSID,
241 	PWLAN_IE_SUPP_RATES pSuppRates,
242 	PWLAN_IE_SUPP_RATES pExtSuppRates,
243 	PERPObject psERP,
244 	PWLAN_IE_RSN pRSN,
245 	PWLAN_IE_RSN_EXT pRSNWPA,
246 	PWLAN_IE_COUNTRY pIE_Country,
247 	PWLAN_IE_QUIET pIE_Quiet,
248 	unsigned int uIELength,
249 	unsigned char *pbyIEs,
250 	void *pRxPacketContext
251 );
252 
253 bool
254 BSSbUpdateToBSSList(
255 	void *hDeviceContext,
256 	__le64 qwTimestamp,
257 	unsigned short wBeaconInterval,
258 	unsigned short wCapInfo,
259 	unsigned char byCurrChannel,
260 	bool bChannelHit,
261 	PWLAN_IE_SSID pSSID,
262 	PWLAN_IE_SUPP_RATES pSuppRates,
263 	PWLAN_IE_SUPP_RATES pExtSuppRates,
264 	PERPObject psERP,
265 	PWLAN_IE_RSN pRSN,
266 	PWLAN_IE_RSN_EXT pRSNWPA,
267 	PWLAN_IE_COUNTRY pIE_Country,
268 	PWLAN_IE_QUIET pIE_Quiet,
269 	PKnownBSS pBSSList,
270 	unsigned int uIELength,
271 	unsigned char *pbyIEs,
272 	void *pRxPacketContext
273 );
274 
275 bool
276 BSSDBbIsSTAInNodeDB(void *hDeviceContext, unsigned char *abyDstAddr,
277 		    unsigned int *puNodeIndex);
278 
279 void
280 BSSvCreateOneNode(void *hDeviceContext, unsigned int *puNodeIndex);
281 
282 void
283 BSSvUpdateAPNode(
284 	void *hDeviceContext,
285 	unsigned short *pwCapInfo,
286 	PWLAN_IE_SUPP_RATES pItemRates,
287 	PWLAN_IE_SUPP_RATES pExtSuppRates
288 );
289 
290 void
291 BSSvSecondCallBack(
292 	void *hDeviceContext
293 );
294 
295 void
296 BSSvUpdateNodeTxCounter(
297 	void *hDeviceContext,
298 	unsigned char byTsr0,
299 	unsigned char byTsr1,
300 	unsigned char *pbyBuffer,
301 	unsigned int uFIFOHeaderSize
302 );
303 
304 void
305 BSSvRemoveOneNode(
306 	void *hDeviceContext,
307 	unsigned int uNodeIndex
308 );
309 
310 void
311 BSSvAddMulticastNode(
312 	void *hDeviceContext
313 );
314 
315 void
316 BSSvClearNodeDBTable(
317 	void *hDeviceContext,
318 	unsigned int uStartIndex
319 );
320 
321 void
322 BSSvClearAnyBSSJoinRecord(
323 	void *hDeviceContext
324 );
325 
326 #endif //__BSSDB_H__
327