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 Chang 2004-09-01 add WMM support
37 #include "../rt_config.h"
40 extern UCHAR CISCO_OUI[];
42 extern UCHAR WPA_OUI[];
43 extern UCHAR RSN_OUI[];
44 extern UCHAR WME_INFO_ELEM[];
45 extern UCHAR WME_PARM_ELEM[];
46 extern UCHAR Ccx2QosInfo[];
47 extern UCHAR RALINK_OUI[];
48 extern UCHAR BROADCOM_OUI[];
49 extern UCHAR WPS_OUI[];
52 ==========================================================================
54 MLME message sanity check
56 TRUE if all parameters are OK, FALSE otherwise
60 ==========================================================================
62 BOOLEAN MlmeAddBAReqSanity(
68 PMLME_ADDBA_REQ_STRUCT pInfo;
70 pInfo = (MLME_ADDBA_REQ_STRUCT *)Msg;
72 if ((MsgLen != sizeof(MLME_ADDBA_REQ_STRUCT)))
74 DBGPRINT(RT_DEBUG_TRACE, ("MlmeAddBAReqSanity fail - message lenght not correct.\n"));
78 if ((pInfo->Wcid >= MAX_LEN_OF_MAC_TABLE))
80 DBGPRINT(RT_DEBUG_TRACE, ("MlmeAddBAReqSanity fail - The peer Mac is not associated yet.\n"));
85 if ((pInfo->BaBufSize > MAX_RX_REORDERBUF) || (pInfo->BaBufSize < 2))
87 DBGPRINT(RT_DEBUG_TRACE, ("MlmeAddBAReqSanity fail - Rx Reordering buffer too big or too small\n"));
92 if ((pInfo->pAddr[0]&0x01) == 0x01)
94 DBGPRINT(RT_DEBUG_TRACE, ("MlmeAddBAReqSanity fail - broadcast address not support BA\n"));
102 ==========================================================================
104 MLME message sanity check
106 TRUE if all parameters are OK, FALSE otherwise
108 IRQL = DISPATCH_LEVEL
110 ==========================================================================
112 BOOLEAN MlmeDelBAReqSanity(
113 IN PRTMP_ADAPTER pAd,
117 MLME_DELBA_REQ_STRUCT *pInfo;
118 pInfo = (MLME_DELBA_REQ_STRUCT *)Msg;
120 if ((MsgLen != sizeof(MLME_DELBA_REQ_STRUCT)))
122 DBGPRINT(RT_DEBUG_ERROR, ("MlmeDelBAReqSanity fail - message lenght not correct.\n"));
126 if ((pInfo->Wcid >= MAX_LEN_OF_MAC_TABLE))
128 DBGPRINT(RT_DEBUG_ERROR, ("MlmeDelBAReqSanity fail - The peer Mac is not associated yet.\n"));
132 if ((pInfo->TID & 0xf0))
134 DBGPRINT(RT_DEBUG_ERROR, ("MlmeDelBAReqSanity fail - The peer TID is incorrect.\n"));
138 if (NdisEqualMemory(pAd->MacTab.Content[pInfo->Wcid].Addr, pInfo->Addr, MAC_ADDR_LEN) == 0)
140 DBGPRINT(RT_DEBUG_ERROR, ("MlmeDelBAReqSanity fail - the peer addr dosen't exist.\n"));
147 BOOLEAN PeerAddBAReqActionSanity(
148 IN PRTMP_ADAPTER pAd,
153 PFRAME_802_11 pFrame = (PFRAME_802_11)pMsg;
154 PFRAME_ADDBA_REQ pAddFrame;
155 pAddFrame = (PFRAME_ADDBA_REQ)(pMsg);
156 if (MsgLen < (sizeof(FRAME_ADDBA_REQ)))
158 DBGPRINT(RT_DEBUG_ERROR,("PeerAddBAReqActionSanity: ADDBA Request frame length size = %ld incorrect\n", MsgLen));
161 // we support immediate BA.
162 *(USHORT *)(&pAddFrame->BaParm) = cpu2le16(*(USHORT *)(&pAddFrame->BaParm));
163 pAddFrame->TimeOutValue = cpu2le16(pAddFrame->TimeOutValue);
164 pAddFrame->BaStartSeq.word = cpu2le16(pAddFrame->BaStartSeq.word);
166 if (pAddFrame->BaParm.BAPolicy != IMMED_BA)
168 DBGPRINT(RT_DEBUG_ERROR,("PeerAddBAReqActionSanity: ADDBA Request Ba Policy[%d] not support\n", pAddFrame->BaParm.BAPolicy));
169 DBGPRINT(RT_DEBUG_ERROR,("ADDBA Request. tid=%x, Bufsize=%x, AMSDUSupported=%x \n", pAddFrame->BaParm.TID, pAddFrame->BaParm.BufSize, pAddFrame->BaParm.AMSDUSupported));
173 // we support immediate BA.
174 if (pAddFrame->BaParm.TID &0xfff0)
176 DBGPRINT(RT_DEBUG_ERROR,("PeerAddBAReqActionSanity: ADDBA Request incorrect TID = %d\n", pAddFrame->BaParm.TID));
179 COPY_MAC_ADDR(pAddr2, pFrame->Hdr.Addr2);
183 BOOLEAN PeerAddBARspActionSanity(
184 IN PRTMP_ADAPTER pAd,
188 //PFRAME_802_11 pFrame = (PFRAME_802_11)pMsg;
189 PFRAME_ADDBA_RSP pAddFrame;
191 pAddFrame = (PFRAME_ADDBA_RSP)(pMsg);
192 if (MsgLen < (sizeof(FRAME_ADDBA_RSP)))
194 DBGPRINT(RT_DEBUG_ERROR,("PeerAddBARspActionSanity: ADDBA Response frame length size = %ld incorrect\n", MsgLen));
197 // we support immediate BA.
198 *(USHORT *)(&pAddFrame->BaParm) = cpu2le16(*(USHORT *)(&pAddFrame->BaParm));
199 pAddFrame->StatusCode = cpu2le16(pAddFrame->StatusCode);
200 pAddFrame->TimeOutValue = cpu2le16(pAddFrame->TimeOutValue);
202 if (pAddFrame->BaParm.BAPolicy != IMMED_BA)
204 DBGPRINT(RT_DEBUG_ERROR,("PeerAddBAReqActionSanity: ADDBA Response Ba Policy[%d] not support\n", pAddFrame->BaParm.BAPolicy));
208 // we support immediate BA.
209 if (pAddFrame->BaParm.TID &0xfff0)
211 DBGPRINT(RT_DEBUG_ERROR,("PeerAddBARspActionSanity: ADDBA Response incorrect TID = %d\n", pAddFrame->BaParm.TID));
218 BOOLEAN PeerDelBAActionSanity(
219 IN PRTMP_ADAPTER pAd,
224 //PFRAME_802_11 pFrame = (PFRAME_802_11)pMsg;
225 PFRAME_DELBA_REQ pDelFrame;
226 if (MsgLen != (sizeof(FRAME_DELBA_REQ)))
229 if (Wcid >= MAX_LEN_OF_MAC_TABLE)
232 pDelFrame = (PFRAME_DELBA_REQ)(pMsg);
234 *(USHORT *)(&pDelFrame->DelbaParm) = cpu2le16(*(USHORT *)(&pDelFrame->DelbaParm));
235 pDelFrame->ReasonCode = cpu2le16(pDelFrame->ReasonCode);
237 if (pDelFrame->DelbaParm.TID &0xfff0)
244 ==========================================================================
246 MLME message sanity check
248 TRUE if all parameters are OK, FALSE otherwise
250 IRQL = DISPATCH_LEVEL
252 ==========================================================================
254 BOOLEAN PeerBeaconAndProbeRspSanity(
255 IN PRTMP_ADAPTER pAd,
264 OUT USHORT *pBeaconPeriod,
266 OUT UCHAR *pNewChannel,
267 OUT LARGE_INTEGER *pTimestamp,
268 OUT CF_PARM *pCfParm,
269 OUT USHORT *pAtimWin,
270 OUT USHORT *pCapabilityInfo,
272 OUT UCHAR *pDtimCount,
273 OUT UCHAR *pDtimPeriod,
274 OUT UCHAR *pBcastFlag,
275 OUT UCHAR *pMessageToMe,
277 OUT UCHAR *pSupRateLen,
279 OUT UCHAR *pExtRateLen,
280 OUT UCHAR *pCkipFlag,
281 OUT UCHAR *pAironetCellPowerLimit,
282 OUT PEDCA_PARM pEdcaParm,
283 OUT PQBSS_LOAD_PARM pQbssLoad,
284 OUT PQOS_CAPABILITY_PARM pQosCapability,
285 OUT ULONG *pRalinkIe,
286 OUT UCHAR *pHtCapabilityLen,
287 #ifdef CONFIG_STA_SUPPORT
288 OUT UCHAR *pPreNHtCapabilityLen,
289 #endif // CONFIG_STA_SUPPORT //
290 OUT HT_CAPABILITY_IE *pHtCapability,
291 OUT UCHAR *AddHtInfoLen,
292 OUT ADD_HT_INFO_IE *AddHtInfo,
293 OUT UCHAR *NewExtChannelOffset, // Ht extension channel offset(above or below)
294 OUT USHORT *LengthVIE,
295 OUT PNDIS_802_11_VARIABLE_IEs pVIE)
298 #ifdef CONFIG_STA_SUPPORT
300 #endif // CONFIG_STA_SUPPORT //
301 PFRAME_802_11 pFrame;
305 //UCHAR ECWMin, ECWMax;
306 //MAC_CSR9_STRUC Csr9;
309 // For some 11a AP which didn't have DS_IE, we use two conditions to decide the channel
310 // 1. If the AP is 11n enabled, then check the control channel.
311 // 2. If the AP didn't have any info about channel, use the channel we received this frame as the channel. (May inaccuracy!!)
312 UCHAR CtrlChannel = 0;
314 // Add for 3 necessary EID field check
324 *pCkipFlag = 0; // Default of CkipFlag is 0
325 *pAironetCellPowerLimit = 0xFF; // Default of AironetCellPowerLimit is 0xFF
326 *LengthVIE = 0; // Set the length of VIE to init value 0
327 *pHtCapabilityLen = 0; // Set the length of VIE to init value 0
328 #ifdef CONFIG_STA_SUPPORT
329 if (pAd->OpMode == OPMODE_STA)
330 *pPreNHtCapabilityLen = 0; // Set the length of VIE to init value 0
331 #endif // CONFIG_STA_SUPPORT //
332 *AddHtInfoLen = 0; // Set the length of VIE to init value 0
335 *NewExtChannelOffset = 0xff; //Default 0xff means no such IE
336 pCfParm->bValid = FALSE; // default: no IE_CF found
337 pQbssLoad->bValid = FALSE; // default: no IE_QBSS_LOAD found
338 pEdcaParm->bValid = FALSE; // default: no IE_EDCA_PARAMETER found
339 pQosCapability->bValid = FALSE; // default: no IE_QOS_CAPABILITY found
341 pFrame = (PFRAME_802_11)Msg;
343 // get subtype from header
344 SubType = (UCHAR)pFrame->Hdr.FC.SubType;
346 // get Addr2 and BSSID from header
347 COPY_MAC_ADDR(pAddr2, pFrame->Hdr.Addr2);
348 COPY_MAC_ADDR(pBssid, pFrame->Hdr.Addr3);
350 // hex_dump("Beacon", Msg, MsgLen);
353 Length += LENGTH_802_11;
355 // get timestamp from payload and advance the pointer
356 NdisMoveMemory(pTimestamp, Ptr, TIMESTAMP_LEN);
358 pTimestamp->u.LowPart = cpu2le32(pTimestamp->u.LowPart);
359 pTimestamp->u.HighPart = cpu2le32(pTimestamp->u.HighPart);
361 Ptr += TIMESTAMP_LEN;
362 Length += TIMESTAMP_LEN;
364 // get beacon interval from payload and advance the pointer
365 NdisMoveMemory(pBeaconPeriod, Ptr, 2);
369 // get capability info from payload and advance the pointer
370 NdisMoveMemory(pCapabilityInfo, Ptr, 2);
374 if (CAP_IS_ESS_ON(*pCapabilityInfo))
375 *pBssType = BSS_INFRA;
377 *pBssType = BSS_ADHOC;
379 pEid = (PEID_STRUCT) Ptr;
381 // get variable fields from payload and advance the pointer
382 while ((Length + 2 + pEid->Len) <= MsgLen)
385 // Secure copy VIE to VarIE[MAX_VIE_LEN] didn't overflow.
387 if ((*LengthVIE + pEid->Len + 2) >= MAX_VIE_LEN)
389 DBGPRINT(RT_DEBUG_WARN, ("PeerBeaconAndProbeRspSanity - Variable IEs out of resource [len(=%d) > MAX_VIE_LEN(=%d)]\n",
390 (*LengthVIE + pEid->Len + 2), MAX_VIE_LEN));
397 // Already has one SSID EID in this beacon, ignore the second one
400 if(pEid->Len <= MAX_LEN_OF_SSID)
402 NdisMoveMemory(Ssid, pEid->Octet, pEid->Len);
403 *pSsidLen = pEid->Len;
408 DBGPRINT(RT_DEBUG_TRACE, ("PeerBeaconAndProbeRspSanity - wrong IE_SSID (len=%d)\n",pEid->Len));
414 if(pEid->Len <= MAX_LEN_OF_SUPPORTED_RATES)
417 NdisMoveMemory(SupRate, pEid->Octet, pEid->Len);
418 *pSupRateLen = pEid->Len;
420 // TODO: 2004-09-14 not a good design here, cause it exclude extra rates
421 // from ScanTab. We should report as is. And filter out unsupported
423 // Check against the supported rates
424 // RTMPCheckRates(pAd, SupRate, pSupRateLen);
428 DBGPRINT(RT_DEBUG_TRACE, ("PeerBeaconAndProbeRspSanity - wrong IE_SUPP_RATES (len=%d)\n",pEid->Len));
434 if (pEid->Len >= SIZE_HT_CAP_IE) //Note: allow extension.!!
436 NdisMoveMemory(pHtCapability, pEid->Octet, sizeof(HT_CAPABILITY_IE));
437 *pHtCapabilityLen = SIZE_HT_CAP_IE; // Nnow we only support 26 bytes.
439 *(USHORT *)(&pHtCapability->HtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->HtCapInfo));
440 *(USHORT *)(&pHtCapability->ExtHtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->ExtHtCapInfo));
442 #ifdef CONFIG_STA_SUPPORT
443 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
445 *pPreNHtCapabilityLen = 0; // Nnow we only support 26 bytes.
448 NdisMoveMemory(Ptr + *LengthVIE, &pEid->Eid, pEid->Len + 2);
449 *LengthVIE += (pEid->Len + 2);
451 #endif // CONFIG_STA_SUPPORT //
455 DBGPRINT(RT_DEBUG_WARN, ("PeerBeaconAndProbeRspSanity - wrong IE_HT_CAP. pEid->Len = %d\n", pEid->Len));
460 if (pEid->Len >= sizeof(ADD_HT_INFO_IE))
462 // This IE allows extension, but we can ignore extra bytes beyond our knowledge , so only
463 // copy first sizeof(ADD_HT_INFO_IE)
464 NdisMoveMemory(AddHtInfo, pEid->Octet, sizeof(ADD_HT_INFO_IE));
465 *AddHtInfoLen = SIZE_ADD_HT_INFO_IE;
467 CtrlChannel = AddHtInfo->ControlChan;
469 *(USHORT *)(&AddHtInfo->AddHtInfo2) = cpu2le16(*(USHORT *)(&AddHtInfo->AddHtInfo2));
470 *(USHORT *)(&AddHtInfo->AddHtInfo3) = cpu2le16(*(USHORT *)(&AddHtInfo->AddHtInfo3));
472 #ifdef CONFIG_STA_SUPPORT
473 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
476 NdisMoveMemory(Ptr + *LengthVIE, &pEid->Eid, pEid->Len + 2);
477 *LengthVIE += (pEid->Len + 2);
479 #endif // CONFIG_STA_SUPPORT //
483 DBGPRINT(RT_DEBUG_WARN, ("PeerBeaconAndProbeRspSanity - wrong IE_ADD_HT. \n"));
487 case IE_SECONDARY_CH_OFFSET:
490 *NewExtChannelOffset = pEid->Octet[0];
494 DBGPRINT(RT_DEBUG_WARN, ("PeerBeaconAndProbeRspSanity - wrong IE_SECONDARY_CH_OFFSET. \n"));
499 DBGPRINT(RT_DEBUG_TRACE, ("PeerBeaconAndProbeRspSanity(IE_FH_PARM) \n"));
505 *pChannel = *pEid->Octet;
506 #ifdef CONFIG_STA_SUPPORT
507 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
509 if (ChannelSanity(pAd, *pChannel) == 0)
515 #endif // CONFIG_STA_SUPPORT //
520 DBGPRINT(RT_DEBUG_TRACE, ("PeerBeaconAndProbeRspSanity - wrong IE_DS_PARM (len=%d)\n",pEid->Len));
528 pCfParm->bValid = TRUE;
529 pCfParm->CfpCount = pEid->Octet[0];
530 pCfParm->CfpPeriod = pEid->Octet[1];
531 pCfParm->CfpMaxDuration = pEid->Octet[2] + 256 * pEid->Octet[3];
532 pCfParm->CfpDurRemaining = pEid->Octet[4] + 256 * pEid->Octet[5];
536 DBGPRINT(RT_DEBUG_TRACE, ("PeerBeaconAndProbeRspSanity - wrong IE_CF_PARM\n"));
544 NdisMoveMemory(pAtimWin, pEid->Octet, pEid->Len);
548 DBGPRINT(RT_DEBUG_TRACE, ("PeerBeaconAndProbeRspSanity - wrong IE_IBSS_PARM\n"));
553 #ifdef CONFIG_STA_SUPPORT
555 if(INFRA_ON(pAd) && SubType == SUBTYPE_BEACON)
557 GetTimBit((PUCHAR)pEid, pAd->StaActive.Aid, &TimLen, pBcastFlag, pDtimCount, pDtimPeriod, pMessageToMe);
560 #endif // CONFIG_STA_SUPPORT //
561 case IE_CHANNEL_SWITCH_ANNOUNCEMENT:
564 *pNewChannel = pEid->Octet[1]; //extract new channel number
569 // CCX v2 has the same IE, we need to parse that too
570 // Wifi WMM use the same IE vale, need to parse that too
572 case IE_VENDOR_SPECIFIC:
573 // Check Broadcom/Atheros 802.11n OUI version, for HT Capability IE.
574 // This HT IE is before IEEE draft set HT IE value.2006-09-28 by Jan.
575 /*if (NdisEqualMemory(pEid->Octet, BROADCOM_OUI, 3) && (pEid->Len >= 4))
577 if ((pEid->Octet[3] == OUI_BROADCOM_HT) && (pEid->Len >= 30))
580 NdisMoveMemory(pHtCapability, &pEid->Octet[4], sizeof(HT_CAPABILITY_IE));
581 *pHtCapabilityLen = SIZE_HT_CAP_IE; // Nnow we only support 26 bytes.
584 if ((pEid->Octet[3] == OUI_BROADCOM_HT) && (pEid->Len >= 26))
587 NdisMoveMemory(AddHtInfo, &pEid->Octet[4], sizeof(ADD_HT_INFO_IE));
588 *AddHtInfoLen = SIZE_ADD_HT_INFO_IE; // Nnow we only support 26 bytes.
593 // Check the OUI version, filter out non-standard usage
594 if (NdisEqualMemory(pEid->Octet, RALINK_OUI, 3) && (pEid->Len == 7))
596 //*pRalinkIe = pEid->Octet[3];
597 if (pEid->Octet[3] != 0)
598 *pRalinkIe = pEid->Octet[3];
600 *pRalinkIe = 0xf0000000; // Set to non-zero value (can't set bit0-2) to represent this is Ralink Chip. So at linkup, we will set ralinkchip flag.
602 #ifdef CONFIG_STA_SUPPORT
603 #ifdef DOT11_N_SUPPORT
604 // This HT IE is before IEEE draft set HT IE value.2006-09-28 by Jan.
606 // Other vendors had production before IE_HT_CAP value is assigned. To backward support those old-firmware AP,
607 // Check broadcom-defiend pre-802.11nD1.0 OUI for HT related IE, including HT Capatilities IE and HT Information IE
608 else if ((*pHtCapabilityLen == 0) && NdisEqualMemory(pEid->Octet, PRE_N_HT_OUI, 3) && (pEid->Len >= 4) && (pAd->OpMode == OPMODE_STA))
610 if ((pEid->Octet[3] == OUI_PREN_HT_CAP) && (pEid->Len >= 30) && (*pHtCapabilityLen == 0))
612 NdisMoveMemory(pHtCapability, &pEid->Octet[4], sizeof(HT_CAPABILITY_IE));
613 *pPreNHtCapabilityLen = SIZE_HT_CAP_IE;
616 if ((pEid->Octet[3] == OUI_PREN_ADD_HT) && (pEid->Len >= 26))
618 NdisMoveMemory(AddHtInfo, &pEid->Octet[4], sizeof(ADD_HT_INFO_IE));
619 *AddHtInfoLen = SIZE_ADD_HT_INFO_IE;
622 #endif // DOT11_N_SUPPORT //
623 #endif // CONFIG_STA_SUPPORT //
624 else if (NdisEqualMemory(pEid->Octet, WPA_OUI, 4))
626 // Copy to pVIE which will report to microsoft bssid list.
628 NdisMoveMemory(Ptr + *LengthVIE, &pEid->Eid, pEid->Len + 2);
629 *LengthVIE += (pEid->Len + 2);
631 else if (NdisEqualMemory(pEid->Octet, WME_PARM_ELEM, 6) && (pEid->Len == 24))
636 // parsing EDCA parameters
637 pEdcaParm->bValid = TRUE;
638 pEdcaParm->bQAck = FALSE; // pEid->Octet[0] & 0x10;
639 pEdcaParm->bQueueRequest = FALSE; // pEid->Octet[0] & 0x20;
640 pEdcaParm->bTxopRequest = FALSE; // pEid->Octet[0] & 0x40;
641 pEdcaParm->EdcaUpdateCount = pEid->Octet[6] & 0x0f;
642 pEdcaParm->bAPSDCapable = (pEid->Octet[6] & 0x80) ? 1 : 0;
643 ptr = &pEid->Octet[8];
646 UCHAR aci = (*ptr & 0x60) >> 5; // b5~6 is AC INDEX
647 pEdcaParm->bACM[aci] = (((*ptr) & 0x10) == 0x10); // b5 is ACM
648 pEdcaParm->Aifsn[aci] = (*ptr) & 0x0f; // b0~3 is AIFSN
649 pEdcaParm->Cwmin[aci] = *(ptr+1) & 0x0f; // b0~4 is Cwmin
650 pEdcaParm->Cwmax[aci] = *(ptr+1) >> 4; // b5~8 is Cwmax
651 pEdcaParm->Txop[aci] = *(ptr+2) + 256 * (*(ptr+3)); // in unit of 32-us
652 ptr += 4; // point to next AC
655 else if (NdisEqualMemory(pEid->Octet, WME_INFO_ELEM, 6) && (pEid->Len == 7))
657 // parsing EDCA parameters
658 pEdcaParm->bValid = TRUE;
659 pEdcaParm->bQAck = FALSE; // pEid->Octet[0] & 0x10;
660 pEdcaParm->bQueueRequest = FALSE; // pEid->Octet[0] & 0x20;
661 pEdcaParm->bTxopRequest = FALSE; // pEid->Octet[0] & 0x40;
662 pEdcaParm->EdcaUpdateCount = pEid->Octet[6] & 0x0f;
663 pEdcaParm->bAPSDCapable = (pEid->Octet[6] & 0x80) ? 1 : 0;
665 // use default EDCA parameter
666 pEdcaParm->bACM[QID_AC_BE] = 0;
667 pEdcaParm->Aifsn[QID_AC_BE] = 3;
668 pEdcaParm->Cwmin[QID_AC_BE] = CW_MIN_IN_BITS;
669 pEdcaParm->Cwmax[QID_AC_BE] = CW_MAX_IN_BITS;
670 pEdcaParm->Txop[QID_AC_BE] = 0;
672 pEdcaParm->bACM[QID_AC_BK] = 0;
673 pEdcaParm->Aifsn[QID_AC_BK] = 7;
674 pEdcaParm->Cwmin[QID_AC_BK] = CW_MIN_IN_BITS;
675 pEdcaParm->Cwmax[QID_AC_BK] = CW_MAX_IN_BITS;
676 pEdcaParm->Txop[QID_AC_BK] = 0;
678 pEdcaParm->bACM[QID_AC_VI] = 0;
679 pEdcaParm->Aifsn[QID_AC_VI] = 2;
680 pEdcaParm->Cwmin[QID_AC_VI] = CW_MIN_IN_BITS-1;
681 pEdcaParm->Cwmax[QID_AC_VI] = CW_MAX_IN_BITS;
682 pEdcaParm->Txop[QID_AC_VI] = 96; // AC_VI: 96*32us ~= 3ms
684 pEdcaParm->bACM[QID_AC_VO] = 0;
685 pEdcaParm->Aifsn[QID_AC_VO] = 2;
686 pEdcaParm->Cwmin[QID_AC_VO] = CW_MIN_IN_BITS-2;
687 pEdcaParm->Cwmax[QID_AC_VO] = CW_MAX_IN_BITS-1;
688 pEdcaParm->Txop[QID_AC_VO] = 48; // AC_VO: 48*32us ~= 1.5ms
692 case IE_EXT_SUPP_RATES:
693 if (pEid->Len <= MAX_LEN_OF_SUPPORTED_RATES)
695 NdisMoveMemory(ExtRate, pEid->Octet, pEid->Len);
696 *pExtRateLen = pEid->Len;
698 // TODO: 2004-09-14 not a good design here, cause it exclude extra rates
699 // from ScanTab. We should report as is. And filter out unsupported
701 // Check against the supported rates
702 // RTMPCheckRates(pAd, ExtRate, pExtRateLen);
709 *pErp = (UCHAR)pEid->Octet[0];
713 case IE_AIRONET_CKIP:
714 // 0. Check Aironet IE length, it must be larger or equal to 28
715 // Cisco AP350 used length as 28
716 // Cisco AP12XX used length as 30
717 if (pEid->Len < (CKIP_NEGOTIATION_LENGTH - 2))
720 // 1. Copy CKIP flag byte to buffer for process
721 *pCkipFlag = *(pEid->Octet + 8);
725 // AP Control of Client Transmit Power
726 //0. Check Aironet IE length, it must be 6
727 if (pEid->Len != 0x06)
730 // Get cell power limit in dBm
731 if (NdisEqualMemory(pEid->Octet, CISCO_OUI, 3) == 1)
732 *pAironetCellPowerLimit = *(pEid->Octet + 4);
735 // WPA2 & 802.11i RSN
737 // There is no OUI for version anymore, check the group cipher OUI before copying
738 if (RTMPEqualMemory(pEid->Octet + 2, RSN_OUI, 3))
740 // Copy to pVIE which will report to microsoft bssid list.
742 NdisMoveMemory(Ptr + *LengthVIE, &pEid->Eid, pEid->Len + 2);
743 *LengthVIE += (pEid->Len + 2);
746 #ifdef CONFIG_STA_SUPPORT
747 #ifdef EXT_BUILD_CHANNEL_LIST
750 NdisMoveMemory(Ptr + *LengthVIE, &pEid->Eid, pEid->Len + 2);
751 *LengthVIE += (pEid->Len + 2);
753 #endif // EXT_BUILD_CHANNEL_LIST //
754 #endif // CONFIG_STA_SUPPORT //
759 Length = Length + 2 + pEid->Len; // Eid[1] + Len[1]+ content[Len]
760 pEid = (PEID_STRUCT)((UCHAR*)pEid + 2 + pEid->Len);
763 // For some 11a AP. it did not have the channel EID, patch here
764 #ifdef CONFIG_STA_SUPPORT
765 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
767 UCHAR LatchRfChannel = MsgChannel;
768 if ((pAd->LatchRfRegs.Channel > 14) && ((Sanity & 0x4) == 0))
770 if (CtrlChannel != 0)
771 *pChannel = CtrlChannel;
773 *pChannel = LatchRfChannel;
777 #endif // CONFIG_STA_SUPPORT //
781 DBGPRINT(RT_DEBUG_WARN, ("PeerBeaconAndProbeRspSanity - missing field, Sanity=0x%02x\n", Sanity));
793 ==========================================================================
795 MLME message sanity check for some IE addressed in 802.11n d3.03.
797 TRUE if all parameters are OK, FALSE otherwise
799 IRQL = DISPATCH_LEVEL
801 ==========================================================================
803 BOOLEAN PeerBeaconAndProbeRspSanity2(
804 IN PRTMP_ADAPTER pAd,
810 PFRAME_802_11 pFrame;
814 pFrame = (PFRAME_802_11)Msg;
818 Length += LENGTH_802_11;
820 // get timestamp from payload and advance the pointer
821 Ptr += TIMESTAMP_LEN;
822 Length += TIMESTAMP_LEN;
824 // get beacon interval from payload and advance the pointer
828 // get capability info from payload and advance the pointer
832 pEid = (PEID_STRUCT) Ptr;
834 // get variable fields from payload and advance the pointer
835 while ((Length + 2 + pEid->Len) <= MsgLen)
839 case IE_SUPP_REG_CLASS:
842 *RegClass = *pEid->Octet;
846 DBGPRINT(RT_DEBUG_TRACE, ("PeerBeaconAndProbeRspSanity - wrong IE_SSID (len=%d)\n",pEid->Len));
852 Length = Length + 2 + pEid->Len; // Eid[1] + Len[1]+ content[Len]
853 pEid = (PEID_STRUCT)((UCHAR*)pEid + 2 + pEid->Len);
859 #endif // DOT11N_DRAFT3 //
862 ==========================================================================
864 MLME message sanity check
866 TRUE if all parameters are OK, FALSE otherwise
867 ==========================================================================
869 BOOLEAN MlmeScanReqSanity(
870 IN PRTMP_ADAPTER pAd,
876 OUT UCHAR *pScanType)
878 MLME_SCAN_REQ_STRUCT *Info;
880 Info = (MLME_SCAN_REQ_STRUCT *)(Msg);
881 *pBssType = Info->BssType;
882 *pSsidLen = Info->SsidLen;
883 NdisMoveMemory(Ssid, Info->Ssid, *pSsidLen);
884 *pScanType = Info->ScanType;
886 if ((*pBssType == BSS_INFRA || *pBssType == BSS_ADHOC || *pBssType == BSS_ANY)
887 && (*pScanType == SCAN_ACTIVE || *pScanType == SCAN_PASSIVE
888 #ifdef CONFIG_STA_SUPPORT
889 || *pScanType == SCAN_CISCO_PASSIVE || *pScanType == SCAN_CISCO_ACTIVE
890 || *pScanType == SCAN_CISCO_CHANNEL_LOAD || *pScanType == SCAN_CISCO_NOISE
891 #endif // CONFIG_STA_SUPPORT //
898 DBGPRINT(RT_DEBUG_TRACE, ("MlmeScanReqSanity fail - wrong BssType or ScanType\n"));
903 // IRQL = DISPATCH_LEVEL
905 IN PRTMP_ADAPTER pAd,
910 for (i = 0; i < pAd->ChannelListNum; i ++)
912 if (channel == pAd->ChannelList[i].Channel)
919 ==========================================================================
921 MLME message sanity check
923 TRUE if all parameters are OK, FALSE otherwise
925 IRQL = DISPATCH_LEVEL
927 ==========================================================================
929 BOOLEAN PeerDeauthSanity(
930 IN PRTMP_ADAPTER pAd,
936 PFRAME_802_11 pFrame = (PFRAME_802_11)Msg;
938 COPY_MAC_ADDR(pAddr2, pFrame->Hdr.Addr2);
939 NdisMoveMemory(pReason, &pFrame->Octet[0], 2);
945 ==========================================================================
947 MLME message sanity check
949 TRUE if all parameters are OK, FALSE otherwise
951 IRQL = DISPATCH_LEVEL
953 ==========================================================================
955 BOOLEAN PeerAuthSanity(
956 IN PRTMP_ADAPTER pAd,
965 PFRAME_802_11 pFrame = (PFRAME_802_11)Msg;
967 COPY_MAC_ADDR(pAddr, pFrame->Hdr.Addr2);
968 NdisMoveMemory(pAlg, &pFrame->Octet[0], 2);
969 NdisMoveMemory(pSeq, &pFrame->Octet[2], 2);
970 NdisMoveMemory(pStatus, &pFrame->Octet[4], 2);
972 if ((*pAlg == Ndis802_11AuthModeOpen)
974 || (*pAlg == CISCO_AuthModeLEAP)
975 #endif // LEAP_SUPPORT //
978 if (*pSeq == 1 || *pSeq == 2)
984 DBGPRINT(RT_DEBUG_TRACE, ("PeerAuthSanity fail - wrong Seg#\n"));
988 else if (*pAlg == Ndis802_11AuthModeShared)
990 if (*pSeq == 1 || *pSeq == 4)
994 else if (*pSeq == 2 || *pSeq == 3)
996 NdisMoveMemory(pChlgText, &pFrame->Octet[8], CIPHER_TEXT_LEN);
1001 DBGPRINT(RT_DEBUG_TRACE, ("PeerAuthSanity fail - wrong Seg#\n"));
1007 DBGPRINT(RT_DEBUG_TRACE, ("PeerAuthSanity fail - wrong algorithm\n"));
1013 ==========================================================================
1015 MLME message sanity check
1017 TRUE if all parameters are OK, FALSE otherwise
1018 ==========================================================================
1020 BOOLEAN MlmeAuthReqSanity(
1021 IN PRTMP_ADAPTER pAd,
1025 OUT ULONG *pTimeout,
1028 MLME_AUTH_REQ_STRUCT *pInfo;
1030 pInfo = (MLME_AUTH_REQ_STRUCT *)Msg;
1031 COPY_MAC_ADDR(pAddr, pInfo->Addr);
1032 *pTimeout = pInfo->Timeout;
1035 if (((*pAlg == Ndis802_11AuthModeShared) ||(*pAlg == Ndis802_11AuthModeOpen)
1037 || (*pAlg == CISCO_AuthModeLEAP)
1038 #endif // LEAP_SUPPORT //
1040 ((*pAddr & 0x01) == 0))
1046 DBGPRINT(RT_DEBUG_TRACE, ("MlmeAuthReqSanity fail - wrong algorithm\n"));
1052 ==========================================================================
1054 MLME message sanity check
1056 TRUE if all parameters are OK, FALSE otherwise
1058 IRQL = DISPATCH_LEVEL
1060 ==========================================================================
1062 BOOLEAN MlmeAssocReqSanity(
1063 IN PRTMP_ADAPTER pAd,
1067 OUT USHORT *pCapabilityInfo,
1068 OUT ULONG *pTimeout,
1069 OUT USHORT *pListenIntv)
1071 MLME_ASSOC_REQ_STRUCT *pInfo;
1073 pInfo = (MLME_ASSOC_REQ_STRUCT *)Msg;
1074 *pTimeout = pInfo->Timeout; // timeout
1075 COPY_MAC_ADDR(pApAddr, pInfo->Addr); // AP address
1076 *pCapabilityInfo = pInfo->CapabilityInfo; // capability info
1077 *pListenIntv = pInfo->ListenIntv;
1083 ==========================================================================
1085 MLME message sanity check
1087 TRUE if all parameters are OK, FALSE otherwise
1089 IRQL = DISPATCH_LEVEL
1091 ==========================================================================
1093 BOOLEAN PeerDisassocSanity(
1094 IN PRTMP_ADAPTER pAd,
1098 OUT USHORT *pReason)
1100 PFRAME_802_11 pFrame = (PFRAME_802_11)Msg;
1102 COPY_MAC_ADDR(pAddr2, pFrame->Hdr.Addr2);
1103 NdisMoveMemory(pReason, &pFrame->Octet[0], 2);
1109 ========================================================================
1110 Routine Description:
1111 Sanity check NetworkType (11b, 11g or 11a)
1114 pBss - Pointer to BSS table.
1117 Ndis802_11DS .......(11b)
1118 Ndis802_11OFDM24....(11g)
1119 Ndis802_11OFDM5.....(11a)
1121 IRQL = DISPATCH_LEVEL
1123 ========================================================================
1125 NDIS_802_11_NETWORK_TYPE NetworkTypeInUseSanity(
1128 NDIS_802_11_NETWORK_TYPE NetWorkType;
1131 NetWorkType = Ndis802_11DS;
1133 if (pBss->Channel <= 14)
1136 // First check support Rate.
1138 for (i = 0; i < pBss->SupRateLen; i++)
1140 rate = pBss->SupRate[i] & 0x7f; // Mask out basic rate set bit
1141 if ((rate == 2) || (rate == 4) || (rate == 11) || (rate == 22))
1148 // Otherwise (even rate > 108) means Ndis802_11OFDM24
1150 NetWorkType = Ndis802_11OFDM24;
1156 // Second check Extend Rate.
1158 if (NetWorkType != Ndis802_11OFDM24)
1160 for (i = 0; i < pBss->ExtRateLen; i++)
1162 rate = pBss->SupRate[i] & 0x7f; // Mask out basic rate set bit
1163 if ((rate == 2) || (rate == 4) || (rate == 11) || (rate == 22))
1170 // Otherwise (even rate > 108) means Ndis802_11OFDM24
1172 NetWorkType = Ndis802_11OFDM24;
1180 NetWorkType = Ndis802_11OFDM5;
1183 if (pBss->HtCapabilityLen != 0)
1185 if (NetWorkType == Ndis802_11OFDM5)
1186 NetWorkType = Ndis802_11OFDM5_N;
1188 NetWorkType = Ndis802_11OFDM24_N;
1195 ==========================================================================
1197 WPA message sanity check
1199 TRUE if all parameters are OK, FALSE otherwise
1200 ==========================================================================
1202 BOOLEAN PeerWpaMessageSanity(
1203 IN PRTMP_ADAPTER pAd,
1204 IN PEAPOL_PACKET pMsg,
1207 IN MAC_TABLE_ENTRY *pEntry)
1209 UCHAR mic[LEN_KEY_DESC_MIC], digest[80], KEYDATA[MAX_LEN_OF_RSNIE];
1210 BOOLEAN bReplayDiff = FALSE;
1211 BOOLEAN bWPA2 = FALSE;
1212 KEY_INFO EapolKeyInfo;
1213 UCHAR GroupKeyIndex = 0;
1216 NdisZeroMemory(mic, sizeof(mic));
1217 NdisZeroMemory(digest, sizeof(digest));
1218 NdisZeroMemory(KEYDATA, sizeof(KEYDATA));
1219 NdisZeroMemory((PUCHAR)&EapolKeyInfo, sizeof(EapolKeyInfo));
1221 NdisMoveMemory((PUCHAR)&EapolKeyInfo, (PUCHAR)&pMsg->KeyDesc.KeyInfo, sizeof(KEY_INFO));
1223 *((USHORT *)&EapolKeyInfo) = cpu2le16(*((USHORT *)&EapolKeyInfo));
1225 // Choose WPA2 or not
1226 if ((pEntry->AuthMode == Ndis802_11AuthModeWPA2) || (pEntry->AuthMode == Ndis802_11AuthModeWPA2PSK))
1230 if ((MsgType > EAPOL_GROUP_MSG_2) || (MsgType < EAPOL_PAIR_MSG_1))
1232 DBGPRINT(RT_DEBUG_ERROR, ("The message type is invalid(%d)! \n", MsgType));
1236 // 1. Replay counter check
1237 if (MsgType == EAPOL_PAIR_MSG_1 || MsgType == EAPOL_PAIR_MSG_3 || MsgType == EAPOL_GROUP_MSG_1) // For supplicant
1239 // First validate replay counter, only accept message with larger replay counter.
1240 // Let equal pass, some AP start with all zero replay counter
1241 UCHAR ZeroReplay[LEN_KEY_DESC_REPLAY];
1243 NdisZeroMemory(ZeroReplay, LEN_KEY_DESC_REPLAY);
1244 if ((RTMPCompareMemory(pMsg->KeyDesc.ReplayCounter, pEntry->R_Counter, LEN_KEY_DESC_REPLAY) != 1) &&
1245 (RTMPCompareMemory(pMsg->KeyDesc.ReplayCounter, ZeroReplay, LEN_KEY_DESC_REPLAY) != 0))
1250 else if (MsgType == EAPOL_PAIR_MSG_2 || MsgType == EAPOL_PAIR_MSG_4 || MsgType == EAPOL_GROUP_MSG_2) // For authenticator
1252 // check Replay Counter coresponds to MSG from authenticator, otherwise discard
1253 if (!NdisEqualMemory(pMsg->KeyDesc.ReplayCounter, pEntry->R_Counter, LEN_KEY_DESC_REPLAY))
1259 // Replay Counter different condition
1262 // send wireless event - for replay counter different
1263 if (pAd->CommonCfg.bWirelessEvent)
1264 RTMPSendWirelessEvent(pAd, IW_REPLAY_COUNTER_DIFF_EVENT_FLAG, pEntry->Addr, pEntry->apidx, 0);
1266 if (MsgType < EAPOL_GROUP_MSG_1)
1268 DBGPRINT(RT_DEBUG_ERROR, ("Replay Counter Different in pairwise msg %d of 4-way handshake!\n", MsgType));
1272 DBGPRINT(RT_DEBUG_ERROR, ("Replay Counter Different in group msg %d of 2-way handshake!\n", (MsgType - EAPOL_PAIR_MSG_4)));
1275 hex_dump("Receive replay counter ", pMsg->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
1276 hex_dump("Current replay counter ", pEntry->R_Counter, LEN_KEY_DESC_REPLAY);
1280 // 2. Verify MIC except Pairwise Msg1
1281 if (MsgType != EAPOL_PAIR_MSG_1)
1283 UCHAR rcvd_mic[LEN_KEY_DESC_MIC];
1285 // Record the received MIC for check later
1286 NdisMoveMemory(rcvd_mic, pMsg->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
1287 NdisZeroMemory(pMsg->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
1289 if (pEntry->WepStatus == Ndis802_11Encryption2Enabled) // TKIP
1291 hmac_md5(pEntry->PTK, LEN_EAP_MICK, (PUCHAR)pMsg, MsgLen, mic);
1293 else if (pEntry->WepStatus == Ndis802_11Encryption3Enabled) // AES
1295 HMAC_SHA1((PUCHAR)pMsg, MsgLen, pEntry->PTK, LEN_EAP_MICK, digest);
1296 NdisMoveMemory(mic, digest, LEN_KEY_DESC_MIC);
1299 if (!NdisEqualMemory(rcvd_mic, mic, LEN_KEY_DESC_MIC))
1301 // send wireless event - for MIC different
1302 if (pAd->CommonCfg.bWirelessEvent)
1303 RTMPSendWirelessEvent(pAd, IW_MIC_DIFF_EVENT_FLAG, pEntry->Addr, pEntry->apidx, 0);
1305 if (MsgType < EAPOL_GROUP_MSG_1)
1307 DBGPRINT(RT_DEBUG_ERROR, ("MIC Different in pairwise msg %d of 4-way handshake!\n", MsgType));
1311 DBGPRINT(RT_DEBUG_ERROR, ("MIC Different in group msg %d of 2-way handshake!\n", (MsgType - EAPOL_PAIR_MSG_4)));
1314 hex_dump("Received MIC", rcvd_mic, LEN_KEY_DESC_MIC);
1315 hex_dump("Desired MIC", mic, LEN_KEY_DESC_MIC);
1321 // Extract the context of the Key Data field if it exist
1322 // The field in pairwise_msg_2_WPA1(WPA2) & pairwise_msg_3_WPA1 is un-encrypted.
1323 // The field in group_msg_1_WPA1(WPA2) & pairwise_msg_3_WPA2 is encrypted.
1324 if (pMsg->KeyDesc.KeyDataLen[1] > 0)
1326 // Decrypt this field
1327 if ((MsgType == EAPOL_PAIR_MSG_3 && bWPA2) || (MsgType == EAPOL_GROUP_MSG_1))
1329 if(pEntry->WepStatus == Ndis802_11Encryption3Enabled)
1332 AES_GTK_KEY_UNWRAP(&pEntry->PTK[16], KEYDATA, pMsg->KeyDesc.KeyDataLen[1],pMsg->KeyDesc.KeyData);
1339 // Construct 32 bytes RC4 Key
1340 NdisMoveMemory(Key, pMsg->KeyDesc.KeyIv, 16);
1341 NdisMoveMemory(&Key[16], &pEntry->PTK[16], 16);
1342 ARCFOUR_INIT(&pAd->PrivateInfo.WEPCONTEXT, Key, 32);
1343 //discard first 256 bytes
1344 for(i = 0; i < 256; i++)
1345 ARCFOUR_BYTE(&pAd->PrivateInfo.WEPCONTEXT);
1346 // Decrypt GTK. Becareful, there is no ICV to check the result is correct or not
1347 ARCFOUR_DECRYPT(&pAd->PrivateInfo.WEPCONTEXT, KEYDATA, pMsg->KeyDesc.KeyData, pMsg->KeyDesc.KeyDataLen[1]);
1350 if (!bWPA2 && (MsgType == EAPOL_GROUP_MSG_1))
1351 GroupKeyIndex = EapolKeyInfo.KeyIndex;
1354 else if ((MsgType == EAPOL_PAIR_MSG_2) || (MsgType == EAPOL_PAIR_MSG_3 && !bWPA2))
1356 NdisMoveMemory(KEYDATA, pMsg->KeyDesc.KeyData, pMsg->KeyDesc.KeyDataLen[1]);
1364 // Parse Key Data field to
1365 // 1. verify RSN IE for pairwise_msg_2_WPA1(WPA2) ,pairwise_msg_3_WPA1(WPA2)
1366 // 2. verify KDE format for pairwise_msg_3_WPA2, group_msg_1_WPA2
1367 // 3. update shared key for pairwise_msg_3_WPA2, group_msg_1_WPA1(WPA2)
1368 if (!RTMPParseEapolKeyData(pAd, KEYDATA, pMsg->KeyDesc.KeyDataLen[1], GroupKeyIndex, MsgType, bWPA2, pEntry))
1378 #ifdef CONFIG_STA_SUPPORT
1379 #ifdef QOS_DLS_SUPPORT
1380 BOOLEAN MlmeDlsReqSanity(
1381 IN PRTMP_ADAPTER pAd,
1384 OUT PRT_802_11_DLS *pDLS,
1385 OUT PUSHORT pReason)
1387 MLME_DLS_REQ_STRUCT *pInfo;
1389 pInfo = (MLME_DLS_REQ_STRUCT *)Msg;
1391 *pDLS = pInfo->pDLS;
1392 *pReason = pInfo->Reason;
1396 #endif // QOS_DLS_SUPPORT //
1397 #endif // CONFIG_STA_SUPPORT //
1399 #ifdef QOS_DLS_SUPPORT
1400 BOOLEAN PeerDlsReqSanity(
1401 IN PRTMP_ADAPTER pAd,
1406 OUT USHORT *pCapabilityInfo,
1407 OUT USHORT *pDlsTimeout,
1408 OUT UCHAR *pRatesLen,
1410 OUT UCHAR *pHtCapabilityLen,
1411 OUT HT_CAPABILITY_IE *pHtCapability)
1414 PFRAME_802_11 Fr = (PFRAME_802_11)Msg;
1415 PEID_STRUCT eid_ptr;
1417 // to prevent caller from using garbage output value
1418 *pCapabilityInfo = 0;
1420 *pHtCapabilityLen = 0;
1424 // offset to destination MAC address (Category and Action field)
1427 // get DA from payload and advance the pointer
1428 NdisMoveMemory(pDA, Ptr, MAC_ADDR_LEN);
1429 Ptr += MAC_ADDR_LEN;
1431 // get SA from payload and advance the pointer
1432 NdisMoveMemory(pSA, Ptr, MAC_ADDR_LEN);
1433 Ptr += MAC_ADDR_LEN;
1435 // get capability info from payload and advance the pointer
1436 NdisMoveMemory(pCapabilityInfo, Ptr, 2);
1439 // get capability info from payload and advance the pointer
1440 NdisMoveMemory(pDlsTimeout, Ptr, 2);
1443 // Category and Action field + DA + SA + capability + Timeout
1444 eid_ptr = (PEID_STRUCT) &Fr->Octet[18];
1446 while (((UCHAR*)eid_ptr + eid_ptr->Len + 1) < ((UCHAR*)Fr + MsgLen))
1448 switch(eid_ptr->Eid)
1451 if ((eid_ptr->Len <= MAX_LEN_OF_SUPPORTED_RATES) && (eid_ptr->Len > 0))
1453 NdisMoveMemory(Rates, eid_ptr->Octet, eid_ptr->Len);
1454 DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsReqSanity - IE_SUPP_RATES., Len=%d. Rates[0]=%x\n",eid_ptr->Len, Rates[0]));
1455 DBGPRINT(RT_DEBUG_TRACE, ("Rates[1]=%x %x %x %x %x %x %x\n", Rates[1], Rates[2], Rates[3], Rates[4], Rates[5], Rates[6], Rates[7]));
1456 *pRatesLen = eid_ptr->Len;
1469 DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsReqSanity - wrong IE_SUPP_RATES., Len=%d\n",eid_ptr->Len));
1473 case IE_EXT_SUPP_RATES:
1474 if (eid_ptr->Len + *pRatesLen <= MAX_LEN_OF_SUPPORTED_RATES)
1476 NdisMoveMemory(&Rates[*pRatesLen], eid_ptr->Octet, eid_ptr->Len);
1477 *pRatesLen = (*pRatesLen) + eid_ptr->Len;
1481 NdisMoveMemory(&Rates[*pRatesLen], eid_ptr->Octet, MAX_LEN_OF_SUPPORTED_RATES - (*pRatesLen));
1482 *pRatesLen = MAX_LEN_OF_SUPPORTED_RATES;
1487 if (eid_ptr->Len >= sizeof(HT_CAPABILITY_IE))
1489 NdisMoveMemory(pHtCapability, eid_ptr->Octet, sizeof(HT_CAPABILITY_IE));
1491 *(USHORT *)(&pHtCapability->HtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->HtCapInfo));
1492 *(USHORT *)(&pHtCapability->ExtHtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->ExtHtCapInfo));
1493 *pHtCapabilityLen = sizeof(HT_CAPABILITY_IE);
1495 DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsReqSanity - IE_HT_CAP\n"));
1499 DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsReqSanity - wrong IE_HT_CAP.eid_ptr->Len = %d\n", eid_ptr->Len));
1507 eid_ptr = (PEID_STRUCT)((UCHAR*)eid_ptr + 2 + eid_ptr->Len);
1513 BOOLEAN PeerDlsRspSanity(
1514 IN PRTMP_ADAPTER pAd,
1519 OUT USHORT *pCapabilityInfo,
1520 OUT USHORT *pStatus,
1521 OUT UCHAR *pRatesLen,
1523 OUT UCHAR *pHtCapabilityLen,
1524 OUT HT_CAPABILITY_IE *pHtCapability)
1527 PFRAME_802_11 Fr = (PFRAME_802_11)Msg;
1528 PEID_STRUCT eid_ptr;
1530 // to prevent caller from using garbage output value
1532 *pCapabilityInfo = 0;
1533 *pHtCapabilityLen = 0;
1537 // offset to destination MAC address (Category and Action field)
1540 // get status code from payload and advance the pointer
1541 NdisMoveMemory(pStatus, Ptr, 2);
1544 // get DA from payload and advance the pointer
1545 NdisMoveMemory(pDA, Ptr, MAC_ADDR_LEN);
1546 Ptr += MAC_ADDR_LEN;
1548 // get SA from payload and advance the pointer
1549 NdisMoveMemory(pSA, Ptr, MAC_ADDR_LEN);
1550 Ptr += MAC_ADDR_LEN;
1554 // get capability info from payload and advance the pointer
1555 NdisMoveMemory(pCapabilityInfo, Ptr, 2);
1559 // Category and Action field + status code + DA + SA + capability
1560 eid_ptr = (PEID_STRUCT) &Fr->Octet[18];
1562 while (((UCHAR*)eid_ptr + eid_ptr->Len + 1) < ((UCHAR*)Fr + MsgLen))
1564 switch(eid_ptr->Eid)
1567 if ((eid_ptr->Len <= MAX_LEN_OF_SUPPORTED_RATES) && (eid_ptr->Len > 0))
1569 NdisMoveMemory(Rates, eid_ptr->Octet, eid_ptr->Len);
1570 DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsRspSanity - IE_SUPP_RATES., Len=%d. Rates[0]=%x\n",eid_ptr->Len, Rates[0]));
1571 DBGPRINT(RT_DEBUG_TRACE, ("Rates[1]=%x %x %x %x %x %x %x\n", Rates[1], Rates[2], Rates[3], Rates[4], Rates[5], Rates[6], Rates[7]));
1572 *pRatesLen = eid_ptr->Len;
1585 DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsRspSanity - wrong IE_SUPP_RATES., Len=%d\n",eid_ptr->Len));
1589 case IE_EXT_SUPP_RATES:
1590 if (eid_ptr->Len + *pRatesLen <= MAX_LEN_OF_SUPPORTED_RATES)
1592 NdisMoveMemory(&Rates[*pRatesLen], eid_ptr->Octet, eid_ptr->Len);
1593 *pRatesLen = (*pRatesLen) + eid_ptr->Len;
1597 NdisMoveMemory(&Rates[*pRatesLen], eid_ptr->Octet, MAX_LEN_OF_SUPPORTED_RATES - (*pRatesLen));
1598 *pRatesLen = MAX_LEN_OF_SUPPORTED_RATES;
1603 if (eid_ptr->Len >= sizeof(HT_CAPABILITY_IE))
1605 NdisMoveMemory(pHtCapability, eid_ptr->Octet, sizeof(HT_CAPABILITY_IE));
1607 *(USHORT *)(&pHtCapability->HtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->HtCapInfo));
1608 *(USHORT *)(&pHtCapability->ExtHtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->ExtHtCapInfo));
1609 *pHtCapabilityLen = sizeof(HT_CAPABILITY_IE);
1611 DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsRspSanity - IE_HT_CAP\n"));
1615 DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsRspSanity - wrong IE_HT_CAP.eid_ptr->Len = %d\n", eid_ptr->Len));
1623 eid_ptr = (PEID_STRUCT)((UCHAR*)eid_ptr + 2 + eid_ptr->Len);
1629 BOOLEAN PeerDlsTearDownSanity(
1630 IN PRTMP_ADAPTER pAd,
1635 OUT USHORT *pReason)
1638 PFRAME_802_11 Fr = (PFRAME_802_11)Msg;
1640 // to prevent caller from using garbage output value
1645 // offset to destination MAC address (Category and Action field)
1648 // get DA from payload and advance the pointer
1649 NdisMoveMemory(pDA, Ptr, MAC_ADDR_LEN);
1650 Ptr += MAC_ADDR_LEN;
1652 // get SA from payload and advance the pointer
1653 NdisMoveMemory(pSA, Ptr, MAC_ADDR_LEN);
1654 Ptr += MAC_ADDR_LEN;
1656 // get reason code from payload and advance the pointer
1657 NdisMoveMemory(pReason, Ptr, 2);
1662 #endif // QOS_DLS_SUPPORT //