2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 * Purpose: Handles the 802.11 management functions
29 * nsMgrObjectInitial - Initialize Management Objet data structure
30 * vMgrObjectReset - Reset Management Object data structure
31 * vMgrAssocBeginSta - Start associate function
32 * vMgrReAssocBeginSta - Start reassociate function
33 * vMgrDisassocBeginSta - Start disassociate function
34 * s_vMgrRxAssocRequest - Handle Rcv associate_request
35 * s_vMgrRxAssocResponse - Handle Rcv associate_response
36 * vMrgAuthenBeginSta - Start authentication function
37 * vMgrDeAuthenDeginSta - Start deauthentication function
38 * s_vMgrRxAuthentication - Handle Rcv authentication
39 * s_vMgrRxAuthenSequence_1 - Handle Rcv authentication sequence 1
40 * s_vMgrRxAuthenSequence_2 - Handle Rcv authentication sequence 2
41 * s_vMgrRxAuthenSequence_3 - Handle Rcv authentication sequence 3
42 * s_vMgrRxAuthenSequence_4 - Handle Rcv authentication sequence 4
43 * s_vMgrRxDisassociation - Handle Rcv disassociation
44 * s_vMgrRxBeacon - Handle Rcv Beacon
45 * vMgrCreateOwnIBSS - Create ad_hoc IBSS or AP BSS
46 * vMgrJoinBSSBegin - Join BSS function
47 * s_vMgrSynchBSS - Synch & adopt BSS parameters
48 * s_MgrMakeBeacon - Create Baecon frame
49 * s_MgrMakeProbeResponse - Create Probe Response frame
50 * s_MgrMakeAssocRequest - Create Associate Request frame
51 * s_MgrMakeReAssocRequest - Create ReAssociate Request frame
52 * s_vMgrRxProbeResponse - Handle Rcv probe_response
53 * s_vMrgRxProbeRequest - Handle Rcv probe_request
54 * bMgrPrepareBeaconToSend - Prepare Beacon frame
55 * s_vMgrLogStatus - Log 802.11 Status
56 * vMgrRxManagePacket - Rcv management frame dispatch function
57 * s_vMgrFormatTIM- Assembler TIM field of beacon
58 * vMgrTimerInit- Initial 1-sec and command call back funtions
84 static int msglevel =MSG_LEVEL_INFO;
85 //static int msglevel =MSG_LEVEL_DEBUG;
87 static int ChannelExceedZoneType(struct vnt_private *, u8 byCurrChannel);
89 /* Association/diassociation functions */
90 static struct vnt_tx_mgmt *s_MgrMakeAssocRequest(struct vnt_private *,
91 struct vnt_manager *pMgmt, u8 *pDAddr, u16 wCurrCapInfo,
92 u16 wListenInterval, PWLAN_IE_SSID pCurrSSID,
93 PWLAN_IE_SUPP_RATES pCurrRates, PWLAN_IE_SUPP_RATES pCurrExtSuppRates);
95 static void s_vMgrRxAssocRequest(struct vnt_private *,
96 struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket,
99 static struct vnt_tx_mgmt *s_MgrMakeReAssocRequest(struct vnt_private *,
100 struct vnt_manager *pMgmt, u8 *pDAddr, u16 wCurrCapInfo,
101 u16 wListenInterval, PWLAN_IE_SSID pCurrSSID,
102 PWLAN_IE_SUPP_RATES pCurrRates, PWLAN_IE_SUPP_RATES pCurrExtSuppRates);
104 static void s_vMgrRxAssocResponse(struct vnt_private *,
105 struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket,
108 static void s_vMgrRxDisassociation(struct vnt_private *,
109 struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket);
111 /* Authentication/deauthen functions */
112 static void s_vMgrRxAuthenSequence_1(struct vnt_private *,
113 struct vnt_manager *pMgmt, PWLAN_FR_AUTHEN pFrame);
115 static void s_vMgrRxAuthenSequence_2(struct vnt_private *,
116 struct vnt_manager *pMgmt, PWLAN_FR_AUTHEN pFrame);
118 static void s_vMgrRxAuthenSequence_3(struct vnt_private *,
119 struct vnt_manager *pMgmt, PWLAN_FR_AUTHEN pFrame);
121 static void s_vMgrRxAuthenSequence_4(struct vnt_private *,
122 struct vnt_manager *pMgmt, PWLAN_FR_AUTHEN pFrame);
124 static void s_vMgrRxAuthentication(struct vnt_private *,
125 struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket);
127 static void s_vMgrRxDeauthentication(struct vnt_private *,
128 struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket);
131 * probe request/response functions */
133 static void s_vMgrRxProbeRequest(struct vnt_private *,
134 struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket);
136 static void s_vMgrRxProbeResponse(struct vnt_private *,
137 struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket);
139 /* beacon functions */
140 static void s_vMgrRxBeacon(struct vnt_private *pDevice,
141 struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket,
144 static void s_vMgrFormatTIM(struct vnt_manager *pMgmt, PWLAN_IE_TIM pTIM);
146 static struct vnt_tx_mgmt *s_MgrMakeBeacon(struct vnt_private *pDevice,
147 struct vnt_manager *pMgmt, u16 wCurrCapInfo, u16 wCurrBeaconPeriod,
148 u32 uCurrChannel, u16 wCurrATIMWinodw, PWLAN_IE_SSID pCurrSSID,
149 u8 *pCurrBSSID, PWLAN_IE_SUPP_RATES pCurrSuppRates,
150 PWLAN_IE_SUPP_RATES pCurrExtSuppRates);
152 /* Association response */
153 static struct vnt_tx_mgmt *s_MgrMakeAssocResponse(struct vnt_private *,
154 struct vnt_manager *pMgmt, u16 wCurrCapInfo, u16 wAssocStatus,
155 u16 wAssocAID, u8 *pDstAddr, PWLAN_IE_SUPP_RATES pCurrSuppRates,
156 PWLAN_IE_SUPP_RATES pCurrExtSuppRates);
158 /* ReAssociation response */
159 static struct vnt_tx_mgmt *s_MgrMakeReAssocResponse(struct vnt_private *,
160 struct vnt_manager *pMgmt, u16 wCurrCapInfo, u16 wAssocStatus,
161 u16 wAssocAID, u8 *pDstAddr, PWLAN_IE_SUPP_RATES pCurrSuppRates,
162 PWLAN_IE_SUPP_RATES pCurrExtSuppRates);
165 static struct vnt_tx_mgmt *s_MgrMakeProbeResponse(struct vnt_private *,
166 struct vnt_manager *pMgmt, u16 wCurrCapInfo, u16 wCurrBeaconPeriod,
167 u32 uCurrChannel, u16 wCurrATIMWinodw, u8 *pDstAddr,
168 PWLAN_IE_SSID pCurrSSID, u8 *pCurrBSSID,
169 PWLAN_IE_SUPP_RATES pCurrSuppRates,
170 PWLAN_IE_SUPP_RATES pCurrExtSuppRates, u8 byPHYType);
172 /* received status */
173 static void s_vMgrLogStatus(struct vnt_manager *pMgmt, u16 wStatus);
175 static void s_vMgrSynchBSS(struct vnt_private *, u32 uBSSMode,
176 PKnownBSS pCurr, PCMD_STATUS pStatus);
181 NDIS_802_11_ENCRYPTION_STATUS EncStatus,
186 static void Encyption_Rebuild(struct vnt_private *, PKnownBSS pCurr);
190 * Routine Description:
191 * Allocates and initializes the Management object.
198 void vMgrObjectInit(struct vnt_private *pDevice)
200 struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
203 pMgmt->pbyPSPacketPool = &pMgmt->byPSPacketPool[0];
204 pMgmt->pbyMgmtPacketPool = &pMgmt->byMgmtPacketPool[0];
205 pMgmt->uCurrChannel = pDevice->uChannel;
206 for (ii = 0; ii < WLAN_BSSID_LEN; ii++)
207 pMgmt->abyDesireBSSID[ii] = 0xFF;
209 pMgmt->sAssocInfo.AssocInfo.Length = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION);
210 //memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN +1);
211 pMgmt->byCSSPK = KEY_CTL_NONE;
212 pMgmt->byCSSGK = KEY_CTL_NONE;
213 pMgmt->wIBSSBeaconPeriod = DEFAULT_IBSS_BI;
214 BSSvClearBSSList((void *) pDevice, false);
216 init_timer(&pDevice->sTimerTxData);
217 pDevice->sTimerTxData.data = (unsigned long)pDevice;
218 pDevice->sTimerTxData.function = (TimerFunction)BSSvSecondTxData;
219 pDevice->sTimerTxData.expires = RUN_AT(10*HZ); //10s callback
220 pDevice->fTxDataInSleep = false;
221 pDevice->IsTxDataTrigger = false;
222 pDevice->nTxDataTimeCout = 0;
224 pDevice->cbFreeCmdQueue = CMD_Q_SIZE;
225 pDevice->uCmdDequeueIdx = 0;
226 pDevice->uCmdEnqueueIdx = 0;
227 pDevice->eCommandState = WLAN_CMD_IDLE;
228 pDevice->bCmdRunning = false;
229 pDevice->bCmdClear = false;
236 * Routine Description:
237 * Start the station association procedure. Namely, send an
238 * association request frame to the AP.
245 void vMgrAssocBeginSta(struct vnt_private *pDevice,
246 struct vnt_manager *pMgmt, PCMD_STATUS pStatus)
248 struct vnt_tx_mgmt *pTxPacket;
250 pMgmt->wCurrCapInfo = 0;
251 pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_ESS(1);
252 if (pDevice->bEncryptionEnable) {
253 pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_PRIVACY(1);
255 // always allow receive short preamble
256 //if (pDevice->byPreambleType == 1) {
257 // pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
259 pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
260 if (pMgmt->wListenInterval == 0)
261 pMgmt->wListenInterval = 1; // at least one.
263 // ERP Phy (802.11g) should support short preamble.
264 if (pMgmt->eCurrentPHYMode == PHY_TYPE_11G) {
265 pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
266 if (pDevice->bShortSlotTime == true)
267 pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTSLOTTIME(1);
269 } else if (pMgmt->eCurrentPHYMode == PHY_TYPE_11B) {
270 if (pDevice->byPreambleType == 1) {
271 pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
274 if (pMgmt->b11hEnable == true)
275 pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SPECTRUMMNG(1);
277 // build an assocreq frame and send it
278 pTxPacket = s_MgrMakeAssocRequest
284 pMgmt->wListenInterval,
285 (PWLAN_IE_SSID)pMgmt->abyCurrSSID,
286 (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
287 (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates
290 if (pTxPacket != NULL ){
292 *pStatus = csMgmt_xmit(pDevice, pTxPacket);
293 if (*pStatus == CMD_STATUS_PENDING) {
294 pMgmt->eCurrState = WMAC_STATE_ASSOCPENDING;
295 *pStatus = CMD_STATUS_SUCCESS;
299 *pStatus = CMD_STATUS_RESOURCES;
306 * Routine Description:
307 * Start the station re-association procedure.
314 void vMgrReAssocBeginSta(struct vnt_private *pDevice,
315 struct vnt_manager *pMgmt, PCMD_STATUS pStatus)
317 struct vnt_tx_mgmt *pTxPacket;
319 pMgmt->wCurrCapInfo = 0;
320 pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_ESS(1);
321 if (pDevice->bEncryptionEnable) {
322 pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_PRIVACY(1);
325 //if (pDevice->byPreambleType == 1) {
326 // pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
328 pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
330 if (pMgmt->wListenInterval == 0)
331 pMgmt->wListenInterval = 1; // at least one.
333 // ERP Phy (802.11g) should support short preamble.
334 if (pMgmt->eCurrentPHYMode == PHY_TYPE_11G) {
335 pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
336 if (pDevice->bShortSlotTime == true)
337 pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTSLOTTIME(1);
339 } else if (pMgmt->eCurrentPHYMode == PHY_TYPE_11B) {
340 if (pDevice->byPreambleType == 1) {
341 pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
344 if (pMgmt->b11hEnable == true)
345 pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SPECTRUMMNG(1);
347 pTxPacket = s_MgrMakeReAssocRequest
353 pMgmt->wListenInterval,
354 (PWLAN_IE_SSID)pMgmt->abyCurrSSID,
355 (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
356 (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates
359 if (pTxPacket != NULL ){
361 *pStatus = csMgmt_xmit(pDevice, pTxPacket);
362 if (*pStatus != CMD_STATUS_PENDING) {
363 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Reassociation tx failed.\n");
366 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Reassociation tx sending.\n");
375 * Routine Description:
376 * Send an dis-association request frame to the AP.
383 void vMgrDisassocBeginSta(struct vnt_private *pDevice,
384 struct vnt_manager *pMgmt, u8 *abyDestAddress, u16 wReason,
387 struct vnt_tx_mgmt *pTxPacket = NULL;
388 WLAN_FR_DISASSOC sFrame;
390 pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool;
391 memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt)
392 + WLAN_DISASSOC_FR_MAXLEN);
393 pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket
394 + sizeof(struct vnt_tx_mgmt));
396 // Setup the sFrame structure
397 sFrame.pBuf = (u8 *)pTxPacket->p80211Header;
398 sFrame.len = WLAN_DISASSOC_FR_MAXLEN;
400 // format fixed field frame structure
401 vMgrEncodeDisassociation(&sFrame);
404 sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
406 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
407 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_DISASSOC)
410 memcpy( sFrame.pHdr->sA3.abyAddr1, abyDestAddress, WLAN_ADDR_LEN);
411 memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
412 memcpy( sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
415 *(sFrame.pwReason) = cpu_to_le16(wReason);
416 pTxPacket->cbMPDULen = sFrame.len;
417 pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
420 *pStatus = csMgmt_xmit(pDevice, pTxPacket);
421 if (*pStatus == CMD_STATUS_PENDING) {
422 pMgmt->eCurrState = WMAC_STATE_IDLE;
423 *pStatus = CMD_STATUS_SUCCESS;
431 * Routine Description:(AP function)
432 * Handle incoming station association request frames.
439 static void s_vMgrRxAssocRequest(struct vnt_private *pDevice,
440 struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket,
443 WLAN_FR_ASSOCREQ sFrame;
445 struct vnt_tx_mgmt *pTxPacket;
446 u16 wAssocStatus = 0;
448 u32 uRateLen = WLAN_RATES_MAXLEN;
449 u8 abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
450 u8 abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
452 if (pMgmt->eCurrMode != WMAC_MODE_ESS_AP)
454 // node index not found
458 //check if node is authenticated
460 memset(&sFrame, 0, sizeof(WLAN_FR_ASSOCREQ));
461 memset(abyCurrSuppRates, 0, WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1);
462 memset(abyCurrExtSuppRates, 0, WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1);
463 sFrame.len = pRxPacket->cbMPDULen;
464 sFrame.pBuf = (u8 *)pRxPacket->p80211Header;
466 vMgrDecodeAssocRequest(&sFrame);
468 if (pMgmt->sNodeDBTable[uNodeIndex].eNodeState >= NODE_AUTH) {
469 pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_ASSOC;
470 pMgmt->sNodeDBTable[uNodeIndex].wCapInfo = cpu_to_le16(*sFrame.pwCapInfo);
471 pMgmt->sNodeDBTable[uNodeIndex].wListenInterval = cpu_to_le16(*sFrame.pwListenInterval);
472 pMgmt->sNodeDBTable[uNodeIndex].bPSEnable =
473 WLAN_GET_FC_PWRMGT(sFrame.pHdr->sA3.wFrameCtl) ? true : false;
474 // Todo: check sta basic rate, if ap can't support, set status code
475 if (pDevice->byBBType == BB_TYPE_11B) {
476 uRateLen = WLAN_RATES_MAXLEN_11B;
478 abyCurrSuppRates[0] = WLAN_EID_SUPP_RATES;
479 abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pSuppRates,
480 (PWLAN_IE_SUPP_RATES)abyCurrSuppRates,
482 abyCurrExtSuppRates[0] = WLAN_EID_EXTSUPP_RATES;
483 if (pDevice->byBBType == BB_TYPE_11G) {
484 abyCurrExtSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pExtSuppRates,
485 (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRates,
488 abyCurrExtSuppRates[1] = 0;
491 RATEvParseMaxRate((void *)pDevice,
492 (PWLAN_IE_SUPP_RATES)abyCurrSuppRates,
493 (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRates,
494 false, // do not change our basic rate
495 &(pMgmt->sNodeDBTable[uNodeIndex].wMaxBasicRate),
496 &(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate),
497 &(pMgmt->sNodeDBTable[uNodeIndex].wSuppRate),
498 &(pMgmt->sNodeDBTable[uNodeIndex].byTopCCKBasicRate),
499 &(pMgmt->sNodeDBTable[uNodeIndex].byTopOFDMBasicRate)
503 pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate =
504 pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate;
505 // Todo: check sta preamble, if ap can't support, set status code
506 pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble =
507 WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame.pwCapInfo);
508 pMgmt->sNodeDBTable[uNodeIndex].bShortSlotTime =
509 WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame.pwCapInfo);
510 pMgmt->sNodeDBTable[uNodeIndex].wAID = (u16)uNodeIndex;
511 wAssocStatus = WLAN_MGMT_STATUS_SUCCESS;
512 wAssocAID = (u16)uNodeIndex;
513 // check if ERP support
514 if(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate > RATE_11M)
515 pMgmt->sNodeDBTable[uNodeIndex].bERPExist = true;
517 if (pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate <= RATE_11M) {
519 pDevice->bProtectMode = true;
520 pDevice->bNonERPPresent = true;
522 if (pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble == false) {
523 pDevice->bBarkerPreambleMd = true;
526 DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "Associate AID= %d \n", wAssocAID);
527 DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "MAC=%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X \n",
528 sFrame.pHdr->sA3.abyAddr2[0],
529 sFrame.pHdr->sA3.abyAddr2[1],
530 sFrame.pHdr->sA3.abyAddr2[2],
531 sFrame.pHdr->sA3.abyAddr2[3],
532 sFrame.pHdr->sA3.abyAddr2[4],
533 sFrame.pHdr->sA3.abyAddr2[5]
535 DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "Max Support rate = %d \n",
536 pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate);
539 // assoc response reply..
540 pTxPacket = s_MgrMakeAssocResponse
547 sFrame.pHdr->sA3.abyAddr2,
548 (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
549 (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates
551 if (pTxPacket != NULL ){
553 if (pDevice->bEnableHostapd) {
557 Status = csMgmt_xmit(pDevice, pTxPacket);
558 if (Status != CMD_STATUS_PENDING) {
559 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Assoc response tx failed\n");
562 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Assoc response tx sending..\n");
572 * Description:(AP function)
573 * Handle incoming station re-association request frames.
577 * pMgmt - Management Object structure
578 * pRxPacket - Received Packet
582 * Return Value: None.
586 static void s_vMgrRxReAssocRequest(struct vnt_private *pDevice,
587 struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket,
590 WLAN_FR_REASSOCREQ sFrame;
592 struct vnt_tx_mgmt *pTxPacket;
593 u16 wAssocStatus = 0;
595 u32 uRateLen = WLAN_RATES_MAXLEN;
596 u8 abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
597 u8 abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
599 if (pMgmt->eCurrMode != WMAC_MODE_ESS_AP)
601 // node index not found
604 //check if node is authenticated
606 memset(&sFrame, 0, sizeof(WLAN_FR_REASSOCREQ));
607 sFrame.len = pRxPacket->cbMPDULen;
608 sFrame.pBuf = (u8 *)pRxPacket->p80211Header;
609 vMgrDecodeReassocRequest(&sFrame);
611 if (pMgmt->sNodeDBTable[uNodeIndex].eNodeState >= NODE_AUTH) {
612 pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_ASSOC;
613 pMgmt->sNodeDBTable[uNodeIndex].wCapInfo = cpu_to_le16(*sFrame.pwCapInfo);
614 pMgmt->sNodeDBTable[uNodeIndex].wListenInterval = cpu_to_le16(*sFrame.pwListenInterval);
615 pMgmt->sNodeDBTable[uNodeIndex].bPSEnable =
616 WLAN_GET_FC_PWRMGT(sFrame.pHdr->sA3.wFrameCtl) ? true : false;
617 // Todo: check sta basic rate, if ap can't support, set status code
619 if (pDevice->byBBType == BB_TYPE_11B) {
620 uRateLen = WLAN_RATES_MAXLEN_11B;
623 abyCurrSuppRates[0] = WLAN_EID_SUPP_RATES;
624 abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pSuppRates,
625 (PWLAN_IE_SUPP_RATES)abyCurrSuppRates,
627 abyCurrExtSuppRates[0] = WLAN_EID_EXTSUPP_RATES;
628 if (pDevice->byBBType == BB_TYPE_11G) {
629 abyCurrExtSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pExtSuppRates,
630 (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRates,
633 abyCurrExtSuppRates[1] = 0;
636 RATEvParseMaxRate((void *)pDevice,
637 (PWLAN_IE_SUPP_RATES)abyCurrSuppRates,
638 (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRates,
639 false, // do not change our basic rate
640 &(pMgmt->sNodeDBTable[uNodeIndex].wMaxBasicRate),
641 &(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate),
642 &(pMgmt->sNodeDBTable[uNodeIndex].wSuppRate),
643 &(pMgmt->sNodeDBTable[uNodeIndex].byTopCCKBasicRate),
644 &(pMgmt->sNodeDBTable[uNodeIndex].byTopOFDMBasicRate)
648 pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate =
649 pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate;
650 // Todo: check sta preamble, if ap can't support, set status code
651 pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble =
652 WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame.pwCapInfo);
653 pMgmt->sNodeDBTable[uNodeIndex].bShortSlotTime =
654 WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame.pwCapInfo);
655 pMgmt->sNodeDBTable[uNodeIndex].wAID = (u16)uNodeIndex;
656 wAssocStatus = WLAN_MGMT_STATUS_SUCCESS;
657 wAssocAID = (u16)uNodeIndex;
660 if(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate > RATE_11M)
661 pMgmt->sNodeDBTable[uNodeIndex].bERPExist = true;
663 if (pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate <= RATE_11M) {
665 pDevice->bProtectMode = true;
666 pDevice->bNonERPPresent = true;
668 if (pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble == false) {
669 pDevice->bBarkerPreambleMd = true;
672 DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "Rx ReAssociate AID= %d \n", wAssocAID);
673 DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "MAC=%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X \n",
674 sFrame.pHdr->sA3.abyAddr2[0],
675 sFrame.pHdr->sA3.abyAddr2[1],
676 sFrame.pHdr->sA3.abyAddr2[2],
677 sFrame.pHdr->sA3.abyAddr2[3],
678 sFrame.pHdr->sA3.abyAddr2[4],
679 sFrame.pHdr->sA3.abyAddr2[5]
681 DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "Max Support rate = %d \n",
682 pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate);
686 // assoc response reply..
687 pTxPacket = s_MgrMakeReAssocResponse
694 sFrame.pHdr->sA3.abyAddr2,
695 (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
696 (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates
699 if (pTxPacket != NULL ){
701 if (pDevice->bEnableHostapd) {
704 Status = csMgmt_xmit(pDevice, pTxPacket);
705 if (Status != CMD_STATUS_PENDING) {
706 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:ReAssoc response tx failed\n");
709 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:ReAssoc response tx sending..\n");
717 * Routine Description:
718 * Handle incoming association response frames.
725 static void s_vMgrRxAssocResponse(struct vnt_private *pDevice,
726 struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket,
729 WLAN_FR_ASSOCRESP sFrame;
730 PWLAN_IE_SSID pItemSSID;
733 if (pMgmt->eCurrState == WMAC_STATE_ASSOCPENDING ||
734 pMgmt->eCurrState == WMAC_STATE_ASSOC) {
736 sFrame.len = pRxPacket->cbMPDULen;
737 sFrame.pBuf = (u8 *)pRxPacket->p80211Header;
739 vMgrDecodeAssocResponse(&sFrame);
740 if ((sFrame.pwCapInfo == NULL)
741 || (sFrame.pwStatus == NULL)
742 || (sFrame.pwAid == NULL)
743 || (sFrame.pSuppRates == NULL)) {
747 pMgmt->sAssocInfo.AssocInfo.ResponseFixedIEs.Capabilities = *(sFrame.pwCapInfo);
748 pMgmt->sAssocInfo.AssocInfo.ResponseFixedIEs.StatusCode = *(sFrame.pwStatus);
749 pMgmt->sAssocInfo.AssocInfo.ResponseFixedIEs.AssociationId = *(sFrame.pwAid);
750 pMgmt->sAssocInfo.AssocInfo.AvailableResponseFixedIEs |= 0x07;
752 pMgmt->sAssocInfo.AssocInfo.ResponseIELength = sFrame.len - 24 - 6;
753 pMgmt->sAssocInfo.AssocInfo.OffsetResponseIEs = pMgmt->sAssocInfo.AssocInfo.OffsetRequestIEs + pMgmt->sAssocInfo.AssocInfo.RequestIELength;
754 pbyIEs = pMgmt->sAssocInfo.abyIEs;
755 pbyIEs += pMgmt->sAssocInfo.AssocInfo.RequestIELength;
756 memcpy(pbyIEs, (sFrame.pBuf + 24 +6), pMgmt->sAssocInfo.AssocInfo.ResponseIELength);
758 // save values and set current BSS state
759 if (cpu_to_le16((*(sFrame.pwStatus))) == WLAN_MGMT_STATUS_SUCCESS ){
761 pMgmt->wCurrAID = cpu_to_le16((*(sFrame.pwAid)));
762 if ( (pMgmt->wCurrAID >> 14) != (BIT0 | BIT1) )
764 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "AID from AP, has two msb clear.\n");
766 DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "Association Successful, AID=%d.\n", pMgmt->wCurrAID & ~(BIT14|BIT15));
767 pMgmt->eCurrState = WMAC_STATE_ASSOC;
768 BSSvUpdateAPNode((void *) pDevice,
771 sFrame.pExtSuppRates);
772 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
773 DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "Link with AP(SSID): %s\n", pItemSSID->abySSID);
774 pDevice->bLinkPass = true;
775 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER);
777 //if(pDevice->bWPASuppWextEnabled == true)
781 union iwreq_data wrqu;
786 len = pMgmt->sAssocInfo.AssocInfo.RequestIELength;
788 memcpy(buf, pMgmt->sAssocInfo.abyIEs, len);
789 memset(&wrqu, 0, sizeof (wrqu));
790 wrqu.data.length = len;
791 we_event = IWEVASSOCREQIE;
792 PRINT_K("wireless_send_event--->IWEVASSOCREQIE\n");
793 wireless_send_event(pDevice->dev, we_event, &wrqu, buf);
797 len = pMgmt->sAssocInfo.AssocInfo.ResponseIELength;
800 memcpy(buf, pbyIEs, len);
801 memset(&wrqu, 0, sizeof (wrqu));
802 wrqu.data.length = len;
803 we_event = IWEVASSOCRESPIE;
804 PRINT_K("wireless_send_event--->IWEVASSOCRESPIE\n");
805 wireless_send_event(pDevice->dev, we_event, &wrqu, buf);
808 memset(&wrqu, 0, sizeof (wrqu));
809 memcpy(wrqu.ap_addr.sa_data, &pMgmt->abyCurrBSSID[0], ETH_ALEN);
810 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
811 PRINT_K("wireless_send_event--->SIOCGIWAP(associated)\n");
812 wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
819 pMgmt->eCurrState = WMAC_STATE_IDLE;
822 // jump back to the auth state and indicate the error
823 pMgmt->eCurrState = WMAC_STATE_AUTH;
825 s_vMgrLogStatus(pMgmt,cpu_to_le16((*(sFrame.pwStatus))));
830 //need clear flags related to Networkmanager
831 pDevice->bwextstep0 = false;
832 pDevice->bwextstep1 = false;
833 pDevice->bwextstep2 = false;
834 pDevice->bwextstep3 = false;
835 pDevice->bWPASuppWextEnabled = false;
837 if (pMgmt->eCurrState == WMAC_STATE_ASSOC)
838 schedule_delayed_work(&pDevice->run_command_work, 0);
845 * Routine Description:
846 * Start the station authentication procedure. Namely, send an
847 * authentication frame to the AP.
854 void vMgrAuthenBeginSta(struct vnt_private *pDevice,
855 struct vnt_manager *pMgmt, PCMD_STATUS pStatus)
857 WLAN_FR_AUTHEN sFrame;
858 struct vnt_tx_mgmt *pTxPacket =
859 (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool;
861 memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt)
862 + WLAN_AUTHEN_FR_MAXLEN);
863 pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket
864 + sizeof(struct vnt_tx_mgmt));
865 sFrame.pBuf = (u8 *)pTxPacket->p80211Header;
866 sFrame.len = WLAN_AUTHEN_FR_MAXLEN;
867 vMgrEncodeAuthen(&sFrame);
869 sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
871 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
872 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN)
874 memcpy( sFrame.pHdr->sA3.abyAddr1, pMgmt->abyCurrBSSID, WLAN_ADDR_LEN);
875 memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
876 memcpy( sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
877 if (pMgmt->bShareKeyAlgorithm)
878 *(sFrame.pwAuthAlgorithm) = cpu_to_le16(WLAN_AUTH_ALG_SHAREDKEY);
880 *(sFrame.pwAuthAlgorithm) = cpu_to_le16(WLAN_AUTH_ALG_OPENSYSTEM);
882 *(sFrame.pwAuthSequence) = cpu_to_le16(1);
883 /* Adjust the length fields */
884 pTxPacket->cbMPDULen = sFrame.len;
885 pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
887 *pStatus = csMgmt_xmit(pDevice, pTxPacket);
888 if (*pStatus == CMD_STATUS_PENDING){
889 pMgmt->eCurrState = WMAC_STATE_AUTHPENDING;
890 *pStatus = CMD_STATUS_SUCCESS;
898 * Routine Description:
899 * Start the station(AP) deauthentication procedure. Namely, send an
900 * deauthentication frame to the AP or Sta.
907 void vMgrDeAuthenBeginSta(struct vnt_private *pDevice,
908 struct vnt_manager *pMgmt, u8 *abyDestAddress, u16 wReason,
911 WLAN_FR_DEAUTHEN sFrame;
912 struct vnt_tx_mgmt *pTxPacket =
913 (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool;
915 memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt)
916 + WLAN_DEAUTHEN_FR_MAXLEN);
917 pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket
918 + sizeof(struct vnt_tx_mgmt));
919 sFrame.pBuf = (u8 *)pTxPacket->p80211Header;
920 sFrame.len = WLAN_DEAUTHEN_FR_MAXLEN;
921 vMgrEncodeDeauthen(&sFrame);
923 sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
925 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
926 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_DEAUTHEN)
929 memcpy( sFrame.pHdr->sA3.abyAddr1, abyDestAddress, WLAN_ADDR_LEN);
930 memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
931 memcpy( sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
933 *(sFrame.pwReason) = cpu_to_le16(wReason); // deauthen. bcs left BSS
934 /* Adjust the length fields */
935 pTxPacket->cbMPDULen = sFrame.len;
936 pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
938 *pStatus = csMgmt_xmit(pDevice, pTxPacket);
939 if (*pStatus == CMD_STATUS_PENDING){
940 *pStatus = CMD_STATUS_SUCCESS;
948 * Routine Description:
949 * Handle incoming authentication frames.
956 static void s_vMgrRxAuthentication(struct vnt_private *pDevice,
957 struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket)
959 WLAN_FR_AUTHEN sFrame;
961 // we better be an AP or a STA in AUTHPENDING otherwise ignore
962 if (!(pMgmt->eCurrMode == WMAC_MODE_ESS_AP ||
963 pMgmt->eCurrState == WMAC_STATE_AUTHPENDING)) {
968 sFrame.len = pRxPacket->cbMPDULen;
969 sFrame.pBuf = (u8 *)pRxPacket->p80211Header;
970 vMgrDecodeAuthen(&sFrame);
971 switch (cpu_to_le16((*(sFrame.pwAuthSequence )))){
974 s_vMgrRxAuthenSequence_1(pDevice,pMgmt, &sFrame);
977 s_vMgrRxAuthenSequence_2(pDevice, pMgmt, &sFrame);
981 s_vMgrRxAuthenSequence_3(pDevice, pMgmt, &sFrame);
984 s_vMgrRxAuthenSequence_4(pDevice, pMgmt, &sFrame);
987 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Auth Sequence error, seq = %d\n",
988 cpu_to_le16((*(sFrame.pwAuthSequence))));
996 * Routine Description:
997 * Handles incoming authen frames with sequence 1. Currently
998 * assumes we're an AP. So far, no one appears to use authentication
1006 static void s_vMgrRxAuthenSequence_1(struct vnt_private *pDevice,
1007 struct vnt_manager *pMgmt, PWLAN_FR_AUTHEN pFrame)
1009 struct vnt_tx_mgmt *pTxPacket = NULL;
1011 WLAN_FR_AUTHEN sFrame;
1012 PSKeyItem pTransmitKey;
1014 /* Insert a Node entry */
1015 if (!BSSbIsSTAInNodeDB(pDevice, pFrame->pHdr->sA3.abyAddr2,
1017 BSSvCreateOneNode(pDevice, &uNodeIndex);
1018 memcpy(pMgmt->sNodeDBTable[uNodeIndex].abyMACAddr,
1019 pFrame->pHdr->sA3.abyAddr2, WLAN_ADDR_LEN);
1022 if (pMgmt->bShareKeyAlgorithm) {
1023 pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_KNOWN;
1024 pMgmt->sNodeDBTable[uNodeIndex].byAuthSequence = 1;
1027 pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_AUTH;
1031 pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool;
1032 memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt)
1033 + WLAN_AUTHEN_FR_MAXLEN);
1034 pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket
1035 + sizeof(struct vnt_tx_mgmt));
1036 sFrame.pBuf = (u8 *)pTxPacket->p80211Header;
1037 sFrame.len = WLAN_AUTHEN_FR_MAXLEN;
1038 // format buffer structure
1039 vMgrEncodeAuthen(&sFrame);
1041 sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
1043 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
1044 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN)|
1045 WLAN_SET_FC_ISWEP(0)
1047 memcpy( sFrame.pHdr->sA3.abyAddr1, pFrame->pHdr->sA3.abyAddr2, WLAN_ADDR_LEN);
1048 memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
1049 memcpy( sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
1050 *(sFrame.pwAuthAlgorithm) = *(pFrame->pwAuthAlgorithm);
1051 *(sFrame.pwAuthSequence) = cpu_to_le16(2);
1053 if (cpu_to_le16(*(pFrame->pwAuthAlgorithm)) == WLAN_AUTH_ALG_SHAREDKEY) {
1054 if (pMgmt->bShareKeyAlgorithm)
1055 *(sFrame.pwStatus) = cpu_to_le16(WLAN_MGMT_STATUS_SUCCESS);
1057 *(sFrame.pwStatus) = cpu_to_le16(WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG);
1060 if (pMgmt->bShareKeyAlgorithm)
1061 *(sFrame.pwStatus) = cpu_to_le16(WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG);
1063 *(sFrame.pwStatus) = cpu_to_le16(WLAN_MGMT_STATUS_SUCCESS);
1066 if (pMgmt->bShareKeyAlgorithm &&
1067 (cpu_to_le16(*(sFrame.pwStatus)) == WLAN_MGMT_STATUS_SUCCESS)) {
1069 sFrame.pChallenge = (PWLAN_IE_CHALLENGE)(sFrame.pBuf + sFrame.len);
1070 sFrame.len += WLAN_CHALLENGE_IE_LEN;
1071 sFrame.pChallenge->byElementID = WLAN_EID_CHALLENGE;
1072 sFrame.pChallenge->len = WLAN_CHALLENGE_LEN;
1073 memset(pMgmt->abyChallenge, 0, WLAN_CHALLENGE_LEN);
1075 if(KeybGetTransmitKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, GROUP_KEY, &pTransmitKey) == true) {
1076 rc4_init(&pDevice->SBox, pDevice->abyPRNG, pTransmitKey->uKeyLength+3);
1077 rc4_encrypt(&pDevice->SBox, pMgmt->abyChallenge, pMgmt->abyChallenge, WLAN_CHALLENGE_LEN);
1079 memcpy(sFrame.pChallenge->abyChallenge, pMgmt->abyChallenge , WLAN_CHALLENGE_LEN);
1082 /* Adjust the length fields */
1083 pTxPacket->cbMPDULen = sFrame.len;
1084 pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
1086 if (pDevice->bEnableHostapd) {
1089 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Authreq_reply sequence_1 tx.. \n");
1090 if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) {
1091 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Authreq_reply sequence_1 tx failed.\n");
1098 * Routine Description:
1099 * Handles incoming auth frames with sequence number 2. Currently
1100 * assumes we're a station.
1108 static void s_vMgrRxAuthenSequence_2(struct vnt_private *pDevice,
1109 struct vnt_manager *pMgmt, PWLAN_FR_AUTHEN pFrame)
1111 WLAN_FR_AUTHEN sFrame;
1112 struct vnt_tx_mgmt *pTxPacket = NULL;
1114 switch (cpu_to_le16((*(pFrame->pwAuthAlgorithm))))
1116 case WLAN_AUTH_ALG_OPENSYSTEM:
1117 if ( cpu_to_le16((*(pFrame->pwStatus))) == WLAN_MGMT_STATUS_SUCCESS ){
1118 DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "802.11 Authen (OPEN) Successful.\n");
1119 pMgmt->eCurrState = WMAC_STATE_AUTH;
1120 schedule_delayed_work(&pDevice->run_command_work, 0);
1123 DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "802.11 Authen (OPEN) Failed.\n");
1124 s_vMgrLogStatus(pMgmt, cpu_to_le16((*(pFrame->pwStatus))));
1125 pMgmt->eCurrState = WMAC_STATE_IDLE;
1127 if (pDevice->eCommandState == WLAN_AUTHENTICATE_WAIT) {
1128 /* spin_unlock_irq(&pDevice->lock);
1129 vCommandTimerWait((void *) pDevice, 0);
1130 spin_lock_irq(&pDevice->lock); */
1134 case WLAN_AUTH_ALG_SHAREDKEY:
1136 if (cpu_to_le16((*(pFrame->pwStatus))) == WLAN_MGMT_STATUS_SUCCESS) {
1137 pTxPacket = (struct vnt_tx_mgmt *)
1138 pMgmt->pbyMgmtPacketPool;
1139 memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt)
1140 + WLAN_AUTHEN_FR_MAXLEN);
1141 pTxPacket->p80211Header
1142 = (PUWLAN_80211HDR)((u8 *)pTxPacket
1143 + sizeof(struct vnt_tx_mgmt));
1144 sFrame.pBuf = (u8 *)pTxPacket->p80211Header;
1145 sFrame.len = WLAN_AUTHEN_FR_MAXLEN;
1146 // format buffer structure
1147 vMgrEncodeAuthen(&sFrame);
1149 sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
1151 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
1152 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN)|
1153 WLAN_SET_FC_ISWEP(1)
1155 memcpy( sFrame.pHdr->sA3.abyAddr1, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
1156 memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
1157 memcpy( sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
1158 *(sFrame.pwAuthAlgorithm) = *(pFrame->pwAuthAlgorithm);
1159 *(sFrame.pwAuthSequence) = cpu_to_le16(3);
1160 *(sFrame.pwStatus) = cpu_to_le16(WLAN_MGMT_STATUS_SUCCESS);
1161 sFrame.pChallenge = (PWLAN_IE_CHALLENGE)(sFrame.pBuf + sFrame.len);
1162 sFrame.len += WLAN_CHALLENGE_IE_LEN;
1163 sFrame.pChallenge->byElementID = WLAN_EID_CHALLENGE;
1164 sFrame.pChallenge->len = WLAN_CHALLENGE_LEN;
1165 memcpy( sFrame.pChallenge->abyChallenge, pFrame->pChallenge->abyChallenge, WLAN_CHALLENGE_LEN);
1166 // Adjust the length fields
1167 pTxPacket->cbMPDULen = sFrame.len;
1168 pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
1170 if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) {
1171 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Auth_reply sequence_2 tx failed.\n");
1173 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Auth_reply sequence_2 tx ...\n");
1176 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:rx Auth_reply sequence_2 status error ...\n");
1177 if ( pDevice->eCommandState == WLAN_AUTHENTICATE_WAIT ) {
1178 /* spin_unlock_irq(&pDevice->lock);
1179 vCommandTimerWait((void *) pDevice, 0);
1180 spin_lock_irq(&pDevice->lock); */
1182 s_vMgrLogStatus(pMgmt, cpu_to_le16((*(pFrame->pwStatus))));
1186 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt: rx auth.seq = 2 unknown AuthAlgorithm=%d\n", cpu_to_le16((*(pFrame->pwAuthAlgorithm))));
1194 * Routine Description:
1195 * Handles incoming authen frames with sequence 3. Currently
1196 * assumes we're an AP. This function assumes the frame has
1197 * already been successfully decrypted.
1205 static void s_vMgrRxAuthenSequence_3(struct vnt_private *pDevice,
1206 struct vnt_manager *pMgmt, PWLAN_FR_AUTHEN pFrame)
1208 struct vnt_tx_mgmt *pTxPacket = NULL;
1209 u32 uStatusCode = 0 ;
1211 WLAN_FR_AUTHEN sFrame;
1213 if (!WLAN_GET_FC_ISWEP(pFrame->pHdr->sA3.wFrameCtl)) {
1214 uStatusCode = WLAN_MGMT_STATUS_CHALLENGE_FAIL;
1217 if (BSSbIsSTAInNodeDB(pDevice, pFrame->pHdr->sA3.abyAddr2, &uNodeIndex)) {
1218 if (pMgmt->sNodeDBTable[uNodeIndex].byAuthSequence != 1) {
1219 uStatusCode = WLAN_MGMT_STATUS_RX_AUTH_NOSEQ;
1222 if (memcmp(pMgmt->abyChallenge, pFrame->pChallenge->abyChallenge, WLAN_CHALLENGE_LEN) != 0) {
1223 uStatusCode = WLAN_MGMT_STATUS_CHALLENGE_FAIL;
1228 uStatusCode = WLAN_MGMT_STATUS_UNSPEC_FAILURE;
1233 pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_AUTH;
1234 pMgmt->sNodeDBTable[uNodeIndex].byAuthSequence = 0;
1236 uStatusCode = WLAN_MGMT_STATUS_SUCCESS;
1237 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Challenge text check ok..\n");
1241 pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool;
1242 memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt)
1243 + WLAN_AUTHEN_FR_MAXLEN);
1244 pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket
1245 + sizeof(struct vnt_tx_mgmt));
1246 sFrame.pBuf = (u8 *)pTxPacket->p80211Header;
1247 sFrame.len = WLAN_AUTHEN_FR_MAXLEN;
1248 // format buffer structure
1249 vMgrEncodeAuthen(&sFrame);
1251 sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
1253 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
1254 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN)|
1255 WLAN_SET_FC_ISWEP(0)
1257 memcpy( sFrame.pHdr->sA3.abyAddr1, pFrame->pHdr->sA3.abyAddr2, WLAN_ADDR_LEN);
1258 memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
1259 memcpy( sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
1260 *(sFrame.pwAuthAlgorithm) = *(pFrame->pwAuthAlgorithm);
1261 *(sFrame.pwAuthSequence) = cpu_to_le16(4);
1262 *(sFrame.pwStatus) = cpu_to_le16(uStatusCode);
1264 /* Adjust the length fields */
1265 pTxPacket->cbMPDULen = sFrame.len;
1266 pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
1268 if (pDevice->bEnableHostapd) {
1271 if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) {
1272 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Authreq_reply sequence_4 tx failed.\n");
1280 * Routine Description:
1281 * Handles incoming authen frames with sequence 4
1288 static void s_vMgrRxAuthenSequence_4(struct vnt_private *pDevice,
1289 struct vnt_manager *pMgmt, PWLAN_FR_AUTHEN pFrame)
1292 if ( cpu_to_le16((*(pFrame->pwStatus))) == WLAN_MGMT_STATUS_SUCCESS ){
1293 DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "802.11 Authen (SHAREDKEY) Successful.\n");
1294 pMgmt->eCurrState = WMAC_STATE_AUTH;
1295 schedule_delayed_work(&pDevice->run_command_work, 0);
1298 DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "802.11 Authen (SHAREDKEY) Failed.\n");
1299 s_vMgrLogStatus(pMgmt, cpu_to_le16((*(pFrame->pwStatus))) );
1300 pMgmt->eCurrState = WMAC_STATE_IDLE;
1303 if ( pDevice->eCommandState == WLAN_AUTHENTICATE_WAIT ) {
1304 /* spin_unlock_irq(&pDevice->lock);
1305 vCommandTimerWait((void *) pDevice, 0);
1306 spin_lock_irq(&pDevice->lock); */
1312 * Routine Description:
1313 * Handles incoming disassociation frames
1321 static void s_vMgrRxDisassociation(struct vnt_private *pDevice,
1322 struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket)
1324 WLAN_FR_DISASSOC sFrame;
1326 CMD_STATUS CmdStatus;
1328 if ( pMgmt->eCurrMode == WMAC_MODE_ESS_AP ){
1329 // if is acting an AP..
1330 // a STA is leaving this BSS..
1331 sFrame.len = pRxPacket->cbMPDULen;
1332 sFrame.pBuf = (u8 *)pRxPacket->p80211Header;
1333 if (BSSbIsSTAInNodeDB(pDevice, pRxPacket->p80211Header->sA3.abyAddr2, &uNodeIndex)) {
1334 BSSvRemoveOneNode(pDevice, uNodeIndex);
1337 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Rx disassoc, sta not found\n");
1340 else if (pMgmt->eCurrMode == WMAC_MODE_ESS_STA ){
1341 sFrame.len = pRxPacket->cbMPDULen;
1342 sFrame.pBuf = (u8 *)pRxPacket->p80211Header;
1343 vMgrDecodeDisassociation(&sFrame);
1344 DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "AP disassociated me, reason=%d.\n", cpu_to_le16(*(sFrame.pwReason)));
1346 pDevice->fWPA_Authened = false;
1348 //TODO: do something let upper layer know or
1349 //try to send associate packet again because of inactivity timeout
1350 if (pMgmt->eCurrState == WMAC_STATE_ASSOC) {
1351 pDevice->bLinkPass = false;
1352 pMgmt->sNodeDBTable[0].bActive = false;
1353 pDevice->byReAssocCount = 0;
1354 pMgmt->eCurrState = WMAC_STATE_AUTH; // jump back to the auth state!
1355 pDevice->eCommandState = WLAN_ASSOCIATE_WAIT;
1356 vMgrReAssocBeginSta(pDevice, pMgmt, &CmdStatus);
1357 if(CmdStatus == CMD_STATUS_PENDING) {
1358 pDevice->byReAssocCount ++;
1359 return; //mike add: you'll retry for many times, so it cann't be regarded as disconnected!
1363 // if(pDevice->bWPASuppWextEnabled == true)
1365 union iwreq_data wrqu;
1366 memset(&wrqu, 0, sizeof (wrqu));
1367 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
1368 PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated)\n");
1369 wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
1372 /* else, ignore it */
1379 * Routine Description:
1380 * Handles incoming deauthentication frames
1388 static void s_vMgrRxDeauthentication(struct vnt_private *pDevice,
1389 struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket)
1391 WLAN_FR_DEAUTHEN sFrame;
1394 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP ){
1396 // if is acting an AP..
1397 // a STA is leaving this BSS..
1398 sFrame.len = pRxPacket->cbMPDULen;
1399 sFrame.pBuf = (u8 *)pRxPacket->p80211Header;
1400 if (BSSbIsSTAInNodeDB(pDevice, pRxPacket->p80211Header->sA3.abyAddr2, &uNodeIndex)) {
1401 BSSvRemoveOneNode(pDevice, uNodeIndex);
1404 DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Rx deauth, sta not found\n");
1408 if (pMgmt->eCurrMode == WMAC_MODE_ESS_STA ) {
1409 sFrame.len = pRxPacket->cbMPDULen;
1410 sFrame.pBuf = (u8 *)pRxPacket->p80211Header;
1411 vMgrDecodeDeauthen(&sFrame);
1412 pDevice->fWPA_Authened = false;
1413 DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "AP deauthed me, reason=%d.\n", cpu_to_le16((*(sFrame.pwReason))));
1414 // TODO: update BSS list for specific BSSID if pre-authentication case
1415 if (ether_addr_equal(sFrame.pHdr->sA3.abyAddr3,
1416 pMgmt->abyCurrBSSID)) {
1417 if (pMgmt->eCurrState >= WMAC_STATE_AUTHPENDING) {
1418 pMgmt->sNodeDBTable[0].bActive = false;
1419 pMgmt->eCurrMode = WMAC_MODE_STANDBY;
1420 pMgmt->eCurrState = WMAC_STATE_IDLE;
1421 netif_stop_queue(pDevice->dev);
1422 pDevice->bLinkPass = false;
1423 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW);
1427 // if(pDevice->bWPASuppWextEnabled == true)
1429 union iwreq_data wrqu;
1430 memset(&wrqu, 0, sizeof (wrqu));
1431 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
1432 PRINT_K("wireless_send_event--->SIOCGIWAP(disauthen)\n");
1433 wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
1437 /* else, ignore it. TODO: IBSS authentication service
1438 would be implemented here */
1445 * Routine Description:
1446 * check if current channel is match ZoneType.
1454 static int ChannelExceedZoneType(struct vnt_private *pDevice, u8 byCurrChannel)
1458 switch(pDevice->byZoneType) {
1459 case 0x00: //USA:1~11
1460 if((byCurrChannel<1) ||(byCurrChannel>11))
1463 case 0x01: //Japan:1~13
1464 case 0x02: //Europe:1~13
1465 if((byCurrChannel<1) ||(byCurrChannel>13))
1468 default: //reserve for other zonetype
1477 * Routine Description:
1478 * Handles and analysis incoming beacon frames.
1486 static void s_vMgrRxBeacon(struct vnt_private *pDevice,
1487 struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket,
1491 WLAN_FR_BEACON sFrame;
1493 int bIsBSSIDEqual = false;
1494 int bIsSSIDEqual = false;
1495 int bTSFLargeDiff = false;
1496 int bTSFOffsetPostive = false;
1497 int bUpdateTSF = false;
1498 int bIsAPBeacon = false;
1499 int bIsChannelEqual = false;
1500 u32 uLocateByteIndex;
1504 u64 qwTimestamp, qwLocalTSF;
1506 u16 wStartIndex = 0;
1508 u8 byCurrChannel = pRxPacket->byRxChannel;
1510 u32 uRateLen = WLAN_RATES_MAXLEN;
1511 int bChannelHit = false;
1512 u8 byOldPreambleType;
1514 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)
1517 memset(&sFrame, 0, sizeof(WLAN_FR_BEACON));
1518 sFrame.len = pRxPacket->cbMPDULen;
1519 sFrame.pBuf = (u8 *)pRxPacket->p80211Header;
1521 // decode the beacon frame
1522 vMgrDecodeBeacon(&sFrame);
1524 if ((sFrame.pwBeaconInterval == NULL)
1525 || (sFrame.pwCapInfo == NULL)
1526 || (sFrame.pSSID == NULL)
1527 || (sFrame.pSuppRates == NULL)) {
1529 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Rx beacon frame error\n");
1533 if( byCurrChannel > CB_MAX_CHANNEL_24G )
1535 if (sFrame.pDSParms != NULL) {
1536 if (byCurrChannel == RFaby11aChannelIndex[sFrame.pDSParms->byCurrChannel-1])
1538 byCurrChannel = RFaby11aChannelIndex[sFrame.pDSParms->byCurrChannel-1];
1544 if (sFrame.pDSParms != NULL) {
1545 if (byCurrChannel == sFrame.pDSParms->byCurrChannel)
1547 byCurrChannel = sFrame.pDSParms->byCurrChannel;
1553 if(ChannelExceedZoneType(pDevice,byCurrChannel)==true)
1556 if (sFrame.pERP != NULL) {
1557 sERP.byERP = sFrame.pERP->byContext;
1558 sERP.bERPExist = true;
1561 sERP.bERPExist = false;
1565 pBSSList = BSSpAddrIsInBSSList((void *) pDevice,
1566 sFrame.pHdr->sA3.abyAddr3,
1568 if (pBSSList == NULL) {
1569 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Beacon/insert: RxChannel = : %d\n", byCurrChannel);
1570 BSSbInsertToBSSList((void *) pDevice,
1571 sFrame.pHdr->sA3.abyAddr3,
1572 *sFrame.pqwTimestamp,
1573 *sFrame.pwBeaconInterval,
1578 sFrame.pExtSuppRates,
1584 sFrame.len - WLAN_HDR_ADDR3_LEN,
1585 sFrame.pHdr->sA4.abyAddr4, // payload of beacon
1586 (void *) pRxPacket);
1589 // DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"update bcn: RxChannel = : %d\n", byCurrChannel);
1590 BSSbUpdateToBSSList((void *) pDevice,
1591 *sFrame.pqwTimestamp,
1592 *sFrame.pwBeaconInterval,
1598 sFrame.pExtSuppRates,
1605 sFrame.len - WLAN_HDR_ADDR3_LEN,
1606 sFrame.pHdr->sA4.abyAddr4, // payload of probresponse
1607 (void *) pRxPacket);
1615 if(byCurrChannel == (u8)pMgmt->uCurrChannel)
1616 bIsChannelEqual = true;
1618 if (bIsChannelEqual && (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) {
1620 // if rx beacon without ERP field
1621 if (sERP.bERPExist) {
1622 if (WLAN_GET_ERP_USE_PROTECTION(sERP.byERP)){
1623 pDevice->byERPFlag |= WLAN_SET_ERP_USE_PROTECTION(1);
1624 pDevice->wUseProtectCntDown = USE_PROTECT_PERIOD;
1628 pDevice->byERPFlag |= WLAN_SET_ERP_USE_PROTECTION(1);
1629 pDevice->wUseProtectCntDown = USE_PROTECT_PERIOD;
1632 if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
1633 if(!WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame.pwCapInfo))
1634 pDevice->byERPFlag |= WLAN_SET_ERP_BARKER_MODE(1);
1636 pDevice->byERPFlag |= WLAN_SET_ERP_NONERP_PRESENT(1);
1640 // check if BSSID the same
1641 if (memcmp(sFrame.pHdr->sA3.abyAddr3,
1642 pMgmt->abyCurrBSSID,
1643 WLAN_BSSID_LEN) == 0) {
1645 bIsBSSIDEqual = true;
1646 pDevice->uCurrRSSI = pRxPacket->uRSSI;
1647 pDevice->byCurrSQ = pRxPacket->bySQ;
1648 if (pMgmt->sNodeDBTable[0].uInActiveCount != 0) {
1649 pMgmt->sNodeDBTable[0].uInActiveCount = 0;
1650 //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BCN:Wake Count= [%d]\n", pMgmt->wCountToWakeUp);
1653 // check if SSID the same
1654 if (sFrame.pSSID->len == ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len) {
1655 if (memcmp(sFrame.pSSID->abySSID,
1656 ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->abySSID,
1659 bIsSSIDEqual = true;
1663 if ((WLAN_GET_CAP_INFO_ESS(*sFrame.pwCapInfo)== true) &&
1664 (bIsBSSIDEqual == true) &&
1665 (bIsSSIDEqual == true) &&
1666 (pMgmt->eCurrMode == WMAC_MODE_ESS_STA) &&
1667 (pMgmt->eCurrState == WMAC_STATE_ASSOC)) {
1668 // add state check to prevent reconnect fail since we'll receive Beacon
1671 if (pBSSList != NULL) {
1674 if ((pBSSList->sERP.bERPExist == true) && (pDevice->byBBType == BB_TYPE_11G)) {
1675 if ((pBSSList->sERP.byERP & WLAN_EID_ERP_USE_PROTECTION) != pDevice->bProtectMode) {//0000 0010
1676 pDevice->bProtectMode = (pBSSList->sERP.byERP & WLAN_EID_ERP_USE_PROTECTION);
1677 if (pDevice->bProtectMode) {
1678 MACvEnableProtectMD(pDevice);
1680 MACvDisableProtectMD(pDevice);
1682 vUpdateIFS(pDevice);
1684 if ((pBSSList->sERP.byERP & WLAN_EID_ERP_NONERP_PRESENT) != pDevice->bNonERPPresent) {//0000 0001
1685 pDevice->bNonERPPresent = (pBSSList->sERP.byERP & WLAN_EID_ERP_USE_PROTECTION);
1687 if ((pBSSList->sERP.byERP & WLAN_EID_ERP_BARKER_MODE) != pDevice->bBarkerPreambleMd) {//0000 0100
1688 pDevice->bBarkerPreambleMd = (pBSSList->sERP.byERP & WLAN_EID_ERP_BARKER_MODE);
1689 //BarkerPreambleMd has higher priority than shortPreamble bit in Cap
1690 if (pDevice->bBarkerPreambleMd) {
1691 MACvEnableBarkerPreambleMd(pDevice);
1693 MACvDisableBarkerPreambleMd(pDevice);
1697 // Sync Short Slot Time
1698 if (WLAN_GET_CAP_INFO_SHORTSLOTTIME(pBSSList->wCapInfo) != pDevice->bShortSlotTime) {
1699 bool bShortSlotTime;
1701 bShortSlotTime = WLAN_GET_CAP_INFO_SHORTSLOTTIME(pBSSList->wCapInfo);
1702 //DBG_PRN_WLAN05(("Set Short Slot Time: %d\n", pDevice->bShortSlotTime));
1703 //Kyle check if it is OK to set G.
1704 if (pDevice->byBBType == BB_TYPE_11A) {
1705 bShortSlotTime = true;
1707 else if (pDevice->byBBType == BB_TYPE_11B) {
1708 bShortSlotTime = false;
1710 if (bShortSlotTime != pDevice->bShortSlotTime) {
1711 pDevice->bShortSlotTime = bShortSlotTime;
1712 BBvSetShortSlotTime(pDevice);
1713 vUpdateIFS(pDevice);
1718 // Preamble may change dynamically
1720 byOldPreambleType = pDevice->byPreambleType;
1721 if (WLAN_GET_CAP_INFO_SHORTPREAMBLE(pBSSList->wCapInfo)) {
1722 pDevice->byPreambleType = pDevice->byShortPreamble;
1725 pDevice->byPreambleType = 0;
1727 if (pDevice->byPreambleType != byOldPreambleType)
1728 CARDvSetRSPINF(pDevice, (u8)pDevice->byBBType);
1730 // Basic Rate Set may change dynamically
1732 if (pBSSList->eNetworkTypeInUse == PHY_TYPE_11B) {
1733 uRateLen = WLAN_RATES_MAXLEN_11B;
1735 pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)pBSSList->abySuppRates,
1736 (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
1738 pMgmt->abyCurrExtSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)pBSSList->abyExtSuppRates,
1739 (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates,
1741 RATEvParseMaxRate((void *)pDevice,
1742 (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
1743 (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates,
1745 &(pMgmt->sNodeDBTable[0].wMaxBasicRate),
1746 &(pMgmt->sNodeDBTable[0].wMaxSuppRate),
1747 &(pMgmt->sNodeDBTable[0].wSuppRate),
1748 &(pMgmt->sNodeDBTable[0].byTopCCKBasicRate),
1749 &(pMgmt->sNodeDBTable[0].byTopOFDMBasicRate)
1755 // DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Beacon 2 \n");
1756 // check if CF field exisit
1757 if (WLAN_GET_CAP_INFO_ESS(*sFrame.pwCapInfo)) {
1758 if (sFrame.pCFParms->wCFPDurRemaining > 0) {
1759 // TODO: deal with CFP period to set NAV
1763 qwTimestamp = cpu_to_le64(*sFrame.pqwTimestamp);
1764 qwLocalTSF = pRxPacket->qwLocalTSF;
1766 // check if beacon TSF larger or small than our local TSF
1767 if (qwTimestamp >= qwLocalTSF)
1768 bTSFOffsetPostive = true;
1770 bTSFOffsetPostive = false;
1772 if (bTSFOffsetPostive) {
1773 qwTSFOffset = CARDqGetTSFOffset(pRxPacket->byRxRate, (qwTimestamp), (qwLocalTSF));
1776 qwTSFOffset = CARDqGetTSFOffset(pRxPacket->byRxRate, (qwLocalTSF), (qwTimestamp));
1779 if (qwTSFOffset > TRIVIAL_SYNC_DIFFERENCE)
1780 bTSFLargeDiff = true;
1783 if (bIsAPBeacon == true) {
1785 // Infra mode: Local TSF always follow AP's TSF if Difference huge.
1789 if ((pDevice->bEnablePSMode == true) && (sFrame.pTIM)) {
1791 /* deal with DTIM, analysis TIM */
1792 pMgmt->bMulticastTIM = WLAN_MGMT_IS_MULTICAST_TIM(sFrame.pTIM->byBitMapCtl) ? true : false ;
1793 pMgmt->byDTIMCount = sFrame.pTIM->byDTIMCount;
1794 pMgmt->byDTIMPeriod = sFrame.pTIM->byDTIMPeriod;
1795 wAIDNumber = pMgmt->wCurrAID & ~(BIT14|BIT15);
1797 // check if AID in TIM field bit on
1799 wStartIndex = WLAN_MGMT_GET_TIM_OFFSET(sFrame.pTIM->byBitMapCtl) << 1;
1801 wAIDIndex = (wAIDNumber >> 3);
1802 if ((wAIDNumber > 0) && (wAIDIndex >= wStartIndex)) {
1803 uLocateByteIndex = wAIDIndex - wStartIndex;
1804 // len = byDTIMCount + byDTIMPeriod + byDTIMPeriod + byVirtBitMap[0~250]
1805 if (sFrame.pTIM->len >= (uLocateByteIndex + 4)) {
1806 byTIMBitOn = (0x01) << ((wAIDNumber) % 8);
1807 pMgmt->bInTIM = sFrame.pTIM->byVirtBitMap[uLocateByteIndex] & byTIMBitOn ? true : false;
1810 pMgmt->bInTIM = false;
1814 pMgmt->bInTIM = false;
1817 if (pMgmt->bInTIM ||
1818 (pMgmt->bMulticastTIM && (pMgmt->byDTIMCount == 0))) {
1819 pMgmt->bInTIMWake = true;
1820 /* send out ps-poll packet */
1822 PSvSendPSPOLL(pDevice);
1826 pMgmt->bInTIMWake = false;
1827 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BCN: Not In TIM..\n");
1828 if (pDevice->bPWBitOn == false) {
1829 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BCN: Send Null Packet\n");
1830 if (PSbSendNullPacket(pDevice))
1831 pDevice->bPWBitOn = true;
1833 if(PSbConsiderPowerDown(pDevice, false, false)) {
1834 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BCN: Power down now...\n");
1842 if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && !bIsAPBeacon && bIsChannelEqual) {
1843 if (bIsBSSIDEqual) {
1844 // Use sNodeDBTable[0].uInActiveCount as IBSS beacons received count.
1845 if (pMgmt->sNodeDBTable[0].uInActiveCount != 0)
1846 pMgmt->sNodeDBTable[0].uInActiveCount = 0;
1848 // adhoc mode:TSF updated only when beacon larger then local TSF
1849 if (bTSFLargeDiff && bTSFOffsetPostive &&
1850 (pMgmt->eCurrState == WMAC_STATE_JOINTED))
1853 // During dpc, already in spinlocked.
1854 if (BSSbIsSTAInNodeDB(pDevice, sFrame.pHdr->sA3.abyAddr2, &uNodeIndex)) {
1856 // Update the STA, (Technically the Beacons of all the IBSS nodes
1857 // should be identical, but that's not happening in practice.
1858 pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pSuppRates,
1859 (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
1860 WLAN_RATES_MAXLEN_11B);
1861 RATEvParseMaxRate((void *)pDevice,
1862 (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
1865 &(pMgmt->sNodeDBTable[uNodeIndex].wMaxBasicRate),
1866 &(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate),
1867 &(pMgmt->sNodeDBTable[uNodeIndex].wSuppRate),
1868 &(pMgmt->sNodeDBTable[uNodeIndex].byTopCCKBasicRate),
1869 &(pMgmt->sNodeDBTable[uNodeIndex].byTopOFDMBasicRate)
1871 pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble = WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame.pwCapInfo);
1872 pMgmt->sNodeDBTable[uNodeIndex].bShortSlotTime = WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame.pwCapInfo);
1873 pMgmt->sNodeDBTable[uNodeIndex].uInActiveCount = 0;
1876 /* Todo, initial Node content */
1877 BSSvCreateOneNode(pDevice, &uNodeIndex);
1879 pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pSuppRates,
1880 (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
1881 WLAN_RATES_MAXLEN_11B);
1882 RATEvParseMaxRate((void *)pDevice,
1883 (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
1886 &(pMgmt->sNodeDBTable[uNodeIndex].wMaxBasicRate),
1887 &(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate),
1888 &(pMgmt->sNodeDBTable[uNodeIndex].wSuppRate),
1889 &(pMgmt->sNodeDBTable[uNodeIndex].byTopCCKBasicRate),
1890 &(pMgmt->sNodeDBTable[uNodeIndex].byTopOFDMBasicRate)
1893 memcpy(pMgmt->sNodeDBTable[uNodeIndex].abyMACAddr, sFrame.pHdr->sA3.abyAddr2, WLAN_ADDR_LEN);
1894 pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble = WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame.pwCapInfo);
1895 pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate = pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate;
1897 pMgmt->sNodeDBTable[uNodeIndex].bShortSlotTime = WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame.pwCapInfo);
1898 if(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate > RATE_11M)
1899 pMgmt->sNodeDBTable[uNodeIndex].bERPExist = true;
1903 // if other stations jointed, indicate connect to upper layer..
1904 if (pMgmt->eCurrState == WMAC_STATE_STARTED) {
1905 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Current IBSS State: [Started]........to: [Jointed] \n");
1906 pMgmt->eCurrState = WMAC_STATE_JOINTED;
1907 pDevice->bLinkPass = true;
1908 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER);
1909 if (netif_queue_stopped(pDevice->dev)){
1910 netif_wake_queue(pDevice->dev);
1912 pMgmt->sNodeDBTable[0].bActive = true;
1913 pMgmt->sNodeDBTable[0].uInActiveCount = 0;
1917 else if (bIsSSIDEqual) {
1919 // See other adhoc sta with the same SSID but BSSID is different.
1920 // adpot this vars only when TSF larger then us.
1921 if (bTSFLargeDiff && bTSFOffsetPostive) {
1922 // we don't support ATIM under adhoc mode
1923 // if ( sFrame.pIBSSParms->wATIMWindow == 0) {
1925 // TODO: check sFrame cap if privacy on, and support rate syn
1926 memcpy(pMgmt->abyCurrBSSID, sFrame.pHdr->sA3.abyAddr3, WLAN_BSSID_LEN);
1927 memcpy(pDevice->abyBSSID, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
1928 pMgmt->wCurrATIMWindow = cpu_to_le16(sFrame.pIBSSParms->wATIMWindow);
1929 pMgmt->wCurrBeaconPeriod = cpu_to_le16(*sFrame.pwBeaconInterval);
1930 pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pSuppRates,
1931 (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
1932 WLAN_RATES_MAXLEN_11B);
1933 // set HW beacon interval and re-synchronizing....
1934 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Rejoining to Other Adhoc group with same SSID........\n");
1936 MACvWriteBeaconInterval(pDevice, pMgmt->wCurrBeaconPeriod);
1937 CARDvAdjustTSF(pDevice, pRxPacket->byRxRate, qwTimestamp, pRxPacket->qwLocalTSF);
1938 CARDvUpdateNextTBTT(pDevice, qwTimestamp, pMgmt->wCurrBeaconPeriod);
1940 // Turn off bssid filter to avoid filter others adhoc station which bssid is different.
1941 MACvWriteBSSIDAddress(pDevice, pMgmt->abyCurrBSSID);
1943 byOldPreambleType = pDevice->byPreambleType;
1944 if (WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame.pwCapInfo)) {
1945 pDevice->byPreambleType = pDevice->byShortPreamble;
1948 pDevice->byPreambleType = 0;
1950 if (pDevice->byPreambleType != byOldPreambleType)
1951 CARDvSetRSPINF(pDevice, (u8)pDevice->byBBType);
1953 // MACvRegBitsOff(pDevice->PortOffset, MAC_REG_RCR, RCR_BSSID);
1954 // set highest basic rate
1955 // s_vSetHighestBasicRate(pDevice, (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates);
1956 // Prepare beacon frame
1957 bMgrPrepareBeaconToSend((void *) pDevice, pMgmt);
1965 CARDbGetCurrentTSF(pDevice, &qwCurrTSF);
1966 CARDvAdjustTSF(pDevice, pRxPacket->byRxRate, qwTimestamp , pRxPacket->qwLocalTSF);
1967 CARDbGetCurrentTSF(pDevice, &qwCurrTSF);
1968 CARDvUpdateNextTBTT(pDevice, qwTimestamp, pMgmt->wCurrBeaconPeriod);
1976 * Routine Description:
1977 * Instructs the hw to create a bss using the supplied
1978 * attributes. Note that this implementation only supports Ad-Hoc
1987 void vMgrCreateOwnIBSS(struct vnt_private *pDevice, PCMD_STATUS pStatus)
1989 struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
1992 u8 byTopCCKBasicRate;
1993 u8 byTopOFDMBasicRate;
1996 u8 abyRATE[] = {0x82, 0x84, 0x8B, 0x96, 0x24, 0x30, 0x48, 0x6C, 0x0C,
1998 u8 abyCCK_RATE[] = {0x82, 0x84, 0x8B, 0x96};
1999 u8 abyOFDM_RATE[] = {0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
2002 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Create Basic Service Set .......\n");
2004 if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) {
2005 if ((pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) &&
2006 (pDevice->eEncryptionStatus != Ndis802_11Encryption2Enabled) &&
2007 (pDevice->eEncryptionStatus != Ndis802_11Encryption3Enabled)) {
2008 // encryption mode error
2009 *pStatus = CMD_STATUS_FAILURE;
2014 pMgmt->abyCurrSuppRates[0] = WLAN_EID_SUPP_RATES;
2015 pMgmt->abyCurrExtSuppRates[0] = WLAN_EID_EXTSUPP_RATES;
2017 if (pMgmt->eConfigMode == WMAC_CONFIG_AP) {
2018 pMgmt->eCurrentPHYMode = pMgmt->byAPBBType;
2020 if (pDevice->byBBType == BB_TYPE_11G)
2021 pMgmt->eCurrentPHYMode = PHY_TYPE_11G;
2022 if (pDevice->byBBType == BB_TYPE_11B)
2023 pMgmt->eCurrentPHYMode = PHY_TYPE_11B;
2024 if (pDevice->byBBType == BB_TYPE_11A)
2025 pMgmt->eCurrentPHYMode = PHY_TYPE_11A;
2028 if (pMgmt->eCurrentPHYMode != PHY_TYPE_11A) {
2029 pMgmt->abyCurrSuppRates[1] = WLAN_RATES_MAXLEN_11B;
2030 pMgmt->abyCurrExtSuppRates[1] = 0;
2031 for (ii = 0; ii < 4; ii++)
2032 pMgmt->abyCurrSuppRates[2+ii] = abyRATE[ii];
2034 pMgmt->abyCurrSuppRates[1] = 8;
2035 pMgmt->abyCurrExtSuppRates[1] = 0;
2036 for (ii = 0; ii < 8; ii++)
2037 pMgmt->abyCurrSuppRates[2+ii] = abyRATE[ii];
2040 if (pMgmt->eCurrentPHYMode == PHY_TYPE_11G) {
2041 pMgmt->abyCurrSuppRates[1] = 8;
2042 pMgmt->abyCurrExtSuppRates[1] = 4;
2043 for (ii = 0; ii < 4; ii++)
2044 pMgmt->abyCurrSuppRates[2+ii] = abyCCK_RATE[ii];
2045 for (ii = 4; ii < 8; ii++)
2046 pMgmt->abyCurrSuppRates[2+ii] = abyOFDM_RATE[ii-4];
2047 for (ii = 0; ii < 4; ii++)
2048 pMgmt->abyCurrExtSuppRates[2+ii] = abyOFDM_RATE[ii+4];
2051 // Disable Protect Mode
2052 pDevice->bProtectMode = 0;
2053 MACvDisableProtectMD(pDevice);
2055 pDevice->bBarkerPreambleMd = 0;
2056 MACvDisableBarkerPreambleMd(pDevice);
2058 // Kyle Test 2003.11.04
2060 // set HW beacon interval
2061 if (pMgmt->wIBSSBeaconPeriod == 0)
2062 pMgmt->wIBSSBeaconPeriod = DEFAULT_IBSS_BI;
2063 MACvWriteBeaconInterval(pDevice, pMgmt->wIBSSBeaconPeriod);
2065 CARDbGetCurrentTSF(pDevice, &qwCurrTSF);
2066 // clear TSF counter
2067 CARDbClearCurrentTSF(pDevice);
2069 // enable TSF counter
2070 MACvRegBitsOn(pDevice,MAC_REG_TFTCTL,TFTCTL_TSFCNTREN);
2072 CARDvSetFirstNextTBTT(pDevice, pMgmt->wIBSSBeaconPeriod);
2074 pMgmt->uIBSSChannel = pDevice->uChannel;
2076 if (pMgmt->uIBSSChannel == 0)
2077 pMgmt->uIBSSChannel = DEFAULT_IBSS_CHANNEL;
2079 // set channel and clear NAV
2080 CARDbSetMediaChannel(pDevice, pMgmt->uIBSSChannel);
2081 pMgmt->uCurrChannel = pMgmt->uIBSSChannel;
2083 pDevice->byPreambleType = pDevice->byShortPreamble;
2087 RATEvParseMaxRate((void *)pDevice,
2088 (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
2089 (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates, true,
2090 &wMaxBasicRate, &wMaxSuppRate, &wSuppRate,
2091 &byTopCCKBasicRate, &byTopOFDMBasicRate);
2093 if (pDevice->byBBType == BB_TYPE_11A) {
2094 pDevice->bShortSlotTime = true;
2096 pDevice->bShortSlotTime = false;
2098 BBvSetShortSlotTime(pDevice);
2099 // vUpdateIFS() use pDevice->bShortSlotTime as parameter so it must be called
2100 // after setting ShortSlotTime.
2101 // CARDvSetBSSMode call vUpdateIFS()
2102 CARDvSetBSSMode(pDevice);
2104 if (pMgmt->eConfigMode == WMAC_CONFIG_AP) {
2105 MACvRegBitsOn(pDevice, MAC_REG_HOSTCR, HOSTCR_AP);
2106 pMgmt->eCurrMode = WMAC_MODE_ESS_AP;
2109 if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) {
2110 MACvRegBitsOn(pDevice, MAC_REG_HOSTCR, HOSTCR_ADHOC);
2111 pMgmt->eCurrMode = WMAC_MODE_IBSS_STA;
2114 // Adopt pre-configured IBSS vars to current vars
2115 pMgmt->eCurrState = WMAC_STATE_STARTED;
2116 pMgmt->wCurrBeaconPeriod = pMgmt->wIBSSBeaconPeriod;
2117 pMgmt->uCurrChannel = pMgmt->uIBSSChannel;
2118 pMgmt->wCurrATIMWindow = pMgmt->wIBSSATIMWindow;
2119 pDevice->uCurrRSSI = 0;
2120 pDevice->byCurrSQ = 0;
2122 memcpy(pMgmt->abyDesireSSID,pMgmt->abyAdHocSSID,
2123 ((PWLAN_IE_SSID)pMgmt->abyAdHocSSID)->len + WLAN_IEHDR_LEN);
2125 memset(pMgmt->abyCurrSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
2126 memcpy(pMgmt->abyCurrSSID,
2127 pMgmt->abyDesireSSID,
2128 ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->len + WLAN_IEHDR_LEN
2131 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
2132 // AP mode BSSID = MAC addr
2133 memcpy(pMgmt->abyCurrBSSID, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
2134 DBG_PRT(MSG_LEVEL_INFO, KERN_INFO"AP beacon created BSSID:"
2135 "%pM\n", pMgmt->abyCurrBSSID);
2138 if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
2140 // BSSID selected must be randomized as spec 11.1.3
2141 pMgmt->abyCurrBSSID[5] = (u8)(qwCurrTSF & 0x000000ff);
2142 pMgmt->abyCurrBSSID[4] = (u8)((qwCurrTSF & 0x0000ff00) >> 8);
2143 pMgmt->abyCurrBSSID[3] = (u8)((qwCurrTSF & 0x00ff0000) >> 16);
2144 pMgmt->abyCurrBSSID[2] = (u8)((qwCurrTSF & 0x00000ff0) >> 4);
2145 pMgmt->abyCurrBSSID[1] = (u8)((qwCurrTSF & 0x000ff000) >> 12);
2146 pMgmt->abyCurrBSSID[0] = (u8)((qwCurrTSF & 0x0ff00000) >> 20);
2147 pMgmt->abyCurrBSSID[5] ^= pMgmt->abyMACAddr[0];
2148 pMgmt->abyCurrBSSID[4] ^= pMgmt->abyMACAddr[1];
2149 pMgmt->abyCurrBSSID[3] ^= pMgmt->abyMACAddr[2];
2150 pMgmt->abyCurrBSSID[2] ^= pMgmt->abyMACAddr[3];
2151 pMgmt->abyCurrBSSID[1] ^= pMgmt->abyMACAddr[4];
2152 pMgmt->abyCurrBSSID[0] ^= pMgmt->abyMACAddr[5];
2153 pMgmt->abyCurrBSSID[0] &= ~IEEE_ADDR_GROUP;
2154 pMgmt->abyCurrBSSID[0] |= IEEE_ADDR_UNIVERSAL;
2156 DBG_PRT(MSG_LEVEL_INFO, KERN_INFO"Adhoc beacon created bssid:"
2157 "%pM\n", pMgmt->abyCurrBSSID);
2161 MACvWriteBSSIDAddress(pDevice, pMgmt->abyCurrBSSID);
2162 memcpy(pDevice->abyBSSID, pMgmt->abyCurrBSSID, WLAN_ADDR_LEN);
2164 MACvRegBitsOn(pDevice, MAC_REG_RCR, RCR_BSSID);
2165 pDevice->byRxMode |= RCR_BSSID;
2166 pMgmt->bCurrBSSIDFilterOn = true;
2168 // Set Capability Info
2169 pMgmt->wCurrCapInfo = 0;
2171 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
2172 pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_ESS(1);
2173 pMgmt->byDTIMPeriod = DEFAULT_DTIM_PERIOD;
2174 pMgmt->byDTIMCount = pMgmt->byDTIMPeriod - 1;
2175 pDevice->eOPMode = OP_MODE_AP;
2178 if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
2179 pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_IBSS(1);
2180 pDevice->eOPMode = OP_MODE_ADHOC;
2183 if (pDevice->bEncryptionEnable) {
2184 pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_PRIVACY(1);
2185 if (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) {
2186 if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) {
2187 pMgmt->byCSSPK = KEY_CTL_CCMP;
2188 pMgmt->byCSSGK = KEY_CTL_CCMP;
2189 } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) {
2190 pMgmt->byCSSPK = KEY_CTL_TKIP;
2191 pMgmt->byCSSGK = KEY_CTL_TKIP;
2193 pMgmt->byCSSPK = KEY_CTL_NONE;
2194 pMgmt->byCSSGK = KEY_CTL_WEP;
2197 pMgmt->byCSSPK = KEY_CTL_WEP;
2198 pMgmt->byCSSGK = KEY_CTL_WEP;
2202 pMgmt->byERPContext = 0;
2204 if (pDevice->byPreambleType == 1) {
2205 pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
2207 pMgmt->wCurrCapInfo &= (~WLAN_SET_CAP_INFO_SHORTPREAMBLE(1));
2210 pMgmt->eCurrState = WMAC_STATE_STARTED;
2211 // Prepare beacon to send
2212 if (bMgrPrepareBeaconToSend((void *) pDevice, pMgmt))
2213 *pStatus = CMD_STATUS_SUCCESS;
2220 * Routine Description:
2221 * Instructs wmac to join a bss using the supplied attributes.
2222 * The arguments may the BSSID or SSID and the rest of the
2223 * attributes are obtained from the scan result of known bss list.
2231 void vMgrJoinBSSBegin(struct vnt_private *pDevice, PCMD_STATUS pStatus)
2233 struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
2234 PKnownBSS pCurr = NULL;
2236 PWLAN_IE_SUPP_RATES pItemRates = NULL;
2237 PWLAN_IE_SUPP_RATES pItemExtRates = NULL;
2238 PWLAN_IE_SSID pItemSSID;
2239 u32 uRateLen = WLAN_RATES_MAXLEN;
2240 u16 wMaxBasicRate = RATE_1M;
2241 u16 wMaxSuppRate = RATE_1M;
2243 u8 byTopCCKBasicRate = RATE_1M;
2244 u8 byTopOFDMBasicRate = RATE_1M;
2245 u8 bShortSlotTime = false;
2247 for (ii = 0; ii < MAX_BSS_NUM; ii++) {
2248 if (pMgmt->sBSSList[ii].bActive == true)
2252 if (ii == MAX_BSS_NUM) {
2253 *pStatus = CMD_STATUS_RESOURCES;
2254 DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "BSS finding:BSS list is empty.\n");
2258 // memset(pMgmt->abyDesireBSSID, 0, WLAN_BSSID_LEN);
2259 // Search known BSS list for prefer BSSID or SSID
2261 pCurr = BSSpSearchBSSList(pDevice,
2262 pMgmt->abyDesireBSSID,
2263 pMgmt->abyDesireSSID,
2264 pDevice->eConfigPHYMode
2268 *pStatus = CMD_STATUS_RESOURCES;
2269 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
2270 DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Scanning [%s] not found, disconnected !\n", pItemSSID->abySSID);
2274 DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "AP(BSS) finding:Found a AP(BSS)..\n");
2276 if (WLAN_GET_CAP_INFO_ESS(cpu_to_le16(pCurr->wCapInfo))){
2278 if ((pMgmt->eAuthenMode == WMAC_AUTH_WPA) ||
2279 (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK)) {
2281 if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) {
2282 if (WPA_SearchRSN(0, WPA_TKIP, pCurr) == false) {
2283 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"No match RSN info. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
2284 // encryption mode error
2285 pMgmt->eCurrState = WMAC_STATE_IDLE;
2288 } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) {
2289 if (WPA_SearchRSN(0, WPA_AESCCMP, pCurr) == false) {
2290 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"No match RSN info. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
2291 // encryption mode error
2292 pMgmt->eCurrState = WMAC_STATE_IDLE;
2299 //if(pDevice->bWPASuppWextEnabled == true)
2300 Encyption_Rebuild(pDevice, pCurr);
2302 // Infrastructure BSS
2303 s_vMgrSynchBSS(pDevice,
2309 if (*pStatus == CMD_STATUS_SUCCESS){
2311 // Adopt this BSS state vars in Mgmt Object
2312 pMgmt->uCurrChannel = pCurr->uChannel;
2314 memset(pMgmt->abyCurrSuppRates, 0 , WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1);
2315 memset(pMgmt->abyCurrExtSuppRates, 0 , WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1);
2317 if (pCurr->eNetworkTypeInUse == PHY_TYPE_11B) {
2318 uRateLen = WLAN_RATES_MAXLEN_11B;
2321 pItemRates = (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates;
2322 pItemExtRates = (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates;
2324 // Parse Support Rate IE
2325 pItemRates->byElementID = WLAN_EID_SUPP_RATES;
2326 pItemRates->len = RATEuSetIE((PWLAN_IE_SUPP_RATES)pCurr->abySuppRates,
2330 // Parse Extension Support Rate IE
2331 pItemExtRates->byElementID = WLAN_EID_EXTSUPP_RATES;
2332 pItemExtRates->len = RATEuSetIE((PWLAN_IE_SUPP_RATES)pCurr->abyExtSuppRates,
2336 if ((pItemExtRates->len > 0) && (pItemRates->len < 8)) {
2337 for (ii = 0; ii < (unsigned int) (8 - pItemRates->len); ) {
2338 pItemRates->abyRates[pItemRates->len + ii] =
2339 pItemExtRates->abyRates[ii];
2341 if (pItemExtRates->len <= ii)
2344 pItemRates->len += (u8)ii;
2345 if (pItemExtRates->len - ii > 0) {
2346 pItemExtRates->len -= (u8)ii;
2347 for (uu = 0; uu < pItemExtRates->len; uu ++) {
2348 pItemExtRates->abyRates[uu] = pItemExtRates->abyRates[uu + ii];
2351 pItemExtRates->len = 0;
2355 RATEvParseMaxRate((void *)pDevice, pItemRates, pItemExtRates, true,
2356 &wMaxBasicRate, &wMaxSuppRate, &wSuppRate,
2357 &byTopCCKBasicRate, &byTopOFDMBasicRate);
2358 vUpdateIFS(pDevice);
2359 // TODO: deal with if wCapInfo the privacy is on, but station WEP is off
2360 // TODO: deal with if wCapInfo the PS-Pollable is on.
2361 pMgmt->wCurrBeaconPeriod = pCurr->wBeaconInterval;
2362 memset(pMgmt->abyCurrSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
2363 memcpy(pMgmt->abyCurrBSSID, pCurr->abyBSSID, WLAN_BSSID_LEN);
2364 memcpy(pMgmt->abyCurrSSID, pCurr->abySSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
2366 pMgmt->eCurrMode = WMAC_MODE_ESS_STA;
2368 pMgmt->eCurrState = WMAC_STATE_JOINTED;
2369 // Adopt BSS state in Adapter Device Object
2370 pDevice->eOPMode = OP_MODE_INFRASTRUCTURE;
2371 memcpy(pDevice->abyBSSID, pCurr->abyBSSID, WLAN_BSSID_LEN);
2373 // Add current BSS to Candidate list
2374 // This should only work for WPA2 BSS, and WPA2 BSS check must be done before.
2375 if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2) {
2376 bool bResult = bAdd_PMKID_Candidate((void *) pDevice,
2377 pMgmt->abyCurrBSSID,
2378 &pCurr->sRSNCapObj);
2379 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"bAdd_PMKID_Candidate: 1(%d)\n", bResult);
2380 if (bResult == false) {
2381 vFlush_PMKID_Candidate((void *) pDevice);
2382 DBG_PRT(MSG_LEVEL_DEBUG,
2383 KERN_INFO "vFlush_PMKID_Candidate: 4\n");
2384 bAdd_PMKID_Candidate((void *) pDevice,
2385 pMgmt->abyCurrBSSID,
2386 &pCurr->sRSNCapObj);
2390 // Preamble type auto-switch: if AP can receive short-preamble cap,
2391 // we can turn on too.
2392 if (WLAN_GET_CAP_INFO_SHORTPREAMBLE(pCurr->wCapInfo)) {
2393 pDevice->byPreambleType = pDevice->byShortPreamble;
2396 pDevice->byPreambleType = 0;
2398 // Change PreambleType must set RSPINF again
2399 CARDvSetRSPINF(pDevice, (u8)pDevice->byBBType);
2401 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Join ESS\n");
2403 if (pCurr->eNetworkTypeInUse == PHY_TYPE_11G) {
2405 if ((pCurr->sERP.byERP & WLAN_EID_ERP_USE_PROTECTION) != pDevice->bProtectMode) {//0000 0010
2406 pDevice->bProtectMode = (pCurr->sERP.byERP & WLAN_EID_ERP_USE_PROTECTION);
2407 if (pDevice->bProtectMode) {
2408 MACvEnableProtectMD(pDevice);
2410 MACvDisableProtectMD(pDevice);
2412 vUpdateIFS(pDevice);
2414 if ((pCurr->sERP.byERP & WLAN_EID_ERP_NONERP_PRESENT) != pDevice->bNonERPPresent) {//0000 0001
2415 pDevice->bNonERPPresent = (pCurr->sERP.byERP & WLAN_EID_ERP_USE_PROTECTION);
2417 if ((pCurr->sERP.byERP & WLAN_EID_ERP_BARKER_MODE) != pDevice->bBarkerPreambleMd) {//0000 0100
2418 pDevice->bBarkerPreambleMd = (pCurr->sERP.byERP & WLAN_EID_ERP_BARKER_MODE);
2419 //BarkerPreambleMd has higher priority than shortPreamble bit in Cap
2420 if (pDevice->bBarkerPreambleMd) {
2421 MACvEnableBarkerPreambleMd(pDevice);
2423 MACvDisableBarkerPreambleMd(pDevice);
2427 //DBG_PRN_WLAN05(("wCapInfo: %X\n", pCurr->wCapInfo));
2428 if (WLAN_GET_CAP_INFO_SHORTSLOTTIME(pCurr->wCapInfo) != pDevice->bShortSlotTime) {
2429 if (pDevice->byBBType == BB_TYPE_11A) {
2430 bShortSlotTime = true;
2432 else if (pDevice->byBBType == BB_TYPE_11B) {
2433 bShortSlotTime = false;
2436 bShortSlotTime = WLAN_GET_CAP_INFO_SHORTSLOTTIME(pCurr->wCapInfo);
2438 //DBG_PRN_WLAN05(("Set Short Slot Time: %d\n", pDevice->bShortSlotTime));
2439 if (bShortSlotTime != pDevice->bShortSlotTime) {
2440 pDevice->bShortSlotTime = bShortSlotTime;
2441 BBvSetShortSlotTime(pDevice);
2442 vUpdateIFS(pDevice);
2446 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"End of Join AP -- A/B/G Action\n");
2449 pMgmt->eCurrState = WMAC_STATE_IDLE;
2455 if (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) {
2457 if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) {
2459 if (WPA_SearchRSN(0, WPA_TKIP, pCurr) == false) {
2460 // encryption mode error
2461 pMgmt->eCurrState = WMAC_STATE_IDLE;
2465 } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) {
2467 if (WPA_SearchRSN(0, WPA_AESCCMP, pCurr) == false) {
2468 // encryption mode error
2469 pMgmt->eCurrState = WMAC_STATE_IDLE;
2474 // encryption mode error
2475 pMgmt->eCurrState = WMAC_STATE_IDLE;
2480 s_vMgrSynchBSS(pDevice,
2486 if (*pStatus == CMD_STATUS_SUCCESS){
2487 // Adopt this BSS state vars in Mgmt Object
2488 // TODO: check if CapInfo privacy on, but we don't..
2489 pMgmt->uCurrChannel = pCurr->uChannel;
2491 // Parse Support Rate IE
2492 pMgmt->abyCurrSuppRates[0] = WLAN_EID_SUPP_RATES;
2493 pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)pCurr->abySuppRates,
2494 (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
2495 WLAN_RATES_MAXLEN_11B);
2497 RATEvParseMaxRate((void *)pDevice,
2498 (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
2499 NULL, true, &wMaxBasicRate, &wMaxSuppRate, &wSuppRate,
2500 &byTopCCKBasicRate, &byTopOFDMBasicRate);
2501 vUpdateIFS(pDevice);
2502 pMgmt->wCurrCapInfo = pCurr->wCapInfo;
2503 pMgmt->wCurrBeaconPeriod = pCurr->wBeaconInterval;
2504 memset(pMgmt->abyCurrSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN);
2505 memcpy(pMgmt->abyCurrBSSID, pCurr->abyBSSID, WLAN_BSSID_LEN);
2506 memcpy(pMgmt->abyCurrSSID, pCurr->abySSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN);
2507 // pMgmt->wCurrATIMWindow = pCurr->wATIMWindow;
2508 pMgmt->eCurrMode = WMAC_MODE_IBSS_STA;
2509 pMgmt->eCurrState = WMAC_STATE_STARTED;
2510 // Adopt BSS state in Adapter Device Object
2511 pDevice->eOPMode = OP_MODE_ADHOC;
2512 pDevice->bLinkPass = true;
2513 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER);
2514 memcpy(pDevice->abyBSSID, pCurr->abyBSSID, WLAN_BSSID_LEN);
2516 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Join IBSS ok:%pM\n",
2517 pMgmt->abyCurrBSSID);
2518 // Preamble type auto-switch: if AP can receive short-preamble cap,
2519 // and if registry setting is short preamble we can turn on too.
2521 if (WLAN_GET_CAP_INFO_SHORTPREAMBLE(pCurr->wCapInfo)) {
2522 pDevice->byPreambleType = pDevice->byShortPreamble;
2525 pDevice->byPreambleType = 0;
2527 // Change PreambleType must set RSPINF again
2528 CARDvSetRSPINF(pDevice, (u8)pDevice->byBBType);
2531 bMgrPrepareBeaconToSend((void *) pDevice, pMgmt);
2534 pMgmt->eCurrState = WMAC_STATE_IDLE;
2542 * Routine Description:
2543 * Set HW to synchronize a specific BSS from known BSS list.
2550 static void s_vMgrSynchBSS(struct vnt_private *pDevice, u32 uBSSMode,
2551 PKnownBSS pCurr, PCMD_STATUS pStatus)
2553 struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
2554 u8 abyCurrSuppRatesG[] = {WLAN_EID_SUPP_RATES,
2555 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C};
2556 /* 1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M*/
2557 u8 abyCurrExtSuppRatesG[] = {WLAN_EID_EXTSUPP_RATES,
2558 4, 0x0C, 0x12, 0x18, 0x60};
2559 /* 6M, 9M, 12M, 48M*/
2560 u8 abyCurrSuppRatesA[] = {WLAN_EID_SUPP_RATES,
2561 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
2562 u8 abyCurrSuppRatesB[] = {WLAN_EID_SUPP_RATES,
2563 4, 0x02, 0x04, 0x0B, 0x16};
2565 *pStatus = CMD_STATUS_FAILURE;
2567 if (s_bCipherMatch(pCurr,
2568 pDevice->eEncryptionStatus,
2570 &(pMgmt->byCSSGK)) == false) {
2571 DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "s_bCipherMatch Fail .......\n");
2575 pMgmt->pCurrBSS = pCurr;
2577 // if previous mode is IBSS.
2578 if(pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
2579 MACvRegBitsOff(pDevice, MAC_REG_TCR, TCR_AUTOBCNTX);
2582 // Init the BSS informations
2583 pDevice->bCCK = true;
2584 pDevice->bProtectMode = false;
2585 MACvDisableProtectMD(pDevice);
2586 pDevice->bBarkerPreambleMd = false;
2587 MACvDisableBarkerPreambleMd(pDevice);
2588 pDevice->bNonERPPresent = false;
2589 pDevice->byPreambleType = 0;
2590 pDevice->wBasicRate = 0;
2592 CARDbAddBasicRate((void *)pDevice, RATE_1M);
2594 // calculate TSF offset
2595 // TSF Offset = Received Timestamp TSF - Marked Local's TSF
2596 CARDvAdjustTSF(pDevice, pCurr->byRxRate, pCurr->qwBSSTimestamp, pCurr->qwLocalTSF);
2598 // set HW beacon interval
2599 MACvWriteBeaconInterval(pDevice, pCurr->wBeaconInterval);
2602 // Next TBTT = ((local_current_TSF / beacon_interval) + 1 ) * beacon_interval
2603 CARDvSetFirstNextTBTT(pDevice, pCurr->wBeaconInterval);
2606 MACvWriteBSSIDAddress(pDevice, pCurr->abyBSSID);
2608 memcpy(pMgmt->abyCurrBSSID, pCurr->abyBSSID, 6);
2610 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Sync:set CurrBSSID address = "
2611 "%pM\n", pMgmt->abyCurrBSSID);
2613 if (pCurr->eNetworkTypeInUse == PHY_TYPE_11A) {
2614 if ((pDevice->eConfigPHYMode == PHY_TYPE_11A) ||
2615 (pDevice->eConfigPHYMode == PHY_TYPE_AUTO)) {
2616 pDevice->byBBType = BB_TYPE_11A;
2617 pMgmt->eCurrentPHYMode = PHY_TYPE_11A;
2618 pDevice->bShortSlotTime = true;
2619 BBvSetShortSlotTime(pDevice);
2620 CARDvSetBSSMode(pDevice);
2624 } else if (pCurr->eNetworkTypeInUse == PHY_TYPE_11B) {
2625 if ((pDevice->eConfigPHYMode == PHY_TYPE_11B) ||
2626 (pDevice->eConfigPHYMode == PHY_TYPE_11G) ||
2627 (pDevice->eConfigPHYMode == PHY_TYPE_AUTO)) {
2628 pDevice->byBBType = BB_TYPE_11B;
2629 pMgmt->eCurrentPHYMode = PHY_TYPE_11B;
2630 pDevice->bShortSlotTime = false;
2631 BBvSetShortSlotTime(pDevice);
2632 CARDvSetBSSMode(pDevice);
2637 if ((pDevice->eConfigPHYMode == PHY_TYPE_11G) ||
2638 (pDevice->eConfigPHYMode == PHY_TYPE_AUTO)) {
2639 pDevice->byBBType = BB_TYPE_11G;
2640 pMgmt->eCurrentPHYMode = PHY_TYPE_11G;
2641 pDevice->bShortSlotTime = true;
2642 BBvSetShortSlotTime(pDevice);
2643 CARDvSetBSSMode(pDevice);
2644 } else if (pDevice->eConfigPHYMode == PHY_TYPE_11B) {
2645 pDevice->byBBType = BB_TYPE_11B;
2646 pDevice->bShortSlotTime = false;
2647 BBvSetShortSlotTime(pDevice);
2648 CARDvSetBSSMode(pDevice);
2654 if (uBSSMode == WMAC_MODE_ESS_STA) {
2655 MACvRegBitsOff(pDevice, MAC_REG_HOSTCR, HOSTCR_ADHOC);
2656 MACvRegBitsOn(pDevice, MAC_REG_RCR, RCR_BSSID);
2657 pDevice->byRxMode |= RCR_BSSID;
2658 pMgmt->bCurrBSSIDFilterOn = true;
2661 // set channel and clear NAV
2662 CARDbSetMediaChannel(pDevice, pCurr->uChannel);
2663 pMgmt->uCurrChannel = pCurr->uChannel;
2664 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "<----s_bSynchBSS Set Channel [%d]\n", pCurr->uChannel);
2666 if ((pDevice->bUpdateBBVGA) &&
2667 (pDevice->byBBVGACurrent != pDevice->abyBBVGA[0])) {
2668 pDevice->byBBVGACurrent = pDevice->abyBBVGA[0];
2669 BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent);
2670 BBvSetShortSlotTime(pDevice);
2674 // 1. In Ad-hoc mode : check if received others beacon as jointed indication,
2675 // otherwise we will start own IBSS.
2676 // 2. In Infra mode : Supposed we already synchronized with AP right now.
2678 if (uBSSMode == WMAC_MODE_IBSS_STA) {
2679 MACvRegBitsOn(pDevice, MAC_REG_HOSTCR, HOSTCR_ADHOC);
2680 MACvRegBitsOn(pDevice, MAC_REG_RCR, RCR_BSSID);
2681 pDevice->byRxMode |= RCR_BSSID;
2682 pMgmt->bCurrBSSIDFilterOn = true;
2685 if (pDevice->byBBType == BB_TYPE_11A) {
2686 memcpy(pMgmt->abyCurrSuppRates, &abyCurrSuppRatesA[0], sizeof(abyCurrSuppRatesA));
2687 pMgmt->abyCurrExtSuppRates[1] = 0;
2688 } else if (pDevice->byBBType == BB_TYPE_11B) {
2689 memcpy(pMgmt->abyCurrSuppRates, &abyCurrSuppRatesB[0], sizeof(abyCurrSuppRatesB));
2690 pMgmt->abyCurrExtSuppRates[1] = 0;
2692 memcpy(pMgmt->abyCurrSuppRates, &abyCurrSuppRatesG[0], sizeof(abyCurrSuppRatesG));
2693 memcpy(pMgmt->abyCurrExtSuppRates, &abyCurrExtSuppRatesG[0], sizeof(abyCurrExtSuppRatesG));
2695 pMgmt->byERPContext = pCurr->sERP.byERP;
2697 *pStatus = CMD_STATUS_SUCCESS;
2702 static void Encyption_Rebuild(struct vnt_private *pDevice, PKnownBSS pCurr)
2704 struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
2706 if ((pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) ||
2707 (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) {
2708 if (pCurr->bWPAValid == true) { /*WPA-PSK */
2709 pMgmt->eAuthenMode = WMAC_AUTH_WPAPSK;
2710 if(pCurr->abyPKType[0] == WPA_TKIP) {
2711 pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled; //TKIP
2712 PRINT_K("Encyption_Rebuild--->ssid reset config to [WPAPSK-TKIP]\n");
2714 else if(pCurr->abyPKType[0] == WPA_AESCCMP) {
2715 pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled; //AES
2716 PRINT_K("Encyption_Rebuild--->ssid reset config to [WPAPSK-AES]\n");
2719 else if(pCurr->bWPA2Valid == true) { //WPA2-PSK
2720 pMgmt->eAuthenMode = WMAC_AUTH_WPA2PSK;
2721 if(pCurr->abyCSSPK[0] == WLAN_11i_CSS_TKIP) {
2722 pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled; //TKIP
2723 PRINT_K("Encyption_Rebuild--->ssid reset config to [WPA2PSK-TKIP]\n");
2725 else if(pCurr->abyCSSPK[0] == WLAN_11i_CSS_CCMP) {
2726 pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled; //AES
2727 PRINT_K("Encyption_Rebuild--->ssid reset config to [WPA2PSK-AES]\n");
2737 * Routine Description:
2746 static void s_vMgrFormatTIM(struct vnt_manager *pMgmt, PWLAN_IE_TIM pTIM)
2748 u8 byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
2751 int bStartFound = false;
2752 int bMulticast = false;
2753 u16 wStartIndex = 0;
2756 // Find size of partial virtual bitmap
2757 for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) {
2758 byMap = pMgmt->abyPSTxMap[ii];
2760 // Mask out the broadcast bit which is indicated separately.
2761 bMulticast = (byMap & byMask[0]) != 0;
2763 pMgmt->sNodeDBTable[0].bRxPSPoll = true;
2770 wStartIndex = (u16)ii;
2772 wEndIndex = (u16)ii;
2776 // Round start index down to nearest even number
2777 wStartIndex &= ~BIT0;
2779 // Round end index up to nearest even number
2780 wEndIndex = ((wEndIndex + 1) & ~BIT0);
2782 // Size of element payload
2784 pTIM->len = 3 + (wEndIndex - wStartIndex) + 1;
2786 // Fill in the Fixed parts of the TIM
2787 pTIM->byDTIMCount = pMgmt->byDTIMCount;
2788 pTIM->byDTIMPeriod = pMgmt->byDTIMPeriod;
2789 pTIM->byBitMapCtl = (bMulticast ? TIM_MULTICAST_MASK : 0) |
2790 (((wStartIndex >> 1) << 1) & TIM_BITMAPOFFSET_MASK);
2792 // Append variable part of TIM
2794 for (ii = wStartIndex, jj =0 ; ii <= wEndIndex; ii++, jj++) {
2795 pTIM->byVirtBitMap[jj] = pMgmt->abyPSTxMap[ii];
2798 // Aid = 0 don't used.
2799 pTIM->byVirtBitMap[0] &= ~BIT0;
2804 * Routine Description:
2805 * Constructs an Beacon frame( Ad-hoc mode)
2809 * PTR to frame; or NULL on allocation failure
2813 static struct vnt_tx_mgmt *s_MgrMakeBeacon(struct vnt_private *pDevice,
2814 struct vnt_manager *pMgmt, u16 wCurrCapInfo, u16 wCurrBeaconPeriod,
2815 u32 uCurrChannel, u16 wCurrATIMWinodw, PWLAN_IE_SSID pCurrSSID,
2816 u8 *pCurrBSSID, PWLAN_IE_SUPP_RATES pCurrSuppRates,
2817 PWLAN_IE_SUPP_RATES pCurrExtSuppRates)
2819 struct vnt_tx_mgmt *pTxPacket = NULL;
2820 WLAN_FR_BEACON sFrame;
2821 u8 abyBroadcastAddr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2823 /* prepare beacon frame */
2824 pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool;
2825 memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt)
2826 + WLAN_BEACON_FR_MAXLEN);
2827 pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket
2828 + sizeof(struct vnt_tx_mgmt));
2829 // Setup the sFrame structure.
2830 sFrame.pBuf = (u8 *)pTxPacket->p80211Header;
2831 sFrame.len = WLAN_BEACON_FR_MAXLEN;
2832 vMgrEncodeBeacon(&sFrame);
2834 sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
2836 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
2837 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_BEACON)
2840 if (pDevice->bEnablePSMode) {
2841 sFrame.pHdr->sA3.wFrameCtl |= cpu_to_le16((u16)WLAN_SET_FC_PWRMGT(1));
2844 memcpy( sFrame.pHdr->sA3.abyAddr1, abyBroadcastAddr, WLAN_ADDR_LEN);
2845 memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
2846 memcpy( sFrame.pHdr->sA3.abyAddr3, pCurrBSSID, WLAN_BSSID_LEN);
2847 *sFrame.pwBeaconInterval = cpu_to_le16(wCurrBeaconPeriod);
2848 *sFrame.pwCapInfo = cpu_to_le16(wCurrCapInfo);
2850 sFrame.pSSID = (PWLAN_IE_SSID)(sFrame.pBuf + sFrame.len);
2851 sFrame.len += ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len + WLAN_IEHDR_LEN;
2852 memcpy(sFrame.pSSID,
2854 ((PWLAN_IE_SSID)pCurrSSID)->len + WLAN_IEHDR_LEN
2856 // Copy the rate set
2857 sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
2858 sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN;
2859 memcpy(sFrame.pSuppRates,
2861 ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN
2864 if (pDevice->byBBType != BB_TYPE_11A) {
2865 sFrame.pDSParms = (PWLAN_IE_DS_PARMS)(sFrame.pBuf + sFrame.len);
2866 sFrame.len += (1) + WLAN_IEHDR_LEN;
2867 sFrame.pDSParms->byElementID = WLAN_EID_DS_PARMS;
2868 sFrame.pDSParms->len = 1;
2869 sFrame.pDSParms->byCurrChannel = (u8)uCurrChannel;
2872 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
2873 sFrame.pTIM = (PWLAN_IE_TIM)(sFrame.pBuf + sFrame.len);
2874 sFrame.pTIM->byElementID = WLAN_EID_TIM;
2875 s_vMgrFormatTIM(pMgmt, sFrame.pTIM);
2876 sFrame.len += (WLAN_IEHDR_LEN + sFrame.pTIM->len);
2879 if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
2882 sFrame.pIBSSParms = (PWLAN_IE_IBSS_PARMS)(sFrame.pBuf + sFrame.len);
2883 sFrame.len += (2) + WLAN_IEHDR_LEN;
2884 sFrame.pIBSSParms->byElementID = WLAN_EID_IBSS_PARMS;
2885 sFrame.pIBSSParms->len = 2;
2886 sFrame.pIBSSParms->wATIMWindow = wCurrATIMWinodw;
2887 if (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) {
2889 sFrame.pRSNWPA = (PWLAN_IE_RSN_EXT)(sFrame.pBuf + sFrame.len);
2890 sFrame.pRSNWPA->byElementID = WLAN_EID_RSN_WPA;
2891 sFrame.pRSNWPA->len = 12;
2892 sFrame.pRSNWPA->abyOUI[0] = 0x00;
2893 sFrame.pRSNWPA->abyOUI[1] = 0x50;
2894 sFrame.pRSNWPA->abyOUI[2] = 0xf2;
2895 sFrame.pRSNWPA->abyOUI[3] = 0x01;
2896 sFrame.pRSNWPA->wVersion = 1;
2897 sFrame.pRSNWPA->abyMulticast[0] = 0x00;
2898 sFrame.pRSNWPA->abyMulticast[1] = 0x50;
2899 sFrame.pRSNWPA->abyMulticast[2] = 0xf2;
2900 if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled)
2901 sFrame.pRSNWPA->abyMulticast[3] = 0x04;//AES
2902 else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled)
2903 sFrame.pRSNWPA->abyMulticast[3] = 0x02;//TKIP
2904 else if (pDevice->eEncryptionStatus == Ndis802_11Encryption1Enabled)
2905 sFrame.pRSNWPA->abyMulticast[3] = 0x01;//WEP40
2907 sFrame.pRSNWPA->abyMulticast[3] = 0x00;//NONE
2909 // Pairwise Key Cipher Suite
2910 sFrame.pRSNWPA->wPKCount = 0;
2911 // Auth Key Management Suite
2912 *((u16 *)(sFrame.pBuf + sFrame.len + sFrame.pRSNWPA->len))=0;
2913 sFrame.pRSNWPA->len +=2;
2916 *((u16 *)(sFrame.pBuf + sFrame.len + sFrame.pRSNWPA->len))=0;
2917 sFrame.pRSNWPA->len +=2;
2918 sFrame.len += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN;
2922 if (pMgmt->eCurrentPHYMode == PHY_TYPE_11G) {
2923 sFrame.pERP = (PWLAN_IE_ERP)(sFrame.pBuf + sFrame.len);
2924 sFrame.len += 1 + WLAN_IEHDR_LEN;
2925 sFrame.pERP->byElementID = WLAN_EID_ERP;
2926 sFrame.pERP->len = 1;
2927 sFrame.pERP->byContext = 0;
2928 if (pDevice->bProtectMode == true)
2929 sFrame.pERP->byContext |= WLAN_EID_ERP_USE_PROTECTION;
2930 if (pDevice->bNonERPPresent == true)
2931 sFrame.pERP->byContext |= WLAN_EID_ERP_NONERP_PRESENT;
2932 if (pDevice->bBarkerPreambleMd == true)
2933 sFrame.pERP->byContext |= WLAN_EID_ERP_BARKER_MODE;
2935 if (((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len != 0) {
2936 sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
2937 sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN;
2938 memcpy(sFrame.pExtSuppRates,
2940 ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN
2943 // hostapd wpa/wpa2 IE
2944 if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && (pDevice->bEnableHostapd == true)) {
2945 if (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) {
2946 if (pMgmt->wWPAIELen != 0) {
2947 sFrame.pRSN = (PWLAN_IE_RSN)(sFrame.pBuf + sFrame.len);
2948 memcpy(sFrame.pRSN, pMgmt->abyWPAIE, pMgmt->wWPAIELen);
2949 sFrame.len += pMgmt->wWPAIELen;
2954 /* Adjust the length fields */
2955 pTxPacket->cbMPDULen = sFrame.len;
2956 pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
2963 * Routine Description:
2964 * Constructs an Prob-response frame
2968 * PTR to frame; or NULL on allocation failure
2972 struct vnt_tx_mgmt *s_MgrMakeProbeResponse(struct vnt_private *pDevice,
2973 struct vnt_manager *pMgmt, u16 wCurrCapInfo, u16 wCurrBeaconPeriod,
2974 u32 uCurrChannel, u16 wCurrATIMWinodw, u8 *pDstAddr,
2975 PWLAN_IE_SSID pCurrSSID, u8 *pCurrBSSID,
2976 PWLAN_IE_SUPP_RATES pCurrSuppRates,
2977 PWLAN_IE_SUPP_RATES pCurrExtSuppRates, u8 byPHYType)
2979 struct vnt_tx_mgmt *pTxPacket = NULL;
2980 WLAN_FR_PROBERESP sFrame;
2982 pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool;
2983 memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt)
2984 + WLAN_PROBERESP_FR_MAXLEN);
2985 pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket
2986 + sizeof(struct vnt_tx_mgmt));
2987 // Setup the sFrame structure.
2988 sFrame.pBuf = (u8 *)pTxPacket->p80211Header;
2989 sFrame.len = WLAN_PROBERESP_FR_MAXLEN;
2990 vMgrEncodeProbeResponse(&sFrame);
2992 sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
2994 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
2995 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_PROBERESP)
2997 memcpy( sFrame.pHdr->sA3.abyAddr1, pDstAddr, WLAN_ADDR_LEN);
2998 memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
2999 memcpy( sFrame.pHdr->sA3.abyAddr3, pCurrBSSID, WLAN_BSSID_LEN);
3000 *sFrame.pwBeaconInterval = cpu_to_le16(wCurrBeaconPeriod);
3001 *sFrame.pwCapInfo = cpu_to_le16(wCurrCapInfo);
3003 if (byPHYType == BB_TYPE_11B) {
3004 *sFrame.pwCapInfo &= cpu_to_le16((u16)~(WLAN_SET_CAP_INFO_SHORTSLOTTIME(1)));
3008 sFrame.pSSID = (PWLAN_IE_SSID)(sFrame.pBuf + sFrame.len);
3009 sFrame.len += ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len + WLAN_IEHDR_LEN;
3010 memcpy(sFrame.pSSID,
3012 ((PWLAN_IE_SSID)pCurrSSID)->len + WLAN_IEHDR_LEN
3014 // Copy the rate set
3015 sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
3017 sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN;
3018 memcpy(sFrame.pSuppRates,
3020 ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN
3024 if (pDevice->byBBType != BB_TYPE_11A) {
3025 sFrame.pDSParms = (PWLAN_IE_DS_PARMS)(sFrame.pBuf + sFrame.len);
3026 sFrame.len += (1) + WLAN_IEHDR_LEN;
3027 sFrame.pDSParms->byElementID = WLAN_EID_DS_PARMS;
3028 sFrame.pDSParms->len = 1;
3029 sFrame.pDSParms->byCurrChannel = (u8)uCurrChannel;
3032 if (pMgmt->eCurrMode != WMAC_MODE_ESS_AP) {
3034 sFrame.pIBSSParms = (PWLAN_IE_IBSS_PARMS)(sFrame.pBuf + sFrame.len);
3035 sFrame.len += (2) + WLAN_IEHDR_LEN;
3036 sFrame.pIBSSParms->byElementID = WLAN_EID_IBSS_PARMS;
3037 sFrame.pIBSSParms->len = 2;
3038 sFrame.pIBSSParms->wATIMWindow = 0;
3040 if (pDevice->byBBType == BB_TYPE_11G) {
3041 sFrame.pERP = (PWLAN_IE_ERP)(sFrame.pBuf + sFrame.len);
3042 sFrame.len += 1 + WLAN_IEHDR_LEN;
3043 sFrame.pERP->byElementID = WLAN_EID_ERP;
3044 sFrame.pERP->len = 1;
3045 sFrame.pERP->byContext = 0;
3046 if (pDevice->bProtectMode == true)
3047 sFrame.pERP->byContext |= WLAN_EID_ERP_USE_PROTECTION;
3048 if (pDevice->bNonERPPresent == true)
3049 sFrame.pERP->byContext |= WLAN_EID_ERP_NONERP_PRESENT;
3050 if (pDevice->bBarkerPreambleMd == true)
3051 sFrame.pERP->byContext |= WLAN_EID_ERP_BARKER_MODE;
3054 if (((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len != 0) {
3055 sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
3056 sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN;
3057 memcpy(sFrame.pExtSuppRates,
3059 ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN
3063 // hostapd wpa/wpa2 IE
3064 if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && (pDevice->bEnableHostapd == true)) {
3065 if (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) {
3066 if (pMgmt->wWPAIELen != 0) {
3067 sFrame.pRSN = (PWLAN_IE_RSN)(sFrame.pBuf + sFrame.len);
3068 memcpy(sFrame.pRSN, pMgmt->abyWPAIE, pMgmt->wWPAIELen);
3069 sFrame.len += pMgmt->wWPAIELen;
3074 // Adjust the length fields
3075 pTxPacket->cbMPDULen = sFrame.len;
3076 pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
3083 * Routine Description:
3084 * Constructs an association request frame
3088 * A ptr to frame or NULL on allocation failure
3092 struct vnt_tx_mgmt *s_MgrMakeAssocRequest(struct vnt_private *pDevice,
3093 struct vnt_manager *pMgmt, u8 *pDAddr, u16 wCurrCapInfo,
3094 u16 wListenInterval,
3095 PWLAN_IE_SSID pCurrSSID,
3096 PWLAN_IE_SUPP_RATES pCurrRates,
3097 PWLAN_IE_SUPP_RATES pCurrExtSuppRates)
3099 struct vnt_tx_mgmt *pTxPacket = NULL;
3100 WLAN_FR_ASSOCREQ sFrame;
3104 pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool;
3105 memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt)
3106 + WLAN_ASSOCREQ_FR_MAXLEN);
3107 pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket
3108 + sizeof(struct vnt_tx_mgmt));
3109 // Setup the sFrame structure.
3110 sFrame.pBuf = (u8 *)pTxPacket->p80211Header;
3111 sFrame.len = WLAN_ASSOCREQ_FR_MAXLEN;
3112 // format fixed field frame structure
3113 vMgrEncodeAssocRequest(&sFrame);
3115 sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
3117 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
3118 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ASSOCREQ)
3120 memcpy( sFrame.pHdr->sA3.abyAddr1, pDAddr, WLAN_ADDR_LEN);
3121 memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
3122 memcpy( sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
3124 // Set the capability and listen interval
3125 *(sFrame.pwCapInfo) = cpu_to_le16(wCurrCapInfo);
3126 *(sFrame.pwListenInterval) = cpu_to_le16(wListenInterval);
3128 // sFrame.len point to end of fixed field
3129 sFrame.pSSID = (PWLAN_IE_SSID)(sFrame.pBuf + sFrame.len);
3130 sFrame.len += pCurrSSID->len + WLAN_IEHDR_LEN;
3131 memcpy(sFrame.pSSID, pCurrSSID, pCurrSSID->len + WLAN_IEHDR_LEN);
3133 pMgmt->sAssocInfo.AssocInfo.RequestIELength = pCurrSSID->len + WLAN_IEHDR_LEN;
3134 pMgmt->sAssocInfo.AssocInfo.OffsetRequestIEs = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION);
3135 pbyIEs = pMgmt->sAssocInfo.abyIEs;
3136 memcpy(pbyIEs, pCurrSSID, pCurrSSID->len + WLAN_IEHDR_LEN);
3137 pbyIEs += pCurrSSID->len + WLAN_IEHDR_LEN;
3139 // Copy the rate set
3140 sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
3141 if ((pDevice->byBBType == BB_TYPE_11B) && (pCurrRates->len > 4))
3142 sFrame.len += 4 + WLAN_IEHDR_LEN;
3144 sFrame.len += pCurrRates->len + WLAN_IEHDR_LEN;
3145 memcpy(sFrame.pSuppRates, pCurrRates, pCurrRates->len + WLAN_IEHDR_LEN);
3147 // Copy the extension rate set
3148 if ((pDevice->byBBType == BB_TYPE_11G) && (pCurrExtSuppRates->len > 0)) {
3149 sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
3150 sFrame.len += pCurrExtSuppRates->len + WLAN_IEHDR_LEN;
3151 memcpy(sFrame.pExtSuppRates, pCurrExtSuppRates, pCurrExtSuppRates->len + WLAN_IEHDR_LEN);
3154 pMgmt->sAssocInfo.AssocInfo.RequestIELength += pCurrRates->len + WLAN_IEHDR_LEN;
3155 memcpy(pbyIEs, pCurrRates, pCurrRates->len + WLAN_IEHDR_LEN);
3156 pbyIEs += pCurrRates->len + WLAN_IEHDR_LEN;
3158 if (((pMgmt->eAuthenMode == WMAC_AUTH_WPA) ||
3159 (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) ||
3160 (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE)) &&
3161 (pMgmt->pCurrBSS != NULL)) {
3163 sFrame.pRSNWPA = (PWLAN_IE_RSN_EXT)(sFrame.pBuf + sFrame.len);
3164 sFrame.pRSNWPA->byElementID = WLAN_EID_RSN_WPA;
3165 sFrame.pRSNWPA->len = 16;
3166 sFrame.pRSNWPA->abyOUI[0] = 0x00;
3167 sFrame.pRSNWPA->abyOUI[1] = 0x50;
3168 sFrame.pRSNWPA->abyOUI[2] = 0xf2;
3169 sFrame.pRSNWPA->abyOUI[3] = 0x01;
3170 sFrame.pRSNWPA->wVersion = 1;
3171 //Group Key Cipher Suite
3172 sFrame.pRSNWPA->abyMulticast[0] = 0x00;
3173 sFrame.pRSNWPA->abyMulticast[1] = 0x50;
3174 sFrame.pRSNWPA->abyMulticast[2] = 0xf2;
3175 if (pMgmt->byCSSGK == KEY_CTL_WEP) {
3176 sFrame.pRSNWPA->abyMulticast[3] = pMgmt->pCurrBSS->byGKType;
3177 } else if (pMgmt->byCSSGK == KEY_CTL_TKIP) {
3178 sFrame.pRSNWPA->abyMulticast[3] = WPA_TKIP;
3179 } else if (pMgmt->byCSSGK == KEY_CTL_CCMP) {
3180 sFrame.pRSNWPA->abyMulticast[3] = WPA_AESCCMP;
3182 sFrame.pRSNWPA->abyMulticast[3] = WPA_NONE;
3184 // Pairwise Key Cipher Suite
3185 sFrame.pRSNWPA->wPKCount = 1;
3186 sFrame.pRSNWPA->PKSList[0].abyOUI[0] = 0x00;
3187 sFrame.pRSNWPA->PKSList[0].abyOUI[1] = 0x50;
3188 sFrame.pRSNWPA->PKSList[0].abyOUI[2] = 0xf2;
3189 if (pMgmt->byCSSPK == KEY_CTL_TKIP) {
3190 sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_TKIP;
3191 } else if (pMgmt->byCSSPK == KEY_CTL_CCMP) {
3192 sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_AESCCMP;
3194 sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_NONE;
3196 // Auth Key Management Suite
3197 pbyRSN = (u8 *)(sFrame.pBuf + sFrame.len + 2 + sFrame.pRSNWPA->len);
3204 if (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) {
3205 *pbyRSN++=WPA_AUTH_PSK;
3207 else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA) {
3208 *pbyRSN++=WPA_AUTH_IEEE802_1X;
3214 sFrame.pRSNWPA->len +=6;
3220 sFrame.pRSNWPA->len +=2;
3222 sFrame.len += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN;
3223 // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION
3224 pMgmt->sAssocInfo.AssocInfo.RequestIELength += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN;
3225 memcpy(pbyIEs, sFrame.pRSNWPA, sFrame.pRSNWPA->len + WLAN_IEHDR_LEN);
3226 pbyIEs += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN;
3228 } else if (((pMgmt->eAuthenMode == WMAC_AUTH_WPA2) ||
3229 (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) &&
3230 (pMgmt->pCurrBSS != NULL)) {
3235 sFrame.pRSN = (PWLAN_IE_RSN)(sFrame.pBuf + sFrame.len);
3236 sFrame.pRSN->byElementID = WLAN_EID_RSN;
3237 sFrame.pRSN->len = 6; //Version(2)+GK(4)
3238 sFrame.pRSN->wVersion = 1;
3239 //Group Key Cipher Suite
3240 sFrame.pRSN->abyRSN[0] = 0x00;
3241 sFrame.pRSN->abyRSN[1] = 0x0F;
3242 sFrame.pRSN->abyRSN[2] = 0xAC;
3243 if (pMgmt->byCSSGK == KEY_CTL_WEP) {
3244 sFrame.pRSN->abyRSN[3] = pMgmt->pCurrBSS->byCSSGK;
3245 } else if (pMgmt->byCSSGK == KEY_CTL_TKIP) {
3246 sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_TKIP;
3247 } else if (pMgmt->byCSSGK == KEY_CTL_CCMP) {
3248 sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_CCMP;
3250 sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_UNKNOWN;
3253 // Pairwise Key Cipher Suite
3254 sFrame.pRSN->abyRSN[4] = 1;
3255 sFrame.pRSN->abyRSN[5] = 0;
3256 sFrame.pRSN->abyRSN[6] = 0x00;
3257 sFrame.pRSN->abyRSN[7] = 0x0F;
3258 sFrame.pRSN->abyRSN[8] = 0xAC;
3259 if (pMgmt->byCSSPK == KEY_CTL_TKIP) {
3260 sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_TKIP;
3261 } else if (pMgmt->byCSSPK == KEY_CTL_CCMP) {
3262 sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_CCMP;
3263 } else if (pMgmt->byCSSPK == KEY_CTL_NONE) {
3264 sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_USE_GROUP;
3266 sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_UNKNOWN;
3268 sFrame.pRSN->len += 6;
3270 // Auth Key Management Suite
3271 sFrame.pRSN->abyRSN[10] = 1;
3272 sFrame.pRSN->abyRSN[11] = 0;
3273 sFrame.pRSN->abyRSN[12] = 0x00;
3274 sFrame.pRSN->abyRSN[13] = 0x0F;
3275 sFrame.pRSN->abyRSN[14] = 0xAC;
3276 if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK) {
3277 sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_PSK;
3278 } else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2) {
3279 sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_802_1X;
3281 sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_UNKNOWN;
3283 sFrame.pRSN->len +=6;
3286 if (pMgmt->pCurrBSS->sRSNCapObj.bRSNCapExist == true) {
3287 memcpy(&sFrame.pRSN->abyRSN[16], &pMgmt->pCurrBSS->sRSNCapObj.wRSNCap, 2);
3289 sFrame.pRSN->abyRSN[16] = 0;
3290 sFrame.pRSN->abyRSN[17] = 0;
3292 sFrame.pRSN->len +=2;
3294 if ((pDevice->gsPMKID.BSSIDInfoCount > 0) && (pDevice->bRoaming == true) && (pMgmt->eAuthenMode == WMAC_AUTH_WPA2)) {
3296 pbyRSN = &sFrame.pRSN->abyRSN[18];
3297 pwPMKID = (u16 *)pbyRSN; // Point to PMKID count
3298 *pwPMKID = 0; // Initialize PMKID count
3299 pbyRSN += 2; // Point to PMKID list
3300 for (ii = 0; ii < pDevice->gsPMKID.BSSIDInfoCount; ii++) {
3301 if (!memcmp(&pDevice->gsPMKID.BSSIDInfo[ii].BSSID[0],
3302 pMgmt->abyCurrBSSID,
3306 pDevice->gsPMKID.BSSIDInfo[ii].PMKID,
3311 if (*pwPMKID != 0) {
3312 sFrame.pRSN->len += (2 + (*pwPMKID)*16);
3316 sFrame.len += sFrame.pRSN->len + WLAN_IEHDR_LEN;
3317 // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION
3318 pMgmt->sAssocInfo.AssocInfo.RequestIELength += sFrame.pRSN->len + WLAN_IEHDR_LEN;
3319 memcpy(pbyIEs, sFrame.pRSN, sFrame.pRSN->len + WLAN_IEHDR_LEN);
3320 pbyIEs += sFrame.pRSN->len + WLAN_IEHDR_LEN;
3323 // Adjust the length fields
3324 pTxPacket->cbMPDULen = sFrame.len;
3325 pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
3331 * Routine Description:
3332 * Constructs an re-association request frame
3336 * A ptr to frame or NULL on allocation failure
3340 struct vnt_tx_mgmt *s_MgrMakeReAssocRequest(struct vnt_private *pDevice,
3341 struct vnt_manager *pMgmt, u8 *pDAddr, u16 wCurrCapInfo,
3342 u16 wListenInterval, PWLAN_IE_SSID pCurrSSID,
3343 PWLAN_IE_SUPP_RATES pCurrRates,
3344 PWLAN_IE_SUPP_RATES pCurrExtSuppRates)
3346 struct vnt_tx_mgmt *pTxPacket = NULL;
3347 WLAN_FR_REASSOCREQ sFrame;
3351 pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool;
3352 memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt)
3353 + WLAN_REASSOCREQ_FR_MAXLEN);
3354 pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket
3355 + sizeof(struct vnt_tx_mgmt));
3356 /* Setup the sFrame structure. */
3357 sFrame.pBuf = (u8 *)pTxPacket->p80211Header;
3358 sFrame.len = WLAN_REASSOCREQ_FR_MAXLEN;
3360 // format fixed field frame structure
3361 vMgrEncodeReassocRequest(&sFrame);
3363 /* Setup the header */
3364 sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
3366 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
3367 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_REASSOCREQ)
3369 memcpy( sFrame.pHdr->sA3.abyAddr1, pDAddr, WLAN_ADDR_LEN);
3370 memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
3371 memcpy( sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
3373 /* Set the capability and listen interval */
3374 *(sFrame.pwCapInfo) = cpu_to_le16(wCurrCapInfo);
3375 *(sFrame.pwListenInterval) = cpu_to_le16(wListenInterval);
3377 memcpy(sFrame.pAddrCurrAP, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
3379 /* sFrame.len point to end of fixed field */
3380 sFrame.pSSID = (PWLAN_IE_SSID)(sFrame.pBuf + sFrame.len);
3381 sFrame.len += pCurrSSID->len + WLAN_IEHDR_LEN;
3382 memcpy(sFrame.pSSID, pCurrSSID, pCurrSSID->len + WLAN_IEHDR_LEN);
3384 pMgmt->sAssocInfo.AssocInfo.RequestIELength = pCurrSSID->len + WLAN_IEHDR_LEN;
3385 pMgmt->sAssocInfo.AssocInfo.OffsetRequestIEs = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION);
3386 pbyIEs = pMgmt->sAssocInfo.abyIEs;
3387 memcpy(pbyIEs, pCurrSSID, pCurrSSID->len + WLAN_IEHDR_LEN);
3388 pbyIEs += pCurrSSID->len + WLAN_IEHDR_LEN;
3390 /* Copy the rate set */
3391 /* sFrame.len point to end of SSID */
3392 sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
3393 sFrame.len += pCurrRates->len + WLAN_IEHDR_LEN;
3394 memcpy(sFrame.pSuppRates, pCurrRates, pCurrRates->len + WLAN_IEHDR_LEN);
3396 // Copy the extension rate set
3397 if ((pMgmt->eCurrentPHYMode == PHY_TYPE_11G) && (pCurrExtSuppRates->len > 0)) {
3398 sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
3399 sFrame.len += pCurrExtSuppRates->len + WLAN_IEHDR_LEN;
3400 memcpy(sFrame.pExtSuppRates, pCurrExtSuppRates, pCurrExtSuppRates->len + WLAN_IEHDR_LEN);
3403 pMgmt->sAssocInfo.AssocInfo.RequestIELength += pCurrRates->len + WLAN_IEHDR_LEN;
3404 memcpy(pbyIEs, pCurrRates, pCurrRates->len + WLAN_IEHDR_LEN);
3405 pbyIEs += pCurrRates->len + WLAN_IEHDR_LEN;
3407 if (((pMgmt->eAuthenMode == WMAC_AUTH_WPA) ||
3408 (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) ||
3409 (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE)) &&
3410 (pMgmt->pCurrBSS != NULL)) {
3412 sFrame.pRSNWPA = (PWLAN_IE_RSN_EXT)(sFrame.pBuf + sFrame.len);
3413 sFrame.pRSNWPA->byElementID = WLAN_EID_RSN_WPA;
3414 sFrame.pRSNWPA->len = 16;
3415 sFrame.pRSNWPA->abyOUI[0] = 0x00;
3416 sFrame.pRSNWPA->abyOUI[1] = 0x50;
3417 sFrame.pRSNWPA->abyOUI[2] = 0xf2;
3418 sFrame.pRSNWPA->abyOUI[3] = 0x01;
3419 sFrame.pRSNWPA->wVersion = 1;
3420 //Group Key Cipher Suite
3421 sFrame.pRSNWPA->abyMulticast[0] = 0x00;
3422 sFrame.pRSNWPA->abyMulticast[1] = 0x50;
3423 sFrame.pRSNWPA->abyMulticast[2] = 0xf2;
3424 if (pMgmt->byCSSGK == KEY_CTL_WEP) {
3425 sFrame.pRSNWPA->abyMulticast[3] = pMgmt->pCurrBSS->byGKType;
3426 } else if (pMgmt->byCSSGK == KEY_CTL_TKIP) {
3427 sFrame.pRSNWPA->abyMulticast[3] = WPA_TKIP;
3428 } else if (pMgmt->byCSSGK == KEY_CTL_CCMP) {
3429 sFrame.pRSNWPA->abyMulticast[3] = WPA_AESCCMP;
3431 sFrame.pRSNWPA->abyMulticast[3] = WPA_NONE;
3433 // Pairwise Key Cipher Suite
3434 sFrame.pRSNWPA->wPKCount = 1;
3435 sFrame.pRSNWPA->PKSList[0].abyOUI[0] = 0x00;
3436 sFrame.pRSNWPA->PKSList[0].abyOUI[1] = 0x50;
3437 sFrame.pRSNWPA->PKSList[0].abyOUI[2] = 0xf2;
3438 if (pMgmt->byCSSPK == KEY_CTL_TKIP) {
3439 sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_TKIP;
3440 } else if (pMgmt->byCSSPK == KEY_CTL_CCMP) {
3441 sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_AESCCMP;
3443 sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_NONE;
3445 // Auth Key Management Suite
3446 pbyRSN = (u8 *)(sFrame.pBuf + sFrame.len + 2 + sFrame.pRSNWPA->len);
3453 if (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) {
3454 *pbyRSN++=WPA_AUTH_PSK;
3455 } else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA) {
3456 *pbyRSN++=WPA_AUTH_IEEE802_1X;
3461 sFrame.pRSNWPA->len +=6;
3466 sFrame.pRSNWPA->len +=2;
3468 sFrame.len += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN;
3469 // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION
3470 pMgmt->sAssocInfo.AssocInfo.RequestIELength += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN;
3471 memcpy(pbyIEs, sFrame.pRSNWPA, sFrame.pRSNWPA->len + WLAN_IEHDR_LEN);
3472 pbyIEs += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN;
3474 } else if (((pMgmt->eAuthenMode == WMAC_AUTH_WPA2) ||
3475 (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) &&
3476 (pMgmt->pCurrBSS != NULL)) {
3481 sFrame.pRSN = (PWLAN_IE_RSN)(sFrame.pBuf + sFrame.len);
3482 sFrame.pRSN->byElementID = WLAN_EID_RSN;
3483 sFrame.pRSN->len = 6; //Version(2)+GK(4)
3484 sFrame.pRSN->wVersion = 1;
3485 //Group Key Cipher Suite
3486 sFrame.pRSN->abyRSN[0] = 0x00;
3487 sFrame.pRSN->abyRSN[1] = 0x0F;
3488 sFrame.pRSN->abyRSN[2] = 0xAC;
3489 if (pMgmt->byCSSGK == KEY_CTL_WEP) {
3490 sFrame.pRSN->abyRSN[3] = pMgmt->pCurrBSS->byCSSGK;
3491 } else if (pMgmt->byCSSGK == KEY_CTL_TKIP) {
3492 sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_TKIP;
3493 } else if (pMgmt->byCSSGK == KEY_CTL_CCMP) {
3494 sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_CCMP;
3496 sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_UNKNOWN;
3499 // Pairwise Key Cipher Suite
3500 sFrame.pRSN->abyRSN[4] = 1;
3501 sFrame.pRSN->abyRSN[5] = 0;
3502 sFrame.pRSN->abyRSN[6] = 0x00;
3503 sFrame.pRSN->abyRSN[7] = 0x0F;
3504 sFrame.pRSN->abyRSN[8] = 0xAC;
3505 if (pMgmt->byCSSPK == KEY_CTL_TKIP) {
3506 sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_TKIP;
3507 } else if (pMgmt->byCSSPK == KEY_CTL_CCMP) {
3508 sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_CCMP;
3509 } else if (pMgmt->byCSSPK == KEY_CTL_NONE) {
3510 sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_USE_GROUP;
3512 sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_UNKNOWN;
3514 sFrame.pRSN->len += 6;
3516 // Auth Key Management Suite
3517 sFrame.pRSN->abyRSN[10] = 1;
3518 sFrame.pRSN->abyRSN[11] = 0;
3519 sFrame.pRSN->abyRSN[12] = 0x00;
3520 sFrame.pRSN->abyRSN[13] = 0x0F;
3521 sFrame.pRSN->abyRSN[14] = 0xAC;
3522 if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK) {
3523 sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_PSK;
3524 } else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2) {
3525 sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_802_1X;
3527 sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_UNKNOWN;
3529 sFrame.pRSN->len +=6;
3532 if (pMgmt->pCurrBSS->sRSNCapObj.bRSNCapExist == true) {
3533 memcpy(&sFrame.pRSN->abyRSN[16], &pMgmt->pCurrBSS->sRSNCapObj.wRSNCap, 2);
3535 sFrame.pRSN->abyRSN[16] = 0;
3536 sFrame.pRSN->abyRSN[17] = 0;
3538 sFrame.pRSN->len +=2;
3540 if ((pDevice->gsPMKID.BSSIDInfoCount > 0) && (pDevice->bRoaming == true) && (pMgmt->eAuthenMode == WMAC_AUTH_WPA2)) {
3542 pbyRSN = &sFrame.pRSN->abyRSN[18];
3543 pwPMKID = (u16 *)pbyRSN; // Point to PMKID count
3544 *pwPMKID = 0; // Initialize PMKID count
3545 pbyRSN += 2; // Point to PMKID list
3546 for (ii = 0; ii < pDevice->gsPMKID.BSSIDInfoCount; ii++) {
3547 if (!memcmp(&pDevice->gsPMKID.BSSIDInfo[ii].BSSID[0],
3548 pMgmt->abyCurrBSSID,
3552 pDevice->gsPMKID.BSSIDInfo[ii].PMKID,
3557 if (*pwPMKID != 0) {
3558 sFrame.pRSN->len += (2 + (*pwPMKID)*16);
3562 sFrame.len += sFrame.pRSN->len + WLAN_IEHDR_LEN;
3563 // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION
3564 pMgmt->sAssocInfo.AssocInfo.RequestIELength += sFrame.pRSN->len + WLAN_IEHDR_LEN;
3565 memcpy(pbyIEs, sFrame.pRSN, sFrame.pRSN->len + WLAN_IEHDR_LEN);
3566 pbyIEs += sFrame.pRSN->len + WLAN_IEHDR_LEN;
3569 /* Adjust the length fields */
3570 pTxPacket->cbMPDULen = sFrame.len;
3571 pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
3578 * Routine Description:
3579 * Constructs an assoc-response frame
3583 * PTR to frame; or NULL on allocation failure
3587 struct vnt_tx_mgmt *s_MgrMakeAssocResponse(struct vnt_private *pDevice,
3588 struct vnt_manager *pMgmt, u16 wCurrCapInfo, u16 wAssocStatus,
3589 u16 wAssocAID, u8 *pDstAddr, PWLAN_IE_SUPP_RATES pCurrSuppRates,
3590 PWLAN_IE_SUPP_RATES pCurrExtSuppRates)
3592 struct vnt_tx_mgmt *pTxPacket = NULL;
3593 WLAN_FR_ASSOCRESP sFrame;
3595 pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool;
3596 memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt)
3597 + WLAN_ASSOCREQ_FR_MAXLEN);
3598 pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket
3599 + sizeof(struct vnt_tx_mgmt));
3600 // Setup the sFrame structure
3601 sFrame.pBuf = (u8 *)pTxPacket->p80211Header;
3602 sFrame.len = WLAN_REASSOCRESP_FR_MAXLEN;
3603 vMgrEncodeAssocResponse(&sFrame);
3605 sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
3607 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
3608 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ASSOCRESP)
3610 memcpy( sFrame.pHdr->sA3.abyAddr1, pDstAddr, WLAN_ADDR_LEN);
3611 memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
3612 memcpy( sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
3614 *sFrame.pwCapInfo = cpu_to_le16(wCurrCapInfo);
3615 *sFrame.pwStatus = cpu_to_le16(wAssocStatus);
3616 *sFrame.pwAid = cpu_to_le16((u16)(wAssocAID | BIT14 | BIT15));
3618 // Copy the rate set
3619 sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
3620 sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN;
3621 memcpy(sFrame.pSuppRates,
3623 ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN
3626 if (((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len != 0) {
3627 sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
3628 sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN;
3629 memcpy(sFrame.pExtSuppRates,
3631 ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN
3635 // Adjust the length fields
3636 pTxPacket->cbMPDULen = sFrame.len;
3637 pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
3644 * Routine Description:
3645 * Constructs an reassoc-response frame
3649 * PTR to frame; or NULL on allocation failure
3653 struct vnt_tx_mgmt *s_MgrMakeReAssocResponse(struct vnt_private *pDevice,
3654 struct vnt_manager *pMgmt, u16 wCurrCapInfo, u16 wAssocStatus,
3655 u16 wAssocAID, u8 *pDstAddr, PWLAN_IE_SUPP_RATES pCurrSuppRates,
3656 PWLAN_IE_SUPP_RATES pCurrExtSuppRates)
3658 struct vnt_tx_mgmt *pTxPacket = NULL;
3659 WLAN_FR_REASSOCRESP sFrame;
3661 pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool;
3662 memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt)
3663 + WLAN_ASSOCREQ_FR_MAXLEN);
3664 pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket
3665 + sizeof(struct vnt_tx_mgmt));
3666 // Setup the sFrame structure
3667 sFrame.pBuf = (u8 *)pTxPacket->p80211Header;
3668 sFrame.len = WLAN_REASSOCRESP_FR_MAXLEN;
3669 vMgrEncodeReassocResponse(&sFrame);
3671 sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
3673 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
3674 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_REASSOCRESP)
3676 memcpy( sFrame.pHdr->sA3.abyAddr1, pDstAddr, WLAN_ADDR_LEN);
3677 memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
3678 memcpy( sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
3680 *sFrame.pwCapInfo = cpu_to_le16(wCurrCapInfo);
3681 *sFrame.pwStatus = cpu_to_le16(wAssocStatus);
3682 *sFrame.pwAid = cpu_to_le16((u16)(wAssocAID | BIT14 | BIT15));
3684 // Copy the rate set
3685 sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
3686 sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN;
3687 memcpy(sFrame.pSuppRates,
3689 ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN
3692 if (((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len != 0) {
3693 sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
3694 sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN;
3695 memcpy(sFrame.pExtSuppRates,
3697 ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN
3701 // Adjust the length fields
3702 pTxPacket->cbMPDULen = sFrame.len;
3703 pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
3710 * Routine Description:
3711 * Handles probe response management frames.
3719 static void s_vMgrRxProbeResponse(struct vnt_private *pDevice,
3720 struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket)
3722 PKnownBSS pBSSList = NULL;
3723 WLAN_FR_PROBERESP sFrame;
3724 u8 byCurrChannel = pRxPacket->byRxChannel;
3726 int bChannelHit = true;
3728 memset(&sFrame, 0, sizeof(WLAN_FR_PROBERESP));
3730 sFrame.len = pRxPacket->cbMPDULen;
3731 sFrame.pBuf = (u8 *)pRxPacket->p80211Header;
3732 vMgrDecodeProbeResponse(&sFrame);
3734 if ((sFrame.pqwTimestamp == NULL)
3735 || (sFrame.pwBeaconInterval == NULL)
3736 || (sFrame.pwCapInfo == NULL)
3737 || (sFrame.pSSID == NULL)
3738 || (sFrame.pSuppRates == NULL)) {
3740 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe resp:Fail addr:[%p]\n",
3741 pRxPacket->p80211Header);
3745 if(sFrame.pSSID->len == 0)
3746 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Rx Probe resp: SSID len = 0 \n");
3748 //{{ RobertYu:20050201, 11a byCurrChannel != sFrame.pDSParms->byCurrChannel mapping
3749 if( byCurrChannel > CB_MAX_CHANNEL_24G )
3751 if (sFrame.pDSParms) {
3752 if (byCurrChannel ==
3753 RFaby11aChannelIndex[sFrame.pDSParms->byCurrChannel-1])
3756 RFaby11aChannelIndex[sFrame.pDSParms->byCurrChannel-1];
3761 if (sFrame.pDSParms) {
3762 if (byCurrChannel == sFrame.pDSParms->byCurrChannel)
3764 byCurrChannel = sFrame.pDSParms->byCurrChannel;
3771 if(ChannelExceedZoneType(pDevice,byCurrChannel)==true)
3775 sERP.byERP = sFrame.pERP->byContext;
3776 sERP.bERPExist = true;
3778 sERP.bERPExist = false;
3782 // update or insert the bss
3783 pBSSList = BSSpAddrIsInBSSList((void *) pDevice,
3784 sFrame.pHdr->sA3.abyAddr3,
3787 BSSbUpdateToBSSList((void *) pDevice,
3788 *sFrame.pqwTimestamp,
3789 *sFrame.pwBeaconInterval,
3795 sFrame.pExtSuppRates,
3802 sFrame.len - WLAN_HDR_ADDR3_LEN,
3803 /* payload of probresponse */
3804 sFrame.pHdr->sA4.abyAddr4,
3805 (void *) pRxPacket);
3807 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Probe resp/insert: RxChannel = : %d\n", byCurrChannel);
3808 BSSbInsertToBSSList((void *) pDevice,
3809 sFrame.pHdr->sA3.abyAddr3,
3810 *sFrame.pqwTimestamp,
3811 *sFrame.pwBeaconInterval,
3816 sFrame.pExtSuppRates,
3822 sFrame.len - WLAN_HDR_ADDR3_LEN,
3823 sFrame.pHdr->sA4.abyAddr4, /* payload of beacon */
3824 (void *) pRxPacket);
3832 * Routine Description:(AP)or(Ad-hoc STA)
3833 * Handles probe request management frames.
3841 static void s_vMgrRxProbeRequest(struct vnt_private *pDevice,
3842 struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket)
3844 WLAN_FR_PROBEREQ sFrame;
3846 struct vnt_tx_mgmt *pTxPacket;
3847 u8 byPHYType = BB_TYPE_11B;
3849 // STA in Ad-hoc mode: when latest TBTT beacon transmit success,
3850 // STA have to response this request.
3851 if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) ||
3852 ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && pDevice->bBeaconSent)) {
3854 memset(&sFrame, 0, sizeof(WLAN_FR_PROBEREQ));
3856 sFrame.len = pRxPacket->cbMPDULen;
3857 sFrame.pBuf = (u8 *)pRxPacket->p80211Header;
3858 vMgrDecodeProbeRequest(&sFrame);
3860 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request rx:MAC addr:%pM\n",
3861 sFrame.pHdr->sA3.abyAddr2);
3863 if (sFrame.pSSID->len != 0) {
3864 if (sFrame.pSSID->len != ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len)
3866 if (memcmp(sFrame.pSSID->abySSID,
3867 ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->abySSID,
3868 ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len) != 0) {
3873 if ((sFrame.pSuppRates->len > 4) || (sFrame.pExtSuppRates != NULL)) {
3874 byPHYType = BB_TYPE_11G;
3877 // Probe response reply..
3878 pTxPacket = s_MgrMakeProbeResponse
3882 pMgmt->wCurrCapInfo,
3883 pMgmt->wCurrBeaconPeriod,
3884 pMgmt->uCurrChannel,
3886 sFrame.pHdr->sA3.abyAddr2,
3887 (PWLAN_IE_SSID)pMgmt->abyCurrSSID,
3888 (u8 *)pMgmt->abyCurrBSSID,
3889 (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
3890 (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates,
3893 if (pTxPacket != NULL ){
3894 /* send the frame */
3895 Status = csMgmt_xmit(pDevice, pTxPacket);
3896 if (Status != CMD_STATUS_PENDING) {
3897 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Probe response tx failed\n");
3900 // DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Probe response tx sending..\n");
3910 * Routine Description:
3912 * Entry point for the reception and handling of 802.11 management
3913 * frames. Makes a determination of the frame type and then calls
3914 * the appropriate function.
3922 void vMgrRxManagePacket(struct vnt_private *pDevice, struct vnt_manager *pMgmt,
3923 struct vnt_rx_mgmt *pRxPacket)
3925 int bInScan = false;
3927 NODE_STATE eNodeState = 0;
3930 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
3931 if (BSSbIsSTAInNodeDB(pDevice, pRxPacket->p80211Header->sA3.abyAddr2, &uNodeIndex))
3932 eNodeState = pMgmt->sNodeDBTable[uNodeIndex].eNodeState;
3935 switch( WLAN_GET_FC_FSTYPE((pRxPacket->p80211Header->sA3.wFrameCtl)) ){
3937 case WLAN_FSTYPE_ASSOCREQ:
3939 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx assocreq\n");
3940 if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) &&
3941 (eNodeState < NODE_AUTH)) {
3942 // send deauth notification
3943 // reason = (6) class 2 received from nonauth sta
3944 vMgrDeAuthenBeginSta(pDevice,
3946 pRxPacket->p80211Header->sA3.abyAddr2,
3950 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wmgr: send vMgrDeAuthenBeginSta 1\n");
3953 s_vMgrRxAssocRequest(pDevice, pMgmt, pRxPacket, uNodeIndex);
3957 case WLAN_FSTYPE_ASSOCRESP:
3959 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx assocresp1\n");
3960 s_vMgrRxAssocResponse(pDevice, pMgmt, pRxPacket, false);
3961 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx assocresp2\n");
3964 case WLAN_FSTYPE_REASSOCREQ:
3966 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx reassocreq\n");
3968 if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) &&
3969 (eNodeState < NODE_AUTH)) {
3970 // send deauth notification
3971 // reason = (6) class 2 received from nonauth sta
3972 vMgrDeAuthenBeginSta(pDevice,
3974 pRxPacket->p80211Header->sA3.abyAddr2,
3978 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wmgr: send vMgrDeAuthenBeginSta 2\n");
3981 s_vMgrRxReAssocRequest(pDevice, pMgmt, pRxPacket, uNodeIndex);
3984 case WLAN_FSTYPE_REASSOCRESP:
3986 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx reassocresp\n");
3987 s_vMgrRxAssocResponse(pDevice, pMgmt, pRxPacket, true);
3990 case WLAN_FSTYPE_PROBEREQ:
3992 //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx probereq\n");
3993 s_vMgrRxProbeRequest(pDevice, pMgmt, pRxPacket);
3996 case WLAN_FSTYPE_PROBERESP:
3998 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx proberesp\n");
4000 s_vMgrRxProbeResponse(pDevice, pMgmt, pRxPacket);
4003 case WLAN_FSTYPE_BEACON:
4005 //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx beacon\n");
4006 if (pMgmt->eScanState != WMAC_NO_SCANNING) {
4009 s_vMgrRxBeacon(pDevice, pMgmt, pRxPacket, bInScan);
4012 case WLAN_FSTYPE_ATIM:
4014 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx atim\n");
4017 case WLAN_FSTYPE_DISASSOC:
4019 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx disassoc\n");
4020 if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) &&
4021 (eNodeState < NODE_AUTH)) {
4022 // send deauth notification
4023 // reason = (6) class 2 received from nonauth sta
4024 vMgrDeAuthenBeginSta(pDevice,
4026 pRxPacket->p80211Header->sA3.abyAddr2,
4030 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wmgr: send vMgrDeAuthenBeginSta 3\n");
4032 s_vMgrRxDisassociation(pDevice, pMgmt, pRxPacket);
4035 case WLAN_FSTYPE_AUTHEN:
4037 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx authen\n");
4038 s_vMgrRxAuthentication(pDevice, pMgmt, pRxPacket);
4041 case WLAN_FSTYPE_DEAUTHEN:
4043 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx deauthen\n");
4044 s_vMgrRxDeauthentication(pDevice, pMgmt, pRxPacket);
4048 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx unknown mgmt\n");
4056 * Routine Description:
4059 * Prepare beacon to send
4062 * true if success; false if failed.
4065 int bMgrPrepareBeaconToSend(struct vnt_private *pDevice,
4066 struct vnt_manager *pMgmt)
4068 struct vnt_tx_mgmt *pTxPacket;
4070 // pDevice->bBeaconBufReady = false;
4071 if (pDevice->bEncryptionEnable || pDevice->bEnable8021x){
4072 pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_PRIVACY(1);
4075 pMgmt->wCurrCapInfo &= ~WLAN_SET_CAP_INFO_PRIVACY(1);
4077 pTxPacket = s_MgrMakeBeacon
4081 pMgmt->wCurrCapInfo,
4082 pMgmt->wCurrBeaconPeriod,
4083 pMgmt->uCurrChannel,
4084 pMgmt->wCurrATIMWindow, //0,
4085 (PWLAN_IE_SSID)pMgmt->abyCurrSSID,
4086 (u8 *)pMgmt->abyCurrBSSID,
4087 (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
4088 (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates
4091 if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) &&
4092 (pMgmt->abyCurrBSSID[0] == 0))
4095 csBeacon_xmit(pDevice, pTxPacket);
4096 MACvRegBitsOn(pDevice, MAC_REG_TCR, TCR_AUTOBCNTX);
4103 * Routine Description:
4105 * Log a warning message based on the contents of the Status
4106 * Code field of an 802.11 management frame. Defines are
4107 * derived from 802.11-1997 SPEC.
4113 static void s_vMgrLogStatus(struct vnt_manager *pMgmt, u16 wStatus)
4116 case WLAN_MGMT_STATUS_UNSPEC_FAILURE:
4117 DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Unspecified error.\n");
4119 case WLAN_MGMT_STATUS_CAPS_UNSUPPORTED:
4120 DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Can't support all requested capabilities.\n");
4122 case WLAN_MGMT_STATUS_REASSOC_NO_ASSOC:
4123 DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Reassoc denied, can't confirm original Association.\n");
4125 case WLAN_MGMT_STATUS_ASSOC_DENIED_UNSPEC:
4126 DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Assoc denied, undefine in spec\n");
4128 case WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG:
4129 DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Peer doesn't support authen algorithm.\n");
4131 case WLAN_MGMT_STATUS_RX_AUTH_NOSEQ:
4132 DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Authen frame received out of sequence.\n");
4134 case WLAN_MGMT_STATUS_CHALLENGE_FAIL:
4135 DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Authen rejected, challenge failure.\n");
4137 case WLAN_MGMT_STATUS_AUTH_TIMEOUT:
4138 DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Authen rejected, timeout waiting for next frame.\n");
4140 case WLAN_MGMT_STATUS_ASSOC_DENIED_BUSY:
4141 DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Assoc denied, AP too busy.\n");
4143 case WLAN_MGMT_STATUS_ASSOC_DENIED_RATES:
4144 DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Assoc denied, we haven't enough basic rates.\n");
4146 case WLAN_MGMT_STATUS_ASSOC_DENIED_SHORTPREAMBLE:
4147 DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Assoc denied, we do not support short preamble.\n");
4149 case WLAN_MGMT_STATUS_ASSOC_DENIED_PBCC:
4150 DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Assoc denied, we do not support PBCC.\n");
4152 case WLAN_MGMT_STATUS_ASSOC_DENIED_AGILITY:
4153 DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Assoc denied, we do not support channel agility.\n");
4156 DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Unknown status code %d.\n", wStatus);
4164 * Add BSSID in PMKID Candidate list.
4168 * hDeviceContext - device structure point
4169 * pbyBSSID - BSSID address for adding
4170 * wRSNCap - BSS's RSN capability
4174 * Return Value: none.
4178 int bAdd_PMKID_Candidate(struct vnt_private *pDevice, u8 *pbyBSSID,
4179 PSRSNCapObject psRSNCapObj)
4181 PPMKID_CANDIDATE pCandidateList;
4184 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"bAdd_PMKID_Candidate START: (%d)\n", (int)pDevice->gsPMKIDCandidate.NumCandidates);
4186 if ((pDevice == NULL) || (pbyBSSID == NULL) || (psRSNCapObj == NULL))
4189 if (pDevice->gsPMKIDCandidate.NumCandidates >= MAX_PMKIDLIST)
4192 // Update Old Candidate
4193 for (ii = 0; ii < pDevice->gsPMKIDCandidate.NumCandidates; ii++) {
4194 pCandidateList = &pDevice->gsPMKIDCandidate.CandidateList[ii];
4195 if (!memcmp(pCandidateList->BSSID, pbyBSSID, ETH_ALEN)) {
4196 if ((psRSNCapObj->bRSNCapExist == true)
4197 && (psRSNCapObj->wRSNCap & BIT0)) {
4198 pCandidateList->Flags |=
4199 NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED;
4201 pCandidateList->Flags &=
4202 ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED);
4209 pCandidateList = &pDevice->gsPMKIDCandidate.CandidateList[pDevice->gsPMKIDCandidate.NumCandidates];
4210 if ((psRSNCapObj->bRSNCapExist == true) && (psRSNCapObj->wRSNCap & BIT0)) {
4211 pCandidateList->Flags |= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED;
4213 pCandidateList->Flags &= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED);
4215 memcpy(pCandidateList->BSSID, pbyBSSID, ETH_ALEN);
4216 pDevice->gsPMKIDCandidate.NumCandidates++;
4217 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"NumCandidates:%d\n", (int)pDevice->gsPMKIDCandidate.NumCandidates);
4224 * Flush PMKID Candidate list.
4228 * hDeviceContext - device structure point
4232 * Return Value: none.
4236 void vFlush_PMKID_Candidate(struct vnt_private *pDevice)
4238 if (pDevice == NULL)
4241 memset(&pDevice->gsPMKIDCandidate, 0, sizeof(SPMKIDCandidateEvent));
4249 NDIS_802_11_ENCRYPTION_STATUS EncStatus,
4254 u8 byMulticastCipher = KEY_CTL_INVALID;
4255 u8 byCipherMask = 0x00;
4258 if (pBSSNode == NULL)
4261 // check cap. of BSS
4262 if ((WLAN_GET_CAP_INFO_PRIVACY(pBSSNode->wCapInfo) != 0) &&
4263 (EncStatus == Ndis802_11Encryption1Enabled)) {
4264 // default is WEP only
4265 byMulticastCipher = KEY_CTL_WEP;
4268 if ((WLAN_GET_CAP_INFO_PRIVACY(pBSSNode->wCapInfo) != 0) &&
4269 (pBSSNode->bWPA2Valid == true) &&
4271 ((EncStatus == Ndis802_11Encryption3Enabled) ||
4272 (EncStatus == Ndis802_11Encryption2Enabled))) {
4274 // check Group Key Cipher
4275 if ((pBSSNode->byCSSGK == WLAN_11i_CSS_WEP40) ||
4276 (pBSSNode->byCSSGK == WLAN_11i_CSS_WEP104)) {
4277 byMulticastCipher = KEY_CTL_WEP;
4278 } else if (pBSSNode->byCSSGK == WLAN_11i_CSS_TKIP) {
4279 byMulticastCipher = KEY_CTL_TKIP;
4280 } else if (pBSSNode->byCSSGK == WLAN_11i_CSS_CCMP) {
4281 byMulticastCipher = KEY_CTL_CCMP;
4283 byMulticastCipher = KEY_CTL_INVALID;
4286 /* check Pairwise Key Cipher */
4287 for (i = 0; i < pBSSNode->wCSSPKCount; i++) {
4288 if ((pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_WEP40) ||
4289 (pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_WEP104)) {
4290 /* this should not happen as defined 802.11i */
4291 byCipherMask |= 0x01;
4292 } else if (pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_TKIP) {
4293 byCipherMask |= 0x02;
4294 } else if (pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_CCMP) {
4295 byCipherMask |= 0x04;
4296 } else if (pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_USE_GROUP) {
4297 /* use group key only ignore all others */
4299 i = pBSSNode->wCSSPKCount;
4303 } else if ((WLAN_GET_CAP_INFO_PRIVACY(pBSSNode->wCapInfo) != 0) &&
4304 (pBSSNode->bWPAValid == true) &&
4305 ((EncStatus == Ndis802_11Encryption2Enabled) || (EncStatus == Ndis802_11Encryption3Enabled))) {
4307 // check Group Key Cipher
4308 if ((pBSSNode->byGKType == WPA_WEP40) ||
4309 (pBSSNode->byGKType == WPA_WEP104)) {
4310 byMulticastCipher = KEY_CTL_WEP;
4311 } else if (pBSSNode->byGKType == WPA_TKIP) {
4312 byMulticastCipher = KEY_CTL_TKIP;
4313 } else if (pBSSNode->byGKType == WPA_AESCCMP) {
4314 byMulticastCipher = KEY_CTL_CCMP;
4316 byMulticastCipher = KEY_CTL_INVALID;
4319 /* check Pairwise Key Cipher */
4320 for (i = 0; i < pBSSNode->wPKCount; i++) {
4321 if (pBSSNode->abyPKType[i] == WPA_TKIP) {
4322 byCipherMask |= 0x02;
4323 } else if (pBSSNode->abyPKType[i] == WPA_AESCCMP) {
4324 byCipherMask |= 0x04;
4325 } else if (pBSSNode->abyPKType[i] == WPA_NONE) {
4326 /* use group key only ignore all others */
4328 i = pBSSNode->wPKCount;
4333 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%d, %d, %d, %d, EncStatus:%d\n",
4334 byMulticastCipher, byCipherMask, pBSSNode->bWPAValid, pBSSNode->bWPA2Valid, EncStatus);
4336 // mask our cap. with BSS
4337 if (EncStatus == Ndis802_11Encryption1Enabled) {
4339 // For supporting Cisco migration mode, don't care pairwise key cipher
4340 //if ((byMulticastCipher == KEY_CTL_WEP) &&
4341 // (byCipherMask == 0)) {
4342 if ((byMulticastCipher == KEY_CTL_WEP) &&
4343 (byCipherMask == 0)) {
4344 *pbyCCSGK = KEY_CTL_WEP;
4345 *pbyCCSPK = KEY_CTL_NONE;
4351 } else if (EncStatus == Ndis802_11Encryption2Enabled) {
4352 if ((byMulticastCipher == KEY_CTL_TKIP) &&
4353 (byCipherMask == 0)) {
4354 *pbyCCSGK = KEY_CTL_TKIP;
4355 *pbyCCSPK = KEY_CTL_NONE;
4357 } else if ((byMulticastCipher == KEY_CTL_WEP) &&
4358 ((byCipherMask & 0x02) != 0)) {
4359 *pbyCCSGK = KEY_CTL_WEP;
4360 *pbyCCSPK = KEY_CTL_TKIP;
4362 } else if ((byMulticastCipher == KEY_CTL_TKIP) &&
4363 ((byCipherMask & 0x02) != 0)) {
4364 *pbyCCSGK = KEY_CTL_TKIP;
4365 *pbyCCSPK = KEY_CTL_TKIP;
4370 } else if (EncStatus == Ndis802_11Encryption3Enabled) {
4371 if ((byMulticastCipher == KEY_CTL_CCMP) &&
4372 (byCipherMask == 0)) {
4373 // When CCMP is enable, "Use group cipher suite" shall not be a valid option.
4375 } else if ((byMulticastCipher == KEY_CTL_WEP) &&
4376 ((byCipherMask & 0x04) != 0)) {
4377 *pbyCCSGK = KEY_CTL_WEP;
4378 *pbyCCSPK = KEY_CTL_CCMP;
4380 } else if ((byMulticastCipher == KEY_CTL_TKIP) &&
4381 ((byCipherMask & 0x04) != 0)) {
4382 *pbyCCSGK = KEY_CTL_TKIP;
4383 *pbyCCSPK = KEY_CTL_CCMP;
4385 } else if ((byMulticastCipher == KEY_CTL_CCMP) &&
4386 ((byCipherMask & 0x04) != 0)) {
4387 *pbyCCSGK = KEY_CTL_CCMP;
4388 *pbyCCSPK = KEY_CTL_CCMP;