Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. |
| 3 | * All rights reserved. |
| 4 | * |
| 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. |
| 9 | * |
| 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. |
| 14 | * |
| 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. |
| 18 | * |
| 19 | * |
| 20 | * File: wmgr.c |
| 21 | * |
| 22 | * Purpose: Handles the 802.11 management functions |
| 23 | * |
| 24 | * Author: Lyndon Chen |
| 25 | * |
| 26 | * Date: May 8, 2002 |
| 27 | * |
| 28 | * Functions: |
| 29 | * nsMgrObjectInitial - Initialize Management Objet data structure |
Justin P. Mattock | a0a1f61 | 2012-08-26 08:16:43 -0700 | [diff] [blame] | 30 | * vMgrObjectReset - Reset Management Object data structure |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 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 |
Masanari Iida | 9318469 | 2012-08-13 21:21:50 +0900 | [diff] [blame] | 57 | * s_vMgrFormatTIM- Assembler TIM field of beacon |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 58 | * vMgrTimerInit- Initial 1-sec and command call back funtions |
| 59 | * |
| 60 | * Revision History: |
| 61 | * |
| 62 | */ |
| 63 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 64 | #include "tmacro.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 65 | #include "desc.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 66 | #include "device.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 67 | #include "card.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 68 | #include "80211hdr.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 69 | #include "80211mgr.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 70 | #include "wmgr.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 71 | #include "wcmd.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 72 | #include "mac.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 73 | #include "bssdb.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 74 | #include "power.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 75 | #include "datarate.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 76 | #include "baseband.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 77 | #include "rxtx.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 78 | #include "wpa.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 79 | #include "rf.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 80 | #include "iowpa.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 81 | #include "control.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 82 | #include "rndis.h" |
Jim Lieb | 9d26d60 | 2009-08-12 14:54:08 -0700 | [diff] [blame] | 83 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 84 | static int msglevel =MSG_LEVEL_INFO; |
| 85 | //static int msglevel =MSG_LEVEL_DEBUG; |
| 86 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 87 | static int ChannelExceedZoneType(struct vnt_private *, u8 byCurrChannel); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 88 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 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); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 94 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 95 | static void s_vMgrRxAssocRequest(struct vnt_private *, |
| 96 | struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket, |
| 97 | u32 uNodeIndex); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 98 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 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); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 103 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 104 | static void s_vMgrRxAssocResponse(struct vnt_private *, |
| 105 | struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket, |
| 106 | int bReAssocType); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 107 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 108 | static void s_vMgrRxDisassociation(struct vnt_private *, |
| 109 | struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 110 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 111 | /* Authentication/deauthen functions */ |
| 112 | static void s_vMgrRxAuthenSequence_1(struct vnt_private *, |
| 113 | struct vnt_manager *pMgmt, PWLAN_FR_AUTHEN pFrame); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 114 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 115 | static void s_vMgrRxAuthenSequence_2(struct vnt_private *, |
| 116 | struct vnt_manager *pMgmt, PWLAN_FR_AUTHEN pFrame); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 117 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 118 | static void s_vMgrRxAuthenSequence_3(struct vnt_private *, |
| 119 | struct vnt_manager *pMgmt, PWLAN_FR_AUTHEN pFrame); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 120 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 121 | static void s_vMgrRxAuthenSequence_4(struct vnt_private *, |
| 122 | struct vnt_manager *pMgmt, PWLAN_FR_AUTHEN pFrame); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 123 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 124 | static void s_vMgrRxAuthentication(struct vnt_private *, |
| 125 | struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 126 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 127 | static void s_vMgrRxDeauthentication(struct vnt_private *, |
| 128 | struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 129 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 130 | /* Scan functions |
| 131 | * probe request/response functions */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 132 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 133 | static void s_vMgrRxProbeRequest(struct vnt_private *, |
| 134 | struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 135 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 136 | static void s_vMgrRxProbeResponse(struct vnt_private *, |
| 137 | struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 138 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 139 | /* beacon functions */ |
| 140 | static void s_vMgrRxBeacon(struct vnt_private *pDevice, |
| 141 | struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket, |
| 142 | int bInScan); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 143 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 144 | static void s_vMgrFormatTIM(struct vnt_manager *pMgmt, PWLAN_IE_TIM pTIM); |
| 145 | |
| 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); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 151 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 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); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 157 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 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); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 163 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 164 | /* Probe response */ |
| 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); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 171 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 172 | /* received status */ |
| 173 | static void s_vMgrLogStatus(struct vnt_manager *pMgmt, u16 wStatus); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 174 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 175 | static void s_vMgrSynchBSS(struct vnt_private *, u32 uBSSMode, |
| 176 | PKnownBSS pCurr, PCMD_STATUS pStatus); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 177 | |
Andres More | dfdcc42 | 2013-02-12 20:36:28 -0500 | [diff] [blame] | 178 | static bool |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 179 | s_bCipherMatch ( |
Andres More | 592ccfe | 2010-04-17 12:07:42 -0300 | [diff] [blame] | 180 | PKnownBSS pBSSNode, |
| 181 | NDIS_802_11_ENCRYPTION_STATUS EncStatus, |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 182 | u8 * pbyCCSPK, |
| 183 | u8 * pbyCCSGK |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 184 | ); |
| 185 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 186 | static void Encyption_Rebuild(struct vnt_private *, PKnownBSS pCurr); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 187 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 188 | /*+ |
| 189 | * |
| 190 | * Routine Description: |
| 191 | * Allocates and initializes the Management object. |
| 192 | * |
| 193 | * Return Value: |
| 194 | * Ndis_staus. |
| 195 | * |
| 196 | -*/ |
| 197 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 198 | void vMgrObjectInit(struct vnt_private *pDevice) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 199 | { |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 200 | struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; |
| 201 | int ii; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 202 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 203 | pMgmt->pbyPSPacketPool = &pMgmt->byPSPacketPool[0]; |
| 204 | pMgmt->pbyMgmtPacketPool = &pMgmt->byMgmtPacketPool[0]; |
| 205 | pMgmt->uCurrChannel = pDevice->uChannel; |
Andres More | 33d33e42 | 2010-05-19 23:50:00 -0300 | [diff] [blame] | 206 | for (ii = 0; ii < WLAN_BSSID_LEN; ii++) |
| 207 | pMgmt->abyDesireBSSID[ii] = 0xFF; |
| 208 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 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; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 214 | BSSvClearBSSList((void *) pDevice, false); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 215 | |
| 216 | init_timer(&pMgmt->sTimerSecondCallback); |
Andres More | cc856e6 | 2010-05-17 21:34:01 -0300 | [diff] [blame] | 217 | pMgmt->sTimerSecondCallback.data = (unsigned long)pDevice; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 218 | pMgmt->sTimerSecondCallback.function = (TimerFunction)BSSvSecondCallBack; |
| 219 | pMgmt->sTimerSecondCallback.expires = RUN_AT(HZ); |
| 220 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 221 | init_timer(&pDevice->sTimerTxData); |
Andres More | cc856e6 | 2010-05-17 21:34:01 -0300 | [diff] [blame] | 222 | pDevice->sTimerTxData.data = (unsigned long)pDevice; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 223 | pDevice->sTimerTxData.function = (TimerFunction)BSSvSecondTxData; |
| 224 | pDevice->sTimerTxData.expires = RUN_AT(10*HZ); //10s callback |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 225 | pDevice->fTxDataInSleep = false; |
| 226 | pDevice->IsTxDataTrigger = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 227 | pDevice->nTxDataTimeCout = 0; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 228 | |
| 229 | pDevice->cbFreeCmdQueue = CMD_Q_SIZE; |
| 230 | pDevice->uCmdDequeueIdx = 0; |
| 231 | pDevice->uCmdEnqueueIdx = 0; |
| 232 | pDevice->eCommandState = WLAN_CMD_IDLE; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 233 | pDevice->bCmdRunning = false; |
| 234 | pDevice->bCmdClear = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 235 | |
| 236 | return; |
| 237 | } |
| 238 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 239 | /*+ |
| 240 | * |
| 241 | * Routine Description: |
| 242 | * Start the station association procedure. Namely, send an |
| 243 | * association request frame to the AP. |
| 244 | * |
| 245 | * Return Value: |
| 246 | * None. |
| 247 | * |
| 248 | -*/ |
| 249 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 250 | void vMgrAssocBeginSta(struct vnt_private *pDevice, |
| 251 | struct vnt_manager *pMgmt, PCMD_STATUS pStatus) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 252 | { |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 253 | struct vnt_tx_mgmt *pTxPacket; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 254 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 255 | pMgmt->wCurrCapInfo = 0; |
| 256 | pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_ESS(1); |
| 257 | if (pDevice->bEncryptionEnable) { |
| 258 | pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_PRIVACY(1); |
| 259 | } |
| 260 | // always allow receive short preamble |
| 261 | //if (pDevice->byPreambleType == 1) { |
| 262 | // pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1); |
| 263 | //} |
| 264 | pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1); |
| 265 | if (pMgmt->wListenInterval == 0) |
| 266 | pMgmt->wListenInterval = 1; // at least one. |
| 267 | |
| 268 | // ERP Phy (802.11g) should support short preamble. |
| 269 | if (pMgmt->eCurrentPHYMode == PHY_TYPE_11G) { |
| 270 | pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1); |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 271 | if (pDevice->bShortSlotTime == true) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 272 | pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTSLOTTIME(1); |
| 273 | |
| 274 | } else if (pMgmt->eCurrentPHYMode == PHY_TYPE_11B) { |
| 275 | if (pDevice->byPreambleType == 1) { |
| 276 | pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1); |
| 277 | } |
| 278 | } |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 279 | if (pMgmt->b11hEnable == true) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 280 | pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SPECTRUMMNG(1); |
| 281 | |
| 282 | // build an assocreq frame and send it |
| 283 | pTxPacket = s_MgrMakeAssocRequest |
| 284 | ( |
| 285 | pDevice, |
| 286 | pMgmt, |
| 287 | pMgmt->abyCurrBSSID, |
| 288 | pMgmt->wCurrCapInfo, |
| 289 | pMgmt->wListenInterval, |
| 290 | (PWLAN_IE_SSID)pMgmt->abyCurrSSID, |
| 291 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, |
| 292 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates |
| 293 | ); |
| 294 | |
| 295 | if (pTxPacket != NULL ){ |
| 296 | // send the frame |
| 297 | *pStatus = csMgmt_xmit(pDevice, pTxPacket); |
| 298 | if (*pStatus == CMD_STATUS_PENDING) { |
| 299 | pMgmt->eCurrState = WMAC_STATE_ASSOCPENDING; |
| 300 | *pStatus = CMD_STATUS_SUCCESS; |
| 301 | } |
| 302 | } |
| 303 | else |
| 304 | *pStatus = CMD_STATUS_RESOURCES; |
| 305 | |
| 306 | return ; |
| 307 | } |
| 308 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 309 | /*+ |
| 310 | * |
| 311 | * Routine Description: |
| 312 | * Start the station re-association procedure. |
| 313 | * |
| 314 | * Return Value: |
| 315 | * None. |
| 316 | * |
| 317 | -*/ |
| 318 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 319 | void vMgrReAssocBeginSta(struct vnt_private *pDevice, |
| 320 | struct vnt_manager *pMgmt, PCMD_STATUS pStatus) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 321 | { |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 322 | struct vnt_tx_mgmt *pTxPacket; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 323 | |
| 324 | pMgmt->wCurrCapInfo = 0; |
| 325 | pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_ESS(1); |
| 326 | if (pDevice->bEncryptionEnable) { |
| 327 | pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_PRIVACY(1); |
| 328 | } |
| 329 | |
| 330 | //if (pDevice->byPreambleType == 1) { |
| 331 | // pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1); |
| 332 | //} |
| 333 | pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1); |
| 334 | |
| 335 | if (pMgmt->wListenInterval == 0) |
| 336 | pMgmt->wListenInterval = 1; // at least one. |
| 337 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 338 | // ERP Phy (802.11g) should support short preamble. |
| 339 | if (pMgmt->eCurrentPHYMode == PHY_TYPE_11G) { |
| 340 | pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1); |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 341 | if (pDevice->bShortSlotTime == true) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 342 | pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTSLOTTIME(1); |
| 343 | |
| 344 | } else if (pMgmt->eCurrentPHYMode == PHY_TYPE_11B) { |
| 345 | if (pDevice->byPreambleType == 1) { |
| 346 | pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1); |
| 347 | } |
| 348 | } |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 349 | if (pMgmt->b11hEnable == true) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 350 | pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SPECTRUMMNG(1); |
| 351 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 352 | pTxPacket = s_MgrMakeReAssocRequest |
| 353 | ( |
| 354 | pDevice, |
| 355 | pMgmt, |
| 356 | pMgmt->abyCurrBSSID, |
| 357 | pMgmt->wCurrCapInfo, |
| 358 | pMgmt->wListenInterval, |
| 359 | (PWLAN_IE_SSID)pMgmt->abyCurrSSID, |
| 360 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, |
| 361 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates |
| 362 | ); |
| 363 | |
| 364 | if (pTxPacket != NULL ){ |
| 365 | // send the frame |
| 366 | *pStatus = csMgmt_xmit(pDevice, pTxPacket); |
| 367 | if (*pStatus != CMD_STATUS_PENDING) { |
| 368 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Reassociation tx failed.\n"); |
| 369 | } |
| 370 | else { |
| 371 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Reassociation tx sending.\n"); |
| 372 | } |
| 373 | } |
| 374 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 375 | return ; |
| 376 | } |
| 377 | |
| 378 | /*+ |
| 379 | * |
| 380 | * Routine Description: |
| 381 | * Send an dis-association request frame to the AP. |
| 382 | * |
| 383 | * Return Value: |
| 384 | * None. |
| 385 | * |
| 386 | -*/ |
| 387 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 388 | void vMgrDisassocBeginSta(struct vnt_private *pDevice, |
| 389 | struct vnt_manager *pMgmt, u8 *abyDestAddress, u16 wReason, |
| 390 | PCMD_STATUS pStatus) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 391 | { |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 392 | struct vnt_tx_mgmt *pTxPacket = NULL; |
| 393 | WLAN_FR_DISASSOC sFrame; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 394 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 395 | pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool; |
| 396 | memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt) |
| 397 | + WLAN_DISASSOC_FR_MAXLEN); |
| 398 | pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket |
| 399 | + sizeof(struct vnt_tx_mgmt)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 400 | |
| 401 | // Setup the sFrame structure |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 402 | sFrame.pBuf = (u8 *)pTxPacket->p80211Header; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 403 | sFrame.len = WLAN_DISASSOC_FR_MAXLEN; |
| 404 | |
| 405 | // format fixed field frame structure |
| 406 | vMgrEncodeDisassociation(&sFrame); |
| 407 | |
| 408 | // Setup the header |
| 409 | sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16( |
| 410 | ( |
| 411 | WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) | |
| 412 | WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_DISASSOC) |
| 413 | )); |
| 414 | |
| 415 | memcpy( sFrame.pHdr->sA3.abyAddr1, abyDestAddress, WLAN_ADDR_LEN); |
| 416 | memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN); |
| 417 | memcpy( sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); |
| 418 | |
| 419 | // Set reason code |
| 420 | *(sFrame.pwReason) = cpu_to_le16(wReason); |
| 421 | pTxPacket->cbMPDULen = sFrame.len; |
| 422 | pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; |
| 423 | |
| 424 | // send the frame |
| 425 | *pStatus = csMgmt_xmit(pDevice, pTxPacket); |
| 426 | if (*pStatus == CMD_STATUS_PENDING) { |
| 427 | pMgmt->eCurrState = WMAC_STATE_IDLE; |
| 428 | *pStatus = CMD_STATUS_SUCCESS; |
Joe Perches | 9fc8602 | 2011-04-10 14:31:32 -0700 | [diff] [blame] | 429 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 430 | |
| 431 | return; |
| 432 | } |
| 433 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 434 | /*+ |
| 435 | * |
| 436 | * Routine Description:(AP function) |
| 437 | * Handle incoming station association request frames. |
| 438 | * |
| 439 | * Return Value: |
| 440 | * None. |
| 441 | * |
| 442 | -*/ |
| 443 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 444 | static void s_vMgrRxAssocRequest(struct vnt_private *pDevice, |
| 445 | struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket, |
| 446 | u32 uNodeIndex) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 447 | { |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 448 | WLAN_FR_ASSOCREQ sFrame; |
| 449 | CMD_STATUS Status; |
| 450 | struct vnt_tx_mgmt *pTxPacket; |
| 451 | u16 wAssocStatus = 0; |
| 452 | u16 wAssocAID = 0; |
| 453 | u32 uRateLen = WLAN_RATES_MAXLEN; |
| 454 | u8 abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; |
| 455 | u8 abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 456 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 457 | if (pMgmt->eCurrMode != WMAC_MODE_ESS_AP) |
| 458 | return; |
| 459 | // node index not found |
| 460 | if (!uNodeIndex) |
| 461 | return; |
| 462 | |
| 463 | //check if node is authenticated |
| 464 | //decode the frame |
| 465 | memset(&sFrame, 0, sizeof(WLAN_FR_ASSOCREQ)); |
| 466 | memset(abyCurrSuppRates, 0, WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1); |
| 467 | memset(abyCurrExtSuppRates, 0, WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1); |
| 468 | sFrame.len = pRxPacket->cbMPDULen; |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 469 | sFrame.pBuf = (u8 *)pRxPacket->p80211Header; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 470 | |
| 471 | vMgrDecodeAssocRequest(&sFrame); |
| 472 | |
| 473 | if (pMgmt->sNodeDBTable[uNodeIndex].eNodeState >= NODE_AUTH) { |
| 474 | pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_ASSOC; |
| 475 | pMgmt->sNodeDBTable[uNodeIndex].wCapInfo = cpu_to_le16(*sFrame.pwCapInfo); |
| 476 | pMgmt->sNodeDBTable[uNodeIndex].wListenInterval = cpu_to_le16(*sFrame.pwListenInterval); |
| 477 | pMgmt->sNodeDBTable[uNodeIndex].bPSEnable = |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 478 | WLAN_GET_FC_PWRMGT(sFrame.pHdr->sA3.wFrameCtl) ? true : false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 479 | // Todo: check sta basic rate, if ap can't support, set status code |
| 480 | if (pDevice->byBBType == BB_TYPE_11B) { |
| 481 | uRateLen = WLAN_RATES_MAXLEN_11B; |
| 482 | } |
| 483 | abyCurrSuppRates[0] = WLAN_EID_SUPP_RATES; |
| 484 | abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pSuppRates, |
| 485 | (PWLAN_IE_SUPP_RATES)abyCurrSuppRates, |
| 486 | uRateLen); |
| 487 | abyCurrExtSuppRates[0] = WLAN_EID_EXTSUPP_RATES; |
| 488 | if (pDevice->byBBType == BB_TYPE_11G) { |
| 489 | abyCurrExtSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pExtSuppRates, |
| 490 | (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRates, |
| 491 | uRateLen); |
| 492 | } else { |
| 493 | abyCurrExtSuppRates[1] = 0; |
| 494 | } |
| 495 | |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 496 | RATEvParseMaxRate((void *)pDevice, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 497 | (PWLAN_IE_SUPP_RATES)abyCurrSuppRates, |
| 498 | (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRates, |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 499 | false, // do not change our basic rate |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 500 | &(pMgmt->sNodeDBTable[uNodeIndex].wMaxBasicRate), |
| 501 | &(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate), |
| 502 | &(pMgmt->sNodeDBTable[uNodeIndex].wSuppRate), |
| 503 | &(pMgmt->sNodeDBTable[uNodeIndex].byTopCCKBasicRate), |
| 504 | &(pMgmt->sNodeDBTable[uNodeIndex].byTopOFDMBasicRate) |
| 505 | ); |
| 506 | |
| 507 | // set max tx rate |
| 508 | pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate = |
| 509 | pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate; |
| 510 | // Todo: check sta preamble, if ap can't support, set status code |
| 511 | pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble = |
| 512 | WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame.pwCapInfo); |
| 513 | pMgmt->sNodeDBTable[uNodeIndex].bShortSlotTime = |
| 514 | WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame.pwCapInfo); |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 515 | pMgmt->sNodeDBTable[uNodeIndex].wAID = (u16)uNodeIndex; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 516 | wAssocStatus = WLAN_MGMT_STATUS_SUCCESS; |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 517 | wAssocAID = (u16)uNodeIndex; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 518 | // check if ERP support |
| 519 | if(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate > RATE_11M) |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 520 | pMgmt->sNodeDBTable[uNodeIndex].bERPExist = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 521 | |
| 522 | if (pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate <= RATE_11M) { |
| 523 | // B only STA join |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 524 | pDevice->bProtectMode = true; |
| 525 | pDevice->bNonERPPresent = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 526 | } |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 527 | if (pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble == false) { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 528 | pDevice->bBarkerPreambleMd = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 529 | } |
| 530 | |
| 531 | DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "Associate AID= %d \n", wAssocAID); |
| 532 | DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "MAC=%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X \n", |
| 533 | sFrame.pHdr->sA3.abyAddr2[0], |
| 534 | sFrame.pHdr->sA3.abyAddr2[1], |
| 535 | sFrame.pHdr->sA3.abyAddr2[2], |
| 536 | sFrame.pHdr->sA3.abyAddr2[3], |
| 537 | sFrame.pHdr->sA3.abyAddr2[4], |
| 538 | sFrame.pHdr->sA3.abyAddr2[5] |
| 539 | ) ; |
| 540 | DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "Max Support rate = %d \n", |
| 541 | pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate); |
| 542 | } |
| 543 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 544 | // assoc response reply.. |
| 545 | pTxPacket = s_MgrMakeAssocResponse |
| 546 | ( |
| 547 | pDevice, |
| 548 | pMgmt, |
| 549 | pMgmt->wCurrCapInfo, |
| 550 | wAssocStatus, |
| 551 | wAssocAID, |
| 552 | sFrame.pHdr->sA3.abyAddr2, |
| 553 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, |
| 554 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates |
| 555 | ); |
| 556 | if (pTxPacket != NULL ){ |
| 557 | |
| 558 | if (pDevice->bEnableHostapd) { |
| 559 | return; |
| 560 | } |
| 561 | /* send the frame */ |
| 562 | Status = csMgmt_xmit(pDevice, pTxPacket); |
| 563 | if (Status != CMD_STATUS_PENDING) { |
| 564 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Assoc response tx failed\n"); |
| 565 | } |
| 566 | else { |
| 567 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Assoc response tx sending..\n"); |
| 568 | } |
| 569 | |
| 570 | } |
| 571 | |
| 572 | return; |
| 573 | } |
| 574 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 575 | /*+ |
| 576 | * |
| 577 | * Description:(AP function) |
| 578 | * Handle incoming station re-association request frames. |
| 579 | * |
| 580 | * Parameters: |
| 581 | * In: |
| 582 | * pMgmt - Management Object structure |
| 583 | * pRxPacket - Received Packet |
| 584 | * Out: |
| 585 | * none |
| 586 | * |
| 587 | * Return Value: None. |
| 588 | * |
| 589 | -*/ |
| 590 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 591 | static void s_vMgrRxReAssocRequest(struct vnt_private *pDevice, |
| 592 | struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket, |
| 593 | u32 uNodeIndex) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 594 | { |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 595 | WLAN_FR_REASSOCREQ sFrame; |
| 596 | CMD_STATUS Status; |
| 597 | struct vnt_tx_mgmt *pTxPacket; |
| 598 | u16 wAssocStatus = 0; |
| 599 | u16 wAssocAID = 0; |
| 600 | u32 uRateLen = WLAN_RATES_MAXLEN; |
| 601 | u8 abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; |
| 602 | u8 abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 603 | |
| 604 | if (pMgmt->eCurrMode != WMAC_MODE_ESS_AP) |
| 605 | return; |
| 606 | // node index not found |
| 607 | if (!uNodeIndex) |
| 608 | return; |
| 609 | //check if node is authenticated |
| 610 | //decode the frame |
| 611 | memset(&sFrame, 0, sizeof(WLAN_FR_REASSOCREQ)); |
| 612 | sFrame.len = pRxPacket->cbMPDULen; |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 613 | sFrame.pBuf = (u8 *)pRxPacket->p80211Header; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 614 | vMgrDecodeReassocRequest(&sFrame); |
| 615 | |
| 616 | if (pMgmt->sNodeDBTable[uNodeIndex].eNodeState >= NODE_AUTH) { |
| 617 | pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_ASSOC; |
| 618 | pMgmt->sNodeDBTable[uNodeIndex].wCapInfo = cpu_to_le16(*sFrame.pwCapInfo); |
| 619 | pMgmt->sNodeDBTable[uNodeIndex].wListenInterval = cpu_to_le16(*sFrame.pwListenInterval); |
| 620 | pMgmt->sNodeDBTable[uNodeIndex].bPSEnable = |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 621 | WLAN_GET_FC_PWRMGT(sFrame.pHdr->sA3.wFrameCtl) ? true : false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 622 | // Todo: check sta basic rate, if ap can't support, set status code |
| 623 | |
| 624 | if (pDevice->byBBType == BB_TYPE_11B) { |
| 625 | uRateLen = WLAN_RATES_MAXLEN_11B; |
| 626 | } |
| 627 | |
| 628 | abyCurrSuppRates[0] = WLAN_EID_SUPP_RATES; |
| 629 | abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pSuppRates, |
| 630 | (PWLAN_IE_SUPP_RATES)abyCurrSuppRates, |
| 631 | uRateLen); |
| 632 | abyCurrExtSuppRates[0] = WLAN_EID_EXTSUPP_RATES; |
| 633 | if (pDevice->byBBType == BB_TYPE_11G) { |
| 634 | abyCurrExtSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pExtSuppRates, |
| 635 | (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRates, |
| 636 | uRateLen); |
| 637 | } else { |
| 638 | abyCurrExtSuppRates[1] = 0; |
| 639 | } |
| 640 | |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 641 | RATEvParseMaxRate((void *)pDevice, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 642 | (PWLAN_IE_SUPP_RATES)abyCurrSuppRates, |
| 643 | (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRates, |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 644 | false, // do not change our basic rate |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 645 | &(pMgmt->sNodeDBTable[uNodeIndex].wMaxBasicRate), |
| 646 | &(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate), |
| 647 | &(pMgmt->sNodeDBTable[uNodeIndex].wSuppRate), |
| 648 | &(pMgmt->sNodeDBTable[uNodeIndex].byTopCCKBasicRate), |
| 649 | &(pMgmt->sNodeDBTable[uNodeIndex].byTopOFDMBasicRate) |
| 650 | ); |
| 651 | |
| 652 | // set max tx rate |
| 653 | pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate = |
| 654 | pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate; |
| 655 | // Todo: check sta preamble, if ap can't support, set status code |
| 656 | pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble = |
| 657 | WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame.pwCapInfo); |
| 658 | pMgmt->sNodeDBTable[uNodeIndex].bShortSlotTime = |
| 659 | WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame.pwCapInfo); |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 660 | pMgmt->sNodeDBTable[uNodeIndex].wAID = (u16)uNodeIndex; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 661 | wAssocStatus = WLAN_MGMT_STATUS_SUCCESS; |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 662 | wAssocAID = (u16)uNodeIndex; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 663 | |
| 664 | // if suppurt ERP |
| 665 | if(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate > RATE_11M) |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 666 | pMgmt->sNodeDBTable[uNodeIndex].bERPExist = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 667 | |
| 668 | if (pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate <= RATE_11M) { |
| 669 | // B only STA join |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 670 | pDevice->bProtectMode = true; |
| 671 | pDevice->bNonERPPresent = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 672 | } |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 673 | if (pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble == false) { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 674 | pDevice->bBarkerPreambleMd = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 675 | } |
| 676 | |
| 677 | DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "Rx ReAssociate AID= %d \n", wAssocAID); |
| 678 | DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "MAC=%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X \n", |
| 679 | sFrame.pHdr->sA3.abyAddr2[0], |
| 680 | sFrame.pHdr->sA3.abyAddr2[1], |
| 681 | sFrame.pHdr->sA3.abyAddr2[2], |
| 682 | sFrame.pHdr->sA3.abyAddr2[3], |
| 683 | sFrame.pHdr->sA3.abyAddr2[4], |
| 684 | sFrame.pHdr->sA3.abyAddr2[5] |
| 685 | ) ; |
| 686 | DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "Max Support rate = %d \n", |
| 687 | pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate); |
| 688 | |
| 689 | } |
| 690 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 691 | // assoc response reply.. |
| 692 | pTxPacket = s_MgrMakeReAssocResponse |
| 693 | ( |
| 694 | pDevice, |
| 695 | pMgmt, |
| 696 | pMgmt->wCurrCapInfo, |
| 697 | wAssocStatus, |
| 698 | wAssocAID, |
| 699 | sFrame.pHdr->sA3.abyAddr2, |
| 700 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, |
| 701 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates |
| 702 | ); |
| 703 | |
| 704 | if (pTxPacket != NULL ){ |
| 705 | /* send the frame */ |
| 706 | if (pDevice->bEnableHostapd) { |
| 707 | return; |
| 708 | } |
| 709 | Status = csMgmt_xmit(pDevice, pTxPacket); |
| 710 | if (Status != CMD_STATUS_PENDING) { |
| 711 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:ReAssoc response tx failed\n"); |
| 712 | } |
| 713 | else { |
| 714 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:ReAssoc response tx sending..\n"); |
| 715 | } |
| 716 | } |
| 717 | return; |
| 718 | } |
| 719 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 720 | /*+ |
| 721 | * |
| 722 | * Routine Description: |
| 723 | * Handle incoming association response frames. |
| 724 | * |
| 725 | * Return Value: |
| 726 | * None. |
| 727 | * |
| 728 | -*/ |
| 729 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 730 | static void s_vMgrRxAssocResponse(struct vnt_private *pDevice, |
| 731 | struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket, |
| 732 | int bReAssocType) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 733 | { |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 734 | WLAN_FR_ASSOCRESP sFrame; |
| 735 | PWLAN_IE_SSID pItemSSID; |
| 736 | u8 *pbyIEs; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 737 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 738 | if (pMgmt->eCurrState == WMAC_STATE_ASSOCPENDING || |
| 739 | pMgmt->eCurrState == WMAC_STATE_ASSOC) { |
| 740 | |
| 741 | sFrame.len = pRxPacket->cbMPDULen; |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 742 | sFrame.pBuf = (u8 *)pRxPacket->p80211Header; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 743 | // decode the frame |
| 744 | vMgrDecodeAssocResponse(&sFrame); |
Andres More | 6e1b4e2 | 2010-05-04 20:40:11 -0300 | [diff] [blame] | 745 | if ((sFrame.pwCapInfo == NULL) |
| 746 | || (sFrame.pwStatus == NULL) |
| 747 | || (sFrame.pwAid == NULL) |
| 748 | || (sFrame.pSuppRates == NULL)) { |
Andres More | 6e1b4e2 | 2010-05-04 20:40:11 -0300 | [diff] [blame] | 749 | return; |
Joe Perches | 9fc8602 | 2011-04-10 14:31:32 -0700 | [diff] [blame] | 750 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 751 | |
| 752 | pMgmt->sAssocInfo.AssocInfo.ResponseFixedIEs.Capabilities = *(sFrame.pwCapInfo); |
| 753 | pMgmt->sAssocInfo.AssocInfo.ResponseFixedIEs.StatusCode = *(sFrame.pwStatus); |
| 754 | pMgmt->sAssocInfo.AssocInfo.ResponseFixedIEs.AssociationId = *(sFrame.pwAid); |
| 755 | pMgmt->sAssocInfo.AssocInfo.AvailableResponseFixedIEs |= 0x07; |
| 756 | |
| 757 | pMgmt->sAssocInfo.AssocInfo.ResponseIELength = sFrame.len - 24 - 6; |
| 758 | pMgmt->sAssocInfo.AssocInfo.OffsetResponseIEs = pMgmt->sAssocInfo.AssocInfo.OffsetRequestIEs + pMgmt->sAssocInfo.AssocInfo.RequestIELength; |
| 759 | pbyIEs = pMgmt->sAssocInfo.abyIEs; |
| 760 | pbyIEs += pMgmt->sAssocInfo.AssocInfo.RequestIELength; |
| 761 | memcpy(pbyIEs, (sFrame.pBuf + 24 +6), pMgmt->sAssocInfo.AssocInfo.ResponseIELength); |
| 762 | |
| 763 | // save values and set current BSS state |
| 764 | if (cpu_to_le16((*(sFrame.pwStatus))) == WLAN_MGMT_STATUS_SUCCESS ){ |
| 765 | // set AID |
| 766 | pMgmt->wCurrAID = cpu_to_le16((*(sFrame.pwAid))); |
| 767 | if ( (pMgmt->wCurrAID >> 14) != (BIT0 | BIT1) ) |
| 768 | { |
| 769 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "AID from AP, has two msb clear.\n"); |
Joe Perches | 9fc8602 | 2011-04-10 14:31:32 -0700 | [diff] [blame] | 770 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 771 | DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "Association Successful, AID=%d.\n", pMgmt->wCurrAID & ~(BIT14|BIT15)); |
| 772 | pMgmt->eCurrState = WMAC_STATE_ASSOC; |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 773 | BSSvUpdateAPNode((void *) pDevice, |
| 774 | sFrame.pwCapInfo, |
| 775 | sFrame.pSuppRates, |
| 776 | sFrame.pExtSuppRates); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 777 | pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; |
| 778 | DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "Link with AP(SSID): %s\n", pItemSSID->abySSID); |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 779 | pDevice->bLinkPass = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 780 | ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER); |
Andres More | 465711b | 2010-08-03 20:25:50 -0300 | [diff] [blame] | 781 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 782 | //if(pDevice->bWPASuppWextEnabled == true) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 783 | { |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 784 | u8 buf[512]; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 785 | size_t len; |
| 786 | union iwreq_data wrqu; |
| 787 | int we_event; |
| 788 | |
| 789 | memset(buf, 0, 512); |
| 790 | |
| 791 | len = pMgmt->sAssocInfo.AssocInfo.RequestIELength; |
| 792 | if(len) { |
| 793 | memcpy(buf, pMgmt->sAssocInfo.abyIEs, len); |
| 794 | memset(&wrqu, 0, sizeof (wrqu)); |
| 795 | wrqu.data.length = len; |
| 796 | we_event = IWEVASSOCREQIE; |
| 797 | PRINT_K("wireless_send_event--->IWEVASSOCREQIE\n"); |
| 798 | wireless_send_event(pDevice->dev, we_event, &wrqu, buf); |
| 799 | } |
| 800 | |
| 801 | memset(buf, 0, 512); |
| 802 | len = pMgmt->sAssocInfo.AssocInfo.ResponseIELength; |
| 803 | |
| 804 | if(len) { |
| 805 | memcpy(buf, pbyIEs, len); |
| 806 | memset(&wrqu, 0, sizeof (wrqu)); |
| 807 | wrqu.data.length = len; |
| 808 | we_event = IWEVASSOCRESPIE; |
| 809 | PRINT_K("wireless_send_event--->IWEVASSOCRESPIE\n"); |
| 810 | wireless_send_event(pDevice->dev, we_event, &wrqu, buf); |
| 811 | } |
| 812 | |
| 813 | memset(&wrqu, 0, sizeof (wrqu)); |
| 814 | memcpy(wrqu.ap_addr.sa_data, &pMgmt->abyCurrBSSID[0], ETH_ALEN); |
| 815 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 816 | PRINT_K("wireless_send_event--->SIOCGIWAP(associated)\n"); |
| 817 | wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL); |
| 818 | |
| 819 | } |
Andres More | 465711b | 2010-08-03 20:25:50 -0300 | [diff] [blame] | 820 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 821 | } |
| 822 | else { |
| 823 | if (bReAssocType) { |
| 824 | pMgmt->eCurrState = WMAC_STATE_IDLE; |
| 825 | } |
| 826 | else { |
| 827 | // jump back to the auth state and indicate the error |
| 828 | pMgmt->eCurrState = WMAC_STATE_AUTH; |
| 829 | } |
| 830 | s_vMgrLogStatus(pMgmt,cpu_to_le16((*(sFrame.pwStatus)))); |
| 831 | } |
| 832 | |
| 833 | } |
| 834 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 835 | //need clear flags related to Networkmanager |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 836 | pDevice->bwextstep0 = false; |
| 837 | pDevice->bwextstep1 = false; |
| 838 | pDevice->bwextstep2 = false; |
| 839 | pDevice->bwextstep3 = false; |
| 840 | pDevice->bWPASuppWextEnabled = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 841 | |
Malcolm Priestley | 94488a7 | 2013-09-27 16:48:14 +0100 | [diff] [blame^] | 842 | if (pMgmt->eCurrState == WMAC_STATE_ASSOC) |
| 843 | schedule_delayed_work(&pDevice->run_command_work, 0); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 844 | |
| 845 | return; |
| 846 | } |
| 847 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 848 | /*+ |
| 849 | * |
| 850 | * Routine Description: |
| 851 | * Start the station authentication procedure. Namely, send an |
| 852 | * authentication frame to the AP. |
| 853 | * |
| 854 | * Return Value: |
| 855 | * None. |
| 856 | * |
| 857 | -*/ |
| 858 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 859 | void vMgrAuthenBeginSta(struct vnt_private *pDevice, |
| 860 | struct vnt_manager *pMgmt, PCMD_STATUS pStatus) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 861 | { |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 862 | WLAN_FR_AUTHEN sFrame; |
| 863 | struct vnt_tx_mgmt *pTxPacket = |
| 864 | (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 865 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 866 | memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt) |
| 867 | + WLAN_AUTHEN_FR_MAXLEN); |
| 868 | pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket |
| 869 | + sizeof(struct vnt_tx_mgmt)); |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 870 | sFrame.pBuf = (u8 *)pTxPacket->p80211Header; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 871 | sFrame.len = WLAN_AUTHEN_FR_MAXLEN; |
| 872 | vMgrEncodeAuthen(&sFrame); |
| 873 | /* insert values */ |
| 874 | sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16( |
| 875 | ( |
| 876 | WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) | |
| 877 | WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN) |
| 878 | )); |
| 879 | memcpy( sFrame.pHdr->sA3.abyAddr1, pMgmt->abyCurrBSSID, WLAN_ADDR_LEN); |
| 880 | memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN); |
| 881 | memcpy( sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); |
| 882 | if (pMgmt->bShareKeyAlgorithm) |
| 883 | *(sFrame.pwAuthAlgorithm) = cpu_to_le16(WLAN_AUTH_ALG_SHAREDKEY); |
| 884 | else |
| 885 | *(sFrame.pwAuthAlgorithm) = cpu_to_le16(WLAN_AUTH_ALG_OPENSYSTEM); |
| 886 | |
| 887 | *(sFrame.pwAuthSequence) = cpu_to_le16(1); |
| 888 | /* Adjust the length fields */ |
| 889 | pTxPacket->cbMPDULen = sFrame.len; |
| 890 | pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; |
| 891 | |
| 892 | *pStatus = csMgmt_xmit(pDevice, pTxPacket); |
| 893 | if (*pStatus == CMD_STATUS_PENDING){ |
| 894 | pMgmt->eCurrState = WMAC_STATE_AUTHPENDING; |
| 895 | *pStatus = CMD_STATUS_SUCCESS; |
| 896 | } |
| 897 | |
| 898 | return ; |
| 899 | } |
| 900 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 901 | /*+ |
| 902 | * |
| 903 | * Routine Description: |
| 904 | * Start the station(AP) deauthentication procedure. Namely, send an |
| 905 | * deauthentication frame to the AP or Sta. |
| 906 | * |
| 907 | * Return Value: |
| 908 | * None. |
| 909 | * |
| 910 | -*/ |
| 911 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 912 | void vMgrDeAuthenBeginSta(struct vnt_private *pDevice, |
| 913 | struct vnt_manager *pMgmt, u8 *abyDestAddress, u16 wReason, |
| 914 | PCMD_STATUS pStatus) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 915 | { |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 916 | WLAN_FR_DEAUTHEN sFrame; |
| 917 | struct vnt_tx_mgmt *pTxPacket = |
| 918 | (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 919 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 920 | memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt) |
| 921 | + WLAN_DEAUTHEN_FR_MAXLEN); |
| 922 | pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket |
| 923 | + sizeof(struct vnt_tx_mgmt)); |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 924 | sFrame.pBuf = (u8 *)pTxPacket->p80211Header; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 925 | sFrame.len = WLAN_DEAUTHEN_FR_MAXLEN; |
| 926 | vMgrEncodeDeauthen(&sFrame); |
| 927 | /* insert values */ |
| 928 | sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16( |
| 929 | ( |
| 930 | WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) | |
| 931 | WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_DEAUTHEN) |
| 932 | )); |
| 933 | |
| 934 | memcpy( sFrame.pHdr->sA3.abyAddr1, abyDestAddress, WLAN_ADDR_LEN); |
| 935 | memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN); |
| 936 | memcpy( sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); |
| 937 | |
| 938 | *(sFrame.pwReason) = cpu_to_le16(wReason); // deauthen. bcs left BSS |
| 939 | /* Adjust the length fields */ |
| 940 | pTxPacket->cbMPDULen = sFrame.len; |
| 941 | pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; |
| 942 | |
| 943 | *pStatus = csMgmt_xmit(pDevice, pTxPacket); |
| 944 | if (*pStatus == CMD_STATUS_PENDING){ |
| 945 | *pStatus = CMD_STATUS_SUCCESS; |
| 946 | } |
| 947 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 948 | return ; |
| 949 | } |
| 950 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 951 | /*+ |
| 952 | * |
| 953 | * Routine Description: |
| 954 | * Handle incoming authentication frames. |
| 955 | * |
| 956 | * Return Value: |
| 957 | * None. |
| 958 | * |
| 959 | -*/ |
| 960 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 961 | static void s_vMgrRxAuthentication(struct vnt_private *pDevice, |
| 962 | struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 963 | { |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 964 | WLAN_FR_AUTHEN sFrame; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 965 | |
| 966 | // we better be an AP or a STA in AUTHPENDING otherwise ignore |
| 967 | if (!(pMgmt->eCurrMode == WMAC_MODE_ESS_AP || |
| 968 | pMgmt->eCurrState == WMAC_STATE_AUTHPENDING)) { |
| 969 | return; |
| 970 | } |
| 971 | |
| 972 | // decode the frame |
| 973 | sFrame.len = pRxPacket->cbMPDULen; |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 974 | sFrame.pBuf = (u8 *)pRxPacket->p80211Header; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 975 | vMgrDecodeAuthen(&sFrame); |
| 976 | switch (cpu_to_le16((*(sFrame.pwAuthSequence )))){ |
| 977 | case 1: |
| 978 | //AP funciton |
| 979 | s_vMgrRxAuthenSequence_1(pDevice,pMgmt, &sFrame); |
| 980 | break; |
| 981 | case 2: |
| 982 | s_vMgrRxAuthenSequence_2(pDevice, pMgmt, &sFrame); |
| 983 | break; |
| 984 | case 3: |
| 985 | //AP funciton |
| 986 | s_vMgrRxAuthenSequence_3(pDevice, pMgmt, &sFrame); |
| 987 | break; |
| 988 | case 4: |
| 989 | s_vMgrRxAuthenSequence_4(pDevice, pMgmt, &sFrame); |
| 990 | break; |
| 991 | default: |
| 992 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Auth Sequence error, seq = %d\n", |
| 993 | cpu_to_le16((*(sFrame.pwAuthSequence)))); |
| 994 | break; |
| 995 | } |
| 996 | return; |
| 997 | } |
| 998 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 999 | /*+ |
| 1000 | * |
| 1001 | * Routine Description: |
| 1002 | * Handles incoming authen frames with sequence 1. Currently |
| 1003 | * assumes we're an AP. So far, no one appears to use authentication |
| 1004 | * in Ad-Hoc mode. |
| 1005 | * |
| 1006 | * Return Value: |
| 1007 | * None. |
| 1008 | * |
| 1009 | -*/ |
| 1010 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 1011 | static void s_vMgrRxAuthenSequence_1(struct vnt_private *pDevice, |
| 1012 | struct vnt_manager *pMgmt, PWLAN_FR_AUTHEN pFrame) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1013 | { |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 1014 | struct vnt_tx_mgmt *pTxPacket = NULL; |
| 1015 | u32 uNodeIndex; |
| 1016 | WLAN_FR_AUTHEN sFrame; |
| 1017 | PSKeyItem pTransmitKey; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1018 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 1019 | /* Insert a Node entry */ |
| 1020 | if (!BSSbIsSTAInNodeDB(pDevice, pFrame->pHdr->sA3.abyAddr2, |
| 1021 | &uNodeIndex)) { |
| 1022 | BSSvCreateOneNode(pDevice, &uNodeIndex); |
| 1023 | memcpy(pMgmt->sNodeDBTable[uNodeIndex].abyMACAddr, |
| 1024 | pFrame->pHdr->sA3.abyAddr2, WLAN_ADDR_LEN); |
| 1025 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1026 | |
| 1027 | if (pMgmt->bShareKeyAlgorithm) { |
| 1028 | pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_KNOWN; |
| 1029 | pMgmt->sNodeDBTable[uNodeIndex].byAuthSequence = 1; |
| 1030 | } |
| 1031 | else { |
| 1032 | pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_AUTH; |
| 1033 | } |
| 1034 | |
| 1035 | // send auth reply |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 1036 | pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool; |
| 1037 | memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt) |
| 1038 | + WLAN_AUTHEN_FR_MAXLEN); |
| 1039 | pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket |
| 1040 | + sizeof(struct vnt_tx_mgmt)); |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 1041 | sFrame.pBuf = (u8 *)pTxPacket->p80211Header; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1042 | sFrame.len = WLAN_AUTHEN_FR_MAXLEN; |
| 1043 | // format buffer structure |
| 1044 | vMgrEncodeAuthen(&sFrame); |
| 1045 | // insert values |
| 1046 | sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16( |
| 1047 | ( |
| 1048 | WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) | |
| 1049 | WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN)| |
| 1050 | WLAN_SET_FC_ISWEP(0) |
| 1051 | )); |
| 1052 | memcpy( sFrame.pHdr->sA3.abyAddr1, pFrame->pHdr->sA3.abyAddr2, WLAN_ADDR_LEN); |
| 1053 | memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN); |
| 1054 | memcpy( sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); |
| 1055 | *(sFrame.pwAuthAlgorithm) = *(pFrame->pwAuthAlgorithm); |
| 1056 | *(sFrame.pwAuthSequence) = cpu_to_le16(2); |
| 1057 | |
| 1058 | if (cpu_to_le16(*(pFrame->pwAuthAlgorithm)) == WLAN_AUTH_ALG_SHAREDKEY) { |
| 1059 | if (pMgmt->bShareKeyAlgorithm) |
| 1060 | *(sFrame.pwStatus) = cpu_to_le16(WLAN_MGMT_STATUS_SUCCESS); |
| 1061 | else |
| 1062 | *(sFrame.pwStatus) = cpu_to_le16(WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG); |
| 1063 | } |
| 1064 | else { |
| 1065 | if (pMgmt->bShareKeyAlgorithm) |
| 1066 | *(sFrame.pwStatus) = cpu_to_le16(WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG); |
| 1067 | else |
| 1068 | *(sFrame.pwStatus) = cpu_to_le16(WLAN_MGMT_STATUS_SUCCESS); |
| 1069 | } |
| 1070 | |
| 1071 | if (pMgmt->bShareKeyAlgorithm && |
| 1072 | (cpu_to_le16(*(sFrame.pwStatus)) == WLAN_MGMT_STATUS_SUCCESS)) { |
| 1073 | |
| 1074 | sFrame.pChallenge = (PWLAN_IE_CHALLENGE)(sFrame.pBuf + sFrame.len); |
| 1075 | sFrame.len += WLAN_CHALLENGE_IE_LEN; |
| 1076 | sFrame.pChallenge->byElementID = WLAN_EID_CHALLENGE; |
| 1077 | sFrame.pChallenge->len = WLAN_CHALLENGE_LEN; |
| 1078 | memset(pMgmt->abyChallenge, 0, WLAN_CHALLENGE_LEN); |
| 1079 | // get group key |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1080 | if(KeybGetTransmitKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, GROUP_KEY, &pTransmitKey) == true) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1081 | rc4_init(&pDevice->SBox, pDevice->abyPRNG, pTransmitKey->uKeyLength+3); |
| 1082 | rc4_encrypt(&pDevice->SBox, pMgmt->abyChallenge, pMgmt->abyChallenge, WLAN_CHALLENGE_LEN); |
| 1083 | } |
| 1084 | memcpy(sFrame.pChallenge->abyChallenge, pMgmt->abyChallenge , WLAN_CHALLENGE_LEN); |
| 1085 | } |
| 1086 | |
| 1087 | /* Adjust the length fields */ |
| 1088 | pTxPacket->cbMPDULen = sFrame.len; |
| 1089 | pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; |
| 1090 | // send the frame |
| 1091 | if (pDevice->bEnableHostapd) { |
| 1092 | return; |
| 1093 | } |
| 1094 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Authreq_reply sequence_1 tx.. \n"); |
| 1095 | if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) { |
| 1096 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Authreq_reply sequence_1 tx failed.\n"); |
| 1097 | } |
| 1098 | return; |
| 1099 | } |
| 1100 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1101 | /*+ |
| 1102 | * |
| 1103 | * Routine Description: |
| 1104 | * Handles incoming auth frames with sequence number 2. Currently |
| 1105 | * assumes we're a station. |
| 1106 | * |
| 1107 | * |
| 1108 | * Return Value: |
| 1109 | * None. |
| 1110 | * |
| 1111 | -*/ |
| 1112 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 1113 | static void s_vMgrRxAuthenSequence_2(struct vnt_private *pDevice, |
| 1114 | struct vnt_manager *pMgmt, PWLAN_FR_AUTHEN pFrame) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1115 | { |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 1116 | WLAN_FR_AUTHEN sFrame; |
| 1117 | struct vnt_tx_mgmt *pTxPacket = NULL; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1118 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1119 | switch (cpu_to_le16((*(pFrame->pwAuthAlgorithm)))) |
| 1120 | { |
| 1121 | case WLAN_AUTH_ALG_OPENSYSTEM: |
| 1122 | if ( cpu_to_le16((*(pFrame->pwStatus))) == WLAN_MGMT_STATUS_SUCCESS ){ |
| 1123 | DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "802.11 Authen (OPEN) Successful.\n"); |
| 1124 | pMgmt->eCurrState = WMAC_STATE_AUTH; |
Malcolm Priestley | 94488a7 | 2013-09-27 16:48:14 +0100 | [diff] [blame^] | 1125 | schedule_delayed_work(&pDevice->run_command_work, 0); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1126 | } |
| 1127 | else { |
| 1128 | DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "802.11 Authen (OPEN) Failed.\n"); |
| 1129 | s_vMgrLogStatus(pMgmt, cpu_to_le16((*(pFrame->pwStatus)))); |
| 1130 | pMgmt->eCurrState = WMAC_STATE_IDLE; |
| 1131 | } |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 1132 | if (pDevice->eCommandState == WLAN_AUTHENTICATE_WAIT) { |
| 1133 | /* spin_unlock_irq(&pDevice->lock); |
| 1134 | vCommandTimerWait((void *) pDevice, 0); |
| 1135 | spin_lock_irq(&pDevice->lock); */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1136 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1137 | break; |
| 1138 | |
| 1139 | case WLAN_AUTH_ALG_SHAREDKEY: |
| 1140 | |
| 1141 | if (cpu_to_le16((*(pFrame->pwStatus))) == WLAN_MGMT_STATUS_SUCCESS) { |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 1142 | pTxPacket = (struct vnt_tx_mgmt *) |
| 1143 | pMgmt->pbyMgmtPacketPool; |
| 1144 | memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt) |
| 1145 | + WLAN_AUTHEN_FR_MAXLEN); |
| 1146 | pTxPacket->p80211Header |
| 1147 | = (PUWLAN_80211HDR)((u8 *)pTxPacket |
| 1148 | + sizeof(struct vnt_tx_mgmt)); |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 1149 | sFrame.pBuf = (u8 *)pTxPacket->p80211Header; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1150 | sFrame.len = WLAN_AUTHEN_FR_MAXLEN; |
| 1151 | // format buffer structure |
| 1152 | vMgrEncodeAuthen(&sFrame); |
| 1153 | // insert values |
| 1154 | sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16( |
| 1155 | ( |
| 1156 | WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) | |
| 1157 | WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN)| |
| 1158 | WLAN_SET_FC_ISWEP(1) |
| 1159 | )); |
| 1160 | memcpy( sFrame.pHdr->sA3.abyAddr1, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); |
| 1161 | memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN); |
| 1162 | memcpy( sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); |
| 1163 | *(sFrame.pwAuthAlgorithm) = *(pFrame->pwAuthAlgorithm); |
| 1164 | *(sFrame.pwAuthSequence) = cpu_to_le16(3); |
| 1165 | *(sFrame.pwStatus) = cpu_to_le16(WLAN_MGMT_STATUS_SUCCESS); |
| 1166 | sFrame.pChallenge = (PWLAN_IE_CHALLENGE)(sFrame.pBuf + sFrame.len); |
| 1167 | sFrame.len += WLAN_CHALLENGE_IE_LEN; |
| 1168 | sFrame.pChallenge->byElementID = WLAN_EID_CHALLENGE; |
| 1169 | sFrame.pChallenge->len = WLAN_CHALLENGE_LEN; |
| 1170 | memcpy( sFrame.pChallenge->abyChallenge, pFrame->pChallenge->abyChallenge, WLAN_CHALLENGE_LEN); |
| 1171 | // Adjust the length fields |
| 1172 | pTxPacket->cbMPDULen = sFrame.len; |
| 1173 | pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; |
| 1174 | // send the frame |
| 1175 | if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) { |
| 1176 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Auth_reply sequence_2 tx failed.\n"); |
| 1177 | } |
| 1178 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Auth_reply sequence_2 tx ...\n"); |
| 1179 | } |
| 1180 | else { |
| 1181 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:rx Auth_reply sequence_2 status error ...\n"); |
| 1182 | if ( pDevice->eCommandState == WLAN_AUTHENTICATE_WAIT ) { |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 1183 | /* spin_unlock_irq(&pDevice->lock); |
| 1184 | vCommandTimerWait((void *) pDevice, 0); |
| 1185 | spin_lock_irq(&pDevice->lock); */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1186 | } |
| 1187 | s_vMgrLogStatus(pMgmt, cpu_to_le16((*(pFrame->pwStatus)))); |
| 1188 | } |
| 1189 | break; |
| 1190 | default: |
| 1191 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt: rx auth.seq = 2 unknown AuthAlgorithm=%d\n", cpu_to_le16((*(pFrame->pwAuthAlgorithm)))); |
| 1192 | break; |
| 1193 | } |
| 1194 | return; |
| 1195 | } |
| 1196 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1197 | /*+ |
| 1198 | * |
| 1199 | * Routine Description: |
| 1200 | * Handles incoming authen frames with sequence 3. Currently |
| 1201 | * assumes we're an AP. This function assumes the frame has |
| 1202 | * already been successfully decrypted. |
| 1203 | * |
| 1204 | * |
| 1205 | * Return Value: |
| 1206 | * None. |
| 1207 | * |
| 1208 | -*/ |
| 1209 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 1210 | static void s_vMgrRxAuthenSequence_3(struct vnt_private *pDevice, |
| 1211 | struct vnt_manager *pMgmt, PWLAN_FR_AUTHEN pFrame) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1212 | { |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 1213 | struct vnt_tx_mgmt *pTxPacket = NULL; |
| 1214 | u32 uStatusCode = 0 ; |
| 1215 | u32 uNodeIndex = 0; |
| 1216 | WLAN_FR_AUTHEN sFrame; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1217 | |
| 1218 | if (!WLAN_GET_FC_ISWEP(pFrame->pHdr->sA3.wFrameCtl)) { |
| 1219 | uStatusCode = WLAN_MGMT_STATUS_CHALLENGE_FAIL; |
| 1220 | goto reply; |
| 1221 | } |
| 1222 | if (BSSbIsSTAInNodeDB(pDevice, pFrame->pHdr->sA3.abyAddr2, &uNodeIndex)) { |
| 1223 | if (pMgmt->sNodeDBTable[uNodeIndex].byAuthSequence != 1) { |
| 1224 | uStatusCode = WLAN_MGMT_STATUS_RX_AUTH_NOSEQ; |
| 1225 | goto reply; |
| 1226 | } |
| 1227 | if (memcmp(pMgmt->abyChallenge, pFrame->pChallenge->abyChallenge, WLAN_CHALLENGE_LEN) != 0) { |
| 1228 | uStatusCode = WLAN_MGMT_STATUS_CHALLENGE_FAIL; |
| 1229 | goto reply; |
| 1230 | } |
| 1231 | } |
| 1232 | else { |
| 1233 | uStatusCode = WLAN_MGMT_STATUS_UNSPEC_FAILURE; |
| 1234 | goto reply; |
| 1235 | } |
| 1236 | |
| 1237 | if (uNodeIndex) { |
| 1238 | pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_AUTH; |
| 1239 | pMgmt->sNodeDBTable[uNodeIndex].byAuthSequence = 0; |
| 1240 | } |
| 1241 | uStatusCode = WLAN_MGMT_STATUS_SUCCESS; |
| 1242 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Challenge text check ok..\n"); |
| 1243 | |
| 1244 | reply: |
| 1245 | // send auth reply |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 1246 | pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool; |
| 1247 | memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt) |
| 1248 | + WLAN_AUTHEN_FR_MAXLEN); |
| 1249 | pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket |
| 1250 | + sizeof(struct vnt_tx_mgmt)); |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 1251 | sFrame.pBuf = (u8 *)pTxPacket->p80211Header; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1252 | sFrame.len = WLAN_AUTHEN_FR_MAXLEN; |
| 1253 | // format buffer structure |
| 1254 | vMgrEncodeAuthen(&sFrame); |
| 1255 | /* insert values */ |
| 1256 | sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16( |
| 1257 | ( |
| 1258 | WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) | |
| 1259 | WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN)| |
| 1260 | WLAN_SET_FC_ISWEP(0) |
| 1261 | )); |
| 1262 | memcpy( sFrame.pHdr->sA3.abyAddr1, pFrame->pHdr->sA3.abyAddr2, WLAN_ADDR_LEN); |
| 1263 | memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN); |
| 1264 | memcpy( sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); |
| 1265 | *(sFrame.pwAuthAlgorithm) = *(pFrame->pwAuthAlgorithm); |
| 1266 | *(sFrame.pwAuthSequence) = cpu_to_le16(4); |
| 1267 | *(sFrame.pwStatus) = cpu_to_le16(uStatusCode); |
| 1268 | |
| 1269 | /* Adjust the length fields */ |
| 1270 | pTxPacket->cbMPDULen = sFrame.len; |
| 1271 | pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; |
| 1272 | // send the frame |
| 1273 | if (pDevice->bEnableHostapd) { |
| 1274 | return; |
| 1275 | } |
| 1276 | if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) { |
| 1277 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Authreq_reply sequence_4 tx failed.\n"); |
| 1278 | } |
| 1279 | return; |
| 1280 | |
| 1281 | } |
| 1282 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1283 | /*+ |
| 1284 | * |
| 1285 | * Routine Description: |
| 1286 | * Handles incoming authen frames with sequence 4 |
| 1287 | * |
| 1288 | * |
| 1289 | * Return Value: |
| 1290 | * None. |
| 1291 | * |
| 1292 | -*/ |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 1293 | static void s_vMgrRxAuthenSequence_4(struct vnt_private *pDevice, |
| 1294 | struct vnt_manager *pMgmt, PWLAN_FR_AUTHEN pFrame) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1295 | { |
| 1296 | |
| 1297 | if ( cpu_to_le16((*(pFrame->pwStatus))) == WLAN_MGMT_STATUS_SUCCESS ){ |
| 1298 | DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "802.11 Authen (SHAREDKEY) Successful.\n"); |
| 1299 | pMgmt->eCurrState = WMAC_STATE_AUTH; |
Malcolm Priestley | 94488a7 | 2013-09-27 16:48:14 +0100 | [diff] [blame^] | 1300 | schedule_delayed_work(&pDevice->run_command_work, 0); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1301 | } |
| 1302 | else{ |
| 1303 | DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "802.11 Authen (SHAREDKEY) Failed.\n"); |
| 1304 | s_vMgrLogStatus(pMgmt, cpu_to_le16((*(pFrame->pwStatus))) ); |
| 1305 | pMgmt->eCurrState = WMAC_STATE_IDLE; |
| 1306 | } |
| 1307 | |
| 1308 | if ( pDevice->eCommandState == WLAN_AUTHENTICATE_WAIT ) { |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 1309 | /* spin_unlock_irq(&pDevice->lock); |
| 1310 | vCommandTimerWait((void *) pDevice, 0); |
| 1311 | spin_lock_irq(&pDevice->lock); */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1312 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1313 | } |
| 1314 | |
| 1315 | /*+ |
| 1316 | * |
| 1317 | * Routine Description: |
| 1318 | * Handles incoming disassociation frames |
| 1319 | * |
| 1320 | * |
| 1321 | * Return Value: |
| 1322 | * None. |
| 1323 | * |
| 1324 | -*/ |
| 1325 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 1326 | static void s_vMgrRxDisassociation(struct vnt_private *pDevice, |
| 1327 | struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1328 | { |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 1329 | WLAN_FR_DISASSOC sFrame; |
| 1330 | u32 uNodeIndex = 0; |
| 1331 | CMD_STATUS CmdStatus; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1332 | |
| 1333 | if ( pMgmt->eCurrMode == WMAC_MODE_ESS_AP ){ |
| 1334 | // if is acting an AP.. |
| 1335 | // a STA is leaving this BSS.. |
| 1336 | sFrame.len = pRxPacket->cbMPDULen; |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 1337 | sFrame.pBuf = (u8 *)pRxPacket->p80211Header; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1338 | if (BSSbIsSTAInNodeDB(pDevice, pRxPacket->p80211Header->sA3.abyAddr2, &uNodeIndex)) { |
| 1339 | BSSvRemoveOneNode(pDevice, uNodeIndex); |
| 1340 | } |
| 1341 | else { |
| 1342 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Rx disassoc, sta not found\n"); |
| 1343 | } |
| 1344 | } |
| 1345 | else if (pMgmt->eCurrMode == WMAC_MODE_ESS_STA ){ |
| 1346 | sFrame.len = pRxPacket->cbMPDULen; |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 1347 | sFrame.pBuf = (u8 *)pRxPacket->p80211Header; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1348 | vMgrDecodeDisassociation(&sFrame); |
| 1349 | DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "AP disassociated me, reason=%d.\n", cpu_to_le16(*(sFrame.pwReason))); |
| 1350 | |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1351 | pDevice->fWPA_Authened = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1352 | |
| 1353 | //TODO: do something let upper layer know or |
| 1354 | //try to send associate packet again because of inactivity timeout |
| 1355 | if (pMgmt->eCurrState == WMAC_STATE_ASSOC) { |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1356 | pDevice->bLinkPass = false; |
| 1357 | pMgmt->sNodeDBTable[0].bActive = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1358 | pDevice->byReAssocCount = 0; |
| 1359 | pMgmt->eCurrState = WMAC_STATE_AUTH; // jump back to the auth state! |
| 1360 | pDevice->eCommandState = WLAN_ASSOCIATE_WAIT; |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 1361 | vMgrReAssocBeginSta(pDevice, pMgmt, &CmdStatus); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1362 | if(CmdStatus == CMD_STATUS_PENDING) { |
| 1363 | pDevice->byReAssocCount ++; |
| 1364 | return; //mike add: you'll retry for many times, so it cann't be regarded as disconnected! |
| 1365 | } |
Joe Perches | 9fc8602 | 2011-04-10 14:31:32 -0700 | [diff] [blame] | 1366 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1367 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1368 | // if(pDevice->bWPASuppWextEnabled == true) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1369 | { |
| 1370 | union iwreq_data wrqu; |
| 1371 | memset(&wrqu, 0, sizeof (wrqu)); |
| 1372 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 1373 | PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated)\n"); |
| 1374 | wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL); |
| 1375 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1376 | } |
| 1377 | /* else, ignore it */ |
| 1378 | |
| 1379 | return; |
| 1380 | } |
| 1381 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1382 | /*+ |
| 1383 | * |
| 1384 | * Routine Description: |
| 1385 | * Handles incoming deauthentication frames |
| 1386 | * |
| 1387 | * |
| 1388 | * Return Value: |
| 1389 | * None. |
| 1390 | * |
| 1391 | -*/ |
| 1392 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 1393 | static void s_vMgrRxDeauthentication(struct vnt_private *pDevice, |
| 1394 | struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1395 | { |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 1396 | WLAN_FR_DEAUTHEN sFrame; |
| 1397 | u32 uNodeIndex = 0; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1398 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1399 | if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP ){ |
| 1400 | //Todo: |
| 1401 | // if is acting an AP.. |
| 1402 | // a STA is leaving this BSS.. |
| 1403 | sFrame.len = pRxPacket->cbMPDULen; |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 1404 | sFrame.pBuf = (u8 *)pRxPacket->p80211Header; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1405 | if (BSSbIsSTAInNodeDB(pDevice, pRxPacket->p80211Header->sA3.abyAddr2, &uNodeIndex)) { |
| 1406 | BSSvRemoveOneNode(pDevice, uNodeIndex); |
| 1407 | } |
| 1408 | else { |
| 1409 | DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Rx deauth, sta not found\n"); |
| 1410 | } |
| 1411 | } |
| 1412 | else { |
| 1413 | if (pMgmt->eCurrMode == WMAC_MODE_ESS_STA ) { |
| 1414 | sFrame.len = pRxPacket->cbMPDULen; |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 1415 | sFrame.pBuf = (u8 *)pRxPacket->p80211Header; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1416 | vMgrDecodeDeauthen(&sFrame); |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1417 | pDevice->fWPA_Authened = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1418 | DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "AP deauthed me, reason=%d.\n", cpu_to_le16((*(sFrame.pwReason)))); |
| 1419 | // TODO: update BSS list for specific BSSID if pre-authentication case |
Joe Perches | 8329419 | 2013-09-01 12:15:47 -0700 | [diff] [blame] | 1420 | if (ether_addr_equal(sFrame.pHdr->sA3.abyAddr3, |
| 1421 | pMgmt->abyCurrBSSID)) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1422 | if (pMgmt->eCurrState >= WMAC_STATE_AUTHPENDING) { |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1423 | pMgmt->sNodeDBTable[0].bActive = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1424 | pMgmt->eCurrMode = WMAC_MODE_STANDBY; |
| 1425 | pMgmt->eCurrState = WMAC_STATE_IDLE; |
| 1426 | netif_stop_queue(pDevice->dev); |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1427 | pDevice->bLinkPass = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1428 | ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW); |
| 1429 | } |
Joe Perches | 9fc8602 | 2011-04-10 14:31:32 -0700 | [diff] [blame] | 1430 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1431 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1432 | // if(pDevice->bWPASuppWextEnabled == true) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1433 | { |
| 1434 | union iwreq_data wrqu; |
| 1435 | memset(&wrqu, 0, sizeof (wrqu)); |
| 1436 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 1437 | PRINT_K("wireless_send_event--->SIOCGIWAP(disauthen)\n"); |
| 1438 | wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL); |
| 1439 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1440 | |
| 1441 | } |
| 1442 | /* else, ignore it. TODO: IBSS authentication service |
| 1443 | would be implemented here */ |
| 1444 | }; |
| 1445 | return; |
| 1446 | } |
| 1447 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1448 | /*+ |
| 1449 | * |
| 1450 | * Routine Description: |
| 1451 | * check if current channel is match ZoneType. |
| 1452 | *for USA:1~11; |
| 1453 | * Japan:1~13; |
| 1454 | * Europe:1~13 |
| 1455 | * Return Value: |
| 1456 | * True:exceed; |
| 1457 | * False:normal case |
| 1458 | -*/ |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 1459 | static int ChannelExceedZoneType(struct vnt_private *pDevice, u8 byCurrChannel) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1460 | { |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1461 | int exceed = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1462 | |
| 1463 | switch(pDevice->byZoneType) { |
| 1464 | case 0x00: //USA:1~11 |
| 1465 | if((byCurrChannel<1) ||(byCurrChannel>11)) |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1466 | exceed = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1467 | break; |
| 1468 | case 0x01: //Japan:1~13 |
| 1469 | case 0x02: //Europe:1~13 |
| 1470 | if((byCurrChannel<1) ||(byCurrChannel>13)) |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1471 | exceed = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1472 | break; |
| 1473 | default: //reserve for other zonetype |
| 1474 | break; |
| 1475 | } |
| 1476 | |
| 1477 | return exceed; |
| 1478 | } |
| 1479 | |
| 1480 | /*+ |
| 1481 | * |
| 1482 | * Routine Description: |
| 1483 | * Handles and analysis incoming beacon frames. |
| 1484 | * |
| 1485 | * |
| 1486 | * Return Value: |
| 1487 | * None. |
| 1488 | * |
| 1489 | -*/ |
| 1490 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 1491 | static void s_vMgrRxBeacon(struct vnt_private *pDevice, |
| 1492 | struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket, |
| 1493 | int bInScan) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1494 | { |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 1495 | PKnownBSS pBSSList; |
| 1496 | WLAN_FR_BEACON sFrame; |
Malcolm Priestley | 7c65fa2 | 2012-11-28 21:11:02 +0000 | [diff] [blame] | 1497 | u64 qwTSFOffset; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1498 | int bIsBSSIDEqual = false; |
| 1499 | int bIsSSIDEqual = false; |
| 1500 | int bTSFLargeDiff = false; |
| 1501 | int bTSFOffsetPostive = false; |
| 1502 | int bUpdateTSF = false; |
| 1503 | int bIsAPBeacon = false; |
| 1504 | int bIsChannelEqual = false; |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 1505 | u32 uLocateByteIndex; |
| 1506 | u8 byTIMBitOn = 0; |
| 1507 | u16 wAIDNumber = 0; |
| 1508 | u32 uNodeIndex; |
Malcolm Priestley | 7c65fa2 | 2012-11-28 21:11:02 +0000 | [diff] [blame] | 1509 | u64 qwTimestamp, qwLocalTSF; |
| 1510 | u64 qwCurrTSF; |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 1511 | u16 wStartIndex = 0; |
| 1512 | u16 wAIDIndex = 0; |
| 1513 | u8 byCurrChannel = pRxPacket->byRxChannel; |
| 1514 | ERPObject sERP; |
| 1515 | u32 uRateLen = WLAN_RATES_MAXLEN; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1516 | int bChannelHit = false; |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 1517 | u8 byOldPreambleType; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1518 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1519 | if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) |
| 1520 | return; |
| 1521 | |
| 1522 | memset(&sFrame, 0, sizeof(WLAN_FR_BEACON)); |
| 1523 | sFrame.len = pRxPacket->cbMPDULen; |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 1524 | sFrame.pBuf = (u8 *)pRxPacket->p80211Header; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1525 | |
| 1526 | // decode the beacon frame |
| 1527 | vMgrDecodeBeacon(&sFrame); |
| 1528 | |
Andres More | 6e1b4e2 | 2010-05-04 20:40:11 -0300 | [diff] [blame] | 1529 | if ((sFrame.pwBeaconInterval == NULL) |
| 1530 | || (sFrame.pwCapInfo == NULL) |
| 1531 | || (sFrame.pSSID == NULL) |
| 1532 | || (sFrame.pSuppRates == NULL)) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1533 | |
Andres More | 6e1b4e2 | 2010-05-04 20:40:11 -0300 | [diff] [blame] | 1534 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Rx beacon frame error\n"); |
| 1535 | return; |
Joe Perches | 9fc8602 | 2011-04-10 14:31:32 -0700 | [diff] [blame] | 1536 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1537 | |
| 1538 | if( byCurrChannel > CB_MAX_CHANNEL_24G ) |
| 1539 | { |
| 1540 | if (sFrame.pDSParms != NULL) { |
| 1541 | if (byCurrChannel == RFaby11aChannelIndex[sFrame.pDSParms->byCurrChannel-1]) |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1542 | bChannelHit = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1543 | byCurrChannel = RFaby11aChannelIndex[sFrame.pDSParms->byCurrChannel-1]; |
| 1544 | } else { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1545 | bChannelHit = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1546 | } |
| 1547 | |
| 1548 | } else { |
| 1549 | if (sFrame.pDSParms != NULL) { |
| 1550 | if (byCurrChannel == sFrame.pDSParms->byCurrChannel) |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1551 | bChannelHit = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1552 | byCurrChannel = sFrame.pDSParms->byCurrChannel; |
| 1553 | } else { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1554 | bChannelHit = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1555 | } |
| 1556 | } |
| 1557 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1558 | if(ChannelExceedZoneType(pDevice,byCurrChannel)==true) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1559 | return; |
| 1560 | |
| 1561 | if (sFrame.pERP != NULL) { |
| 1562 | sERP.byERP = sFrame.pERP->byContext; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1563 | sERP.bERPExist = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1564 | |
| 1565 | } else { |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1566 | sERP.bERPExist = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1567 | sERP.byERP = 0; |
| 1568 | } |
| 1569 | |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 1570 | pBSSList = BSSpAddrIsInBSSList((void *) pDevice, |
| 1571 | sFrame.pHdr->sA3.abyAddr3, |
| 1572 | sFrame.pSSID); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1573 | if (pBSSList == NULL) { |
| 1574 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Beacon/insert: RxChannel = : %d\n", byCurrChannel); |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 1575 | BSSbInsertToBSSList((void *) pDevice, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1576 | sFrame.pHdr->sA3.abyAddr3, |
| 1577 | *sFrame.pqwTimestamp, |
| 1578 | *sFrame.pwBeaconInterval, |
| 1579 | *sFrame.pwCapInfo, |
| 1580 | byCurrChannel, |
| 1581 | sFrame.pSSID, |
| 1582 | sFrame.pSuppRates, |
| 1583 | sFrame.pExtSuppRates, |
| 1584 | &sERP, |
| 1585 | sFrame.pRSN, |
| 1586 | sFrame.pRSNWPA, |
| 1587 | sFrame.pIE_Country, |
| 1588 | sFrame.pIE_Quiet, |
| 1589 | sFrame.len - WLAN_HDR_ADDR3_LEN, |
| 1590 | sFrame.pHdr->sA4.abyAddr4, // payload of beacon |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 1591 | (void *) pRxPacket); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1592 | } |
| 1593 | else { |
| 1594 | // DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"update bcn: RxChannel = : %d\n", byCurrChannel); |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 1595 | BSSbUpdateToBSSList((void *) pDevice, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1596 | *sFrame.pqwTimestamp, |
| 1597 | *sFrame.pwBeaconInterval, |
| 1598 | *sFrame.pwCapInfo, |
| 1599 | byCurrChannel, |
| 1600 | bChannelHit, |
| 1601 | sFrame.pSSID, |
| 1602 | sFrame.pSuppRates, |
| 1603 | sFrame.pExtSuppRates, |
| 1604 | &sERP, |
| 1605 | sFrame.pRSN, |
| 1606 | sFrame.pRSNWPA, |
| 1607 | sFrame.pIE_Country, |
| 1608 | sFrame.pIE_Quiet, |
| 1609 | pBSSList, |
| 1610 | sFrame.len - WLAN_HDR_ADDR3_LEN, |
| 1611 | sFrame.pHdr->sA4.abyAddr4, // payload of probresponse |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 1612 | (void *) pRxPacket); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1613 | |
| 1614 | } |
| 1615 | |
| 1616 | if (bInScan) { |
| 1617 | return; |
| 1618 | } |
| 1619 | |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 1620 | if(byCurrChannel == (u8)pMgmt->uCurrChannel) |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1621 | bIsChannelEqual = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1622 | |
| 1623 | if (bIsChannelEqual && (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) { |
| 1624 | |
| 1625 | // if rx beacon without ERP field |
| 1626 | if (sERP.bERPExist) { |
| 1627 | if (WLAN_GET_ERP_USE_PROTECTION(sERP.byERP)){ |
| 1628 | pDevice->byERPFlag |= WLAN_SET_ERP_USE_PROTECTION(1); |
| 1629 | pDevice->wUseProtectCntDown = USE_PROTECT_PERIOD; |
| 1630 | } |
| 1631 | } |
| 1632 | else { |
| 1633 | pDevice->byERPFlag |= WLAN_SET_ERP_USE_PROTECTION(1); |
| 1634 | pDevice->wUseProtectCntDown = USE_PROTECT_PERIOD; |
| 1635 | } |
| 1636 | |
| 1637 | if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) { |
| 1638 | if(!WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame.pwCapInfo)) |
| 1639 | pDevice->byERPFlag |= WLAN_SET_ERP_BARKER_MODE(1); |
| 1640 | if(!sERP.bERPExist) |
| 1641 | pDevice->byERPFlag |= WLAN_SET_ERP_NONERP_PRESENT(1); |
| 1642 | } |
| 1643 | } |
| 1644 | |
| 1645 | // check if BSSID the same |
| 1646 | if (memcmp(sFrame.pHdr->sA3.abyAddr3, |
| 1647 | pMgmt->abyCurrBSSID, |
| 1648 | WLAN_BSSID_LEN) == 0) { |
| 1649 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1650 | bIsBSSIDEqual = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1651 | pDevice->uCurrRSSI = pRxPacket->uRSSI; |
| 1652 | pDevice->byCurrSQ = pRxPacket->bySQ; |
| 1653 | if (pMgmt->sNodeDBTable[0].uInActiveCount != 0) { |
| 1654 | pMgmt->sNodeDBTable[0].uInActiveCount = 0; |
| 1655 | //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BCN:Wake Count= [%d]\n", pMgmt->wCountToWakeUp); |
| 1656 | } |
| 1657 | } |
| 1658 | // check if SSID the same |
| 1659 | if (sFrame.pSSID->len == ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len) { |
| 1660 | if (memcmp(sFrame.pSSID->abySSID, |
| 1661 | ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->abySSID, |
| 1662 | sFrame.pSSID->len |
| 1663 | ) == 0) { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1664 | bIsSSIDEqual = true; |
Joe Perches | 9fc8602 | 2011-04-10 14:31:32 -0700 | [diff] [blame] | 1665 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1666 | } |
| 1667 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1668 | if ((WLAN_GET_CAP_INFO_ESS(*sFrame.pwCapInfo)== true) && |
| 1669 | (bIsBSSIDEqual == true) && |
| 1670 | (bIsSSIDEqual == true) && |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1671 | (pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && |
| 1672 | (pMgmt->eCurrState == WMAC_STATE_ASSOC)) { |
| 1673 | // add state check to prevent reconnect fail since we'll receive Beacon |
| 1674 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1675 | bIsAPBeacon = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1676 | if (pBSSList != NULL) { |
| 1677 | |
| 1678 | // Sync ERP field |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1679 | if ((pBSSList->sERP.bERPExist == true) && (pDevice->byBBType == BB_TYPE_11G)) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1680 | if ((pBSSList->sERP.byERP & WLAN_EID_ERP_USE_PROTECTION) != pDevice->bProtectMode) {//0000 0010 |
| 1681 | pDevice->bProtectMode = (pBSSList->sERP.byERP & WLAN_EID_ERP_USE_PROTECTION); |
| 1682 | if (pDevice->bProtectMode) { |
| 1683 | MACvEnableProtectMD(pDevice); |
| 1684 | } else { |
| 1685 | MACvDisableProtectMD(pDevice); |
| 1686 | } |
| 1687 | vUpdateIFS(pDevice); |
| 1688 | } |
| 1689 | if ((pBSSList->sERP.byERP & WLAN_EID_ERP_NONERP_PRESENT) != pDevice->bNonERPPresent) {//0000 0001 |
| 1690 | pDevice->bNonERPPresent = (pBSSList->sERP.byERP & WLAN_EID_ERP_USE_PROTECTION); |
| 1691 | } |
| 1692 | if ((pBSSList->sERP.byERP & WLAN_EID_ERP_BARKER_MODE) != pDevice->bBarkerPreambleMd) {//0000 0100 |
| 1693 | pDevice->bBarkerPreambleMd = (pBSSList->sERP.byERP & WLAN_EID_ERP_BARKER_MODE); |
| 1694 | //BarkerPreambleMd has higher priority than shortPreamble bit in Cap |
| 1695 | if (pDevice->bBarkerPreambleMd) { |
| 1696 | MACvEnableBarkerPreambleMd(pDevice); |
| 1697 | } else { |
| 1698 | MACvDisableBarkerPreambleMd(pDevice); |
| 1699 | } |
| 1700 | } |
| 1701 | } |
| 1702 | // Sync Short Slot Time |
| 1703 | if (WLAN_GET_CAP_INFO_SHORTSLOTTIME(pBSSList->wCapInfo) != pDevice->bShortSlotTime) { |
Andres More | dfdcc42 | 2013-02-12 20:36:28 -0500 | [diff] [blame] | 1704 | bool bShortSlotTime; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1705 | |
| 1706 | bShortSlotTime = WLAN_GET_CAP_INFO_SHORTSLOTTIME(pBSSList->wCapInfo); |
| 1707 | //DBG_PRN_WLAN05(("Set Short Slot Time: %d\n", pDevice->bShortSlotTime)); |
| 1708 | //Kyle check if it is OK to set G. |
| 1709 | if (pDevice->byBBType == BB_TYPE_11A) { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1710 | bShortSlotTime = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1711 | } |
| 1712 | else if (pDevice->byBBType == BB_TYPE_11B) { |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1713 | bShortSlotTime = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1714 | } |
| 1715 | if (bShortSlotTime != pDevice->bShortSlotTime) { |
| 1716 | pDevice->bShortSlotTime = bShortSlotTime; |
| 1717 | BBvSetShortSlotTime(pDevice); |
| 1718 | vUpdateIFS(pDevice); |
| 1719 | } |
| 1720 | } |
| 1721 | |
| 1722 | // |
Masanari Iida | 9318469 | 2012-08-13 21:21:50 +0900 | [diff] [blame] | 1723 | // Preamble may change dynamically |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1724 | // |
| 1725 | byOldPreambleType = pDevice->byPreambleType; |
| 1726 | if (WLAN_GET_CAP_INFO_SHORTPREAMBLE(pBSSList->wCapInfo)) { |
| 1727 | pDevice->byPreambleType = pDevice->byShortPreamble; |
| 1728 | } |
| 1729 | else { |
| 1730 | pDevice->byPreambleType = 0; |
| 1731 | } |
| 1732 | if (pDevice->byPreambleType != byOldPreambleType) |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 1733 | CARDvSetRSPINF(pDevice, (u8)pDevice->byBBType); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1734 | // |
Masanari Iida | 9318469 | 2012-08-13 21:21:50 +0900 | [diff] [blame] | 1735 | // Basic Rate Set may change dynamically |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1736 | // |
| 1737 | if (pBSSList->eNetworkTypeInUse == PHY_TYPE_11B) { |
| 1738 | uRateLen = WLAN_RATES_MAXLEN_11B; |
| 1739 | } |
| 1740 | pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)pBSSList->abySuppRates, |
| 1741 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, |
| 1742 | uRateLen); |
| 1743 | pMgmt->abyCurrExtSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)pBSSList->abyExtSuppRates, |
| 1744 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates, |
| 1745 | uRateLen); |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 1746 | RATEvParseMaxRate((void *)pDevice, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1747 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, |
| 1748 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates, |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1749 | true, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1750 | &(pMgmt->sNodeDBTable[0].wMaxBasicRate), |
| 1751 | &(pMgmt->sNodeDBTable[0].wMaxSuppRate), |
| 1752 | &(pMgmt->sNodeDBTable[0].wSuppRate), |
| 1753 | &(pMgmt->sNodeDBTable[0].byTopCCKBasicRate), |
| 1754 | &(pMgmt->sNodeDBTable[0].byTopOFDMBasicRate) |
| 1755 | ); |
| 1756 | |
| 1757 | } |
| 1758 | } |
| 1759 | |
| 1760 | // DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Beacon 2 \n"); |
| 1761 | // check if CF field exisit |
| 1762 | if (WLAN_GET_CAP_INFO_ESS(*sFrame.pwCapInfo)) { |
| 1763 | if (sFrame.pCFParms->wCFPDurRemaining > 0) { |
| 1764 | // TODO: deal with CFP period to set NAV |
Joe Perches | 9fc8602 | 2011-04-10 14:31:32 -0700 | [diff] [blame] | 1765 | } |
| 1766 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1767 | |
Malcolm Priestley | 7c65fa2 | 2012-11-28 21:11:02 +0000 | [diff] [blame] | 1768 | qwTimestamp = cpu_to_le64(*sFrame.pqwTimestamp); |
| 1769 | qwLocalTSF = pRxPacket->qwLocalTSF; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1770 | |
| 1771 | // check if beacon TSF larger or small than our local TSF |
Malcolm Priestley | 7c65fa2 | 2012-11-28 21:11:02 +0000 | [diff] [blame] | 1772 | if (qwTimestamp >= qwLocalTSF) |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1773 | bTSFOffsetPostive = true; |
Malcolm Priestley | 7c65fa2 | 2012-11-28 21:11:02 +0000 | [diff] [blame] | 1774 | else |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1775 | bTSFOffsetPostive = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1776 | |
| 1777 | if (bTSFOffsetPostive) { |
| 1778 | qwTSFOffset = CARDqGetTSFOffset(pRxPacket->byRxRate, (qwTimestamp), (qwLocalTSF)); |
| 1779 | } |
| 1780 | else { |
| 1781 | qwTSFOffset = CARDqGetTSFOffset(pRxPacket->byRxRate, (qwLocalTSF), (qwTimestamp)); |
| 1782 | } |
| 1783 | |
Malcolm Priestley | 7c65fa2 | 2012-11-28 21:11:02 +0000 | [diff] [blame] | 1784 | if (qwTSFOffset > TRIVIAL_SYNC_DIFFERENCE) |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1785 | bTSFLargeDiff = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1786 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1787 | // if infra mode |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1788 | if (bIsAPBeacon == true) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1789 | |
| 1790 | // Infra mode: Local TSF always follow AP's TSF if Difference huge. |
| 1791 | if (bTSFLargeDiff) |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1792 | bUpdateTSF = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1793 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1794 | if ((pDevice->bEnablePSMode == true) && (sFrame.pTIM)) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1795 | |
Andres More | 6e1b4e2 | 2010-05-04 20:40:11 -0300 | [diff] [blame] | 1796 | /* deal with DTIM, analysis TIM */ |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1797 | pMgmt->bMulticastTIM = WLAN_MGMT_IS_MULTICAST_TIM(sFrame.pTIM->byBitMapCtl) ? true : false ; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1798 | pMgmt->byDTIMCount = sFrame.pTIM->byDTIMCount; |
| 1799 | pMgmt->byDTIMPeriod = sFrame.pTIM->byDTIMPeriod; |
| 1800 | wAIDNumber = pMgmt->wCurrAID & ~(BIT14|BIT15); |
| 1801 | |
| 1802 | // check if AID in TIM field bit on |
| 1803 | // wStartIndex = N1 |
| 1804 | wStartIndex = WLAN_MGMT_GET_TIM_OFFSET(sFrame.pTIM->byBitMapCtl) << 1; |
| 1805 | // AIDIndex = N2 |
| 1806 | wAIDIndex = (wAIDNumber >> 3); |
| 1807 | if ((wAIDNumber > 0) && (wAIDIndex >= wStartIndex)) { |
| 1808 | uLocateByteIndex = wAIDIndex - wStartIndex; |
| 1809 | // len = byDTIMCount + byDTIMPeriod + byDTIMPeriod + byVirtBitMap[0~250] |
| 1810 | if (sFrame.pTIM->len >= (uLocateByteIndex + 4)) { |
| 1811 | byTIMBitOn = (0x01) << ((wAIDNumber) % 8); |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1812 | pMgmt->bInTIM = sFrame.pTIM->byVirtBitMap[uLocateByteIndex] & byTIMBitOn ? true : false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1813 | } |
| 1814 | else { |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1815 | pMgmt->bInTIM = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1816 | }; |
| 1817 | } |
| 1818 | else { |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1819 | pMgmt->bInTIM = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1820 | }; |
| 1821 | |
| 1822 | if (pMgmt->bInTIM || |
| 1823 | (pMgmt->bMulticastTIM && (pMgmt->byDTIMCount == 0))) { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1824 | pMgmt->bInTIMWake = true; |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 1825 | /* send out ps-poll packet */ |
| 1826 | if (pMgmt->bInTIM) |
| 1827 | PSvSendPSPOLL(pDevice); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1828 | |
| 1829 | } |
| 1830 | else { |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1831 | pMgmt->bInTIMWake = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1832 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BCN: Not In TIM..\n"); |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1833 | if (pDevice->bPWBitOn == false) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1834 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BCN: Send Null Packet\n"); |
| 1835 | if (PSbSendNullPacket(pDevice)) |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1836 | pDevice->bPWBitOn = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1837 | } |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1838 | if(PSbConsiderPowerDown(pDevice, false, false)) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1839 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BCN: Power down now...\n"); |
Joe Perches | 9fc8602 | 2011-04-10 14:31:32 -0700 | [diff] [blame] | 1840 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1841 | } |
| 1842 | |
| 1843 | } |
| 1844 | |
| 1845 | } |
| 1846 | // if adhoc mode |
| 1847 | if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && !bIsAPBeacon && bIsChannelEqual) { |
| 1848 | if (bIsBSSIDEqual) { |
| 1849 | // Use sNodeDBTable[0].uInActiveCount as IBSS beacons received count. |
| 1850 | if (pMgmt->sNodeDBTable[0].uInActiveCount != 0) |
| 1851 | pMgmt->sNodeDBTable[0].uInActiveCount = 0; |
| 1852 | |
| 1853 | // adhoc mode:TSF updated only when beacon larger then local TSF |
| 1854 | if (bTSFLargeDiff && bTSFOffsetPostive && |
| 1855 | (pMgmt->eCurrState == WMAC_STATE_JOINTED)) |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1856 | bUpdateTSF = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1857 | |
| 1858 | // During dpc, already in spinlocked. |
| 1859 | if (BSSbIsSTAInNodeDB(pDevice, sFrame.pHdr->sA3.abyAddr2, &uNodeIndex)) { |
| 1860 | |
Justin P. Mattock | a0a1f61 | 2012-08-26 08:16:43 -0700 | [diff] [blame] | 1861 | // Update the STA, (Technically the Beacons of all the IBSS nodes |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1862 | // should be identical, but that's not happening in practice. |
| 1863 | pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pSuppRates, |
| 1864 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, |
| 1865 | WLAN_RATES_MAXLEN_11B); |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 1866 | RATEvParseMaxRate((void *)pDevice, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1867 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, |
| 1868 | NULL, |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1869 | true, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1870 | &(pMgmt->sNodeDBTable[uNodeIndex].wMaxBasicRate), |
| 1871 | &(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate), |
| 1872 | &(pMgmt->sNodeDBTable[uNodeIndex].wSuppRate), |
| 1873 | &(pMgmt->sNodeDBTable[uNodeIndex].byTopCCKBasicRate), |
| 1874 | &(pMgmt->sNodeDBTable[uNodeIndex].byTopOFDMBasicRate) |
| 1875 | ); |
| 1876 | pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble = WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame.pwCapInfo); |
| 1877 | pMgmt->sNodeDBTable[uNodeIndex].bShortSlotTime = WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame.pwCapInfo); |
| 1878 | pMgmt->sNodeDBTable[uNodeIndex].uInActiveCount = 0; |
| 1879 | } |
| 1880 | else { |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 1881 | /* Todo, initial Node content */ |
| 1882 | BSSvCreateOneNode(pDevice, &uNodeIndex); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1883 | |
| 1884 | pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pSuppRates, |
| 1885 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, |
| 1886 | WLAN_RATES_MAXLEN_11B); |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 1887 | RATEvParseMaxRate((void *)pDevice, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1888 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, |
| 1889 | NULL, |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1890 | true, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1891 | &(pMgmt->sNodeDBTable[uNodeIndex].wMaxBasicRate), |
| 1892 | &(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate), |
| 1893 | &(pMgmt->sNodeDBTable[uNodeIndex].wSuppRate), |
| 1894 | &(pMgmt->sNodeDBTable[uNodeIndex].byTopCCKBasicRate), |
| 1895 | &(pMgmt->sNodeDBTable[uNodeIndex].byTopOFDMBasicRate) |
| 1896 | ); |
| 1897 | |
| 1898 | memcpy(pMgmt->sNodeDBTable[uNodeIndex].abyMACAddr, sFrame.pHdr->sA3.abyAddr2, WLAN_ADDR_LEN); |
| 1899 | pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble = WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame.pwCapInfo); |
| 1900 | pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate = pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate; |
| 1901 | /* |
| 1902 | pMgmt->sNodeDBTable[uNodeIndex].bShortSlotTime = WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame.pwCapInfo); |
| 1903 | if(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate > RATE_11M) |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1904 | pMgmt->sNodeDBTable[uNodeIndex].bERPExist = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1905 | */ |
| 1906 | } |
| 1907 | |
| 1908 | // if other stations jointed, indicate connect to upper layer.. |
| 1909 | if (pMgmt->eCurrState == WMAC_STATE_STARTED) { |
| 1910 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Current IBSS State: [Started]........to: [Jointed] \n"); |
| 1911 | pMgmt->eCurrState = WMAC_STATE_JOINTED; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1912 | pDevice->bLinkPass = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1913 | ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER); |
| 1914 | if (netif_queue_stopped(pDevice->dev)){ |
| 1915 | netif_wake_queue(pDevice->dev); |
| 1916 | } |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1917 | pMgmt->sNodeDBTable[0].bActive = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1918 | pMgmt->sNodeDBTable[0].uInActiveCount = 0; |
| 1919 | |
Joe Perches | 9fc8602 | 2011-04-10 14:31:32 -0700 | [diff] [blame] | 1920 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1921 | } |
| 1922 | else if (bIsSSIDEqual) { |
| 1923 | |
| 1924 | // See other adhoc sta with the same SSID but BSSID is different. |
| 1925 | // adpot this vars only when TSF larger then us. |
| 1926 | if (bTSFLargeDiff && bTSFOffsetPostive) { |
| 1927 | // we don't support ATIM under adhoc mode |
| 1928 | // if ( sFrame.pIBSSParms->wATIMWindow == 0) { |
| 1929 | // adpot this vars |
| 1930 | // TODO: check sFrame cap if privacy on, and support rate syn |
| 1931 | memcpy(pMgmt->abyCurrBSSID, sFrame.pHdr->sA3.abyAddr3, WLAN_BSSID_LEN); |
| 1932 | memcpy(pDevice->abyBSSID, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); |
| 1933 | pMgmt->wCurrATIMWindow = cpu_to_le16(sFrame.pIBSSParms->wATIMWindow); |
| 1934 | pMgmt->wCurrBeaconPeriod = cpu_to_le16(*sFrame.pwBeaconInterval); |
| 1935 | pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pSuppRates, |
| 1936 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, |
| 1937 | WLAN_RATES_MAXLEN_11B); |
| 1938 | // set HW beacon interval and re-synchronizing.... |
| 1939 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Rejoining to Other Adhoc group with same SSID........\n"); |
| 1940 | |
| 1941 | MACvWriteBeaconInterval(pDevice, pMgmt->wCurrBeaconPeriod); |
| 1942 | CARDvAdjustTSF(pDevice, pRxPacket->byRxRate, qwTimestamp, pRxPacket->qwLocalTSF); |
| 1943 | CARDvUpdateNextTBTT(pDevice, qwTimestamp, pMgmt->wCurrBeaconPeriod); |
| 1944 | |
| 1945 | // Turn off bssid filter to avoid filter others adhoc station which bssid is different. |
| 1946 | MACvWriteBSSIDAddress(pDevice, pMgmt->abyCurrBSSID); |
| 1947 | |
| 1948 | byOldPreambleType = pDevice->byPreambleType; |
| 1949 | if (WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame.pwCapInfo)) { |
| 1950 | pDevice->byPreambleType = pDevice->byShortPreamble; |
| 1951 | } |
| 1952 | else { |
| 1953 | pDevice->byPreambleType = 0; |
| 1954 | } |
| 1955 | if (pDevice->byPreambleType != byOldPreambleType) |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 1956 | CARDvSetRSPINF(pDevice, (u8)pDevice->byBBType); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1957 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1958 | // MACvRegBitsOff(pDevice->PortOffset, MAC_REG_RCR, RCR_BSSID); |
| 1959 | // set highest basic rate |
| 1960 | // s_vSetHighestBasicRate(pDevice, (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates); |
| 1961 | // Prepare beacon frame |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 1962 | bMgrPrepareBeaconToSend((void *) pDevice, pMgmt); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1963 | // } |
Joe Perches | 9fc8602 | 2011-04-10 14:31:32 -0700 | [diff] [blame] | 1964 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1965 | } |
Joe Perches | 9fc8602 | 2011-04-10 14:31:32 -0700 | [diff] [blame] | 1966 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1967 | // endian issue ??? |
| 1968 | // Update TSF |
| 1969 | if (bUpdateTSF) { |
| 1970 | CARDbGetCurrentTSF(pDevice, &qwCurrTSF); |
| 1971 | CARDvAdjustTSF(pDevice, pRxPacket->byRxRate, qwTimestamp , pRxPacket->qwLocalTSF); |
| 1972 | CARDbGetCurrentTSF(pDevice, &qwCurrTSF); |
| 1973 | CARDvUpdateNextTBTT(pDevice, qwTimestamp, pMgmt->wCurrBeaconPeriod); |
| 1974 | } |
| 1975 | |
| 1976 | return; |
| 1977 | } |
| 1978 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1979 | /*+ |
| 1980 | * |
| 1981 | * Routine Description: |
| 1982 | * Instructs the hw to create a bss using the supplied |
| 1983 | * attributes. Note that this implementation only supports Ad-Hoc |
| 1984 | * BSS creation. |
| 1985 | * |
| 1986 | * |
| 1987 | * Return Value: |
| 1988 | * CMD_STATUS |
| 1989 | * |
| 1990 | -*/ |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 1991 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 1992 | void vMgrCreateOwnIBSS(struct vnt_private *pDevice, PCMD_STATUS pStatus) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1993 | { |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 1994 | struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; |
| 1995 | u16 wMaxBasicRate; |
| 1996 | u16 wMaxSuppRate; |
| 1997 | u8 byTopCCKBasicRate; |
| 1998 | u8 byTopOFDMBasicRate; |
Malcolm Priestley | 7c65fa2 | 2012-11-28 21:11:02 +0000 | [diff] [blame] | 1999 | u64 qwCurrTSF = 0; |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 2000 | int ii; |
| 2001 | u8 abyRATE[] = {0x82, 0x84, 0x8B, 0x96, 0x24, 0x30, 0x48, 0x6C, 0x0C, |
| 2002 | 0x12, 0x18, 0x60}; |
| 2003 | u8 abyCCK_RATE[] = {0x82, 0x84, 0x8B, 0x96}; |
| 2004 | u8 abyOFDM_RATE[] = {0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C}; |
| 2005 | u16 wSuppRate; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2006 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2007 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Create Basic Service Set .......\n"); |
| 2008 | |
| 2009 | if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) { |
| 2010 | if ((pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) && |
| 2011 | (pDevice->eEncryptionStatus != Ndis802_11Encryption2Enabled) && |
| 2012 | (pDevice->eEncryptionStatus != Ndis802_11Encryption3Enabled)) { |
| 2013 | // encryption mode error |
| 2014 | *pStatus = CMD_STATUS_FAILURE; |
| 2015 | return; |
| 2016 | } |
| 2017 | } |
| 2018 | |
| 2019 | pMgmt->abyCurrSuppRates[0] = WLAN_EID_SUPP_RATES; |
| 2020 | pMgmt->abyCurrExtSuppRates[0] = WLAN_EID_EXTSUPP_RATES; |
| 2021 | |
| 2022 | if (pMgmt->eConfigMode == WMAC_CONFIG_AP) { |
| 2023 | pMgmt->eCurrentPHYMode = pMgmt->byAPBBType; |
| 2024 | } else { |
| 2025 | if (pDevice->byBBType == BB_TYPE_11G) |
| 2026 | pMgmt->eCurrentPHYMode = PHY_TYPE_11G; |
| 2027 | if (pDevice->byBBType == BB_TYPE_11B) |
| 2028 | pMgmt->eCurrentPHYMode = PHY_TYPE_11B; |
| 2029 | if (pDevice->byBBType == BB_TYPE_11A) |
| 2030 | pMgmt->eCurrentPHYMode = PHY_TYPE_11A; |
| 2031 | } |
| 2032 | |
| 2033 | if (pMgmt->eCurrentPHYMode != PHY_TYPE_11A) { |
| 2034 | pMgmt->abyCurrSuppRates[1] = WLAN_RATES_MAXLEN_11B; |
| 2035 | pMgmt->abyCurrExtSuppRates[1] = 0; |
| 2036 | for (ii = 0; ii < 4; ii++) |
| 2037 | pMgmt->abyCurrSuppRates[2+ii] = abyRATE[ii]; |
| 2038 | } else { |
| 2039 | pMgmt->abyCurrSuppRates[1] = 8; |
| 2040 | pMgmt->abyCurrExtSuppRates[1] = 0; |
| 2041 | for (ii = 0; ii < 8; ii++) |
| 2042 | pMgmt->abyCurrSuppRates[2+ii] = abyRATE[ii]; |
| 2043 | } |
| 2044 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2045 | if (pMgmt->eCurrentPHYMode == PHY_TYPE_11G) { |
| 2046 | pMgmt->abyCurrSuppRates[1] = 8; |
| 2047 | pMgmt->abyCurrExtSuppRates[1] = 4; |
| 2048 | for (ii = 0; ii < 4; ii++) |
| 2049 | pMgmt->abyCurrSuppRates[2+ii] = abyCCK_RATE[ii]; |
| 2050 | for (ii = 4; ii < 8; ii++) |
| 2051 | pMgmt->abyCurrSuppRates[2+ii] = abyOFDM_RATE[ii-4]; |
| 2052 | for (ii = 0; ii < 4; ii++) |
| 2053 | pMgmt->abyCurrExtSuppRates[2+ii] = abyOFDM_RATE[ii+4]; |
| 2054 | } |
| 2055 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2056 | // Disable Protect Mode |
| 2057 | pDevice->bProtectMode = 0; |
| 2058 | MACvDisableProtectMD(pDevice); |
| 2059 | |
| 2060 | pDevice->bBarkerPreambleMd = 0; |
| 2061 | MACvDisableBarkerPreambleMd(pDevice); |
| 2062 | |
| 2063 | // Kyle Test 2003.11.04 |
| 2064 | |
| 2065 | // set HW beacon interval |
| 2066 | if (pMgmt->wIBSSBeaconPeriod == 0) |
| 2067 | pMgmt->wIBSSBeaconPeriod = DEFAULT_IBSS_BI; |
| 2068 | MACvWriteBeaconInterval(pDevice, pMgmt->wIBSSBeaconPeriod); |
| 2069 | |
| 2070 | CARDbGetCurrentTSF(pDevice, &qwCurrTSF); |
| 2071 | // clear TSF counter |
| 2072 | CARDbClearCurrentTSF(pDevice); |
| 2073 | |
| 2074 | // enable TSF counter |
| 2075 | MACvRegBitsOn(pDevice,MAC_REG_TFTCTL,TFTCTL_TSFCNTREN); |
| 2076 | // set Next TBTT |
| 2077 | CARDvSetFirstNextTBTT(pDevice, pMgmt->wIBSSBeaconPeriod); |
| 2078 | |
| 2079 | pMgmt->uIBSSChannel = pDevice->uChannel; |
| 2080 | |
| 2081 | if (pMgmt->uIBSSChannel == 0) |
| 2082 | pMgmt->uIBSSChannel = DEFAULT_IBSS_CHANNEL; |
| 2083 | |
| 2084 | // set channel and clear NAV |
| 2085 | CARDbSetMediaChannel(pDevice, pMgmt->uIBSSChannel); |
| 2086 | pMgmt->uCurrChannel = pMgmt->uIBSSChannel; |
| 2087 | |
| 2088 | pDevice->byPreambleType = pDevice->byShortPreamble; |
| 2089 | |
| 2090 | // set basic rate |
| 2091 | |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 2092 | RATEvParseMaxRate((void *)pDevice, |
| 2093 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2094 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates, true, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2095 | &wMaxBasicRate, &wMaxSuppRate, &wSuppRate, |
| 2096 | &byTopCCKBasicRate, &byTopOFDMBasicRate); |
| 2097 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2098 | if (pDevice->byBBType == BB_TYPE_11A) { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2099 | pDevice->bShortSlotTime = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2100 | } else { |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 2101 | pDevice->bShortSlotTime = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2102 | } |
| 2103 | BBvSetShortSlotTime(pDevice); |
| 2104 | // vUpdateIFS() use pDevice->bShortSlotTime as parameter so it must be called |
| 2105 | // after setting ShortSlotTime. |
| 2106 | // CARDvSetBSSMode call vUpdateIFS() |
| 2107 | CARDvSetBSSMode(pDevice); |
| 2108 | |
| 2109 | if (pMgmt->eConfigMode == WMAC_CONFIG_AP) { |
| 2110 | MACvRegBitsOn(pDevice, MAC_REG_HOSTCR, HOSTCR_AP); |
| 2111 | pMgmt->eCurrMode = WMAC_MODE_ESS_AP; |
| 2112 | } |
| 2113 | |
| 2114 | if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) { |
| 2115 | MACvRegBitsOn(pDevice, MAC_REG_HOSTCR, HOSTCR_ADHOC); |
| 2116 | pMgmt->eCurrMode = WMAC_MODE_IBSS_STA; |
| 2117 | } |
| 2118 | |
| 2119 | // Adopt pre-configured IBSS vars to current vars |
| 2120 | pMgmt->eCurrState = WMAC_STATE_STARTED; |
| 2121 | pMgmt->wCurrBeaconPeriod = pMgmt->wIBSSBeaconPeriod; |
| 2122 | pMgmt->uCurrChannel = pMgmt->uIBSSChannel; |
| 2123 | pMgmt->wCurrATIMWindow = pMgmt->wIBSSATIMWindow; |
| 2124 | pDevice->uCurrRSSI = 0; |
| 2125 | pDevice->byCurrSQ = 0; |
| 2126 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2127 | memcpy(pMgmt->abyDesireSSID,pMgmt->abyAdHocSSID, |
| 2128 | ((PWLAN_IE_SSID)pMgmt->abyAdHocSSID)->len + WLAN_IEHDR_LEN); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2129 | |
| 2130 | memset(pMgmt->abyCurrSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); |
| 2131 | memcpy(pMgmt->abyCurrSSID, |
| 2132 | pMgmt->abyDesireSSID, |
| 2133 | ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->len + WLAN_IEHDR_LEN |
| 2134 | ); |
| 2135 | |
| 2136 | if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { |
| 2137 | // AP mode BSSID = MAC addr |
| 2138 | memcpy(pMgmt->abyCurrBSSID, pMgmt->abyMACAddr, WLAN_ADDR_LEN); |
Andy Shevchenko | d6a32aa | 2011-07-26 10:35:31 +0300 | [diff] [blame] | 2139 | DBG_PRT(MSG_LEVEL_INFO, KERN_INFO"AP beacon created BSSID:" |
| 2140 | "%pM\n", pMgmt->abyCurrBSSID); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2141 | } |
| 2142 | |
| 2143 | if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) { |
| 2144 | |
| 2145 | // BSSID selected must be randomized as spec 11.1.3 |
Malcolm Priestley | 7c65fa2 | 2012-11-28 21:11:02 +0000 | [diff] [blame] | 2146 | pMgmt->abyCurrBSSID[5] = (u8)(qwCurrTSF & 0x000000ff); |
| 2147 | pMgmt->abyCurrBSSID[4] = (u8)((qwCurrTSF & 0x0000ff00) >> 8); |
| 2148 | pMgmt->abyCurrBSSID[3] = (u8)((qwCurrTSF & 0x00ff0000) >> 16); |
| 2149 | pMgmt->abyCurrBSSID[2] = (u8)((qwCurrTSF & 0x00000ff0) >> 4); |
| 2150 | pMgmt->abyCurrBSSID[1] = (u8)((qwCurrTSF & 0x000ff000) >> 12); |
| 2151 | pMgmt->abyCurrBSSID[0] = (u8)((qwCurrTSF & 0x0ff00000) >> 20); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2152 | pMgmt->abyCurrBSSID[5] ^= pMgmt->abyMACAddr[0]; |
| 2153 | pMgmt->abyCurrBSSID[4] ^= pMgmt->abyMACAddr[1]; |
| 2154 | pMgmt->abyCurrBSSID[3] ^= pMgmt->abyMACAddr[2]; |
| 2155 | pMgmt->abyCurrBSSID[2] ^= pMgmt->abyMACAddr[3]; |
| 2156 | pMgmt->abyCurrBSSID[1] ^= pMgmt->abyMACAddr[4]; |
| 2157 | pMgmt->abyCurrBSSID[0] ^= pMgmt->abyMACAddr[5]; |
| 2158 | pMgmt->abyCurrBSSID[0] &= ~IEEE_ADDR_GROUP; |
| 2159 | pMgmt->abyCurrBSSID[0] |= IEEE_ADDR_UNIVERSAL; |
| 2160 | |
Andy Shevchenko | d6a32aa | 2011-07-26 10:35:31 +0300 | [diff] [blame] | 2161 | DBG_PRT(MSG_LEVEL_INFO, KERN_INFO"Adhoc beacon created bssid:" |
| 2162 | "%pM\n", pMgmt->abyCurrBSSID); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2163 | } |
| 2164 | |
| 2165 | // set BSSID filter |
| 2166 | MACvWriteBSSIDAddress(pDevice, pMgmt->abyCurrBSSID); |
| 2167 | memcpy(pDevice->abyBSSID, pMgmt->abyCurrBSSID, WLAN_ADDR_LEN); |
| 2168 | |
| 2169 | MACvRegBitsOn(pDevice, MAC_REG_RCR, RCR_BSSID); |
| 2170 | pDevice->byRxMode |= RCR_BSSID; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2171 | pMgmt->bCurrBSSIDFilterOn = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2172 | |
| 2173 | // Set Capability Info |
| 2174 | pMgmt->wCurrCapInfo = 0; |
| 2175 | |
| 2176 | if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { |
| 2177 | pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_ESS(1); |
| 2178 | pMgmt->byDTIMPeriod = DEFAULT_DTIM_PERIOD; |
| 2179 | pMgmt->byDTIMCount = pMgmt->byDTIMPeriod - 1; |
| 2180 | pDevice->eOPMode = OP_MODE_AP; |
| 2181 | } |
| 2182 | |
| 2183 | if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) { |
| 2184 | pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_IBSS(1); |
| 2185 | pDevice->eOPMode = OP_MODE_ADHOC; |
| 2186 | } |
| 2187 | |
| 2188 | if (pDevice->bEncryptionEnable) { |
| 2189 | pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_PRIVACY(1); |
| 2190 | if (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) { |
| 2191 | if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) { |
| 2192 | pMgmt->byCSSPK = KEY_CTL_CCMP; |
| 2193 | pMgmt->byCSSGK = KEY_CTL_CCMP; |
| 2194 | } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) { |
| 2195 | pMgmt->byCSSPK = KEY_CTL_TKIP; |
| 2196 | pMgmt->byCSSGK = KEY_CTL_TKIP; |
| 2197 | } else { |
| 2198 | pMgmt->byCSSPK = KEY_CTL_NONE; |
| 2199 | pMgmt->byCSSGK = KEY_CTL_WEP; |
| 2200 | } |
| 2201 | } else { |
| 2202 | pMgmt->byCSSPK = KEY_CTL_WEP; |
| 2203 | pMgmt->byCSSGK = KEY_CTL_WEP; |
| 2204 | } |
Joe Perches | 9fc8602 | 2011-04-10 14:31:32 -0700 | [diff] [blame] | 2205 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2206 | |
| 2207 | pMgmt->byERPContext = 0; |
| 2208 | |
| 2209 | if (pDevice->byPreambleType == 1) { |
| 2210 | pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1); |
| 2211 | } else { |
| 2212 | pMgmt->wCurrCapInfo &= (~WLAN_SET_CAP_INFO_SHORTPREAMBLE(1)); |
| 2213 | } |
| 2214 | |
| 2215 | pMgmt->eCurrState = WMAC_STATE_STARTED; |
| 2216 | // Prepare beacon to send |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 2217 | if (bMgrPrepareBeaconToSend((void *) pDevice, pMgmt)) |
| 2218 | *pStatus = CMD_STATUS_SUCCESS; |
| 2219 | |
| 2220 | return; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2221 | } |
| 2222 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2223 | /*+ |
| 2224 | * |
| 2225 | * Routine Description: |
| 2226 | * Instructs wmac to join a bss using the supplied attributes. |
| 2227 | * The arguments may the BSSID or SSID and the rest of the |
| 2228 | * attributes are obtained from the scan result of known bss list. |
| 2229 | * |
| 2230 | * |
| 2231 | * Return Value: |
| 2232 | * None. |
| 2233 | * |
| 2234 | -*/ |
| 2235 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 2236 | void vMgrJoinBSSBegin(struct vnt_private *pDevice, PCMD_STATUS pStatus) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2237 | { |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 2238 | struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; |
| 2239 | PKnownBSS pCurr = NULL; |
| 2240 | int ii, uu; |
| 2241 | PWLAN_IE_SUPP_RATES pItemRates = NULL; |
| 2242 | PWLAN_IE_SUPP_RATES pItemExtRates = NULL; |
| 2243 | PWLAN_IE_SSID pItemSSID; |
| 2244 | u32 uRateLen = WLAN_RATES_MAXLEN; |
| 2245 | u16 wMaxBasicRate = RATE_1M; |
| 2246 | u16 wMaxSuppRate = RATE_1M; |
| 2247 | u16 wSuppRate; |
| 2248 | u8 byTopCCKBasicRate = RATE_1M; |
| 2249 | u8 byTopOFDMBasicRate = RATE_1M; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 2250 | u8 bShortSlotTime = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2251 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2252 | for (ii = 0; ii < MAX_BSS_NUM; ii++) { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2253 | if (pMgmt->sBSSList[ii].bActive == true) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2254 | break; |
| 2255 | } |
| 2256 | |
| 2257 | if (ii == MAX_BSS_NUM) { |
| 2258 | *pStatus = CMD_STATUS_RESOURCES; |
| 2259 | DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "BSS finding:BSS list is empty.\n"); |
| 2260 | return; |
Joe Perches | 9fc8602 | 2011-04-10 14:31:32 -0700 | [diff] [blame] | 2261 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2262 | |
| 2263 | // memset(pMgmt->abyDesireBSSID, 0, WLAN_BSSID_LEN); |
| 2264 | // Search known BSS list for prefer BSSID or SSID |
| 2265 | |
| 2266 | pCurr = BSSpSearchBSSList(pDevice, |
| 2267 | pMgmt->abyDesireBSSID, |
| 2268 | pMgmt->abyDesireSSID, |
| 2269 | pDevice->eConfigPHYMode |
| 2270 | ); |
| 2271 | |
| 2272 | if (pCurr == NULL){ |
| 2273 | *pStatus = CMD_STATUS_RESOURCES; |
| 2274 | pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID; |
| 2275 | DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Scanning [%s] not found, disconnected !\n", pItemSSID->abySSID); |
| 2276 | return; |
Joe Perches | 9fc8602 | 2011-04-10 14:31:32 -0700 | [diff] [blame] | 2277 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2278 | |
| 2279 | DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "AP(BSS) finding:Found a AP(BSS)..\n"); |
| 2280 | |
| 2281 | if (WLAN_GET_CAP_INFO_ESS(cpu_to_le16(pCurr->wCapInfo))){ |
| 2282 | |
Andres More | bd2bc4c | 2010-08-02 23:35:57 -0300 | [diff] [blame] | 2283 | if ((pMgmt->eAuthenMode == WMAC_AUTH_WPA) || |
| 2284 | (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK)) { |
| 2285 | /* |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2286 | if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) { |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 2287 | if (WPA_SearchRSN(0, WPA_TKIP, pCurr) == false) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2288 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"No match RSN info. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); |
| 2289 | // encryption mode error |
| 2290 | pMgmt->eCurrState = WMAC_STATE_IDLE; |
| 2291 | return; |
| 2292 | } |
| 2293 | } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) { |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 2294 | if (WPA_SearchRSN(0, WPA_AESCCMP, pCurr) == false) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2295 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"No match RSN info. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); |
| 2296 | // encryption mode error |
| 2297 | pMgmt->eCurrState = WMAC_STATE_IDLE; |
| 2298 | return; |
| 2299 | } |
| 2300 | } |
| 2301 | */ |
| 2302 | } |
| 2303 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2304 | //if(pDevice->bWPASuppWextEnabled == true) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2305 | Encyption_Rebuild(pDevice, pCurr); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2306 | |
| 2307 | // Infrastructure BSS |
| 2308 | s_vMgrSynchBSS(pDevice, |
| 2309 | WMAC_MODE_ESS_STA, |
| 2310 | pCurr, |
| 2311 | pStatus |
| 2312 | ); |
| 2313 | |
| 2314 | if (*pStatus == CMD_STATUS_SUCCESS){ |
| 2315 | |
| 2316 | // Adopt this BSS state vars in Mgmt Object |
| 2317 | pMgmt->uCurrChannel = pCurr->uChannel; |
| 2318 | |
| 2319 | memset(pMgmt->abyCurrSuppRates, 0 , WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1); |
| 2320 | memset(pMgmt->abyCurrExtSuppRates, 0 , WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1); |
| 2321 | |
| 2322 | if (pCurr->eNetworkTypeInUse == PHY_TYPE_11B) { |
| 2323 | uRateLen = WLAN_RATES_MAXLEN_11B; |
| 2324 | } |
| 2325 | |
| 2326 | pItemRates = (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates; |
| 2327 | pItemExtRates = (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates; |
| 2328 | |
| 2329 | // Parse Support Rate IE |
| 2330 | pItemRates->byElementID = WLAN_EID_SUPP_RATES; |
| 2331 | pItemRates->len = RATEuSetIE((PWLAN_IE_SUPP_RATES)pCurr->abySuppRates, |
| 2332 | pItemRates, |
| 2333 | uRateLen); |
| 2334 | |
| 2335 | // Parse Extension Support Rate IE |
| 2336 | pItemExtRates->byElementID = WLAN_EID_EXTSUPP_RATES; |
| 2337 | pItemExtRates->len = RATEuSetIE((PWLAN_IE_SUPP_RATES)pCurr->abyExtSuppRates, |
| 2338 | pItemExtRates, |
| 2339 | uRateLen); |
| 2340 | // Stuffing Rate IE |
| 2341 | if ((pItemExtRates->len > 0) && (pItemRates->len < 8)) { |
Andres More | cc856e6 | 2010-05-17 21:34:01 -0300 | [diff] [blame] | 2342 | for (ii = 0; ii < (unsigned int) (8 - pItemRates->len); ) { |
| 2343 | pItemRates->abyRates[pItemRates->len + ii] = |
| 2344 | pItemExtRates->abyRates[ii]; |
| 2345 | ii++; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2346 | if (pItemExtRates->len <= ii) |
| 2347 | break; |
| 2348 | } |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 2349 | pItemRates->len += (u8)ii; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2350 | if (pItemExtRates->len - ii > 0) { |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 2351 | pItemExtRates->len -= (u8)ii; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2352 | for (uu = 0; uu < pItemExtRates->len; uu ++) { |
| 2353 | pItemExtRates->abyRates[uu] = pItemExtRates->abyRates[uu + ii]; |
| 2354 | } |
| 2355 | } else { |
| 2356 | pItemExtRates->len = 0; |
| 2357 | } |
| 2358 | } |
| 2359 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2360 | RATEvParseMaxRate((void *)pDevice, pItemRates, pItemExtRates, true, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2361 | &wMaxBasicRate, &wMaxSuppRate, &wSuppRate, |
| 2362 | &byTopCCKBasicRate, &byTopOFDMBasicRate); |
| 2363 | vUpdateIFS(pDevice); |
| 2364 | // TODO: deal with if wCapInfo the privacy is on, but station WEP is off |
| 2365 | // TODO: deal with if wCapInfo the PS-Pollable is on. |
| 2366 | pMgmt->wCurrBeaconPeriod = pCurr->wBeaconInterval; |
| 2367 | memset(pMgmt->abyCurrSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); |
| 2368 | memcpy(pMgmt->abyCurrBSSID, pCurr->abyBSSID, WLAN_BSSID_LEN); |
| 2369 | memcpy(pMgmt->abyCurrSSID, pCurr->abySSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); |
| 2370 | |
| 2371 | pMgmt->eCurrMode = WMAC_MODE_ESS_STA; |
| 2372 | |
| 2373 | pMgmt->eCurrState = WMAC_STATE_JOINTED; |
| 2374 | // Adopt BSS state in Adapter Device Object |
| 2375 | pDevice->eOPMode = OP_MODE_INFRASTRUCTURE; |
| 2376 | memcpy(pDevice->abyBSSID, pCurr->abyBSSID, WLAN_BSSID_LEN); |
| 2377 | |
| 2378 | // Add current BSS to Candidate list |
Justin P. Mattock | a0a1f61 | 2012-08-26 08:16:43 -0700 | [diff] [blame] | 2379 | // This should only work for WPA2 BSS, and WPA2 BSS check must be done before. |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2380 | if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2) { |
Andres More | dfdcc42 | 2013-02-12 20:36:28 -0500 | [diff] [blame] | 2381 | bool bResult = bAdd_PMKID_Candidate((void *) pDevice, |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 2382 | pMgmt->abyCurrBSSID, |
| 2383 | &pCurr->sRSNCapObj); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2384 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"bAdd_PMKID_Candidate: 1(%d)\n", bResult); |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 2385 | if (bResult == false) { |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 2386 | vFlush_PMKID_Candidate((void *) pDevice); |
| 2387 | DBG_PRT(MSG_LEVEL_DEBUG, |
| 2388 | KERN_INFO "vFlush_PMKID_Candidate: 4\n"); |
| 2389 | bAdd_PMKID_Candidate((void *) pDevice, |
| 2390 | pMgmt->abyCurrBSSID, |
| 2391 | &pCurr->sRSNCapObj); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2392 | } |
| 2393 | } |
| 2394 | |
| 2395 | // Preamble type auto-switch: if AP can receive short-preamble cap, |
| 2396 | // we can turn on too. |
| 2397 | if (WLAN_GET_CAP_INFO_SHORTPREAMBLE(pCurr->wCapInfo)) { |
| 2398 | pDevice->byPreambleType = pDevice->byShortPreamble; |
| 2399 | } |
| 2400 | else { |
| 2401 | pDevice->byPreambleType = 0; |
| 2402 | } |
| 2403 | // Change PreambleType must set RSPINF again |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 2404 | CARDvSetRSPINF(pDevice, (u8)pDevice->byBBType); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2405 | |
| 2406 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Join ESS\n"); |
| 2407 | |
| 2408 | if (pCurr->eNetworkTypeInUse == PHY_TYPE_11G) { |
| 2409 | |
| 2410 | if ((pCurr->sERP.byERP & WLAN_EID_ERP_USE_PROTECTION) != pDevice->bProtectMode) {//0000 0010 |
| 2411 | pDevice->bProtectMode = (pCurr->sERP.byERP & WLAN_EID_ERP_USE_PROTECTION); |
| 2412 | if (pDevice->bProtectMode) { |
| 2413 | MACvEnableProtectMD(pDevice); |
| 2414 | } else { |
| 2415 | MACvDisableProtectMD(pDevice); |
| 2416 | } |
| 2417 | vUpdateIFS(pDevice); |
| 2418 | } |
| 2419 | if ((pCurr->sERP.byERP & WLAN_EID_ERP_NONERP_PRESENT) != pDevice->bNonERPPresent) {//0000 0001 |
| 2420 | pDevice->bNonERPPresent = (pCurr->sERP.byERP & WLAN_EID_ERP_USE_PROTECTION); |
| 2421 | } |
| 2422 | if ((pCurr->sERP.byERP & WLAN_EID_ERP_BARKER_MODE) != pDevice->bBarkerPreambleMd) {//0000 0100 |
| 2423 | pDevice->bBarkerPreambleMd = (pCurr->sERP.byERP & WLAN_EID_ERP_BARKER_MODE); |
| 2424 | //BarkerPreambleMd has higher priority than shortPreamble bit in Cap |
| 2425 | if (pDevice->bBarkerPreambleMd) { |
| 2426 | MACvEnableBarkerPreambleMd(pDevice); |
| 2427 | } else { |
| 2428 | MACvDisableBarkerPreambleMd(pDevice); |
| 2429 | } |
| 2430 | } |
| 2431 | } |
| 2432 | //DBG_PRN_WLAN05(("wCapInfo: %X\n", pCurr->wCapInfo)); |
| 2433 | if (WLAN_GET_CAP_INFO_SHORTSLOTTIME(pCurr->wCapInfo) != pDevice->bShortSlotTime) { |
| 2434 | if (pDevice->byBBType == BB_TYPE_11A) { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2435 | bShortSlotTime = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2436 | } |
| 2437 | else if (pDevice->byBBType == BB_TYPE_11B) { |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 2438 | bShortSlotTime = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2439 | } |
| 2440 | else { |
| 2441 | bShortSlotTime = WLAN_GET_CAP_INFO_SHORTSLOTTIME(pCurr->wCapInfo); |
| 2442 | } |
| 2443 | //DBG_PRN_WLAN05(("Set Short Slot Time: %d\n", pDevice->bShortSlotTime)); |
| 2444 | if (bShortSlotTime != pDevice->bShortSlotTime) { |
| 2445 | pDevice->bShortSlotTime = bShortSlotTime; |
| 2446 | BBvSetShortSlotTime(pDevice); |
| 2447 | vUpdateIFS(pDevice); |
| 2448 | } |
| 2449 | } |
| 2450 | |
| 2451 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"End of Join AP -- A/B/G Action\n"); |
| 2452 | } |
| 2453 | else { |
| 2454 | pMgmt->eCurrState = WMAC_STATE_IDLE; |
| 2455 | }; |
| 2456 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2457 | } |
| 2458 | else { |
| 2459 | // ad-hoc mode BSS |
| 2460 | if (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) { |
| 2461 | |
| 2462 | if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) { |
| 2463 | /* |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 2464 | if (WPA_SearchRSN(0, WPA_TKIP, pCurr) == false) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2465 | // encryption mode error |
| 2466 | pMgmt->eCurrState = WMAC_STATE_IDLE; |
| 2467 | return; |
| 2468 | } |
| 2469 | */ |
| 2470 | } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) { |
| 2471 | /* |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 2472 | if (WPA_SearchRSN(0, WPA_AESCCMP, pCurr) == false) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2473 | // encryption mode error |
| 2474 | pMgmt->eCurrState = WMAC_STATE_IDLE; |
| 2475 | return; |
| 2476 | } |
| 2477 | */ |
| 2478 | } else { |
| 2479 | // encryption mode error |
| 2480 | pMgmt->eCurrState = WMAC_STATE_IDLE; |
| 2481 | return; |
| 2482 | } |
| 2483 | } |
| 2484 | |
| 2485 | s_vMgrSynchBSS(pDevice, |
| 2486 | WMAC_MODE_IBSS_STA, |
| 2487 | pCurr, |
| 2488 | pStatus |
| 2489 | ); |
| 2490 | |
| 2491 | if (*pStatus == CMD_STATUS_SUCCESS){ |
| 2492 | // Adopt this BSS state vars in Mgmt Object |
| 2493 | // TODO: check if CapInfo privacy on, but we don't.. |
| 2494 | pMgmt->uCurrChannel = pCurr->uChannel; |
| 2495 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2496 | // Parse Support Rate IE |
| 2497 | pMgmt->abyCurrSuppRates[0] = WLAN_EID_SUPP_RATES; |
| 2498 | pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)pCurr->abySuppRates, |
| 2499 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, |
| 2500 | WLAN_RATES_MAXLEN_11B); |
| 2501 | // set basic rate |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 2502 | RATEvParseMaxRate((void *)pDevice, |
| 2503 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2504 | NULL, true, &wMaxBasicRate, &wMaxSuppRate, &wSuppRate, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2505 | &byTopCCKBasicRate, &byTopOFDMBasicRate); |
| 2506 | vUpdateIFS(pDevice); |
| 2507 | pMgmt->wCurrCapInfo = pCurr->wCapInfo; |
| 2508 | pMgmt->wCurrBeaconPeriod = pCurr->wBeaconInterval; |
| 2509 | memset(pMgmt->abyCurrSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN); |
| 2510 | memcpy(pMgmt->abyCurrBSSID, pCurr->abyBSSID, WLAN_BSSID_LEN); |
| 2511 | memcpy(pMgmt->abyCurrSSID, pCurr->abySSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN); |
| 2512 | // pMgmt->wCurrATIMWindow = pCurr->wATIMWindow; |
| 2513 | pMgmt->eCurrMode = WMAC_MODE_IBSS_STA; |
| 2514 | pMgmt->eCurrState = WMAC_STATE_STARTED; |
| 2515 | // Adopt BSS state in Adapter Device Object |
| 2516 | pDevice->eOPMode = OP_MODE_ADHOC; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2517 | pDevice->bLinkPass = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2518 | ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER); |
| 2519 | memcpy(pDevice->abyBSSID, pCurr->abyBSSID, WLAN_BSSID_LEN); |
| 2520 | |
Andy Shevchenko | d6a32aa | 2011-07-26 10:35:31 +0300 | [diff] [blame] | 2521 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Join IBSS ok:%pM\n", |
| 2522 | pMgmt->abyCurrBSSID); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2523 | // Preamble type auto-switch: if AP can receive short-preamble cap, |
| 2524 | // and if registry setting is short preamble we can turn on too. |
| 2525 | |
| 2526 | if (WLAN_GET_CAP_INFO_SHORTPREAMBLE(pCurr->wCapInfo)) { |
| 2527 | pDevice->byPreambleType = pDevice->byShortPreamble; |
| 2528 | } |
| 2529 | else { |
| 2530 | pDevice->byPreambleType = 0; |
| 2531 | } |
| 2532 | // Change PreambleType must set RSPINF again |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 2533 | CARDvSetRSPINF(pDevice, (u8)pDevice->byBBType); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2534 | |
| 2535 | // Prepare beacon |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 2536 | bMgrPrepareBeaconToSend((void *) pDevice, pMgmt); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2537 | } |
| 2538 | else { |
| 2539 | pMgmt->eCurrState = WMAC_STATE_IDLE; |
| 2540 | }; |
| 2541 | }; |
| 2542 | return; |
| 2543 | } |
| 2544 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2545 | /*+ |
| 2546 | * |
| 2547 | * Routine Description: |
| 2548 | * Set HW to synchronize a specific BSS from known BSS list. |
| 2549 | * |
| 2550 | * |
| 2551 | * Return Value: |
| 2552 | * PCM_STATUS |
| 2553 | * |
| 2554 | -*/ |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 2555 | static void s_vMgrSynchBSS(struct vnt_private *pDevice, u32 uBSSMode, |
| 2556 | PKnownBSS pCurr, PCMD_STATUS pStatus) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2557 | { |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 2558 | struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; |
| 2559 | u8 abyCurrSuppRatesG[] = {WLAN_EID_SUPP_RATES, |
| 2560 | 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C}; |
| 2561 | /* 1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M*/ |
| 2562 | u8 abyCurrExtSuppRatesG[] = {WLAN_EID_EXTSUPP_RATES, |
| 2563 | 4, 0x0C, 0x12, 0x18, 0x60}; |
| 2564 | /* 6M, 9M, 12M, 48M*/ |
| 2565 | u8 abyCurrSuppRatesA[] = {WLAN_EID_SUPP_RATES, |
| 2566 | 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C}; |
| 2567 | u8 abyCurrSuppRatesB[] = {WLAN_EID_SUPP_RATES, |
| 2568 | 4, 0x02, 0x04, 0x0B, 0x16}; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2569 | |
| 2570 | *pStatus = CMD_STATUS_FAILURE; |
| 2571 | |
| 2572 | if (s_bCipherMatch(pCurr, |
| 2573 | pDevice->eEncryptionStatus, |
| 2574 | &(pMgmt->byCSSPK), |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 2575 | &(pMgmt->byCSSGK)) == false) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2576 | DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "s_bCipherMatch Fail .......\n"); |
| 2577 | return; |
| 2578 | } |
| 2579 | |
| 2580 | pMgmt->pCurrBSS = pCurr; |
| 2581 | |
| 2582 | // if previous mode is IBSS. |
| 2583 | if(pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) { |
| 2584 | MACvRegBitsOff(pDevice, MAC_REG_TCR, TCR_AUTOBCNTX); |
| 2585 | } |
| 2586 | |
| 2587 | // Init the BSS informations |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2588 | pDevice->bCCK = true; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 2589 | pDevice->bProtectMode = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2590 | MACvDisableProtectMD(pDevice); |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 2591 | pDevice->bBarkerPreambleMd = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2592 | MACvDisableBarkerPreambleMd(pDevice); |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 2593 | pDevice->bNonERPPresent = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2594 | pDevice->byPreambleType = 0; |
| 2595 | pDevice->wBasicRate = 0; |
| 2596 | // Set Basic Rate |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 2597 | CARDbAddBasicRate((void *)pDevice, RATE_1M); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2598 | |
| 2599 | // calculate TSF offset |
| 2600 | // TSF Offset = Received Timestamp TSF - Marked Local's TSF |
| 2601 | CARDvAdjustTSF(pDevice, pCurr->byRxRate, pCurr->qwBSSTimestamp, pCurr->qwLocalTSF); |
| 2602 | |
| 2603 | // set HW beacon interval |
| 2604 | MACvWriteBeaconInterval(pDevice, pCurr->wBeaconInterval); |
| 2605 | |
| 2606 | // set Next TBTT |
| 2607 | // Next TBTT = ((local_current_TSF / beacon_interval) + 1 ) * beacon_interval |
| 2608 | CARDvSetFirstNextTBTT(pDevice, pCurr->wBeaconInterval); |
| 2609 | |
| 2610 | // set BSSID |
| 2611 | MACvWriteBSSIDAddress(pDevice, pCurr->abyBSSID); |
| 2612 | |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 2613 | memcpy(pMgmt->abyCurrBSSID, pCurr->abyBSSID, 6); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2614 | |
Andy Shevchenko | d6a32aa | 2011-07-26 10:35:31 +0300 | [diff] [blame] | 2615 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Sync:set CurrBSSID address = " |
| 2616 | "%pM\n", pMgmt->abyCurrBSSID); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2617 | |
| 2618 | if (pCurr->eNetworkTypeInUse == PHY_TYPE_11A) { |
| 2619 | if ((pDevice->eConfigPHYMode == PHY_TYPE_11A) || |
| 2620 | (pDevice->eConfigPHYMode == PHY_TYPE_AUTO)) { |
| 2621 | pDevice->byBBType = BB_TYPE_11A; |
| 2622 | pMgmt->eCurrentPHYMode = PHY_TYPE_11A; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2623 | pDevice->bShortSlotTime = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2624 | BBvSetShortSlotTime(pDevice); |
| 2625 | CARDvSetBSSMode(pDevice); |
| 2626 | } else { |
| 2627 | return; |
| 2628 | } |
| 2629 | } else if (pCurr->eNetworkTypeInUse == PHY_TYPE_11B) { |
| 2630 | if ((pDevice->eConfigPHYMode == PHY_TYPE_11B) || |
| 2631 | (pDevice->eConfigPHYMode == PHY_TYPE_11G) || |
| 2632 | (pDevice->eConfigPHYMode == PHY_TYPE_AUTO)) { |
| 2633 | pDevice->byBBType = BB_TYPE_11B; |
| 2634 | pMgmt->eCurrentPHYMode = PHY_TYPE_11B; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 2635 | pDevice->bShortSlotTime = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2636 | BBvSetShortSlotTime(pDevice); |
| 2637 | CARDvSetBSSMode(pDevice); |
| 2638 | } else { |
| 2639 | return; |
| 2640 | } |
| 2641 | } else { |
| 2642 | if ((pDevice->eConfigPHYMode == PHY_TYPE_11G) || |
| 2643 | (pDevice->eConfigPHYMode == PHY_TYPE_AUTO)) { |
| 2644 | pDevice->byBBType = BB_TYPE_11G; |
| 2645 | pMgmt->eCurrentPHYMode = PHY_TYPE_11G; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2646 | pDevice->bShortSlotTime = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2647 | BBvSetShortSlotTime(pDevice); |
| 2648 | CARDvSetBSSMode(pDevice); |
| 2649 | } else if (pDevice->eConfigPHYMode == PHY_TYPE_11B) { |
| 2650 | pDevice->byBBType = BB_TYPE_11B; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 2651 | pDevice->bShortSlotTime = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2652 | BBvSetShortSlotTime(pDevice); |
| 2653 | CARDvSetBSSMode(pDevice); |
| 2654 | } else { |
| 2655 | return; |
| 2656 | } |
| 2657 | } |
| 2658 | |
| 2659 | if (uBSSMode == WMAC_MODE_ESS_STA) { |
| 2660 | MACvRegBitsOff(pDevice, MAC_REG_HOSTCR, HOSTCR_ADHOC); |
| 2661 | MACvRegBitsOn(pDevice, MAC_REG_RCR, RCR_BSSID); |
| 2662 | pDevice->byRxMode |= RCR_BSSID; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2663 | pMgmt->bCurrBSSIDFilterOn = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2664 | } |
| 2665 | |
| 2666 | // set channel and clear NAV |
| 2667 | CARDbSetMediaChannel(pDevice, pCurr->uChannel); |
| 2668 | pMgmt->uCurrChannel = pCurr->uChannel; |
| 2669 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "<----s_bSynchBSS Set Channel [%d]\n", pCurr->uChannel); |
| 2670 | |
| 2671 | if ((pDevice->bUpdateBBVGA) && |
| 2672 | (pDevice->byBBVGACurrent != pDevice->abyBBVGA[0])) { |
| 2673 | pDevice->byBBVGACurrent = pDevice->abyBBVGA[0]; |
| 2674 | BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent); |
| 2675 | BBvSetShortSlotTime(pDevice); |
| 2676 | } |
| 2677 | // |
| 2678 | // Notes: |
| 2679 | // 1. In Ad-hoc mode : check if received others beacon as jointed indication, |
| 2680 | // otherwise we will start own IBSS. |
| 2681 | // 2. In Infra mode : Supposed we already synchronized with AP right now. |
| 2682 | |
| 2683 | if (uBSSMode == WMAC_MODE_IBSS_STA) { |
| 2684 | MACvRegBitsOn(pDevice, MAC_REG_HOSTCR, HOSTCR_ADHOC); |
| 2685 | MACvRegBitsOn(pDevice, MAC_REG_RCR, RCR_BSSID); |
| 2686 | pDevice->byRxMode |= RCR_BSSID; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2687 | pMgmt->bCurrBSSIDFilterOn = true; |
Joe Perches | 9fc8602 | 2011-04-10 14:31:32 -0700 | [diff] [blame] | 2688 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2689 | |
| 2690 | if (pDevice->byBBType == BB_TYPE_11A) { |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 2691 | memcpy(pMgmt->abyCurrSuppRates, &abyCurrSuppRatesA[0], sizeof(abyCurrSuppRatesA)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2692 | pMgmt->abyCurrExtSuppRates[1] = 0; |
| 2693 | } else if (pDevice->byBBType == BB_TYPE_11B) { |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 2694 | memcpy(pMgmt->abyCurrSuppRates, &abyCurrSuppRatesB[0], sizeof(abyCurrSuppRatesB)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2695 | pMgmt->abyCurrExtSuppRates[1] = 0; |
| 2696 | } else { |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 2697 | memcpy(pMgmt->abyCurrSuppRates, &abyCurrSuppRatesG[0], sizeof(abyCurrSuppRatesG)); |
| 2698 | memcpy(pMgmt->abyCurrExtSuppRates, &abyCurrExtSuppRatesG[0], sizeof(abyCurrExtSuppRatesG)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2699 | } |
| 2700 | pMgmt->byERPContext = pCurr->sERP.byERP; |
| 2701 | |
| 2702 | *pStatus = CMD_STATUS_SUCCESS; |
| 2703 | |
| 2704 | return; |
| 2705 | }; |
| 2706 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 2707 | static void Encyption_Rebuild(struct vnt_private *pDevice, PKnownBSS pCurr) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2708 | { |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 2709 | struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2710 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 2711 | if ((pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) || |
| 2712 | (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2713 | if (pCurr->bWPAValid == true) { /*WPA-PSK */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2714 | pMgmt->eAuthenMode = WMAC_AUTH_WPAPSK; |
| 2715 | if(pCurr->abyPKType[0] == WPA_TKIP) { |
| 2716 | pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled; //TKIP |
| 2717 | PRINT_K("Encyption_Rebuild--->ssid reset config to [WPAPSK-TKIP]\n"); |
| 2718 | } |
| 2719 | else if(pCurr->abyPKType[0] == WPA_AESCCMP) { |
| 2720 | pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled; //AES |
| 2721 | PRINT_K("Encyption_Rebuild--->ssid reset config to [WPAPSK-AES]\n"); |
| 2722 | } |
| 2723 | } |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2724 | else if(pCurr->bWPA2Valid == true) { //WPA2-PSK |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2725 | pMgmt->eAuthenMode = WMAC_AUTH_WPA2PSK; |
| 2726 | if(pCurr->abyCSSPK[0] == WLAN_11i_CSS_TKIP) { |
| 2727 | pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled; //TKIP |
| 2728 | PRINT_K("Encyption_Rebuild--->ssid reset config to [WPA2PSK-TKIP]\n"); |
| 2729 | } |
| 2730 | else if(pCurr->abyCSSPK[0] == WLAN_11i_CSS_CCMP) { |
| 2731 | pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled; //AES |
| 2732 | PRINT_K("Encyption_Rebuild--->ssid reset config to [WPA2PSK-AES]\n"); |
| 2733 | } |
| 2734 | } |
| 2735 | } |
| 2736 | // } |
| 2737 | return; |
| 2738 | } |
| 2739 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2740 | /*+ |
| 2741 | * |
| 2742 | * Routine Description: |
| 2743 | * Format TIM field |
| 2744 | * |
| 2745 | * |
| 2746 | * Return Value: |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 2747 | * void |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2748 | * |
| 2749 | -*/ |
| 2750 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 2751 | static void s_vMgrFormatTIM(struct vnt_manager *pMgmt, PWLAN_IE_TIM pTIM) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2752 | { |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 2753 | u8 byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80}; |
| 2754 | u8 byMap; |
| 2755 | int ii, jj; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 2756 | int bStartFound = false; |
| 2757 | int bMulticast = false; |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 2758 | u16 wStartIndex = 0; |
| 2759 | u16 wEndIndex = 0; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2760 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2761 | // Find size of partial virtual bitmap |
| 2762 | for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) { |
| 2763 | byMap = pMgmt->abyPSTxMap[ii]; |
| 2764 | if (!ii) { |
| 2765 | // Mask out the broadcast bit which is indicated separately. |
| 2766 | bMulticast = (byMap & byMask[0]) != 0; |
| 2767 | if(bMulticast) { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2768 | pMgmt->sNodeDBTable[0].bRxPSPoll = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2769 | } |
| 2770 | byMap = 0; |
| 2771 | } |
| 2772 | if (byMap) { |
| 2773 | if (!bStartFound) { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2774 | bStartFound = true; |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 2775 | wStartIndex = (u16)ii; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2776 | } |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 2777 | wEndIndex = (u16)ii; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2778 | } |
Joe Perches | 273f4be | 2011-04-10 14:31:34 -0700 | [diff] [blame] | 2779 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2780 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2781 | // Round start index down to nearest even number |
| 2782 | wStartIndex &= ~BIT0; |
| 2783 | |
| 2784 | // Round end index up to nearest even number |
| 2785 | wEndIndex = ((wEndIndex + 1) & ~BIT0); |
| 2786 | |
| 2787 | // Size of element payload |
| 2788 | |
| 2789 | pTIM->len = 3 + (wEndIndex - wStartIndex) + 1; |
| 2790 | |
| 2791 | // Fill in the Fixed parts of the TIM |
| 2792 | pTIM->byDTIMCount = pMgmt->byDTIMCount; |
| 2793 | pTIM->byDTIMPeriod = pMgmt->byDTIMPeriod; |
| 2794 | pTIM->byBitMapCtl = (bMulticast ? TIM_MULTICAST_MASK : 0) | |
| 2795 | (((wStartIndex >> 1) << 1) & TIM_BITMAPOFFSET_MASK); |
| 2796 | |
| 2797 | // Append variable part of TIM |
| 2798 | |
| 2799 | for (ii = wStartIndex, jj =0 ; ii <= wEndIndex; ii++, jj++) { |
| 2800 | pTIM->byVirtBitMap[jj] = pMgmt->abyPSTxMap[ii]; |
| 2801 | } |
| 2802 | |
| 2803 | // Aid = 0 don't used. |
| 2804 | pTIM->byVirtBitMap[0] &= ~BIT0; |
| 2805 | } |
| 2806 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2807 | /*+ |
| 2808 | * |
| 2809 | * Routine Description: |
| 2810 | * Constructs an Beacon frame( Ad-hoc mode) |
| 2811 | * |
| 2812 | * |
| 2813 | * Return Value: |
Justin P. Mattock | a0a1f61 | 2012-08-26 08:16:43 -0700 | [diff] [blame] | 2814 | * PTR to frame; or NULL on allocation failure |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2815 | * |
| 2816 | -*/ |
| 2817 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 2818 | static struct vnt_tx_mgmt *s_MgrMakeBeacon(struct vnt_private *pDevice, |
| 2819 | struct vnt_manager *pMgmt, u16 wCurrCapInfo, u16 wCurrBeaconPeriod, |
| 2820 | u32 uCurrChannel, u16 wCurrATIMWinodw, PWLAN_IE_SSID pCurrSSID, |
| 2821 | u8 *pCurrBSSID, PWLAN_IE_SUPP_RATES pCurrSuppRates, |
| 2822 | PWLAN_IE_SUPP_RATES pCurrExtSuppRates) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2823 | { |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 2824 | struct vnt_tx_mgmt *pTxPacket = NULL; |
| 2825 | WLAN_FR_BEACON sFrame; |
| 2826 | u8 abyBroadcastAddr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2827 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 2828 | /* prepare beacon frame */ |
| 2829 | pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool; |
| 2830 | memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt) |
| 2831 | + WLAN_BEACON_FR_MAXLEN); |
| 2832 | pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket |
| 2833 | + sizeof(struct vnt_tx_mgmt)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2834 | // Setup the sFrame structure. |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 2835 | sFrame.pBuf = (u8 *)pTxPacket->p80211Header; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2836 | sFrame.len = WLAN_BEACON_FR_MAXLEN; |
| 2837 | vMgrEncodeBeacon(&sFrame); |
| 2838 | // Setup the header |
| 2839 | sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16( |
| 2840 | ( |
| 2841 | WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) | |
| 2842 | WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_BEACON) |
| 2843 | )); |
| 2844 | |
| 2845 | if (pDevice->bEnablePSMode) { |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 2846 | sFrame.pHdr->sA3.wFrameCtl |= cpu_to_le16((u16)WLAN_SET_FC_PWRMGT(1)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2847 | } |
| 2848 | |
| 2849 | memcpy( sFrame.pHdr->sA3.abyAddr1, abyBroadcastAddr, WLAN_ADDR_LEN); |
| 2850 | memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN); |
| 2851 | memcpy( sFrame.pHdr->sA3.abyAddr3, pCurrBSSID, WLAN_BSSID_LEN); |
| 2852 | *sFrame.pwBeaconInterval = cpu_to_le16(wCurrBeaconPeriod); |
| 2853 | *sFrame.pwCapInfo = cpu_to_le16(wCurrCapInfo); |
| 2854 | // Copy SSID |
| 2855 | sFrame.pSSID = (PWLAN_IE_SSID)(sFrame.pBuf + sFrame.len); |
| 2856 | sFrame.len += ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len + WLAN_IEHDR_LEN; |
| 2857 | memcpy(sFrame.pSSID, |
| 2858 | pCurrSSID, |
| 2859 | ((PWLAN_IE_SSID)pCurrSSID)->len + WLAN_IEHDR_LEN |
| 2860 | ); |
| 2861 | // Copy the rate set |
| 2862 | sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len); |
| 2863 | sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN; |
| 2864 | memcpy(sFrame.pSuppRates, |
| 2865 | pCurrSuppRates, |
| 2866 | ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN |
| 2867 | ); |
| 2868 | // DS parameter |
| 2869 | if (pDevice->byBBType != BB_TYPE_11A) { |
| 2870 | sFrame.pDSParms = (PWLAN_IE_DS_PARMS)(sFrame.pBuf + sFrame.len); |
| 2871 | sFrame.len += (1) + WLAN_IEHDR_LEN; |
| 2872 | sFrame.pDSParms->byElementID = WLAN_EID_DS_PARMS; |
| 2873 | sFrame.pDSParms->len = 1; |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 2874 | sFrame.pDSParms->byCurrChannel = (u8)uCurrChannel; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2875 | } |
| 2876 | // TIM field |
| 2877 | if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { |
| 2878 | sFrame.pTIM = (PWLAN_IE_TIM)(sFrame.pBuf + sFrame.len); |
| 2879 | sFrame.pTIM->byElementID = WLAN_EID_TIM; |
| 2880 | s_vMgrFormatTIM(pMgmt, sFrame.pTIM); |
| 2881 | sFrame.len += (WLAN_IEHDR_LEN + sFrame.pTIM->len); |
| 2882 | } |
| 2883 | |
| 2884 | if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) { |
| 2885 | |
| 2886 | // IBSS parameter |
| 2887 | sFrame.pIBSSParms = (PWLAN_IE_IBSS_PARMS)(sFrame.pBuf + sFrame.len); |
| 2888 | sFrame.len += (2) + WLAN_IEHDR_LEN; |
| 2889 | sFrame.pIBSSParms->byElementID = WLAN_EID_IBSS_PARMS; |
| 2890 | sFrame.pIBSSParms->len = 2; |
| 2891 | sFrame.pIBSSParms->wATIMWindow = wCurrATIMWinodw; |
| 2892 | if (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) { |
| 2893 | /* RSN parameter */ |
| 2894 | sFrame.pRSNWPA = (PWLAN_IE_RSN_EXT)(sFrame.pBuf + sFrame.len); |
| 2895 | sFrame.pRSNWPA->byElementID = WLAN_EID_RSN_WPA; |
| 2896 | sFrame.pRSNWPA->len = 12; |
| 2897 | sFrame.pRSNWPA->abyOUI[0] = 0x00; |
| 2898 | sFrame.pRSNWPA->abyOUI[1] = 0x50; |
| 2899 | sFrame.pRSNWPA->abyOUI[2] = 0xf2; |
| 2900 | sFrame.pRSNWPA->abyOUI[3] = 0x01; |
| 2901 | sFrame.pRSNWPA->wVersion = 1; |
| 2902 | sFrame.pRSNWPA->abyMulticast[0] = 0x00; |
| 2903 | sFrame.pRSNWPA->abyMulticast[1] = 0x50; |
| 2904 | sFrame.pRSNWPA->abyMulticast[2] = 0xf2; |
| 2905 | if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) |
| 2906 | sFrame.pRSNWPA->abyMulticast[3] = 0x04;//AES |
| 2907 | else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) |
| 2908 | sFrame.pRSNWPA->abyMulticast[3] = 0x02;//TKIP |
| 2909 | else if (pDevice->eEncryptionStatus == Ndis802_11Encryption1Enabled) |
| 2910 | sFrame.pRSNWPA->abyMulticast[3] = 0x01;//WEP40 |
| 2911 | else |
| 2912 | sFrame.pRSNWPA->abyMulticast[3] = 0x00;//NONE |
| 2913 | |
| 2914 | // Pairwise Key Cipher Suite |
| 2915 | sFrame.pRSNWPA->wPKCount = 0; |
| 2916 | // Auth Key Management Suite |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 2917 | *((u16 *)(sFrame.pBuf + sFrame.len + sFrame.pRSNWPA->len))=0; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2918 | sFrame.pRSNWPA->len +=2; |
| 2919 | |
| 2920 | // RSN Capabilites |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 2921 | *((u16 *)(sFrame.pBuf + sFrame.len + sFrame.pRSNWPA->len))=0; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2922 | sFrame.pRSNWPA->len +=2; |
| 2923 | sFrame.len += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN; |
| 2924 | } |
| 2925 | } |
| 2926 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2927 | if (pMgmt->eCurrentPHYMode == PHY_TYPE_11G) { |
| 2928 | sFrame.pERP = (PWLAN_IE_ERP)(sFrame.pBuf + sFrame.len); |
| 2929 | sFrame.len += 1 + WLAN_IEHDR_LEN; |
| 2930 | sFrame.pERP->byElementID = WLAN_EID_ERP; |
| 2931 | sFrame.pERP->len = 1; |
| 2932 | sFrame.pERP->byContext = 0; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2933 | if (pDevice->bProtectMode == true) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2934 | sFrame.pERP->byContext |= WLAN_EID_ERP_USE_PROTECTION; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2935 | if (pDevice->bNonERPPresent == true) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2936 | sFrame.pERP->byContext |= WLAN_EID_ERP_NONERP_PRESENT; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2937 | if (pDevice->bBarkerPreambleMd == true) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2938 | sFrame.pERP->byContext |= WLAN_EID_ERP_BARKER_MODE; |
| 2939 | } |
| 2940 | if (((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len != 0) { |
| 2941 | sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len); |
| 2942 | sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN; |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 2943 | memcpy(sFrame.pExtSuppRates, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2944 | pCurrExtSuppRates, |
| 2945 | ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN |
| 2946 | ); |
| 2947 | } |
| 2948 | // hostapd wpa/wpa2 IE |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2949 | if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && (pDevice->bEnableHostapd == true)) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2950 | if (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) { |
| 2951 | if (pMgmt->wWPAIELen != 0) { |
| 2952 | sFrame.pRSN = (PWLAN_IE_RSN)(sFrame.pBuf + sFrame.len); |
| 2953 | memcpy(sFrame.pRSN, pMgmt->abyWPAIE, pMgmt->wWPAIELen); |
| 2954 | sFrame.len += pMgmt->wWPAIELen; |
| 2955 | } |
| 2956 | } |
| 2957 | } |
| 2958 | |
| 2959 | /* Adjust the length fields */ |
| 2960 | pTxPacket->cbMPDULen = sFrame.len; |
| 2961 | pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; |
| 2962 | |
| 2963 | return pTxPacket; |
| 2964 | } |
| 2965 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2966 | /*+ |
| 2967 | * |
| 2968 | * Routine Description: |
| 2969 | * Constructs an Prob-response frame |
| 2970 | * |
| 2971 | * |
| 2972 | * Return Value: |
Justin P. Mattock | a0a1f61 | 2012-08-26 08:16:43 -0700 | [diff] [blame] | 2973 | * PTR to frame; or NULL on allocation failure |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2974 | * |
| 2975 | -*/ |
| 2976 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 2977 | struct vnt_tx_mgmt *s_MgrMakeProbeResponse(struct vnt_private *pDevice, |
| 2978 | struct vnt_manager *pMgmt, u16 wCurrCapInfo, u16 wCurrBeaconPeriod, |
| 2979 | u32 uCurrChannel, u16 wCurrATIMWinodw, u8 *pDstAddr, |
| 2980 | PWLAN_IE_SSID pCurrSSID, u8 *pCurrBSSID, |
| 2981 | PWLAN_IE_SUPP_RATES pCurrSuppRates, |
| 2982 | PWLAN_IE_SUPP_RATES pCurrExtSuppRates, u8 byPHYType) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2983 | { |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 2984 | struct vnt_tx_mgmt *pTxPacket = NULL; |
| 2985 | WLAN_FR_PROBERESP sFrame; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2986 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 2987 | pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool; |
| 2988 | memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt) |
| 2989 | + WLAN_PROBERESP_FR_MAXLEN); |
| 2990 | pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket |
| 2991 | + sizeof(struct vnt_tx_mgmt)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2992 | // Setup the sFrame structure. |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 2993 | sFrame.pBuf = (u8 *)pTxPacket->p80211Header; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2994 | sFrame.len = WLAN_PROBERESP_FR_MAXLEN; |
| 2995 | vMgrEncodeProbeResponse(&sFrame); |
| 2996 | // Setup the header |
| 2997 | sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16( |
| 2998 | ( |
| 2999 | WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) | |
| 3000 | WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_PROBERESP) |
| 3001 | )); |
| 3002 | memcpy( sFrame.pHdr->sA3.abyAddr1, pDstAddr, WLAN_ADDR_LEN); |
| 3003 | memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN); |
| 3004 | memcpy( sFrame.pHdr->sA3.abyAddr3, pCurrBSSID, WLAN_BSSID_LEN); |
| 3005 | *sFrame.pwBeaconInterval = cpu_to_le16(wCurrBeaconPeriod); |
| 3006 | *sFrame.pwCapInfo = cpu_to_le16(wCurrCapInfo); |
| 3007 | |
| 3008 | if (byPHYType == BB_TYPE_11B) { |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 3009 | *sFrame.pwCapInfo &= cpu_to_le16((u16)~(WLAN_SET_CAP_INFO_SHORTSLOTTIME(1))); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3010 | } |
| 3011 | |
| 3012 | // Copy SSID |
| 3013 | sFrame.pSSID = (PWLAN_IE_SSID)(sFrame.pBuf + sFrame.len); |
| 3014 | sFrame.len += ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len + WLAN_IEHDR_LEN; |
| 3015 | memcpy(sFrame.pSSID, |
| 3016 | pCurrSSID, |
| 3017 | ((PWLAN_IE_SSID)pCurrSSID)->len + WLAN_IEHDR_LEN |
| 3018 | ); |
| 3019 | // Copy the rate set |
| 3020 | sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len); |
| 3021 | |
| 3022 | sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN; |
| 3023 | memcpy(sFrame.pSuppRates, |
| 3024 | pCurrSuppRates, |
| 3025 | ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN |
| 3026 | ); |
| 3027 | |
| 3028 | // DS parameter |
| 3029 | if (pDevice->byBBType != BB_TYPE_11A) { |
| 3030 | sFrame.pDSParms = (PWLAN_IE_DS_PARMS)(sFrame.pBuf + sFrame.len); |
| 3031 | sFrame.len += (1) + WLAN_IEHDR_LEN; |
| 3032 | sFrame.pDSParms->byElementID = WLAN_EID_DS_PARMS; |
| 3033 | sFrame.pDSParms->len = 1; |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 3034 | sFrame.pDSParms->byCurrChannel = (u8)uCurrChannel; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3035 | } |
| 3036 | |
| 3037 | if (pMgmt->eCurrMode != WMAC_MODE_ESS_AP) { |
| 3038 | // IBSS parameter |
| 3039 | sFrame.pIBSSParms = (PWLAN_IE_IBSS_PARMS)(sFrame.pBuf + sFrame.len); |
| 3040 | sFrame.len += (2) + WLAN_IEHDR_LEN; |
| 3041 | sFrame.pIBSSParms->byElementID = WLAN_EID_IBSS_PARMS; |
| 3042 | sFrame.pIBSSParms->len = 2; |
| 3043 | sFrame.pIBSSParms->wATIMWindow = 0; |
| 3044 | } |
| 3045 | if (pDevice->byBBType == BB_TYPE_11G) { |
| 3046 | sFrame.pERP = (PWLAN_IE_ERP)(sFrame.pBuf + sFrame.len); |
| 3047 | sFrame.len += 1 + WLAN_IEHDR_LEN; |
| 3048 | sFrame.pERP->byElementID = WLAN_EID_ERP; |
| 3049 | sFrame.pERP->len = 1; |
| 3050 | sFrame.pERP->byContext = 0; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 3051 | if (pDevice->bProtectMode == true) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3052 | sFrame.pERP->byContext |= WLAN_EID_ERP_USE_PROTECTION; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 3053 | if (pDevice->bNonERPPresent == true) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3054 | sFrame.pERP->byContext |= WLAN_EID_ERP_NONERP_PRESENT; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 3055 | if (pDevice->bBarkerPreambleMd == true) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3056 | sFrame.pERP->byContext |= WLAN_EID_ERP_BARKER_MODE; |
| 3057 | } |
| 3058 | |
| 3059 | if (((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len != 0) { |
| 3060 | sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len); |
| 3061 | sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN; |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 3062 | memcpy(sFrame.pExtSuppRates, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3063 | pCurrExtSuppRates, |
| 3064 | ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN |
| 3065 | ); |
| 3066 | } |
| 3067 | |
| 3068 | // hostapd wpa/wpa2 IE |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 3069 | if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && (pDevice->bEnableHostapd == true)) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3070 | if (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) { |
| 3071 | if (pMgmt->wWPAIELen != 0) { |
| 3072 | sFrame.pRSN = (PWLAN_IE_RSN)(sFrame.pBuf + sFrame.len); |
| 3073 | memcpy(sFrame.pRSN, pMgmt->abyWPAIE, pMgmt->wWPAIELen); |
| 3074 | sFrame.len += pMgmt->wWPAIELen; |
| 3075 | } |
| 3076 | } |
| 3077 | } |
| 3078 | |
| 3079 | // Adjust the length fields |
| 3080 | pTxPacket->cbMPDULen = sFrame.len; |
| 3081 | pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; |
| 3082 | |
| 3083 | return pTxPacket; |
| 3084 | } |
| 3085 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3086 | /*+ |
| 3087 | * |
| 3088 | * Routine Description: |
| 3089 | * Constructs an association request frame |
| 3090 | * |
| 3091 | * |
| 3092 | * Return Value: |
Masanari Iida | a0ae9e3c | 2013-09-15 20:31:37 +0900 | [diff] [blame] | 3093 | * A ptr to frame or NULL on allocation failure |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3094 | * |
| 3095 | -*/ |
| 3096 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 3097 | struct vnt_tx_mgmt *s_MgrMakeAssocRequest(struct vnt_private *pDevice, |
| 3098 | struct vnt_manager *pMgmt, u8 *pDAddr, u16 wCurrCapInfo, |
| 3099 | u16 wListenInterval, |
| 3100 | PWLAN_IE_SSID pCurrSSID, |
| 3101 | PWLAN_IE_SUPP_RATES pCurrRates, |
| 3102 | PWLAN_IE_SUPP_RATES pCurrExtSuppRates) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3103 | { |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 3104 | struct vnt_tx_mgmt *pTxPacket = NULL; |
| 3105 | WLAN_FR_ASSOCREQ sFrame; |
| 3106 | u8 *pbyIEs; |
| 3107 | u8 *pbyRSN; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3108 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 3109 | pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool; |
| 3110 | memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt) |
| 3111 | + WLAN_ASSOCREQ_FR_MAXLEN); |
| 3112 | pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket |
| 3113 | + sizeof(struct vnt_tx_mgmt)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3114 | // Setup the sFrame structure. |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 3115 | sFrame.pBuf = (u8 *)pTxPacket->p80211Header; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3116 | sFrame.len = WLAN_ASSOCREQ_FR_MAXLEN; |
| 3117 | // format fixed field frame structure |
| 3118 | vMgrEncodeAssocRequest(&sFrame); |
| 3119 | // Setup the header |
| 3120 | sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16( |
| 3121 | ( |
| 3122 | WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) | |
| 3123 | WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ASSOCREQ) |
| 3124 | )); |
| 3125 | memcpy( sFrame.pHdr->sA3.abyAddr1, pDAddr, WLAN_ADDR_LEN); |
| 3126 | memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN); |
| 3127 | memcpy( sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); |
| 3128 | |
Justin P. Mattock | a0a1f61 | 2012-08-26 08:16:43 -0700 | [diff] [blame] | 3129 | // Set the capability and listen interval |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3130 | *(sFrame.pwCapInfo) = cpu_to_le16(wCurrCapInfo); |
| 3131 | *(sFrame.pwListenInterval) = cpu_to_le16(wListenInterval); |
| 3132 | |
| 3133 | // sFrame.len point to end of fixed field |
| 3134 | sFrame.pSSID = (PWLAN_IE_SSID)(sFrame.pBuf + sFrame.len); |
| 3135 | sFrame.len += pCurrSSID->len + WLAN_IEHDR_LEN; |
| 3136 | memcpy(sFrame.pSSID, pCurrSSID, pCurrSSID->len + WLAN_IEHDR_LEN); |
| 3137 | |
| 3138 | pMgmt->sAssocInfo.AssocInfo.RequestIELength = pCurrSSID->len + WLAN_IEHDR_LEN; |
| 3139 | pMgmt->sAssocInfo.AssocInfo.OffsetRequestIEs = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION); |
| 3140 | pbyIEs = pMgmt->sAssocInfo.abyIEs; |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 3141 | memcpy(pbyIEs, pCurrSSID, pCurrSSID->len + WLAN_IEHDR_LEN); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3142 | pbyIEs += pCurrSSID->len + WLAN_IEHDR_LEN; |
| 3143 | |
| 3144 | // Copy the rate set |
| 3145 | sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len); |
| 3146 | if ((pDevice->byBBType == BB_TYPE_11B) && (pCurrRates->len > 4)) |
| 3147 | sFrame.len += 4 + WLAN_IEHDR_LEN; |
| 3148 | else |
| 3149 | sFrame.len += pCurrRates->len + WLAN_IEHDR_LEN; |
| 3150 | memcpy(sFrame.pSuppRates, pCurrRates, pCurrRates->len + WLAN_IEHDR_LEN); |
| 3151 | |
| 3152 | // Copy the extension rate set |
| 3153 | if ((pDevice->byBBType == BB_TYPE_11G) && (pCurrExtSuppRates->len > 0)) { |
| 3154 | sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len); |
| 3155 | sFrame.len += pCurrExtSuppRates->len + WLAN_IEHDR_LEN; |
| 3156 | memcpy(sFrame.pExtSuppRates, pCurrExtSuppRates, pCurrExtSuppRates->len + WLAN_IEHDR_LEN); |
| 3157 | } |
| 3158 | |
| 3159 | pMgmt->sAssocInfo.AssocInfo.RequestIELength += pCurrRates->len + WLAN_IEHDR_LEN; |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 3160 | memcpy(pbyIEs, pCurrRates, pCurrRates->len + WLAN_IEHDR_LEN); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3161 | pbyIEs += pCurrRates->len + WLAN_IEHDR_LEN; |
| 3162 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3163 | if (((pMgmt->eAuthenMode == WMAC_AUTH_WPA) || |
| 3164 | (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) || |
| 3165 | (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE)) && |
| 3166 | (pMgmt->pCurrBSS != NULL)) { |
| 3167 | /* WPA IE */ |
| 3168 | sFrame.pRSNWPA = (PWLAN_IE_RSN_EXT)(sFrame.pBuf + sFrame.len); |
| 3169 | sFrame.pRSNWPA->byElementID = WLAN_EID_RSN_WPA; |
| 3170 | sFrame.pRSNWPA->len = 16; |
| 3171 | sFrame.pRSNWPA->abyOUI[0] = 0x00; |
| 3172 | sFrame.pRSNWPA->abyOUI[1] = 0x50; |
| 3173 | sFrame.pRSNWPA->abyOUI[2] = 0xf2; |
| 3174 | sFrame.pRSNWPA->abyOUI[3] = 0x01; |
| 3175 | sFrame.pRSNWPA->wVersion = 1; |
| 3176 | //Group Key Cipher Suite |
| 3177 | sFrame.pRSNWPA->abyMulticast[0] = 0x00; |
| 3178 | sFrame.pRSNWPA->abyMulticast[1] = 0x50; |
| 3179 | sFrame.pRSNWPA->abyMulticast[2] = 0xf2; |
| 3180 | if (pMgmt->byCSSGK == KEY_CTL_WEP) { |
| 3181 | sFrame.pRSNWPA->abyMulticast[3] = pMgmt->pCurrBSS->byGKType; |
| 3182 | } else if (pMgmt->byCSSGK == KEY_CTL_TKIP) { |
| 3183 | sFrame.pRSNWPA->abyMulticast[3] = WPA_TKIP; |
| 3184 | } else if (pMgmt->byCSSGK == KEY_CTL_CCMP) { |
| 3185 | sFrame.pRSNWPA->abyMulticast[3] = WPA_AESCCMP; |
| 3186 | } else { |
| 3187 | sFrame.pRSNWPA->abyMulticast[3] = WPA_NONE; |
| 3188 | } |
| 3189 | // Pairwise Key Cipher Suite |
| 3190 | sFrame.pRSNWPA->wPKCount = 1; |
| 3191 | sFrame.pRSNWPA->PKSList[0].abyOUI[0] = 0x00; |
| 3192 | sFrame.pRSNWPA->PKSList[0].abyOUI[1] = 0x50; |
| 3193 | sFrame.pRSNWPA->PKSList[0].abyOUI[2] = 0xf2; |
| 3194 | if (pMgmt->byCSSPK == KEY_CTL_TKIP) { |
| 3195 | sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_TKIP; |
| 3196 | } else if (pMgmt->byCSSPK == KEY_CTL_CCMP) { |
| 3197 | sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_AESCCMP; |
| 3198 | } else { |
| 3199 | sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_NONE; |
| 3200 | } |
| 3201 | // Auth Key Management Suite |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 3202 | pbyRSN = (u8 *)(sFrame.pBuf + sFrame.len + 2 + sFrame.pRSNWPA->len); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3203 | *pbyRSN++=0x01; |
| 3204 | *pbyRSN++=0x00; |
| 3205 | *pbyRSN++=0x00; |
| 3206 | |
| 3207 | *pbyRSN++=0x50; |
| 3208 | *pbyRSN++=0xf2; |
| 3209 | if (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) { |
| 3210 | *pbyRSN++=WPA_AUTH_PSK; |
| 3211 | } |
| 3212 | else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA) { |
| 3213 | *pbyRSN++=WPA_AUTH_IEEE802_1X; |
| 3214 | } |
| 3215 | else { |
| 3216 | *pbyRSN++=WPA_NONE; |
| 3217 | } |
| 3218 | |
| 3219 | sFrame.pRSNWPA->len +=6; |
| 3220 | |
| 3221 | // RSN Capabilites |
| 3222 | |
| 3223 | *pbyRSN++=0x00; |
| 3224 | *pbyRSN++=0x00; |
| 3225 | sFrame.pRSNWPA->len +=2; |
| 3226 | |
| 3227 | sFrame.len += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN; |
| 3228 | // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION |
| 3229 | pMgmt->sAssocInfo.AssocInfo.RequestIELength += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN; |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 3230 | memcpy(pbyIEs, sFrame.pRSNWPA, sFrame.pRSNWPA->len + WLAN_IEHDR_LEN); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3231 | pbyIEs += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN; |
| 3232 | |
| 3233 | } else if (((pMgmt->eAuthenMode == WMAC_AUTH_WPA2) || |
| 3234 | (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) && |
| 3235 | (pMgmt->pCurrBSS != NULL)) { |
Andres More | cc856e6 | 2010-05-17 21:34:01 -0300 | [diff] [blame] | 3236 | unsigned int ii; |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 3237 | u16 * pwPMKID; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3238 | |
| 3239 | // WPA IE |
| 3240 | sFrame.pRSN = (PWLAN_IE_RSN)(sFrame.pBuf + sFrame.len); |
| 3241 | sFrame.pRSN->byElementID = WLAN_EID_RSN; |
| 3242 | sFrame.pRSN->len = 6; //Version(2)+GK(4) |
| 3243 | sFrame.pRSN->wVersion = 1; |
| 3244 | //Group Key Cipher Suite |
| 3245 | sFrame.pRSN->abyRSN[0] = 0x00; |
| 3246 | sFrame.pRSN->abyRSN[1] = 0x0F; |
| 3247 | sFrame.pRSN->abyRSN[2] = 0xAC; |
| 3248 | if (pMgmt->byCSSGK == KEY_CTL_WEP) { |
| 3249 | sFrame.pRSN->abyRSN[3] = pMgmt->pCurrBSS->byCSSGK; |
| 3250 | } else if (pMgmt->byCSSGK == KEY_CTL_TKIP) { |
| 3251 | sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_TKIP; |
| 3252 | } else if (pMgmt->byCSSGK == KEY_CTL_CCMP) { |
| 3253 | sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_CCMP; |
| 3254 | } else { |
| 3255 | sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_UNKNOWN; |
| 3256 | } |
| 3257 | |
| 3258 | // Pairwise Key Cipher Suite |
| 3259 | sFrame.pRSN->abyRSN[4] = 1; |
| 3260 | sFrame.pRSN->abyRSN[5] = 0; |
| 3261 | sFrame.pRSN->abyRSN[6] = 0x00; |
| 3262 | sFrame.pRSN->abyRSN[7] = 0x0F; |
| 3263 | sFrame.pRSN->abyRSN[8] = 0xAC; |
| 3264 | if (pMgmt->byCSSPK == KEY_CTL_TKIP) { |
| 3265 | sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_TKIP; |
| 3266 | } else if (pMgmt->byCSSPK == KEY_CTL_CCMP) { |
| 3267 | sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_CCMP; |
| 3268 | } else if (pMgmt->byCSSPK == KEY_CTL_NONE) { |
| 3269 | sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_USE_GROUP; |
| 3270 | } else { |
| 3271 | sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_UNKNOWN; |
| 3272 | } |
| 3273 | sFrame.pRSN->len += 6; |
| 3274 | |
| 3275 | // Auth Key Management Suite |
| 3276 | sFrame.pRSN->abyRSN[10] = 1; |
| 3277 | sFrame.pRSN->abyRSN[11] = 0; |
| 3278 | sFrame.pRSN->abyRSN[12] = 0x00; |
| 3279 | sFrame.pRSN->abyRSN[13] = 0x0F; |
| 3280 | sFrame.pRSN->abyRSN[14] = 0xAC; |
| 3281 | if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK) { |
| 3282 | sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_PSK; |
| 3283 | } else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2) { |
| 3284 | sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_802_1X; |
| 3285 | } else { |
| 3286 | sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_UNKNOWN; |
| 3287 | } |
| 3288 | sFrame.pRSN->len +=6; |
| 3289 | |
| 3290 | // RSN Capabilites |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 3291 | if (pMgmt->pCurrBSS->sRSNCapObj.bRSNCapExist == true) { |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 3292 | memcpy(&sFrame.pRSN->abyRSN[16], &pMgmt->pCurrBSS->sRSNCapObj.wRSNCap, 2); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3293 | } else { |
| 3294 | sFrame.pRSN->abyRSN[16] = 0; |
| 3295 | sFrame.pRSN->abyRSN[17] = 0; |
| 3296 | } |
| 3297 | sFrame.pRSN->len +=2; |
| 3298 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 3299 | if ((pDevice->gsPMKID.BSSIDInfoCount > 0) && (pDevice->bRoaming == true) && (pMgmt->eAuthenMode == WMAC_AUTH_WPA2)) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3300 | // RSN PMKID |
| 3301 | pbyRSN = &sFrame.pRSN->abyRSN[18]; |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 3302 | pwPMKID = (u16 *)pbyRSN; // Point to PMKID count |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3303 | *pwPMKID = 0; // Initialize PMKID count |
| 3304 | pbyRSN += 2; // Point to PMKID list |
Andres More | 9a0e756 | 2010-04-13 21:54:48 -0300 | [diff] [blame] | 3305 | for (ii = 0; ii < pDevice->gsPMKID.BSSIDInfoCount; ii++) { |
| 3306 | if (!memcmp(&pDevice->gsPMKID.BSSIDInfo[ii].BSSID[0], |
| 3307 | pMgmt->abyCurrBSSID, |
| 3308 | ETH_ALEN)) { |
| 3309 | (*pwPMKID)++; |
| 3310 | memcpy(pbyRSN, |
| 3311 | pDevice->gsPMKID.BSSIDInfo[ii].PMKID, |
| 3312 | 16); |
| 3313 | pbyRSN += 16; |
| 3314 | } |
| 3315 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3316 | if (*pwPMKID != 0) { |
| 3317 | sFrame.pRSN->len += (2 + (*pwPMKID)*16); |
| 3318 | } |
| 3319 | } |
| 3320 | |
| 3321 | sFrame.len += sFrame.pRSN->len + WLAN_IEHDR_LEN; |
| 3322 | // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION |
| 3323 | pMgmt->sAssocInfo.AssocInfo.RequestIELength += sFrame.pRSN->len + WLAN_IEHDR_LEN; |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 3324 | memcpy(pbyIEs, sFrame.pRSN, sFrame.pRSN->len + WLAN_IEHDR_LEN); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3325 | pbyIEs += sFrame.pRSN->len + WLAN_IEHDR_LEN; |
| 3326 | } |
| 3327 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3328 | // Adjust the length fields |
| 3329 | pTxPacket->cbMPDULen = sFrame.len; |
| 3330 | pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; |
| 3331 | return pTxPacket; |
| 3332 | } |
| 3333 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3334 | /*+ |
| 3335 | * |
| 3336 | * Routine Description: |
| 3337 | * Constructs an re-association request frame |
| 3338 | * |
| 3339 | * |
| 3340 | * Return Value: |
Justin P. Mattock | a0a1f61 | 2012-08-26 08:16:43 -0700 | [diff] [blame] | 3341 | * A ptr to frame or NULL on allocation failure |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3342 | * |
| 3343 | -*/ |
| 3344 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 3345 | struct vnt_tx_mgmt *s_MgrMakeReAssocRequest(struct vnt_private *pDevice, |
| 3346 | struct vnt_manager *pMgmt, u8 *pDAddr, u16 wCurrCapInfo, |
| 3347 | u16 wListenInterval, PWLAN_IE_SSID pCurrSSID, |
| 3348 | PWLAN_IE_SUPP_RATES pCurrRates, |
| 3349 | PWLAN_IE_SUPP_RATES pCurrExtSuppRates) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3350 | { |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 3351 | struct vnt_tx_mgmt *pTxPacket = NULL; |
| 3352 | WLAN_FR_REASSOCREQ sFrame; |
| 3353 | u8 *pbyIEs; |
| 3354 | u8 *pbyRSN; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3355 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 3356 | pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool; |
| 3357 | memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt) |
| 3358 | + WLAN_REASSOCREQ_FR_MAXLEN); |
| 3359 | pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket |
| 3360 | + sizeof(struct vnt_tx_mgmt)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3361 | /* Setup the sFrame structure. */ |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 3362 | sFrame.pBuf = (u8 *)pTxPacket->p80211Header; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3363 | sFrame.len = WLAN_REASSOCREQ_FR_MAXLEN; |
| 3364 | |
| 3365 | // format fixed field frame structure |
| 3366 | vMgrEncodeReassocRequest(&sFrame); |
| 3367 | |
| 3368 | /* Setup the header */ |
| 3369 | sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16( |
| 3370 | ( |
| 3371 | WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) | |
| 3372 | WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_REASSOCREQ) |
| 3373 | )); |
| 3374 | memcpy( sFrame.pHdr->sA3.abyAddr1, pDAddr, WLAN_ADDR_LEN); |
| 3375 | memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN); |
| 3376 | memcpy( sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); |
| 3377 | |
Justin P. Mattock | a0a1f61 | 2012-08-26 08:16:43 -0700 | [diff] [blame] | 3378 | /* Set the capability and listen interval */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3379 | *(sFrame.pwCapInfo) = cpu_to_le16(wCurrCapInfo); |
| 3380 | *(sFrame.pwListenInterval) = cpu_to_le16(wListenInterval); |
| 3381 | |
| 3382 | memcpy(sFrame.pAddrCurrAP, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); |
| 3383 | /* Copy the SSID */ |
| 3384 | /* sFrame.len point to end of fixed field */ |
| 3385 | sFrame.pSSID = (PWLAN_IE_SSID)(sFrame.pBuf + sFrame.len); |
| 3386 | sFrame.len += pCurrSSID->len + WLAN_IEHDR_LEN; |
| 3387 | memcpy(sFrame.pSSID, pCurrSSID, pCurrSSID->len + WLAN_IEHDR_LEN); |
| 3388 | |
| 3389 | pMgmt->sAssocInfo.AssocInfo.RequestIELength = pCurrSSID->len + WLAN_IEHDR_LEN; |
| 3390 | pMgmt->sAssocInfo.AssocInfo.OffsetRequestIEs = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION); |
| 3391 | pbyIEs = pMgmt->sAssocInfo.abyIEs; |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 3392 | memcpy(pbyIEs, pCurrSSID, pCurrSSID->len + WLAN_IEHDR_LEN); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3393 | pbyIEs += pCurrSSID->len + WLAN_IEHDR_LEN; |
| 3394 | |
| 3395 | /* Copy the rate set */ |
| 3396 | /* sFrame.len point to end of SSID */ |
| 3397 | sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len); |
| 3398 | sFrame.len += pCurrRates->len + WLAN_IEHDR_LEN; |
| 3399 | memcpy(sFrame.pSuppRates, pCurrRates, pCurrRates->len + WLAN_IEHDR_LEN); |
| 3400 | |
| 3401 | // Copy the extension rate set |
| 3402 | if ((pMgmt->eCurrentPHYMode == PHY_TYPE_11G) && (pCurrExtSuppRates->len > 0)) { |
| 3403 | sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len); |
| 3404 | sFrame.len += pCurrExtSuppRates->len + WLAN_IEHDR_LEN; |
| 3405 | memcpy(sFrame.pExtSuppRates, pCurrExtSuppRates, pCurrExtSuppRates->len + WLAN_IEHDR_LEN); |
| 3406 | } |
| 3407 | |
| 3408 | pMgmt->sAssocInfo.AssocInfo.RequestIELength += pCurrRates->len + WLAN_IEHDR_LEN; |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 3409 | memcpy(pbyIEs, pCurrRates, pCurrRates->len + WLAN_IEHDR_LEN); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3410 | pbyIEs += pCurrRates->len + WLAN_IEHDR_LEN; |
| 3411 | |
| 3412 | if (((pMgmt->eAuthenMode == WMAC_AUTH_WPA) || |
| 3413 | (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) || |
| 3414 | (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE)) && |
| 3415 | (pMgmt->pCurrBSS != NULL)) { |
| 3416 | /* WPA IE */ |
| 3417 | sFrame.pRSNWPA = (PWLAN_IE_RSN_EXT)(sFrame.pBuf + sFrame.len); |
| 3418 | sFrame.pRSNWPA->byElementID = WLAN_EID_RSN_WPA; |
| 3419 | sFrame.pRSNWPA->len = 16; |
| 3420 | sFrame.pRSNWPA->abyOUI[0] = 0x00; |
| 3421 | sFrame.pRSNWPA->abyOUI[1] = 0x50; |
| 3422 | sFrame.pRSNWPA->abyOUI[2] = 0xf2; |
| 3423 | sFrame.pRSNWPA->abyOUI[3] = 0x01; |
| 3424 | sFrame.pRSNWPA->wVersion = 1; |
| 3425 | //Group Key Cipher Suite |
| 3426 | sFrame.pRSNWPA->abyMulticast[0] = 0x00; |
| 3427 | sFrame.pRSNWPA->abyMulticast[1] = 0x50; |
| 3428 | sFrame.pRSNWPA->abyMulticast[2] = 0xf2; |
| 3429 | if (pMgmt->byCSSGK == KEY_CTL_WEP) { |
| 3430 | sFrame.pRSNWPA->abyMulticast[3] = pMgmt->pCurrBSS->byGKType; |
| 3431 | } else if (pMgmt->byCSSGK == KEY_CTL_TKIP) { |
| 3432 | sFrame.pRSNWPA->abyMulticast[3] = WPA_TKIP; |
| 3433 | } else if (pMgmt->byCSSGK == KEY_CTL_CCMP) { |
| 3434 | sFrame.pRSNWPA->abyMulticast[3] = WPA_AESCCMP; |
| 3435 | } else { |
| 3436 | sFrame.pRSNWPA->abyMulticast[3] = WPA_NONE; |
| 3437 | } |
| 3438 | // Pairwise Key Cipher Suite |
| 3439 | sFrame.pRSNWPA->wPKCount = 1; |
| 3440 | sFrame.pRSNWPA->PKSList[0].abyOUI[0] = 0x00; |
| 3441 | sFrame.pRSNWPA->PKSList[0].abyOUI[1] = 0x50; |
| 3442 | sFrame.pRSNWPA->PKSList[0].abyOUI[2] = 0xf2; |
| 3443 | if (pMgmt->byCSSPK == KEY_CTL_TKIP) { |
| 3444 | sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_TKIP; |
| 3445 | } else if (pMgmt->byCSSPK == KEY_CTL_CCMP) { |
| 3446 | sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_AESCCMP; |
| 3447 | } else { |
| 3448 | sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_NONE; |
| 3449 | } |
| 3450 | // Auth Key Management Suite |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 3451 | pbyRSN = (u8 *)(sFrame.pBuf + sFrame.len + 2 + sFrame.pRSNWPA->len); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3452 | *pbyRSN++=0x01; |
| 3453 | *pbyRSN++=0x00; |
| 3454 | *pbyRSN++=0x00; |
| 3455 | |
| 3456 | *pbyRSN++=0x50; |
| 3457 | *pbyRSN++=0xf2; |
| 3458 | if (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) { |
| 3459 | *pbyRSN++=WPA_AUTH_PSK; |
| 3460 | } else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA) { |
| 3461 | *pbyRSN++=WPA_AUTH_IEEE802_1X; |
| 3462 | } else { |
| 3463 | *pbyRSN++=WPA_NONE; |
| 3464 | } |
| 3465 | |
| 3466 | sFrame.pRSNWPA->len +=6; |
| 3467 | |
| 3468 | // RSN Capabilites |
| 3469 | *pbyRSN++=0x00; |
| 3470 | *pbyRSN++=0x00; |
| 3471 | sFrame.pRSNWPA->len +=2; |
| 3472 | |
| 3473 | sFrame.len += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN; |
| 3474 | // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION |
| 3475 | pMgmt->sAssocInfo.AssocInfo.RequestIELength += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN; |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 3476 | memcpy(pbyIEs, sFrame.pRSNWPA, sFrame.pRSNWPA->len + WLAN_IEHDR_LEN); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3477 | pbyIEs += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN; |
| 3478 | |
| 3479 | } else if (((pMgmt->eAuthenMode == WMAC_AUTH_WPA2) || |
| 3480 | (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) && |
| 3481 | (pMgmt->pCurrBSS != NULL)) { |
Andres More | cc856e6 | 2010-05-17 21:34:01 -0300 | [diff] [blame] | 3482 | unsigned int ii; |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 3483 | u16 * pwPMKID; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3484 | |
| 3485 | /* WPA IE */ |
| 3486 | sFrame.pRSN = (PWLAN_IE_RSN)(sFrame.pBuf + sFrame.len); |
| 3487 | sFrame.pRSN->byElementID = WLAN_EID_RSN; |
| 3488 | sFrame.pRSN->len = 6; //Version(2)+GK(4) |
| 3489 | sFrame.pRSN->wVersion = 1; |
| 3490 | //Group Key Cipher Suite |
| 3491 | sFrame.pRSN->abyRSN[0] = 0x00; |
| 3492 | sFrame.pRSN->abyRSN[1] = 0x0F; |
| 3493 | sFrame.pRSN->abyRSN[2] = 0xAC; |
| 3494 | if (pMgmt->byCSSGK == KEY_CTL_WEP) { |
| 3495 | sFrame.pRSN->abyRSN[3] = pMgmt->pCurrBSS->byCSSGK; |
| 3496 | } else if (pMgmt->byCSSGK == KEY_CTL_TKIP) { |
| 3497 | sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_TKIP; |
| 3498 | } else if (pMgmt->byCSSGK == KEY_CTL_CCMP) { |
| 3499 | sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_CCMP; |
| 3500 | } else { |
| 3501 | sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_UNKNOWN; |
| 3502 | } |
| 3503 | |
| 3504 | // Pairwise Key Cipher Suite |
| 3505 | sFrame.pRSN->abyRSN[4] = 1; |
| 3506 | sFrame.pRSN->abyRSN[5] = 0; |
| 3507 | sFrame.pRSN->abyRSN[6] = 0x00; |
| 3508 | sFrame.pRSN->abyRSN[7] = 0x0F; |
| 3509 | sFrame.pRSN->abyRSN[8] = 0xAC; |
| 3510 | if (pMgmt->byCSSPK == KEY_CTL_TKIP) { |
| 3511 | sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_TKIP; |
| 3512 | } else if (pMgmt->byCSSPK == KEY_CTL_CCMP) { |
| 3513 | sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_CCMP; |
| 3514 | } else if (pMgmt->byCSSPK == KEY_CTL_NONE) { |
| 3515 | sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_USE_GROUP; |
| 3516 | } else { |
| 3517 | sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_UNKNOWN; |
| 3518 | } |
| 3519 | sFrame.pRSN->len += 6; |
| 3520 | |
| 3521 | // Auth Key Management Suite |
| 3522 | sFrame.pRSN->abyRSN[10] = 1; |
| 3523 | sFrame.pRSN->abyRSN[11] = 0; |
| 3524 | sFrame.pRSN->abyRSN[12] = 0x00; |
| 3525 | sFrame.pRSN->abyRSN[13] = 0x0F; |
| 3526 | sFrame.pRSN->abyRSN[14] = 0xAC; |
| 3527 | if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK) { |
| 3528 | sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_PSK; |
| 3529 | } else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2) { |
| 3530 | sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_802_1X; |
| 3531 | } else { |
| 3532 | sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_UNKNOWN; |
| 3533 | } |
| 3534 | sFrame.pRSN->len +=6; |
| 3535 | |
| 3536 | // RSN Capabilites |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 3537 | if (pMgmt->pCurrBSS->sRSNCapObj.bRSNCapExist == true) { |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 3538 | memcpy(&sFrame.pRSN->abyRSN[16], &pMgmt->pCurrBSS->sRSNCapObj.wRSNCap, 2); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3539 | } else { |
| 3540 | sFrame.pRSN->abyRSN[16] = 0; |
| 3541 | sFrame.pRSN->abyRSN[17] = 0; |
| 3542 | } |
| 3543 | sFrame.pRSN->len +=2; |
| 3544 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 3545 | if ((pDevice->gsPMKID.BSSIDInfoCount > 0) && (pDevice->bRoaming == true) && (pMgmt->eAuthenMode == WMAC_AUTH_WPA2)) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3546 | // RSN PMKID |
| 3547 | pbyRSN = &sFrame.pRSN->abyRSN[18]; |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 3548 | pwPMKID = (u16 *)pbyRSN; // Point to PMKID count |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3549 | *pwPMKID = 0; // Initialize PMKID count |
| 3550 | pbyRSN += 2; // Point to PMKID list |
| 3551 | for (ii = 0; ii < pDevice->gsPMKID.BSSIDInfoCount; ii++) { |
Andres More | 9a0e756 | 2010-04-13 21:54:48 -0300 | [diff] [blame] | 3552 | if (!memcmp(&pDevice->gsPMKID.BSSIDInfo[ii].BSSID[0], |
| 3553 | pMgmt->abyCurrBSSID, |
| 3554 | ETH_ALEN)) { |
| 3555 | (*pwPMKID)++; |
| 3556 | memcpy(pbyRSN, |
| 3557 | pDevice->gsPMKID.BSSIDInfo[ii].PMKID, |
| 3558 | 16); |
| 3559 | pbyRSN += 16; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3560 | } |
| 3561 | } |
| 3562 | if (*pwPMKID != 0) { |
| 3563 | sFrame.pRSN->len += (2 + (*pwPMKID)*16); |
| 3564 | } |
| 3565 | } |
| 3566 | |
| 3567 | sFrame.len += sFrame.pRSN->len + WLAN_IEHDR_LEN; |
| 3568 | // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION |
| 3569 | pMgmt->sAssocInfo.AssocInfo.RequestIELength += sFrame.pRSN->len + WLAN_IEHDR_LEN; |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 3570 | memcpy(pbyIEs, sFrame.pRSN, sFrame.pRSN->len + WLAN_IEHDR_LEN); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3571 | pbyIEs += sFrame.pRSN->len + WLAN_IEHDR_LEN; |
| 3572 | } |
| 3573 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3574 | /* Adjust the length fields */ |
| 3575 | pTxPacket->cbMPDULen = sFrame.len; |
| 3576 | pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; |
| 3577 | |
| 3578 | return pTxPacket; |
| 3579 | } |
| 3580 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3581 | /*+ |
| 3582 | * |
| 3583 | * Routine Description: |
| 3584 | * Constructs an assoc-response frame |
| 3585 | * |
| 3586 | * |
| 3587 | * Return Value: |
Justin P. Mattock | a0a1f61 | 2012-08-26 08:16:43 -0700 | [diff] [blame] | 3588 | * PTR to frame; or NULL on allocation failure |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3589 | * |
| 3590 | -*/ |
| 3591 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 3592 | struct vnt_tx_mgmt *s_MgrMakeAssocResponse(struct vnt_private *pDevice, |
| 3593 | struct vnt_manager *pMgmt, u16 wCurrCapInfo, u16 wAssocStatus, |
| 3594 | u16 wAssocAID, u8 *pDstAddr, PWLAN_IE_SUPP_RATES pCurrSuppRates, |
| 3595 | PWLAN_IE_SUPP_RATES pCurrExtSuppRates) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3596 | { |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 3597 | struct vnt_tx_mgmt *pTxPacket = NULL; |
| 3598 | WLAN_FR_ASSOCRESP sFrame; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3599 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 3600 | pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool; |
| 3601 | memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt) |
| 3602 | + WLAN_ASSOCREQ_FR_MAXLEN); |
| 3603 | pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket |
| 3604 | + sizeof(struct vnt_tx_mgmt)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3605 | // Setup the sFrame structure |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 3606 | sFrame.pBuf = (u8 *)pTxPacket->p80211Header; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3607 | sFrame.len = WLAN_REASSOCRESP_FR_MAXLEN; |
| 3608 | vMgrEncodeAssocResponse(&sFrame); |
| 3609 | // Setup the header |
| 3610 | sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16( |
| 3611 | ( |
| 3612 | WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) | |
| 3613 | WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ASSOCRESP) |
| 3614 | )); |
| 3615 | memcpy( sFrame.pHdr->sA3.abyAddr1, pDstAddr, WLAN_ADDR_LEN); |
| 3616 | memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN); |
| 3617 | memcpy( sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); |
| 3618 | |
| 3619 | *sFrame.pwCapInfo = cpu_to_le16(wCurrCapInfo); |
| 3620 | *sFrame.pwStatus = cpu_to_le16(wAssocStatus); |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 3621 | *sFrame.pwAid = cpu_to_le16((u16)(wAssocAID | BIT14 | BIT15)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3622 | |
| 3623 | // Copy the rate set |
| 3624 | sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len); |
| 3625 | sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN; |
| 3626 | memcpy(sFrame.pSuppRates, |
| 3627 | pCurrSuppRates, |
| 3628 | ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN |
| 3629 | ); |
| 3630 | |
| 3631 | if (((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len != 0) { |
| 3632 | sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len); |
| 3633 | sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN; |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 3634 | memcpy(sFrame.pExtSuppRates, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3635 | pCurrExtSuppRates, |
| 3636 | ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN |
| 3637 | ); |
| 3638 | } |
| 3639 | |
| 3640 | // Adjust the length fields |
| 3641 | pTxPacket->cbMPDULen = sFrame.len; |
| 3642 | pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; |
| 3643 | |
| 3644 | return pTxPacket; |
| 3645 | } |
| 3646 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3647 | /*+ |
| 3648 | * |
| 3649 | * Routine Description: |
| 3650 | * Constructs an reassoc-response frame |
| 3651 | * |
| 3652 | * |
| 3653 | * Return Value: |
Justin P. Mattock | a0a1f61 | 2012-08-26 08:16:43 -0700 | [diff] [blame] | 3654 | * PTR to frame; or NULL on allocation failure |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3655 | * |
| 3656 | -*/ |
| 3657 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 3658 | struct vnt_tx_mgmt *s_MgrMakeReAssocResponse(struct vnt_private *pDevice, |
| 3659 | struct vnt_manager *pMgmt, u16 wCurrCapInfo, u16 wAssocStatus, |
| 3660 | u16 wAssocAID, u8 *pDstAddr, PWLAN_IE_SUPP_RATES pCurrSuppRates, |
| 3661 | PWLAN_IE_SUPP_RATES pCurrExtSuppRates) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3662 | { |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 3663 | struct vnt_tx_mgmt *pTxPacket = NULL; |
| 3664 | WLAN_FR_REASSOCRESP sFrame; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3665 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 3666 | pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool; |
| 3667 | memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt) |
| 3668 | + WLAN_ASSOCREQ_FR_MAXLEN); |
| 3669 | pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket |
| 3670 | + sizeof(struct vnt_tx_mgmt)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3671 | // Setup the sFrame structure |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 3672 | sFrame.pBuf = (u8 *)pTxPacket->p80211Header; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3673 | sFrame.len = WLAN_REASSOCRESP_FR_MAXLEN; |
| 3674 | vMgrEncodeReassocResponse(&sFrame); |
| 3675 | // Setup the header |
| 3676 | sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16( |
| 3677 | ( |
| 3678 | WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) | |
| 3679 | WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_REASSOCRESP) |
| 3680 | )); |
| 3681 | memcpy( sFrame.pHdr->sA3.abyAddr1, pDstAddr, WLAN_ADDR_LEN); |
| 3682 | memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN); |
| 3683 | memcpy( sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); |
| 3684 | |
| 3685 | *sFrame.pwCapInfo = cpu_to_le16(wCurrCapInfo); |
| 3686 | *sFrame.pwStatus = cpu_to_le16(wAssocStatus); |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 3687 | *sFrame.pwAid = cpu_to_le16((u16)(wAssocAID | BIT14 | BIT15)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3688 | |
| 3689 | // Copy the rate set |
| 3690 | sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len); |
| 3691 | sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN; |
| 3692 | memcpy(sFrame.pSuppRates, |
| 3693 | pCurrSuppRates, |
| 3694 | ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN |
| 3695 | ); |
| 3696 | |
| 3697 | if (((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len != 0) { |
| 3698 | sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len); |
| 3699 | sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN; |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 3700 | memcpy(sFrame.pExtSuppRates, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3701 | pCurrExtSuppRates, |
| 3702 | ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN |
| 3703 | ); |
| 3704 | } |
| 3705 | |
| 3706 | // Adjust the length fields |
| 3707 | pTxPacket->cbMPDULen = sFrame.len; |
| 3708 | pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; |
| 3709 | |
| 3710 | return pTxPacket; |
| 3711 | } |
| 3712 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3713 | /*+ |
| 3714 | * |
| 3715 | * Routine Description: |
| 3716 | * Handles probe response management frames. |
| 3717 | * |
| 3718 | * |
| 3719 | * Return Value: |
| 3720 | * none. |
| 3721 | * |
| 3722 | -*/ |
| 3723 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 3724 | static void s_vMgrRxProbeResponse(struct vnt_private *pDevice, |
| 3725 | struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3726 | { |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 3727 | PKnownBSS pBSSList = NULL; |
| 3728 | WLAN_FR_PROBERESP sFrame; |
| 3729 | u8 byCurrChannel = pRxPacket->byRxChannel; |
| 3730 | ERPObject sERP; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 3731 | int bChannelHit = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3732 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3733 | memset(&sFrame, 0, sizeof(WLAN_FR_PROBERESP)); |
| 3734 | // decode the frame |
| 3735 | sFrame.len = pRxPacket->cbMPDULen; |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 3736 | sFrame.pBuf = (u8 *)pRxPacket->p80211Header; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3737 | vMgrDecodeProbeResponse(&sFrame); |
| 3738 | |
Andres More | 6e1b4e2 | 2010-05-04 20:40:11 -0300 | [diff] [blame] | 3739 | if ((sFrame.pqwTimestamp == NULL) |
| 3740 | || (sFrame.pwBeaconInterval == NULL) |
| 3741 | || (sFrame.pwCapInfo == NULL) |
| 3742 | || (sFrame.pSSID == NULL) |
| 3743 | || (sFrame.pSuppRates == NULL)) { |
| 3744 | |
| 3745 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe resp:Fail addr:[%p]\n", |
| 3746 | pRxPacket->p80211Header); |
Andres More | 6e1b4e2 | 2010-05-04 20:40:11 -0300 | [diff] [blame] | 3747 | return; |
Joe Perches | 9fc8602 | 2011-04-10 14:31:32 -0700 | [diff] [blame] | 3748 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3749 | |
| 3750 | if(sFrame.pSSID->len == 0) |
| 3751 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Rx Probe resp: SSID len = 0 \n"); |
| 3752 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3753 | //{{ RobertYu:20050201, 11a byCurrChannel != sFrame.pDSParms->byCurrChannel mapping |
| 3754 | if( byCurrChannel > CB_MAX_CHANNEL_24G ) |
| 3755 | { |
Andres More | 6e1b4e2 | 2010-05-04 20:40:11 -0300 | [diff] [blame] | 3756 | if (sFrame.pDSParms) { |
| 3757 | if (byCurrChannel == |
| 3758 | RFaby11aChannelIndex[sFrame.pDSParms->byCurrChannel-1]) |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 3759 | bChannelHit = true; |
Andres More | 6e1b4e2 | 2010-05-04 20:40:11 -0300 | [diff] [blame] | 3760 | byCurrChannel = |
| 3761 | RFaby11aChannelIndex[sFrame.pDSParms->byCurrChannel-1]; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3762 | } else { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 3763 | bChannelHit = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3764 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3765 | } else { |
Andres More | 6e1b4e2 | 2010-05-04 20:40:11 -0300 | [diff] [blame] | 3766 | if (sFrame.pDSParms) { |
| 3767 | if (byCurrChannel == sFrame.pDSParms->byCurrChannel) |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 3768 | bChannelHit = true; |
Andres More | 6e1b4e2 | 2010-05-04 20:40:11 -0300 | [diff] [blame] | 3769 | byCurrChannel = sFrame.pDSParms->byCurrChannel; |
| 3770 | } else { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 3771 | bChannelHit = true; |
Andres More | 6e1b4e2 | 2010-05-04 20:40:11 -0300 | [diff] [blame] | 3772 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3773 | } |
| 3774 | //RobertYu:20050201 |
| 3775 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 3776 | if(ChannelExceedZoneType(pDevice,byCurrChannel)==true) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3777 | return; |
| 3778 | |
Andres More | 6e1b4e2 | 2010-05-04 20:40:11 -0300 | [diff] [blame] | 3779 | if (sFrame.pERP) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3780 | sERP.byERP = sFrame.pERP->byContext; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 3781 | sERP.bERPExist = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3782 | } else { |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 3783 | sERP.bERPExist = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3784 | sERP.byERP = 0; |
| 3785 | } |
| 3786 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3787 | // update or insert the bss |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 3788 | pBSSList = BSSpAddrIsInBSSList((void *) pDevice, |
| 3789 | sFrame.pHdr->sA3.abyAddr3, |
| 3790 | sFrame.pSSID); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3791 | if (pBSSList) { |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 3792 | BSSbUpdateToBSSList((void *) pDevice, |
| 3793 | *sFrame.pqwTimestamp, |
| 3794 | *sFrame.pwBeaconInterval, |
| 3795 | *sFrame.pwCapInfo, |
| 3796 | byCurrChannel, |
| 3797 | bChannelHit, |
| 3798 | sFrame.pSSID, |
| 3799 | sFrame.pSuppRates, |
| 3800 | sFrame.pExtSuppRates, |
| 3801 | &sERP, |
| 3802 | sFrame.pRSN, |
| 3803 | sFrame.pRSNWPA, |
| 3804 | sFrame.pIE_Country, |
| 3805 | sFrame.pIE_Quiet, |
| 3806 | pBSSList, |
| 3807 | sFrame.len - WLAN_HDR_ADDR3_LEN, |
| 3808 | /* payload of probresponse */ |
| 3809 | sFrame.pHdr->sA4.abyAddr4, |
| 3810 | (void *) pRxPacket); |
| 3811 | } else { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3812 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Probe resp/insert: RxChannel = : %d\n", byCurrChannel); |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 3813 | BSSbInsertToBSSList((void *) pDevice, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3814 | sFrame.pHdr->sA3.abyAddr3, |
| 3815 | *sFrame.pqwTimestamp, |
| 3816 | *sFrame.pwBeaconInterval, |
| 3817 | *sFrame.pwCapInfo, |
| 3818 | byCurrChannel, |
| 3819 | sFrame.pSSID, |
| 3820 | sFrame.pSuppRates, |
| 3821 | sFrame.pExtSuppRates, |
| 3822 | &sERP, |
| 3823 | sFrame.pRSN, |
| 3824 | sFrame.pRSNWPA, |
| 3825 | sFrame.pIE_Country, |
| 3826 | sFrame.pIE_Quiet, |
| 3827 | sFrame.len - WLAN_HDR_ADDR3_LEN, |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 3828 | sFrame.pHdr->sA4.abyAddr4, /* payload of beacon */ |
| 3829 | (void *) pRxPacket); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3830 | } |
| 3831 | return; |
| 3832 | |
| 3833 | } |
| 3834 | |
| 3835 | /*+ |
| 3836 | * |
| 3837 | * Routine Description:(AP)or(Ad-hoc STA) |
| 3838 | * Handles probe request management frames. |
| 3839 | * |
| 3840 | * |
| 3841 | * Return Value: |
| 3842 | * none. |
| 3843 | * |
| 3844 | -*/ |
| 3845 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 3846 | static void s_vMgrRxProbeRequest(struct vnt_private *pDevice, |
| 3847 | struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3848 | { |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 3849 | WLAN_FR_PROBEREQ sFrame; |
| 3850 | CMD_STATUS Status; |
| 3851 | struct vnt_tx_mgmt *pTxPacket; |
| 3852 | u8 byPHYType = BB_TYPE_11B; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3853 | |
| 3854 | // STA in Ad-hoc mode: when latest TBTT beacon transmit success, |
| 3855 | // STA have to response this request. |
| 3856 | if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) || |
| 3857 | ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && pDevice->bBeaconSent)) { |
| 3858 | |
| 3859 | memset(&sFrame, 0, sizeof(WLAN_FR_PROBEREQ)); |
| 3860 | // decode the frame |
| 3861 | sFrame.len = pRxPacket->cbMPDULen; |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 3862 | sFrame.pBuf = (u8 *)pRxPacket->p80211Header; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3863 | vMgrDecodeProbeRequest(&sFrame); |
| 3864 | /* |
Andy Shevchenko | d6a32aa | 2011-07-26 10:35:31 +0300 | [diff] [blame] | 3865 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request rx:MAC addr:%pM\n", |
| 3866 | sFrame.pHdr->sA3.abyAddr2); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3867 | */ |
| 3868 | if (sFrame.pSSID->len != 0) { |
| 3869 | if (sFrame.pSSID->len != ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len) |
| 3870 | return; |
| 3871 | if (memcmp(sFrame.pSSID->abySSID, |
| 3872 | ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->abySSID, |
| 3873 | ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len) != 0) { |
| 3874 | return; |
| 3875 | } |
| 3876 | } |
| 3877 | |
| 3878 | if ((sFrame.pSuppRates->len > 4) || (sFrame.pExtSuppRates != NULL)) { |
| 3879 | byPHYType = BB_TYPE_11G; |
| 3880 | } |
| 3881 | |
| 3882 | // Probe response reply.. |
| 3883 | pTxPacket = s_MgrMakeProbeResponse |
| 3884 | ( |
| 3885 | pDevice, |
| 3886 | pMgmt, |
| 3887 | pMgmt->wCurrCapInfo, |
| 3888 | pMgmt->wCurrBeaconPeriod, |
| 3889 | pMgmt->uCurrChannel, |
| 3890 | 0, |
| 3891 | sFrame.pHdr->sA3.abyAddr2, |
| 3892 | (PWLAN_IE_SSID)pMgmt->abyCurrSSID, |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 3893 | (u8 *)pMgmt->abyCurrBSSID, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3894 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, |
| 3895 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates, |
| 3896 | byPHYType |
| 3897 | ); |
| 3898 | if (pTxPacket != NULL ){ |
| 3899 | /* send the frame */ |
| 3900 | Status = csMgmt_xmit(pDevice, pTxPacket); |
| 3901 | if (Status != CMD_STATUS_PENDING) { |
| 3902 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Probe response tx failed\n"); |
| 3903 | } |
| 3904 | else { |
| 3905 | // DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Probe response tx sending..\n"); |
| 3906 | } |
| 3907 | } |
| 3908 | } |
| 3909 | |
| 3910 | return; |
| 3911 | } |
| 3912 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3913 | /*+ |
| 3914 | * |
| 3915 | * Routine Description: |
| 3916 | * |
| 3917 | * Entry point for the reception and handling of 802.11 management |
| 3918 | * frames. Makes a determination of the frame type and then calls |
| 3919 | * the appropriate function. |
| 3920 | * |
| 3921 | * |
| 3922 | * Return Value: |
| 3923 | * none. |
| 3924 | * |
| 3925 | -*/ |
| 3926 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 3927 | void vMgrRxManagePacket(struct vnt_private *pDevice, struct vnt_manager *pMgmt, |
| 3928 | struct vnt_rx_mgmt *pRxPacket) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3929 | { |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 3930 | int bInScan = false; |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 3931 | u32 uNodeIndex = 0; |
| 3932 | NODE_STATE eNodeState = 0; |
| 3933 | CMD_STATUS Status; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3934 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3935 | if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { |
| 3936 | if (BSSbIsSTAInNodeDB(pDevice, pRxPacket->p80211Header->sA3.abyAddr2, &uNodeIndex)) |
| 3937 | eNodeState = pMgmt->sNodeDBTable[uNodeIndex].eNodeState; |
| 3938 | } |
| 3939 | |
| 3940 | switch( WLAN_GET_FC_FSTYPE((pRxPacket->p80211Header->sA3.wFrameCtl)) ){ |
| 3941 | |
| 3942 | case WLAN_FSTYPE_ASSOCREQ: |
| 3943 | // Frame Clase = 2 |
| 3944 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx assocreq\n"); |
| 3945 | if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && |
| 3946 | (eNodeState < NODE_AUTH)) { |
| 3947 | // send deauth notification |
| 3948 | // reason = (6) class 2 received from nonauth sta |
| 3949 | vMgrDeAuthenBeginSta(pDevice, |
| 3950 | pMgmt, |
| 3951 | pRxPacket->p80211Header->sA3.abyAddr2, |
| 3952 | (6), |
| 3953 | &Status |
| 3954 | ); |
| 3955 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wmgr: send vMgrDeAuthenBeginSta 1\n"); |
| 3956 | } |
| 3957 | else { |
| 3958 | s_vMgrRxAssocRequest(pDevice, pMgmt, pRxPacket, uNodeIndex); |
| 3959 | } |
| 3960 | break; |
| 3961 | |
| 3962 | case WLAN_FSTYPE_ASSOCRESP: |
| 3963 | // Frame Clase = 2 |
| 3964 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx assocresp1\n"); |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 3965 | s_vMgrRxAssocResponse(pDevice, pMgmt, pRxPacket, false); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3966 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx assocresp2\n"); |
| 3967 | break; |
| 3968 | |
| 3969 | case WLAN_FSTYPE_REASSOCREQ: |
| 3970 | // Frame Clase = 2 |
| 3971 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx reassocreq\n"); |
| 3972 | // Todo: reassoc |
| 3973 | if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && |
| 3974 | (eNodeState < NODE_AUTH)) { |
| 3975 | // send deauth notification |
| 3976 | // reason = (6) class 2 received from nonauth sta |
| 3977 | vMgrDeAuthenBeginSta(pDevice, |
| 3978 | pMgmt, |
| 3979 | pRxPacket->p80211Header->sA3.abyAddr2, |
| 3980 | (6), |
| 3981 | &Status |
| 3982 | ); |
| 3983 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wmgr: send vMgrDeAuthenBeginSta 2\n"); |
| 3984 | |
| 3985 | } |
| 3986 | s_vMgrRxReAssocRequest(pDevice, pMgmt, pRxPacket, uNodeIndex); |
| 3987 | break; |
| 3988 | |
| 3989 | case WLAN_FSTYPE_REASSOCRESP: |
| 3990 | // Frame Clase = 2 |
| 3991 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx reassocresp\n"); |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 3992 | s_vMgrRxAssocResponse(pDevice, pMgmt, pRxPacket, true); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 3993 | break; |
| 3994 | |
| 3995 | case WLAN_FSTYPE_PROBEREQ: |
| 3996 | // Frame Clase = 0 |
| 3997 | //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx probereq\n"); |
| 3998 | s_vMgrRxProbeRequest(pDevice, pMgmt, pRxPacket); |
| 3999 | break; |
| 4000 | |
| 4001 | case WLAN_FSTYPE_PROBERESP: |
| 4002 | // Frame Clase = 0 |
| 4003 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx proberesp\n"); |
| 4004 | |
| 4005 | s_vMgrRxProbeResponse(pDevice, pMgmt, pRxPacket); |
| 4006 | break; |
| 4007 | |
| 4008 | case WLAN_FSTYPE_BEACON: |
| 4009 | // Frame Clase = 0 |
| 4010 | //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx beacon\n"); |
| 4011 | if (pMgmt->eScanState != WMAC_NO_SCANNING) { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 4012 | bInScan = true; |
Joe Perches | 9fc8602 | 2011-04-10 14:31:32 -0700 | [diff] [blame] | 4013 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4014 | s_vMgrRxBeacon(pDevice, pMgmt, pRxPacket, bInScan); |
| 4015 | break; |
| 4016 | |
| 4017 | case WLAN_FSTYPE_ATIM: |
| 4018 | // Frame Clase = 1 |
| 4019 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx atim\n"); |
| 4020 | break; |
| 4021 | |
| 4022 | case WLAN_FSTYPE_DISASSOC: |
| 4023 | // Frame Clase = 2 |
| 4024 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx disassoc\n"); |
| 4025 | if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && |
| 4026 | (eNodeState < NODE_AUTH)) { |
| 4027 | // send deauth notification |
| 4028 | // reason = (6) class 2 received from nonauth sta |
| 4029 | vMgrDeAuthenBeginSta(pDevice, |
| 4030 | pMgmt, |
| 4031 | pRxPacket->p80211Header->sA3.abyAddr2, |
| 4032 | (6), |
| 4033 | &Status |
| 4034 | ); |
| 4035 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wmgr: send vMgrDeAuthenBeginSta 3\n"); |
| 4036 | } |
| 4037 | s_vMgrRxDisassociation(pDevice, pMgmt, pRxPacket); |
| 4038 | break; |
| 4039 | |
| 4040 | case WLAN_FSTYPE_AUTHEN: |
| 4041 | // Frame Clase = 1 |
| 4042 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx authen\n"); |
| 4043 | s_vMgrRxAuthentication(pDevice, pMgmt, pRxPacket); |
| 4044 | break; |
| 4045 | |
| 4046 | case WLAN_FSTYPE_DEAUTHEN: |
| 4047 | // Frame Clase = 1 |
| 4048 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx deauthen\n"); |
| 4049 | s_vMgrRxDeauthentication(pDevice, pMgmt, pRxPacket); |
| 4050 | break; |
| 4051 | |
| 4052 | default: |
| 4053 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx unknown mgmt\n"); |
| 4054 | } |
| 4055 | |
| 4056 | return; |
| 4057 | } |
| 4058 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4059 | /*+ |
| 4060 | * |
| 4061 | * Routine Description: |
| 4062 | * |
| 4063 | * |
| 4064 | * Prepare beacon to send |
| 4065 | * |
| 4066 | * Return Value: |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 4067 | * true if success; false if failed. |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4068 | * |
| 4069 | -*/ |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 4070 | int bMgrPrepareBeaconToSend(struct vnt_private *pDevice, |
| 4071 | struct vnt_manager *pMgmt) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4072 | { |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 4073 | struct vnt_tx_mgmt *pTxPacket; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4074 | |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 4075 | // pDevice->bBeaconBufReady = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4076 | if (pDevice->bEncryptionEnable || pDevice->bEnable8021x){ |
| 4077 | pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_PRIVACY(1); |
| 4078 | } |
| 4079 | else { |
| 4080 | pMgmt->wCurrCapInfo &= ~WLAN_SET_CAP_INFO_PRIVACY(1); |
| 4081 | } |
| 4082 | pTxPacket = s_MgrMakeBeacon |
| 4083 | ( |
| 4084 | pDevice, |
| 4085 | pMgmt, |
| 4086 | pMgmt->wCurrCapInfo, |
| 4087 | pMgmt->wCurrBeaconPeriod, |
| 4088 | pMgmt->uCurrChannel, |
| 4089 | pMgmt->wCurrATIMWindow, //0, |
| 4090 | (PWLAN_IE_SSID)pMgmt->abyCurrSSID, |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 4091 | (u8 *)pMgmt->abyCurrBSSID, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4092 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, |
| 4093 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates |
| 4094 | ); |
| 4095 | |
| 4096 | if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && |
| 4097 | (pMgmt->abyCurrBSSID[0] == 0)) |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 4098 | return false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4099 | |
| 4100 | csBeacon_xmit(pDevice, pTxPacket); |
| 4101 | MACvRegBitsOn(pDevice, MAC_REG_TCR, TCR_AUTOBCNTX); |
| 4102 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 4103 | return true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4104 | } |
| 4105 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4106 | /*+ |
| 4107 | * |
| 4108 | * Routine Description: |
| 4109 | * |
| 4110 | * Log a warning message based on the contents of the Status |
| 4111 | * Code field of an 802.11 management frame. Defines are |
| 4112 | * derived from 802.11-1997 SPEC. |
| 4113 | * |
| 4114 | * Return Value: |
| 4115 | * none. |
| 4116 | * |
| 4117 | -*/ |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 4118 | static void s_vMgrLogStatus(struct vnt_manager *pMgmt, u16 wStatus) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4119 | { |
| 4120 | switch( wStatus ){ |
| 4121 | case WLAN_MGMT_STATUS_UNSPEC_FAILURE: |
| 4122 | DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Unspecified error.\n"); |
| 4123 | break; |
| 4124 | case WLAN_MGMT_STATUS_CAPS_UNSUPPORTED: |
| 4125 | DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Can't support all requested capabilities.\n"); |
| 4126 | break; |
| 4127 | case WLAN_MGMT_STATUS_REASSOC_NO_ASSOC: |
| 4128 | DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Reassoc denied, can't confirm original Association.\n"); |
| 4129 | break; |
| 4130 | case WLAN_MGMT_STATUS_ASSOC_DENIED_UNSPEC: |
| 4131 | DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Assoc denied, undefine in spec\n"); |
| 4132 | break; |
| 4133 | case WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG: |
| 4134 | DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Peer doesn't support authen algorithm.\n"); |
| 4135 | break; |
| 4136 | case WLAN_MGMT_STATUS_RX_AUTH_NOSEQ: |
| 4137 | DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Authen frame received out of sequence.\n"); |
| 4138 | break; |
| 4139 | case WLAN_MGMT_STATUS_CHALLENGE_FAIL: |
| 4140 | DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Authen rejected, challenge failure.\n"); |
| 4141 | break; |
| 4142 | case WLAN_MGMT_STATUS_AUTH_TIMEOUT: |
| 4143 | DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Authen rejected, timeout waiting for next frame.\n"); |
| 4144 | break; |
| 4145 | case WLAN_MGMT_STATUS_ASSOC_DENIED_BUSY: |
| 4146 | DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Assoc denied, AP too busy.\n"); |
| 4147 | break; |
| 4148 | case WLAN_MGMT_STATUS_ASSOC_DENIED_RATES: |
| 4149 | DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Assoc denied, we haven't enough basic rates.\n"); |
| 4150 | break; |
| 4151 | case WLAN_MGMT_STATUS_ASSOC_DENIED_SHORTPREAMBLE: |
| 4152 | DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Assoc denied, we do not support short preamble.\n"); |
| 4153 | break; |
| 4154 | case WLAN_MGMT_STATUS_ASSOC_DENIED_PBCC: |
| 4155 | DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Assoc denied, we do not support PBCC.\n"); |
| 4156 | break; |
| 4157 | case WLAN_MGMT_STATUS_ASSOC_DENIED_AGILITY: |
| 4158 | DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Assoc denied, we do not support channel agility.\n"); |
| 4159 | break; |
| 4160 | default: |
| 4161 | DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Unknown status code %d.\n", wStatus); |
| 4162 | break; |
| 4163 | } |
| 4164 | } |
| 4165 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4166 | /* |
| 4167 | * |
| 4168 | * Description: |
| 4169 | * Add BSSID in PMKID Candidate list. |
| 4170 | * |
| 4171 | * Parameters: |
| 4172 | * In: |
| 4173 | * hDeviceContext - device structure point |
| 4174 | * pbyBSSID - BSSID address for adding |
| 4175 | * wRSNCap - BSS's RSN capability |
| 4176 | * Out: |
| 4177 | * none |
| 4178 | * |
| 4179 | * Return Value: none. |
| 4180 | * |
| 4181 | -*/ |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 4182 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 4183 | int bAdd_PMKID_Candidate(struct vnt_private *pDevice, u8 *pbyBSSID, |
| 4184 | PSRSNCapObject psRSNCapObj) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4185 | { |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 4186 | PPMKID_CANDIDATE pCandidateList; |
| 4187 | int ii = 0; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4188 | |
| 4189 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"bAdd_PMKID_Candidate START: (%d)\n", (int)pDevice->gsPMKIDCandidate.NumCandidates); |
| 4190 | |
| 4191 | if ((pDevice == NULL) || (pbyBSSID == NULL) || (psRSNCapObj == NULL)) |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 4192 | return false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4193 | |
| 4194 | if (pDevice->gsPMKIDCandidate.NumCandidates >= MAX_PMKIDLIST) |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 4195 | return false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4196 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4197 | // Update Old Candidate |
| 4198 | for (ii = 0; ii < pDevice->gsPMKIDCandidate.NumCandidates; ii++) { |
Andres More | 9a0e756 | 2010-04-13 21:54:48 -0300 | [diff] [blame] | 4199 | pCandidateList = &pDevice->gsPMKIDCandidate.CandidateList[ii]; |
| 4200 | if (!memcmp(pCandidateList->BSSID, pbyBSSID, ETH_ALEN)) { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 4201 | if ((psRSNCapObj->bRSNCapExist == true) |
Andres More | 9a0e756 | 2010-04-13 21:54:48 -0300 | [diff] [blame] | 4202 | && (psRSNCapObj->wRSNCap & BIT0)) { |
| 4203 | pCandidateList->Flags |= |
| 4204 | NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED; |
| 4205 | } else { |
| 4206 | pCandidateList->Flags &= |
| 4207 | ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED); |
| 4208 | } |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 4209 | return true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4210 | } |
| 4211 | } |
| 4212 | |
| 4213 | // New Candidate |
| 4214 | pCandidateList = &pDevice->gsPMKIDCandidate.CandidateList[pDevice->gsPMKIDCandidate.NumCandidates]; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 4215 | if ((psRSNCapObj->bRSNCapExist == true) && (psRSNCapObj->wRSNCap & BIT0)) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4216 | pCandidateList->Flags |= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED; |
| 4217 | } else { |
| 4218 | pCandidateList->Flags &= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED); |
| 4219 | } |
Andres More | 9a0e756 | 2010-04-13 21:54:48 -0300 | [diff] [blame] | 4220 | memcpy(pCandidateList->BSSID, pbyBSSID, ETH_ALEN); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4221 | pDevice->gsPMKIDCandidate.NumCandidates++; |
| 4222 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"NumCandidates:%d\n", (int)pDevice->gsPMKIDCandidate.NumCandidates); |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 4223 | return true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4224 | } |
| 4225 | |
| 4226 | /* |
| 4227 | * |
| 4228 | * Description: |
| 4229 | * Flush PMKID Candidate list. |
| 4230 | * |
| 4231 | * Parameters: |
| 4232 | * In: |
| 4233 | * hDeviceContext - device structure point |
| 4234 | * Out: |
| 4235 | * none |
| 4236 | * |
| 4237 | * Return Value: none. |
| 4238 | * |
| 4239 | -*/ |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 4240 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 4241 | void vFlush_PMKID_Candidate(struct vnt_private *pDevice) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4242 | { |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 4243 | if (pDevice == NULL) |
| 4244 | return; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4245 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 4246 | memset(&pDevice->gsPMKIDCandidate, 0, sizeof(SPMKIDCandidateEvent)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4247 | |
Malcolm Priestley | 78f41c9 | 2012-12-10 22:03:56 +0000 | [diff] [blame] | 4248 | return; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4249 | } |
| 4250 | |
Andres More | dfdcc42 | 2013-02-12 20:36:28 -0500 | [diff] [blame] | 4251 | static bool |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4252 | s_bCipherMatch ( |
Andres More | 592ccfe | 2010-04-17 12:07:42 -0300 | [diff] [blame] | 4253 | PKnownBSS pBSSNode, |
| 4254 | NDIS_802_11_ENCRYPTION_STATUS EncStatus, |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 4255 | u8 * pbyCCSPK, |
| 4256 | u8 * pbyCCSGK |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4257 | ) |
| 4258 | { |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 4259 | u8 byMulticastCipher = KEY_CTL_INVALID; |
| 4260 | u8 byCipherMask = 0x00; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4261 | int i; |
| 4262 | |
| 4263 | if (pBSSNode == NULL) |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 4264 | return false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4265 | |
| 4266 | // check cap. of BSS |
| 4267 | if ((WLAN_GET_CAP_INFO_PRIVACY(pBSSNode->wCapInfo) != 0) && |
| 4268 | (EncStatus == Ndis802_11Encryption1Enabled)) { |
| 4269 | // default is WEP only |
| 4270 | byMulticastCipher = KEY_CTL_WEP; |
| 4271 | } |
| 4272 | |
| 4273 | if ((WLAN_GET_CAP_INFO_PRIVACY(pBSSNode->wCapInfo) != 0) && |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 4274 | (pBSSNode->bWPA2Valid == true) && |
Andres More | 465711b | 2010-08-03 20:25:50 -0300 | [diff] [blame] | 4275 | |
Andres More | bd2bc4c | 2010-08-02 23:35:57 -0300 | [diff] [blame] | 4276 | ((EncStatus == Ndis802_11Encryption3Enabled) || |
| 4277 | (EncStatus == Ndis802_11Encryption2Enabled))) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4278 | //WPA2 |
| 4279 | // check Group Key Cipher |
| 4280 | if ((pBSSNode->byCSSGK == WLAN_11i_CSS_WEP40) || |
| 4281 | (pBSSNode->byCSSGK == WLAN_11i_CSS_WEP104)) { |
| 4282 | byMulticastCipher = KEY_CTL_WEP; |
| 4283 | } else if (pBSSNode->byCSSGK == WLAN_11i_CSS_TKIP) { |
| 4284 | byMulticastCipher = KEY_CTL_TKIP; |
| 4285 | } else if (pBSSNode->byCSSGK == WLAN_11i_CSS_CCMP) { |
| 4286 | byMulticastCipher = KEY_CTL_CCMP; |
| 4287 | } else { |
| 4288 | byMulticastCipher = KEY_CTL_INVALID; |
| 4289 | } |
| 4290 | |
Andres More | 33d33e42 | 2010-05-19 23:50:00 -0300 | [diff] [blame] | 4291 | /* check Pairwise Key Cipher */ |
| 4292 | for (i = 0; i < pBSSNode->wCSSPKCount; i++) { |
| 4293 | if ((pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_WEP40) || |
| 4294 | (pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_WEP104)) { |
| 4295 | /* this should not happen as defined 802.11i */ |
| 4296 | byCipherMask |= 0x01; |
| 4297 | } else if (pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_TKIP) { |
| 4298 | byCipherMask |= 0x02; |
| 4299 | } else if (pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_CCMP) { |
| 4300 | byCipherMask |= 0x04; |
| 4301 | } else if (pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_USE_GROUP) { |
| 4302 | /* use group key only ignore all others */ |
| 4303 | byCipherMask = 0; |
| 4304 | i = pBSSNode->wCSSPKCount; |
| 4305 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4306 | } |
| 4307 | |
| 4308 | } else if ((WLAN_GET_CAP_INFO_PRIVACY(pBSSNode->wCapInfo) != 0) && |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 4309 | (pBSSNode->bWPAValid == true) && |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4310 | ((EncStatus == Ndis802_11Encryption2Enabled) || (EncStatus == Ndis802_11Encryption3Enabled))) { |
| 4311 | //WPA |
| 4312 | // check Group Key Cipher |
| 4313 | if ((pBSSNode->byGKType == WPA_WEP40) || |
| 4314 | (pBSSNode->byGKType == WPA_WEP104)) { |
| 4315 | byMulticastCipher = KEY_CTL_WEP; |
| 4316 | } else if (pBSSNode->byGKType == WPA_TKIP) { |
| 4317 | byMulticastCipher = KEY_CTL_TKIP; |
| 4318 | } else if (pBSSNode->byGKType == WPA_AESCCMP) { |
| 4319 | byMulticastCipher = KEY_CTL_CCMP; |
| 4320 | } else { |
| 4321 | byMulticastCipher = KEY_CTL_INVALID; |
| 4322 | } |
| 4323 | |
Andres More | 33d33e42 | 2010-05-19 23:50:00 -0300 | [diff] [blame] | 4324 | /* check Pairwise Key Cipher */ |
| 4325 | for (i = 0; i < pBSSNode->wPKCount; i++) { |
| 4326 | if (pBSSNode->abyPKType[i] == WPA_TKIP) { |
| 4327 | byCipherMask |= 0x02; |
| 4328 | } else if (pBSSNode->abyPKType[i] == WPA_AESCCMP) { |
| 4329 | byCipherMask |= 0x04; |
| 4330 | } else if (pBSSNode->abyPKType[i] == WPA_NONE) { |
| 4331 | /* use group key only ignore all others */ |
| 4332 | byCipherMask = 0; |
| 4333 | i = pBSSNode->wPKCount; |
| 4334 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4335 | } |
| 4336 | } |
| 4337 | |
| 4338 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%d, %d, %d, %d, EncStatus:%d\n", |
| 4339 | byMulticastCipher, byCipherMask, pBSSNode->bWPAValid, pBSSNode->bWPA2Valid, EncStatus); |
| 4340 | |
| 4341 | // mask our cap. with BSS |
| 4342 | if (EncStatus == Ndis802_11Encryption1Enabled) { |
| 4343 | |
| 4344 | // For supporting Cisco migration mode, don't care pairwise key cipher |
| 4345 | //if ((byMulticastCipher == KEY_CTL_WEP) && |
| 4346 | // (byCipherMask == 0)) { |
| 4347 | if ((byMulticastCipher == KEY_CTL_WEP) && |
| 4348 | (byCipherMask == 0)) { |
| 4349 | *pbyCCSGK = KEY_CTL_WEP; |
| 4350 | *pbyCCSPK = KEY_CTL_NONE; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 4351 | return true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4352 | } else { |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 4353 | return false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4354 | } |
| 4355 | |
| 4356 | } else if (EncStatus == Ndis802_11Encryption2Enabled) { |
| 4357 | if ((byMulticastCipher == KEY_CTL_TKIP) && |
| 4358 | (byCipherMask == 0)) { |
| 4359 | *pbyCCSGK = KEY_CTL_TKIP; |
| 4360 | *pbyCCSPK = KEY_CTL_NONE; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 4361 | return true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4362 | } else if ((byMulticastCipher == KEY_CTL_WEP) && |
| 4363 | ((byCipherMask & 0x02) != 0)) { |
| 4364 | *pbyCCSGK = KEY_CTL_WEP; |
| 4365 | *pbyCCSPK = KEY_CTL_TKIP; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 4366 | return true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4367 | } else if ((byMulticastCipher == KEY_CTL_TKIP) && |
| 4368 | ((byCipherMask & 0x02) != 0)) { |
| 4369 | *pbyCCSGK = KEY_CTL_TKIP; |
| 4370 | *pbyCCSPK = KEY_CTL_TKIP; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 4371 | return true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4372 | } else { |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 4373 | return false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4374 | } |
| 4375 | } else if (EncStatus == Ndis802_11Encryption3Enabled) { |
| 4376 | if ((byMulticastCipher == KEY_CTL_CCMP) && |
| 4377 | (byCipherMask == 0)) { |
| 4378 | // When CCMP is enable, "Use group cipher suite" shall not be a valid option. |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 4379 | return false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4380 | } else if ((byMulticastCipher == KEY_CTL_WEP) && |
| 4381 | ((byCipherMask & 0x04) != 0)) { |
| 4382 | *pbyCCSGK = KEY_CTL_WEP; |
| 4383 | *pbyCCSPK = KEY_CTL_CCMP; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 4384 | return true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4385 | } else if ((byMulticastCipher == KEY_CTL_TKIP) && |
| 4386 | ((byCipherMask & 0x04) != 0)) { |
| 4387 | *pbyCCSGK = KEY_CTL_TKIP; |
| 4388 | *pbyCCSPK = KEY_CTL_CCMP; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 4389 | return true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4390 | } else if ((byMulticastCipher == KEY_CTL_CCMP) && |
| 4391 | ((byCipherMask & 0x04) != 0)) { |
| 4392 | *pbyCCSGK = KEY_CTL_CCMP; |
| 4393 | *pbyCCSPK = KEY_CTL_CCMP; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 4394 | return true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4395 | } else { |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 4396 | return false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4397 | } |
| 4398 | } |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 4399 | return true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 4400 | } |
| 4401 | |