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 pDevice
->cbFreeCmdQueue
= CMD_Q_SIZE
;
217 pDevice
->uCmdDequeueIdx
= 0;
218 pDevice
->uCmdEnqueueIdx
= 0;
219 pDevice
->eCommandState
= WLAN_CMD_IDLE
;
220 pDevice
->bCmdRunning
= false;
221 pDevice
->bCmdClear
= false;
228 * Routine Description:
229 * Start the station association procedure. Namely, send an
230 * association request frame to the AP.
237 void vMgrAssocBeginSta(struct vnt_private
*pDevice
,
238 struct vnt_manager
*pMgmt
, PCMD_STATUS pStatus
)
240 struct vnt_tx_mgmt
*pTxPacket
;
242 pMgmt
->wCurrCapInfo
= 0;
243 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_ESS(1);
244 if (pDevice
->bEncryptionEnable
) {
245 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_PRIVACY(1);
247 // always allow receive short preamble
248 //if (pDevice->byPreambleType == 1) {
249 // pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
251 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
252 if (pMgmt
->wListenInterval
== 0)
253 pMgmt
->wListenInterval
= 1; // at least one.
255 // ERP Phy (802.11g) should support short preamble.
256 if (pMgmt
->eCurrentPHYMode
== PHY_TYPE_11G
) {
257 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
258 if (pDevice
->bShortSlotTime
== true)
259 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTSLOTTIME(1);
261 } else if (pMgmt
->eCurrentPHYMode
== PHY_TYPE_11B
) {
262 if (pDevice
->byPreambleType
== 1) {
263 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
266 if (pMgmt
->b11hEnable
== true)
267 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SPECTRUMMNG(1);
269 // build an assocreq frame and send it
270 pTxPacket
= s_MgrMakeAssocRequest
276 pMgmt
->wListenInterval
,
277 (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
,
278 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
279 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
282 if (pTxPacket
!= NULL
){
284 *pStatus
= csMgmt_xmit(pDevice
, pTxPacket
);
285 if (*pStatus
== CMD_STATUS_PENDING
) {
286 pMgmt
->eCurrState
= WMAC_STATE_ASSOCPENDING
;
287 *pStatus
= CMD_STATUS_SUCCESS
;
291 *pStatus
= CMD_STATUS_RESOURCES
;
298 * Routine Description:
299 * Start the station re-association procedure.
306 void vMgrReAssocBeginSta(struct vnt_private
*pDevice
,
307 struct vnt_manager
*pMgmt
, PCMD_STATUS pStatus
)
309 struct vnt_tx_mgmt
*pTxPacket
;
311 pMgmt
->wCurrCapInfo
= 0;
312 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_ESS(1);
313 if (pDevice
->bEncryptionEnable
) {
314 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_PRIVACY(1);
317 //if (pDevice->byPreambleType == 1) {
318 // pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
320 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
322 if (pMgmt
->wListenInterval
== 0)
323 pMgmt
->wListenInterval
= 1; // at least one.
325 // ERP Phy (802.11g) should support short preamble.
326 if (pMgmt
->eCurrentPHYMode
== PHY_TYPE_11G
) {
327 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
328 if (pDevice
->bShortSlotTime
== true)
329 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTSLOTTIME(1);
331 } else if (pMgmt
->eCurrentPHYMode
== PHY_TYPE_11B
) {
332 if (pDevice
->byPreambleType
== 1) {
333 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
336 if (pMgmt
->b11hEnable
== true)
337 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SPECTRUMMNG(1);
339 pTxPacket
= s_MgrMakeReAssocRequest
345 pMgmt
->wListenInterval
,
346 (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
,
347 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
348 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
351 if (pTxPacket
!= NULL
){
353 *pStatus
= csMgmt_xmit(pDevice
, pTxPacket
);
354 if (*pStatus
!= CMD_STATUS_PENDING
) {
355 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Reassociation tx failed.\n");
358 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Reassociation tx sending.\n");
367 * Routine Description:
368 * Send an dis-association request frame to the AP.
375 void vMgrDisassocBeginSta(struct vnt_private
*pDevice
,
376 struct vnt_manager
*pMgmt
, u8
*abyDestAddress
, u16 wReason
,
379 struct vnt_tx_mgmt
*pTxPacket
= NULL
;
380 WLAN_FR_DISASSOC sFrame
;
382 pTxPacket
= (struct vnt_tx_mgmt
*)pMgmt
->pbyMgmtPacketPool
;
383 memset(pTxPacket
, 0, sizeof(struct vnt_tx_mgmt
)
384 + WLAN_DISASSOC_FR_MAXLEN
);
385 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((u8
*)pTxPacket
386 + sizeof(struct vnt_tx_mgmt
));
388 // Setup the sFrame structure
389 sFrame
.pBuf
= (u8
*)pTxPacket
->p80211Header
;
390 sFrame
.len
= WLAN_DISASSOC_FR_MAXLEN
;
392 // format fixed field frame structure
393 vMgrEncodeDisassociation(&sFrame
);
396 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
398 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
399 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_DISASSOC
)
402 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, abyDestAddress
, WLAN_ADDR_LEN
);
403 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
404 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
407 *(sFrame
.pwReason
) = cpu_to_le16(wReason
);
408 pTxPacket
->cbMPDULen
= sFrame
.len
;
409 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
412 *pStatus
= csMgmt_xmit(pDevice
, pTxPacket
);
413 if (*pStatus
== CMD_STATUS_PENDING
) {
414 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
415 *pStatus
= CMD_STATUS_SUCCESS
;
423 * Routine Description:(AP function)
424 * Handle incoming station association request frames.
431 static void s_vMgrRxAssocRequest(struct vnt_private
*pDevice
,
432 struct vnt_manager
*pMgmt
, struct vnt_rx_mgmt
*pRxPacket
,
435 WLAN_FR_ASSOCREQ sFrame
;
437 struct vnt_tx_mgmt
*pTxPacket
;
438 u16 wAssocStatus
= 0;
440 u32 uRateLen
= WLAN_RATES_MAXLEN
;
441 u8 abyCurrSuppRates
[WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1];
442 u8 abyCurrExtSuppRates
[WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1];
444 if (pMgmt
->eCurrMode
!= WMAC_MODE_ESS_AP
)
446 // node index not found
450 //check if node is authenticated
452 memset(&sFrame
, 0, sizeof(WLAN_FR_ASSOCREQ
));
453 memset(abyCurrSuppRates
, 0, WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1);
454 memset(abyCurrExtSuppRates
, 0, WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1);
455 sFrame
.len
= pRxPacket
->cbMPDULen
;
456 sFrame
.pBuf
= (u8
*)pRxPacket
->p80211Header
;
458 vMgrDecodeAssocRequest(&sFrame
);
460 if (pMgmt
->sNodeDBTable
[uNodeIndex
].eNodeState
>= NODE_AUTH
) {
461 pMgmt
->sNodeDBTable
[uNodeIndex
].eNodeState
= NODE_ASSOC
;
462 pMgmt
->sNodeDBTable
[uNodeIndex
].wCapInfo
= cpu_to_le16(*sFrame
.pwCapInfo
);
463 pMgmt
->sNodeDBTable
[uNodeIndex
].wListenInterval
= cpu_to_le16(*sFrame
.pwListenInterval
);
464 pMgmt
->sNodeDBTable
[uNodeIndex
].bPSEnable
=
465 WLAN_GET_FC_PWRMGT(sFrame
.pHdr
->sA3
.wFrameCtl
) ? true : false;
466 // Todo: check sta basic rate, if ap can't support, set status code
467 if (pDevice
->byBBType
== BB_TYPE_11B
) {
468 uRateLen
= WLAN_RATES_MAXLEN_11B
;
470 abyCurrSuppRates
[0] = WLAN_EID_SUPP_RATES
;
471 abyCurrSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)sFrame
.pSuppRates
,
472 (PWLAN_IE_SUPP_RATES
)abyCurrSuppRates
,
474 abyCurrExtSuppRates
[0] = WLAN_EID_EXTSUPP_RATES
;
475 if (pDevice
->byBBType
== BB_TYPE_11G
) {
476 abyCurrExtSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)sFrame
.pExtSuppRates
,
477 (PWLAN_IE_SUPP_RATES
)abyCurrExtSuppRates
,
480 abyCurrExtSuppRates
[1] = 0;
483 RATEvParseMaxRate((void *)pDevice
,
484 (PWLAN_IE_SUPP_RATES
)abyCurrSuppRates
,
485 (PWLAN_IE_SUPP_RATES
)abyCurrExtSuppRates
,
486 false, // do not change our basic rate
487 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxBasicRate
),
488 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
),
489 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wSuppRate
),
490 &(pMgmt
->sNodeDBTable
[uNodeIndex
].byTopCCKBasicRate
),
491 &(pMgmt
->sNodeDBTable
[uNodeIndex
].byTopOFDMBasicRate
)
495 pMgmt
->sNodeDBTable
[uNodeIndex
].wTxDataRate
=
496 pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
;
497 // Todo: check sta preamble, if ap can't support, set status code
498 pMgmt
->sNodeDBTable
[uNodeIndex
].bShortPreamble
=
499 WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame
.pwCapInfo
);
500 pMgmt
->sNodeDBTable
[uNodeIndex
].bShortSlotTime
=
501 WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame
.pwCapInfo
);
502 pMgmt
->sNodeDBTable
[uNodeIndex
].wAID
= (u16
)uNodeIndex
;
503 wAssocStatus
= WLAN_MGMT_STATUS_SUCCESS
;
504 wAssocAID
= (u16
)uNodeIndex
;
505 // check if ERP support
506 if(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
> RATE_11M
)
507 pMgmt
->sNodeDBTable
[uNodeIndex
].bERPExist
= true;
509 if (pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
<= RATE_11M
) {
511 pDevice
->bProtectMode
= true;
512 pDevice
->bNonERPPresent
= true;
514 if (pMgmt
->sNodeDBTable
[uNodeIndex
].bShortPreamble
== false) {
515 pDevice
->bBarkerPreambleMd
= true;
518 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"Associate AID= %d \n", wAssocAID
);
519 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"MAC=%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X \n",
520 sFrame
.pHdr
->sA3
.abyAddr2
[0],
521 sFrame
.pHdr
->sA3
.abyAddr2
[1],
522 sFrame
.pHdr
->sA3
.abyAddr2
[2],
523 sFrame
.pHdr
->sA3
.abyAddr2
[3],
524 sFrame
.pHdr
->sA3
.abyAddr2
[4],
525 sFrame
.pHdr
->sA3
.abyAddr2
[5]
527 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"Max Support rate = %d \n",
528 pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
);
531 // assoc response reply..
532 pTxPacket
= s_MgrMakeAssocResponse
539 sFrame
.pHdr
->sA3
.abyAddr2
,
540 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
541 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
543 if (pTxPacket
!= NULL
){
545 if (pDevice
->bEnableHostapd
) {
549 Status
= csMgmt_xmit(pDevice
, pTxPacket
);
550 if (Status
!= CMD_STATUS_PENDING
) {
551 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Assoc response tx failed\n");
554 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Assoc response tx sending..\n");
564 * Description:(AP function)
565 * Handle incoming station re-association request frames.
569 * pMgmt - Management Object structure
570 * pRxPacket - Received Packet
574 * Return Value: None.
578 static void s_vMgrRxReAssocRequest(struct vnt_private
*pDevice
,
579 struct vnt_manager
*pMgmt
, struct vnt_rx_mgmt
*pRxPacket
,
582 WLAN_FR_REASSOCREQ sFrame
;
584 struct vnt_tx_mgmt
*pTxPacket
;
585 u16 wAssocStatus
= 0;
587 u32 uRateLen
= WLAN_RATES_MAXLEN
;
588 u8 abyCurrSuppRates
[WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1];
589 u8 abyCurrExtSuppRates
[WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1];
591 if (pMgmt
->eCurrMode
!= WMAC_MODE_ESS_AP
)
593 // node index not found
596 //check if node is authenticated
598 memset(&sFrame
, 0, sizeof(WLAN_FR_REASSOCREQ
));
599 sFrame
.len
= pRxPacket
->cbMPDULen
;
600 sFrame
.pBuf
= (u8
*)pRxPacket
->p80211Header
;
601 vMgrDecodeReassocRequest(&sFrame
);
603 if (pMgmt
->sNodeDBTable
[uNodeIndex
].eNodeState
>= NODE_AUTH
) {
604 pMgmt
->sNodeDBTable
[uNodeIndex
].eNodeState
= NODE_ASSOC
;
605 pMgmt
->sNodeDBTable
[uNodeIndex
].wCapInfo
= cpu_to_le16(*sFrame
.pwCapInfo
);
606 pMgmt
->sNodeDBTable
[uNodeIndex
].wListenInterval
= cpu_to_le16(*sFrame
.pwListenInterval
);
607 pMgmt
->sNodeDBTable
[uNodeIndex
].bPSEnable
=
608 WLAN_GET_FC_PWRMGT(sFrame
.pHdr
->sA3
.wFrameCtl
) ? true : false;
609 // Todo: check sta basic rate, if ap can't support, set status code
611 if (pDevice
->byBBType
== BB_TYPE_11B
) {
612 uRateLen
= WLAN_RATES_MAXLEN_11B
;
615 abyCurrSuppRates
[0] = WLAN_EID_SUPP_RATES
;
616 abyCurrSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)sFrame
.pSuppRates
,
617 (PWLAN_IE_SUPP_RATES
)abyCurrSuppRates
,
619 abyCurrExtSuppRates
[0] = WLAN_EID_EXTSUPP_RATES
;
620 if (pDevice
->byBBType
== BB_TYPE_11G
) {
621 abyCurrExtSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)sFrame
.pExtSuppRates
,
622 (PWLAN_IE_SUPP_RATES
)abyCurrExtSuppRates
,
625 abyCurrExtSuppRates
[1] = 0;
628 RATEvParseMaxRate((void *)pDevice
,
629 (PWLAN_IE_SUPP_RATES
)abyCurrSuppRates
,
630 (PWLAN_IE_SUPP_RATES
)abyCurrExtSuppRates
,
631 false, // do not change our basic rate
632 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxBasicRate
),
633 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
),
634 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wSuppRate
),
635 &(pMgmt
->sNodeDBTable
[uNodeIndex
].byTopCCKBasicRate
),
636 &(pMgmt
->sNodeDBTable
[uNodeIndex
].byTopOFDMBasicRate
)
640 pMgmt
->sNodeDBTable
[uNodeIndex
].wTxDataRate
=
641 pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
;
642 // Todo: check sta preamble, if ap can't support, set status code
643 pMgmt
->sNodeDBTable
[uNodeIndex
].bShortPreamble
=
644 WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame
.pwCapInfo
);
645 pMgmt
->sNodeDBTable
[uNodeIndex
].bShortSlotTime
=
646 WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame
.pwCapInfo
);
647 pMgmt
->sNodeDBTable
[uNodeIndex
].wAID
= (u16
)uNodeIndex
;
648 wAssocStatus
= WLAN_MGMT_STATUS_SUCCESS
;
649 wAssocAID
= (u16
)uNodeIndex
;
652 if(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
> RATE_11M
)
653 pMgmt
->sNodeDBTable
[uNodeIndex
].bERPExist
= true;
655 if (pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
<= RATE_11M
) {
657 pDevice
->bProtectMode
= true;
658 pDevice
->bNonERPPresent
= true;
660 if (pMgmt
->sNodeDBTable
[uNodeIndex
].bShortPreamble
== false) {
661 pDevice
->bBarkerPreambleMd
= true;
664 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"Rx ReAssociate AID= %d \n", wAssocAID
);
665 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"MAC=%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X \n",
666 sFrame
.pHdr
->sA3
.abyAddr2
[0],
667 sFrame
.pHdr
->sA3
.abyAddr2
[1],
668 sFrame
.pHdr
->sA3
.abyAddr2
[2],
669 sFrame
.pHdr
->sA3
.abyAddr2
[3],
670 sFrame
.pHdr
->sA3
.abyAddr2
[4],
671 sFrame
.pHdr
->sA3
.abyAddr2
[5]
673 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"Max Support rate = %d \n",
674 pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
);
678 // assoc response reply..
679 pTxPacket
= s_MgrMakeReAssocResponse
686 sFrame
.pHdr
->sA3
.abyAddr2
,
687 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
688 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
691 if (pTxPacket
!= NULL
){
693 if (pDevice
->bEnableHostapd
) {
696 Status
= csMgmt_xmit(pDevice
, pTxPacket
);
697 if (Status
!= CMD_STATUS_PENDING
) {
698 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:ReAssoc response tx failed\n");
701 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:ReAssoc response tx sending..\n");
709 * Routine Description:
710 * Handle incoming association response frames.
717 static void s_vMgrRxAssocResponse(struct vnt_private
*pDevice
,
718 struct vnt_manager
*pMgmt
, struct vnt_rx_mgmt
*pRxPacket
,
721 WLAN_FR_ASSOCRESP sFrame
;
722 PWLAN_IE_SSID pItemSSID
;
725 if (pMgmt
->eCurrState
== WMAC_STATE_ASSOCPENDING
||
726 pMgmt
->eCurrState
== WMAC_STATE_ASSOC
) {
728 sFrame
.len
= pRxPacket
->cbMPDULen
;
729 sFrame
.pBuf
= (u8
*)pRxPacket
->p80211Header
;
731 vMgrDecodeAssocResponse(&sFrame
);
732 if ((sFrame
.pwCapInfo
== NULL
)
733 || (sFrame
.pwStatus
== NULL
)
734 || (sFrame
.pwAid
== NULL
)
735 || (sFrame
.pSuppRates
== NULL
)) {
739 pMgmt
->sAssocInfo
.AssocInfo
.ResponseFixedIEs
.Capabilities
= *(sFrame
.pwCapInfo
);
740 pMgmt
->sAssocInfo
.AssocInfo
.ResponseFixedIEs
.StatusCode
= *(sFrame
.pwStatus
);
741 pMgmt
->sAssocInfo
.AssocInfo
.ResponseFixedIEs
.AssociationId
= *(sFrame
.pwAid
);
742 pMgmt
->sAssocInfo
.AssocInfo
.AvailableResponseFixedIEs
|= 0x07;
744 pMgmt
->sAssocInfo
.AssocInfo
.ResponseIELength
= sFrame
.len
- 24 - 6;
745 pMgmt
->sAssocInfo
.AssocInfo
.OffsetResponseIEs
= pMgmt
->sAssocInfo
.AssocInfo
.OffsetRequestIEs
+ pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
;
746 pbyIEs
= pMgmt
->sAssocInfo
.abyIEs
;
747 pbyIEs
+= pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
;
748 memcpy(pbyIEs
, (sFrame
.pBuf
+ 24 +6), pMgmt
->sAssocInfo
.AssocInfo
.ResponseIELength
);
750 // save values and set current BSS state
751 if (cpu_to_le16((*(sFrame
.pwStatus
))) == WLAN_MGMT_STATUS_SUCCESS
){
753 pMgmt
->wCurrAID
= cpu_to_le16((*(sFrame
.pwAid
)));
754 if ( (pMgmt
->wCurrAID
>> 14) != (BIT0
| BIT1
) )
756 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"AID from AP, has two msb clear.\n");
758 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"Association Successful, AID=%d.\n", pMgmt
->wCurrAID
& ~(BIT14
|BIT15
));
759 pMgmt
->eCurrState
= WMAC_STATE_ASSOC
;
760 BSSvUpdateAPNode((void *) pDevice
,
763 sFrame
.pExtSuppRates
);
764 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
;
765 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"Link with AP(SSID): %s\n", pItemSSID
->abySSID
);
766 pDevice
->bLinkPass
= true;
767 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_INTER
);
769 //if(pDevice->bWPASuppWextEnabled == true)
773 union iwreq_data wrqu
;
778 len
= pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
;
780 memcpy(buf
, pMgmt
->sAssocInfo
.abyIEs
, len
);
781 memset(&wrqu
, 0, sizeof (wrqu
));
782 wrqu
.data
.length
= len
;
783 we_event
= IWEVASSOCREQIE
;
784 PRINT_K("wireless_send_event--->IWEVASSOCREQIE\n");
785 wireless_send_event(pDevice
->dev
, we_event
, &wrqu
, buf
);
789 len
= pMgmt
->sAssocInfo
.AssocInfo
.ResponseIELength
;
792 memcpy(buf
, pbyIEs
, len
);
793 memset(&wrqu
, 0, sizeof (wrqu
));
794 wrqu
.data
.length
= len
;
795 we_event
= IWEVASSOCRESPIE
;
796 PRINT_K("wireless_send_event--->IWEVASSOCRESPIE\n");
797 wireless_send_event(pDevice
->dev
, we_event
, &wrqu
, buf
);
800 memset(&wrqu
, 0, sizeof (wrqu
));
801 memcpy(wrqu
.ap_addr
.sa_data
, &pMgmt
->abyCurrBSSID
[0], ETH_ALEN
);
802 wrqu
.ap_addr
.sa_family
= ARPHRD_ETHER
;
803 PRINT_K("wireless_send_event--->SIOCGIWAP(associated)\n");
804 wireless_send_event(pDevice
->dev
, SIOCGIWAP
, &wrqu
, NULL
);
811 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
814 // jump back to the auth state and indicate the error
815 pMgmt
->eCurrState
= WMAC_STATE_AUTH
;
817 s_vMgrLogStatus(pMgmt
,cpu_to_le16((*(sFrame
.pwStatus
))));
822 //need clear flags related to Networkmanager
823 pDevice
->bwextstep0
= false;
824 pDevice
->bwextstep1
= false;
825 pDevice
->bwextstep2
= false;
826 pDevice
->bwextstep3
= false;
827 pDevice
->bWPASuppWextEnabled
= false;
829 if (pMgmt
->eCurrState
== WMAC_STATE_ASSOC
)
830 schedule_delayed_work(&pDevice
->run_command_work
, 0);
837 * Routine Description:
838 * Start the station authentication procedure. Namely, send an
839 * authentication frame to the AP.
846 void vMgrAuthenBeginSta(struct vnt_private
*pDevice
,
847 struct vnt_manager
*pMgmt
, PCMD_STATUS pStatus
)
849 WLAN_FR_AUTHEN sFrame
;
850 struct vnt_tx_mgmt
*pTxPacket
=
851 (struct vnt_tx_mgmt
*)pMgmt
->pbyMgmtPacketPool
;
853 memset(pTxPacket
, 0, sizeof(struct vnt_tx_mgmt
)
854 + WLAN_AUTHEN_FR_MAXLEN
);
855 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((u8
*)pTxPacket
856 + sizeof(struct vnt_tx_mgmt
));
857 sFrame
.pBuf
= (u8
*)pTxPacket
->p80211Header
;
858 sFrame
.len
= WLAN_AUTHEN_FR_MAXLEN
;
859 vMgrEncodeAuthen(&sFrame
);
861 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
863 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
864 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN
)
866 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pMgmt
->abyCurrBSSID
, WLAN_ADDR_LEN
);
867 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
868 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
869 if (pMgmt
->bShareKeyAlgorithm
)
870 *(sFrame
.pwAuthAlgorithm
) = cpu_to_le16(WLAN_AUTH_ALG_SHAREDKEY
);
872 *(sFrame
.pwAuthAlgorithm
) = cpu_to_le16(WLAN_AUTH_ALG_OPENSYSTEM
);
874 *(sFrame
.pwAuthSequence
) = cpu_to_le16(1);
875 /* Adjust the length fields */
876 pTxPacket
->cbMPDULen
= sFrame
.len
;
877 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
879 *pStatus
= csMgmt_xmit(pDevice
, pTxPacket
);
880 if (*pStatus
== CMD_STATUS_PENDING
){
881 pMgmt
->eCurrState
= WMAC_STATE_AUTHPENDING
;
882 *pStatus
= CMD_STATUS_SUCCESS
;
890 * Routine Description:
891 * Start the station(AP) deauthentication procedure. Namely, send an
892 * deauthentication frame to the AP or Sta.
899 void vMgrDeAuthenBeginSta(struct vnt_private
*pDevice
,
900 struct vnt_manager
*pMgmt
, u8
*abyDestAddress
, u16 wReason
,
903 WLAN_FR_DEAUTHEN sFrame
;
904 struct vnt_tx_mgmt
*pTxPacket
=
905 (struct vnt_tx_mgmt
*)pMgmt
->pbyMgmtPacketPool
;
907 memset(pTxPacket
, 0, sizeof(struct vnt_tx_mgmt
)
908 + WLAN_DEAUTHEN_FR_MAXLEN
);
909 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((u8
*)pTxPacket
910 + sizeof(struct vnt_tx_mgmt
));
911 sFrame
.pBuf
= (u8
*)pTxPacket
->p80211Header
;
912 sFrame
.len
= WLAN_DEAUTHEN_FR_MAXLEN
;
913 vMgrEncodeDeauthen(&sFrame
);
915 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
917 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
918 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_DEAUTHEN
)
921 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, abyDestAddress
, WLAN_ADDR_LEN
);
922 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
923 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
925 *(sFrame
.pwReason
) = cpu_to_le16(wReason
); // deauthen. bcs left BSS
926 /* Adjust the length fields */
927 pTxPacket
->cbMPDULen
= sFrame
.len
;
928 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
930 *pStatus
= csMgmt_xmit(pDevice
, pTxPacket
);
931 if (*pStatus
== CMD_STATUS_PENDING
){
932 *pStatus
= CMD_STATUS_SUCCESS
;
940 * Routine Description:
941 * Handle incoming authentication frames.
948 static void s_vMgrRxAuthentication(struct vnt_private
*pDevice
,
949 struct vnt_manager
*pMgmt
, struct vnt_rx_mgmt
*pRxPacket
)
951 WLAN_FR_AUTHEN sFrame
;
953 // we better be an AP or a STA in AUTHPENDING otherwise ignore
954 if (!(pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
||
955 pMgmt
->eCurrState
== WMAC_STATE_AUTHPENDING
)) {
960 sFrame
.len
= pRxPacket
->cbMPDULen
;
961 sFrame
.pBuf
= (u8
*)pRxPacket
->p80211Header
;
962 vMgrDecodeAuthen(&sFrame
);
963 switch (cpu_to_le16((*(sFrame
.pwAuthSequence
)))){
966 s_vMgrRxAuthenSequence_1(pDevice
,pMgmt
, &sFrame
);
969 s_vMgrRxAuthenSequence_2(pDevice
, pMgmt
, &sFrame
);
973 s_vMgrRxAuthenSequence_3(pDevice
, pMgmt
, &sFrame
);
976 s_vMgrRxAuthenSequence_4(pDevice
, pMgmt
, &sFrame
);
979 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Auth Sequence error, seq = %d\n",
980 cpu_to_le16((*(sFrame
.pwAuthSequence
))));
988 * Routine Description:
989 * Handles incoming authen frames with sequence 1. Currently
990 * assumes we're an AP. So far, no one appears to use authentication
998 static void s_vMgrRxAuthenSequence_1(struct vnt_private
*pDevice
,
999 struct vnt_manager
*pMgmt
, PWLAN_FR_AUTHEN pFrame
)
1001 struct vnt_tx_mgmt
*pTxPacket
= NULL
;
1003 WLAN_FR_AUTHEN sFrame
;
1004 PSKeyItem pTransmitKey
;
1006 /* Insert a Node entry */
1007 if (!BSSbIsSTAInNodeDB(pDevice
, pFrame
->pHdr
->sA3
.abyAddr2
,
1009 BSSvCreateOneNode(pDevice
, &uNodeIndex
);
1010 memcpy(pMgmt
->sNodeDBTable
[uNodeIndex
].abyMACAddr
,
1011 pFrame
->pHdr
->sA3
.abyAddr2
, WLAN_ADDR_LEN
);
1014 if (pMgmt
->bShareKeyAlgorithm
) {
1015 pMgmt
->sNodeDBTable
[uNodeIndex
].eNodeState
= NODE_KNOWN
;
1016 pMgmt
->sNodeDBTable
[uNodeIndex
].byAuthSequence
= 1;
1019 pMgmt
->sNodeDBTable
[uNodeIndex
].eNodeState
= NODE_AUTH
;
1023 pTxPacket
= (struct vnt_tx_mgmt
*)pMgmt
->pbyMgmtPacketPool
;
1024 memset(pTxPacket
, 0, sizeof(struct vnt_tx_mgmt
)
1025 + WLAN_AUTHEN_FR_MAXLEN
);
1026 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((u8
*)pTxPacket
1027 + sizeof(struct vnt_tx_mgmt
));
1028 sFrame
.pBuf
= (u8
*)pTxPacket
->p80211Header
;
1029 sFrame
.len
= WLAN_AUTHEN_FR_MAXLEN
;
1030 // format buffer structure
1031 vMgrEncodeAuthen(&sFrame
);
1033 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
1035 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
1036 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN
)|
1037 WLAN_SET_FC_ISWEP(0)
1039 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pFrame
->pHdr
->sA3
.abyAddr2
, WLAN_ADDR_LEN
);
1040 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
1041 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
1042 *(sFrame
.pwAuthAlgorithm
) = *(pFrame
->pwAuthAlgorithm
);
1043 *(sFrame
.pwAuthSequence
) = cpu_to_le16(2);
1045 if (cpu_to_le16(*(pFrame
->pwAuthAlgorithm
)) == WLAN_AUTH_ALG_SHAREDKEY
) {
1046 if (pMgmt
->bShareKeyAlgorithm
)
1047 *(sFrame
.pwStatus
) = cpu_to_le16(WLAN_MGMT_STATUS_SUCCESS
);
1049 *(sFrame
.pwStatus
) = cpu_to_le16(WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG
);
1052 if (pMgmt
->bShareKeyAlgorithm
)
1053 *(sFrame
.pwStatus
) = cpu_to_le16(WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG
);
1055 *(sFrame
.pwStatus
) = cpu_to_le16(WLAN_MGMT_STATUS_SUCCESS
);
1058 if (pMgmt
->bShareKeyAlgorithm
&&
1059 (cpu_to_le16(*(sFrame
.pwStatus
)) == WLAN_MGMT_STATUS_SUCCESS
)) {
1061 sFrame
.pChallenge
= (PWLAN_IE_CHALLENGE
)(sFrame
.pBuf
+ sFrame
.len
);
1062 sFrame
.len
+= WLAN_CHALLENGE_IE_LEN
;
1063 sFrame
.pChallenge
->byElementID
= WLAN_EID_CHALLENGE
;
1064 sFrame
.pChallenge
->len
= WLAN_CHALLENGE_LEN
;
1065 memset(pMgmt
->abyChallenge
, 0, WLAN_CHALLENGE_LEN
);
1067 if(KeybGetTransmitKey(&(pDevice
->sKey
), pDevice
->abyBroadcastAddr
, GROUP_KEY
, &pTransmitKey
) == true) {
1068 rc4_init(&pDevice
->SBox
, pDevice
->abyPRNG
, pTransmitKey
->uKeyLength
+3);
1069 rc4_encrypt(&pDevice
->SBox
, pMgmt
->abyChallenge
, pMgmt
->abyChallenge
, WLAN_CHALLENGE_LEN
);
1071 memcpy(sFrame
.pChallenge
->abyChallenge
, pMgmt
->abyChallenge
, WLAN_CHALLENGE_LEN
);
1074 /* Adjust the length fields */
1075 pTxPacket
->cbMPDULen
= sFrame
.len
;
1076 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
1078 if (pDevice
->bEnableHostapd
) {
1081 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Authreq_reply sequence_1 tx.. \n");
1082 if (csMgmt_xmit(pDevice
, pTxPacket
) != CMD_STATUS_PENDING
) {
1083 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Authreq_reply sequence_1 tx failed.\n");
1090 * Routine Description:
1091 * Handles incoming auth frames with sequence number 2. Currently
1092 * assumes we're a station.
1100 static void s_vMgrRxAuthenSequence_2(struct vnt_private
*pDevice
,
1101 struct vnt_manager
*pMgmt
, PWLAN_FR_AUTHEN pFrame
)
1103 WLAN_FR_AUTHEN sFrame
;
1104 struct vnt_tx_mgmt
*pTxPacket
= NULL
;
1106 switch (cpu_to_le16((*(pFrame
->pwAuthAlgorithm
))))
1108 case WLAN_AUTH_ALG_OPENSYSTEM
:
1109 if ( cpu_to_le16((*(pFrame
->pwStatus
))) == WLAN_MGMT_STATUS_SUCCESS
){
1110 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"802.11 Authen (OPEN) Successful.\n");
1111 pMgmt
->eCurrState
= WMAC_STATE_AUTH
;
1112 schedule_delayed_work(&pDevice
->run_command_work
, 0);
1115 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"802.11 Authen (OPEN) Failed.\n");
1116 s_vMgrLogStatus(pMgmt
, cpu_to_le16((*(pFrame
->pwStatus
))));
1117 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
1119 if (pDevice
->eCommandState
== WLAN_AUTHENTICATE_WAIT
) {
1120 /* spin_unlock_irq(&pDevice->lock);
1121 vCommandTimerWait((void *) pDevice, 0);
1122 spin_lock_irq(&pDevice->lock); */
1126 case WLAN_AUTH_ALG_SHAREDKEY
:
1128 if (cpu_to_le16((*(pFrame
->pwStatus
))) == WLAN_MGMT_STATUS_SUCCESS
) {
1129 pTxPacket
= (struct vnt_tx_mgmt
*)
1130 pMgmt
->pbyMgmtPacketPool
;
1131 memset(pTxPacket
, 0, sizeof(struct vnt_tx_mgmt
)
1132 + WLAN_AUTHEN_FR_MAXLEN
);
1133 pTxPacket
->p80211Header
1134 = (PUWLAN_80211HDR
)((u8
*)pTxPacket
1135 + sizeof(struct vnt_tx_mgmt
));
1136 sFrame
.pBuf
= (u8
*)pTxPacket
->p80211Header
;
1137 sFrame
.len
= WLAN_AUTHEN_FR_MAXLEN
;
1138 // format buffer structure
1139 vMgrEncodeAuthen(&sFrame
);
1141 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
1143 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
1144 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN
)|
1145 WLAN_SET_FC_ISWEP(1)
1147 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
1148 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
1149 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
1150 *(sFrame
.pwAuthAlgorithm
) = *(pFrame
->pwAuthAlgorithm
);
1151 *(sFrame
.pwAuthSequence
) = cpu_to_le16(3);
1152 *(sFrame
.pwStatus
) = cpu_to_le16(WLAN_MGMT_STATUS_SUCCESS
);
1153 sFrame
.pChallenge
= (PWLAN_IE_CHALLENGE
)(sFrame
.pBuf
+ sFrame
.len
);
1154 sFrame
.len
+= WLAN_CHALLENGE_IE_LEN
;
1155 sFrame
.pChallenge
->byElementID
= WLAN_EID_CHALLENGE
;
1156 sFrame
.pChallenge
->len
= WLAN_CHALLENGE_LEN
;
1157 memcpy( sFrame
.pChallenge
->abyChallenge
, pFrame
->pChallenge
->abyChallenge
, WLAN_CHALLENGE_LEN
);
1158 // Adjust the length fields
1159 pTxPacket
->cbMPDULen
= sFrame
.len
;
1160 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
1162 if (csMgmt_xmit(pDevice
, pTxPacket
) != CMD_STATUS_PENDING
) {
1163 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Auth_reply sequence_2 tx failed.\n");
1165 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Auth_reply sequence_2 tx ...\n");
1168 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:rx Auth_reply sequence_2 status error ...\n");
1169 if ( pDevice
->eCommandState
== WLAN_AUTHENTICATE_WAIT
) {
1170 /* spin_unlock_irq(&pDevice->lock);
1171 vCommandTimerWait((void *) pDevice, 0);
1172 spin_lock_irq(&pDevice->lock); */
1174 s_vMgrLogStatus(pMgmt
, cpu_to_le16((*(pFrame
->pwStatus
))));
1178 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt: rx auth.seq = 2 unknown AuthAlgorithm=%d\n", cpu_to_le16((*(pFrame
->pwAuthAlgorithm
))));
1186 * Routine Description:
1187 * Handles incoming authen frames with sequence 3. Currently
1188 * assumes we're an AP. This function assumes the frame has
1189 * already been successfully decrypted.
1197 static void s_vMgrRxAuthenSequence_3(struct vnt_private
*pDevice
,
1198 struct vnt_manager
*pMgmt
, PWLAN_FR_AUTHEN pFrame
)
1200 struct vnt_tx_mgmt
*pTxPacket
= NULL
;
1201 u32 uStatusCode
= 0 ;
1203 WLAN_FR_AUTHEN sFrame
;
1205 if (!WLAN_GET_FC_ISWEP(pFrame
->pHdr
->sA3
.wFrameCtl
)) {
1206 uStatusCode
= WLAN_MGMT_STATUS_CHALLENGE_FAIL
;
1209 if (BSSbIsSTAInNodeDB(pDevice
, pFrame
->pHdr
->sA3
.abyAddr2
, &uNodeIndex
)) {
1210 if (pMgmt
->sNodeDBTable
[uNodeIndex
].byAuthSequence
!= 1) {
1211 uStatusCode
= WLAN_MGMT_STATUS_RX_AUTH_NOSEQ
;
1214 if (memcmp(pMgmt
->abyChallenge
, pFrame
->pChallenge
->abyChallenge
, WLAN_CHALLENGE_LEN
) != 0) {
1215 uStatusCode
= WLAN_MGMT_STATUS_CHALLENGE_FAIL
;
1220 uStatusCode
= WLAN_MGMT_STATUS_UNSPEC_FAILURE
;
1225 pMgmt
->sNodeDBTable
[uNodeIndex
].eNodeState
= NODE_AUTH
;
1226 pMgmt
->sNodeDBTable
[uNodeIndex
].byAuthSequence
= 0;
1228 uStatusCode
= WLAN_MGMT_STATUS_SUCCESS
;
1229 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Challenge text check ok..\n");
1233 pTxPacket
= (struct vnt_tx_mgmt
*)pMgmt
->pbyMgmtPacketPool
;
1234 memset(pTxPacket
, 0, sizeof(struct vnt_tx_mgmt
)
1235 + WLAN_AUTHEN_FR_MAXLEN
);
1236 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((u8
*)pTxPacket
1237 + sizeof(struct vnt_tx_mgmt
));
1238 sFrame
.pBuf
= (u8
*)pTxPacket
->p80211Header
;
1239 sFrame
.len
= WLAN_AUTHEN_FR_MAXLEN
;
1240 // format buffer structure
1241 vMgrEncodeAuthen(&sFrame
);
1243 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
1245 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
1246 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN
)|
1247 WLAN_SET_FC_ISWEP(0)
1249 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pFrame
->pHdr
->sA3
.abyAddr2
, WLAN_ADDR_LEN
);
1250 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
1251 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
1252 *(sFrame
.pwAuthAlgorithm
) = *(pFrame
->pwAuthAlgorithm
);
1253 *(sFrame
.pwAuthSequence
) = cpu_to_le16(4);
1254 *(sFrame
.pwStatus
) = cpu_to_le16(uStatusCode
);
1256 /* Adjust the length fields */
1257 pTxPacket
->cbMPDULen
= sFrame
.len
;
1258 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
1260 if (pDevice
->bEnableHostapd
) {
1263 if (csMgmt_xmit(pDevice
, pTxPacket
) != CMD_STATUS_PENDING
) {
1264 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Authreq_reply sequence_4 tx failed.\n");
1272 * Routine Description:
1273 * Handles incoming authen frames with sequence 4
1280 static void s_vMgrRxAuthenSequence_4(struct vnt_private
*pDevice
,
1281 struct vnt_manager
*pMgmt
, PWLAN_FR_AUTHEN pFrame
)
1284 if ( cpu_to_le16((*(pFrame
->pwStatus
))) == WLAN_MGMT_STATUS_SUCCESS
){
1285 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"802.11 Authen (SHAREDKEY) Successful.\n");
1286 pMgmt
->eCurrState
= WMAC_STATE_AUTH
;
1287 schedule_delayed_work(&pDevice
->run_command_work
, 0);
1290 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"802.11 Authen (SHAREDKEY) Failed.\n");
1291 s_vMgrLogStatus(pMgmt
, cpu_to_le16((*(pFrame
->pwStatus
))) );
1292 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
1295 if ( pDevice
->eCommandState
== WLAN_AUTHENTICATE_WAIT
) {
1296 /* spin_unlock_irq(&pDevice->lock);
1297 vCommandTimerWait((void *) pDevice, 0);
1298 spin_lock_irq(&pDevice->lock); */
1304 * Routine Description:
1305 * Handles incoming disassociation frames
1313 static void s_vMgrRxDisassociation(struct vnt_private
*pDevice
,
1314 struct vnt_manager
*pMgmt
, struct vnt_rx_mgmt
*pRxPacket
)
1316 WLAN_FR_DISASSOC sFrame
;
1318 CMD_STATUS CmdStatus
;
1320 if ( pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
){
1321 // if is acting an AP..
1322 // a STA is leaving this BSS..
1323 sFrame
.len
= pRxPacket
->cbMPDULen
;
1324 sFrame
.pBuf
= (u8
*)pRxPacket
->p80211Header
;
1325 if (BSSbIsSTAInNodeDB(pDevice
, pRxPacket
->p80211Header
->sA3
.abyAddr2
, &uNodeIndex
)) {
1326 BSSvRemoveOneNode(pDevice
, uNodeIndex
);
1329 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Rx disassoc, sta not found\n");
1332 else if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_STA
){
1333 sFrame
.len
= pRxPacket
->cbMPDULen
;
1334 sFrame
.pBuf
= (u8
*)pRxPacket
->p80211Header
;
1335 vMgrDecodeDisassociation(&sFrame
);
1336 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"AP disassociated me, reason=%d.\n", cpu_to_le16(*(sFrame
.pwReason
)));
1338 pDevice
->fWPA_Authened
= false;
1340 //TODO: do something let upper layer know or
1341 //try to send associate packet again because of inactivity timeout
1342 if (pMgmt
->eCurrState
== WMAC_STATE_ASSOC
) {
1343 pDevice
->bLinkPass
= false;
1344 pMgmt
->sNodeDBTable
[0].bActive
= false;
1345 pDevice
->byReAssocCount
= 0;
1346 pMgmt
->eCurrState
= WMAC_STATE_AUTH
; // jump back to the auth state!
1347 pDevice
->eCommandState
= WLAN_ASSOCIATE_WAIT
;
1348 vMgrReAssocBeginSta(pDevice
, pMgmt
, &CmdStatus
);
1349 if(CmdStatus
== CMD_STATUS_PENDING
) {
1350 pDevice
->byReAssocCount
++;
1351 return; //mike add: you'll retry for many times, so it cann't be regarded as disconnected!
1355 // if(pDevice->bWPASuppWextEnabled == true)
1357 union iwreq_data wrqu
;
1358 memset(&wrqu
, 0, sizeof (wrqu
));
1359 wrqu
.ap_addr
.sa_family
= ARPHRD_ETHER
;
1360 PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated)\n");
1361 wireless_send_event(pDevice
->dev
, SIOCGIWAP
, &wrqu
, NULL
);
1364 /* else, ignore it */
1371 * Routine Description:
1372 * Handles incoming deauthentication frames
1380 static void s_vMgrRxDeauthentication(struct vnt_private
*pDevice
,
1381 struct vnt_manager
*pMgmt
, struct vnt_rx_mgmt
*pRxPacket
)
1383 WLAN_FR_DEAUTHEN sFrame
;
1386 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
){
1388 // if is acting an AP..
1389 // a STA is leaving this BSS..
1390 sFrame
.len
= pRxPacket
->cbMPDULen
;
1391 sFrame
.pBuf
= (u8
*)pRxPacket
->p80211Header
;
1392 if (BSSbIsSTAInNodeDB(pDevice
, pRxPacket
->p80211Header
->sA3
.abyAddr2
, &uNodeIndex
)) {
1393 BSSvRemoveOneNode(pDevice
, uNodeIndex
);
1396 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Rx deauth, sta not found\n");
1400 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_STA
) {
1401 sFrame
.len
= pRxPacket
->cbMPDULen
;
1402 sFrame
.pBuf
= (u8
*)pRxPacket
->p80211Header
;
1403 vMgrDecodeDeauthen(&sFrame
);
1404 pDevice
->fWPA_Authened
= false;
1405 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"AP deauthed me, reason=%d.\n", cpu_to_le16((*(sFrame
.pwReason
))));
1406 // TODO: update BSS list for specific BSSID if pre-authentication case
1407 if (ether_addr_equal(sFrame
.pHdr
->sA3
.abyAddr3
,
1408 pMgmt
->abyCurrBSSID
)) {
1409 if (pMgmt
->eCurrState
>= WMAC_STATE_AUTHPENDING
) {
1410 pMgmt
->sNodeDBTable
[0].bActive
= false;
1411 pMgmt
->eCurrMode
= WMAC_MODE_STANDBY
;
1412 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
1413 netif_stop_queue(pDevice
->dev
);
1414 pDevice
->bLinkPass
= false;
1415 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_SLOW
);
1419 // if(pDevice->bWPASuppWextEnabled == true)
1421 union iwreq_data wrqu
;
1422 memset(&wrqu
, 0, sizeof (wrqu
));
1423 wrqu
.ap_addr
.sa_family
= ARPHRD_ETHER
;
1424 PRINT_K("wireless_send_event--->SIOCGIWAP(disauthen)\n");
1425 wireless_send_event(pDevice
->dev
, SIOCGIWAP
, &wrqu
, NULL
);
1429 /* else, ignore it. TODO: IBSS authentication service
1430 would be implemented here */
1437 * Routine Description:
1438 * check if current channel is match ZoneType.
1446 static int ChannelExceedZoneType(struct vnt_private
*pDevice
, u8 byCurrChannel
)
1450 switch(pDevice
->byZoneType
) {
1451 case 0x00: //USA:1~11
1452 if((byCurrChannel
<1) ||(byCurrChannel
>11))
1455 case 0x01: //Japan:1~13
1456 case 0x02: //Europe:1~13
1457 if((byCurrChannel
<1) ||(byCurrChannel
>13))
1460 default: //reserve for other zonetype
1469 * Routine Description:
1470 * Handles and analysis incoming beacon frames.
1478 static void s_vMgrRxBeacon(struct vnt_private
*pDevice
,
1479 struct vnt_manager
*pMgmt
, struct vnt_rx_mgmt
*pRxPacket
,
1483 WLAN_FR_BEACON sFrame
;
1485 int bIsBSSIDEqual
= false;
1486 int bIsSSIDEqual
= false;
1487 int bTSFLargeDiff
= false;
1488 int bTSFOffsetPostive
= false;
1489 int bUpdateTSF
= false;
1490 int bIsAPBeacon
= false;
1491 int bIsChannelEqual
= false;
1492 u32 uLocateByteIndex
;
1496 u64 qwTimestamp
, qwLocalTSF
;
1498 u16 wStartIndex
= 0;
1500 u8 byCurrChannel
= pRxPacket
->byRxChannel
;
1502 u32 uRateLen
= WLAN_RATES_MAXLEN
;
1503 int bChannelHit
= false;
1504 u8 byOldPreambleType
;
1506 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
)
1509 memset(&sFrame
, 0, sizeof(WLAN_FR_BEACON
));
1510 sFrame
.len
= pRxPacket
->cbMPDULen
;
1511 sFrame
.pBuf
= (u8
*)pRxPacket
->p80211Header
;
1513 // decode the beacon frame
1514 vMgrDecodeBeacon(&sFrame
);
1516 if ((sFrame
.pwBeaconInterval
== NULL
)
1517 || (sFrame
.pwCapInfo
== NULL
)
1518 || (sFrame
.pSSID
== NULL
)
1519 || (sFrame
.pSuppRates
== NULL
)) {
1521 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Rx beacon frame error\n");
1525 if( byCurrChannel
> CB_MAX_CHANNEL_24G
)
1527 if (sFrame
.pDSParms
!= NULL
) {
1528 if (byCurrChannel
== RFaby11aChannelIndex
[sFrame
.pDSParms
->byCurrChannel
-1])
1530 byCurrChannel
= RFaby11aChannelIndex
[sFrame
.pDSParms
->byCurrChannel
-1];
1536 if (sFrame
.pDSParms
!= NULL
) {
1537 if (byCurrChannel
== sFrame
.pDSParms
->byCurrChannel
)
1539 byCurrChannel
= sFrame
.pDSParms
->byCurrChannel
;
1545 if(ChannelExceedZoneType(pDevice
,byCurrChannel
)==true)
1548 if (sFrame
.pERP
!= NULL
) {
1549 sERP
.byERP
= sFrame
.pERP
->byContext
;
1550 sERP
.bERPExist
= true;
1553 sERP
.bERPExist
= false;
1557 pBSSList
= BSSpAddrIsInBSSList((void *) pDevice
,
1558 sFrame
.pHdr
->sA3
.abyAddr3
,
1560 if (pBSSList
== NULL
) {
1561 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Beacon/insert: RxChannel = : %d\n", byCurrChannel
);
1562 BSSbInsertToBSSList((void *) pDevice
,
1563 sFrame
.pHdr
->sA3
.abyAddr3
,
1564 *sFrame
.pqwTimestamp
,
1565 *sFrame
.pwBeaconInterval
,
1570 sFrame
.pExtSuppRates
,
1576 sFrame
.len
- WLAN_HDR_ADDR3_LEN
,
1577 sFrame
.pHdr
->sA4
.abyAddr4
, // payload of beacon
1578 (void *) pRxPacket
);
1581 // DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"update bcn: RxChannel = : %d\n", byCurrChannel);
1582 BSSbUpdateToBSSList((void *) pDevice
,
1583 *sFrame
.pqwTimestamp
,
1584 *sFrame
.pwBeaconInterval
,
1590 sFrame
.pExtSuppRates
,
1597 sFrame
.len
- WLAN_HDR_ADDR3_LEN
,
1598 sFrame
.pHdr
->sA4
.abyAddr4
, // payload of probresponse
1599 (void *) pRxPacket
);
1607 if(byCurrChannel
== (u8
)pMgmt
->uCurrChannel
)
1608 bIsChannelEqual
= true;
1610 if (bIsChannelEqual
&& (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
)) {
1612 // if rx beacon without ERP field
1613 if (sERP
.bERPExist
) {
1614 if (WLAN_GET_ERP_USE_PROTECTION(sERP
.byERP
)){
1615 pDevice
->byERPFlag
|= WLAN_SET_ERP_USE_PROTECTION(1);
1616 pDevice
->wUseProtectCntDown
= USE_PROTECT_PERIOD
;
1620 pDevice
->byERPFlag
|= WLAN_SET_ERP_USE_PROTECTION(1);
1621 pDevice
->wUseProtectCntDown
= USE_PROTECT_PERIOD
;
1624 if (pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) {
1625 if(!WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame
.pwCapInfo
))
1626 pDevice
->byERPFlag
|= WLAN_SET_ERP_BARKER_MODE(1);
1628 pDevice
->byERPFlag
|= WLAN_SET_ERP_NONERP_PRESENT(1);
1632 // check if BSSID the same
1633 if (memcmp(sFrame
.pHdr
->sA3
.abyAddr3
,
1634 pMgmt
->abyCurrBSSID
,
1635 WLAN_BSSID_LEN
) == 0) {
1637 bIsBSSIDEqual
= true;
1638 pDevice
->uCurrRSSI
= pRxPacket
->uRSSI
;
1639 pDevice
->byCurrSQ
= pRxPacket
->bySQ
;
1640 if (pMgmt
->sNodeDBTable
[0].uInActiveCount
!= 0) {
1641 pMgmt
->sNodeDBTable
[0].uInActiveCount
= 0;
1642 //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BCN:Wake Count= [%d]\n", pMgmt->wCountToWakeUp);
1645 // check if SSID the same
1646 if (sFrame
.pSSID
->len
== ((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->len
) {
1647 if (memcmp(sFrame
.pSSID
->abySSID
,
1648 ((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->abySSID
,
1651 bIsSSIDEqual
= true;
1655 if ((WLAN_GET_CAP_INFO_ESS(*sFrame
.pwCapInfo
)== true) &&
1656 (bIsBSSIDEqual
== true) &&
1657 (bIsSSIDEqual
== true) &&
1658 (pMgmt
->eCurrMode
== WMAC_MODE_ESS_STA
) &&
1659 (pMgmt
->eCurrState
== WMAC_STATE_ASSOC
)) {
1660 // add state check to prevent reconnect fail since we'll receive Beacon
1663 if (pBSSList
!= NULL
) {
1666 if ((pBSSList
->sERP
.bERPExist
== true) && (pDevice
->byBBType
== BB_TYPE_11G
)) {
1667 if ((pBSSList
->sERP
.byERP
& WLAN_EID_ERP_USE_PROTECTION
) != pDevice
->bProtectMode
) {//0000 0010
1668 pDevice
->bProtectMode
= (pBSSList
->sERP
.byERP
& WLAN_EID_ERP_USE_PROTECTION
);
1669 if (pDevice
->bProtectMode
) {
1670 MACvEnableProtectMD(pDevice
);
1672 MACvDisableProtectMD(pDevice
);
1674 vUpdateIFS(pDevice
);
1676 if ((pBSSList
->sERP
.byERP
& WLAN_EID_ERP_NONERP_PRESENT
) != pDevice
->bNonERPPresent
) {//0000 0001
1677 pDevice
->bNonERPPresent
= (pBSSList
->sERP
.byERP
& WLAN_EID_ERP_USE_PROTECTION
);
1679 if ((pBSSList
->sERP
.byERP
& WLAN_EID_ERP_BARKER_MODE
) != pDevice
->bBarkerPreambleMd
) {//0000 0100
1680 pDevice
->bBarkerPreambleMd
= (pBSSList
->sERP
.byERP
& WLAN_EID_ERP_BARKER_MODE
);
1681 //BarkerPreambleMd has higher priority than shortPreamble bit in Cap
1682 if (pDevice
->bBarkerPreambleMd
) {
1683 MACvEnableBarkerPreambleMd(pDevice
);
1685 MACvDisableBarkerPreambleMd(pDevice
);
1689 // Sync Short Slot Time
1690 if (WLAN_GET_CAP_INFO_SHORTSLOTTIME(pBSSList
->wCapInfo
) != pDevice
->bShortSlotTime
) {
1691 bool bShortSlotTime
;
1693 bShortSlotTime
= WLAN_GET_CAP_INFO_SHORTSLOTTIME(pBSSList
->wCapInfo
);
1694 //DBG_PRN_WLAN05(("Set Short Slot Time: %d\n", pDevice->bShortSlotTime));
1695 //Kyle check if it is OK to set G.
1696 if (pDevice
->byBBType
== BB_TYPE_11A
) {
1697 bShortSlotTime
= true;
1699 else if (pDevice
->byBBType
== BB_TYPE_11B
) {
1700 bShortSlotTime
= false;
1702 if (bShortSlotTime
!= pDevice
->bShortSlotTime
) {
1703 pDevice
->bShortSlotTime
= bShortSlotTime
;
1704 BBvSetShortSlotTime(pDevice
);
1705 vUpdateIFS(pDevice
);
1710 // Preamble may change dynamically
1712 byOldPreambleType
= pDevice
->byPreambleType
;
1713 if (WLAN_GET_CAP_INFO_SHORTPREAMBLE(pBSSList
->wCapInfo
)) {
1714 pDevice
->byPreambleType
= pDevice
->byShortPreamble
;
1717 pDevice
->byPreambleType
= 0;
1719 if (pDevice
->byPreambleType
!= byOldPreambleType
)
1720 CARDvSetRSPINF(pDevice
, (u8
)pDevice
->byBBType
);
1722 // Basic Rate Set may change dynamically
1724 if (pBSSList
->eNetworkTypeInUse
== PHY_TYPE_11B
) {
1725 uRateLen
= WLAN_RATES_MAXLEN_11B
;
1727 pMgmt
->abyCurrSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)pBSSList
->abySuppRates
,
1728 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
1730 pMgmt
->abyCurrExtSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)pBSSList
->abyExtSuppRates
,
1731 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
,
1733 RATEvParseMaxRate((void *)pDevice
,
1734 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
1735 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
,
1737 &(pMgmt
->sNodeDBTable
[0].wMaxBasicRate
),
1738 &(pMgmt
->sNodeDBTable
[0].wMaxSuppRate
),
1739 &(pMgmt
->sNodeDBTable
[0].wSuppRate
),
1740 &(pMgmt
->sNodeDBTable
[0].byTopCCKBasicRate
),
1741 &(pMgmt
->sNodeDBTable
[0].byTopOFDMBasicRate
)
1747 // DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Beacon 2 \n");
1748 // check if CF field exisit
1749 if (WLAN_GET_CAP_INFO_ESS(*sFrame
.pwCapInfo
)) {
1750 if (sFrame
.pCFParms
->wCFPDurRemaining
> 0) {
1751 // TODO: deal with CFP period to set NAV
1755 qwTimestamp
= cpu_to_le64(*sFrame
.pqwTimestamp
);
1756 qwLocalTSF
= pRxPacket
->qwLocalTSF
;
1758 // check if beacon TSF larger or small than our local TSF
1759 if (qwTimestamp
>= qwLocalTSF
)
1760 bTSFOffsetPostive
= true;
1762 bTSFOffsetPostive
= false;
1764 if (bTSFOffsetPostive
) {
1765 qwTSFOffset
= CARDqGetTSFOffset(pRxPacket
->byRxRate
, (qwTimestamp
), (qwLocalTSF
));
1768 qwTSFOffset
= CARDqGetTSFOffset(pRxPacket
->byRxRate
, (qwLocalTSF
), (qwTimestamp
));
1771 if (qwTSFOffset
> TRIVIAL_SYNC_DIFFERENCE
)
1772 bTSFLargeDiff
= true;
1775 if (bIsAPBeacon
== true) {
1777 // Infra mode: Local TSF always follow AP's TSF if Difference huge.
1781 if ((pDevice
->bEnablePSMode
== true) && (sFrame
.pTIM
)) {
1783 /* deal with DTIM, analysis TIM */
1784 pMgmt
->bMulticastTIM
= WLAN_MGMT_IS_MULTICAST_TIM(sFrame
.pTIM
->byBitMapCtl
) ? true : false ;
1785 pMgmt
->byDTIMCount
= sFrame
.pTIM
->byDTIMCount
;
1786 pMgmt
->byDTIMPeriod
= sFrame
.pTIM
->byDTIMPeriod
;
1787 wAIDNumber
= pMgmt
->wCurrAID
& ~(BIT14
|BIT15
);
1789 // check if AID in TIM field bit on
1791 wStartIndex
= WLAN_MGMT_GET_TIM_OFFSET(sFrame
.pTIM
->byBitMapCtl
) << 1;
1793 wAIDIndex
= (wAIDNumber
>> 3);
1794 if ((wAIDNumber
> 0) && (wAIDIndex
>= wStartIndex
)) {
1795 uLocateByteIndex
= wAIDIndex
- wStartIndex
;
1796 // len = byDTIMCount + byDTIMPeriod + byDTIMPeriod + byVirtBitMap[0~250]
1797 if (sFrame
.pTIM
->len
>= (uLocateByteIndex
+ 4)) {
1798 byTIMBitOn
= (0x01) << ((wAIDNumber
) % 8);
1799 pMgmt
->bInTIM
= sFrame
.pTIM
->byVirtBitMap
[uLocateByteIndex
] & byTIMBitOn
? true : false;
1802 pMgmt
->bInTIM
= false;
1806 pMgmt
->bInTIM
= false;
1809 if (pMgmt
->bInTIM
||
1810 (pMgmt
->bMulticastTIM
&& (pMgmt
->byDTIMCount
== 0))) {
1811 pMgmt
->bInTIMWake
= true;
1812 /* send out ps-poll packet */
1814 PSvSendPSPOLL(pDevice
);
1818 pMgmt
->bInTIMWake
= false;
1819 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"BCN: Not In TIM..\n");
1820 if (pDevice
->bPWBitOn
== false) {
1821 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"BCN: Send Null Packet\n");
1822 if (PSbSendNullPacket(pDevice
))
1823 pDevice
->bPWBitOn
= true;
1825 if(PSbConsiderPowerDown(pDevice
, false, false)) {
1826 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"BCN: Power down now...\n");
1834 if ((pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) && !bIsAPBeacon
&& bIsChannelEqual
) {
1835 if (bIsBSSIDEqual
) {
1836 // Use sNodeDBTable[0].uInActiveCount as IBSS beacons received count.
1837 if (pMgmt
->sNodeDBTable
[0].uInActiveCount
!= 0)
1838 pMgmt
->sNodeDBTable
[0].uInActiveCount
= 0;
1840 // adhoc mode:TSF updated only when beacon larger then local TSF
1841 if (bTSFLargeDiff
&& bTSFOffsetPostive
&&
1842 (pMgmt
->eCurrState
== WMAC_STATE_JOINTED
))
1845 // During dpc, already in spinlocked.
1846 if (BSSbIsSTAInNodeDB(pDevice
, sFrame
.pHdr
->sA3
.abyAddr2
, &uNodeIndex
)) {
1848 // Update the STA, (Technically the Beacons of all the IBSS nodes
1849 // should be identical, but that's not happening in practice.
1850 pMgmt
->abyCurrSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)sFrame
.pSuppRates
,
1851 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
1852 WLAN_RATES_MAXLEN_11B
);
1853 RATEvParseMaxRate((void *)pDevice
,
1854 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
1857 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxBasicRate
),
1858 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
),
1859 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wSuppRate
),
1860 &(pMgmt
->sNodeDBTable
[uNodeIndex
].byTopCCKBasicRate
),
1861 &(pMgmt
->sNodeDBTable
[uNodeIndex
].byTopOFDMBasicRate
)
1863 pMgmt
->sNodeDBTable
[uNodeIndex
].bShortPreamble
= WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame
.pwCapInfo
);
1864 pMgmt
->sNodeDBTable
[uNodeIndex
].bShortSlotTime
= WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame
.pwCapInfo
);
1865 pMgmt
->sNodeDBTable
[uNodeIndex
].uInActiveCount
= 0;
1868 /* Todo, initial Node content */
1869 BSSvCreateOneNode(pDevice
, &uNodeIndex
);
1871 pMgmt
->abyCurrSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)sFrame
.pSuppRates
,
1872 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
1873 WLAN_RATES_MAXLEN_11B
);
1874 RATEvParseMaxRate((void *)pDevice
,
1875 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
1878 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxBasicRate
),
1879 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
),
1880 &(pMgmt
->sNodeDBTable
[uNodeIndex
].wSuppRate
),
1881 &(pMgmt
->sNodeDBTable
[uNodeIndex
].byTopCCKBasicRate
),
1882 &(pMgmt
->sNodeDBTable
[uNodeIndex
].byTopOFDMBasicRate
)
1885 memcpy(pMgmt
->sNodeDBTable
[uNodeIndex
].abyMACAddr
, sFrame
.pHdr
->sA3
.abyAddr2
, WLAN_ADDR_LEN
);
1886 pMgmt
->sNodeDBTable
[uNodeIndex
].bShortPreamble
= WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame
.pwCapInfo
);
1887 pMgmt
->sNodeDBTable
[uNodeIndex
].wTxDataRate
= pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
;
1889 pMgmt->sNodeDBTable[uNodeIndex].bShortSlotTime = WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame.pwCapInfo);
1890 if(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate > RATE_11M)
1891 pMgmt->sNodeDBTable[uNodeIndex].bERPExist = true;
1895 // if other stations jointed, indicate connect to upper layer..
1896 if (pMgmt
->eCurrState
== WMAC_STATE_STARTED
) {
1897 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Current IBSS State: [Started]........to: [Jointed] \n");
1898 pMgmt
->eCurrState
= WMAC_STATE_JOINTED
;
1899 pDevice
->bLinkPass
= true;
1900 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_INTER
);
1901 if (netif_queue_stopped(pDevice
->dev
)){
1902 netif_wake_queue(pDevice
->dev
);
1904 pMgmt
->sNodeDBTable
[0].bActive
= true;
1905 pMgmt
->sNodeDBTable
[0].uInActiveCount
= 0;
1909 else if (bIsSSIDEqual
) {
1911 // See other adhoc sta with the same SSID but BSSID is different.
1912 // adpot this vars only when TSF larger then us.
1913 if (bTSFLargeDiff
&& bTSFOffsetPostive
) {
1914 // we don't support ATIM under adhoc mode
1915 // if ( sFrame.pIBSSParms->wATIMWindow == 0) {
1917 // TODO: check sFrame cap if privacy on, and support rate syn
1918 memcpy(pMgmt
->abyCurrBSSID
, sFrame
.pHdr
->sA3
.abyAddr3
, WLAN_BSSID_LEN
);
1919 memcpy(pDevice
->abyBSSID
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
1920 pMgmt
->wCurrATIMWindow
= cpu_to_le16(sFrame
.pIBSSParms
->wATIMWindow
);
1921 pMgmt
->wCurrBeaconPeriod
= cpu_to_le16(*sFrame
.pwBeaconInterval
);
1922 pMgmt
->abyCurrSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)sFrame
.pSuppRates
,
1923 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
1924 WLAN_RATES_MAXLEN_11B
);
1925 // set HW beacon interval and re-synchronizing....
1926 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Rejoining to Other Adhoc group with same SSID........\n");
1928 MACvWriteBeaconInterval(pDevice
, pMgmt
->wCurrBeaconPeriod
);
1929 CARDvAdjustTSF(pDevice
, pRxPacket
->byRxRate
, qwTimestamp
, pRxPacket
->qwLocalTSF
);
1930 CARDvUpdateNextTBTT(pDevice
, qwTimestamp
, pMgmt
->wCurrBeaconPeriod
);
1932 // Turn off bssid filter to avoid filter others adhoc station which bssid is different.
1933 MACvWriteBSSIDAddress(pDevice
, pMgmt
->abyCurrBSSID
);
1935 byOldPreambleType
= pDevice
->byPreambleType
;
1936 if (WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame
.pwCapInfo
)) {
1937 pDevice
->byPreambleType
= pDevice
->byShortPreamble
;
1940 pDevice
->byPreambleType
= 0;
1942 if (pDevice
->byPreambleType
!= byOldPreambleType
)
1943 CARDvSetRSPINF(pDevice
, (u8
)pDevice
->byBBType
);
1945 // MACvRegBitsOff(pDevice->PortOffset, MAC_REG_RCR, RCR_BSSID);
1946 // set highest basic rate
1947 // s_vSetHighestBasicRate(pDevice, (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates);
1948 // Prepare beacon frame
1949 bMgrPrepareBeaconToSend((void *) pDevice
, pMgmt
);
1957 CARDbGetCurrentTSF(pDevice
, &qwCurrTSF
);
1958 CARDvAdjustTSF(pDevice
, pRxPacket
->byRxRate
, qwTimestamp
, pRxPacket
->qwLocalTSF
);
1959 CARDbGetCurrentTSF(pDevice
, &qwCurrTSF
);
1960 CARDvUpdateNextTBTT(pDevice
, qwTimestamp
, pMgmt
->wCurrBeaconPeriod
);
1968 * Routine Description:
1969 * Instructs the hw to create a bss using the supplied
1970 * attributes. Note that this implementation only supports Ad-Hoc
1979 void vMgrCreateOwnIBSS(struct vnt_private
*pDevice
, PCMD_STATUS pStatus
)
1981 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
1984 u8 byTopCCKBasicRate
;
1985 u8 byTopOFDMBasicRate
;
1988 u8 abyRATE
[] = {0x82, 0x84, 0x8B, 0x96, 0x24, 0x30, 0x48, 0x6C, 0x0C,
1990 u8 abyCCK_RATE
[] = {0x82, 0x84, 0x8B, 0x96};
1991 u8 abyOFDM_RATE
[] = {0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
1994 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Create Basic Service Set .......\n");
1996 if (pMgmt
->eConfigMode
== WMAC_CONFIG_IBSS_STA
) {
1997 if ((pMgmt
->eAuthenMode
== WMAC_AUTH_WPANONE
) &&
1998 (pDevice
->eEncryptionStatus
!= Ndis802_11Encryption2Enabled
) &&
1999 (pDevice
->eEncryptionStatus
!= Ndis802_11Encryption3Enabled
)) {
2000 // encryption mode error
2001 *pStatus
= CMD_STATUS_FAILURE
;
2006 pMgmt
->abyCurrSuppRates
[0] = WLAN_EID_SUPP_RATES
;
2007 pMgmt
->abyCurrExtSuppRates
[0] = WLAN_EID_EXTSUPP_RATES
;
2009 if (pMgmt
->eConfigMode
== WMAC_CONFIG_AP
) {
2010 pMgmt
->eCurrentPHYMode
= pMgmt
->byAPBBType
;
2012 if (pDevice
->byBBType
== BB_TYPE_11G
)
2013 pMgmt
->eCurrentPHYMode
= PHY_TYPE_11G
;
2014 if (pDevice
->byBBType
== BB_TYPE_11B
)
2015 pMgmt
->eCurrentPHYMode
= PHY_TYPE_11B
;
2016 if (pDevice
->byBBType
== BB_TYPE_11A
)
2017 pMgmt
->eCurrentPHYMode
= PHY_TYPE_11A
;
2020 if (pMgmt
->eCurrentPHYMode
!= PHY_TYPE_11A
) {
2021 pMgmt
->abyCurrSuppRates
[1] = WLAN_RATES_MAXLEN_11B
;
2022 pMgmt
->abyCurrExtSuppRates
[1] = 0;
2023 for (ii
= 0; ii
< 4; ii
++)
2024 pMgmt
->abyCurrSuppRates
[2+ii
] = abyRATE
[ii
];
2026 pMgmt
->abyCurrSuppRates
[1] = 8;
2027 pMgmt
->abyCurrExtSuppRates
[1] = 0;
2028 for (ii
= 0; ii
< 8; ii
++)
2029 pMgmt
->abyCurrSuppRates
[2+ii
] = abyRATE
[ii
];
2032 if (pMgmt
->eCurrentPHYMode
== PHY_TYPE_11G
) {
2033 pMgmt
->abyCurrSuppRates
[1] = 8;
2034 pMgmt
->abyCurrExtSuppRates
[1] = 4;
2035 for (ii
= 0; ii
< 4; ii
++)
2036 pMgmt
->abyCurrSuppRates
[2+ii
] = abyCCK_RATE
[ii
];
2037 for (ii
= 4; ii
< 8; ii
++)
2038 pMgmt
->abyCurrSuppRates
[2+ii
] = abyOFDM_RATE
[ii
-4];
2039 for (ii
= 0; ii
< 4; ii
++)
2040 pMgmt
->abyCurrExtSuppRates
[2+ii
] = abyOFDM_RATE
[ii
+4];
2043 // Disable Protect Mode
2044 pDevice
->bProtectMode
= 0;
2045 MACvDisableProtectMD(pDevice
);
2047 pDevice
->bBarkerPreambleMd
= 0;
2048 MACvDisableBarkerPreambleMd(pDevice
);
2050 // Kyle Test 2003.11.04
2052 // set HW beacon interval
2053 if (pMgmt
->wIBSSBeaconPeriod
== 0)
2054 pMgmt
->wIBSSBeaconPeriod
= DEFAULT_IBSS_BI
;
2055 MACvWriteBeaconInterval(pDevice
, pMgmt
->wIBSSBeaconPeriod
);
2057 CARDbGetCurrentTSF(pDevice
, &qwCurrTSF
);
2058 // clear TSF counter
2059 CARDbClearCurrentTSF(pDevice
);
2061 // enable TSF counter
2062 MACvRegBitsOn(pDevice
,MAC_REG_TFTCTL
,TFTCTL_TSFCNTREN
);
2064 CARDvSetFirstNextTBTT(pDevice
, pMgmt
->wIBSSBeaconPeriod
);
2066 pMgmt
->uIBSSChannel
= pDevice
->uChannel
;
2068 if (pMgmt
->uIBSSChannel
== 0)
2069 pMgmt
->uIBSSChannel
= DEFAULT_IBSS_CHANNEL
;
2071 // set channel and clear NAV
2072 CARDbSetMediaChannel(pDevice
, pMgmt
->uIBSSChannel
);
2073 pMgmt
->uCurrChannel
= pMgmt
->uIBSSChannel
;
2075 pDevice
->byPreambleType
= pDevice
->byShortPreamble
;
2079 RATEvParseMaxRate((void *)pDevice
,
2080 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
2081 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
, true,
2082 &wMaxBasicRate
, &wMaxSuppRate
, &wSuppRate
,
2083 &byTopCCKBasicRate
, &byTopOFDMBasicRate
);
2085 if (pDevice
->byBBType
== BB_TYPE_11A
) {
2086 pDevice
->bShortSlotTime
= true;
2088 pDevice
->bShortSlotTime
= false;
2090 BBvSetShortSlotTime(pDevice
);
2091 // vUpdateIFS() use pDevice->bShortSlotTime as parameter so it must be called
2092 // after setting ShortSlotTime.
2093 // CARDvSetBSSMode call vUpdateIFS()
2094 CARDvSetBSSMode(pDevice
);
2096 if (pMgmt
->eConfigMode
== WMAC_CONFIG_AP
) {
2097 MACvRegBitsOn(pDevice
, MAC_REG_HOSTCR
, HOSTCR_AP
);
2098 pMgmt
->eCurrMode
= WMAC_MODE_ESS_AP
;
2101 if (pMgmt
->eConfigMode
== WMAC_CONFIG_IBSS_STA
) {
2102 MACvRegBitsOn(pDevice
, MAC_REG_HOSTCR
, HOSTCR_ADHOC
);
2103 pMgmt
->eCurrMode
= WMAC_MODE_IBSS_STA
;
2106 // Adopt pre-configured IBSS vars to current vars
2107 pMgmt
->eCurrState
= WMAC_STATE_STARTED
;
2108 pMgmt
->wCurrBeaconPeriod
= pMgmt
->wIBSSBeaconPeriod
;
2109 pMgmt
->uCurrChannel
= pMgmt
->uIBSSChannel
;
2110 pMgmt
->wCurrATIMWindow
= pMgmt
->wIBSSATIMWindow
;
2111 pDevice
->uCurrRSSI
= 0;
2112 pDevice
->byCurrSQ
= 0;
2114 memcpy(pMgmt
->abyDesireSSID
,pMgmt
->abyAdHocSSID
,
2115 ((PWLAN_IE_SSID
)pMgmt
->abyAdHocSSID
)->len
+ WLAN_IEHDR_LEN
);
2117 memset(pMgmt
->abyCurrSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
2118 memcpy(pMgmt
->abyCurrSSID
,
2119 pMgmt
->abyDesireSSID
,
2120 ((PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
)->len
+ WLAN_IEHDR_LEN
2123 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) {
2124 // AP mode BSSID = MAC addr
2125 memcpy(pMgmt
->abyCurrBSSID
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
2126 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"AP beacon created BSSID:"
2127 "%pM\n", pMgmt
->abyCurrBSSID
);
2130 if (pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) {
2132 // BSSID selected must be randomized as spec 11.1.3
2133 pMgmt
->abyCurrBSSID
[5] = (u8
)(qwCurrTSF
& 0x000000ff);
2134 pMgmt
->abyCurrBSSID
[4] = (u8
)((qwCurrTSF
& 0x0000ff00) >> 8);
2135 pMgmt
->abyCurrBSSID
[3] = (u8
)((qwCurrTSF
& 0x00ff0000) >> 16);
2136 pMgmt
->abyCurrBSSID
[2] = (u8
)((qwCurrTSF
& 0x00000ff0) >> 4);
2137 pMgmt
->abyCurrBSSID
[1] = (u8
)((qwCurrTSF
& 0x000ff000) >> 12);
2138 pMgmt
->abyCurrBSSID
[0] = (u8
)((qwCurrTSF
& 0x0ff00000) >> 20);
2139 pMgmt
->abyCurrBSSID
[5] ^= pMgmt
->abyMACAddr
[0];
2140 pMgmt
->abyCurrBSSID
[4] ^= pMgmt
->abyMACAddr
[1];
2141 pMgmt
->abyCurrBSSID
[3] ^= pMgmt
->abyMACAddr
[2];
2142 pMgmt
->abyCurrBSSID
[2] ^= pMgmt
->abyMACAddr
[3];
2143 pMgmt
->abyCurrBSSID
[1] ^= pMgmt
->abyMACAddr
[4];
2144 pMgmt
->abyCurrBSSID
[0] ^= pMgmt
->abyMACAddr
[5];
2145 pMgmt
->abyCurrBSSID
[0] &= ~IEEE_ADDR_GROUP
;
2146 pMgmt
->abyCurrBSSID
[0] |= IEEE_ADDR_UNIVERSAL
;
2148 DBG_PRT(MSG_LEVEL_INFO
, KERN_INFO
"Adhoc beacon created bssid:"
2149 "%pM\n", pMgmt
->abyCurrBSSID
);
2153 MACvWriteBSSIDAddress(pDevice
, pMgmt
->abyCurrBSSID
);
2154 memcpy(pDevice
->abyBSSID
, pMgmt
->abyCurrBSSID
, WLAN_ADDR_LEN
);
2156 MACvRegBitsOn(pDevice
, MAC_REG_RCR
, RCR_BSSID
);
2157 pDevice
->byRxMode
|= RCR_BSSID
;
2158 pMgmt
->bCurrBSSIDFilterOn
= true;
2160 // Set Capability Info
2161 pMgmt
->wCurrCapInfo
= 0;
2163 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) {
2164 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_ESS(1);
2165 pMgmt
->byDTIMPeriod
= DEFAULT_DTIM_PERIOD
;
2166 pMgmt
->byDTIMCount
= pMgmt
->byDTIMPeriod
- 1;
2167 pDevice
->eOPMode
= OP_MODE_AP
;
2170 if (pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) {
2171 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_IBSS(1);
2172 pDevice
->eOPMode
= OP_MODE_ADHOC
;
2175 if (pDevice
->bEncryptionEnable
) {
2176 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_PRIVACY(1);
2177 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPANONE
) {
2178 if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
) {
2179 pMgmt
->byCSSPK
= KEY_CTL_CCMP
;
2180 pMgmt
->byCSSGK
= KEY_CTL_CCMP
;
2181 } else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
) {
2182 pMgmt
->byCSSPK
= KEY_CTL_TKIP
;
2183 pMgmt
->byCSSGK
= KEY_CTL_TKIP
;
2185 pMgmt
->byCSSPK
= KEY_CTL_NONE
;
2186 pMgmt
->byCSSGK
= KEY_CTL_WEP
;
2189 pMgmt
->byCSSPK
= KEY_CTL_WEP
;
2190 pMgmt
->byCSSGK
= KEY_CTL_WEP
;
2194 pMgmt
->byERPContext
= 0;
2196 if (pDevice
->byPreambleType
== 1) {
2197 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
2199 pMgmt
->wCurrCapInfo
&= (~WLAN_SET_CAP_INFO_SHORTPREAMBLE(1));
2202 pMgmt
->eCurrState
= WMAC_STATE_STARTED
;
2203 // Prepare beacon to send
2204 if (bMgrPrepareBeaconToSend((void *) pDevice
, pMgmt
))
2205 *pStatus
= CMD_STATUS_SUCCESS
;
2212 * Routine Description:
2213 * Instructs wmac to join a bss using the supplied attributes.
2214 * The arguments may the BSSID or SSID and the rest of the
2215 * attributes are obtained from the scan result of known bss list.
2223 void vMgrJoinBSSBegin(struct vnt_private
*pDevice
, PCMD_STATUS pStatus
)
2225 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
2226 PKnownBSS pCurr
= NULL
;
2228 PWLAN_IE_SUPP_RATES pItemRates
= NULL
;
2229 PWLAN_IE_SUPP_RATES pItemExtRates
= NULL
;
2230 PWLAN_IE_SSID pItemSSID
;
2231 u32 uRateLen
= WLAN_RATES_MAXLEN
;
2232 u16 wMaxBasicRate
= RATE_1M
;
2233 u16 wMaxSuppRate
= RATE_1M
;
2235 u8 byTopCCKBasicRate
= RATE_1M
;
2236 u8 byTopOFDMBasicRate
= RATE_1M
;
2237 u8 bShortSlotTime
= false;
2239 for (ii
= 0; ii
< MAX_BSS_NUM
; ii
++) {
2240 if (pMgmt
->sBSSList
[ii
].bActive
== true)
2244 if (ii
== MAX_BSS_NUM
) {
2245 *pStatus
= CMD_STATUS_RESOURCES
;
2246 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"BSS finding:BSS list is empty.\n");
2250 // memset(pMgmt->abyDesireBSSID, 0, WLAN_BSSID_LEN);
2251 // Search known BSS list for prefer BSSID or SSID
2253 pCurr
= BSSpSearchBSSList(pDevice
,
2254 pMgmt
->abyDesireBSSID
,
2255 pMgmt
->abyDesireSSID
,
2256 pDevice
->eConfigPHYMode
2260 *pStatus
= CMD_STATUS_RESOURCES
;
2261 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
;
2262 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Scanning [%s] not found, disconnected !\n", pItemSSID
->abySSID
);
2266 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"AP(BSS) finding:Found a AP(BSS)..\n");
2268 if (WLAN_GET_CAP_INFO_ESS(cpu_to_le16(pCurr
->wCapInfo
))){
2270 if ((pMgmt
->eAuthenMode
== WMAC_AUTH_WPA
) ||
2271 (pMgmt
->eAuthenMode
== WMAC_AUTH_WPAPSK
)) {
2273 if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) {
2274 if (WPA_SearchRSN(0, WPA_TKIP, pCurr) == false) {
2275 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"No match RSN info. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
2276 // encryption mode error
2277 pMgmt->eCurrState = WMAC_STATE_IDLE;
2280 } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) {
2281 if (WPA_SearchRSN(0, WPA_AESCCMP, pCurr) == false) {
2282 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"No match RSN info. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
2283 // encryption mode error
2284 pMgmt->eCurrState = WMAC_STATE_IDLE;
2291 //if(pDevice->bWPASuppWextEnabled == true)
2292 Encyption_Rebuild(pDevice
, pCurr
);
2294 // Infrastructure BSS
2295 s_vMgrSynchBSS(pDevice
,
2301 if (*pStatus
== CMD_STATUS_SUCCESS
){
2303 // Adopt this BSS state vars in Mgmt Object
2304 pMgmt
->uCurrChannel
= pCurr
->uChannel
;
2306 memset(pMgmt
->abyCurrSuppRates
, 0 , WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1);
2307 memset(pMgmt
->abyCurrExtSuppRates
, 0 , WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1);
2309 if (pCurr
->eNetworkTypeInUse
== PHY_TYPE_11B
) {
2310 uRateLen
= WLAN_RATES_MAXLEN_11B
;
2313 pItemRates
= (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
;
2314 pItemExtRates
= (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
;
2316 // Parse Support Rate IE
2317 pItemRates
->byElementID
= WLAN_EID_SUPP_RATES
;
2318 pItemRates
->len
= RATEuSetIE((PWLAN_IE_SUPP_RATES
)pCurr
->abySuppRates
,
2322 // Parse Extension Support Rate IE
2323 pItemExtRates
->byElementID
= WLAN_EID_EXTSUPP_RATES
;
2324 pItemExtRates
->len
= RATEuSetIE((PWLAN_IE_SUPP_RATES
)pCurr
->abyExtSuppRates
,
2328 if ((pItemExtRates
->len
> 0) && (pItemRates
->len
< 8)) {
2329 for (ii
= 0; ii
< (unsigned int) (8 - pItemRates
->len
); ) {
2330 pItemRates
->abyRates
[pItemRates
->len
+ ii
] =
2331 pItemExtRates
->abyRates
[ii
];
2333 if (pItemExtRates
->len
<= ii
)
2336 pItemRates
->len
+= (u8
)ii
;
2337 if (pItemExtRates
->len
- ii
> 0) {
2338 pItemExtRates
->len
-= (u8
)ii
;
2339 for (uu
= 0; uu
< pItemExtRates
->len
; uu
++) {
2340 pItemExtRates
->abyRates
[uu
] = pItemExtRates
->abyRates
[uu
+ ii
];
2343 pItemExtRates
->len
= 0;
2347 RATEvParseMaxRate((void *)pDevice
, pItemRates
, pItemExtRates
, true,
2348 &wMaxBasicRate
, &wMaxSuppRate
, &wSuppRate
,
2349 &byTopCCKBasicRate
, &byTopOFDMBasicRate
);
2350 vUpdateIFS(pDevice
);
2351 // TODO: deal with if wCapInfo the privacy is on, but station WEP is off
2352 // TODO: deal with if wCapInfo the PS-Pollable is on.
2353 pMgmt
->wCurrBeaconPeriod
= pCurr
->wBeaconInterval
;
2354 memset(pMgmt
->abyCurrSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
2355 memcpy(pMgmt
->abyCurrBSSID
, pCurr
->abyBSSID
, WLAN_BSSID_LEN
);
2356 memcpy(pMgmt
->abyCurrSSID
, pCurr
->abySSID
, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
2358 pMgmt
->eCurrMode
= WMAC_MODE_ESS_STA
;
2360 pMgmt
->eCurrState
= WMAC_STATE_JOINTED
;
2361 // Adopt BSS state in Adapter Device Object
2362 pDevice
->eOPMode
= OP_MODE_INFRASTRUCTURE
;
2363 memcpy(pDevice
->abyBSSID
, pCurr
->abyBSSID
, WLAN_BSSID_LEN
);
2365 // Add current BSS to Candidate list
2366 // This should only work for WPA2 BSS, and WPA2 BSS check must be done before.
2367 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2
) {
2368 bool bResult
= bAdd_PMKID_Candidate((void *) pDevice
,
2369 pMgmt
->abyCurrBSSID
,
2370 &pCurr
->sRSNCapObj
);
2371 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"bAdd_PMKID_Candidate: 1(%d)\n", bResult
);
2372 if (bResult
== false) {
2373 vFlush_PMKID_Candidate((void *) pDevice
);
2374 DBG_PRT(MSG_LEVEL_DEBUG
,
2375 KERN_INFO
"vFlush_PMKID_Candidate: 4\n");
2376 bAdd_PMKID_Candidate((void *) pDevice
,
2377 pMgmt
->abyCurrBSSID
,
2378 &pCurr
->sRSNCapObj
);
2382 // Preamble type auto-switch: if AP can receive short-preamble cap,
2383 // we can turn on too.
2384 if (WLAN_GET_CAP_INFO_SHORTPREAMBLE(pCurr
->wCapInfo
)) {
2385 pDevice
->byPreambleType
= pDevice
->byShortPreamble
;
2388 pDevice
->byPreambleType
= 0;
2390 // Change PreambleType must set RSPINF again
2391 CARDvSetRSPINF(pDevice
, (u8
)pDevice
->byBBType
);
2393 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Join ESS\n");
2395 if (pCurr
->eNetworkTypeInUse
== PHY_TYPE_11G
) {
2397 if ((pCurr
->sERP
.byERP
& WLAN_EID_ERP_USE_PROTECTION
) != pDevice
->bProtectMode
) {//0000 0010
2398 pDevice
->bProtectMode
= (pCurr
->sERP
.byERP
& WLAN_EID_ERP_USE_PROTECTION
);
2399 if (pDevice
->bProtectMode
) {
2400 MACvEnableProtectMD(pDevice
);
2402 MACvDisableProtectMD(pDevice
);
2404 vUpdateIFS(pDevice
);
2406 if ((pCurr
->sERP
.byERP
& WLAN_EID_ERP_NONERP_PRESENT
) != pDevice
->bNonERPPresent
) {//0000 0001
2407 pDevice
->bNonERPPresent
= (pCurr
->sERP
.byERP
& WLAN_EID_ERP_USE_PROTECTION
);
2409 if ((pCurr
->sERP
.byERP
& WLAN_EID_ERP_BARKER_MODE
) != pDevice
->bBarkerPreambleMd
) {//0000 0100
2410 pDevice
->bBarkerPreambleMd
= (pCurr
->sERP
.byERP
& WLAN_EID_ERP_BARKER_MODE
);
2411 //BarkerPreambleMd has higher priority than shortPreamble bit in Cap
2412 if (pDevice
->bBarkerPreambleMd
) {
2413 MACvEnableBarkerPreambleMd(pDevice
);
2415 MACvDisableBarkerPreambleMd(pDevice
);
2419 //DBG_PRN_WLAN05(("wCapInfo: %X\n", pCurr->wCapInfo));
2420 if (WLAN_GET_CAP_INFO_SHORTSLOTTIME(pCurr
->wCapInfo
) != pDevice
->bShortSlotTime
) {
2421 if (pDevice
->byBBType
== BB_TYPE_11A
) {
2422 bShortSlotTime
= true;
2424 else if (pDevice
->byBBType
== BB_TYPE_11B
) {
2425 bShortSlotTime
= false;
2428 bShortSlotTime
= WLAN_GET_CAP_INFO_SHORTSLOTTIME(pCurr
->wCapInfo
);
2430 //DBG_PRN_WLAN05(("Set Short Slot Time: %d\n", pDevice->bShortSlotTime));
2431 if (bShortSlotTime
!= pDevice
->bShortSlotTime
) {
2432 pDevice
->bShortSlotTime
= bShortSlotTime
;
2433 BBvSetShortSlotTime(pDevice
);
2434 vUpdateIFS(pDevice
);
2438 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"End of Join AP -- A/B/G Action\n");
2441 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
2447 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPANONE
) {
2449 if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
) {
2451 if (WPA_SearchRSN(0, WPA_TKIP, pCurr) == false) {
2452 // encryption mode error
2453 pMgmt->eCurrState = WMAC_STATE_IDLE;
2457 } else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
) {
2459 if (WPA_SearchRSN(0, WPA_AESCCMP, pCurr) == false) {
2460 // encryption mode error
2461 pMgmt->eCurrState = WMAC_STATE_IDLE;
2466 // encryption mode error
2467 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
2472 s_vMgrSynchBSS(pDevice
,
2478 if (*pStatus
== CMD_STATUS_SUCCESS
){
2479 // Adopt this BSS state vars in Mgmt Object
2480 // TODO: check if CapInfo privacy on, but we don't..
2481 pMgmt
->uCurrChannel
= pCurr
->uChannel
;
2483 // Parse Support Rate IE
2484 pMgmt
->abyCurrSuppRates
[0] = WLAN_EID_SUPP_RATES
;
2485 pMgmt
->abyCurrSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)pCurr
->abySuppRates
,
2486 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
2487 WLAN_RATES_MAXLEN_11B
);
2489 RATEvParseMaxRate((void *)pDevice
,
2490 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
2491 NULL
, true, &wMaxBasicRate
, &wMaxSuppRate
, &wSuppRate
,
2492 &byTopCCKBasicRate
, &byTopOFDMBasicRate
);
2493 vUpdateIFS(pDevice
);
2494 pMgmt
->wCurrCapInfo
= pCurr
->wCapInfo
;
2495 pMgmt
->wCurrBeaconPeriod
= pCurr
->wBeaconInterval
;
2496 memset(pMgmt
->abyCurrSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
);
2497 memcpy(pMgmt
->abyCurrBSSID
, pCurr
->abyBSSID
, WLAN_BSSID_LEN
);
2498 memcpy(pMgmt
->abyCurrSSID
, pCurr
->abySSID
, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
);
2499 // pMgmt->wCurrATIMWindow = pCurr->wATIMWindow;
2500 pMgmt
->eCurrMode
= WMAC_MODE_IBSS_STA
;
2501 pMgmt
->eCurrState
= WMAC_STATE_STARTED
;
2502 // Adopt BSS state in Adapter Device Object
2503 pDevice
->eOPMode
= OP_MODE_ADHOC
;
2504 pDevice
->bLinkPass
= true;
2505 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_INTER
);
2506 memcpy(pDevice
->abyBSSID
, pCurr
->abyBSSID
, WLAN_BSSID_LEN
);
2508 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Join IBSS ok:%pM\n",
2509 pMgmt
->abyCurrBSSID
);
2510 // Preamble type auto-switch: if AP can receive short-preamble cap,
2511 // and if registry setting is short preamble we can turn on too.
2513 if (WLAN_GET_CAP_INFO_SHORTPREAMBLE(pCurr
->wCapInfo
)) {
2514 pDevice
->byPreambleType
= pDevice
->byShortPreamble
;
2517 pDevice
->byPreambleType
= 0;
2519 // Change PreambleType must set RSPINF again
2520 CARDvSetRSPINF(pDevice
, (u8
)pDevice
->byBBType
);
2523 bMgrPrepareBeaconToSend((void *) pDevice
, pMgmt
);
2526 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
2534 * Routine Description:
2535 * Set HW to synchronize a specific BSS from known BSS list.
2542 static void s_vMgrSynchBSS(struct vnt_private
*pDevice
, u32 uBSSMode
,
2543 PKnownBSS pCurr
, PCMD_STATUS pStatus
)
2545 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
2546 u8 abyCurrSuppRatesG
[] = {WLAN_EID_SUPP_RATES
,
2547 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C};
2548 /* 1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M*/
2549 u8 abyCurrExtSuppRatesG
[] = {WLAN_EID_EXTSUPP_RATES
,
2550 4, 0x0C, 0x12, 0x18, 0x60};
2551 /* 6M, 9M, 12M, 48M*/
2552 u8 abyCurrSuppRatesA
[] = {WLAN_EID_SUPP_RATES
,
2553 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
2554 u8 abyCurrSuppRatesB
[] = {WLAN_EID_SUPP_RATES
,
2555 4, 0x02, 0x04, 0x0B, 0x16};
2557 *pStatus
= CMD_STATUS_FAILURE
;
2559 if (s_bCipherMatch(pCurr
,
2560 pDevice
->eEncryptionStatus
,
2562 &(pMgmt
->byCSSGK
)) == false) {
2563 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"s_bCipherMatch Fail .......\n");
2567 pMgmt
->pCurrBSS
= pCurr
;
2569 // if previous mode is IBSS.
2570 if(pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) {
2571 MACvRegBitsOff(pDevice
, MAC_REG_TCR
, TCR_AUTOBCNTX
);
2574 // Init the BSS informations
2575 pDevice
->bCCK
= true;
2576 pDevice
->bProtectMode
= false;
2577 MACvDisableProtectMD(pDevice
);
2578 pDevice
->bBarkerPreambleMd
= false;
2579 MACvDisableBarkerPreambleMd(pDevice
);
2580 pDevice
->bNonERPPresent
= false;
2581 pDevice
->byPreambleType
= 0;
2582 pDevice
->wBasicRate
= 0;
2584 CARDbAddBasicRate((void *)pDevice
, RATE_1M
);
2586 // calculate TSF offset
2587 // TSF Offset = Received Timestamp TSF - Marked Local's TSF
2588 CARDvAdjustTSF(pDevice
, pCurr
->byRxRate
, pCurr
->qwBSSTimestamp
, pCurr
->qwLocalTSF
);
2590 // set HW beacon interval
2591 MACvWriteBeaconInterval(pDevice
, pCurr
->wBeaconInterval
);
2594 // Next TBTT = ((local_current_TSF / beacon_interval) + 1 ) * beacon_interval
2595 CARDvSetFirstNextTBTT(pDevice
, pCurr
->wBeaconInterval
);
2598 MACvWriteBSSIDAddress(pDevice
, pCurr
->abyBSSID
);
2600 memcpy(pMgmt
->abyCurrBSSID
, pCurr
->abyBSSID
, 6);
2602 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Sync:set CurrBSSID address = "
2603 "%pM\n", pMgmt
->abyCurrBSSID
);
2605 if (pCurr
->eNetworkTypeInUse
== PHY_TYPE_11A
) {
2606 if ((pDevice
->eConfigPHYMode
== PHY_TYPE_11A
) ||
2607 (pDevice
->eConfigPHYMode
== PHY_TYPE_AUTO
)) {
2608 pDevice
->byBBType
= BB_TYPE_11A
;
2609 pMgmt
->eCurrentPHYMode
= PHY_TYPE_11A
;
2610 pDevice
->bShortSlotTime
= true;
2611 BBvSetShortSlotTime(pDevice
);
2612 CARDvSetBSSMode(pDevice
);
2616 } else if (pCurr
->eNetworkTypeInUse
== PHY_TYPE_11B
) {
2617 if ((pDevice
->eConfigPHYMode
== PHY_TYPE_11B
) ||
2618 (pDevice
->eConfigPHYMode
== PHY_TYPE_11G
) ||
2619 (pDevice
->eConfigPHYMode
== PHY_TYPE_AUTO
)) {
2620 pDevice
->byBBType
= BB_TYPE_11B
;
2621 pMgmt
->eCurrentPHYMode
= PHY_TYPE_11B
;
2622 pDevice
->bShortSlotTime
= false;
2623 BBvSetShortSlotTime(pDevice
);
2624 CARDvSetBSSMode(pDevice
);
2629 if ((pDevice
->eConfigPHYMode
== PHY_TYPE_11G
) ||
2630 (pDevice
->eConfigPHYMode
== PHY_TYPE_AUTO
)) {
2631 pDevice
->byBBType
= BB_TYPE_11G
;
2632 pMgmt
->eCurrentPHYMode
= PHY_TYPE_11G
;
2633 pDevice
->bShortSlotTime
= true;
2634 BBvSetShortSlotTime(pDevice
);
2635 CARDvSetBSSMode(pDevice
);
2636 } else if (pDevice
->eConfigPHYMode
== PHY_TYPE_11B
) {
2637 pDevice
->byBBType
= BB_TYPE_11B
;
2638 pDevice
->bShortSlotTime
= false;
2639 BBvSetShortSlotTime(pDevice
);
2640 CARDvSetBSSMode(pDevice
);
2646 if (uBSSMode
== WMAC_MODE_ESS_STA
) {
2647 MACvRegBitsOff(pDevice
, MAC_REG_HOSTCR
, HOSTCR_ADHOC
);
2648 MACvRegBitsOn(pDevice
, MAC_REG_RCR
, RCR_BSSID
);
2649 pDevice
->byRxMode
|= RCR_BSSID
;
2650 pMgmt
->bCurrBSSIDFilterOn
= true;
2653 // set channel and clear NAV
2654 CARDbSetMediaChannel(pDevice
, pCurr
->uChannel
);
2655 pMgmt
->uCurrChannel
= pCurr
->uChannel
;
2656 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"<----s_bSynchBSS Set Channel [%d]\n", pCurr
->uChannel
);
2658 if ((pDevice
->bUpdateBBVGA
) &&
2659 (pDevice
->byBBVGACurrent
!= pDevice
->abyBBVGA
[0])) {
2660 pDevice
->byBBVGACurrent
= pDevice
->abyBBVGA
[0];
2661 BBvSetVGAGainOffset(pDevice
, pDevice
->byBBVGACurrent
);
2662 BBvSetShortSlotTime(pDevice
);
2666 // 1. In Ad-hoc mode : check if received others beacon as jointed indication,
2667 // otherwise we will start own IBSS.
2668 // 2. In Infra mode : Supposed we already synchronized with AP right now.
2670 if (uBSSMode
== WMAC_MODE_IBSS_STA
) {
2671 MACvRegBitsOn(pDevice
, MAC_REG_HOSTCR
, HOSTCR_ADHOC
);
2672 MACvRegBitsOn(pDevice
, MAC_REG_RCR
, RCR_BSSID
);
2673 pDevice
->byRxMode
|= RCR_BSSID
;
2674 pMgmt
->bCurrBSSIDFilterOn
= true;
2677 if (pDevice
->byBBType
== BB_TYPE_11A
) {
2678 memcpy(pMgmt
->abyCurrSuppRates
, &abyCurrSuppRatesA
[0], sizeof(abyCurrSuppRatesA
));
2679 pMgmt
->abyCurrExtSuppRates
[1] = 0;
2680 } else if (pDevice
->byBBType
== BB_TYPE_11B
) {
2681 memcpy(pMgmt
->abyCurrSuppRates
, &abyCurrSuppRatesB
[0], sizeof(abyCurrSuppRatesB
));
2682 pMgmt
->abyCurrExtSuppRates
[1] = 0;
2684 memcpy(pMgmt
->abyCurrSuppRates
, &abyCurrSuppRatesG
[0], sizeof(abyCurrSuppRatesG
));
2685 memcpy(pMgmt
->abyCurrExtSuppRates
, &abyCurrExtSuppRatesG
[0], sizeof(abyCurrExtSuppRatesG
));
2687 pMgmt
->byERPContext
= pCurr
->sERP
.byERP
;
2689 *pStatus
= CMD_STATUS_SUCCESS
;
2694 static void Encyption_Rebuild(struct vnt_private
*pDevice
, PKnownBSS pCurr
)
2696 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
2698 if ((pMgmt
->eAuthenMode
== WMAC_AUTH_WPAPSK
) ||
2699 (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2PSK
)) {
2700 if (pCurr
->bWPAValid
== true) { /*WPA-PSK */
2701 pMgmt
->eAuthenMode
= WMAC_AUTH_WPAPSK
;
2702 if(pCurr
->abyPKType
[0] == WPA_TKIP
) {
2703 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
; //TKIP
2704 PRINT_K("Encyption_Rebuild--->ssid reset config to [WPAPSK-TKIP]\n");
2706 else if(pCurr
->abyPKType
[0] == WPA_AESCCMP
) {
2707 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
; //AES
2708 PRINT_K("Encyption_Rebuild--->ssid reset config to [WPAPSK-AES]\n");
2711 else if(pCurr
->bWPA2Valid
== true) { //WPA2-PSK
2712 pMgmt
->eAuthenMode
= WMAC_AUTH_WPA2PSK
;
2713 if(pCurr
->abyCSSPK
[0] == WLAN_11i_CSS_TKIP
) {
2714 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
; //TKIP
2715 PRINT_K("Encyption_Rebuild--->ssid reset config to [WPA2PSK-TKIP]\n");
2717 else if(pCurr
->abyCSSPK
[0] == WLAN_11i_CSS_CCMP
) {
2718 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
; //AES
2719 PRINT_K("Encyption_Rebuild--->ssid reset config to [WPA2PSK-AES]\n");
2729 * Routine Description:
2738 static void s_vMgrFormatTIM(struct vnt_manager
*pMgmt
, PWLAN_IE_TIM pTIM
)
2740 u8 byMask
[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
2743 int bStartFound
= false;
2744 int bMulticast
= false;
2745 u16 wStartIndex
= 0;
2748 // Find size of partial virtual bitmap
2749 for (ii
= 0; ii
< (MAX_NODE_NUM
+ 1); ii
++) {
2750 byMap
= pMgmt
->abyPSTxMap
[ii
];
2752 // Mask out the broadcast bit which is indicated separately.
2753 bMulticast
= (byMap
& byMask
[0]) != 0;
2755 pMgmt
->sNodeDBTable
[0].bRxPSPoll
= true;
2762 wStartIndex
= (u16
)ii
;
2764 wEndIndex
= (u16
)ii
;
2768 // Round start index down to nearest even number
2769 wStartIndex
&= ~BIT0
;
2771 // Round end index up to nearest even number
2772 wEndIndex
= ((wEndIndex
+ 1) & ~BIT0
);
2774 // Size of element payload
2776 pTIM
->len
= 3 + (wEndIndex
- wStartIndex
) + 1;
2778 // Fill in the Fixed parts of the TIM
2779 pTIM
->byDTIMCount
= pMgmt
->byDTIMCount
;
2780 pTIM
->byDTIMPeriod
= pMgmt
->byDTIMPeriod
;
2781 pTIM
->byBitMapCtl
= (bMulticast
? TIM_MULTICAST_MASK
: 0) |
2782 (((wStartIndex
>> 1) << 1) & TIM_BITMAPOFFSET_MASK
);
2784 // Append variable part of TIM
2786 for (ii
= wStartIndex
, jj
=0 ; ii
<= wEndIndex
; ii
++, jj
++) {
2787 pTIM
->byVirtBitMap
[jj
] = pMgmt
->abyPSTxMap
[ii
];
2790 // Aid = 0 don't used.
2791 pTIM
->byVirtBitMap
[0] &= ~BIT0
;
2796 * Routine Description:
2797 * Constructs an Beacon frame( Ad-hoc mode)
2801 * PTR to frame; or NULL on allocation failure
2805 static struct vnt_tx_mgmt
*s_MgrMakeBeacon(struct vnt_private
*pDevice
,
2806 struct vnt_manager
*pMgmt
, u16 wCurrCapInfo
, u16 wCurrBeaconPeriod
,
2807 u32 uCurrChannel
, u16 wCurrATIMWinodw
, PWLAN_IE_SSID pCurrSSID
,
2808 u8
*pCurrBSSID
, PWLAN_IE_SUPP_RATES pCurrSuppRates
,
2809 PWLAN_IE_SUPP_RATES pCurrExtSuppRates
)
2811 struct vnt_tx_mgmt
*pTxPacket
= NULL
;
2812 WLAN_FR_BEACON sFrame
;
2813 u8 abyBroadcastAddr
[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2815 /* prepare beacon frame */
2816 pTxPacket
= (struct vnt_tx_mgmt
*)pMgmt
->pbyMgmtPacketPool
;
2817 memset(pTxPacket
, 0, sizeof(struct vnt_tx_mgmt
)
2818 + WLAN_BEACON_FR_MAXLEN
);
2819 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((u8
*)pTxPacket
2820 + sizeof(struct vnt_tx_mgmt
));
2821 // Setup the sFrame structure.
2822 sFrame
.pBuf
= (u8
*)pTxPacket
->p80211Header
;
2823 sFrame
.len
= WLAN_BEACON_FR_MAXLEN
;
2824 vMgrEncodeBeacon(&sFrame
);
2826 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
2828 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
2829 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_BEACON
)
2832 if (pDevice
->bEnablePSMode
) {
2833 sFrame
.pHdr
->sA3
.wFrameCtl
|= cpu_to_le16((u16
)WLAN_SET_FC_PWRMGT(1));
2836 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, abyBroadcastAddr
, WLAN_ADDR_LEN
);
2837 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
2838 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pCurrBSSID
, WLAN_BSSID_LEN
);
2839 *sFrame
.pwBeaconInterval
= cpu_to_le16(wCurrBeaconPeriod
);
2840 *sFrame
.pwCapInfo
= cpu_to_le16(wCurrCapInfo
);
2842 sFrame
.pSSID
= (PWLAN_IE_SSID
)(sFrame
.pBuf
+ sFrame
.len
);
2843 sFrame
.len
+= ((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->len
+ WLAN_IEHDR_LEN
;
2844 memcpy(sFrame
.pSSID
,
2846 ((PWLAN_IE_SSID
)pCurrSSID
)->len
+ WLAN_IEHDR_LEN
2848 // Copy the rate set
2849 sFrame
.pSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
2850 sFrame
.len
+= ((PWLAN_IE_SUPP_RATES
)pCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
;
2851 memcpy(sFrame
.pSuppRates
,
2853 ((PWLAN_IE_SUPP_RATES
)pCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
2856 if (pDevice
->byBBType
!= BB_TYPE_11A
) {
2857 sFrame
.pDSParms
= (PWLAN_IE_DS_PARMS
)(sFrame
.pBuf
+ sFrame
.len
);
2858 sFrame
.len
+= (1) + WLAN_IEHDR_LEN
;
2859 sFrame
.pDSParms
->byElementID
= WLAN_EID_DS_PARMS
;
2860 sFrame
.pDSParms
->len
= 1;
2861 sFrame
.pDSParms
->byCurrChannel
= (u8
)uCurrChannel
;
2864 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) {
2865 sFrame
.pTIM
= (PWLAN_IE_TIM
)(sFrame
.pBuf
+ sFrame
.len
);
2866 sFrame
.pTIM
->byElementID
= WLAN_EID_TIM
;
2867 s_vMgrFormatTIM(pMgmt
, sFrame
.pTIM
);
2868 sFrame
.len
+= (WLAN_IEHDR_LEN
+ sFrame
.pTIM
->len
);
2871 if (pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) {
2874 sFrame
.pIBSSParms
= (PWLAN_IE_IBSS_PARMS
)(sFrame
.pBuf
+ sFrame
.len
);
2875 sFrame
.len
+= (2) + WLAN_IEHDR_LEN
;
2876 sFrame
.pIBSSParms
->byElementID
= WLAN_EID_IBSS_PARMS
;
2877 sFrame
.pIBSSParms
->len
= 2;
2878 sFrame
.pIBSSParms
->wATIMWindow
= wCurrATIMWinodw
;
2879 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPANONE
) {
2881 sFrame
.pRSNWPA
= (PWLAN_IE_RSN_EXT
)(sFrame
.pBuf
+ sFrame
.len
);
2882 sFrame
.pRSNWPA
->byElementID
= WLAN_EID_RSN_WPA
;
2883 sFrame
.pRSNWPA
->len
= 12;
2884 sFrame
.pRSNWPA
->abyOUI
[0] = 0x00;
2885 sFrame
.pRSNWPA
->abyOUI
[1] = 0x50;
2886 sFrame
.pRSNWPA
->abyOUI
[2] = 0xf2;
2887 sFrame
.pRSNWPA
->abyOUI
[3] = 0x01;
2888 sFrame
.pRSNWPA
->wVersion
= 1;
2889 sFrame
.pRSNWPA
->abyMulticast
[0] = 0x00;
2890 sFrame
.pRSNWPA
->abyMulticast
[1] = 0x50;
2891 sFrame
.pRSNWPA
->abyMulticast
[2] = 0xf2;
2892 if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
)
2893 sFrame
.pRSNWPA
->abyMulticast
[3] = 0x04;//AES
2894 else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
)
2895 sFrame
.pRSNWPA
->abyMulticast
[3] = 0x02;//TKIP
2896 else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption1Enabled
)
2897 sFrame
.pRSNWPA
->abyMulticast
[3] = 0x01;//WEP40
2899 sFrame
.pRSNWPA
->abyMulticast
[3] = 0x00;//NONE
2901 // Pairwise Key Cipher Suite
2902 sFrame
.pRSNWPA
->wPKCount
= 0;
2903 // Auth Key Management Suite
2904 *((u16
*)(sFrame
.pBuf
+ sFrame
.len
+ sFrame
.pRSNWPA
->len
))=0;
2905 sFrame
.pRSNWPA
->len
+=2;
2908 *((u16
*)(sFrame
.pBuf
+ sFrame
.len
+ sFrame
.pRSNWPA
->len
))=0;
2909 sFrame
.pRSNWPA
->len
+=2;
2910 sFrame
.len
+= sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
;
2914 if (pMgmt
->eCurrentPHYMode
== PHY_TYPE_11G
) {
2915 sFrame
.pERP
= (PWLAN_IE_ERP
)(sFrame
.pBuf
+ sFrame
.len
);
2916 sFrame
.len
+= 1 + WLAN_IEHDR_LEN
;
2917 sFrame
.pERP
->byElementID
= WLAN_EID_ERP
;
2918 sFrame
.pERP
->len
= 1;
2919 sFrame
.pERP
->byContext
= 0;
2920 if (pDevice
->bProtectMode
== true)
2921 sFrame
.pERP
->byContext
|= WLAN_EID_ERP_USE_PROTECTION
;
2922 if (pDevice
->bNonERPPresent
== true)
2923 sFrame
.pERP
->byContext
|= WLAN_EID_ERP_NONERP_PRESENT
;
2924 if (pDevice
->bBarkerPreambleMd
== true)
2925 sFrame
.pERP
->byContext
|= WLAN_EID_ERP_BARKER_MODE
;
2927 if (((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
!= 0) {
2928 sFrame
.pExtSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
2929 sFrame
.len
+= ((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
;
2930 memcpy(sFrame
.pExtSuppRates
,
2932 ((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
2935 // hostapd wpa/wpa2 IE
2936 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) && (pDevice
->bEnableHostapd
== true)) {
2937 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPANONE
) {
2938 if (pMgmt
->wWPAIELen
!= 0) {
2939 sFrame
.pRSN
= (PWLAN_IE_RSN
)(sFrame
.pBuf
+ sFrame
.len
);
2940 memcpy(sFrame
.pRSN
, pMgmt
->abyWPAIE
, pMgmt
->wWPAIELen
);
2941 sFrame
.len
+= pMgmt
->wWPAIELen
;
2946 /* Adjust the length fields */
2947 pTxPacket
->cbMPDULen
= sFrame
.len
;
2948 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
2955 * Routine Description:
2956 * Constructs an Prob-response frame
2960 * PTR to frame; or NULL on allocation failure
2964 static struct vnt_tx_mgmt
*s_MgrMakeProbeResponse(struct vnt_private
*pDevice
,
2965 struct vnt_manager
*pMgmt
, u16 wCurrCapInfo
, u16 wCurrBeaconPeriod
,
2966 u32 uCurrChannel
, u16 wCurrATIMWinodw
, u8
*pDstAddr
,
2967 PWLAN_IE_SSID pCurrSSID
, u8
*pCurrBSSID
,
2968 PWLAN_IE_SUPP_RATES pCurrSuppRates
,
2969 PWLAN_IE_SUPP_RATES pCurrExtSuppRates
, u8 byPHYType
)
2971 struct vnt_tx_mgmt
*pTxPacket
= NULL
;
2972 WLAN_FR_PROBERESP sFrame
;
2974 pTxPacket
= (struct vnt_tx_mgmt
*)pMgmt
->pbyMgmtPacketPool
;
2975 memset(pTxPacket
, 0, sizeof(struct vnt_tx_mgmt
)
2976 + WLAN_PROBERESP_FR_MAXLEN
);
2977 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((u8
*)pTxPacket
2978 + sizeof(struct vnt_tx_mgmt
));
2979 // Setup the sFrame structure.
2980 sFrame
.pBuf
= (u8
*)pTxPacket
->p80211Header
;
2981 sFrame
.len
= WLAN_PROBERESP_FR_MAXLEN
;
2982 vMgrEncodeProbeResponse(&sFrame
);
2984 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
2986 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
2987 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_PROBERESP
)
2989 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pDstAddr
, WLAN_ADDR_LEN
);
2990 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
2991 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pCurrBSSID
, WLAN_BSSID_LEN
);
2992 *sFrame
.pwBeaconInterval
= cpu_to_le16(wCurrBeaconPeriod
);
2993 *sFrame
.pwCapInfo
= cpu_to_le16(wCurrCapInfo
);
2995 if (byPHYType
== BB_TYPE_11B
) {
2996 *sFrame
.pwCapInfo
&= cpu_to_le16((u16
)~(WLAN_SET_CAP_INFO_SHORTSLOTTIME(1)));
3000 sFrame
.pSSID
= (PWLAN_IE_SSID
)(sFrame
.pBuf
+ sFrame
.len
);
3001 sFrame
.len
+= ((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->len
+ WLAN_IEHDR_LEN
;
3002 memcpy(sFrame
.pSSID
,
3004 ((PWLAN_IE_SSID
)pCurrSSID
)->len
+ WLAN_IEHDR_LEN
3006 // Copy the rate set
3007 sFrame
.pSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3009 sFrame
.len
+= ((PWLAN_IE_SUPP_RATES
)pCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
;
3010 memcpy(sFrame
.pSuppRates
,
3012 ((PWLAN_IE_SUPP_RATES
)pCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
3016 if (pDevice
->byBBType
!= BB_TYPE_11A
) {
3017 sFrame
.pDSParms
= (PWLAN_IE_DS_PARMS
)(sFrame
.pBuf
+ sFrame
.len
);
3018 sFrame
.len
+= (1) + WLAN_IEHDR_LEN
;
3019 sFrame
.pDSParms
->byElementID
= WLAN_EID_DS_PARMS
;
3020 sFrame
.pDSParms
->len
= 1;
3021 sFrame
.pDSParms
->byCurrChannel
= (u8
)uCurrChannel
;
3024 if (pMgmt
->eCurrMode
!= WMAC_MODE_ESS_AP
) {
3026 sFrame
.pIBSSParms
= (PWLAN_IE_IBSS_PARMS
)(sFrame
.pBuf
+ sFrame
.len
);
3027 sFrame
.len
+= (2) + WLAN_IEHDR_LEN
;
3028 sFrame
.pIBSSParms
->byElementID
= WLAN_EID_IBSS_PARMS
;
3029 sFrame
.pIBSSParms
->len
= 2;
3030 sFrame
.pIBSSParms
->wATIMWindow
= 0;
3032 if (pDevice
->byBBType
== BB_TYPE_11G
) {
3033 sFrame
.pERP
= (PWLAN_IE_ERP
)(sFrame
.pBuf
+ sFrame
.len
);
3034 sFrame
.len
+= 1 + WLAN_IEHDR_LEN
;
3035 sFrame
.pERP
->byElementID
= WLAN_EID_ERP
;
3036 sFrame
.pERP
->len
= 1;
3037 sFrame
.pERP
->byContext
= 0;
3038 if (pDevice
->bProtectMode
== true)
3039 sFrame
.pERP
->byContext
|= WLAN_EID_ERP_USE_PROTECTION
;
3040 if (pDevice
->bNonERPPresent
== true)
3041 sFrame
.pERP
->byContext
|= WLAN_EID_ERP_NONERP_PRESENT
;
3042 if (pDevice
->bBarkerPreambleMd
== true)
3043 sFrame
.pERP
->byContext
|= WLAN_EID_ERP_BARKER_MODE
;
3046 if (((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
!= 0) {
3047 sFrame
.pExtSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3048 sFrame
.len
+= ((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
;
3049 memcpy(sFrame
.pExtSuppRates
,
3051 ((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
3055 // hostapd wpa/wpa2 IE
3056 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) && (pDevice
->bEnableHostapd
== true)) {
3057 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPANONE
) {
3058 if (pMgmt
->wWPAIELen
!= 0) {
3059 sFrame
.pRSN
= (PWLAN_IE_RSN
)(sFrame
.pBuf
+ sFrame
.len
);
3060 memcpy(sFrame
.pRSN
, pMgmt
->abyWPAIE
, pMgmt
->wWPAIELen
);
3061 sFrame
.len
+= pMgmt
->wWPAIELen
;
3066 // Adjust the length fields
3067 pTxPacket
->cbMPDULen
= sFrame
.len
;
3068 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
3075 * Routine Description:
3076 * Constructs an association request frame
3080 * A ptr to frame or NULL on allocation failure
3084 static struct vnt_tx_mgmt
*s_MgrMakeAssocRequest(struct vnt_private
*pDevice
,
3085 struct vnt_manager
*pMgmt
, u8
*pDAddr
, u16 wCurrCapInfo
,
3086 u16 wListenInterval
,
3087 PWLAN_IE_SSID pCurrSSID
,
3088 PWLAN_IE_SUPP_RATES pCurrRates
,
3089 PWLAN_IE_SUPP_RATES pCurrExtSuppRates
)
3091 struct vnt_tx_mgmt
*pTxPacket
= NULL
;
3092 WLAN_FR_ASSOCREQ sFrame
;
3096 pTxPacket
= (struct vnt_tx_mgmt
*)pMgmt
->pbyMgmtPacketPool
;
3097 memset(pTxPacket
, 0, sizeof(struct vnt_tx_mgmt
)
3098 + WLAN_ASSOCREQ_FR_MAXLEN
);
3099 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((u8
*)pTxPacket
3100 + sizeof(struct vnt_tx_mgmt
));
3101 // Setup the sFrame structure.
3102 sFrame
.pBuf
= (u8
*)pTxPacket
->p80211Header
;
3103 sFrame
.len
= WLAN_ASSOCREQ_FR_MAXLEN
;
3104 // format fixed field frame structure
3105 vMgrEncodeAssocRequest(&sFrame
);
3107 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
3109 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
3110 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ASSOCREQ
)
3112 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pDAddr
, WLAN_ADDR_LEN
);
3113 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
3114 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
3116 // Set the capability and listen interval
3117 *(sFrame
.pwCapInfo
) = cpu_to_le16(wCurrCapInfo
);
3118 *(sFrame
.pwListenInterval
) = cpu_to_le16(wListenInterval
);
3120 // sFrame.len point to end of fixed field
3121 sFrame
.pSSID
= (PWLAN_IE_SSID
)(sFrame
.pBuf
+ sFrame
.len
);
3122 sFrame
.len
+= pCurrSSID
->len
+ WLAN_IEHDR_LEN
;
3123 memcpy(sFrame
.pSSID
, pCurrSSID
, pCurrSSID
->len
+ WLAN_IEHDR_LEN
);
3125 pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
= pCurrSSID
->len
+ WLAN_IEHDR_LEN
;
3126 pMgmt
->sAssocInfo
.AssocInfo
.OffsetRequestIEs
= sizeof(NDIS_802_11_ASSOCIATION_INFORMATION
);
3127 pbyIEs
= pMgmt
->sAssocInfo
.abyIEs
;
3128 memcpy(pbyIEs
, pCurrSSID
, pCurrSSID
->len
+ WLAN_IEHDR_LEN
);
3129 pbyIEs
+= pCurrSSID
->len
+ WLAN_IEHDR_LEN
;
3131 // Copy the rate set
3132 sFrame
.pSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3133 if ((pDevice
->byBBType
== BB_TYPE_11B
) && (pCurrRates
->len
> 4))
3134 sFrame
.len
+= 4 + WLAN_IEHDR_LEN
;
3136 sFrame
.len
+= pCurrRates
->len
+ WLAN_IEHDR_LEN
;
3137 memcpy(sFrame
.pSuppRates
, pCurrRates
, pCurrRates
->len
+ WLAN_IEHDR_LEN
);
3139 // Copy the extension rate set
3140 if ((pDevice
->byBBType
== BB_TYPE_11G
) && (pCurrExtSuppRates
->len
> 0)) {
3141 sFrame
.pExtSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3142 sFrame
.len
+= pCurrExtSuppRates
->len
+ WLAN_IEHDR_LEN
;
3143 memcpy(sFrame
.pExtSuppRates
, pCurrExtSuppRates
, pCurrExtSuppRates
->len
+ WLAN_IEHDR_LEN
);
3146 pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
+= pCurrRates
->len
+ WLAN_IEHDR_LEN
;
3147 memcpy(pbyIEs
, pCurrRates
, pCurrRates
->len
+ WLAN_IEHDR_LEN
);
3148 pbyIEs
+= pCurrRates
->len
+ WLAN_IEHDR_LEN
;
3150 if (((pMgmt
->eAuthenMode
== WMAC_AUTH_WPA
) ||
3151 (pMgmt
->eAuthenMode
== WMAC_AUTH_WPAPSK
) ||
3152 (pMgmt
->eAuthenMode
== WMAC_AUTH_WPANONE
)) &&
3153 (pMgmt
->pCurrBSS
!= NULL
)) {
3155 sFrame
.pRSNWPA
= (PWLAN_IE_RSN_EXT
)(sFrame
.pBuf
+ sFrame
.len
);
3156 sFrame
.pRSNWPA
->byElementID
= WLAN_EID_RSN_WPA
;
3157 sFrame
.pRSNWPA
->len
= 16;
3158 sFrame
.pRSNWPA
->abyOUI
[0] = 0x00;
3159 sFrame
.pRSNWPA
->abyOUI
[1] = 0x50;
3160 sFrame
.pRSNWPA
->abyOUI
[2] = 0xf2;
3161 sFrame
.pRSNWPA
->abyOUI
[3] = 0x01;
3162 sFrame
.pRSNWPA
->wVersion
= 1;
3163 //Group Key Cipher Suite
3164 sFrame
.pRSNWPA
->abyMulticast
[0] = 0x00;
3165 sFrame
.pRSNWPA
->abyMulticast
[1] = 0x50;
3166 sFrame
.pRSNWPA
->abyMulticast
[2] = 0xf2;
3167 if (pMgmt
->byCSSGK
== KEY_CTL_WEP
) {
3168 sFrame
.pRSNWPA
->abyMulticast
[3] = pMgmt
->pCurrBSS
->byGKType
;
3169 } else if (pMgmt
->byCSSGK
== KEY_CTL_TKIP
) {
3170 sFrame
.pRSNWPA
->abyMulticast
[3] = WPA_TKIP
;
3171 } else if (pMgmt
->byCSSGK
== KEY_CTL_CCMP
) {
3172 sFrame
.pRSNWPA
->abyMulticast
[3] = WPA_AESCCMP
;
3174 sFrame
.pRSNWPA
->abyMulticast
[3] = WPA_NONE
;
3176 // Pairwise Key Cipher Suite
3177 sFrame
.pRSNWPA
->wPKCount
= 1;
3178 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[0] = 0x00;
3179 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[1] = 0x50;
3180 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[2] = 0xf2;
3181 if (pMgmt
->byCSSPK
== KEY_CTL_TKIP
) {
3182 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[3] = WPA_TKIP
;
3183 } else if (pMgmt
->byCSSPK
== KEY_CTL_CCMP
) {
3184 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[3] = WPA_AESCCMP
;
3186 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[3] = WPA_NONE
;
3188 // Auth Key Management Suite
3189 pbyRSN
= (u8
*)(sFrame
.pBuf
+ sFrame
.len
+ 2 + sFrame
.pRSNWPA
->len
);
3196 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPAPSK
) {
3197 *pbyRSN
++=WPA_AUTH_PSK
;
3199 else if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA
) {
3200 *pbyRSN
++=WPA_AUTH_IEEE802_1X
;
3206 sFrame
.pRSNWPA
->len
+=6;
3212 sFrame
.pRSNWPA
->len
+=2;
3214 sFrame
.len
+= sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
;
3215 // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION
3216 pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
+= sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
;
3217 memcpy(pbyIEs
, sFrame
.pRSNWPA
, sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
);
3218 pbyIEs
+= sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
;
3220 } else if (((pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2
) ||
3221 (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2PSK
)) &&
3222 (pMgmt
->pCurrBSS
!= NULL
)) {
3227 sFrame
.pRSN
= (PWLAN_IE_RSN
)(sFrame
.pBuf
+ sFrame
.len
);
3228 sFrame
.pRSN
->byElementID
= WLAN_EID_RSN
;
3229 sFrame
.pRSN
->len
= 6; //Version(2)+GK(4)
3230 sFrame
.pRSN
->wVersion
= 1;
3231 //Group Key Cipher Suite
3232 sFrame
.pRSN
->abyRSN
[0] = 0x00;
3233 sFrame
.pRSN
->abyRSN
[1] = 0x0F;
3234 sFrame
.pRSN
->abyRSN
[2] = 0xAC;
3235 if (pMgmt
->byCSSGK
== KEY_CTL_WEP
) {
3236 sFrame
.pRSN
->abyRSN
[3] = pMgmt
->pCurrBSS
->byCSSGK
;
3237 } else if (pMgmt
->byCSSGK
== KEY_CTL_TKIP
) {
3238 sFrame
.pRSN
->abyRSN
[3] = WLAN_11i_CSS_TKIP
;
3239 } else if (pMgmt
->byCSSGK
== KEY_CTL_CCMP
) {
3240 sFrame
.pRSN
->abyRSN
[3] = WLAN_11i_CSS_CCMP
;
3242 sFrame
.pRSN
->abyRSN
[3] = WLAN_11i_CSS_UNKNOWN
;
3245 // Pairwise Key Cipher Suite
3246 sFrame
.pRSN
->abyRSN
[4] = 1;
3247 sFrame
.pRSN
->abyRSN
[5] = 0;
3248 sFrame
.pRSN
->abyRSN
[6] = 0x00;
3249 sFrame
.pRSN
->abyRSN
[7] = 0x0F;
3250 sFrame
.pRSN
->abyRSN
[8] = 0xAC;
3251 if (pMgmt
->byCSSPK
== KEY_CTL_TKIP
) {
3252 sFrame
.pRSN
->abyRSN
[9] = WLAN_11i_CSS_TKIP
;
3253 } else if (pMgmt
->byCSSPK
== KEY_CTL_CCMP
) {
3254 sFrame
.pRSN
->abyRSN
[9] = WLAN_11i_CSS_CCMP
;
3255 } else if (pMgmt
->byCSSPK
== KEY_CTL_NONE
) {
3256 sFrame
.pRSN
->abyRSN
[9] = WLAN_11i_CSS_USE_GROUP
;
3258 sFrame
.pRSN
->abyRSN
[9] = WLAN_11i_CSS_UNKNOWN
;
3260 sFrame
.pRSN
->len
+= 6;
3262 // Auth Key Management Suite
3263 sFrame
.pRSN
->abyRSN
[10] = 1;
3264 sFrame
.pRSN
->abyRSN
[11] = 0;
3265 sFrame
.pRSN
->abyRSN
[12] = 0x00;
3266 sFrame
.pRSN
->abyRSN
[13] = 0x0F;
3267 sFrame
.pRSN
->abyRSN
[14] = 0xAC;
3268 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2PSK
) {
3269 sFrame
.pRSN
->abyRSN
[15] = WLAN_11i_AKMSS_PSK
;
3270 } else if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2
) {
3271 sFrame
.pRSN
->abyRSN
[15] = WLAN_11i_AKMSS_802_1X
;
3273 sFrame
.pRSN
->abyRSN
[15] = WLAN_11i_AKMSS_UNKNOWN
;
3275 sFrame
.pRSN
->len
+=6;
3278 if (pMgmt
->pCurrBSS
->sRSNCapObj
.bRSNCapExist
== true) {
3279 memcpy(&sFrame
.pRSN
->abyRSN
[16], &pMgmt
->pCurrBSS
->sRSNCapObj
.wRSNCap
, 2);
3281 sFrame
.pRSN
->abyRSN
[16] = 0;
3282 sFrame
.pRSN
->abyRSN
[17] = 0;
3284 sFrame
.pRSN
->len
+=2;
3286 if ((pDevice
->gsPMKID
.BSSIDInfoCount
> 0) && (pDevice
->bRoaming
== true) && (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2
)) {
3288 pbyRSN
= &sFrame
.pRSN
->abyRSN
[18];
3289 pwPMKID
= (u16
*)pbyRSN
; // Point to PMKID count
3290 *pwPMKID
= 0; // Initialize PMKID count
3291 pbyRSN
+= 2; // Point to PMKID list
3292 for (ii
= 0; ii
< pDevice
->gsPMKID
.BSSIDInfoCount
; ii
++) {
3293 if (!memcmp(&pDevice
->gsPMKID
.BSSIDInfo
[ii
].BSSID
[0],
3294 pMgmt
->abyCurrBSSID
,
3298 pDevice
->gsPMKID
.BSSIDInfo
[ii
].PMKID
,
3303 if (*pwPMKID
!= 0) {
3304 sFrame
.pRSN
->len
+= (2 + (*pwPMKID
)*16);
3308 sFrame
.len
+= sFrame
.pRSN
->len
+ WLAN_IEHDR_LEN
;
3309 // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION
3310 pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
+= sFrame
.pRSN
->len
+ WLAN_IEHDR_LEN
;
3311 memcpy(pbyIEs
, sFrame
.pRSN
, sFrame
.pRSN
->len
+ WLAN_IEHDR_LEN
);
3312 pbyIEs
+= sFrame
.pRSN
->len
+ WLAN_IEHDR_LEN
;
3315 // Adjust the length fields
3316 pTxPacket
->cbMPDULen
= sFrame
.len
;
3317 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
3323 * Routine Description:
3324 * Constructs an re-association request frame
3328 * A ptr to frame or NULL on allocation failure
3332 static struct vnt_tx_mgmt
*s_MgrMakeReAssocRequest(struct vnt_private
*pDevice
,
3333 struct vnt_manager
*pMgmt
, u8
*pDAddr
, u16 wCurrCapInfo
,
3334 u16 wListenInterval
, PWLAN_IE_SSID pCurrSSID
,
3335 PWLAN_IE_SUPP_RATES pCurrRates
,
3336 PWLAN_IE_SUPP_RATES pCurrExtSuppRates
)
3338 struct vnt_tx_mgmt
*pTxPacket
= NULL
;
3339 WLAN_FR_REASSOCREQ sFrame
;
3343 pTxPacket
= (struct vnt_tx_mgmt
*)pMgmt
->pbyMgmtPacketPool
;
3344 memset(pTxPacket
, 0, sizeof(struct vnt_tx_mgmt
)
3345 + WLAN_REASSOCREQ_FR_MAXLEN
);
3346 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((u8
*)pTxPacket
3347 + sizeof(struct vnt_tx_mgmt
));
3348 /* Setup the sFrame structure. */
3349 sFrame
.pBuf
= (u8
*)pTxPacket
->p80211Header
;
3350 sFrame
.len
= WLAN_REASSOCREQ_FR_MAXLEN
;
3352 // format fixed field frame structure
3353 vMgrEncodeReassocRequest(&sFrame
);
3355 /* Setup the header */
3356 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
3358 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
3359 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_REASSOCREQ
)
3361 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pDAddr
, WLAN_ADDR_LEN
);
3362 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
3363 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
3365 /* Set the capability and listen interval */
3366 *(sFrame
.pwCapInfo
) = cpu_to_le16(wCurrCapInfo
);
3367 *(sFrame
.pwListenInterval
) = cpu_to_le16(wListenInterval
);
3369 memcpy(sFrame
.pAddrCurrAP
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
3371 /* sFrame.len point to end of fixed field */
3372 sFrame
.pSSID
= (PWLAN_IE_SSID
)(sFrame
.pBuf
+ sFrame
.len
);
3373 sFrame
.len
+= pCurrSSID
->len
+ WLAN_IEHDR_LEN
;
3374 memcpy(sFrame
.pSSID
, pCurrSSID
, pCurrSSID
->len
+ WLAN_IEHDR_LEN
);
3376 pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
= pCurrSSID
->len
+ WLAN_IEHDR_LEN
;
3377 pMgmt
->sAssocInfo
.AssocInfo
.OffsetRequestIEs
= sizeof(NDIS_802_11_ASSOCIATION_INFORMATION
);
3378 pbyIEs
= pMgmt
->sAssocInfo
.abyIEs
;
3379 memcpy(pbyIEs
, pCurrSSID
, pCurrSSID
->len
+ WLAN_IEHDR_LEN
);
3380 pbyIEs
+= pCurrSSID
->len
+ WLAN_IEHDR_LEN
;
3382 /* Copy the rate set */
3383 /* sFrame.len point to end of SSID */
3384 sFrame
.pSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3385 sFrame
.len
+= pCurrRates
->len
+ WLAN_IEHDR_LEN
;
3386 memcpy(sFrame
.pSuppRates
, pCurrRates
, pCurrRates
->len
+ WLAN_IEHDR_LEN
);
3388 // Copy the extension rate set
3389 if ((pMgmt
->eCurrentPHYMode
== PHY_TYPE_11G
) && (pCurrExtSuppRates
->len
> 0)) {
3390 sFrame
.pExtSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3391 sFrame
.len
+= pCurrExtSuppRates
->len
+ WLAN_IEHDR_LEN
;
3392 memcpy(sFrame
.pExtSuppRates
, pCurrExtSuppRates
, pCurrExtSuppRates
->len
+ WLAN_IEHDR_LEN
);
3395 pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
+= pCurrRates
->len
+ WLAN_IEHDR_LEN
;
3396 memcpy(pbyIEs
, pCurrRates
, pCurrRates
->len
+ WLAN_IEHDR_LEN
);
3397 pbyIEs
+= pCurrRates
->len
+ WLAN_IEHDR_LEN
;
3399 if (((pMgmt
->eAuthenMode
== WMAC_AUTH_WPA
) ||
3400 (pMgmt
->eAuthenMode
== WMAC_AUTH_WPAPSK
) ||
3401 (pMgmt
->eAuthenMode
== WMAC_AUTH_WPANONE
)) &&
3402 (pMgmt
->pCurrBSS
!= NULL
)) {
3404 sFrame
.pRSNWPA
= (PWLAN_IE_RSN_EXT
)(sFrame
.pBuf
+ sFrame
.len
);
3405 sFrame
.pRSNWPA
->byElementID
= WLAN_EID_RSN_WPA
;
3406 sFrame
.pRSNWPA
->len
= 16;
3407 sFrame
.pRSNWPA
->abyOUI
[0] = 0x00;
3408 sFrame
.pRSNWPA
->abyOUI
[1] = 0x50;
3409 sFrame
.pRSNWPA
->abyOUI
[2] = 0xf2;
3410 sFrame
.pRSNWPA
->abyOUI
[3] = 0x01;
3411 sFrame
.pRSNWPA
->wVersion
= 1;
3412 //Group Key Cipher Suite
3413 sFrame
.pRSNWPA
->abyMulticast
[0] = 0x00;
3414 sFrame
.pRSNWPA
->abyMulticast
[1] = 0x50;
3415 sFrame
.pRSNWPA
->abyMulticast
[2] = 0xf2;
3416 if (pMgmt
->byCSSGK
== KEY_CTL_WEP
) {
3417 sFrame
.pRSNWPA
->abyMulticast
[3] = pMgmt
->pCurrBSS
->byGKType
;
3418 } else if (pMgmt
->byCSSGK
== KEY_CTL_TKIP
) {
3419 sFrame
.pRSNWPA
->abyMulticast
[3] = WPA_TKIP
;
3420 } else if (pMgmt
->byCSSGK
== KEY_CTL_CCMP
) {
3421 sFrame
.pRSNWPA
->abyMulticast
[3] = WPA_AESCCMP
;
3423 sFrame
.pRSNWPA
->abyMulticast
[3] = WPA_NONE
;
3425 // Pairwise Key Cipher Suite
3426 sFrame
.pRSNWPA
->wPKCount
= 1;
3427 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[0] = 0x00;
3428 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[1] = 0x50;
3429 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[2] = 0xf2;
3430 if (pMgmt
->byCSSPK
== KEY_CTL_TKIP
) {
3431 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[3] = WPA_TKIP
;
3432 } else if (pMgmt
->byCSSPK
== KEY_CTL_CCMP
) {
3433 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[3] = WPA_AESCCMP
;
3435 sFrame
.pRSNWPA
->PKSList
[0].abyOUI
[3] = WPA_NONE
;
3437 // Auth Key Management Suite
3438 pbyRSN
= (u8
*)(sFrame
.pBuf
+ sFrame
.len
+ 2 + sFrame
.pRSNWPA
->len
);
3445 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPAPSK
) {
3446 *pbyRSN
++=WPA_AUTH_PSK
;
3447 } else if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA
) {
3448 *pbyRSN
++=WPA_AUTH_IEEE802_1X
;
3453 sFrame
.pRSNWPA
->len
+=6;
3458 sFrame
.pRSNWPA
->len
+=2;
3460 sFrame
.len
+= sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
;
3461 // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION
3462 pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
+= sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
;
3463 memcpy(pbyIEs
, sFrame
.pRSNWPA
, sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
);
3464 pbyIEs
+= sFrame
.pRSNWPA
->len
+ WLAN_IEHDR_LEN
;
3466 } else if (((pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2
) ||
3467 (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2PSK
)) &&
3468 (pMgmt
->pCurrBSS
!= NULL
)) {
3473 sFrame
.pRSN
= (PWLAN_IE_RSN
)(sFrame
.pBuf
+ sFrame
.len
);
3474 sFrame
.pRSN
->byElementID
= WLAN_EID_RSN
;
3475 sFrame
.pRSN
->len
= 6; //Version(2)+GK(4)
3476 sFrame
.pRSN
->wVersion
= 1;
3477 //Group Key Cipher Suite
3478 sFrame
.pRSN
->abyRSN
[0] = 0x00;
3479 sFrame
.pRSN
->abyRSN
[1] = 0x0F;
3480 sFrame
.pRSN
->abyRSN
[2] = 0xAC;
3481 if (pMgmt
->byCSSGK
== KEY_CTL_WEP
) {
3482 sFrame
.pRSN
->abyRSN
[3] = pMgmt
->pCurrBSS
->byCSSGK
;
3483 } else if (pMgmt
->byCSSGK
== KEY_CTL_TKIP
) {
3484 sFrame
.pRSN
->abyRSN
[3] = WLAN_11i_CSS_TKIP
;
3485 } else if (pMgmt
->byCSSGK
== KEY_CTL_CCMP
) {
3486 sFrame
.pRSN
->abyRSN
[3] = WLAN_11i_CSS_CCMP
;
3488 sFrame
.pRSN
->abyRSN
[3] = WLAN_11i_CSS_UNKNOWN
;
3491 // Pairwise Key Cipher Suite
3492 sFrame
.pRSN
->abyRSN
[4] = 1;
3493 sFrame
.pRSN
->abyRSN
[5] = 0;
3494 sFrame
.pRSN
->abyRSN
[6] = 0x00;
3495 sFrame
.pRSN
->abyRSN
[7] = 0x0F;
3496 sFrame
.pRSN
->abyRSN
[8] = 0xAC;
3497 if (pMgmt
->byCSSPK
== KEY_CTL_TKIP
) {
3498 sFrame
.pRSN
->abyRSN
[9] = WLAN_11i_CSS_TKIP
;
3499 } else if (pMgmt
->byCSSPK
== KEY_CTL_CCMP
) {
3500 sFrame
.pRSN
->abyRSN
[9] = WLAN_11i_CSS_CCMP
;
3501 } else if (pMgmt
->byCSSPK
== KEY_CTL_NONE
) {
3502 sFrame
.pRSN
->abyRSN
[9] = WLAN_11i_CSS_USE_GROUP
;
3504 sFrame
.pRSN
->abyRSN
[9] = WLAN_11i_CSS_UNKNOWN
;
3506 sFrame
.pRSN
->len
+= 6;
3508 // Auth Key Management Suite
3509 sFrame
.pRSN
->abyRSN
[10] = 1;
3510 sFrame
.pRSN
->abyRSN
[11] = 0;
3511 sFrame
.pRSN
->abyRSN
[12] = 0x00;
3512 sFrame
.pRSN
->abyRSN
[13] = 0x0F;
3513 sFrame
.pRSN
->abyRSN
[14] = 0xAC;
3514 if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2PSK
) {
3515 sFrame
.pRSN
->abyRSN
[15] = WLAN_11i_AKMSS_PSK
;
3516 } else if (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2
) {
3517 sFrame
.pRSN
->abyRSN
[15] = WLAN_11i_AKMSS_802_1X
;
3519 sFrame
.pRSN
->abyRSN
[15] = WLAN_11i_AKMSS_UNKNOWN
;
3521 sFrame
.pRSN
->len
+=6;
3524 if (pMgmt
->pCurrBSS
->sRSNCapObj
.bRSNCapExist
== true) {
3525 memcpy(&sFrame
.pRSN
->abyRSN
[16], &pMgmt
->pCurrBSS
->sRSNCapObj
.wRSNCap
, 2);
3527 sFrame
.pRSN
->abyRSN
[16] = 0;
3528 sFrame
.pRSN
->abyRSN
[17] = 0;
3530 sFrame
.pRSN
->len
+=2;
3532 if ((pDevice
->gsPMKID
.BSSIDInfoCount
> 0) && (pDevice
->bRoaming
== true) && (pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2
)) {
3534 pbyRSN
= &sFrame
.pRSN
->abyRSN
[18];
3535 pwPMKID
= (u16
*)pbyRSN
; // Point to PMKID count
3536 *pwPMKID
= 0; // Initialize PMKID count
3537 pbyRSN
+= 2; // Point to PMKID list
3538 for (ii
= 0; ii
< pDevice
->gsPMKID
.BSSIDInfoCount
; ii
++) {
3539 if (!memcmp(&pDevice
->gsPMKID
.BSSIDInfo
[ii
].BSSID
[0],
3540 pMgmt
->abyCurrBSSID
,
3544 pDevice
->gsPMKID
.BSSIDInfo
[ii
].PMKID
,
3549 if (*pwPMKID
!= 0) {
3550 sFrame
.pRSN
->len
+= (2 + (*pwPMKID
)*16);
3554 sFrame
.len
+= sFrame
.pRSN
->len
+ WLAN_IEHDR_LEN
;
3555 // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION
3556 pMgmt
->sAssocInfo
.AssocInfo
.RequestIELength
+= sFrame
.pRSN
->len
+ WLAN_IEHDR_LEN
;
3557 memcpy(pbyIEs
, sFrame
.pRSN
, sFrame
.pRSN
->len
+ WLAN_IEHDR_LEN
);
3558 pbyIEs
+= sFrame
.pRSN
->len
+ WLAN_IEHDR_LEN
;
3561 /* Adjust the length fields */
3562 pTxPacket
->cbMPDULen
= sFrame
.len
;
3563 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
3570 * Routine Description:
3571 * Constructs an assoc-response frame
3575 * PTR to frame; or NULL on allocation failure
3579 static struct vnt_tx_mgmt
*s_MgrMakeAssocResponse(struct vnt_private
*pDevice
,
3580 struct vnt_manager
*pMgmt
, u16 wCurrCapInfo
, u16 wAssocStatus
,
3581 u16 wAssocAID
, u8
*pDstAddr
, PWLAN_IE_SUPP_RATES pCurrSuppRates
,
3582 PWLAN_IE_SUPP_RATES pCurrExtSuppRates
)
3584 struct vnt_tx_mgmt
*pTxPacket
= NULL
;
3585 WLAN_FR_ASSOCRESP sFrame
;
3587 pTxPacket
= (struct vnt_tx_mgmt
*)pMgmt
->pbyMgmtPacketPool
;
3588 memset(pTxPacket
, 0, sizeof(struct vnt_tx_mgmt
)
3589 + WLAN_ASSOCREQ_FR_MAXLEN
);
3590 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((u8
*)pTxPacket
3591 + sizeof(struct vnt_tx_mgmt
));
3592 // Setup the sFrame structure
3593 sFrame
.pBuf
= (u8
*)pTxPacket
->p80211Header
;
3594 sFrame
.len
= WLAN_REASSOCRESP_FR_MAXLEN
;
3595 vMgrEncodeAssocResponse(&sFrame
);
3597 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
3599 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
3600 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ASSOCRESP
)
3602 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pDstAddr
, WLAN_ADDR_LEN
);
3603 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
3604 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
3606 *sFrame
.pwCapInfo
= cpu_to_le16(wCurrCapInfo
);
3607 *sFrame
.pwStatus
= cpu_to_le16(wAssocStatus
);
3608 *sFrame
.pwAid
= cpu_to_le16((u16
)(wAssocAID
| BIT14
| BIT15
));
3610 // Copy the rate set
3611 sFrame
.pSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3612 sFrame
.len
+= ((PWLAN_IE_SUPP_RATES
)pCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
;
3613 memcpy(sFrame
.pSuppRates
,
3615 ((PWLAN_IE_SUPP_RATES
)pCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
3618 if (((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
!= 0) {
3619 sFrame
.pExtSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3620 sFrame
.len
+= ((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
;
3621 memcpy(sFrame
.pExtSuppRates
,
3623 ((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
3627 // Adjust the length fields
3628 pTxPacket
->cbMPDULen
= sFrame
.len
;
3629 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
3636 * Routine Description:
3637 * Constructs an reassoc-response frame
3641 * PTR to frame; or NULL on allocation failure
3645 static struct vnt_tx_mgmt
*s_MgrMakeReAssocResponse(struct vnt_private
*pDevice
,
3646 struct vnt_manager
*pMgmt
, u16 wCurrCapInfo
, u16 wAssocStatus
,
3647 u16 wAssocAID
, u8
*pDstAddr
, PWLAN_IE_SUPP_RATES pCurrSuppRates
,
3648 PWLAN_IE_SUPP_RATES pCurrExtSuppRates
)
3650 struct vnt_tx_mgmt
*pTxPacket
= NULL
;
3651 WLAN_FR_REASSOCRESP sFrame
;
3653 pTxPacket
= (struct vnt_tx_mgmt
*)pMgmt
->pbyMgmtPacketPool
;
3654 memset(pTxPacket
, 0, sizeof(struct vnt_tx_mgmt
)
3655 + WLAN_ASSOCREQ_FR_MAXLEN
);
3656 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((u8
*)pTxPacket
3657 + sizeof(struct vnt_tx_mgmt
));
3658 // Setup the sFrame structure
3659 sFrame
.pBuf
= (u8
*)pTxPacket
->p80211Header
;
3660 sFrame
.len
= WLAN_REASSOCRESP_FR_MAXLEN
;
3661 vMgrEncodeReassocResponse(&sFrame
);
3663 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
3665 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
3666 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_REASSOCRESP
)
3668 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pDstAddr
, WLAN_ADDR_LEN
);
3669 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
3670 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
3672 *sFrame
.pwCapInfo
= cpu_to_le16(wCurrCapInfo
);
3673 *sFrame
.pwStatus
= cpu_to_le16(wAssocStatus
);
3674 *sFrame
.pwAid
= cpu_to_le16((u16
)(wAssocAID
| BIT14
| BIT15
));
3676 // Copy the rate set
3677 sFrame
.pSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3678 sFrame
.len
+= ((PWLAN_IE_SUPP_RATES
)pCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
;
3679 memcpy(sFrame
.pSuppRates
,
3681 ((PWLAN_IE_SUPP_RATES
)pCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
3684 if (((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
!= 0) {
3685 sFrame
.pExtSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
3686 sFrame
.len
+= ((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
;
3687 memcpy(sFrame
.pExtSuppRates
,
3689 ((PWLAN_IE_SUPP_RATES
)pCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
3693 // Adjust the length fields
3694 pTxPacket
->cbMPDULen
= sFrame
.len
;
3695 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
3702 * Routine Description:
3703 * Handles probe response management frames.
3711 static void s_vMgrRxProbeResponse(struct vnt_private
*pDevice
,
3712 struct vnt_manager
*pMgmt
, struct vnt_rx_mgmt
*pRxPacket
)
3714 PKnownBSS pBSSList
= NULL
;
3715 WLAN_FR_PROBERESP sFrame
;
3716 u8 byCurrChannel
= pRxPacket
->byRxChannel
;
3718 int bChannelHit
= true;
3720 memset(&sFrame
, 0, sizeof(WLAN_FR_PROBERESP
));
3722 sFrame
.len
= pRxPacket
->cbMPDULen
;
3723 sFrame
.pBuf
= (u8
*)pRxPacket
->p80211Header
;
3724 vMgrDecodeProbeResponse(&sFrame
);
3726 if ((sFrame
.pqwTimestamp
== NULL
)
3727 || (sFrame
.pwBeaconInterval
== NULL
)
3728 || (sFrame
.pwCapInfo
== NULL
)
3729 || (sFrame
.pSSID
== NULL
)
3730 || (sFrame
.pSuppRates
== NULL
)) {
3732 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Probe resp:Fail addr:[%p]\n",
3733 pRxPacket
->p80211Header
);
3737 if(sFrame
.pSSID
->len
== 0)
3738 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Rx Probe resp: SSID len = 0 \n");
3740 //{{ RobertYu:20050201, 11a byCurrChannel != sFrame.pDSParms->byCurrChannel mapping
3741 if( byCurrChannel
> CB_MAX_CHANNEL_24G
)
3743 if (sFrame
.pDSParms
) {
3744 if (byCurrChannel
==
3745 RFaby11aChannelIndex
[sFrame
.pDSParms
->byCurrChannel
-1])
3748 RFaby11aChannelIndex
[sFrame
.pDSParms
->byCurrChannel
-1];
3753 if (sFrame
.pDSParms
) {
3754 if (byCurrChannel
== sFrame
.pDSParms
->byCurrChannel
)
3756 byCurrChannel
= sFrame
.pDSParms
->byCurrChannel
;
3763 if(ChannelExceedZoneType(pDevice
,byCurrChannel
)==true)
3767 sERP
.byERP
= sFrame
.pERP
->byContext
;
3768 sERP
.bERPExist
= true;
3770 sERP
.bERPExist
= false;
3774 // update or insert the bss
3775 pBSSList
= BSSpAddrIsInBSSList((void *) pDevice
,
3776 sFrame
.pHdr
->sA3
.abyAddr3
,
3779 BSSbUpdateToBSSList((void *) pDevice
,
3780 *sFrame
.pqwTimestamp
,
3781 *sFrame
.pwBeaconInterval
,
3787 sFrame
.pExtSuppRates
,
3794 sFrame
.len
- WLAN_HDR_ADDR3_LEN
,
3795 /* payload of probresponse */
3796 sFrame
.pHdr
->sA4
.abyAddr4
,
3797 (void *) pRxPacket
);
3799 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Probe resp/insert: RxChannel = : %d\n", byCurrChannel
);
3800 BSSbInsertToBSSList((void *) pDevice
,
3801 sFrame
.pHdr
->sA3
.abyAddr3
,
3802 *sFrame
.pqwTimestamp
,
3803 *sFrame
.pwBeaconInterval
,
3808 sFrame
.pExtSuppRates
,
3814 sFrame
.len
- WLAN_HDR_ADDR3_LEN
,
3815 sFrame
.pHdr
->sA4
.abyAddr4
, /* payload of beacon */
3816 (void *) pRxPacket
);
3824 * Routine Description:(AP)or(Ad-hoc STA)
3825 * Handles probe request management frames.
3833 static void s_vMgrRxProbeRequest(struct vnt_private
*pDevice
,
3834 struct vnt_manager
*pMgmt
, struct vnt_rx_mgmt
*pRxPacket
)
3836 WLAN_FR_PROBEREQ sFrame
;
3838 struct vnt_tx_mgmt
*pTxPacket
;
3839 u8 byPHYType
= BB_TYPE_11B
;
3841 // STA in Ad-hoc mode: when latest TBTT beacon transmit success,
3842 // STA have to response this request.
3843 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) ||
3844 ((pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) && pDevice
->bBeaconSent
)) {
3846 memset(&sFrame
, 0, sizeof(WLAN_FR_PROBEREQ
));
3848 sFrame
.len
= pRxPacket
->cbMPDULen
;
3849 sFrame
.pBuf
= (u8
*)pRxPacket
->p80211Header
;
3850 vMgrDecodeProbeRequest(&sFrame
);
3852 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request rx:MAC addr:%pM\n",
3853 sFrame.pHdr->sA3.abyAddr2);
3855 if (sFrame
.pSSID
->len
!= 0) {
3856 if (sFrame
.pSSID
->len
!= ((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->len
)
3858 if (memcmp(sFrame
.pSSID
->abySSID
,
3859 ((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->abySSID
,
3860 ((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->len
) != 0) {
3865 if ((sFrame
.pSuppRates
->len
> 4) || (sFrame
.pExtSuppRates
!= NULL
)) {
3866 byPHYType
= BB_TYPE_11G
;
3869 // Probe response reply..
3870 pTxPacket
= s_MgrMakeProbeResponse
3874 pMgmt
->wCurrCapInfo
,
3875 pMgmt
->wCurrBeaconPeriod
,
3876 pMgmt
->uCurrChannel
,
3878 sFrame
.pHdr
->sA3
.abyAddr2
,
3879 (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
,
3880 (u8
*)pMgmt
->abyCurrBSSID
,
3881 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
3882 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
,
3885 if (pTxPacket
!= NULL
){
3886 /* send the frame */
3887 Status
= csMgmt_xmit(pDevice
, pTxPacket
);
3888 if (Status
!= CMD_STATUS_PENDING
) {
3889 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Mgt:Probe response tx failed\n");
3892 // DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Probe response tx sending..\n");
3902 * Routine Description:
3904 * Entry point for the reception and handling of 802.11 management
3905 * frames. Makes a determination of the frame type and then calls
3906 * the appropriate function.
3914 void vMgrRxManagePacket(struct vnt_private
*pDevice
, struct vnt_manager
*pMgmt
,
3915 struct vnt_rx_mgmt
*pRxPacket
)
3917 int bInScan
= false;
3919 NODE_STATE eNodeState
= 0;
3922 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) {
3923 if (BSSbIsSTAInNodeDB(pDevice
, pRxPacket
->p80211Header
->sA3
.abyAddr2
, &uNodeIndex
))
3924 eNodeState
= pMgmt
->sNodeDBTable
[uNodeIndex
].eNodeState
;
3927 switch( WLAN_GET_FC_FSTYPE((pRxPacket
->p80211Header
->sA3
.wFrameCtl
)) ){
3929 case WLAN_FSTYPE_ASSOCREQ
:
3931 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx assocreq\n");
3932 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) &&
3933 (eNodeState
< NODE_AUTH
)) {
3934 // send deauth notification
3935 // reason = (6) class 2 received from nonauth sta
3936 vMgrDeAuthenBeginSta(pDevice
,
3938 pRxPacket
->p80211Header
->sA3
.abyAddr2
,
3942 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"wmgr: send vMgrDeAuthenBeginSta 1\n");
3945 s_vMgrRxAssocRequest(pDevice
, pMgmt
, pRxPacket
, uNodeIndex
);
3949 case WLAN_FSTYPE_ASSOCRESP
:
3951 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx assocresp1\n");
3952 s_vMgrRxAssocResponse(pDevice
, pMgmt
, pRxPacket
, false);
3953 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx assocresp2\n");
3956 case WLAN_FSTYPE_REASSOCREQ
:
3958 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx reassocreq\n");
3960 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) &&
3961 (eNodeState
< NODE_AUTH
)) {
3962 // send deauth notification
3963 // reason = (6) class 2 received from nonauth sta
3964 vMgrDeAuthenBeginSta(pDevice
,
3966 pRxPacket
->p80211Header
->sA3
.abyAddr2
,
3970 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"wmgr: send vMgrDeAuthenBeginSta 2\n");
3973 s_vMgrRxReAssocRequest(pDevice
, pMgmt
, pRxPacket
, uNodeIndex
);
3976 case WLAN_FSTYPE_REASSOCRESP
:
3978 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx reassocresp\n");
3979 s_vMgrRxAssocResponse(pDevice
, pMgmt
, pRxPacket
, true);
3982 case WLAN_FSTYPE_PROBEREQ
:
3984 //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx probereq\n");
3985 s_vMgrRxProbeRequest(pDevice
, pMgmt
, pRxPacket
);
3988 case WLAN_FSTYPE_PROBERESP
:
3990 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx proberesp\n");
3992 s_vMgrRxProbeResponse(pDevice
, pMgmt
, pRxPacket
);
3995 case WLAN_FSTYPE_BEACON
:
3997 //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx beacon\n");
3998 if (pMgmt
->eScanState
!= WMAC_NO_SCANNING
) {
4001 s_vMgrRxBeacon(pDevice
, pMgmt
, pRxPacket
, bInScan
);
4004 case WLAN_FSTYPE_ATIM
:
4006 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx atim\n");
4009 case WLAN_FSTYPE_DISASSOC
:
4011 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx disassoc\n");
4012 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) &&
4013 (eNodeState
< NODE_AUTH
)) {
4014 // send deauth notification
4015 // reason = (6) class 2 received from nonauth sta
4016 vMgrDeAuthenBeginSta(pDevice
,
4018 pRxPacket
->p80211Header
->sA3
.abyAddr2
,
4022 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"wmgr: send vMgrDeAuthenBeginSta 3\n");
4024 s_vMgrRxDisassociation(pDevice
, pMgmt
, pRxPacket
);
4027 case WLAN_FSTYPE_AUTHEN
:
4029 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx authen\n");
4030 s_vMgrRxAuthentication(pDevice
, pMgmt
, pRxPacket
);
4033 case WLAN_FSTYPE_DEAUTHEN
:
4035 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx deauthen\n");
4036 s_vMgrRxDeauthentication(pDevice
, pMgmt
, pRxPacket
);
4040 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"rx unknown mgmt\n");
4048 * Routine Description:
4051 * Prepare beacon to send
4054 * true if success; false if failed.
4057 int bMgrPrepareBeaconToSend(struct vnt_private
*pDevice
,
4058 struct vnt_manager
*pMgmt
)
4060 struct vnt_tx_mgmt
*pTxPacket
;
4062 // pDevice->bBeaconBufReady = false;
4063 if (pDevice
->bEncryptionEnable
|| pDevice
->bEnable8021x
){
4064 pMgmt
->wCurrCapInfo
|= WLAN_SET_CAP_INFO_PRIVACY(1);
4067 pMgmt
->wCurrCapInfo
&= ~WLAN_SET_CAP_INFO_PRIVACY(1);
4069 pTxPacket
= s_MgrMakeBeacon
4073 pMgmt
->wCurrCapInfo
,
4074 pMgmt
->wCurrBeaconPeriod
,
4075 pMgmt
->uCurrChannel
,
4076 pMgmt
->wCurrATIMWindow
, //0,
4077 (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
,
4078 (u8
*)pMgmt
->abyCurrBSSID
,
4079 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
4080 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
4083 if ((pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) &&
4084 (pMgmt
->abyCurrBSSID
[0] == 0))
4087 csBeacon_xmit(pDevice
, pTxPacket
);
4088 MACvRegBitsOn(pDevice
, MAC_REG_TCR
, TCR_AUTOBCNTX
);
4095 * Routine Description:
4097 * Log a warning message based on the contents of the Status
4098 * Code field of an 802.11 management frame. Defines are
4099 * derived from 802.11-1997 SPEC.
4105 static void s_vMgrLogStatus(struct vnt_manager
*pMgmt
, u16 wStatus
)
4108 case WLAN_MGMT_STATUS_UNSPEC_FAILURE
:
4109 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Unspecified error.\n");
4111 case WLAN_MGMT_STATUS_CAPS_UNSUPPORTED
:
4112 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Can't support all requested capabilities.\n");
4114 case WLAN_MGMT_STATUS_REASSOC_NO_ASSOC
:
4115 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Reassoc denied, can't confirm original Association.\n");
4117 case WLAN_MGMT_STATUS_ASSOC_DENIED_UNSPEC
:
4118 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Assoc denied, undefine in spec\n");
4120 case WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG
:
4121 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Peer doesn't support authen algorithm.\n");
4123 case WLAN_MGMT_STATUS_RX_AUTH_NOSEQ
:
4124 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Authen frame received out of sequence.\n");
4126 case WLAN_MGMT_STATUS_CHALLENGE_FAIL
:
4127 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Authen rejected, challenge failure.\n");
4129 case WLAN_MGMT_STATUS_AUTH_TIMEOUT
:
4130 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Authen rejected, timeout waiting for next frame.\n");
4132 case WLAN_MGMT_STATUS_ASSOC_DENIED_BUSY
:
4133 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Assoc denied, AP too busy.\n");
4135 case WLAN_MGMT_STATUS_ASSOC_DENIED_RATES
:
4136 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Assoc denied, we haven't enough basic rates.\n");
4138 case WLAN_MGMT_STATUS_ASSOC_DENIED_SHORTPREAMBLE
:
4139 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Assoc denied, we do not support short preamble.\n");
4141 case WLAN_MGMT_STATUS_ASSOC_DENIED_PBCC
:
4142 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Assoc denied, we do not support PBCC.\n");
4144 case WLAN_MGMT_STATUS_ASSOC_DENIED_AGILITY
:
4145 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Status code == Assoc denied, we do not support channel agility.\n");
4148 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Unknown status code %d.\n", wStatus
);
4156 * Add BSSID in PMKID Candidate list.
4160 * hDeviceContext - device structure point
4161 * pbyBSSID - BSSID address for adding
4162 * wRSNCap - BSS's RSN capability
4166 * Return Value: none.
4170 int bAdd_PMKID_Candidate(struct vnt_private
*pDevice
, u8
*pbyBSSID
,
4171 PSRSNCapObject psRSNCapObj
)
4173 PPMKID_CANDIDATE pCandidateList
;
4176 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"bAdd_PMKID_Candidate START: (%d)\n", (int)pDevice
->gsPMKIDCandidate
.NumCandidates
);
4178 if ((pDevice
== NULL
) || (pbyBSSID
== NULL
) || (psRSNCapObj
== NULL
))
4181 if (pDevice
->gsPMKIDCandidate
.NumCandidates
>= MAX_PMKIDLIST
)
4184 // Update Old Candidate
4185 for (ii
= 0; ii
< pDevice
->gsPMKIDCandidate
.NumCandidates
; ii
++) {
4186 pCandidateList
= &pDevice
->gsPMKIDCandidate
.CandidateList
[ii
];
4187 if (!memcmp(pCandidateList
->BSSID
, pbyBSSID
, ETH_ALEN
)) {
4188 if ((psRSNCapObj
->bRSNCapExist
== true)
4189 && (psRSNCapObj
->wRSNCap
& BIT0
)) {
4190 pCandidateList
->Flags
|=
4191 NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED
;
4193 pCandidateList
->Flags
&=
4194 ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED
);
4201 pCandidateList
= &pDevice
->gsPMKIDCandidate
.CandidateList
[pDevice
->gsPMKIDCandidate
.NumCandidates
];
4202 if ((psRSNCapObj
->bRSNCapExist
== true) && (psRSNCapObj
->wRSNCap
& BIT0
)) {
4203 pCandidateList
->Flags
|= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED
;
4205 pCandidateList
->Flags
&= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED
);
4207 memcpy(pCandidateList
->BSSID
, pbyBSSID
, ETH_ALEN
);
4208 pDevice
->gsPMKIDCandidate
.NumCandidates
++;
4209 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"NumCandidates:%d\n", (int)pDevice
->gsPMKIDCandidate
.NumCandidates
);
4216 * Flush PMKID Candidate list.
4220 * hDeviceContext - device structure point
4224 * Return Value: none.
4228 void vFlush_PMKID_Candidate(struct vnt_private
*pDevice
)
4230 if (pDevice
== NULL
)
4233 memset(&pDevice
->gsPMKIDCandidate
, 0, sizeof(SPMKIDCandidateEvent
));
4241 NDIS_802_11_ENCRYPTION_STATUS EncStatus
,
4246 u8 byMulticastCipher
= KEY_CTL_INVALID
;
4247 u8 byCipherMask
= 0x00;
4250 if (pBSSNode
== NULL
)
4253 // check cap. of BSS
4254 if ((WLAN_GET_CAP_INFO_PRIVACY(pBSSNode
->wCapInfo
) != 0) &&
4255 (EncStatus
== Ndis802_11Encryption1Enabled
)) {
4256 // default is WEP only
4257 byMulticastCipher
= KEY_CTL_WEP
;
4260 if ((WLAN_GET_CAP_INFO_PRIVACY(pBSSNode
->wCapInfo
) != 0) &&
4261 (pBSSNode
->bWPA2Valid
== true) &&
4263 ((EncStatus
== Ndis802_11Encryption3Enabled
) ||
4264 (EncStatus
== Ndis802_11Encryption2Enabled
))) {
4266 // check Group Key Cipher
4267 if ((pBSSNode
->byCSSGK
== WLAN_11i_CSS_WEP40
) ||
4268 (pBSSNode
->byCSSGK
== WLAN_11i_CSS_WEP104
)) {
4269 byMulticastCipher
= KEY_CTL_WEP
;
4270 } else if (pBSSNode
->byCSSGK
== WLAN_11i_CSS_TKIP
) {
4271 byMulticastCipher
= KEY_CTL_TKIP
;
4272 } else if (pBSSNode
->byCSSGK
== WLAN_11i_CSS_CCMP
) {
4273 byMulticastCipher
= KEY_CTL_CCMP
;
4275 byMulticastCipher
= KEY_CTL_INVALID
;
4278 /* check Pairwise Key Cipher */
4279 for (i
= 0; i
< pBSSNode
->wCSSPKCount
; i
++) {
4280 if ((pBSSNode
->abyCSSPK
[i
] == WLAN_11i_CSS_WEP40
) ||
4281 (pBSSNode
->abyCSSPK
[i
] == WLAN_11i_CSS_WEP104
)) {
4282 /* this should not happen as defined 802.11i */
4283 byCipherMask
|= 0x01;
4284 } else if (pBSSNode
->abyCSSPK
[i
] == WLAN_11i_CSS_TKIP
) {
4285 byCipherMask
|= 0x02;
4286 } else if (pBSSNode
->abyCSSPK
[i
] == WLAN_11i_CSS_CCMP
) {
4287 byCipherMask
|= 0x04;
4288 } else if (pBSSNode
->abyCSSPK
[i
] == WLAN_11i_CSS_USE_GROUP
) {
4289 /* use group key only ignore all others */
4291 i
= pBSSNode
->wCSSPKCount
;
4295 } else if ((WLAN_GET_CAP_INFO_PRIVACY(pBSSNode
->wCapInfo
) != 0) &&
4296 (pBSSNode
->bWPAValid
== true) &&
4297 ((EncStatus
== Ndis802_11Encryption2Enabled
) || (EncStatus
== Ndis802_11Encryption3Enabled
))) {
4299 // check Group Key Cipher
4300 if ((pBSSNode
->byGKType
== WPA_WEP40
) ||
4301 (pBSSNode
->byGKType
== WPA_WEP104
)) {
4302 byMulticastCipher
= KEY_CTL_WEP
;
4303 } else if (pBSSNode
->byGKType
== WPA_TKIP
) {
4304 byMulticastCipher
= KEY_CTL_TKIP
;
4305 } else if (pBSSNode
->byGKType
== WPA_AESCCMP
) {
4306 byMulticastCipher
= KEY_CTL_CCMP
;
4308 byMulticastCipher
= KEY_CTL_INVALID
;
4311 /* check Pairwise Key Cipher */
4312 for (i
= 0; i
< pBSSNode
->wPKCount
; i
++) {
4313 if (pBSSNode
->abyPKType
[i
] == WPA_TKIP
) {
4314 byCipherMask
|= 0x02;
4315 } else if (pBSSNode
->abyPKType
[i
] == WPA_AESCCMP
) {
4316 byCipherMask
|= 0x04;
4317 } else if (pBSSNode
->abyPKType
[i
] == WPA_NONE
) {
4318 /* use group key only ignore all others */
4320 i
= pBSSNode
->wPKCount
;
4325 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%d, %d, %d, %d, EncStatus:%d\n",
4326 byMulticastCipher
, byCipherMask
, pBSSNode
->bWPAValid
, pBSSNode
->bWPA2Valid
, EncStatus
);
4328 // mask our cap. with BSS
4329 if (EncStatus
== Ndis802_11Encryption1Enabled
) {
4331 // For supporting Cisco migration mode, don't care pairwise key cipher
4332 //if ((byMulticastCipher == KEY_CTL_WEP) &&
4333 // (byCipherMask == 0)) {
4334 if ((byMulticastCipher
== KEY_CTL_WEP
) &&
4335 (byCipherMask
== 0)) {
4336 *pbyCCSGK
= KEY_CTL_WEP
;
4337 *pbyCCSPK
= KEY_CTL_NONE
;
4343 } else if (EncStatus
== Ndis802_11Encryption2Enabled
) {
4344 if ((byMulticastCipher
== KEY_CTL_TKIP
) &&
4345 (byCipherMask
== 0)) {
4346 *pbyCCSGK
= KEY_CTL_TKIP
;
4347 *pbyCCSPK
= KEY_CTL_NONE
;
4349 } else if ((byMulticastCipher
== KEY_CTL_WEP
) &&
4350 ((byCipherMask
& 0x02) != 0)) {
4351 *pbyCCSGK
= KEY_CTL_WEP
;
4352 *pbyCCSPK
= KEY_CTL_TKIP
;
4354 } else if ((byMulticastCipher
== KEY_CTL_TKIP
) &&
4355 ((byCipherMask
& 0x02) != 0)) {
4356 *pbyCCSGK
= KEY_CTL_TKIP
;
4357 *pbyCCSPK
= KEY_CTL_TKIP
;
4362 } else if (EncStatus
== Ndis802_11Encryption3Enabled
) {
4363 if ((byMulticastCipher
== KEY_CTL_CCMP
) &&
4364 (byCipherMask
== 0)) {
4365 // When CCMP is enable, "Use group cipher suite" shall not be a valid option.
4367 } else if ((byMulticastCipher
== KEY_CTL_WEP
) &&
4368 ((byCipherMask
& 0x04) != 0)) {
4369 *pbyCCSGK
= KEY_CTL_WEP
;
4370 *pbyCCSPK
= KEY_CTL_CCMP
;
4372 } else if ((byMulticastCipher
== KEY_CTL_TKIP
) &&
4373 ((byCipherMask
& 0x04) != 0)) {
4374 *pbyCCSGK
= KEY_CTL_TKIP
;
4375 *pbyCCSPK
= KEY_CTL_CCMP
;
4377 } else if ((byMulticastCipher
== KEY_CTL_CCMP
) &&
4378 ((byCipherMask
& 0x04) != 0)) {
4379 *pbyCCSGK
= KEY_CTL_CCMP
;
4380 *pbyCCSPK
= KEY_CTL_CCMP
;