blob: 7055f229e511d9f93d8153da922d0ac7f6141f1d [file] [log] [blame]
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001/*
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 Zolnierkiewicz51126de2009-12-11 12:23:15 -080039u8 CipherWpaTemplate[] = {
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -080040 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 Zolnierkiewicz0f65bec2009-12-11 12:23:14 -080049};
Greg Kroah-Hartman91980992008-10-28 14:48:09 -070050
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -080051u8 CipherWpa2Template[] = {
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -080052 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 Zolnierkiewicz0f65bec2009-12-11 12:23:14 -080061};
Greg Kroah-Hartman91980992008-10-28 14:48:09 -070062
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -080063u8 Ccx2IeInfo[] = { 0x00, 0x40, 0x96, 0x03, 0x02 };
Greg Kroah-Hartman91980992008-10-28 14:48:09 -070064
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 Zolnierkiewicz62eb7342009-12-11 12:23:16 -080076void AssocStateMachineInit(struct rt_rtmp_adapter *pAd,
77 struct rt_state_machine *S, OUT STATE_MACHINE_FUNC Trans[])
Greg Kroah-Hartman91980992008-10-28 14:48:09 -070078{
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -080079 StateMachineInit(S, Trans, MAX_ASSOC_STATE, MAX_ASSOC_MSG,
80 (STATE_MACHINE_FUNC) Drop, ASSOC_IDLE,
81 ASSOC_MACHINE_BASE);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -070082
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -080083 /* first column */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -080084 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-Hartman91980992008-10-28 14:48:09 -070092
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -080093 /* second column */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -080094 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 Zolnierkiewicz82819582009-12-11 12:23:15 -0800105 /* */
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 Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800109 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-Hartman91980992008-10-28 14:48:09 -0700113
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800114 /* third column */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800115 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 Zolnierkiewicz82819582009-12-11 12:23:15 -0800126 /* */
127 /* Patch, AP doesn't send Reassociate Rsp frame to Station. */
128 /* */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800129 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-Hartman91980992008-10-28 14:48:09 -0700133
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800134 /* fourth column */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800135 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-Hartman91980992008-10-28 14:48:09 -0700146
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800147 /* initialize the timer */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800148 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-Hartman91980992008-10-28 14:48:09 -0700154}
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 Zolnierkiewicz51126de2009-12-11 12:23:15 -0800168void AssocTimeout(void *SystemSpecific1,
169 void *FunctionContext,
170 void *SystemSpecific2, void *SystemSpecific3)
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700171{
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -0800172 struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)FunctionContext;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700173
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800174 /* Do nothing if the driver is starting halt state. */
175 /* This might happen when timer already been fired before cancel timer with mlmehalt */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800176 if (RTMP_TEST_FLAG
177 (pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700178 return;
179
180 MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_ASSOC_TIMEOUT, 0, NULL);
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +0200181 RTMP_MLME_HANDLER(pAd);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700182}
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 Zolnierkiewicz51126de2009-12-11 12:23:15 -0800196void ReassocTimeout(void *SystemSpecific1,
197 void *FunctionContext,
198 void *SystemSpecific2, void *SystemSpecific3)
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700199{
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -0800200 struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)FunctionContext;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700201
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800202 /* Do nothing if the driver is starting halt state. */
203 /* This might happen when timer already been fired before cancel timer with mlmehalt */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800204 if (RTMP_TEST_FLAG
205 (pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700206 return;
207
208 MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_REASSOC_TIMEOUT, 0, NULL);
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +0200209 RTMP_MLME_HANDLER(pAd);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700210}
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 Zolnierkiewicz51126de2009-12-11 12:23:15 -0800224void DisassocTimeout(void *SystemSpecific1,
225 void *FunctionContext,
226 void *SystemSpecific2, void *SystemSpecific3)
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700227{
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -0800228 struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)FunctionContext;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700229
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800230 /* Do nothing if the driver is starting halt state. */
231 /* This might happen when timer already been fired before cancel timer with mlmehalt */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800232 if (RTMP_TEST_FLAG
233 (pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700234 return;
235
236 MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_DISASSOC_TIMEOUT, 0, NULL);
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +0200237 RTMP_MLME_HANDLER(pAd);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700238}
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 Zolnierkiewicz62eb7342009-12-11 12:23:16 -0800262void MlmeAssocReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700263{
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800264 u8 ApAddr[6];
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -0800265 struct rt_header_802_11 AssocHdr;
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800266 u8 WmeIe[9] =
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800267 { IE_VENDOR_SPECIFIC, 0x07, 0x00, 0x50, 0xf2, 0x02, 0x00, 0x01,
268 0x00 };
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800269 u16 ListenIntv;
270 unsigned long Timeout;
271 u16 CapabilityInfo;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800272 BOOLEAN TimerCancelled;
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800273 u8 *pOutBuffer = NULL;
274 int NStatus;
275 unsigned long FrameLen = 0;
276 unsigned long tmp;
277 u16 VarIesOffset;
278 u16 Status;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700279
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800280 /* Block all authentication request durning WPA block period */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800281 if (pAd->StaCfg.bBlockAssoc == TRUE) {
282 DBGPRINT(RT_DEBUG_TRACE,
283 ("ASSOC - Block Assoc request durning WPA block period!\n"));
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700284 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
285 Status = MLME_STATE_MACHINE_REJECT;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800286 MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2,
287 &Status);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700288 }
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800289 /* check sanity first */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800290 else if (MlmeAssocReqSanity
291 (pAd, Elem->Msg, Elem->MsgLen, ApAddr, &CapabilityInfo,
292 &Timeout, &ListenIntv)) {
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700293 RTMPCancelTimer(&pAd->MlmeAux.AssocTimer, &TimerCancelled);
294 COPY_MAC_ADDR(pAd->MlmeAux.Bssid, ApAddr);
295
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800296 /* Get an unused nonpaged memory */
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700297 NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800298 if (NStatus != NDIS_STATUS_SUCCESS) {
299 DBGPRINT(RT_DEBUG_TRACE,
300 ("ASSOC - MlmeAssocReqAction() allocate memory failed \n"));
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700301 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
302 Status = MLME_FAIL_NO_RESOURCE;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800303 MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE,
304 MT2_ASSOC_CONF, 2, &Status);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700305 return;
306 }
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800307 /* Add by James 03/06/27 */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800308 pAd->StaCfg.AssocInfo.Length =
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -0800309 sizeof(struct rt_ndis_802_11_association_information);
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800310 /* Association don't need to report MAC address */
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700311 pAd->StaCfg.AssocInfo.AvailableRequestFixedIEs =
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800312 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 Zolnierkiewicz82819582009-12-11 12:23:15 -0800318 /* Only reassociate need this */
319 /*COPY_MAC_ADDR(pAd->StaCfg.AssocInfo.RequestFixedIEs.CurrentAPAddress, ApAddr); */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800320 pAd->StaCfg.AssocInfo.OffsetRequestIEs =
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -0800321 sizeof(struct rt_ndis_802_11_association_information);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700322
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800323 NdisZeroMemory(pAd->StaCfg.ReqVarIEs, MAX_VIE_LEN);
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800324 /* First add SSID */
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700325 VarIesOffset = 0;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800326 NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &SsidIe,
327 1);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700328 VarIesOffset += 1;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800329 NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset,
330 &pAd->MlmeAux.SsidLen, 1);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700331 VarIesOffset += 1;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800332 NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset,
333 pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700334 VarIesOffset += pAd->MlmeAux.SsidLen;
335
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800336 /* Second add Supported rates */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800337 NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &SupRateIe,
338 1);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700339 VarIesOffset += 1;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800340 NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset,
341 &pAd->MlmeAux.SupRateLen, 1);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700342 VarIesOffset += 1;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800343 NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset,
344 pAd->MlmeAux.SupRate, pAd->MlmeAux.SupRateLen);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700345 VarIesOffset += pAd->MlmeAux.SupRateLen;
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800346 /* End Add by James */
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700347
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800348 if ((pAd->CommonCfg.Channel > 14) &&
349 (pAd->CommonCfg.bIEEE80211H == TRUE))
350 CapabilityInfo |= 0x0100;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700351
352 DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - Send ASSOC request...\n"));
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800353 MgtMacHeaderInit(pAd, &AssocHdr, SUBTYPE_ASSOC_REQ, 0, ApAddr,
354 ApAddr);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700355
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800356 /* Build basic frame first */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800357 MakeOutgoingFrame(pOutBuffer, &FrameLen,
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -0800358 sizeof(struct rt_header_802_11), &AssocHdr,
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800359 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-Hartman91980992008-10-28 14:48:09 -0700368
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800369 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-Hartman91980992008-10-28 14:48:09 -0700375 FrameLen += tmp;
376 }
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800377 /* HT */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800378 if ((pAd->MlmeAux.HtCapabilityLen > 0)
379 && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)) {
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800380 unsigned long TmpLen;
381 u8 HtLen;
382 u8 BROADCOM[4] = { 0x0, 0x90, 0x4c, 0x33 };
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800383 if (pAd->StaActive.SupportedPhyInfo.bPreNHt == TRUE) {
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700384 HtLen = SIZE_HT_CAP_IE + 4;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800385 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-Hartman91980992008-10-28 14:48:09 -0700398 }
399 FrameLen += TmpLen;
400 }
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800401 /* 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 Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800409 if (pAd->CommonCfg.bAggregationCapable) {
410 if ((pAd->CommonCfg.bPiggyBackCapable)
411 && ((pAd->MlmeAux.APRalinkIe & 0x00000003) == 3)) {
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800412 unsigned long TmpLen;
413 u8 RalinkIe[9] =
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800414 { 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 Zolnierkiewicz51126de2009-12-11 12:23:15 -0800421 unsigned long TmpLen;
422 u8 RalinkIe[9] =
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800423 { 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-Hartman91980992008-10-28 14:48:09 -0700428 FrameLen += TmpLen;
429 }
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800430 } else {
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800431 unsigned long TmpLen;
432 u8 RalinkIe[9] =
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800433 { 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-Hartman91980992008-10-28 14:48:09 -0700437 FrameLen += TmpLen;
438 }
439
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800440 if (pAd->MlmeAux.APEdcaParm.bValid) {
441 if (pAd->CommonCfg.bAPSDCapable
442 && pAd->MlmeAux.APEdcaParm.bAPSDCapable) {
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -0800443 struct rt_qbss_sta_info_parm QosInfo;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700444
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800445 NdisZeroMemory(&QosInfo,
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -0800446 sizeof(struct rt_qbss_sta_info_parm));
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700447 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 Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800451 QosInfo.MaxSPLength =
452 pAd->CommonCfg.MaxSPLength;
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800453 WmeIe[8] |= *(u8 *)& QosInfo;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800454 } else {
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800455 /* The Parameter Set Count is set to ¡§0¡¨ in the association request frames */
456 /* WmeIe[8] |= (pAd->MlmeAux.APEdcaParm.EdcaUpdateCount & 0x0f); */
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700457 }
458
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800459 MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
460 9, &WmeIe[0], END_OF_ARGS);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700461 FrameLen += tmp;
462 }
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800463 /* */
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-Hartman91980992008-10-28 14:48:09 -0700469 if (((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800470 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
471 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
472 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2)
473 )
474 ) {
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800475 u8 RSNIe = IE_WPA;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700476
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800477 if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
478 || (pAd->StaCfg.AuthMode ==
479 Ndis802_11AuthModeWPA2)) {
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700480 RSNIe = IE_WPA2;
481 }
482
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800483 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-Hartman91980992008-10-28 14:48:09 -0700488
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800489 /* Check for WPA PMK cache list */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800490 if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) {
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800491 int idx;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800492 BOOLEAN FoundPMK = FALSE;
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800493 /* Search chched PMKID, append it if existed */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800494 for (idx = 0; idx < PMKID_NO; idx++) {
495 if (NdisEqualMemory
496 (ApAddr,
497 &pAd->StaCfg.SavedPMK[idx].BSSID,
498 6)) {
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700499 FoundPMK = TRUE;
500 break;
501 }
502 }
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800503 if (FoundPMK) {
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800504 /* Set PMK number */
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800505 *(u16 *)& pAd->StaCfg.RSN_IE[pAd->
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800506 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-Hartman91980992008-10-28 14:48:09 -0700515 }
516 }
517
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800518 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-Hartman91980992008-10-28 14:48:09 -0700533 }
534
535 FrameLen += tmp;
536
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800537 if ((pAd->StaCfg.WpaSupplicantUP !=
538 WPA_SUPPLICANT_ENABLE)
539 || (pAd->StaCfg.bRSN_IE_FromWpaSupplicant ==
540 FALSE)) {
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800541 /* Append Variable IE */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800542 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-Hartman91980992008-10-28 14:48:09 -0700549 }
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800550 NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset,
551 pAd->StaCfg.RSN_IE,
552 pAd->StaCfg.RSNIE_Len);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700553 VarIesOffset += pAd->StaCfg.RSNIE_Len;
554
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800555 /* Set Variable IEs Length */
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700556 pAd->StaCfg.ReqVarIELen = VarIesOffset;
557 }
558
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700559 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 Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800564 } else {
565 DBGPRINT(RT_DEBUG_TRACE,
Sebastian Dalfuß06aea992009-11-07 17:31:12 +0100566 ("ASSOC - MlmeAssocReqAction() sanity check failed. BUG!\n"));
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700567 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
568 Status = MLME_INVALID_FORMAT;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800569 MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2,
570 &Status);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700571 }
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 Zolnierkiewicz62eb7342009-12-11 12:23:16 -0800592void MlmeReassocReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700593{
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800594 u8 ApAddr[6];
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -0800595 struct rt_header_802_11 ReassocHdr;
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800596 u8 WmeIe[9] =
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800597 { IE_VENDOR_SPECIFIC, 0x07, 0x00, 0x50, 0xf2, 0x02, 0x00, 0x01,
598 0x00 };
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800599 u16 CapabilityInfo, ListenIntv;
600 unsigned long Timeout;
601 unsigned long FrameLen = 0;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800602 BOOLEAN TimerCancelled;
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800603 int NStatus;
604 unsigned long tmp;
605 u8 *pOutBuffer = NULL;
606 u16 Status;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700607
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800608 /* Block all authentication request durning WPA block period */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800609 if (pAd->StaCfg.bBlockAssoc == TRUE) {
610 DBGPRINT(RT_DEBUG_TRACE,
611 ("ASSOC - Block ReAssoc request durning WPA block period!\n"));
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700612 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
613 Status = MLME_STATE_MACHINE_REJECT;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800614 MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2,
615 &Status);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700616 }
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800617 /* the parameters are the same as the association */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800618 else if (MlmeAssocReqSanity
619 (pAd, Elem->Msg, Elem->MsgLen, ApAddr, &CapabilityInfo,
620 &Timeout, &ListenIntv)) {
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700621 RTMPCancelTimer(&pAd->MlmeAux.ReassocTimer, &TimerCancelled);
622
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800623 NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800624 if (NStatus != NDIS_STATUS_SUCCESS) {
625 DBGPRINT(RT_DEBUG_TRACE,
626 ("ASSOC - MlmeReassocReqAction() allocate memory failed \n"));
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700627 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
628 Status = MLME_FAIL_NO_RESOURCE;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800629 MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE,
630 MT2_REASSOC_CONF, 2, &Status);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700631 return;
632 }
633
634 COPY_MAC_ADDR(pAd->MlmeAux.Bssid, ApAddr);
635
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800636 /* make frame, use bssid as the AP address?? */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800637 DBGPRINT(RT_DEBUG_TRACE,
638 ("ASSOC - Send RE-ASSOC request...\n"));
639 MgtMacHeaderInit(pAd, &ReassocHdr, SUBTYPE_REASSOC_REQ, 0,
640 ApAddr, ApAddr);
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -0800641 MakeOutgoingFrame(pOutBuffer, &FrameLen, sizeof(struct rt_header_802_11),
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800642 &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-Hartman91980992008-10-28 14:48:09 -0700649
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800650 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-Hartman91980992008-10-28 14:48:09 -0700656 FrameLen += tmp;
657 }
658
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800659 if (pAd->MlmeAux.APEdcaParm.bValid) {
660 if (pAd->CommonCfg.bAPSDCapable
661 && pAd->MlmeAux.APEdcaParm.bAPSDCapable) {
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -0800662 struct rt_qbss_sta_info_parm QosInfo;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700663
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800664 NdisZeroMemory(&QosInfo,
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -0800665 sizeof(struct rt_qbss_sta_info_parm));
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700666 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 Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800670 QosInfo.MaxSPLength =
671 pAd->CommonCfg.MaxSPLength;
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800672 WmeIe[8] |= *(u8 *)& QosInfo;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700673 }
674
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800675 MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
676 9, &WmeIe[0], END_OF_ARGS);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700677 FrameLen += tmp;
678 }
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800679 /* HT */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800680 if ((pAd->MlmeAux.HtCapabilityLen > 0)
681 && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)) {
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800682 unsigned long TmpLen;
683 u8 HtLen;
684 u8 BROADCOM[4] = { 0x0, 0x90, 0x4c, 0x33 };
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800685 if (pAd->StaActive.SupportedPhyInfo.bPreNHt == TRUE) {
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700686 HtLen = SIZE_HT_CAP_IE + 4;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800687 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-Hartman91980992008-10-28 14:48:09 -0700700 }
701 FrameLen += TmpLen;
702 }
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800703 /* 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 Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800711 if (pAd->CommonCfg.bAggregationCapable) {
712 if ((pAd->CommonCfg.bPiggyBackCapable)
713 && ((pAd->MlmeAux.APRalinkIe & 0x00000003) == 3)) {
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800714 unsigned long TmpLen;
715 u8 RalinkIe[9] =
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800716 { 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 Zolnierkiewicz51126de2009-12-11 12:23:15 -0800723 unsigned long TmpLen;
724 u8 RalinkIe[9] =
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800725 { 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-Hartman91980992008-10-28 14:48:09 -0700730 FrameLen += TmpLen;
731 }
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800732 } else {
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800733 unsigned long TmpLen;
734 u8 RalinkIe[9] =
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800735 { 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-Hartman91980992008-10-28 14:48:09 -0700739 FrameLen += TmpLen;
740 }
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700741
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700742 MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
743 MlmeFreeMemory(pAd, pOutBuffer);
744
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800745 RTMPSetTimer(&pAd->MlmeAux.ReassocTimer, Timeout); /* in mSec */
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700746 pAd->Mlme.AssocMachine.CurrState = REASSOC_WAIT_RSP;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800747 } else {
748 DBGPRINT(RT_DEBUG_TRACE,
Sebastian Dalfuß06aea992009-11-07 17:31:12 +0100749 ("ASSOC - MlmeReassocReqAction() sanity check failed. BUG!\n"));
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700750 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
751 Status = MLME_INVALID_FORMAT;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800752 MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2,
753 &Status);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700754 }
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 Zolnierkiewicz62eb7342009-12-11 12:23:16 -0800768void MlmeDisassocReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700769{
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -0800770 struct rt_mlme_disassoc_req *pDisassocReq;
771 struct rt_header_802_11 DisassocHdr;
772 struct rt_header_802_11 * pDisassocHdr;
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800773 u8 *pOutBuffer = NULL;
774 unsigned long FrameLen = 0;
775 int NStatus;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800776 BOOLEAN TimerCancelled;
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800777 unsigned long Timeout = 500;
778 u16 Status;
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +0200779
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800780 /* skip sanity check */
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -0800781 pDisassocReq = (struct rt_mlme_disassoc_req *)(Elem->Msg);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700782
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800783 NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800784 if (NStatus != NDIS_STATUS_SUCCESS) {
785 DBGPRINT(RT_DEBUG_TRACE,
786 ("ASSOC - MlmeDisassocReqAction() allocate memory failed\n"));
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700787 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
788 Status = MLME_FAIL_NO_RESOURCE;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800789 MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DISASSOC_CONF, 2,
790 &Status);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700791 return;
792 }
793
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700794 RTMPCancelTimer(&pAd->MlmeAux.DisassocTimer, &TimerCancelled);
795
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800796 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 Zolnierkiewicz82819582009-12-11 12:23:15 -0800802 MgtMacHeaderInit(pAd, &DisassocHdr, SUBTYPE_DISASSOC, 0, pDisassocReq->Addr, pDisassocReq->Addr); /* patch peap ttls switching issue */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800803 MakeOutgoingFrame(pOutBuffer, &FrameLen,
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -0800804 sizeof(struct rt_header_802_11), &DisassocHdr,
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800805 2, &pDisassocReq->Reason, END_OF_ARGS);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700806 MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
807
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800808 /* 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 Zolnierkiewicz62eb7342009-12-11 12:23:16 -0800811 pDisassocHdr = (struct rt_header_802_11 *) pOutBuffer;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700812 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 Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800820 RTMPSetTimer(&pAd->MlmeAux.DisassocTimer, Timeout); /* in mSec */
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700821 pAd->Mlme.AssocMachine.CurrState = DISASSOC_WAIT_RSP;
822
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +0200823 RtmpOSWrielessEventSend(pAd, SIOCGIWAP, -1, NULL, NULL, 0);
824
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700825}
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 Zolnierkiewicz62eb7342009-12-11 12:23:16 -0800838void PeerAssocRspAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700839{
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800840 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 Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800844 BOOLEAN TimerCancelled;
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800845 u8 CkipFlag;
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -0800846 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 Zolnierkiewicz51126de2009-12-11 12:23:15 -0800849 u8 HtCapabilityLen = 0;
850 u8 AddHtInfoLen;
851 u8 NewExtChannelOffset = 0xff;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700852
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800853 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 Zolnierkiewicz82819582009-12-11 12:23:15 -0800858 /* The frame is for me ? */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800859 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 Zolnierkiewiczca97b832009-09-22 20:44:07 +0200871
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800872 if (Status == MLME_SUCCESS) {
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800873 u8 MaxSupportedRateIn500Kbps = 0;
874 u8 idx;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700875
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800876 /* supported rates array may not be sorted. sort it and find the maximum rate */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800877 for (idx = 0; idx < SupRateLen; idx++) {
878 if (MaxSupportedRateIn500Kbps <
879 (SupRate[idx] & 0x7f))
880 MaxSupportedRateIn500Kbps =
881 SupRate[idx] & 0x7f;
882 }
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +0200883
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800884 for (idx = 0; idx < ExtRateLen; idx++) {
885 if (MaxSupportedRateIn500Kbps <
886 (ExtRate[idx] & 0x7f))
887 MaxSupportedRateIn500Kbps =
888 ExtRate[idx] & 0x7f;
889 }
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800890 /* go to procedure listed on page 376 */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800891 AssocPostProc(pAd, Addr2, CapabilityInfo, Aid,
892 SupRate, SupRateLen, ExtRate,
893 ExtRateLen, &EdcaParm,
894 &HtCapability, HtCapabilityLen,
895 &AddHtInfo);
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +0200896
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +0200897 StaAddMacTableEntry(pAd,
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800898 &pAd->MacTab.
899 Content[BSSID_WCID],
900 MaxSupportedRateIn500Kbps,
901 &HtCapability,
902 HtCapabilityLen, &AddHtInfo,
903 AddHtInfoLen,
904 CapabilityInfo);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700905 }
906 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800907 MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE,
908 MT2_ASSOC_CONF, 2, &Status);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700909 }
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800910 } else {
911 DBGPRINT(RT_DEBUG_TRACE,
912 ("ASSOC - PeerAssocRspAction() sanity check fail\n"));
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700913 }
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 Zolnierkiewicz62eb7342009-12-11 12:23:16 -0800927void PeerReassocRspAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700928{
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800929 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 Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800936 BOOLEAN TimerCancelled;
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -0800937 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 Zolnierkiewicz51126de2009-12-11 12:23:15 -0800940 u8 HtCapabilityLen;
941 u8 AddHtInfoLen;
942 u8 NewExtChannelOffset = 0xff;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700943
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800944 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 Zolnierkiewicz82819582009-12-11 12:23:15 -0800949 if (MAC_ADDR_EQUAL(Addr2, pAd->MlmeAux.Bssid)) /* The frame is for me ? */
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700950 {
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800951 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-Hartman91980992008-10-28 14:48:09 -0700956
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800957 if (Status == MLME_SUCCESS) {
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800958 /* go to procedure listed on page 376 */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800959 AssocPostProc(pAd, Addr2, CapabilityInfo, Aid,
960 SupRate, SupRateLen, ExtRate,
961 ExtRateLen, &EdcaParm,
962 &HtCapability, HtCapabilityLen,
963 &AddHtInfo);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700964
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800965 {
966 wext_notify_event_assoc(pAd);
967 RtmpOSWrielessEventSend(pAd, SIOCGIWAP,
968 -1,
969 &pAd->MlmeAux.
970 Bssid[0], NULL,
971 0);
972 }
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700973
974 }
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -0800975 /* CkipFlag is no use for reassociate */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800976 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
977 MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE,
978 MT2_REASSOC_CONF, 2, &Status);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700979 }
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -0800980 } else {
981 DBGPRINT(RT_DEBUG_TRACE,
982 ("ASSOC - PeerReassocRspAction() sanity check fail\n"));
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700983 }
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 Zolnierkiewicz62eb7342009-12-11 12:23:16 -0800997void 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-Hartman91980992008-10-28 14:48:09 -0700998{
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800999 unsigned long Idx;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001000
1001 pAd->MlmeAux.BssType = BSS_INFRA;
1002 COPY_MAC_ADDR(pAd->MlmeAux.Bssid, pAddr2);
1003 pAd->MlmeAux.Aid = Aid;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001004 pAd->MlmeAux.CapabilityInfo =
1005 CapabilityInfo & SUPPORTED_CAPABILITY_INFO;
Bartlomiej Zolnierkiewicz16232672009-04-26 16:06:00 +02001006
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -08001007 /* Some HT AP might lost WMM IE. We add WMM ourselves. beacuase HT requires QoS on. */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001008 if ((HtCapabilityLen > 0) && (pEdcaParm->bValid == FALSE)) {
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001009 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 Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001025 pEdcaParm->Txop[0] = 0;
1026 pEdcaParm->Txop[1] = 0;
1027 pEdcaParm->Txop[2] = 96;
1028 pEdcaParm->Txop[3] = 48;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001029
1030 }
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001031
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -08001032 NdisMoveMemory(&pAd->MlmeAux.APEdcaParm, pEdcaParm, sizeof(struct rt_edca_parm));
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001033
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -08001034 /* filter out un-supported rates */
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001035 pAd->MlmeAux.SupRateLen = SupRateLen;
1036 NdisMoveMemory(pAd->MlmeAux.SupRate, SupRate, SupRateLen);
1037 RTMPCheckRates(pAd, pAd->MlmeAux.SupRate, &pAd->MlmeAux.SupRateLen);
1038
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -08001039 /* filter out un-supported rates */
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001040 pAd->MlmeAux.ExtRateLen = ExtRateLen;
1041 NdisMoveMemory(pAd->MlmeAux.ExtRate, ExtRate, ExtRateLen);
1042 RTMPCheckRates(pAd, pAd->MlmeAux.ExtRate, &pAd->MlmeAux.ExtRateLen);
1043
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001044 if (HtCapabilityLen > 0) {
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001045 RTMPCheckHt(pAd, BSSID_WCID, pHtCapability, pAddHtInfo);
1046 }
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001047 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-Hartman91980992008-10-28 14:48:09 -07001051
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001052 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-Hartman91980992008-10-28 14:48:09 -07001056
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -08001057 /* Set New WPA information */
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001058 Idx = BssTableSearch(&pAd->ScanTab, pAddr2, pAd->MlmeAux.Channel);
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001059 if (Idx == BSS_NOT_FOUND) {
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001060 DBGPRINT_ERR(("ASSOC - Can't find BSS after receiving Assoc response\n"));
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001061 } else {
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -08001062 /* Init variable */
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001063 pAd->MacTab.Content[BSSID_WCID].RSNIE_Len = 0;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001064 NdisZeroMemory(pAd->MacTab.Content[BSSID_WCID].RSN_IE,
1065 MAX_LEN_OF_RSNIE);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001066
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -08001067 /* Store appropriate RSN_IE for WPA SM negotiation later */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001068 if ((pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
1069 && (pAd->ScanTab.BssEntry[Idx].VarIELen != 0)) {
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -08001070 u8 *pVIE;
1071 u16 len;
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -08001072 struct rt_eid * pEid;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001073
1074 pVIE = pAd->ScanTab.BssEntry[Idx].VarIEs;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001075 len = pAd->ScanTab.BssEntry[Idx].VarIELen;
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -08001076 /*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 Zolnierkiewiczca97b832009-09-22 20:44:07 +02001079 RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001080
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001081 while (len > 0) {
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -08001082 pEid = (struct rt_eid *) pVIE;
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -08001083 /* For WPA/WPAPSK */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001084 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-Hartman91980992008-10-28 14:48:09 -07001099 }
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -08001100 /* For WPA2/WPA2PSK */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001101 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-Hartman91980992008-10-28 14:48:09 -07001117 }
1118
1119 pVIE += (pEid->Len + 2);
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001120 len -= (pEid->Len + 2);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001121 }
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +02001122
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001123 }
1124
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001125 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-Hartman91980992008-10-28 14:48:09 -07001132 }
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 Zolnierkiewicz62eb7342009-12-11 12:23:16 -08001147void PeerDisassocAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001148{
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -08001149 u8 Addr2[MAC_ADDR_LEN];
1150 u16 Reason;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001151
1152 DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - PeerDisassocAction()\n"));
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001153 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-Hartman91980992008-10-28 14:48:09 -07001159
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001160 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-Hartman91980992008-10-28 14:48:09 -07001166 }
1167
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001168 LinkDown(pAd, TRUE);
1169 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
1170
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001171 RtmpOSWrielessEventSend(pAd, SIOCGIWAP, -1, NULL, NULL,
1172 0);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001173 }
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001174 } else {
1175 DBGPRINT(RT_DEBUG_TRACE,
1176 ("ASSOC - PeerDisassocAction() sanity check fail\n"));
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001177 }
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 Zolnierkiewicz62eb7342009-12-11 12:23:16 -08001192void AssocTimeoutAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001193{
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -08001194 u16 Status;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001195 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 Zolnierkiewicz62eb7342009-12-11 12:23:16 -08001210void ReassocTimeoutAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001211{
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -08001212 u16 Status;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001213 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 Zolnierkiewicz62eb7342009-12-11 12:23:16 -08001228void DisassocTimeoutAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001229{
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -08001230 u16 Status;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001231 DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - DisassocTimeoutAction\n"));
1232 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
1233 Status = MLME_SUCCESS;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001234 MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DISASSOC_CONF, 2,
1235 &Status);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001236}
1237
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -08001238void InvalidStateWhenAssoc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001239{
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -08001240 u16 Status;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001241 DBGPRINT(RT_DEBUG_TRACE,
1242 ("ASSOC - InvalidStateWhenAssoc(state=%ld), reset ASSOC state machine\n",
1243 pAd->Mlme.AssocMachine.CurrState));
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001244 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 Zolnierkiewicz62eb7342009-12-11 12:23:16 -08001249void InvalidStateWhenReassoc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001250{
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -08001251 u16 Status;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001252 DBGPRINT(RT_DEBUG_TRACE,
1253 ("ASSOC - InvalidStateWhenReassoc(state=%ld), reset ASSOC state machine\n",
1254 pAd->Mlme.AssocMachine.CurrState));
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001255 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 Zolnierkiewicz62eb7342009-12-11 12:23:16 -08001260void InvalidStateWhenDisassociate(struct rt_rtmp_adapter *pAd,
1261 struct rt_mlme_queue_elem *Elem)
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001262{
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -08001263 u16 Status;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001264 DBGPRINT(RT_DEBUG_TRACE,
1265 ("ASSOC - InvalidStateWhenDisassoc(state=%ld), reset ASSOC state machine\n",
1266 pAd->Mlme.AssocMachine.CurrState));
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001267 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
1268 Status = MLME_STATE_MACHINE_REJECT;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001269 MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DISASSOC_CONF, 2,
1270 &Status);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001271}
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 Zolnierkiewicz62eb7342009-12-11 12:23:16 -08001286void Cls3errAction(struct rt_rtmp_adapter *pAd, u8 *pAddr)
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001287{
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -08001288 struct rt_header_802_11 DisassocHdr;
1289 struct rt_header_802_11 * pDisassocHdr;
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -08001290 u8 *pOutBuffer = NULL;
1291 unsigned long FrameLen = 0;
1292 int NStatus;
1293 u16 Reason = REASON_CLS3ERR;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001294
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -08001295 NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001296 if (NStatus != NDIS_STATUS_SUCCESS)
1297 return;
1298
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001299 DBGPRINT(RT_DEBUG_TRACE,
1300 ("ASSOC - Class 3 Error, Send DISASSOC frame\n"));
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -08001301 MgtMacHeaderInit(pAd, &DisassocHdr, SUBTYPE_DISASSOC, 0, pAddr, pAd->CommonCfg.Bssid); /* patch peap ttls switching issue */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001302 MakeOutgoingFrame(pOutBuffer, &FrameLen,
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -08001303 sizeof(struct rt_header_802_11), &DisassocHdr,
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001304 2, &Reason, END_OF_ARGS);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001305 MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
1306
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -08001307 /* 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 Zolnierkiewicz62eb7342009-12-11 12:23:16 -08001310 pDisassocHdr = (struct rt_header_802_11 *) pOutBuffer;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001311 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 Zolnierkiewicz62eb7342009-12-11 12:23:16 -08001320int wext_notify_event_assoc(struct rt_rtmp_adapter *pAd)
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001321{
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001322 char custom[IW_CUSTOM_MAX] = { 0 };
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001323
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001324 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-Hartman91980992008-10-28 14:48:09 -07001332
1333 return 0;
1334
1335}
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001336
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -08001337BOOLEAN StaAddMacTableEntry(struct rt_rtmp_adapter *pAd,
1338 struct rt_mac_table_entry *pEntry,
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -08001339 u8 MaxSupportedRateIn500Kbps,
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -08001340 struct rt_ht_capability_ie * pHtCapability,
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -08001341 u8 HtCapabilityLen,
Bartlomiej Zolnierkiewicz62eb7342009-12-11 12:23:16 -08001342 struct rt_add_ht_info_ie * pAddHtInfo,
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -08001343 u8 AddHtInfoLen, u16 CapabilityInfo)
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001344{
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -08001345 u8 MaxSupportedRate = RATE_11;
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001346
1347 if (ADHOC_ON(pAd))
1348 CLIENT_STATUS_CLEAR_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE);
1349
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001350 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 Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001391
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001392 if ((pAd->CommonCfg.PhyMode == PHY_11G)
1393 && (MaxSupportedRate < RATE_FIRST_OFDM_RATE))
1394 return FALSE;
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001395
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -08001396 /* 11n only */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001397 if (((pAd->CommonCfg.PhyMode == PHY_11N_2_4G)
1398 || (pAd->CommonCfg.PhyMode == PHY_11N_5G))
1399 && (HtCapabilityLen == 0))
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001400 return FALSE;
1401
1402 if (!pEntry)
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001403 return FALSE;
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001404
1405 NdisAcquireSpinLock(&pAd->MacTabLock);
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001406 if (pEntry) {
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001407 pEntry->PortSecured = WPA_802_1X_PORT_SECURED;
1408 if ((MaxSupportedRate < RATE_FIRST_OFDM_RATE) ||
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001409 (pAd->CommonCfg.PhyMode == PHY_11B)) {
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001410 pEntry->RateLen = 4;
1411 if (MaxSupportedRate >= RATE_FIRST_OFDM_RATE)
1412 MaxSupportedRate = RATE_11;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001413 } else
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001414 pEntry->RateLen = 12;
1415
1416 pEntry->MaxHTPhyMode.word = 0;
1417 pEntry->MinHTPhyMode.word = 0;
1418 pEntry->HTPhyMode.word = 0;
1419 pEntry->MaxSupportedRate = MaxSupportedRate;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001420 if (pEntry->MaxSupportedRate < RATE_FIRST_OFDM_RATE) {
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001421 pEntry->MaxHTPhyMode.field.MODE = MODE_CCK;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001422 pEntry->MaxHTPhyMode.field.MCS =
1423 pEntry->MaxSupportedRate;
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001424 pEntry->MinHTPhyMode.field.MODE = MODE_CCK;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001425 pEntry->MinHTPhyMode.field.MCS =
1426 pEntry->MaxSupportedRate;
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001427 pEntry->HTPhyMode.field.MODE = MODE_CCK;
1428 pEntry->HTPhyMode.field.MCS = pEntry->MaxSupportedRate;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001429 } else {
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001430 pEntry->MaxHTPhyMode.field.MODE = MODE_OFDM;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001431 pEntry->MaxHTPhyMode.field.MCS =
1432 OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001433 pEntry->MinHTPhyMode.field.MODE = MODE_OFDM;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001434 pEntry->MinHTPhyMode.field.MCS =
1435 OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001436 pEntry->HTPhyMode.field.MODE = MODE_OFDM;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001437 pEntry->HTPhyMode.field.MCS =
1438 OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001439 }
1440 pEntry->CapabilityInfo = CapabilityInfo;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001441 CLIENT_STATUS_CLEAR_FLAG(pEntry,
1442 fCLIENT_STATUS_AGGREGATION_CAPABLE);
1443 CLIENT_STATUS_CLEAR_FLAG(pEntry,
1444 fCLIENT_STATUS_PIGGYBACK_CAPABLE);
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001445 }
1446
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +02001447 NdisZeroMemory(&pEntry->HTCapability, sizeof(pEntry->HTCapability));
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -08001448 /* If this Entry supports 802.11n, upgrade to HT rate. */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001449 if ((HtCapabilityLen != 0)
1450 && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)) {
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -08001451 u8 j, bitmask; /*k,bitmask; */
1452 char i;
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001453
1454 if (ADHOC_ON(pAd))
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001455 CLIENT_STATUS_SET_FLAG(pEntry,
1456 fCLIENT_STATUS_WMM_CAPABLE);
1457 if ((pHtCapability->HtCapInfo.GF)
1458 && (pAd->CommonCfg.DesiredHtPhy.GF)) {
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001459 pEntry->MaxHTPhyMode.field.MODE = MODE_HTGREENFIELD;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001460 } else {
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001461 pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
1462 pAd->MacTab.fAnyStationNonGF = TRUE;
1463 pAd->CommonCfg.AddHTInfo.AddHtInfo2.NonGfPresent = 1;
1464 }
1465
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +02001466 if ((pHtCapability->HtCapInfo.ChannelWidth) &&
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001467 (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 Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001479 pEntry->MaxHTPhyMode.field.BW = BW_20;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001480 pEntry->MaxHTPhyMode.field.ShortGI =
1481 ((pAd->CommonCfg.DesiredHtPhy.
1482 ShortGIfor20) & (pHtCapability->HtCapInfo.
1483 ShortGIfor20));
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001484 pAd->MacTab.fAnyStation20Only = TRUE;
1485 }
1486
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -08001487 /* 3*3 */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001488 if (pAd->MACVersion >= RALINK_2883_VERSION
1489 && pAd->MACVersion < RALINK_3070_VERSION)
1490 pEntry->MaxHTPhyMode.field.TxBF =
1491 pAd->CommonCfg.RegTransmitSetting.field.TxBF;
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001492
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -08001493 /* find max fixed rate */
1494 for (i = 23; i >= 0; i--) /* 3*3 */
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001495 {
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001496 j = i / 8;
1497 bitmask = (1 << (i - (j * 8)));
1498 if ((pAd->StaCfg.DesiredHtPhyInfo.MCSSet[j] & bitmask)
1499 && (pHtCapability->MCSSet[j] & bitmask)) {
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001500 pEntry->MaxHTPhyMode.field.MCS = i;
1501 break;
1502 }
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001503 if (i == 0)
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001504 break;
1505 }
1506
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001507 if (pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO) {
1508 if (pAd->StaCfg.DesiredTransmitSetting.field.MCS == 32) {
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -08001509 /* Fix MCS as HT Duplicated Mode */
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001510 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 Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001515 } else if (pEntry->MaxHTPhyMode.field.MCS >
1516 pAd->StaCfg.HTPhyMode.field.MCS) {
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -08001517 /* STA supports fixed MCS */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001518 pEntry->MaxHTPhyMode.field.MCS =
1519 pAd->StaCfg.HTPhyMode.field.MCS;
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001520 }
1521 }
1522
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001523 pEntry->MaxHTPhyMode.field.STBC =
1524 (pHtCapability->HtCapInfo.
1525 RxSTBC & (pAd->CommonCfg.DesiredHtPhy.TxSTBC));
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001526 pEntry->MpduDensity = pHtCapability->HtCapParm.MpduDensity;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001527 pEntry->MaxRAmpduFactor =
1528 pHtCapability->HtCapParm.MaxRAmpduFactor;
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -08001529 pEntry->MmpsMode = (u8)pHtCapability->HtCapInfo.MimoPs;
1530 pEntry->AMsduSize = (u8)pHtCapability->HtCapInfo.AMsduSize;
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001531 pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
1532
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001533 if (pAd->CommonCfg.DesiredHtPhy.AmsduEnable
1534 && (pAd->CommonCfg.REGBACapability.field.AutoBA == FALSE))
1535 CLIENT_STATUS_SET_FLAG(pEntry,
1536 fCLIENT_STATUS_AMSDU_INUSED);
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001537 if (pHtCapability->HtCapInfo.ShortGIfor20)
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001538 CLIENT_STATUS_SET_FLAG(pEntry,
1539 fCLIENT_STATUS_SGI20_CAPABLE);
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001540 if (pHtCapability->HtCapInfo.ShortGIfor40)
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001541 CLIENT_STATUS_SET_FLAG(pEntry,
1542 fCLIENT_STATUS_SGI40_CAPABLE);
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001543 if (pHtCapability->HtCapInfo.TxSTBC)
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001544 CLIENT_STATUS_SET_FLAG(pEntry,
1545 fCLIENT_STATUS_TxSTBC_CAPABLE);
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001546 if (pHtCapability->HtCapInfo.RxSTBC)
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001547 CLIENT_STATUS_SET_FLAG(pEntry,
1548 fCLIENT_STATUS_RxSTBC_CAPABLE);
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001549 if (pHtCapability->ExtHtCapInfo.PlusHTC)
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001550 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 Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001556 if (pHtCapability->ExtHtCapInfo.MCSFeedback == 0x03)
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001557 CLIENT_STATUS_SET_FLAG(pEntry,
1558 fCLIENT_STATUS_MCSFEEDBACK_CAPABLE);
1559 NdisMoveMemory(&pEntry->HTCapability, pHtCapability,
1560 HtCapabilityLen);
1561 } else {
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001562 pAd->MacTab.fAnyStationIsLegacy = TRUE;
1563 }
1564
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001565 pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
1566 pEntry->CurrTxRate = pEntry->MaxSupportedRate;
1567
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -08001568 /* Set asic auto fall back */
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001569 if (pAd->StaCfg.bAutoTxRateSwitch == TRUE) {
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -08001570 u8 *pTable;
1571 u8 TableSize = 0;
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001572
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001573 MlmeSelectTxRateTable(pAd, pEntry, &pTable, &TableSize,
1574 &pEntry->CurrTxRateIndex);
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001575 pEntry->bAutoTxRateSwitch = TRUE;
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001576 } else {
1577 pEntry->HTPhyMode.field.MODE = pAd->StaCfg.HTPhyMode.field.MODE;
1578 pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001579 pEntry->bAutoTxRateSwitch = FALSE;
1580
Bartlomiej Zolnierkiewicz82819582009-12-11 12:23:15 -08001581 /* If the legacy mode is set, overwrite the transmit setting of this entry. */
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -08001582 RTMPUpdateLegacyTxSetting((u8)pAd->StaCfg.
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001583 DesiredTransmitSetting.field.
1584 FixedTxMode, pEntry);
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001585 }
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 Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001595 {
1596 union iwreq_data wrqu;
1597 wext_notify_event_assoc(pAd);
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001598
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001599 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 Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001602
Bartlomiej Zolnierkiewicz0f65bec2009-12-11 12:23:14 -08001603 }
Bartlomiej Zolnierkiewicz5f5d2df2009-04-26 16:06:29 +02001604 return TRUE;
1605}