2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
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.
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.
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.
46 /*--------------------- Export Definitions -------------------------*/
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)
56 #define WCMD_ACTIVE_SCAN_TIME 50 //(ms)
57 #define WCMD_PASSIVE_SCAN_TIME 100 //(ms)
59 #define DEFAULT_MSDU_LIFETIME 512 // ms
60 #define DEFAULT_MSDU_LIFETIME_RES_64us 8000 // 64us
62 #define DEFAULT_MGN_LIFETIME 8 // ms
63 #define DEFAULT_MGN_LIFETIME_RES_64us 125 // 64us
65 #define MAKE_BEACON_RESERVED 10 //(us)
67 #define TIM_MULTICAST_MASK 0x01
68 #define TIM_BITMAPOFFSET_MASK 0xFE
69 #define DEFAULT_DTIM_PERIOD 1
71 #define AP_LONG_RETRY_LIMIT 4
73 #define DEFAULT_IBSS_CHANNEL 6 //2.4G
75 /*--------------------- Export Classes ----------------------------*/
77 /*--------------------- Export Variables --------------------------*/
79 /*--------------------- Export Types ------------------------------*/
80 #define timer_expire(timer, next_tick) mod_timer(&timer, RUN_AT(next_tick))
81 typedef void (*TimerFunction
)(unsigned long);
85 typedef unsigned char NDIS_802_11_MAC_ADDRESS
[6];
86 typedef struct _NDIS_802_11_AI_REQFI
88 unsigned short Capabilities
;
89 unsigned short ListenInterval
;
90 NDIS_802_11_MAC_ADDRESS CurrentAPAddress
;
91 } NDIS_802_11_AI_REQFI
, *PNDIS_802_11_AI_REQFI
;
93 typedef struct _NDIS_802_11_AI_RESFI
95 unsigned short Capabilities
;
96 unsigned short StatusCode
;
97 unsigned short AssociationId
;
98 } NDIS_802_11_AI_RESFI
, *PNDIS_802_11_AI_RESFI
;
100 typedef struct _NDIS_802_11_ASSOCIATION_INFORMATION
102 unsigned long Length
;
103 unsigned short AvailableRequestFixedIEs
;
104 NDIS_802_11_AI_REQFI RequestFixedIEs
;
105 unsigned long RequestIELength
;
106 unsigned long OffsetRequestIEs
;
107 unsigned short AvailableResponseFixedIEs
;
108 NDIS_802_11_AI_RESFI ResponseFixedIEs
;
109 unsigned long ResponseIELength
;
110 unsigned long OffsetResponseIEs
;
111 } NDIS_802_11_ASSOCIATION_INFORMATION
, *PNDIS_802_11_ASSOCIATION_INFORMATION
;
113 typedef struct tagSAssocInfo
{
114 NDIS_802_11_ASSOCIATION_INFORMATION AssocInfo
;
115 unsigned char abyIEs
[WLAN_BEACON_FR_MAXLEN
+WLAN_BEACON_FR_MAXLEN
];
116 // store ReqIEs set by OID_802_11_ASSOCIATION_INFORMATION
117 unsigned long RequestIELength
;
118 unsigned char abyReqIEs
[WLAN_BEACON_FR_MAXLEN
];
119 } SAssocInfo
, *PSAssocInfo
;
123 typedef enum tagWMAC_AUTHENTICATION_MODE {
132 WMAC_AUTH_MAX // Not a real mode, defined as upper bound
134 } WMAC_AUTHENTICATION_MODE, *PWMAC_AUTHENTICATION_MODE;
137 // Pre-configured Mode (from XP)
139 typedef enum tagWMAC_CONFIG_MODE {
141 WMAC_CONFIG_IBSS_STA,
145 } WMAC_CONFIG_MODE, *PWMAC_CONFIG_MODE;
148 typedef enum tagWMAC_SCAN_TYPE
{
152 } WMAC_SCAN_TYPE
, *PWMAC_SCAN_TYPE
;
154 typedef enum tagWMAC_SCAN_STATE
{
158 } WMAC_SCAN_STATE
, *PWMAC_SCAN_STATE
;
161 // Basic Service Set state explained as following:
162 // WMAC_STATE_IDLE : no BSS is selected (Adhoc or Infra)
163 // WMAC_STATE_STARTED : no BSS is selected, start own IBSS (Adhoc only)
164 // WMAC_STATE_JOINTED : BSS is selected and synchronized (Adhoc or Infra)
165 // WMAC_STATE_AUTHPENDING : Authentication pending (Infra)
166 // WMAC_STATE_AUTH : Authenticated (Infra)
167 // WMAC_STATE_ASSOCPENDING : Association pending (Infra)
168 // WMAC_STATE_ASSOC : Associated (Infra)
170 typedef enum tagWMAC_BSS_STATE
{
174 WMAC_STATE_AUTHPENDING
,
176 WMAC_STATE_ASSOCPENDING
,
178 } WMAC_BSS_STATE
, *PWMAC_BSS_STATE
;
180 // WMAC selected running mode
181 typedef enum tagWMAC_CURRENT_MODE
{
186 } WMAC_CURRENT_MODE
, *PWMAC_CURRENT_MODE
;
189 typedef enum tagWMAC_POWER_MODE {
194 } WMAC_POWER_MODE, *PWMAC_POWER_MODE;
197 // Tx Management Packet descriptor
198 typedef struct tagSTxMgmtPacket
{
199 PUWLAN_80211HDR p80211Header
;
200 unsigned int cbMPDULen
;
201 unsigned int cbPayloadLen
;
202 } STxMgmtPacket
, *PSTxMgmtPacket
;
204 // Rx Management Packet descriptor
205 typedef struct tagSRxMgmtPacket
{
206 PUWLAN_80211HDR p80211Header
;
208 unsigned int cbMPDULen
;
209 unsigned int cbPayloadLen
;
212 unsigned char byRxRate
;
213 unsigned char byRxChannel
;
214 } SRxMgmtPacket
, *PSRxMgmtPacket
;
216 typedef struct tagSMgmtObject
220 unsigned char abyMACAddr
[WLAN_ADDR_LEN
];
222 // Configuration Mode
223 WMAC_CONFIG_MODE eConfigMode
; // MAC pre-configed mode
224 CARD_PHY_TYPE eCurrentPHYMode
;
225 CARD_PHY_TYPE eConfigPHYMode
;
227 // Operation state variables
228 WMAC_CURRENT_MODE eCurrMode
; // MAC current connection mode
229 WMAC_BSS_STATE eCurrState
; // MAC current BSS state
232 unsigned char byCSSGK
;
233 unsigned char byCSSPK
;
235 // unsigned char abyNewSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
236 // unsigned char abyNewExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
238 // Current state vars
239 unsigned int uCurrChannel
;
240 unsigned char abyCurrSuppRates
[WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1];
241 unsigned char abyCurrExtSuppRates
[WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1];
242 unsigned char abyCurrSSID
[WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1];
243 unsigned char abyCurrBSSID
[WLAN_BSSID_LEN
];
244 unsigned short wCurrCapInfo
;
245 unsigned short wCurrAID
;
246 unsigned short wCurrATIMWindow
;
247 unsigned short wCurrBeaconPeriod
;
249 unsigned char byERPContext
;
251 CMD_STATE eCommandState
;
252 unsigned int uScanChannel
;
254 // Desire joining BSS vars
255 unsigned char abyDesireSSID
[WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1];
256 unsigned char abyDesireBSSID
[WLAN_BSSID_LEN
];
258 // Adhoc or AP configuration vars
259 //unsigned char abyAdHocSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
260 unsigned short wIBSSBeaconPeriod
;
261 unsigned short wIBSSATIMWindow
;
262 unsigned int uIBSSChannel
;
263 unsigned char abyIBSSSuppRates
[WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1];
264 unsigned char byAPBBType
;
265 unsigned char abyWPAIE
[MAX_WPA_IE_LEN
];
266 unsigned short wWPAIELen
;
268 unsigned int uAssocCount
;
272 WMAC_SCAN_STATE eScanState
;
273 WMAC_SCAN_TYPE eScanType
;
274 unsigned int uScanStartCh
;
275 unsigned int uScanEndCh
;
276 unsigned short wScanSteps
;
277 unsigned int uScanBSSType
;
278 // Desire scanning vars
279 unsigned char abyScanSSID
[WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1];
280 unsigned char abyScanBSSID
[WLAN_BSSID_LEN
];
283 WMAC_AUTHENTICATION_MODE eAuthenMode
;
284 WMAC_ENCRYPTION_MODE eEncryptionMode
;
285 bool bShareKeyAlgorithm
;
286 unsigned char abyChallenge
[WLAN_CHALLENGE_LEN
];
287 bool bPrivacyInvoked
;
289 // Received beacon state vars
292 unsigned char byDTIMCount
;
293 unsigned char byDTIMPeriod
;
295 // Power saving state vars
296 WMAC_POWER_MODE ePSMode
;
297 unsigned short wListenInterval
;
298 unsigned short wCountToWakeUp
;
300 unsigned char *pbyPSPacketPool
;
301 unsigned char byPSPacketPool
[sizeof(STxMgmtPacket
) + WLAN_NULLDATA_FR_MAXLEN
];
302 bool bRxBeaconInTBTTWake
;
303 unsigned char abyPSTxMap
[MAX_NODE_NUM
+ 1];
305 // management command related
306 unsigned int uCmdBusy
;
307 unsigned int uCmdHostAPBusy
;
309 // management packet pool
310 unsigned char *pbyMgmtPacketPool
;
311 unsigned char byMgmtPacketPool
[sizeof(STxMgmtPacket
) + WLAN_A3FR_MAXLEN
];
313 // One second callback timer
314 struct timer_list sTimerSecondCallback
;
316 // Temporarily Rx Mgmt Packet Descriptor
317 SRxMgmtPacket sRxPacket
;
319 // link list of known bss's (scan results)
320 KnownBSS sBSSList
[MAX_BSS_NUM
];
322 // table list of known node
323 // sNodeDBList[0] is reserved for AP under Infra mode
324 // sNodeDBList[0] is reserved for Multicast under adhoc/AP mode
325 KnownNodeDB sNodeDBTable
[MAX_NODE_NUM
+ 1];
328 SPMKIDCache gsPMKIDCache
;
331 // rate fall back vars
334 SAssocInfo sAssocInfo
;
339 unsigned char byNewChannel
;
340 PWLAN_IE_MEASURE_REP pCurrMeasureEIDRep
;
341 unsigned int uLengthOfRepEIDs
;
342 unsigned char abyCurrentMSRReq
[sizeof(STxMgmtPacket
) + WLAN_A3FR_MAXLEN
];
343 unsigned char abyCurrentMSRRep
[sizeof(STxMgmtPacket
) + WLAN_A3FR_MAXLEN
];
344 unsigned char abyIECountry
[WLAN_A3FR_MAXLEN
];
345 unsigned char abyIBSSDFSOwner
[6];
346 unsigned char byIBSSDFSRecovery
;
349 } SMgmtObject
, *PSMgmtObject
;
351 /*--------------------- Export Macros ------------------------------*/
353 /*--------------------- Export Functions --------------------------*/
372 void *hDeviceContext
,
379 void *hDeviceContext
,
385 vMgrDisassocBeginSta(
386 void *hDeviceContext
,
388 unsigned char *abyDestAddress
,
389 unsigned short wReason
,
395 void *hDeviceContext
,
402 void *hDeviceContext
,
408 void *hDeviceContext
,
414 void *hDeviceContext
,
416 PSRxMgmtPacket pRxPacket
422 void *hDeviceContext,
428 vMgrDeAuthenBeginSta(
429 void *hDeviceContext
,
431 unsigned char *abyDestAddress
,
432 unsigned short wReason
,
437 bMgrPrepareBeaconToSend(
438 void *hDeviceContext
,
443 bAdd_PMKID_Candidate(
444 void *hDeviceContext
,
445 unsigned char *pbyBSSID
,
446 PSRSNCapObject psRSNCapObj
450 vFlush_PMKID_Candidate(