2 *************************************************************************
4 * 5F., No.36, Taiyuan St., Jhubei City,
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
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. *
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. *
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. *
25 *************************************************************************
34 -------- ---------- ----------------------------------------------
35 John 2004-9-3 porting from RT2500
38 #include "../rt_config.h"
41 UCHAR CipherWpaTemplate
[] = {
44 0x00, 0x50, 0xf2, 0x01, // oui
45 0x01, 0x00, // Version
46 0x00, 0x50, 0xf2, 0x02, // Multicast
47 0x01, 0x00, // Number of unicast
48 0x00, 0x50, 0xf2, 0x02, // unicast
49 0x01, 0x00, // number of authentication method
50 0x00, 0x50, 0xf2, 0x01 // authentication
53 UCHAR CipherWpa2Template
[] = {
56 0x01, 0x00, // Version
57 0x00, 0x0f, 0xac, 0x02, // group cipher, TKIP
58 0x01, 0x00, // number of pairwise
59 0x00, 0x0f, 0xac, 0x02, // unicast
60 0x01, 0x00, // number of authentication method
61 0x00, 0x0f, 0xac, 0x02, // authentication
62 0x00, 0x00, // RSN capability
65 UCHAR Ccx2IeInfo
[] = { 0x00, 0x40, 0x96, 0x03, 0x02};
68 ==========================================================================
70 association state machine init, including state transition and timer init
72 S - pointer to the association state machine
76 ==========================================================================
78 VOID
AssocStateMachineInit(
81 OUT STATE_MACHINE_FUNC Trans
[])
83 StateMachineInit(S
, Trans
, MAX_ASSOC_STATE
, MAX_ASSOC_MSG
, (STATE_MACHINE_FUNC
)Drop
, ASSOC_IDLE
, ASSOC_MACHINE_BASE
);
86 StateMachineSetAction(S
, ASSOC_IDLE
, MT2_MLME_ASSOC_REQ
, (STATE_MACHINE_FUNC
)MlmeAssocReqAction
);
87 StateMachineSetAction(S
, ASSOC_IDLE
, MT2_MLME_REASSOC_REQ
, (STATE_MACHINE_FUNC
)MlmeReassocReqAction
);
88 StateMachineSetAction(S
, ASSOC_IDLE
, MT2_MLME_DISASSOC_REQ
, (STATE_MACHINE_FUNC
)MlmeDisassocReqAction
);
89 StateMachineSetAction(S
, ASSOC_IDLE
, MT2_PEER_DISASSOC_REQ
, (STATE_MACHINE_FUNC
)PeerDisassocAction
);
92 StateMachineSetAction(S
, ASSOC_WAIT_RSP
, MT2_MLME_ASSOC_REQ
, (STATE_MACHINE_FUNC
)InvalidStateWhenAssoc
);
93 StateMachineSetAction(S
, ASSOC_WAIT_RSP
, MT2_MLME_REASSOC_REQ
, (STATE_MACHINE_FUNC
)InvalidStateWhenReassoc
);
94 StateMachineSetAction(S
, ASSOC_WAIT_RSP
, MT2_MLME_DISASSOC_REQ
, (STATE_MACHINE_FUNC
)InvalidStateWhenDisassociate
);
95 StateMachineSetAction(S
, ASSOC_WAIT_RSP
, MT2_PEER_DISASSOC_REQ
, (STATE_MACHINE_FUNC
)PeerDisassocAction
);
96 StateMachineSetAction(S
, ASSOC_WAIT_RSP
, MT2_PEER_ASSOC_RSP
, (STATE_MACHINE_FUNC
)PeerAssocRspAction
);
98 // Patch 3Com AP MOde:3CRWE454G72
99 // We send Assoc request frame to this AP, it always send Reassoc Rsp not Associate Rsp.
101 StateMachineSetAction(S
, ASSOC_WAIT_RSP
, MT2_PEER_REASSOC_RSP
, (STATE_MACHINE_FUNC
)PeerAssocRspAction
);
102 StateMachineSetAction(S
, ASSOC_WAIT_RSP
, MT2_ASSOC_TIMEOUT
, (STATE_MACHINE_FUNC
)AssocTimeoutAction
);
105 StateMachineSetAction(S
, REASSOC_WAIT_RSP
, MT2_MLME_ASSOC_REQ
, (STATE_MACHINE_FUNC
)InvalidStateWhenAssoc
);
106 StateMachineSetAction(S
, REASSOC_WAIT_RSP
, MT2_MLME_REASSOC_REQ
, (STATE_MACHINE_FUNC
)InvalidStateWhenReassoc
);
107 StateMachineSetAction(S
, REASSOC_WAIT_RSP
, MT2_MLME_DISASSOC_REQ
, (STATE_MACHINE_FUNC
)InvalidStateWhenDisassociate
);
108 StateMachineSetAction(S
, REASSOC_WAIT_RSP
, MT2_PEER_DISASSOC_REQ
, (STATE_MACHINE_FUNC
)PeerDisassocAction
);
109 StateMachineSetAction(S
, REASSOC_WAIT_RSP
, MT2_PEER_REASSOC_RSP
, (STATE_MACHINE_FUNC
)PeerReassocRspAction
);
111 // Patch, AP doesn't send Reassociate Rsp frame to Station.
113 StateMachineSetAction(S
, REASSOC_WAIT_RSP
, MT2_PEER_ASSOC_RSP
, (STATE_MACHINE_FUNC
)PeerReassocRspAction
);
114 StateMachineSetAction(S
, REASSOC_WAIT_RSP
, MT2_REASSOC_TIMEOUT
, (STATE_MACHINE_FUNC
)ReassocTimeoutAction
);
117 StateMachineSetAction(S
, DISASSOC_WAIT_RSP
, MT2_MLME_ASSOC_REQ
, (STATE_MACHINE_FUNC
)InvalidStateWhenAssoc
);
118 StateMachineSetAction(S
, DISASSOC_WAIT_RSP
, MT2_MLME_REASSOC_REQ
, (STATE_MACHINE_FUNC
)InvalidStateWhenReassoc
);
119 StateMachineSetAction(S
, DISASSOC_WAIT_RSP
, MT2_MLME_DISASSOC_REQ
, (STATE_MACHINE_FUNC
)InvalidStateWhenDisassociate
);
120 StateMachineSetAction(S
, DISASSOC_WAIT_RSP
, MT2_PEER_DISASSOC_REQ
, (STATE_MACHINE_FUNC
)PeerDisassocAction
);
121 StateMachineSetAction(S
, DISASSOC_WAIT_RSP
, MT2_DISASSOC_TIMEOUT
, (STATE_MACHINE_FUNC
)DisassocTimeoutAction
);
123 // initialize the timer
124 RTMPInitTimer(pAd
, &pAd
->MlmeAux
.AssocTimer
, GET_TIMER_FUNCTION(AssocTimeout
), pAd
, FALSE
);
125 RTMPInitTimer(pAd
, &pAd
->MlmeAux
.ReassocTimer
, GET_TIMER_FUNCTION(ReassocTimeout
), pAd
, FALSE
);
126 RTMPInitTimer(pAd
, &pAd
->MlmeAux
.DisassocTimer
, GET_TIMER_FUNCTION(DisassocTimeout
), pAd
, FALSE
);
130 ==========================================================================
132 Association timeout procedure. After association timeout, this function
133 will be called and it will put a message into the MLME queue
135 Standard timer parameters
137 IRQL = DISPATCH_LEVEL
139 ==========================================================================
141 VOID
AssocTimeout(IN PVOID SystemSpecific1
,
142 IN PVOID FunctionContext
,
143 IN PVOID SystemSpecific2
,
144 IN PVOID SystemSpecific3
)
146 RTMP_ADAPTER
*pAd
= (RTMP_ADAPTER
*)FunctionContext
;
148 // Do nothing if the driver is starting halt state.
149 // This might happen when timer already been fired before cancel timer with mlmehalt
150 if (RTMP_TEST_FLAG(pAd
, fRTMP_ADAPTER_HALT_IN_PROGRESS
| fRTMP_ADAPTER_NIC_NOT_EXIST
))
153 MlmeEnqueue(pAd
, ASSOC_STATE_MACHINE
, MT2_ASSOC_TIMEOUT
, 0, NULL
);
154 RTMP_MLME_HANDLER(pAd
);
158 ==========================================================================
160 Reassociation timeout procedure. After reassociation timeout, this
161 function will be called and put a message into the MLME queue
163 Standard timer parameters
165 IRQL = DISPATCH_LEVEL
167 ==========================================================================
169 VOID
ReassocTimeout(IN PVOID SystemSpecific1
,
170 IN PVOID FunctionContext
,
171 IN PVOID SystemSpecific2
,
172 IN PVOID SystemSpecific3
)
174 RTMP_ADAPTER
*pAd
= (RTMP_ADAPTER
*)FunctionContext
;
176 // Do nothing if the driver is starting halt state.
177 // This might happen when timer already been fired before cancel timer with mlmehalt
178 if (RTMP_TEST_FLAG(pAd
, fRTMP_ADAPTER_HALT_IN_PROGRESS
| fRTMP_ADAPTER_NIC_NOT_EXIST
))
181 MlmeEnqueue(pAd
, ASSOC_STATE_MACHINE
, MT2_REASSOC_TIMEOUT
, 0, NULL
);
182 RTMP_MLME_HANDLER(pAd
);
186 ==========================================================================
188 Disassociation timeout procedure. After disassociation timeout, this
189 function will be called and put a message into the MLME queue
191 Standard timer parameters
193 IRQL = DISPATCH_LEVEL
195 ==========================================================================
197 VOID
DisassocTimeout(IN PVOID SystemSpecific1
,
198 IN PVOID FunctionContext
,
199 IN PVOID SystemSpecific2
,
200 IN PVOID SystemSpecific3
)
202 RTMP_ADAPTER
*pAd
= (RTMP_ADAPTER
*)FunctionContext
;
204 // Do nothing if the driver is starting halt state.
205 // This might happen when timer already been fired before cancel timer with mlmehalt
206 if (RTMP_TEST_FLAG(pAd
, fRTMP_ADAPTER_HALT_IN_PROGRESS
| fRTMP_ADAPTER_NIC_NOT_EXIST
))
209 MlmeEnqueue(pAd
, ASSOC_STATE_MACHINE
, MT2_DISASSOC_TIMEOUT
, 0, NULL
);
210 RTMP_MLME_HANDLER(pAd
);
214 ==========================================================================
216 mlme assoc req handling procedure
218 Adapter - Adapter pointer
219 Elem - MLME Queue Element
221 the station has been authenticated and the following information is stored in the config
223 -# supported rates and their length
224 -# listen interval (Adapter->StaCfg.default_listen_count)
225 -# Transmit power (Adapter->StaCfg.tx_power)
227 -# An association request frame is generated and sent to the air
228 -# Association timer starts
229 -# Association state -> ASSOC_WAIT_RSP
231 IRQL = DISPATCH_LEVEL
233 ==========================================================================
235 VOID
MlmeAssocReqAction(
236 IN PRTMP_ADAPTER pAd
,
237 IN MLME_QUEUE_ELEM
*Elem
)
240 HEADER_802_11 AssocHdr
;
241 UCHAR WmeIe
[9] = {IE_VENDOR_SPECIFIC
, 0x07, 0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, 0x00};
244 USHORT CapabilityInfo
;
245 BOOLEAN TimerCancelled
;
246 PUCHAR pOutBuffer
= NULL
;
253 // Block all authentication request durning WPA block period
254 if (pAd
->StaCfg
.bBlockAssoc
== TRUE
)
256 DBGPRINT(RT_DEBUG_TRACE
, ("ASSOC - Block Assoc request durning WPA block period!\n"));
257 pAd
->Mlme
.AssocMachine
.CurrState
= ASSOC_IDLE
;
258 Status
= MLME_STATE_MACHINE_REJECT
;
259 MlmeEnqueue(pAd
, MLME_CNTL_STATE_MACHINE
, MT2_ASSOC_CONF
, 2, &Status
);
261 // check sanity first
262 else if (MlmeAssocReqSanity(pAd
, Elem
->Msg
, Elem
->MsgLen
, ApAddr
, &CapabilityInfo
, &Timeout
, &ListenIntv
))
264 RTMPCancelTimer(&pAd
->MlmeAux
.AssocTimer
, &TimerCancelled
);
265 COPY_MAC_ADDR(pAd
->MlmeAux
.Bssid
, ApAddr
);
267 // Get an unused nonpaged memory
268 NStatus
= MlmeAllocateMemory(pAd
, &pOutBuffer
);
269 if (NStatus
!= NDIS_STATUS_SUCCESS
)
271 DBGPRINT(RT_DEBUG_TRACE
,("ASSOC - MlmeAssocReqAction() allocate memory failed \n"));
272 pAd
->Mlme
.AssocMachine
.CurrState
= ASSOC_IDLE
;
273 Status
= MLME_FAIL_NO_RESOURCE
;
274 MlmeEnqueue(pAd
, MLME_CNTL_STATE_MACHINE
, MT2_ASSOC_CONF
, 2, &Status
);
278 // Add by James 03/06/27
279 pAd
->StaCfg
.AssocInfo
.Length
= sizeof(NDIS_802_11_ASSOCIATION_INFORMATION
);
280 // Association don't need to report MAC address
281 pAd
->StaCfg
.AssocInfo
.AvailableRequestFixedIEs
=
282 NDIS_802_11_AI_REQFI_CAPABILITIES
| NDIS_802_11_AI_REQFI_LISTENINTERVAL
;
283 pAd
->StaCfg
.AssocInfo
.RequestFixedIEs
.Capabilities
= CapabilityInfo
;
284 pAd
->StaCfg
.AssocInfo
.RequestFixedIEs
.ListenInterval
= ListenIntv
;
285 // Only reassociate need this
286 //COPY_MAC_ADDR(pAd->StaCfg.AssocInfo.RequestFixedIEs.CurrentAPAddress, ApAddr);
287 pAd
->StaCfg
.AssocInfo
.OffsetRequestIEs
= sizeof(NDIS_802_11_ASSOCIATION_INFORMATION
);
289 NdisZeroMemory(pAd
->StaCfg
.ReqVarIEs
, MAX_VIE_LEN
);
292 NdisMoveMemory(pAd
->StaCfg
.ReqVarIEs
+ VarIesOffset
, &SsidIe
, 1);
294 NdisMoveMemory(pAd
->StaCfg
.ReqVarIEs
+ VarIesOffset
, &pAd
->MlmeAux
.SsidLen
, 1);
296 NdisMoveMemory(pAd
->StaCfg
.ReqVarIEs
+ VarIesOffset
, pAd
->MlmeAux
.Ssid
, pAd
->MlmeAux
.SsidLen
);
297 VarIesOffset
+= pAd
->MlmeAux
.SsidLen
;
299 // Second add Supported rates
300 NdisMoveMemory(pAd
->StaCfg
.ReqVarIEs
+ VarIesOffset
, &SupRateIe
, 1);
302 NdisMoveMemory(pAd
->StaCfg
.ReqVarIEs
+ VarIesOffset
, &pAd
->MlmeAux
.SupRateLen
, 1);
304 NdisMoveMemory(pAd
->StaCfg
.ReqVarIEs
+ VarIesOffset
, pAd
->MlmeAux
.SupRate
, pAd
->MlmeAux
.SupRateLen
);
305 VarIesOffset
+= pAd
->MlmeAux
.SupRateLen
;
308 if ((pAd
->CommonCfg
.Channel
> 14) &&
309 (pAd
->CommonCfg
.bIEEE80211H
== TRUE
))
310 CapabilityInfo
|= 0x0100;
312 DBGPRINT(RT_DEBUG_TRACE
, ("ASSOC - Send ASSOC request...\n"));
313 MgtMacHeaderInit(pAd
, &AssocHdr
, SUBTYPE_ASSOC_REQ
, 0, ApAddr
, ApAddr
);
315 // Build basic frame first
316 MakeOutgoingFrame(pOutBuffer
, &FrameLen
,
317 sizeof(HEADER_802_11
), &AssocHdr
,
321 1, &pAd
->MlmeAux
.SsidLen
,
322 pAd
->MlmeAux
.SsidLen
, pAd
->MlmeAux
.Ssid
,
324 1, &pAd
->MlmeAux
.SupRateLen
,
325 pAd
->MlmeAux
.SupRateLen
, pAd
->MlmeAux
.SupRate
,
328 if (pAd
->MlmeAux
.ExtRateLen
!= 0)
330 MakeOutgoingFrame(pOutBuffer
+ FrameLen
, &tmp
,
332 1, &pAd
->MlmeAux
.ExtRateLen
,
333 pAd
->MlmeAux
.ExtRateLen
, pAd
->MlmeAux
.ExtRate
,
339 #ifdef DOT11_N_SUPPORT
341 if ((pAd
->MlmeAux
.HtCapabilityLen
> 0) && (pAd
->CommonCfg
.PhyMode
>= PHY_11ABGN_MIXED
))
345 UCHAR BROADCOM
[4] = {0x0, 0x90, 0x4c, 0x33};
346 if (pAd
->StaActive
.SupportedPhyInfo
.bPreNHt
== TRUE
)
348 HtLen
= SIZE_HT_CAP_IE
+ 4;
349 MakeOutgoingFrame(pOutBuffer
+ FrameLen
, &TmpLen
,
353 pAd
->MlmeAux
.HtCapabilityLen
, &pAd
->MlmeAux
.HtCapability
,
359 HT_CAPABILITY_IE HtCapabilityTmp
;
362 #ifndef RT_BIG_ENDIAN
363 MakeOutgoingFrame(pOutBuffer
+ FrameLen
, &TmpLen
,
365 1, &pAd
->MlmeAux
.HtCapabilityLen
,
366 pAd
->MlmeAux
.HtCapabilityLen
, &pAd
->MlmeAux
.HtCapability
,
369 NdisZeroMemory(&HtCapabilityTmp
, sizeof(HT_CAPABILITY_IE
));
370 NdisMoveMemory(&HtCapabilityTmp
, &pAd
->MlmeAux
.HtCapability
, pAd
->MlmeAux
.HtCapabilityLen
);
371 *(USHORT
*)(&HtCapabilityTmp
.HtCapInfo
) = SWAP16(*(USHORT
*)(&HtCapabilityTmp
.HtCapInfo
));
372 *(USHORT
*)(&HtCapabilityTmp
.ExtHtCapInfo
) = SWAP16(*(USHORT
*)(&HtCapabilityTmp
.ExtHtCapInfo
));
374 MakeOutgoingFrame(pOutBuffer
+ FrameLen
, &TmpLen
,
376 1, &pAd
->MlmeAux
.HtCapabilityLen
,
377 pAd
->MlmeAux
.HtCapabilityLen
,&HtCapabilityTmp
,
383 #endif // DOT11_N_SUPPORT //
385 // add Ralink proprietary IE to inform AP this STA is going to use AGGREGATION or PIGGY-BACK+AGGREGATION
386 // Case I: (Aggregation + Piggy-Back)
387 // 1. user enable aggregation, AND
388 // 2. Mac support piggy-back
389 // 3. AP annouces it's PIGGY-BACK+AGGREGATION-capable in BEACON
390 // Case II: (Aggregation)
391 // 1. user enable aggregation, AND
392 // 2. AP annouces it's AGGREGATION-capable in BEACON
393 if (pAd
->CommonCfg
.bAggregationCapable
)
395 if ((pAd
->CommonCfg
.bPiggyBackCapable
) && ((pAd
->MlmeAux
.APRalinkIe
& 0x00000003) == 3))
398 UCHAR RalinkIe
[9] = {IE_VENDOR_SPECIFIC
, 7, 0x00, 0x0c, 0x43, 0x03, 0x00, 0x00, 0x00};
399 MakeOutgoingFrame(pOutBuffer
+FrameLen
, &TmpLen
,
404 else if (pAd
->MlmeAux
.APRalinkIe
& 0x00000001)
407 UCHAR RalinkIe
[9] = {IE_VENDOR_SPECIFIC
, 7, 0x00, 0x0c, 0x43, 0x01, 0x00, 0x00, 0x00};
408 MakeOutgoingFrame(pOutBuffer
+FrameLen
, &TmpLen
,
417 UCHAR RalinkIe
[9] = {IE_VENDOR_SPECIFIC
, 7, 0x00, 0x0c, 0x43, 0x06, 0x00, 0x00, 0x00};
418 MakeOutgoingFrame(pOutBuffer
+FrameLen
, &TmpLen
,
424 if (pAd
->MlmeAux
.APEdcaParm
.bValid
)
426 if (pAd
->CommonCfg
.bAPSDCapable
&& pAd
->MlmeAux
.APEdcaParm
.bAPSDCapable
)
428 QBSS_STA_INFO_PARM QosInfo
;
430 NdisZeroMemory(&QosInfo
, sizeof(QBSS_STA_INFO_PARM
));
431 QosInfo
.UAPSD_AC_BE
= pAd
->CommonCfg
.bAPSDAC_BE
;
432 QosInfo
.UAPSD_AC_BK
= pAd
->CommonCfg
.bAPSDAC_BK
;
433 QosInfo
.UAPSD_AC_VI
= pAd
->CommonCfg
.bAPSDAC_VI
;
434 QosInfo
.UAPSD_AC_VO
= pAd
->CommonCfg
.bAPSDAC_VO
;
435 QosInfo
.MaxSPLength
= pAd
->CommonCfg
.MaxSPLength
;
436 WmeIe
[8] |= *(PUCHAR
)&QosInfo
;
440 // The Parameter Set Count is set to ��0�� in the association request frames
441 // WmeIe[8] |= (pAd->MlmeAux.APEdcaParm.EdcaUpdateCount & 0x0f);
444 MakeOutgoingFrame(pOutBuffer
+ FrameLen
, &tmp
,
451 // Let WPA(#221) Element ID on the end of this association frame.
452 // Otherwise some AP will fail on parsing Element ID and set status fail on Assoc Rsp.
453 // For example: Put Vendor Specific IE on the front of WPA IE.
454 // This happens on AP (Model No:Linksys WRK54G)
456 if (((pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPAPSK
) ||
457 (pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA2PSK
) ||
458 (pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA
) ||
459 (pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA2
)
463 UCHAR RSNIe
= IE_WPA
;
465 if ((pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA2PSK
) ||
466 (pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA2
))
471 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
473 if ((pAd
->StaCfg
.WpaSupplicantUP
!= WPA_SUPPLICANT_ENABLE
) &&
474 (pAd
->StaCfg
.bRSN_IE_FromWpaSupplicant
== FALSE
))
475 #endif // SIOCSIWGENIE //
476 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
477 RTMPMakeRSNIE(pAd
, pAd
->StaCfg
.AuthMode
, pAd
->StaCfg
.WepStatus
, BSS0
);
479 // Check for WPA PMK cache list
480 if (pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA2
)
483 BOOLEAN FoundPMK
= FALSE
;
484 // Search chched PMKID, append it if existed
485 for (idx
= 0; idx
< PMKID_NO
; idx
++)
487 if (NdisEqualMemory(ApAddr
, &pAd
->StaCfg
.SavedPMK
[idx
].BSSID
, 6))
497 *(PUSHORT
) &pAd
->StaCfg
.RSN_IE
[pAd
->StaCfg
.RSNIE_Len
] = 1;
498 NdisMoveMemory(&pAd
->StaCfg
.RSN_IE
[pAd
->StaCfg
.RSNIE_Len
+ 2], &pAd
->StaCfg
.SavedPMK
[idx
].PMKID
, 16);
499 pAd
->StaCfg
.RSNIE_Len
+= 18;
503 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
505 if ((pAd
->StaCfg
.WpaSupplicantUP
== WPA_SUPPLICANT_ENABLE
) &&
506 (pAd
->StaCfg
.bRSN_IE_FromWpaSupplicant
== TRUE
))
508 MakeOutgoingFrame(pOutBuffer
+ FrameLen
, &tmp
,
509 pAd
->StaCfg
.RSNIE_Len
, pAd
->StaCfg
.RSN_IE
,
514 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
516 MakeOutgoingFrame(pOutBuffer
+ FrameLen
, &tmp
,
518 1, &pAd
->StaCfg
.RSNIE_Len
,
519 pAd
->StaCfg
.RSNIE_Len
, pAd
->StaCfg
.RSN_IE
,
525 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
527 if ((pAd
->StaCfg
.WpaSupplicantUP
!= WPA_SUPPLICANT_ENABLE
) ||
528 (pAd
->StaCfg
.bRSN_IE_FromWpaSupplicant
== FALSE
))
530 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
532 // Append Variable IE
533 NdisMoveMemory(pAd
->StaCfg
.ReqVarIEs
+ VarIesOffset
, &RSNIe
, 1);
535 NdisMoveMemory(pAd
->StaCfg
.ReqVarIEs
+ VarIesOffset
, &pAd
->StaCfg
.RSNIE_Len
, 1);
538 NdisMoveMemory(pAd
->StaCfg
.ReqVarIEs
+ VarIesOffset
, pAd
->StaCfg
.RSN_IE
, pAd
->StaCfg
.RSNIE_Len
);
539 VarIesOffset
+= pAd
->StaCfg
.RSNIE_Len
;
541 // Set Variable IEs Length
542 pAd
->StaCfg
.ReqVarIELen
= VarIesOffset
;
546 MiniportMMRequest(pAd
, 0, pOutBuffer
, FrameLen
);
547 MlmeFreeMemory(pAd
, pOutBuffer
);
549 RTMPSetTimer(&pAd
->MlmeAux
.AssocTimer
, Timeout
);
550 pAd
->Mlme
.AssocMachine
.CurrState
= ASSOC_WAIT_RSP
;
554 DBGPRINT(RT_DEBUG_TRACE
,("ASSOC - MlmeAssocReqAction() sanity check failed. BUG!!!!!! \n"));
555 pAd
->Mlme
.AssocMachine
.CurrState
= ASSOC_IDLE
;
556 Status
= MLME_INVALID_FORMAT
;
557 MlmeEnqueue(pAd
, MLME_CNTL_STATE_MACHINE
, MT2_ASSOC_CONF
, 2, &Status
);
563 ==========================================================================
565 mlme reassoc req handling procedure
569 -# SSID (Adapter->StaCfg.ssid[])
570 -# BSSID (AP address, Adapter->StaCfg.bssid)
571 -# Supported rates (Adapter->StaCfg.supported_rates[])
572 -# Supported rates length (Adapter->StaCfg.supported_rates_len)
573 -# Tx power (Adapter->StaCfg.tx_power)
575 IRQL = DISPATCH_LEVEL
577 ==========================================================================
579 VOID
MlmeReassocReqAction(
580 IN PRTMP_ADAPTER pAd
,
581 IN MLME_QUEUE_ELEM
*Elem
)
584 HEADER_802_11 ReassocHdr
;
585 UCHAR WmeIe
[9] = {IE_VENDOR_SPECIFIC
, 0x07, 0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, 0x00};
586 USHORT CapabilityInfo
, ListenIntv
;
589 BOOLEAN TimerCancelled
;
592 PUCHAR pOutBuffer
= NULL
;
595 // Block all authentication request durning WPA block period
596 if (pAd
->StaCfg
.bBlockAssoc
== TRUE
)
598 DBGPRINT(RT_DEBUG_TRACE
, ("ASSOC - Block ReAssoc request durning WPA block period!\n"));
599 pAd
->Mlme
.AssocMachine
.CurrState
= ASSOC_IDLE
;
600 Status
= MLME_STATE_MACHINE_REJECT
;
601 MlmeEnqueue(pAd
, MLME_CNTL_STATE_MACHINE
, MT2_REASSOC_CONF
, 2, &Status
);
603 // the parameters are the same as the association
604 else if(MlmeAssocReqSanity(pAd
, Elem
->Msg
, Elem
->MsgLen
, ApAddr
, &CapabilityInfo
, &Timeout
, &ListenIntv
))
606 RTMPCancelTimer(&pAd
->MlmeAux
.ReassocTimer
, &TimerCancelled
);
608 NStatus
= MlmeAllocateMemory(pAd
, &pOutBuffer
); //Get an unused nonpaged memory
609 if(NStatus
!= NDIS_STATUS_SUCCESS
)
611 DBGPRINT(RT_DEBUG_TRACE
,("ASSOC - MlmeReassocReqAction() allocate memory failed \n"));
612 pAd
->Mlme
.AssocMachine
.CurrState
= ASSOC_IDLE
;
613 Status
= MLME_FAIL_NO_RESOURCE
;
614 MlmeEnqueue(pAd
, MLME_CNTL_STATE_MACHINE
, MT2_REASSOC_CONF
, 2, &Status
);
618 COPY_MAC_ADDR(pAd
->MlmeAux
.Bssid
, ApAddr
);
620 // make frame, use bssid as the AP address??
621 DBGPRINT(RT_DEBUG_TRACE
, ("ASSOC - Send RE-ASSOC request...\n"));
622 MgtMacHeaderInit(pAd
, &ReassocHdr
, SUBTYPE_REASSOC_REQ
, 0, ApAddr
, ApAddr
);
623 MakeOutgoingFrame(pOutBuffer
, &FrameLen
,
624 sizeof(HEADER_802_11
), &ReassocHdr
,
627 MAC_ADDR_LEN
, ApAddr
,
629 1, &pAd
->MlmeAux
.SsidLen
,
630 pAd
->MlmeAux
.SsidLen
, pAd
->MlmeAux
.Ssid
,
632 1, &pAd
->MlmeAux
.SupRateLen
,
633 pAd
->MlmeAux
.SupRateLen
, pAd
->MlmeAux
.SupRate
,
636 if (pAd
->MlmeAux
.ExtRateLen
!= 0)
638 MakeOutgoingFrame(pOutBuffer
+ FrameLen
, &tmp
,
640 1, &pAd
->MlmeAux
.ExtRateLen
,
641 pAd
->MlmeAux
.ExtRateLen
, pAd
->MlmeAux
.ExtRate
,
647 if (pAd
->MlmeAux
.APEdcaParm
.bValid
)
649 if (pAd
->CommonCfg
.bAPSDCapable
&& pAd
->MlmeAux
.APEdcaParm
.bAPSDCapable
)
651 QBSS_STA_INFO_PARM QosInfo
;
653 NdisZeroMemory(&QosInfo
, sizeof(QBSS_STA_INFO_PARM
));
654 QosInfo
.UAPSD_AC_BE
= pAd
->CommonCfg
.bAPSDAC_BE
;
655 QosInfo
.UAPSD_AC_BK
= pAd
->CommonCfg
.bAPSDAC_BK
;
656 QosInfo
.UAPSD_AC_VI
= pAd
->CommonCfg
.bAPSDAC_VI
;
657 QosInfo
.UAPSD_AC_VO
= pAd
->CommonCfg
.bAPSDAC_VO
;
658 QosInfo
.MaxSPLength
= pAd
->CommonCfg
.MaxSPLength
;
659 WmeIe
[8] |= *(PUCHAR
)&QosInfo
;
662 MakeOutgoingFrame(pOutBuffer
+ FrameLen
, &tmp
,
668 #ifdef DOT11_N_SUPPORT
670 if ((pAd
->MlmeAux
.HtCapabilityLen
> 0) && (pAd
->CommonCfg
.PhyMode
>= PHY_11ABGN_MIXED
))
674 UCHAR BROADCOM
[4] = {0x0, 0x90, 0x4c, 0x33};
675 if (pAd
->StaActive
.SupportedPhyInfo
.bPreNHt
== TRUE
)
677 HtLen
= SIZE_HT_CAP_IE
+ 4;
678 MakeOutgoingFrame(pOutBuffer
+ FrameLen
, &TmpLen
,
682 pAd
->MlmeAux
.HtCapabilityLen
, &pAd
->MlmeAux
.HtCapability
,
687 MakeOutgoingFrame(pOutBuffer
+ FrameLen
, &TmpLen
,
689 1, &pAd
->MlmeAux
.HtCapabilityLen
,
690 pAd
->MlmeAux
.HtCapabilityLen
, &pAd
->MlmeAux
.HtCapability
,
695 #endif // DOT11_N_SUPPORT //
697 // add Ralink proprietary IE to inform AP this STA is going to use AGGREGATION or PIGGY-BACK+AGGREGATION
698 // Case I: (Aggregation + Piggy-Back)
699 // 1. user enable aggregation, AND
700 // 2. Mac support piggy-back
701 // 3. AP annouces it's PIGGY-BACK+AGGREGATION-capable in BEACON
702 // Case II: (Aggregation)
703 // 1. user enable aggregation, AND
704 // 2. AP annouces it's AGGREGATION-capable in BEACON
705 if (pAd
->CommonCfg
.bAggregationCapable
)
707 if ((pAd
->CommonCfg
.bPiggyBackCapable
) && ((pAd
->MlmeAux
.APRalinkIe
& 0x00000003) == 3))
710 UCHAR RalinkIe
[9] = {IE_VENDOR_SPECIFIC
, 7, 0x00, 0x0c, 0x43, 0x03, 0x00, 0x00, 0x00};
711 MakeOutgoingFrame(pOutBuffer
+FrameLen
, &TmpLen
,
716 else if (pAd
->MlmeAux
.APRalinkIe
& 0x00000001)
719 UCHAR RalinkIe
[9] = {IE_VENDOR_SPECIFIC
, 7, 0x00, 0x0c, 0x43, 0x01, 0x00, 0x00, 0x00};
720 MakeOutgoingFrame(pOutBuffer
+FrameLen
, &TmpLen
,
729 UCHAR RalinkIe
[9] = {IE_VENDOR_SPECIFIC
, 7, 0x00, 0x0c, 0x43, 0x04, 0x00, 0x00, 0x00};
730 MakeOutgoingFrame(pOutBuffer
+FrameLen
, &TmpLen
,
736 MiniportMMRequest(pAd
, 0, pOutBuffer
, FrameLen
);
737 MlmeFreeMemory(pAd
, pOutBuffer
);
739 RTMPSetTimer(&pAd
->MlmeAux
.ReassocTimer
, Timeout
); /* in mSec */
740 pAd
->Mlme
.AssocMachine
.CurrState
= REASSOC_WAIT_RSP
;
744 DBGPRINT(RT_DEBUG_TRACE
,("ASSOC - MlmeReassocReqAction() sanity check failed. BUG!!!! \n"));
745 pAd
->Mlme
.AssocMachine
.CurrState
= ASSOC_IDLE
;
746 Status
= MLME_INVALID_FORMAT
;
747 MlmeEnqueue(pAd
, MLME_CNTL_STATE_MACHINE
, MT2_REASSOC_CONF
, 2, &Status
);
752 ==========================================================================
754 Upper layer issues disassoc request
760 ==========================================================================
762 VOID
MlmeDisassocReqAction(
763 IN PRTMP_ADAPTER pAd
,
764 IN MLME_QUEUE_ELEM
*Elem
)
766 PMLME_DISASSOC_REQ_STRUCT pDisassocReq
;
767 HEADER_802_11 DisassocHdr
;
768 PHEADER_802_11 pDisassocHdr
;
769 PUCHAR pOutBuffer
= NULL
;
772 BOOLEAN TimerCancelled
;
776 #ifdef QOS_DLS_SUPPORT
777 // send DLS-TEAR_DOWN message,
778 if (pAd
->CommonCfg
.bDLSCapable
)
782 // tear down local dls table entry
783 for (i
=0; i
<MAX_NUM_OF_INIT_DLS_ENTRY
; i
++)
785 if (pAd
->StaCfg
.DLSEntry
[i
].Valid
&& (pAd
->StaCfg
.DLSEntry
[i
].Status
== DLS_FINISH
))
787 RTMPSendDLSTearDownFrame(pAd
, pAd
->StaCfg
.DLSEntry
[i
].MacAddr
);
788 pAd
->StaCfg
.DLSEntry
[i
].Status
= DLS_NONE
;
789 pAd
->StaCfg
.DLSEntry
[i
].Valid
= FALSE
;
793 // tear down peer dls table entry
794 for (i
=MAX_NUM_OF_INIT_DLS_ENTRY
; i
<MAX_NUM_OF_DLS_ENTRY
; i
++)
796 if (pAd
->StaCfg
.DLSEntry
[i
].Valid
&& (pAd
->StaCfg
.DLSEntry
[i
].Status
== DLS_FINISH
))
798 RTMPSendDLSTearDownFrame(pAd
, pAd
->StaCfg
.DLSEntry
[i
].MacAddr
);
799 pAd
->StaCfg
.DLSEntry
[i
].Status
= DLS_NONE
;
800 pAd
->StaCfg
.DLSEntry
[i
].Valid
= FALSE
;
804 #endif // QOS_DLS_SUPPORT //
807 pDisassocReq
= (PMLME_DISASSOC_REQ_STRUCT
)(Elem
->Msg
);
809 NStatus
= MlmeAllocateMemory(pAd
, &pOutBuffer
); //Get an unused nonpaged memory
810 if (NStatus
!= NDIS_STATUS_SUCCESS
)
812 DBGPRINT(RT_DEBUG_TRACE
, ("ASSOC - MlmeDisassocReqAction() allocate memory failed\n"));
813 pAd
->Mlme
.AssocMachine
.CurrState
= ASSOC_IDLE
;
814 Status
= MLME_FAIL_NO_RESOURCE
;
815 MlmeEnqueue(pAd
, MLME_CNTL_STATE_MACHINE
, MT2_DISASSOC_CONF
, 2, &Status
);
822 RTMPCancelTimer(&pAd
->MlmeAux
.DisassocTimer
, &TimerCancelled
);
824 DBGPRINT(RT_DEBUG_TRACE
, ("ASSOC - Send DISASSOC request[BSSID::%02x:%02x:%02x:%02x:%02x:%02x (Reason=%d)\n",
825 pDisassocReq
->Addr
[0], pDisassocReq
->Addr
[1], pDisassocReq
->Addr
[2],
826 pDisassocReq
->Addr
[3], pDisassocReq
->Addr
[4], pDisassocReq
->Addr
[5], pDisassocReq
->Reason
));
827 MgtMacHeaderInit(pAd
, &DisassocHdr
, SUBTYPE_DISASSOC
, 0, pDisassocReq
->Addr
, pDisassocReq
->Addr
); // patch peap ttls switching issue
828 MakeOutgoingFrame(pOutBuffer
, &FrameLen
,
829 sizeof(HEADER_802_11
),&DisassocHdr
,
830 2, &pDisassocReq
->Reason
,
832 MiniportMMRequest(pAd
, 0, pOutBuffer
, FrameLen
);
834 // To patch Instance and Buffalo(N) AP
835 // Driver has to send deauth to Instance AP, but Buffalo(N) needs to send disassoc to reset Authenticator's state machine
836 // Therefore, we send both of them.
837 pDisassocHdr
= (PHEADER_802_11
)pOutBuffer
;
838 pDisassocHdr
->FC
.SubType
= SUBTYPE_DEAUTH
;
839 MiniportMMRequest(pAd
, 0, pOutBuffer
, FrameLen
);
841 MlmeFreeMemory(pAd
, pOutBuffer
);
843 pAd
->StaCfg
.DisassocReason
= REASON_DISASSOC_STA_LEAVING
;
844 COPY_MAC_ADDR(pAd
->StaCfg
.DisassocSta
, pDisassocReq
->Addr
);
846 RTMPSetTimer(&pAd
->MlmeAux
.DisassocTimer
, Timeout
); /* in mSec */
847 pAd
->Mlme
.AssocMachine
.CurrState
= DISASSOC_WAIT_RSP
;
849 #ifdef WPA_SUPPLICANT_SUPPORT
850 #ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
851 if (pAd
->StaCfg
.WpaSupplicantUP
!= WPA_SUPPLICANT_DISABLE
)
853 //send disassociate event to wpa_supplicant
854 RtmpOSWrielessEventSend(pAd
, IWEVCUSTOM
, RT_DISASSOC_EVENT_FLAG
, NULL
, NULL
, 0);
856 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
857 #endif // WPA_SUPPLICANT_SUPPORT //
859 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
860 RtmpOSWrielessEventSend(pAd
, SIOCGIWAP
, -1, NULL
, NULL
, 0);
861 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
866 ==========================================================================
868 peer sends assoc rsp back
870 Elme - MLME message containing the received frame
872 IRQL = DISPATCH_LEVEL
874 ==========================================================================
876 VOID
PeerAssocRspAction(
877 IN PRTMP_ADAPTER pAd
,
878 IN MLME_QUEUE_ELEM
*Elem
)
880 USHORT CapabilityInfo
, Status
, Aid
;
881 UCHAR SupRate
[MAX_LEN_OF_SUPPORTED_RATES
], SupRateLen
;
882 UCHAR ExtRate
[MAX_LEN_OF_SUPPORTED_RATES
], ExtRateLen
;
883 UCHAR Addr2
[MAC_ADDR_LEN
];
884 BOOLEAN TimerCancelled
;
887 HT_CAPABILITY_IE HtCapability
;
888 ADD_HT_INFO_IE AddHtInfo
; // AP might use this additional ht info IE
889 UCHAR HtCapabilityLen
;
891 UCHAR NewExtChannelOffset
= 0xff;
893 if (PeerAssocRspSanity(pAd
, Elem
->Msg
, Elem
->MsgLen
, Addr2
, &CapabilityInfo
, &Status
, &Aid
, SupRate
, &SupRateLen
, ExtRate
, &ExtRateLen
,
894 &HtCapability
,&AddHtInfo
, &HtCapabilityLen
,&AddHtInfoLen
,&NewExtChannelOffset
, &EdcaParm
, &CkipFlag
))
896 // The frame is for me ?
897 if(MAC_ADDR_EQUAL(Addr2
, pAd
->MlmeAux
.Bssid
))
899 DBGPRINT(RT_DEBUG_TRACE
, ("PeerAssocRspAction():ASSOC - receive ASSOC_RSP to me (status=%d)\n", Status
));
900 #ifdef DOT11_N_SUPPORT
901 DBGPRINT(RT_DEBUG_TRACE
, ("PeerAssocRspAction():MacTable [%d].AMsduSize = %d. ClientStatusFlags = 0x%lx \n",Elem
->Wcid
, pAd
->MacTab
.Content
[BSSID_WCID
].AMsduSize
, pAd
->MacTab
.Content
[BSSID_WCID
].ClientStatusFlags
));
902 #endif // DOT11_N_SUPPORT //
903 RTMPCancelTimer(&pAd
->MlmeAux
.AssocTimer
, &TimerCancelled
);
906 if(Status
== MLME_SUCCESS
)
908 UCHAR MaxSupportedRateIn500Kbps
= 0;
911 // supported rates array may not be sorted. sort it and find the maximum rate
912 for (idx
=0; idx
<SupRateLen
; idx
++)
914 if (MaxSupportedRateIn500Kbps
< (SupRate
[idx
] & 0x7f))
915 MaxSupportedRateIn500Kbps
= SupRate
[idx
] & 0x7f;
918 for (idx
=0; idx
<ExtRateLen
; idx
++)
920 if (MaxSupportedRateIn500Kbps
< (ExtRate
[idx
] & 0x7f))
921 MaxSupportedRateIn500Kbps
= ExtRate
[idx
] & 0x7f;
923 // go to procedure listed on page 376
924 AssocPostProc(pAd
, Addr2
, CapabilityInfo
, Aid
, SupRate
, SupRateLen
, ExtRate
, ExtRateLen
,
925 &EdcaParm
, &HtCapability
, HtCapabilityLen
, &AddHtInfo
);
927 StaAddMacTableEntry(pAd
,
928 &pAd
->MacTab
.Content
[BSSID_WCID
],
929 MaxSupportedRateIn500Kbps
,
936 pAd
->Mlme
.AssocMachine
.CurrState
= ASSOC_IDLE
;
937 MlmeEnqueue(pAd
, MLME_CNTL_STATE_MACHINE
, MT2_ASSOC_CONF
, 2, &Status
);
942 DBGPRINT(RT_DEBUG_TRACE
, ("ASSOC - PeerAssocRspAction() sanity check fail\n"));
947 ==========================================================================
949 peer sends reassoc rsp
951 Elem - MLME message cntaining the received frame
953 IRQL = DISPATCH_LEVEL
955 ==========================================================================
957 VOID
PeerReassocRspAction(
958 IN PRTMP_ADAPTER pAd
,
959 IN MLME_QUEUE_ELEM
*Elem
)
961 USHORT CapabilityInfo
;
964 UCHAR SupRate
[MAX_LEN_OF_SUPPORTED_RATES
], SupRateLen
;
965 UCHAR ExtRate
[MAX_LEN_OF_SUPPORTED_RATES
], ExtRateLen
;
966 UCHAR Addr2
[MAC_ADDR_LEN
];
968 BOOLEAN TimerCancelled
;
970 HT_CAPABILITY_IE HtCapability
;
971 ADD_HT_INFO_IE AddHtInfo
; // AP might use this additional ht info IE
972 UCHAR HtCapabilityLen
;
974 UCHAR NewExtChannelOffset
= 0xff;
976 if(PeerAssocRspSanity(pAd
, Elem
->Msg
, Elem
->MsgLen
, Addr2
, &CapabilityInfo
, &Status
, &Aid
, SupRate
, &SupRateLen
, ExtRate
, &ExtRateLen
,
977 &HtCapability
, &AddHtInfo
, &HtCapabilityLen
, &AddHtInfoLen
,&NewExtChannelOffset
, &EdcaParm
, &CkipFlag
))
979 if(MAC_ADDR_EQUAL(Addr2
, pAd
->MlmeAux
.Bssid
)) // The frame is for me ?
981 DBGPRINT(RT_DEBUG_TRACE
, ("ASSOC - receive REASSOC_RSP to me (status=%d)\n", Status
));
982 RTMPCancelTimer(&pAd
->MlmeAux
.ReassocTimer
, &TimerCancelled
);
984 if(Status
== MLME_SUCCESS
)
986 // go to procedure listed on page 376
987 AssocPostProc(pAd
, Addr2
, CapabilityInfo
, Aid
, SupRate
, SupRateLen
, ExtRate
, ExtRateLen
,
988 &EdcaParm
, &HtCapability
, HtCapabilityLen
, &AddHtInfo
);
990 #ifdef WPA_SUPPLICANT_SUPPORT
991 #ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
992 if (pAd
->StaCfg
.WpaSupplicantUP
!= WPA_SUPPLICANT_DISABLE
)
994 SendAssocIEsToWpaSupplicant(pAd
);
995 RtmpOSWrielessEventSend(pAd
, IWEVCUSTOM
, RT_ASSOC_EVENT_FLAG
, NULL
, NULL
, 0);
997 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
998 #endif // WPA_SUPPLICANT_SUPPORT //
1000 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
1002 wext_notify_event_assoc(pAd
);
1003 RtmpOSWrielessEventSend(pAd
, SIOCGIWAP
, -1, &pAd
->MlmeAux
.Bssid
[0], NULL
, 0);
1005 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
1009 // CkipFlag is no use for reassociate
1010 pAd
->Mlme
.AssocMachine
.CurrState
= ASSOC_IDLE
;
1011 MlmeEnqueue(pAd
, MLME_CNTL_STATE_MACHINE
, MT2_REASSOC_CONF
, 2, &Status
);
1016 DBGPRINT(RT_DEBUG_TRACE
, ("ASSOC - PeerReassocRspAction() sanity check fail\n"));
1022 ==========================================================================
1024 procedures on IEEE 802.11/1999 p.376
1027 IRQL = DISPATCH_LEVEL
1029 ==========================================================================
1032 IN PRTMP_ADAPTER pAd
,
1034 IN USHORT CapabilityInfo
,
1037 IN UCHAR SupRateLen
,
1039 IN UCHAR ExtRateLen
,
1040 IN PEDCA_PARM pEdcaParm
,
1041 IN HT_CAPABILITY_IE
*pHtCapability
,
1042 IN UCHAR HtCapabilityLen
,
1043 IN ADD_HT_INFO_IE
*pAddHtInfo
) // AP might use this additional ht info IE
1047 pAd
->MlmeAux
.BssType
= BSS_INFRA
;
1048 COPY_MAC_ADDR(pAd
->MlmeAux
.Bssid
, pAddr2
);
1049 pAd
->MlmeAux
.Aid
= Aid
;
1050 pAd
->MlmeAux
.CapabilityInfo
= CapabilityInfo
& SUPPORTED_CAPABILITY_INFO
;
1052 #ifdef DOT11_N_SUPPORT
1053 // Some HT AP might lost WMM IE. We add WMM ourselves. beacuase HT requires QoS on.
1054 if ((HtCapabilityLen
> 0) && (pEdcaParm
->bValid
== FALSE
))
1056 pEdcaParm
->bValid
= TRUE
;
1057 pEdcaParm
->Aifsn
[0] = 3;
1058 pEdcaParm
->Aifsn
[1] = 7;
1059 pEdcaParm
->Aifsn
[2] = 2;
1060 pEdcaParm
->Aifsn
[3] = 2;
1062 pEdcaParm
->Cwmin
[0] = 4;
1063 pEdcaParm
->Cwmin
[1] = 4;
1064 pEdcaParm
->Cwmin
[2] = 3;
1065 pEdcaParm
->Cwmin
[3] = 2;
1067 pEdcaParm
->Cwmax
[0] = 10;
1068 pEdcaParm
->Cwmax
[1] = 10;
1069 pEdcaParm
->Cwmax
[2] = 4;
1070 pEdcaParm
->Cwmax
[3] = 3;
1072 pEdcaParm
->Txop
[0] = 0;
1073 pEdcaParm
->Txop
[1] = 0;
1074 pEdcaParm
->Txop
[2] = 96;
1075 pEdcaParm
->Txop
[3] = 48;
1078 #endif // DOT11_N_SUPPORT //
1080 NdisMoveMemory(&pAd
->MlmeAux
.APEdcaParm
, pEdcaParm
, sizeof(EDCA_PARM
));
1082 // filter out un-supported rates
1083 pAd
->MlmeAux
.SupRateLen
= SupRateLen
;
1084 NdisMoveMemory(pAd
->MlmeAux
.SupRate
, SupRate
, SupRateLen
);
1085 RTMPCheckRates(pAd
, pAd
->MlmeAux
.SupRate
, &pAd
->MlmeAux
.SupRateLen
);
1087 // filter out un-supported rates
1088 pAd
->MlmeAux
.ExtRateLen
= ExtRateLen
;
1089 NdisMoveMemory(pAd
->MlmeAux
.ExtRate
, ExtRate
, ExtRateLen
);
1090 RTMPCheckRates(pAd
, pAd
->MlmeAux
.ExtRate
, &pAd
->MlmeAux
.ExtRateLen
);
1092 #ifdef DOT11_N_SUPPORT
1093 if (HtCapabilityLen
> 0)
1095 RTMPCheckHt(pAd
, BSSID_WCID
, pHtCapability
, pAddHtInfo
);
1097 DBGPRINT(RT_DEBUG_TRACE
, ("AssocPostProc===> AP.AMsduSize = %d. ClientStatusFlags = 0x%lx \n", pAd
->MacTab
.Content
[BSSID_WCID
].AMsduSize
, pAd
->MacTab
.Content
[BSSID_WCID
].ClientStatusFlags
));
1099 DBGPRINT(RT_DEBUG_TRACE
, ("AssocPostProc===> (Mmps=%d, AmsduSize=%d, )\n",
1100 pAd
->MacTab
.Content
[BSSID_WCID
].MmpsMode
, pAd
->MacTab
.Content
[BSSID_WCID
].AMsduSize
));
1101 #endif // DOT11_N_SUPPORT //
1103 // Set New WPA information
1104 Idx
= BssTableSearch(&pAd
->ScanTab
, pAddr2
, pAd
->MlmeAux
.Channel
);
1105 if (Idx
== BSS_NOT_FOUND
)
1107 DBGPRINT_ERR(("ASSOC - Can't find BSS after receiving Assoc response\n"));
1112 pAd
->MacTab
.Content
[BSSID_WCID
].RSNIE_Len
= 0;
1113 NdisZeroMemory(pAd
->MacTab
.Content
[BSSID_WCID
].RSN_IE
, MAX_LEN_OF_RSNIE
);
1115 // Store appropriate RSN_IE for WPA SM negotiation later
1116 if ((pAd
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA
) && (pAd
->ScanTab
.BssEntry
[Idx
].VarIELen
!= 0))
1122 pVIE
= pAd
->ScanTab
.BssEntry
[Idx
].VarIEs
;
1123 len
= pAd
->ScanTab
.BssEntry
[Idx
].VarIELen
;
1124 //KH need to check again
1125 // Don't allow to go to sleep mode if authmode is WPA-related.
1126 //This can make Authentication process more smoothly.
1127 RTMP_CLEAR_PSFLAG(pAd
, fRTMP_PS_CAN_GO_SLEEP
);
1131 pEid
= (PEID_STRUCT
) pVIE
;
1133 if ((pEid
->Eid
== IE_WPA
) && (NdisEqualMemory(pEid
->Octet
, WPA_OUI
, 4))
1134 && (pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA
|| pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPAPSK
))
1136 NdisMoveMemory(pAd
->MacTab
.Content
[BSSID_WCID
].RSN_IE
, pVIE
, (pEid
->Len
+ 2));
1137 pAd
->MacTab
.Content
[BSSID_WCID
].RSNIE_Len
= (pEid
->Len
+ 2);
1138 DBGPRINT(RT_DEBUG_TRACE
, ("AssocPostProc===> Store RSN_IE for WPA SM negotiation \n"));
1141 else if ((pEid
->Eid
== IE_RSN
) && (NdisEqualMemory(pEid
->Octet
+ 2, RSN_OUI
, 3))
1142 && (pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA2
|| pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA2PSK
))
1144 NdisMoveMemory(pAd
->MacTab
.Content
[BSSID_WCID
].RSN_IE
, pVIE
, (pEid
->Len
+ 2));
1145 pAd
->MacTab
.Content
[BSSID_WCID
].RSNIE_Len
= (pEid
->Len
+ 2);
1146 DBGPRINT(RT_DEBUG_TRACE
, ("AssocPostProc===> Store RSN_IE for WPA2 SM negotiation \n"));
1149 pVIE
+= (pEid
->Len
+ 2);
1150 len
-= (pEid
->Len
+ 2);
1156 if (pAd
->MacTab
.Content
[BSSID_WCID
].RSNIE_Len
== 0)
1158 DBGPRINT(RT_DEBUG_TRACE
, ("AssocPostProc===> no RSN_IE \n"));
1162 hex_dump("RSN_IE", pAd
->MacTab
.Content
[BSSID_WCID
].RSN_IE
, pAd
->MacTab
.Content
[BSSID_WCID
].RSNIE_Len
);
1168 ==========================================================================
1170 left part of IEEE 802.11/1999 p.374
1172 Elem - MLME message containing the received frame
1174 IRQL = DISPATCH_LEVEL
1176 ==========================================================================
1178 VOID
PeerDisassocAction(
1179 IN PRTMP_ADAPTER pAd
,
1180 IN MLME_QUEUE_ELEM
*Elem
)
1182 UCHAR Addr2
[MAC_ADDR_LEN
];
1185 DBGPRINT(RT_DEBUG_TRACE
, ("ASSOC - PeerDisassocAction()\n"));
1186 if(PeerDisassocSanity(pAd
, Elem
->Msg
, Elem
->MsgLen
, Addr2
, &Reason
))
1188 DBGPRINT(RT_DEBUG_TRACE
, ("ASSOC - PeerDisassocAction() Reason = %d\n", Reason
));
1189 if (INFRA_ON(pAd
) && MAC_ADDR_EQUAL(pAd
->CommonCfg
.Bssid
, Addr2
))
1192 if (pAd
->CommonCfg
.bWirelessEvent
)
1194 RTMPSendWirelessEvent(pAd
, IW_DISASSOC_EVENT_FLAG
, pAd
->MacTab
.Content
[BSSID_WCID
].Addr
, BSS0
, 0);
1198 LinkDown(pAd
, TRUE
);
1199 pAd
->Mlme
.AssocMachine
.CurrState
= ASSOC_IDLE
;
1201 #ifdef WPA_SUPPLICANT_SUPPORT
1202 #ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
1203 if (pAd
->StaCfg
.WpaSupplicantUP
!= WPA_SUPPLICANT_DISABLE
)
1205 //send disassociate event to wpa_supplicant
1206 RtmpOSWrielessEventSend(pAd
, IWEVCUSTOM
, RT_DISASSOC_EVENT_FLAG
, NULL
, NULL
, 0);
1208 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
1209 #endif // WPA_SUPPLICANT_SUPPORT //
1211 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
1212 RtmpOSWrielessEventSend(pAd
, SIOCGIWAP
, -1, NULL
, NULL
, 0);
1213 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
1218 DBGPRINT(RT_DEBUG_TRACE
, ("ASSOC - PeerDisassocAction() sanity check fail\n"));
1224 ==========================================================================
1226 what the state machine will do after assoc timeout
1230 IRQL = DISPATCH_LEVEL
1232 ==========================================================================
1234 VOID
AssocTimeoutAction(
1235 IN PRTMP_ADAPTER pAd
,
1236 IN MLME_QUEUE_ELEM
*Elem
)
1239 DBGPRINT(RT_DEBUG_TRACE
, ("ASSOC - AssocTimeoutAction\n"));
1240 pAd
->Mlme
.AssocMachine
.CurrState
= ASSOC_IDLE
;
1241 Status
= MLME_REJ_TIMEOUT
;
1242 MlmeEnqueue(pAd
, MLME_CNTL_STATE_MACHINE
, MT2_ASSOC_CONF
, 2, &Status
);
1246 ==========================================================================
1248 what the state machine will do after reassoc timeout
1250 IRQL = DISPATCH_LEVEL
1252 ==========================================================================
1254 VOID
ReassocTimeoutAction(
1255 IN PRTMP_ADAPTER pAd
,
1256 IN MLME_QUEUE_ELEM
*Elem
)
1259 DBGPRINT(RT_DEBUG_TRACE
, ("ASSOC - ReassocTimeoutAction\n"));
1260 pAd
->Mlme
.AssocMachine
.CurrState
= ASSOC_IDLE
;
1261 Status
= MLME_REJ_TIMEOUT
;
1262 MlmeEnqueue(pAd
, MLME_CNTL_STATE_MACHINE
, MT2_REASSOC_CONF
, 2, &Status
);
1266 ==========================================================================
1268 what the state machine will do after disassoc timeout
1270 IRQL = DISPATCH_LEVEL
1272 ==========================================================================
1274 VOID
DisassocTimeoutAction(
1275 IN PRTMP_ADAPTER pAd
,
1276 IN MLME_QUEUE_ELEM
*Elem
)
1279 DBGPRINT(RT_DEBUG_TRACE
, ("ASSOC - DisassocTimeoutAction\n"));
1280 pAd
->Mlme
.AssocMachine
.CurrState
= ASSOC_IDLE
;
1281 Status
= MLME_SUCCESS
;
1282 MlmeEnqueue(pAd
, MLME_CNTL_STATE_MACHINE
, MT2_DISASSOC_CONF
, 2, &Status
);
1285 VOID
InvalidStateWhenAssoc(
1286 IN PRTMP_ADAPTER pAd
,
1287 IN MLME_QUEUE_ELEM
*Elem
)
1290 DBGPRINT(RT_DEBUG_TRACE
, ("ASSOC - InvalidStateWhenAssoc(state=%ld), reset ASSOC state machine\n",
1291 pAd
->Mlme
.AssocMachine
.CurrState
));
1292 pAd
->Mlme
.AssocMachine
.CurrState
= ASSOC_IDLE
;
1293 Status
= MLME_STATE_MACHINE_REJECT
;
1294 MlmeEnqueue(pAd
, MLME_CNTL_STATE_MACHINE
, MT2_ASSOC_CONF
, 2, &Status
);
1297 VOID
InvalidStateWhenReassoc(
1298 IN PRTMP_ADAPTER pAd
,
1299 IN MLME_QUEUE_ELEM
*Elem
)
1302 DBGPRINT(RT_DEBUG_TRACE
, ("ASSOC - InvalidStateWhenReassoc(state=%ld), reset ASSOC state machine\n",
1303 pAd
->Mlme
.AssocMachine
.CurrState
));
1304 pAd
->Mlme
.AssocMachine
.CurrState
= ASSOC_IDLE
;
1305 Status
= MLME_STATE_MACHINE_REJECT
;
1306 MlmeEnqueue(pAd
, MLME_CNTL_STATE_MACHINE
, MT2_REASSOC_CONF
, 2, &Status
);
1309 VOID
InvalidStateWhenDisassociate(
1310 IN PRTMP_ADAPTER pAd
,
1311 IN MLME_QUEUE_ELEM
*Elem
)
1314 DBGPRINT(RT_DEBUG_TRACE
, ("ASSOC - InvalidStateWhenDisassoc(state=%ld), reset ASSOC state machine\n",
1315 pAd
->Mlme
.AssocMachine
.CurrState
));
1316 pAd
->Mlme
.AssocMachine
.CurrState
= ASSOC_IDLE
;
1317 Status
= MLME_STATE_MACHINE_REJECT
;
1318 MlmeEnqueue(pAd
, MLME_CNTL_STATE_MACHINE
, MT2_DISASSOC_CONF
, 2, &Status
);
1322 ==========================================================================
1324 right part of IEEE 802.11/1999 page 374
1326 This event should never cause ASSOC state machine perform state
1327 transition, and has no relationship with CNTL machine. So we separate
1328 this routine as a service outside of ASSOC state transition table.
1330 IRQL = DISPATCH_LEVEL
1332 ==========================================================================
1335 IN PRTMP_ADAPTER pAd
,
1338 HEADER_802_11 DisassocHdr
;
1339 PHEADER_802_11 pDisassocHdr
;
1340 PUCHAR pOutBuffer
= NULL
;
1342 NDIS_STATUS NStatus
;
1343 USHORT Reason
= REASON_CLS3ERR
;
1345 NStatus
= MlmeAllocateMemory(pAd
, &pOutBuffer
); //Get an unused nonpaged memory
1346 if (NStatus
!= NDIS_STATUS_SUCCESS
)
1349 DBGPRINT(RT_DEBUG_TRACE
, ("ASSOC - Class 3 Error, Send DISASSOC frame\n"));
1350 MgtMacHeaderInit(pAd
, &DisassocHdr
, SUBTYPE_DISASSOC
, 0, pAddr
, pAd
->CommonCfg
.Bssid
); // patch peap ttls switching issue
1351 MakeOutgoingFrame(pOutBuffer
, &FrameLen
,
1352 sizeof(HEADER_802_11
),&DisassocHdr
,
1355 MiniportMMRequest(pAd
, 0, pOutBuffer
, FrameLen
);
1357 // To patch Instance and Buffalo(N) AP
1358 // Driver has to send deauth to Instance AP, but Buffalo(N) needs to send disassoc to reset Authenticator's state machine
1359 // Therefore, we send both of them.
1360 pDisassocHdr
= (PHEADER_802_11
)pOutBuffer
;
1361 pDisassocHdr
->FC
.SubType
= SUBTYPE_DEAUTH
;
1362 MiniportMMRequest(pAd
, 0, pOutBuffer
, FrameLen
);
1364 MlmeFreeMemory(pAd
, pOutBuffer
);
1366 pAd
->StaCfg
.DisassocReason
= REASON_CLS3ERR
;
1367 COPY_MAC_ADDR(pAd
->StaCfg
.DisassocSta
, pAddr
);
1370 #ifdef WPA_SUPPLICANT_SUPPORT
1371 #ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
1372 VOID
SendAssocIEsToWpaSupplicant(
1373 IN PRTMP_ADAPTER pAd
)
1375 STRING custom
[IW_CUSTOM_MAX
] = {0};
1377 if ((pAd
->StaCfg
.ReqVarIELen
+ 17) <= IW_CUSTOM_MAX
)
1379 sprintf(custom
, "ASSOCINFO_ReqIEs=");
1380 NdisMoveMemory(custom
+17, pAd
->StaCfg
.ReqVarIEs
, pAd
->StaCfg
.ReqVarIELen
);
1381 RtmpOSWrielessEventSend(pAd
, IWEVCUSTOM
, RT_REQIE_EVENT_FLAG
, NULL
, (PUCHAR
)custom
, pAd
->StaCfg
.ReqVarIELen
+ 17);
1383 RtmpOSWrielessEventSend(pAd
, IWEVCUSTOM
, RT_ASSOCINFO_EVENT_FLAG
, NULL
, NULL
, 0);
1386 DBGPRINT(RT_DEBUG_TRACE
, ("pAd->StaCfg.ReqVarIELen + 17 > MAX_CUSTOM_LEN\n"));
1390 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
1391 #endif // WPA_SUPPLICANT_SUPPORT //
1393 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
1394 int wext_notify_event_assoc(
1395 IN RTMP_ADAPTER
*pAd
)
1397 char custom
[IW_CUSTOM_MAX
] = {0};
1399 #if WIRELESS_EXT > 17
1400 if (pAd
->StaCfg
.ReqVarIELen
<= IW_CUSTOM_MAX
)
1402 NdisMoveMemory(custom
, pAd
->StaCfg
.ReqVarIEs
, pAd
->StaCfg
.ReqVarIELen
);
1403 RtmpOSWrielessEventSend(pAd
, IWEVASSOCREQIE
, -1, NULL
, custom
, pAd
->StaCfg
.ReqVarIELen
);
1406 DBGPRINT(RT_DEBUG_TRACE
, ("pAd->StaCfg.ReqVarIELen > MAX_CUSTOM_LEN\n"));
1410 len
= (pAd
->StaCfg
.ReqVarIELen
*2) + 17;
1411 if (len
<= IW_CUSTOM_MAX
)
1414 sprintf(custom
, "ASSOCINFO(ReqIEs=");
1415 for (idx
=0; idx
<pAd
->StaCfg
.ReqVarIELen
; idx
++)
1416 sprintf(custom
, "%s%02x", custom
, pAd
->StaCfg
.ReqVarIEs
[idx
]);
1417 RtmpOSWrielessEventSend(pAd
, IWEVCUSTOM
, -1, NULL
, custom
, len
);
1420 DBGPRINT(RT_DEBUG_TRACE
, ("len(%d) > MAX_CUSTOM_LEN\n", len
));
1426 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
1429 BOOLEAN
StaAddMacTableEntry(
1430 IN PRTMP_ADAPTER pAd
,
1431 IN PMAC_TABLE_ENTRY pEntry
,
1432 IN UCHAR MaxSupportedRateIn500Kbps
,
1433 IN HT_CAPABILITY_IE
*pHtCapability
,
1434 IN UCHAR HtCapabilityLen
,
1435 IN ADD_HT_INFO_IE
*pAddHtInfo
,
1436 IN UCHAR AddHtInfoLen
,
1437 IN USHORT CapabilityInfo
)
1439 UCHAR MaxSupportedRate
= RATE_11
;
1442 CLIENT_STATUS_CLEAR_FLAG(pEntry
, fCLIENT_STATUS_WMM_CAPABLE
);
1444 switch (MaxSupportedRateIn500Kbps
)
1446 case 108: MaxSupportedRate
= RATE_54
; break;
1447 case 96: MaxSupportedRate
= RATE_48
; break;
1448 case 72: MaxSupportedRate
= RATE_36
; break;
1449 case 48: MaxSupportedRate
= RATE_24
; break;
1450 case 36: MaxSupportedRate
= RATE_18
; break;
1451 case 24: MaxSupportedRate
= RATE_12
; break;
1452 case 18: MaxSupportedRate
= RATE_9
; break;
1453 case 12: MaxSupportedRate
= RATE_6
; break;
1454 case 22: MaxSupportedRate
= RATE_11
; break;
1455 case 11: MaxSupportedRate
= RATE_5_5
; break;
1456 case 4: MaxSupportedRate
= RATE_2
; break;
1457 case 2: MaxSupportedRate
= RATE_1
; break;
1458 default: MaxSupportedRate
= RATE_11
; break;
1461 if ((pAd
->CommonCfg
.PhyMode
== PHY_11G
) && (MaxSupportedRate
< RATE_FIRST_OFDM_RATE
))
1464 #ifdef DOT11_N_SUPPORT
1466 if (((pAd
->CommonCfg
.PhyMode
== PHY_11N_2_4G
) || (pAd
->CommonCfg
.PhyMode
== PHY_11N_5G
))&& (HtCapabilityLen
== 0))
1468 #endif // DOT11_N_SUPPORT //
1473 NdisAcquireSpinLock(&pAd
->MacTabLock
);
1476 pEntry
->PortSecured
= WPA_802_1X_PORT_SECURED
;
1477 if ((MaxSupportedRate
< RATE_FIRST_OFDM_RATE
) ||
1478 (pAd
->CommonCfg
.PhyMode
== PHY_11B
))
1480 pEntry
->RateLen
= 4;
1481 if (MaxSupportedRate
>= RATE_FIRST_OFDM_RATE
)
1482 MaxSupportedRate
= RATE_11
;
1485 pEntry
->RateLen
= 12;
1487 pEntry
->MaxHTPhyMode
.word
= 0;
1488 pEntry
->MinHTPhyMode
.word
= 0;
1489 pEntry
->HTPhyMode
.word
= 0;
1490 pEntry
->MaxSupportedRate
= MaxSupportedRate
;
1491 if (pEntry
->MaxSupportedRate
< RATE_FIRST_OFDM_RATE
)
1493 pEntry
->MaxHTPhyMode
.field
.MODE
= MODE_CCK
;
1494 pEntry
->MaxHTPhyMode
.field
.MCS
= pEntry
->MaxSupportedRate
;
1495 pEntry
->MinHTPhyMode
.field
.MODE
= MODE_CCK
;
1496 pEntry
->MinHTPhyMode
.field
.MCS
= pEntry
->MaxSupportedRate
;
1497 pEntry
->HTPhyMode
.field
.MODE
= MODE_CCK
;
1498 pEntry
->HTPhyMode
.field
.MCS
= pEntry
->MaxSupportedRate
;
1502 pEntry
->MaxHTPhyMode
.field
.MODE
= MODE_OFDM
;
1503 pEntry
->MaxHTPhyMode
.field
.MCS
= OfdmRateToRxwiMCS
[pEntry
->MaxSupportedRate
];
1504 pEntry
->MinHTPhyMode
.field
.MODE
= MODE_OFDM
;
1505 pEntry
->MinHTPhyMode
.field
.MCS
= OfdmRateToRxwiMCS
[pEntry
->MaxSupportedRate
];
1506 pEntry
->HTPhyMode
.field
.MODE
= MODE_OFDM
;
1507 pEntry
->HTPhyMode
.field
.MCS
= OfdmRateToRxwiMCS
[pEntry
->MaxSupportedRate
];
1509 pEntry
->CapabilityInfo
= CapabilityInfo
;
1510 CLIENT_STATUS_CLEAR_FLAG(pEntry
, fCLIENT_STATUS_AGGREGATION_CAPABLE
);
1511 CLIENT_STATUS_CLEAR_FLAG(pEntry
, fCLIENT_STATUS_PIGGYBACK_CAPABLE
);
1514 #ifdef DOT11_N_SUPPORT
1515 NdisZeroMemory(&pEntry
->HTCapability
, sizeof(pEntry
->HTCapability
));
1516 // If this Entry supports 802.11n, upgrade to HT rate.
1517 if ((HtCapabilityLen
!= 0) && (pAd
->CommonCfg
.PhyMode
>= PHY_11ABGN_MIXED
))
1519 UCHAR j
, bitmask
; //k,bitmask;
1523 CLIENT_STATUS_SET_FLAG(pEntry
, fCLIENT_STATUS_WMM_CAPABLE
);
1524 if ((pHtCapability
->HtCapInfo
.GF
) && (pAd
->CommonCfg
.DesiredHtPhy
.GF
))
1526 pEntry
->MaxHTPhyMode
.field
.MODE
= MODE_HTGREENFIELD
;
1530 pEntry
->MaxHTPhyMode
.field
.MODE
= MODE_HTMIX
;
1531 pAd
->MacTab
.fAnyStationNonGF
= TRUE
;
1532 pAd
->CommonCfg
.AddHTInfo
.AddHtInfo2
.NonGfPresent
= 1;
1535 if ((pHtCapability
->HtCapInfo
.ChannelWidth
) &&
1536 (pAd
->CommonCfg
.DesiredHtPhy
.ChannelWidth
) &&
1537 ((pAd
->StaCfg
.BssType
== BSS_INFRA
) || ((pAd
->StaCfg
.BssType
== BSS_ADHOC
) && (pAddHtInfo
->AddHtInfo
.ExtChanOffset
== pAd
->CommonCfg
.AddHTInfo
.AddHtInfo
.ExtChanOffset
))))
1539 pEntry
->MaxHTPhyMode
.field
.BW
= BW_40
;
1540 pEntry
->MaxHTPhyMode
.field
.ShortGI
= ((pAd
->CommonCfg
.DesiredHtPhy
.ShortGIfor40
)&(pHtCapability
->HtCapInfo
.ShortGIfor40
));
1544 pEntry
->MaxHTPhyMode
.field
.BW
= BW_20
;
1545 pEntry
->MaxHTPhyMode
.field
.ShortGI
= ((pAd
->CommonCfg
.DesiredHtPhy
.ShortGIfor20
)&(pHtCapability
->HtCapInfo
.ShortGIfor20
));
1546 pAd
->MacTab
.fAnyStation20Only
= TRUE
;
1550 if (pAd
->MACVersion
>= RALINK_2883_VERSION
&& pAd
->MACVersion
< RALINK_3070_VERSION
)
1551 pEntry
->MaxHTPhyMode
.field
.TxBF
= pAd
->CommonCfg
.RegTransmitSetting
.field
.TxBF
;
1553 // find max fixed rate
1554 for (i
=23; i
>=0; i
--) // 3*3
1557 bitmask
= (1<<(i
-(j
*8)));
1558 if ((pAd
->StaCfg
.DesiredHtPhyInfo
.MCSSet
[j
] & bitmask
) && (pHtCapability
->MCSSet
[j
] & bitmask
))
1560 pEntry
->MaxHTPhyMode
.field
.MCS
= i
;
1568 if (pAd
->StaCfg
.DesiredTransmitSetting
.field
.MCS
!= MCS_AUTO
)
1570 if (pAd
->StaCfg
.DesiredTransmitSetting
.field
.MCS
== 32)
1572 // Fix MCS as HT Duplicated Mode
1573 pEntry
->MaxHTPhyMode
.field
.BW
= 1;
1574 pEntry
->MaxHTPhyMode
.field
.MODE
= MODE_HTMIX
;
1575 pEntry
->MaxHTPhyMode
.field
.STBC
= 0;
1576 pEntry
->MaxHTPhyMode
.field
.ShortGI
= 0;
1577 pEntry
->MaxHTPhyMode
.field
.MCS
= 32;
1579 else if (pEntry
->MaxHTPhyMode
.field
.MCS
> pAd
->StaCfg
.HTPhyMode
.field
.MCS
)
1581 // STA supports fixed MCS
1582 pEntry
->MaxHTPhyMode
.field
.MCS
= pAd
->StaCfg
.HTPhyMode
.field
.MCS
;
1586 pEntry
->MaxHTPhyMode
.field
.STBC
= (pHtCapability
->HtCapInfo
.RxSTBC
& (pAd
->CommonCfg
.DesiredHtPhy
.TxSTBC
));
1587 pEntry
->MpduDensity
= pHtCapability
->HtCapParm
.MpduDensity
;
1588 pEntry
->MaxRAmpduFactor
= pHtCapability
->HtCapParm
.MaxRAmpduFactor
;
1589 pEntry
->MmpsMode
= (UCHAR
)pHtCapability
->HtCapInfo
.MimoPs
;
1590 pEntry
->AMsduSize
= (UCHAR
)pHtCapability
->HtCapInfo
.AMsduSize
;
1591 pEntry
->HTPhyMode
.word
= pEntry
->MaxHTPhyMode
.word
;
1593 if (pAd
->CommonCfg
.DesiredHtPhy
.AmsduEnable
&& (pAd
->CommonCfg
.REGBACapability
.field
.AutoBA
== FALSE
))
1594 CLIENT_STATUS_SET_FLAG(pEntry
, fCLIENT_STATUS_AMSDU_INUSED
);
1595 if (pHtCapability
->HtCapInfo
.ShortGIfor20
)
1596 CLIENT_STATUS_SET_FLAG(pEntry
, fCLIENT_STATUS_SGI20_CAPABLE
);
1597 if (pHtCapability
->HtCapInfo
.ShortGIfor40
)
1598 CLIENT_STATUS_SET_FLAG(pEntry
, fCLIENT_STATUS_SGI40_CAPABLE
);
1599 if (pHtCapability
->HtCapInfo
.TxSTBC
)
1600 CLIENT_STATUS_SET_FLAG(pEntry
, fCLIENT_STATUS_TxSTBC_CAPABLE
);
1601 if (pHtCapability
->HtCapInfo
.RxSTBC
)
1602 CLIENT_STATUS_SET_FLAG(pEntry
, fCLIENT_STATUS_RxSTBC_CAPABLE
);
1603 if (pHtCapability
->ExtHtCapInfo
.PlusHTC
)
1604 CLIENT_STATUS_SET_FLAG(pEntry
, fCLIENT_STATUS_HTC_CAPABLE
);
1605 if (pAd
->CommonCfg
.bRdg
&& pHtCapability
->ExtHtCapInfo
.RDGSupport
)
1606 CLIENT_STATUS_SET_FLAG(pEntry
, fCLIENT_STATUS_RDG_CAPABLE
);
1607 if (pHtCapability
->ExtHtCapInfo
.MCSFeedback
== 0x03)
1608 CLIENT_STATUS_SET_FLAG(pEntry
, fCLIENT_STATUS_MCSFEEDBACK_CAPABLE
);
1609 NdisMoveMemory(&pEntry
->HTCapability
, pHtCapability
, HtCapabilityLen
);
1613 pAd
->MacTab
.fAnyStationIsLegacy
= TRUE
;
1615 #endif // DOT11_N_SUPPORT //
1617 pEntry
->HTPhyMode
.word
= pEntry
->MaxHTPhyMode
.word
;
1618 pEntry
->CurrTxRate
= pEntry
->MaxSupportedRate
;
1620 // Set asic auto fall back
1621 if (pAd
->StaCfg
.bAutoTxRateSwitch
== TRUE
)
1624 UCHAR TableSize
= 0;
1626 MlmeSelectTxRateTable(pAd
, pEntry
, &pTable
, &TableSize
, &pEntry
->CurrTxRateIndex
);
1627 pEntry
->bAutoTxRateSwitch
= TRUE
;
1631 pEntry
->HTPhyMode
.field
.MODE
= pAd
->StaCfg
.HTPhyMode
.field
.MODE
;
1632 pEntry
->HTPhyMode
.field
.MCS
= pAd
->StaCfg
.HTPhyMode
.field
.MCS
;
1633 pEntry
->bAutoTxRateSwitch
= FALSE
;
1635 // If the legacy mode is set, overwrite the transmit setting of this entry.
1636 RTMPUpdateLegacyTxSetting((UCHAR
)pAd
->StaCfg
.DesiredTransmitSetting
.field
.FixedTxMode
, pEntry
);
1639 pEntry
->PortSecured
= WPA_802_1X_PORT_SECURED
;
1640 pEntry
->Sst
= SST_ASSOC
;
1641 pEntry
->AuthState
= AS_AUTH_OPEN
;
1642 pEntry
->AuthMode
= pAd
->StaCfg
.AuthMode
;
1643 pEntry
->WepStatus
= pAd
->StaCfg
.WepStatus
;
1645 NdisReleaseSpinLock(&pAd
->MacTabLock
);
1647 #ifdef WPA_SUPPLICANT_SUPPORT
1648 #ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
1649 if (pAd
->StaCfg
.WpaSupplicantUP
)
1651 union iwreq_data wrqu
;
1653 SendAssocIEsToWpaSupplicant(pAd
);
1654 memset(&wrqu
, 0, sizeof(wrqu
));
1655 wrqu
.data
.flags
= RT_ASSOC_EVENT_FLAG
;
1656 wireless_send_event(pAd
->net_dev
, IWEVCUSTOM
, &wrqu
, NULL
);
1658 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
1659 #endif // WPA_SUPPLICANT_SUPPORT //
1661 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
1663 union iwreq_data wrqu
;
1664 wext_notify_event_assoc(pAd
);
1666 memset(wrqu
.ap_addr
.sa_data
, 0, MAC_ADDR_LEN
);
1667 memcpy(wrqu
.ap_addr
.sa_data
, pAd
->MlmeAux
.Bssid
, MAC_ADDR_LEN
);
1668 wireless_send_event(pAd
->net_dev
, SIOCGIWAP
, &wrqu
, NULL
);
1671 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //