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
85 /*--------------------- Static Definitions -------------------------*/
89 /*--------------------- Static Classes ----------------------------*/
91 /*--------------------- Static Variables --------------------------*/
92 static int msglevel
=MSG_LEVEL_INFO
;
93 //static int msglevel =MSG_LEVEL_DEBUG;
95 /*--------------------- Static Functions --------------------------*/
96 //2008-8-4 <add> by chester
97 static bool ChannelExceedZoneType(
99 unsigned char byCurrChannel
102 // Association/diassociation functions
105 s_MgrMakeAssocRequest(
108 unsigned char *pDAddr
,
109 unsigned short wCurrCapInfo
,
110 unsigned short wListenInterval
,
111 PWLAN_IE_SSID pCurrSSID
,
112 PWLAN_IE_SUPP_RATES pCurrRates
,
113 PWLAN_IE_SUPP_RATES pCurrExtSuppRates
118 s_vMgrRxAssocRequest(
121 PSRxMgmtPacket pRxPacket
,
122 unsigned int uNodeIndex
127 s_MgrMakeReAssocRequest(
130 unsigned char *pDAddr
,
131 unsigned short wCurrCapInfo
,
132 unsigned short wListenInterval
,
133 PWLAN_IE_SSID pCurrSSID
,
134 PWLAN_IE_SUPP_RATES pCurrRates
,
135 PWLAN_IE_SUPP_RATES pCurrExtSuppRates
140 s_vMgrRxAssocResponse(
143 PSRxMgmtPacket pRxPacket
,
149 s_vMgrRxDisassociation(
152 PSRxMgmtPacket pRxPacket
155 // Authentication/deauthen functions
158 s_vMgrRxAuthenSequence_1(
161 PWLAN_FR_AUTHEN pFrame
166 s_vMgrRxAuthenSequence_2(
169 PWLAN_FR_AUTHEN pFrame
174 s_vMgrRxAuthenSequence_3(
177 PWLAN_FR_AUTHEN pFrame
182 s_vMgrRxAuthenSequence_4(
185 PWLAN_FR_AUTHEN pFrame
190 s_vMgrRxAuthentication(
193 PSRxMgmtPacket pRxPacket
198 s_vMgrRxDeauthentication(
201 PSRxMgmtPacket pRxPacket
205 // probe request/response functions
208 s_vMgrRxProbeRequest(
211 PSRxMgmtPacket pRxPacket
216 s_vMgrRxProbeResponse(
219 PSRxMgmtPacket pRxPacket
228 PSRxMgmtPacket pRxPacket
,
244 unsigned short wCurrCapInfo
,
245 unsigned short wCurrBeaconPeriod
,
246 unsigned int uCurrChannel
,
247 unsigned short wCurrATIMWinodw
,
248 PWLAN_IE_SSID pCurrSSID
,
249 unsigned char *pCurrBSSID
,
250 PWLAN_IE_SUPP_RATES pCurrSuppRates
,
251 PWLAN_IE_SUPP_RATES pCurrExtSuppRates
255 // Association response
258 s_MgrMakeAssocResponse(
261 unsigned short wCurrCapInfo
,
262 unsigned short wAssocStatus
,
263 unsigned short wAssocAID
,
264 unsigned char *pDstAddr
,
265 PWLAN_IE_SUPP_RATES pCurrSuppRates
,
266 PWLAN_IE_SUPP_RATES pCurrExtSuppRates
269 // ReAssociation response
272 s_MgrMakeReAssocResponse(
275 unsigned short wCurrCapInfo
,
276 unsigned short wAssocStatus
,
277 unsigned short wAssocAID
,
278 unsigned char *pDstAddr
,
279 PWLAN_IE_SUPP_RATES pCurrSuppRates
,
280 PWLAN_IE_SUPP_RATES pCurrExtSuppRates
286 s_MgrMakeProbeResponse(
289 unsigned short wCurrCapInfo
,
290 unsigned short wCurrBeaconPeriod
,
291 unsigned int uCurrChannel
,
292 unsigned short wCurrATIMWinodw
,
293 unsigned char *pDstAddr
,
294 PWLAN_IE_SSID pCurrSSID
,
295 unsigned char *pCurrBSSID
,
296 PWLAN_IE_SUPP_RATES pCurrSuppRates
,
297 PWLAN_IE_SUPP_RATES pCurrExtSuppRates
,
298 unsigned char byPHYType
306 unsigned short wStatus
314 unsigned int uBSSMode
,
323 NDIS_802_11_ENCRYPTION_STATUS EncStatus
,
324 unsigned char *pbyCCSPK
,
325 unsigned char *pbyCCSGK
328 static void Encyption_Rebuild(
335 /*--------------------- Export Variables --------------------------*/
338 /*--------------------- Export Functions --------------------------*/
343 * Routine Description:
344 * Allocates and initializes the Management object.
356 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
357 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
361 pMgmt
->pbyPSPacketPool
= &pMgmt
->byPSPacketPool
[0];
362 pMgmt
->pbyMgmtPacketPool
= &pMgmt
->byMgmtPacketPool
[0];
363 pMgmt
->uCurrChannel
= pDevice
->uChannel
;
364 for(ii
=0;ii
<WLAN_BSSID_LEN
;ii
++) {
365 pMgmt
->abyDesireBSSID
[ii
] = 0xFF;
367 pMgmt
->sAssocInfo
.AssocInfo
.Length
= sizeof(NDIS_802_11_ASSOCIATION_INFORMATION
);
368 //memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN +1);
369 pMgmt
->byCSSPK
= KEY_CTL_NONE
;
370 pMgmt
->byCSSGK
= KEY_CTL_NONE
;
371 pMgmt
->wIBSSBeaconPeriod
= DEFAULT_IBSS_BI
;
372 BSSvClearBSSList((void *)pDevice
, false);
379 * Routine Description:
380 * Initializes timer object
392 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
393 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
396 init_timer(&pMgmt
->sTimerSecondCallback
);
397 pMgmt
->sTimerSecondCallback
.data
= (unsigned long) pDevice
;
398 pMgmt
->sTimerSecondCallback
.function
= (TimerFunction
)BSSvSecondCallBack
;
399 pMgmt
->sTimerSecondCallback
.expires
= RUN_AT(HZ
);
401 init_timer(&pDevice
->sTimerCommand
);
402 pDevice
->sTimerCommand
.data
= (unsigned long) pDevice
;
403 pDevice
->sTimerCommand
.function
= (TimerFunction
)vCommandTimer
;
404 pDevice
->sTimerCommand
.expires
= RUN_AT(HZ
);
407 init_timer(&pDevice
->sTimerTxData
);
408 pDevice
->sTimerTxData
.data
= (unsigned long) pDevice
;
409 pDevice
->sTimerTxData
.function
= (TimerFunction
)BSSvSecondTxData
;
410 pDevice
->sTimerTxData
.expires
= RUN_AT(10*HZ
); //10s callback
411 pDevice
->fTxDataInSleep
= false;
412 pDevice
->IsTxDataTrigger
= false;
413 pDevice
->nTxDataTimeCout
= 0;
416 pDevice
->cbFreeCmdQueue
= CMD_Q_SIZE
;
417 pDevice
->uCmdDequeueIdx
= 0;
418 pDevice
->uCmdEnqueueIdx
= 0;
427 * Routine Description:
428 * Reset the management object structure.
440 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
441 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
443 pMgmt
->eCurrMode
= WMAC_MODE_STANDBY
;
444 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
445 pDevice
->bEnablePSMode
= false;
454 * Routine Description:
455 * Start the station association procedure. Namely, send an
456 * association request frame to the AP.
466 void *hDeviceContext
,
471 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
472 PSTxMgmtPacket pTxPacket
;
475 pMgmt
->wCurrCapInfo
= 0;
476 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_ESS(1);
477 if (pDevice
->bEncryptionEnable
) {
478 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_PRIVACY(1);
480 // always allow receive short preamble
481 //if (pDevice->byPreambleType == 1) {
482 // pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
484 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
485 if (pMgmt
->wListenInterval
== 0)
486 pMgmt
->wListenInterval
= 1; // at least one.
488 // ERP Phy (802.11g) should support short preamble.
489 if (pMgmt
->eCurrentPHYMode
== PHY_TYPE_11G
) {
490 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
491 if (CARDbIsShorSlotTime(pMgmt
->pAdapter
) == true) {
492 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTSLOTTIME(1);
494 } else if (pMgmt
->eCurrentPHYMode
== PHY_TYPE_11B
) {
495 if (CARDbIsShortPreamble(pMgmt
->pAdapter
) == true) {
496 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
499 if (pMgmt
->b11hEnable
== true)
500 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SPECTRUMMNG(1);
502 /* build an assocreq frame and send it */
503 pTxPacket
= s_MgrMakeAssocRequest
509 pMgmt
->wListenInterval
,
510 (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
,
511 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
512 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
515 if (pTxPacket
!= NULL
){
517 *pStatus
= csMgmt_xmit(pDevice
, pTxPacket
);
518 if (*pStatus
== CMD_STATUS_PENDING
) {
519 pMgmt
->eCurrState
= WMAC_STATE_ASSOCPENDING
;
520 *pStatus
= CMD_STATUS_SUCCESS
;
524 *pStatus
= CMD_STATUS_RESOURCES
;
532 * Routine Description:
533 * Start the station re-association procedure.
542 void *hDeviceContext
,
547 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
548 PSTxMgmtPacket pTxPacket
;
552 pMgmt
->wCurrCapInfo
= 0;
553 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_ESS(1);
554 if (pDevice
->bEncryptionEnable
) {
555 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_PRIVACY(1);
558 //if (pDevice->byPreambleType == 1) {
559 // pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
561 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
563 if (pMgmt
->wListenInterval
== 0)
564 pMgmt
->wListenInterval
= 1; // at least one.
567 // ERP Phy (802.11g) should support short preamble.
568 if (pMgmt
->eCurrentPHYMode
== PHY_TYPE_11G
) {
569 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
570 if (CARDbIsShorSlotTime(pMgmt
->pAdapter
) == true) {
571 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTSLOTTIME(1);
573 } else if (pMgmt
->eCurrentPHYMode
== PHY_TYPE_11B
) {
574 if (CARDbIsShortPreamble(pMgmt
->pAdapter
) == true) {
575 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
578 if (pMgmt
->b11hEnable
== true)
579 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SPECTRUMMNG(1);
582 pTxPacket
= s_MgrMakeReAssocRequest
588 pMgmt
->wListenInterval
,
589 (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
,
590 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
591 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
594 if (pTxPacket
!= NULL
){
596 *pStatus
= csMgmt_xmit(pDevice
, pTxPacket
);
597 if (*pStatus
!= CMD_STATUS_PENDING
) {
598 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Reassociation tx failed.\n");
601 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Reassociation tx sending.\n");
611 * Routine Description:
612 * Send an dis-association request frame to the AP.
620 vMgrDisassocBeginSta(
621 void *hDeviceContext
,
623 unsigned char *abyDestAddress
,
624 unsigned short wReason
,
628 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
629 PSTxMgmtPacket pTxPacket
= NULL
;
630 WLAN_FR_DISASSOC sFrame
;
632 pTxPacket
= (PSTxMgmtPacket
)pMgmt
->pbyMgmtPacketPool
;
633 memset(pTxPacket
, 0, sizeof(STxMgmtPacket
) + WLAN_DISASSOC_FR_MAXLEN
);
634 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((unsigned char *)pTxPacket
+ sizeof(STxMgmtPacket
));
636 // Setup the sFrame structure
637 sFrame
.pBuf
= (unsigned char *)pTxPacket
->p80211Header
;
638 sFrame
.len
= WLAN_DISASSOC_FR_MAXLEN
;
640 // format fixed field frame structure
641 vMgrEncodeDisassociation(&sFrame
);
644 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
646 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
647 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_DISASSOC
)
650 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, abyDestAddress
, WLAN_ADDR_LEN
);
651 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
652 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
655 *(sFrame
.pwReason
) = cpu_to_le16(wReason
);
656 pTxPacket
->cbMPDULen
= sFrame
.len
;
657 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
660 *pStatus
= csMgmt_xmit(pDevice
, pTxPacket
);
661 if (*pStatus
== CMD_STATUS_PENDING
) {
662 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
663 *pStatus
= CMD_STATUS_SUCCESS
;
673 * Routine Description:(AP function)
674 * Handle incoming station association request frames.
683 s_vMgrRxAssocRequest(
686 PSRxMgmtPacket pRxPacket
,
687 unsigned int uNodeIndex
690 WLAN_FR_ASSOCREQ sFrame
;
692 PSTxMgmtPacket pTxPacket
;
693 unsigned short wAssocStatus
= 0;
694 unsigned short wAssocAID
= 0;
695 unsigned int uRateLen
= WLAN_RATES_MAXLEN
;
696 unsigned char abyCurrSuppRates
[WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1];
697 unsigned char abyCurrExtSuppRates
[WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1];
700 if (pMgmt
->eCurrMode
!= WMAC_MODE_ESS_AP
)
702 // node index not found
706 //check if node is authenticated
708 memset(&sFrame
, 0, sizeof(WLAN_FR_ASSOCREQ
));
709 memset(abyCurrSuppRates
, 0, WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1);
710 memset(abyCurrExtSuppRates
, 0, WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1);
711 sFrame
.len
= pRxPacket
->cbMPDULen
;
712 sFrame
.pBuf
= (unsigned char *)pRxPacket
->p80211Header
;
714 vMgrDecodeAssocRequest(&sFrame
);
716 if (pMgmt
->sNodeDBTable
[uNodeIndex
].eNodeState
>= NODE_AUTH
) {
717 pMgmt
->sNodeDBTable
[uNodeIndex
].eNodeState
= NODE_ASSOC
;
718 pMgmt
->sNodeDBTable
[uNodeIndex
].wCapInfo
= cpu_to_le16(*sFrame
.pwCapInfo
);
719 pMgmt
->sNodeDBTable
[uNodeIndex
].wListenInterval
= cpu_to_le16(*sFrame
.pwListenInterval
);
720 pMgmt
->sNodeDBTable
[uNodeIndex
].bPSEnable
=
721 WLAN_GET_FC_PWRMGT(sFrame
.pHdr
->sA3
.wFrameCtl
) ? true : false;
722 // Todo: check sta basic rate, if ap can't support, set status code
723 if (pDevice
->eCurrentPHYType
== PHY_TYPE_11B
) {
724 uRateLen
= WLAN_RATES_MAXLEN_11B
;
726 abyCurrSuppRates
[0] = WLAN_EID_SUPP_RATES
;
727 abyCurrSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)sFrame
.pSuppRates
,
728 (PWLAN_IE_SUPP_RATES
)abyCurrSuppRates
,
730 abyCurrExtSuppRates
[0] = WLAN_EID_EXTSUPP_RATES
;
731 if (pDevice
->eCurrentPHYType
== PHY_TYPE_11G
) {
732 abyCurrExtSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)sFrame
.pExtSuppRates
,
733 (PWLAN_IE_SUPP_RATES
)abyCurrExtSuppRates
,
736 abyCurrExtSuppRates
[1] = 0;
740 RATEvParseMaxRate((void *)pDevice
,
741 (PWLAN_IE_SUPP_RATES
)abyCurrSuppRates
,
742 (PWLAN_IE_SUPP_RATES
)abyCurrExtSuppRates
,
743 false, // do not change our basic rate
744 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxBasicRate
),
745 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
),
746 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wSuppRate
),
747 &(pMgmt
->sNodeDBTable
[uNodeIndex
].byTopCCKBasicRate
),
748 &(pMgmt
->sNodeDBTable
[uNodeIndex
].byTopOFDMBasicRate
)
752 pMgmt
->sNodeDBTable
[uNodeIndex
].wTxDataRate
=
753 pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
;
755 printk("RxAssocRequest:wTxDataRate is %d\n",pMgmt
->sNodeDBTable
[uNodeIndex
].wTxDataRate
);
757 // Todo: check sta preamble, if ap can't support, set status code
758 pMgmt
->sNodeDBTable
[uNodeIndex
].bShortPreamble
=
759 WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame
.pwCapInfo
);
760 pMgmt
->sNodeDBTable
[uNodeIndex
].bShortSlotTime
=
761 WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame
.pwCapInfo
);
762 pMgmt
->sNodeDBTable
[uNodeIndex
].wAID
= (unsigned short)uNodeIndex
;
763 wAssocStatus
= WLAN_MGMT_STATUS_SUCCESS
;
764 wAssocAID
= (unsigned short)uNodeIndex
;
765 // check if ERP support
766 if(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
> RATE_11M
)
767 pMgmt
->sNodeDBTable
[uNodeIndex
].bERPExist
= true;
769 if (pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
<= RATE_11M
) {
771 pDevice
->bProtectMode
= true;
772 pDevice
->bNonERPPresent
= true;
774 if (pMgmt
->sNodeDBTable
[uNodeIndex
].bShortPreamble
== false) {
775 pDevice
->bBarkerPreambleMd
= true;
778 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"Associate AID= %d \n", wAssocAID
);
779 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"MAC=%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X \n",
780 sFrame
.pHdr
->sA3
.abyAddr2
[0],
781 sFrame
.pHdr
->sA3
.abyAddr2
[1],
782 sFrame
.pHdr
->sA3
.abyAddr2
[2],
783 sFrame
.pHdr
->sA3
.abyAddr2
[3],
784 sFrame
.pHdr
->sA3
.abyAddr2
[4],
785 sFrame
.pHdr
->sA3
.abyAddr2
[5]
787 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"Max Support rate = %d \n",
788 pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
);
789 }//else { TODO: received STA under state1 handle }
795 // assoc response reply..
796 pTxPacket
= s_MgrMakeAssocResponse
803 sFrame
.pHdr
->sA3
.abyAddr2
,
804 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
805 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
807 if (pTxPacket
!= NULL
){
809 if (pDevice
->bEnableHostapd
) {
813 Status
= csMgmt_xmit(pDevice
, pTxPacket
);
814 if (Status
!= CMD_STATUS_PENDING
) {
815 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Assoc response tx failed\n");
818 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Assoc response tx sending..\n");
829 * Description:(AP function)
830 * Handle incoming station re-association request frames.
834 * pMgmt - Management Object structure
835 * pRxPacket - Received Packet
839 * Return Value: None.
845 s_vMgrRxReAssocRequest(
848 PSRxMgmtPacket pRxPacket
,
849 unsigned int uNodeIndex
852 WLAN_FR_REASSOCREQ sFrame
;
854 PSTxMgmtPacket pTxPacket
;
855 unsigned short wAssocStatus
= 0;
856 unsigned short wAssocAID
= 0;
857 unsigned int uRateLen
= WLAN_RATES_MAXLEN
;
858 unsigned char abyCurrSuppRates
[WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1];
859 unsigned char abyCurrExtSuppRates
[WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1];
861 if (pMgmt
->eCurrMode
!= WMAC_MODE_ESS_AP
)
863 // node index not found
866 //check if node is authenticated
868 memset(&sFrame
, 0, sizeof(WLAN_FR_REASSOCREQ
));
869 sFrame
.len
= pRxPacket
->cbMPDULen
;
870 sFrame
.pBuf
= (unsigned char *)pRxPacket
->p80211Header
;
871 vMgrDecodeReassocRequest(&sFrame
);
873 if (pMgmt
->sNodeDBTable
[uNodeIndex
].eNodeState
>= NODE_AUTH
) {
874 pMgmt
->sNodeDBTable
[uNodeIndex
].eNodeState
= NODE_ASSOC
;
875 pMgmt
->sNodeDBTable
[uNodeIndex
].wCapInfo
= cpu_to_le16(*sFrame
.pwCapInfo
);
876 pMgmt
->sNodeDBTable
[uNodeIndex
].wListenInterval
= cpu_to_le16(*sFrame
.pwListenInterval
);
877 pMgmt
->sNodeDBTable
[uNodeIndex
].bPSEnable
=
878 WLAN_GET_FC_PWRMGT(sFrame
.pHdr
->sA3
.wFrameCtl
) ? true : false;
879 // Todo: check sta basic rate, if ap can't support, set status code
881 if (pDevice
->eCurrentPHYType
== PHY_TYPE_11B
) {
882 uRateLen
= WLAN_RATES_MAXLEN_11B
;
885 abyCurrSuppRates
[0] = WLAN_EID_SUPP_RATES
;
886 abyCurrSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)sFrame
.pSuppRates
,
887 (PWLAN_IE_SUPP_RATES
)abyCurrSuppRates
,
889 abyCurrExtSuppRates
[0] = WLAN_EID_EXTSUPP_RATES
;
890 if (pDevice
->eCurrentPHYType
== PHY_TYPE_11G
) {
891 abyCurrExtSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)sFrame
.pExtSuppRates
,
892 (PWLAN_IE_SUPP_RATES
)abyCurrExtSuppRates
,
895 abyCurrExtSuppRates
[1] = 0;
899 RATEvParseMaxRate((void *)pDevice
,
900 (PWLAN_IE_SUPP_RATES
)abyCurrSuppRates
,
901 (PWLAN_IE_SUPP_RATES
)abyCurrExtSuppRates
,
902 false, // do not change our basic rate
903 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxBasicRate
),
904 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
),
905 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wSuppRate
),
906 &(pMgmt
->sNodeDBTable
[uNodeIndex
].byTopCCKBasicRate
),
907 &(pMgmt
->sNodeDBTable
[uNodeIndex
].byTopOFDMBasicRate
)
911 pMgmt
->sNodeDBTable
[uNodeIndex
].wTxDataRate
=
912 pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
;
914 printk("RxReAssocRequest:TxDataRate is %d\n",pMgmt
->sNodeDBTable
[uNodeIndex
].wTxDataRate
);
916 // Todo: check sta preamble, if ap can't support, set status code
917 pMgmt
->sNodeDBTable
[uNodeIndex
].bShortPreamble
=
918 WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame
.pwCapInfo
);
919 pMgmt
->sNodeDBTable
[uNodeIndex
].bShortSlotTime
=
920 WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame
.pwCapInfo
);
921 pMgmt
->sNodeDBTable
[uNodeIndex
].wAID
= (unsigned short)uNodeIndex
;
922 wAssocStatus
= WLAN_MGMT_STATUS_SUCCESS
;
923 wAssocAID
= (unsigned short)uNodeIndex
;
926 if(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
> RATE_11M
)
927 pMgmt
->sNodeDBTable
[uNodeIndex
].bERPExist
= true;
929 if (pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
<= RATE_11M
) {
931 pDevice
->bProtectMode
= true;
932 pDevice
->bNonERPPresent
= true;
934 if (pMgmt
->sNodeDBTable
[uNodeIndex
].bShortPreamble
== false) {
935 pDevice
->bBarkerPreambleMd
= true;
938 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"Rx ReAssociate AID= %d \n", wAssocAID
);
939 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"MAC=%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X \n",
940 sFrame
.pHdr
->sA3
.abyAddr2
[0],
941 sFrame
.pHdr
->sA3
.abyAddr2
[1],
942 sFrame
.pHdr
->sA3
.abyAddr2
[2],
943 sFrame
.pHdr
->sA3
.abyAddr2
[3],
944 sFrame
.pHdr
->sA3
.abyAddr2
[4],
945 sFrame
.pHdr
->sA3
.abyAddr2
[5]
947 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"Max Support rate = %d \n",
948 pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
);
953 // assoc response reply..
954 pTxPacket
= s_MgrMakeReAssocResponse
961 sFrame
.pHdr
->sA3
.abyAddr2
,
962 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
963 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
966 if (pTxPacket
!= NULL
){
968 if (pDevice
->bEnableHostapd
) {
971 Status
= csMgmt_xmit(pDevice
, pTxPacket
);
972 if (Status
!= CMD_STATUS_PENDING
) {
973 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:ReAssoc response tx failed\n");
976 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:ReAssoc response tx sending..\n");
985 * Routine Description:
986 * Handle incoming association response frames.
995 s_vMgrRxAssocResponse(
998 PSRxMgmtPacket pRxPacket
,
1002 WLAN_FR_ASSOCRESP sFrame
;
1003 PWLAN_IE_SSID pItemSSID
;
1004 unsigned char *pbyIEs
;
1005 viawget_wpa_header
*wpahdr
;
1009 if (pMgmt
->eCurrState
== WMAC_STATE_ASSOCPENDING
||
1010 pMgmt
->eCurrState
== WMAC_STATE_ASSOC
) {
1012 sFrame
.len
= pRxPacket
->cbMPDULen
;
1013 sFrame
.pBuf
= (unsigned char *)pRxPacket
->p80211Header
;
1015 vMgrDecodeAssocResponse(&sFrame
);
1016 if ((sFrame
.pwCapInfo
== 0) ||
1017 (sFrame
.pwStatus
== 0) ||
1018 (sFrame
.pwAid
== 0) ||
1019 (sFrame
.pSuppRates
== 0)){
1024 pMgmt
->sAssocInfo
.AssocInfo
.ResponseFixedIEs
.Capabilities
= *(sFrame
.pwCapInfo
);
1025 pMgmt
->sAssocInfo
.AssocInfo
.ResponseFixedIEs
.StatusCode
= *(sFrame
.pwStatus
);
1026 pMgmt
->sAssocInfo
.AssocInfo
.ResponseFixedIEs
.AssociationId
= *(sFrame
.pwAid
);
1027 pMgmt
->sAssocInfo
.AssocInfo
.AvailableResponseFixedIEs
|= 0x07;
1029 pMgmt
->sAssocInfo
.AssocInfo
.ResponseIELength
= sFrame
.len
- 24 - 6;
1030 pMgmt
->sAssocInfo
.AssocInfo
.OffsetResponseIEs
= pMgmt
->sAssocInfo
.AssocInfo
.OffsetRequestIEs
+ pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
;
1031 pbyIEs
= pMgmt
->sAssocInfo
.abyIEs
;
1032 pbyIEs
+= pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
;
1033 memcpy(pbyIEs
, (sFrame
.pBuf
+ 24 +6), pMgmt
->sAssocInfo
.AssocInfo
.ResponseIELength
);
1035 // save values and set current BSS state
1036 if (cpu_to_le16((*(sFrame
.pwStatus
))) == WLAN_MGMT_STATUS_SUCCESS
){
1038 pMgmt
->wCurrAID
= cpu_to_le16((*(sFrame
.pwAid
)));
1039 if ( (pMgmt
->wCurrAID
>> 14) != (BIT0
| BIT1
) )
1041 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"AID from AP, has two msb clear.\n");
1043 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"Association Successful, AID=%d.\n", pMgmt
->wCurrAID
& ~(BIT14
|BIT15
));
1044 pMgmt
->eCurrState
= WMAC_STATE_ASSOC
;
1045 BSSvUpdateAPNode((void *)pDevice
, sFrame
.pwCapInfo
, sFrame
.pSuppRates
, sFrame
.pExtSuppRates
);
1046 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
;
1047 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"Link with AP(SSID): %s\n", pItemSSID
->abySSID
);
1048 pDevice
->bLinkPass
= true;
1049 pDevice
->uBBVGADiffCount
= 0;
1050 if ((pDevice
->bWPADEVUp
) && (pDevice
->skb
!= NULL
)) {
1051 if(skb_tailroom(pDevice
->skb
) <(sizeof(viawget_wpa_header
)+pMgmt
->sAssocInfo
.AssocInfo
.ResponseIELength
+
1052 pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
)) { //data room not enough
1053 dev_kfree_skb(pDevice
->skb
);
1054 pDevice
->skb
= dev_alloc_skb((int)pDevice
->rx_buf_sz
);
1056 wpahdr
= (viawget_wpa_header
*)pDevice
->skb
->data
;
1057 wpahdr
->type
= VIAWGET_ASSOC_MSG
;
1058 wpahdr
->resp_ie_len
= pMgmt
->sAssocInfo
.AssocInfo
.ResponseIELength
;
1059 wpahdr
->req_ie_len
= pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
;
1060 memcpy(pDevice
->skb
->data
+ sizeof(viawget_wpa_header
), pMgmt
->sAssocInfo
.abyIEs
, wpahdr
->req_ie_len
);
1061 memcpy(pDevice
->skb
->data
+ sizeof(viawget_wpa_header
) + wpahdr
->req_ie_len
,
1065 skb_put(pDevice
->skb
, sizeof(viawget_wpa_header
) + wpahdr
->resp_ie_len
+ wpahdr
->req_ie_len
);
1066 pDevice
->skb
->dev
= pDevice
->wpadev
;
1067 skb_reset_mac_header(pDevice
->skb
);
1068 pDevice
->skb
->pkt_type
= PACKET_HOST
;
1069 pDevice
->skb
->protocol
= htons(ETH_P_802_2
);
1070 memset(pDevice
->skb
->cb
, 0, sizeof(pDevice
->skb
->cb
));
1071 netif_rx(pDevice
->skb
);
1072 pDevice
->skb
= dev_alloc_skb((int)pDevice
->rx_buf_sz
);
1075 //2008-0409-07, <Add> by Einsn Liu
1076 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1077 //if(pDevice->bWPADevEnable == true)
1079 unsigned char buf
[512];
1081 union iwreq_data wrqu
;
1084 memset(buf
, 0, 512);
1086 len
= pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
;
1088 memcpy(buf
, pMgmt
->sAssocInfo
.abyIEs
, len
);
1089 memset(&wrqu
, 0, sizeof (wrqu
));
1090 wrqu
.data
.length
= len
;
1091 we_event
= IWEVASSOCREQIE
;
1092 wireless_send_event(pDevice
->dev
, we_event
, &wrqu
, buf
);
1095 memset(buf
, 0, 512);
1096 len
= pMgmt
->sAssocInfo
.AssocInfo
.ResponseIELength
;
1099 memcpy(buf
, pbyIEs
, len
);
1100 memset(&wrqu
, 0, sizeof (wrqu
));
1101 wrqu
.data
.length
= len
;
1102 we_event
= IWEVASSOCRESPIE
;
1103 wireless_send_event(pDevice
->dev
, we_event
, &wrqu
, buf
);
1107 memset(&wrqu
, 0, sizeof (wrqu
));
1108 memcpy(wrqu
.ap_addr
.sa_data
, &pMgmt
->abyCurrBSSID
[0], ETH_ALEN
);
1109 wrqu
.ap_addr
.sa_family
= ARPHRD_ETHER
;
1110 wireless_send_event(pDevice
->dev
, SIOCGIWAP
, &wrqu
, NULL
);
1112 #endif //#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1113 //End Add -- //2008-0409-07, <Add> by Einsn Liu
1117 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
1120 // jump back to the auth state and indicate the error
1121 pMgmt
->eCurrState
= WMAC_STATE_AUTH
;
1123 s_vMgrLogStatus(pMgmt
,cpu_to_le16((*(sFrame
.pwStatus
))));
1128 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1129 //need clear flags related to Networkmanager
1131 pDevice
->bwextcount
= 0;
1132 pDevice
->bWPASuppWextEnabled
= false;
1136 if(pMgmt
->eCurrState
== WMAC_STATE_ASSOC
)
1137 timer_expire(pDevice
->sTimerCommand
, 0);
1145 * Routine Description:
1146 * Start the station authentication procedure. Namely, send an
1147 * authentication frame to the AP.
1156 void *hDeviceContext
,
1161 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
1162 WLAN_FR_AUTHEN sFrame
;
1163 PSTxMgmtPacket pTxPacket
= NULL
;
1165 pTxPacket
= (PSTxMgmtPacket
)pMgmt
->pbyMgmtPacketPool
;
1166 memset(pTxPacket
, 0, sizeof(STxMgmtPacket
) + WLAN_AUTHEN_FR_MAXLEN
);
1167 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((unsigned char *)pTxPacket
+ sizeof(STxMgmtPacket
));
1168 sFrame
.pBuf
= (unsigned char *)pTxPacket
->p80211Header
;
1169 sFrame
.len
= WLAN_AUTHEN_FR_MAXLEN
;
1170 vMgrEncodeAuthen(&sFrame
);
1172 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
1174 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
1175 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN
)
1177 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pMgmt
->abyCurrBSSID
, WLAN_ADDR_LEN
);
1178 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
1179 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
1180 if (pMgmt
->bShareKeyAlgorithm
)
1181 *(sFrame
.pwAuthAlgorithm
) = cpu_to_le16(WLAN_AUTH_ALG_SHAREDKEY
);
1183 *(sFrame
.pwAuthAlgorithm
) = cpu_to_le16(WLAN_AUTH_ALG_OPENSYSTEM
);
1185 *(sFrame
.pwAuthSequence
) = cpu_to_le16(1);
1186 /* Adjust the length fields */
1187 pTxPacket
->cbMPDULen
= sFrame
.len
;
1188 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
1190 *pStatus
= csMgmt_xmit(pDevice
, pTxPacket
);
1191 if (*pStatus
== CMD_STATUS_PENDING
){
1192 pMgmt
->eCurrState
= WMAC_STATE_AUTHPENDING
;
1193 *pStatus
= CMD_STATUS_SUCCESS
;
1203 * Routine Description:
1204 * Start the station(AP) deauthentication procedure. Namely, send an
1205 * deauthentication frame to the AP or Sta.
1213 vMgrDeAuthenBeginSta(
1214 void *hDeviceContext
,
1216 unsigned char *abyDestAddress
,
1217 unsigned short wReason
,
1221 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
1222 WLAN_FR_DEAUTHEN sFrame
;
1223 PSTxMgmtPacket pTxPacket
= NULL
;
1226 pTxPacket
= (PSTxMgmtPacket
)pMgmt
->pbyMgmtPacketPool
;
1227 memset(pTxPacket
, 0, sizeof(STxMgmtPacket
) + WLAN_DEAUTHEN_FR_MAXLEN
);
1228 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((unsigned char *)pTxPacket
+ sizeof(STxMgmtPacket
));
1229 sFrame
.pBuf
= (unsigned char *)pTxPacket
->p80211Header
;
1230 sFrame
.len
= WLAN_DEAUTHEN_FR_MAXLEN
;
1231 vMgrEncodeDeauthen(&sFrame
);
1233 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
1235 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
1236 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_DEAUTHEN
)
1239 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, abyDestAddress
, WLAN_ADDR_LEN
);
1240 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
1241 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
1243 *(sFrame
.pwReason
) = cpu_to_le16(wReason
); // deauthen. bcs left BSS
1244 /* Adjust the length fields */
1245 pTxPacket
->cbMPDULen
= sFrame
.len
;
1246 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
1248 *pStatus
= csMgmt_xmit(pDevice
, pTxPacket
);
1249 if (*pStatus
== CMD_STATUS_PENDING
){
1250 *pStatus
= CMD_STATUS_SUCCESS
;
1260 * Routine Description:
1261 * Handle incoming authentication frames.
1270 s_vMgrRxAuthentication(
1273 PSRxMgmtPacket pRxPacket
1276 WLAN_FR_AUTHEN sFrame
;
1278 // we better be an AP or a STA in AUTHPENDING otherwise ignore
1279 if (!(pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
||
1280 pMgmt
->eCurrState
== WMAC_STATE_AUTHPENDING
)) {
1285 sFrame
.len
= pRxPacket
->cbMPDULen
;
1286 sFrame
.pBuf
= (unsigned char *)pRxPacket
->p80211Header
;
1287 vMgrDecodeAuthen(&sFrame
);
1288 switch (cpu_to_le16((*(sFrame
.pwAuthSequence
)))){
1291 s_vMgrRxAuthenSequence_1(pDevice
,pMgmt
, &sFrame
);
1294 s_vMgrRxAuthenSequence_2(pDevice
, pMgmt
, &sFrame
);
1298 s_vMgrRxAuthenSequence_3(pDevice
, pMgmt
, &sFrame
);
1301 s_vMgrRxAuthenSequence_4(pDevice
, pMgmt
, &sFrame
);
1304 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Auth Sequence error, seq = %d\n",
1305 cpu_to_le16((*(sFrame
.pwAuthSequence
))));
1315 * Routine Description:
1316 * Handles incoming authen frames with sequence 1. Currently
1317 * assumes we're an AP. So far, no one appears to use authentication
1328 s_vMgrRxAuthenSequence_1(
1331 PWLAN_FR_AUTHEN pFrame
1334 PSTxMgmtPacket pTxPacket
= NULL
;
1335 unsigned int uNodeIndex
;
1336 WLAN_FR_AUTHEN sFrame
;
1337 PSKeyItem pTransmitKey
;
1339 // Insert a Node entry
1340 if (!BSSDBbIsSTAInNodeDB(pMgmt
, pFrame
->pHdr
->sA3
.abyAddr2
, &uNodeIndex
)) {
1341 BSSvCreateOneNode((PSDevice
)pDevice
, &uNodeIndex
);
1342 memcpy(pMgmt
->sNodeDBTable
[uNodeIndex
].abyMACAddr
, pFrame
->pHdr
->sA3
.abyAddr2
,
1346 if (pMgmt
->bShareKeyAlgorithm
) {
1347 pMgmt
->sNodeDBTable
[uNodeIndex
].eNodeState
= NODE_KNOWN
;
1348 pMgmt
->sNodeDBTable
[uNodeIndex
].byAuthSequence
= 1;
1351 pMgmt
->sNodeDBTable
[uNodeIndex
].eNodeState
= NODE_AUTH
;
1355 pTxPacket
= (PSTxMgmtPacket
)pMgmt
->pbyMgmtPacketPool
;
1356 memset(pTxPacket
, 0, sizeof(STxMgmtPacket
) + WLAN_AUTHEN_FR_MAXLEN
);
1357 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((unsigned char *)pTxPacket
+ sizeof(STxMgmtPacket
));
1358 sFrame
.pBuf
= (unsigned char *)pTxPacket
->p80211Header
;
1359 sFrame
.len
= WLAN_AUTHEN_FR_MAXLEN
;
1360 // format buffer structure
1361 vMgrEncodeAuthen(&sFrame
);
1363 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
1365 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
1366 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN
)|
1367 WLAN_SET_FC_ISWEP(0)
1369 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pFrame
->pHdr
->sA3
.abyAddr2
, WLAN_ADDR_LEN
);
1370 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
1371 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
1372 *(sFrame
.pwAuthAlgorithm
) = *(pFrame
->pwAuthAlgorithm
);
1373 *(sFrame
.pwAuthSequence
) = cpu_to_le16(2);
1375 if (cpu_to_le16(*(pFrame
->pwAuthAlgorithm
)) == WLAN_AUTH_ALG_SHAREDKEY
) {
1376 if (pMgmt
->bShareKeyAlgorithm
)
1377 *(sFrame
.pwStatus
) = cpu_to_le16(WLAN_MGMT_STATUS_SUCCESS
);
1379 *(sFrame
.pwStatus
) = cpu_to_le16(WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG
);
1382 if (pMgmt
->bShareKeyAlgorithm
)
1383 *(sFrame
.pwStatus
) = cpu_to_le16(WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG
);
1385 *(sFrame
.pwStatus
) = cpu_to_le16(WLAN_MGMT_STATUS_SUCCESS
);
1388 if (pMgmt
->bShareKeyAlgorithm
&&
1389 (cpu_to_le16(*(sFrame
.pwStatus
)) == WLAN_MGMT_STATUS_SUCCESS
)) {
1391 sFrame
.pChallenge
= (PWLAN_IE_CHALLENGE
)(sFrame
.pBuf
+ sFrame
.len
);
1392 sFrame
.len
+= WLAN_CHALLENGE_IE_LEN
;
1393 sFrame
.pChallenge
->byElementID
= WLAN_EID_CHALLENGE
;
1394 sFrame
.pChallenge
->len
= WLAN_CHALLENGE_LEN
;
1395 memset(pMgmt
->abyChallenge
, 0, WLAN_CHALLENGE_LEN
);
1397 if(KeybGetTransmitKey(&(pDevice
->sKey
), pDevice
->abyBroadcastAddr
, GROUP_KEY
, &pTransmitKey
) == true) {
1398 rc4_init(&pDevice
->SBox
, pDevice
->abyPRNG
, pTransmitKey
->uKeyLength
+3);
1399 rc4_encrypt(&pDevice
->SBox
, pMgmt
->abyChallenge
, pMgmt
->abyChallenge
, WLAN_CHALLENGE_LEN
);
1401 memcpy(sFrame
.pChallenge
->abyChallenge
, pMgmt
->abyChallenge
, WLAN_CHALLENGE_LEN
);
1404 /* Adjust the length fields */
1405 pTxPacket
->cbMPDULen
= sFrame
.len
;
1406 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
1408 if (pDevice
->bEnableHostapd
) {
1411 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Authreq_reply sequence_1 tx.. \n");
1412 if (csMgmt_xmit(pDevice
, pTxPacket
) != CMD_STATUS_PENDING
) {
1413 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Authreq_reply sequence_1 tx failed.\n");
1422 * Routine Description:
1423 * Handles incoming auth frames with sequence number 2. Currently
1424 * assumes we're a station.
1434 s_vMgrRxAuthenSequence_2(
1437 PWLAN_FR_AUTHEN pFrame
1440 WLAN_FR_AUTHEN sFrame
;
1441 PSTxMgmtPacket pTxPacket
= NULL
;
1444 switch (cpu_to_le16((*(pFrame
->pwAuthAlgorithm
))))
1446 case WLAN_AUTH_ALG_OPENSYSTEM
:
1447 if ( cpu_to_le16((*(pFrame
->pwStatus
))) == WLAN_MGMT_STATUS_SUCCESS
){
1448 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"802.11 Authen (OPEN) Successful.\n");
1449 pMgmt
->eCurrState
= WMAC_STATE_AUTH
;
1450 timer_expire(pDevice
->sTimerCommand
, 0);
1453 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"802.11 Authen (OPEN) Failed.\n");
1454 s_vMgrLogStatus(pMgmt
, cpu_to_le16((*(pFrame
->pwStatus
))));
1455 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
1457 if (pDevice
->eCommandState
== WLAN_AUTHENTICATE_WAIT
) {
1458 // spin_unlock_irq(&pDevice->lock);
1459 // vCommandTimerWait((void *)pDevice, 0);
1460 // spin_lock_irq(&pDevice->lock);
1465 case WLAN_AUTH_ALG_SHAREDKEY
:
1467 if (cpu_to_le16((*(pFrame
->pwStatus
))) == WLAN_MGMT_STATUS_SUCCESS
) {
1468 pTxPacket
= (PSTxMgmtPacket
)pMgmt
->pbyMgmtPacketPool
;
1469 memset(pTxPacket
, 0, sizeof(STxMgmtPacket
) + WLAN_AUTHEN_FR_MAXLEN
);
1470 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((unsigned char *)pTxPacket
+ sizeof(STxMgmtPacket
));
1471 sFrame
.pBuf
= (unsigned char *)pTxPacket
->p80211Header
;
1472 sFrame
.len
= WLAN_AUTHEN_FR_MAXLEN
;
1473 // format buffer structure
1474 vMgrEncodeAuthen(&sFrame
);
1476 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
1478 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
1479 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN
)|
1480 WLAN_SET_FC_ISWEP(1)
1482 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
1483 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
1484 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
1485 *(sFrame
.pwAuthAlgorithm
) = *(pFrame
->pwAuthAlgorithm
);
1486 *(sFrame
.pwAuthSequence
) = cpu_to_le16(3);
1487 *(sFrame
.pwStatus
) = cpu_to_le16(WLAN_MGMT_STATUS_SUCCESS
);
1488 sFrame
.pChallenge
= (PWLAN_IE_CHALLENGE
)(sFrame
.pBuf
+ sFrame
.len
);
1489 sFrame
.len
+= WLAN_CHALLENGE_IE_LEN
;
1490 sFrame
.pChallenge
->byElementID
= WLAN_EID_CHALLENGE
;
1491 sFrame
.pChallenge
->len
= WLAN_CHALLENGE_LEN
;
1492 memcpy( sFrame
.pChallenge
->abyChallenge
, pFrame
->pChallenge
->abyChallenge
, WLAN_CHALLENGE_LEN
);
1493 // Adjust the length fields
1494 pTxPacket
->cbMPDULen
= sFrame
.len
;
1495 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
1497 if (csMgmt_xmit(pDevice
, pTxPacket
) != CMD_STATUS_PENDING
) {
1498 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Auth_reply sequence_2 tx failed.\n");
1500 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Auth_reply sequence_2 tx ...\n");
1503 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:rx Auth_reply sequence_2 status error ...\n");
1504 if ( pDevice
->eCommandState
== WLAN_AUTHENTICATE_WAIT
) {
1505 // spin_unlock_irq(&pDevice->lock);
1506 // vCommandTimerWait((void *)pDevice, 0);
1507 // spin_lock_irq(&pDevice->lock);
1509 s_vMgrLogStatus(pMgmt
, cpu_to_le16((*(pFrame
->pwStatus
))));
1513 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt: rx auth.seq = 2 unknown AuthAlgorithm=%d\n", cpu_to_le16((*(pFrame
->pwAuthAlgorithm
))));
1523 * Routine Description:
1524 * Handles incoming authen frames with sequence 3. Currently
1525 * assumes we're an AP. This function assumes the frame has
1526 * already been successfully decrypted.
1536 s_vMgrRxAuthenSequence_3(
1539 PWLAN_FR_AUTHEN pFrame
1542 PSTxMgmtPacket pTxPacket
= NULL
;
1543 unsigned int uStatusCode
= 0 ;
1544 unsigned int uNodeIndex
= 0;
1545 WLAN_FR_AUTHEN sFrame
;
1547 if (!WLAN_GET_FC_ISWEP(pFrame
->pHdr
->sA3
.wFrameCtl
)) {
1548 uStatusCode
= WLAN_MGMT_STATUS_CHALLENGE_FAIL
;
1551 if (BSSDBbIsSTAInNodeDB(pMgmt
, pFrame
->pHdr
->sA3
.abyAddr2
, &uNodeIndex
)) {
1552 if (pMgmt
->sNodeDBTable
[uNodeIndex
].byAuthSequence
!= 1) {
1553 uStatusCode
= WLAN_MGMT_STATUS_RX_AUTH_NOSEQ
;
1556 if (memcmp(pMgmt
->abyChallenge
, pFrame
->pChallenge
->abyChallenge
, WLAN_CHALLENGE_LEN
) != 0) {
1557 uStatusCode
= WLAN_MGMT_STATUS_CHALLENGE_FAIL
;
1562 uStatusCode
= WLAN_MGMT_STATUS_UNSPEC_FAILURE
;
1567 pMgmt
->sNodeDBTable
[uNodeIndex
].eNodeState
= NODE_AUTH
;
1568 pMgmt
->sNodeDBTable
[uNodeIndex
].byAuthSequence
= 0;
1570 uStatusCode
= WLAN_MGMT_STATUS_SUCCESS
;
1571 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Challenge text check ok..\n");
1575 pTxPacket
= (PSTxMgmtPacket
)pMgmt
->pbyMgmtPacketPool
;
1576 memset(pTxPacket
, 0, sizeof(STxMgmtPacket
) + WLAN_AUTHEN_FR_MAXLEN
);
1577 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((unsigned char *)pTxPacket
+ sizeof(STxMgmtPacket
));
1578 sFrame
.pBuf
= (unsigned char *)pTxPacket
->p80211Header
;
1579 sFrame
.len
= WLAN_AUTHEN_FR_MAXLEN
;
1580 // format buffer structure
1581 vMgrEncodeAuthen(&sFrame
);
1583 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
1585 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
1586 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN
)|
1587 WLAN_SET_FC_ISWEP(0)
1589 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pFrame
->pHdr
->sA3
.abyAddr2
, WLAN_ADDR_LEN
);
1590 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
1591 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
1592 *(sFrame
.pwAuthAlgorithm
) = *(pFrame
->pwAuthAlgorithm
);
1593 *(sFrame
.pwAuthSequence
) = cpu_to_le16(4);
1594 *(sFrame
.pwStatus
) = cpu_to_le16(uStatusCode
);
1596 /* Adjust the length fields */
1597 pTxPacket
->cbMPDULen
= sFrame
.len
;
1598 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
1600 if (pDevice
->bEnableHostapd
) {
1603 if (csMgmt_xmit(pDevice
, pTxPacket
) != CMD_STATUS_PENDING
) {
1604 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Authreq_reply sequence_4 tx failed.\n");
1614 * Routine Description:
1615 * Handles incoming authen frames with sequence 4
1624 s_vMgrRxAuthenSequence_4(
1627 PWLAN_FR_AUTHEN pFrame
1631 if ( cpu_to_le16((*(pFrame
->pwStatus
))) == WLAN_MGMT_STATUS_SUCCESS
){
1632 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"802.11 Authen (SHAREDKEY) Successful.\n");
1633 pMgmt
->eCurrState
= WMAC_STATE_AUTH
;
1634 timer_expire(pDevice
->sTimerCommand
, 0);
1637 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"802.11 Authen (SHAREDKEY) Failed.\n");
1638 s_vMgrLogStatus(pMgmt
, cpu_to_le16((*(pFrame
->pwStatus
))) );
1639 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
1642 if ( pDevice
->eCommandState
== WLAN_AUTHENTICATE_WAIT
) {
1643 // spin_unlock_irq(&pDevice->lock);
1644 // vCommandTimerWait((void *)pDevice, 0);
1645 // spin_lock_irq(&pDevice->lock);
1652 * Routine Description:
1653 * Handles incoming disassociation frames
1663 s_vMgrRxDisassociation(
1666 PSRxMgmtPacket pRxPacket
1669 WLAN_FR_DISASSOC sFrame
;
1670 unsigned int uNodeIndex
= 0;
1671 // CMD_STATUS CmdStatus;
1672 viawget_wpa_header
*wpahdr
;
1674 if ( pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
){
1675 // if is acting an AP..
1676 // a STA is leaving this BSS..
1677 sFrame
.len
= pRxPacket
->cbMPDULen
;
1678 sFrame
.pBuf
= (unsigned char *)pRxPacket
->p80211Header
;
1679 if (BSSDBbIsSTAInNodeDB(pMgmt
, pRxPacket
->p80211Header
->sA3
.abyAddr2
, &uNodeIndex
)) {
1680 BSSvRemoveOneNode(pDevice
, uNodeIndex
);
1683 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Rx disassoc, sta not found\n");
1686 else if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_STA
){
1687 sFrame
.len
= pRxPacket
->cbMPDULen
;
1688 sFrame
.pBuf
= (unsigned char *)pRxPacket
->p80211Header
;
1689 vMgrDecodeDisassociation(&sFrame
);
1690 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"AP disassociated me, reason=%d.\n", cpu_to_le16(*(sFrame
.pwReason
)));
1691 //TODO: do something let upper layer know or
1692 //try to send associate packet again because of inactivity timeout
1693 // if (pMgmt->eCurrState == WMAC_STATE_ASSOC) {
1694 // vMgrReAssocBeginSta((PSDevice)pDevice, pMgmt, &CmdStatus);
1696 if ((pDevice
->bWPADEVUp
) && (pDevice
->skb
!= NULL
)) {
1697 wpahdr
= (viawget_wpa_header
*)pDevice
->skb
->data
;
1698 wpahdr
->type
= VIAWGET_DISASSOC_MSG
;
1699 wpahdr
->resp_ie_len
= 0;
1700 wpahdr
->req_ie_len
= 0;
1701 skb_put(pDevice
->skb
, sizeof(viawget_wpa_header
));
1702 pDevice
->skb
->dev
= pDevice
->wpadev
;
1703 skb_reset_mac_header(pDevice
->skb
);
1705 pDevice
->skb
->pkt_type
= PACKET_HOST
;
1706 pDevice
->skb
->protocol
= htons(ETH_P_802_2
);
1707 memset(pDevice
->skb
->cb
, 0, sizeof(pDevice
->skb
->cb
));
1708 netif_rx(pDevice
->skb
);
1709 pDevice
->skb
= dev_alloc_skb((int)pDevice
->rx_buf_sz
);
1712 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1713 // if(pDevice->bWPASuppWextEnabled == true)
1715 union iwreq_data wrqu
;
1716 memset(&wrqu
, 0, sizeof (wrqu
));
1717 wrqu
.ap_addr
.sa_family
= ARPHRD_ETHER
;
1718 printk("wireless_send_event--->SIOCGIWAP(disassociated)\n");
1719 wireless_send_event(pDevice
->dev
, SIOCGIWAP
, &wrqu
, NULL
);
1723 /* else, ignore it */
1731 * Routine Description:
1732 * Handles incoming deauthentication frames
1742 s_vMgrRxDeauthentication(
1745 PSRxMgmtPacket pRxPacket
1748 WLAN_FR_DEAUTHEN sFrame
;
1749 unsigned int uNodeIndex
= 0;
1750 viawget_wpa_header
*wpahdr
;
1753 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
){
1755 // if is acting an AP..
1756 // a STA is leaving this BSS..
1757 sFrame
.len
= pRxPacket
->cbMPDULen
;
1758 sFrame
.pBuf
= (unsigned char *)pRxPacket
->p80211Header
;
1759 if (BSSDBbIsSTAInNodeDB(pMgmt
, pRxPacket
->p80211Header
->sA3
.abyAddr2
, &uNodeIndex
)) {
1760 BSSvRemoveOneNode(pDevice
, uNodeIndex
);
1763 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Rx deauth, sta not found\n");
1767 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_STA
) {
1768 sFrame
.len
= pRxPacket
->cbMPDULen
;
1769 sFrame
.pBuf
= (unsigned char *)pRxPacket
->p80211Header
;
1770 vMgrDecodeDeauthen(&sFrame
);
1771 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"AP deauthed me, reason=%d.\n", cpu_to_le16((*(sFrame
.pwReason
))));
1772 // TODO: update BSS list for specific BSSID if pre-authentication case
1773 if (!compare_ether_addr(sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
)) {
1774 if (pMgmt
->eCurrState
>= WMAC_STATE_AUTHPENDING
) {
1775 pMgmt
->sNodeDBTable
[0].bActive
= false;
1776 pMgmt
->eCurrMode
= WMAC_MODE_STANDBY
;
1777 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
1778 netif_stop_queue(pDevice
->dev
);
1779 pDevice
->bLinkPass
= false;
1783 if ((pDevice
->bWPADEVUp
) && (pDevice
->skb
!= NULL
)) {
1784 wpahdr
= (viawget_wpa_header
*)pDevice
->skb
->data
;
1785 wpahdr
->type
= VIAWGET_DISASSOC_MSG
;
1786 wpahdr
->resp_ie_len
= 0;
1787 wpahdr
->req_ie_len
= 0;
1788 skb_put(pDevice
->skb
, sizeof(viawget_wpa_header
));
1789 pDevice
->skb
->dev
= pDevice
->wpadev
;
1790 skb_reset_mac_header(pDevice
->skb
);
1791 pDevice
->skb
->pkt_type
= PACKET_HOST
;
1792 pDevice
->skb
->protocol
= htons(ETH_P_802_2
);
1793 memset(pDevice
->skb
->cb
, 0, sizeof(pDevice
->skb
->cb
));
1794 netif_rx(pDevice
->skb
);
1795 pDevice
->skb
= dev_alloc_skb((int)pDevice
->rx_buf_sz
);
1798 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1799 // if(pDevice->bWPASuppWextEnabled == true)
1801 union iwreq_data wrqu
;
1802 memset(&wrqu
, 0, sizeof (wrqu
));
1803 wrqu
.ap_addr
.sa_family
= ARPHRD_ETHER
;
1804 PRINT_K("wireless_send_event--->SIOCGIWAP(disauthen)\n");
1805 wireless_send_event(pDevice
->dev
, SIOCGIWAP
, &wrqu
, NULL
);
1810 /* else, ignore it. TODO: IBSS authentication service
1811 would be implemented here */
1817 //2008-8-4 <add> by chester
1820 * Routine Description:
1821 * check if current channel is match ZoneType.
1830 ChannelExceedZoneType(
1832 unsigned char byCurrChannel
1837 switch(pDevice
->byZoneType
) {
1838 case 0x00: //USA:1~11
1839 if((byCurrChannel
<1) ||(byCurrChannel
>11))
1842 case 0x01: //Japan:1~13
1843 case 0x02: //Europe:1~13
1844 if((byCurrChannel
<1) ||(byCurrChannel
>13))
1847 default: //reserve for other zonetype
1857 * Routine Description:
1858 * Handles and analysis incoming beacon frames.
1871 PSRxMgmtPacket pRxPacket
,
1877 WLAN_FR_BEACON sFrame
;
1879 bool bIsBSSIDEqual
= false;
1880 bool bIsSSIDEqual
= false;
1881 bool bTSFLargeDiff
= false;
1882 bool bTSFOffsetPostive
= false;
1883 bool bUpdateTSF
= false;
1884 bool bIsAPBeacon
= false;
1885 bool bIsChannelEqual
= false;
1886 unsigned int uLocateByteIndex
;
1887 unsigned char byTIMBitOn
= 0;
1888 unsigned short wAIDNumber
= 0;
1889 unsigned int uNodeIndex
;
1890 QWORD qwTimestamp
, qwLocalTSF
;
1892 unsigned short wStartIndex
= 0;
1893 unsigned short wAIDIndex
= 0;
1894 unsigned char byCurrChannel
= pRxPacket
->byRxChannel
;
1896 unsigned int uRateLen
= WLAN_RATES_MAXLEN
;
1897 bool bChannelHit
= false;
1898 bool bUpdatePhyParameter
= false;
1899 unsigned char byIEChannel
= 0;
1902 memset(&sFrame
, 0, sizeof(WLAN_FR_BEACON
));
1903 sFrame
.len
= pRxPacket
->cbMPDULen
;
1904 sFrame
.pBuf
= (unsigned char *)pRxPacket
->p80211Header
;
1906 // decode the beacon frame
1907 vMgrDecodeBeacon(&sFrame
);
1909 if ((sFrame
.pwBeaconInterval
== 0) ||
1910 (sFrame
.pwCapInfo
== 0) ||
1911 (sFrame
.pSSID
== 0) ||
1912 (sFrame
.pSuppRates
== 0) ) {
1913 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Rx beacon frame error\n");
1918 if (sFrame
.pDSParms
!= NULL
) {
1919 if (byCurrChannel
> CB_MAX_CHANNEL_24G
) {
1920 // channel remapping to
1921 byIEChannel
= get_channel_mapping(pDevice
, sFrame
.pDSParms
->byCurrChannel
, PHY_TYPE_11A
);
1923 byIEChannel
= sFrame
.pDSParms
->byCurrChannel
;
1925 if (byCurrChannel
!= byIEChannel
) {
1926 // adjust channel info. bcs we rcv adjcent channel pakckets
1927 bChannelHit
= false;
1928 byCurrChannel
= byIEChannel
;
1931 // no DS channel info
1934 //2008-0730-01<Add>by MikeLiu
1935 if(ChannelExceedZoneType(pDevice
,byCurrChannel
)==true)
1938 if (sFrame
.pERP
!= NULL
) {
1939 sERP
.byERP
= sFrame
.pERP
->byContext
;
1940 sERP
.bERPExist
= true;
1943 sERP
.bERPExist
= false;
1947 pBSSList
= BSSpAddrIsInBSSList((void *)pDevice
, sFrame
.pHdr
->sA3
.abyAddr3
, sFrame
.pSSID
);
1948 if (pBSSList
== NULL
) {
1949 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Beacon/insert: RxChannel = : %d\n", byCurrChannel
);
1950 BSSbInsertToBSSList((void *)pDevice
,
1951 sFrame
.pHdr
->sA3
.abyAddr3
,
1952 *sFrame
.pqwTimestamp
,
1953 *sFrame
.pwBeaconInterval
,
1958 sFrame
.pExtSuppRates
,
1964 sFrame
.len
- WLAN_HDR_ADDR3_LEN
,
1965 sFrame
.pHdr
->sA4
.abyAddr4
, // payload of beacon
1970 // DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"update bcn: RxChannel = : %d\n", byCurrChannel);
1971 BSSbUpdateToBSSList((void *)pDevice
,
1972 *sFrame
.pqwTimestamp
,
1973 *sFrame
.pwBeaconInterval
,
1979 sFrame
.pExtSuppRates
,
1986 sFrame
.len
- WLAN_HDR_ADDR3_LEN
,
1987 sFrame
.pHdr
->sA4
.abyAddr4
, // payload of probresponse
1997 if(byCurrChannel
== (unsigned char)pMgmt
->uCurrChannel
)
1998 bIsChannelEqual
= true;
2000 if (bIsChannelEqual
&& (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
)) {
2002 // if rx beacon without ERP field
2003 if (sERP
.bERPExist
) {
2004 if (WLAN_GET_ERP_USE_PROTECTION(sERP
.byERP
)){
2005 pDevice
->byERPFlag
|= WLAN_SET_ERP_USE_PROTECTION(1);
2006 pDevice
->wUseProtectCntDown
= USE_PROTECT_PERIOD
;
2010 pDevice
->byERPFlag
|= WLAN_SET_ERP_USE_PROTECTION(1);
2011 pDevice
->wUseProtectCntDown
= USE_PROTECT_PERIOD
;
2014 if (pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) {
2015 if(!WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame
.pwCapInfo
))
2016 pDevice
->byERPFlag
|= WLAN_SET_ERP_BARKER_MODE(1);
2018 pDevice
->byERPFlag
|= WLAN_SET_ERP_NONERP_PRESENT(1);
2022 if (WLAN_GET_ERP_USE_PROTECTION(pDevice
->byERPFlag
)){
2023 if (!pDevice
->bProtectMode
) {
2024 MACvEnableProtectMD(pDevice
->PortOffset
);
2025 pDevice
->bProtectMode
= true;
2031 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
)
2034 // check if BSSID the same
2035 if (memcmp(sFrame
.pHdr
->sA3
.abyAddr3
,
2036 pMgmt
->abyCurrBSSID
,
2037 WLAN_BSSID_LEN
) == 0) {
2039 bIsBSSIDEqual
= true;
2041 // 2008-05-21 <add> by Richardtai
2042 pDevice
->uCurrRSSI
= pRxPacket
->uRSSI
;
2043 pDevice
->byCurrSQ
= pRxPacket
->bySQ
;
2045 if (pMgmt
->sNodeDBTable
[0].uInActiveCount
!= 0) {
2046 pMgmt
->sNodeDBTable
[0].uInActiveCount
= 0;
2047 //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BCN:Wake Count= [%d]\n", pMgmt->wCountToWakeUp);
2050 // check if SSID the same
2051 if (sFrame
.pSSID
->len
== ((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->len
) {
2052 if (memcmp(sFrame
.pSSID
->abySSID
,
2053 ((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->abySSID
,
2056 bIsSSIDEqual
= true;
2060 if ((WLAN_GET_CAP_INFO_ESS(*sFrame
.pwCapInfo
)== true) &&
2061 (bIsBSSIDEqual
== true) &&
2062 (bIsSSIDEqual
== true) &&
2063 (pMgmt
->eCurrMode
== WMAC_MODE_ESS_STA
) &&
2064 (pMgmt
->eCurrState
== WMAC_STATE_ASSOC
)) {
2065 // add state check to prevent reconnect fail since we'll receive Beacon
2069 if (pBSSList
!= NULL
) {
2071 // Compare PHY paramater setting
2072 if (pMgmt
->wCurrCapInfo
!= pBSSList
->wCapInfo
) {
2073 bUpdatePhyParameter
= true;
2074 pMgmt
->wCurrCapInfo
= pBSSList
->wCapInfo
;
2076 if (sFrame
.pERP
!= NULL
) {
2077 if ((sFrame
.pERP
->byElementID
== WLAN_EID_ERP
) &&
2078 (pMgmt
->byERPContext
!= sFrame
.pERP
->byContext
)) {
2079 bUpdatePhyParameter
= true;
2080 pMgmt
->byERPContext
= sFrame
.pERP
->byContext
;
2084 // Basic Rate Set may change dynamiclly
2086 if (pBSSList
->eNetworkTypeInUse
== PHY_TYPE_11B
) {
2087 uRateLen
= WLAN_RATES_MAXLEN_11B
;
2089 pMgmt
->abyCurrSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)pBSSList
->abySuppRates
,
2090 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
2092 pMgmt
->abyCurrExtSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)pBSSList
->abyExtSuppRates
,
2093 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
,
2095 RATEvParseMaxRate( (void *)pDevice
,
2096 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
2097 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
,
2099 &(pMgmt
->sNodeDBTable
[0].wMaxBasicRate
),
2100 &(pMgmt
->sNodeDBTable
[0].wMaxSuppRate
),
2101 &(pMgmt
->sNodeDBTable
[0].wSuppRate
),
2102 &(pMgmt
->sNodeDBTable
[0].byTopCCKBasicRate
),
2103 &(pMgmt
->sNodeDBTable
[0].byTopOFDMBasicRate
)
2106 //printk("RxBeacon:MaxSuppRate is %d\n",pMgmt->sNodeDBTable[0].wMaxSuppRate);
2108 if (bUpdatePhyParameter
== true) {
2109 CARDbSetPhyParameter( pMgmt
->pAdapter
,
2110 pMgmt
->eCurrentPHYMode
,
2111 pMgmt
->wCurrCapInfo
,
2112 pMgmt
->byERPContext
,
2113 pMgmt
->abyCurrSuppRates
,
2114 pMgmt
->abyCurrExtSuppRates
2117 if (sFrame
.pIE_PowerConstraint
!= NULL
) {
2118 CARDvSetPowerConstraint(pMgmt
->pAdapter
,
2119 (unsigned char) pBSSList
->uChannel
,
2120 sFrame
.pIE_PowerConstraint
->byPower
2123 if (sFrame
.pIE_CHSW
!= NULL
) {
2124 CARDbChannelSwitch( pMgmt
->pAdapter
,
2125 sFrame
.pIE_CHSW
->byMode
,
2126 get_channel_mapping(pMgmt
->pAdapter
, sFrame
.pIE_CHSW
->byMode
, pMgmt
->eCurrentPHYMode
),
2127 sFrame
.pIE_CHSW
->byCount
2130 } else if (bIsChannelEqual
== false) {
2131 set_channel(pMgmt
->pAdapter
, pBSSList
->uChannel
);
2136 // DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Beacon 2 \n");
2137 // check if CF field exisit
2138 if (WLAN_GET_CAP_INFO_ESS(*sFrame
.pwCapInfo
)) {
2139 if (sFrame
.pCFParms
->wCFPDurRemaining
> 0) {
2140 // TODO: deal with CFP period to set NAV
2144 HIDWORD(qwTimestamp
) = cpu_to_le32(HIDWORD(*sFrame
.pqwTimestamp
));
2145 LODWORD(qwTimestamp
) = cpu_to_le32(LODWORD(*sFrame
.pqwTimestamp
));
2146 HIDWORD(qwLocalTSF
) = HIDWORD(pRxPacket
->qwLocalTSF
);
2147 LODWORD(qwLocalTSF
) = LODWORD(pRxPacket
->qwLocalTSF
);
2149 // check if beacon TSF larger or small than our local TSF
2150 if (HIDWORD(qwTimestamp
) == HIDWORD(qwLocalTSF
)) {
2151 if (LODWORD(qwTimestamp
) >= LODWORD(qwLocalTSF
)) {
2152 bTSFOffsetPostive
= true;
2155 bTSFOffsetPostive
= false;
2158 else if (HIDWORD(qwTimestamp
) > HIDWORD(qwLocalTSF
)) {
2159 bTSFOffsetPostive
= true;
2161 else if (HIDWORD(qwTimestamp
) < HIDWORD(qwLocalTSF
)) {
2162 bTSFOffsetPostive
= false;
2165 if (bTSFOffsetPostive
) {
2166 qwTSFOffset
= CARDqGetTSFOffset(pRxPacket
->byRxRate
, (qwTimestamp
), (qwLocalTSF
));
2169 qwTSFOffset
= CARDqGetTSFOffset(pRxPacket
->byRxRate
, (qwLocalTSF
), (qwTimestamp
));
2172 if (HIDWORD(qwTSFOffset
) != 0 ||
2173 (LODWORD(qwTSFOffset
) > TRIVIAL_SYNC_DIFFERENCE
)) {
2174 bTSFLargeDiff
= true;
2179 if (bIsAPBeacon
== true) {
2181 // Infra mode: Local TSF always follow AP's TSF if Difference huge.
2185 if ((pDevice
->bEnablePSMode
== true) &&(sFrame
.pTIM
!= 0)) {
2187 // deal with DTIM, analysis TIM
2188 pMgmt
->bMulticastTIM
= WLAN_MGMT_IS_MULTICAST_TIM(sFrame
.pTIM
->byBitMapCtl
) ? true : false ;
2189 pMgmt
->byDTIMCount
= sFrame
.pTIM
->byDTIMCount
;
2190 pMgmt
->byDTIMPeriod
= sFrame
.pTIM
->byDTIMPeriod
;
2191 wAIDNumber
= pMgmt
->wCurrAID
& ~(BIT14
|BIT15
);
2193 // check if AID in TIM field bit on
2195 wStartIndex
= WLAN_MGMT_GET_TIM_OFFSET(sFrame
.pTIM
->byBitMapCtl
) << 1;
2197 wAIDIndex
= (wAIDNumber
>> 3);
2198 if ((wAIDNumber
> 0) && (wAIDIndex
>= wStartIndex
)) {
2199 uLocateByteIndex
= wAIDIndex
- wStartIndex
;
2200 // len = byDTIMCount + byDTIMPeriod + byDTIMPeriod + byVirtBitMap[0~250]
2201 if (sFrame
.pTIM
->len
>= (uLocateByteIndex
+ 4)) {
2202 byTIMBitOn
= (0x01) << ((wAIDNumber
) % 8);
2203 pMgmt
->bInTIM
= sFrame
.pTIM
->byVirtBitMap
[uLocateByteIndex
] & byTIMBitOn
? true : false;
2206 pMgmt
->bInTIM
= false;
2210 pMgmt
->bInTIM
= false;
2213 if (pMgmt
->bInTIM
||
2214 (pMgmt
->bMulticastTIM
&& (pMgmt
->byDTIMCount
== 0))) {
2215 pMgmt
->bInTIMWake
= true;
2216 // send out ps-poll packet
2217 // DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BCN:In TIM\n");
2218 if (pMgmt
->bInTIM
) {
2219 PSvSendPSPOLL((PSDevice
)pDevice
);
2220 // DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BCN:PS-POLL sent..\n");
2225 pMgmt
->bInTIMWake
= false;
2226 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"BCN: Not In TIM..\n");
2227 if (pDevice
->bPWBitOn
== false) {
2228 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"BCN: Send Null Packet\n");
2229 if (PSbSendNullPacket(pDevice
))
2230 pDevice
->bPWBitOn
= true;
2232 if(PSbConsiderPowerDown(pDevice
, false, false)) {
2233 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"BCN: Power down now...\n");
2241 if ((pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) && !bIsAPBeacon
&& bIsChannelEqual
) {
2242 if (bIsBSSIDEqual
) {
2243 // Use sNodeDBTable[0].uInActiveCount as IBSS beacons received count.
2244 if (pMgmt
->sNodeDBTable
[0].uInActiveCount
!= 0)
2245 pMgmt
->sNodeDBTable
[0].uInActiveCount
= 0;
2247 // adhoc mode:TSF updated only when beacon larger then local TSF
2248 if (bTSFLargeDiff
&& bTSFOffsetPostive
&&
2249 (pMgmt
->eCurrState
== WMAC_STATE_JOINTED
))
2252 // During dpc, already in spinlocked.
2253 if (BSSDBbIsSTAInNodeDB(pMgmt
, sFrame
.pHdr
->sA3
.abyAddr2
, &uNodeIndex
)) {
2255 // Update the STA, (Techically the Beacons of all the IBSS nodes
2256 // should be identical, but that's not happening in practice.
2257 pMgmt
->abyCurrSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)sFrame
.pSuppRates
,
2258 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
2259 WLAN_RATES_MAXLEN_11B
);
2260 RATEvParseMaxRate( (void *)pDevice
,
2261 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
2264 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxBasicRate
),
2265 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
),
2266 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wSuppRate
),
2267 &(pMgmt
->sNodeDBTable
[uNodeIndex
].byTopCCKBasicRate
),
2268 &(pMgmt
->sNodeDBTable
[uNodeIndex
].byTopOFDMBasicRate
)
2270 pMgmt
->sNodeDBTable
[uNodeIndex
].bShortPreamble
= WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame
.pwCapInfo
);
2271 pMgmt
->sNodeDBTable
[uNodeIndex
].bShortSlotTime
= WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame
.pwCapInfo
);
2272 pMgmt
->sNodeDBTable
[uNodeIndex
].uInActiveCount
= 0;
2275 // Todo, initial Node content
2276 BSSvCreateOneNode((PSDevice
)pDevice
, &uNodeIndex
);
2278 pMgmt
->abyCurrSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)sFrame
.pSuppRates
,
2279 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
2280 WLAN_RATES_MAXLEN_11B
);
2281 RATEvParseMaxRate( (void *)pDevice
,
2282 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
2285 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxBasicRate
),
2286 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
),
2287 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wSuppRate
),
2288 &(pMgmt
->sNodeDBTable
[uNodeIndex
].byTopCCKBasicRate
),
2289 &(pMgmt
->sNodeDBTable
[uNodeIndex
].byTopOFDMBasicRate
)
2292 memcpy(pMgmt
->sNodeDBTable
[uNodeIndex
].abyMACAddr
, sFrame
.pHdr
->sA3
.abyAddr2
, WLAN_ADDR_LEN
);
2293 pMgmt
->sNodeDBTable
[uNodeIndex
].bShortPreamble
= WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame
.pwCapInfo
);
2294 pMgmt
->sNodeDBTable
[uNodeIndex
].wTxDataRate
= pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
;
2296 //if (uNodeIndex == 0)
2298 printk("s_vMgrRxBeacon:TxDataRate is %d,Index is %d\n",pMgmt
->sNodeDBTable
[uNodeIndex
].wTxDataRate
,uNodeIndex
);
2302 pMgmt->sNodeDBTable[uNodeIndex].bShortSlotTime = WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame.pwCapInfo);
2303 if(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate > RATE_11M)
2304 pMgmt->sNodeDBTable[uNodeIndex].bERPExist = true;
2308 // if other stations jointed, indicate connect to upper layer..
2309 if (pMgmt
->eCurrState
== WMAC_STATE_STARTED
) {
2310 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Current IBSS State: [Started]........to: [Jointed] \n");
2311 pMgmt
->eCurrState
= WMAC_STATE_JOINTED
;
2312 pDevice
->bLinkPass
= true;
2313 if (netif_queue_stopped(pDevice
->dev
)){
2314 netif_wake_queue(pDevice
->dev
);
2316 pMgmt
->sNodeDBTable
[0].bActive
= true;
2317 pMgmt
->sNodeDBTable
[0].uInActiveCount
= 0;
2321 else if (bIsSSIDEqual
) {
2323 // See other adhoc sta with the same SSID but BSSID is different.
2324 // adpot this vars only when TSF larger then us.
2325 if (bTSFLargeDiff
&& bTSFOffsetPostive
) {
2326 // we don't support ATIM under adhoc mode
2327 // if ( sFrame.pIBSSParms->wATIMWindow == 0) {
2329 // TODO: check sFrame cap if privacy on, and support rate syn
2330 memcpy(pMgmt
->abyCurrBSSID
, sFrame
.pHdr
->sA3
.abyAddr3
, WLAN_BSSID_LEN
);
2331 memcpy(pDevice
->abyBSSID
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
2332 pMgmt
->wCurrATIMWindow
= cpu_to_le16(sFrame
.pIBSSParms
->wATIMWindow
);
2333 pMgmt
->wCurrBeaconPeriod
= cpu_to_le16(*sFrame
.pwBeaconInterval
);
2334 pMgmt
->abyCurrSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)sFrame
.pSuppRates
,
2335 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
2336 WLAN_RATES_MAXLEN_11B
);
2337 // set HW beacon interval and re-synchronizing....
2338 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Rejoining to Other Adhoc group with same SSID........\n");
2339 VNSvOutPortW(pDevice
->PortOffset
+ MAC_REG_BI
, pMgmt
->wCurrBeaconPeriod
);
2340 CARDbUpdateTSF(pDevice
, pRxPacket
->byRxRate
, qwTimestamp
, qwLocalTSF
);
2341 CARDvUpdateNextTBTT(pDevice
->PortOffset
, qwTimestamp
, pMgmt
->wCurrBeaconPeriod
);
2342 // Turn off bssid filter to avoid filter others adhoc station which bssid is different.
2343 MACvWriteBSSIDAddress(pDevice
->PortOffset
, pMgmt
->abyCurrBSSID
);
2345 CARDbSetPhyParameter ( pMgmt
->pAdapter
,
2346 pMgmt
->eCurrentPHYMode
,
2347 pMgmt
->wCurrCapInfo
,
2348 pMgmt
->byERPContext
,
2349 pMgmt
->abyCurrSuppRates
,
2350 pMgmt
->abyCurrExtSuppRates
);
2353 // MACvRegBitsOff(pDevice->PortOffset, MAC_REG_RCR, RCR_BSSID);
2354 // set highest basic rate
2355 // s_vSetHighestBasicRate(pDevice, (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates);
2356 // Prepare beacon frame
2357 bMgrPrepareBeaconToSend((void *)pDevice
, pMgmt
);
2365 CARDbGetCurrentTSF(pDevice
->PortOffset
, &qwCurrTSF
);
2366 CARDbUpdateTSF(pDevice
, pRxPacket
->byRxRate
, qwTimestamp
, pRxPacket
->qwLocalTSF
);
2367 CARDbGetCurrentTSF(pDevice
->PortOffset
, &qwCurrTSF
);
2368 CARDvUpdateNextTBTT(pDevice
->PortOffset
, qwTimestamp
, pMgmt
->wCurrBeaconPeriod
);
2378 * Routine Description:
2379 * Instructs the hw to create a bss using the supplied
2380 * attributes. Note that this implementation only supports Ad-Hoc
2390 void *hDeviceContext
,
2394 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
2395 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
2396 unsigned short wMaxBasicRate
;
2397 unsigned short wMaxSuppRate
;
2398 unsigned char byTopCCKBasicRate
;
2399 unsigned char byTopOFDMBasicRate
;
2402 unsigned char abyRATE
[] = {0x82, 0x84, 0x8B, 0x96, 0x24, 0x30, 0x48, 0x6C, 0x0C, 0x12, 0x18, 0x60};
2403 unsigned char abyCCK_RATE
[] = {0x82, 0x84, 0x8B, 0x96};
2404 unsigned char abyOFDM_RATE
[] = {0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
2405 unsigned short wSuppRate
;
2407 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Create Basic Service Set .......\n");
2409 if (pMgmt
->eConfigMode
== WMAC_CONFIG_IBSS_STA
) {
2410 if ((pMgmt
->eAuthenMode
== WMAC_AUTH_WPANONE
) &&
2411 (pDevice
->eEncryptionStatus
!= Ndis802_11Encryption2Enabled
) &&
2412 (pDevice
->eEncryptionStatus
!= Ndis802_11Encryption3Enabled
)) {
2413 // encryption mode error
2414 *pStatus
= CMD_STATUS_FAILURE
;
2419 pMgmt
->abyCurrSuppRates
[0] = WLAN_EID_SUPP_RATES
;
2420 pMgmt
->abyCurrExtSuppRates
[0] = WLAN_EID_EXTSUPP_RATES
;
2422 if (pMgmt
->eConfigMode
== WMAC_CONFIG_AP
) {
2423 pMgmt
->eCurrentPHYMode
= pMgmt
->byAPBBType
;
2425 if (pDevice
->byBBType
== BB_TYPE_11G
)
2426 pMgmt
->eCurrentPHYMode
= PHY_TYPE_11G
;
2427 if (pDevice
->byBBType
== BB_TYPE_11B
)
2428 pMgmt
->eCurrentPHYMode
= PHY_TYPE_11B
;
2429 if (pDevice
->byBBType
== BB_TYPE_11A
)
2430 pMgmt
->eCurrentPHYMode
= PHY_TYPE_11A
;
2433 if (pMgmt
->eCurrentPHYMode
!= PHY_TYPE_11A
) {
2434 pMgmt
->abyCurrSuppRates
[1] = WLAN_RATES_MAXLEN_11B
;
2435 pMgmt
->abyCurrExtSuppRates
[1] = 0;
2436 for (ii
= 0; ii
< 4; ii
++)
2437 pMgmt
->abyCurrSuppRates
[2+ii
] = abyRATE
[ii
];
2439 pMgmt
->abyCurrSuppRates
[1] = 8;
2440 pMgmt
->abyCurrExtSuppRates
[1] = 0;
2441 for (ii
= 0; ii
< 8; ii
++)
2442 pMgmt
->abyCurrSuppRates
[2+ii
] = abyRATE
[ii
];
2446 if (pMgmt
->eCurrentPHYMode
== PHY_TYPE_11G
) {
2447 pMgmt
->abyCurrSuppRates
[1] = 8;
2448 pMgmt
->abyCurrExtSuppRates
[1] = 4;
2449 for (ii
= 0; ii
< 4; ii
++)
2450 pMgmt
->abyCurrSuppRates
[2+ii
] = abyCCK_RATE
[ii
];
2451 for (ii
= 4; ii
< 8; ii
++)
2452 pMgmt
->abyCurrSuppRates
[2+ii
] = abyOFDM_RATE
[ii
-4];
2453 for (ii
= 0; ii
< 4; ii
++)
2454 pMgmt
->abyCurrExtSuppRates
[2+ii
] = abyOFDM_RATE
[ii
+4];
2458 // Disable Protect Mode
2459 pDevice
->bProtectMode
= 0;
2460 MACvDisableProtectMD(pDevice
->PortOffset
);
2462 pDevice
->bBarkerPreambleMd
= 0;
2463 MACvDisableBarkerPreambleMd(pDevice
->PortOffset
);
2465 // Kyle Test 2003.11.04
2467 // set HW beacon interval
2468 if (pMgmt
->wIBSSBeaconPeriod
== 0)
2469 pMgmt
->wIBSSBeaconPeriod
= DEFAULT_IBSS_BI
;
2472 CARDbGetCurrentTSF(pDevice
->PortOffset
, &qwCurrTSF
);
2473 // clear TSF counter
2474 VNSvOutPortB(pDevice
->PortOffset
+ MAC_REG_TFTCTL
, TFTCTL_TSFCNTRST
);
2475 // enable TSF counter
2476 VNSvOutPortB(pDevice
->PortOffset
+ MAC_REG_TFTCTL
, TFTCTL_TSFCNTREN
);
2479 CARDvSetFirstNextTBTT(pDevice
->PortOffset
, pMgmt
->wIBSSBeaconPeriod
);
2481 pMgmt
->uIBSSChannel
= pDevice
->uChannel
;
2483 if (pMgmt
->uIBSSChannel
== 0)
2484 pMgmt
->uIBSSChannel
= DEFAULT_IBSS_CHANNEL
;
2489 RATEvParseMaxRate((void *)pDevice
, (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
2490 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
, true,
2491 &wMaxBasicRate
, &wMaxSuppRate
, &wSuppRate
,
2492 &byTopCCKBasicRate
, &byTopOFDMBasicRate
);
2495 if (pMgmt
->eConfigMode
== WMAC_CONFIG_AP
) {
2496 pMgmt
->eCurrMode
= WMAC_MODE_ESS_AP
;
2499 if (pMgmt
->eConfigMode
== WMAC_CONFIG_IBSS_STA
) {
2500 memcpy(pMgmt
->abyIBSSDFSOwner
, pDevice
->abyCurrentNetAddr
, 6);
2501 pMgmt
->byIBSSDFSRecovery
= 10;
2502 pMgmt
->eCurrMode
= WMAC_MODE_IBSS_STA
;
2505 // Adopt pre-configured IBSS vars to current vars
2506 pMgmt
->eCurrState
= WMAC_STATE_STARTED
;
2507 pMgmt
->wCurrBeaconPeriod
= pMgmt
->wIBSSBeaconPeriod
;
2508 pMgmt
->uCurrChannel
= pMgmt
->uIBSSChannel
;
2509 pMgmt
->wCurrATIMWindow
= pMgmt
->wIBSSATIMWindow
;
2510 MACvWriteATIMW(pDevice
->PortOffset
, pMgmt
->wCurrATIMWindow
);
2511 pDevice
->uCurrRSSI
= 0;
2512 pDevice
->byCurrSQ
= 0;
2513 //memcpy(pMgmt->abyDesireSSID,pMgmt->abyAdHocSSID,
2514 // ((PWLAN_IE_SSID)pMgmt->abyAdHocSSID)->len + WLAN_IEHDR_LEN);
2515 memset(pMgmt
->abyCurrSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
2516 memcpy(pMgmt
->abyCurrSSID
,
2517 pMgmt
->abyDesireSSID
,
2518 ((PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
)->len
+ WLAN_IEHDR_LEN
2521 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) {
2522 // AP mode BSSID = MAC addr
2523 memcpy(pMgmt
->abyCurrBSSID
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
2524 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"AP beacon created BSSID:%02x-%02x-%02x-%02x-%02x-%02x \n",
2525 pMgmt
->abyCurrBSSID
[0],
2526 pMgmt
->abyCurrBSSID
[1],
2527 pMgmt
->abyCurrBSSID
[2],
2528 pMgmt
->abyCurrBSSID
[3],
2529 pMgmt
->abyCurrBSSID
[4],
2530 pMgmt
->abyCurrBSSID
[5]
2534 if (pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) {
2536 // BSSID selected must be randomized as spec 11.1.3
2537 pMgmt
->abyCurrBSSID
[5] = (unsigned char) (LODWORD(qwCurrTSF
)& 0x000000ff);
2538 pMgmt
->abyCurrBSSID
[4] = (unsigned char)((LODWORD(qwCurrTSF
)& 0x0000ff00) >> 8);
2539 pMgmt
->abyCurrBSSID
[3] = (unsigned char)((LODWORD(qwCurrTSF
)& 0x00ff0000) >> 16);
2540 pMgmt
->abyCurrBSSID
[2] = (unsigned char)((LODWORD(qwCurrTSF
)& 0x00000ff0) >> 4);
2541 pMgmt
->abyCurrBSSID
[1] = (unsigned char)((LODWORD(qwCurrTSF
)& 0x000ff000) >> 12);
2542 pMgmt
->abyCurrBSSID
[0] = (unsigned char)((LODWORD(qwCurrTSF
)& 0x0ff00000) >> 20);
2543 pMgmt
->abyCurrBSSID
[5] ^= pMgmt
->abyMACAddr
[0];
2544 pMgmt
->abyCurrBSSID
[4] ^= pMgmt
->abyMACAddr
[1];
2545 pMgmt
->abyCurrBSSID
[3] ^= pMgmt
->abyMACAddr
[2];
2546 pMgmt
->abyCurrBSSID
[2] ^= pMgmt
->abyMACAddr
[3];
2547 pMgmt
->abyCurrBSSID
[1] ^= pMgmt
->abyMACAddr
[4];
2548 pMgmt
->abyCurrBSSID
[0] ^= pMgmt
->abyMACAddr
[5];
2549 pMgmt
->abyCurrBSSID
[0] &= ~IEEE_ADDR_GROUP
;
2550 pMgmt
->abyCurrBSSID
[0] |= IEEE_ADDR_UNIVERSAL
;
2553 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"Adhoc beacon created bssid:%02x-%02x-%02x-%02x-%02x-%02x \n",
2554 pMgmt
->abyCurrBSSID
[0],
2555 pMgmt
->abyCurrBSSID
[1],
2556 pMgmt
->abyCurrBSSID
[2],
2557 pMgmt
->abyCurrBSSID
[3],
2558 pMgmt
->abyCurrBSSID
[4],
2559 pMgmt
->abyCurrBSSID
[5]
2563 // Set Capability Info
2564 pMgmt
->wCurrCapInfo
= 0;
2566 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) {
2567 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_ESS(1);
2568 pMgmt
->byDTIMPeriod
= DEFAULT_DTIM_PERIOD
;
2569 pMgmt
->byDTIMCount
= pMgmt
->byDTIMPeriod
- 1;
2572 if (pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) {
2573 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_IBSS(1);
2576 if (pDevice
->bEncryptionEnable
) {
2577 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_PRIVACY(1);
2578 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPANONE
) {
2579 if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
) {
2580 pMgmt
->byCSSPK
= KEY_CTL_CCMP
;
2581 pMgmt
->byCSSGK
= KEY_CTL_CCMP
;
2582 } else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
) {
2583 pMgmt
->byCSSPK
= KEY_CTL_TKIP
;
2584 pMgmt
->byCSSGK
= KEY_CTL_TKIP
;
2586 pMgmt
->byCSSPK
= KEY_CTL_NONE
;
2587 pMgmt
->byCSSGK
= KEY_CTL_WEP
;
2590 pMgmt
->byCSSPK
= KEY_CTL_WEP
;
2591 pMgmt
->byCSSGK
= KEY_CTL_WEP
;
2595 pMgmt
->byERPContext
= 0;
2597 // memcpy(pDevice->abyBSSID, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
2599 if (pMgmt
->eConfigMode
== WMAC_CONFIG_AP
) {
2600 CARDbSetBSSID(pMgmt
->pAdapter
, pMgmt
->abyCurrBSSID
, OP_MODE_AP
);
2602 CARDbSetBSSID(pMgmt
->pAdapter
, pMgmt
->abyCurrBSSID
, OP_MODE_ADHOC
);
2605 CARDbSetPhyParameter( pMgmt
->pAdapter
,
2606 pMgmt
->eCurrentPHYMode
,
2607 pMgmt
->wCurrCapInfo
,
2608 pMgmt
->byERPContext
,
2609 pMgmt
->abyCurrSuppRates
,
2610 pMgmt
->abyCurrExtSuppRates
2613 CARDbSetBeaconPeriod(pMgmt
->pAdapter
, pMgmt
->wIBSSBeaconPeriod
);
2614 // set channel and clear NAV
2615 set_channel(pMgmt
->pAdapter
, pMgmt
->uIBSSChannel
);
2616 pMgmt
->uCurrChannel
= pMgmt
->uIBSSChannel
;
2618 if (CARDbIsShortPreamble(pMgmt
->pAdapter
)) {
2619 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
2621 pMgmt
->wCurrCapInfo
&= (~WLAN_SET_CAP_INFO_SHORTPREAMBLE(1));
2624 if ((pMgmt
->b11hEnable
== true) &&
2625 (pMgmt
->eCurrentPHYMode
== PHY_TYPE_11A
)) {
2626 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SPECTRUMMNG(1);
2628 pMgmt
->wCurrCapInfo
&= (~WLAN_SET_CAP_INFO_SPECTRUMMNG(1));
2631 pMgmt
->eCurrState
= WMAC_STATE_STARTED
;
2632 // Prepare beacon to send
2633 if (bMgrPrepareBeaconToSend((void *)pDevice
, pMgmt
)) {
2634 *pStatus
= CMD_STATUS_SUCCESS
;
2644 * Routine Description:
2645 * Instructs wmac to join a bss using the supplied attributes.
2646 * The arguments may the BSSID or SSID and the rest of the
2647 * attributes are obtained from the scan result of known bss list.
2657 void *hDeviceContext
,
2662 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
2663 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
2664 PKnownBSS pCurr
= NULL
;
2665 unsigned int ii
, uu
;
2666 PWLAN_IE_SUPP_RATES pItemRates
= NULL
;
2667 PWLAN_IE_SUPP_RATES pItemExtRates
= NULL
;
2668 PWLAN_IE_SSID pItemSSID
;
2669 unsigned int uRateLen
= WLAN_RATES_MAXLEN
;
2670 unsigned short wMaxBasicRate
= RATE_1M
;
2671 unsigned short wMaxSuppRate
= RATE_1M
;
2672 unsigned short wSuppRate
;
2673 unsigned char byTopCCKBasicRate
= RATE_1M
;
2674 unsigned char byTopOFDMBasicRate
= RATE_1M
;
2677 for (ii
= 0; ii
< MAX_BSS_NUM
; ii
++) {
2678 if (pMgmt
->sBSSList
[ii
].bActive
== true)
2682 if (ii
== MAX_BSS_NUM
) {
2683 *pStatus
= CMD_STATUS_RESOURCES
;
2684 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"BSS finding:BSS list is empty.\n");
2688 // memset(pMgmt->abyDesireBSSID, 0, WLAN_BSSID_LEN);
2689 // Search known BSS list for prefer BSSID or SSID
2691 pCurr
= BSSpSearchBSSList(pDevice
,
2692 pMgmt
->abyDesireBSSID
,
2693 pMgmt
->abyDesireSSID
,
2694 pMgmt
->eConfigPHYMode
2698 *pStatus
= CMD_STATUS_RESOURCES
;
2699 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
;
2700 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Scanning [%s] not found, disconnected !\n", pItemSSID
->abySSID
);
2704 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"AP(BSS) finding:Found a AP(BSS)..\n");
2705 if (WLAN_GET_CAP_INFO_ESS(cpu_to_le16(pCurr
->wCapInfo
))){
2707 if ((pMgmt
->eAuthenMode
== WMAC_AUTH_WPA
)||(pMgmt
->eAuthenMode
== WMAC_AUTH_WPAPSK
)) {
2709 // patch for CISCO migration mode
2711 if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) {
2712 if (WPA_SearchRSN(0, WPA_TKIP, pCurr) == false) {
2713 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"No match RSN info. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
2714 // encryption mode error
2715 pMgmt->eCurrState = WMAC_STATE_IDLE;
2718 } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) {
2719 if (WPA_SearchRSN(0, WPA_AESCCMP, pCurr) == false) {
2720 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"No match RSN info. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
2721 // encryption mode error
2722 pMgmt->eCurrState = WMAC_STATE_IDLE;
2729 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
2730 //if(pDevice->bWPASuppWextEnabled == true)
2731 Encyption_Rebuild(pDevice
, pCurr
);
2733 // Infrastructure BSS
2734 s_vMgrSynchBSS(pDevice
,
2740 if (*pStatus
== CMD_STATUS_SUCCESS
){
2742 // Adopt this BSS state vars in Mgmt Object
2743 pMgmt
->uCurrChannel
= pCurr
->uChannel
;
2745 memset(pMgmt
->abyCurrSuppRates
, 0 , WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1);
2746 memset(pMgmt
->abyCurrExtSuppRates
, 0 , WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1);
2748 if (pCurr
->eNetworkTypeInUse
== PHY_TYPE_11B
) {
2749 uRateLen
= WLAN_RATES_MAXLEN_11B
;
2752 pItemRates
= (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
;
2753 pItemExtRates
= (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
;
2755 // Parse Support Rate IE
2756 pItemRates
->byElementID
= WLAN_EID_SUPP_RATES
;
2757 pItemRates
->len
= RATEuSetIE((PWLAN_IE_SUPP_RATES
)pCurr
->abySuppRates
,
2761 // Parse Extension Support Rate IE
2762 pItemExtRates
->byElementID
= WLAN_EID_EXTSUPP_RATES
;
2763 pItemExtRates
->len
= RATEuSetIE((PWLAN_IE_SUPP_RATES
)pCurr
->abyExtSuppRates
,
2767 if ((pItemExtRates
->len
> 0) && (pItemRates
->len
< 8)) {
2768 for (ii
= 0; ii
< (unsigned int)(8 - pItemRates
->len
); ) {
2769 pItemRates
->abyRates
[pItemRates
->len
+ ii
] = pItemExtRates
->abyRates
[ii
];
2771 if (pItemExtRates
->len
<= ii
)
2774 pItemRates
->len
+= (unsigned char)ii
;
2775 if (pItemExtRates
->len
- ii
> 0) {
2776 pItemExtRates
->len
-= (unsigned char)ii
;
2777 for (uu
= 0; uu
< pItemExtRates
->len
; uu
++) {
2778 pItemExtRates
->abyRates
[uu
] = pItemExtRates
->abyRates
[uu
+ ii
];
2781 pItemExtRates
->len
= 0;
2785 RATEvParseMaxRate((void *)pDevice
, pItemRates
, pItemExtRates
, true,
2786 &wMaxBasicRate
, &wMaxSuppRate
, &wSuppRate
,
2787 &byTopCCKBasicRate
, &byTopOFDMBasicRate
);
2789 // TODO: deal with if wCapInfo the privacy is on, but station WEP is off
2790 // TODO: deal with if wCapInfo the PS-Pollable is on.
2791 pMgmt
->wCurrBeaconPeriod
= pCurr
->wBeaconInterval
;
2792 memset(pMgmt
->abyCurrSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
2793 memcpy(pMgmt
->abyCurrBSSID
, pCurr
->abyBSSID
, WLAN_BSSID_LEN
);
2794 memcpy(pMgmt
->abyCurrSSID
, pCurr
->abySSID
, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
2796 pMgmt
->eCurrMode
= WMAC_MODE_ESS_STA
;
2798 pMgmt
->eCurrState
= WMAC_STATE_JOINTED
;
2799 // Adopt BSS state in Adapter Device Object
2800 //pDevice->byOpMode = OP_MODE_INFRASTRUCTURE;
2801 // memcpy(pDevice->abyBSSID, pCurr->abyBSSID, WLAN_BSSID_LEN);
2803 // Add current BSS to Candidate list
2804 // This should only works for WPA2 BSS, and WPA2 BSS check must be done before.
2805 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2
) {
2806 bool bResult
= bAdd_PMKID_Candidate((void *)pDevice
, pMgmt
->abyCurrBSSID
, &pCurr
->sRSNCapObj
);
2807 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"bAdd_PMKID_Candidate: 1(%d)\n", bResult
);
2808 if (bResult
== false) {
2809 vFlush_PMKID_Candidate((void *)pDevice
);
2810 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"vFlush_PMKID_Candidate: 4\n");
2811 bAdd_PMKID_Candidate((void *)pDevice
, pMgmt
->abyCurrBSSID
, &pCurr
->sRSNCapObj
);
2815 // Preamble type auto-switch: if AP can receive short-preamble cap,
2816 // we can turn on too.
2818 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Join ESS\n");
2822 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"End of Join AP -- A/B/G Action\n");
2825 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
2832 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPANONE
) {
2834 if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
) {
2835 if (WPA_SearchRSN(0, WPA_TKIP
, pCurr
) == false) {
2836 // encryption mode error
2837 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
2840 } else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
) {
2841 if (WPA_SearchRSN(0, WPA_AESCCMP
, pCurr
) == false) {
2842 // encryption mode error
2843 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
2847 // encryption mode error
2848 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
2853 s_vMgrSynchBSS(pDevice
,
2859 if (*pStatus
== CMD_STATUS_SUCCESS
){
2860 // Adopt this BSS state vars in Mgmt Object
2861 // TODO: check if CapInfo privacy on, but we don't..
2862 pMgmt
->uCurrChannel
= pCurr
->uChannel
;
2865 // Parse Support Rate IE
2866 pMgmt
->abyCurrSuppRates
[0] = WLAN_EID_SUPP_RATES
;
2867 pMgmt
->abyCurrSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)pCurr
->abySuppRates
,
2868 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
2869 WLAN_RATES_MAXLEN_11B
);
2871 RATEvParseMaxRate((void *)pDevice
, (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
2872 NULL
, true, &wMaxBasicRate
, &wMaxSuppRate
, &wSuppRate
,
2873 &byTopCCKBasicRate
, &byTopOFDMBasicRate
);
2875 pMgmt
->wCurrCapInfo
= pCurr
->wCapInfo
;
2876 pMgmt
->wCurrBeaconPeriod
= pCurr
->wBeaconInterval
;
2877 memset(pMgmt
->abyCurrSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
);
2878 memcpy(pMgmt
->abyCurrBSSID
, pCurr
->abyBSSID
, WLAN_BSSID_LEN
);
2879 memcpy(pMgmt
->abyCurrSSID
, pCurr
->abySSID
, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
);
2880 // pMgmt->wCurrATIMWindow = pCurr->wATIMWindow;
2881 MACvWriteATIMW(pDevice
->PortOffset
, pMgmt
->wCurrATIMWindow
);
2882 pMgmt
->eCurrMode
= WMAC_MODE_IBSS_STA
;
2884 pMgmt
->eCurrState
= WMAC_STATE_STARTED
;
2885 // Adopt BSS state in Adapter Device Object
2886 //pDevice->byOpMode = OP_MODE_ADHOC;
2887 // pDevice->bLinkPass = true;
2888 // memcpy(pDevice->abyBSSID, pCurr->abyBSSID, WLAN_BSSID_LEN);
2890 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Join IBSS ok:%02x-%02x-%02x-%02x-%02x-%02x \n",
2891 pMgmt
->abyCurrBSSID
[0],
2892 pMgmt
->abyCurrBSSID
[1],
2893 pMgmt
->abyCurrBSSID
[2],
2894 pMgmt
->abyCurrBSSID
[3],
2895 pMgmt
->abyCurrBSSID
[4],
2896 pMgmt
->abyCurrBSSID
[5]
2898 // Preamble type auto-switch: if AP can receive short-preamble cap,
2899 // and if registry setting is short preamble we can turn on too.
2902 bMgrPrepareBeaconToSend((void *)pDevice
, pMgmt
);
2905 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
2915 * Routine Description:
2916 * Set HW to synchronize a specific BSS from known BSS list.
2927 unsigned int uBSSMode
,
2932 CARD_PHY_TYPE ePhyType
= PHY_TYPE_11B
;
2933 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
2935 //1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M
2936 unsigned char abyCurrSuppRatesG
[] = {WLAN_EID_SUPP_RATES
, 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C};
2937 unsigned char abyCurrExtSuppRatesG
[] = {WLAN_EID_EXTSUPP_RATES
, 4, 0x0C, 0x12, 0x18, 0x60};
2939 unsigned char abyCurrSuppRatesA
[] = {WLAN_EID_SUPP_RATES
, 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
2940 unsigned char abyCurrSuppRatesB
[] = {WLAN_EID_SUPP_RATES
, 4, 0x02, 0x04, 0x0B, 0x16};
2943 *pStatus
= CMD_STATUS_FAILURE
;
2945 if (s_bCipherMatch(pCurr
,
2946 pDevice
->eEncryptionStatus
,
2948 &(pMgmt
->byCSSGK
)) == false) {
2949 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"s_bCipherMatch Fail .......\n");
2953 pMgmt
->pCurrBSS
= pCurr
;
2955 // if previous mode is IBSS.
2956 if(pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) {
2957 MACvRegBitsOff(pDevice
->PortOffset
, MAC_REG_BCNDMACTL
, BEACON_READY
);
2958 MACvRegBitsOff(pDevice
->PortOffset
, MAC_REG_TCR
, TCR_AUTOBCNTX
);
2961 // Init the BSS informations
2962 pDevice
->bCCK
= true;
2963 pDevice
->bProtectMode
= false;
2964 MACvDisableProtectMD(pDevice
->PortOffset
);
2965 pDevice
->bBarkerPreambleMd
= false;
2966 MACvDisableBarkerPreambleMd(pDevice
->PortOffset
);
2967 pDevice
->bNonERPPresent
= false;
2968 pDevice
->byPreambleType
= 0;
2969 pDevice
->wBasicRate
= 0;
2971 CARDbAddBasicRate((void *)pDevice
, RATE_1M
);
2972 // calculate TSF offset
2973 // TSF Offset = Received Timestamp TSF - Marked Local's TSF
2974 CARDbUpdateTSF(pDevice
, pCurr
->byRxRate
, pCurr
->qwBSSTimestamp
, pCurr
->qwLocalTSF
);
2976 CARDbSetBeaconPeriod(pDevice
, pCurr
->wBeaconInterval
);
2979 // Next TBTT = ((local_current_TSF / beacon_interval) + 1 ) * beacon_interval
2980 CARDvSetFirstNextTBTT(pDevice
->PortOffset
, pCurr
->wBeaconInterval
);
2983 MACvWriteBSSIDAddress(pDevice
->PortOffset
, pCurr
->abyBSSID
);
2985 MACvReadBSSIDAddress(pDevice
->PortOffset
, pMgmt
->abyCurrBSSID
);
2987 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Sync:set CurrBSSID address = %02x-%02x-%02x=%02x-%02x-%02x\n",
2988 pMgmt
->abyCurrBSSID
[0],
2989 pMgmt
->abyCurrBSSID
[1],
2990 pMgmt
->abyCurrBSSID
[2],
2991 pMgmt
->abyCurrBSSID
[3],
2992 pMgmt
->abyCurrBSSID
[4],
2993 pMgmt
->abyCurrBSSID
[5]);
2995 if (pCurr
->eNetworkTypeInUse
== PHY_TYPE_11A
) {
2996 if ((pMgmt
->eConfigPHYMode
== PHY_TYPE_11A
) ||
2997 (pMgmt
->eConfigPHYMode
== PHY_TYPE_AUTO
)) {
2998 ePhyType
= PHY_TYPE_11A
;
3002 } else if (pCurr
->eNetworkTypeInUse
== PHY_TYPE_11B
) {
3003 if ((pMgmt
->eConfigPHYMode
== PHY_TYPE_11B
) ||
3004 (pMgmt
->eConfigPHYMode
== PHY_TYPE_11G
) ||
3005 (pMgmt
->eConfigPHYMode
== PHY_TYPE_AUTO
)) {
3006 ePhyType
= PHY_TYPE_11B
;
3011 if ((pMgmt
->eConfigPHYMode
== PHY_TYPE_11G
) ||
3012 (pMgmt
->eConfigPHYMode
== PHY_TYPE_AUTO
)) {
3013 ePhyType
= PHY_TYPE_11G
;
3014 } else if (pMgmt
->eConfigPHYMode
== PHY_TYPE_11B
) {
3015 ePhyType
= PHY_TYPE_11B
;
3021 if (ePhyType
== PHY_TYPE_11A
) {
3022 memcpy(pMgmt
->abyCurrSuppRates
, &abyCurrSuppRatesA
[0], sizeof(abyCurrSuppRatesA
));
3023 pMgmt
->abyCurrExtSuppRates
[1] = 0;
3024 } else if (ePhyType
== PHY_TYPE_11B
) {
3025 memcpy(pMgmt
->abyCurrSuppRates
, &abyCurrSuppRatesB
[0], sizeof(abyCurrSuppRatesB
));
3026 pMgmt
->abyCurrExtSuppRates
[1] = 0;
3028 memcpy(pMgmt
->abyCurrSuppRates
, &abyCurrSuppRatesG
[0], sizeof(abyCurrSuppRatesG
));
3029 memcpy(pMgmt
->abyCurrExtSuppRates
, &abyCurrExtSuppRatesG
[0], sizeof(abyCurrExtSuppRatesG
));
3033 if (WLAN_GET_CAP_INFO_ESS(pCurr
->wCapInfo
)) {
3034 CARDbSetBSSID(pMgmt
->pAdapter
, pCurr
->abyBSSID
, OP_MODE_INFRASTRUCTURE
);
3035 // Add current BSS to Candidate list
3036 // This should only works for WPA2 BSS, and WPA2 BSS check must be done before.
3037 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2
) {
3038 CARDbAdd_PMKID_Candidate(pMgmt
->pAdapter
, pMgmt
->abyCurrBSSID
, pCurr
->sRSNCapObj
.bRSNCapExist
, pCurr
->sRSNCapObj
.wRSNCap
);
3041 CARDbSetBSSID(pMgmt
->pAdapter
, pCurr
->abyBSSID
, OP_MODE_ADHOC
);
3044 if (CARDbSetPhyParameter( pMgmt
->pAdapter
,
3048 pMgmt
->abyCurrSuppRates
,
3049 pMgmt
->abyCurrExtSuppRates
3051 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"<----s_bSynchBSS Set Phy Mode Fail [%d]\n", ePhyType
);
3054 // set channel and clear NAV
3055 if (set_channel(pMgmt
->pAdapter
, pCurr
->uChannel
) == false) {
3056 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"<----s_bSynchBSS Set Channel [%d]\n", pCurr
->uChannel
);
3061 for (ii=0;ii<BB_VGA_LEVEL;ii++) {
3062 if (pCurr->ldBmMAX< pDevice->ldBmThreshold[ii]) {
3063 pDevice->byBBVGANew = pDevice->abyBBVGA[ii];
3068 if (pDevice->byBBVGANew != pDevice->byBBVGACurrent) {
3069 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"RSSI[%d] NewGain[%d] OldGain[%d] \n",
3070 (int)pCurr->ldBmMAX, pDevice->byBBVGANew, pDevice->byBBVGACurrent);
3071 printk("RSSI[%d] NewGain[%d] OldGain[%d] \n",
3072 (int)pCurr->ldBmMAX, pDevice->byBBVGANew, pDevice->byBBVGACurrent);
3073 BBvSetVGAGainOffset(pDevice, pDevice->byBBVGANew);
3075 printk("ldBmMAX[%d] NewGain[%d] OldGain[%d] \n",
3076 (int)pCurr->ldBmMAX, pDevice->byBBVGANew, pDevice->byBBVGACurrent);
3078 pMgmt
->uCurrChannel
= pCurr
->uChannel
;
3079 pMgmt
->eCurrentPHYMode
= ePhyType
;
3080 pMgmt
->byERPContext
= pCurr
->sERP
.byERP
;
3081 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Sync:Set to channel = [%d]\n", (int)pCurr
->uChannel
);
3084 *pStatus
= CMD_STATUS_SUCCESS
;
3090 //mike add: fix NetworkManager 0.7.0 hidden ssid mode in WPA encryption
3091 // ,need reset eAuthenMode and eEncryptionStatus
3092 static void Encyption_Rebuild(
3097 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
3098 // unsigned int ii , uSameBssidNum=0;
3100 // for (ii = 0; ii < MAX_BSS_NUM; ii++) {
3101 // if (pMgmt->sBSSList[ii].bActive &&
3102 // !compare_ether_addr(pMgmt->sBSSList[ii].abyBSSID, pCurr->abyBSSID)) {
3106 // if( uSameBssidNum>=2) { //we only check AP in hidden sssid mode
3107 if ((pMgmt
->eAuthenMode
== WMAC_AUTH_WPAPSK
) || //networkmanager 0.7.0 does not give the pairwise-key selsection,
3108 (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2PSK
)) { // so we need re-selsect it according to real pairwise-key info.
3109 if(pCurr
->bWPAValid
== true) { //WPA-PSK
3110 pMgmt
->eAuthenMode
= WMAC_AUTH_WPAPSK
;
3111 if(pCurr
->abyPKType
[0] == WPA_TKIP
) {
3112 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
; //TKIP
3113 PRINT_K("Encyption_Rebuild--->ssid reset config to [WPAPSK-TKIP]\n");
3115 else if(pCurr
->abyPKType
[0] == WPA_AESCCMP
) {
3116 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
; //AES
3117 PRINT_K("Encyption_Rebuild--->ssid reset config to [WPAPSK-AES]\n");
3120 else if(pCurr
->bWPA2Valid
== true) { //WPA2-PSK
3121 pMgmt
->eAuthenMode
= WMAC_AUTH_WPA2PSK
;
3122 if(pCurr
->abyCSSPK
[0] == WLAN_11i_CSS_TKIP
) {
3123 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
; //TKIP
3124 PRINT_K("Encyption_Rebuild--->ssid reset config to [WPA2PSK-TKIP]\n");
3126 else if(pCurr
->abyCSSPK
[0] == WLAN_11i_CSS_CCMP
) {
3127 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
; //AES
3128 PRINT_K("Encyption_Rebuild--->ssid reset config to [WPA2PSK-AES]\n");
3139 * Routine Description:
3155 unsigned char byMask
[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
3156 unsigned char byMap
;
3157 unsigned int ii
, jj
;
3158 bool bStartFound
= false;
3159 bool bMulticast
= false;
3160 unsigned short wStartIndex
= 0;
3161 unsigned short wEndIndex
= 0;
3164 // Find size of partial virtual bitmap
3165 for (ii
= 0; ii
< (MAX_NODE_NUM
+ 1); ii
++) {
3166 byMap
= pMgmt
->abyPSTxMap
[ii
];
3168 // Mask out the broadcast bit which is indicated separately.
3169 bMulticast
= (byMap
& byMask
[0]) != 0;
3171 pMgmt
->sNodeDBTable
[0].bRxPSPoll
= true;
3185 // Round start index down to nearest even number
3186 wStartIndex
&= ~BIT0
;
3188 // Round end index up to nearest even number
3189 wEndIndex
= ((wEndIndex
+ 1) & ~BIT0
);
3191 // Size of element payload
3193 pTIM
->len
= 3 + (wEndIndex
- wStartIndex
) + 1;
3195 // Fill in the Fixed parts of the TIM
3196 pTIM
->byDTIMCount
= pMgmt
->byDTIMCount
;
3197 pTIM
->byDTIMPeriod
= pMgmt
->byDTIMPeriod
;
3198 pTIM
->byBitMapCtl
= (bMulticast
? TIM_MULTICAST_MASK
: 0) |
3199 (((wStartIndex
>> 1) << 1) & TIM_BITMAPOFFSET_MASK
);
3201 // Append variable part of TIM
3203 for (ii
= wStartIndex
, jj
=0 ; ii
<= wEndIndex
; ii
++, jj
++) {
3204 pTIM
->byVirtBitMap
[jj
] = pMgmt
->abyPSTxMap
[ii
];
3207 // Aid = 0 don't used.
3208 pTIM
->byVirtBitMap
[0] &= ~BIT0
;
3214 * Routine Description:
3215 * Constructs an Beacon frame( Ad-hoc mode)
3219 * PTR to frame; or NULL on allocation failue
3228 unsigned short wCurrCapInfo
,
3229 unsigned short wCurrBeaconPeriod
,
3230 unsigned int uCurrChannel
,
3231 unsigned short wCurrATIMWinodw
,
3232 PWLAN_IE_SSID pCurrSSID
,
3233 unsigned char *pCurrBSSID
,
3234 PWLAN_IE_SUPP_RATES pCurrSuppRates
,
3235 PWLAN_IE_SUPP_RATES pCurrExtSuppRates
3238 PSTxMgmtPacket pTxPacket
= NULL
;
3239 WLAN_FR_BEACON sFrame
;
3240 unsigned char abyBroadcastAddr
[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
3241 unsigned char *pbyBuffer
;
3242 unsigned int uLength
= 0;
3243 PWLAN_IE_IBSS_DFS pIBSSDFS
= NULL
;
3246 // prepare beacon frame
3247 pTxPacket
= (PSTxMgmtPacket
)pMgmt
->pbyMgmtPacketPool
;
3248 memset(pTxPacket
, 0, sizeof(STxMgmtPacket
) + WLAN_BEACON_FR_MAXLEN
);
3249 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((unsigned char *)pTxPacket
+ sizeof(STxMgmtPacket
));
3250 // Setup the sFrame structure.
3251 sFrame
.pBuf
= (unsigned char *)pTxPacket
->p80211Header
;
3252 sFrame
.len
= WLAN_BEACON_FR_MAXLEN
;
3253 vMgrEncodeBeacon(&sFrame
);
3255 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
3257 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
3258 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_BEACON
)
3261 if (pDevice
->bEnablePSMode
) {
3262 sFrame
.pHdr
->sA3
.wFrameCtl
|= cpu_to_le16((unsigned short)WLAN_SET_FC_PWRMGT(1));
3265 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, abyBroadcastAddr
, WLAN_ADDR_LEN
);
3266 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
3267 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pCurrBSSID
, WLAN_BSSID_LEN
);
3268 *sFrame
.pwBeaconInterval
= cpu_to_le16(wCurrBeaconPeriod
);
3269 *sFrame
.pwCapInfo
= cpu_to_le16(wCurrCapInfo
);
3271 sFrame
.pSSID
= (PWLAN_IE_SSID
)(sFrame
.pBuf
+ sFrame
.len
);
3272 sFrame
.len
+= ((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->len
+ WLAN_IEHDR_LEN
;
3273 memcpy(sFrame
.pSSID
,
3275 ((PWLAN_IE_SSID
)pCurrSSID
)->len
+ WLAN_IEHDR_LEN
3277 // Copy the rate set
3278 sFrame
.pSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3279 sFrame
.len
+= ((PWLAN_IE_SUPP_RATES
)pCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
;
3280 memcpy(sFrame
.pSuppRates
,
3282 ((PWLAN_IE_SUPP_RATES
)pCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
3285 if (pDevice
->eCurrentPHYType
!= PHY_TYPE_11A
) {
3286 sFrame
.pDSParms
= (PWLAN_IE_DS_PARMS
)(sFrame
.pBuf
+ sFrame
.len
);
3287 sFrame
.len
+= (1) + WLAN_IEHDR_LEN
;
3288 sFrame
.pDSParms
->byElementID
= WLAN_EID_DS_PARMS
;
3289 sFrame
.pDSParms
->len
= 1;
3290 sFrame
.pDSParms
->byCurrChannel
= (unsigned char)uCurrChannel
;
3293 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) {
3294 sFrame
.pTIM
= (PWLAN_IE_TIM
)(sFrame
.pBuf
+ sFrame
.len
);
3295 sFrame
.pTIM
->byElementID
= WLAN_EID_TIM
;
3296 s_vMgrFormatTIM(pMgmt
, sFrame
.pTIM
);
3297 sFrame
.len
+= (WLAN_IEHDR_LEN
+ sFrame
.pTIM
->len
);
3300 if (pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) {
3303 sFrame
.pIBSSParms
= (PWLAN_IE_IBSS_PARMS
)(sFrame
.pBuf
+ sFrame
.len
);
3304 sFrame
.len
+= (2) + WLAN_IEHDR_LEN
;
3305 sFrame
.pIBSSParms
->byElementID
= WLAN_EID_IBSS_PARMS
;
3306 sFrame
.pIBSSParms
->len
= 2;
3307 sFrame
.pIBSSParms
->wATIMWindow
= wCurrATIMWinodw
;
3308 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPANONE
) {
3310 sFrame
.pRSNWPA
= (PWLAN_IE_RSN_EXT
)(sFrame
.pBuf
+ sFrame
.len
);
3311 sFrame
.pRSNWPA
->byElementID
= WLAN_EID_RSN_WPA
;
3312 sFrame
.pRSNWPA
->len
= 12;
3313 sFrame
.pRSNWPA
->abyOUI
[0] = 0x00;
3314 sFrame
.pRSNWPA
->abyOUI
[1] = 0x50;
3315 sFrame
.pRSNWPA
->abyOUI
[2] = 0xf2;
3316 sFrame
.pRSNWPA
->abyOUI
[3] = 0x01;
3317 sFrame
.pRSNWPA
->wVersion
= 1;
3318 sFrame
.pRSNWPA
->abyMulticast
[0] = 0x00;
3319 sFrame
.pRSNWPA
->abyMulticast
[1] = 0x50;
3320 sFrame
.pRSNWPA
->abyMulticast
[2] = 0xf2;
3321 if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
)
3322 sFrame
.pRSNWPA
->abyMulticast
[3] = 0x04;//AES
3323 else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
)
3324 sFrame
.pRSNWPA
->abyMulticast
[3] = 0x02;//TKIP
3325 else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption1Enabled
)
3326 sFrame
.pRSNWPA
->abyMulticast
[3] = 0x01;//WEP40
3328 sFrame
.pRSNWPA
->abyMulticast
[3] = 0x00;//NONE
3330 // Pairwise Key Cipher Suite
3331 sFrame
.pRSNWPA
->wPKCount
= 0;
3332 // Auth Key Management Suite
3333 *((unsigned short *)(sFrame
.pBuf
+ sFrame
.len
+ sFrame
.pRSNWPA
->len
))=0;
3334 sFrame
.pRSNWPA
->len
+=2;
3337 *((unsigned short *)(sFrame
.pBuf
+ sFrame
.len
+ sFrame
.pRSNWPA
->len
))=0;
3338 sFrame
.pRSNWPA
->len
+=2;
3339 sFrame
.len
+= sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
;
3343 if ((pMgmt
->b11hEnable
== true) &&
3344 (pMgmt
->eCurrentPHYMode
== PHY_TYPE_11A
)) {
3346 pbyBuffer
= (unsigned char *)(sFrame
.pBuf
+ sFrame
.len
);
3347 set_country_IE(pMgmt
->pAdapter
, pbyBuffer
);
3348 set_country_info(pMgmt
->pAdapter
, PHY_TYPE_11A
, pbyBuffer
);
3349 uLength
+= ((PWLAN_IE_COUNTRY
) pbyBuffer
)->len
+ WLAN_IEHDR_LEN
;
3350 pbyBuffer
+= (((PWLAN_IE_COUNTRY
) pbyBuffer
)->len
+ WLAN_IEHDR_LEN
);
3351 // Power Constrain IE
3352 ((PWLAN_IE_PW_CONST
) pbyBuffer
)->byElementID
= WLAN_EID_PWR_CONSTRAINT
;
3353 ((PWLAN_IE_PW_CONST
) pbyBuffer
)->len
= 1;
3354 ((PWLAN_IE_PW_CONST
) pbyBuffer
)->byPower
= 0;
3355 pbyBuffer
+= (1) + WLAN_IEHDR_LEN
;
3356 uLength
+= (1) + WLAN_IEHDR_LEN
;
3357 if (pMgmt
->bSwitchChannel
== true) {
3358 // Channel Switch IE
3359 ((PWLAN_IE_CH_SW
) pbyBuffer
)->byElementID
= WLAN_EID_CH_SWITCH
;
3360 ((PWLAN_IE_CH_SW
) pbyBuffer
)->len
= 3;
3361 ((PWLAN_IE_CH_SW
) pbyBuffer
)->byMode
= 1;
3362 ((PWLAN_IE_CH_SW
) pbyBuffer
)->byChannel
= get_channel_number(pMgmt
->pAdapter
, pMgmt
->byNewChannel
);
3363 ((PWLAN_IE_CH_SW
) pbyBuffer
)->byCount
= 0;
3364 pbyBuffer
+= (3) + WLAN_IEHDR_LEN
;
3365 uLength
+= (3) + WLAN_IEHDR_LEN
;
3368 ((PWLAN_IE_TPC_REP
) pbyBuffer
)->byElementID
= WLAN_EID_TPC_REP
;
3369 ((PWLAN_IE_TPC_REP
) pbyBuffer
)->len
= 2;
3370 ((PWLAN_IE_TPC_REP
) pbyBuffer
)->byTxPower
= CARDbyGetTransmitPower(pMgmt
->pAdapter
);
3371 ((PWLAN_IE_TPC_REP
) pbyBuffer
)->byLinkMargin
= 0;
3372 pbyBuffer
+= (2) + WLAN_IEHDR_LEN
;
3373 uLength
+= (2) + WLAN_IEHDR_LEN
;
3375 if (pMgmt
->eCurrMode
!= WMAC_MODE_ESS_AP
) {
3376 pIBSSDFS
= (PWLAN_IE_IBSS_DFS
) pbyBuffer
;
3377 pIBSSDFS
->byElementID
= WLAN_EID_IBSS_DFS
;
3379 memcpy( pIBSSDFS
->abyDFSOwner
,
3380 pMgmt
->abyIBSSDFSOwner
,
3382 pIBSSDFS
->byDFSRecovery
= pMgmt
->byIBSSDFSRecovery
;
3383 pbyBuffer
+= (7) + WLAN_IEHDR_LEN
;
3384 uLength
+= (7) + WLAN_IEHDR_LEN
;
3385 for(ii
=CB_MAX_CHANNEL_24G
+1; ii
<=CB_MAX_CHANNEL
; ii
++ ) {
3386 if (get_channel_map_info(pMgmt
->pAdapter
, ii
, pbyBuffer
, pbyBuffer
+1) == true) {
3393 sFrame
.len
+= uLength
;
3396 if (pMgmt
->eCurrentPHYMode
== PHY_TYPE_11G
) {
3397 sFrame
.pERP
= (PWLAN_IE_ERP
)(sFrame
.pBuf
+ sFrame
.len
);
3398 sFrame
.len
+= 1 + WLAN_IEHDR_LEN
;
3399 sFrame
.pERP
->byElementID
= WLAN_EID_ERP
;
3400 sFrame
.pERP
->len
= 1;
3401 sFrame
.pERP
->byContext
= 0;
3402 if (pDevice
->bProtectMode
== true)
3403 sFrame
.pERP
->byContext
|= WLAN_EID_ERP_USE_PROTECTION
;
3404 if (pDevice
->bNonERPPresent
== true)
3405 sFrame
.pERP
->byContext
|= WLAN_EID_ERP_NONERP_PRESENT
;
3406 if (pDevice
->bBarkerPreambleMd
== true)
3407 sFrame
.pERP
->byContext
|= WLAN_EID_ERP_BARKER_MODE
;
3409 if (((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
!= 0) {
3410 sFrame
.pExtSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3411 sFrame
.len
+= ((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
;
3412 memcpy(sFrame
.pExtSuppRates
,
3414 ((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
3417 // hostapd wpa/wpa2 IE
3418 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) && (pDevice
->bEnableHostapd
== true)) {
3419 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPANONE
) {
3420 if (pMgmt
->wWPAIELen
!= 0) {
3421 sFrame
.pRSN
= (PWLAN_IE_RSN
)(sFrame
.pBuf
+ sFrame
.len
);
3422 memcpy(sFrame
.pRSN
, pMgmt
->abyWPAIE
, pMgmt
->wWPAIELen
);
3423 sFrame
.len
+= pMgmt
->wWPAIELen
;
3428 /* Adjust the length fields */
3429 pTxPacket
->cbMPDULen
= sFrame
.len
;
3430 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
3441 * Routine Description:
3442 * Constructs an Prob-response frame
3446 * PTR to frame; or NULL on allocation failue
3454 s_MgrMakeProbeResponse(
3457 unsigned short wCurrCapInfo
,
3458 unsigned short wCurrBeaconPeriod
,
3459 unsigned int uCurrChannel
,
3460 unsigned short wCurrATIMWinodw
,
3461 unsigned char *pDstAddr
,
3462 PWLAN_IE_SSID pCurrSSID
,
3463 unsigned char *pCurrBSSID
,
3464 PWLAN_IE_SUPP_RATES pCurrSuppRates
,
3465 PWLAN_IE_SUPP_RATES pCurrExtSuppRates
,
3466 unsigned char byPHYType
3469 PSTxMgmtPacket pTxPacket
= NULL
;
3470 WLAN_FR_PROBERESP sFrame
;
3471 unsigned char *pbyBuffer
;
3472 unsigned int uLength
= 0;
3473 PWLAN_IE_IBSS_DFS pIBSSDFS
= NULL
;
3477 pTxPacket
= (PSTxMgmtPacket
)pMgmt
->pbyMgmtPacketPool
;
3478 memset(pTxPacket
, 0, sizeof(STxMgmtPacket
) + WLAN_PROBERESP_FR_MAXLEN
);
3479 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((unsigned char *)pTxPacket
+ sizeof(STxMgmtPacket
));
3480 // Setup the sFrame structure.
3481 sFrame
.pBuf
= (unsigned char *)pTxPacket
->p80211Header
;
3482 sFrame
.len
= WLAN_PROBERESP_FR_MAXLEN
;
3483 vMgrEncodeProbeResponse(&sFrame
);
3485 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
3487 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
3488 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_PROBERESP
)
3490 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pDstAddr
, WLAN_ADDR_LEN
);
3491 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
3492 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pCurrBSSID
, WLAN_BSSID_LEN
);
3493 *sFrame
.pwBeaconInterval
= cpu_to_le16(wCurrBeaconPeriod
);
3494 *sFrame
.pwCapInfo
= cpu_to_le16(wCurrCapInfo
);
3496 if (byPHYType
== BB_TYPE_11B
) {
3497 *sFrame
.pwCapInfo
&= cpu_to_le16((unsigned short)~(WLAN_SET_CAP_INFO_SHORTSLOTTIME(1)));
3501 sFrame
.pSSID
= (PWLAN_IE_SSID
)(sFrame
.pBuf
+ sFrame
.len
);
3502 sFrame
.len
+= ((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->len
+ WLAN_IEHDR_LEN
;
3503 memcpy(sFrame
.pSSID
,
3505 ((PWLAN_IE_SSID
)pCurrSSID
)->len
+ WLAN_IEHDR_LEN
3507 // Copy the rate set
3508 sFrame
.pSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3510 sFrame
.len
+= ((PWLAN_IE_SUPP_RATES
)pCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
;
3511 memcpy(sFrame
.pSuppRates
,
3513 ((PWLAN_IE_SUPP_RATES
)pCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
3517 if (pDevice
->eCurrentPHYType
!= PHY_TYPE_11A
) {
3518 sFrame
.pDSParms
= (PWLAN_IE_DS_PARMS
)(sFrame
.pBuf
+ sFrame
.len
);
3519 sFrame
.len
+= (1) + WLAN_IEHDR_LEN
;
3520 sFrame
.pDSParms
->byElementID
= WLAN_EID_DS_PARMS
;
3521 sFrame
.pDSParms
->len
= 1;
3522 sFrame
.pDSParms
->byCurrChannel
= (unsigned char)uCurrChannel
;
3525 if (pMgmt
->eCurrMode
!= WMAC_MODE_ESS_AP
) {
3527 sFrame
.pIBSSParms
= (PWLAN_IE_IBSS_PARMS
)(sFrame
.pBuf
+ sFrame
.len
);
3528 sFrame
.len
+= (2) + WLAN_IEHDR_LEN
;
3529 sFrame
.pIBSSParms
->byElementID
= WLAN_EID_IBSS_PARMS
;
3530 sFrame
.pIBSSParms
->len
= 2;
3531 sFrame
.pIBSSParms
->wATIMWindow
= 0;
3533 if (pDevice
->eCurrentPHYType
== PHY_TYPE_11G
) {
3534 sFrame
.pERP
= (PWLAN_IE_ERP
)(sFrame
.pBuf
+ sFrame
.len
);
3535 sFrame
.len
+= 1 + WLAN_IEHDR_LEN
;
3536 sFrame
.pERP
->byElementID
= WLAN_EID_ERP
;
3537 sFrame
.pERP
->len
= 1;
3538 sFrame
.pERP
->byContext
= 0;
3539 if (pDevice
->bProtectMode
== true)
3540 sFrame
.pERP
->byContext
|= WLAN_EID_ERP_USE_PROTECTION
;
3541 if (pDevice
->bNonERPPresent
== true)
3542 sFrame
.pERP
->byContext
|= WLAN_EID_ERP_NONERP_PRESENT
;
3543 if (pDevice
->bBarkerPreambleMd
== true)
3544 sFrame
.pERP
->byContext
|= WLAN_EID_ERP_BARKER_MODE
;
3547 if ((pMgmt
->b11hEnable
== true) &&
3548 (pMgmt
->eCurrentPHYMode
== PHY_TYPE_11A
)) {
3550 pbyBuffer
= (unsigned char *)(sFrame
.pBuf
+ sFrame
.len
);
3551 set_country_IE(pMgmt
->pAdapter
, pbyBuffer
);
3552 set_country_info(pMgmt
->pAdapter
, PHY_TYPE_11A
, pbyBuffer
);
3553 uLength
+= ((PWLAN_IE_COUNTRY
) pbyBuffer
)->len
+ WLAN_IEHDR_LEN
;
3554 pbyBuffer
+= (((PWLAN_IE_COUNTRY
) pbyBuffer
)->len
+ WLAN_IEHDR_LEN
);
3555 // Power Constrain IE
3556 ((PWLAN_IE_PW_CONST
) pbyBuffer
)->byElementID
= WLAN_EID_PWR_CONSTRAINT
;
3557 ((PWLAN_IE_PW_CONST
) pbyBuffer
)->len
= 1;
3558 ((PWLAN_IE_PW_CONST
) pbyBuffer
)->byPower
= 0;
3559 pbyBuffer
+= (1) + WLAN_IEHDR_LEN
;
3560 uLength
+= (1) + WLAN_IEHDR_LEN
;
3561 if (pMgmt
->bSwitchChannel
== true) {
3562 // Channel Switch IE
3563 ((PWLAN_IE_CH_SW
) pbyBuffer
)->byElementID
= WLAN_EID_CH_SWITCH
;
3564 ((PWLAN_IE_CH_SW
) pbyBuffer
)->len
= 3;
3565 ((PWLAN_IE_CH_SW
) pbyBuffer
)->byMode
= 1;
3566 ((PWLAN_IE_CH_SW
) pbyBuffer
)->byChannel
= get_channel_number(pMgmt
->pAdapter
, pMgmt
->byNewChannel
);
3567 ((PWLAN_IE_CH_SW
) pbyBuffer
)->byCount
= 0;
3568 pbyBuffer
+= (3) + WLAN_IEHDR_LEN
;
3569 uLength
+= (3) + WLAN_IEHDR_LEN
;
3572 ((PWLAN_IE_TPC_REP
) pbyBuffer
)->byElementID
= WLAN_EID_TPC_REP
;
3573 ((PWLAN_IE_TPC_REP
) pbyBuffer
)->len
= 2;
3574 ((PWLAN_IE_TPC_REP
) pbyBuffer
)->byTxPower
= CARDbyGetTransmitPower(pMgmt
->pAdapter
);
3575 ((PWLAN_IE_TPC_REP
) pbyBuffer
)->byLinkMargin
= 0;
3576 pbyBuffer
+= (2) + WLAN_IEHDR_LEN
;
3577 uLength
+= (2) + WLAN_IEHDR_LEN
;
3579 if (pMgmt
->eCurrMode
!= WMAC_MODE_ESS_AP
) {
3580 pIBSSDFS
= (PWLAN_IE_IBSS_DFS
) pbyBuffer
;
3581 pIBSSDFS
->byElementID
= WLAN_EID_IBSS_DFS
;
3583 memcpy( pIBSSDFS
->abyDFSOwner
,
3584 pMgmt
->abyIBSSDFSOwner
,
3586 pIBSSDFS
->byDFSRecovery
= pMgmt
->byIBSSDFSRecovery
;
3587 pbyBuffer
+= (7) + WLAN_IEHDR_LEN
;
3588 uLength
+= (7) + WLAN_IEHDR_LEN
;
3589 for(ii
=CB_MAX_CHANNEL_24G
+1; ii
<=CB_MAX_CHANNEL
; ii
++ ) {
3590 if (get_channel_map_info(pMgmt
->pAdapter
, ii
, pbyBuffer
, pbyBuffer
+1) == true) {
3597 sFrame
.len
+= uLength
;
3601 if (((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
!= 0) {
3602 sFrame
.pExtSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3603 sFrame
.len
+= ((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
;
3604 memcpy(sFrame
.pExtSuppRates
,
3606 ((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
3610 // hostapd wpa/wpa2 IE
3611 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) && (pDevice
->bEnableHostapd
== true)) {
3612 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPANONE
) {
3613 if (pMgmt
->wWPAIELen
!= 0) {
3614 sFrame
.pRSN
= (PWLAN_IE_RSN
)(sFrame
.pBuf
+ sFrame
.len
);
3615 memcpy(sFrame
.pRSN
, pMgmt
->abyWPAIE
, pMgmt
->wWPAIELen
);
3616 sFrame
.len
+= pMgmt
->wWPAIELen
;
3621 // Adjust the length fields
3622 pTxPacket
->cbMPDULen
= sFrame
.len
;
3623 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
3632 * Routine Description:
3633 * Constructs an association request frame
3637 * A ptr to frame or NULL on allocation failue
3643 s_MgrMakeAssocRequest(
3646 unsigned char *pDAddr
,
3647 unsigned short wCurrCapInfo
,
3648 unsigned short wListenInterval
,
3649 PWLAN_IE_SSID pCurrSSID
,
3650 PWLAN_IE_SUPP_RATES pCurrRates
,
3651 PWLAN_IE_SUPP_RATES pCurrExtSuppRates
3654 PSTxMgmtPacket pTxPacket
= NULL
;
3655 WLAN_FR_ASSOCREQ sFrame
;
3656 unsigned char *pbyIEs
;
3657 unsigned char *pbyRSN
;
3660 pTxPacket
= (PSTxMgmtPacket
)pMgmt
->pbyMgmtPacketPool
;
3661 memset(pTxPacket
, 0, sizeof(STxMgmtPacket
) + WLAN_ASSOCREQ_FR_MAXLEN
);
3662 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((unsigned char *)pTxPacket
+ sizeof(STxMgmtPacket
));
3663 // Setup the sFrame structure.
3664 sFrame
.pBuf
= (unsigned char *)pTxPacket
->p80211Header
;
3665 sFrame
.len
= WLAN_ASSOCREQ_FR_MAXLEN
;
3666 // format fixed field frame structure
3667 vMgrEncodeAssocRequest(&sFrame
);
3669 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
3671 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
3672 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ASSOCREQ
)
3674 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pDAddr
, WLAN_ADDR_LEN
);
3675 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
3676 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
3678 // Set the capibility and listen interval
3679 *(sFrame
.pwCapInfo
) = cpu_to_le16(wCurrCapInfo
);
3680 *(sFrame
.pwListenInterval
) = cpu_to_le16(wListenInterval
);
3682 // sFrame.len point to end of fixed field
3683 sFrame
.pSSID
= (PWLAN_IE_SSID
)(sFrame
.pBuf
+ sFrame
.len
);
3684 sFrame
.len
+= pCurrSSID
->len
+ WLAN_IEHDR_LEN
;
3685 memcpy(sFrame
.pSSID
, pCurrSSID
, pCurrSSID
->len
+ WLAN_IEHDR_LEN
);
3687 pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
= pCurrSSID
->len
+ WLAN_IEHDR_LEN
;
3688 pMgmt
->sAssocInfo
.AssocInfo
.OffsetRequestIEs
= sizeof(NDIS_802_11_ASSOCIATION_INFORMATION
);
3689 pbyIEs
= pMgmt
->sAssocInfo
.abyIEs
;
3690 memcpy(pbyIEs
, pCurrSSID
, pCurrSSID
->len
+ WLAN_IEHDR_LEN
);
3691 pbyIEs
+= pCurrSSID
->len
+ WLAN_IEHDR_LEN
;
3693 // Copy the rate set
3694 sFrame
.pSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3695 if ((pDevice
->eCurrentPHYType
== PHY_TYPE_11B
) && (pCurrRates
->len
> 4))
3696 sFrame
.len
+= 4 + WLAN_IEHDR_LEN
;
3698 sFrame
.len
+= pCurrRates
->len
+ WLAN_IEHDR_LEN
;
3699 memcpy(sFrame
.pSuppRates
, pCurrRates
, pCurrRates
->len
+ WLAN_IEHDR_LEN
);
3701 // Copy the extension rate set
3702 if ((pDevice
->eCurrentPHYType
== PHY_TYPE_11G
) && (pCurrExtSuppRates
->len
> 0)) {
3703 sFrame
.pExtSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3704 sFrame
.len
+= pCurrExtSuppRates
->len
+ WLAN_IEHDR_LEN
;
3705 memcpy(sFrame
.pExtSuppRates
, pCurrExtSuppRates
, pCurrExtSuppRates
->len
+ WLAN_IEHDR_LEN
);
3708 pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
+= pCurrRates
->len
+ WLAN_IEHDR_LEN
;
3709 memcpy(pbyIEs
, pCurrRates
, pCurrRates
->len
+ WLAN_IEHDR_LEN
);
3710 pbyIEs
+= pCurrRates
->len
+ WLAN_IEHDR_LEN
;
3713 if (pMgmt
->b11hEnable
== true) {
3714 if (sFrame
.pCurrPowerCap
== NULL
) {
3715 sFrame
.pCurrPowerCap
= (PWLAN_IE_PW_CAP
)(sFrame
.pBuf
+ sFrame
.len
);
3716 sFrame
.len
+= (2 + WLAN_IEHDR_LEN
);
3717 sFrame
.pCurrPowerCap
->byElementID
= WLAN_EID_PWR_CAPABILITY
;
3718 sFrame
.pCurrPowerCap
->len
= 2;
3719 CARDvGetPowerCapability(pMgmt
->pAdapter
,
3720 &(sFrame
.pCurrPowerCap
->byMinPower
),
3721 &(sFrame
.pCurrPowerCap
->byMaxPower
)
3724 if (sFrame
.pCurrSuppCh
== NULL
) {
3725 sFrame
.pCurrSuppCh
= (PWLAN_IE_SUPP_CH
)(sFrame
.pBuf
+ sFrame
.len
);
3726 sFrame
.len
+= set_support_channels(pMgmt
->pAdapter
,(unsigned char *)sFrame
.pCurrSuppCh
);
3730 if (((pMgmt
->eAuthenMode
== WMAC_AUTH_WPA
) ||
3731 (pMgmt
->eAuthenMode
== WMAC_AUTH_WPAPSK
) ||
3732 (pMgmt
->eAuthenMode
== WMAC_AUTH_WPANONE
)) &&
3733 (pMgmt
->pCurrBSS
!= NULL
)) {
3735 sFrame
.pRSNWPA
= (PWLAN_IE_RSN_EXT
)(sFrame
.pBuf
+ sFrame
.len
);
3736 sFrame
.pRSNWPA
->byElementID
= WLAN_EID_RSN_WPA
;
3737 sFrame
.pRSNWPA
->len
= 16;
3738 sFrame
.pRSNWPA
->abyOUI
[0] = 0x00;
3739 sFrame
.pRSNWPA
->abyOUI
[1] = 0x50;
3740 sFrame
.pRSNWPA
->abyOUI
[2] = 0xf2;
3741 sFrame
.pRSNWPA
->abyOUI
[3] = 0x01;
3742 sFrame
.pRSNWPA
->wVersion
= 1;
3743 //Group Key Cipher Suite
3744 sFrame
.pRSNWPA
->abyMulticast
[0] = 0x00;
3745 sFrame
.pRSNWPA
->abyMulticast
[1] = 0x50;
3746 sFrame
.pRSNWPA
->abyMulticast
[2] = 0xf2;
3747 if (pMgmt
->byCSSGK
== KEY_CTL_WEP
) {
3748 sFrame
.pRSNWPA
->abyMulticast
[3] = pMgmt
->pCurrBSS
->byGKType
;
3749 } else if (pMgmt
->byCSSGK
== KEY_CTL_TKIP
) {
3750 sFrame
.pRSNWPA
->abyMulticast
[3] = WPA_TKIP
;
3751 } else if (pMgmt
->byCSSGK
== KEY_CTL_CCMP
) {
3752 sFrame
.pRSNWPA
->abyMulticast
[3] = WPA_AESCCMP
;
3754 sFrame
.pRSNWPA
->abyMulticast
[3] = WPA_NONE
;
3756 // Pairwise Key Cipher Suite
3757 sFrame
.pRSNWPA
->wPKCount
= 1;
3758 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[0] = 0x00;
3759 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[1] = 0x50;
3760 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[2] = 0xf2;
3761 if (pMgmt
->byCSSPK
== KEY_CTL_TKIP
) {
3762 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[3] = WPA_TKIP
;
3763 } else if (pMgmt
->byCSSPK
== KEY_CTL_CCMP
) {
3764 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[3] = WPA_AESCCMP
;
3766 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[3] = WPA_NONE
;
3768 // Auth Key Management Suite
3769 pbyRSN
= (unsigned char *)(sFrame
.pBuf
+ sFrame
.len
+ 2 + sFrame
.pRSNWPA
->len
);
3776 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPAPSK
) {
3777 *pbyRSN
++=WPA_AUTH_PSK
;
3779 else if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA
) {
3780 *pbyRSN
++=WPA_AUTH_IEEE802_1X
;
3786 sFrame
.pRSNWPA
->len
+=6;
3792 sFrame
.pRSNWPA
->len
+=2;
3794 sFrame
.len
+= sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
;
3795 // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION
3796 pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
+= sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
;
3797 memcpy(pbyIEs
, sFrame
.pRSNWPA
, sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
);
3798 pbyIEs
+= sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
;
3800 } else if (((pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2
) ||
3801 (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2PSK
)) &&
3802 (pMgmt
->pCurrBSS
!= NULL
)) {
3804 unsigned short *pwPMKID
;
3807 sFrame
.pRSN
= (PWLAN_IE_RSN
)(sFrame
.pBuf
+ sFrame
.len
);
3808 sFrame
.pRSN
->byElementID
= WLAN_EID_RSN
;
3809 sFrame
.pRSN
->len
= 6; //Version(2)+GK(4)
3810 sFrame
.pRSN
->wVersion
= 1;
3811 //Group Key Cipher Suite
3812 sFrame
.pRSN
->abyRSN
[0] = 0x00;
3813 sFrame
.pRSN
->abyRSN
[1] = 0x0F;
3814 sFrame
.pRSN
->abyRSN
[2] = 0xAC;
3815 if (pMgmt
->byCSSGK
== KEY_CTL_WEP
) {
3816 sFrame
.pRSN
->abyRSN
[3] = pMgmt
->pCurrBSS
->byCSSGK
;
3817 } else if (pMgmt
->byCSSGK
== KEY_CTL_TKIP
) {
3818 sFrame
.pRSN
->abyRSN
[3] = WLAN_11i_CSS_TKIP
;
3819 } else if (pMgmt
->byCSSGK
== KEY_CTL_CCMP
) {
3820 sFrame
.pRSN
->abyRSN
[3] = WLAN_11i_CSS_CCMP
;
3822 sFrame
.pRSN
->abyRSN
[3] = WLAN_11i_CSS_UNKNOWN
;
3825 // Pairwise Key Cipher Suite
3826 sFrame
.pRSN
->abyRSN
[4] = 1;
3827 sFrame
.pRSN
->abyRSN
[5] = 0;
3828 sFrame
.pRSN
->abyRSN
[6] = 0x00;
3829 sFrame
.pRSN
->abyRSN
[7] = 0x0F;
3830 sFrame
.pRSN
->abyRSN
[8] = 0xAC;
3831 if (pMgmt
->byCSSPK
== KEY_CTL_TKIP
) {
3832 sFrame
.pRSN
->abyRSN
[9] = WLAN_11i_CSS_TKIP
;
3833 } else if (pMgmt
->byCSSPK
== KEY_CTL_CCMP
) {
3834 sFrame
.pRSN
->abyRSN
[9] = WLAN_11i_CSS_CCMP
;
3835 } else if (pMgmt
->byCSSPK
== KEY_CTL_NONE
) {
3836 sFrame
.pRSN
->abyRSN
[9] = WLAN_11i_CSS_USE_GROUP
;
3838 sFrame
.pRSN
->abyRSN
[9] = WLAN_11i_CSS_UNKNOWN
;
3840 sFrame
.pRSN
->len
+= 6;
3842 // Auth Key Management Suite
3843 sFrame
.pRSN
->abyRSN
[10] = 1;
3844 sFrame
.pRSN
->abyRSN
[11] = 0;
3845 sFrame
.pRSN
->abyRSN
[12] = 0x00;
3846 sFrame
.pRSN
->abyRSN
[13] = 0x0F;
3847 sFrame
.pRSN
->abyRSN
[14] = 0xAC;
3848 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2PSK
) {
3849 sFrame
.pRSN
->abyRSN
[15] = WLAN_11i_AKMSS_PSK
;
3850 } else if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2
) {
3851 sFrame
.pRSN
->abyRSN
[15] = WLAN_11i_AKMSS_802_1X
;
3853 sFrame
.pRSN
->abyRSN
[15] = WLAN_11i_AKMSS_UNKNOWN
;
3855 sFrame
.pRSN
->len
+=6;
3858 if (pMgmt
->pCurrBSS
->sRSNCapObj
.bRSNCapExist
== true) {
3859 memcpy(&sFrame
.pRSN
->abyRSN
[16], &pMgmt
->pCurrBSS
->sRSNCapObj
.wRSNCap
, 2);
3861 sFrame
.pRSN
->abyRSN
[16] = 0;
3862 sFrame
.pRSN
->abyRSN
[17] = 0;
3864 sFrame
.pRSN
->len
+=2;
3866 if ((pDevice
->gsPMKID
.BSSIDInfoCount
> 0) && (pDevice
->bRoaming
== true) && (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2
)) {
3868 pbyRSN
= &sFrame
.pRSN
->abyRSN
[18];
3869 pwPMKID
= (unsigned short *)pbyRSN
; // Point to PMKID count
3870 *pwPMKID
= 0; // Initialize PMKID count
3871 pbyRSN
+= 2; // Point to PMKID list
3872 for (ii
= 0; ii
< pDevice
->gsPMKID
.BSSIDInfoCount
; ii
++) {
3873 if ( !memcmp(&pDevice
->gsPMKID
.BSSIDInfo
[ii
].BSSID
[0], pMgmt
->abyCurrBSSID
, ETH_ALEN
)) {
3875 memcpy(pbyRSN
, pDevice
->gsPMKID
.BSSIDInfo
[ii
].PMKID
, 16);
3879 if (*pwPMKID
!= 0) {
3880 sFrame
.pRSN
->len
+= (2 + (*pwPMKID
)*16);
3884 sFrame
.len
+= sFrame
.pRSN
->len
+ WLAN_IEHDR_LEN
;
3885 // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION
3886 pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
+= sFrame
.pRSN
->len
+ WLAN_IEHDR_LEN
;
3887 memcpy(pbyIEs
, sFrame
.pRSN
, sFrame
.pRSN
->len
+ WLAN_IEHDR_LEN
);
3888 pbyIEs
+= sFrame
.pRSN
->len
+ WLAN_IEHDR_LEN
;
3892 // Adjust the length fields
3893 pTxPacket
->cbMPDULen
= sFrame
.len
;
3894 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
3907 * Routine Description:
3908 * Constructs an re-association request frame
3912 * A ptr to frame or NULL on allocation failue
3918 s_MgrMakeReAssocRequest(
3921 unsigned char *pDAddr
,
3922 unsigned short wCurrCapInfo
,
3923 unsigned short wListenInterval
,
3924 PWLAN_IE_SSID pCurrSSID
,
3925 PWLAN_IE_SUPP_RATES pCurrRates
,
3926 PWLAN_IE_SUPP_RATES pCurrExtSuppRates
3929 PSTxMgmtPacket pTxPacket
= NULL
;
3930 WLAN_FR_REASSOCREQ sFrame
;
3931 unsigned char *pbyIEs
;
3932 unsigned char *pbyRSN
;
3935 pTxPacket
= (PSTxMgmtPacket
)pMgmt
->pbyMgmtPacketPool
;
3936 memset( pTxPacket
, 0, sizeof(STxMgmtPacket
) + WLAN_REASSOCREQ_FR_MAXLEN
);
3937 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((unsigned char *)pTxPacket
+ sizeof(STxMgmtPacket
));
3938 /* Setup the sFrame structure. */
3939 sFrame
.pBuf
= (unsigned char *)pTxPacket
->p80211Header
;
3940 sFrame
.len
= WLAN_REASSOCREQ_FR_MAXLEN
;
3942 // format fixed field frame structure
3943 vMgrEncodeReassocRequest(&sFrame
);
3945 /* Setup the header */
3946 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
3948 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
3949 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_REASSOCREQ
)
3951 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pDAddr
, WLAN_ADDR_LEN
);
3952 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
3953 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
3955 /* Set the capibility and listen interval */
3956 *(sFrame
.pwCapInfo
) = cpu_to_le16(wCurrCapInfo
);
3957 *(sFrame
.pwListenInterval
) = cpu_to_le16(wListenInterval
);
3959 memcpy(sFrame
.pAddrCurrAP
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
3961 /* sFrame.len point to end of fixed field */
3962 sFrame
.pSSID
= (PWLAN_IE_SSID
)(sFrame
.pBuf
+ sFrame
.len
);
3963 sFrame
.len
+= pCurrSSID
->len
+ WLAN_IEHDR_LEN
;
3964 memcpy(sFrame
.pSSID
, pCurrSSID
, pCurrSSID
->len
+ WLAN_IEHDR_LEN
);
3966 pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
= pCurrSSID
->len
+ WLAN_IEHDR_LEN
;
3967 pMgmt
->sAssocInfo
.AssocInfo
.OffsetRequestIEs
= sizeof(NDIS_802_11_ASSOCIATION_INFORMATION
);
3968 pbyIEs
= pMgmt
->sAssocInfo
.abyIEs
;
3969 memcpy(pbyIEs
, pCurrSSID
, pCurrSSID
->len
+ WLAN_IEHDR_LEN
);
3970 pbyIEs
+= pCurrSSID
->len
+ WLAN_IEHDR_LEN
;
3972 /* Copy the rate set */
3973 /* sFrame.len point to end of SSID */
3974 sFrame
.pSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3975 sFrame
.len
+= pCurrRates
->len
+ WLAN_IEHDR_LEN
;
3976 memcpy(sFrame
.pSuppRates
, pCurrRates
, pCurrRates
->len
+ WLAN_IEHDR_LEN
);
3978 // Copy the extension rate set
3979 if ((pMgmt
->eCurrentPHYMode
== PHY_TYPE_11G
) && (pCurrExtSuppRates
->len
> 0)) {
3980 sFrame
.pExtSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3981 sFrame
.len
+= pCurrExtSuppRates
->len
+ WLAN_IEHDR_LEN
;
3982 memcpy(sFrame
.pExtSuppRates
, pCurrExtSuppRates
, pCurrExtSuppRates
->len
+ WLAN_IEHDR_LEN
);
3985 pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
+= pCurrRates
->len
+ WLAN_IEHDR_LEN
;
3986 memcpy(pbyIEs
, pCurrRates
, pCurrRates
->len
+ WLAN_IEHDR_LEN
);
3987 pbyIEs
+= pCurrRates
->len
+ WLAN_IEHDR_LEN
;
3989 if (((pMgmt
->eAuthenMode
== WMAC_AUTH_WPA
) ||
3990 (pMgmt
->eAuthenMode
== WMAC_AUTH_WPAPSK
) ||
3991 (pMgmt
->eAuthenMode
== WMAC_AUTH_WPANONE
)) &&
3992 (pMgmt
->pCurrBSS
!= NULL
)) {
3994 sFrame
.pRSNWPA
= (PWLAN_IE_RSN_EXT
)(sFrame
.pBuf
+ sFrame
.len
);
3995 sFrame
.pRSNWPA
->byElementID
= WLAN_EID_RSN_WPA
;
3996 sFrame
.pRSNWPA
->len
= 16;
3997 sFrame
.pRSNWPA
->abyOUI
[0] = 0x00;
3998 sFrame
.pRSNWPA
->abyOUI
[1] = 0x50;
3999 sFrame
.pRSNWPA
->abyOUI
[2] = 0xf2;
4000 sFrame
.pRSNWPA
->abyOUI
[3] = 0x01;
4001 sFrame
.pRSNWPA
->wVersion
= 1;
4002 //Group Key Cipher Suite
4003 sFrame
.pRSNWPA
->abyMulticast
[0] = 0x00;
4004 sFrame
.pRSNWPA
->abyMulticast
[1] = 0x50;
4005 sFrame
.pRSNWPA
->abyMulticast
[2] = 0xf2;
4006 if (pMgmt
->byCSSGK
== KEY_CTL_WEP
) {
4007 sFrame
.pRSNWPA
->abyMulticast
[3] = pMgmt
->pCurrBSS
->byGKType
;
4008 } else if (pMgmt
->byCSSGK
== KEY_CTL_TKIP
) {
4009 sFrame
.pRSNWPA
->abyMulticast
[3] = WPA_TKIP
;
4010 } else if (pMgmt
->byCSSGK
== KEY_CTL_CCMP
) {
4011 sFrame
.pRSNWPA
->abyMulticast
[3] = WPA_AESCCMP
;
4013 sFrame
.pRSNWPA
->abyMulticast
[3] = WPA_NONE
;
4015 // Pairwise Key Cipher Suite
4016 sFrame
.pRSNWPA
->wPKCount
= 1;
4017 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[0] = 0x00;
4018 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[1] = 0x50;
4019 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[2] = 0xf2;
4020 if (pMgmt
->byCSSPK
== KEY_CTL_TKIP
) {
4021 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[3] = WPA_TKIP
;
4022 } else if (pMgmt
->byCSSPK
== KEY_CTL_CCMP
) {
4023 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[3] = WPA_AESCCMP
;
4025 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[3] = WPA_NONE
;
4027 // Auth Key Management Suite
4028 pbyRSN
= (unsigned char *)(sFrame
.pBuf
+ sFrame
.len
+ 2 + sFrame
.pRSNWPA
->len
);
4035 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPAPSK
) {
4036 *pbyRSN
++=WPA_AUTH_PSK
;
4037 } else if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA
) {
4038 *pbyRSN
++=WPA_AUTH_IEEE802_1X
;
4043 sFrame
.pRSNWPA
->len
+=6;
4048 sFrame
.pRSNWPA
->len
+=2;
4050 sFrame
.len
+= sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
;
4051 // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION
4052 pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
+= sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
;
4053 memcpy(pbyIEs
, sFrame
.pRSNWPA
, sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
);
4054 pbyIEs
+= sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
;
4056 } else if (((pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2
) ||
4057 (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2PSK
)) &&
4058 (pMgmt
->pCurrBSS
!= NULL
)) {
4060 unsigned short *pwPMKID
;
4063 sFrame
.pRSN
= (PWLAN_IE_RSN
)(sFrame
.pBuf
+ sFrame
.len
);
4064 sFrame
.pRSN
->byElementID
= WLAN_EID_RSN
;
4065 sFrame
.pRSN
->len
= 6; //Version(2)+GK(4)
4066 sFrame
.pRSN
->wVersion
= 1;
4067 //Group Key Cipher Suite
4068 sFrame
.pRSN
->abyRSN
[0] = 0x00;
4069 sFrame
.pRSN
->abyRSN
[1] = 0x0F;
4070 sFrame
.pRSN
->abyRSN
[2] = 0xAC;
4071 if (pMgmt
->byCSSGK
== KEY_CTL_WEP
) {
4072 sFrame
.pRSN
->abyRSN
[3] = pMgmt
->pCurrBSS
->byCSSGK
;
4073 } else if (pMgmt
->byCSSGK
== KEY_CTL_TKIP
) {
4074 sFrame
.pRSN
->abyRSN
[3] = WLAN_11i_CSS_TKIP
;
4075 } else if (pMgmt
->byCSSGK
== KEY_CTL_CCMP
) {
4076 sFrame
.pRSN
->abyRSN
[3] = WLAN_11i_CSS_CCMP
;
4078 sFrame
.pRSN
->abyRSN
[3] = WLAN_11i_CSS_UNKNOWN
;
4081 // Pairwise Key Cipher Suite
4082 sFrame
.pRSN
->abyRSN
[4] = 1;
4083 sFrame
.pRSN
->abyRSN
[5] = 0;
4084 sFrame
.pRSN
->abyRSN
[6] = 0x00;
4085 sFrame
.pRSN
->abyRSN
[7] = 0x0F;
4086 sFrame
.pRSN
->abyRSN
[8] = 0xAC;
4087 if (pMgmt
->byCSSPK
== KEY_CTL_TKIP
) {
4088 sFrame
.pRSN
->abyRSN
[9] = WLAN_11i_CSS_TKIP
;
4089 } else if (pMgmt
->byCSSPK
== KEY_CTL_CCMP
) {
4090 sFrame
.pRSN
->abyRSN
[9] = WLAN_11i_CSS_CCMP
;
4091 } else if (pMgmt
->byCSSPK
== KEY_CTL_NONE
) {
4092 sFrame
.pRSN
->abyRSN
[9] = WLAN_11i_CSS_USE_GROUP
;
4094 sFrame
.pRSN
->abyRSN
[9] = WLAN_11i_CSS_UNKNOWN
;
4096 sFrame
.pRSN
->len
+= 6;
4098 // Auth Key Management Suite
4099 sFrame
.pRSN
->abyRSN
[10] = 1;
4100 sFrame
.pRSN
->abyRSN
[11] = 0;
4101 sFrame
.pRSN
->abyRSN
[12] = 0x00;
4102 sFrame
.pRSN
->abyRSN
[13] = 0x0F;
4103 sFrame
.pRSN
->abyRSN
[14] = 0xAC;
4104 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2PSK
) {
4105 sFrame
.pRSN
->abyRSN
[15] = WLAN_11i_AKMSS_PSK
;
4106 } else if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2
) {
4107 sFrame
.pRSN
->abyRSN
[15] = WLAN_11i_AKMSS_802_1X
;
4109 sFrame
.pRSN
->abyRSN
[15] = WLAN_11i_AKMSS_UNKNOWN
;
4111 sFrame
.pRSN
->len
+=6;
4114 if (pMgmt
->pCurrBSS
->sRSNCapObj
.bRSNCapExist
== true) {
4115 memcpy(&sFrame
.pRSN
->abyRSN
[16], &pMgmt
->pCurrBSS
->sRSNCapObj
.wRSNCap
, 2);
4117 sFrame
.pRSN
->abyRSN
[16] = 0;
4118 sFrame
.pRSN
->abyRSN
[17] = 0;
4120 sFrame
.pRSN
->len
+=2;
4122 if ((pDevice
->gsPMKID
.BSSIDInfoCount
> 0) && (pDevice
->bRoaming
== true) && (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2
)) {
4124 pbyRSN
= &sFrame
.pRSN
->abyRSN
[18];
4125 pwPMKID
= (unsigned short *)pbyRSN
; // Point to PMKID count
4126 *pwPMKID
= 0; // Initialize PMKID count
4127 pbyRSN
+= 2; // Point to PMKID list
4128 for (ii
= 0; ii
< pDevice
->gsPMKID
.BSSIDInfoCount
; ii
++) {
4129 if ( !memcmp(&pDevice
->gsPMKID
.BSSIDInfo
[ii
].BSSID
[0], pMgmt
->abyCurrBSSID
, ETH_ALEN
)) {
4131 memcpy(pbyRSN
, pDevice
->gsPMKID
.BSSIDInfo
[ii
].PMKID
, 16);
4135 if (*pwPMKID
!= 0) {
4136 sFrame
.pRSN
->len
+= (2 + (*pwPMKID
)*16);
4140 sFrame
.len
+= sFrame
.pRSN
->len
+ WLAN_IEHDR_LEN
;
4141 // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION
4142 pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
+= sFrame
.pRSN
->len
+ WLAN_IEHDR_LEN
;
4143 memcpy(pbyIEs
, sFrame
.pRSN
, sFrame
.pRSN
->len
+ WLAN_IEHDR_LEN
);
4144 pbyIEs
+= sFrame
.pRSN
->len
+ WLAN_IEHDR_LEN
;
4148 /* Adjust the length fields */
4149 pTxPacket
->cbMPDULen
= sFrame
.len
;
4150 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
4159 * Routine Description:
4160 * Constructs an assoc-response frame
4164 * PTR to frame; or NULL on allocation failue
4170 s_MgrMakeAssocResponse(
4173 unsigned short wCurrCapInfo
,
4174 unsigned short wAssocStatus
,
4175 unsigned short wAssocAID
,
4176 unsigned char *pDstAddr
,
4177 PWLAN_IE_SUPP_RATES pCurrSuppRates
,
4178 PWLAN_IE_SUPP_RATES pCurrExtSuppRates
4181 PSTxMgmtPacket pTxPacket
= NULL
;
4182 WLAN_FR_ASSOCRESP sFrame
;
4185 pTxPacket
= (PSTxMgmtPacket
)pMgmt
->pbyMgmtPacketPool
;
4186 memset(pTxPacket
, 0, sizeof(STxMgmtPacket
) + WLAN_ASSOCREQ_FR_MAXLEN
);
4187 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((unsigned char *)pTxPacket
+ sizeof(STxMgmtPacket
));
4188 // Setup the sFrame structure
4189 sFrame
.pBuf
= (unsigned char *)pTxPacket
->p80211Header
;
4190 sFrame
.len
= WLAN_REASSOCRESP_FR_MAXLEN
;
4191 vMgrEncodeAssocResponse(&sFrame
);
4193 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
4195 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
4196 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ASSOCRESP
)
4198 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pDstAddr
, WLAN_ADDR_LEN
);
4199 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
4200 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
4202 *sFrame
.pwCapInfo
= cpu_to_le16(wCurrCapInfo
);
4203 *sFrame
.pwStatus
= cpu_to_le16(wAssocStatus
);
4204 *sFrame
.pwAid
= cpu_to_le16((unsigned short)(wAssocAID
| BIT14
| BIT15
));
4206 // Copy the rate set
4207 sFrame
.pSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
4208 sFrame
.len
+= ((PWLAN_IE_SUPP_RATES
)pCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
;
4209 memcpy(sFrame
.pSuppRates
,
4211 ((PWLAN_IE_SUPP_RATES
)pCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
4214 if (((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
!= 0) {
4215 sFrame
.pExtSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
4216 sFrame
.len
+= ((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
;
4217 memcpy(sFrame
.pExtSuppRates
,
4219 ((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
4223 // Adjust the length fields
4224 pTxPacket
->cbMPDULen
= sFrame
.len
;
4225 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
4233 * Routine Description:
4234 * Constructs an reassoc-response frame
4238 * PTR to frame; or NULL on allocation failue
4244 s_MgrMakeReAssocResponse(
4247 unsigned short wCurrCapInfo
,
4248 unsigned short wAssocStatus
,
4249 unsigned short wAssocAID
,
4250 unsigned char *pDstAddr
,
4251 PWLAN_IE_SUPP_RATES pCurrSuppRates
,
4252 PWLAN_IE_SUPP_RATES pCurrExtSuppRates
4255 PSTxMgmtPacket pTxPacket
= NULL
;
4256 WLAN_FR_REASSOCRESP sFrame
;
4259 pTxPacket
= (PSTxMgmtPacket
)pMgmt
->pbyMgmtPacketPool
;
4260 memset(pTxPacket
, 0, sizeof(STxMgmtPacket
) + WLAN_ASSOCREQ_FR_MAXLEN
);
4261 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((unsigned char *)pTxPacket
+ sizeof(STxMgmtPacket
));
4262 // Setup the sFrame structure
4263 sFrame
.pBuf
= (unsigned char *)pTxPacket
->p80211Header
;
4264 sFrame
.len
= WLAN_REASSOCRESP_FR_MAXLEN
;
4265 vMgrEncodeReassocResponse(&sFrame
);
4267 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
4269 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
4270 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_REASSOCRESP
)
4272 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pDstAddr
, WLAN_ADDR_LEN
);
4273 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
4274 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
4276 *sFrame
.pwCapInfo
= cpu_to_le16(wCurrCapInfo
);
4277 *sFrame
.pwStatus
= cpu_to_le16(wAssocStatus
);
4278 *sFrame
.pwAid
= cpu_to_le16((unsigned short)(wAssocAID
| BIT14
| BIT15
));
4280 // Copy the rate set
4281 sFrame
.pSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
4282 sFrame
.len
+= ((PWLAN_IE_SUPP_RATES
)pCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
;
4283 memcpy(sFrame
.pSuppRates
,
4285 ((PWLAN_IE_SUPP_RATES
)pCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
4288 if (((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
!= 0) {
4289 sFrame
.pExtSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
4290 sFrame
.len
+= ((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
;
4291 memcpy(sFrame
.pExtSuppRates
,
4293 ((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
4297 // Adjust the length fields
4298 pTxPacket
->cbMPDULen
= sFrame
.len
;
4299 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
4307 * Routine Description:
4308 * Handles probe response management frames.
4318 s_vMgrRxProbeResponse(
4321 PSRxMgmtPacket pRxPacket
4324 PKnownBSS pBSSList
= NULL
;
4325 WLAN_FR_PROBERESP sFrame
;
4326 unsigned char byCurrChannel
= pRxPacket
->byRxChannel
;
4328 unsigned char byIEChannel
= 0;
4329 bool bChannelHit
= true;
4332 memset(&sFrame
, 0, sizeof(WLAN_FR_PROBERESP
));
4334 sFrame
.len
= pRxPacket
->cbMPDULen
;
4335 sFrame
.pBuf
= (unsigned char *)pRxPacket
->p80211Header
;
4336 vMgrDecodeProbeResponse(&sFrame
);
4338 if ((sFrame
.pqwTimestamp
== 0) ||
4339 (sFrame
.pwBeaconInterval
== 0) ||
4340 (sFrame
.pwCapInfo
== 0) ||
4341 (sFrame
.pSSID
== 0) ||
4342 (sFrame
.pSuppRates
== 0)) {
4343 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Probe resp:Fail addr:[%p] \n", pRxPacket
->p80211Header
);
4348 if(sFrame
.pSSID
->len
== 0)
4349 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Rx Probe resp: SSID len = 0 \n");
4351 if (sFrame
.pDSParms
!= 0) {
4352 if (byCurrChannel
> CB_MAX_CHANNEL_24G
) {
4353 // channel remapping to
4354 byIEChannel
= get_channel_mapping(pMgmt
->pAdapter
, sFrame
.pDSParms
->byCurrChannel
, PHY_TYPE_11A
);
4356 byIEChannel
= sFrame
.pDSParms
->byCurrChannel
;
4358 if (byCurrChannel
!= byIEChannel
) {
4359 // adjust channel info. bcs we rcv adjcent channel pakckets
4360 bChannelHit
= false;
4361 byCurrChannel
= byIEChannel
;
4364 // no DS channel info
4368 //2008-0730-01<Add>by MikeLiu
4369 if(ChannelExceedZoneType(pDevice
,byCurrChannel
)==true)
4372 if (sFrame
.pERP
!= NULL
) {
4373 sERP
.byERP
= sFrame
.pERP
->byContext
;
4374 sERP
.bERPExist
= true;
4376 sERP
.bERPExist
= false;
4381 // update or insert the bss
4382 pBSSList
= BSSpAddrIsInBSSList((void *)pDevice
, sFrame
.pHdr
->sA3
.abyAddr3
, sFrame
.pSSID
);
4384 BSSbUpdateToBSSList((void *)pDevice
,
4385 *sFrame
.pqwTimestamp
,
4386 *sFrame
.pwBeaconInterval
,
4392 sFrame
.pExtSuppRates
,
4399 sFrame
.len
- WLAN_HDR_ADDR3_LEN
,
4400 sFrame
.pHdr
->sA4
.abyAddr4
, // payload of probresponse
4405 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Probe resp/insert: RxChannel = : %d\n", byCurrChannel
);
4406 BSSbInsertToBSSList((void *)pDevice
,
4407 sFrame
.pHdr
->sA3
.abyAddr3
,
4408 *sFrame
.pqwTimestamp
,
4409 *sFrame
.pwBeaconInterval
,
4414 sFrame
.pExtSuppRates
,
4420 sFrame
.len
- WLAN_HDR_ADDR3_LEN
,
4421 sFrame
.pHdr
->sA4
.abyAddr4
, // payload of beacon
4431 * Routine Description:(AP)or(Ad-hoc STA)
4432 * Handles probe request management frames.
4443 s_vMgrRxProbeRequest(
4446 PSRxMgmtPacket pRxPacket
4449 WLAN_FR_PROBEREQ sFrame
;
4451 PSTxMgmtPacket pTxPacket
;
4452 unsigned char byPHYType
= BB_TYPE_11B
;
4454 // STA in Ad-hoc mode: when latest TBTT beacon transmit success,
4455 // STA have to response this request.
4456 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) ||
4457 ((pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) && pDevice
->bBeaconSent
)) {
4459 memset(&sFrame
, 0, sizeof(WLAN_FR_PROBEREQ
));
4461 sFrame
.len
= pRxPacket
->cbMPDULen
;
4462 sFrame
.pBuf
= (unsigned char *)pRxPacket
->p80211Header
;
4463 vMgrDecodeProbeRequest(&sFrame
);
4465 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request rx:MAC addr:%02x-%02x-%02x=%02x-%02x-%02x \n",
4466 sFrame.pHdr->sA3.abyAddr2[0],
4467 sFrame.pHdr->sA3.abyAddr2[1],
4468 sFrame.pHdr->sA3.abyAddr2[2],
4469 sFrame.pHdr->sA3.abyAddr2[3],
4470 sFrame.pHdr->sA3.abyAddr2[4],
4471 sFrame.pHdr->sA3.abyAddr2[5]
4474 if (sFrame
.pSSID
->len
!= 0) {
4475 if (sFrame
.pSSID
->len
!= ((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->len
)
4477 if (memcmp(sFrame
.pSSID
->abySSID
,
4478 ((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->abySSID
,
4479 ((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->len
) != 0) {
4484 if ((sFrame
.pSuppRates
->len
> 4) || (sFrame
.pExtSuppRates
!= NULL
)) {
4485 byPHYType
= BB_TYPE_11G
;
4488 // Probe response reply..
4489 pTxPacket
= s_MgrMakeProbeResponse
4493 pMgmt
->wCurrCapInfo
,
4494 pMgmt
->wCurrBeaconPeriod
,
4495 pMgmt
->uCurrChannel
,
4497 sFrame
.pHdr
->sA3
.abyAddr2
,
4498 (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
,
4499 (unsigned char *)pMgmt
->abyCurrBSSID
,
4500 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
4501 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
,
4504 if (pTxPacket
!= NULL
){
4505 /* send the frame */
4506 Status
= csMgmt_xmit(pDevice
, pTxPacket
);
4507 if (Status
!= CMD_STATUS_PENDING
) {
4508 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Probe response tx failed\n");
4511 // DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Probe response tx sending..\n");
4525 * Routine Description:
4527 * Entry point for the reception and handling of 802.11 management
4528 * frames. Makes a determination of the frame type and then calls
4529 * the appropriate function.
4540 void *hDeviceContext
,
4542 PSRxMgmtPacket pRxPacket
4545 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
4546 bool bInScan
= false;
4547 unsigned int uNodeIndex
= 0;
4548 NODE_STATE eNodeState
= 0;
4552 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) {
4553 if (BSSDBbIsSTAInNodeDB(pMgmt
, pRxPacket
->p80211Header
->sA3
.abyAddr2
, &uNodeIndex
))
4554 eNodeState
= pMgmt
->sNodeDBTable
[uNodeIndex
].eNodeState
;
4557 switch( WLAN_GET_FC_FSTYPE((pRxPacket
->p80211Header
->sA3
.wFrameCtl
)) ){
4559 case WLAN_FSTYPE_ASSOCREQ
:
4561 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx assocreq\n");
4562 if (eNodeState
< NODE_AUTH
) {
4563 // send deauth notification
4564 // reason = (6) class 2 received from nonauth sta
4565 vMgrDeAuthenBeginSta(pDevice
,
4567 pRxPacket
->p80211Header
->sA3
.abyAddr2
,
4571 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"wmgr: send vMgrDeAuthenBeginSta 1\n");
4574 s_vMgrRxAssocRequest(pDevice
, pMgmt
, pRxPacket
, uNodeIndex
);
4578 case WLAN_FSTYPE_ASSOCRESP
:
4580 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx assocresp1\n");
4581 s_vMgrRxAssocResponse(pDevice
, pMgmt
, pRxPacket
, false);
4582 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx assocresp2\n");
4585 case WLAN_FSTYPE_REASSOCREQ
:
4587 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx reassocreq\n");
4589 if (eNodeState
< NODE_AUTH
) {
4590 // send deauth notification
4591 // reason = (6) class 2 received from nonauth sta
4592 vMgrDeAuthenBeginSta(pDevice
,
4594 pRxPacket
->p80211Header
->sA3
.abyAddr2
,
4598 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"wmgr: send vMgrDeAuthenBeginSta 2\n");
4601 s_vMgrRxReAssocRequest(pDevice
, pMgmt
, pRxPacket
, uNodeIndex
);
4604 case WLAN_FSTYPE_REASSOCRESP
:
4606 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx reassocresp\n");
4607 s_vMgrRxAssocResponse(pDevice
, pMgmt
, pRxPacket
, true);
4610 case WLAN_FSTYPE_PROBEREQ
:
4612 //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx probereq\n");
4613 s_vMgrRxProbeRequest(pDevice
, pMgmt
, pRxPacket
);
4616 case WLAN_FSTYPE_PROBERESP
:
4618 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx proberesp\n");
4620 s_vMgrRxProbeResponse(pDevice
, pMgmt
, pRxPacket
);
4623 case WLAN_FSTYPE_BEACON
:
4625 //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx beacon\n");
4626 if (pMgmt
->eScanState
!= WMAC_NO_SCANNING
) {
4629 s_vMgrRxBeacon(pDevice
, pMgmt
, pRxPacket
, bInScan
);
4632 case WLAN_FSTYPE_ATIM
:
4634 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx atim\n");
4637 case WLAN_FSTYPE_DISASSOC
:
4639 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx disassoc\n");
4640 if (eNodeState
< NODE_AUTH
) {
4641 // send deauth notification
4642 // reason = (6) class 2 received from nonauth sta
4643 vMgrDeAuthenBeginSta(pDevice
,
4645 pRxPacket
->p80211Header
->sA3
.abyAddr2
,
4649 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"wmgr: send vMgrDeAuthenBeginSta 3\n");
4651 s_vMgrRxDisassociation(pDevice
, pMgmt
, pRxPacket
);
4654 case WLAN_FSTYPE_AUTHEN
:
4656 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx authen\n");
4657 s_vMgrRxAuthentication(pDevice
, pMgmt
, pRxPacket
);
4660 case WLAN_FSTYPE_DEAUTHEN
:
4662 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx deauthen\n");
4663 s_vMgrRxDeauthentication(pDevice
, pMgmt
, pRxPacket
);
4667 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx unknown mgmt\n");
4678 * Routine Description:
4681 * Prepare beacon to send
4684 * true if success; false if failed.
4688 bMgrPrepareBeaconToSend(
4689 void *hDeviceContext
,
4693 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
4694 PSTxMgmtPacket pTxPacket
;
4696 // pDevice->bBeaconBufReady = false;
4697 if (pDevice
->bEncryptionEnable
|| pDevice
->bEnable8021x
){
4698 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_PRIVACY(1);
4701 pMgmt
->wCurrCapInfo
&= ~WLAN_SET_CAP_INFO_PRIVACY(1);
4703 pTxPacket
= s_MgrMakeBeacon
4707 pMgmt
->wCurrCapInfo
,
4708 pMgmt
->wCurrBeaconPeriod
,
4709 pMgmt
->uCurrChannel
,
4710 pMgmt
->wCurrATIMWindow
, //0,
4711 (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
,
4712 (unsigned char *)pMgmt
->abyCurrBSSID
,
4713 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
4714 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
4717 if ((pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) &&
4718 (pMgmt
->abyCurrBSSID
[0] == 0))
4721 csBeacon_xmit(pDevice
, pTxPacket
);
4731 * Routine Description:
4733 * Log a warning message based on the contents of the Status
4734 * Code field of an 802.11 management frame. Defines are
4735 * derived from 802.11-1997 SPEC.
4745 unsigned short wStatus
4749 case WLAN_MGMT_STATUS_UNSPEC_FAILURE
:
4750 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Unspecified error.\n");
4752 case WLAN_MGMT_STATUS_CAPS_UNSUPPORTED
:
4753 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Can't support all requested capabilities.\n");
4755 case WLAN_MGMT_STATUS_REASSOC_NO_ASSOC
:
4756 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Reassoc denied, can't confirm original Association.\n");
4758 case WLAN_MGMT_STATUS_ASSOC_DENIED_UNSPEC
:
4759 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Assoc denied, undefine in spec\n");
4761 case WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG
:
4762 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Peer doesn't support authen algorithm.\n");
4764 case WLAN_MGMT_STATUS_RX_AUTH_NOSEQ
:
4765 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Authen frame received out of sequence.\n");
4767 case WLAN_MGMT_STATUS_CHALLENGE_FAIL
:
4768 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Authen rejected, challenge failure.\n");
4770 case WLAN_MGMT_STATUS_AUTH_TIMEOUT
:
4771 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Authen rejected, timeout waiting for next frame.\n");
4773 case WLAN_MGMT_STATUS_ASSOC_DENIED_BUSY
:
4774 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Assoc denied, AP too busy.\n");
4776 case WLAN_MGMT_STATUS_ASSOC_DENIED_RATES
:
4777 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Assoc denied, we haven't enough basic rates.\n");
4779 case WLAN_MGMT_STATUS_ASSOC_DENIED_SHORTPREAMBLE
:
4780 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Assoc denied, we do not support short preamble.\n");
4782 case WLAN_MGMT_STATUS_ASSOC_DENIED_PBCC
:
4783 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Assoc denied, we do not support PBCC.\n");
4785 case WLAN_MGMT_STATUS_ASSOC_DENIED_AGILITY
:
4786 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Assoc denied, we do not support channel agility.\n");
4789 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Unknown status code %d.\n", wStatus
);
4798 * Add BSSID in PMKID Candidate list.
4802 * hDeviceContext - device structure point
4803 * pbyBSSID - BSSID address for adding
4804 * wRSNCap - BSS's RSN capability
4808 * Return Value: none.
4812 bAdd_PMKID_Candidate (
4813 void *hDeviceContext
,
4814 unsigned char *pbyBSSID
,
4815 PSRSNCapObject psRSNCapObj
4818 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
4819 PPMKID_CANDIDATE pCandidateList
;
4820 unsigned int ii
= 0;
4822 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"bAdd_PMKID_Candidate START: (%d)\n", (int)pDevice
->gsPMKIDCandidate
.NumCandidates
);
4824 if ((pDevice
== NULL
) || (pbyBSSID
== NULL
) || (psRSNCapObj
== NULL
))
4827 if (pDevice
->gsPMKIDCandidate
.NumCandidates
>= MAX_PMKIDLIST
)
4832 // Update Old Candidate
4833 for (ii
= 0; ii
< pDevice
->gsPMKIDCandidate
.NumCandidates
; ii
++) {
4834 pCandidateList
= &pDevice
->gsPMKIDCandidate
.CandidateList
[ii
];
4835 if ( !memcmp(pCandidateList
->BSSID
, pbyBSSID
, ETH_ALEN
)) {
4836 if ((psRSNCapObj
->bRSNCapExist
== true) && (psRSNCapObj
->wRSNCap
& BIT0
)) {
4837 pCandidateList
->Flags
|= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED
;
4839 pCandidateList
->Flags
&= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED
);
4846 pCandidateList
= &pDevice
->gsPMKIDCandidate
.CandidateList
[pDevice
->gsPMKIDCandidate
.NumCandidates
];
4847 if ((psRSNCapObj
->bRSNCapExist
== true) && (psRSNCapObj
->wRSNCap
& BIT0
)) {
4848 pCandidateList
->Flags
|= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED
;
4850 pCandidateList
->Flags
&= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED
);
4852 memcpy(pCandidateList
->BSSID
, pbyBSSID
, ETH_ALEN
);
4853 pDevice
->gsPMKIDCandidate
.NumCandidates
++;
4854 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"NumCandidates:%d\n", (int)pDevice
->gsPMKIDCandidate
.NumCandidates
);
4861 * Flush PMKID Candidate list.
4865 * hDeviceContext - device structure point
4869 * Return Value: none.
4873 vFlush_PMKID_Candidate (
4874 void *hDeviceContext
4877 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
4879 if (pDevice
== NULL
)
4882 memset(&pDevice
->gsPMKIDCandidate
, 0, sizeof(SPMKIDCandidateEvent
));
4888 NDIS_802_11_ENCRYPTION_STATUS EncStatus
,
4889 unsigned char *pbyCCSPK
,
4890 unsigned char *pbyCCSGK
4893 unsigned char byMulticastCipher
= KEY_CTL_INVALID
;
4894 unsigned char byCipherMask
= 0x00;
4897 if (pBSSNode
== NULL
)
4900 // check cap. of BSS
4901 if ((WLAN_GET_CAP_INFO_PRIVACY(pBSSNode
->wCapInfo
) != 0) &&
4902 (EncStatus
== Ndis802_11Encryption1Enabled
)) {
4903 // default is WEP only
4904 byMulticastCipher
= KEY_CTL_WEP
;
4907 if ((WLAN_GET_CAP_INFO_PRIVACY(pBSSNode
->wCapInfo
) != 0) &&
4908 (pBSSNode
->bWPA2Valid
== true) &&
4909 //20080123-01,<Add> by Einsn Liu
4910 ((EncStatus
== Ndis802_11Encryption3Enabled
)||(EncStatus
== Ndis802_11Encryption2Enabled
))) {
4912 // check Group Key Cipher
4913 if ((pBSSNode
->byCSSGK
== WLAN_11i_CSS_WEP40
) ||
4914 (pBSSNode
->byCSSGK
== WLAN_11i_CSS_WEP104
)) {
4915 byMulticastCipher
= KEY_CTL_WEP
;
4916 } else if (pBSSNode
->byCSSGK
== WLAN_11i_CSS_TKIP
) {
4917 byMulticastCipher
= KEY_CTL_TKIP
;
4918 } else if (pBSSNode
->byCSSGK
== WLAN_11i_CSS_CCMP
) {
4919 byMulticastCipher
= KEY_CTL_CCMP
;
4921 byMulticastCipher
= KEY_CTL_INVALID
;
4924 // check Pairwise Key Cipher
4925 for(i
=0;i
<pBSSNode
->wCSSPKCount
;i
++) {
4926 if ((pBSSNode
->abyCSSPK
[i
] == WLAN_11i_CSS_WEP40
) ||
4927 (pBSSNode
->abyCSSPK
[i
] == WLAN_11i_CSS_WEP104
)) {
4928 // this should not happen as defined 802.11i
4929 byCipherMask
|= 0x01;
4930 } else if (pBSSNode
->abyCSSPK
[i
] == WLAN_11i_CSS_TKIP
) {
4931 byCipherMask
|= 0x02;
4932 } else if (pBSSNode
->abyCSSPK
[i
] == WLAN_11i_CSS_CCMP
) {
4933 byCipherMask
|= 0x04;
4934 } else if (pBSSNode
->abyCSSPK
[i
] == WLAN_11i_CSS_USE_GROUP
) {
4935 // use group key only ignore all others
4937 i
= pBSSNode
->wCSSPKCount
;
4941 } else if ((WLAN_GET_CAP_INFO_PRIVACY(pBSSNode
->wCapInfo
) != 0) &&
4942 (pBSSNode
->bWPAValid
== true) &&
4943 ((EncStatus
== Ndis802_11Encryption3Enabled
) || (EncStatus
== Ndis802_11Encryption2Enabled
))) {
4945 // check Group Key Cipher
4946 if ((pBSSNode
->byGKType
== WPA_WEP40
) ||
4947 (pBSSNode
->byGKType
== WPA_WEP104
)) {
4948 byMulticastCipher
= KEY_CTL_WEP
;
4949 } else if (pBSSNode
->byGKType
== WPA_TKIP
) {
4950 byMulticastCipher
= KEY_CTL_TKIP
;
4951 } else if (pBSSNode
->byGKType
== WPA_AESCCMP
) {
4952 byMulticastCipher
= KEY_CTL_CCMP
;
4954 byMulticastCipher
= KEY_CTL_INVALID
;
4957 // check Pairwise Key Cipher
4958 for(i
=0;i
<pBSSNode
->wPKCount
;i
++) {
4959 if (pBSSNode
->abyPKType
[i
] == WPA_TKIP
) {
4960 byCipherMask
|= 0x02;
4961 } else if (pBSSNode
->abyPKType
[i
] == WPA_AESCCMP
) {
4962 byCipherMask
|= 0x04;
4963 } else if (pBSSNode
->abyPKType
[i
] == WPA_NONE
) {
4964 // use group key only ignore all others
4966 i
= pBSSNode
->wPKCount
;
4971 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%d, %d, %d, %d, EncStatus:%d\n",
4972 byMulticastCipher
, byCipherMask
, pBSSNode
->bWPAValid
, pBSSNode
->bWPA2Valid
, EncStatus
);
4974 // mask our cap. with BSS
4975 if (EncStatus
== Ndis802_11Encryption1Enabled
) {
4977 // For supporting Cisco migration mode, don't care pairwise key cipher
4978 if ((byMulticastCipher
== KEY_CTL_WEP
) &&
4979 (byCipherMask
== 0)) {
4980 *pbyCCSGK
= KEY_CTL_WEP
;
4981 *pbyCCSPK
= KEY_CTL_NONE
;
4987 } else if (EncStatus
== Ndis802_11Encryption2Enabled
) {
4988 if ((byMulticastCipher
== KEY_CTL_TKIP
) &&
4989 (byCipherMask
== 0)) {
4990 *pbyCCSGK
= KEY_CTL_TKIP
;
4991 *pbyCCSPK
= KEY_CTL_NONE
;
4993 } else if ((byMulticastCipher
== KEY_CTL_WEP
) &&
4994 ((byCipherMask
& 0x02) != 0)) {
4995 *pbyCCSGK
= KEY_CTL_WEP
;
4996 *pbyCCSPK
= KEY_CTL_TKIP
;
4998 } else if ((byMulticastCipher
== KEY_CTL_TKIP
) &&
4999 ((byCipherMask
& 0x02) != 0)) {
5000 *pbyCCSGK
= KEY_CTL_TKIP
;
5001 *pbyCCSPK
= KEY_CTL_TKIP
;
5006 } else if (EncStatus
== Ndis802_11Encryption3Enabled
) {
5007 if ((byMulticastCipher
== KEY_CTL_CCMP
) &&
5008 (byCipherMask
== 0)) {
5009 // When CCMP is enable, "Use group cipher suite" shall not be a valid option.
5011 } else if ((byMulticastCipher
== KEY_CTL_WEP
) &&
5012 ((byCipherMask
& 0x04) != 0)) {
5013 *pbyCCSGK
= KEY_CTL_WEP
;
5014 *pbyCCSPK
= KEY_CTL_CCMP
;
5016 } else if ((byMulticastCipher
== KEY_CTL_TKIP
) &&
5017 ((byCipherMask
& 0x04) != 0)) {
5018 *pbyCCSGK
= KEY_CTL_TKIP
;
5019 *pbyCCSPK
= KEY_CTL_CCMP
;
5021 } else if ((byMulticastCipher
== KEY_CTL_CCMP
) &&
5022 ((byCipherMask
& 0x04) != 0)) {
5023 *pbyCCSGK
= KEY_CTL_CCMP
;
5024 *pbyCCSPK
= KEY_CTL_CCMP
;