MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / drivers / net / wireless / rtlink.org / sanity.c
blobecec148914a30c00b43a227bb96f749ddf5d2db9
1 /****************************************************************************
2 * Ralink Tech Inc.
3 * 4F, No. 2 Technology 5th Rd.
4 * Science-based Industrial Park
5 * Hsin-chu, Taiwan, R.O.C.
6 * (c) Copyright 2002, Ralink Technology, Inc.
8 * All rights reserved. Ralink's source code is an unpublished work and the
9 * use of a copyright notice does not imply otherwise. This source code
10 * contains confidential trade secret material of Ralink Tech. Any attemp
11 * or participation in deciphering, decoding, reverse engineering or in any
12 * way altering the source code is stricitly prohibited, unless the prior
13 * written consent of Ralink Technology, Inc. is obtained.
14 ****************************************************************************/
16 #include "rt_config.h"
18 UCHAR WPA_OUI[] = {0x00, 0x50, 0xf2, 0x01};
20 /*
21 ==========================================================================
22 Description:
23 MLME message sanity check
24 Return:
25 TRUE if all parameters are OK, FALSE otherwise
26 ==========================================================================
28 BOOLEAN MlmeScanReqSanity(
29 IN PRTMP_ADAPTER pAd,
30 IN VOID *Msg,
31 IN ULONG MsgLen,
32 OUT UCHAR *BssType,
33 OUT CHAR Ssid[],
34 OUT UCHAR *SsidLen,
35 OUT UCHAR *ScanType)
37 MLME_SCAN_REQ_STRUCT *Info;
39 Info = (MLME_SCAN_REQ_STRUCT *)(Msg);
40 *BssType = Info->BssType;
41 *SsidLen = Info->SsidLen;
42 NdisMoveMemory(Ssid, Info->Ssid, *SsidLen);
43 *ScanType = Info->ScanType;
45 if ((*BssType == BSS_INFRA || *BssType == BSS_INDEP || *BssType == BSS_ANY) &&
46 (*ScanType == SCAN_ACTIVE || *ScanType == SCAN_PASSIVE))
47 return TRUE;
48 else
50 DBGPRINT(RT_DEBUG_TRACE, "MlmeScanReqSanity fail - wrong BssType or ScanType\n");
51 return FALSE;
55 /*
56 ==========================================================================
57 Description:
58 MLME message sanity check
59 Return:
60 TRUE if all parameters are OK, FALSE otherwise
61 ==========================================================================
63 BOOLEAN MlmeStartReqSanity(
64 IN PRTMP_ADAPTER pAd,
65 IN VOID *Msg,
66 IN ULONG MsgLen,
67 OUT CHAR Ssid[],
68 OUT UCHAR *SsidLen)
70 MLME_START_REQ_STRUCT *Info;
72 Info = (MLME_START_REQ_STRUCT *)(Msg);
74 if (Info->SsidLen > MAX_LEN_OF_SSID)
76 DBGPRINT(RT_DEBUG_TRACE, "MlmeStartReqSanity fail - wrong SSID length\n");
77 return FALSE;
80 *SsidLen = Info->SsidLen;
81 NdisMoveMemory(Ssid, Info->Ssid, *SsidLen);
83 return TRUE;
86 /*
87 ==========================================================================
88 Description:
89 MLME message sanity check
90 Return:
91 TRUE if all parameters are OK, FALSE otherwise
92 ==========================================================================
94 BOOLEAN MlmeAssocReqSanity(
95 IN PRTMP_ADAPTER pAd,
96 IN VOID *Msg,
97 IN ULONG MsgLen,
98 OUT MACADDR *ApAddr,
99 OUT USHORT *CapabilityInfo,
100 OUT ULONG *Timeout,
101 OUT USHORT *ListenIntv)
103 MLME_ASSOC_REQ_STRUCT *Info;
105 Info = (MLME_ASSOC_REQ_STRUCT *)Msg;
106 *Timeout = Info->Timeout; // timeout
107 COPY_MAC_ADDR(ApAddr, &Info->Addr); // AP address
108 *CapabilityInfo = Info->CapabilityInfo; // capability info
109 *ListenIntv = Info->ListenIntv;
111 return TRUE;
115 ==========================================================================
116 Description:
117 MLME message sanity check
118 Return:
119 TRUE if all parameters are OK, FALSE otherwise
120 ==========================================================================
122 BOOLEAN MlmeAuthReqSanity(
123 IN PRTMP_ADAPTER pAd,
124 IN VOID *Msg,
125 IN ULONG MsgLen,
126 OUT MACADDR *Addr,
127 OUT ULONG *Timeout,
128 OUT USHORT *Alg)
130 MLME_AUTH_REQ_STRUCT *Info;
132 Info = (MLME_AUTH_REQ_STRUCT *)Msg;
133 COPY_MAC_ADDR(Addr, &Info->Addr);
134 *Timeout = Info->Timeout;
135 *Alg = Info->Alg;
137 if ((*Alg == Ndis802_11AuthModeShared || *Alg == Ndis802_11AuthModeOpen) && !MAC_ADDR_IS_GROUP(*Addr))
139 return TRUE;
141 else
143 DBGPRINT(RT_DEBUG_TRACE, "MlmeAuthReqSanity fail - wrong algorithm\n");
144 return FALSE;
149 ==========================================================================
150 Description:
151 MLME message sanity check
152 Return:
153 TRUE if all parameters are OK, FALSE otherwise
154 ==========================================================================
156 BOOLEAN PeerAssocRspSanity(
157 IN PRTMP_ADAPTER pAd,
158 IN VOID *Msg,
159 IN ULONG MsgLen,
160 OUT MACADDR *Addr2,
161 OUT USHORT *CapabilityInfo,
162 OUT USHORT *Status,
163 OUT USHORT *Aid,
164 OUT UCHAR Rates[],
165 OUT UCHAR *RatesLen,
166 OUT BOOLEAN *ExtendedRateIeExist)
168 CHAR IeType, *Ptr;
169 MACFRAME *Fr = (MACFRAME *)Msg;
170 PBEACON_EID_STRUCT eid_ptr;
172 COPY_MAC_ADDR(Addr2, &Fr->Hdr.Addr2);
173 Ptr = Fr->Octet;
175 NdisMoveMemory(CapabilityInfo, &Fr->Octet[0], 2);
176 NdisMoveMemory(Status, &Fr->Octet[2], 2);
177 // Mask out unnecessary capability information
178 *CapabilityInfo &= SUPPORTED_CAPABILITY_INFO;
180 if (*Status == MLME_SUCCESS)
182 NdisMoveMemory(Aid, &Fr->Octet[4], 2);
183 *Aid = (*Aid) & 0x3fff; // AID is low 14-bit
185 // -- get supported rates from payload and advance the pointer
186 IeType = Fr->Octet[6];
187 *RatesLen = Fr->Octet[7];
188 if ((IeType != IE_SUPP_RATES) || (*RatesLen > MAX_LEN_OF_SUPPORTED_RATES))
190 DBGPRINT(RT_DEBUG_TRACE, "PeerAssocRspSanity fail - wrong SupportedRates IE\n");
191 return FALSE;
193 else
194 NdisMoveMemory(Rates, &Fr->Octet[8], *RatesLen);
196 // many AP implement proprietary IEs in non-standard order, we'd better
197 // tolerate mis-ordered IEs to get best compatibility
198 *ExtendedRateIeExist = FALSE;
199 eid_ptr = (PBEACON_EID_STRUCT) &Fr->Octet[8 + (*RatesLen)];
201 // get variable fields from payload and advance the pointer
202 while (((UCHAR*)eid_ptr + eid_ptr->Len + 1) < ((UCHAR*)Fr + MsgLen))
204 switch (eid_ptr->Eid)
206 case IE_EXT_SUPP_RATES:
207 *ExtendedRateIeExist = TRUE;
208 if ((*RatesLen + eid_ptr->Len) <= MAX_LEN_OF_SUPPORTED_RATES)
210 NdisMoveMemory(&Rates[*RatesLen], eid_ptr->Octet, eid_ptr->Len);
211 *RatesLen = (*RatesLen) + eid_ptr->Len;
213 else
215 NdisMoveMemory(&Rates[*RatesLen], eid_ptr->Octet, MAX_LEN_OF_SUPPORTED_RATES - (*RatesLen));
216 *RatesLen = MAX_LEN_OF_SUPPORTED_RATES;
218 break;
219 default:
220 DBGPRINT(RT_DEBUG_TRACE, "PeerAssocRspSanity - ignore unrecognized EID = %d\n", eid_ptr->Eid);
221 break;
224 eid_ptr = (PBEACON_EID_STRUCT)((UCHAR*)eid_ptr + 2 + eid_ptr->Len);
229 return TRUE;
233 ==========================================================================
234 Description:
235 MLME message sanity check
236 Return:
237 TRUE if all parameters are OK, FALSE otherwise
238 ==========================================================================
240 BOOLEAN PeerDisassocSanity(
241 IN PRTMP_ADAPTER pAd,
242 IN VOID *Msg,
243 IN ULONG MsgLen,
244 OUT MACADDR *Addr2,
245 OUT USHORT *Reason)
247 MACFRAME *Fr = (MACFRAME *)Msg;
249 COPY_MAC_ADDR(Addr2, &Fr->Hdr.Addr2);
250 NdisMoveMemory(Reason, &Fr->Octet[0], 2);
252 return TRUE;
256 ==========================================================================
257 Description:
258 MLME message sanity check
259 Return:
260 TRUE if all parameters are OK, FALSE otherwise
261 ==========================================================================
263 BOOLEAN PeerDeauthSanity(
264 IN PRTMP_ADAPTER pAd,
265 IN VOID *Msg,
266 IN ULONG MsgLen,
267 OUT MACADDR *Addr2,
268 OUT USHORT *Reason)
270 MACFRAME *Fr = (MACFRAME *)Msg;
272 COPY_MAC_ADDR(Addr2, &Fr->Hdr.Addr2);
273 NdisMoveMemory(Reason, &Fr->Octet[0], 2);
275 return TRUE;
279 ==========================================================================
280 Description:
281 MLME message sanity check
282 Return:
283 TRUE if all parameters are OK, FALSE otherwise
284 ==========================================================================
286 BOOLEAN PeerAuthSanity(
287 IN PRTMP_ADAPTER pAd,
288 IN VOID *Msg,
289 IN ULONG MsgLen,
290 OUT MACADDR *Addr,
291 OUT USHORT *Alg,
292 OUT USHORT *Seq,
293 OUT USHORT *Status,
294 CHAR *ChlgText)
296 MACFRAME *Fr = (MACFRAME *)Msg;
298 COPY_MAC_ADDR(Addr, &Fr->Hdr.Addr2);
299 NdisMoveMemory(Alg, &Fr->Octet[0], 2);
300 NdisMoveMemory(Seq, &Fr->Octet[2], 2);
301 NdisMoveMemory(Status, &Fr->Octet[4], 2);
303 if (*Alg == Ndis802_11AuthModeOpen)
305 if (*Seq == 1 || *Seq == 2)
307 return TRUE;
309 else
311 DBGPRINT(RT_DEBUG_TRACE, "PeerAuthSanity fail - wrong Seg#\n");
312 return FALSE;
315 else if (*Alg == Ndis802_11AuthModeShared)
317 if (*Seq == 1 || *Seq == 4)
319 return TRUE;
321 else if (*Seq == 2 || *Seq == 3)
323 NdisMoveMemory(ChlgText, &Fr->Octet[8], CIPHER_TEXT_LEN);
324 return TRUE;
326 else
328 DBGPRINT(RT_DEBUG_TRACE, "PeerAuthSanity fail - wrong Seg#\n");
329 return FALSE;
332 else
334 DBGPRINT(RT_DEBUG_TRACE, "PeerAuthSanity fail - wrong algorithm\n");
335 return FALSE;
340 ==========================================================================
341 Description:
342 MLME message sanity check
343 Return:
344 TRUE if all parameters are OK, FALSE otherwise
345 ==========================================================================
347 BOOLEAN PeerProbeReqSanity(
348 IN PRTMP_ADAPTER pAd,
349 IN VOID *Msg,
350 IN ULONG MsgLen,
351 OUT MACADDR *Addr2,
352 OUT CHAR Ssid[],
353 OUT UCHAR *SsidLen)
354 // OUT UCHAR Rates[],
355 // OUT UCHAR *RatesLen)
357 UCHAR Idx;
358 UCHAR RateLen;
359 CHAR IeType;
360 MACFRAME *Fr = (MACFRAME *)Msg;
362 COPY_MAC_ADDR(Addr2, &Fr->Hdr.Addr2);
364 if ((Fr->Octet[0] != IE_SSID) || (Fr->Octet[1] > MAX_LEN_OF_SSID))
366 DBGPRINT(RT_DEBUG_TRACE, "PeerProbeReqSanity fail - wrong SSID IE(Type=%d,Len=%d)\n",Fr->Octet[0],Fr->Octet[1]);
367 return FALSE;
370 *SsidLen = Fr->Octet[1];
371 NdisMoveMemory(Ssid, &Fr->Octet[2], *SsidLen);
373 #if 1
374 Idx = *SsidLen + 2;
376 // -- get supported rates from payload and advance the pointer
377 IeType = Fr->Octet[Idx];
378 RateLen = Fr->Octet[Idx + 1];
379 if (IeType != IE_SUPP_RATES)
381 DBGPRINT(RT_DEBUG_TRACE, "PeerProbeReqSanity fail - wrong SupportRates IE(Type=%d,Len=%d)\n",Fr->Octet[Idx],Fr->Octet[Idx+1]);
382 return FALSE;
384 else
386 if ((pAd->PortCfg.AdhocMode == 2) && (RateLen < 8))
387 return (FALSE);
389 #endif
390 return TRUE;
394 ==========================================================================
395 Description:
396 MLME message sanity check
397 Return:
398 TRUE if all parameters are OK, FALSE otherwise
399 ==========================================================================
401 BOOLEAN PeerBeaconAndProbeRspSanity(
402 IN PRTMP_ADAPTER pAd,
403 IN VOID *Msg,
404 IN ULONG MsgLen,
405 OUT MACADDR *Addr2,
406 OUT MACADDR *Bssid,
407 OUT CHAR Ssid[],
408 OUT UCHAR *SsidLen,
409 OUT UCHAR *BssType,
410 OUT USHORT *BeaconPeriod,
411 OUT UCHAR *Channel,
412 OUT LARGE_INTEGER *Timestamp,
413 OUT BOOLEAN *CfExist,
414 OUT CF_PARM *CfParm,
415 OUT USHORT *AtimWin,
416 OUT USHORT *CapabilityInfo,
417 OUT UCHAR Rate[],
418 OUT UCHAR *RateLen,
419 OUT BOOLEAN *ExtendedRateIeExist,
420 OUT UCHAR *Erp,
421 OUT UCHAR *DtimCount,
422 OUT UCHAR *DtimPeriod,
423 OUT UCHAR *BcastFlag,
424 OUT UCHAR *MessageToMe,
425 OUT UCHAR *Legacy,
426 OUT UCHAR SupRate[],
427 OUT UCHAR *SupRateLen,
428 OUT UCHAR ExtRate[],
429 OUT UCHAR *ExtRateLen,
430 OUT PNDIS_802_11_VARIABLE_IEs pVIE)
432 CHAR *Ptr, TimLen;
433 MACFRAME *Fr;
434 PBEACON_EID_STRUCT eid_ptr;
435 UCHAR SubType;
436 UCHAR Sanity;
438 // Add for 3 necessary EID field check
439 Sanity = 0;
441 *ExtendedRateIeExist = FALSE;
442 *Erp = 0;
444 Fr = (MACFRAME *)Msg;
446 // get subtype from header
447 SubType = (UCHAR)Fr->Hdr.SubType;
449 // get Addr2 and BSSID from header
450 COPY_MAC_ADDR(Addr2, &Fr->Hdr.Addr2);
451 COPY_MAC_ADDR(Bssid, &Fr->Hdr.Addr3);
453 Ptr = Fr->Octet;
455 // get timestamp from payload and advance the pointer
456 NdisMoveMemory(Timestamp, Ptr, TIMESTAMP_LEN);
457 Ptr += TIMESTAMP_LEN;
459 // get beacon interval from payload and advance the pointer
460 NdisMoveMemory(BeaconPeriod, Ptr, 2);
461 Ptr += 2;
463 // get capability info from payload and advance the pointer
464 NdisMoveMemory(CapabilityInfo, Ptr, 2);
465 Ptr += 2;
466 if (CAP_IS_ESS_ON(*CapabilityInfo))
468 *BssType = BSS_INFRA;
470 else
472 *BssType = BSS_INDEP;
475 // Mask out unnecessary capability information
476 *CapabilityInfo &= SUPPORTED_CAPABILITY_INFO;
478 eid_ptr = (PBEACON_EID_STRUCT) Ptr;
480 // Scott: 2004-12-03
482 unsigned long *aa=(unsigned long *)eid_ptr;
483 if (((UCHAR*)eid_ptr + eid_ptr->Len + 1) >= ((UCHAR*)Fr + MsgLen))
485 //DBGPRINT(RT_DEBUG_TRACE, "%08lX %08lX %08lX %08lX\n", aa[0], aa[1], aa[2], aa[3]);
486 DBGPRINT(RT_DEBUG_TRACE, "Invalid length (eid_ptr=0x%X, eid_ptr->Len=%d, Fr=0x%X, MsgLen=%d)\n", eid_ptr, eid_ptr->Len, Fr, MsgLen);
490 // get variable fields from payload and advance the pointer
491 while(((UCHAR*)eid_ptr + eid_ptr->Len + 1) < ((UCHAR*)Fr + MsgLen))
493 switch(eid_ptr->Eid)
495 case IE_SSID:
496 // Already has one SSID EID in this beacon, ignore the second one
497 if (Sanity & 0x1)
498 break;
499 if(eid_ptr->Len <= MAX_LEN_OF_SSID)
501 NdisMoveMemory(Ssid, eid_ptr->Octet, eid_ptr->Len);
502 *SsidLen = eid_ptr->Len;
503 Sanity |= 0x1;
505 else
507 DBGPRINT(RT_DEBUG_TRACE, "PeerBeaconAndProbeRspSanity - wrong IE_SSID (len=%d)\n",eid_ptr->Len);
508 return FALSE;
510 break;
512 case IE_SUPP_RATES:
513 if(eid_ptr->Len <= MAX_LEN_OF_SUPPORTED_RATES)
515 int index;
516 UCHAR rate, i;
517 PUCHAR eid_rate;
519 i = 0;
520 eid_rate = eid_ptr->Octet;
521 for (index = 0; index < eid_ptr->Len; index++)
523 rate = eid_rate[index] & 0x7f; // Mask out basic rate set bit
524 if ((rate == 2) || (rate == 4) || (rate == 11) || (rate == 22) ||
525 (rate == 12) || (rate == 18) || (rate == 24) || (rate == 36) ||
526 (rate == 48) || (rate == 72) || (rate == 96) || (rate == 108))
527 Rate[i++] = eid_rate[index]; // Save rate with basic rate set bit if exists
529 *RateLen = i;
530 Sanity |= 0x2;
532 // Copy supported rate from desired AP's beacon. We are trying to match
533 // AP's supported and extended rate settings.
534 NdisMoveMemory(SupRate, eid_ptr->Octet, eid_ptr->Len);
535 *SupRateLen = eid_ptr->Len;
537 else
539 DBGPRINT(RT_DEBUG_TRACE, "PeerBeaconAndProbeRspSanity - wrong IE_SUPP_RATES (len=%d)\n",eid_ptr->Len);
540 return FALSE;
542 break;
544 case IE_FH_PARM:
545 DBGPRINT(RT_DEBUG_TRACE, "PeerBeaconAndProbeRspSanity(IE_FH_PARM) \n");
546 break;
548 case IE_DS_PARM:
549 if(eid_ptr->Len == 1)
551 *Channel = *eid_ptr->Octet;
552 if (ChannelSanity(pAd, *Channel) == 0)
554 DBGPRINT(RT_DEBUG_TRACE, "PeerBeaconAndProbeRspSanity - wrong IE_DS_PARM (ch=%d)\n",*Channel);
555 return FALSE;
557 Sanity |= 0x4;
559 else
561 DBGPRINT(RT_DEBUG_TRACE, "PeerBeaconAndProbeRspSanity - wrong IE_DS_PARM (len=%d)\n",eid_ptr->Len);
562 return FALSE;
564 break;
566 case IE_CF_PARM:
567 if(eid_ptr->Len == 6)
569 *CfExist = TRUE;
570 NdisMoveMemory(CfParm, eid_ptr->Octet, eid_ptr->Len);
572 else
574 DBGPRINT(RT_DEBUG_TRACE, "PeerBeaconAndProbeRspSanity - wrong IE_CF_PARM\n");
575 return FALSE;
577 break;
579 case IE_IBSS_PARM:
580 if(eid_ptr->Len == 2)
582 NdisMoveMemory(AtimWin, eid_ptr->Octet, eid_ptr->Len);
584 else
586 DBGPRINT(RT_DEBUG_TRACE, "PeerBeaconAndProbeRspSanity - wrong IE_IBSS_PARM\n");
587 return FALSE;
589 break;
591 case IE_TIM:
592 if(INFRA_ON(pAd) && SubType == SUBTYPE_BEACON)
594 GetTimBit((PUCHAR)eid_ptr, pAd->PortCfg.Aid, &TimLen, BcastFlag, DtimCount, DtimPeriod, MessageToMe);
596 break;
598 // New for WPA
599 case IE_WPA:
600 // Check the OUI version, filter out non-standard usage
601 if (RTMPEqualMemory(eid_ptr->Octet, WPA_OUI, 4))
603 // Copy to pVIE which will report to microsoft bssid list.
604 pVIE->ElementID = eid_ptr->Eid;
605 pVIE->Length = eid_ptr->Len;
606 NdisMoveMemory(pVIE->data, eid_ptr->Octet, eid_ptr->Len);
608 DBGPRINT(RT_DEBUG_INFO, "PeerBeaconAndProbeRspSanity - Receive IE_WPA\n");
609 break;
611 case IE_EXT_SUPP_RATES:
612 // concatenate all extended rates to Rates[] and RateLen
613 *ExtendedRateIeExist = TRUE;
614 if (eid_ptr->Len <= MAX_LEN_OF_SUPPORTED_RATES)
616 int index;
617 UCHAR rate, i;
618 PUCHAR eid_rate;
620 i = *RateLen;
621 eid_rate = eid_ptr->Octet;
622 for (index = 0; index < eid_ptr->Len; index++)
624 rate = eid_rate[index] & 0x7f; // Mask out basic rate set bit
625 if ((rate == 2) || (rate == 4) || (rate == 11) || (rate == 22) ||
626 (rate == 12) || (rate == 18) || (rate == 24) || (rate == 36) ||
627 (rate == 48) || (rate == 72) || (rate == 96) || (rate == 108))
628 Rate[i++] = eid_rate[index]; // Save rate with basic rate set bit if exists
630 if (i >= MAX_LEN_OF_SUPPORTED_RATES)
631 break;
633 *RateLen = i;
634 // Copy extended rate from desired AP's beacon. We are trying to match
635 // AP's supported and extended rate settings.
636 NdisMoveMemory(ExtRate, eid_ptr->Octet, eid_ptr->Len);
637 *ExtRateLen = eid_ptr->Len;
639 break;
641 case IE_ERP:
642 if (eid_ptr->Len == 1)
644 *Erp = (UCHAR)eid_ptr->Octet[0];
646 break;
648 default:
649 DBGPRINT(RT_DEBUG_INFO, "PeerBeaconAndProbeRspSanity - unrecognized EID = %d\n", eid_ptr->Eid);
650 break;
653 eid_ptr = (PBEACON_EID_STRUCT)((UCHAR*)eid_ptr + 2 + eid_ptr->Len);
657 // in 802.11a band, AP may skip this DS IE in their BEACON
658 if ((pAd->PortCfg.Channel > 14) && ((Sanity & 0x04)==0))
660 *Channel = pAd->PortCfg.Channel;
661 Sanity |= 0x04;
664 if (Sanity != 0x7)
666 DBGPRINT(RT_DEBUG_WARN, "PeerBeaconAndProbeRspSanity - missing field, Sanity=0x%02x\n", Sanity);
667 return FALSE;
669 else
671 return TRUE;
677 ==========================================================================
678 Description:
679 ==========================================================================
681 BOOLEAN GetTimBit(
682 IN CHAR *Ptr,
683 IN USHORT Aid,
684 OUT UCHAR *TimLen,
685 OUT UCHAR *BcastFlag,
686 OUT UCHAR *DtimCount,
687 OUT UCHAR *DtimPeriod,
688 OUT UCHAR *MessageToMe)
690 UCHAR BitCntl, N1, N2, MyByte, MyBit;
691 CHAR *IdxPtr;
693 IdxPtr = Ptr;
695 IdxPtr ++;
696 *TimLen = *IdxPtr;
698 // get DTIM Count from TIM element
699 IdxPtr ++;
700 *DtimCount = *IdxPtr;
702 // get DTIM Period from TIM element
703 IdxPtr++;
704 *DtimPeriod = *IdxPtr;
706 // get Bitmap Control from TIM element
707 IdxPtr++;
708 BitCntl = *IdxPtr;
710 if ((*DtimCount == 0) && (BitCntl & 0x01))
711 *BcastFlag = TRUE;
712 else
713 *BcastFlag = FALSE;
715 #if 1
716 // Parse Partial Virtual Bitmap from TIM element
717 N1 = BitCntl & 0xfe; // N1 is the first bitmap byte#
718 N2 = *TimLen - 4 + N1; // N2 is the last bitmap byte#
720 if ((Aid < (N1 << 3)) || (Aid >= ((N2 + 1) << 3)))
721 *MessageToMe = FALSE;
722 else
724 MyByte = (Aid >> 3) - N1; // my byte position in the bitmap byte-stream
725 MyBit = Aid % 16 - ((MyByte & 0x01)? 8:0);
727 IdxPtr += (MyByte + 1);
729 //if (*IdxPtr)
730 // DBGPRINT(RT_DEBUG_WARN, ("TIM bitmap = 0x%02x\n", *IdxPtr));
732 if (*IdxPtr & (0x01 << MyBit))
733 *MessageToMe = TRUE;
734 else
735 *MessageToMe = FALSE;
737 #else
738 *MessageToMe = FALSE;
739 #endif
741 return TRUE;
746 * \brief Get legacy bit, right now for 11b it is always 0
747 * \param
748 * \return TRUE if the parameters are OK, FALSE otherwise. Always return TRUE
749 * \pre
750 * \post
752 BOOLEAN GetLegacy(
753 IN CHAR *Ptr,
754 OUT UCHAR *Legacy)
756 *Legacy = 0;
757 return TRUE;
760 UCHAR ChannelSanity(
761 IN PRTMP_ADAPTER pAd,
762 IN UCHAR channel)
764 UCHAR index;
766 for (index = 0; index < pAd->PortCfg.ChannelListNum; index ++)
768 if (channel == pAd->PortCfg.ChannelList[index])
769 return 1;
771 return 0;
773 #if 0
774 switch (pAd->PortCfg.CountryRegion)
776 case REGION_FCC: // 1 - 11
777 if ((channel > 0) && (channel < 12))
778 return 1;
779 break;
781 case REGION_IC: // 1 -11
782 if ((channel > 0) && (channel < 12))
783 return 1;
784 break;
786 case REGION_ETSI: // 1 - 13
787 if ((channel > 0) && (channel < 14))
788 return 1;
789 break;
791 case REGION_SPAIN: // 10 - 11
792 if ((channel > 9) && (channel < 12))
793 return 1;
794 break;
796 case REGION_FRANCE: // 10 -13
797 if ((channel > 9) && (channel < 14))
798 return 1;
799 break;
801 case REGION_MKK: // 14
802 if (channel == 14)
803 return 1;
804 break;
806 case REGION_MKK1: // 1 - 14
807 if ((channel > 0) && (channel < 15))
808 return 1;
809 break;
811 case REGION_ISRAEL: // 3 - 9
812 if ((channel > 2) && (channel < 10))
813 return 1;
814 break;
816 default: // Error
817 return 0;
819 return (0);
820 #endif