Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1 | /* |
| 2 | ************************************************************************* |
| 3 | * Ralink Tech Inc. |
| 4 | * 5F., No.36, Taiyuan St., Jhubei City, |
| 5 | * Hsinchu County 302, |
| 6 | * Taiwan, R.O.C. |
| 7 | * |
| 8 | * (c) Copyright 2002-2007, Ralink Technology, Inc. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify * |
| 11 | * it under the terms of the GNU General Public License as published by * |
| 12 | * the Free Software Foundation; either version 2 of the License, or * |
| 13 | * (at your option) any later version. * |
| 14 | * * |
| 15 | * This program is distributed in the hope that it will be useful, * |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 18 | * GNU General Public License for more details. * |
| 19 | * * |
| 20 | * You should have received a copy of the GNU General Public License * |
| 21 | * along with this program; if not, write to the * |
| 22 | * Free Software Foundation, Inc., * |
| 23 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
| 24 | * * |
| 25 | ************************************************************************* |
| 26 | |
| 27 | Module Name: |
| 28 | assoc.c |
| 29 | |
| 30 | Abstract: |
| 31 | |
| 32 | Revision History: |
| 33 | Who When What |
| 34 | -------- ---------- ---------------------------------------------- |
| 35 | John 2004-9-3 porting from RT2500 |
| 36 | */ |
| 37 | #include "../rt_config.h" |
| 38 | |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 39 | u8 CipherWpaTemplate[] = { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 40 | 0xdd, /* WPA IE */ |
| 41 | 0x16, /* Length */ |
| 42 | 0x00, 0x50, 0xf2, 0x01, /* oui */ |
| 43 | 0x01, 0x00, /* Version */ |
| 44 | 0x00, 0x50, 0xf2, 0x02, /* Multicast */ |
| 45 | 0x01, 0x00, /* Number of unicast */ |
| 46 | 0x00, 0x50, 0xf2, 0x02, /* unicast */ |
| 47 | 0x01, 0x00, /* number of authentication method */ |
| 48 | 0x00, 0x50, 0xf2, 0x01 /* authentication */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 49 | }; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 50 | |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 51 | u8 CipherWpa2Template[] = { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 52 | 0x30, /* RSN IE */ |
| 53 | 0x14, /* Length */ |
| 54 | 0x01, 0x00, /* Version */ |
| 55 | 0x00, 0x0f, 0xac, 0x02, /* group cipher, TKIP */ |
| 56 | 0x01, 0x00, /* number of pairwise */ |
| 57 | 0x00, 0x0f, 0xac, 0x02, /* unicast */ |
| 58 | 0x01, 0x00, /* number of authentication method */ |
| 59 | 0x00, 0x0f, 0xac, 0x02, /* authentication */ |
| 60 | 0x00, 0x00, /* RSN capability */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 61 | }; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 62 | |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 63 | u8 Ccx2IeInfo[] = { 0x00, 0x40, 0x96, 0x03, 0x02 }; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 64 | |
| 65 | /* |
| 66 | ========================================================================== |
| 67 | Description: |
| 68 | association state machine init, including state transition and timer init |
| 69 | Parameters: |
| 70 | S - pointer to the association state machine |
| 71 | |
| 72 | IRQL = PASSIVE_LEVEL |
| 73 | |
| 74 | ========================================================================== |
| 75 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 76 | void AssocStateMachineInit(struct rt_rtmp_adapter *pAd, |
| 77 | struct rt_state_machine *S, OUT STATE_MACHINE_FUNC Trans[]) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 78 | { |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 79 | StateMachineInit(S, Trans, MAX_ASSOC_STATE, MAX_ASSOC_MSG, |
| 80 | (STATE_MACHINE_FUNC) Drop, ASSOC_IDLE, |
| 81 | ASSOC_MACHINE_BASE); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 82 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 83 | /* first column */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 84 | StateMachineSetAction(S, ASSOC_IDLE, MT2_MLME_ASSOC_REQ, |
| 85 | (STATE_MACHINE_FUNC) MlmeAssocReqAction); |
| 86 | StateMachineSetAction(S, ASSOC_IDLE, MT2_MLME_REASSOC_REQ, |
| 87 | (STATE_MACHINE_FUNC) MlmeReassocReqAction); |
| 88 | StateMachineSetAction(S, ASSOC_IDLE, MT2_MLME_DISASSOC_REQ, |
| 89 | (STATE_MACHINE_FUNC) MlmeDisassocReqAction); |
| 90 | StateMachineSetAction(S, ASSOC_IDLE, MT2_PEER_DISASSOC_REQ, |
| 91 | (STATE_MACHINE_FUNC) PeerDisassocAction); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 92 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 93 | /* second column */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 94 | StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_MLME_ASSOC_REQ, |
| 95 | (STATE_MACHINE_FUNC) InvalidStateWhenAssoc); |
| 96 | StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_MLME_REASSOC_REQ, |
| 97 | (STATE_MACHINE_FUNC) InvalidStateWhenReassoc); |
| 98 | StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_MLME_DISASSOC_REQ, |
| 99 | (STATE_MACHINE_FUNC) |
| 100 | InvalidStateWhenDisassociate); |
| 101 | StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_PEER_DISASSOC_REQ, |
| 102 | (STATE_MACHINE_FUNC) PeerDisassocAction); |
| 103 | StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_PEER_ASSOC_RSP, |
| 104 | (STATE_MACHINE_FUNC) PeerAssocRspAction); |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 105 | /* */ |
| 106 | /* Patch 3Com AP MOde:3CRWE454G72 */ |
| 107 | /* We send Assoc request frame to this AP, it always send Reassoc Rsp not Associate Rsp. */ |
| 108 | /* */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 109 | StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_PEER_REASSOC_RSP, |
| 110 | (STATE_MACHINE_FUNC) PeerAssocRspAction); |
| 111 | StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_ASSOC_TIMEOUT, |
| 112 | (STATE_MACHINE_FUNC) AssocTimeoutAction); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 113 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 114 | /* third column */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 115 | StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_MLME_ASSOC_REQ, |
| 116 | (STATE_MACHINE_FUNC) InvalidStateWhenAssoc); |
| 117 | StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_MLME_REASSOC_REQ, |
| 118 | (STATE_MACHINE_FUNC) InvalidStateWhenReassoc); |
| 119 | StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_MLME_DISASSOC_REQ, |
| 120 | (STATE_MACHINE_FUNC) |
| 121 | InvalidStateWhenDisassociate); |
| 122 | StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_PEER_DISASSOC_REQ, |
| 123 | (STATE_MACHINE_FUNC) PeerDisassocAction); |
| 124 | StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_PEER_REASSOC_RSP, |
| 125 | (STATE_MACHINE_FUNC) PeerReassocRspAction); |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 126 | /* */ |
| 127 | /* Patch, AP doesn't send Reassociate Rsp frame to Station. */ |
| 128 | /* */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 129 | StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_PEER_ASSOC_RSP, |
| 130 | (STATE_MACHINE_FUNC) PeerReassocRspAction); |
| 131 | StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_REASSOC_TIMEOUT, |
| 132 | (STATE_MACHINE_FUNC) ReassocTimeoutAction); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 133 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 134 | /* fourth column */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 135 | StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_MLME_ASSOC_REQ, |
| 136 | (STATE_MACHINE_FUNC) InvalidStateWhenAssoc); |
| 137 | StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_MLME_REASSOC_REQ, |
| 138 | (STATE_MACHINE_FUNC) InvalidStateWhenReassoc); |
| 139 | StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_MLME_DISASSOC_REQ, |
| 140 | (STATE_MACHINE_FUNC) |
| 141 | InvalidStateWhenDisassociate); |
| 142 | StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_PEER_DISASSOC_REQ, |
| 143 | (STATE_MACHINE_FUNC) PeerDisassocAction); |
| 144 | StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_DISASSOC_TIMEOUT, |
| 145 | (STATE_MACHINE_FUNC) DisassocTimeoutAction); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 146 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 147 | /* initialize the timer */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 148 | RTMPInitTimer(pAd, &pAd->MlmeAux.AssocTimer, |
| 149 | GET_TIMER_FUNCTION(AssocTimeout), pAd, FALSE); |
| 150 | RTMPInitTimer(pAd, &pAd->MlmeAux.ReassocTimer, |
| 151 | GET_TIMER_FUNCTION(ReassocTimeout), pAd, FALSE); |
| 152 | RTMPInitTimer(pAd, &pAd->MlmeAux.DisassocTimer, |
| 153 | GET_TIMER_FUNCTION(DisassocTimeout), pAd, FALSE); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | /* |
| 157 | ========================================================================== |
| 158 | Description: |
| 159 | Association timeout procedure. After association timeout, this function |
| 160 | will be called and it will put a message into the MLME queue |
| 161 | Parameters: |
| 162 | Standard timer parameters |
| 163 | |
| 164 | IRQL = DISPATCH_LEVEL |
| 165 | |
| 166 | ========================================================================== |
| 167 | */ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 168 | void AssocTimeout(void *SystemSpecific1, |
| 169 | void *FunctionContext, |
| 170 | void *SystemSpecific2, void *SystemSpecific3) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 171 | { |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 172 | struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)FunctionContext; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 173 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 174 | /* Do nothing if the driver is starting halt state. */ |
| 175 | /* This might happen when timer already been fired before cancel timer with mlmehalt */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 176 | if (RTMP_TEST_FLAG |
| 177 | (pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST)) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 178 | return; |
| 179 | |
| 180 | MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_ASSOC_TIMEOUT, 0, NULL); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 181 | RTMP_MLME_HANDLER(pAd); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | /* |
| 185 | ========================================================================== |
| 186 | Description: |
| 187 | Reassociation timeout procedure. After reassociation timeout, this |
| 188 | function will be called and put a message into the MLME queue |
| 189 | Parameters: |
| 190 | Standard timer parameters |
| 191 | |
| 192 | IRQL = DISPATCH_LEVEL |
| 193 | |
| 194 | ========================================================================== |
| 195 | */ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 196 | void ReassocTimeout(void *SystemSpecific1, |
| 197 | void *FunctionContext, |
| 198 | void *SystemSpecific2, void *SystemSpecific3) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 199 | { |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 200 | struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)FunctionContext; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 201 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 202 | /* Do nothing if the driver is starting halt state. */ |
| 203 | /* This might happen when timer already been fired before cancel timer with mlmehalt */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 204 | if (RTMP_TEST_FLAG |
| 205 | (pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST)) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 206 | return; |
| 207 | |
| 208 | MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_REASSOC_TIMEOUT, 0, NULL); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 209 | RTMP_MLME_HANDLER(pAd); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 210 | } |
| 211 | |
| 212 | /* |
| 213 | ========================================================================== |
| 214 | Description: |
| 215 | Disassociation timeout procedure. After disassociation timeout, this |
| 216 | function will be called and put a message into the MLME queue |
| 217 | Parameters: |
| 218 | Standard timer parameters |
| 219 | |
| 220 | IRQL = DISPATCH_LEVEL |
| 221 | |
| 222 | ========================================================================== |
| 223 | */ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 224 | void DisassocTimeout(void *SystemSpecific1, |
| 225 | void *FunctionContext, |
| 226 | void *SystemSpecific2, void *SystemSpecific3) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 227 | { |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 228 | struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)FunctionContext; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 229 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 230 | /* Do nothing if the driver is starting halt state. */ |
| 231 | /* This might happen when timer already been fired before cancel timer with mlmehalt */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 232 | if (RTMP_TEST_FLAG |
| 233 | (pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST)) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 234 | return; |
| 235 | |
| 236 | MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_DISASSOC_TIMEOUT, 0, NULL); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 237 | RTMP_MLME_HANDLER(pAd); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | /* |
| 241 | ========================================================================== |
| 242 | Description: |
| 243 | mlme assoc req handling procedure |
| 244 | Parameters: |
| 245 | Adapter - Adapter pointer |
| 246 | Elem - MLME Queue Element |
| 247 | Pre: |
| 248 | the station has been authenticated and the following information is stored in the config |
| 249 | -# SSID |
| 250 | -# supported rates and their length |
| 251 | -# listen interval (Adapter->StaCfg.default_listen_count) |
| 252 | -# Transmit power (Adapter->StaCfg.tx_power) |
| 253 | Post : |
| 254 | -# An association request frame is generated and sent to the air |
| 255 | -# Association timer starts |
| 256 | -# Association state -> ASSOC_WAIT_RSP |
| 257 | |
| 258 | IRQL = DISPATCH_LEVEL |
| 259 | |
| 260 | ========================================================================== |
| 261 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 262 | void MlmeAssocReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 263 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 264 | u8 ApAddr[6]; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 265 | struct rt_header_802_11 AssocHdr; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 266 | u8 WmeIe[9] = |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 267 | { IE_VENDOR_SPECIFIC, 0x07, 0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, |
| 268 | 0x00 }; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 269 | u16 ListenIntv; |
| 270 | unsigned long Timeout; |
| 271 | u16 CapabilityInfo; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 272 | BOOLEAN TimerCancelled; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 273 | u8 *pOutBuffer = NULL; |
| 274 | int NStatus; |
| 275 | unsigned long FrameLen = 0; |
| 276 | unsigned long tmp; |
| 277 | u16 VarIesOffset; |
| 278 | u16 Status; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 279 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 280 | /* Block all authentication request durning WPA block period */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 281 | if (pAd->StaCfg.bBlockAssoc == TRUE) { |
| 282 | DBGPRINT(RT_DEBUG_TRACE, |
| 283 | ("ASSOC - Block Assoc request durning WPA block period!\n")); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 284 | pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; |
| 285 | Status = MLME_STATE_MACHINE_REJECT; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 286 | MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, |
| 287 | &Status); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 288 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 289 | /* check sanity first */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 290 | else if (MlmeAssocReqSanity |
| 291 | (pAd, Elem->Msg, Elem->MsgLen, ApAddr, &CapabilityInfo, |
| 292 | &Timeout, &ListenIntv)) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 293 | RTMPCancelTimer(&pAd->MlmeAux.AssocTimer, &TimerCancelled); |
| 294 | COPY_MAC_ADDR(pAd->MlmeAux.Bssid, ApAddr); |
| 295 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 296 | /* Get an unused nonpaged memory */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 297 | NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 298 | if (NStatus != NDIS_STATUS_SUCCESS) { |
| 299 | DBGPRINT(RT_DEBUG_TRACE, |
| 300 | ("ASSOC - MlmeAssocReqAction() allocate memory failed \n")); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 301 | pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; |
| 302 | Status = MLME_FAIL_NO_RESOURCE; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 303 | MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, |
| 304 | MT2_ASSOC_CONF, 2, &Status); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 305 | return; |
| 306 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 307 | /* Add by James 03/06/27 */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 308 | pAd->StaCfg.AssocInfo.Length = |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 309 | sizeof(struct rt_ndis_802_11_association_information); |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 310 | /* Association don't need to report MAC address */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 311 | pAd->StaCfg.AssocInfo.AvailableRequestFixedIEs = |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 312 | NDIS_802_11_AI_REQFI_CAPABILITIES | |
| 313 | NDIS_802_11_AI_REQFI_LISTENINTERVAL; |
| 314 | pAd->StaCfg.AssocInfo.RequestFixedIEs.Capabilities = |
| 315 | CapabilityInfo; |
| 316 | pAd->StaCfg.AssocInfo.RequestFixedIEs.ListenInterval = |
| 317 | ListenIntv; |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 318 | /* Only reassociate need this */ |
| 319 | /*COPY_MAC_ADDR(pAd->StaCfg.AssocInfo.RequestFixedIEs.CurrentAPAddress, ApAddr); */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 320 | pAd->StaCfg.AssocInfo.OffsetRequestIEs = |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 321 | sizeof(struct rt_ndis_802_11_association_information); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 322 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 323 | NdisZeroMemory(pAd->StaCfg.ReqVarIEs, MAX_VIE_LEN); |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 324 | /* First add SSID */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 325 | VarIesOffset = 0; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 326 | NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &SsidIe, |
| 327 | 1); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 328 | VarIesOffset += 1; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 329 | NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, |
| 330 | &pAd->MlmeAux.SsidLen, 1); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 331 | VarIesOffset += 1; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 332 | NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, |
| 333 | pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 334 | VarIesOffset += pAd->MlmeAux.SsidLen; |
| 335 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 336 | /* Second add Supported rates */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 337 | NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &SupRateIe, |
| 338 | 1); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 339 | VarIesOffset += 1; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 340 | NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, |
| 341 | &pAd->MlmeAux.SupRateLen, 1); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 342 | VarIesOffset += 1; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 343 | NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, |
| 344 | pAd->MlmeAux.SupRate, pAd->MlmeAux.SupRateLen); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 345 | VarIesOffset += pAd->MlmeAux.SupRateLen; |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 346 | /* End Add by James */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 347 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 348 | if ((pAd->CommonCfg.Channel > 14) && |
| 349 | (pAd->CommonCfg.bIEEE80211H == TRUE)) |
| 350 | CapabilityInfo |= 0x0100; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 351 | |
| 352 | DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - Send ASSOC request...\n")); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 353 | MgtMacHeaderInit(pAd, &AssocHdr, SUBTYPE_ASSOC_REQ, 0, ApAddr, |
| 354 | ApAddr); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 355 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 356 | /* Build basic frame first */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 357 | MakeOutgoingFrame(pOutBuffer, &FrameLen, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 358 | sizeof(struct rt_header_802_11), &AssocHdr, |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 359 | 2, &CapabilityInfo, |
| 360 | 2, &ListenIntv, |
| 361 | 1, &SsidIe, |
| 362 | 1, &pAd->MlmeAux.SsidLen, |
| 363 | pAd->MlmeAux.SsidLen, pAd->MlmeAux.Ssid, |
| 364 | 1, &SupRateIe, |
| 365 | 1, &pAd->MlmeAux.SupRateLen, |
| 366 | pAd->MlmeAux.SupRateLen, pAd->MlmeAux.SupRate, |
| 367 | END_OF_ARGS); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 368 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 369 | if (pAd->MlmeAux.ExtRateLen != 0) { |
| 370 | MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp, |
| 371 | 1, &ExtRateIe, |
| 372 | 1, &pAd->MlmeAux.ExtRateLen, |
| 373 | pAd->MlmeAux.ExtRateLen, |
| 374 | pAd->MlmeAux.ExtRate, END_OF_ARGS); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 375 | FrameLen += tmp; |
| 376 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 377 | /* HT */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 378 | if ((pAd->MlmeAux.HtCapabilityLen > 0) |
| 379 | && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)) { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 380 | unsigned long TmpLen; |
| 381 | u8 HtLen; |
| 382 | u8 BROADCOM[4] = { 0x0, 0x90, 0x4c, 0x33 }; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 383 | if (pAd->StaActive.SupportedPhyInfo.bPreNHt == TRUE) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 384 | HtLen = SIZE_HT_CAP_IE + 4; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 385 | MakeOutgoingFrame(pOutBuffer + FrameLen, |
| 386 | &TmpLen, 1, &WpaIe, 1, &HtLen, |
| 387 | 4, &BROADCOM[0], |
| 388 | pAd->MlmeAux.HtCapabilityLen, |
| 389 | &pAd->MlmeAux.HtCapability, |
| 390 | END_OF_ARGS); |
| 391 | } else { |
| 392 | MakeOutgoingFrame(pOutBuffer + FrameLen, |
| 393 | &TmpLen, 1, &HtCapIe, 1, |
| 394 | &pAd->MlmeAux.HtCapabilityLen, |
| 395 | pAd->MlmeAux.HtCapabilityLen, |
| 396 | &pAd->MlmeAux.HtCapability, |
| 397 | END_OF_ARGS); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 398 | } |
| 399 | FrameLen += TmpLen; |
| 400 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 401 | /* add Ralink proprietary IE to inform AP this STA is going to use AGGREGATION or PIGGY-BACK+AGGREGATION */ |
| 402 | /* Case I: (Aggregation + Piggy-Back) */ |
| 403 | /* 1. user enable aggregation, AND */ |
| 404 | /* 2. Mac support piggy-back */ |
| 405 | /* 3. AP annouces it's PIGGY-BACK+AGGREGATION-capable in BEACON */ |
| 406 | /* Case II: (Aggregation) */ |
| 407 | /* 1. user enable aggregation, AND */ |
| 408 | /* 2. AP annouces it's AGGREGATION-capable in BEACON */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 409 | if (pAd->CommonCfg.bAggregationCapable) { |
| 410 | if ((pAd->CommonCfg.bPiggyBackCapable) |
| 411 | && ((pAd->MlmeAux.APRalinkIe & 0x00000003) == 3)) { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 412 | unsigned long TmpLen; |
| 413 | u8 RalinkIe[9] = |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 414 | { IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, |
| 415 | 0x03, 0x00, 0x00, 0x00 }; |
| 416 | MakeOutgoingFrame(pOutBuffer + FrameLen, |
| 417 | &TmpLen, 9, RalinkIe, |
| 418 | END_OF_ARGS); |
| 419 | FrameLen += TmpLen; |
| 420 | } else if (pAd->MlmeAux.APRalinkIe & 0x00000001) { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 421 | unsigned long TmpLen; |
| 422 | u8 RalinkIe[9] = |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 423 | { IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, |
| 424 | 0x01, 0x00, 0x00, 0x00 }; |
| 425 | MakeOutgoingFrame(pOutBuffer + FrameLen, |
| 426 | &TmpLen, 9, RalinkIe, |
| 427 | END_OF_ARGS); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 428 | FrameLen += TmpLen; |
| 429 | } |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 430 | } else { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 431 | unsigned long TmpLen; |
| 432 | u8 RalinkIe[9] = |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 433 | { IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x06, |
| 434 | 0x00, 0x00, 0x00 }; |
| 435 | MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen, 9, |
| 436 | RalinkIe, END_OF_ARGS); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 437 | FrameLen += TmpLen; |
| 438 | } |
| 439 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 440 | if (pAd->MlmeAux.APEdcaParm.bValid) { |
| 441 | if (pAd->CommonCfg.bAPSDCapable |
| 442 | && pAd->MlmeAux.APEdcaParm.bAPSDCapable) { |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 443 | struct rt_qbss_sta_info_parm QosInfo; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 444 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 445 | NdisZeroMemory(&QosInfo, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 446 | sizeof(struct rt_qbss_sta_info_parm)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 447 | QosInfo.UAPSD_AC_BE = pAd->CommonCfg.bAPSDAC_BE; |
| 448 | QosInfo.UAPSD_AC_BK = pAd->CommonCfg.bAPSDAC_BK; |
| 449 | QosInfo.UAPSD_AC_VI = pAd->CommonCfg.bAPSDAC_VI; |
| 450 | QosInfo.UAPSD_AC_VO = pAd->CommonCfg.bAPSDAC_VO; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 451 | QosInfo.MaxSPLength = |
| 452 | pAd->CommonCfg.MaxSPLength; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 453 | WmeIe[8] |= *(u8 *)& QosInfo; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 454 | } else { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 455 | /* The Parameter Set Count is set to ¡§0¡¨ in the association request frames */ |
| 456 | /* WmeIe[8] |= (pAd->MlmeAux.APEdcaParm.EdcaUpdateCount & 0x0f); */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 457 | } |
| 458 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 459 | MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp, |
| 460 | 9, &WmeIe[0], END_OF_ARGS); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 461 | FrameLen += tmp; |
| 462 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 463 | /* */ |
| 464 | /* Let WPA(#221) Element ID on the end of this association frame. */ |
| 465 | /* Otherwise some AP will fail on parsing Element ID and set status fail on Assoc Rsp. */ |
| 466 | /* For example: Put Vendor Specific IE on the front of WPA IE. */ |
| 467 | /* This happens on AP (Model No:Linksys WRK54G) */ |
| 468 | /* */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 469 | if (((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) || |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 470 | (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) || |
| 471 | (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || |
| 472 | (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) |
| 473 | ) |
| 474 | ) { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 475 | u8 RSNIe = IE_WPA; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 476 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 477 | if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) |
| 478 | || (pAd->StaCfg.AuthMode == |
| 479 | Ndis802_11AuthModeWPA2)) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 480 | RSNIe = IE_WPA2; |
| 481 | } |
| 482 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 483 | if ((pAd->StaCfg.WpaSupplicantUP != |
| 484 | WPA_SUPPLICANT_ENABLE) |
| 485 | && (pAd->StaCfg.bRSN_IE_FromWpaSupplicant == FALSE)) |
| 486 | RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, |
| 487 | pAd->StaCfg.WepStatus, BSS0); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 488 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 489 | /* Check for WPA PMK cache list */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 490 | if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 491 | int idx; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 492 | BOOLEAN FoundPMK = FALSE; |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 493 | /* Search chched PMKID, append it if existed */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 494 | for (idx = 0; idx < PMKID_NO; idx++) { |
| 495 | if (NdisEqualMemory |
| 496 | (ApAddr, |
| 497 | &pAd->StaCfg.SavedPMK[idx].BSSID, |
| 498 | 6)) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 499 | FoundPMK = TRUE; |
| 500 | break; |
| 501 | } |
| 502 | } |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 503 | if (FoundPMK) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 504 | /* Set PMK number */ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 505 | *(u16 *)& pAd->StaCfg.RSN_IE[pAd-> |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 506 | StaCfg. |
| 507 | RSNIE_Len] |
| 508 | = 1; |
| 509 | NdisMoveMemory(&pAd->StaCfg. |
| 510 | RSN_IE[pAd->StaCfg. |
| 511 | RSNIE_Len + 2], |
| 512 | &pAd->StaCfg. |
| 513 | SavedPMK[idx].PMKID, 16); |
| 514 | pAd->StaCfg.RSNIE_Len += 18; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 515 | } |
| 516 | } |
| 517 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 518 | if ((pAd->StaCfg.WpaSupplicantUP == |
| 519 | WPA_SUPPLICANT_ENABLE) |
| 520 | && (pAd->StaCfg.bRSN_IE_FromWpaSupplicant == |
| 521 | TRUE)) { |
| 522 | MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp, |
| 523 | pAd->StaCfg.RSNIE_Len, |
| 524 | pAd->StaCfg.RSN_IE, |
| 525 | END_OF_ARGS); |
| 526 | } else { |
| 527 | MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp, |
| 528 | 1, &RSNIe, |
| 529 | 1, &pAd->StaCfg.RSNIE_Len, |
| 530 | pAd->StaCfg.RSNIE_Len, |
| 531 | pAd->StaCfg.RSN_IE, |
| 532 | END_OF_ARGS); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 533 | } |
| 534 | |
| 535 | FrameLen += tmp; |
| 536 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 537 | if ((pAd->StaCfg.WpaSupplicantUP != |
| 538 | WPA_SUPPLICANT_ENABLE) |
| 539 | || (pAd->StaCfg.bRSN_IE_FromWpaSupplicant == |
| 540 | FALSE)) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 541 | /* Append Variable IE */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 542 | NdisMoveMemory(pAd->StaCfg.ReqVarIEs + |
| 543 | VarIesOffset, &RSNIe, 1); |
| 544 | VarIesOffset += 1; |
| 545 | NdisMoveMemory(pAd->StaCfg.ReqVarIEs + |
| 546 | VarIesOffset, |
| 547 | &pAd->StaCfg.RSNIE_Len, 1); |
| 548 | VarIesOffset += 1; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 549 | } |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 550 | NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, |
| 551 | pAd->StaCfg.RSN_IE, |
| 552 | pAd->StaCfg.RSNIE_Len); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 553 | VarIesOffset += pAd->StaCfg.RSNIE_Len; |
| 554 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 555 | /* Set Variable IEs Length */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 556 | pAd->StaCfg.ReqVarIELen = VarIesOffset; |
| 557 | } |
| 558 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 559 | MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen); |
| 560 | MlmeFreeMemory(pAd, pOutBuffer); |
| 561 | |
| 562 | RTMPSetTimer(&pAd->MlmeAux.AssocTimer, Timeout); |
| 563 | pAd->Mlme.AssocMachine.CurrState = ASSOC_WAIT_RSP; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 564 | } else { |
| 565 | DBGPRINT(RT_DEBUG_TRACE, |
Sebastian Dalfuß | 06aea99 | 2009-11-07 17:31:12 +0100 | [diff] [blame^] | 566 | ("ASSOC - MlmeAssocReqAction() sanity check failed. BUG!\n")); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 567 | pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; |
| 568 | Status = MLME_INVALID_FORMAT; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 569 | MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, |
| 570 | &Status); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 571 | } |
| 572 | |
| 573 | } |
| 574 | |
| 575 | /* |
| 576 | ========================================================================== |
| 577 | Description: |
| 578 | mlme reassoc req handling procedure |
| 579 | Parameters: |
| 580 | Elem - |
| 581 | Pre: |
| 582 | -# SSID (Adapter->StaCfg.ssid[]) |
| 583 | -# BSSID (AP address, Adapter->StaCfg.bssid) |
| 584 | -# Supported rates (Adapter->StaCfg.supported_rates[]) |
| 585 | -# Supported rates length (Adapter->StaCfg.supported_rates_len) |
| 586 | -# Tx power (Adapter->StaCfg.tx_power) |
| 587 | |
| 588 | IRQL = DISPATCH_LEVEL |
| 589 | |
| 590 | ========================================================================== |
| 591 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 592 | void MlmeReassocReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 593 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 594 | u8 ApAddr[6]; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 595 | struct rt_header_802_11 ReassocHdr; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 596 | u8 WmeIe[9] = |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 597 | { IE_VENDOR_SPECIFIC, 0x07, 0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, |
| 598 | 0x00 }; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 599 | u16 CapabilityInfo, ListenIntv; |
| 600 | unsigned long Timeout; |
| 601 | unsigned long FrameLen = 0; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 602 | BOOLEAN TimerCancelled; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 603 | int NStatus; |
| 604 | unsigned long tmp; |
| 605 | u8 *pOutBuffer = NULL; |
| 606 | u16 Status; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 607 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 608 | /* Block all authentication request durning WPA block period */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 609 | if (pAd->StaCfg.bBlockAssoc == TRUE) { |
| 610 | DBGPRINT(RT_DEBUG_TRACE, |
| 611 | ("ASSOC - Block ReAssoc request durning WPA block period!\n")); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 612 | pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; |
| 613 | Status = MLME_STATE_MACHINE_REJECT; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 614 | MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, |
| 615 | &Status); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 616 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 617 | /* the parameters are the same as the association */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 618 | else if (MlmeAssocReqSanity |
| 619 | (pAd, Elem->Msg, Elem->MsgLen, ApAddr, &CapabilityInfo, |
| 620 | &Timeout, &ListenIntv)) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 621 | RTMPCancelTimer(&pAd->MlmeAux.ReassocTimer, &TimerCancelled); |
| 622 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 623 | NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 624 | if (NStatus != NDIS_STATUS_SUCCESS) { |
| 625 | DBGPRINT(RT_DEBUG_TRACE, |
| 626 | ("ASSOC - MlmeReassocReqAction() allocate memory failed \n")); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 627 | pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; |
| 628 | Status = MLME_FAIL_NO_RESOURCE; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 629 | MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, |
| 630 | MT2_REASSOC_CONF, 2, &Status); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 631 | return; |
| 632 | } |
| 633 | |
| 634 | COPY_MAC_ADDR(pAd->MlmeAux.Bssid, ApAddr); |
| 635 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 636 | /* make frame, use bssid as the AP address?? */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 637 | DBGPRINT(RT_DEBUG_TRACE, |
| 638 | ("ASSOC - Send RE-ASSOC request...\n")); |
| 639 | MgtMacHeaderInit(pAd, &ReassocHdr, SUBTYPE_REASSOC_REQ, 0, |
| 640 | ApAddr, ApAddr); |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 641 | MakeOutgoingFrame(pOutBuffer, &FrameLen, sizeof(struct rt_header_802_11), |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 642 | &ReassocHdr, 2, &CapabilityInfo, 2, |
| 643 | &ListenIntv, MAC_ADDR_LEN, ApAddr, 1, &SsidIe, |
| 644 | 1, &pAd->MlmeAux.SsidLen, |
| 645 | pAd->MlmeAux.SsidLen, pAd->MlmeAux.Ssid, 1, |
| 646 | &SupRateIe, 1, &pAd->MlmeAux.SupRateLen, |
| 647 | pAd->MlmeAux.SupRateLen, pAd->MlmeAux.SupRate, |
| 648 | END_OF_ARGS); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 649 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 650 | if (pAd->MlmeAux.ExtRateLen != 0) { |
| 651 | MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp, |
| 652 | 1, &ExtRateIe, |
| 653 | 1, &pAd->MlmeAux.ExtRateLen, |
| 654 | pAd->MlmeAux.ExtRateLen, |
| 655 | pAd->MlmeAux.ExtRate, END_OF_ARGS); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 656 | FrameLen += tmp; |
| 657 | } |
| 658 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 659 | if (pAd->MlmeAux.APEdcaParm.bValid) { |
| 660 | if (pAd->CommonCfg.bAPSDCapable |
| 661 | && pAd->MlmeAux.APEdcaParm.bAPSDCapable) { |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 662 | struct rt_qbss_sta_info_parm QosInfo; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 663 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 664 | NdisZeroMemory(&QosInfo, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 665 | sizeof(struct rt_qbss_sta_info_parm)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 666 | QosInfo.UAPSD_AC_BE = pAd->CommonCfg.bAPSDAC_BE; |
| 667 | QosInfo.UAPSD_AC_BK = pAd->CommonCfg.bAPSDAC_BK; |
| 668 | QosInfo.UAPSD_AC_VI = pAd->CommonCfg.bAPSDAC_VI; |
| 669 | QosInfo.UAPSD_AC_VO = pAd->CommonCfg.bAPSDAC_VO; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 670 | QosInfo.MaxSPLength = |
| 671 | pAd->CommonCfg.MaxSPLength; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 672 | WmeIe[8] |= *(u8 *)& QosInfo; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 673 | } |
| 674 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 675 | MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp, |
| 676 | 9, &WmeIe[0], END_OF_ARGS); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 677 | FrameLen += tmp; |
| 678 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 679 | /* HT */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 680 | if ((pAd->MlmeAux.HtCapabilityLen > 0) |
| 681 | && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)) { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 682 | unsigned long TmpLen; |
| 683 | u8 HtLen; |
| 684 | u8 BROADCOM[4] = { 0x0, 0x90, 0x4c, 0x33 }; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 685 | if (pAd->StaActive.SupportedPhyInfo.bPreNHt == TRUE) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 686 | HtLen = SIZE_HT_CAP_IE + 4; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 687 | MakeOutgoingFrame(pOutBuffer + FrameLen, |
| 688 | &TmpLen, 1, &WpaIe, 1, &HtLen, |
| 689 | 4, &BROADCOM[0], |
| 690 | pAd->MlmeAux.HtCapabilityLen, |
| 691 | &pAd->MlmeAux.HtCapability, |
| 692 | END_OF_ARGS); |
| 693 | } else { |
| 694 | MakeOutgoingFrame(pOutBuffer + FrameLen, |
| 695 | &TmpLen, 1, &HtCapIe, 1, |
| 696 | &pAd->MlmeAux.HtCapabilityLen, |
| 697 | pAd->MlmeAux.HtCapabilityLen, |
| 698 | &pAd->MlmeAux.HtCapability, |
| 699 | END_OF_ARGS); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 700 | } |
| 701 | FrameLen += TmpLen; |
| 702 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 703 | /* add Ralink proprietary IE to inform AP this STA is going to use AGGREGATION or PIGGY-BACK+AGGREGATION */ |
| 704 | /* Case I: (Aggregation + Piggy-Back) */ |
| 705 | /* 1. user enable aggregation, AND */ |
| 706 | /* 2. Mac support piggy-back */ |
| 707 | /* 3. AP annouces it's PIGGY-BACK+AGGREGATION-capable in BEACON */ |
| 708 | /* Case II: (Aggregation) */ |
| 709 | /* 1. user enable aggregation, AND */ |
| 710 | /* 2. AP annouces it's AGGREGATION-capable in BEACON */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 711 | if (pAd->CommonCfg.bAggregationCapable) { |
| 712 | if ((pAd->CommonCfg.bPiggyBackCapable) |
| 713 | && ((pAd->MlmeAux.APRalinkIe & 0x00000003) == 3)) { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 714 | unsigned long TmpLen; |
| 715 | u8 RalinkIe[9] = |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 716 | { IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, |
| 717 | 0x03, 0x00, 0x00, 0x00 }; |
| 718 | MakeOutgoingFrame(pOutBuffer + FrameLen, |
| 719 | &TmpLen, 9, RalinkIe, |
| 720 | END_OF_ARGS); |
| 721 | FrameLen += TmpLen; |
| 722 | } else if (pAd->MlmeAux.APRalinkIe & 0x00000001) { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 723 | unsigned long TmpLen; |
| 724 | u8 RalinkIe[9] = |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 725 | { IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, |
| 726 | 0x01, 0x00, 0x00, 0x00 }; |
| 727 | MakeOutgoingFrame(pOutBuffer + FrameLen, |
| 728 | &TmpLen, 9, RalinkIe, |
| 729 | END_OF_ARGS); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 730 | FrameLen += TmpLen; |
| 731 | } |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 732 | } else { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 733 | unsigned long TmpLen; |
| 734 | u8 RalinkIe[9] = |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 735 | { IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x04, |
| 736 | 0x00, 0x00, 0x00 }; |
| 737 | MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen, 9, |
| 738 | RalinkIe, END_OF_ARGS); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 739 | FrameLen += TmpLen; |
| 740 | } |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 741 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 742 | MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen); |
| 743 | MlmeFreeMemory(pAd, pOutBuffer); |
| 744 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 745 | RTMPSetTimer(&pAd->MlmeAux.ReassocTimer, Timeout); /* in mSec */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 746 | pAd->Mlme.AssocMachine.CurrState = REASSOC_WAIT_RSP; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 747 | } else { |
| 748 | DBGPRINT(RT_DEBUG_TRACE, |
Sebastian Dalfuß | 06aea99 | 2009-11-07 17:31:12 +0100 | [diff] [blame^] | 749 | ("ASSOC - MlmeReassocReqAction() sanity check failed. BUG!\n")); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 750 | pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; |
| 751 | Status = MLME_INVALID_FORMAT; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 752 | MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, |
| 753 | &Status); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 754 | } |
| 755 | } |
| 756 | |
| 757 | /* |
| 758 | ========================================================================== |
| 759 | Description: |
| 760 | Upper layer issues disassoc request |
| 761 | Parameters: |
| 762 | Elem - |
| 763 | |
| 764 | IRQL = PASSIVE_LEVEL |
| 765 | |
| 766 | ========================================================================== |
| 767 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 768 | void MlmeDisassocReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 769 | { |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 770 | struct rt_mlme_disassoc_req *pDisassocReq; |
| 771 | struct rt_header_802_11 DisassocHdr; |
| 772 | struct rt_header_802_11 * pDisassocHdr; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 773 | u8 *pOutBuffer = NULL; |
| 774 | unsigned long FrameLen = 0; |
| 775 | int NStatus; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 776 | BOOLEAN TimerCancelled; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 777 | unsigned long Timeout = 500; |
| 778 | u16 Status; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 779 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 780 | /* skip sanity check */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 781 | pDisassocReq = (struct rt_mlme_disassoc_req *)(Elem->Msg); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 782 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 783 | NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 784 | if (NStatus != NDIS_STATUS_SUCCESS) { |
| 785 | DBGPRINT(RT_DEBUG_TRACE, |
| 786 | ("ASSOC - MlmeDisassocReqAction() allocate memory failed\n")); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 787 | pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; |
| 788 | Status = MLME_FAIL_NO_RESOURCE; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 789 | MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DISASSOC_CONF, 2, |
| 790 | &Status); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 791 | return; |
| 792 | } |
| 793 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 794 | RTMPCancelTimer(&pAd->MlmeAux.DisassocTimer, &TimerCancelled); |
| 795 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 796 | DBGPRINT(RT_DEBUG_TRACE, |
| 797 | ("ASSOC - Send DISASSOC request[BSSID::%02x:%02x:%02x:%02x:%02x:%02x (Reason=%d)\n", |
| 798 | pDisassocReq->Addr[0], pDisassocReq->Addr[1], |
| 799 | pDisassocReq->Addr[2], pDisassocReq->Addr[3], |
| 800 | pDisassocReq->Addr[4], pDisassocReq->Addr[5], |
| 801 | pDisassocReq->Reason)); |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 802 | MgtMacHeaderInit(pAd, &DisassocHdr, SUBTYPE_DISASSOC, 0, pDisassocReq->Addr, pDisassocReq->Addr); /* patch peap ttls switching issue */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 803 | MakeOutgoingFrame(pOutBuffer, &FrameLen, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 804 | sizeof(struct rt_header_802_11), &DisassocHdr, |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 805 | 2, &pDisassocReq->Reason, END_OF_ARGS); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 806 | MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen); |
| 807 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 808 | /* To patch Instance and Buffalo(N) AP */ |
| 809 | /* Driver has to send deauth to Instance AP, but Buffalo(N) needs to send disassoc to reset Authenticator's state machine */ |
| 810 | /* Therefore, we send both of them. */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 811 | pDisassocHdr = (struct rt_header_802_11 *) pOutBuffer; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 812 | pDisassocHdr->FC.SubType = SUBTYPE_DEAUTH; |
| 813 | MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen); |
| 814 | |
| 815 | MlmeFreeMemory(pAd, pOutBuffer); |
| 816 | |
| 817 | pAd->StaCfg.DisassocReason = REASON_DISASSOC_STA_LEAVING; |
| 818 | COPY_MAC_ADDR(pAd->StaCfg.DisassocSta, pDisassocReq->Addr); |
| 819 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 820 | RTMPSetTimer(&pAd->MlmeAux.DisassocTimer, Timeout); /* in mSec */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 821 | pAd->Mlme.AssocMachine.CurrState = DISASSOC_WAIT_RSP; |
| 822 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 823 | RtmpOSWrielessEventSend(pAd, SIOCGIWAP, -1, NULL, NULL, 0); |
| 824 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 825 | } |
| 826 | |
| 827 | /* |
| 828 | ========================================================================== |
| 829 | Description: |
| 830 | peer sends assoc rsp back |
| 831 | Parameters: |
| 832 | Elme - MLME message containing the received frame |
| 833 | |
| 834 | IRQL = DISPATCH_LEVEL |
| 835 | |
| 836 | ========================================================================== |
| 837 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 838 | void PeerAssocRspAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 839 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 840 | u16 CapabilityInfo, Status, Aid; |
| 841 | u8 SupRate[MAX_LEN_OF_SUPPORTED_RATES], SupRateLen; |
| 842 | u8 ExtRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRateLen; |
| 843 | u8 Addr2[MAC_ADDR_LEN]; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 844 | BOOLEAN TimerCancelled; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 845 | u8 CkipFlag; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 846 | struct rt_edca_parm EdcaParm; |
| 847 | struct rt_ht_capability_ie HtCapability; |
| 848 | struct rt_add_ht_info_ie AddHtInfo; /* AP might use this additional ht info IE */ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 849 | u8 HtCapabilityLen = 0; |
| 850 | u8 AddHtInfoLen; |
| 851 | u8 NewExtChannelOffset = 0xff; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 852 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 853 | if (PeerAssocRspSanity |
| 854 | (pAd, Elem->Msg, Elem->MsgLen, Addr2, &CapabilityInfo, &Status, |
| 855 | &Aid, SupRate, &SupRateLen, ExtRate, &ExtRateLen, &HtCapability, |
| 856 | &AddHtInfo, &HtCapabilityLen, &AddHtInfoLen, &NewExtChannelOffset, |
| 857 | &EdcaParm, &CkipFlag)) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 858 | /* The frame is for me ? */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 859 | if (MAC_ADDR_EQUAL(Addr2, pAd->MlmeAux.Bssid)) { |
| 860 | DBGPRINT(RT_DEBUG_TRACE, |
| 861 | ("PeerAssocRspAction():ASSOC - receive ASSOC_RSP to me (status=%d)\n", |
| 862 | Status)); |
| 863 | DBGPRINT(RT_DEBUG_TRACE, |
| 864 | ("PeerAssocRspAction():MacTable [%d].AMsduSize = %d. ClientStatusFlags = 0x%lx \n", |
| 865 | Elem->Wcid, |
| 866 | pAd->MacTab.Content[BSSID_WCID].AMsduSize, |
| 867 | pAd->MacTab.Content[BSSID_WCID]. |
| 868 | ClientStatusFlags)); |
| 869 | RTMPCancelTimer(&pAd->MlmeAux.AssocTimer, |
| 870 | &TimerCancelled); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 871 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 872 | if (Status == MLME_SUCCESS) { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 873 | u8 MaxSupportedRateIn500Kbps = 0; |
| 874 | u8 idx; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 875 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 876 | /* supported rates array may not be sorted. sort it and find the maximum rate */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 877 | for (idx = 0; idx < SupRateLen; idx++) { |
| 878 | if (MaxSupportedRateIn500Kbps < |
| 879 | (SupRate[idx] & 0x7f)) |
| 880 | MaxSupportedRateIn500Kbps = |
| 881 | SupRate[idx] & 0x7f; |
| 882 | } |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 883 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 884 | for (idx = 0; idx < ExtRateLen; idx++) { |
| 885 | if (MaxSupportedRateIn500Kbps < |
| 886 | (ExtRate[idx] & 0x7f)) |
| 887 | MaxSupportedRateIn500Kbps = |
| 888 | ExtRate[idx] & 0x7f; |
| 889 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 890 | /* go to procedure listed on page 376 */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 891 | AssocPostProc(pAd, Addr2, CapabilityInfo, Aid, |
| 892 | SupRate, SupRateLen, ExtRate, |
| 893 | ExtRateLen, &EdcaParm, |
| 894 | &HtCapability, HtCapabilityLen, |
| 895 | &AddHtInfo); |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 896 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 897 | StaAddMacTableEntry(pAd, |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 898 | &pAd->MacTab. |
| 899 | Content[BSSID_WCID], |
| 900 | MaxSupportedRateIn500Kbps, |
| 901 | &HtCapability, |
| 902 | HtCapabilityLen, &AddHtInfo, |
| 903 | AddHtInfoLen, |
| 904 | CapabilityInfo); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 905 | } |
| 906 | pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 907 | MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, |
| 908 | MT2_ASSOC_CONF, 2, &Status); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 909 | } |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 910 | } else { |
| 911 | DBGPRINT(RT_DEBUG_TRACE, |
| 912 | ("ASSOC - PeerAssocRspAction() sanity check fail\n")); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 913 | } |
| 914 | } |
| 915 | |
| 916 | /* |
| 917 | ========================================================================== |
| 918 | Description: |
| 919 | peer sends reassoc rsp |
| 920 | Parametrs: |
| 921 | Elem - MLME message cntaining the received frame |
| 922 | |
| 923 | IRQL = DISPATCH_LEVEL |
| 924 | |
| 925 | ========================================================================== |
| 926 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 927 | void PeerReassocRspAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 928 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 929 | u16 CapabilityInfo; |
| 930 | u16 Status; |
| 931 | u16 Aid; |
| 932 | u8 SupRate[MAX_LEN_OF_SUPPORTED_RATES], SupRateLen; |
| 933 | u8 ExtRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRateLen; |
| 934 | u8 Addr2[MAC_ADDR_LEN]; |
| 935 | u8 CkipFlag; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 936 | BOOLEAN TimerCancelled; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 937 | struct rt_edca_parm EdcaParm; |
| 938 | struct rt_ht_capability_ie HtCapability; |
| 939 | struct rt_add_ht_info_ie AddHtInfo; /* AP might use this additional ht info IE */ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 940 | u8 HtCapabilityLen; |
| 941 | u8 AddHtInfoLen; |
| 942 | u8 NewExtChannelOffset = 0xff; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 943 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 944 | if (PeerAssocRspSanity |
| 945 | (pAd, Elem->Msg, Elem->MsgLen, Addr2, &CapabilityInfo, &Status, |
| 946 | &Aid, SupRate, &SupRateLen, ExtRate, &ExtRateLen, &HtCapability, |
| 947 | &AddHtInfo, &HtCapabilityLen, &AddHtInfoLen, &NewExtChannelOffset, |
| 948 | &EdcaParm, &CkipFlag)) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 949 | if (MAC_ADDR_EQUAL(Addr2, pAd->MlmeAux.Bssid)) /* The frame is for me ? */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 950 | { |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 951 | DBGPRINT(RT_DEBUG_TRACE, |
| 952 | ("ASSOC - receive REASSOC_RSP to me (status=%d)\n", |
| 953 | Status)); |
| 954 | RTMPCancelTimer(&pAd->MlmeAux.ReassocTimer, |
| 955 | &TimerCancelled); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 956 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 957 | if (Status == MLME_SUCCESS) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 958 | /* go to procedure listed on page 376 */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 959 | AssocPostProc(pAd, Addr2, CapabilityInfo, Aid, |
| 960 | SupRate, SupRateLen, ExtRate, |
| 961 | ExtRateLen, &EdcaParm, |
| 962 | &HtCapability, HtCapabilityLen, |
| 963 | &AddHtInfo); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 964 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 965 | { |
| 966 | wext_notify_event_assoc(pAd); |
| 967 | RtmpOSWrielessEventSend(pAd, SIOCGIWAP, |
| 968 | -1, |
| 969 | &pAd->MlmeAux. |
| 970 | Bssid[0], NULL, |
| 971 | 0); |
| 972 | } |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 973 | |
| 974 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 975 | /* CkipFlag is no use for reassociate */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 976 | pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; |
| 977 | MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, |
| 978 | MT2_REASSOC_CONF, 2, &Status); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 979 | } |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 980 | } else { |
| 981 | DBGPRINT(RT_DEBUG_TRACE, |
| 982 | ("ASSOC - PeerReassocRspAction() sanity check fail\n")); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 983 | } |
| 984 | |
| 985 | } |
| 986 | |
| 987 | /* |
| 988 | ========================================================================== |
| 989 | Description: |
| 990 | procedures on IEEE 802.11/1999 p.376 |
| 991 | Parametrs: |
| 992 | |
| 993 | IRQL = DISPATCH_LEVEL |
| 994 | |
| 995 | ========================================================================== |
| 996 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 997 | void AssocPostProc(struct rt_rtmp_adapter *pAd, u8 *pAddr2, u16 CapabilityInfo, u16 Aid, u8 SupRate[], u8 SupRateLen, u8 ExtRate[], u8 ExtRateLen, struct rt_edca_parm *pEdcaParm, struct rt_ht_capability_ie * pHtCapability, u8 HtCapabilityLen, struct rt_add_ht_info_ie * pAddHtInfo) /* AP might use this additional ht info IE */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 998 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 999 | unsigned long Idx; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1000 | |
| 1001 | pAd->MlmeAux.BssType = BSS_INFRA; |
| 1002 | COPY_MAC_ADDR(pAd->MlmeAux.Bssid, pAddr2); |
| 1003 | pAd->MlmeAux.Aid = Aid; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1004 | pAd->MlmeAux.CapabilityInfo = |
| 1005 | CapabilityInfo & SUPPORTED_CAPABILITY_INFO; |
Bartlomiej Zolnierkiewicz | 1623267 | 2009-04-26 16:06:00 +0200 | [diff] [blame] | 1006 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1007 | /* Some HT AP might lost WMM IE. We add WMM ourselves. beacuase HT requires QoS on. */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1008 | if ((HtCapabilityLen > 0) && (pEdcaParm->bValid == FALSE)) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1009 | pEdcaParm->bValid = TRUE; |
| 1010 | pEdcaParm->Aifsn[0] = 3; |
| 1011 | pEdcaParm->Aifsn[1] = 7; |
| 1012 | pEdcaParm->Aifsn[2] = 2; |
| 1013 | pEdcaParm->Aifsn[3] = 2; |
| 1014 | |
| 1015 | pEdcaParm->Cwmin[0] = 4; |
| 1016 | pEdcaParm->Cwmin[1] = 4; |
| 1017 | pEdcaParm->Cwmin[2] = 3; |
| 1018 | pEdcaParm->Cwmin[3] = 2; |
| 1019 | |
| 1020 | pEdcaParm->Cwmax[0] = 10; |
| 1021 | pEdcaParm->Cwmax[1] = 10; |
| 1022 | pEdcaParm->Cwmax[2] = 4; |
| 1023 | pEdcaParm->Cwmax[3] = 3; |
| 1024 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1025 | pEdcaParm->Txop[0] = 0; |
| 1026 | pEdcaParm->Txop[1] = 0; |
| 1027 | pEdcaParm->Txop[2] = 96; |
| 1028 | pEdcaParm->Txop[3] = 48; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1029 | |
| 1030 | } |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1031 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1032 | NdisMoveMemory(&pAd->MlmeAux.APEdcaParm, pEdcaParm, sizeof(struct rt_edca_parm)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1033 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1034 | /* filter out un-supported rates */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1035 | pAd->MlmeAux.SupRateLen = SupRateLen; |
| 1036 | NdisMoveMemory(pAd->MlmeAux.SupRate, SupRate, SupRateLen); |
| 1037 | RTMPCheckRates(pAd, pAd->MlmeAux.SupRate, &pAd->MlmeAux.SupRateLen); |
| 1038 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1039 | /* filter out un-supported rates */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1040 | pAd->MlmeAux.ExtRateLen = ExtRateLen; |
| 1041 | NdisMoveMemory(pAd->MlmeAux.ExtRate, ExtRate, ExtRateLen); |
| 1042 | RTMPCheckRates(pAd, pAd->MlmeAux.ExtRate, &pAd->MlmeAux.ExtRateLen); |
| 1043 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1044 | if (HtCapabilityLen > 0) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1045 | RTMPCheckHt(pAd, BSSID_WCID, pHtCapability, pAddHtInfo); |
| 1046 | } |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1047 | DBGPRINT(RT_DEBUG_TRACE, |
| 1048 | ("AssocPostProc===> AP.AMsduSize = %d. ClientStatusFlags = 0x%lx \n", |
| 1049 | pAd->MacTab.Content[BSSID_WCID].AMsduSize, |
| 1050 | pAd->MacTab.Content[BSSID_WCID].ClientStatusFlags)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1051 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1052 | DBGPRINT(RT_DEBUG_TRACE, |
| 1053 | ("AssocPostProc===> (Mmps=%d, AmsduSize=%d, )\n", |
| 1054 | pAd->MacTab.Content[BSSID_WCID].MmpsMode, |
| 1055 | pAd->MacTab.Content[BSSID_WCID].AMsduSize)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1056 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1057 | /* Set New WPA information */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1058 | Idx = BssTableSearch(&pAd->ScanTab, pAddr2, pAd->MlmeAux.Channel); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1059 | if (Idx == BSS_NOT_FOUND) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1060 | DBGPRINT_ERR(("ASSOC - Can't find BSS after receiving Assoc response\n")); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1061 | } else { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1062 | /* Init variable */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1063 | pAd->MacTab.Content[BSSID_WCID].RSNIE_Len = 0; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1064 | NdisZeroMemory(pAd->MacTab.Content[BSSID_WCID].RSN_IE, |
| 1065 | MAX_LEN_OF_RSNIE); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1066 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1067 | /* Store appropriate RSN_IE for WPA SM negotiation later */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1068 | if ((pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) |
| 1069 | && (pAd->ScanTab.BssEntry[Idx].VarIELen != 0)) { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1070 | u8 *pVIE; |
| 1071 | u16 len; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1072 | struct rt_eid * pEid; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1073 | |
| 1074 | pVIE = pAd->ScanTab.BssEntry[Idx].VarIEs; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1075 | len = pAd->ScanTab.BssEntry[Idx].VarIELen; |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1076 | /*KH need to check again */ |
| 1077 | /* Don't allow to go to sleep mode if authmode is WPA-related. */ |
| 1078 | /*This can make Authentication process more smoothly. */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1079 | RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1080 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1081 | while (len > 0) { |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1082 | pEid = (struct rt_eid *) pVIE; |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1083 | /* For WPA/WPAPSK */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1084 | if ((pEid->Eid == IE_WPA) |
| 1085 | && |
| 1086 | (NdisEqualMemory(pEid->Octet, WPA_OUI, 4)) |
| 1087 | && (pAd->StaCfg.AuthMode == |
| 1088 | Ndis802_11AuthModeWPA |
| 1089 | || pAd->StaCfg.AuthMode == |
| 1090 | Ndis802_11AuthModeWPAPSK)) { |
| 1091 | NdisMoveMemory(pAd->MacTab. |
| 1092 | Content[BSSID_WCID]. |
| 1093 | RSN_IE, pVIE, |
| 1094 | (pEid->Len + 2)); |
| 1095 | pAd->MacTab.Content[BSSID_WCID]. |
| 1096 | RSNIE_Len = (pEid->Len + 2); |
| 1097 | DBGPRINT(RT_DEBUG_TRACE, |
| 1098 | ("AssocPostProc===> Store RSN_IE for WPA SM negotiation \n")); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1099 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1100 | /* For WPA2/WPA2PSK */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1101 | else if ((pEid->Eid == IE_RSN) |
| 1102 | && |
| 1103 | (NdisEqualMemory |
| 1104 | (pEid->Octet + 2, RSN_OUI, 3)) |
| 1105 | && (pAd->StaCfg.AuthMode == |
| 1106 | Ndis802_11AuthModeWPA2 |
| 1107 | || pAd->StaCfg.AuthMode == |
| 1108 | Ndis802_11AuthModeWPA2PSK)) { |
| 1109 | NdisMoveMemory(pAd->MacTab. |
| 1110 | Content[BSSID_WCID]. |
| 1111 | RSN_IE, pVIE, |
| 1112 | (pEid->Len + 2)); |
| 1113 | pAd->MacTab.Content[BSSID_WCID]. |
| 1114 | RSNIE_Len = (pEid->Len + 2); |
| 1115 | DBGPRINT(RT_DEBUG_TRACE, |
| 1116 | ("AssocPostProc===> Store RSN_IE for WPA2 SM negotiation \n")); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1117 | } |
| 1118 | |
| 1119 | pVIE += (pEid->Len + 2); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1120 | len -= (pEid->Len + 2); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1121 | } |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1122 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1123 | } |
| 1124 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1125 | if (pAd->MacTab.Content[BSSID_WCID].RSNIE_Len == 0) { |
| 1126 | DBGPRINT(RT_DEBUG_TRACE, |
| 1127 | ("AssocPostProc===> no RSN_IE \n")); |
| 1128 | } else { |
| 1129 | hex_dump("RSN_IE", |
| 1130 | pAd->MacTab.Content[BSSID_WCID].RSN_IE, |
| 1131 | pAd->MacTab.Content[BSSID_WCID].RSNIE_Len); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1132 | } |
| 1133 | } |
| 1134 | } |
| 1135 | |
| 1136 | /* |
| 1137 | ========================================================================== |
| 1138 | Description: |
| 1139 | left part of IEEE 802.11/1999 p.374 |
| 1140 | Parameters: |
| 1141 | Elem - MLME message containing the received frame |
| 1142 | |
| 1143 | IRQL = DISPATCH_LEVEL |
| 1144 | |
| 1145 | ========================================================================== |
| 1146 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1147 | void PeerDisassocAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1148 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1149 | u8 Addr2[MAC_ADDR_LEN]; |
| 1150 | u16 Reason; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1151 | |
| 1152 | DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - PeerDisassocAction()\n")); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1153 | if (PeerDisassocSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Reason)) { |
| 1154 | DBGPRINT(RT_DEBUG_TRACE, |
| 1155 | ("ASSOC - PeerDisassocAction() Reason = %d\n", |
| 1156 | Reason)); |
| 1157 | if (INFRA_ON(pAd) |
| 1158 | && MAC_ADDR_EQUAL(pAd->CommonCfg.Bssid, Addr2)) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1159 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1160 | if (pAd->CommonCfg.bWirelessEvent) { |
| 1161 | RTMPSendWirelessEvent(pAd, |
| 1162 | IW_DISASSOC_EVENT_FLAG, |
| 1163 | pAd->MacTab. |
| 1164 | Content[BSSID_WCID].Addr, |
| 1165 | BSS0, 0); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1166 | } |
| 1167 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1168 | LinkDown(pAd, TRUE); |
| 1169 | pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; |
| 1170 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1171 | RtmpOSWrielessEventSend(pAd, SIOCGIWAP, -1, NULL, NULL, |
| 1172 | 0); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1173 | } |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1174 | } else { |
| 1175 | DBGPRINT(RT_DEBUG_TRACE, |
| 1176 | ("ASSOC - PeerDisassocAction() sanity check fail\n")); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1177 | } |
| 1178 | |
| 1179 | } |
| 1180 | |
| 1181 | /* |
| 1182 | ========================================================================== |
| 1183 | Description: |
| 1184 | what the state machine will do after assoc timeout |
| 1185 | Parameters: |
| 1186 | Elme - |
| 1187 | |
| 1188 | IRQL = DISPATCH_LEVEL |
| 1189 | |
| 1190 | ========================================================================== |
| 1191 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1192 | void AssocTimeoutAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1193 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1194 | u16 Status; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1195 | DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - AssocTimeoutAction\n")); |
| 1196 | pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; |
| 1197 | Status = MLME_REJ_TIMEOUT; |
| 1198 | MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, &Status); |
| 1199 | } |
| 1200 | |
| 1201 | /* |
| 1202 | ========================================================================== |
| 1203 | Description: |
| 1204 | what the state machine will do after reassoc timeout |
| 1205 | |
| 1206 | IRQL = DISPATCH_LEVEL |
| 1207 | |
| 1208 | ========================================================================== |
| 1209 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1210 | void ReassocTimeoutAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1211 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1212 | u16 Status; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1213 | DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - ReassocTimeoutAction\n")); |
| 1214 | pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; |
| 1215 | Status = MLME_REJ_TIMEOUT; |
| 1216 | MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status); |
| 1217 | } |
| 1218 | |
| 1219 | /* |
| 1220 | ========================================================================== |
| 1221 | Description: |
| 1222 | what the state machine will do after disassoc timeout |
| 1223 | |
| 1224 | IRQL = DISPATCH_LEVEL |
| 1225 | |
| 1226 | ========================================================================== |
| 1227 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1228 | void DisassocTimeoutAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1229 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1230 | u16 Status; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1231 | DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - DisassocTimeoutAction\n")); |
| 1232 | pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; |
| 1233 | Status = MLME_SUCCESS; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1234 | MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DISASSOC_CONF, 2, |
| 1235 | &Status); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1236 | } |
| 1237 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1238 | void InvalidStateWhenAssoc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1239 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1240 | u16 Status; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1241 | DBGPRINT(RT_DEBUG_TRACE, |
| 1242 | ("ASSOC - InvalidStateWhenAssoc(state=%ld), reset ASSOC state machine\n", |
| 1243 | pAd->Mlme.AssocMachine.CurrState)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1244 | pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; |
| 1245 | Status = MLME_STATE_MACHINE_REJECT; |
| 1246 | MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, &Status); |
| 1247 | } |
| 1248 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1249 | void InvalidStateWhenReassoc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1250 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1251 | u16 Status; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1252 | DBGPRINT(RT_DEBUG_TRACE, |
| 1253 | ("ASSOC - InvalidStateWhenReassoc(state=%ld), reset ASSOC state machine\n", |
| 1254 | pAd->Mlme.AssocMachine.CurrState)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1255 | pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; |
| 1256 | Status = MLME_STATE_MACHINE_REJECT; |
| 1257 | MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status); |
| 1258 | } |
| 1259 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1260 | void InvalidStateWhenDisassociate(struct rt_rtmp_adapter *pAd, |
| 1261 | struct rt_mlme_queue_elem *Elem) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1262 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1263 | u16 Status; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1264 | DBGPRINT(RT_DEBUG_TRACE, |
| 1265 | ("ASSOC - InvalidStateWhenDisassoc(state=%ld), reset ASSOC state machine\n", |
| 1266 | pAd->Mlme.AssocMachine.CurrState)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1267 | pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; |
| 1268 | Status = MLME_STATE_MACHINE_REJECT; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1269 | MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DISASSOC_CONF, 2, |
| 1270 | &Status); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1271 | } |
| 1272 | |
| 1273 | /* |
| 1274 | ========================================================================== |
| 1275 | Description: |
| 1276 | right part of IEEE 802.11/1999 page 374 |
| 1277 | Note: |
| 1278 | This event should never cause ASSOC state machine perform state |
| 1279 | transition, and has no relationship with CNTL machine. So we separate |
| 1280 | this routine as a service outside of ASSOC state transition table. |
| 1281 | |
| 1282 | IRQL = DISPATCH_LEVEL |
| 1283 | |
| 1284 | ========================================================================== |
| 1285 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1286 | void Cls3errAction(struct rt_rtmp_adapter *pAd, u8 *pAddr) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1287 | { |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1288 | struct rt_header_802_11 DisassocHdr; |
| 1289 | struct rt_header_802_11 * pDisassocHdr; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1290 | u8 *pOutBuffer = NULL; |
| 1291 | unsigned long FrameLen = 0; |
| 1292 | int NStatus; |
| 1293 | u16 Reason = REASON_CLS3ERR; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1294 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1295 | NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1296 | if (NStatus != NDIS_STATUS_SUCCESS) |
| 1297 | return; |
| 1298 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1299 | DBGPRINT(RT_DEBUG_TRACE, |
| 1300 | ("ASSOC - Class 3 Error, Send DISASSOC frame\n")); |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1301 | MgtMacHeaderInit(pAd, &DisassocHdr, SUBTYPE_DISASSOC, 0, pAddr, pAd->CommonCfg.Bssid); /* patch peap ttls switching issue */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1302 | MakeOutgoingFrame(pOutBuffer, &FrameLen, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1303 | sizeof(struct rt_header_802_11), &DisassocHdr, |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1304 | 2, &Reason, END_OF_ARGS); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1305 | MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen); |
| 1306 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1307 | /* To patch Instance and Buffalo(N) AP */ |
| 1308 | /* Driver has to send deauth to Instance AP, but Buffalo(N) needs to send disassoc to reset Authenticator's state machine */ |
| 1309 | /* Therefore, we send both of them. */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1310 | pDisassocHdr = (struct rt_header_802_11 *) pOutBuffer; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1311 | pDisassocHdr->FC.SubType = SUBTYPE_DEAUTH; |
| 1312 | MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen); |
| 1313 | |
| 1314 | MlmeFreeMemory(pAd, pOutBuffer); |
| 1315 | |
| 1316 | pAd->StaCfg.DisassocReason = REASON_CLS3ERR; |
| 1317 | COPY_MAC_ADDR(pAd->StaCfg.DisassocSta, pAddr); |
| 1318 | } |
| 1319 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1320 | int wext_notify_event_assoc(struct rt_rtmp_adapter *pAd) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1321 | { |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1322 | char custom[IW_CUSTOM_MAX] = { 0 }; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1323 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1324 | if (pAd->StaCfg.ReqVarIELen <= IW_CUSTOM_MAX) { |
| 1325 | NdisMoveMemory(custom, pAd->StaCfg.ReqVarIEs, |
| 1326 | pAd->StaCfg.ReqVarIELen); |
| 1327 | RtmpOSWrielessEventSend(pAd, IWEVASSOCREQIE, -1, NULL, custom, |
| 1328 | pAd->StaCfg.ReqVarIELen); |
| 1329 | } else |
| 1330 | DBGPRINT(RT_DEBUG_TRACE, |
| 1331 | ("pAd->StaCfg.ReqVarIELen > MAX_CUSTOM_LEN\n")); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1332 | |
| 1333 | return 0; |
| 1334 | |
| 1335 | } |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1336 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1337 | BOOLEAN StaAddMacTableEntry(struct rt_rtmp_adapter *pAd, |
| 1338 | struct rt_mac_table_entry *pEntry, |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1339 | u8 MaxSupportedRateIn500Kbps, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1340 | struct rt_ht_capability_ie * pHtCapability, |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1341 | u8 HtCapabilityLen, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1342 | struct rt_add_ht_info_ie * pAddHtInfo, |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1343 | u8 AddHtInfoLen, u16 CapabilityInfo) |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1344 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1345 | u8 MaxSupportedRate = RATE_11; |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1346 | |
| 1347 | if (ADHOC_ON(pAd)) |
| 1348 | CLIENT_STATUS_CLEAR_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE); |
| 1349 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1350 | switch (MaxSupportedRateIn500Kbps) { |
| 1351 | case 108: |
| 1352 | MaxSupportedRate = RATE_54; |
| 1353 | break; |
| 1354 | case 96: |
| 1355 | MaxSupportedRate = RATE_48; |
| 1356 | break; |
| 1357 | case 72: |
| 1358 | MaxSupportedRate = RATE_36; |
| 1359 | break; |
| 1360 | case 48: |
| 1361 | MaxSupportedRate = RATE_24; |
| 1362 | break; |
| 1363 | case 36: |
| 1364 | MaxSupportedRate = RATE_18; |
| 1365 | break; |
| 1366 | case 24: |
| 1367 | MaxSupportedRate = RATE_12; |
| 1368 | break; |
| 1369 | case 18: |
| 1370 | MaxSupportedRate = RATE_9; |
| 1371 | break; |
| 1372 | case 12: |
| 1373 | MaxSupportedRate = RATE_6; |
| 1374 | break; |
| 1375 | case 22: |
| 1376 | MaxSupportedRate = RATE_11; |
| 1377 | break; |
| 1378 | case 11: |
| 1379 | MaxSupportedRate = RATE_5_5; |
| 1380 | break; |
| 1381 | case 4: |
| 1382 | MaxSupportedRate = RATE_2; |
| 1383 | break; |
| 1384 | case 2: |
| 1385 | MaxSupportedRate = RATE_1; |
| 1386 | break; |
| 1387 | default: |
| 1388 | MaxSupportedRate = RATE_11; |
| 1389 | break; |
| 1390 | } |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1391 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1392 | if ((pAd->CommonCfg.PhyMode == PHY_11G) |
| 1393 | && (MaxSupportedRate < RATE_FIRST_OFDM_RATE)) |
| 1394 | return FALSE; |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1395 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1396 | /* 11n only */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1397 | if (((pAd->CommonCfg.PhyMode == PHY_11N_2_4G) |
| 1398 | || (pAd->CommonCfg.PhyMode == PHY_11N_5G)) |
| 1399 | && (HtCapabilityLen == 0)) |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1400 | return FALSE; |
| 1401 | |
| 1402 | if (!pEntry) |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1403 | return FALSE; |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1404 | |
| 1405 | NdisAcquireSpinLock(&pAd->MacTabLock); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1406 | if (pEntry) { |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1407 | pEntry->PortSecured = WPA_802_1X_PORT_SECURED; |
| 1408 | if ((MaxSupportedRate < RATE_FIRST_OFDM_RATE) || |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1409 | (pAd->CommonCfg.PhyMode == PHY_11B)) { |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1410 | pEntry->RateLen = 4; |
| 1411 | if (MaxSupportedRate >= RATE_FIRST_OFDM_RATE) |
| 1412 | MaxSupportedRate = RATE_11; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1413 | } else |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1414 | pEntry->RateLen = 12; |
| 1415 | |
| 1416 | pEntry->MaxHTPhyMode.word = 0; |
| 1417 | pEntry->MinHTPhyMode.word = 0; |
| 1418 | pEntry->HTPhyMode.word = 0; |
| 1419 | pEntry->MaxSupportedRate = MaxSupportedRate; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1420 | if (pEntry->MaxSupportedRate < RATE_FIRST_OFDM_RATE) { |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1421 | pEntry->MaxHTPhyMode.field.MODE = MODE_CCK; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1422 | pEntry->MaxHTPhyMode.field.MCS = |
| 1423 | pEntry->MaxSupportedRate; |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1424 | pEntry->MinHTPhyMode.field.MODE = MODE_CCK; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1425 | pEntry->MinHTPhyMode.field.MCS = |
| 1426 | pEntry->MaxSupportedRate; |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1427 | pEntry->HTPhyMode.field.MODE = MODE_CCK; |
| 1428 | pEntry->HTPhyMode.field.MCS = pEntry->MaxSupportedRate; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1429 | } else { |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1430 | pEntry->MaxHTPhyMode.field.MODE = MODE_OFDM; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1431 | pEntry->MaxHTPhyMode.field.MCS = |
| 1432 | OfdmRateToRxwiMCS[pEntry->MaxSupportedRate]; |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1433 | pEntry->MinHTPhyMode.field.MODE = MODE_OFDM; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1434 | pEntry->MinHTPhyMode.field.MCS = |
| 1435 | OfdmRateToRxwiMCS[pEntry->MaxSupportedRate]; |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1436 | pEntry->HTPhyMode.field.MODE = MODE_OFDM; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1437 | pEntry->HTPhyMode.field.MCS = |
| 1438 | OfdmRateToRxwiMCS[pEntry->MaxSupportedRate]; |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1439 | } |
| 1440 | pEntry->CapabilityInfo = CapabilityInfo; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1441 | CLIENT_STATUS_CLEAR_FLAG(pEntry, |
| 1442 | fCLIENT_STATUS_AGGREGATION_CAPABLE); |
| 1443 | CLIENT_STATUS_CLEAR_FLAG(pEntry, |
| 1444 | fCLIENT_STATUS_PIGGYBACK_CAPABLE); |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1445 | } |
| 1446 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1447 | NdisZeroMemory(&pEntry->HTCapability, sizeof(pEntry->HTCapability)); |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1448 | /* If this Entry supports 802.11n, upgrade to HT rate. */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1449 | if ((HtCapabilityLen != 0) |
| 1450 | && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)) { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1451 | u8 j, bitmask; /*k,bitmask; */ |
| 1452 | char i; |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1453 | |
| 1454 | if (ADHOC_ON(pAd)) |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1455 | CLIENT_STATUS_SET_FLAG(pEntry, |
| 1456 | fCLIENT_STATUS_WMM_CAPABLE); |
| 1457 | if ((pHtCapability->HtCapInfo.GF) |
| 1458 | && (pAd->CommonCfg.DesiredHtPhy.GF)) { |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1459 | pEntry->MaxHTPhyMode.field.MODE = MODE_HTGREENFIELD; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1460 | } else { |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1461 | pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX; |
| 1462 | pAd->MacTab.fAnyStationNonGF = TRUE; |
| 1463 | pAd->CommonCfg.AddHTInfo.AddHtInfo2.NonGfPresent = 1; |
| 1464 | } |
| 1465 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1466 | if ((pHtCapability->HtCapInfo.ChannelWidth) && |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1467 | (pAd->CommonCfg.DesiredHtPhy.ChannelWidth) && |
| 1468 | ((pAd->StaCfg.BssType == BSS_INFRA) |
| 1469 | || ((pAd->StaCfg.BssType == BSS_ADHOC) |
| 1470 | && (pAddHtInfo->AddHtInfo.ExtChanOffset == |
| 1471 | pAd->CommonCfg.AddHTInfo.AddHtInfo. |
| 1472 | ExtChanOffset)))) { |
| 1473 | pEntry->MaxHTPhyMode.field.BW = BW_40; |
| 1474 | pEntry->MaxHTPhyMode.field.ShortGI = |
| 1475 | ((pAd->CommonCfg.DesiredHtPhy. |
| 1476 | ShortGIfor40) & (pHtCapability->HtCapInfo. |
| 1477 | ShortGIfor40)); |
| 1478 | } else { |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1479 | pEntry->MaxHTPhyMode.field.BW = BW_20; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1480 | pEntry->MaxHTPhyMode.field.ShortGI = |
| 1481 | ((pAd->CommonCfg.DesiredHtPhy. |
| 1482 | ShortGIfor20) & (pHtCapability->HtCapInfo. |
| 1483 | ShortGIfor20)); |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1484 | pAd->MacTab.fAnyStation20Only = TRUE; |
| 1485 | } |
| 1486 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1487 | /* 3*3 */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1488 | if (pAd->MACVersion >= RALINK_2883_VERSION |
| 1489 | && pAd->MACVersion < RALINK_3070_VERSION) |
| 1490 | pEntry->MaxHTPhyMode.field.TxBF = |
| 1491 | pAd->CommonCfg.RegTransmitSetting.field.TxBF; |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1492 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1493 | /* find max fixed rate */ |
| 1494 | for (i = 23; i >= 0; i--) /* 3*3 */ |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1495 | { |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1496 | j = i / 8; |
| 1497 | bitmask = (1 << (i - (j * 8))); |
| 1498 | if ((pAd->StaCfg.DesiredHtPhyInfo.MCSSet[j] & bitmask) |
| 1499 | && (pHtCapability->MCSSet[j] & bitmask)) { |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1500 | pEntry->MaxHTPhyMode.field.MCS = i; |
| 1501 | break; |
| 1502 | } |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1503 | if (i == 0) |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1504 | break; |
| 1505 | } |
| 1506 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1507 | if (pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO) { |
| 1508 | if (pAd->StaCfg.DesiredTransmitSetting.field.MCS == 32) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1509 | /* Fix MCS as HT Duplicated Mode */ |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1510 | pEntry->MaxHTPhyMode.field.BW = 1; |
| 1511 | pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX; |
| 1512 | pEntry->MaxHTPhyMode.field.STBC = 0; |
| 1513 | pEntry->MaxHTPhyMode.field.ShortGI = 0; |
| 1514 | pEntry->MaxHTPhyMode.field.MCS = 32; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1515 | } else if (pEntry->MaxHTPhyMode.field.MCS > |
| 1516 | pAd->StaCfg.HTPhyMode.field.MCS) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1517 | /* STA supports fixed MCS */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1518 | pEntry->MaxHTPhyMode.field.MCS = |
| 1519 | pAd->StaCfg.HTPhyMode.field.MCS; |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1520 | } |
| 1521 | } |
| 1522 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1523 | pEntry->MaxHTPhyMode.field.STBC = |
| 1524 | (pHtCapability->HtCapInfo. |
| 1525 | RxSTBC & (pAd->CommonCfg.DesiredHtPhy.TxSTBC)); |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1526 | pEntry->MpduDensity = pHtCapability->HtCapParm.MpduDensity; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1527 | pEntry->MaxRAmpduFactor = |
| 1528 | pHtCapability->HtCapParm.MaxRAmpduFactor; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1529 | pEntry->MmpsMode = (u8)pHtCapability->HtCapInfo.MimoPs; |
| 1530 | pEntry->AMsduSize = (u8)pHtCapability->HtCapInfo.AMsduSize; |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1531 | pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word; |
| 1532 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1533 | if (pAd->CommonCfg.DesiredHtPhy.AmsduEnable |
| 1534 | && (pAd->CommonCfg.REGBACapability.field.AutoBA == FALSE)) |
| 1535 | CLIENT_STATUS_SET_FLAG(pEntry, |
| 1536 | fCLIENT_STATUS_AMSDU_INUSED); |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1537 | if (pHtCapability->HtCapInfo.ShortGIfor20) |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1538 | CLIENT_STATUS_SET_FLAG(pEntry, |
| 1539 | fCLIENT_STATUS_SGI20_CAPABLE); |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1540 | if (pHtCapability->HtCapInfo.ShortGIfor40) |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1541 | CLIENT_STATUS_SET_FLAG(pEntry, |
| 1542 | fCLIENT_STATUS_SGI40_CAPABLE); |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1543 | if (pHtCapability->HtCapInfo.TxSTBC) |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1544 | CLIENT_STATUS_SET_FLAG(pEntry, |
| 1545 | fCLIENT_STATUS_TxSTBC_CAPABLE); |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1546 | if (pHtCapability->HtCapInfo.RxSTBC) |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1547 | CLIENT_STATUS_SET_FLAG(pEntry, |
| 1548 | fCLIENT_STATUS_RxSTBC_CAPABLE); |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1549 | if (pHtCapability->ExtHtCapInfo.PlusHTC) |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1550 | CLIENT_STATUS_SET_FLAG(pEntry, |
| 1551 | fCLIENT_STATUS_HTC_CAPABLE); |
| 1552 | if (pAd->CommonCfg.bRdg |
| 1553 | && pHtCapability->ExtHtCapInfo.RDGSupport) |
| 1554 | CLIENT_STATUS_SET_FLAG(pEntry, |
| 1555 | fCLIENT_STATUS_RDG_CAPABLE); |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1556 | if (pHtCapability->ExtHtCapInfo.MCSFeedback == 0x03) |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1557 | CLIENT_STATUS_SET_FLAG(pEntry, |
| 1558 | fCLIENT_STATUS_MCSFEEDBACK_CAPABLE); |
| 1559 | NdisMoveMemory(&pEntry->HTCapability, pHtCapability, |
| 1560 | HtCapabilityLen); |
| 1561 | } else { |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1562 | pAd->MacTab.fAnyStationIsLegacy = TRUE; |
| 1563 | } |
| 1564 | |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1565 | pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word; |
| 1566 | pEntry->CurrTxRate = pEntry->MaxSupportedRate; |
| 1567 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1568 | /* Set asic auto fall back */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1569 | if (pAd->StaCfg.bAutoTxRateSwitch == TRUE) { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1570 | u8 *pTable; |
| 1571 | u8 TableSize = 0; |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1572 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1573 | MlmeSelectTxRateTable(pAd, pEntry, &pTable, &TableSize, |
| 1574 | &pEntry->CurrTxRateIndex); |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1575 | pEntry->bAutoTxRateSwitch = TRUE; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1576 | } else { |
| 1577 | pEntry->HTPhyMode.field.MODE = pAd->StaCfg.HTPhyMode.field.MODE; |
| 1578 | pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS; |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1579 | pEntry->bAutoTxRateSwitch = FALSE; |
| 1580 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1581 | /* If the legacy mode is set, overwrite the transmit setting of this entry. */ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1582 | RTMPUpdateLegacyTxSetting((u8)pAd->StaCfg. |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1583 | DesiredTransmitSetting.field. |
| 1584 | FixedTxMode, pEntry); |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1585 | } |
| 1586 | |
| 1587 | pEntry->PortSecured = WPA_802_1X_PORT_SECURED; |
| 1588 | pEntry->Sst = SST_ASSOC; |
| 1589 | pEntry->AuthState = AS_AUTH_OPEN; |
| 1590 | pEntry->AuthMode = pAd->StaCfg.AuthMode; |
| 1591 | pEntry->WepStatus = pAd->StaCfg.WepStatus; |
| 1592 | |
| 1593 | NdisReleaseSpinLock(&pAd->MacTabLock); |
| 1594 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1595 | { |
| 1596 | union iwreq_data wrqu; |
| 1597 | wext_notify_event_assoc(pAd); |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1598 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1599 | memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN); |
| 1600 | memcpy(wrqu.ap_addr.sa_data, pAd->MlmeAux.Bssid, MAC_ADDR_LEN); |
| 1601 | wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL); |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1602 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1603 | } |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1604 | return TRUE; |
| 1605 | } |