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 Objet 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- Assember TIM field of beacon
58 * vMgrTimerInit- Initial 1-sec and command call back funtions
84 /*--------------------- Static Definitions -------------------------*/
88 /*--------------------- Static Classes ----------------------------*/
90 /*--------------------- Static Variables --------------------------*/
91 static int msglevel
=MSG_LEVEL_INFO
;
92 //static int msglevel =MSG_LEVEL_DEBUG;
94 /*--------------------- Static Functions --------------------------*/
95 //2008-0730-01<Add>by MikeLiu
96 static BOOL
ChannelExceedZoneType(
101 // Association/diassociation functions
104 s_MgrMakeAssocRequest(
106 IN PSMgmtObject pMgmt
,
108 IN WORD wCurrCapInfo
,
109 IN WORD wListenInterval
,
110 IN PWLAN_IE_SSID pCurrSSID
,
111 IN PWLAN_IE_SUPP_RATES pCurrRates
,
112 IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates
117 s_vMgrRxAssocRequest(
119 IN PSMgmtObject pMgmt
,
120 IN PSRxMgmtPacket pRxPacket
,
126 s_MgrMakeReAssocRequest(
128 IN PSMgmtObject pMgmt
,
130 IN WORD wCurrCapInfo
,
131 IN WORD wListenInterval
,
132 IN PWLAN_IE_SSID pCurrSSID
,
133 IN PWLAN_IE_SUPP_RATES pCurrRates
,
134 IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates
139 s_vMgrRxAssocResponse(
141 IN PSMgmtObject pMgmt
,
142 IN PSRxMgmtPacket pRxPacket
,
148 s_vMgrRxDisassociation(
150 IN PSMgmtObject pMgmt
,
151 IN PSRxMgmtPacket pRxPacket
154 // Authentication/deauthen functions
157 s_vMgrRxAuthenSequence_1(
159 IN PSMgmtObject pMgmt
,
160 IN PWLAN_FR_AUTHEN pFrame
165 s_vMgrRxAuthenSequence_2(
167 IN PSMgmtObject pMgmt
,
168 IN PWLAN_FR_AUTHEN pFrame
173 s_vMgrRxAuthenSequence_3(
175 IN PSMgmtObject pMgmt
,
176 IN PWLAN_FR_AUTHEN pFrame
181 s_vMgrRxAuthenSequence_4(
183 IN PSMgmtObject pMgmt
,
184 IN PWLAN_FR_AUTHEN pFrame
189 s_vMgrRxAuthentication(
191 IN PSMgmtObject pMgmt
,
192 IN PSRxMgmtPacket pRxPacket
197 s_vMgrRxDeauthentication(
199 IN PSMgmtObject pMgmt
,
200 IN PSRxMgmtPacket pRxPacket
204 // probe request/response functions
207 s_vMgrRxProbeRequest(
209 IN PSMgmtObject pMgmt
,
210 IN PSRxMgmtPacket pRxPacket
215 s_vMgrRxProbeResponse(
217 IN PSMgmtObject pMgmt
,
218 IN PSRxMgmtPacket pRxPacket
226 IN PSMgmtObject pMgmt
,
227 IN PSRxMgmtPacket pRxPacket
,
234 IN PSMgmtObject pMgmt
,
242 IN PSMgmtObject pMgmt
,
243 IN WORD wCurrCapInfo
,
244 IN WORD wCurrBeaconPeriod
,
245 IN UINT uCurrChannel
,
246 IN WORD wCurrATIMWinodw
,
247 IN PWLAN_IE_SSID pCurrSSID
,
249 IN PWLAN_IE_SUPP_RATES pCurrSuppRates
,
250 IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates
254 // Association response
257 s_MgrMakeAssocResponse(
259 IN PSMgmtObject pMgmt
,
260 IN WORD wCurrCapInfo
,
261 IN WORD wAssocStatus
,
264 IN PWLAN_IE_SUPP_RATES pCurrSuppRates
,
265 IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates
268 // ReAssociation response
271 s_MgrMakeReAssocResponse(
273 IN PSMgmtObject pMgmt
,
274 IN WORD wCurrCapInfo
,
275 IN WORD wAssocStatus
,
278 IN PWLAN_IE_SUPP_RATES pCurrSuppRates
,
279 IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates
285 s_MgrMakeProbeResponse(
287 IN PSMgmtObject pMgmt
,
288 IN WORD wCurrCapInfo
,
289 IN WORD wCurrBeaconPeriod
,
290 IN UINT uCurrChannel
,
291 IN WORD wCurrATIMWinodw
,
293 IN PWLAN_IE_SSID pCurrSSID
,
295 IN PWLAN_IE_SUPP_RATES pCurrSuppRates
,
296 IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates
,
304 IN PSMgmtObject pMgmt
,
315 OUT PCMD_STATUS pStatus
321 IN PKnownBSS pBSSNode
,
322 IN NDIS_802_11_ENCRYPTION_STATUS EncStatus
,
327 static VOID
Encyption_Rebuild(
334 /*--------------------- Export Variables --------------------------*/
337 /*--------------------- Export Functions --------------------------*/
342 * Routine Description:
343 * Allocates and initializes the Management object.
352 IN HANDLE hDeviceContext
355 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
356 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
360 pMgmt
->pbyPSPacketPool
= &pMgmt
->byPSPacketPool
[0];
361 pMgmt
->pbyMgmtPacketPool
= &pMgmt
->byMgmtPacketPool
[0];
362 pMgmt
->uCurrChannel
= pDevice
->uChannel
;
363 for(ii
=0;ii
<WLAN_BSSID_LEN
;ii
++) {
364 pMgmt
->abyDesireBSSID
[ii
] = 0xFF;
366 pMgmt
->sAssocInfo
.AssocInfo
.Length
= sizeof(NDIS_802_11_ASSOCIATION_INFORMATION
);
367 //memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN +1);
368 pMgmt
->byCSSPK
= KEY_CTL_NONE
;
369 pMgmt
->byCSSGK
= KEY_CTL_NONE
;
370 pMgmt
->wIBSSBeaconPeriod
= DEFAULT_IBSS_BI
;
371 BSSvClearBSSList((HANDLE
)pDevice
, FALSE
);
373 init_timer(&pMgmt
->sTimerSecondCallback
);
374 pMgmt
->sTimerSecondCallback
.data
= (ULONG
)pDevice
;
375 pMgmt
->sTimerSecondCallback
.function
= (TimerFunction
)BSSvSecondCallBack
;
376 pMgmt
->sTimerSecondCallback
.expires
= RUN_AT(HZ
);
378 init_timer(&pDevice
->sTimerCommand
);
379 pDevice
->sTimerCommand
.data
= (ULONG
)pDevice
;
380 pDevice
->sTimerCommand
.function
= (TimerFunction
)vRunCommand
;
381 pDevice
->sTimerCommand
.expires
= RUN_AT(HZ
);
383 //2007-0115-10<Add>by MikeLiu
385 init_timer(&pDevice
->sTimerTxData
);
386 pDevice
->sTimerTxData
.data
= (ULONG
)pDevice
;
387 pDevice
->sTimerTxData
.function
= (TimerFunction
)BSSvSecondTxData
;
388 pDevice
->sTimerTxData
.expires
= RUN_AT(10*HZ
); //10s callback
389 pDevice
->fTxDataInSleep
= FALSE
;
390 pDevice
->IsTxDataTrigger
= FALSE
;
391 pDevice
->nTxDataTimeCout
= 0;
394 pDevice
->cbFreeCmdQueue
= CMD_Q_SIZE
;
395 pDevice
->uCmdDequeueIdx
= 0;
396 pDevice
->uCmdEnqueueIdx
= 0;
397 pDevice
->eCommandState
= WLAN_CMD_IDLE
;
398 pDevice
->bCmdRunning
= FALSE
;
399 pDevice
->bCmdClear
= FALSE
;
408 * Routine Description:
409 * Start the station association procedure. Namely, send an
410 * association request frame to the AP.
420 IN HANDLE hDeviceContext
,
421 IN PSMgmtObject pMgmt
,
422 OUT PCMD_STATUS pStatus
425 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
426 PSTxMgmtPacket pTxPacket
;
429 pMgmt
->wCurrCapInfo
= 0;
430 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_ESS(1);
431 if (pDevice
->bEncryptionEnable
) {
432 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_PRIVACY(1);
434 // always allow receive short preamble
435 //if (pDevice->byPreambleType == 1) {
436 // pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
438 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
439 if (pMgmt
->wListenInterval
== 0)
440 pMgmt
->wListenInterval
= 1; // at least one.
442 // ERP Phy (802.11g) should support short preamble.
443 if (pMgmt
->eCurrentPHYMode
== PHY_TYPE_11G
) {
444 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
445 if (pDevice
->bShortSlotTime
== TRUE
)
446 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTSLOTTIME(1);
448 } else if (pMgmt
->eCurrentPHYMode
== PHY_TYPE_11B
) {
449 if (pDevice
->byPreambleType
== 1) {
450 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
453 if (pMgmt
->b11hEnable
== TRUE
)
454 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SPECTRUMMNG(1);
456 // build an assocreq frame and send it
457 pTxPacket
= s_MgrMakeAssocRequest
463 pMgmt
->wListenInterval
,
464 (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
,
465 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
466 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
469 if (pTxPacket
!= NULL
){
471 *pStatus
= csMgmt_xmit(pDevice
, pTxPacket
);
472 if (*pStatus
== CMD_STATUS_PENDING
) {
473 pMgmt
->eCurrState
= WMAC_STATE_ASSOCPENDING
;
474 *pStatus
= CMD_STATUS_SUCCESS
;
478 *pStatus
= CMD_STATUS_RESOURCES
;
486 * Routine Description:
487 * Start the station re-association procedure.
496 IN HANDLE hDeviceContext
,
497 IN PSMgmtObject pMgmt
,
498 OUT PCMD_STATUS pStatus
501 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
502 PSTxMgmtPacket pTxPacket
;
506 pMgmt
->wCurrCapInfo
= 0;
507 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_ESS(1);
508 if (pDevice
->bEncryptionEnable
) {
509 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_PRIVACY(1);
512 //if (pDevice->byPreambleType == 1) {
513 // pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
515 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
517 if (pMgmt
->wListenInterval
== 0)
518 pMgmt
->wListenInterval
= 1; // at least one.
521 // ERP Phy (802.11g) should support short preamble.
522 if (pMgmt
->eCurrentPHYMode
== PHY_TYPE_11G
) {
523 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
524 if (pDevice
->bShortSlotTime
== TRUE
)
525 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTSLOTTIME(1);
527 } else if (pMgmt
->eCurrentPHYMode
== PHY_TYPE_11B
) {
528 if (pDevice
->byPreambleType
== 1) {
529 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
532 if (pMgmt
->b11hEnable
== TRUE
)
533 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SPECTRUMMNG(1);
536 pTxPacket
= s_MgrMakeReAssocRequest
542 pMgmt
->wListenInterval
,
543 (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
,
544 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
545 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
548 if (pTxPacket
!= NULL
){
550 *pStatus
= csMgmt_xmit(pDevice
, pTxPacket
);
551 if (*pStatus
!= CMD_STATUS_PENDING
) {
552 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Reassociation tx failed.\n");
555 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Reassociation tx sending.\n");
565 * Routine Description:
566 * Send an dis-association request frame to the AP.
574 vMgrDisassocBeginSta(
575 IN HANDLE hDeviceContext
,
576 IN PSMgmtObject pMgmt
,
577 IN PBYTE abyDestAddress
,
579 OUT PCMD_STATUS pStatus
582 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
583 PSTxMgmtPacket pTxPacket
= NULL
;
584 WLAN_FR_DISASSOC sFrame
;
586 pTxPacket
= (PSTxMgmtPacket
)pMgmt
->pbyMgmtPacketPool
;
587 memset(pTxPacket
, 0, sizeof(STxMgmtPacket
) + WLAN_DISASSOC_FR_MAXLEN
);
588 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((PBYTE
)pTxPacket
+ sizeof(STxMgmtPacket
));
590 // Setup the sFrame structure
591 sFrame
.pBuf
= (PBYTE
)pTxPacket
->p80211Header
;
592 sFrame
.len
= WLAN_DISASSOC_FR_MAXLEN
;
594 // format fixed field frame structure
595 vMgrEncodeDisassociation(&sFrame
);
598 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
600 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
601 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_DISASSOC
)
604 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, abyDestAddress
, WLAN_ADDR_LEN
);
605 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
606 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
609 *(sFrame
.pwReason
) = cpu_to_le16(wReason
);
610 pTxPacket
->cbMPDULen
= sFrame
.len
;
611 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
614 *pStatus
= csMgmt_xmit(pDevice
, pTxPacket
);
615 if (*pStatus
== CMD_STATUS_PENDING
) {
616 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
617 *pStatus
= CMD_STATUS_SUCCESS
;
627 * Routine Description:(AP function)
628 * Handle incoming station association request frames.
637 s_vMgrRxAssocRequest(
639 IN PSMgmtObject pMgmt
,
640 IN PSRxMgmtPacket pRxPacket
,
644 WLAN_FR_ASSOCREQ sFrame
;
646 PSTxMgmtPacket pTxPacket
;
647 WORD wAssocStatus
= 0;
649 UINT uRateLen
= WLAN_RATES_MAXLEN
;
650 BYTE abyCurrSuppRates
[WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1];
651 BYTE abyCurrExtSuppRates
[WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1];
654 if (pMgmt
->eCurrMode
!= WMAC_MODE_ESS_AP
)
656 // node index not found
660 //check if node is authenticated
662 memset(&sFrame
, 0, sizeof(WLAN_FR_ASSOCREQ
));
663 memset(abyCurrSuppRates
, 0, WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1);
664 memset(abyCurrExtSuppRates
, 0, WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1);
665 sFrame
.len
= pRxPacket
->cbMPDULen
;
666 sFrame
.pBuf
= (PBYTE
)pRxPacket
->p80211Header
;
668 vMgrDecodeAssocRequest(&sFrame
);
670 if (pMgmt
->sNodeDBTable
[uNodeIndex
].eNodeState
>= NODE_AUTH
) {
671 pMgmt
->sNodeDBTable
[uNodeIndex
].eNodeState
= NODE_ASSOC
;
672 pMgmt
->sNodeDBTable
[uNodeIndex
].wCapInfo
= cpu_to_le16(*sFrame
.pwCapInfo
);
673 pMgmt
->sNodeDBTable
[uNodeIndex
].wListenInterval
= cpu_to_le16(*sFrame
.pwListenInterval
);
674 pMgmt
->sNodeDBTable
[uNodeIndex
].bPSEnable
=
675 WLAN_GET_FC_PWRMGT(sFrame
.pHdr
->sA3
.wFrameCtl
) ? TRUE
: FALSE
;
676 // Todo: check sta basic rate, if ap can't support, set status code
677 if (pDevice
->byBBType
== BB_TYPE_11B
) {
678 uRateLen
= WLAN_RATES_MAXLEN_11B
;
680 abyCurrSuppRates
[0] = WLAN_EID_SUPP_RATES
;
681 abyCurrSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)sFrame
.pSuppRates
,
682 (PWLAN_IE_SUPP_RATES
)abyCurrSuppRates
,
684 abyCurrExtSuppRates
[0] = WLAN_EID_EXTSUPP_RATES
;
685 if (pDevice
->byBBType
== BB_TYPE_11G
) {
686 abyCurrExtSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)sFrame
.pExtSuppRates
,
687 (PWLAN_IE_SUPP_RATES
)abyCurrExtSuppRates
,
690 abyCurrExtSuppRates
[1] = 0;
694 RATEvParseMaxRate((PVOID
)pDevice
,
695 (PWLAN_IE_SUPP_RATES
)abyCurrSuppRates
,
696 (PWLAN_IE_SUPP_RATES
)abyCurrExtSuppRates
,
697 FALSE
, // do not change our basic rate
698 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxBasicRate
),
699 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
),
700 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wSuppRate
),
701 &(pMgmt
->sNodeDBTable
[uNodeIndex
].byTopCCKBasicRate
),
702 &(pMgmt
->sNodeDBTable
[uNodeIndex
].byTopOFDMBasicRate
)
706 pMgmt
->sNodeDBTable
[uNodeIndex
].wTxDataRate
=
707 pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
;
708 // Todo: check sta preamble, if ap can't support, set status code
709 pMgmt
->sNodeDBTable
[uNodeIndex
].bShortPreamble
=
710 WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame
.pwCapInfo
);
711 pMgmt
->sNodeDBTable
[uNodeIndex
].bShortSlotTime
=
712 WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame
.pwCapInfo
);
713 pMgmt
->sNodeDBTable
[uNodeIndex
].wAID
= (WORD
)uNodeIndex
;
714 wAssocStatus
= WLAN_MGMT_STATUS_SUCCESS
;
715 wAssocAID
= (WORD
)uNodeIndex
;
716 // check if ERP support
717 if(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
> RATE_11M
)
718 pMgmt
->sNodeDBTable
[uNodeIndex
].bERPExist
= TRUE
;
720 if (pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
<= RATE_11M
) {
722 pDevice
->bProtectMode
= TRUE
;
723 pDevice
->bNonERPPresent
= TRUE
;
725 if (pMgmt
->sNodeDBTable
[uNodeIndex
].bShortPreamble
== FALSE
) {
726 pDevice
->bBarkerPreambleMd
= TRUE
;
729 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"Associate AID= %d \n", wAssocAID
);
730 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"MAC=%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X \n",
731 sFrame
.pHdr
->sA3
.abyAddr2
[0],
732 sFrame
.pHdr
->sA3
.abyAddr2
[1],
733 sFrame
.pHdr
->sA3
.abyAddr2
[2],
734 sFrame
.pHdr
->sA3
.abyAddr2
[3],
735 sFrame
.pHdr
->sA3
.abyAddr2
[4],
736 sFrame
.pHdr
->sA3
.abyAddr2
[5]
738 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"Max Support rate = %d \n",
739 pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
);
743 // assoc response reply..
744 pTxPacket
= s_MgrMakeAssocResponse
751 sFrame
.pHdr
->sA3
.abyAddr2
,
752 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
753 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
755 if (pTxPacket
!= NULL
){
757 if (pDevice
->bEnableHostapd
) {
761 Status
= csMgmt_xmit(pDevice
, pTxPacket
);
762 if (Status
!= CMD_STATUS_PENDING
) {
763 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Assoc response tx failed\n");
766 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Assoc response tx sending..\n");
777 * Description:(AP function)
778 * Handle incoming station re-association request frames.
782 * pMgmt - Management Object structure
783 * pRxPacket - Received Packet
787 * Return Value: None.
793 s_vMgrRxReAssocRequest(
795 IN PSMgmtObject pMgmt
,
796 IN PSRxMgmtPacket pRxPacket
,
800 WLAN_FR_REASSOCREQ sFrame
;
802 PSTxMgmtPacket pTxPacket
;
803 WORD wAssocStatus
= 0;
805 UINT uRateLen
= WLAN_RATES_MAXLEN
;
806 BYTE abyCurrSuppRates
[WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1];
807 BYTE abyCurrExtSuppRates
[WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1];
809 if (pMgmt
->eCurrMode
!= WMAC_MODE_ESS_AP
)
811 // node index not found
814 //check if node is authenticated
816 memset(&sFrame
, 0, sizeof(WLAN_FR_REASSOCREQ
));
817 sFrame
.len
= pRxPacket
->cbMPDULen
;
818 sFrame
.pBuf
= (PBYTE
)pRxPacket
->p80211Header
;
819 vMgrDecodeReassocRequest(&sFrame
);
821 if (pMgmt
->sNodeDBTable
[uNodeIndex
].eNodeState
>= NODE_AUTH
) {
822 pMgmt
->sNodeDBTable
[uNodeIndex
].eNodeState
= NODE_ASSOC
;
823 pMgmt
->sNodeDBTable
[uNodeIndex
].wCapInfo
= cpu_to_le16(*sFrame
.pwCapInfo
);
824 pMgmt
->sNodeDBTable
[uNodeIndex
].wListenInterval
= cpu_to_le16(*sFrame
.pwListenInterval
);
825 pMgmt
->sNodeDBTable
[uNodeIndex
].bPSEnable
=
826 WLAN_GET_FC_PWRMGT(sFrame
.pHdr
->sA3
.wFrameCtl
) ? TRUE
: FALSE
;
827 // Todo: check sta basic rate, if ap can't support, set status code
829 if (pDevice
->byBBType
== BB_TYPE_11B
) {
830 uRateLen
= WLAN_RATES_MAXLEN_11B
;
833 abyCurrSuppRates
[0] = WLAN_EID_SUPP_RATES
;
834 abyCurrSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)sFrame
.pSuppRates
,
835 (PWLAN_IE_SUPP_RATES
)abyCurrSuppRates
,
837 abyCurrExtSuppRates
[0] = WLAN_EID_EXTSUPP_RATES
;
838 if (pDevice
->byBBType
== BB_TYPE_11G
) {
839 abyCurrExtSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)sFrame
.pExtSuppRates
,
840 (PWLAN_IE_SUPP_RATES
)abyCurrExtSuppRates
,
843 abyCurrExtSuppRates
[1] = 0;
847 RATEvParseMaxRate((PVOID
)pDevice
,
848 (PWLAN_IE_SUPP_RATES
)abyCurrSuppRates
,
849 (PWLAN_IE_SUPP_RATES
)abyCurrExtSuppRates
,
850 FALSE
, // do not change our basic rate
851 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxBasicRate
),
852 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
),
853 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wSuppRate
),
854 &(pMgmt
->sNodeDBTable
[uNodeIndex
].byTopCCKBasicRate
),
855 &(pMgmt
->sNodeDBTable
[uNodeIndex
].byTopOFDMBasicRate
)
859 pMgmt
->sNodeDBTable
[uNodeIndex
].wTxDataRate
=
860 pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
;
861 // Todo: check sta preamble, if ap can't support, set status code
862 pMgmt
->sNodeDBTable
[uNodeIndex
].bShortPreamble
=
863 WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame
.pwCapInfo
);
864 pMgmt
->sNodeDBTable
[uNodeIndex
].bShortSlotTime
=
865 WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame
.pwCapInfo
);
866 pMgmt
->sNodeDBTable
[uNodeIndex
].wAID
= (WORD
)uNodeIndex
;
867 wAssocStatus
= WLAN_MGMT_STATUS_SUCCESS
;
868 wAssocAID
= (WORD
)uNodeIndex
;
871 if(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
> RATE_11M
)
872 pMgmt
->sNodeDBTable
[uNodeIndex
].bERPExist
= TRUE
;
874 if (pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
<= RATE_11M
) {
876 pDevice
->bProtectMode
= TRUE
;
877 pDevice
->bNonERPPresent
= TRUE
;
879 if (pMgmt
->sNodeDBTable
[uNodeIndex
].bShortPreamble
== FALSE
) {
880 pDevice
->bBarkerPreambleMd
= TRUE
;
883 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"Rx ReAssociate AID= %d \n", wAssocAID
);
884 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"MAC=%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X \n",
885 sFrame
.pHdr
->sA3
.abyAddr2
[0],
886 sFrame
.pHdr
->sA3
.abyAddr2
[1],
887 sFrame
.pHdr
->sA3
.abyAddr2
[2],
888 sFrame
.pHdr
->sA3
.abyAddr2
[3],
889 sFrame
.pHdr
->sA3
.abyAddr2
[4],
890 sFrame
.pHdr
->sA3
.abyAddr2
[5]
892 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"Max Support rate = %d \n",
893 pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
);
898 // assoc response reply..
899 pTxPacket
= s_MgrMakeReAssocResponse
906 sFrame
.pHdr
->sA3
.abyAddr2
,
907 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
908 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
911 if (pTxPacket
!= NULL
){
913 if (pDevice
->bEnableHostapd
) {
916 Status
= csMgmt_xmit(pDevice
, pTxPacket
);
917 if (Status
!= CMD_STATUS_PENDING
) {
918 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:ReAssoc response tx failed\n");
921 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:ReAssoc response tx sending..\n");
930 * Routine Description:
931 * Handle incoming association response frames.
940 s_vMgrRxAssocResponse(
942 IN PSMgmtObject pMgmt
,
943 IN PSRxMgmtPacket pRxPacket
,
947 WLAN_FR_ASSOCRESP sFrame
;
948 PWLAN_IE_SSID pItemSSID
;
950 viawget_wpa_header
*wpahdr
;
954 if (pMgmt
->eCurrState
== WMAC_STATE_ASSOCPENDING
||
955 pMgmt
->eCurrState
== WMAC_STATE_ASSOC
) {
957 sFrame
.len
= pRxPacket
->cbMPDULen
;
958 sFrame
.pBuf
= (PBYTE
)pRxPacket
->p80211Header
;
960 vMgrDecodeAssocResponse(&sFrame
);
961 if ((sFrame
.pwCapInfo
== 0) ||
962 (sFrame
.pwStatus
== 0) ||
963 (sFrame
.pwAid
== 0) ||
964 (sFrame
.pSuppRates
== 0)){
969 pMgmt
->sAssocInfo
.AssocInfo
.ResponseFixedIEs
.Capabilities
= *(sFrame
.pwCapInfo
);
970 pMgmt
->sAssocInfo
.AssocInfo
.ResponseFixedIEs
.StatusCode
= *(sFrame
.pwStatus
);
971 pMgmt
->sAssocInfo
.AssocInfo
.ResponseFixedIEs
.AssociationId
= *(sFrame
.pwAid
);
972 pMgmt
->sAssocInfo
.AssocInfo
.AvailableResponseFixedIEs
|= 0x07;
974 pMgmt
->sAssocInfo
.AssocInfo
.ResponseIELength
= sFrame
.len
- 24 - 6;
975 pMgmt
->sAssocInfo
.AssocInfo
.OffsetResponseIEs
= pMgmt
->sAssocInfo
.AssocInfo
.OffsetRequestIEs
+ pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
;
976 pbyIEs
= pMgmt
->sAssocInfo
.abyIEs
;
977 pbyIEs
+= pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
;
978 memcpy(pbyIEs
, (sFrame
.pBuf
+ 24 +6), pMgmt
->sAssocInfo
.AssocInfo
.ResponseIELength
);
980 // save values and set current BSS state
981 if (cpu_to_le16((*(sFrame
.pwStatus
))) == WLAN_MGMT_STATUS_SUCCESS
){
983 pMgmt
->wCurrAID
= cpu_to_le16((*(sFrame
.pwAid
)));
984 if ( (pMgmt
->wCurrAID
>> 14) != (BIT0
| BIT1
) )
986 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"AID from AP, has two msb clear.\n");
988 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"Association Successful, AID=%d.\n", pMgmt
->wCurrAID
& ~(BIT14
|BIT15
));
989 pMgmt
->eCurrState
= WMAC_STATE_ASSOC
;
990 BSSvUpdateAPNode((HANDLE
)pDevice
, sFrame
.pwCapInfo
, sFrame
.pSuppRates
, sFrame
.pExtSuppRates
);
991 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
;
992 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"Link with AP(SSID): %s\n", pItemSSID
->abySSID
);
993 pDevice
->bLinkPass
= TRUE
;
994 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_INTER
);
995 if ((pDevice
->bWPADEVUp
) && (pDevice
->skb
!= NULL
)) {
996 if(skb_tailroom(pDevice
->skb
) <(sizeof(viawget_wpa_header
)+pMgmt
->sAssocInfo
.AssocInfo
.ResponseIELength
+
997 pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
)) { //data room not enough
998 dev_kfree_skb(pDevice
->skb
);
999 pDevice
->skb
= dev_alloc_skb((int)pDevice
->rx_buf_sz
);
1001 wpahdr
= (viawget_wpa_header
*)pDevice
->skb
->data
;
1002 wpahdr
->type
= VIAWGET_ASSOC_MSG
;
1003 wpahdr
->resp_ie_len
= pMgmt
->sAssocInfo
.AssocInfo
.ResponseIELength
;
1004 wpahdr
->req_ie_len
= pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
;
1005 memcpy(pDevice
->skb
->data
+ sizeof(viawget_wpa_header
), pMgmt
->sAssocInfo
.abyIEs
, wpahdr
->req_ie_len
);
1006 memcpy(pDevice
->skb
->data
+ sizeof(viawget_wpa_header
) + wpahdr
->req_ie_len
,
1010 skb_put(pDevice
->skb
, sizeof(viawget_wpa_header
) + wpahdr
->resp_ie_len
+ wpahdr
->req_ie_len
);
1011 pDevice
->skb
->dev
= pDevice
->wpadev
;
1012 skb_reset_mac_header(pDevice
->skb
);
1013 pDevice
->skb
->pkt_type
= PACKET_HOST
;
1014 pDevice
->skb
->protocol
= htons(ETH_P_802_2
);
1015 memset(pDevice
->skb
->cb
, 0, sizeof(pDevice
->skb
->cb
));
1016 netif_rx(pDevice
->skb
);
1017 pDevice
->skb
= dev_alloc_skb((int)pDevice
->rx_buf_sz
);
1019 //2008-0409-07, <Add> by Einsn Liu
1020 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1021 //if(pDevice->bWPASuppWextEnabled == TRUE)
1025 union iwreq_data wrqu
;
1028 memset(buf
, 0, 512);
1030 len
= pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
;
1032 memcpy(buf
, pMgmt
->sAssocInfo
.abyIEs
, len
);
1033 memset(&wrqu
, 0, sizeof (wrqu
));
1034 wrqu
.data
.length
= len
;
1035 we_event
= IWEVASSOCREQIE
;
1036 PRINT_K("wireless_send_event--->IWEVASSOCREQIE\n");
1037 wireless_send_event(pDevice
->dev
, we_event
, &wrqu
, buf
);
1040 memset(buf
, 0, 512);
1041 len
= pMgmt
->sAssocInfo
.AssocInfo
.ResponseIELength
;
1044 memcpy(buf
, pbyIEs
, len
);
1045 memset(&wrqu
, 0, sizeof (wrqu
));
1046 wrqu
.data
.length
= len
;
1047 we_event
= IWEVASSOCRESPIE
;
1048 PRINT_K("wireless_send_event--->IWEVASSOCRESPIE\n");
1049 wireless_send_event(pDevice
->dev
, we_event
, &wrqu
, buf
);
1052 memset(&wrqu
, 0, sizeof (wrqu
));
1053 memcpy(wrqu
.ap_addr
.sa_data
, &pMgmt
->abyCurrBSSID
[0], ETH_ALEN
);
1054 wrqu
.ap_addr
.sa_family
= ARPHRD_ETHER
;
1055 PRINT_K("wireless_send_event--->SIOCGIWAP(associated)\n");
1056 wireless_send_event(pDevice
->dev
, SIOCGIWAP
, &wrqu
, NULL
);
1059 #endif //#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1060 //End Add -- //2008-0409-07, <Add> by Einsn Liu
1064 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
1067 // jump back to the auth state and indicate the error
1068 pMgmt
->eCurrState
= WMAC_STATE_AUTH
;
1070 s_vMgrLogStatus(pMgmt
,cpu_to_le16((*(sFrame
.pwStatus
))));
1076 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1077 //need clear flags related to Networkmanager
1078 pDevice
->bwextstep0
= FALSE
;
1079 pDevice
->bwextstep1
= FALSE
;
1080 pDevice
->bwextstep2
= FALSE
;
1081 pDevice
->bwextstep3
= FALSE
;
1082 pDevice
->bWPASuppWextEnabled
= FALSE
;
1086 if(pMgmt
->eCurrState
== WMAC_STATE_ASSOC
)
1087 timer_expire(pDevice
->sTimerCommand
, 0);
1096 * Routine Description:
1097 * Start the station authentication procedure. Namely, send an
1098 * authentication frame to the AP.
1107 IN HANDLE hDeviceContext
,
1108 IN PSMgmtObject pMgmt
,
1109 OUT PCMD_STATUS pStatus
1112 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
1113 WLAN_FR_AUTHEN sFrame
;
1114 PSTxMgmtPacket pTxPacket
= NULL
;
1116 pTxPacket
= (PSTxMgmtPacket
)pMgmt
->pbyMgmtPacketPool
;
1117 memset(pTxPacket
, 0, sizeof(STxMgmtPacket
) + WLAN_AUTHEN_FR_MAXLEN
);
1118 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((PBYTE
)pTxPacket
+ sizeof(STxMgmtPacket
));
1119 sFrame
.pBuf
= (PBYTE
)pTxPacket
->p80211Header
;
1120 sFrame
.len
= WLAN_AUTHEN_FR_MAXLEN
;
1121 vMgrEncodeAuthen(&sFrame
);
1123 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
1125 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
1126 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN
)
1128 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pMgmt
->abyCurrBSSID
, WLAN_ADDR_LEN
);
1129 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
1130 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
1131 if (pMgmt
->bShareKeyAlgorithm
)
1132 *(sFrame
.pwAuthAlgorithm
) = cpu_to_le16(WLAN_AUTH_ALG_SHAREDKEY
);
1134 *(sFrame
.pwAuthAlgorithm
) = cpu_to_le16(WLAN_AUTH_ALG_OPENSYSTEM
);
1136 *(sFrame
.pwAuthSequence
) = cpu_to_le16(1);
1137 /* Adjust the length fields */
1138 pTxPacket
->cbMPDULen
= sFrame
.len
;
1139 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
1141 *pStatus
= csMgmt_xmit(pDevice
, pTxPacket
);
1142 if (*pStatus
== CMD_STATUS_PENDING
){
1143 pMgmt
->eCurrState
= WMAC_STATE_AUTHPENDING
;
1144 *pStatus
= CMD_STATUS_SUCCESS
;
1154 * Routine Description:
1155 * Start the station(AP) deauthentication procedure. Namely, send an
1156 * deauthentication frame to the AP or Sta.
1164 vMgrDeAuthenBeginSta(
1165 IN HANDLE hDeviceContext
,
1166 IN PSMgmtObject pMgmt
,
1167 IN PBYTE abyDestAddress
,
1169 OUT PCMD_STATUS pStatus
1172 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
1173 WLAN_FR_DEAUTHEN sFrame
;
1174 PSTxMgmtPacket pTxPacket
= NULL
;
1177 pTxPacket
= (PSTxMgmtPacket
)pMgmt
->pbyMgmtPacketPool
;
1178 memset(pTxPacket
, 0, sizeof(STxMgmtPacket
) + WLAN_DEAUTHEN_FR_MAXLEN
);
1179 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((PBYTE
)pTxPacket
+ sizeof(STxMgmtPacket
));
1180 sFrame
.pBuf
= (PBYTE
)pTxPacket
->p80211Header
;
1181 sFrame
.len
= WLAN_DEAUTHEN_FR_MAXLEN
;
1182 vMgrEncodeDeauthen(&sFrame
);
1184 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
1186 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
1187 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_DEAUTHEN
)
1190 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, abyDestAddress
, WLAN_ADDR_LEN
);
1191 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
1192 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
1194 *(sFrame
.pwReason
) = cpu_to_le16(wReason
); // deauthen. bcs left BSS
1195 /* Adjust the length fields */
1196 pTxPacket
->cbMPDULen
= sFrame
.len
;
1197 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
1199 *pStatus
= csMgmt_xmit(pDevice
, pTxPacket
);
1200 if (*pStatus
== CMD_STATUS_PENDING
){
1201 *pStatus
= CMD_STATUS_SUCCESS
;
1211 * Routine Description:
1212 * Handle incoming authentication frames.
1221 s_vMgrRxAuthentication(
1222 IN PSDevice pDevice
,
1223 IN PSMgmtObject pMgmt
,
1224 IN PSRxMgmtPacket pRxPacket
1227 WLAN_FR_AUTHEN sFrame
;
1229 // we better be an AP or a STA in AUTHPENDING otherwise ignore
1230 if (!(pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
||
1231 pMgmt
->eCurrState
== WMAC_STATE_AUTHPENDING
)) {
1236 sFrame
.len
= pRxPacket
->cbMPDULen
;
1237 sFrame
.pBuf
= (PBYTE
)pRxPacket
->p80211Header
;
1238 vMgrDecodeAuthen(&sFrame
);
1239 switch (cpu_to_le16((*(sFrame
.pwAuthSequence
)))){
1242 s_vMgrRxAuthenSequence_1(pDevice
,pMgmt
, &sFrame
);
1245 s_vMgrRxAuthenSequence_2(pDevice
, pMgmt
, &sFrame
);
1249 s_vMgrRxAuthenSequence_3(pDevice
, pMgmt
, &sFrame
);
1252 s_vMgrRxAuthenSequence_4(pDevice
, pMgmt
, &sFrame
);
1255 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Auth Sequence error, seq = %d\n",
1256 cpu_to_le16((*(sFrame
.pwAuthSequence
))));
1266 * Routine Description:
1267 * Handles incoming authen frames with sequence 1. Currently
1268 * assumes we're an AP. So far, no one appears to use authentication
1279 s_vMgrRxAuthenSequence_1(
1280 IN PSDevice pDevice
,
1281 IN PSMgmtObject pMgmt
,
1282 IN PWLAN_FR_AUTHEN pFrame
1285 PSTxMgmtPacket pTxPacket
= NULL
;
1287 WLAN_FR_AUTHEN sFrame
;
1288 PSKeyItem pTransmitKey
;
1290 // Insert a Node entry
1291 if (!BSSbIsSTAInNodeDB(pDevice
, pFrame
->pHdr
->sA3
.abyAddr2
, &uNodeIndex
)) {
1292 BSSvCreateOneNode((PSDevice
)pDevice
, &uNodeIndex
);
1293 memcpy(pMgmt
->sNodeDBTable
[uNodeIndex
].abyMACAddr
, pFrame
->pHdr
->sA3
.abyAddr2
,
1297 if (pMgmt
->bShareKeyAlgorithm
) {
1298 pMgmt
->sNodeDBTable
[uNodeIndex
].eNodeState
= NODE_KNOWN
;
1299 pMgmt
->sNodeDBTable
[uNodeIndex
].byAuthSequence
= 1;
1302 pMgmt
->sNodeDBTable
[uNodeIndex
].eNodeState
= NODE_AUTH
;
1306 pTxPacket
= (PSTxMgmtPacket
)pMgmt
->pbyMgmtPacketPool
;
1307 memset(pTxPacket
, 0, sizeof(STxMgmtPacket
) + WLAN_AUTHEN_FR_MAXLEN
);
1308 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((PBYTE
)pTxPacket
+ sizeof(STxMgmtPacket
));
1309 sFrame
.pBuf
= (PBYTE
)pTxPacket
->p80211Header
;
1310 sFrame
.len
= WLAN_AUTHEN_FR_MAXLEN
;
1311 // format buffer structure
1312 vMgrEncodeAuthen(&sFrame
);
1314 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
1316 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
1317 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN
)|
1318 WLAN_SET_FC_ISWEP(0)
1320 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pFrame
->pHdr
->sA3
.abyAddr2
, WLAN_ADDR_LEN
);
1321 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
1322 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
1323 *(sFrame
.pwAuthAlgorithm
) = *(pFrame
->pwAuthAlgorithm
);
1324 *(sFrame
.pwAuthSequence
) = cpu_to_le16(2);
1326 if (cpu_to_le16(*(pFrame
->pwAuthAlgorithm
)) == WLAN_AUTH_ALG_SHAREDKEY
) {
1327 if (pMgmt
->bShareKeyAlgorithm
)
1328 *(sFrame
.pwStatus
) = cpu_to_le16(WLAN_MGMT_STATUS_SUCCESS
);
1330 *(sFrame
.pwStatus
) = cpu_to_le16(WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG
);
1333 if (pMgmt
->bShareKeyAlgorithm
)
1334 *(sFrame
.pwStatus
) = cpu_to_le16(WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG
);
1336 *(sFrame
.pwStatus
) = cpu_to_le16(WLAN_MGMT_STATUS_SUCCESS
);
1339 if (pMgmt
->bShareKeyAlgorithm
&&
1340 (cpu_to_le16(*(sFrame
.pwStatus
)) == WLAN_MGMT_STATUS_SUCCESS
)) {
1342 sFrame
.pChallenge
= (PWLAN_IE_CHALLENGE
)(sFrame
.pBuf
+ sFrame
.len
);
1343 sFrame
.len
+= WLAN_CHALLENGE_IE_LEN
;
1344 sFrame
.pChallenge
->byElementID
= WLAN_EID_CHALLENGE
;
1345 sFrame
.pChallenge
->len
= WLAN_CHALLENGE_LEN
;
1346 memset(pMgmt
->abyChallenge
, 0, WLAN_CHALLENGE_LEN
);
1348 if(KeybGetTransmitKey(&(pDevice
->sKey
), pDevice
->abyBroadcastAddr
, GROUP_KEY
, &pTransmitKey
) == TRUE
) {
1349 rc4_init(&pDevice
->SBox
, pDevice
->abyPRNG
, pTransmitKey
->uKeyLength
+3);
1350 rc4_encrypt(&pDevice
->SBox
, pMgmt
->abyChallenge
, pMgmt
->abyChallenge
, WLAN_CHALLENGE_LEN
);
1352 memcpy(sFrame
.pChallenge
->abyChallenge
, pMgmt
->abyChallenge
, WLAN_CHALLENGE_LEN
);
1355 /* Adjust the length fields */
1356 pTxPacket
->cbMPDULen
= sFrame
.len
;
1357 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
1359 if (pDevice
->bEnableHostapd
) {
1362 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Authreq_reply sequence_1 tx.. \n");
1363 if (csMgmt_xmit(pDevice
, pTxPacket
) != CMD_STATUS_PENDING
) {
1364 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Authreq_reply sequence_1 tx failed.\n");
1373 * Routine Description:
1374 * Handles incoming auth frames with sequence number 2. Currently
1375 * assumes we're a station.
1385 s_vMgrRxAuthenSequence_2(
1386 IN PSDevice pDevice
,
1387 IN PSMgmtObject pMgmt
,
1388 IN PWLAN_FR_AUTHEN pFrame
1391 WLAN_FR_AUTHEN sFrame
;
1392 PSTxMgmtPacket pTxPacket
= NULL
;
1395 switch (cpu_to_le16((*(pFrame
->pwAuthAlgorithm
))))
1397 case WLAN_AUTH_ALG_OPENSYSTEM
:
1398 if ( cpu_to_le16((*(pFrame
->pwStatus
))) == WLAN_MGMT_STATUS_SUCCESS
){
1399 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"802.11 Authen (OPEN) Successful.\n");
1400 pMgmt
->eCurrState
= WMAC_STATE_AUTH
;
1401 timer_expire(pDevice
->sTimerCommand
, 0);
1404 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"802.11 Authen (OPEN) Failed.\n");
1405 s_vMgrLogStatus(pMgmt
, cpu_to_le16((*(pFrame
->pwStatus
))));
1406 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
1408 if (pDevice
->eCommandState
== WLAN_AUTHENTICATE_WAIT
) {
1409 // spin_unlock_irq(&pDevice->lock);
1410 // vCommandTimerWait((HANDLE)pDevice, 0);
1411 // spin_lock_irq(&pDevice->lock);
1416 case WLAN_AUTH_ALG_SHAREDKEY
:
1418 if (cpu_to_le16((*(pFrame
->pwStatus
))) == WLAN_MGMT_STATUS_SUCCESS
) {
1419 pTxPacket
= (PSTxMgmtPacket
)pMgmt
->pbyMgmtPacketPool
;
1420 memset(pTxPacket
, 0, sizeof(STxMgmtPacket
) + WLAN_AUTHEN_FR_MAXLEN
);
1421 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((PBYTE
)pTxPacket
+ sizeof(STxMgmtPacket
));
1422 sFrame
.pBuf
= (PBYTE
)pTxPacket
->p80211Header
;
1423 sFrame
.len
= WLAN_AUTHEN_FR_MAXLEN
;
1424 // format buffer structure
1425 vMgrEncodeAuthen(&sFrame
);
1427 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
1429 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
1430 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN
)|
1431 WLAN_SET_FC_ISWEP(1)
1433 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
1434 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
1435 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
1436 *(sFrame
.pwAuthAlgorithm
) = *(pFrame
->pwAuthAlgorithm
);
1437 *(sFrame
.pwAuthSequence
) = cpu_to_le16(3);
1438 *(sFrame
.pwStatus
) = cpu_to_le16(WLAN_MGMT_STATUS_SUCCESS
);
1439 sFrame
.pChallenge
= (PWLAN_IE_CHALLENGE
)(sFrame
.pBuf
+ sFrame
.len
);
1440 sFrame
.len
+= WLAN_CHALLENGE_IE_LEN
;
1441 sFrame
.pChallenge
->byElementID
= WLAN_EID_CHALLENGE
;
1442 sFrame
.pChallenge
->len
= WLAN_CHALLENGE_LEN
;
1443 memcpy( sFrame
.pChallenge
->abyChallenge
, pFrame
->pChallenge
->abyChallenge
, WLAN_CHALLENGE_LEN
);
1444 // Adjust the length fields
1445 pTxPacket
->cbMPDULen
= sFrame
.len
;
1446 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
1448 if (csMgmt_xmit(pDevice
, pTxPacket
) != CMD_STATUS_PENDING
) {
1449 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Auth_reply sequence_2 tx failed.\n");
1451 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Auth_reply sequence_2 tx ...\n");
1454 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:rx Auth_reply sequence_2 status error ...\n");
1455 if ( pDevice
->eCommandState
== WLAN_AUTHENTICATE_WAIT
) {
1456 // spin_unlock_irq(&pDevice->lock);
1457 // vCommandTimerWait((HANDLE)pDevice, 0);
1458 // spin_lock_irq(&pDevice->lock);
1460 s_vMgrLogStatus(pMgmt
, cpu_to_le16((*(pFrame
->pwStatus
))));
1464 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt: rx auth.seq = 2 unknown AuthAlgorithm=%d\n", cpu_to_le16((*(pFrame
->pwAuthAlgorithm
))));
1474 * Routine Description:
1475 * Handles incoming authen frames with sequence 3. Currently
1476 * assumes we're an AP. This function assumes the frame has
1477 * already been successfully decrypted.
1487 s_vMgrRxAuthenSequence_3(
1488 IN PSDevice pDevice
,
1489 IN PSMgmtObject pMgmt
,
1490 IN PWLAN_FR_AUTHEN pFrame
1493 PSTxMgmtPacket pTxPacket
= NULL
;
1494 UINT uStatusCode
= 0 ;
1495 UINT uNodeIndex
= 0;
1496 WLAN_FR_AUTHEN sFrame
;
1498 if (!WLAN_GET_FC_ISWEP(pFrame
->pHdr
->sA3
.wFrameCtl
)) {
1499 uStatusCode
= WLAN_MGMT_STATUS_CHALLENGE_FAIL
;
1502 if (BSSbIsSTAInNodeDB(pDevice
, pFrame
->pHdr
->sA3
.abyAddr2
, &uNodeIndex
)) {
1503 if (pMgmt
->sNodeDBTable
[uNodeIndex
].byAuthSequence
!= 1) {
1504 uStatusCode
= WLAN_MGMT_STATUS_RX_AUTH_NOSEQ
;
1507 if (memcmp(pMgmt
->abyChallenge
, pFrame
->pChallenge
->abyChallenge
, WLAN_CHALLENGE_LEN
) != 0) {
1508 uStatusCode
= WLAN_MGMT_STATUS_CHALLENGE_FAIL
;
1513 uStatusCode
= WLAN_MGMT_STATUS_UNSPEC_FAILURE
;
1518 pMgmt
->sNodeDBTable
[uNodeIndex
].eNodeState
= NODE_AUTH
;
1519 pMgmt
->sNodeDBTable
[uNodeIndex
].byAuthSequence
= 0;
1521 uStatusCode
= WLAN_MGMT_STATUS_SUCCESS
;
1522 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Challenge text check ok..\n");
1526 pTxPacket
= (PSTxMgmtPacket
)pMgmt
->pbyMgmtPacketPool
;
1527 memset(pTxPacket
, 0, sizeof(STxMgmtPacket
) + WLAN_AUTHEN_FR_MAXLEN
);
1528 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((PBYTE
)pTxPacket
+ sizeof(STxMgmtPacket
));
1529 sFrame
.pBuf
= (PBYTE
)pTxPacket
->p80211Header
;
1530 sFrame
.len
= WLAN_AUTHEN_FR_MAXLEN
;
1531 // format buffer structure
1532 vMgrEncodeAuthen(&sFrame
);
1534 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
1536 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
1537 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN
)|
1538 WLAN_SET_FC_ISWEP(0)
1540 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pFrame
->pHdr
->sA3
.abyAddr2
, WLAN_ADDR_LEN
);
1541 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
1542 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
1543 *(sFrame
.pwAuthAlgorithm
) = *(pFrame
->pwAuthAlgorithm
);
1544 *(sFrame
.pwAuthSequence
) = cpu_to_le16(4);
1545 *(sFrame
.pwStatus
) = cpu_to_le16(uStatusCode
);
1547 /* Adjust the length fields */
1548 pTxPacket
->cbMPDULen
= sFrame
.len
;
1549 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
1551 if (pDevice
->bEnableHostapd
) {
1554 if (csMgmt_xmit(pDevice
, pTxPacket
) != CMD_STATUS_PENDING
) {
1555 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Authreq_reply sequence_4 tx failed.\n");
1565 * Routine Description:
1566 * Handles incoming authen frames with sequence 4
1575 s_vMgrRxAuthenSequence_4(
1576 IN PSDevice pDevice
,
1577 IN PSMgmtObject pMgmt
,
1578 IN PWLAN_FR_AUTHEN pFrame
1582 if ( cpu_to_le16((*(pFrame
->pwStatus
))) == WLAN_MGMT_STATUS_SUCCESS
){
1583 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"802.11 Authen (SHAREDKEY) Successful.\n");
1584 pMgmt
->eCurrState
= WMAC_STATE_AUTH
;
1585 timer_expire(pDevice
->sTimerCommand
, 0);
1588 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"802.11 Authen (SHAREDKEY) Failed.\n");
1589 s_vMgrLogStatus(pMgmt
, cpu_to_le16((*(pFrame
->pwStatus
))) );
1590 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
1593 if ( pDevice
->eCommandState
== WLAN_AUTHENTICATE_WAIT
) {
1594 // spin_unlock_irq(&pDevice->lock);
1595 // vCommandTimerWait((HANDLE)pDevice, 0);
1596 // spin_lock_irq(&pDevice->lock);
1603 * Routine Description:
1604 * Handles incoming disassociation frames
1614 s_vMgrRxDisassociation(
1615 IN PSDevice pDevice
,
1616 IN PSMgmtObject pMgmt
,
1617 IN PSRxMgmtPacket pRxPacket
1620 WLAN_FR_DISASSOC sFrame
;
1621 UINT uNodeIndex
= 0;
1622 CMD_STATUS CmdStatus
;
1623 viawget_wpa_header
*wpahdr
;
1625 if ( pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
){
1626 // if is acting an AP..
1627 // a STA is leaving this BSS..
1628 sFrame
.len
= pRxPacket
->cbMPDULen
;
1629 sFrame
.pBuf
= (PBYTE
)pRxPacket
->p80211Header
;
1630 if (BSSbIsSTAInNodeDB(pDevice
, pRxPacket
->p80211Header
->sA3
.abyAddr2
, &uNodeIndex
)) {
1631 BSSvRemoveOneNode(pDevice
, uNodeIndex
);
1634 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Rx disassoc, sta not found\n");
1637 else if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_STA
){
1638 sFrame
.len
= pRxPacket
->cbMPDULen
;
1639 sFrame
.pBuf
= (PBYTE
)pRxPacket
->p80211Header
;
1640 vMgrDecodeDisassociation(&sFrame
);
1641 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"AP disassociated me, reason=%d.\n", cpu_to_le16(*(sFrame
.pwReason
)));
1643 pDevice
->fWPA_Authened
= FALSE
;
1644 if ((pDevice
->bWPADEVUp
) && (pDevice
->skb
!= NULL
)) {
1645 wpahdr
= (viawget_wpa_header
*)pDevice
->skb
->data
;
1646 wpahdr
->type
= VIAWGET_DISASSOC_MSG
;
1647 wpahdr
->resp_ie_len
= 0;
1648 wpahdr
->req_ie_len
= 0;
1649 skb_put(pDevice
->skb
, sizeof(viawget_wpa_header
));
1650 pDevice
->skb
->dev
= pDevice
->wpadev
;
1651 skb_reset_mac_header(pDevice
->skb
);
1652 pDevice
->skb
->pkt_type
= PACKET_HOST
;
1653 pDevice
->skb
->protocol
= htons(ETH_P_802_2
);
1654 memset(pDevice
->skb
->cb
, 0, sizeof(pDevice
->skb
->cb
));
1655 netif_rx(pDevice
->skb
);
1656 pDevice
->skb
= dev_alloc_skb((int)pDevice
->rx_buf_sz
);
1659 //TODO: do something let upper layer know or
1660 //try to send associate packet again because of inactivity timeout
1661 if (pMgmt
->eCurrState
== WMAC_STATE_ASSOC
) {
1662 pDevice
->bLinkPass
= FALSE
;
1663 pMgmt
->sNodeDBTable
[0].bActive
= FALSE
;
1664 pDevice
->byReAssocCount
= 0;
1665 pMgmt
->eCurrState
= WMAC_STATE_AUTH
; // jump back to the auth state!
1666 pDevice
->eCommandState
= WLAN_ASSOCIATE_WAIT
;
1667 vMgrReAssocBeginSta((PSDevice
)pDevice
, pMgmt
, &CmdStatus
);
1668 if(CmdStatus
== CMD_STATUS_PENDING
) {
1669 pDevice
->byReAssocCount
++;
1670 return; //mike add: you'll retry for many times, so it cann't be regarded as disconnected!
1674 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1675 // if(pDevice->bWPASuppWextEnabled == TRUE)
1677 union iwreq_data wrqu
;
1678 memset(&wrqu
, 0, sizeof (wrqu
));
1679 wrqu
.ap_addr
.sa_family
= ARPHRD_ETHER
;
1680 PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated)\n");
1681 wireless_send_event(pDevice
->dev
, SIOCGIWAP
, &wrqu
, NULL
);
1685 /* else, ignore it */
1693 * Routine Description:
1694 * Handles incoming deauthentication frames
1704 s_vMgrRxDeauthentication(
1705 IN PSDevice pDevice
,
1706 IN PSMgmtObject pMgmt
,
1707 IN PSRxMgmtPacket pRxPacket
1710 WLAN_FR_DEAUTHEN sFrame
;
1711 UINT uNodeIndex
= 0;
1712 viawget_wpa_header
*wpahdr
;
1715 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
){
1717 // if is acting an AP..
1718 // a STA is leaving this BSS..
1719 sFrame
.len
= pRxPacket
->cbMPDULen
;
1720 sFrame
.pBuf
= (PBYTE
)pRxPacket
->p80211Header
;
1721 if (BSSbIsSTAInNodeDB(pDevice
, pRxPacket
->p80211Header
->sA3
.abyAddr2
, &uNodeIndex
)) {
1722 BSSvRemoveOneNode(pDevice
, uNodeIndex
);
1725 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Rx deauth, sta not found\n");
1729 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_STA
) {
1730 sFrame
.len
= pRxPacket
->cbMPDULen
;
1731 sFrame
.pBuf
= (PBYTE
)pRxPacket
->p80211Header
;
1732 vMgrDecodeDeauthen(&sFrame
);
1733 pDevice
->fWPA_Authened
= FALSE
;
1734 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"AP deauthed me, reason=%d.\n", cpu_to_le16((*(sFrame
.pwReason
))));
1735 // TODO: update BSS list for specific BSSID if pre-authentication case
1736 if (IS_ETH_ADDRESS_EQUAL(sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
)) {
1737 if (pMgmt
->eCurrState
>= WMAC_STATE_AUTHPENDING
) {
1738 pMgmt
->sNodeDBTable
[0].bActive
= FALSE
;
1739 pMgmt
->eCurrMode
= WMAC_MODE_STANDBY
;
1740 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
1741 netif_stop_queue(pDevice
->dev
);
1742 pDevice
->bLinkPass
= FALSE
;
1743 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_SLOW
);
1747 if ((pDevice
->bWPADEVUp
) && (pDevice
->skb
!= NULL
)) {
1748 wpahdr
= (viawget_wpa_header
*)pDevice
->skb
->data
;
1749 wpahdr
->type
= VIAWGET_DISASSOC_MSG
;
1750 wpahdr
->resp_ie_len
= 0;
1751 wpahdr
->req_ie_len
= 0;
1752 skb_put(pDevice
->skb
, sizeof(viawget_wpa_header
));
1753 pDevice
->skb
->dev
= pDevice
->wpadev
;
1754 skb_reset_mac_header(pDevice
->skb
);
1755 pDevice
->skb
->pkt_type
= PACKET_HOST
;
1756 pDevice
->skb
->protocol
= htons(ETH_P_802_2
);
1757 memset(pDevice
->skb
->cb
, 0, sizeof(pDevice
->skb
->cb
));
1758 netif_rx(pDevice
->skb
);
1759 pDevice
->skb
= dev_alloc_skb((int)pDevice
->rx_buf_sz
);
1762 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1763 // if(pDevice->bWPASuppWextEnabled == TRUE)
1765 union iwreq_data wrqu
;
1766 memset(&wrqu
, 0, sizeof (wrqu
));
1767 wrqu
.ap_addr
.sa_family
= ARPHRD_ETHER
;
1768 PRINT_K("wireless_send_event--->SIOCGIWAP(disauthen)\n");
1769 wireless_send_event(pDevice
->dev
, SIOCGIWAP
, &wrqu
, NULL
);
1774 /* else, ignore it. TODO: IBSS authentication service
1775 would be implemented here */
1780 //2008-0730-01<Add>by MikeLiu
1783 * Routine Description:
1784 * check if current channel is match ZoneType.
1793 ChannelExceedZoneType(
1794 IN PSDevice pDevice
,
1795 IN BYTE byCurrChannel
1800 switch(pDevice
->byZoneType
) {
1801 case 0x00: //USA:1~11
1802 if((byCurrChannel
<1) ||(byCurrChannel
>11))
1805 case 0x01: //Japan:1~13
1806 case 0x02: //Europe:1~13
1807 if((byCurrChannel
<1) ||(byCurrChannel
>13))
1810 default: //reserve for other zonetype
1819 * Routine Description:
1820 * Handles and analysis incoming beacon frames.
1831 IN PSDevice pDevice
,
1832 IN PSMgmtObject pMgmt
,
1833 IN PSRxMgmtPacket pRxPacket
,
1839 WLAN_FR_BEACON sFrame
;
1841 BOOL bIsBSSIDEqual
= FALSE
;
1842 BOOL bIsSSIDEqual
= FALSE
;
1843 BOOL bTSFLargeDiff
= FALSE
;
1844 BOOL bTSFOffsetPostive
= FALSE
;
1845 BOOL bUpdateTSF
= FALSE
;
1846 BOOL bIsAPBeacon
= FALSE
;
1847 BOOL bIsChannelEqual
= FALSE
;
1848 UINT uLocateByteIndex
;
1849 BYTE byTIMBitOn
= 0;
1850 WORD wAIDNumber
= 0;
1852 QWORD qwTimestamp
, qwLocalTSF
;
1854 WORD wStartIndex
= 0;
1856 BYTE byCurrChannel
= pRxPacket
->byRxChannel
;
1858 UINT uRateLen
= WLAN_RATES_MAXLEN
;
1859 BOOL bChannelHit
= FALSE
;
1860 BYTE byOldPreambleType
;
1864 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
)
1867 memset(&sFrame
, 0, sizeof(WLAN_FR_BEACON
));
1868 sFrame
.len
= pRxPacket
->cbMPDULen
;
1869 sFrame
.pBuf
= (PBYTE
)pRxPacket
->p80211Header
;
1871 // decode the beacon frame
1872 vMgrDecodeBeacon(&sFrame
);
1874 if ((sFrame
.pwBeaconInterval
== 0) ||
1875 (sFrame
.pwCapInfo
== 0) ||
1876 (sFrame
.pSSID
== 0) ||
1877 (sFrame
.pSuppRates
== 0) ) {
1878 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Rx beacon frame error\n");
1883 if( byCurrChannel
> CB_MAX_CHANNEL_24G
)
1885 if (sFrame
.pDSParms
!= NULL
) {
1886 if (byCurrChannel
== RFaby11aChannelIndex
[sFrame
.pDSParms
->byCurrChannel
-1])
1888 byCurrChannel
= RFaby11aChannelIndex
[sFrame
.pDSParms
->byCurrChannel
-1];
1894 if (sFrame
.pDSParms
!= NULL
) {
1895 if (byCurrChannel
== sFrame
.pDSParms
->byCurrChannel
)
1897 byCurrChannel
= sFrame
.pDSParms
->byCurrChannel
;
1903 //2008-0730-01<Add>by MikeLiu
1904 if(ChannelExceedZoneType(pDevice
,byCurrChannel
)==TRUE
)
1907 if (sFrame
.pERP
!= NULL
) {
1908 sERP
.byERP
= sFrame
.pERP
->byContext
;
1909 sERP
.bERPExist
= TRUE
;
1912 sERP
.bERPExist
= FALSE
;
1916 pBSSList
= BSSpAddrIsInBSSList((HANDLE
)pDevice
, sFrame
.pHdr
->sA3
.abyAddr3
, sFrame
.pSSID
);
1917 if (pBSSList
== NULL
) {
1918 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Beacon/insert: RxChannel = : %d\n", byCurrChannel
);
1919 BSSbInsertToBSSList((HANDLE
)pDevice
,
1920 sFrame
.pHdr
->sA3
.abyAddr3
,
1921 *sFrame
.pqwTimestamp
,
1922 *sFrame
.pwBeaconInterval
,
1927 sFrame
.pExtSuppRates
,
1933 sFrame
.len
- WLAN_HDR_ADDR3_LEN
,
1934 sFrame
.pHdr
->sA4
.abyAddr4
, // payload of beacon
1939 // DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"update bcn: RxChannel = : %d\n", byCurrChannel);
1940 BSSbUpdateToBSSList((HANDLE
)pDevice
,
1941 *sFrame
.pqwTimestamp
,
1942 *sFrame
.pwBeaconInterval
,
1948 sFrame
.pExtSuppRates
,
1955 sFrame
.len
- WLAN_HDR_ADDR3_LEN
,
1956 sFrame
.pHdr
->sA4
.abyAddr4
, // payload of probresponse
1966 if(byCurrChannel
== (BYTE
)pMgmt
->uCurrChannel
)
1967 bIsChannelEqual
= TRUE
;
1969 if (bIsChannelEqual
&& (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
)) {
1971 // if rx beacon without ERP field
1972 if (sERP
.bERPExist
) {
1973 if (WLAN_GET_ERP_USE_PROTECTION(sERP
.byERP
)){
1974 pDevice
->byERPFlag
|= WLAN_SET_ERP_USE_PROTECTION(1);
1975 pDevice
->wUseProtectCntDown
= USE_PROTECT_PERIOD
;
1979 pDevice
->byERPFlag
|= WLAN_SET_ERP_USE_PROTECTION(1);
1980 pDevice
->wUseProtectCntDown
= USE_PROTECT_PERIOD
;
1983 if (pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) {
1984 if(!WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame
.pwCapInfo
))
1985 pDevice
->byERPFlag
|= WLAN_SET_ERP_BARKER_MODE(1);
1987 pDevice
->byERPFlag
|= WLAN_SET_ERP_NONERP_PRESENT(1);
1991 // check if BSSID the same
1992 if (memcmp(sFrame
.pHdr
->sA3
.abyAddr3
,
1993 pMgmt
->abyCurrBSSID
,
1994 WLAN_BSSID_LEN
) == 0) {
1996 bIsBSSIDEqual
= TRUE
;
1997 pDevice
->uCurrRSSI
= pRxPacket
->uRSSI
;
1998 pDevice
->byCurrSQ
= pRxPacket
->bySQ
;
1999 if (pMgmt
->sNodeDBTable
[0].uInActiveCount
!= 0) {
2000 pMgmt
->sNodeDBTable
[0].uInActiveCount
= 0;
2001 //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BCN:Wake Count= [%d]\n", pMgmt->wCountToWakeUp);
2004 // check if SSID the same
2005 if (sFrame
.pSSID
->len
== ((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->len
) {
2006 if (memcmp(sFrame
.pSSID
->abySSID
,
2007 ((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->abySSID
,
2010 bIsSSIDEqual
= TRUE
;
2014 if ((WLAN_GET_CAP_INFO_ESS(*sFrame
.pwCapInfo
)== TRUE
) &&
2015 (bIsBSSIDEqual
== TRUE
) &&
2016 (bIsSSIDEqual
== TRUE
) &&
2017 (pMgmt
->eCurrMode
== WMAC_MODE_ESS_STA
) &&
2018 (pMgmt
->eCurrState
== WMAC_STATE_ASSOC
)) {
2019 // add state check to prevent reconnect fail since we'll receive Beacon
2022 if (pBSSList
!= NULL
) {
2025 if ((pBSSList
->sERP
.bERPExist
== TRUE
) && (pDevice
->byBBType
== BB_TYPE_11G
)) {
2026 if ((pBSSList
->sERP
.byERP
& WLAN_EID_ERP_USE_PROTECTION
) != pDevice
->bProtectMode
) {//0000 0010
2027 pDevice
->bProtectMode
= (pBSSList
->sERP
.byERP
& WLAN_EID_ERP_USE_PROTECTION
);
2028 if (pDevice
->bProtectMode
) {
2029 MACvEnableProtectMD(pDevice
);
2031 MACvDisableProtectMD(pDevice
);
2033 vUpdateIFS(pDevice
);
2035 if ((pBSSList
->sERP
.byERP
& WLAN_EID_ERP_NONERP_PRESENT
) != pDevice
->bNonERPPresent
) {//0000 0001
2036 pDevice
->bNonERPPresent
= (pBSSList
->sERP
.byERP
& WLAN_EID_ERP_USE_PROTECTION
);
2038 if ((pBSSList
->sERP
.byERP
& WLAN_EID_ERP_BARKER_MODE
) != pDevice
->bBarkerPreambleMd
) {//0000 0100
2039 pDevice
->bBarkerPreambleMd
= (pBSSList
->sERP
.byERP
& WLAN_EID_ERP_BARKER_MODE
);
2040 //BarkerPreambleMd has higher priority than shortPreamble bit in Cap
2041 if (pDevice
->bBarkerPreambleMd
) {
2042 MACvEnableBarkerPreambleMd(pDevice
);
2044 MACvDisableBarkerPreambleMd(pDevice
);
2048 // Sync Short Slot Time
2049 if (WLAN_GET_CAP_INFO_SHORTSLOTTIME(pBSSList
->wCapInfo
) != pDevice
->bShortSlotTime
) {
2050 BOOL bShortSlotTime
;
2052 bShortSlotTime
= WLAN_GET_CAP_INFO_SHORTSLOTTIME(pBSSList
->wCapInfo
);
2053 //DBG_PRN_WLAN05(("Set Short Slot Time: %d\n", pDevice->bShortSlotTime));
2054 //Kyle check if it is OK to set G.
2055 if (pDevice
->byBBType
== BB_TYPE_11A
) {
2056 bShortSlotTime
= TRUE
;
2058 else if (pDevice
->byBBType
== BB_TYPE_11B
) {
2059 bShortSlotTime
= FALSE
;
2061 if (bShortSlotTime
!= pDevice
->bShortSlotTime
) {
2062 pDevice
->bShortSlotTime
= bShortSlotTime
;
2063 BBvSetShortSlotTime(pDevice
);
2064 vUpdateIFS(pDevice
);
2069 // Preamble may change dynamiclly
2071 byOldPreambleType
= pDevice
->byPreambleType
;
2072 if (WLAN_GET_CAP_INFO_SHORTPREAMBLE(pBSSList
->wCapInfo
)) {
2073 pDevice
->byPreambleType
= pDevice
->byShortPreamble
;
2076 pDevice
->byPreambleType
= 0;
2078 if (pDevice
->byPreambleType
!= byOldPreambleType
)
2079 CARDvSetRSPINF(pDevice
, (BYTE
)pDevice
->byBBType
);
2081 // Basic Rate Set may change dynamiclly
2083 if (pBSSList
->eNetworkTypeInUse
== PHY_TYPE_11B
) {
2084 uRateLen
= WLAN_RATES_MAXLEN_11B
;
2086 pMgmt
->abyCurrSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)pBSSList
->abySuppRates
,
2087 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
2089 pMgmt
->abyCurrExtSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)pBSSList
->abyExtSuppRates
,
2090 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
,
2092 RATEvParseMaxRate( (PVOID
)pDevice
,
2093 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
2094 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
,
2096 &(pMgmt
->sNodeDBTable
[0].wMaxBasicRate
),
2097 &(pMgmt
->sNodeDBTable
[0].wMaxSuppRate
),
2098 &(pMgmt
->sNodeDBTable
[0].wSuppRate
),
2099 &(pMgmt
->sNodeDBTable
[0].byTopCCKBasicRate
),
2100 &(pMgmt
->sNodeDBTable
[0].byTopOFDMBasicRate
)
2106 // DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Beacon 2 \n");
2107 // check if CF field exisit
2108 if (WLAN_GET_CAP_INFO_ESS(*sFrame
.pwCapInfo
)) {
2109 if (sFrame
.pCFParms
->wCFPDurRemaining
> 0) {
2110 // TODO: deal with CFP period to set NAV
2114 HIDWORD(qwTimestamp
) = cpu_to_le32(HIDWORD(*sFrame
.pqwTimestamp
));
2115 LODWORD(qwTimestamp
) = cpu_to_le32(LODWORD(*sFrame
.pqwTimestamp
));
2116 HIDWORD(qwLocalTSF
) = HIDWORD(pRxPacket
->qwLocalTSF
);
2117 LODWORD(qwLocalTSF
) = LODWORD(pRxPacket
->qwLocalTSF
);
2119 // check if beacon TSF larger or small than our local TSF
2120 if (HIDWORD(qwTimestamp
) == HIDWORD(qwLocalTSF
)) {
2121 if (LODWORD(qwTimestamp
) >= LODWORD(qwLocalTSF
)) {
2122 bTSFOffsetPostive
= TRUE
;
2125 bTSFOffsetPostive
= FALSE
;
2128 else if (HIDWORD(qwTimestamp
) > HIDWORD(qwLocalTSF
)) {
2129 bTSFOffsetPostive
= TRUE
;
2131 else if (HIDWORD(qwTimestamp
) < HIDWORD(qwLocalTSF
)) {
2132 bTSFOffsetPostive
= FALSE
;
2135 if (bTSFOffsetPostive
) {
2136 qwTSFOffset
= CARDqGetTSFOffset(pRxPacket
->byRxRate
, (qwTimestamp
), (qwLocalTSF
));
2139 qwTSFOffset
= CARDqGetTSFOffset(pRxPacket
->byRxRate
, (qwLocalTSF
), (qwTimestamp
));
2142 if (HIDWORD(qwTSFOffset
) != 0 ||
2143 (LODWORD(qwTSFOffset
) > TRIVIAL_SYNC_DIFFERENCE
)) {
2144 bTSFLargeDiff
= TRUE
;
2149 if (bIsAPBeacon
== TRUE
) {
2151 // Infra mode: Local TSF always follow AP's TSF if Difference huge.
2155 if ((pDevice
->bEnablePSMode
== TRUE
) &&(sFrame
.pTIM
!= 0)) {
2157 // deal with DTIM, analysis TIM
2158 pMgmt
->bMulticastTIM
= WLAN_MGMT_IS_MULTICAST_TIM(sFrame
.pTIM
->byBitMapCtl
) ? TRUE
: FALSE
;
2159 pMgmt
->byDTIMCount
= sFrame
.pTIM
->byDTIMCount
;
2160 pMgmt
->byDTIMPeriod
= sFrame
.pTIM
->byDTIMPeriod
;
2161 wAIDNumber
= pMgmt
->wCurrAID
& ~(BIT14
|BIT15
);
2163 // check if AID in TIM field bit on
2165 wStartIndex
= WLAN_MGMT_GET_TIM_OFFSET(sFrame
.pTIM
->byBitMapCtl
) << 1;
2167 wAIDIndex
= (wAIDNumber
>> 3);
2168 if ((wAIDNumber
> 0) && (wAIDIndex
>= wStartIndex
)) {
2169 uLocateByteIndex
= wAIDIndex
- wStartIndex
;
2170 // len = byDTIMCount + byDTIMPeriod + byDTIMPeriod + byVirtBitMap[0~250]
2171 if (sFrame
.pTIM
->len
>= (uLocateByteIndex
+ 4)) {
2172 byTIMBitOn
= (0x01) << ((wAIDNumber
) % 8);
2173 pMgmt
->bInTIM
= sFrame
.pTIM
->byVirtBitMap
[uLocateByteIndex
] & byTIMBitOn
? TRUE
: FALSE
;
2176 pMgmt
->bInTIM
= FALSE
;
2180 pMgmt
->bInTIM
= FALSE
;
2183 if (pMgmt
->bInTIM
||
2184 (pMgmt
->bMulticastTIM
&& (pMgmt
->byDTIMCount
== 0))) {
2185 pMgmt
->bInTIMWake
= TRUE
;
2186 // send out ps-poll packet
2187 // DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BCN:In TIM\n");
2188 if (pMgmt
->bInTIM
) {
2189 PSvSendPSPOLL((PSDevice
)pDevice
);
2190 // DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BCN:PS-POLL sent..\n");
2195 pMgmt
->bInTIMWake
= FALSE
;
2196 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"BCN: Not In TIM..\n");
2197 if (pDevice
->bPWBitOn
== FALSE
) {
2198 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"BCN: Send Null Packet\n");
2199 if (PSbSendNullPacket(pDevice
))
2200 pDevice
->bPWBitOn
= TRUE
;
2202 if(PSbConsiderPowerDown(pDevice
, FALSE
, FALSE
)) {
2203 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"BCN: Power down now...\n");
2211 if ((pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) && !bIsAPBeacon
&& bIsChannelEqual
) {
2212 if (bIsBSSIDEqual
) {
2213 // Use sNodeDBTable[0].uInActiveCount as IBSS beacons received count.
2214 if (pMgmt
->sNodeDBTable
[0].uInActiveCount
!= 0)
2215 pMgmt
->sNodeDBTable
[0].uInActiveCount
= 0;
2217 // adhoc mode:TSF updated only when beacon larger then local TSF
2218 if (bTSFLargeDiff
&& bTSFOffsetPostive
&&
2219 (pMgmt
->eCurrState
== WMAC_STATE_JOINTED
))
2222 // During dpc, already in spinlocked.
2223 if (BSSbIsSTAInNodeDB(pDevice
, sFrame
.pHdr
->sA3
.abyAddr2
, &uNodeIndex
)) {
2225 // Update the STA, (Techically the Beacons of all the IBSS nodes
2226 // should be identical, but that's not happening in practice.
2227 pMgmt
->abyCurrSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)sFrame
.pSuppRates
,
2228 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
2229 WLAN_RATES_MAXLEN_11B
);
2230 RATEvParseMaxRate( (PVOID
)pDevice
,
2231 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
2234 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxBasicRate
),
2235 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
),
2236 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wSuppRate
),
2237 &(pMgmt
->sNodeDBTable
[uNodeIndex
].byTopCCKBasicRate
),
2238 &(pMgmt
->sNodeDBTable
[uNodeIndex
].byTopOFDMBasicRate
)
2240 pMgmt
->sNodeDBTable
[uNodeIndex
].bShortPreamble
= WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame
.pwCapInfo
);
2241 pMgmt
->sNodeDBTable
[uNodeIndex
].bShortSlotTime
= WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame
.pwCapInfo
);
2242 pMgmt
->sNodeDBTable
[uNodeIndex
].uInActiveCount
= 0;
2245 // Todo, initial Node content
2246 BSSvCreateOneNode((PSDevice
)pDevice
, &uNodeIndex
);
2248 pMgmt
->abyCurrSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)sFrame
.pSuppRates
,
2249 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
2250 WLAN_RATES_MAXLEN_11B
);
2251 RATEvParseMaxRate( (PVOID
)pDevice
,
2252 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
2255 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxBasicRate
),
2256 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
),
2257 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wSuppRate
),
2258 &(pMgmt
->sNodeDBTable
[uNodeIndex
].byTopCCKBasicRate
),
2259 &(pMgmt
->sNodeDBTable
[uNodeIndex
].byTopOFDMBasicRate
)
2262 memcpy(pMgmt
->sNodeDBTable
[uNodeIndex
].abyMACAddr
, sFrame
.pHdr
->sA3
.abyAddr2
, WLAN_ADDR_LEN
);
2263 pMgmt
->sNodeDBTable
[uNodeIndex
].bShortPreamble
= WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame
.pwCapInfo
);
2264 pMgmt
->sNodeDBTable
[uNodeIndex
].wTxDataRate
= pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
;
2266 pMgmt->sNodeDBTable[uNodeIndex].bShortSlotTime = WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame.pwCapInfo);
2267 if(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate > RATE_11M)
2268 pMgmt->sNodeDBTable[uNodeIndex].bERPExist = TRUE;
2272 // if other stations jointed, indicate connect to upper layer..
2273 if (pMgmt
->eCurrState
== WMAC_STATE_STARTED
) {
2274 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Current IBSS State: [Started]........to: [Jointed] \n");
2275 pMgmt
->eCurrState
= WMAC_STATE_JOINTED
;
2276 pDevice
->bLinkPass
= TRUE
;
2277 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_INTER
);
2278 if (netif_queue_stopped(pDevice
->dev
)){
2279 netif_wake_queue(pDevice
->dev
);
2281 pMgmt
->sNodeDBTable
[0].bActive
= TRUE
;
2282 pMgmt
->sNodeDBTable
[0].uInActiveCount
= 0;
2286 else if (bIsSSIDEqual
) {
2288 // See other adhoc sta with the same SSID but BSSID is different.
2289 // adpot this vars only when TSF larger then us.
2290 if (bTSFLargeDiff
&& bTSFOffsetPostive
) {
2291 // we don't support ATIM under adhoc mode
2292 // if ( sFrame.pIBSSParms->wATIMWindow == 0) {
2294 // TODO: check sFrame cap if privacy on, and support rate syn
2295 memcpy(pMgmt
->abyCurrBSSID
, sFrame
.pHdr
->sA3
.abyAddr3
, WLAN_BSSID_LEN
);
2296 memcpy(pDevice
->abyBSSID
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
2297 pMgmt
->wCurrATIMWindow
= cpu_to_le16(sFrame
.pIBSSParms
->wATIMWindow
);
2298 pMgmt
->wCurrBeaconPeriod
= cpu_to_le16(*sFrame
.pwBeaconInterval
);
2299 pMgmt
->abyCurrSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)sFrame
.pSuppRates
,
2300 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
2301 WLAN_RATES_MAXLEN_11B
);
2302 // set HW beacon interval and re-synchronizing....
2303 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Rejoining to Other Adhoc group with same SSID........\n");
2305 MACvWriteBeaconInterval(pDevice
, pMgmt
->wCurrBeaconPeriod
);
2306 CARDvAdjustTSF(pDevice
, pRxPacket
->byRxRate
, qwTimestamp
, pRxPacket
->qwLocalTSF
);
2307 CARDvUpdateNextTBTT(pDevice
, qwTimestamp
, pMgmt
->wCurrBeaconPeriod
);
2309 // Turn off bssid filter to avoid filter others adhoc station which bssid is different.
2310 MACvWriteBSSIDAddress(pDevice
, pMgmt
->abyCurrBSSID
);
2312 byOldPreambleType
= pDevice
->byPreambleType
;
2313 if (WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame
.pwCapInfo
)) {
2314 pDevice
->byPreambleType
= pDevice
->byShortPreamble
;
2317 pDevice
->byPreambleType
= 0;
2319 if (pDevice
->byPreambleType
!= byOldPreambleType
)
2320 CARDvSetRSPINF(pDevice
, (BYTE
)pDevice
->byBBType
);
2323 // MACvRegBitsOff(pDevice->PortOffset, MAC_REG_RCR, RCR_BSSID);
2324 // set highest basic rate
2325 // s_vSetHighestBasicRate(pDevice, (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates);
2326 // Prepare beacon frame
2327 bMgrPrepareBeaconToSend((HANDLE
)pDevice
, pMgmt
);
2335 CARDbGetCurrentTSF(pDevice
, &qwCurrTSF
);
2336 CARDvAdjustTSF(pDevice
, pRxPacket
->byRxRate
, qwTimestamp
, pRxPacket
->qwLocalTSF
);
2337 CARDbGetCurrentTSF(pDevice
, &qwCurrTSF
);
2338 CARDvUpdateNextTBTT(pDevice
, qwTimestamp
, pMgmt
->wCurrBeaconPeriod
);
2348 * Routine Description:
2349 * Instructs the hw to create a bss using the supplied
2350 * attributes. Note that this implementation only supports Ad-Hoc
2360 IN HANDLE hDeviceContext
,
2361 OUT PCMD_STATUS pStatus
2364 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
2365 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
2368 BYTE byTopCCKBasicRate
;
2369 BYTE byTopOFDMBasicRate
;
2372 BYTE abyRATE
[] = {0x82, 0x84, 0x8B, 0x96, 0x24, 0x30, 0x48, 0x6C, 0x0C, 0x12, 0x18, 0x60};
2373 BYTE abyCCK_RATE
[] = {0x82, 0x84, 0x8B, 0x96};
2374 BYTE abyOFDM_RATE
[] = {0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
2379 HIDWORD(qwCurrTSF
) = 0;
2380 LODWORD(qwCurrTSF
) = 0;
2382 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Create Basic Service Set .......\n");
2384 if (pMgmt
->eConfigMode
== WMAC_CONFIG_IBSS_STA
) {
2385 if ((pMgmt
->eAuthenMode
== WMAC_AUTH_WPANONE
) &&
2386 (pDevice
->eEncryptionStatus
!= Ndis802_11Encryption2Enabled
) &&
2387 (pDevice
->eEncryptionStatus
!= Ndis802_11Encryption3Enabled
)) {
2388 // encryption mode error
2389 *pStatus
= CMD_STATUS_FAILURE
;
2394 pMgmt
->abyCurrSuppRates
[0] = WLAN_EID_SUPP_RATES
;
2395 pMgmt
->abyCurrExtSuppRates
[0] = WLAN_EID_EXTSUPP_RATES
;
2397 if (pMgmt
->eConfigMode
== WMAC_CONFIG_AP
) {
2398 pMgmt
->eCurrentPHYMode
= pMgmt
->byAPBBType
;
2400 if (pDevice
->byBBType
== BB_TYPE_11G
)
2401 pMgmt
->eCurrentPHYMode
= PHY_TYPE_11G
;
2402 if (pDevice
->byBBType
== BB_TYPE_11B
)
2403 pMgmt
->eCurrentPHYMode
= PHY_TYPE_11B
;
2404 if (pDevice
->byBBType
== BB_TYPE_11A
)
2405 pMgmt
->eCurrentPHYMode
= PHY_TYPE_11A
;
2408 if (pMgmt
->eCurrentPHYMode
!= PHY_TYPE_11A
) {
2409 pMgmt
->abyCurrSuppRates
[1] = WLAN_RATES_MAXLEN_11B
;
2410 pMgmt
->abyCurrExtSuppRates
[1] = 0;
2411 for (ii
= 0; ii
< 4; ii
++)
2412 pMgmt
->abyCurrSuppRates
[2+ii
] = abyRATE
[ii
];
2414 pMgmt
->abyCurrSuppRates
[1] = 8;
2415 pMgmt
->abyCurrExtSuppRates
[1] = 0;
2416 for (ii
= 0; ii
< 8; ii
++)
2417 pMgmt
->abyCurrSuppRates
[2+ii
] = abyRATE
[ii
];
2421 if (pMgmt
->eCurrentPHYMode
== PHY_TYPE_11G
) {
2422 pMgmt
->abyCurrSuppRates
[1] = 8;
2423 pMgmt
->abyCurrExtSuppRates
[1] = 4;
2424 for (ii
= 0; ii
< 4; ii
++)
2425 pMgmt
->abyCurrSuppRates
[2+ii
] = abyCCK_RATE
[ii
];
2426 for (ii
= 4; ii
< 8; ii
++)
2427 pMgmt
->abyCurrSuppRates
[2+ii
] = abyOFDM_RATE
[ii
-4];
2428 for (ii
= 0; ii
< 4; ii
++)
2429 pMgmt
->abyCurrExtSuppRates
[2+ii
] = abyOFDM_RATE
[ii
+4];
2433 // Disable Protect Mode
2434 pDevice
->bProtectMode
= 0;
2435 MACvDisableProtectMD(pDevice
);
2437 pDevice
->bBarkerPreambleMd
= 0;
2438 MACvDisableBarkerPreambleMd(pDevice
);
2440 // Kyle Test 2003.11.04
2442 // set HW beacon interval
2443 if (pMgmt
->wIBSSBeaconPeriod
== 0)
2444 pMgmt
->wIBSSBeaconPeriod
= DEFAULT_IBSS_BI
;
2445 MACvWriteBeaconInterval(pDevice
, pMgmt
->wIBSSBeaconPeriod
);
2447 CARDbGetCurrentTSF(pDevice
, &qwCurrTSF
);
2448 // clear TSF counter
2449 CARDbClearCurrentTSF(pDevice
);
2451 // enable TSF counter
2452 MACvRegBitsOn(pDevice
,MAC_REG_TFTCTL
,TFTCTL_TSFCNTREN
);
2454 CARDvSetFirstNextTBTT(pDevice
, pMgmt
->wIBSSBeaconPeriod
);
2456 pMgmt
->uIBSSChannel
= pDevice
->uChannel
;
2458 if (pMgmt
->uIBSSChannel
== 0)
2459 pMgmt
->uIBSSChannel
= DEFAULT_IBSS_CHANNEL
;
2461 // set channel and clear NAV
2462 CARDbSetMediaChannel(pDevice
, pMgmt
->uIBSSChannel
);
2463 pMgmt
->uCurrChannel
= pMgmt
->uIBSSChannel
;
2465 pDevice
->byPreambleType
= pDevice
->byShortPreamble
;
2469 RATEvParseMaxRate((PVOID
)pDevice
, (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
2470 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
, TRUE
,
2471 &wMaxBasicRate
, &wMaxSuppRate
, &wSuppRate
,
2472 &byTopCCKBasicRate
, &byTopOFDMBasicRate
);
2476 if (pDevice
->byBBType
== BB_TYPE_11A
) {
2477 pDevice
->bShortSlotTime
= TRUE
;
2479 pDevice
->bShortSlotTime
= FALSE
;
2481 BBvSetShortSlotTime(pDevice
);
2482 // vUpdateIFS() use pDevice->bShortSlotTime as parameter so it must be called
2483 // after setting ShortSlotTime.
2484 // CARDvSetBSSMode call vUpdateIFS()
2485 CARDvSetBSSMode(pDevice
);
2487 if (pMgmt
->eConfigMode
== WMAC_CONFIG_AP
) {
2488 MACvRegBitsOn(pDevice
, MAC_REG_HOSTCR
, HOSTCR_AP
);
2489 pMgmt
->eCurrMode
= WMAC_MODE_ESS_AP
;
2492 if (pMgmt
->eConfigMode
== WMAC_CONFIG_IBSS_STA
) {
2493 MACvRegBitsOn(pDevice
, MAC_REG_HOSTCR
, HOSTCR_ADHOC
);
2494 pMgmt
->eCurrMode
= WMAC_MODE_IBSS_STA
;
2497 // Adopt pre-configured IBSS vars to current vars
2498 pMgmt
->eCurrState
= WMAC_STATE_STARTED
;
2499 pMgmt
->wCurrBeaconPeriod
= pMgmt
->wIBSSBeaconPeriod
;
2500 pMgmt
->uCurrChannel
= pMgmt
->uIBSSChannel
;
2501 pMgmt
->wCurrATIMWindow
= pMgmt
->wIBSSATIMWindow
;
2502 pDevice
->uCurrRSSI
= 0;
2503 pDevice
->byCurrSQ
= 0;
2505 //20080131-04,<Add> by Mike Liu
2507 memcpy(pMgmt
->abyDesireSSID
,pMgmt
->abyAdHocSSID
,
2508 ((PWLAN_IE_SSID
)pMgmt
->abyAdHocSSID
)->len
+ WLAN_IEHDR_LEN
);
2511 memset(pMgmt
->abyCurrSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
2512 memcpy(pMgmt
->abyCurrSSID
,
2513 pMgmt
->abyDesireSSID
,
2514 ((PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
)->len
+ WLAN_IEHDR_LEN
2517 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) {
2518 // AP mode BSSID = MAC addr
2519 memcpy(pMgmt
->abyCurrBSSID
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
2520 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"AP beacon created BSSID:%02x-%02x-%02x-%02x-%02x-%02x \n",
2521 pMgmt
->abyCurrBSSID
[0],
2522 pMgmt
->abyCurrBSSID
[1],
2523 pMgmt
->abyCurrBSSID
[2],
2524 pMgmt
->abyCurrBSSID
[3],
2525 pMgmt
->abyCurrBSSID
[4],
2526 pMgmt
->abyCurrBSSID
[5]
2530 if (pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) {
2532 // BSSID selected must be randomized as spec 11.1.3
2533 pMgmt
->abyCurrBSSID
[5] = (BYTE
) (LODWORD(qwCurrTSF
)& 0x000000ff);
2534 pMgmt
->abyCurrBSSID
[4] = (BYTE
)((LODWORD(qwCurrTSF
)& 0x0000ff00) >> 8);
2535 pMgmt
->abyCurrBSSID
[3] = (BYTE
)((LODWORD(qwCurrTSF
)& 0x00ff0000) >> 16);
2536 pMgmt
->abyCurrBSSID
[2] = (BYTE
)((LODWORD(qwCurrTSF
)& 0x00000ff0) >> 4);
2537 pMgmt
->abyCurrBSSID
[1] = (BYTE
)((LODWORD(qwCurrTSF
)& 0x000ff000) >> 12);
2538 pMgmt
->abyCurrBSSID
[0] = (BYTE
)((LODWORD(qwCurrTSF
)& 0x0ff00000) >> 20);
2539 pMgmt
->abyCurrBSSID
[5] ^= pMgmt
->abyMACAddr
[0];
2540 pMgmt
->abyCurrBSSID
[4] ^= pMgmt
->abyMACAddr
[1];
2541 pMgmt
->abyCurrBSSID
[3] ^= pMgmt
->abyMACAddr
[2];
2542 pMgmt
->abyCurrBSSID
[2] ^= pMgmt
->abyMACAddr
[3];
2543 pMgmt
->abyCurrBSSID
[1] ^= pMgmt
->abyMACAddr
[4];
2544 pMgmt
->abyCurrBSSID
[0] ^= pMgmt
->abyMACAddr
[5];
2545 pMgmt
->abyCurrBSSID
[0] &= ~IEEE_ADDR_GROUP
;
2546 pMgmt
->abyCurrBSSID
[0] |= IEEE_ADDR_UNIVERSAL
;
2549 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"Adhoc beacon created bssid:%02x-%02x-%02x-%02x-%02x-%02x \n",
2550 pMgmt
->abyCurrBSSID
[0],
2551 pMgmt
->abyCurrBSSID
[1],
2552 pMgmt
->abyCurrBSSID
[2],
2553 pMgmt
->abyCurrBSSID
[3],
2554 pMgmt
->abyCurrBSSID
[4],
2555 pMgmt
->abyCurrBSSID
[5]
2560 MACvWriteBSSIDAddress(pDevice
, pMgmt
->abyCurrBSSID
);
2561 memcpy(pDevice
->abyBSSID
, pMgmt
->abyCurrBSSID
, WLAN_ADDR_LEN
);
2563 MACvRegBitsOn(pDevice
, MAC_REG_RCR
, RCR_BSSID
);
2564 pDevice
->byRxMode
|= RCR_BSSID
;
2565 pMgmt
->bCurrBSSIDFilterOn
= TRUE
;
2567 // Set Capability Info
2568 pMgmt
->wCurrCapInfo
= 0;
2570 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) {
2571 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_ESS(1);
2572 pMgmt
->byDTIMPeriod
= DEFAULT_DTIM_PERIOD
;
2573 pMgmt
->byDTIMCount
= pMgmt
->byDTIMPeriod
- 1;
2574 pDevice
->eOPMode
= OP_MODE_AP
;
2577 if (pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) {
2578 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_IBSS(1);
2579 pDevice
->eOPMode
= OP_MODE_ADHOC
;
2582 if (pDevice
->bEncryptionEnable
) {
2583 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_PRIVACY(1);
2584 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPANONE
) {
2585 if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
) {
2586 pMgmt
->byCSSPK
= KEY_CTL_CCMP
;
2587 pMgmt
->byCSSGK
= KEY_CTL_CCMP
;
2588 } else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
) {
2589 pMgmt
->byCSSPK
= KEY_CTL_TKIP
;
2590 pMgmt
->byCSSGK
= KEY_CTL_TKIP
;
2592 pMgmt
->byCSSPK
= KEY_CTL_NONE
;
2593 pMgmt
->byCSSGK
= KEY_CTL_WEP
;
2596 pMgmt
->byCSSPK
= KEY_CTL_WEP
;
2597 pMgmt
->byCSSGK
= KEY_CTL_WEP
;
2601 pMgmt
->byERPContext
= 0;
2603 if (pDevice
->byPreambleType
== 1) {
2604 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
2606 pMgmt
->wCurrCapInfo
&= (~WLAN_SET_CAP_INFO_SHORTPREAMBLE(1));
2609 pMgmt
->eCurrState
= WMAC_STATE_STARTED
;
2610 // Prepare beacon to send
2611 if (bMgrPrepareBeaconToSend((HANDLE
)pDevice
, pMgmt
)) {
2612 *pStatus
= CMD_STATUS_SUCCESS
;
2621 * Routine Description:
2622 * Instructs wmac to join a bss using the supplied attributes.
2623 * The arguments may the BSSID or SSID and the rest of the
2624 * attributes are obtained from the scan result of known bss list.
2634 IN HANDLE hDeviceContext
,
2635 OUT PCMD_STATUS pStatus
2639 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
2640 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
2641 PKnownBSS pCurr
= NULL
;
2643 PWLAN_IE_SUPP_RATES pItemRates
= NULL
;
2644 PWLAN_IE_SUPP_RATES pItemExtRates
= NULL
;
2645 PWLAN_IE_SSID pItemSSID
;
2646 UINT uRateLen
= WLAN_RATES_MAXLEN
;
2647 WORD wMaxBasicRate
= RATE_1M
;
2648 WORD wMaxSuppRate
= RATE_1M
;
2650 BYTE byTopCCKBasicRate
= RATE_1M
;
2651 BYTE byTopOFDMBasicRate
= RATE_1M
;
2652 BOOL bShortSlotTime
= FALSE
;
2655 for (ii
= 0; ii
< MAX_BSS_NUM
; ii
++) {
2656 if (pMgmt
->sBSSList
[ii
].bActive
== TRUE
)
2660 if (ii
== MAX_BSS_NUM
) {
2661 *pStatus
= CMD_STATUS_RESOURCES
;
2662 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"BSS finding:BSS list is empty.\n");
2666 // memset(pMgmt->abyDesireBSSID, 0, WLAN_BSSID_LEN);
2667 // Search known BSS list for prefer BSSID or SSID
2669 pCurr
= BSSpSearchBSSList(pDevice
,
2670 pMgmt
->abyDesireBSSID
,
2671 pMgmt
->abyDesireSSID
,
2672 pDevice
->eConfigPHYMode
2676 *pStatus
= CMD_STATUS_RESOURCES
;
2677 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
;
2678 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Scanning [%s] not found, disconnected !\n", pItemSSID
->abySSID
);
2682 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"AP(BSS) finding:Found a AP(BSS)..\n");
2684 if (WLAN_GET_CAP_INFO_ESS(cpu_to_le16(pCurr
->wCapInfo
))){
2686 if ((pMgmt
->eAuthenMode
== WMAC_AUTH_WPA
)||(pMgmt
->eAuthenMode
== WMAC_AUTH_WPAPSK
)) {
2688 if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) {
2689 if (WPA_SearchRSN(0, WPA_TKIP, pCurr) == FALSE) {
2690 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"No match RSN info. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
2691 // encryption mode error
2692 pMgmt->eCurrState = WMAC_STATE_IDLE;
2695 } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) {
2696 if (WPA_SearchRSN(0, WPA_AESCCMP, pCurr) == FALSE) {
2697 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"No match RSN info. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
2698 // encryption mode error
2699 pMgmt->eCurrState = WMAC_STATE_IDLE;
2706 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
2707 //if(pDevice->bWPASuppWextEnabled == TRUE)
2708 Encyption_Rebuild(pDevice
, pCurr
);
2711 // Infrastructure BSS
2712 s_vMgrSynchBSS(pDevice
,
2718 if (*pStatus
== CMD_STATUS_SUCCESS
){
2720 // Adopt this BSS state vars in Mgmt Object
2721 pMgmt
->uCurrChannel
= pCurr
->uChannel
;
2723 memset(pMgmt
->abyCurrSuppRates
, 0 , WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1);
2724 memset(pMgmt
->abyCurrExtSuppRates
, 0 , WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1);
2726 if (pCurr
->eNetworkTypeInUse
== PHY_TYPE_11B
) {
2727 uRateLen
= WLAN_RATES_MAXLEN_11B
;
2730 pItemRates
= (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
;
2731 pItemExtRates
= (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
;
2733 // Parse Support Rate IE
2734 pItemRates
->byElementID
= WLAN_EID_SUPP_RATES
;
2735 pItemRates
->len
= RATEuSetIE((PWLAN_IE_SUPP_RATES
)pCurr
->abySuppRates
,
2739 // Parse Extension Support Rate IE
2740 pItemExtRates
->byElementID
= WLAN_EID_EXTSUPP_RATES
;
2741 pItemExtRates
->len
= RATEuSetIE((PWLAN_IE_SUPP_RATES
)pCurr
->abyExtSuppRates
,
2745 if ((pItemExtRates
->len
> 0) && (pItemRates
->len
< 8)) {
2746 for (ii
= 0; ii
< (UINT
)(8 - pItemRates
->len
); ) {
2747 pItemRates
->abyRates
[pItemRates
->len
+ ii
] = pItemExtRates
->abyRates
[ii
];
2749 if (pItemExtRates
->len
<= ii
)
2752 pItemRates
->len
+= (BYTE
)ii
;
2753 if (pItemExtRates
->len
- ii
> 0) {
2754 pItemExtRates
->len
-= (BYTE
)ii
;
2755 for (uu
= 0; uu
< pItemExtRates
->len
; uu
++) {
2756 pItemExtRates
->abyRates
[uu
] = pItemExtRates
->abyRates
[uu
+ ii
];
2759 pItemExtRates
->len
= 0;
2763 RATEvParseMaxRate((PVOID
)pDevice
, pItemRates
, pItemExtRates
, TRUE
,
2764 &wMaxBasicRate
, &wMaxSuppRate
, &wSuppRate
,
2765 &byTopCCKBasicRate
, &byTopOFDMBasicRate
);
2766 vUpdateIFS(pDevice
);
2767 // TODO: deal with if wCapInfo the privacy is on, but station WEP is off
2768 // TODO: deal with if wCapInfo the PS-Pollable is on.
2769 pMgmt
->wCurrBeaconPeriod
= pCurr
->wBeaconInterval
;
2770 memset(pMgmt
->abyCurrSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
2771 memcpy(pMgmt
->abyCurrBSSID
, pCurr
->abyBSSID
, WLAN_BSSID_LEN
);
2772 memcpy(pMgmt
->abyCurrSSID
, pCurr
->abySSID
, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
2774 pMgmt
->eCurrMode
= WMAC_MODE_ESS_STA
;
2776 pMgmt
->eCurrState
= WMAC_STATE_JOINTED
;
2777 // Adopt BSS state in Adapter Device Object
2778 pDevice
->eOPMode
= OP_MODE_INFRASTRUCTURE
;
2779 memcpy(pDevice
->abyBSSID
, pCurr
->abyBSSID
, WLAN_BSSID_LEN
);
2781 // Add current BSS to Candidate list
2782 // This should only works for WPA2 BSS, and WPA2 BSS check must be done before.
2783 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2
) {
2784 BOOL bResult
= bAdd_PMKID_Candidate((HANDLE
)pDevice
, pMgmt
->abyCurrBSSID
, &pCurr
->sRSNCapObj
);
2785 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"bAdd_PMKID_Candidate: 1(%d)\n", bResult
);
2786 if (bResult
== FALSE
) {
2787 vFlush_PMKID_Candidate((HANDLE
)pDevice
);
2788 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"vFlush_PMKID_Candidate: 4\n");
2789 bAdd_PMKID_Candidate((HANDLE
)pDevice
, pMgmt
->abyCurrBSSID
, &pCurr
->sRSNCapObj
);
2793 // Preamble type auto-switch: if AP can receive short-preamble cap,
2794 // we can turn on too.
2795 if (WLAN_GET_CAP_INFO_SHORTPREAMBLE(pCurr
->wCapInfo
)) {
2796 pDevice
->byPreambleType
= pDevice
->byShortPreamble
;
2799 pDevice
->byPreambleType
= 0;
2801 // Change PreambleType must set RSPINF again
2802 CARDvSetRSPINF(pDevice
, (BYTE
)pDevice
->byBBType
);
2804 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Join ESS\n");
2806 if (pCurr
->eNetworkTypeInUse
== PHY_TYPE_11G
) {
2808 if ((pCurr
->sERP
.byERP
& WLAN_EID_ERP_USE_PROTECTION
) != pDevice
->bProtectMode
) {//0000 0010
2809 pDevice
->bProtectMode
= (pCurr
->sERP
.byERP
& WLAN_EID_ERP_USE_PROTECTION
);
2810 if (pDevice
->bProtectMode
) {
2811 MACvEnableProtectMD(pDevice
);
2813 MACvDisableProtectMD(pDevice
);
2815 vUpdateIFS(pDevice
);
2817 if ((pCurr
->sERP
.byERP
& WLAN_EID_ERP_NONERP_PRESENT
) != pDevice
->bNonERPPresent
) {//0000 0001
2818 pDevice
->bNonERPPresent
= (pCurr
->sERP
.byERP
& WLAN_EID_ERP_USE_PROTECTION
);
2820 if ((pCurr
->sERP
.byERP
& WLAN_EID_ERP_BARKER_MODE
) != pDevice
->bBarkerPreambleMd
) {//0000 0100
2821 pDevice
->bBarkerPreambleMd
= (pCurr
->sERP
.byERP
& WLAN_EID_ERP_BARKER_MODE
);
2822 //BarkerPreambleMd has higher priority than shortPreamble bit in Cap
2823 if (pDevice
->bBarkerPreambleMd
) {
2824 MACvEnableBarkerPreambleMd(pDevice
);
2826 MACvDisableBarkerPreambleMd(pDevice
);
2830 //DBG_PRN_WLAN05(("wCapInfo: %X\n", pCurr->wCapInfo));
2831 if (WLAN_GET_CAP_INFO_SHORTSLOTTIME(pCurr
->wCapInfo
) != pDevice
->bShortSlotTime
) {
2832 if (pDevice
->byBBType
== BB_TYPE_11A
) {
2833 bShortSlotTime
= TRUE
;
2835 else if (pDevice
->byBBType
== BB_TYPE_11B
) {
2836 bShortSlotTime
= FALSE
;
2839 bShortSlotTime
= WLAN_GET_CAP_INFO_SHORTSLOTTIME(pCurr
->wCapInfo
);
2841 //DBG_PRN_WLAN05(("Set Short Slot Time: %d\n", pDevice->bShortSlotTime));
2842 if (bShortSlotTime
!= pDevice
->bShortSlotTime
) {
2843 pDevice
->bShortSlotTime
= bShortSlotTime
;
2844 BBvSetShortSlotTime(pDevice
);
2845 vUpdateIFS(pDevice
);
2849 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"End of Join AP -- A/B/G Action\n");
2852 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
2859 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPANONE
) {
2861 if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
) {
2863 if (WPA_SearchRSN(0, WPA_TKIP, pCurr) == FALSE) {
2864 // encryption mode error
2865 pMgmt->eCurrState = WMAC_STATE_IDLE;
2869 } else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
) {
2871 if (WPA_SearchRSN(0, WPA_AESCCMP, pCurr) == FALSE) {
2872 // encryption mode error
2873 pMgmt->eCurrState = WMAC_STATE_IDLE;
2878 // encryption mode error
2879 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
2884 s_vMgrSynchBSS(pDevice
,
2890 if (*pStatus
== CMD_STATUS_SUCCESS
){
2891 // Adopt this BSS state vars in Mgmt Object
2892 // TODO: check if CapInfo privacy on, but we don't..
2893 pMgmt
->uCurrChannel
= pCurr
->uChannel
;
2896 // Parse Support Rate IE
2897 pMgmt
->abyCurrSuppRates
[0] = WLAN_EID_SUPP_RATES
;
2898 pMgmt
->abyCurrSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)pCurr
->abySuppRates
,
2899 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
2900 WLAN_RATES_MAXLEN_11B
);
2902 RATEvParseMaxRate((PVOID
)pDevice
, (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
2903 NULL
, TRUE
, &wMaxBasicRate
, &wMaxSuppRate
, &wSuppRate
,
2904 &byTopCCKBasicRate
, &byTopOFDMBasicRate
);
2905 vUpdateIFS(pDevice
);
2906 pMgmt
->wCurrCapInfo
= pCurr
->wCapInfo
;
2907 pMgmt
->wCurrBeaconPeriod
= pCurr
->wBeaconInterval
;
2908 memset(pMgmt
->abyCurrSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
);
2909 memcpy(pMgmt
->abyCurrBSSID
, pCurr
->abyBSSID
, WLAN_BSSID_LEN
);
2910 memcpy(pMgmt
->abyCurrSSID
, pCurr
->abySSID
, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
);
2911 // pMgmt->wCurrATIMWindow = pCurr->wATIMWindow;
2912 pMgmt
->eCurrMode
= WMAC_MODE_IBSS_STA
;
2913 pMgmt
->eCurrState
= WMAC_STATE_STARTED
;
2914 // Adopt BSS state in Adapter Device Object
2915 pDevice
->eOPMode
= OP_MODE_ADHOC
;
2916 pDevice
->bLinkPass
= TRUE
;
2917 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_INTER
);
2918 memcpy(pDevice
->abyBSSID
, pCurr
->abyBSSID
, WLAN_BSSID_LEN
);
2920 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Join IBSS ok:%02x-%02x-%02x-%02x-%02x-%02x \n",
2921 pMgmt
->abyCurrBSSID
[0],
2922 pMgmt
->abyCurrBSSID
[1],
2923 pMgmt
->abyCurrBSSID
[2],
2924 pMgmt
->abyCurrBSSID
[3],
2925 pMgmt
->abyCurrBSSID
[4],
2926 pMgmt
->abyCurrBSSID
[5]
2928 // Preamble type auto-switch: if AP can receive short-preamble cap,
2929 // and if registry setting is short preamble we can turn on too.
2931 if (WLAN_GET_CAP_INFO_SHORTPREAMBLE(pCurr
->wCapInfo
)) {
2932 pDevice
->byPreambleType
= pDevice
->byShortPreamble
;
2935 pDevice
->byPreambleType
= 0;
2937 // Change PreambleType must set RSPINF again
2938 CARDvSetRSPINF(pDevice
, (BYTE
)pDevice
->byBBType
);
2941 bMgrPrepareBeaconToSend((HANDLE
)pDevice
, pMgmt
);
2944 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
2954 * Routine Description:
2955 * Set HW to synchronize a specific BSS from known BSS list.
2965 IN PSDevice pDevice
,
2968 OUT PCMD_STATUS pStatus
2971 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
2972 //1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M
2973 BYTE abyCurrSuppRatesG
[] = {WLAN_EID_SUPP_RATES
, 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C};
2974 BYTE abyCurrExtSuppRatesG
[] = {WLAN_EID_EXTSUPP_RATES
, 4, 0x0C, 0x12, 0x18, 0x60};
2976 BYTE abyCurrSuppRatesA
[] = {WLAN_EID_SUPP_RATES
, 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
2977 BYTE abyCurrSuppRatesB
[] = {WLAN_EID_SUPP_RATES
, 4, 0x02, 0x04, 0x0B, 0x16};
2980 *pStatus
= CMD_STATUS_FAILURE
;
2982 if (s_bCipherMatch(pCurr
,
2983 pDevice
->eEncryptionStatus
,
2985 &(pMgmt
->byCSSGK
)) == FALSE
) {
2986 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"s_bCipherMatch Fail .......\n");
2990 pMgmt
->pCurrBSS
= pCurr
;
2992 // if previous mode is IBSS.
2993 if(pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) {
2994 MACvRegBitsOff(pDevice
, MAC_REG_TCR
, TCR_AUTOBCNTX
);
2997 // Init the BSS informations
2998 pDevice
->bCCK
= TRUE
;
2999 pDevice
->bProtectMode
= FALSE
;
3000 MACvDisableProtectMD(pDevice
);
3001 pDevice
->bBarkerPreambleMd
= FALSE
;
3002 MACvDisableBarkerPreambleMd(pDevice
);
3003 pDevice
->bNonERPPresent
= FALSE
;
3004 pDevice
->byPreambleType
= 0;
3005 pDevice
->wBasicRate
= 0;
3007 CARDbAddBasicRate((PVOID
)pDevice
, RATE_1M
);
3009 // calculate TSF offset
3010 // TSF Offset = Received Timestamp TSF - Marked Local's TSF
3011 CARDvAdjustTSF(pDevice
, pCurr
->byRxRate
, pCurr
->qwBSSTimestamp
, pCurr
->qwLocalTSF
);
3013 // set HW beacon interval
3014 MACvWriteBeaconInterval(pDevice
, pCurr
->wBeaconInterval
);
3017 // Next TBTT = ((local_current_TSF / beacon_interval) + 1 ) * beacon_interval
3018 CARDvSetFirstNextTBTT(pDevice
, pCurr
->wBeaconInterval
);
3021 MACvWriteBSSIDAddress(pDevice
, pCurr
->abyBSSID
);
3023 memcpy(pMgmt
->abyCurrBSSID
, pCurr
->abyBSSID
, 6);
3025 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Sync:set CurrBSSID address = %02x-%02x-%02x=%02x-%02x-%02x\n",
3026 pMgmt
->abyCurrBSSID
[0],
3027 pMgmt
->abyCurrBSSID
[1],
3028 pMgmt
->abyCurrBSSID
[2],
3029 pMgmt
->abyCurrBSSID
[3],
3030 pMgmt
->abyCurrBSSID
[4],
3031 pMgmt
->abyCurrBSSID
[5]);
3033 if (pCurr
->eNetworkTypeInUse
== PHY_TYPE_11A
) {
3034 if ((pDevice
->eConfigPHYMode
== PHY_TYPE_11A
) ||
3035 (pDevice
->eConfigPHYMode
== PHY_TYPE_AUTO
)) {
3036 pDevice
->byBBType
= BB_TYPE_11A
;
3037 pMgmt
->eCurrentPHYMode
= PHY_TYPE_11A
;
3038 pDevice
->bShortSlotTime
= TRUE
;
3039 BBvSetShortSlotTime(pDevice
);
3040 CARDvSetBSSMode(pDevice
);
3044 } else if (pCurr
->eNetworkTypeInUse
== PHY_TYPE_11B
) {
3045 if ((pDevice
->eConfigPHYMode
== PHY_TYPE_11B
) ||
3046 (pDevice
->eConfigPHYMode
== PHY_TYPE_11G
) ||
3047 (pDevice
->eConfigPHYMode
== PHY_TYPE_AUTO
)) {
3048 pDevice
->byBBType
= BB_TYPE_11B
;
3049 pMgmt
->eCurrentPHYMode
= PHY_TYPE_11B
;
3050 pDevice
->bShortSlotTime
= FALSE
;
3051 BBvSetShortSlotTime(pDevice
);
3052 CARDvSetBSSMode(pDevice
);
3057 if ((pDevice
->eConfigPHYMode
== PHY_TYPE_11G
) ||
3058 (pDevice
->eConfigPHYMode
== PHY_TYPE_AUTO
)) {
3059 pDevice
->byBBType
= BB_TYPE_11G
;
3060 pMgmt
->eCurrentPHYMode
= PHY_TYPE_11G
;
3061 pDevice
->bShortSlotTime
= TRUE
;
3062 BBvSetShortSlotTime(pDevice
);
3063 CARDvSetBSSMode(pDevice
);
3064 } else if (pDevice
->eConfigPHYMode
== PHY_TYPE_11B
) {
3065 pDevice
->byBBType
= BB_TYPE_11B
;
3066 pDevice
->bShortSlotTime
= FALSE
;
3067 BBvSetShortSlotTime(pDevice
);
3068 CARDvSetBSSMode(pDevice
);
3074 if (uBSSMode
== WMAC_MODE_ESS_STA
) {
3075 MACvRegBitsOff(pDevice
, MAC_REG_HOSTCR
, HOSTCR_ADHOC
);
3076 MACvRegBitsOn(pDevice
, MAC_REG_RCR
, RCR_BSSID
);
3077 pDevice
->byRxMode
|= RCR_BSSID
;
3078 pMgmt
->bCurrBSSIDFilterOn
= TRUE
;
3081 // set channel and clear NAV
3082 CARDbSetMediaChannel(pDevice
, pCurr
->uChannel
);
3083 pMgmt
->uCurrChannel
= pCurr
->uChannel
;
3084 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"<----s_bSynchBSS Set Channel [%d]\n", pCurr
->uChannel
);
3086 if ((pDevice
->bUpdateBBVGA
) &&
3087 (pDevice
->byBBVGACurrent
!= pDevice
->abyBBVGA
[0])) {
3088 pDevice
->byBBVGACurrent
= pDevice
->abyBBVGA
[0];
3089 BBvSetVGAGainOffset(pDevice
, pDevice
->byBBVGACurrent
);
3090 BBvSetShortSlotTime(pDevice
);
3094 // 1. In Ad-hoc mode : check if received others beacon as jointed indication,
3095 // otherwise we will start own IBSS.
3096 // 2. In Infra mode : Supposed we already synchronized with AP right now.
3098 if (uBSSMode
== WMAC_MODE_IBSS_STA
) {
3099 MACvRegBitsOn(pDevice
, MAC_REG_HOSTCR
, HOSTCR_ADHOC
);
3100 MACvRegBitsOn(pDevice
, MAC_REG_RCR
, RCR_BSSID
);
3101 pDevice
->byRxMode
|= RCR_BSSID
;
3102 pMgmt
->bCurrBSSIDFilterOn
= TRUE
;
3105 if (pDevice
->byBBType
== BB_TYPE_11A
) {
3106 memcpy(pMgmt
->abyCurrSuppRates
, &abyCurrSuppRatesA
[0], sizeof(abyCurrSuppRatesA
));
3107 pMgmt
->abyCurrExtSuppRates
[1] = 0;
3108 } else if (pDevice
->byBBType
== BB_TYPE_11B
) {
3109 memcpy(pMgmt
->abyCurrSuppRates
, &abyCurrSuppRatesB
[0], sizeof(abyCurrSuppRatesB
));
3110 pMgmt
->abyCurrExtSuppRates
[1] = 0;
3112 memcpy(pMgmt
->abyCurrSuppRates
, &abyCurrSuppRatesG
[0], sizeof(abyCurrSuppRatesG
));
3113 memcpy(pMgmt
->abyCurrExtSuppRates
, &abyCurrExtSuppRatesG
[0], sizeof(abyCurrExtSuppRatesG
));
3115 pMgmt
->byERPContext
= pCurr
->sERP
.byERP
;
3117 *pStatus
= CMD_STATUS_SUCCESS
;
3123 //mike add: fix NetworkManager 0.7.0 hidden ssid mode in WPA encryption
3124 // ,need reset eAuthenMode and eEncryptionStatus
3125 static VOID
Encyption_Rebuild(
3126 IN PSDevice pDevice
,
3130 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
3131 // UINT ii , uSameBssidNum=0;
3133 // for (ii = 0; ii < MAX_BSS_NUM; ii++) {
3134 // if (pMgmt->sBSSList[ii].bActive &&
3135 // IS_ETH_ADDRESS_EQUAL(pMgmt->sBSSList[ii].abyBSSID, pCurr->abyBSSID)) {
3139 // if( uSameBssidNum>=2) { //we only check AP in hidden sssid mode
3140 if ((pMgmt
->eAuthenMode
== WMAC_AUTH_WPAPSK
) || //networkmanager 0.7.0 does not give the pairwise-key selsection,
3141 (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2PSK
)) { // so we need re-selsect it according to real pairwise-key info.
3142 if(pCurr
->bWPAValid
== TRUE
) { //WPA-PSK
3143 pMgmt
->eAuthenMode
= WMAC_AUTH_WPAPSK
;
3144 if(pCurr
->abyPKType
[0] == WPA_TKIP
) {
3145 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
; //TKIP
3146 PRINT_K("Encyption_Rebuild--->ssid reset config to [WPAPSK-TKIP]\n");
3148 else if(pCurr
->abyPKType
[0] == WPA_AESCCMP
) {
3149 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
; //AES
3150 PRINT_K("Encyption_Rebuild--->ssid reset config to [WPAPSK-AES]\n");
3153 else if(pCurr
->bWPA2Valid
== TRUE
) { //WPA2-PSK
3154 pMgmt
->eAuthenMode
= WMAC_AUTH_WPA2PSK
;
3155 if(pCurr
->abyCSSPK
[0] == WLAN_11i_CSS_TKIP
) {
3156 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
; //TKIP
3157 PRINT_K("Encyption_Rebuild--->ssid reset config to [WPA2PSK-TKIP]\n");
3159 else if(pCurr
->abyCSSPK
[0] == WLAN_11i_CSS_CCMP
) {
3160 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
; //AES
3161 PRINT_K("Encyption_Rebuild--->ssid reset config to [WPA2PSK-AES]\n");
3172 * Routine Description:
3184 IN PSMgmtObject pMgmt
,
3185 IN PWLAN_IE_TIM pTIM
3188 BYTE byMask
[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
3191 BOOL bStartFound
= FALSE
;
3192 BOOL bMulticast
= FALSE
;
3193 WORD wStartIndex
= 0;
3197 // Find size of partial virtual bitmap
3198 for (ii
= 0; ii
< (MAX_NODE_NUM
+ 1); ii
++) {
3199 byMap
= pMgmt
->abyPSTxMap
[ii
];
3201 // Mask out the broadcast bit which is indicated separately.
3202 bMulticast
= (byMap
& byMask
[0]) != 0;
3204 pMgmt
->sNodeDBTable
[0].bRxPSPoll
= TRUE
;
3211 wStartIndex
= (WORD
)ii
;
3213 wEndIndex
= (WORD
)ii
;
3218 // Round start index down to nearest even number
3219 wStartIndex
&= ~BIT0
;
3221 // Round end index up to nearest even number
3222 wEndIndex
= ((wEndIndex
+ 1) & ~BIT0
);
3224 // Size of element payload
3226 pTIM
->len
= 3 + (wEndIndex
- wStartIndex
) + 1;
3228 // Fill in the Fixed parts of the TIM
3229 pTIM
->byDTIMCount
= pMgmt
->byDTIMCount
;
3230 pTIM
->byDTIMPeriod
= pMgmt
->byDTIMPeriod
;
3231 pTIM
->byBitMapCtl
= (bMulticast
? TIM_MULTICAST_MASK
: 0) |
3232 (((wStartIndex
>> 1) << 1) & TIM_BITMAPOFFSET_MASK
);
3234 // Append variable part of TIM
3236 for (ii
= wStartIndex
, jj
=0 ; ii
<= wEndIndex
; ii
++, jj
++) {
3237 pTIM
->byVirtBitMap
[jj
] = pMgmt
->abyPSTxMap
[ii
];
3240 // Aid = 0 don't used.
3241 pTIM
->byVirtBitMap
[0] &= ~BIT0
;
3247 * Routine Description:
3248 * Constructs an Beacon frame( Ad-hoc mode)
3252 * PTR to frame; or NULL on allocation failue
3259 IN PSDevice pDevice
,
3260 IN PSMgmtObject pMgmt
,
3261 IN WORD wCurrCapInfo
,
3262 IN WORD wCurrBeaconPeriod
,
3263 IN UINT uCurrChannel
,
3264 IN WORD wCurrATIMWinodw
,
3265 IN PWLAN_IE_SSID pCurrSSID
,
3266 IN PBYTE pCurrBSSID
,
3267 IN PWLAN_IE_SUPP_RATES pCurrSuppRates
,
3268 IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates
3271 PSTxMgmtPacket pTxPacket
= NULL
;
3272 WLAN_FR_BEACON sFrame
;
3273 BYTE abyBroadcastAddr
[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
3276 // prepare beacon frame
3277 pTxPacket
= (PSTxMgmtPacket
)pMgmt
->pbyMgmtPacketPool
;
3278 memset(pTxPacket
, 0, sizeof(STxMgmtPacket
) + WLAN_BEACON_FR_MAXLEN
);
3279 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((PBYTE
)pTxPacket
+ sizeof(STxMgmtPacket
));
3280 // Setup the sFrame structure.
3281 sFrame
.pBuf
= (PBYTE
)pTxPacket
->p80211Header
;
3282 sFrame
.len
= WLAN_BEACON_FR_MAXLEN
;
3283 vMgrEncodeBeacon(&sFrame
);
3285 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
3287 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
3288 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_BEACON
)
3291 if (pDevice
->bEnablePSMode
) {
3292 sFrame
.pHdr
->sA3
.wFrameCtl
|= cpu_to_le16((WORD
)WLAN_SET_FC_PWRMGT(1));
3295 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, abyBroadcastAddr
, WLAN_ADDR_LEN
);
3296 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
3297 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pCurrBSSID
, WLAN_BSSID_LEN
);
3298 *sFrame
.pwBeaconInterval
= cpu_to_le16(wCurrBeaconPeriod
);
3299 *sFrame
.pwCapInfo
= cpu_to_le16(wCurrCapInfo
);
3301 sFrame
.pSSID
= (PWLAN_IE_SSID
)(sFrame
.pBuf
+ sFrame
.len
);
3302 sFrame
.len
+= ((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->len
+ WLAN_IEHDR_LEN
;
3303 memcpy(sFrame
.pSSID
,
3305 ((PWLAN_IE_SSID
)pCurrSSID
)->len
+ WLAN_IEHDR_LEN
3307 // Copy the rate set
3308 sFrame
.pSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3309 sFrame
.len
+= ((PWLAN_IE_SUPP_RATES
)pCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
;
3310 memcpy(sFrame
.pSuppRates
,
3312 ((PWLAN_IE_SUPP_RATES
)pCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
3315 if (pDevice
->byBBType
!= BB_TYPE_11A
) {
3316 sFrame
.pDSParms
= (PWLAN_IE_DS_PARMS
)(sFrame
.pBuf
+ sFrame
.len
);
3317 sFrame
.len
+= (1) + WLAN_IEHDR_LEN
;
3318 sFrame
.pDSParms
->byElementID
= WLAN_EID_DS_PARMS
;
3319 sFrame
.pDSParms
->len
= 1;
3320 sFrame
.pDSParms
->byCurrChannel
= (BYTE
)uCurrChannel
;
3323 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) {
3324 sFrame
.pTIM
= (PWLAN_IE_TIM
)(sFrame
.pBuf
+ sFrame
.len
);
3325 sFrame
.pTIM
->byElementID
= WLAN_EID_TIM
;
3326 s_vMgrFormatTIM(pMgmt
, sFrame
.pTIM
);
3327 sFrame
.len
+= (WLAN_IEHDR_LEN
+ sFrame
.pTIM
->len
);
3330 if (pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) {
3333 sFrame
.pIBSSParms
= (PWLAN_IE_IBSS_PARMS
)(sFrame
.pBuf
+ sFrame
.len
);
3334 sFrame
.len
+= (2) + WLAN_IEHDR_LEN
;
3335 sFrame
.pIBSSParms
->byElementID
= WLAN_EID_IBSS_PARMS
;
3336 sFrame
.pIBSSParms
->len
= 2;
3337 sFrame
.pIBSSParms
->wATIMWindow
= wCurrATIMWinodw
;
3338 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPANONE
) {
3340 sFrame
.pRSNWPA
= (PWLAN_IE_RSN_EXT
)(sFrame
.pBuf
+ sFrame
.len
);
3341 sFrame
.pRSNWPA
->byElementID
= WLAN_EID_RSN_WPA
;
3342 sFrame
.pRSNWPA
->len
= 12;
3343 sFrame
.pRSNWPA
->abyOUI
[0] = 0x00;
3344 sFrame
.pRSNWPA
->abyOUI
[1] = 0x50;
3345 sFrame
.pRSNWPA
->abyOUI
[2] = 0xf2;
3346 sFrame
.pRSNWPA
->abyOUI
[3] = 0x01;
3347 sFrame
.pRSNWPA
->wVersion
= 1;
3348 sFrame
.pRSNWPA
->abyMulticast
[0] = 0x00;
3349 sFrame
.pRSNWPA
->abyMulticast
[1] = 0x50;
3350 sFrame
.pRSNWPA
->abyMulticast
[2] = 0xf2;
3351 if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
)
3352 sFrame
.pRSNWPA
->abyMulticast
[3] = 0x04;//AES
3353 else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
)
3354 sFrame
.pRSNWPA
->abyMulticast
[3] = 0x02;//TKIP
3355 else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption1Enabled
)
3356 sFrame
.pRSNWPA
->abyMulticast
[3] = 0x01;//WEP40
3358 sFrame
.pRSNWPA
->abyMulticast
[3] = 0x00;//NONE
3360 // Pairwise Key Cipher Suite
3361 sFrame
.pRSNWPA
->wPKCount
= 0;
3362 // Auth Key Management Suite
3363 *((PWORD
)(sFrame
.pBuf
+ sFrame
.len
+ sFrame
.pRSNWPA
->len
))=0;
3364 sFrame
.pRSNWPA
->len
+=2;
3367 *((PWORD
)(sFrame
.pBuf
+ sFrame
.len
+ sFrame
.pRSNWPA
->len
))=0;
3368 sFrame
.pRSNWPA
->len
+=2;
3369 sFrame
.len
+= sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
;
3374 if (pMgmt
->eCurrentPHYMode
== PHY_TYPE_11G
) {
3375 sFrame
.pERP
= (PWLAN_IE_ERP
)(sFrame
.pBuf
+ sFrame
.len
);
3376 sFrame
.len
+= 1 + WLAN_IEHDR_LEN
;
3377 sFrame
.pERP
->byElementID
= WLAN_EID_ERP
;
3378 sFrame
.pERP
->len
= 1;
3379 sFrame
.pERP
->byContext
= 0;
3380 if (pDevice
->bProtectMode
== TRUE
)
3381 sFrame
.pERP
->byContext
|= WLAN_EID_ERP_USE_PROTECTION
;
3382 if (pDevice
->bNonERPPresent
== TRUE
)
3383 sFrame
.pERP
->byContext
|= WLAN_EID_ERP_NONERP_PRESENT
;
3384 if (pDevice
->bBarkerPreambleMd
== TRUE
)
3385 sFrame
.pERP
->byContext
|= WLAN_EID_ERP_BARKER_MODE
;
3387 if (((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
!= 0) {
3388 sFrame
.pExtSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3389 sFrame
.len
+= ((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
;
3390 memcpy(sFrame
.pExtSuppRates
,
3392 ((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
3395 // hostapd wpa/wpa2 IE
3396 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) && (pDevice
->bEnableHostapd
== TRUE
)) {
3397 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPANONE
) {
3398 if (pMgmt
->wWPAIELen
!= 0) {
3399 sFrame
.pRSN
= (PWLAN_IE_RSN
)(sFrame
.pBuf
+ sFrame
.len
);
3400 memcpy(sFrame
.pRSN
, pMgmt
->abyWPAIE
, pMgmt
->wWPAIELen
);
3401 sFrame
.len
+= pMgmt
->wWPAIELen
;
3406 /* Adjust the length fields */
3407 pTxPacket
->cbMPDULen
= sFrame
.len
;
3408 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
3419 * Routine Description:
3420 * Constructs an Prob-response frame
3424 * PTR to frame; or NULL on allocation failue
3432 s_MgrMakeProbeResponse(
3433 IN PSDevice pDevice
,
3434 IN PSMgmtObject pMgmt
,
3435 IN WORD wCurrCapInfo
,
3436 IN WORD wCurrBeaconPeriod
,
3437 IN UINT uCurrChannel
,
3438 IN WORD wCurrATIMWinodw
,
3440 IN PWLAN_IE_SSID pCurrSSID
,
3441 IN PBYTE pCurrBSSID
,
3442 IN PWLAN_IE_SUPP_RATES pCurrSuppRates
,
3443 IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates
,
3447 PSTxMgmtPacket pTxPacket
= NULL
;
3448 WLAN_FR_PROBERESP sFrame
;
3452 pTxPacket
= (PSTxMgmtPacket
)pMgmt
->pbyMgmtPacketPool
;
3453 memset(pTxPacket
, 0, sizeof(STxMgmtPacket
) + WLAN_PROBERESP_FR_MAXLEN
);
3454 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((PBYTE
)pTxPacket
+ sizeof(STxMgmtPacket
));
3455 // Setup the sFrame structure.
3456 sFrame
.pBuf
= (PBYTE
)pTxPacket
->p80211Header
;
3457 sFrame
.len
= WLAN_PROBERESP_FR_MAXLEN
;
3458 vMgrEncodeProbeResponse(&sFrame
);
3460 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
3462 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
3463 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_PROBERESP
)
3465 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pDstAddr
, WLAN_ADDR_LEN
);
3466 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
3467 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pCurrBSSID
, WLAN_BSSID_LEN
);
3468 *sFrame
.pwBeaconInterval
= cpu_to_le16(wCurrBeaconPeriod
);
3469 *sFrame
.pwCapInfo
= cpu_to_le16(wCurrCapInfo
);
3471 if (byPHYType
== BB_TYPE_11B
) {
3472 *sFrame
.pwCapInfo
&= cpu_to_le16((WORD
)~(WLAN_SET_CAP_INFO_SHORTSLOTTIME(1)));
3476 sFrame
.pSSID
= (PWLAN_IE_SSID
)(sFrame
.pBuf
+ sFrame
.len
);
3477 sFrame
.len
+= ((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->len
+ WLAN_IEHDR_LEN
;
3478 memcpy(sFrame
.pSSID
,
3480 ((PWLAN_IE_SSID
)pCurrSSID
)->len
+ WLAN_IEHDR_LEN
3482 // Copy the rate set
3483 sFrame
.pSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3485 sFrame
.len
+= ((PWLAN_IE_SUPP_RATES
)pCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
;
3486 memcpy(sFrame
.pSuppRates
,
3488 ((PWLAN_IE_SUPP_RATES
)pCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
3492 if (pDevice
->byBBType
!= BB_TYPE_11A
) {
3493 sFrame
.pDSParms
= (PWLAN_IE_DS_PARMS
)(sFrame
.pBuf
+ sFrame
.len
);
3494 sFrame
.len
+= (1) + WLAN_IEHDR_LEN
;
3495 sFrame
.pDSParms
->byElementID
= WLAN_EID_DS_PARMS
;
3496 sFrame
.pDSParms
->len
= 1;
3497 sFrame
.pDSParms
->byCurrChannel
= (BYTE
)uCurrChannel
;
3500 if (pMgmt
->eCurrMode
!= WMAC_MODE_ESS_AP
) {
3502 sFrame
.pIBSSParms
= (PWLAN_IE_IBSS_PARMS
)(sFrame
.pBuf
+ sFrame
.len
);
3503 sFrame
.len
+= (2) + WLAN_IEHDR_LEN
;
3504 sFrame
.pIBSSParms
->byElementID
= WLAN_EID_IBSS_PARMS
;
3505 sFrame
.pIBSSParms
->len
= 2;
3506 sFrame
.pIBSSParms
->wATIMWindow
= 0;
3508 if (pDevice
->byBBType
== BB_TYPE_11G
) {
3509 sFrame
.pERP
= (PWLAN_IE_ERP
)(sFrame
.pBuf
+ sFrame
.len
);
3510 sFrame
.len
+= 1 + WLAN_IEHDR_LEN
;
3511 sFrame
.pERP
->byElementID
= WLAN_EID_ERP
;
3512 sFrame
.pERP
->len
= 1;
3513 sFrame
.pERP
->byContext
= 0;
3514 if (pDevice
->bProtectMode
== TRUE
)
3515 sFrame
.pERP
->byContext
|= WLAN_EID_ERP_USE_PROTECTION
;
3516 if (pDevice
->bNonERPPresent
== TRUE
)
3517 sFrame
.pERP
->byContext
|= WLAN_EID_ERP_NONERP_PRESENT
;
3518 if (pDevice
->bBarkerPreambleMd
== TRUE
)
3519 sFrame
.pERP
->byContext
|= WLAN_EID_ERP_BARKER_MODE
;
3522 if (((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
!= 0) {
3523 sFrame
.pExtSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3524 sFrame
.len
+= ((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
;
3525 memcpy(sFrame
.pExtSuppRates
,
3527 ((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
3531 // hostapd wpa/wpa2 IE
3532 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) && (pDevice
->bEnableHostapd
== TRUE
)) {
3533 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPANONE
) {
3534 if (pMgmt
->wWPAIELen
!= 0) {
3535 sFrame
.pRSN
= (PWLAN_IE_RSN
)(sFrame
.pBuf
+ sFrame
.len
);
3536 memcpy(sFrame
.pRSN
, pMgmt
->abyWPAIE
, pMgmt
->wWPAIELen
);
3537 sFrame
.len
+= pMgmt
->wWPAIELen
;
3542 // Adjust the length fields
3543 pTxPacket
->cbMPDULen
= sFrame
.len
;
3544 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
3553 * Routine Description:
3554 * Constructs an association request frame
3558 * A ptr to frame or NULL on allocation failue
3564 s_MgrMakeAssocRequest(
3565 IN PSDevice pDevice
,
3566 IN PSMgmtObject pMgmt
,
3568 IN WORD wCurrCapInfo
,
3569 IN WORD wListenInterval
,
3570 IN PWLAN_IE_SSID pCurrSSID
,
3571 IN PWLAN_IE_SUPP_RATES pCurrRates
,
3572 IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates
3575 PSTxMgmtPacket pTxPacket
= NULL
;
3576 WLAN_FR_ASSOCREQ sFrame
;
3581 pTxPacket
= (PSTxMgmtPacket
)pMgmt
->pbyMgmtPacketPool
;
3582 memset(pTxPacket
, 0, sizeof(STxMgmtPacket
) + WLAN_ASSOCREQ_FR_MAXLEN
);
3583 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((PBYTE
)pTxPacket
+ sizeof(STxMgmtPacket
));
3584 // Setup the sFrame structure.
3585 sFrame
.pBuf
= (PBYTE
)pTxPacket
->p80211Header
;
3586 sFrame
.len
= WLAN_ASSOCREQ_FR_MAXLEN
;
3587 // format fixed field frame structure
3588 vMgrEncodeAssocRequest(&sFrame
);
3590 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
3592 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
3593 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ASSOCREQ
)
3595 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pDAddr
, WLAN_ADDR_LEN
);
3596 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
3597 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
3599 // Set the capibility and listen interval
3600 *(sFrame
.pwCapInfo
) = cpu_to_le16(wCurrCapInfo
);
3601 *(sFrame
.pwListenInterval
) = cpu_to_le16(wListenInterval
);
3603 // sFrame.len point to end of fixed field
3604 sFrame
.pSSID
= (PWLAN_IE_SSID
)(sFrame
.pBuf
+ sFrame
.len
);
3605 sFrame
.len
+= pCurrSSID
->len
+ WLAN_IEHDR_LEN
;
3606 memcpy(sFrame
.pSSID
, pCurrSSID
, pCurrSSID
->len
+ WLAN_IEHDR_LEN
);
3608 pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
= pCurrSSID
->len
+ WLAN_IEHDR_LEN
;
3609 pMgmt
->sAssocInfo
.AssocInfo
.OffsetRequestIEs
= sizeof(NDIS_802_11_ASSOCIATION_INFORMATION
);
3610 pbyIEs
= pMgmt
->sAssocInfo
.abyIEs
;
3611 memcpy(pbyIEs
, pCurrSSID
, pCurrSSID
->len
+ WLAN_IEHDR_LEN
);
3612 pbyIEs
+= pCurrSSID
->len
+ WLAN_IEHDR_LEN
;
3614 // Copy the rate set
3615 sFrame
.pSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3616 if ((pDevice
->byBBType
== BB_TYPE_11B
) && (pCurrRates
->len
> 4))
3617 sFrame
.len
+= 4 + WLAN_IEHDR_LEN
;
3619 sFrame
.len
+= pCurrRates
->len
+ WLAN_IEHDR_LEN
;
3620 memcpy(sFrame
.pSuppRates
, pCurrRates
, pCurrRates
->len
+ WLAN_IEHDR_LEN
);
3622 // Copy the extension rate set
3623 if ((pDevice
->byBBType
== BB_TYPE_11G
) && (pCurrExtSuppRates
->len
> 0)) {
3624 sFrame
.pExtSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3625 sFrame
.len
+= pCurrExtSuppRates
->len
+ WLAN_IEHDR_LEN
;
3626 memcpy(sFrame
.pExtSuppRates
, pCurrExtSuppRates
, pCurrExtSuppRates
->len
+ WLAN_IEHDR_LEN
);
3629 pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
+= pCurrRates
->len
+ WLAN_IEHDR_LEN
;
3630 memcpy(pbyIEs
, pCurrRates
, pCurrRates
->len
+ WLAN_IEHDR_LEN
);
3631 pbyIEs
+= pCurrRates
->len
+ WLAN_IEHDR_LEN
;
3634 if (((pMgmt
->eAuthenMode
== WMAC_AUTH_WPA
) ||
3635 (pMgmt
->eAuthenMode
== WMAC_AUTH_WPAPSK
) ||
3636 (pMgmt
->eAuthenMode
== WMAC_AUTH_WPANONE
)) &&
3637 (pMgmt
->pCurrBSS
!= NULL
)) {
3639 sFrame
.pRSNWPA
= (PWLAN_IE_RSN_EXT
)(sFrame
.pBuf
+ sFrame
.len
);
3640 sFrame
.pRSNWPA
->byElementID
= WLAN_EID_RSN_WPA
;
3641 sFrame
.pRSNWPA
->len
= 16;
3642 sFrame
.pRSNWPA
->abyOUI
[0] = 0x00;
3643 sFrame
.pRSNWPA
->abyOUI
[1] = 0x50;
3644 sFrame
.pRSNWPA
->abyOUI
[2] = 0xf2;
3645 sFrame
.pRSNWPA
->abyOUI
[3] = 0x01;
3646 sFrame
.pRSNWPA
->wVersion
= 1;
3647 //Group Key Cipher Suite
3648 sFrame
.pRSNWPA
->abyMulticast
[0] = 0x00;
3649 sFrame
.pRSNWPA
->abyMulticast
[1] = 0x50;
3650 sFrame
.pRSNWPA
->abyMulticast
[2] = 0xf2;
3651 if (pMgmt
->byCSSGK
== KEY_CTL_WEP
) {
3652 sFrame
.pRSNWPA
->abyMulticast
[3] = pMgmt
->pCurrBSS
->byGKType
;
3653 } else if (pMgmt
->byCSSGK
== KEY_CTL_TKIP
) {
3654 sFrame
.pRSNWPA
->abyMulticast
[3] = WPA_TKIP
;
3655 } else if (pMgmt
->byCSSGK
== KEY_CTL_CCMP
) {
3656 sFrame
.pRSNWPA
->abyMulticast
[3] = WPA_AESCCMP
;
3658 sFrame
.pRSNWPA
->abyMulticast
[3] = WPA_NONE
;
3660 // Pairwise Key Cipher Suite
3661 sFrame
.pRSNWPA
->wPKCount
= 1;
3662 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[0] = 0x00;
3663 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[1] = 0x50;
3664 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[2] = 0xf2;
3665 if (pMgmt
->byCSSPK
== KEY_CTL_TKIP
) {
3666 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[3] = WPA_TKIP
;
3667 } else if (pMgmt
->byCSSPK
== KEY_CTL_CCMP
) {
3668 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[3] = WPA_AESCCMP
;
3670 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[3] = WPA_NONE
;
3672 // Auth Key Management Suite
3673 pbyRSN
= (PBYTE
)(sFrame
.pBuf
+ sFrame
.len
+ 2 + sFrame
.pRSNWPA
->len
);
3680 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPAPSK
) {
3681 *pbyRSN
++=WPA_AUTH_PSK
;
3683 else if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA
) {
3684 *pbyRSN
++=WPA_AUTH_IEEE802_1X
;
3690 sFrame
.pRSNWPA
->len
+=6;
3696 sFrame
.pRSNWPA
->len
+=2;
3698 sFrame
.len
+= sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
;
3699 // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION
3700 pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
+= sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
;
3701 memcpy(pbyIEs
, sFrame
.pRSNWPA
, sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
);
3702 pbyIEs
+= sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
;
3704 } else if (((pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2
) ||
3705 (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2PSK
)) &&
3706 (pMgmt
->pCurrBSS
!= NULL
)) {
3711 sFrame
.pRSN
= (PWLAN_IE_RSN
)(sFrame
.pBuf
+ sFrame
.len
);
3712 sFrame
.pRSN
->byElementID
= WLAN_EID_RSN
;
3713 sFrame
.pRSN
->len
= 6; //Version(2)+GK(4)
3714 sFrame
.pRSN
->wVersion
= 1;
3715 //Group Key Cipher Suite
3716 sFrame
.pRSN
->abyRSN
[0] = 0x00;
3717 sFrame
.pRSN
->abyRSN
[1] = 0x0F;
3718 sFrame
.pRSN
->abyRSN
[2] = 0xAC;
3719 if (pMgmt
->byCSSGK
== KEY_CTL_WEP
) {
3720 sFrame
.pRSN
->abyRSN
[3] = pMgmt
->pCurrBSS
->byCSSGK
;
3721 } else if (pMgmt
->byCSSGK
== KEY_CTL_TKIP
) {
3722 sFrame
.pRSN
->abyRSN
[3] = WLAN_11i_CSS_TKIP
;
3723 } else if (pMgmt
->byCSSGK
== KEY_CTL_CCMP
) {
3724 sFrame
.pRSN
->abyRSN
[3] = WLAN_11i_CSS_CCMP
;
3726 sFrame
.pRSN
->abyRSN
[3] = WLAN_11i_CSS_UNKNOWN
;
3729 // Pairwise Key Cipher Suite
3730 sFrame
.pRSN
->abyRSN
[4] = 1;
3731 sFrame
.pRSN
->abyRSN
[5] = 0;
3732 sFrame
.pRSN
->abyRSN
[6] = 0x00;
3733 sFrame
.pRSN
->abyRSN
[7] = 0x0F;
3734 sFrame
.pRSN
->abyRSN
[8] = 0xAC;
3735 if (pMgmt
->byCSSPK
== KEY_CTL_TKIP
) {
3736 sFrame
.pRSN
->abyRSN
[9] = WLAN_11i_CSS_TKIP
;
3737 } else if (pMgmt
->byCSSPK
== KEY_CTL_CCMP
) {
3738 sFrame
.pRSN
->abyRSN
[9] = WLAN_11i_CSS_CCMP
;
3739 } else if (pMgmt
->byCSSPK
== KEY_CTL_NONE
) {
3740 sFrame
.pRSN
->abyRSN
[9] = WLAN_11i_CSS_USE_GROUP
;
3742 sFrame
.pRSN
->abyRSN
[9] = WLAN_11i_CSS_UNKNOWN
;
3744 sFrame
.pRSN
->len
+= 6;
3746 // Auth Key Management Suite
3747 sFrame
.pRSN
->abyRSN
[10] = 1;
3748 sFrame
.pRSN
->abyRSN
[11] = 0;
3749 sFrame
.pRSN
->abyRSN
[12] = 0x00;
3750 sFrame
.pRSN
->abyRSN
[13] = 0x0F;
3751 sFrame
.pRSN
->abyRSN
[14] = 0xAC;
3752 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2PSK
) {
3753 sFrame
.pRSN
->abyRSN
[15] = WLAN_11i_AKMSS_PSK
;
3754 } else if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2
) {
3755 sFrame
.pRSN
->abyRSN
[15] = WLAN_11i_AKMSS_802_1X
;
3757 sFrame
.pRSN
->abyRSN
[15] = WLAN_11i_AKMSS_UNKNOWN
;
3759 sFrame
.pRSN
->len
+=6;
3762 if (pMgmt
->pCurrBSS
->sRSNCapObj
.bRSNCapExist
== TRUE
) {
3763 memcpy(&sFrame
.pRSN
->abyRSN
[16], &pMgmt
->pCurrBSS
->sRSNCapObj
.wRSNCap
, 2);
3765 sFrame
.pRSN
->abyRSN
[16] = 0;
3766 sFrame
.pRSN
->abyRSN
[17] = 0;
3768 sFrame
.pRSN
->len
+=2;
3770 if ((pDevice
->gsPMKID
.BSSIDInfoCount
> 0) && (pDevice
->bRoaming
== TRUE
) && (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2
)) {
3772 pbyRSN
= &sFrame
.pRSN
->abyRSN
[18];
3773 pwPMKID
= (PWORD
)pbyRSN
; // Point to PMKID count
3774 *pwPMKID
= 0; // Initialize PMKID count
3775 pbyRSN
+= 2; // Point to PMKID list
3776 for (ii
= 0; ii
< pDevice
->gsPMKID
.BSSIDInfoCount
; ii
++) {
3777 if ( !memcmp(&pDevice
->gsPMKID
.BSSIDInfo
[ii
].BSSID
[0], pMgmt
->abyCurrBSSID
, U_ETHER_ADDR_LEN
)) {
3779 memcpy(pbyRSN
, pDevice
->gsPMKID
.BSSIDInfo
[ii
].PMKID
, 16);
3783 if (*pwPMKID
!= 0) {
3784 sFrame
.pRSN
->len
+= (2 + (*pwPMKID
)*16);
3788 sFrame
.len
+= sFrame
.pRSN
->len
+ WLAN_IEHDR_LEN
;
3789 // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION
3790 pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
+= sFrame
.pRSN
->len
+ WLAN_IEHDR_LEN
;
3791 memcpy(pbyIEs
, sFrame
.pRSN
, sFrame
.pRSN
->len
+ WLAN_IEHDR_LEN
);
3792 pbyIEs
+= sFrame
.pRSN
->len
+ WLAN_IEHDR_LEN
;
3796 // Adjust the length fields
3797 pTxPacket
->cbMPDULen
= sFrame
.len
;
3798 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
3811 * Routine Description:
3812 * Constructs an re-association request frame
3816 * A ptr to frame or NULL on allocation failue
3822 s_MgrMakeReAssocRequest(
3823 IN PSDevice pDevice
,
3824 IN PSMgmtObject pMgmt
,
3826 IN WORD wCurrCapInfo
,
3827 IN WORD wListenInterval
,
3828 IN PWLAN_IE_SSID pCurrSSID
,
3829 IN PWLAN_IE_SUPP_RATES pCurrRates
,
3830 IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates
3833 PSTxMgmtPacket pTxPacket
= NULL
;
3834 WLAN_FR_REASSOCREQ sFrame
;
3839 pTxPacket
= (PSTxMgmtPacket
)pMgmt
->pbyMgmtPacketPool
;
3840 memset( pTxPacket
, 0, sizeof(STxMgmtPacket
) + WLAN_REASSOCREQ_FR_MAXLEN
);
3841 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((PBYTE
)pTxPacket
+ sizeof(STxMgmtPacket
));
3842 /* Setup the sFrame structure. */
3843 sFrame
.pBuf
= (PBYTE
)pTxPacket
->p80211Header
;
3844 sFrame
.len
= WLAN_REASSOCREQ_FR_MAXLEN
;
3846 // format fixed field frame structure
3847 vMgrEncodeReassocRequest(&sFrame
);
3849 /* Setup the header */
3850 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
3852 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
3853 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_REASSOCREQ
)
3855 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pDAddr
, WLAN_ADDR_LEN
);
3856 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
3857 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
3859 /* Set the capibility and listen interval */
3860 *(sFrame
.pwCapInfo
) = cpu_to_le16(wCurrCapInfo
);
3861 *(sFrame
.pwListenInterval
) = cpu_to_le16(wListenInterval
);
3863 memcpy(sFrame
.pAddrCurrAP
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
3865 /* sFrame.len point to end of fixed field */
3866 sFrame
.pSSID
= (PWLAN_IE_SSID
)(sFrame
.pBuf
+ sFrame
.len
);
3867 sFrame
.len
+= pCurrSSID
->len
+ WLAN_IEHDR_LEN
;
3868 memcpy(sFrame
.pSSID
, pCurrSSID
, pCurrSSID
->len
+ WLAN_IEHDR_LEN
);
3870 pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
= pCurrSSID
->len
+ WLAN_IEHDR_LEN
;
3871 pMgmt
->sAssocInfo
.AssocInfo
.OffsetRequestIEs
= sizeof(NDIS_802_11_ASSOCIATION_INFORMATION
);
3872 pbyIEs
= pMgmt
->sAssocInfo
.abyIEs
;
3873 memcpy(pbyIEs
, pCurrSSID
, pCurrSSID
->len
+ WLAN_IEHDR_LEN
);
3874 pbyIEs
+= pCurrSSID
->len
+ WLAN_IEHDR_LEN
;
3876 /* Copy the rate set */
3877 /* sFrame.len point to end of SSID */
3878 sFrame
.pSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3879 sFrame
.len
+= pCurrRates
->len
+ WLAN_IEHDR_LEN
;
3880 memcpy(sFrame
.pSuppRates
, pCurrRates
, pCurrRates
->len
+ WLAN_IEHDR_LEN
);
3882 // Copy the extension rate set
3883 if ((pMgmt
->eCurrentPHYMode
== PHY_TYPE_11G
) && (pCurrExtSuppRates
->len
> 0)) {
3884 sFrame
.pExtSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3885 sFrame
.len
+= pCurrExtSuppRates
->len
+ WLAN_IEHDR_LEN
;
3886 memcpy(sFrame
.pExtSuppRates
, pCurrExtSuppRates
, pCurrExtSuppRates
->len
+ WLAN_IEHDR_LEN
);
3889 pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
+= pCurrRates
->len
+ WLAN_IEHDR_LEN
;
3890 memcpy(pbyIEs
, pCurrRates
, pCurrRates
->len
+ WLAN_IEHDR_LEN
);
3891 pbyIEs
+= pCurrRates
->len
+ WLAN_IEHDR_LEN
;
3893 if (((pMgmt
->eAuthenMode
== WMAC_AUTH_WPA
) ||
3894 (pMgmt
->eAuthenMode
== WMAC_AUTH_WPAPSK
) ||
3895 (pMgmt
->eAuthenMode
== WMAC_AUTH_WPANONE
)) &&
3896 (pMgmt
->pCurrBSS
!= NULL
)) {
3898 sFrame
.pRSNWPA
= (PWLAN_IE_RSN_EXT
)(sFrame
.pBuf
+ sFrame
.len
);
3899 sFrame
.pRSNWPA
->byElementID
= WLAN_EID_RSN_WPA
;
3900 sFrame
.pRSNWPA
->len
= 16;
3901 sFrame
.pRSNWPA
->abyOUI
[0] = 0x00;
3902 sFrame
.pRSNWPA
->abyOUI
[1] = 0x50;
3903 sFrame
.pRSNWPA
->abyOUI
[2] = 0xf2;
3904 sFrame
.pRSNWPA
->abyOUI
[3] = 0x01;
3905 sFrame
.pRSNWPA
->wVersion
= 1;
3906 //Group Key Cipher Suite
3907 sFrame
.pRSNWPA
->abyMulticast
[0] = 0x00;
3908 sFrame
.pRSNWPA
->abyMulticast
[1] = 0x50;
3909 sFrame
.pRSNWPA
->abyMulticast
[2] = 0xf2;
3910 if (pMgmt
->byCSSGK
== KEY_CTL_WEP
) {
3911 sFrame
.pRSNWPA
->abyMulticast
[3] = pMgmt
->pCurrBSS
->byGKType
;
3912 } else if (pMgmt
->byCSSGK
== KEY_CTL_TKIP
) {
3913 sFrame
.pRSNWPA
->abyMulticast
[3] = WPA_TKIP
;
3914 } else if (pMgmt
->byCSSGK
== KEY_CTL_CCMP
) {
3915 sFrame
.pRSNWPA
->abyMulticast
[3] = WPA_AESCCMP
;
3917 sFrame
.pRSNWPA
->abyMulticast
[3] = WPA_NONE
;
3919 // Pairwise Key Cipher Suite
3920 sFrame
.pRSNWPA
->wPKCount
= 1;
3921 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[0] = 0x00;
3922 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[1] = 0x50;
3923 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[2] = 0xf2;
3924 if (pMgmt
->byCSSPK
== KEY_CTL_TKIP
) {
3925 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[3] = WPA_TKIP
;
3926 } else if (pMgmt
->byCSSPK
== KEY_CTL_CCMP
) {
3927 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[3] = WPA_AESCCMP
;
3929 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[3] = WPA_NONE
;
3931 // Auth Key Management Suite
3932 pbyRSN
= (PBYTE
)(sFrame
.pBuf
+ sFrame
.len
+ 2 + sFrame
.pRSNWPA
->len
);
3939 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPAPSK
) {
3940 *pbyRSN
++=WPA_AUTH_PSK
;
3941 } else if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA
) {
3942 *pbyRSN
++=WPA_AUTH_IEEE802_1X
;
3947 sFrame
.pRSNWPA
->len
+=6;
3952 sFrame
.pRSNWPA
->len
+=2;
3954 sFrame
.len
+= sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
;
3955 // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION
3956 pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
+= sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
;
3957 memcpy(pbyIEs
, sFrame
.pRSNWPA
, sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
);
3958 pbyIEs
+= sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
;
3960 } else if (((pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2
) ||
3961 (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2PSK
)) &&
3962 (pMgmt
->pCurrBSS
!= NULL
)) {
3967 sFrame
.pRSN
= (PWLAN_IE_RSN
)(sFrame
.pBuf
+ sFrame
.len
);
3968 sFrame
.pRSN
->byElementID
= WLAN_EID_RSN
;
3969 sFrame
.pRSN
->len
= 6; //Version(2)+GK(4)
3970 sFrame
.pRSN
->wVersion
= 1;
3971 //Group Key Cipher Suite
3972 sFrame
.pRSN
->abyRSN
[0] = 0x00;
3973 sFrame
.pRSN
->abyRSN
[1] = 0x0F;
3974 sFrame
.pRSN
->abyRSN
[2] = 0xAC;
3975 if (pMgmt
->byCSSGK
== KEY_CTL_WEP
) {
3976 sFrame
.pRSN
->abyRSN
[3] = pMgmt
->pCurrBSS
->byCSSGK
;
3977 } else if (pMgmt
->byCSSGK
== KEY_CTL_TKIP
) {
3978 sFrame
.pRSN
->abyRSN
[3] = WLAN_11i_CSS_TKIP
;
3979 } else if (pMgmt
->byCSSGK
== KEY_CTL_CCMP
) {
3980 sFrame
.pRSN
->abyRSN
[3] = WLAN_11i_CSS_CCMP
;
3982 sFrame
.pRSN
->abyRSN
[3] = WLAN_11i_CSS_UNKNOWN
;
3985 // Pairwise Key Cipher Suite
3986 sFrame
.pRSN
->abyRSN
[4] = 1;
3987 sFrame
.pRSN
->abyRSN
[5] = 0;
3988 sFrame
.pRSN
->abyRSN
[6] = 0x00;
3989 sFrame
.pRSN
->abyRSN
[7] = 0x0F;
3990 sFrame
.pRSN
->abyRSN
[8] = 0xAC;
3991 if (pMgmt
->byCSSPK
== KEY_CTL_TKIP
) {
3992 sFrame
.pRSN
->abyRSN
[9] = WLAN_11i_CSS_TKIP
;
3993 } else if (pMgmt
->byCSSPK
== KEY_CTL_CCMP
) {
3994 sFrame
.pRSN
->abyRSN
[9] = WLAN_11i_CSS_CCMP
;
3995 } else if (pMgmt
->byCSSPK
== KEY_CTL_NONE
) {
3996 sFrame
.pRSN
->abyRSN
[9] = WLAN_11i_CSS_USE_GROUP
;
3998 sFrame
.pRSN
->abyRSN
[9] = WLAN_11i_CSS_UNKNOWN
;
4000 sFrame
.pRSN
->len
+= 6;
4002 // Auth Key Management Suite
4003 sFrame
.pRSN
->abyRSN
[10] = 1;
4004 sFrame
.pRSN
->abyRSN
[11] = 0;
4005 sFrame
.pRSN
->abyRSN
[12] = 0x00;
4006 sFrame
.pRSN
->abyRSN
[13] = 0x0F;
4007 sFrame
.pRSN
->abyRSN
[14] = 0xAC;
4008 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2PSK
) {
4009 sFrame
.pRSN
->abyRSN
[15] = WLAN_11i_AKMSS_PSK
;
4010 } else if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2
) {
4011 sFrame
.pRSN
->abyRSN
[15] = WLAN_11i_AKMSS_802_1X
;
4013 sFrame
.pRSN
->abyRSN
[15] = WLAN_11i_AKMSS_UNKNOWN
;
4015 sFrame
.pRSN
->len
+=6;
4018 if (pMgmt
->pCurrBSS
->sRSNCapObj
.bRSNCapExist
== TRUE
) {
4019 memcpy(&sFrame
.pRSN
->abyRSN
[16], &pMgmt
->pCurrBSS
->sRSNCapObj
.wRSNCap
, 2);
4021 sFrame
.pRSN
->abyRSN
[16] = 0;
4022 sFrame
.pRSN
->abyRSN
[17] = 0;
4024 sFrame
.pRSN
->len
+=2;
4026 if ((pDevice
->gsPMKID
.BSSIDInfoCount
> 0) && (pDevice
->bRoaming
== TRUE
) && (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2
)) {
4028 pbyRSN
= &sFrame
.pRSN
->abyRSN
[18];
4029 pwPMKID
= (PWORD
)pbyRSN
; // Point to PMKID count
4030 *pwPMKID
= 0; // Initialize PMKID count
4031 pbyRSN
+= 2; // Point to PMKID list
4032 for (ii
= 0; ii
< pDevice
->gsPMKID
.BSSIDInfoCount
; ii
++) {
4033 if ( !memcmp(&pDevice
->gsPMKID
.BSSIDInfo
[ii
].BSSID
[0], pMgmt
->abyCurrBSSID
, U_ETHER_ADDR_LEN
)) {
4035 memcpy(pbyRSN
, pDevice
->gsPMKID
.BSSIDInfo
[ii
].PMKID
, 16);
4039 if (*pwPMKID
!= 0) {
4040 sFrame
.pRSN
->len
+= (2 + (*pwPMKID
)*16);
4044 sFrame
.len
+= sFrame
.pRSN
->len
+ WLAN_IEHDR_LEN
;
4045 // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION
4046 pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
+= sFrame
.pRSN
->len
+ WLAN_IEHDR_LEN
;
4047 memcpy(pbyIEs
, sFrame
.pRSN
, sFrame
.pRSN
->len
+ WLAN_IEHDR_LEN
);
4048 pbyIEs
+= sFrame
.pRSN
->len
+ WLAN_IEHDR_LEN
;
4053 /* Adjust the length fields */
4054 pTxPacket
->cbMPDULen
= sFrame
.len
;
4055 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
4064 * Routine Description:
4065 * Constructs an assoc-response frame
4069 * PTR to frame; or NULL on allocation failue
4075 s_MgrMakeAssocResponse(
4076 IN PSDevice pDevice
,
4077 IN PSMgmtObject pMgmt
,
4078 IN WORD wCurrCapInfo
,
4079 IN WORD wAssocStatus
,
4082 IN PWLAN_IE_SUPP_RATES pCurrSuppRates
,
4083 IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates
4086 PSTxMgmtPacket pTxPacket
= NULL
;
4087 WLAN_FR_ASSOCRESP sFrame
;
4090 pTxPacket
= (PSTxMgmtPacket
)pMgmt
->pbyMgmtPacketPool
;
4091 memset(pTxPacket
, 0, sizeof(STxMgmtPacket
) + WLAN_ASSOCREQ_FR_MAXLEN
);
4092 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((PBYTE
)pTxPacket
+ sizeof(STxMgmtPacket
));
4093 // Setup the sFrame structure
4094 sFrame
.pBuf
= (PBYTE
)pTxPacket
->p80211Header
;
4095 sFrame
.len
= WLAN_REASSOCRESP_FR_MAXLEN
;
4096 vMgrEncodeAssocResponse(&sFrame
);
4098 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
4100 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
4101 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ASSOCRESP
)
4103 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pDstAddr
, WLAN_ADDR_LEN
);
4104 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
4105 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
4107 *sFrame
.pwCapInfo
= cpu_to_le16(wCurrCapInfo
);
4108 *sFrame
.pwStatus
= cpu_to_le16(wAssocStatus
);
4109 *sFrame
.pwAid
= cpu_to_le16((WORD
)(wAssocAID
| BIT14
| BIT15
));
4111 // Copy the rate set
4112 sFrame
.pSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
4113 sFrame
.len
+= ((PWLAN_IE_SUPP_RATES
)pCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
;
4114 memcpy(sFrame
.pSuppRates
,
4116 ((PWLAN_IE_SUPP_RATES
)pCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
4119 if (((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
!= 0) {
4120 sFrame
.pExtSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
4121 sFrame
.len
+= ((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
;
4122 memcpy(sFrame
.pExtSuppRates
,
4124 ((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
4128 // Adjust the length fields
4129 pTxPacket
->cbMPDULen
= sFrame
.len
;
4130 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
4138 * Routine Description:
4139 * Constructs an reassoc-response frame
4143 * PTR to frame; or NULL on allocation failue
4149 s_MgrMakeReAssocResponse(
4150 IN PSDevice pDevice
,
4151 IN PSMgmtObject pMgmt
,
4152 IN WORD wCurrCapInfo
,
4153 IN WORD wAssocStatus
,
4156 IN PWLAN_IE_SUPP_RATES pCurrSuppRates
,
4157 IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates
4160 PSTxMgmtPacket pTxPacket
= NULL
;
4161 WLAN_FR_REASSOCRESP sFrame
;
4164 pTxPacket
= (PSTxMgmtPacket
)pMgmt
->pbyMgmtPacketPool
;
4165 memset(pTxPacket
, 0, sizeof(STxMgmtPacket
) + WLAN_ASSOCREQ_FR_MAXLEN
);
4166 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((PBYTE
)pTxPacket
+ sizeof(STxMgmtPacket
));
4167 // Setup the sFrame structure
4168 sFrame
.pBuf
= (PBYTE
)pTxPacket
->p80211Header
;
4169 sFrame
.len
= WLAN_REASSOCRESP_FR_MAXLEN
;
4170 vMgrEncodeReassocResponse(&sFrame
);
4172 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
4174 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
4175 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_REASSOCRESP
)
4177 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pDstAddr
, WLAN_ADDR_LEN
);
4178 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
4179 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
4181 *sFrame
.pwCapInfo
= cpu_to_le16(wCurrCapInfo
);
4182 *sFrame
.pwStatus
= cpu_to_le16(wAssocStatus
);
4183 *sFrame
.pwAid
= cpu_to_le16((WORD
)(wAssocAID
| BIT14
| BIT15
));
4185 // Copy the rate set
4186 sFrame
.pSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
4187 sFrame
.len
+= ((PWLAN_IE_SUPP_RATES
)pCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
;
4188 memcpy(sFrame
.pSuppRates
,
4190 ((PWLAN_IE_SUPP_RATES
)pCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
4193 if (((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
!= 0) {
4194 sFrame
.pExtSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
4195 sFrame
.len
+= ((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
;
4196 memcpy(sFrame
.pExtSuppRates
,
4198 ((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
4202 // Adjust the length fields
4203 pTxPacket
->cbMPDULen
= sFrame
.len
;
4204 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
4212 * Routine Description:
4213 * Handles probe response management frames.
4223 s_vMgrRxProbeResponse(
4224 IN PSDevice pDevice
,
4225 IN PSMgmtObject pMgmt
,
4226 IN PSRxMgmtPacket pRxPacket
4229 PKnownBSS pBSSList
= NULL
;
4230 WLAN_FR_PROBERESP sFrame
;
4231 BYTE byCurrChannel
= pRxPacket
->byRxChannel
;
4233 BOOL bChannelHit
= TRUE
;
4236 memset(&sFrame
, 0, sizeof(WLAN_FR_PROBERESP
));
4238 sFrame
.len
= pRxPacket
->cbMPDULen
;
4239 sFrame
.pBuf
= (PBYTE
)pRxPacket
->p80211Header
;
4240 vMgrDecodeProbeResponse(&sFrame
);
4242 if ((sFrame
.pqwTimestamp
== 0) ||
4243 (sFrame
.pwBeaconInterval
== 0) ||
4244 (sFrame
.pwCapInfo
== 0) ||
4245 (sFrame
.pSSID
== 0) ||
4246 (sFrame
.pSuppRates
== 0)) {
4247 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Probe resp:Fail addr:[%p] \n", pRxPacket
->p80211Header
);
4252 if(sFrame
.pSSID
->len
== 0)
4253 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Rx Probe resp: SSID len = 0 \n");
4256 //{{ RobertYu:20050201, 11a byCurrChannel != sFrame.pDSParms->byCurrChannel mapping
4257 if( byCurrChannel
> CB_MAX_CHANNEL_24G
)
4259 if (sFrame
.pDSParms
!= 0) {
4260 if (byCurrChannel
== RFaby11aChannelIndex
[sFrame
.pDSParms
->byCurrChannel
-1])
4262 byCurrChannel
= RFaby11aChannelIndex
[sFrame
.pDSParms
->byCurrChannel
-1];
4268 if (sFrame
.pDSParms
!= 0) {
4269 if (byCurrChannel
== sFrame
.pDSParms
->byCurrChannel
)
4271 byCurrChannel
= sFrame
.pDSParms
->byCurrChannel
;
4278 //2008-0730-01<Add>by MikeLiu
4279 if(ChannelExceedZoneType(pDevice
,byCurrChannel
)==TRUE
)
4282 if (sFrame
.pERP
!= NULL
) {
4283 sERP
.byERP
= sFrame
.pERP
->byContext
;
4284 sERP
.bERPExist
= TRUE
;
4286 sERP
.bERPExist
= FALSE
;
4291 // update or insert the bss
4292 pBSSList
= BSSpAddrIsInBSSList((HANDLE
)pDevice
, sFrame
.pHdr
->sA3
.abyAddr3
, sFrame
.pSSID
);
4294 BSSbUpdateToBSSList((HANDLE
)pDevice
,
4295 *sFrame
.pqwTimestamp
,
4296 *sFrame
.pwBeaconInterval
,
4302 sFrame
.pExtSuppRates
,
4309 sFrame
.len
- WLAN_HDR_ADDR3_LEN
,
4310 sFrame
.pHdr
->sA4
.abyAddr4
, // payload of probresponse
4315 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Probe resp/insert: RxChannel = : %d\n", byCurrChannel
);
4316 BSSbInsertToBSSList((HANDLE
)pDevice
,
4317 sFrame
.pHdr
->sA3
.abyAddr3
,
4318 *sFrame
.pqwTimestamp
,
4319 *sFrame
.pwBeaconInterval
,
4324 sFrame
.pExtSuppRates
,
4330 sFrame
.len
- WLAN_HDR_ADDR3_LEN
,
4331 sFrame
.pHdr
->sA4
.abyAddr4
, // payload of beacon
4341 * Routine Description:(AP)or(Ad-hoc STA)
4342 * Handles probe request management frames.
4353 s_vMgrRxProbeRequest(
4354 IN PSDevice pDevice
,
4355 IN PSMgmtObject pMgmt
,
4356 IN PSRxMgmtPacket pRxPacket
4359 WLAN_FR_PROBEREQ sFrame
;
4361 PSTxMgmtPacket pTxPacket
;
4362 BYTE byPHYType
= BB_TYPE_11B
;
4364 // STA in Ad-hoc mode: when latest TBTT beacon transmit success,
4365 // STA have to response this request.
4366 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) ||
4367 ((pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) && pDevice
->bBeaconSent
)) {
4369 memset(&sFrame
, 0, sizeof(WLAN_FR_PROBEREQ
));
4371 sFrame
.len
= pRxPacket
->cbMPDULen
;
4372 sFrame
.pBuf
= (PBYTE
)pRxPacket
->p80211Header
;
4373 vMgrDecodeProbeRequest(&sFrame
);
4375 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request rx:MAC addr:%02x-%02x-%02x=%02x-%02x-%02x \n",
4376 sFrame.pHdr->sA3.abyAddr2[0],
4377 sFrame.pHdr->sA3.abyAddr2[1],
4378 sFrame.pHdr->sA3.abyAddr2[2],
4379 sFrame.pHdr->sA3.abyAddr2[3],
4380 sFrame.pHdr->sA3.abyAddr2[4],
4381 sFrame.pHdr->sA3.abyAddr2[5]
4384 if (sFrame
.pSSID
->len
!= 0) {
4385 if (sFrame
.pSSID
->len
!= ((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->len
)
4387 if (memcmp(sFrame
.pSSID
->abySSID
,
4388 ((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->abySSID
,
4389 ((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->len
) != 0) {
4394 if ((sFrame
.pSuppRates
->len
> 4) || (sFrame
.pExtSuppRates
!= NULL
)) {
4395 byPHYType
= BB_TYPE_11G
;
4398 // Probe response reply..
4399 pTxPacket
= s_MgrMakeProbeResponse
4403 pMgmt
->wCurrCapInfo
,
4404 pMgmt
->wCurrBeaconPeriod
,
4405 pMgmt
->uCurrChannel
,
4407 sFrame
.pHdr
->sA3
.abyAddr2
,
4408 (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
,
4409 (PBYTE
)pMgmt
->abyCurrBSSID
,
4410 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
4411 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
,
4414 if (pTxPacket
!= NULL
){
4415 /* send the frame */
4416 Status
= csMgmt_xmit(pDevice
, pTxPacket
);
4417 if (Status
!= CMD_STATUS_PENDING
) {
4418 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Probe response tx failed\n");
4421 // DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Probe response tx sending..\n");
4435 * Routine Description:
4437 * Entry point for the reception and handling of 802.11 management
4438 * frames. Makes a determination of the frame type and then calls
4439 * the appropriate function.
4450 IN HANDLE hDeviceContext
,
4451 IN PSMgmtObject pMgmt
,
4452 IN PSRxMgmtPacket pRxPacket
4455 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
4456 BOOL bInScan
= FALSE
;
4457 UINT uNodeIndex
= 0;
4458 NODE_STATE eNodeState
= 0;
4462 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) {
4463 if (BSSbIsSTAInNodeDB(pDevice
, pRxPacket
->p80211Header
->sA3
.abyAddr2
, &uNodeIndex
))
4464 eNodeState
= pMgmt
->sNodeDBTable
[uNodeIndex
].eNodeState
;
4467 switch( WLAN_GET_FC_FSTYPE((pRxPacket
->p80211Header
->sA3
.wFrameCtl
)) ){
4469 case WLAN_FSTYPE_ASSOCREQ
:
4471 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx assocreq\n");
4472 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) &&
4473 (eNodeState
< NODE_AUTH
)) {
4474 // send deauth notification
4475 // reason = (6) class 2 received from nonauth sta
4476 vMgrDeAuthenBeginSta(pDevice
,
4478 pRxPacket
->p80211Header
->sA3
.abyAddr2
,
4482 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"wmgr: send vMgrDeAuthenBeginSta 1\n");
4485 s_vMgrRxAssocRequest(pDevice
, pMgmt
, pRxPacket
, uNodeIndex
);
4489 case WLAN_FSTYPE_ASSOCRESP
:
4491 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx assocresp1\n");
4492 s_vMgrRxAssocResponse(pDevice
, pMgmt
, pRxPacket
, FALSE
);
4493 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx assocresp2\n");
4496 case WLAN_FSTYPE_REASSOCREQ
:
4498 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx reassocreq\n");
4500 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) &&
4501 (eNodeState
< NODE_AUTH
)) {
4502 // send deauth notification
4503 // reason = (6) class 2 received from nonauth sta
4504 vMgrDeAuthenBeginSta(pDevice
,
4506 pRxPacket
->p80211Header
->sA3
.abyAddr2
,
4510 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"wmgr: send vMgrDeAuthenBeginSta 2\n");
4513 s_vMgrRxReAssocRequest(pDevice
, pMgmt
, pRxPacket
, uNodeIndex
);
4516 case WLAN_FSTYPE_REASSOCRESP
:
4518 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx reassocresp\n");
4519 s_vMgrRxAssocResponse(pDevice
, pMgmt
, pRxPacket
, TRUE
);
4522 case WLAN_FSTYPE_PROBEREQ
:
4524 //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx probereq\n");
4525 s_vMgrRxProbeRequest(pDevice
, pMgmt
, pRxPacket
);
4528 case WLAN_FSTYPE_PROBERESP
:
4530 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx proberesp\n");
4532 s_vMgrRxProbeResponse(pDevice
, pMgmt
, pRxPacket
);
4535 case WLAN_FSTYPE_BEACON
:
4537 //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx beacon\n");
4538 if (pMgmt
->eScanState
!= WMAC_NO_SCANNING
) {
4541 s_vMgrRxBeacon(pDevice
, pMgmt
, pRxPacket
, bInScan
);
4544 case WLAN_FSTYPE_ATIM
:
4546 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx atim\n");
4549 case WLAN_FSTYPE_DISASSOC
:
4551 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx disassoc\n");
4552 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) &&
4553 (eNodeState
< NODE_AUTH
)) {
4554 // send deauth notification
4555 // reason = (6) class 2 received from nonauth sta
4556 vMgrDeAuthenBeginSta(pDevice
,
4558 pRxPacket
->p80211Header
->sA3
.abyAddr2
,
4562 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"wmgr: send vMgrDeAuthenBeginSta 3\n");
4564 s_vMgrRxDisassociation(pDevice
, pMgmt
, pRxPacket
);
4567 case WLAN_FSTYPE_AUTHEN
:
4569 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx authen\n");
4570 s_vMgrRxAuthentication(pDevice
, pMgmt
, pRxPacket
);
4573 case WLAN_FSTYPE_DEAUTHEN
:
4575 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx deauthen\n");
4576 s_vMgrRxDeauthentication(pDevice
, pMgmt
, pRxPacket
);
4580 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx unknown mgmt\n");
4591 * Routine Description:
4594 * Prepare beacon to send
4597 * TRUE if success; FALSE if failed.
4601 bMgrPrepareBeaconToSend(
4602 IN HANDLE hDeviceContext
,
4603 IN PSMgmtObject pMgmt
4606 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
4607 PSTxMgmtPacket pTxPacket
;
4609 // pDevice->bBeaconBufReady = FALSE;
4610 if (pDevice
->bEncryptionEnable
|| pDevice
->bEnable8021x
){
4611 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_PRIVACY(1);
4614 pMgmt
->wCurrCapInfo
&= ~WLAN_SET_CAP_INFO_PRIVACY(1);
4616 pTxPacket
= s_MgrMakeBeacon
4620 pMgmt
->wCurrCapInfo
,
4621 pMgmt
->wCurrBeaconPeriod
,
4622 pMgmt
->uCurrChannel
,
4623 pMgmt
->wCurrATIMWindow
, //0,
4624 (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
,
4625 (PBYTE
)pMgmt
->abyCurrBSSID
,
4626 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
4627 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
4630 if ((pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) &&
4631 (pMgmt
->abyCurrBSSID
[0] == 0))
4634 csBeacon_xmit(pDevice
, pTxPacket
);
4635 MACvRegBitsOn(pDevice
, MAC_REG_TCR
, TCR_AUTOBCNTX
);
4645 * Routine Description:
4647 * Log a warning message based on the contents of the Status
4648 * Code field of an 802.11 management frame. Defines are
4649 * derived from 802.11-1997 SPEC.
4658 IN PSMgmtObject pMgmt
,
4663 case WLAN_MGMT_STATUS_UNSPEC_FAILURE
:
4664 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Unspecified error.\n");
4666 case WLAN_MGMT_STATUS_CAPS_UNSUPPORTED
:
4667 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Can't support all requested capabilities.\n");
4669 case WLAN_MGMT_STATUS_REASSOC_NO_ASSOC
:
4670 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Reassoc denied, can't confirm original Association.\n");
4672 case WLAN_MGMT_STATUS_ASSOC_DENIED_UNSPEC
:
4673 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Assoc denied, undefine in spec\n");
4675 case WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG
:
4676 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Peer doesn't support authen algorithm.\n");
4678 case WLAN_MGMT_STATUS_RX_AUTH_NOSEQ
:
4679 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Authen frame received out of sequence.\n");
4681 case WLAN_MGMT_STATUS_CHALLENGE_FAIL
:
4682 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Authen rejected, challenge failure.\n");
4684 case WLAN_MGMT_STATUS_AUTH_TIMEOUT
:
4685 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Authen rejected, timeout waiting for next frame.\n");
4687 case WLAN_MGMT_STATUS_ASSOC_DENIED_BUSY
:
4688 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Assoc denied, AP too busy.\n");
4690 case WLAN_MGMT_STATUS_ASSOC_DENIED_RATES
:
4691 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Assoc denied, we haven't enough basic rates.\n");
4693 case WLAN_MGMT_STATUS_ASSOC_DENIED_SHORTPREAMBLE
:
4694 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Assoc denied, we do not support short preamble.\n");
4696 case WLAN_MGMT_STATUS_ASSOC_DENIED_PBCC
:
4697 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Assoc denied, we do not support PBCC.\n");
4699 case WLAN_MGMT_STATUS_ASSOC_DENIED_AGILITY
:
4700 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Assoc denied, we do not support channel agility.\n");
4703 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Unknown status code %d.\n", wStatus
);
4712 * Add BSSID in PMKID Candidate list.
4716 * hDeviceContext - device structure point
4717 * pbyBSSID - BSSID address for adding
4718 * wRSNCap - BSS's RSN capability
4722 * Return Value: none.
4726 bAdd_PMKID_Candidate (
4727 IN HANDLE hDeviceContext
,
4729 IN PSRSNCapObject psRSNCapObj
4732 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
4733 PPMKID_CANDIDATE pCandidateList
;
4736 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"bAdd_PMKID_Candidate START: (%d)\n", (int)pDevice
->gsPMKIDCandidate
.NumCandidates
);
4738 if ((pDevice
== NULL
) || (pbyBSSID
== NULL
) || (psRSNCapObj
== NULL
))
4741 if (pDevice
->gsPMKIDCandidate
.NumCandidates
>= MAX_PMKIDLIST
)
4746 // Update Old Candidate
4747 for (ii
= 0; ii
< pDevice
->gsPMKIDCandidate
.NumCandidates
; ii
++) {
4748 pCandidateList
= &pDevice
->gsPMKIDCandidate
.CandidateList
[ii
];
4749 if ( !memcmp(pCandidateList
->BSSID
, pbyBSSID
, U_ETHER_ADDR_LEN
)) {
4750 if ((psRSNCapObj
->bRSNCapExist
== TRUE
) && (psRSNCapObj
->wRSNCap
& BIT0
)) {
4751 pCandidateList
->Flags
|= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED
;
4753 pCandidateList
->Flags
&= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED
);
4760 pCandidateList
= &pDevice
->gsPMKIDCandidate
.CandidateList
[pDevice
->gsPMKIDCandidate
.NumCandidates
];
4761 if ((psRSNCapObj
->bRSNCapExist
== TRUE
) && (psRSNCapObj
->wRSNCap
& BIT0
)) {
4762 pCandidateList
->Flags
|= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED
;
4764 pCandidateList
->Flags
&= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED
);
4766 memcpy(pCandidateList
->BSSID
, pbyBSSID
, U_ETHER_ADDR_LEN
);
4767 pDevice
->gsPMKIDCandidate
.NumCandidates
++;
4768 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"NumCandidates:%d\n", (int)pDevice
->gsPMKIDCandidate
.NumCandidates
);
4775 * Flush PMKID Candidate list.
4779 * hDeviceContext - device structure point
4783 * Return Value: none.
4787 vFlush_PMKID_Candidate (
4788 IN HANDLE hDeviceContext
4791 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
4793 if (pDevice
== NULL
)
4796 memset(&pDevice
->gsPMKIDCandidate
, 0, sizeof(SPMKIDCandidateEvent
));
4801 IN PKnownBSS pBSSNode
,
4802 IN NDIS_802_11_ENCRYPTION_STATUS EncStatus
,
4807 BYTE byMulticastCipher
= KEY_CTL_INVALID
;
4808 BYTE byCipherMask
= 0x00;
4811 if (pBSSNode
== NULL
)
4814 // check cap. of BSS
4815 if ((WLAN_GET_CAP_INFO_PRIVACY(pBSSNode
->wCapInfo
) != 0) &&
4816 (EncStatus
== Ndis802_11Encryption1Enabled
)) {
4817 // default is WEP only
4818 byMulticastCipher
= KEY_CTL_WEP
;
4821 if ((WLAN_GET_CAP_INFO_PRIVACY(pBSSNode
->wCapInfo
) != 0) &&
4822 (pBSSNode
->bWPA2Valid
== TRUE
) &&
4823 //20080123-01,<Add> by Einsn Liu
4824 ((EncStatus
== Ndis802_11Encryption3Enabled
)||(EncStatus
== Ndis802_11Encryption2Enabled
))) {
4826 // check Group Key Cipher
4827 if ((pBSSNode
->byCSSGK
== WLAN_11i_CSS_WEP40
) ||
4828 (pBSSNode
->byCSSGK
== WLAN_11i_CSS_WEP104
)) {
4829 byMulticastCipher
= KEY_CTL_WEP
;
4830 } else if (pBSSNode
->byCSSGK
== WLAN_11i_CSS_TKIP
) {
4831 byMulticastCipher
= KEY_CTL_TKIP
;
4832 } else if (pBSSNode
->byCSSGK
== WLAN_11i_CSS_CCMP
) {
4833 byMulticastCipher
= KEY_CTL_CCMP
;
4835 byMulticastCipher
= KEY_CTL_INVALID
;
4838 // check Pairwise Key Cipher
4839 for(i
=0;i
<pBSSNode
->wCSSPKCount
;i
++) {
4840 if ((pBSSNode
->abyCSSPK
[i
] == WLAN_11i_CSS_WEP40
) ||
4841 (pBSSNode
->abyCSSPK
[i
] == WLAN_11i_CSS_WEP104
)) {
4842 // this should not happen as defined 802.11i
4843 byCipherMask
|= 0x01;
4844 } else if (pBSSNode
->abyCSSPK
[i
] == WLAN_11i_CSS_TKIP
) {
4845 byCipherMask
|= 0x02;
4846 } else if (pBSSNode
->abyCSSPK
[i
] == WLAN_11i_CSS_CCMP
) {
4847 byCipherMask
|= 0x04;
4848 } else if (pBSSNode
->abyCSSPK
[i
] == WLAN_11i_CSS_USE_GROUP
) {
4849 // use group key only ignore all others
4851 i
= pBSSNode
->wCSSPKCount
;
4855 } else if ((WLAN_GET_CAP_INFO_PRIVACY(pBSSNode
->wCapInfo
) != 0) &&
4856 (pBSSNode
->bWPAValid
== TRUE
) &&
4857 ((EncStatus
== Ndis802_11Encryption2Enabled
) || (EncStatus
== Ndis802_11Encryption3Enabled
))) {
4859 // check Group Key Cipher
4860 if ((pBSSNode
->byGKType
== WPA_WEP40
) ||
4861 (pBSSNode
->byGKType
== WPA_WEP104
)) {
4862 byMulticastCipher
= KEY_CTL_WEP
;
4863 } else if (pBSSNode
->byGKType
== WPA_TKIP
) {
4864 byMulticastCipher
= KEY_CTL_TKIP
;
4865 } else if (pBSSNode
->byGKType
== WPA_AESCCMP
) {
4866 byMulticastCipher
= KEY_CTL_CCMP
;
4868 byMulticastCipher
= KEY_CTL_INVALID
;
4871 // check Pairwise Key Cipher
4872 for(i
=0;i
<pBSSNode
->wPKCount
;i
++) {
4873 if (pBSSNode
->abyPKType
[i
] == WPA_TKIP
) {
4874 byCipherMask
|= 0x02;
4875 } else if (pBSSNode
->abyPKType
[i
] == WPA_AESCCMP
) {
4876 byCipherMask
|= 0x04;
4877 } else if (pBSSNode
->abyPKType
[i
] == WPA_NONE
) {
4878 // use group key only ignore all others
4880 i
= pBSSNode
->wPKCount
;
4885 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%d, %d, %d, %d, EncStatus:%d\n",
4886 byMulticastCipher
, byCipherMask
, pBSSNode
->bWPAValid
, pBSSNode
->bWPA2Valid
, EncStatus
);
4888 // mask our cap. with BSS
4889 if (EncStatus
== Ndis802_11Encryption1Enabled
) {
4891 // For supporting Cisco migration mode, don't care pairwise key cipher
4892 //if ((byMulticastCipher == KEY_CTL_WEP) &&
4893 // (byCipherMask == 0)) {
4894 if ((byMulticastCipher
== KEY_CTL_WEP
) &&
4895 (byCipherMask
== 0)) {
4896 *pbyCCSGK
= KEY_CTL_WEP
;
4897 *pbyCCSPK
= KEY_CTL_NONE
;
4903 } else if (EncStatus
== Ndis802_11Encryption2Enabled
) {
4904 if ((byMulticastCipher
== KEY_CTL_TKIP
) &&
4905 (byCipherMask
== 0)) {
4906 *pbyCCSGK
= KEY_CTL_TKIP
;
4907 *pbyCCSPK
= KEY_CTL_NONE
;
4909 } else if ((byMulticastCipher
== KEY_CTL_WEP
) &&
4910 ((byCipherMask
& 0x02) != 0)) {
4911 *pbyCCSGK
= KEY_CTL_WEP
;
4912 *pbyCCSPK
= KEY_CTL_TKIP
;
4914 } else if ((byMulticastCipher
== KEY_CTL_TKIP
) &&
4915 ((byCipherMask
& 0x02) != 0)) {
4916 *pbyCCSGK
= KEY_CTL_TKIP
;
4917 *pbyCCSPK
= KEY_CTL_TKIP
;
4922 } else if (EncStatus
== Ndis802_11Encryption3Enabled
) {
4923 if ((byMulticastCipher
== KEY_CTL_CCMP
) &&
4924 (byCipherMask
== 0)) {
4925 // When CCMP is enable, "Use group cipher suite" shall not be a valid option.
4927 } else if ((byMulticastCipher
== KEY_CTL_WEP
) &&
4928 ((byCipherMask
& 0x04) != 0)) {
4929 *pbyCCSGK
= KEY_CTL_WEP
;
4930 *pbyCCSPK
= KEY_CTL_CCMP
;
4932 } else if ((byMulticastCipher
== KEY_CTL_TKIP
) &&
4933 ((byCipherMask
& 0x04) != 0)) {
4934 *pbyCCSGK
= KEY_CTL_TKIP
;
4935 *pbyCCSPK
= KEY_CTL_CCMP
;
4937 } else if ((byMulticastCipher
== KEY_CTL_CCMP
) &&
4938 ((byCipherMask
& 0x04) != 0)) {
4939 *pbyCCSGK
= KEY_CTL_CCMP
;
4940 *pbyCCSPK
= KEY_CTL_CCMP
;