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.
22 * Purpose: Handles the 802.11 management functions
29 * nsMgrObjectInitial - Initialize Management Objet data structure
30 * vMgrObjectReset - Reset Management Object data structure
31 * vMgrAssocBeginSta - Start associate function
32 * vMgrReAssocBeginSta - Start reassociate function
33 * vMgrDisassocBeginSta - Start disassociate function
34 * s_vMgrRxAssocRequest - Handle Rcv associate_request
35 * s_vMgrRxAssocResponse - Handle Rcv associate_response
36 * vMrgAuthenBeginSta - Start authentication function
37 * vMgrDeAuthenDeginSta - Start deauthentication function
38 * s_vMgrRxAuthentication - Handle Rcv authentication
39 * s_vMgrRxAuthenSequence_1 - Handle Rcv authentication sequence 1
40 * s_vMgrRxAuthenSequence_2 - Handle Rcv authentication sequence 2
41 * s_vMgrRxAuthenSequence_3 - Handle Rcv authentication sequence 3
42 * s_vMgrRxAuthenSequence_4 - Handle Rcv authentication sequence 4
43 * s_vMgrRxDisassociation - Handle Rcv disassociation
44 * s_vMgrRxBeacon - Handle Rcv Beacon
45 * vMgrCreateOwnIBSS - Create ad_hoc IBSS or AP BSS
46 * vMgrJoinBSSBegin - Join BSS function
47 * s_vMgrSynchBSS - Synch & adopt BSS parameters
48 * s_MgrMakeBeacon - Create Baecon frame
49 * s_MgrMakeProbeResponse - Create Probe Response frame
50 * s_MgrMakeAssocRequest - Create Associate Request frame
51 * s_MgrMakeReAssocRequest - Create ReAssociate Request frame
52 * s_vMgrRxProbeResponse - Handle Rcv probe_response
53 * s_vMrgRxProbeRequest - Handle Rcv probe_request
54 * bMgrPrepareBeaconToSend - Prepare Beacon frame
55 * s_vMgrLogStatus - Log 802.11 Status
56 * vMgrRxManagePacket - Rcv management frame dispatch function
57 * s_vMgrFormatTIM- Assembler TIM field of beacon
58 * vMgrTimerInit- Initial 1-sec and command call back funtions
84 static int msglevel
=MSG_LEVEL_INFO
;
85 //static int msglevel =MSG_LEVEL_DEBUG;
87 static int ChannelExceedZoneType(struct vnt_private
*, u8 byCurrChannel
);
89 /* Association/diassociation functions */
90 static struct vnt_tx_mgmt
*s_MgrMakeAssocRequest(struct vnt_private
*,
91 struct vnt_manager
*pMgmt
, u8
*pDAddr
, u16 wCurrCapInfo
,
92 u16 wListenInterval
, PWLAN_IE_SSID pCurrSSID
,
93 PWLAN_IE_SUPP_RATES pCurrRates
, PWLAN_IE_SUPP_RATES pCurrExtSuppRates
);
95 static void s_vMgrRxAssocRequest(struct vnt_private
*,
96 struct vnt_manager
*pMgmt
, struct vnt_rx_mgmt
*pRxPacket
,
99 static struct vnt_tx_mgmt
*s_MgrMakeReAssocRequest(struct vnt_private
*,
100 struct vnt_manager
*pMgmt
, u8
*pDAddr
, u16 wCurrCapInfo
,
101 u16 wListenInterval
, PWLAN_IE_SSID pCurrSSID
,
102 PWLAN_IE_SUPP_RATES pCurrRates
, PWLAN_IE_SUPP_RATES pCurrExtSuppRates
);
104 static void s_vMgrRxAssocResponse(struct vnt_private
*,
105 struct vnt_manager
*pMgmt
, struct vnt_rx_mgmt
*pRxPacket
,
108 static void s_vMgrRxDisassociation(struct vnt_private
*,
109 struct vnt_manager
*pMgmt
, struct vnt_rx_mgmt
*pRxPacket
);
111 /* Authentication/deauthen functions */
112 static void s_vMgrRxAuthenSequence_1(struct vnt_private
*,
113 struct vnt_manager
*pMgmt
, PWLAN_FR_AUTHEN pFrame
);
115 static void s_vMgrRxAuthenSequence_2(struct vnt_private
*,
116 struct vnt_manager
*pMgmt
, PWLAN_FR_AUTHEN pFrame
);
118 static void s_vMgrRxAuthenSequence_3(struct vnt_private
*,
119 struct vnt_manager
*pMgmt
, PWLAN_FR_AUTHEN pFrame
);
121 static void s_vMgrRxAuthenSequence_4(struct vnt_private
*,
122 struct vnt_manager
*pMgmt
, PWLAN_FR_AUTHEN pFrame
);
124 static void s_vMgrRxAuthentication(struct vnt_private
*,
125 struct vnt_manager
*pMgmt
, struct vnt_rx_mgmt
*pRxPacket
);
127 static void s_vMgrRxDeauthentication(struct vnt_private
*,
128 struct vnt_manager
*pMgmt
, struct vnt_rx_mgmt
*pRxPacket
);
131 * probe request/response functions */
133 static void s_vMgrRxProbeRequest(struct vnt_private
*,
134 struct vnt_manager
*pMgmt
, struct vnt_rx_mgmt
*pRxPacket
);
136 static void s_vMgrRxProbeResponse(struct vnt_private
*,
137 struct vnt_manager
*pMgmt
, struct vnt_rx_mgmt
*pRxPacket
);
139 /* beacon functions */
140 static void s_vMgrRxBeacon(struct vnt_private
*pDevice
,
141 struct vnt_manager
*pMgmt
, struct vnt_rx_mgmt
*pRxPacket
,
144 static void s_vMgrFormatTIM(struct vnt_manager
*pMgmt
, PWLAN_IE_TIM pTIM
);
146 static struct vnt_tx_mgmt
*s_MgrMakeBeacon(struct vnt_private
*pDevice
,
147 struct vnt_manager
*pMgmt
, u16 wCurrCapInfo
, u16 wCurrBeaconPeriod
,
148 u32 uCurrChannel
, u16 wCurrATIMWinodw
, PWLAN_IE_SSID pCurrSSID
,
149 u8
*pCurrBSSID
, PWLAN_IE_SUPP_RATES pCurrSuppRates
,
150 PWLAN_IE_SUPP_RATES pCurrExtSuppRates
);
152 /* Association response */
153 static struct vnt_tx_mgmt
*s_MgrMakeAssocResponse(struct vnt_private
*,
154 struct vnt_manager
*pMgmt
, u16 wCurrCapInfo
, u16 wAssocStatus
,
155 u16 wAssocAID
, u8
*pDstAddr
, PWLAN_IE_SUPP_RATES pCurrSuppRates
,
156 PWLAN_IE_SUPP_RATES pCurrExtSuppRates
);
158 /* ReAssociation response */
159 static struct vnt_tx_mgmt
*s_MgrMakeReAssocResponse(struct vnt_private
*,
160 struct vnt_manager
*pMgmt
, u16 wCurrCapInfo
, u16 wAssocStatus
,
161 u16 wAssocAID
, u8
*pDstAddr
, PWLAN_IE_SUPP_RATES pCurrSuppRates
,
162 PWLAN_IE_SUPP_RATES pCurrExtSuppRates
);
165 static struct vnt_tx_mgmt
*s_MgrMakeProbeResponse(struct vnt_private
*,
166 struct vnt_manager
*pMgmt
, u16 wCurrCapInfo
, u16 wCurrBeaconPeriod
,
167 u32 uCurrChannel
, u16 wCurrATIMWinodw
, u8
*pDstAddr
,
168 PWLAN_IE_SSID pCurrSSID
, u8
*pCurrBSSID
,
169 PWLAN_IE_SUPP_RATES pCurrSuppRates
,
170 PWLAN_IE_SUPP_RATES pCurrExtSuppRates
, u8 byPHYType
);
172 /* received status */
173 static void s_vMgrLogStatus(struct vnt_manager
*pMgmt
, u16 wStatus
);
175 static void s_vMgrSynchBSS(struct vnt_private
*, u32 uBSSMode
,
176 PKnownBSS pCurr
, PCMD_STATUS pStatus
);
181 NDIS_802_11_ENCRYPTION_STATUS EncStatus
,
186 static void Encyption_Rebuild(struct vnt_private
*, PKnownBSS pCurr
);
190 * Routine Description:
191 * Allocates and initializes the Management object.
198 void vMgrObjectInit(struct vnt_private
*pDevice
)
200 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
203 pMgmt
->pbyPSPacketPool
= &pMgmt
->byPSPacketPool
[0];
204 pMgmt
->pbyMgmtPacketPool
= &pMgmt
->byMgmtPacketPool
[0];
205 pMgmt
->uCurrChannel
= pDevice
->uChannel
;
206 for (ii
= 0; ii
< WLAN_BSSID_LEN
; ii
++)
207 pMgmt
->abyDesireBSSID
[ii
] = 0xFF;
209 pMgmt
->sAssocInfo
.AssocInfo
.Length
= sizeof(NDIS_802_11_ASSOCIATION_INFORMATION
);
210 //memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN +1);
211 pMgmt
->byCSSPK
= KEY_CTL_NONE
;
212 pMgmt
->byCSSGK
= KEY_CTL_NONE
;
213 pMgmt
->wIBSSBeaconPeriod
= DEFAULT_IBSS_BI
;
214 BSSvClearBSSList((void *) pDevice
, false);
216 init_timer(&pMgmt
->sTimerSecondCallback
);
217 pMgmt
->sTimerSecondCallback
.data
= (unsigned long)pDevice
;
218 pMgmt
->sTimerSecondCallback
.function
= (TimerFunction
)BSSvSecondCallBack
;
219 pMgmt
->sTimerSecondCallback
.expires
= RUN_AT(HZ
);
221 init_timer(&pDevice
->sTimerCommand
);
222 pDevice
->sTimerCommand
.data
= (unsigned long)pDevice
;
223 pDevice
->sTimerCommand
.function
= (TimerFunction
)vRunCommand
;
224 pDevice
->sTimerCommand
.expires
= RUN_AT(HZ
);
226 init_timer(&pDevice
->sTimerTxData
);
227 pDevice
->sTimerTxData
.data
= (unsigned long)pDevice
;
228 pDevice
->sTimerTxData
.function
= (TimerFunction
)BSSvSecondTxData
;
229 pDevice
->sTimerTxData
.expires
= RUN_AT(10*HZ
); //10s callback
230 pDevice
->fTxDataInSleep
= false;
231 pDevice
->IsTxDataTrigger
= false;
232 pDevice
->nTxDataTimeCout
= 0;
234 pDevice
->cbFreeCmdQueue
= CMD_Q_SIZE
;
235 pDevice
->uCmdDequeueIdx
= 0;
236 pDevice
->uCmdEnqueueIdx
= 0;
237 pDevice
->eCommandState
= WLAN_CMD_IDLE
;
238 pDevice
->bCmdRunning
= false;
239 pDevice
->bCmdClear
= false;
246 * Routine Description:
247 * Start the station association procedure. Namely, send an
248 * association request frame to the AP.
255 void vMgrAssocBeginSta(struct vnt_private
*pDevice
,
256 struct vnt_manager
*pMgmt
, PCMD_STATUS pStatus
)
258 struct vnt_tx_mgmt
*pTxPacket
;
260 pMgmt
->wCurrCapInfo
= 0;
261 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_ESS(1);
262 if (pDevice
->bEncryptionEnable
) {
263 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_PRIVACY(1);
265 // always allow receive short preamble
266 //if (pDevice->byPreambleType == 1) {
267 // pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
269 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
270 if (pMgmt
->wListenInterval
== 0)
271 pMgmt
->wListenInterval
= 1; // at least one.
273 // ERP Phy (802.11g) should support short preamble.
274 if (pMgmt
->eCurrentPHYMode
== PHY_TYPE_11G
) {
275 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
276 if (pDevice
->bShortSlotTime
== true)
277 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTSLOTTIME(1);
279 } else if (pMgmt
->eCurrentPHYMode
== PHY_TYPE_11B
) {
280 if (pDevice
->byPreambleType
== 1) {
281 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
284 if (pMgmt
->b11hEnable
== true)
285 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SPECTRUMMNG(1);
287 // build an assocreq frame and send it
288 pTxPacket
= s_MgrMakeAssocRequest
294 pMgmt
->wListenInterval
,
295 (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
,
296 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
297 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
300 if (pTxPacket
!= NULL
){
302 *pStatus
= csMgmt_xmit(pDevice
, pTxPacket
);
303 if (*pStatus
== CMD_STATUS_PENDING
) {
304 pMgmt
->eCurrState
= WMAC_STATE_ASSOCPENDING
;
305 *pStatus
= CMD_STATUS_SUCCESS
;
309 *pStatus
= CMD_STATUS_RESOURCES
;
316 * Routine Description:
317 * Start the station re-association procedure.
324 void vMgrReAssocBeginSta(struct vnt_private
*pDevice
,
325 struct vnt_manager
*pMgmt
, PCMD_STATUS pStatus
)
327 struct vnt_tx_mgmt
*pTxPacket
;
329 pMgmt
->wCurrCapInfo
= 0;
330 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_ESS(1);
331 if (pDevice
->bEncryptionEnable
) {
332 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_PRIVACY(1);
335 //if (pDevice->byPreambleType == 1) {
336 // pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
338 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
340 if (pMgmt
->wListenInterval
== 0)
341 pMgmt
->wListenInterval
= 1; // at least one.
343 // ERP Phy (802.11g) should support short preamble.
344 if (pMgmt
->eCurrentPHYMode
== PHY_TYPE_11G
) {
345 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
346 if (pDevice
->bShortSlotTime
== true)
347 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTSLOTTIME(1);
349 } else if (pMgmt
->eCurrentPHYMode
== PHY_TYPE_11B
) {
350 if (pDevice
->byPreambleType
== 1) {
351 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
354 if (pMgmt
->b11hEnable
== true)
355 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SPECTRUMMNG(1);
357 pTxPacket
= s_MgrMakeReAssocRequest
363 pMgmt
->wListenInterval
,
364 (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
,
365 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
366 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
369 if (pTxPacket
!= NULL
){
371 *pStatus
= csMgmt_xmit(pDevice
, pTxPacket
);
372 if (*pStatus
!= CMD_STATUS_PENDING
) {
373 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Reassociation tx failed.\n");
376 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Reassociation tx sending.\n");
385 * Routine Description:
386 * Send an dis-association request frame to the AP.
393 void vMgrDisassocBeginSta(struct vnt_private
*pDevice
,
394 struct vnt_manager
*pMgmt
, u8
*abyDestAddress
, u16 wReason
,
397 struct vnt_tx_mgmt
*pTxPacket
= NULL
;
398 WLAN_FR_DISASSOC sFrame
;
400 pTxPacket
= (struct vnt_tx_mgmt
*)pMgmt
->pbyMgmtPacketPool
;
401 memset(pTxPacket
, 0, sizeof(struct vnt_tx_mgmt
)
402 + WLAN_DISASSOC_FR_MAXLEN
);
403 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((u8
*)pTxPacket
404 + sizeof(struct vnt_tx_mgmt
));
406 // Setup the sFrame structure
407 sFrame
.pBuf
= (u8
*)pTxPacket
->p80211Header
;
408 sFrame
.len
= WLAN_DISASSOC_FR_MAXLEN
;
410 // format fixed field frame structure
411 vMgrEncodeDisassociation(&sFrame
);
414 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
416 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
417 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_DISASSOC
)
420 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, abyDestAddress
, WLAN_ADDR_LEN
);
421 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
422 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
425 *(sFrame
.pwReason
) = cpu_to_le16(wReason
);
426 pTxPacket
->cbMPDULen
= sFrame
.len
;
427 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
430 *pStatus
= csMgmt_xmit(pDevice
, pTxPacket
);
431 if (*pStatus
== CMD_STATUS_PENDING
) {
432 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
433 *pStatus
= CMD_STATUS_SUCCESS
;
441 * Routine Description:(AP function)
442 * Handle incoming station association request frames.
449 static void s_vMgrRxAssocRequest(struct vnt_private
*pDevice
,
450 struct vnt_manager
*pMgmt
, struct vnt_rx_mgmt
*pRxPacket
,
453 WLAN_FR_ASSOCREQ sFrame
;
455 struct vnt_tx_mgmt
*pTxPacket
;
456 u16 wAssocStatus
= 0;
458 u32 uRateLen
= WLAN_RATES_MAXLEN
;
459 u8 abyCurrSuppRates
[WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1];
460 u8 abyCurrExtSuppRates
[WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1];
462 if (pMgmt
->eCurrMode
!= WMAC_MODE_ESS_AP
)
464 // node index not found
468 //check if node is authenticated
470 memset(&sFrame
, 0, sizeof(WLAN_FR_ASSOCREQ
));
471 memset(abyCurrSuppRates
, 0, WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1);
472 memset(abyCurrExtSuppRates
, 0, WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1);
473 sFrame
.len
= pRxPacket
->cbMPDULen
;
474 sFrame
.pBuf
= (u8
*)pRxPacket
->p80211Header
;
476 vMgrDecodeAssocRequest(&sFrame
);
478 if (pMgmt
->sNodeDBTable
[uNodeIndex
].eNodeState
>= NODE_AUTH
) {
479 pMgmt
->sNodeDBTable
[uNodeIndex
].eNodeState
= NODE_ASSOC
;
480 pMgmt
->sNodeDBTable
[uNodeIndex
].wCapInfo
= cpu_to_le16(*sFrame
.pwCapInfo
);
481 pMgmt
->sNodeDBTable
[uNodeIndex
].wListenInterval
= cpu_to_le16(*sFrame
.pwListenInterval
);
482 pMgmt
->sNodeDBTable
[uNodeIndex
].bPSEnable
=
483 WLAN_GET_FC_PWRMGT(sFrame
.pHdr
->sA3
.wFrameCtl
) ? true : false;
484 // Todo: check sta basic rate, if ap can't support, set status code
485 if (pDevice
->byBBType
== BB_TYPE_11B
) {
486 uRateLen
= WLAN_RATES_MAXLEN_11B
;
488 abyCurrSuppRates
[0] = WLAN_EID_SUPP_RATES
;
489 abyCurrSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)sFrame
.pSuppRates
,
490 (PWLAN_IE_SUPP_RATES
)abyCurrSuppRates
,
492 abyCurrExtSuppRates
[0] = WLAN_EID_EXTSUPP_RATES
;
493 if (pDevice
->byBBType
== BB_TYPE_11G
) {
494 abyCurrExtSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)sFrame
.pExtSuppRates
,
495 (PWLAN_IE_SUPP_RATES
)abyCurrExtSuppRates
,
498 abyCurrExtSuppRates
[1] = 0;
501 RATEvParseMaxRate((void *)pDevice
,
502 (PWLAN_IE_SUPP_RATES
)abyCurrSuppRates
,
503 (PWLAN_IE_SUPP_RATES
)abyCurrExtSuppRates
,
504 false, // do not change our basic rate
505 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxBasicRate
),
506 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
),
507 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wSuppRate
),
508 &(pMgmt
->sNodeDBTable
[uNodeIndex
].byTopCCKBasicRate
),
509 &(pMgmt
->sNodeDBTable
[uNodeIndex
].byTopOFDMBasicRate
)
513 pMgmt
->sNodeDBTable
[uNodeIndex
].wTxDataRate
=
514 pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
;
515 // Todo: check sta preamble, if ap can't support, set status code
516 pMgmt
->sNodeDBTable
[uNodeIndex
].bShortPreamble
=
517 WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame
.pwCapInfo
);
518 pMgmt
->sNodeDBTable
[uNodeIndex
].bShortSlotTime
=
519 WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame
.pwCapInfo
);
520 pMgmt
->sNodeDBTable
[uNodeIndex
].wAID
= (u16
)uNodeIndex
;
521 wAssocStatus
= WLAN_MGMT_STATUS_SUCCESS
;
522 wAssocAID
= (u16
)uNodeIndex
;
523 // check if ERP support
524 if(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
> RATE_11M
)
525 pMgmt
->sNodeDBTable
[uNodeIndex
].bERPExist
= true;
527 if (pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
<= RATE_11M
) {
529 pDevice
->bProtectMode
= true;
530 pDevice
->bNonERPPresent
= true;
532 if (pMgmt
->sNodeDBTable
[uNodeIndex
].bShortPreamble
== false) {
533 pDevice
->bBarkerPreambleMd
= true;
536 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"Associate AID= %d \n", wAssocAID
);
537 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"MAC=%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X \n",
538 sFrame
.pHdr
->sA3
.abyAddr2
[0],
539 sFrame
.pHdr
->sA3
.abyAddr2
[1],
540 sFrame
.pHdr
->sA3
.abyAddr2
[2],
541 sFrame
.pHdr
->sA3
.abyAddr2
[3],
542 sFrame
.pHdr
->sA3
.abyAddr2
[4],
543 sFrame
.pHdr
->sA3
.abyAddr2
[5]
545 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"Max Support rate = %d \n",
546 pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
);
549 // assoc response reply..
550 pTxPacket
= s_MgrMakeAssocResponse
557 sFrame
.pHdr
->sA3
.abyAddr2
,
558 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
559 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
561 if (pTxPacket
!= NULL
){
563 if (pDevice
->bEnableHostapd
) {
567 Status
= csMgmt_xmit(pDevice
, pTxPacket
);
568 if (Status
!= CMD_STATUS_PENDING
) {
569 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Assoc response tx failed\n");
572 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Assoc response tx sending..\n");
582 * Description:(AP function)
583 * Handle incoming station re-association request frames.
587 * pMgmt - Management Object structure
588 * pRxPacket - Received Packet
592 * Return Value: None.
596 static void s_vMgrRxReAssocRequest(struct vnt_private
*pDevice
,
597 struct vnt_manager
*pMgmt
, struct vnt_rx_mgmt
*pRxPacket
,
600 WLAN_FR_REASSOCREQ sFrame
;
602 struct vnt_tx_mgmt
*pTxPacket
;
603 u16 wAssocStatus
= 0;
605 u32 uRateLen
= WLAN_RATES_MAXLEN
;
606 u8 abyCurrSuppRates
[WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1];
607 u8 abyCurrExtSuppRates
[WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1];
609 if (pMgmt
->eCurrMode
!= WMAC_MODE_ESS_AP
)
611 // node index not found
614 //check if node is authenticated
616 memset(&sFrame
, 0, sizeof(WLAN_FR_REASSOCREQ
));
617 sFrame
.len
= pRxPacket
->cbMPDULen
;
618 sFrame
.pBuf
= (u8
*)pRxPacket
->p80211Header
;
619 vMgrDecodeReassocRequest(&sFrame
);
621 if (pMgmt
->sNodeDBTable
[uNodeIndex
].eNodeState
>= NODE_AUTH
) {
622 pMgmt
->sNodeDBTable
[uNodeIndex
].eNodeState
= NODE_ASSOC
;
623 pMgmt
->sNodeDBTable
[uNodeIndex
].wCapInfo
= cpu_to_le16(*sFrame
.pwCapInfo
);
624 pMgmt
->sNodeDBTable
[uNodeIndex
].wListenInterval
= cpu_to_le16(*sFrame
.pwListenInterval
);
625 pMgmt
->sNodeDBTable
[uNodeIndex
].bPSEnable
=
626 WLAN_GET_FC_PWRMGT(sFrame
.pHdr
->sA3
.wFrameCtl
) ? true : false;
627 // Todo: check sta basic rate, if ap can't support, set status code
629 if (pDevice
->byBBType
== BB_TYPE_11B
) {
630 uRateLen
= WLAN_RATES_MAXLEN_11B
;
633 abyCurrSuppRates
[0] = WLAN_EID_SUPP_RATES
;
634 abyCurrSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)sFrame
.pSuppRates
,
635 (PWLAN_IE_SUPP_RATES
)abyCurrSuppRates
,
637 abyCurrExtSuppRates
[0] = WLAN_EID_EXTSUPP_RATES
;
638 if (pDevice
->byBBType
== BB_TYPE_11G
) {
639 abyCurrExtSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)sFrame
.pExtSuppRates
,
640 (PWLAN_IE_SUPP_RATES
)abyCurrExtSuppRates
,
643 abyCurrExtSuppRates
[1] = 0;
646 RATEvParseMaxRate((void *)pDevice
,
647 (PWLAN_IE_SUPP_RATES
)abyCurrSuppRates
,
648 (PWLAN_IE_SUPP_RATES
)abyCurrExtSuppRates
,
649 false, // do not change our basic rate
650 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxBasicRate
),
651 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
),
652 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wSuppRate
),
653 &(pMgmt
->sNodeDBTable
[uNodeIndex
].byTopCCKBasicRate
),
654 &(pMgmt
->sNodeDBTable
[uNodeIndex
].byTopOFDMBasicRate
)
658 pMgmt
->sNodeDBTable
[uNodeIndex
].wTxDataRate
=
659 pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
;
660 // Todo: check sta preamble, if ap can't support, set status code
661 pMgmt
->sNodeDBTable
[uNodeIndex
].bShortPreamble
=
662 WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame
.pwCapInfo
);
663 pMgmt
->sNodeDBTable
[uNodeIndex
].bShortSlotTime
=
664 WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame
.pwCapInfo
);
665 pMgmt
->sNodeDBTable
[uNodeIndex
].wAID
= (u16
)uNodeIndex
;
666 wAssocStatus
= WLAN_MGMT_STATUS_SUCCESS
;
667 wAssocAID
= (u16
)uNodeIndex
;
670 if(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
> RATE_11M
)
671 pMgmt
->sNodeDBTable
[uNodeIndex
].bERPExist
= true;
673 if (pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
<= RATE_11M
) {
675 pDevice
->bProtectMode
= true;
676 pDevice
->bNonERPPresent
= true;
678 if (pMgmt
->sNodeDBTable
[uNodeIndex
].bShortPreamble
== false) {
679 pDevice
->bBarkerPreambleMd
= true;
682 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"Rx ReAssociate AID= %d \n", wAssocAID
);
683 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"MAC=%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X \n",
684 sFrame
.pHdr
->sA3
.abyAddr2
[0],
685 sFrame
.pHdr
->sA3
.abyAddr2
[1],
686 sFrame
.pHdr
->sA3
.abyAddr2
[2],
687 sFrame
.pHdr
->sA3
.abyAddr2
[3],
688 sFrame
.pHdr
->sA3
.abyAddr2
[4],
689 sFrame
.pHdr
->sA3
.abyAddr2
[5]
691 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"Max Support rate = %d \n",
692 pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
);
696 // assoc response reply..
697 pTxPacket
= s_MgrMakeReAssocResponse
704 sFrame
.pHdr
->sA3
.abyAddr2
,
705 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
706 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
709 if (pTxPacket
!= NULL
){
711 if (pDevice
->bEnableHostapd
) {
714 Status
= csMgmt_xmit(pDevice
, pTxPacket
);
715 if (Status
!= CMD_STATUS_PENDING
) {
716 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:ReAssoc response tx failed\n");
719 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:ReAssoc response tx sending..\n");
727 * Routine Description:
728 * Handle incoming association response frames.
735 static void s_vMgrRxAssocResponse(struct vnt_private
*pDevice
,
736 struct vnt_manager
*pMgmt
, struct vnt_rx_mgmt
*pRxPacket
,
739 WLAN_FR_ASSOCRESP sFrame
;
740 PWLAN_IE_SSID pItemSSID
;
743 if (pMgmt
->eCurrState
== WMAC_STATE_ASSOCPENDING
||
744 pMgmt
->eCurrState
== WMAC_STATE_ASSOC
) {
746 sFrame
.len
= pRxPacket
->cbMPDULen
;
747 sFrame
.pBuf
= (u8
*)pRxPacket
->p80211Header
;
749 vMgrDecodeAssocResponse(&sFrame
);
750 if ((sFrame
.pwCapInfo
== NULL
)
751 || (sFrame
.pwStatus
== NULL
)
752 || (sFrame
.pwAid
== NULL
)
753 || (sFrame
.pSuppRates
== NULL
)) {
757 pMgmt
->sAssocInfo
.AssocInfo
.ResponseFixedIEs
.Capabilities
= *(sFrame
.pwCapInfo
);
758 pMgmt
->sAssocInfo
.AssocInfo
.ResponseFixedIEs
.StatusCode
= *(sFrame
.pwStatus
);
759 pMgmt
->sAssocInfo
.AssocInfo
.ResponseFixedIEs
.AssociationId
= *(sFrame
.pwAid
);
760 pMgmt
->sAssocInfo
.AssocInfo
.AvailableResponseFixedIEs
|= 0x07;
762 pMgmt
->sAssocInfo
.AssocInfo
.ResponseIELength
= sFrame
.len
- 24 - 6;
763 pMgmt
->sAssocInfo
.AssocInfo
.OffsetResponseIEs
= pMgmt
->sAssocInfo
.AssocInfo
.OffsetRequestIEs
+ pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
;
764 pbyIEs
= pMgmt
->sAssocInfo
.abyIEs
;
765 pbyIEs
+= pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
;
766 memcpy(pbyIEs
, (sFrame
.pBuf
+ 24 +6), pMgmt
->sAssocInfo
.AssocInfo
.ResponseIELength
);
768 // save values and set current BSS state
769 if (cpu_to_le16((*(sFrame
.pwStatus
))) == WLAN_MGMT_STATUS_SUCCESS
){
771 pMgmt
->wCurrAID
= cpu_to_le16((*(sFrame
.pwAid
)));
772 if ( (pMgmt
->wCurrAID
>> 14) != (BIT0
| BIT1
) )
774 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"AID from AP, has two msb clear.\n");
776 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"Association Successful, AID=%d.\n", pMgmt
->wCurrAID
& ~(BIT14
|BIT15
));
777 pMgmt
->eCurrState
= WMAC_STATE_ASSOC
;
778 BSSvUpdateAPNode((void *) pDevice
,
781 sFrame
.pExtSuppRates
);
782 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
;
783 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"Link with AP(SSID): %s\n", pItemSSID
->abySSID
);
784 pDevice
->bLinkPass
= true;
785 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_INTER
);
787 //if(pDevice->bWPASuppWextEnabled == true)
791 union iwreq_data wrqu
;
796 len
= pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
;
798 memcpy(buf
, pMgmt
->sAssocInfo
.abyIEs
, len
);
799 memset(&wrqu
, 0, sizeof (wrqu
));
800 wrqu
.data
.length
= len
;
801 we_event
= IWEVASSOCREQIE
;
802 PRINT_K("wireless_send_event--->IWEVASSOCREQIE\n");
803 wireless_send_event(pDevice
->dev
, we_event
, &wrqu
, buf
);
807 len
= pMgmt
->sAssocInfo
.AssocInfo
.ResponseIELength
;
810 memcpy(buf
, pbyIEs
, len
);
811 memset(&wrqu
, 0, sizeof (wrqu
));
812 wrqu
.data
.length
= len
;
813 we_event
= IWEVASSOCRESPIE
;
814 PRINT_K("wireless_send_event--->IWEVASSOCRESPIE\n");
815 wireless_send_event(pDevice
->dev
, we_event
, &wrqu
, buf
);
818 memset(&wrqu
, 0, sizeof (wrqu
));
819 memcpy(wrqu
.ap_addr
.sa_data
, &pMgmt
->abyCurrBSSID
[0], ETH_ALEN
);
820 wrqu
.ap_addr
.sa_family
= ARPHRD_ETHER
;
821 PRINT_K("wireless_send_event--->SIOCGIWAP(associated)\n");
822 wireless_send_event(pDevice
->dev
, SIOCGIWAP
, &wrqu
, NULL
);
829 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
832 // jump back to the auth state and indicate the error
833 pMgmt
->eCurrState
= WMAC_STATE_AUTH
;
835 s_vMgrLogStatus(pMgmt
,cpu_to_le16((*(sFrame
.pwStatus
))));
840 //need clear flags related to Networkmanager
841 pDevice
->bwextstep0
= false;
842 pDevice
->bwextstep1
= false;
843 pDevice
->bwextstep2
= false;
844 pDevice
->bwextstep3
= false;
845 pDevice
->bWPASuppWextEnabled
= false;
847 if(pMgmt
->eCurrState
== WMAC_STATE_ASSOC
)
848 timer_expire(pDevice
->sTimerCommand
, 0);
855 * Routine Description:
856 * Start the station authentication procedure. Namely, send an
857 * authentication frame to the AP.
864 void vMgrAuthenBeginSta(struct vnt_private
*pDevice
,
865 struct vnt_manager
*pMgmt
, PCMD_STATUS pStatus
)
867 WLAN_FR_AUTHEN sFrame
;
868 struct vnt_tx_mgmt
*pTxPacket
=
869 (struct vnt_tx_mgmt
*)pMgmt
->pbyMgmtPacketPool
;
871 memset(pTxPacket
, 0, sizeof(struct vnt_tx_mgmt
)
872 + WLAN_AUTHEN_FR_MAXLEN
);
873 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((u8
*)pTxPacket
874 + sizeof(struct vnt_tx_mgmt
));
875 sFrame
.pBuf
= (u8
*)pTxPacket
->p80211Header
;
876 sFrame
.len
= WLAN_AUTHEN_FR_MAXLEN
;
877 vMgrEncodeAuthen(&sFrame
);
879 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
881 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
882 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN
)
884 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pMgmt
->abyCurrBSSID
, WLAN_ADDR_LEN
);
885 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
886 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
887 if (pMgmt
->bShareKeyAlgorithm
)
888 *(sFrame
.pwAuthAlgorithm
) = cpu_to_le16(WLAN_AUTH_ALG_SHAREDKEY
);
890 *(sFrame
.pwAuthAlgorithm
) = cpu_to_le16(WLAN_AUTH_ALG_OPENSYSTEM
);
892 *(sFrame
.pwAuthSequence
) = cpu_to_le16(1);
893 /* Adjust the length fields */
894 pTxPacket
->cbMPDULen
= sFrame
.len
;
895 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
897 *pStatus
= csMgmt_xmit(pDevice
, pTxPacket
);
898 if (*pStatus
== CMD_STATUS_PENDING
){
899 pMgmt
->eCurrState
= WMAC_STATE_AUTHPENDING
;
900 *pStatus
= CMD_STATUS_SUCCESS
;
908 * Routine Description:
909 * Start the station(AP) deauthentication procedure. Namely, send an
910 * deauthentication frame to the AP or Sta.
917 void vMgrDeAuthenBeginSta(struct vnt_private
*pDevice
,
918 struct vnt_manager
*pMgmt
, u8
*abyDestAddress
, u16 wReason
,
921 WLAN_FR_DEAUTHEN sFrame
;
922 struct vnt_tx_mgmt
*pTxPacket
=
923 (struct vnt_tx_mgmt
*)pMgmt
->pbyMgmtPacketPool
;
925 memset(pTxPacket
, 0, sizeof(struct vnt_tx_mgmt
)
926 + WLAN_DEAUTHEN_FR_MAXLEN
);
927 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((u8
*)pTxPacket
928 + sizeof(struct vnt_tx_mgmt
));
929 sFrame
.pBuf
= (u8
*)pTxPacket
->p80211Header
;
930 sFrame
.len
= WLAN_DEAUTHEN_FR_MAXLEN
;
931 vMgrEncodeDeauthen(&sFrame
);
933 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
935 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
936 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_DEAUTHEN
)
939 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, abyDestAddress
, WLAN_ADDR_LEN
);
940 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
941 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
943 *(sFrame
.pwReason
) = cpu_to_le16(wReason
); // deauthen. bcs left BSS
944 /* Adjust the length fields */
945 pTxPacket
->cbMPDULen
= sFrame
.len
;
946 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
948 *pStatus
= csMgmt_xmit(pDevice
, pTxPacket
);
949 if (*pStatus
== CMD_STATUS_PENDING
){
950 *pStatus
= CMD_STATUS_SUCCESS
;
958 * Routine Description:
959 * Handle incoming authentication frames.
966 static void s_vMgrRxAuthentication(struct vnt_private
*pDevice
,
967 struct vnt_manager
*pMgmt
, struct vnt_rx_mgmt
*pRxPacket
)
969 WLAN_FR_AUTHEN sFrame
;
971 // we better be an AP or a STA in AUTHPENDING otherwise ignore
972 if (!(pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
||
973 pMgmt
->eCurrState
== WMAC_STATE_AUTHPENDING
)) {
978 sFrame
.len
= pRxPacket
->cbMPDULen
;
979 sFrame
.pBuf
= (u8
*)pRxPacket
->p80211Header
;
980 vMgrDecodeAuthen(&sFrame
);
981 switch (cpu_to_le16((*(sFrame
.pwAuthSequence
)))){
984 s_vMgrRxAuthenSequence_1(pDevice
,pMgmt
, &sFrame
);
987 s_vMgrRxAuthenSequence_2(pDevice
, pMgmt
, &sFrame
);
991 s_vMgrRxAuthenSequence_3(pDevice
, pMgmt
, &sFrame
);
994 s_vMgrRxAuthenSequence_4(pDevice
, pMgmt
, &sFrame
);
997 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Auth Sequence error, seq = %d\n",
998 cpu_to_le16((*(sFrame
.pwAuthSequence
))));
1006 * Routine Description:
1007 * Handles incoming authen frames with sequence 1. Currently
1008 * assumes we're an AP. So far, no one appears to use authentication
1016 static void s_vMgrRxAuthenSequence_1(struct vnt_private
*pDevice
,
1017 struct vnt_manager
*pMgmt
, PWLAN_FR_AUTHEN pFrame
)
1019 struct vnt_tx_mgmt
*pTxPacket
= NULL
;
1021 WLAN_FR_AUTHEN sFrame
;
1022 PSKeyItem pTransmitKey
;
1024 /* Insert a Node entry */
1025 if (!BSSbIsSTAInNodeDB(pDevice
, pFrame
->pHdr
->sA3
.abyAddr2
,
1027 BSSvCreateOneNode(pDevice
, &uNodeIndex
);
1028 memcpy(pMgmt
->sNodeDBTable
[uNodeIndex
].abyMACAddr
,
1029 pFrame
->pHdr
->sA3
.abyAddr2
, WLAN_ADDR_LEN
);
1032 if (pMgmt
->bShareKeyAlgorithm
) {
1033 pMgmt
->sNodeDBTable
[uNodeIndex
].eNodeState
= NODE_KNOWN
;
1034 pMgmt
->sNodeDBTable
[uNodeIndex
].byAuthSequence
= 1;
1037 pMgmt
->sNodeDBTable
[uNodeIndex
].eNodeState
= NODE_AUTH
;
1041 pTxPacket
= (struct vnt_tx_mgmt
*)pMgmt
->pbyMgmtPacketPool
;
1042 memset(pTxPacket
, 0, sizeof(struct vnt_tx_mgmt
)
1043 + WLAN_AUTHEN_FR_MAXLEN
);
1044 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((u8
*)pTxPacket
1045 + sizeof(struct vnt_tx_mgmt
));
1046 sFrame
.pBuf
= (u8
*)pTxPacket
->p80211Header
;
1047 sFrame
.len
= WLAN_AUTHEN_FR_MAXLEN
;
1048 // format buffer structure
1049 vMgrEncodeAuthen(&sFrame
);
1051 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
1053 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
1054 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN
)|
1055 WLAN_SET_FC_ISWEP(0)
1057 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pFrame
->pHdr
->sA3
.abyAddr2
, WLAN_ADDR_LEN
);
1058 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
1059 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
1060 *(sFrame
.pwAuthAlgorithm
) = *(pFrame
->pwAuthAlgorithm
);
1061 *(sFrame
.pwAuthSequence
) = cpu_to_le16(2);
1063 if (cpu_to_le16(*(pFrame
->pwAuthAlgorithm
)) == WLAN_AUTH_ALG_SHAREDKEY
) {
1064 if (pMgmt
->bShareKeyAlgorithm
)
1065 *(sFrame
.pwStatus
) = cpu_to_le16(WLAN_MGMT_STATUS_SUCCESS
);
1067 *(sFrame
.pwStatus
) = cpu_to_le16(WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG
);
1070 if (pMgmt
->bShareKeyAlgorithm
)
1071 *(sFrame
.pwStatus
) = cpu_to_le16(WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG
);
1073 *(sFrame
.pwStatus
) = cpu_to_le16(WLAN_MGMT_STATUS_SUCCESS
);
1076 if (pMgmt
->bShareKeyAlgorithm
&&
1077 (cpu_to_le16(*(sFrame
.pwStatus
)) == WLAN_MGMT_STATUS_SUCCESS
)) {
1079 sFrame
.pChallenge
= (PWLAN_IE_CHALLENGE
)(sFrame
.pBuf
+ sFrame
.len
);
1080 sFrame
.len
+= WLAN_CHALLENGE_IE_LEN
;
1081 sFrame
.pChallenge
->byElementID
= WLAN_EID_CHALLENGE
;
1082 sFrame
.pChallenge
->len
= WLAN_CHALLENGE_LEN
;
1083 memset(pMgmt
->abyChallenge
, 0, WLAN_CHALLENGE_LEN
);
1085 if(KeybGetTransmitKey(&(pDevice
->sKey
), pDevice
->abyBroadcastAddr
, GROUP_KEY
, &pTransmitKey
) == true) {
1086 rc4_init(&pDevice
->SBox
, pDevice
->abyPRNG
, pTransmitKey
->uKeyLength
+3);
1087 rc4_encrypt(&pDevice
->SBox
, pMgmt
->abyChallenge
, pMgmt
->abyChallenge
, WLAN_CHALLENGE_LEN
);
1089 memcpy(sFrame
.pChallenge
->abyChallenge
, pMgmt
->abyChallenge
, WLAN_CHALLENGE_LEN
);
1092 /* Adjust the length fields */
1093 pTxPacket
->cbMPDULen
= sFrame
.len
;
1094 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
1096 if (pDevice
->bEnableHostapd
) {
1099 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Authreq_reply sequence_1 tx.. \n");
1100 if (csMgmt_xmit(pDevice
, pTxPacket
) != CMD_STATUS_PENDING
) {
1101 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Authreq_reply sequence_1 tx failed.\n");
1108 * Routine Description:
1109 * Handles incoming auth frames with sequence number 2. Currently
1110 * assumes we're a station.
1118 static void s_vMgrRxAuthenSequence_2(struct vnt_private
*pDevice
,
1119 struct vnt_manager
*pMgmt
, PWLAN_FR_AUTHEN pFrame
)
1121 WLAN_FR_AUTHEN sFrame
;
1122 struct vnt_tx_mgmt
*pTxPacket
= NULL
;
1124 switch (cpu_to_le16((*(pFrame
->pwAuthAlgorithm
))))
1126 case WLAN_AUTH_ALG_OPENSYSTEM
:
1127 if ( cpu_to_le16((*(pFrame
->pwStatus
))) == WLAN_MGMT_STATUS_SUCCESS
){
1128 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"802.11 Authen (OPEN) Successful.\n");
1129 pMgmt
->eCurrState
= WMAC_STATE_AUTH
;
1130 timer_expire(pDevice
->sTimerCommand
, 0);
1133 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"802.11 Authen (OPEN) Failed.\n");
1134 s_vMgrLogStatus(pMgmt
, cpu_to_le16((*(pFrame
->pwStatus
))));
1135 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
1137 if (pDevice
->eCommandState
== WLAN_AUTHENTICATE_WAIT
) {
1138 /* spin_unlock_irq(&pDevice->lock);
1139 vCommandTimerWait((void *) pDevice, 0);
1140 spin_lock_irq(&pDevice->lock); */
1144 case WLAN_AUTH_ALG_SHAREDKEY
:
1146 if (cpu_to_le16((*(pFrame
->pwStatus
))) == WLAN_MGMT_STATUS_SUCCESS
) {
1147 pTxPacket
= (struct vnt_tx_mgmt
*)
1148 pMgmt
->pbyMgmtPacketPool
;
1149 memset(pTxPacket
, 0, sizeof(struct vnt_tx_mgmt
)
1150 + WLAN_AUTHEN_FR_MAXLEN
);
1151 pTxPacket
->p80211Header
1152 = (PUWLAN_80211HDR
)((u8
*)pTxPacket
1153 + sizeof(struct vnt_tx_mgmt
));
1154 sFrame
.pBuf
= (u8
*)pTxPacket
->p80211Header
;
1155 sFrame
.len
= WLAN_AUTHEN_FR_MAXLEN
;
1156 // format buffer structure
1157 vMgrEncodeAuthen(&sFrame
);
1159 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
1161 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
1162 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN
)|
1163 WLAN_SET_FC_ISWEP(1)
1165 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
1166 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
1167 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
1168 *(sFrame
.pwAuthAlgorithm
) = *(pFrame
->pwAuthAlgorithm
);
1169 *(sFrame
.pwAuthSequence
) = cpu_to_le16(3);
1170 *(sFrame
.pwStatus
) = cpu_to_le16(WLAN_MGMT_STATUS_SUCCESS
);
1171 sFrame
.pChallenge
= (PWLAN_IE_CHALLENGE
)(sFrame
.pBuf
+ sFrame
.len
);
1172 sFrame
.len
+= WLAN_CHALLENGE_IE_LEN
;
1173 sFrame
.pChallenge
->byElementID
= WLAN_EID_CHALLENGE
;
1174 sFrame
.pChallenge
->len
= WLAN_CHALLENGE_LEN
;
1175 memcpy( sFrame
.pChallenge
->abyChallenge
, pFrame
->pChallenge
->abyChallenge
, WLAN_CHALLENGE_LEN
);
1176 // Adjust the length fields
1177 pTxPacket
->cbMPDULen
= sFrame
.len
;
1178 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
1180 if (csMgmt_xmit(pDevice
, pTxPacket
) != CMD_STATUS_PENDING
) {
1181 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Auth_reply sequence_2 tx failed.\n");
1183 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Auth_reply sequence_2 tx ...\n");
1186 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:rx Auth_reply sequence_2 status error ...\n");
1187 if ( pDevice
->eCommandState
== WLAN_AUTHENTICATE_WAIT
) {
1188 /* spin_unlock_irq(&pDevice->lock);
1189 vCommandTimerWait((void *) pDevice, 0);
1190 spin_lock_irq(&pDevice->lock); */
1192 s_vMgrLogStatus(pMgmt
, cpu_to_le16((*(pFrame
->pwStatus
))));
1196 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt: rx auth.seq = 2 unknown AuthAlgorithm=%d\n", cpu_to_le16((*(pFrame
->pwAuthAlgorithm
))));
1204 * Routine Description:
1205 * Handles incoming authen frames with sequence 3. Currently
1206 * assumes we're an AP. This function assumes the frame has
1207 * already been successfully decrypted.
1215 static void s_vMgrRxAuthenSequence_3(struct vnt_private
*pDevice
,
1216 struct vnt_manager
*pMgmt
, PWLAN_FR_AUTHEN pFrame
)
1218 struct vnt_tx_mgmt
*pTxPacket
= NULL
;
1219 u32 uStatusCode
= 0 ;
1221 WLAN_FR_AUTHEN sFrame
;
1223 if (!WLAN_GET_FC_ISWEP(pFrame
->pHdr
->sA3
.wFrameCtl
)) {
1224 uStatusCode
= WLAN_MGMT_STATUS_CHALLENGE_FAIL
;
1227 if (BSSbIsSTAInNodeDB(pDevice
, pFrame
->pHdr
->sA3
.abyAddr2
, &uNodeIndex
)) {
1228 if (pMgmt
->sNodeDBTable
[uNodeIndex
].byAuthSequence
!= 1) {
1229 uStatusCode
= WLAN_MGMT_STATUS_RX_AUTH_NOSEQ
;
1232 if (memcmp(pMgmt
->abyChallenge
, pFrame
->pChallenge
->abyChallenge
, WLAN_CHALLENGE_LEN
) != 0) {
1233 uStatusCode
= WLAN_MGMT_STATUS_CHALLENGE_FAIL
;
1238 uStatusCode
= WLAN_MGMT_STATUS_UNSPEC_FAILURE
;
1243 pMgmt
->sNodeDBTable
[uNodeIndex
].eNodeState
= NODE_AUTH
;
1244 pMgmt
->sNodeDBTable
[uNodeIndex
].byAuthSequence
= 0;
1246 uStatusCode
= WLAN_MGMT_STATUS_SUCCESS
;
1247 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Challenge text check ok..\n");
1251 pTxPacket
= (struct vnt_tx_mgmt
*)pMgmt
->pbyMgmtPacketPool
;
1252 memset(pTxPacket
, 0, sizeof(struct vnt_tx_mgmt
)
1253 + WLAN_AUTHEN_FR_MAXLEN
);
1254 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((u8
*)pTxPacket
1255 + sizeof(struct vnt_tx_mgmt
));
1256 sFrame
.pBuf
= (u8
*)pTxPacket
->p80211Header
;
1257 sFrame
.len
= WLAN_AUTHEN_FR_MAXLEN
;
1258 // format buffer structure
1259 vMgrEncodeAuthen(&sFrame
);
1261 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
1263 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
1264 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN
)|
1265 WLAN_SET_FC_ISWEP(0)
1267 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pFrame
->pHdr
->sA3
.abyAddr2
, WLAN_ADDR_LEN
);
1268 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
1269 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
1270 *(sFrame
.pwAuthAlgorithm
) = *(pFrame
->pwAuthAlgorithm
);
1271 *(sFrame
.pwAuthSequence
) = cpu_to_le16(4);
1272 *(sFrame
.pwStatus
) = cpu_to_le16(uStatusCode
);
1274 /* Adjust the length fields */
1275 pTxPacket
->cbMPDULen
= sFrame
.len
;
1276 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
1278 if (pDevice
->bEnableHostapd
) {
1281 if (csMgmt_xmit(pDevice
, pTxPacket
) != CMD_STATUS_PENDING
) {
1282 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Authreq_reply sequence_4 tx failed.\n");
1290 * Routine Description:
1291 * Handles incoming authen frames with sequence 4
1298 static void s_vMgrRxAuthenSequence_4(struct vnt_private
*pDevice
,
1299 struct vnt_manager
*pMgmt
, PWLAN_FR_AUTHEN pFrame
)
1302 if ( cpu_to_le16((*(pFrame
->pwStatus
))) == WLAN_MGMT_STATUS_SUCCESS
){
1303 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"802.11 Authen (SHAREDKEY) Successful.\n");
1304 pMgmt
->eCurrState
= WMAC_STATE_AUTH
;
1305 timer_expire(pDevice
->sTimerCommand
, 0);
1308 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"802.11 Authen (SHAREDKEY) Failed.\n");
1309 s_vMgrLogStatus(pMgmt
, cpu_to_le16((*(pFrame
->pwStatus
))) );
1310 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
1313 if ( pDevice
->eCommandState
== WLAN_AUTHENTICATE_WAIT
) {
1314 /* spin_unlock_irq(&pDevice->lock);
1315 vCommandTimerWait((void *) pDevice, 0);
1316 spin_lock_irq(&pDevice->lock); */
1322 * Routine Description:
1323 * Handles incoming disassociation frames
1331 static void s_vMgrRxDisassociation(struct vnt_private
*pDevice
,
1332 struct vnt_manager
*pMgmt
, struct vnt_rx_mgmt
*pRxPacket
)
1334 WLAN_FR_DISASSOC sFrame
;
1336 CMD_STATUS CmdStatus
;
1338 if ( pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
){
1339 // if is acting an AP..
1340 // a STA is leaving this BSS..
1341 sFrame
.len
= pRxPacket
->cbMPDULen
;
1342 sFrame
.pBuf
= (u8
*)pRxPacket
->p80211Header
;
1343 if (BSSbIsSTAInNodeDB(pDevice
, pRxPacket
->p80211Header
->sA3
.abyAddr2
, &uNodeIndex
)) {
1344 BSSvRemoveOneNode(pDevice
, uNodeIndex
);
1347 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Rx disassoc, sta not found\n");
1350 else if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_STA
){
1351 sFrame
.len
= pRxPacket
->cbMPDULen
;
1352 sFrame
.pBuf
= (u8
*)pRxPacket
->p80211Header
;
1353 vMgrDecodeDisassociation(&sFrame
);
1354 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"AP disassociated me, reason=%d.\n", cpu_to_le16(*(sFrame
.pwReason
)));
1356 pDevice
->fWPA_Authened
= false;
1358 //TODO: do something let upper layer know or
1359 //try to send associate packet again because of inactivity timeout
1360 if (pMgmt
->eCurrState
== WMAC_STATE_ASSOC
) {
1361 pDevice
->bLinkPass
= false;
1362 pMgmt
->sNodeDBTable
[0].bActive
= false;
1363 pDevice
->byReAssocCount
= 0;
1364 pMgmt
->eCurrState
= WMAC_STATE_AUTH
; // jump back to the auth state!
1365 pDevice
->eCommandState
= WLAN_ASSOCIATE_WAIT
;
1366 vMgrReAssocBeginSta(pDevice
, pMgmt
, &CmdStatus
);
1367 if(CmdStatus
== CMD_STATUS_PENDING
) {
1368 pDevice
->byReAssocCount
++;
1369 return; //mike add: you'll retry for many times, so it cann't be regarded as disconnected!
1373 // if(pDevice->bWPASuppWextEnabled == true)
1375 union iwreq_data wrqu
;
1376 memset(&wrqu
, 0, sizeof (wrqu
));
1377 wrqu
.ap_addr
.sa_family
= ARPHRD_ETHER
;
1378 PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated)\n");
1379 wireless_send_event(pDevice
->dev
, SIOCGIWAP
, &wrqu
, NULL
);
1382 /* else, ignore it */
1389 * Routine Description:
1390 * Handles incoming deauthentication frames
1398 static void s_vMgrRxDeauthentication(struct vnt_private
*pDevice
,
1399 struct vnt_manager
*pMgmt
, struct vnt_rx_mgmt
*pRxPacket
)
1401 WLAN_FR_DEAUTHEN sFrame
;
1404 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
){
1406 // if is acting an AP..
1407 // a STA is leaving this BSS..
1408 sFrame
.len
= pRxPacket
->cbMPDULen
;
1409 sFrame
.pBuf
= (u8
*)pRxPacket
->p80211Header
;
1410 if (BSSbIsSTAInNodeDB(pDevice
, pRxPacket
->p80211Header
->sA3
.abyAddr2
, &uNodeIndex
)) {
1411 BSSvRemoveOneNode(pDevice
, uNodeIndex
);
1414 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Rx deauth, sta not found\n");
1418 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_STA
) {
1419 sFrame
.len
= pRxPacket
->cbMPDULen
;
1420 sFrame
.pBuf
= (u8
*)pRxPacket
->p80211Header
;
1421 vMgrDecodeDeauthen(&sFrame
);
1422 pDevice
->fWPA_Authened
= false;
1423 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"AP deauthed me, reason=%d.\n", cpu_to_le16((*(sFrame
.pwReason
))));
1424 // TODO: update BSS list for specific BSSID if pre-authentication case
1425 if (!compare_ether_addr(sFrame
.pHdr
->sA3
.abyAddr3
,
1426 pMgmt
->abyCurrBSSID
)) {
1427 if (pMgmt
->eCurrState
>= WMAC_STATE_AUTHPENDING
) {
1428 pMgmt
->sNodeDBTable
[0].bActive
= false;
1429 pMgmt
->eCurrMode
= WMAC_MODE_STANDBY
;
1430 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
1431 netif_stop_queue(pDevice
->dev
);
1432 pDevice
->bLinkPass
= false;
1433 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_SLOW
);
1437 // if(pDevice->bWPASuppWextEnabled == true)
1439 union iwreq_data wrqu
;
1440 memset(&wrqu
, 0, sizeof (wrqu
));
1441 wrqu
.ap_addr
.sa_family
= ARPHRD_ETHER
;
1442 PRINT_K("wireless_send_event--->SIOCGIWAP(disauthen)\n");
1443 wireless_send_event(pDevice
->dev
, SIOCGIWAP
, &wrqu
, NULL
);
1447 /* else, ignore it. TODO: IBSS authentication service
1448 would be implemented here */
1455 * Routine Description:
1456 * check if current channel is match ZoneType.
1464 static int ChannelExceedZoneType(struct vnt_private
*pDevice
, u8 byCurrChannel
)
1468 switch(pDevice
->byZoneType
) {
1469 case 0x00: //USA:1~11
1470 if((byCurrChannel
<1) ||(byCurrChannel
>11))
1473 case 0x01: //Japan:1~13
1474 case 0x02: //Europe:1~13
1475 if((byCurrChannel
<1) ||(byCurrChannel
>13))
1478 default: //reserve for other zonetype
1487 * Routine Description:
1488 * Handles and analysis incoming beacon frames.
1496 static void s_vMgrRxBeacon(struct vnt_private
*pDevice
,
1497 struct vnt_manager
*pMgmt
, struct vnt_rx_mgmt
*pRxPacket
,
1501 WLAN_FR_BEACON sFrame
;
1503 int bIsBSSIDEqual
= false;
1504 int bIsSSIDEqual
= false;
1505 int bTSFLargeDiff
= false;
1506 int bTSFOffsetPostive
= false;
1507 int bUpdateTSF
= false;
1508 int bIsAPBeacon
= false;
1509 int bIsChannelEqual
= false;
1510 u32 uLocateByteIndex
;
1514 u64 qwTimestamp
, qwLocalTSF
;
1516 u16 wStartIndex
= 0;
1518 u8 byCurrChannel
= pRxPacket
->byRxChannel
;
1520 u32 uRateLen
= WLAN_RATES_MAXLEN
;
1521 int bChannelHit
= false;
1522 u8 byOldPreambleType
;
1524 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
)
1527 memset(&sFrame
, 0, sizeof(WLAN_FR_BEACON
));
1528 sFrame
.len
= pRxPacket
->cbMPDULen
;
1529 sFrame
.pBuf
= (u8
*)pRxPacket
->p80211Header
;
1531 // decode the beacon frame
1532 vMgrDecodeBeacon(&sFrame
);
1534 if ((sFrame
.pwBeaconInterval
== NULL
)
1535 || (sFrame
.pwCapInfo
== NULL
)
1536 || (sFrame
.pSSID
== NULL
)
1537 || (sFrame
.pSuppRates
== NULL
)) {
1539 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Rx beacon frame error\n");
1543 if( byCurrChannel
> CB_MAX_CHANNEL_24G
)
1545 if (sFrame
.pDSParms
!= NULL
) {
1546 if (byCurrChannel
== RFaby11aChannelIndex
[sFrame
.pDSParms
->byCurrChannel
-1])
1548 byCurrChannel
= RFaby11aChannelIndex
[sFrame
.pDSParms
->byCurrChannel
-1];
1554 if (sFrame
.pDSParms
!= NULL
) {
1555 if (byCurrChannel
== sFrame
.pDSParms
->byCurrChannel
)
1557 byCurrChannel
= sFrame
.pDSParms
->byCurrChannel
;
1563 if(ChannelExceedZoneType(pDevice
,byCurrChannel
)==true)
1566 if (sFrame
.pERP
!= NULL
) {
1567 sERP
.byERP
= sFrame
.pERP
->byContext
;
1568 sERP
.bERPExist
= true;
1571 sERP
.bERPExist
= false;
1575 pBSSList
= BSSpAddrIsInBSSList((void *) pDevice
,
1576 sFrame
.pHdr
->sA3
.abyAddr3
,
1578 if (pBSSList
== NULL
) {
1579 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Beacon/insert: RxChannel = : %d\n", byCurrChannel
);
1580 BSSbInsertToBSSList((void *) pDevice
,
1581 sFrame
.pHdr
->sA3
.abyAddr3
,
1582 *sFrame
.pqwTimestamp
,
1583 *sFrame
.pwBeaconInterval
,
1588 sFrame
.pExtSuppRates
,
1594 sFrame
.len
- WLAN_HDR_ADDR3_LEN
,
1595 sFrame
.pHdr
->sA4
.abyAddr4
, // payload of beacon
1596 (void *) pRxPacket
);
1599 // DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"update bcn: RxChannel = : %d\n", byCurrChannel);
1600 BSSbUpdateToBSSList((void *) pDevice
,
1601 *sFrame
.pqwTimestamp
,
1602 *sFrame
.pwBeaconInterval
,
1608 sFrame
.pExtSuppRates
,
1615 sFrame
.len
- WLAN_HDR_ADDR3_LEN
,
1616 sFrame
.pHdr
->sA4
.abyAddr4
, // payload of probresponse
1617 (void *) pRxPacket
);
1625 if(byCurrChannel
== (u8
)pMgmt
->uCurrChannel
)
1626 bIsChannelEqual
= true;
1628 if (bIsChannelEqual
&& (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
)) {
1630 // if rx beacon without ERP field
1631 if (sERP
.bERPExist
) {
1632 if (WLAN_GET_ERP_USE_PROTECTION(sERP
.byERP
)){
1633 pDevice
->byERPFlag
|= WLAN_SET_ERP_USE_PROTECTION(1);
1634 pDevice
->wUseProtectCntDown
= USE_PROTECT_PERIOD
;
1638 pDevice
->byERPFlag
|= WLAN_SET_ERP_USE_PROTECTION(1);
1639 pDevice
->wUseProtectCntDown
= USE_PROTECT_PERIOD
;
1642 if (pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) {
1643 if(!WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame
.pwCapInfo
))
1644 pDevice
->byERPFlag
|= WLAN_SET_ERP_BARKER_MODE(1);
1646 pDevice
->byERPFlag
|= WLAN_SET_ERP_NONERP_PRESENT(1);
1650 // check if BSSID the same
1651 if (memcmp(sFrame
.pHdr
->sA3
.abyAddr3
,
1652 pMgmt
->abyCurrBSSID
,
1653 WLAN_BSSID_LEN
) == 0) {
1655 bIsBSSIDEqual
= true;
1656 pDevice
->uCurrRSSI
= pRxPacket
->uRSSI
;
1657 pDevice
->byCurrSQ
= pRxPacket
->bySQ
;
1658 if (pMgmt
->sNodeDBTable
[0].uInActiveCount
!= 0) {
1659 pMgmt
->sNodeDBTable
[0].uInActiveCount
= 0;
1660 //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BCN:Wake Count= [%d]\n", pMgmt->wCountToWakeUp);
1663 // check if SSID the same
1664 if (sFrame
.pSSID
->len
== ((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->len
) {
1665 if (memcmp(sFrame
.pSSID
->abySSID
,
1666 ((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->abySSID
,
1669 bIsSSIDEqual
= true;
1673 if ((WLAN_GET_CAP_INFO_ESS(*sFrame
.pwCapInfo
)== true) &&
1674 (bIsBSSIDEqual
== true) &&
1675 (bIsSSIDEqual
== true) &&
1676 (pMgmt
->eCurrMode
== WMAC_MODE_ESS_STA
) &&
1677 (pMgmt
->eCurrState
== WMAC_STATE_ASSOC
)) {
1678 // add state check to prevent reconnect fail since we'll receive Beacon
1681 if (pBSSList
!= NULL
) {
1684 if ((pBSSList
->sERP
.bERPExist
== true) && (pDevice
->byBBType
== BB_TYPE_11G
)) {
1685 if ((pBSSList
->sERP
.byERP
& WLAN_EID_ERP_USE_PROTECTION
) != pDevice
->bProtectMode
) {//0000 0010
1686 pDevice
->bProtectMode
= (pBSSList
->sERP
.byERP
& WLAN_EID_ERP_USE_PROTECTION
);
1687 if (pDevice
->bProtectMode
) {
1688 MACvEnableProtectMD(pDevice
);
1690 MACvDisableProtectMD(pDevice
);
1692 vUpdateIFS(pDevice
);
1694 if ((pBSSList
->sERP
.byERP
& WLAN_EID_ERP_NONERP_PRESENT
) != pDevice
->bNonERPPresent
) {//0000 0001
1695 pDevice
->bNonERPPresent
= (pBSSList
->sERP
.byERP
& WLAN_EID_ERP_USE_PROTECTION
);
1697 if ((pBSSList
->sERP
.byERP
& WLAN_EID_ERP_BARKER_MODE
) != pDevice
->bBarkerPreambleMd
) {//0000 0100
1698 pDevice
->bBarkerPreambleMd
= (pBSSList
->sERP
.byERP
& WLAN_EID_ERP_BARKER_MODE
);
1699 //BarkerPreambleMd has higher priority than shortPreamble bit in Cap
1700 if (pDevice
->bBarkerPreambleMd
) {
1701 MACvEnableBarkerPreambleMd(pDevice
);
1703 MACvDisableBarkerPreambleMd(pDevice
);
1707 // Sync Short Slot Time
1708 if (WLAN_GET_CAP_INFO_SHORTSLOTTIME(pBSSList
->wCapInfo
) != pDevice
->bShortSlotTime
) {
1709 bool bShortSlotTime
;
1711 bShortSlotTime
= WLAN_GET_CAP_INFO_SHORTSLOTTIME(pBSSList
->wCapInfo
);
1712 //DBG_PRN_WLAN05(("Set Short Slot Time: %d\n", pDevice->bShortSlotTime));
1713 //Kyle check if it is OK to set G.
1714 if (pDevice
->byBBType
== BB_TYPE_11A
) {
1715 bShortSlotTime
= true;
1717 else if (pDevice
->byBBType
== BB_TYPE_11B
) {
1718 bShortSlotTime
= false;
1720 if (bShortSlotTime
!= pDevice
->bShortSlotTime
) {
1721 pDevice
->bShortSlotTime
= bShortSlotTime
;
1722 BBvSetShortSlotTime(pDevice
);
1723 vUpdateIFS(pDevice
);
1728 // Preamble may change dynamically
1730 byOldPreambleType
= pDevice
->byPreambleType
;
1731 if (WLAN_GET_CAP_INFO_SHORTPREAMBLE(pBSSList
->wCapInfo
)) {
1732 pDevice
->byPreambleType
= pDevice
->byShortPreamble
;
1735 pDevice
->byPreambleType
= 0;
1737 if (pDevice
->byPreambleType
!= byOldPreambleType
)
1738 CARDvSetRSPINF(pDevice
, (u8
)pDevice
->byBBType
);
1740 // Basic Rate Set may change dynamically
1742 if (pBSSList
->eNetworkTypeInUse
== PHY_TYPE_11B
) {
1743 uRateLen
= WLAN_RATES_MAXLEN_11B
;
1745 pMgmt
->abyCurrSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)pBSSList
->abySuppRates
,
1746 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
1748 pMgmt
->abyCurrExtSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)pBSSList
->abyExtSuppRates
,
1749 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
,
1751 RATEvParseMaxRate((void *)pDevice
,
1752 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
1753 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
,
1755 &(pMgmt
->sNodeDBTable
[0].wMaxBasicRate
),
1756 &(pMgmt
->sNodeDBTable
[0].wMaxSuppRate
),
1757 &(pMgmt
->sNodeDBTable
[0].wSuppRate
),
1758 &(pMgmt
->sNodeDBTable
[0].byTopCCKBasicRate
),
1759 &(pMgmt
->sNodeDBTable
[0].byTopOFDMBasicRate
)
1765 // DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Beacon 2 \n");
1766 // check if CF field exisit
1767 if (WLAN_GET_CAP_INFO_ESS(*sFrame
.pwCapInfo
)) {
1768 if (sFrame
.pCFParms
->wCFPDurRemaining
> 0) {
1769 // TODO: deal with CFP period to set NAV
1773 qwTimestamp
= cpu_to_le64(*sFrame
.pqwTimestamp
);
1774 qwLocalTSF
= pRxPacket
->qwLocalTSF
;
1776 // check if beacon TSF larger or small than our local TSF
1777 if (qwTimestamp
>= qwLocalTSF
)
1778 bTSFOffsetPostive
= true;
1780 bTSFOffsetPostive
= false;
1782 if (bTSFOffsetPostive
) {
1783 qwTSFOffset
= CARDqGetTSFOffset(pRxPacket
->byRxRate
, (qwTimestamp
), (qwLocalTSF
));
1786 qwTSFOffset
= CARDqGetTSFOffset(pRxPacket
->byRxRate
, (qwLocalTSF
), (qwTimestamp
));
1789 if (qwTSFOffset
> TRIVIAL_SYNC_DIFFERENCE
)
1790 bTSFLargeDiff
= true;
1793 if (bIsAPBeacon
== true) {
1795 // Infra mode: Local TSF always follow AP's TSF if Difference huge.
1799 if ((pDevice
->bEnablePSMode
== true) && (sFrame
.pTIM
)) {
1801 /* deal with DTIM, analysis TIM */
1802 pMgmt
->bMulticastTIM
= WLAN_MGMT_IS_MULTICAST_TIM(sFrame
.pTIM
->byBitMapCtl
) ? true : false ;
1803 pMgmt
->byDTIMCount
= sFrame
.pTIM
->byDTIMCount
;
1804 pMgmt
->byDTIMPeriod
= sFrame
.pTIM
->byDTIMPeriod
;
1805 wAIDNumber
= pMgmt
->wCurrAID
& ~(BIT14
|BIT15
);
1807 // check if AID in TIM field bit on
1809 wStartIndex
= WLAN_MGMT_GET_TIM_OFFSET(sFrame
.pTIM
->byBitMapCtl
) << 1;
1811 wAIDIndex
= (wAIDNumber
>> 3);
1812 if ((wAIDNumber
> 0) && (wAIDIndex
>= wStartIndex
)) {
1813 uLocateByteIndex
= wAIDIndex
- wStartIndex
;
1814 // len = byDTIMCount + byDTIMPeriod + byDTIMPeriod + byVirtBitMap[0~250]
1815 if (sFrame
.pTIM
->len
>= (uLocateByteIndex
+ 4)) {
1816 byTIMBitOn
= (0x01) << ((wAIDNumber
) % 8);
1817 pMgmt
->bInTIM
= sFrame
.pTIM
->byVirtBitMap
[uLocateByteIndex
] & byTIMBitOn
? true : false;
1820 pMgmt
->bInTIM
= false;
1824 pMgmt
->bInTIM
= false;
1827 if (pMgmt
->bInTIM
||
1828 (pMgmt
->bMulticastTIM
&& (pMgmt
->byDTIMCount
== 0))) {
1829 pMgmt
->bInTIMWake
= true;
1830 /* send out ps-poll packet */
1832 PSvSendPSPOLL(pDevice
);
1836 pMgmt
->bInTIMWake
= false;
1837 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"BCN: Not In TIM..\n");
1838 if (pDevice
->bPWBitOn
== false) {
1839 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"BCN: Send Null Packet\n");
1840 if (PSbSendNullPacket(pDevice
))
1841 pDevice
->bPWBitOn
= true;
1843 if(PSbConsiderPowerDown(pDevice
, false, false)) {
1844 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"BCN: Power down now...\n");
1852 if ((pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) && !bIsAPBeacon
&& bIsChannelEqual
) {
1853 if (bIsBSSIDEqual
) {
1854 // Use sNodeDBTable[0].uInActiveCount as IBSS beacons received count.
1855 if (pMgmt
->sNodeDBTable
[0].uInActiveCount
!= 0)
1856 pMgmt
->sNodeDBTable
[0].uInActiveCount
= 0;
1858 // adhoc mode:TSF updated only when beacon larger then local TSF
1859 if (bTSFLargeDiff
&& bTSFOffsetPostive
&&
1860 (pMgmt
->eCurrState
== WMAC_STATE_JOINTED
))
1863 // During dpc, already in spinlocked.
1864 if (BSSbIsSTAInNodeDB(pDevice
, sFrame
.pHdr
->sA3
.abyAddr2
, &uNodeIndex
)) {
1866 // Update the STA, (Technically the Beacons of all the IBSS nodes
1867 // should be identical, but that's not happening in practice.
1868 pMgmt
->abyCurrSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)sFrame
.pSuppRates
,
1869 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
1870 WLAN_RATES_MAXLEN_11B
);
1871 RATEvParseMaxRate((void *)pDevice
,
1872 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
1875 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxBasicRate
),
1876 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
),
1877 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wSuppRate
),
1878 &(pMgmt
->sNodeDBTable
[uNodeIndex
].byTopCCKBasicRate
),
1879 &(pMgmt
->sNodeDBTable
[uNodeIndex
].byTopOFDMBasicRate
)
1881 pMgmt
->sNodeDBTable
[uNodeIndex
].bShortPreamble
= WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame
.pwCapInfo
);
1882 pMgmt
->sNodeDBTable
[uNodeIndex
].bShortSlotTime
= WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame
.pwCapInfo
);
1883 pMgmt
->sNodeDBTable
[uNodeIndex
].uInActiveCount
= 0;
1886 /* Todo, initial Node content */
1887 BSSvCreateOneNode(pDevice
, &uNodeIndex
);
1889 pMgmt
->abyCurrSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)sFrame
.pSuppRates
,
1890 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
1891 WLAN_RATES_MAXLEN_11B
);
1892 RATEvParseMaxRate((void *)pDevice
,
1893 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
1896 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxBasicRate
),
1897 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
),
1898 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wSuppRate
),
1899 &(pMgmt
->sNodeDBTable
[uNodeIndex
].byTopCCKBasicRate
),
1900 &(pMgmt
->sNodeDBTable
[uNodeIndex
].byTopOFDMBasicRate
)
1903 memcpy(pMgmt
->sNodeDBTable
[uNodeIndex
].abyMACAddr
, sFrame
.pHdr
->sA3
.abyAddr2
, WLAN_ADDR_LEN
);
1904 pMgmt
->sNodeDBTable
[uNodeIndex
].bShortPreamble
= WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame
.pwCapInfo
);
1905 pMgmt
->sNodeDBTable
[uNodeIndex
].wTxDataRate
= pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
;
1907 pMgmt->sNodeDBTable[uNodeIndex].bShortSlotTime = WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame.pwCapInfo);
1908 if(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate > RATE_11M)
1909 pMgmt->sNodeDBTable[uNodeIndex].bERPExist = true;
1913 // if other stations jointed, indicate connect to upper layer..
1914 if (pMgmt
->eCurrState
== WMAC_STATE_STARTED
) {
1915 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Current IBSS State: [Started]........to: [Jointed] \n");
1916 pMgmt
->eCurrState
= WMAC_STATE_JOINTED
;
1917 pDevice
->bLinkPass
= true;
1918 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_INTER
);
1919 if (netif_queue_stopped(pDevice
->dev
)){
1920 netif_wake_queue(pDevice
->dev
);
1922 pMgmt
->sNodeDBTable
[0].bActive
= true;
1923 pMgmt
->sNodeDBTable
[0].uInActiveCount
= 0;
1927 else if (bIsSSIDEqual
) {
1929 // See other adhoc sta with the same SSID but BSSID is different.
1930 // adpot this vars only when TSF larger then us.
1931 if (bTSFLargeDiff
&& bTSFOffsetPostive
) {
1932 // we don't support ATIM under adhoc mode
1933 // if ( sFrame.pIBSSParms->wATIMWindow == 0) {
1935 // TODO: check sFrame cap if privacy on, and support rate syn
1936 memcpy(pMgmt
->abyCurrBSSID
, sFrame
.pHdr
->sA3
.abyAddr3
, WLAN_BSSID_LEN
);
1937 memcpy(pDevice
->abyBSSID
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
1938 pMgmt
->wCurrATIMWindow
= cpu_to_le16(sFrame
.pIBSSParms
->wATIMWindow
);
1939 pMgmt
->wCurrBeaconPeriod
= cpu_to_le16(*sFrame
.pwBeaconInterval
);
1940 pMgmt
->abyCurrSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)sFrame
.pSuppRates
,
1941 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
1942 WLAN_RATES_MAXLEN_11B
);
1943 // set HW beacon interval and re-synchronizing....
1944 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Rejoining to Other Adhoc group with same SSID........\n");
1946 MACvWriteBeaconInterval(pDevice
, pMgmt
->wCurrBeaconPeriod
);
1947 CARDvAdjustTSF(pDevice
, pRxPacket
->byRxRate
, qwTimestamp
, pRxPacket
->qwLocalTSF
);
1948 CARDvUpdateNextTBTT(pDevice
, qwTimestamp
, pMgmt
->wCurrBeaconPeriod
);
1950 // Turn off bssid filter to avoid filter others adhoc station which bssid is different.
1951 MACvWriteBSSIDAddress(pDevice
, pMgmt
->abyCurrBSSID
);
1953 byOldPreambleType
= pDevice
->byPreambleType
;
1954 if (WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame
.pwCapInfo
)) {
1955 pDevice
->byPreambleType
= pDevice
->byShortPreamble
;
1958 pDevice
->byPreambleType
= 0;
1960 if (pDevice
->byPreambleType
!= byOldPreambleType
)
1961 CARDvSetRSPINF(pDevice
, (u8
)pDevice
->byBBType
);
1963 // MACvRegBitsOff(pDevice->PortOffset, MAC_REG_RCR, RCR_BSSID);
1964 // set highest basic rate
1965 // s_vSetHighestBasicRate(pDevice, (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates);
1966 // Prepare beacon frame
1967 bMgrPrepareBeaconToSend((void *) pDevice
, pMgmt
);
1975 CARDbGetCurrentTSF(pDevice
, &qwCurrTSF
);
1976 CARDvAdjustTSF(pDevice
, pRxPacket
->byRxRate
, qwTimestamp
, pRxPacket
->qwLocalTSF
);
1977 CARDbGetCurrentTSF(pDevice
, &qwCurrTSF
);
1978 CARDvUpdateNextTBTT(pDevice
, qwTimestamp
, pMgmt
->wCurrBeaconPeriod
);
1986 * Routine Description:
1987 * Instructs the hw to create a bss using the supplied
1988 * attributes. Note that this implementation only supports Ad-Hoc
1997 void vMgrCreateOwnIBSS(struct vnt_private
*pDevice
, PCMD_STATUS pStatus
)
1999 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
2002 u8 byTopCCKBasicRate
;
2003 u8 byTopOFDMBasicRate
;
2006 u8 abyRATE
[] = {0x82, 0x84, 0x8B, 0x96, 0x24, 0x30, 0x48, 0x6C, 0x0C,
2008 u8 abyCCK_RATE
[] = {0x82, 0x84, 0x8B, 0x96};
2009 u8 abyOFDM_RATE
[] = {0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
2012 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Create Basic Service Set .......\n");
2014 if (pMgmt
->eConfigMode
== WMAC_CONFIG_IBSS_STA
) {
2015 if ((pMgmt
->eAuthenMode
== WMAC_AUTH_WPANONE
) &&
2016 (pDevice
->eEncryptionStatus
!= Ndis802_11Encryption2Enabled
) &&
2017 (pDevice
->eEncryptionStatus
!= Ndis802_11Encryption3Enabled
)) {
2018 // encryption mode error
2019 *pStatus
= CMD_STATUS_FAILURE
;
2024 pMgmt
->abyCurrSuppRates
[0] = WLAN_EID_SUPP_RATES
;
2025 pMgmt
->abyCurrExtSuppRates
[0] = WLAN_EID_EXTSUPP_RATES
;
2027 if (pMgmt
->eConfigMode
== WMAC_CONFIG_AP
) {
2028 pMgmt
->eCurrentPHYMode
= pMgmt
->byAPBBType
;
2030 if (pDevice
->byBBType
== BB_TYPE_11G
)
2031 pMgmt
->eCurrentPHYMode
= PHY_TYPE_11G
;
2032 if (pDevice
->byBBType
== BB_TYPE_11B
)
2033 pMgmt
->eCurrentPHYMode
= PHY_TYPE_11B
;
2034 if (pDevice
->byBBType
== BB_TYPE_11A
)
2035 pMgmt
->eCurrentPHYMode
= PHY_TYPE_11A
;
2038 if (pMgmt
->eCurrentPHYMode
!= PHY_TYPE_11A
) {
2039 pMgmt
->abyCurrSuppRates
[1] = WLAN_RATES_MAXLEN_11B
;
2040 pMgmt
->abyCurrExtSuppRates
[1] = 0;
2041 for (ii
= 0; ii
< 4; ii
++)
2042 pMgmt
->abyCurrSuppRates
[2+ii
] = abyRATE
[ii
];
2044 pMgmt
->abyCurrSuppRates
[1] = 8;
2045 pMgmt
->abyCurrExtSuppRates
[1] = 0;
2046 for (ii
= 0; ii
< 8; ii
++)
2047 pMgmt
->abyCurrSuppRates
[2+ii
] = abyRATE
[ii
];
2050 if (pMgmt
->eCurrentPHYMode
== PHY_TYPE_11G
) {
2051 pMgmt
->abyCurrSuppRates
[1] = 8;
2052 pMgmt
->abyCurrExtSuppRates
[1] = 4;
2053 for (ii
= 0; ii
< 4; ii
++)
2054 pMgmt
->abyCurrSuppRates
[2+ii
] = abyCCK_RATE
[ii
];
2055 for (ii
= 4; ii
< 8; ii
++)
2056 pMgmt
->abyCurrSuppRates
[2+ii
] = abyOFDM_RATE
[ii
-4];
2057 for (ii
= 0; ii
< 4; ii
++)
2058 pMgmt
->abyCurrExtSuppRates
[2+ii
] = abyOFDM_RATE
[ii
+4];
2061 // Disable Protect Mode
2062 pDevice
->bProtectMode
= 0;
2063 MACvDisableProtectMD(pDevice
);
2065 pDevice
->bBarkerPreambleMd
= 0;
2066 MACvDisableBarkerPreambleMd(pDevice
);
2068 // Kyle Test 2003.11.04
2070 // set HW beacon interval
2071 if (pMgmt
->wIBSSBeaconPeriod
== 0)
2072 pMgmt
->wIBSSBeaconPeriod
= DEFAULT_IBSS_BI
;
2073 MACvWriteBeaconInterval(pDevice
, pMgmt
->wIBSSBeaconPeriod
);
2075 CARDbGetCurrentTSF(pDevice
, &qwCurrTSF
);
2076 // clear TSF counter
2077 CARDbClearCurrentTSF(pDevice
);
2079 // enable TSF counter
2080 MACvRegBitsOn(pDevice
,MAC_REG_TFTCTL
,TFTCTL_TSFCNTREN
);
2082 CARDvSetFirstNextTBTT(pDevice
, pMgmt
->wIBSSBeaconPeriod
);
2084 pMgmt
->uIBSSChannel
= pDevice
->uChannel
;
2086 if (pMgmt
->uIBSSChannel
== 0)
2087 pMgmt
->uIBSSChannel
= DEFAULT_IBSS_CHANNEL
;
2089 // set channel and clear NAV
2090 CARDbSetMediaChannel(pDevice
, pMgmt
->uIBSSChannel
);
2091 pMgmt
->uCurrChannel
= pMgmt
->uIBSSChannel
;
2093 pDevice
->byPreambleType
= pDevice
->byShortPreamble
;
2097 RATEvParseMaxRate((void *)pDevice
,
2098 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
2099 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
, true,
2100 &wMaxBasicRate
, &wMaxSuppRate
, &wSuppRate
,
2101 &byTopCCKBasicRate
, &byTopOFDMBasicRate
);
2103 if (pDevice
->byBBType
== BB_TYPE_11A
) {
2104 pDevice
->bShortSlotTime
= true;
2106 pDevice
->bShortSlotTime
= false;
2108 BBvSetShortSlotTime(pDevice
);
2109 // vUpdateIFS() use pDevice->bShortSlotTime as parameter so it must be called
2110 // after setting ShortSlotTime.
2111 // CARDvSetBSSMode call vUpdateIFS()
2112 CARDvSetBSSMode(pDevice
);
2114 if (pMgmt
->eConfigMode
== WMAC_CONFIG_AP
) {
2115 MACvRegBitsOn(pDevice
, MAC_REG_HOSTCR
, HOSTCR_AP
);
2116 pMgmt
->eCurrMode
= WMAC_MODE_ESS_AP
;
2119 if (pMgmt
->eConfigMode
== WMAC_CONFIG_IBSS_STA
) {
2120 MACvRegBitsOn(pDevice
, MAC_REG_HOSTCR
, HOSTCR_ADHOC
);
2121 pMgmt
->eCurrMode
= WMAC_MODE_IBSS_STA
;
2124 // Adopt pre-configured IBSS vars to current vars
2125 pMgmt
->eCurrState
= WMAC_STATE_STARTED
;
2126 pMgmt
->wCurrBeaconPeriod
= pMgmt
->wIBSSBeaconPeriod
;
2127 pMgmt
->uCurrChannel
= pMgmt
->uIBSSChannel
;
2128 pMgmt
->wCurrATIMWindow
= pMgmt
->wIBSSATIMWindow
;
2129 pDevice
->uCurrRSSI
= 0;
2130 pDevice
->byCurrSQ
= 0;
2132 memcpy(pMgmt
->abyDesireSSID
,pMgmt
->abyAdHocSSID
,
2133 ((PWLAN_IE_SSID
)pMgmt
->abyAdHocSSID
)->len
+ WLAN_IEHDR_LEN
);
2135 memset(pMgmt
->abyCurrSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
2136 memcpy(pMgmt
->abyCurrSSID
,
2137 pMgmt
->abyDesireSSID
,
2138 ((PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
)->len
+ WLAN_IEHDR_LEN
2141 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) {
2142 // AP mode BSSID = MAC addr
2143 memcpy(pMgmt
->abyCurrBSSID
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
2144 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"AP beacon created BSSID:"
2145 "%pM\n", pMgmt
->abyCurrBSSID
);
2148 if (pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) {
2150 // BSSID selected must be randomized as spec 11.1.3
2151 pMgmt
->abyCurrBSSID
[5] = (u8
)(qwCurrTSF
& 0x000000ff);
2152 pMgmt
->abyCurrBSSID
[4] = (u8
)((qwCurrTSF
& 0x0000ff00) >> 8);
2153 pMgmt
->abyCurrBSSID
[3] = (u8
)((qwCurrTSF
& 0x00ff0000) >> 16);
2154 pMgmt
->abyCurrBSSID
[2] = (u8
)((qwCurrTSF
& 0x00000ff0) >> 4);
2155 pMgmt
->abyCurrBSSID
[1] = (u8
)((qwCurrTSF
& 0x000ff000) >> 12);
2156 pMgmt
->abyCurrBSSID
[0] = (u8
)((qwCurrTSF
& 0x0ff00000) >> 20);
2157 pMgmt
->abyCurrBSSID
[5] ^= pMgmt
->abyMACAddr
[0];
2158 pMgmt
->abyCurrBSSID
[4] ^= pMgmt
->abyMACAddr
[1];
2159 pMgmt
->abyCurrBSSID
[3] ^= pMgmt
->abyMACAddr
[2];
2160 pMgmt
->abyCurrBSSID
[2] ^= pMgmt
->abyMACAddr
[3];
2161 pMgmt
->abyCurrBSSID
[1] ^= pMgmt
->abyMACAddr
[4];
2162 pMgmt
->abyCurrBSSID
[0] ^= pMgmt
->abyMACAddr
[5];
2163 pMgmt
->abyCurrBSSID
[0] &= ~IEEE_ADDR_GROUP
;
2164 pMgmt
->abyCurrBSSID
[0] |= IEEE_ADDR_UNIVERSAL
;
2166 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"Adhoc beacon created bssid:"
2167 "%pM\n", pMgmt
->abyCurrBSSID
);
2171 MACvWriteBSSIDAddress(pDevice
, pMgmt
->abyCurrBSSID
);
2172 memcpy(pDevice
->abyBSSID
, pMgmt
->abyCurrBSSID
, WLAN_ADDR_LEN
);
2174 MACvRegBitsOn(pDevice
, MAC_REG_RCR
, RCR_BSSID
);
2175 pDevice
->byRxMode
|= RCR_BSSID
;
2176 pMgmt
->bCurrBSSIDFilterOn
= true;
2178 // Set Capability Info
2179 pMgmt
->wCurrCapInfo
= 0;
2181 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) {
2182 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_ESS(1);
2183 pMgmt
->byDTIMPeriod
= DEFAULT_DTIM_PERIOD
;
2184 pMgmt
->byDTIMCount
= pMgmt
->byDTIMPeriod
- 1;
2185 pDevice
->eOPMode
= OP_MODE_AP
;
2188 if (pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) {
2189 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_IBSS(1);
2190 pDevice
->eOPMode
= OP_MODE_ADHOC
;
2193 if (pDevice
->bEncryptionEnable
) {
2194 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_PRIVACY(1);
2195 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPANONE
) {
2196 if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
) {
2197 pMgmt
->byCSSPK
= KEY_CTL_CCMP
;
2198 pMgmt
->byCSSGK
= KEY_CTL_CCMP
;
2199 } else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
) {
2200 pMgmt
->byCSSPK
= KEY_CTL_TKIP
;
2201 pMgmt
->byCSSGK
= KEY_CTL_TKIP
;
2203 pMgmt
->byCSSPK
= KEY_CTL_NONE
;
2204 pMgmt
->byCSSGK
= KEY_CTL_WEP
;
2207 pMgmt
->byCSSPK
= KEY_CTL_WEP
;
2208 pMgmt
->byCSSGK
= KEY_CTL_WEP
;
2212 pMgmt
->byERPContext
= 0;
2214 if (pDevice
->byPreambleType
== 1) {
2215 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
2217 pMgmt
->wCurrCapInfo
&= (~WLAN_SET_CAP_INFO_SHORTPREAMBLE(1));
2220 pMgmt
->eCurrState
= WMAC_STATE_STARTED
;
2221 // Prepare beacon to send
2222 if (bMgrPrepareBeaconToSend((void *) pDevice
, pMgmt
))
2223 *pStatus
= CMD_STATUS_SUCCESS
;
2230 * Routine Description:
2231 * Instructs wmac to join a bss using the supplied attributes.
2232 * The arguments may the BSSID or SSID and the rest of the
2233 * attributes are obtained from the scan result of known bss list.
2241 void vMgrJoinBSSBegin(struct vnt_private
*pDevice
, PCMD_STATUS pStatus
)
2243 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
2244 PKnownBSS pCurr
= NULL
;
2246 PWLAN_IE_SUPP_RATES pItemRates
= NULL
;
2247 PWLAN_IE_SUPP_RATES pItemExtRates
= NULL
;
2248 PWLAN_IE_SSID pItemSSID
;
2249 u32 uRateLen
= WLAN_RATES_MAXLEN
;
2250 u16 wMaxBasicRate
= RATE_1M
;
2251 u16 wMaxSuppRate
= RATE_1M
;
2253 u8 byTopCCKBasicRate
= RATE_1M
;
2254 u8 byTopOFDMBasicRate
= RATE_1M
;
2255 u8 bShortSlotTime
= false;
2257 for (ii
= 0; ii
< MAX_BSS_NUM
; ii
++) {
2258 if (pMgmt
->sBSSList
[ii
].bActive
== true)
2262 if (ii
== MAX_BSS_NUM
) {
2263 *pStatus
= CMD_STATUS_RESOURCES
;
2264 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"BSS finding:BSS list is empty.\n");
2268 // memset(pMgmt->abyDesireBSSID, 0, WLAN_BSSID_LEN);
2269 // Search known BSS list for prefer BSSID or SSID
2271 pCurr
= BSSpSearchBSSList(pDevice
,
2272 pMgmt
->abyDesireBSSID
,
2273 pMgmt
->abyDesireSSID
,
2274 pDevice
->eConfigPHYMode
2278 *pStatus
= CMD_STATUS_RESOURCES
;
2279 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
;
2280 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Scanning [%s] not found, disconnected !\n", pItemSSID
->abySSID
);
2284 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"AP(BSS) finding:Found a AP(BSS)..\n");
2286 if (WLAN_GET_CAP_INFO_ESS(cpu_to_le16(pCurr
->wCapInfo
))){
2288 if ((pMgmt
->eAuthenMode
== WMAC_AUTH_WPA
) ||
2289 (pMgmt
->eAuthenMode
== WMAC_AUTH_WPAPSK
)) {
2291 if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) {
2292 if (WPA_SearchRSN(0, WPA_TKIP, pCurr) == false) {
2293 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"No match RSN info. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
2294 // encryption mode error
2295 pMgmt->eCurrState = WMAC_STATE_IDLE;
2298 } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) {
2299 if (WPA_SearchRSN(0, WPA_AESCCMP, pCurr) == false) {
2300 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"No match RSN info. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
2301 // encryption mode error
2302 pMgmt->eCurrState = WMAC_STATE_IDLE;
2309 //if(pDevice->bWPASuppWextEnabled == true)
2310 Encyption_Rebuild(pDevice
, pCurr
);
2312 // Infrastructure BSS
2313 s_vMgrSynchBSS(pDevice
,
2319 if (*pStatus
== CMD_STATUS_SUCCESS
){
2321 // Adopt this BSS state vars in Mgmt Object
2322 pMgmt
->uCurrChannel
= pCurr
->uChannel
;
2324 memset(pMgmt
->abyCurrSuppRates
, 0 , WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1);
2325 memset(pMgmt
->abyCurrExtSuppRates
, 0 , WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1);
2327 if (pCurr
->eNetworkTypeInUse
== PHY_TYPE_11B
) {
2328 uRateLen
= WLAN_RATES_MAXLEN_11B
;
2331 pItemRates
= (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
;
2332 pItemExtRates
= (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
;
2334 // Parse Support Rate IE
2335 pItemRates
->byElementID
= WLAN_EID_SUPP_RATES
;
2336 pItemRates
->len
= RATEuSetIE((PWLAN_IE_SUPP_RATES
)pCurr
->abySuppRates
,
2340 // Parse Extension Support Rate IE
2341 pItemExtRates
->byElementID
= WLAN_EID_EXTSUPP_RATES
;
2342 pItemExtRates
->len
= RATEuSetIE((PWLAN_IE_SUPP_RATES
)pCurr
->abyExtSuppRates
,
2346 if ((pItemExtRates
->len
> 0) && (pItemRates
->len
< 8)) {
2347 for (ii
= 0; ii
< (unsigned int) (8 - pItemRates
->len
); ) {
2348 pItemRates
->abyRates
[pItemRates
->len
+ ii
] =
2349 pItemExtRates
->abyRates
[ii
];
2351 if (pItemExtRates
->len
<= ii
)
2354 pItemRates
->len
+= (u8
)ii
;
2355 if (pItemExtRates
->len
- ii
> 0) {
2356 pItemExtRates
->len
-= (u8
)ii
;
2357 for (uu
= 0; uu
< pItemExtRates
->len
; uu
++) {
2358 pItemExtRates
->abyRates
[uu
] = pItemExtRates
->abyRates
[uu
+ ii
];
2361 pItemExtRates
->len
= 0;
2365 RATEvParseMaxRate((void *)pDevice
, pItemRates
, pItemExtRates
, true,
2366 &wMaxBasicRate
, &wMaxSuppRate
, &wSuppRate
,
2367 &byTopCCKBasicRate
, &byTopOFDMBasicRate
);
2368 vUpdateIFS(pDevice
);
2369 // TODO: deal with if wCapInfo the privacy is on, but station WEP is off
2370 // TODO: deal with if wCapInfo the PS-Pollable is on.
2371 pMgmt
->wCurrBeaconPeriod
= pCurr
->wBeaconInterval
;
2372 memset(pMgmt
->abyCurrSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
2373 memcpy(pMgmt
->abyCurrBSSID
, pCurr
->abyBSSID
, WLAN_BSSID_LEN
);
2374 memcpy(pMgmt
->abyCurrSSID
, pCurr
->abySSID
, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
2376 pMgmt
->eCurrMode
= WMAC_MODE_ESS_STA
;
2378 pMgmt
->eCurrState
= WMAC_STATE_JOINTED
;
2379 // Adopt BSS state in Adapter Device Object
2380 pDevice
->eOPMode
= OP_MODE_INFRASTRUCTURE
;
2381 memcpy(pDevice
->abyBSSID
, pCurr
->abyBSSID
, WLAN_BSSID_LEN
);
2383 // Add current BSS to Candidate list
2384 // This should only work for WPA2 BSS, and WPA2 BSS check must be done before.
2385 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2
) {
2386 bool bResult
= bAdd_PMKID_Candidate((void *) pDevice
,
2387 pMgmt
->abyCurrBSSID
,
2388 &pCurr
->sRSNCapObj
);
2389 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"bAdd_PMKID_Candidate: 1(%d)\n", bResult
);
2390 if (bResult
== false) {
2391 vFlush_PMKID_Candidate((void *) pDevice
);
2392 DBG_PRT(MSG_LEVEL_DEBUG
,
2393 KERN_INFO
"vFlush_PMKID_Candidate: 4\n");
2394 bAdd_PMKID_Candidate((void *) pDevice
,
2395 pMgmt
->abyCurrBSSID
,
2396 &pCurr
->sRSNCapObj
);
2400 // Preamble type auto-switch: if AP can receive short-preamble cap,
2401 // we can turn on too.
2402 if (WLAN_GET_CAP_INFO_SHORTPREAMBLE(pCurr
->wCapInfo
)) {
2403 pDevice
->byPreambleType
= pDevice
->byShortPreamble
;
2406 pDevice
->byPreambleType
= 0;
2408 // Change PreambleType must set RSPINF again
2409 CARDvSetRSPINF(pDevice
, (u8
)pDevice
->byBBType
);
2411 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Join ESS\n");
2413 if (pCurr
->eNetworkTypeInUse
== PHY_TYPE_11G
) {
2415 if ((pCurr
->sERP
.byERP
& WLAN_EID_ERP_USE_PROTECTION
) != pDevice
->bProtectMode
) {//0000 0010
2416 pDevice
->bProtectMode
= (pCurr
->sERP
.byERP
& WLAN_EID_ERP_USE_PROTECTION
);
2417 if (pDevice
->bProtectMode
) {
2418 MACvEnableProtectMD(pDevice
);
2420 MACvDisableProtectMD(pDevice
);
2422 vUpdateIFS(pDevice
);
2424 if ((pCurr
->sERP
.byERP
& WLAN_EID_ERP_NONERP_PRESENT
) != pDevice
->bNonERPPresent
) {//0000 0001
2425 pDevice
->bNonERPPresent
= (pCurr
->sERP
.byERP
& WLAN_EID_ERP_USE_PROTECTION
);
2427 if ((pCurr
->sERP
.byERP
& WLAN_EID_ERP_BARKER_MODE
) != pDevice
->bBarkerPreambleMd
) {//0000 0100
2428 pDevice
->bBarkerPreambleMd
= (pCurr
->sERP
.byERP
& WLAN_EID_ERP_BARKER_MODE
);
2429 //BarkerPreambleMd has higher priority than shortPreamble bit in Cap
2430 if (pDevice
->bBarkerPreambleMd
) {
2431 MACvEnableBarkerPreambleMd(pDevice
);
2433 MACvDisableBarkerPreambleMd(pDevice
);
2437 //DBG_PRN_WLAN05(("wCapInfo: %X\n", pCurr->wCapInfo));
2438 if (WLAN_GET_CAP_INFO_SHORTSLOTTIME(pCurr
->wCapInfo
) != pDevice
->bShortSlotTime
) {
2439 if (pDevice
->byBBType
== BB_TYPE_11A
) {
2440 bShortSlotTime
= true;
2442 else if (pDevice
->byBBType
== BB_TYPE_11B
) {
2443 bShortSlotTime
= false;
2446 bShortSlotTime
= WLAN_GET_CAP_INFO_SHORTSLOTTIME(pCurr
->wCapInfo
);
2448 //DBG_PRN_WLAN05(("Set Short Slot Time: %d\n", pDevice->bShortSlotTime));
2449 if (bShortSlotTime
!= pDevice
->bShortSlotTime
) {
2450 pDevice
->bShortSlotTime
= bShortSlotTime
;
2451 BBvSetShortSlotTime(pDevice
);
2452 vUpdateIFS(pDevice
);
2456 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"End of Join AP -- A/B/G Action\n");
2459 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
2465 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPANONE
) {
2467 if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
) {
2469 if (WPA_SearchRSN(0, WPA_TKIP, pCurr) == false) {
2470 // encryption mode error
2471 pMgmt->eCurrState = WMAC_STATE_IDLE;
2475 } else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
) {
2477 if (WPA_SearchRSN(0, WPA_AESCCMP, pCurr) == false) {
2478 // encryption mode error
2479 pMgmt->eCurrState = WMAC_STATE_IDLE;
2484 // encryption mode error
2485 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
2490 s_vMgrSynchBSS(pDevice
,
2496 if (*pStatus
== CMD_STATUS_SUCCESS
){
2497 // Adopt this BSS state vars in Mgmt Object
2498 // TODO: check if CapInfo privacy on, but we don't..
2499 pMgmt
->uCurrChannel
= pCurr
->uChannel
;
2501 // Parse Support Rate IE
2502 pMgmt
->abyCurrSuppRates
[0] = WLAN_EID_SUPP_RATES
;
2503 pMgmt
->abyCurrSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)pCurr
->abySuppRates
,
2504 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
2505 WLAN_RATES_MAXLEN_11B
);
2507 RATEvParseMaxRate((void *)pDevice
,
2508 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
2509 NULL
, true, &wMaxBasicRate
, &wMaxSuppRate
, &wSuppRate
,
2510 &byTopCCKBasicRate
, &byTopOFDMBasicRate
);
2511 vUpdateIFS(pDevice
);
2512 pMgmt
->wCurrCapInfo
= pCurr
->wCapInfo
;
2513 pMgmt
->wCurrBeaconPeriod
= pCurr
->wBeaconInterval
;
2514 memset(pMgmt
->abyCurrSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
);
2515 memcpy(pMgmt
->abyCurrBSSID
, pCurr
->abyBSSID
, WLAN_BSSID_LEN
);
2516 memcpy(pMgmt
->abyCurrSSID
, pCurr
->abySSID
, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
);
2517 // pMgmt->wCurrATIMWindow = pCurr->wATIMWindow;
2518 pMgmt
->eCurrMode
= WMAC_MODE_IBSS_STA
;
2519 pMgmt
->eCurrState
= WMAC_STATE_STARTED
;
2520 // Adopt BSS state in Adapter Device Object
2521 pDevice
->eOPMode
= OP_MODE_ADHOC
;
2522 pDevice
->bLinkPass
= true;
2523 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_INTER
);
2524 memcpy(pDevice
->abyBSSID
, pCurr
->abyBSSID
, WLAN_BSSID_LEN
);
2526 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Join IBSS ok:%pM\n",
2527 pMgmt
->abyCurrBSSID
);
2528 // Preamble type auto-switch: if AP can receive short-preamble cap,
2529 // and if registry setting is short preamble we can turn on too.
2531 if (WLAN_GET_CAP_INFO_SHORTPREAMBLE(pCurr
->wCapInfo
)) {
2532 pDevice
->byPreambleType
= pDevice
->byShortPreamble
;
2535 pDevice
->byPreambleType
= 0;
2537 // Change PreambleType must set RSPINF again
2538 CARDvSetRSPINF(pDevice
, (u8
)pDevice
->byBBType
);
2541 bMgrPrepareBeaconToSend((void *) pDevice
, pMgmt
);
2544 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
2552 * Routine Description:
2553 * Set HW to synchronize a specific BSS from known BSS list.
2560 static void s_vMgrSynchBSS(struct vnt_private
*pDevice
, u32 uBSSMode
,
2561 PKnownBSS pCurr
, PCMD_STATUS pStatus
)
2563 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
2564 u8 abyCurrSuppRatesG
[] = {WLAN_EID_SUPP_RATES
,
2565 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C};
2566 /* 1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M*/
2567 u8 abyCurrExtSuppRatesG
[] = {WLAN_EID_EXTSUPP_RATES
,
2568 4, 0x0C, 0x12, 0x18, 0x60};
2569 /* 6M, 9M, 12M, 48M*/
2570 u8 abyCurrSuppRatesA
[] = {WLAN_EID_SUPP_RATES
,
2571 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
2572 u8 abyCurrSuppRatesB
[] = {WLAN_EID_SUPP_RATES
,
2573 4, 0x02, 0x04, 0x0B, 0x16};
2575 *pStatus
= CMD_STATUS_FAILURE
;
2577 if (s_bCipherMatch(pCurr
,
2578 pDevice
->eEncryptionStatus
,
2580 &(pMgmt
->byCSSGK
)) == false) {
2581 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"s_bCipherMatch Fail .......\n");
2585 pMgmt
->pCurrBSS
= pCurr
;
2587 // if previous mode is IBSS.
2588 if(pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) {
2589 MACvRegBitsOff(pDevice
, MAC_REG_TCR
, TCR_AUTOBCNTX
);
2592 // Init the BSS informations
2593 pDevice
->bCCK
= true;
2594 pDevice
->bProtectMode
= false;
2595 MACvDisableProtectMD(pDevice
);
2596 pDevice
->bBarkerPreambleMd
= false;
2597 MACvDisableBarkerPreambleMd(pDevice
);
2598 pDevice
->bNonERPPresent
= false;
2599 pDevice
->byPreambleType
= 0;
2600 pDevice
->wBasicRate
= 0;
2602 CARDbAddBasicRate((void *)pDevice
, RATE_1M
);
2604 // calculate TSF offset
2605 // TSF Offset = Received Timestamp TSF - Marked Local's TSF
2606 CARDvAdjustTSF(pDevice
, pCurr
->byRxRate
, pCurr
->qwBSSTimestamp
, pCurr
->qwLocalTSF
);
2608 // set HW beacon interval
2609 MACvWriteBeaconInterval(pDevice
, pCurr
->wBeaconInterval
);
2612 // Next TBTT = ((local_current_TSF / beacon_interval) + 1 ) * beacon_interval
2613 CARDvSetFirstNextTBTT(pDevice
, pCurr
->wBeaconInterval
);
2616 MACvWriteBSSIDAddress(pDevice
, pCurr
->abyBSSID
);
2618 memcpy(pMgmt
->abyCurrBSSID
, pCurr
->abyBSSID
, 6);
2620 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Sync:set CurrBSSID address = "
2621 "%pM\n", pMgmt
->abyCurrBSSID
);
2623 if (pCurr
->eNetworkTypeInUse
== PHY_TYPE_11A
) {
2624 if ((pDevice
->eConfigPHYMode
== PHY_TYPE_11A
) ||
2625 (pDevice
->eConfigPHYMode
== PHY_TYPE_AUTO
)) {
2626 pDevice
->byBBType
= BB_TYPE_11A
;
2627 pMgmt
->eCurrentPHYMode
= PHY_TYPE_11A
;
2628 pDevice
->bShortSlotTime
= true;
2629 BBvSetShortSlotTime(pDevice
);
2630 CARDvSetBSSMode(pDevice
);
2634 } else if (pCurr
->eNetworkTypeInUse
== PHY_TYPE_11B
) {
2635 if ((pDevice
->eConfigPHYMode
== PHY_TYPE_11B
) ||
2636 (pDevice
->eConfigPHYMode
== PHY_TYPE_11G
) ||
2637 (pDevice
->eConfigPHYMode
== PHY_TYPE_AUTO
)) {
2638 pDevice
->byBBType
= BB_TYPE_11B
;
2639 pMgmt
->eCurrentPHYMode
= PHY_TYPE_11B
;
2640 pDevice
->bShortSlotTime
= false;
2641 BBvSetShortSlotTime(pDevice
);
2642 CARDvSetBSSMode(pDevice
);
2647 if ((pDevice
->eConfigPHYMode
== PHY_TYPE_11G
) ||
2648 (pDevice
->eConfigPHYMode
== PHY_TYPE_AUTO
)) {
2649 pDevice
->byBBType
= BB_TYPE_11G
;
2650 pMgmt
->eCurrentPHYMode
= PHY_TYPE_11G
;
2651 pDevice
->bShortSlotTime
= true;
2652 BBvSetShortSlotTime(pDevice
);
2653 CARDvSetBSSMode(pDevice
);
2654 } else if (pDevice
->eConfigPHYMode
== PHY_TYPE_11B
) {
2655 pDevice
->byBBType
= BB_TYPE_11B
;
2656 pDevice
->bShortSlotTime
= false;
2657 BBvSetShortSlotTime(pDevice
);
2658 CARDvSetBSSMode(pDevice
);
2664 if (uBSSMode
== WMAC_MODE_ESS_STA
) {
2665 MACvRegBitsOff(pDevice
, MAC_REG_HOSTCR
, HOSTCR_ADHOC
);
2666 MACvRegBitsOn(pDevice
, MAC_REG_RCR
, RCR_BSSID
);
2667 pDevice
->byRxMode
|= RCR_BSSID
;
2668 pMgmt
->bCurrBSSIDFilterOn
= true;
2671 // set channel and clear NAV
2672 CARDbSetMediaChannel(pDevice
, pCurr
->uChannel
);
2673 pMgmt
->uCurrChannel
= pCurr
->uChannel
;
2674 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"<----s_bSynchBSS Set Channel [%d]\n", pCurr
->uChannel
);
2676 if ((pDevice
->bUpdateBBVGA
) &&
2677 (pDevice
->byBBVGACurrent
!= pDevice
->abyBBVGA
[0])) {
2678 pDevice
->byBBVGACurrent
= pDevice
->abyBBVGA
[0];
2679 BBvSetVGAGainOffset(pDevice
, pDevice
->byBBVGACurrent
);
2680 BBvSetShortSlotTime(pDevice
);
2684 // 1. In Ad-hoc mode : check if received others beacon as jointed indication,
2685 // otherwise we will start own IBSS.
2686 // 2. In Infra mode : Supposed we already synchronized with AP right now.
2688 if (uBSSMode
== WMAC_MODE_IBSS_STA
) {
2689 MACvRegBitsOn(pDevice
, MAC_REG_HOSTCR
, HOSTCR_ADHOC
);
2690 MACvRegBitsOn(pDevice
, MAC_REG_RCR
, RCR_BSSID
);
2691 pDevice
->byRxMode
|= RCR_BSSID
;
2692 pMgmt
->bCurrBSSIDFilterOn
= true;
2695 if (pDevice
->byBBType
== BB_TYPE_11A
) {
2696 memcpy(pMgmt
->abyCurrSuppRates
, &abyCurrSuppRatesA
[0], sizeof(abyCurrSuppRatesA
));
2697 pMgmt
->abyCurrExtSuppRates
[1] = 0;
2698 } else if (pDevice
->byBBType
== BB_TYPE_11B
) {
2699 memcpy(pMgmt
->abyCurrSuppRates
, &abyCurrSuppRatesB
[0], sizeof(abyCurrSuppRatesB
));
2700 pMgmt
->abyCurrExtSuppRates
[1] = 0;
2702 memcpy(pMgmt
->abyCurrSuppRates
, &abyCurrSuppRatesG
[0], sizeof(abyCurrSuppRatesG
));
2703 memcpy(pMgmt
->abyCurrExtSuppRates
, &abyCurrExtSuppRatesG
[0], sizeof(abyCurrExtSuppRatesG
));
2705 pMgmt
->byERPContext
= pCurr
->sERP
.byERP
;
2707 *pStatus
= CMD_STATUS_SUCCESS
;
2712 static void Encyption_Rebuild(struct vnt_private
*pDevice
, PKnownBSS pCurr
)
2714 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
2716 if ((pMgmt
->eAuthenMode
== WMAC_AUTH_WPAPSK
) ||
2717 (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2PSK
)) {
2718 if (pCurr
->bWPAValid
== true) { /*WPA-PSK */
2719 pMgmt
->eAuthenMode
= WMAC_AUTH_WPAPSK
;
2720 if(pCurr
->abyPKType
[0] == WPA_TKIP
) {
2721 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
; //TKIP
2722 PRINT_K("Encyption_Rebuild--->ssid reset config to [WPAPSK-TKIP]\n");
2724 else if(pCurr
->abyPKType
[0] == WPA_AESCCMP
) {
2725 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
; //AES
2726 PRINT_K("Encyption_Rebuild--->ssid reset config to [WPAPSK-AES]\n");
2729 else if(pCurr
->bWPA2Valid
== true) { //WPA2-PSK
2730 pMgmt
->eAuthenMode
= WMAC_AUTH_WPA2PSK
;
2731 if(pCurr
->abyCSSPK
[0] == WLAN_11i_CSS_TKIP
) {
2732 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
; //TKIP
2733 PRINT_K("Encyption_Rebuild--->ssid reset config to [WPA2PSK-TKIP]\n");
2735 else if(pCurr
->abyCSSPK
[0] == WLAN_11i_CSS_CCMP
) {
2736 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
; //AES
2737 PRINT_K("Encyption_Rebuild--->ssid reset config to [WPA2PSK-AES]\n");
2747 * Routine Description:
2756 static void s_vMgrFormatTIM(struct vnt_manager
*pMgmt
, PWLAN_IE_TIM pTIM
)
2758 u8 byMask
[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
2761 int bStartFound
= false;
2762 int bMulticast
= false;
2763 u16 wStartIndex
= 0;
2766 // Find size of partial virtual bitmap
2767 for (ii
= 0; ii
< (MAX_NODE_NUM
+ 1); ii
++) {
2768 byMap
= pMgmt
->abyPSTxMap
[ii
];
2770 // Mask out the broadcast bit which is indicated separately.
2771 bMulticast
= (byMap
& byMask
[0]) != 0;
2773 pMgmt
->sNodeDBTable
[0].bRxPSPoll
= true;
2780 wStartIndex
= (u16
)ii
;
2782 wEndIndex
= (u16
)ii
;
2786 // Round start index down to nearest even number
2787 wStartIndex
&= ~BIT0
;
2789 // Round end index up to nearest even number
2790 wEndIndex
= ((wEndIndex
+ 1) & ~BIT0
);
2792 // Size of element payload
2794 pTIM
->len
= 3 + (wEndIndex
- wStartIndex
) + 1;
2796 // Fill in the Fixed parts of the TIM
2797 pTIM
->byDTIMCount
= pMgmt
->byDTIMCount
;
2798 pTIM
->byDTIMPeriod
= pMgmt
->byDTIMPeriod
;
2799 pTIM
->byBitMapCtl
= (bMulticast
? TIM_MULTICAST_MASK
: 0) |
2800 (((wStartIndex
>> 1) << 1) & TIM_BITMAPOFFSET_MASK
);
2802 // Append variable part of TIM
2804 for (ii
= wStartIndex
, jj
=0 ; ii
<= wEndIndex
; ii
++, jj
++) {
2805 pTIM
->byVirtBitMap
[jj
] = pMgmt
->abyPSTxMap
[ii
];
2808 // Aid = 0 don't used.
2809 pTIM
->byVirtBitMap
[0] &= ~BIT0
;
2814 * Routine Description:
2815 * Constructs an Beacon frame( Ad-hoc mode)
2819 * PTR to frame; or NULL on allocation failure
2823 static struct vnt_tx_mgmt
*s_MgrMakeBeacon(struct vnt_private
*pDevice
,
2824 struct vnt_manager
*pMgmt
, u16 wCurrCapInfo
, u16 wCurrBeaconPeriod
,
2825 u32 uCurrChannel
, u16 wCurrATIMWinodw
, PWLAN_IE_SSID pCurrSSID
,
2826 u8
*pCurrBSSID
, PWLAN_IE_SUPP_RATES pCurrSuppRates
,
2827 PWLAN_IE_SUPP_RATES pCurrExtSuppRates
)
2829 struct vnt_tx_mgmt
*pTxPacket
= NULL
;
2830 WLAN_FR_BEACON sFrame
;
2831 u8 abyBroadcastAddr
[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2833 /* prepare beacon frame */
2834 pTxPacket
= (struct vnt_tx_mgmt
*)pMgmt
->pbyMgmtPacketPool
;
2835 memset(pTxPacket
, 0, sizeof(struct vnt_tx_mgmt
)
2836 + WLAN_BEACON_FR_MAXLEN
);
2837 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((u8
*)pTxPacket
2838 + sizeof(struct vnt_tx_mgmt
));
2839 // Setup the sFrame structure.
2840 sFrame
.pBuf
= (u8
*)pTxPacket
->p80211Header
;
2841 sFrame
.len
= WLAN_BEACON_FR_MAXLEN
;
2842 vMgrEncodeBeacon(&sFrame
);
2844 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
2846 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
2847 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_BEACON
)
2850 if (pDevice
->bEnablePSMode
) {
2851 sFrame
.pHdr
->sA3
.wFrameCtl
|= cpu_to_le16((u16
)WLAN_SET_FC_PWRMGT(1));
2854 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, abyBroadcastAddr
, WLAN_ADDR_LEN
);
2855 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
2856 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pCurrBSSID
, WLAN_BSSID_LEN
);
2857 *sFrame
.pwBeaconInterval
= cpu_to_le16(wCurrBeaconPeriod
);
2858 *sFrame
.pwCapInfo
= cpu_to_le16(wCurrCapInfo
);
2860 sFrame
.pSSID
= (PWLAN_IE_SSID
)(sFrame
.pBuf
+ sFrame
.len
);
2861 sFrame
.len
+= ((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->len
+ WLAN_IEHDR_LEN
;
2862 memcpy(sFrame
.pSSID
,
2864 ((PWLAN_IE_SSID
)pCurrSSID
)->len
+ WLAN_IEHDR_LEN
2866 // Copy the rate set
2867 sFrame
.pSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
2868 sFrame
.len
+= ((PWLAN_IE_SUPP_RATES
)pCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
;
2869 memcpy(sFrame
.pSuppRates
,
2871 ((PWLAN_IE_SUPP_RATES
)pCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
2874 if (pDevice
->byBBType
!= BB_TYPE_11A
) {
2875 sFrame
.pDSParms
= (PWLAN_IE_DS_PARMS
)(sFrame
.pBuf
+ sFrame
.len
);
2876 sFrame
.len
+= (1) + WLAN_IEHDR_LEN
;
2877 sFrame
.pDSParms
->byElementID
= WLAN_EID_DS_PARMS
;
2878 sFrame
.pDSParms
->len
= 1;
2879 sFrame
.pDSParms
->byCurrChannel
= (u8
)uCurrChannel
;
2882 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) {
2883 sFrame
.pTIM
= (PWLAN_IE_TIM
)(sFrame
.pBuf
+ sFrame
.len
);
2884 sFrame
.pTIM
->byElementID
= WLAN_EID_TIM
;
2885 s_vMgrFormatTIM(pMgmt
, sFrame
.pTIM
);
2886 sFrame
.len
+= (WLAN_IEHDR_LEN
+ sFrame
.pTIM
->len
);
2889 if (pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) {
2892 sFrame
.pIBSSParms
= (PWLAN_IE_IBSS_PARMS
)(sFrame
.pBuf
+ sFrame
.len
);
2893 sFrame
.len
+= (2) + WLAN_IEHDR_LEN
;
2894 sFrame
.pIBSSParms
->byElementID
= WLAN_EID_IBSS_PARMS
;
2895 sFrame
.pIBSSParms
->len
= 2;
2896 sFrame
.pIBSSParms
->wATIMWindow
= wCurrATIMWinodw
;
2897 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPANONE
) {
2899 sFrame
.pRSNWPA
= (PWLAN_IE_RSN_EXT
)(sFrame
.pBuf
+ sFrame
.len
);
2900 sFrame
.pRSNWPA
->byElementID
= WLAN_EID_RSN_WPA
;
2901 sFrame
.pRSNWPA
->len
= 12;
2902 sFrame
.pRSNWPA
->abyOUI
[0] = 0x00;
2903 sFrame
.pRSNWPA
->abyOUI
[1] = 0x50;
2904 sFrame
.pRSNWPA
->abyOUI
[2] = 0xf2;
2905 sFrame
.pRSNWPA
->abyOUI
[3] = 0x01;
2906 sFrame
.pRSNWPA
->wVersion
= 1;
2907 sFrame
.pRSNWPA
->abyMulticast
[0] = 0x00;
2908 sFrame
.pRSNWPA
->abyMulticast
[1] = 0x50;
2909 sFrame
.pRSNWPA
->abyMulticast
[2] = 0xf2;
2910 if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
)
2911 sFrame
.pRSNWPA
->abyMulticast
[3] = 0x04;//AES
2912 else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
)
2913 sFrame
.pRSNWPA
->abyMulticast
[3] = 0x02;//TKIP
2914 else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption1Enabled
)
2915 sFrame
.pRSNWPA
->abyMulticast
[3] = 0x01;//WEP40
2917 sFrame
.pRSNWPA
->abyMulticast
[3] = 0x00;//NONE
2919 // Pairwise Key Cipher Suite
2920 sFrame
.pRSNWPA
->wPKCount
= 0;
2921 // Auth Key Management Suite
2922 *((u16
*)(sFrame
.pBuf
+ sFrame
.len
+ sFrame
.pRSNWPA
->len
))=0;
2923 sFrame
.pRSNWPA
->len
+=2;
2926 *((u16
*)(sFrame
.pBuf
+ sFrame
.len
+ sFrame
.pRSNWPA
->len
))=0;
2927 sFrame
.pRSNWPA
->len
+=2;
2928 sFrame
.len
+= sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
;
2932 if (pMgmt
->eCurrentPHYMode
== PHY_TYPE_11G
) {
2933 sFrame
.pERP
= (PWLAN_IE_ERP
)(sFrame
.pBuf
+ sFrame
.len
);
2934 sFrame
.len
+= 1 + WLAN_IEHDR_LEN
;
2935 sFrame
.pERP
->byElementID
= WLAN_EID_ERP
;
2936 sFrame
.pERP
->len
= 1;
2937 sFrame
.pERP
->byContext
= 0;
2938 if (pDevice
->bProtectMode
== true)
2939 sFrame
.pERP
->byContext
|= WLAN_EID_ERP_USE_PROTECTION
;
2940 if (pDevice
->bNonERPPresent
== true)
2941 sFrame
.pERP
->byContext
|= WLAN_EID_ERP_NONERP_PRESENT
;
2942 if (pDevice
->bBarkerPreambleMd
== true)
2943 sFrame
.pERP
->byContext
|= WLAN_EID_ERP_BARKER_MODE
;
2945 if (((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
!= 0) {
2946 sFrame
.pExtSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
2947 sFrame
.len
+= ((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
;
2948 memcpy(sFrame
.pExtSuppRates
,
2950 ((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
2953 // hostapd wpa/wpa2 IE
2954 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) && (pDevice
->bEnableHostapd
== true)) {
2955 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPANONE
) {
2956 if (pMgmt
->wWPAIELen
!= 0) {
2957 sFrame
.pRSN
= (PWLAN_IE_RSN
)(sFrame
.pBuf
+ sFrame
.len
);
2958 memcpy(sFrame
.pRSN
, pMgmt
->abyWPAIE
, pMgmt
->wWPAIELen
);
2959 sFrame
.len
+= pMgmt
->wWPAIELen
;
2964 /* Adjust the length fields */
2965 pTxPacket
->cbMPDULen
= sFrame
.len
;
2966 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
2973 * Routine Description:
2974 * Constructs an Prob-response frame
2978 * PTR to frame; or NULL on allocation failure
2982 struct vnt_tx_mgmt
*s_MgrMakeProbeResponse(struct vnt_private
*pDevice
,
2983 struct vnt_manager
*pMgmt
, u16 wCurrCapInfo
, u16 wCurrBeaconPeriod
,
2984 u32 uCurrChannel
, u16 wCurrATIMWinodw
, u8
*pDstAddr
,
2985 PWLAN_IE_SSID pCurrSSID
, u8
*pCurrBSSID
,
2986 PWLAN_IE_SUPP_RATES pCurrSuppRates
,
2987 PWLAN_IE_SUPP_RATES pCurrExtSuppRates
, u8 byPHYType
)
2989 struct vnt_tx_mgmt
*pTxPacket
= NULL
;
2990 WLAN_FR_PROBERESP sFrame
;
2992 pTxPacket
= (struct vnt_tx_mgmt
*)pMgmt
->pbyMgmtPacketPool
;
2993 memset(pTxPacket
, 0, sizeof(struct vnt_tx_mgmt
)
2994 + WLAN_PROBERESP_FR_MAXLEN
);
2995 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((u8
*)pTxPacket
2996 + sizeof(struct vnt_tx_mgmt
));
2997 // Setup the sFrame structure.
2998 sFrame
.pBuf
= (u8
*)pTxPacket
->p80211Header
;
2999 sFrame
.len
= WLAN_PROBERESP_FR_MAXLEN
;
3000 vMgrEncodeProbeResponse(&sFrame
);
3002 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
3004 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
3005 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_PROBERESP
)
3007 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pDstAddr
, WLAN_ADDR_LEN
);
3008 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
3009 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pCurrBSSID
, WLAN_BSSID_LEN
);
3010 *sFrame
.pwBeaconInterval
= cpu_to_le16(wCurrBeaconPeriod
);
3011 *sFrame
.pwCapInfo
= cpu_to_le16(wCurrCapInfo
);
3013 if (byPHYType
== BB_TYPE_11B
) {
3014 *sFrame
.pwCapInfo
&= cpu_to_le16((u16
)~(WLAN_SET_CAP_INFO_SHORTSLOTTIME(1)));
3018 sFrame
.pSSID
= (PWLAN_IE_SSID
)(sFrame
.pBuf
+ sFrame
.len
);
3019 sFrame
.len
+= ((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->len
+ WLAN_IEHDR_LEN
;
3020 memcpy(sFrame
.pSSID
,
3022 ((PWLAN_IE_SSID
)pCurrSSID
)->len
+ WLAN_IEHDR_LEN
3024 // Copy the rate set
3025 sFrame
.pSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3027 sFrame
.len
+= ((PWLAN_IE_SUPP_RATES
)pCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
;
3028 memcpy(sFrame
.pSuppRates
,
3030 ((PWLAN_IE_SUPP_RATES
)pCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
3034 if (pDevice
->byBBType
!= BB_TYPE_11A
) {
3035 sFrame
.pDSParms
= (PWLAN_IE_DS_PARMS
)(sFrame
.pBuf
+ sFrame
.len
);
3036 sFrame
.len
+= (1) + WLAN_IEHDR_LEN
;
3037 sFrame
.pDSParms
->byElementID
= WLAN_EID_DS_PARMS
;
3038 sFrame
.pDSParms
->len
= 1;
3039 sFrame
.pDSParms
->byCurrChannel
= (u8
)uCurrChannel
;
3042 if (pMgmt
->eCurrMode
!= WMAC_MODE_ESS_AP
) {
3044 sFrame
.pIBSSParms
= (PWLAN_IE_IBSS_PARMS
)(sFrame
.pBuf
+ sFrame
.len
);
3045 sFrame
.len
+= (2) + WLAN_IEHDR_LEN
;
3046 sFrame
.pIBSSParms
->byElementID
= WLAN_EID_IBSS_PARMS
;
3047 sFrame
.pIBSSParms
->len
= 2;
3048 sFrame
.pIBSSParms
->wATIMWindow
= 0;
3050 if (pDevice
->byBBType
== BB_TYPE_11G
) {
3051 sFrame
.pERP
= (PWLAN_IE_ERP
)(sFrame
.pBuf
+ sFrame
.len
);
3052 sFrame
.len
+= 1 + WLAN_IEHDR_LEN
;
3053 sFrame
.pERP
->byElementID
= WLAN_EID_ERP
;
3054 sFrame
.pERP
->len
= 1;
3055 sFrame
.pERP
->byContext
= 0;
3056 if (pDevice
->bProtectMode
== true)
3057 sFrame
.pERP
->byContext
|= WLAN_EID_ERP_USE_PROTECTION
;
3058 if (pDevice
->bNonERPPresent
== true)
3059 sFrame
.pERP
->byContext
|= WLAN_EID_ERP_NONERP_PRESENT
;
3060 if (pDevice
->bBarkerPreambleMd
== true)
3061 sFrame
.pERP
->byContext
|= WLAN_EID_ERP_BARKER_MODE
;
3064 if (((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
!= 0) {
3065 sFrame
.pExtSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3066 sFrame
.len
+= ((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
;
3067 memcpy(sFrame
.pExtSuppRates
,
3069 ((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
3073 // hostapd wpa/wpa2 IE
3074 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) && (pDevice
->bEnableHostapd
== true)) {
3075 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPANONE
) {
3076 if (pMgmt
->wWPAIELen
!= 0) {
3077 sFrame
.pRSN
= (PWLAN_IE_RSN
)(sFrame
.pBuf
+ sFrame
.len
);
3078 memcpy(sFrame
.pRSN
, pMgmt
->abyWPAIE
, pMgmt
->wWPAIELen
);
3079 sFrame
.len
+= pMgmt
->wWPAIELen
;
3084 // Adjust the length fields
3085 pTxPacket
->cbMPDULen
= sFrame
.len
;
3086 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
3093 * Routine Description:
3094 * Constructs an association request frame
3098 * A ptr to frame or NULL on allocation failue
3102 struct vnt_tx_mgmt
*s_MgrMakeAssocRequest(struct vnt_private
*pDevice
,
3103 struct vnt_manager
*pMgmt
, u8
*pDAddr
, u16 wCurrCapInfo
,
3104 u16 wListenInterval
,
3105 PWLAN_IE_SSID pCurrSSID
,
3106 PWLAN_IE_SUPP_RATES pCurrRates
,
3107 PWLAN_IE_SUPP_RATES pCurrExtSuppRates
)
3109 struct vnt_tx_mgmt
*pTxPacket
= NULL
;
3110 WLAN_FR_ASSOCREQ sFrame
;
3114 pTxPacket
= (struct vnt_tx_mgmt
*)pMgmt
->pbyMgmtPacketPool
;
3115 memset(pTxPacket
, 0, sizeof(struct vnt_tx_mgmt
)
3116 + WLAN_ASSOCREQ_FR_MAXLEN
);
3117 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((u8
*)pTxPacket
3118 + sizeof(struct vnt_tx_mgmt
));
3119 // Setup the sFrame structure.
3120 sFrame
.pBuf
= (u8
*)pTxPacket
->p80211Header
;
3121 sFrame
.len
= WLAN_ASSOCREQ_FR_MAXLEN
;
3122 // format fixed field frame structure
3123 vMgrEncodeAssocRequest(&sFrame
);
3125 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
3127 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
3128 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ASSOCREQ
)
3130 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pDAddr
, WLAN_ADDR_LEN
);
3131 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
3132 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
3134 // Set the capability and listen interval
3135 *(sFrame
.pwCapInfo
) = cpu_to_le16(wCurrCapInfo
);
3136 *(sFrame
.pwListenInterval
) = cpu_to_le16(wListenInterval
);
3138 // sFrame.len point to end of fixed field
3139 sFrame
.pSSID
= (PWLAN_IE_SSID
)(sFrame
.pBuf
+ sFrame
.len
);
3140 sFrame
.len
+= pCurrSSID
->len
+ WLAN_IEHDR_LEN
;
3141 memcpy(sFrame
.pSSID
, pCurrSSID
, pCurrSSID
->len
+ WLAN_IEHDR_LEN
);
3143 pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
= pCurrSSID
->len
+ WLAN_IEHDR_LEN
;
3144 pMgmt
->sAssocInfo
.AssocInfo
.OffsetRequestIEs
= sizeof(NDIS_802_11_ASSOCIATION_INFORMATION
);
3145 pbyIEs
= pMgmt
->sAssocInfo
.abyIEs
;
3146 memcpy(pbyIEs
, pCurrSSID
, pCurrSSID
->len
+ WLAN_IEHDR_LEN
);
3147 pbyIEs
+= pCurrSSID
->len
+ WLAN_IEHDR_LEN
;
3149 // Copy the rate set
3150 sFrame
.pSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3151 if ((pDevice
->byBBType
== BB_TYPE_11B
) && (pCurrRates
->len
> 4))
3152 sFrame
.len
+= 4 + WLAN_IEHDR_LEN
;
3154 sFrame
.len
+= pCurrRates
->len
+ WLAN_IEHDR_LEN
;
3155 memcpy(sFrame
.pSuppRates
, pCurrRates
, pCurrRates
->len
+ WLAN_IEHDR_LEN
);
3157 // Copy the extension rate set
3158 if ((pDevice
->byBBType
== BB_TYPE_11G
) && (pCurrExtSuppRates
->len
> 0)) {
3159 sFrame
.pExtSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3160 sFrame
.len
+= pCurrExtSuppRates
->len
+ WLAN_IEHDR_LEN
;
3161 memcpy(sFrame
.pExtSuppRates
, pCurrExtSuppRates
, pCurrExtSuppRates
->len
+ WLAN_IEHDR_LEN
);
3164 pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
+= pCurrRates
->len
+ WLAN_IEHDR_LEN
;
3165 memcpy(pbyIEs
, pCurrRates
, pCurrRates
->len
+ WLAN_IEHDR_LEN
);
3166 pbyIEs
+= pCurrRates
->len
+ WLAN_IEHDR_LEN
;
3168 if (((pMgmt
->eAuthenMode
== WMAC_AUTH_WPA
) ||
3169 (pMgmt
->eAuthenMode
== WMAC_AUTH_WPAPSK
) ||
3170 (pMgmt
->eAuthenMode
== WMAC_AUTH_WPANONE
)) &&
3171 (pMgmt
->pCurrBSS
!= NULL
)) {
3173 sFrame
.pRSNWPA
= (PWLAN_IE_RSN_EXT
)(sFrame
.pBuf
+ sFrame
.len
);
3174 sFrame
.pRSNWPA
->byElementID
= WLAN_EID_RSN_WPA
;
3175 sFrame
.pRSNWPA
->len
= 16;
3176 sFrame
.pRSNWPA
->abyOUI
[0] = 0x00;
3177 sFrame
.pRSNWPA
->abyOUI
[1] = 0x50;
3178 sFrame
.pRSNWPA
->abyOUI
[2] = 0xf2;
3179 sFrame
.pRSNWPA
->abyOUI
[3] = 0x01;
3180 sFrame
.pRSNWPA
->wVersion
= 1;
3181 //Group Key Cipher Suite
3182 sFrame
.pRSNWPA
->abyMulticast
[0] = 0x00;
3183 sFrame
.pRSNWPA
->abyMulticast
[1] = 0x50;
3184 sFrame
.pRSNWPA
->abyMulticast
[2] = 0xf2;
3185 if (pMgmt
->byCSSGK
== KEY_CTL_WEP
) {
3186 sFrame
.pRSNWPA
->abyMulticast
[3] = pMgmt
->pCurrBSS
->byGKType
;
3187 } else if (pMgmt
->byCSSGK
== KEY_CTL_TKIP
) {
3188 sFrame
.pRSNWPA
->abyMulticast
[3] = WPA_TKIP
;
3189 } else if (pMgmt
->byCSSGK
== KEY_CTL_CCMP
) {
3190 sFrame
.pRSNWPA
->abyMulticast
[3] = WPA_AESCCMP
;
3192 sFrame
.pRSNWPA
->abyMulticast
[3] = WPA_NONE
;
3194 // Pairwise Key Cipher Suite
3195 sFrame
.pRSNWPA
->wPKCount
= 1;
3196 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[0] = 0x00;
3197 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[1] = 0x50;
3198 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[2] = 0xf2;
3199 if (pMgmt
->byCSSPK
== KEY_CTL_TKIP
) {
3200 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[3] = WPA_TKIP
;
3201 } else if (pMgmt
->byCSSPK
== KEY_CTL_CCMP
) {
3202 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[3] = WPA_AESCCMP
;
3204 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[3] = WPA_NONE
;
3206 // Auth Key Management Suite
3207 pbyRSN
= (u8
*)(sFrame
.pBuf
+ sFrame
.len
+ 2 + sFrame
.pRSNWPA
->len
);
3214 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPAPSK
) {
3215 *pbyRSN
++=WPA_AUTH_PSK
;
3217 else if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA
) {
3218 *pbyRSN
++=WPA_AUTH_IEEE802_1X
;
3224 sFrame
.pRSNWPA
->len
+=6;
3230 sFrame
.pRSNWPA
->len
+=2;
3232 sFrame
.len
+= sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
;
3233 // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION
3234 pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
+= sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
;
3235 memcpy(pbyIEs
, sFrame
.pRSNWPA
, sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
);
3236 pbyIEs
+= sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
;
3238 } else if (((pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2
) ||
3239 (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2PSK
)) &&
3240 (pMgmt
->pCurrBSS
!= NULL
)) {
3245 sFrame
.pRSN
= (PWLAN_IE_RSN
)(sFrame
.pBuf
+ sFrame
.len
);
3246 sFrame
.pRSN
->byElementID
= WLAN_EID_RSN
;
3247 sFrame
.pRSN
->len
= 6; //Version(2)+GK(4)
3248 sFrame
.pRSN
->wVersion
= 1;
3249 //Group Key Cipher Suite
3250 sFrame
.pRSN
->abyRSN
[0] = 0x00;
3251 sFrame
.pRSN
->abyRSN
[1] = 0x0F;
3252 sFrame
.pRSN
->abyRSN
[2] = 0xAC;
3253 if (pMgmt
->byCSSGK
== KEY_CTL_WEP
) {
3254 sFrame
.pRSN
->abyRSN
[3] = pMgmt
->pCurrBSS
->byCSSGK
;
3255 } else if (pMgmt
->byCSSGK
== KEY_CTL_TKIP
) {
3256 sFrame
.pRSN
->abyRSN
[3] = WLAN_11i_CSS_TKIP
;
3257 } else if (pMgmt
->byCSSGK
== KEY_CTL_CCMP
) {
3258 sFrame
.pRSN
->abyRSN
[3] = WLAN_11i_CSS_CCMP
;
3260 sFrame
.pRSN
->abyRSN
[3] = WLAN_11i_CSS_UNKNOWN
;
3263 // Pairwise Key Cipher Suite
3264 sFrame
.pRSN
->abyRSN
[4] = 1;
3265 sFrame
.pRSN
->abyRSN
[5] = 0;
3266 sFrame
.pRSN
->abyRSN
[6] = 0x00;
3267 sFrame
.pRSN
->abyRSN
[7] = 0x0F;
3268 sFrame
.pRSN
->abyRSN
[8] = 0xAC;
3269 if (pMgmt
->byCSSPK
== KEY_CTL_TKIP
) {
3270 sFrame
.pRSN
->abyRSN
[9] = WLAN_11i_CSS_TKIP
;
3271 } else if (pMgmt
->byCSSPK
== KEY_CTL_CCMP
) {
3272 sFrame
.pRSN
->abyRSN
[9] = WLAN_11i_CSS_CCMP
;
3273 } else if (pMgmt
->byCSSPK
== KEY_CTL_NONE
) {
3274 sFrame
.pRSN
->abyRSN
[9] = WLAN_11i_CSS_USE_GROUP
;
3276 sFrame
.pRSN
->abyRSN
[9] = WLAN_11i_CSS_UNKNOWN
;
3278 sFrame
.pRSN
->len
+= 6;
3280 // Auth Key Management Suite
3281 sFrame
.pRSN
->abyRSN
[10] = 1;
3282 sFrame
.pRSN
->abyRSN
[11] = 0;
3283 sFrame
.pRSN
->abyRSN
[12] = 0x00;
3284 sFrame
.pRSN
->abyRSN
[13] = 0x0F;
3285 sFrame
.pRSN
->abyRSN
[14] = 0xAC;
3286 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2PSK
) {
3287 sFrame
.pRSN
->abyRSN
[15] = WLAN_11i_AKMSS_PSK
;
3288 } else if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2
) {
3289 sFrame
.pRSN
->abyRSN
[15] = WLAN_11i_AKMSS_802_1X
;
3291 sFrame
.pRSN
->abyRSN
[15] = WLAN_11i_AKMSS_UNKNOWN
;
3293 sFrame
.pRSN
->len
+=6;
3296 if (pMgmt
->pCurrBSS
->sRSNCapObj
.bRSNCapExist
== true) {
3297 memcpy(&sFrame
.pRSN
->abyRSN
[16], &pMgmt
->pCurrBSS
->sRSNCapObj
.wRSNCap
, 2);
3299 sFrame
.pRSN
->abyRSN
[16] = 0;
3300 sFrame
.pRSN
->abyRSN
[17] = 0;
3302 sFrame
.pRSN
->len
+=2;
3304 if ((pDevice
->gsPMKID
.BSSIDInfoCount
> 0) && (pDevice
->bRoaming
== true) && (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2
)) {
3306 pbyRSN
= &sFrame
.pRSN
->abyRSN
[18];
3307 pwPMKID
= (u16
*)pbyRSN
; // Point to PMKID count
3308 *pwPMKID
= 0; // Initialize PMKID count
3309 pbyRSN
+= 2; // Point to PMKID list
3310 for (ii
= 0; ii
< pDevice
->gsPMKID
.BSSIDInfoCount
; ii
++) {
3311 if (!memcmp(&pDevice
->gsPMKID
.BSSIDInfo
[ii
].BSSID
[0],
3312 pMgmt
->abyCurrBSSID
,
3316 pDevice
->gsPMKID
.BSSIDInfo
[ii
].PMKID
,
3321 if (*pwPMKID
!= 0) {
3322 sFrame
.pRSN
->len
+= (2 + (*pwPMKID
)*16);
3326 sFrame
.len
+= sFrame
.pRSN
->len
+ WLAN_IEHDR_LEN
;
3327 // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION
3328 pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
+= sFrame
.pRSN
->len
+ WLAN_IEHDR_LEN
;
3329 memcpy(pbyIEs
, sFrame
.pRSN
, sFrame
.pRSN
->len
+ WLAN_IEHDR_LEN
);
3330 pbyIEs
+= sFrame
.pRSN
->len
+ WLAN_IEHDR_LEN
;
3333 // Adjust the length fields
3334 pTxPacket
->cbMPDULen
= sFrame
.len
;
3335 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
3341 * Routine Description:
3342 * Constructs an re-association request frame
3346 * A ptr to frame or NULL on allocation failure
3350 struct vnt_tx_mgmt
*s_MgrMakeReAssocRequest(struct vnt_private
*pDevice
,
3351 struct vnt_manager
*pMgmt
, u8
*pDAddr
, u16 wCurrCapInfo
,
3352 u16 wListenInterval
, PWLAN_IE_SSID pCurrSSID
,
3353 PWLAN_IE_SUPP_RATES pCurrRates
,
3354 PWLAN_IE_SUPP_RATES pCurrExtSuppRates
)
3356 struct vnt_tx_mgmt
*pTxPacket
= NULL
;
3357 WLAN_FR_REASSOCREQ sFrame
;
3361 pTxPacket
= (struct vnt_tx_mgmt
*)pMgmt
->pbyMgmtPacketPool
;
3362 memset(pTxPacket
, 0, sizeof(struct vnt_tx_mgmt
)
3363 + WLAN_REASSOCREQ_FR_MAXLEN
);
3364 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((u8
*)pTxPacket
3365 + sizeof(struct vnt_tx_mgmt
));
3366 /* Setup the sFrame structure. */
3367 sFrame
.pBuf
= (u8
*)pTxPacket
->p80211Header
;
3368 sFrame
.len
= WLAN_REASSOCREQ_FR_MAXLEN
;
3370 // format fixed field frame structure
3371 vMgrEncodeReassocRequest(&sFrame
);
3373 /* Setup the header */
3374 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
3376 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
3377 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_REASSOCREQ
)
3379 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pDAddr
, WLAN_ADDR_LEN
);
3380 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
3381 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
3383 /* Set the capability and listen interval */
3384 *(sFrame
.pwCapInfo
) = cpu_to_le16(wCurrCapInfo
);
3385 *(sFrame
.pwListenInterval
) = cpu_to_le16(wListenInterval
);
3387 memcpy(sFrame
.pAddrCurrAP
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
3389 /* sFrame.len point to end of fixed field */
3390 sFrame
.pSSID
= (PWLAN_IE_SSID
)(sFrame
.pBuf
+ sFrame
.len
);
3391 sFrame
.len
+= pCurrSSID
->len
+ WLAN_IEHDR_LEN
;
3392 memcpy(sFrame
.pSSID
, pCurrSSID
, pCurrSSID
->len
+ WLAN_IEHDR_LEN
);
3394 pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
= pCurrSSID
->len
+ WLAN_IEHDR_LEN
;
3395 pMgmt
->sAssocInfo
.AssocInfo
.OffsetRequestIEs
= sizeof(NDIS_802_11_ASSOCIATION_INFORMATION
);
3396 pbyIEs
= pMgmt
->sAssocInfo
.abyIEs
;
3397 memcpy(pbyIEs
, pCurrSSID
, pCurrSSID
->len
+ WLAN_IEHDR_LEN
);
3398 pbyIEs
+= pCurrSSID
->len
+ WLAN_IEHDR_LEN
;
3400 /* Copy the rate set */
3401 /* sFrame.len point to end of SSID */
3402 sFrame
.pSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3403 sFrame
.len
+= pCurrRates
->len
+ WLAN_IEHDR_LEN
;
3404 memcpy(sFrame
.pSuppRates
, pCurrRates
, pCurrRates
->len
+ WLAN_IEHDR_LEN
);
3406 // Copy the extension rate set
3407 if ((pMgmt
->eCurrentPHYMode
== PHY_TYPE_11G
) && (pCurrExtSuppRates
->len
> 0)) {
3408 sFrame
.pExtSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3409 sFrame
.len
+= pCurrExtSuppRates
->len
+ WLAN_IEHDR_LEN
;
3410 memcpy(sFrame
.pExtSuppRates
, pCurrExtSuppRates
, pCurrExtSuppRates
->len
+ WLAN_IEHDR_LEN
);
3413 pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
+= pCurrRates
->len
+ WLAN_IEHDR_LEN
;
3414 memcpy(pbyIEs
, pCurrRates
, pCurrRates
->len
+ WLAN_IEHDR_LEN
);
3415 pbyIEs
+= pCurrRates
->len
+ WLAN_IEHDR_LEN
;
3417 if (((pMgmt
->eAuthenMode
== WMAC_AUTH_WPA
) ||
3418 (pMgmt
->eAuthenMode
== WMAC_AUTH_WPAPSK
) ||
3419 (pMgmt
->eAuthenMode
== WMAC_AUTH_WPANONE
)) &&
3420 (pMgmt
->pCurrBSS
!= NULL
)) {
3422 sFrame
.pRSNWPA
= (PWLAN_IE_RSN_EXT
)(sFrame
.pBuf
+ sFrame
.len
);
3423 sFrame
.pRSNWPA
->byElementID
= WLAN_EID_RSN_WPA
;
3424 sFrame
.pRSNWPA
->len
= 16;
3425 sFrame
.pRSNWPA
->abyOUI
[0] = 0x00;
3426 sFrame
.pRSNWPA
->abyOUI
[1] = 0x50;
3427 sFrame
.pRSNWPA
->abyOUI
[2] = 0xf2;
3428 sFrame
.pRSNWPA
->abyOUI
[3] = 0x01;
3429 sFrame
.pRSNWPA
->wVersion
= 1;
3430 //Group Key Cipher Suite
3431 sFrame
.pRSNWPA
->abyMulticast
[0] = 0x00;
3432 sFrame
.pRSNWPA
->abyMulticast
[1] = 0x50;
3433 sFrame
.pRSNWPA
->abyMulticast
[2] = 0xf2;
3434 if (pMgmt
->byCSSGK
== KEY_CTL_WEP
) {
3435 sFrame
.pRSNWPA
->abyMulticast
[3] = pMgmt
->pCurrBSS
->byGKType
;
3436 } else if (pMgmt
->byCSSGK
== KEY_CTL_TKIP
) {
3437 sFrame
.pRSNWPA
->abyMulticast
[3] = WPA_TKIP
;
3438 } else if (pMgmt
->byCSSGK
== KEY_CTL_CCMP
) {
3439 sFrame
.pRSNWPA
->abyMulticast
[3] = WPA_AESCCMP
;
3441 sFrame
.pRSNWPA
->abyMulticast
[3] = WPA_NONE
;
3443 // Pairwise Key Cipher Suite
3444 sFrame
.pRSNWPA
->wPKCount
= 1;
3445 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[0] = 0x00;
3446 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[1] = 0x50;
3447 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[2] = 0xf2;
3448 if (pMgmt
->byCSSPK
== KEY_CTL_TKIP
) {
3449 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[3] = WPA_TKIP
;
3450 } else if (pMgmt
->byCSSPK
== KEY_CTL_CCMP
) {
3451 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[3] = WPA_AESCCMP
;
3453 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[3] = WPA_NONE
;
3455 // Auth Key Management Suite
3456 pbyRSN
= (u8
*)(sFrame
.pBuf
+ sFrame
.len
+ 2 + sFrame
.pRSNWPA
->len
);
3463 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPAPSK
) {
3464 *pbyRSN
++=WPA_AUTH_PSK
;
3465 } else if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA
) {
3466 *pbyRSN
++=WPA_AUTH_IEEE802_1X
;
3471 sFrame
.pRSNWPA
->len
+=6;
3476 sFrame
.pRSNWPA
->len
+=2;
3478 sFrame
.len
+= sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
;
3479 // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION
3480 pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
+= sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
;
3481 memcpy(pbyIEs
, sFrame
.pRSNWPA
, sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
);
3482 pbyIEs
+= sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
;
3484 } else if (((pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2
) ||
3485 (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2PSK
)) &&
3486 (pMgmt
->pCurrBSS
!= NULL
)) {
3491 sFrame
.pRSN
= (PWLAN_IE_RSN
)(sFrame
.pBuf
+ sFrame
.len
);
3492 sFrame
.pRSN
->byElementID
= WLAN_EID_RSN
;
3493 sFrame
.pRSN
->len
= 6; //Version(2)+GK(4)
3494 sFrame
.pRSN
->wVersion
= 1;
3495 //Group Key Cipher Suite
3496 sFrame
.pRSN
->abyRSN
[0] = 0x00;
3497 sFrame
.pRSN
->abyRSN
[1] = 0x0F;
3498 sFrame
.pRSN
->abyRSN
[2] = 0xAC;
3499 if (pMgmt
->byCSSGK
== KEY_CTL_WEP
) {
3500 sFrame
.pRSN
->abyRSN
[3] = pMgmt
->pCurrBSS
->byCSSGK
;
3501 } else if (pMgmt
->byCSSGK
== KEY_CTL_TKIP
) {
3502 sFrame
.pRSN
->abyRSN
[3] = WLAN_11i_CSS_TKIP
;
3503 } else if (pMgmt
->byCSSGK
== KEY_CTL_CCMP
) {
3504 sFrame
.pRSN
->abyRSN
[3] = WLAN_11i_CSS_CCMP
;
3506 sFrame
.pRSN
->abyRSN
[3] = WLAN_11i_CSS_UNKNOWN
;
3509 // Pairwise Key Cipher Suite
3510 sFrame
.pRSN
->abyRSN
[4] = 1;
3511 sFrame
.pRSN
->abyRSN
[5] = 0;
3512 sFrame
.pRSN
->abyRSN
[6] = 0x00;
3513 sFrame
.pRSN
->abyRSN
[7] = 0x0F;
3514 sFrame
.pRSN
->abyRSN
[8] = 0xAC;
3515 if (pMgmt
->byCSSPK
== KEY_CTL_TKIP
) {
3516 sFrame
.pRSN
->abyRSN
[9] = WLAN_11i_CSS_TKIP
;
3517 } else if (pMgmt
->byCSSPK
== KEY_CTL_CCMP
) {
3518 sFrame
.pRSN
->abyRSN
[9] = WLAN_11i_CSS_CCMP
;
3519 } else if (pMgmt
->byCSSPK
== KEY_CTL_NONE
) {
3520 sFrame
.pRSN
->abyRSN
[9] = WLAN_11i_CSS_USE_GROUP
;
3522 sFrame
.pRSN
->abyRSN
[9] = WLAN_11i_CSS_UNKNOWN
;
3524 sFrame
.pRSN
->len
+= 6;
3526 // Auth Key Management Suite
3527 sFrame
.pRSN
->abyRSN
[10] = 1;
3528 sFrame
.pRSN
->abyRSN
[11] = 0;
3529 sFrame
.pRSN
->abyRSN
[12] = 0x00;
3530 sFrame
.pRSN
->abyRSN
[13] = 0x0F;
3531 sFrame
.pRSN
->abyRSN
[14] = 0xAC;
3532 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2PSK
) {
3533 sFrame
.pRSN
->abyRSN
[15] = WLAN_11i_AKMSS_PSK
;
3534 } else if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2
) {
3535 sFrame
.pRSN
->abyRSN
[15] = WLAN_11i_AKMSS_802_1X
;
3537 sFrame
.pRSN
->abyRSN
[15] = WLAN_11i_AKMSS_UNKNOWN
;
3539 sFrame
.pRSN
->len
+=6;
3542 if (pMgmt
->pCurrBSS
->sRSNCapObj
.bRSNCapExist
== true) {
3543 memcpy(&sFrame
.pRSN
->abyRSN
[16], &pMgmt
->pCurrBSS
->sRSNCapObj
.wRSNCap
, 2);
3545 sFrame
.pRSN
->abyRSN
[16] = 0;
3546 sFrame
.pRSN
->abyRSN
[17] = 0;
3548 sFrame
.pRSN
->len
+=2;
3550 if ((pDevice
->gsPMKID
.BSSIDInfoCount
> 0) && (pDevice
->bRoaming
== true) && (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2
)) {
3552 pbyRSN
= &sFrame
.pRSN
->abyRSN
[18];
3553 pwPMKID
= (u16
*)pbyRSN
; // Point to PMKID count
3554 *pwPMKID
= 0; // Initialize PMKID count
3555 pbyRSN
+= 2; // Point to PMKID list
3556 for (ii
= 0; ii
< pDevice
->gsPMKID
.BSSIDInfoCount
; ii
++) {
3557 if (!memcmp(&pDevice
->gsPMKID
.BSSIDInfo
[ii
].BSSID
[0],
3558 pMgmt
->abyCurrBSSID
,
3562 pDevice
->gsPMKID
.BSSIDInfo
[ii
].PMKID
,
3567 if (*pwPMKID
!= 0) {
3568 sFrame
.pRSN
->len
+= (2 + (*pwPMKID
)*16);
3572 sFrame
.len
+= sFrame
.pRSN
->len
+ WLAN_IEHDR_LEN
;
3573 // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION
3574 pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
+= sFrame
.pRSN
->len
+ WLAN_IEHDR_LEN
;
3575 memcpy(pbyIEs
, sFrame
.pRSN
, sFrame
.pRSN
->len
+ WLAN_IEHDR_LEN
);
3576 pbyIEs
+= sFrame
.pRSN
->len
+ WLAN_IEHDR_LEN
;
3579 /* Adjust the length fields */
3580 pTxPacket
->cbMPDULen
= sFrame
.len
;
3581 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
3588 * Routine Description:
3589 * Constructs an assoc-response frame
3593 * PTR to frame; or NULL on allocation failure
3597 struct vnt_tx_mgmt
*s_MgrMakeAssocResponse(struct vnt_private
*pDevice
,
3598 struct vnt_manager
*pMgmt
, u16 wCurrCapInfo
, u16 wAssocStatus
,
3599 u16 wAssocAID
, u8
*pDstAddr
, PWLAN_IE_SUPP_RATES pCurrSuppRates
,
3600 PWLAN_IE_SUPP_RATES pCurrExtSuppRates
)
3602 struct vnt_tx_mgmt
*pTxPacket
= NULL
;
3603 WLAN_FR_ASSOCRESP sFrame
;
3605 pTxPacket
= (struct vnt_tx_mgmt
*)pMgmt
->pbyMgmtPacketPool
;
3606 memset(pTxPacket
, 0, sizeof(struct vnt_tx_mgmt
)
3607 + WLAN_ASSOCREQ_FR_MAXLEN
);
3608 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((u8
*)pTxPacket
3609 + sizeof(struct vnt_tx_mgmt
));
3610 // Setup the sFrame structure
3611 sFrame
.pBuf
= (u8
*)pTxPacket
->p80211Header
;
3612 sFrame
.len
= WLAN_REASSOCRESP_FR_MAXLEN
;
3613 vMgrEncodeAssocResponse(&sFrame
);
3615 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
3617 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
3618 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ASSOCRESP
)
3620 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pDstAddr
, WLAN_ADDR_LEN
);
3621 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
3622 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
3624 *sFrame
.pwCapInfo
= cpu_to_le16(wCurrCapInfo
);
3625 *sFrame
.pwStatus
= cpu_to_le16(wAssocStatus
);
3626 *sFrame
.pwAid
= cpu_to_le16((u16
)(wAssocAID
| BIT14
| BIT15
));
3628 // Copy the rate set
3629 sFrame
.pSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3630 sFrame
.len
+= ((PWLAN_IE_SUPP_RATES
)pCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
;
3631 memcpy(sFrame
.pSuppRates
,
3633 ((PWLAN_IE_SUPP_RATES
)pCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
3636 if (((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
!= 0) {
3637 sFrame
.pExtSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3638 sFrame
.len
+= ((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
;
3639 memcpy(sFrame
.pExtSuppRates
,
3641 ((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
3645 // Adjust the length fields
3646 pTxPacket
->cbMPDULen
= sFrame
.len
;
3647 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
3654 * Routine Description:
3655 * Constructs an reassoc-response frame
3659 * PTR to frame; or NULL on allocation failure
3663 struct vnt_tx_mgmt
*s_MgrMakeReAssocResponse(struct vnt_private
*pDevice
,
3664 struct vnt_manager
*pMgmt
, u16 wCurrCapInfo
, u16 wAssocStatus
,
3665 u16 wAssocAID
, u8
*pDstAddr
, PWLAN_IE_SUPP_RATES pCurrSuppRates
,
3666 PWLAN_IE_SUPP_RATES pCurrExtSuppRates
)
3668 struct vnt_tx_mgmt
*pTxPacket
= NULL
;
3669 WLAN_FR_REASSOCRESP sFrame
;
3671 pTxPacket
= (struct vnt_tx_mgmt
*)pMgmt
->pbyMgmtPacketPool
;
3672 memset(pTxPacket
, 0, sizeof(struct vnt_tx_mgmt
)
3673 + WLAN_ASSOCREQ_FR_MAXLEN
);
3674 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((u8
*)pTxPacket
3675 + sizeof(struct vnt_tx_mgmt
));
3676 // Setup the sFrame structure
3677 sFrame
.pBuf
= (u8
*)pTxPacket
->p80211Header
;
3678 sFrame
.len
= WLAN_REASSOCRESP_FR_MAXLEN
;
3679 vMgrEncodeReassocResponse(&sFrame
);
3681 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
3683 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
3684 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_REASSOCRESP
)
3686 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pDstAddr
, WLAN_ADDR_LEN
);
3687 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
3688 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
3690 *sFrame
.pwCapInfo
= cpu_to_le16(wCurrCapInfo
);
3691 *sFrame
.pwStatus
= cpu_to_le16(wAssocStatus
);
3692 *sFrame
.pwAid
= cpu_to_le16((u16
)(wAssocAID
| BIT14
| BIT15
));
3694 // Copy the rate set
3695 sFrame
.pSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3696 sFrame
.len
+= ((PWLAN_IE_SUPP_RATES
)pCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
;
3697 memcpy(sFrame
.pSuppRates
,
3699 ((PWLAN_IE_SUPP_RATES
)pCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
3702 if (((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
!= 0) {
3703 sFrame
.pExtSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3704 sFrame
.len
+= ((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
;
3705 memcpy(sFrame
.pExtSuppRates
,
3707 ((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
3711 // Adjust the length fields
3712 pTxPacket
->cbMPDULen
= sFrame
.len
;
3713 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
3720 * Routine Description:
3721 * Handles probe response management frames.
3729 static void s_vMgrRxProbeResponse(struct vnt_private
*pDevice
,
3730 struct vnt_manager
*pMgmt
, struct vnt_rx_mgmt
*pRxPacket
)
3732 PKnownBSS pBSSList
= NULL
;
3733 WLAN_FR_PROBERESP sFrame
;
3734 u8 byCurrChannel
= pRxPacket
->byRxChannel
;
3736 int bChannelHit
= true;
3738 memset(&sFrame
, 0, sizeof(WLAN_FR_PROBERESP
));
3740 sFrame
.len
= pRxPacket
->cbMPDULen
;
3741 sFrame
.pBuf
= (u8
*)pRxPacket
->p80211Header
;
3742 vMgrDecodeProbeResponse(&sFrame
);
3744 if ((sFrame
.pqwTimestamp
== NULL
)
3745 || (sFrame
.pwBeaconInterval
== NULL
)
3746 || (sFrame
.pwCapInfo
== NULL
)
3747 || (sFrame
.pSSID
== NULL
)
3748 || (sFrame
.pSuppRates
== NULL
)) {
3750 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Probe resp:Fail addr:[%p]\n",
3751 pRxPacket
->p80211Header
);
3755 if(sFrame
.pSSID
->len
== 0)
3756 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Rx Probe resp: SSID len = 0 \n");
3758 //{{ RobertYu:20050201, 11a byCurrChannel != sFrame.pDSParms->byCurrChannel mapping
3759 if( byCurrChannel
> CB_MAX_CHANNEL_24G
)
3761 if (sFrame
.pDSParms
) {
3762 if (byCurrChannel
==
3763 RFaby11aChannelIndex
[sFrame
.pDSParms
->byCurrChannel
-1])
3766 RFaby11aChannelIndex
[sFrame
.pDSParms
->byCurrChannel
-1];
3771 if (sFrame
.pDSParms
) {
3772 if (byCurrChannel
== sFrame
.pDSParms
->byCurrChannel
)
3774 byCurrChannel
= sFrame
.pDSParms
->byCurrChannel
;
3781 if(ChannelExceedZoneType(pDevice
,byCurrChannel
)==true)
3785 sERP
.byERP
= sFrame
.pERP
->byContext
;
3786 sERP
.bERPExist
= true;
3788 sERP
.bERPExist
= false;
3792 // update or insert the bss
3793 pBSSList
= BSSpAddrIsInBSSList((void *) pDevice
,
3794 sFrame
.pHdr
->sA3
.abyAddr3
,
3797 BSSbUpdateToBSSList((void *) pDevice
,
3798 *sFrame
.pqwTimestamp
,
3799 *sFrame
.pwBeaconInterval
,
3805 sFrame
.pExtSuppRates
,
3812 sFrame
.len
- WLAN_HDR_ADDR3_LEN
,
3813 /* payload of probresponse */
3814 sFrame
.pHdr
->sA4
.abyAddr4
,
3815 (void *) pRxPacket
);
3817 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Probe resp/insert: RxChannel = : %d\n", byCurrChannel
);
3818 BSSbInsertToBSSList((void *) pDevice
,
3819 sFrame
.pHdr
->sA3
.abyAddr3
,
3820 *sFrame
.pqwTimestamp
,
3821 *sFrame
.pwBeaconInterval
,
3826 sFrame
.pExtSuppRates
,
3832 sFrame
.len
- WLAN_HDR_ADDR3_LEN
,
3833 sFrame
.pHdr
->sA4
.abyAddr4
, /* payload of beacon */
3834 (void *) pRxPacket
);
3842 * Routine Description:(AP)or(Ad-hoc STA)
3843 * Handles probe request management frames.
3851 static void s_vMgrRxProbeRequest(struct vnt_private
*pDevice
,
3852 struct vnt_manager
*pMgmt
, struct vnt_rx_mgmt
*pRxPacket
)
3854 WLAN_FR_PROBEREQ sFrame
;
3856 struct vnt_tx_mgmt
*pTxPacket
;
3857 u8 byPHYType
= BB_TYPE_11B
;
3859 // STA in Ad-hoc mode: when latest TBTT beacon transmit success,
3860 // STA have to response this request.
3861 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) ||
3862 ((pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) && pDevice
->bBeaconSent
)) {
3864 memset(&sFrame
, 0, sizeof(WLAN_FR_PROBEREQ
));
3866 sFrame
.len
= pRxPacket
->cbMPDULen
;
3867 sFrame
.pBuf
= (u8
*)pRxPacket
->p80211Header
;
3868 vMgrDecodeProbeRequest(&sFrame
);
3870 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request rx:MAC addr:%pM\n",
3871 sFrame.pHdr->sA3.abyAddr2);
3873 if (sFrame
.pSSID
->len
!= 0) {
3874 if (sFrame
.pSSID
->len
!= ((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->len
)
3876 if (memcmp(sFrame
.pSSID
->abySSID
,
3877 ((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->abySSID
,
3878 ((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->len
) != 0) {
3883 if ((sFrame
.pSuppRates
->len
> 4) || (sFrame
.pExtSuppRates
!= NULL
)) {
3884 byPHYType
= BB_TYPE_11G
;
3887 // Probe response reply..
3888 pTxPacket
= s_MgrMakeProbeResponse
3892 pMgmt
->wCurrCapInfo
,
3893 pMgmt
->wCurrBeaconPeriod
,
3894 pMgmt
->uCurrChannel
,
3896 sFrame
.pHdr
->sA3
.abyAddr2
,
3897 (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
,
3898 (u8
*)pMgmt
->abyCurrBSSID
,
3899 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
3900 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
,
3903 if (pTxPacket
!= NULL
){
3904 /* send the frame */
3905 Status
= csMgmt_xmit(pDevice
, pTxPacket
);
3906 if (Status
!= CMD_STATUS_PENDING
) {
3907 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Probe response tx failed\n");
3910 // DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Probe response tx sending..\n");
3920 * Routine Description:
3922 * Entry point for the reception and handling of 802.11 management
3923 * frames. Makes a determination of the frame type and then calls
3924 * the appropriate function.
3932 void vMgrRxManagePacket(struct vnt_private
*pDevice
, struct vnt_manager
*pMgmt
,
3933 struct vnt_rx_mgmt
*pRxPacket
)
3935 int bInScan
= false;
3937 NODE_STATE eNodeState
= 0;
3940 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) {
3941 if (BSSbIsSTAInNodeDB(pDevice
, pRxPacket
->p80211Header
->sA3
.abyAddr2
, &uNodeIndex
))
3942 eNodeState
= pMgmt
->sNodeDBTable
[uNodeIndex
].eNodeState
;
3945 switch( WLAN_GET_FC_FSTYPE((pRxPacket
->p80211Header
->sA3
.wFrameCtl
)) ){
3947 case WLAN_FSTYPE_ASSOCREQ
:
3949 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx assocreq\n");
3950 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) &&
3951 (eNodeState
< NODE_AUTH
)) {
3952 // send deauth notification
3953 // reason = (6) class 2 received from nonauth sta
3954 vMgrDeAuthenBeginSta(pDevice
,
3956 pRxPacket
->p80211Header
->sA3
.abyAddr2
,
3960 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"wmgr: send vMgrDeAuthenBeginSta 1\n");
3963 s_vMgrRxAssocRequest(pDevice
, pMgmt
, pRxPacket
, uNodeIndex
);
3967 case WLAN_FSTYPE_ASSOCRESP
:
3969 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx assocresp1\n");
3970 s_vMgrRxAssocResponse(pDevice
, pMgmt
, pRxPacket
, false);
3971 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx assocresp2\n");
3974 case WLAN_FSTYPE_REASSOCREQ
:
3976 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx reassocreq\n");
3978 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) &&
3979 (eNodeState
< NODE_AUTH
)) {
3980 // send deauth notification
3981 // reason = (6) class 2 received from nonauth sta
3982 vMgrDeAuthenBeginSta(pDevice
,
3984 pRxPacket
->p80211Header
->sA3
.abyAddr2
,
3988 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"wmgr: send vMgrDeAuthenBeginSta 2\n");
3991 s_vMgrRxReAssocRequest(pDevice
, pMgmt
, pRxPacket
, uNodeIndex
);
3994 case WLAN_FSTYPE_REASSOCRESP
:
3996 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx reassocresp\n");
3997 s_vMgrRxAssocResponse(pDevice
, pMgmt
, pRxPacket
, true);
4000 case WLAN_FSTYPE_PROBEREQ
:
4002 //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx probereq\n");
4003 s_vMgrRxProbeRequest(pDevice
, pMgmt
, pRxPacket
);
4006 case WLAN_FSTYPE_PROBERESP
:
4008 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx proberesp\n");
4010 s_vMgrRxProbeResponse(pDevice
, pMgmt
, pRxPacket
);
4013 case WLAN_FSTYPE_BEACON
:
4015 //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx beacon\n");
4016 if (pMgmt
->eScanState
!= WMAC_NO_SCANNING
) {
4019 s_vMgrRxBeacon(pDevice
, pMgmt
, pRxPacket
, bInScan
);
4022 case WLAN_FSTYPE_ATIM
:
4024 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx atim\n");
4027 case WLAN_FSTYPE_DISASSOC
:
4029 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx disassoc\n");
4030 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) &&
4031 (eNodeState
< NODE_AUTH
)) {
4032 // send deauth notification
4033 // reason = (6) class 2 received from nonauth sta
4034 vMgrDeAuthenBeginSta(pDevice
,
4036 pRxPacket
->p80211Header
->sA3
.abyAddr2
,
4040 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"wmgr: send vMgrDeAuthenBeginSta 3\n");
4042 s_vMgrRxDisassociation(pDevice
, pMgmt
, pRxPacket
);
4045 case WLAN_FSTYPE_AUTHEN
:
4047 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx authen\n");
4048 s_vMgrRxAuthentication(pDevice
, pMgmt
, pRxPacket
);
4051 case WLAN_FSTYPE_DEAUTHEN
:
4053 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx deauthen\n");
4054 s_vMgrRxDeauthentication(pDevice
, pMgmt
, pRxPacket
);
4058 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx unknown mgmt\n");
4066 * Routine Description:
4069 * Prepare beacon to send
4072 * true if success; false if failed.
4075 int bMgrPrepareBeaconToSend(struct vnt_private
*pDevice
,
4076 struct vnt_manager
*pMgmt
)
4078 struct vnt_tx_mgmt
*pTxPacket
;
4080 // pDevice->bBeaconBufReady = false;
4081 if (pDevice
->bEncryptionEnable
|| pDevice
->bEnable8021x
){
4082 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_PRIVACY(1);
4085 pMgmt
->wCurrCapInfo
&= ~WLAN_SET_CAP_INFO_PRIVACY(1);
4087 pTxPacket
= s_MgrMakeBeacon
4091 pMgmt
->wCurrCapInfo
,
4092 pMgmt
->wCurrBeaconPeriod
,
4093 pMgmt
->uCurrChannel
,
4094 pMgmt
->wCurrATIMWindow
, //0,
4095 (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
,
4096 (u8
*)pMgmt
->abyCurrBSSID
,
4097 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
4098 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
4101 if ((pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) &&
4102 (pMgmt
->abyCurrBSSID
[0] == 0))
4105 csBeacon_xmit(pDevice
, pTxPacket
);
4106 MACvRegBitsOn(pDevice
, MAC_REG_TCR
, TCR_AUTOBCNTX
);
4113 * Routine Description:
4115 * Log a warning message based on the contents of the Status
4116 * Code field of an 802.11 management frame. Defines are
4117 * derived from 802.11-1997 SPEC.
4123 static void s_vMgrLogStatus(struct vnt_manager
*pMgmt
, u16 wStatus
)
4126 case WLAN_MGMT_STATUS_UNSPEC_FAILURE
:
4127 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Unspecified error.\n");
4129 case WLAN_MGMT_STATUS_CAPS_UNSUPPORTED
:
4130 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Can't support all requested capabilities.\n");
4132 case WLAN_MGMT_STATUS_REASSOC_NO_ASSOC
:
4133 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Reassoc denied, can't confirm original Association.\n");
4135 case WLAN_MGMT_STATUS_ASSOC_DENIED_UNSPEC
:
4136 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Assoc denied, undefine in spec\n");
4138 case WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG
:
4139 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Peer doesn't support authen algorithm.\n");
4141 case WLAN_MGMT_STATUS_RX_AUTH_NOSEQ
:
4142 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Authen frame received out of sequence.\n");
4144 case WLAN_MGMT_STATUS_CHALLENGE_FAIL
:
4145 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Authen rejected, challenge failure.\n");
4147 case WLAN_MGMT_STATUS_AUTH_TIMEOUT
:
4148 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Authen rejected, timeout waiting for next frame.\n");
4150 case WLAN_MGMT_STATUS_ASSOC_DENIED_BUSY
:
4151 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Assoc denied, AP too busy.\n");
4153 case WLAN_MGMT_STATUS_ASSOC_DENIED_RATES
:
4154 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Assoc denied, we haven't enough basic rates.\n");
4156 case WLAN_MGMT_STATUS_ASSOC_DENIED_SHORTPREAMBLE
:
4157 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Assoc denied, we do not support short preamble.\n");
4159 case WLAN_MGMT_STATUS_ASSOC_DENIED_PBCC
:
4160 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Assoc denied, we do not support PBCC.\n");
4162 case WLAN_MGMT_STATUS_ASSOC_DENIED_AGILITY
:
4163 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Assoc denied, we do not support channel agility.\n");
4166 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Unknown status code %d.\n", wStatus
);
4174 * Add BSSID in PMKID Candidate list.
4178 * hDeviceContext - device structure point
4179 * pbyBSSID - BSSID address for adding
4180 * wRSNCap - BSS's RSN capability
4184 * Return Value: none.
4188 int bAdd_PMKID_Candidate(struct vnt_private
*pDevice
, u8
*pbyBSSID
,
4189 PSRSNCapObject psRSNCapObj
)
4191 PPMKID_CANDIDATE pCandidateList
;
4194 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"bAdd_PMKID_Candidate START: (%d)\n", (int)pDevice
->gsPMKIDCandidate
.NumCandidates
);
4196 if ((pDevice
== NULL
) || (pbyBSSID
== NULL
) || (psRSNCapObj
== NULL
))
4199 if (pDevice
->gsPMKIDCandidate
.NumCandidates
>= MAX_PMKIDLIST
)
4202 // Update Old Candidate
4203 for (ii
= 0; ii
< pDevice
->gsPMKIDCandidate
.NumCandidates
; ii
++) {
4204 pCandidateList
= &pDevice
->gsPMKIDCandidate
.CandidateList
[ii
];
4205 if (!memcmp(pCandidateList
->BSSID
, pbyBSSID
, ETH_ALEN
)) {
4206 if ((psRSNCapObj
->bRSNCapExist
== true)
4207 && (psRSNCapObj
->wRSNCap
& BIT0
)) {
4208 pCandidateList
->Flags
|=
4209 NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED
;
4211 pCandidateList
->Flags
&=
4212 ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED
);
4219 pCandidateList
= &pDevice
->gsPMKIDCandidate
.CandidateList
[pDevice
->gsPMKIDCandidate
.NumCandidates
];
4220 if ((psRSNCapObj
->bRSNCapExist
== true) && (psRSNCapObj
->wRSNCap
& BIT0
)) {
4221 pCandidateList
->Flags
|= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED
;
4223 pCandidateList
->Flags
&= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED
);
4225 memcpy(pCandidateList
->BSSID
, pbyBSSID
, ETH_ALEN
);
4226 pDevice
->gsPMKIDCandidate
.NumCandidates
++;
4227 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"NumCandidates:%d\n", (int)pDevice
->gsPMKIDCandidate
.NumCandidates
);
4234 * Flush PMKID Candidate list.
4238 * hDeviceContext - device structure point
4242 * Return Value: none.
4246 void vFlush_PMKID_Candidate(struct vnt_private
*pDevice
)
4248 if (pDevice
== NULL
)
4251 memset(&pDevice
->gsPMKIDCandidate
, 0, sizeof(SPMKIDCandidateEvent
));
4259 NDIS_802_11_ENCRYPTION_STATUS EncStatus
,
4264 u8 byMulticastCipher
= KEY_CTL_INVALID
;
4265 u8 byCipherMask
= 0x00;
4268 if (pBSSNode
== NULL
)
4271 // check cap. of BSS
4272 if ((WLAN_GET_CAP_INFO_PRIVACY(pBSSNode
->wCapInfo
) != 0) &&
4273 (EncStatus
== Ndis802_11Encryption1Enabled
)) {
4274 // default is WEP only
4275 byMulticastCipher
= KEY_CTL_WEP
;
4278 if ((WLAN_GET_CAP_INFO_PRIVACY(pBSSNode
->wCapInfo
) != 0) &&
4279 (pBSSNode
->bWPA2Valid
== true) &&
4281 ((EncStatus
== Ndis802_11Encryption3Enabled
) ||
4282 (EncStatus
== Ndis802_11Encryption2Enabled
))) {
4284 // check Group Key Cipher
4285 if ((pBSSNode
->byCSSGK
== WLAN_11i_CSS_WEP40
) ||
4286 (pBSSNode
->byCSSGK
== WLAN_11i_CSS_WEP104
)) {
4287 byMulticastCipher
= KEY_CTL_WEP
;
4288 } else if (pBSSNode
->byCSSGK
== WLAN_11i_CSS_TKIP
) {
4289 byMulticastCipher
= KEY_CTL_TKIP
;
4290 } else if (pBSSNode
->byCSSGK
== WLAN_11i_CSS_CCMP
) {
4291 byMulticastCipher
= KEY_CTL_CCMP
;
4293 byMulticastCipher
= KEY_CTL_INVALID
;
4296 /* check Pairwise Key Cipher */
4297 for (i
= 0; i
< pBSSNode
->wCSSPKCount
; i
++) {
4298 if ((pBSSNode
->abyCSSPK
[i
] == WLAN_11i_CSS_WEP40
) ||
4299 (pBSSNode
->abyCSSPK
[i
] == WLAN_11i_CSS_WEP104
)) {
4300 /* this should not happen as defined 802.11i */
4301 byCipherMask
|= 0x01;
4302 } else if (pBSSNode
->abyCSSPK
[i
] == WLAN_11i_CSS_TKIP
) {
4303 byCipherMask
|= 0x02;
4304 } else if (pBSSNode
->abyCSSPK
[i
] == WLAN_11i_CSS_CCMP
) {
4305 byCipherMask
|= 0x04;
4306 } else if (pBSSNode
->abyCSSPK
[i
] == WLAN_11i_CSS_USE_GROUP
) {
4307 /* use group key only ignore all others */
4309 i
= pBSSNode
->wCSSPKCount
;
4313 } else if ((WLAN_GET_CAP_INFO_PRIVACY(pBSSNode
->wCapInfo
) != 0) &&
4314 (pBSSNode
->bWPAValid
== true) &&
4315 ((EncStatus
== Ndis802_11Encryption2Enabled
) || (EncStatus
== Ndis802_11Encryption3Enabled
))) {
4317 // check Group Key Cipher
4318 if ((pBSSNode
->byGKType
== WPA_WEP40
) ||
4319 (pBSSNode
->byGKType
== WPA_WEP104
)) {
4320 byMulticastCipher
= KEY_CTL_WEP
;
4321 } else if (pBSSNode
->byGKType
== WPA_TKIP
) {
4322 byMulticastCipher
= KEY_CTL_TKIP
;
4323 } else if (pBSSNode
->byGKType
== WPA_AESCCMP
) {
4324 byMulticastCipher
= KEY_CTL_CCMP
;
4326 byMulticastCipher
= KEY_CTL_INVALID
;
4329 /* check Pairwise Key Cipher */
4330 for (i
= 0; i
< pBSSNode
->wPKCount
; i
++) {
4331 if (pBSSNode
->abyPKType
[i
] == WPA_TKIP
) {
4332 byCipherMask
|= 0x02;
4333 } else if (pBSSNode
->abyPKType
[i
] == WPA_AESCCMP
) {
4334 byCipherMask
|= 0x04;
4335 } else if (pBSSNode
->abyPKType
[i
] == WPA_NONE
) {
4336 /* use group key only ignore all others */
4338 i
= pBSSNode
->wPKCount
;
4343 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%d, %d, %d, %d, EncStatus:%d\n",
4344 byMulticastCipher
, byCipherMask
, pBSSNode
->bWPAValid
, pBSSNode
->bWPA2Valid
, EncStatus
);
4346 // mask our cap. with BSS
4347 if (EncStatus
== Ndis802_11Encryption1Enabled
) {
4349 // For supporting Cisco migration mode, don't care pairwise key cipher
4350 //if ((byMulticastCipher == KEY_CTL_WEP) &&
4351 // (byCipherMask == 0)) {
4352 if ((byMulticastCipher
== KEY_CTL_WEP
) &&
4353 (byCipherMask
== 0)) {
4354 *pbyCCSGK
= KEY_CTL_WEP
;
4355 *pbyCCSPK
= KEY_CTL_NONE
;
4361 } else if (EncStatus
== Ndis802_11Encryption2Enabled
) {
4362 if ((byMulticastCipher
== KEY_CTL_TKIP
) &&
4363 (byCipherMask
== 0)) {
4364 *pbyCCSGK
= KEY_CTL_TKIP
;
4365 *pbyCCSPK
= KEY_CTL_NONE
;
4367 } else if ((byMulticastCipher
== KEY_CTL_WEP
) &&
4368 ((byCipherMask
& 0x02) != 0)) {
4369 *pbyCCSGK
= KEY_CTL_WEP
;
4370 *pbyCCSPK
= KEY_CTL_TKIP
;
4372 } else if ((byMulticastCipher
== KEY_CTL_TKIP
) &&
4373 ((byCipherMask
& 0x02) != 0)) {
4374 *pbyCCSGK
= KEY_CTL_TKIP
;
4375 *pbyCCSPK
= KEY_CTL_TKIP
;
4380 } else if (EncStatus
== Ndis802_11Encryption3Enabled
) {
4381 if ((byMulticastCipher
== KEY_CTL_CCMP
) &&
4382 (byCipherMask
== 0)) {
4383 // When CCMP is enable, "Use group cipher suite" shall not be a valid option.
4385 } else if ((byMulticastCipher
== KEY_CTL_WEP
) &&
4386 ((byCipherMask
& 0x04) != 0)) {
4387 *pbyCCSGK
= KEY_CTL_WEP
;
4388 *pbyCCSPK
= KEY_CTL_CCMP
;
4390 } else if ((byMulticastCipher
== KEY_CTL_TKIP
) &&
4391 ((byCipherMask
& 0x04) != 0)) {
4392 *pbyCCSGK
= KEY_CTL_TKIP
;
4393 *pbyCCSPK
= KEY_CTL_CCMP
;
4395 } else if ((byMulticastCipher
== KEY_CTL_CCMP
) &&
4396 ((byCipherMask
& 0x04) != 0)) {
4397 *pbyCCSGK
= KEY_CTL_CCMP
;
4398 *pbyCCSPK
= KEY_CTL_CCMP
;