• 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: wmgr.h
21  *
22  * Purpose:
23  *
24  * Author: lyndon chen
25  *
26  * Date: Jan 2, 2003
27  *
28  * Functions:
29  *
30  * Revision History:
31  *
32  */
33 
34 #ifndef __WMGR_H__
35 #define __WMGR_H__
36 
37 #include "ttype.h"
38 #include "80211mgr.h"
39 #include "80211hdr.h"
40 #include "wcmd.h"
41 #include "bssdb.h"
42 #include "wpa2.h"
43 #include "vntwifi.h"
44 #include "card.h"
45 
46 /*---------------------  Export Definitions -------------------------*/
47 
48 // Scan time
49 #define PROBE_DELAY                  100  // (us)
50 #define SWITCH_CHANNEL_DELAY         200 // (us)
51 #define WLAN_SCAN_MINITIME           25   // (ms)
52 #define WLAN_SCAN_MAXTIME            100  // (ms)
53 #define TRIVIAL_SYNC_DIFFERENCE      0    // (us)
54 #define DEFAULT_IBSS_BI              100  // (ms)
55 
56 #define WCMD_ACTIVE_SCAN_TIME   50 //(ms)
57 #define WCMD_PASSIVE_SCAN_TIME  100 //(ms)
58 
59 #define DEFAULT_MSDU_LIFETIME           512  // ms
60 #define DEFAULT_MSDU_LIFETIME_RES_64us  8000 // 64us
61 
62 #define DEFAULT_MGN_LIFETIME            8    // ms
63 #define DEFAULT_MGN_LIFETIME_RES_64us   125  // 64us
64 
65 #define MAKE_BEACON_RESERVED            10  //(us)
66 
67 #define TIM_MULTICAST_MASK           0x01
68 #define TIM_BITMAPOFFSET_MASK        0xFE
69 #define DEFAULT_DTIM_PERIOD             1
70 
71 #define AP_LONG_RETRY_LIMIT             4
72 
73 #define DEFAULT_IBSS_CHANNEL            6  //2.4G
74 
75 /*---------------------  Export Classes  ----------------------------*/
76 
77 /*---------------------  Export Variables  --------------------------*/
78 
79 /*---------------------  Export Types  ------------------------------*/
80 #define timer_expire(timer, next_tick)   mod_timer(&timer, RUN_AT(next_tick))
81 typedef void (*TimerFunction)(unsigned long);
82 
83 //+++ NDIS related
84 
85 typedef unsigned char NDIS_802_11_MAC_ADDRESS[6];
86 typedef struct _NDIS_802_11_AI_REQFI {
87 	unsigned short Capabilities;
88 	unsigned short ListenInterval;
89 	NDIS_802_11_MAC_ADDRESS  CurrentAPAddress;
90 } NDIS_802_11_AI_REQFI, *PNDIS_802_11_AI_REQFI;
91 
92 typedef struct _NDIS_802_11_AI_RESFI {
93 	unsigned short Capabilities;
94 	unsigned short StatusCode;
95 	unsigned short AssociationId;
96 } NDIS_802_11_AI_RESFI, *PNDIS_802_11_AI_RESFI;
97 
98 typedef struct _NDIS_802_11_ASSOCIATION_INFORMATION {
99 	unsigned long Length;
100 	unsigned short          AvailableRequestFixedIEs;
101 	NDIS_802_11_AI_REQFI    RequestFixedIEs;
102 	unsigned long RequestIELength;
103 	unsigned long OffsetRequestIEs;
104 	unsigned short          AvailableResponseFixedIEs;
105 	NDIS_802_11_AI_RESFI    ResponseFixedIEs;
106 	unsigned long ResponseIELength;
107 	unsigned long OffsetResponseIEs;
108 } NDIS_802_11_ASSOCIATION_INFORMATION, *PNDIS_802_11_ASSOCIATION_INFORMATION;
109 
110 typedef struct tagSAssocInfo {
111 	NDIS_802_11_ASSOCIATION_INFORMATION     AssocInfo;
112 	unsigned char abyIEs[WLAN_BEACON_FR_MAXLEN+WLAN_BEACON_FR_MAXLEN];
113 	// store ReqIEs set by OID_802_11_ASSOCIATION_INFORMATION
114 	unsigned long RequestIELength;
115 	unsigned char abyReqIEs[WLAN_BEACON_FR_MAXLEN];
116 } SAssocInfo, *PSAssocInfo;
117 //---
118 
119 typedef enum tagWMAC_SCAN_TYPE {
120 	WMAC_SCAN_ACTIVE,
121 	WMAC_SCAN_PASSIVE,
122 	WMAC_SCAN_HYBRID
123 } WMAC_SCAN_TYPE, *PWMAC_SCAN_TYPE;
124 
125 typedef enum tagWMAC_SCAN_STATE {
126 	WMAC_NO_SCANNING,
127 	WMAC_IS_SCANNING,
128 	WMAC_IS_PROBEPENDING
129 } WMAC_SCAN_STATE, *PWMAC_SCAN_STATE;
130 
131 // Notes:
132 // Basic Service Set state explained as following:
133 // WMAC_STATE_IDLE          : no BSS is selected (Adhoc or Infra)
134 // WMAC_STATE_STARTED       : no BSS is selected, start own IBSS (Adhoc only)
135 // WMAC_STATE_JOINTED       : BSS is selected and synchronized (Adhoc or Infra)
136 // WMAC_STATE_AUTHPENDING   : Authentication pending (Infra)
137 // WMAC_STATE_AUTH          : Authenticated (Infra)
138 // WMAC_STATE_ASSOCPENDING  : Association pending (Infra)
139 // WMAC_STATE_ASSOC         : Associated (Infra)
140 
141 typedef enum tagWMAC_BSS_STATE {
142 	WMAC_STATE_IDLE,
143 	WMAC_STATE_STARTED,
144 	WMAC_STATE_JOINTED,
145 	WMAC_STATE_AUTHPENDING,
146 	WMAC_STATE_AUTH,
147 	WMAC_STATE_ASSOCPENDING,
148 	WMAC_STATE_ASSOC
149 } WMAC_BSS_STATE, *PWMAC_BSS_STATE;
150 
151 // WMAC selected running mode
152 typedef enum tagWMAC_CURRENT_MODE {
153 	WMAC_MODE_STANDBY,
154 	WMAC_MODE_ESS_STA,
155 	WMAC_MODE_IBSS_STA,
156 	WMAC_MODE_ESS_AP
157 } WMAC_CURRENT_MODE, *PWMAC_CURRENT_MODE;
158 
159 /*
160   typedef enum tagWMAC_POWER_MODE {
161   WMAC_POWER_CAM,
162   WMAC_POWER_FAST,
163   WMAC_POWER_MAX
164 
165   } WMAC_POWER_MODE, *PWMAC_POWER_MODE;
166 */
167 
168 // Tx Management Packet descriptor
169 typedef struct tagSTxMgmtPacket {
170 	PUWLAN_80211HDR     p80211Header;
171 	unsigned int cbMPDULen;
172 	unsigned int cbPayloadLen;
173 } STxMgmtPacket, *PSTxMgmtPacket;
174 
175 // Rx Management Packet descriptor
176 typedef struct tagSRxMgmtPacket {
177 	PUWLAN_80211HDR     p80211Header;
178 	u64 qwLocalTSF;
179 	unsigned int cbMPDULen;
180 	unsigned int cbPayloadLen;
181 	unsigned int uRSSI;
182 	unsigned char bySQ;
183 	unsigned char byRxRate;
184 	unsigned char byRxChannel;
185 } SRxMgmtPacket, *PSRxMgmtPacket;
186 
187 typedef struct tagSMgmtObject {
188 	void *pAdapter;
189 	// MAC address
190 	unsigned char abyMACAddr[WLAN_ADDR_LEN];
191 
192 	// Configuration Mode
193 	WMAC_CONFIG_MODE        eConfigMode; // MAC pre-configed mode
194 	CARD_PHY_TYPE           eCurrentPHYMode;
195 	CARD_PHY_TYPE           eConfigPHYMode;
196 
197 	// Operation state variables
198 	WMAC_CURRENT_MODE       eCurrMode;   // MAC current connection mode
199 	WMAC_BSS_STATE          eCurrState;  // MAC current BSS state
200 
201 	PKnownBSS               pCurrBSS;
202 	unsigned char byCSSGK;
203 	unsigned char byCSSPK;
204 
205 	// Current state vars
206 	unsigned int	uCurrChannel;
207 	unsigned char abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
208 	unsigned char abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
209 	unsigned char abyCurrSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
210 	unsigned char abyCurrBSSID[WLAN_BSSID_LEN];
211 	unsigned short wCurrCapInfo;
212 	unsigned short wCurrAID;
213 	unsigned short wCurrATIMWindow;
214 	unsigned short wCurrBeaconPeriod;
215 	bool bIsDS;
216 	unsigned char byERPContext;
217 
218 	CMD_STATE               eCommandState;
219 	unsigned int	uScanChannel;
220 
221 	// Desire joining BSS vars
222 	unsigned char abyDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
223 	unsigned char abyDesireBSSID[WLAN_BSSID_LEN];
224 
225 	// Adhoc or AP configuration vars
226 	unsigned short wIBSSBeaconPeriod;
227 	unsigned short wIBSSATIMWindow;
228 	unsigned int	uIBSSChannel;
229 	unsigned char abyIBSSSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
230 	unsigned char byAPBBType;
231 	unsigned char abyWPAIE[MAX_WPA_IE_LEN];
232 	unsigned short wWPAIELen;
233 
234 	unsigned int	uAssocCount;
235 	bool bMoreData;
236 
237 	// Scan state vars
238 	WMAC_SCAN_STATE         eScanState;
239 	WMAC_SCAN_TYPE          eScanType;
240 	unsigned int	uScanStartCh;
241 	unsigned int	uScanEndCh;
242 	unsigned short wScanSteps;
243 	unsigned int	uScanBSSType;
244 	// Desire scanning vars
245 	unsigned char abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
246 	unsigned char abyScanBSSID[WLAN_BSSID_LEN];
247 
248 	// Privacy
249 	WMAC_AUTHENTICATION_MODE eAuthenMode;
250 	WMAC_ENCRYPTION_MODE    eEncryptionMode;
251 	bool bShareKeyAlgorithm;
252 	unsigned char abyChallenge[WLAN_CHALLENGE_LEN];
253 	bool bPrivacyInvoked;
254 
255 	// Received beacon state vars
256 	bool bInTIM;
257 	bool bMulticastTIM;
258 	unsigned char byDTIMCount;
259 	unsigned char byDTIMPeriod;
260 
261 	// Power saving state vars
262 	WMAC_POWER_MODE         ePSMode;
263 	unsigned short wListenInterval;
264 	unsigned short wCountToWakeUp;
265 	bool bInTIMWake;
266 	unsigned char *pbyPSPacketPool;
267 	unsigned char byPSPacketPool[sizeof(STxMgmtPacket) + WLAN_NULLDATA_FR_MAXLEN];
268 	bool bRxBeaconInTBTTWake;
269 	unsigned char abyPSTxMap[MAX_NODE_NUM + 1];
270 
271 	// management command related
272 	unsigned int	uCmdBusy;
273 	unsigned int	uCmdHostAPBusy;
274 
275 	// management packet pool
276 	unsigned char *pbyMgmtPacketPool;
277 	unsigned char byMgmtPacketPool[sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN];
278 
279 	// One second callback timer
280 	struct timer_list	    sTimerSecondCallback;
281 
282 	// Temporarily Rx Mgmt Packet Descriptor
283 	SRxMgmtPacket           sRxPacket;
284 
285 	// link list of known bss's (scan results)
286 	KnownBSS                sBSSList[MAX_BSS_NUM];
287 
288 	// table list of known node
289 	// sNodeDBList[0] is reserved for AP under Infra mode
290 	// sNodeDBList[0] is reserved for Multicast under adhoc/AP mode
291 	KnownNodeDB             sNodeDBTable[MAX_NODE_NUM + 1];
292 
293 	// WPA2 PMKID Cache
294 	SPMKIDCache             gsPMKIDCache;
295 	bool bRoaming;
296 
297 	// rate fall back vars
298 
299 	// associate info
300 	SAssocInfo              sAssocInfo;
301 
302 	// for 802.11h
303 	bool b11hEnable;
304 	bool bSwitchChannel;
305 	unsigned char byNewChannel;
306 	PWLAN_IE_MEASURE_REP    pCurrMeasureEIDRep;
307 	unsigned int	uLengthOfRepEIDs;
308 	unsigned char abyCurrentMSRReq[sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN];
309 	unsigned char abyCurrentMSRRep[sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN];
310 	unsigned char abyIECountry[WLAN_A3FR_MAXLEN];
311 	unsigned char abyIBSSDFSOwner[6];
312 	unsigned char byIBSSDFSRecovery;
313 
314 	struct sk_buff  skb;
315 } SMgmtObject, *PSMgmtObject;
316 
317 /*---------------------  Export Macros ------------------------------*/
318 
319 /*---------------------  Export Functions  --------------------------*/
320 
321 void
322 vMgrObjectInit(
323 	void *hDeviceContext
324 );
325 
326 void
327 vMgrTimerInit(
328 	void *hDeviceContext
329 );
330 
331 void
332 vMgrObjectReset(
333 	void *hDeviceContext
334 );
335 
336 void
337 vMgrAssocBeginSta(
338 	void *hDeviceContext,
339 	PSMgmtObject pMgmt,
340 	PCMD_STATUS pStatus
341 );
342 
343 void
344 vMgrReAssocBeginSta(
345 	void *hDeviceContext,
346 	PSMgmtObject pMgmt,
347 	PCMD_STATUS pStatus
348 );
349 
350 void
351 vMgrDisassocBeginSta(
352 	void *hDeviceContext,
353 	PSMgmtObject pMgmt,
354 	unsigned char *abyDestAddress,
355 	unsigned short wReason,
356 	PCMD_STATUS pStatus
357 );
358 
359 void
360 vMgrAuthenBeginSta(
361 	void *hDeviceContext,
362 	PSMgmtObject pMgmt,
363 	PCMD_STATUS pStatus
364 );
365 
366 void
367 vMgrCreateOwnIBSS(
368 	void *hDeviceContext,
369 	PCMD_STATUS pStatus
370 );
371 
372 void
373 vMgrJoinBSSBegin(
374 	void *hDeviceContext,
375 	PCMD_STATUS pStatus
376 );
377 
378 void
379 vMgrRxManagePacket(
380 	void *hDeviceContext,
381 	PSMgmtObject pMgmt,
382 	PSRxMgmtPacket pRxPacket
383 );
384 
385 /*
386   void
387   vMgrScanBegin(
388   void *hDeviceContext,
389   PCMD_STATUS pStatus
390 );
391 */
392 
393 void
394 vMgrDeAuthenBeginSta(
395 	void *hDeviceContext,
396 	PSMgmtObject  pMgmt,
397 	unsigned char *abyDestAddress,
398 	unsigned short wReason,
399 	PCMD_STATUS pStatus
400 );
401 
402 bool
403 bMgrPrepareBeaconToSend(
404 	void *hDeviceContext,
405 	PSMgmtObject pMgmt
406 );
407 
408 bool
409 bAdd_PMKID_Candidate(
410 	void *hDeviceContext,
411 	unsigned char *pbyBSSID,
412 	PSRSNCapObject psRSNCapObj
413 );
414 
415 void
416 vFlush_PMKID_Candidate(
417 	void *hDeviceContext
418 );
419 
420 #endif // __WMGR_H__
421