MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / drivers / net / wireless / rtlink / Module / sanity.c
blobd6994a21c3ee3af975e155d0dca4b8fb5b22a74b
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 * *
7 * (c) Copyright 2002, Ralink Technology, Inc. *
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 * This program is distributed in the hope that it will be useful, *
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
17 * GNU General Public License for more details. *
18 * *
19 * You should have received a copy of the GNU General Public License *
20 * along with this program; if not, write to the *
21 * Free Software Foundation, Inc., *
22 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
23 * *
24 *************************************************************************/
26 #include "rt_config.h"
28 UCHAR WPA_OUI[] = {0x00, 0x50, 0xf2, 0x01};
30 /*
31 ==========================================================================
32 Description:
33 MLME message sanity check
34 Return:
35 TRUE if all parameters are OK, FALSE otherwise
36 ==========================================================================
38 BOOLEAN MlmeScanReqSanity(
39 IN PRTMP_ADAPTER pAd,
40 IN VOID *Msg,
41 IN ULONG MsgLen,
42 OUT UCHAR *BssType,
43 OUT CHAR Ssid[],
44 OUT UCHAR *SsidLen,
45 OUT UCHAR *ScanType)
47 MLME_SCAN_REQ_STRUCT *Info;
49 Info = (MLME_SCAN_REQ_STRUCT *)(Msg);
50 *BssType = Info->BssType;
51 *SsidLen = Info->SsidLen;
52 NdisMoveMemory(Ssid, Info->Ssid, *SsidLen);
53 *ScanType = Info->ScanType;
55 if ((*BssType == BSS_INFRA || *BssType == BSS_INDEP || *BssType == BSS_ANY) &&
56 (*ScanType == SCAN_ACTIVE || *ScanType == SCAN_PASSIVE))
57 return TRUE;
58 else
60 DBGPRINT(RT_DEBUG_TRACE, "MlmeScanReqSanity fail - wrong BssType or ScanType\n");
61 return FALSE;
65 /*
66 ==========================================================================
67 Description:
68 MLME message sanity check
69 Return:
70 TRUE if all parameters are OK, FALSE otherwise
71 ==========================================================================
73 BOOLEAN MlmeStartReqSanity(
74 IN PRTMP_ADAPTER pAd,
75 IN VOID *Msg,
76 IN ULONG MsgLen,
77 OUT CHAR Ssid[],
78 OUT UCHAR *SsidLen)
80 MLME_START_REQ_STRUCT *Info;
82 Info = (MLME_START_REQ_STRUCT *)(Msg);
84 if (Info->SsidLen > MAX_LEN_OF_SSID)
86 DBGPRINT(RT_DEBUG_TRACE, "MlmeStartReqSanity fail - wrong SSID length\n");
87 return FALSE;
90 *SsidLen = Info->SsidLen;
91 NdisMoveMemory(Ssid, Info->Ssid, *SsidLen);
93 return TRUE;
96 /*
97 ==========================================================================
98 Description:
99 MLME message sanity check
100 Return:
101 TRUE if all parameters are OK, FALSE otherwise
102 ==========================================================================
104 BOOLEAN MlmeAssocReqSanity(
105 IN PRTMP_ADAPTER pAd,
106 IN VOID *Msg,
107 IN ULONG MsgLen,
108 OUT MACADDR *ApAddr,
109 OUT USHORT *CapabilityInfo,
110 OUT ULONG *Timeout,
111 OUT USHORT *ListenIntv)
113 MLME_ASSOC_REQ_STRUCT *Info;
115 Info = (MLME_ASSOC_REQ_STRUCT *)Msg;
116 *Timeout = Info->Timeout; // timeout
117 COPY_MAC_ADDR(ApAddr, &Info->Addr); // AP address
118 *CapabilityInfo = Info->CapabilityInfo; // capability info
119 *ListenIntv = Info->ListenIntv;
121 return TRUE;
125 ==========================================================================
126 Description:
127 MLME message sanity check
128 Return:
129 TRUE if all parameters are OK, FALSE otherwise
130 ==========================================================================
132 BOOLEAN MlmeAuthReqSanity(
133 IN PRTMP_ADAPTER pAd,
134 IN VOID *Msg,
135 IN ULONG MsgLen,
136 OUT MACADDR *Addr,
137 OUT ULONG *Timeout,
138 OUT USHORT *Alg)
140 MLME_AUTH_REQ_STRUCT *Info;
142 Info = (MLME_AUTH_REQ_STRUCT *)Msg;
143 COPY_MAC_ADDR(Addr, &Info->Addr);
144 *Timeout = Info->Timeout;
145 *Alg = Info->Alg;
147 if ((*Alg == Ndis802_11AuthModeShared || *Alg == Ndis802_11AuthModeOpen) && !MAC_ADDR_IS_GROUP(*Addr))
149 return TRUE;
151 else
153 DBGPRINT(RT_DEBUG_TRACE, "MlmeAuthReqSanity fail - wrong algorithm\n");
154 return FALSE;
159 ==========================================================================
160 Description:
161 MLME message sanity check
162 Return:
163 TRUE if all parameters are OK, FALSE otherwise
164 ==========================================================================
166 BOOLEAN PeerAssocRspSanity(
167 IN PRTMP_ADAPTER pAd,
168 IN VOID *Msg,
169 IN ULONG MsgLen,
170 OUT MACADDR *Addr2,
171 OUT USHORT *CapabilityInfo,
172 OUT USHORT *Status,
173 OUT USHORT *Aid,
174 OUT UCHAR Rates[],
175 OUT UCHAR *RatesLen,
176 OUT BOOLEAN *ExtendedRateIeExist)
178 CHAR IeType, *Ptr;
179 MACFRAME *Fr = (MACFRAME *)Msg;
180 PBEACON_EID_STRUCT eid_ptr;
182 COPY_MAC_ADDR(Addr2, &Fr->Hdr.Addr2);
183 Ptr = Fr->Octet;
185 NdisMoveMemory(CapabilityInfo, &Fr->Octet[0], 2);
186 NdisMoveMemory(Status, &Fr->Octet[2], 2);
187 // Mask out unnecessary capability information
188 *CapabilityInfo &= SUPPORTED_CAPABILITY_INFO;
190 if (*Status == MLME_SUCCESS)
192 NdisMoveMemory(Aid, &Fr->Octet[4], 2);
193 *Aid = (*Aid) & 0x3fff; // AID is low 14-bit
195 // -- get supported rates from payload and advance the pointer
196 IeType = Fr->Octet[6];
197 *RatesLen = Fr->Octet[7];
198 if ((IeType != IE_SUPP_RATES) || (*RatesLen > MAX_LEN_OF_SUPPORTED_RATES))
200 DBGPRINT(RT_DEBUG_TRACE, "PeerAssocRspSanity fail - wrong SupportedRates IE\n");
201 return FALSE;
203 else
204 NdisMoveMemory(Rates, &Fr->Octet[8], *RatesLen);
206 // many AP implement proprietary IEs in non-standard order, we'd better
207 // tolerate mis-ordered IEs to get best compatibility
208 *ExtendedRateIeExist = FALSE;
209 eid_ptr = (PBEACON_EID_STRUCT) &Fr->Octet[8 + (*RatesLen)];
211 // get variable fields from payload and advance the pointer
212 while (((UCHAR*)eid_ptr + eid_ptr->Len + 1) < ((UCHAR*)Fr + MsgLen))
214 switch (eid_ptr->Eid)
216 case IE_EXT_SUPP_RATES:
217 *ExtendedRateIeExist = TRUE;
218 if ((*RatesLen + eid_ptr->Len) <= MAX_LEN_OF_SUPPORTED_RATES)
220 NdisMoveMemory(&Rates[*RatesLen], eid_ptr->Octet, eid_ptr->Len);
221 *RatesLen = (*RatesLen) + eid_ptr->Len;
223 else
225 NdisMoveMemory(&Rates[*RatesLen], eid_ptr->Octet, MAX_LEN_OF_SUPPORTED_RATES - (*RatesLen));
226 *RatesLen = MAX_LEN_OF_SUPPORTED_RATES;
228 break;
229 default:
230 DBGPRINT(RT_DEBUG_TRACE, "PeerAssocRspSanity - ignore unrecognized EID = %d\n", eid_ptr->Eid);
231 break;
234 eid_ptr = (PBEACON_EID_STRUCT)((UCHAR*)eid_ptr + 2 + eid_ptr->Len);
239 return TRUE;
243 ==========================================================================
244 Description:
245 MLME message sanity check
246 Return:
247 TRUE if all parameters are OK, FALSE otherwise
248 ==========================================================================
250 BOOLEAN PeerDisassocSanity(
251 IN PRTMP_ADAPTER pAd,
252 IN VOID *Msg,
253 IN ULONG MsgLen,
254 OUT MACADDR *Addr2,
255 OUT USHORT *Reason)
257 MACFRAME *Fr = (MACFRAME *)Msg;
259 COPY_MAC_ADDR(Addr2, &Fr->Hdr.Addr2);
260 NdisMoveMemory(Reason, &Fr->Octet[0], 2);
262 return TRUE;
266 ==========================================================================
267 Description:
268 MLME message sanity check
269 Return:
270 TRUE if all parameters are OK, FALSE otherwise
271 ==========================================================================
273 BOOLEAN PeerDeauthSanity(
274 IN PRTMP_ADAPTER pAd,
275 IN VOID *Msg,
276 IN ULONG MsgLen,
277 OUT MACADDR *Addr2,
278 OUT USHORT *Reason)
280 MACFRAME *Fr = (MACFRAME *)Msg;
282 COPY_MAC_ADDR(Addr2, &Fr->Hdr.Addr2);
283 NdisMoveMemory(Reason, &Fr->Octet[0], 2);
285 return TRUE;
289 ==========================================================================
290 Description:
291 MLME message sanity check
292 Return:
293 TRUE if all parameters are OK, FALSE otherwise
294 ==========================================================================
296 BOOLEAN PeerAuthSanity(
297 IN PRTMP_ADAPTER pAd,
298 IN VOID *Msg,
299 IN ULONG MsgLen,
300 OUT MACADDR *Addr,
301 OUT USHORT *Alg,
302 OUT USHORT *Seq,
303 OUT USHORT *Status,
304 CHAR *ChlgText)
306 MACFRAME *Fr = (MACFRAME *)Msg;
308 COPY_MAC_ADDR(Addr, &Fr->Hdr.Addr2);
309 NdisMoveMemory(Alg, &Fr->Octet[0], 2);
310 NdisMoveMemory(Seq, &Fr->Octet[2], 2);
311 NdisMoveMemory(Status, &Fr->Octet[4], 2);
313 if (*Alg == Ndis802_11AuthModeOpen)
315 if (*Seq == 1 || *Seq == 2)
317 return TRUE;
319 else
321 DBGPRINT(RT_DEBUG_TRACE, "PeerAuthSanity fail - wrong Seg#\n");
322 return FALSE;
325 else if (*Alg == Ndis802_11AuthModeShared)
327 if (*Seq == 1 || *Seq == 4)
329 return TRUE;
331 else if (*Seq == 2 || *Seq == 3)
333 NdisMoveMemory(ChlgText, &Fr->Octet[8], CIPHER_TEXT_LEN);
334 return TRUE;
336 else
338 DBGPRINT(RT_DEBUG_TRACE, "PeerAuthSanity fail - wrong Seg#\n");
339 return FALSE;
342 else
344 DBGPRINT(RT_DEBUG_TRACE, "PeerAuthSanity fail - wrong algorithm\n");
345 return FALSE;
350 ==========================================================================
351 Description:
352 MLME message sanity check
353 Return:
354 TRUE if all parameters are OK, FALSE otherwise
355 ==========================================================================
357 BOOLEAN PeerProbeReqSanity(
358 IN PRTMP_ADAPTER pAd,
359 IN VOID *Msg,
360 IN ULONG MsgLen,
361 OUT MACADDR *Addr2,
362 OUT CHAR Ssid[],
363 OUT UCHAR *SsidLen)
364 // OUT UCHAR Rates[],
365 // OUT UCHAR *RatesLen)
367 UCHAR Idx;
368 UCHAR RateLen;
369 CHAR IeType;
370 MACFRAME *Fr = (MACFRAME *)Msg;
372 COPY_MAC_ADDR(Addr2, &Fr->Hdr.Addr2);
374 if ((Fr->Octet[0] != IE_SSID) || (Fr->Octet[1] > MAX_LEN_OF_SSID))
376 DBGPRINT(RT_DEBUG_TRACE, "PeerProbeReqSanity fail - wrong SSID IE(Type=%d,Len=%d)\n",Fr->Octet[0],Fr->Octet[1]);
377 return FALSE;
380 *SsidLen = Fr->Octet[1];
381 NdisMoveMemory(Ssid, &Fr->Octet[2], *SsidLen);
383 #if 1
384 Idx = *SsidLen + 2;
386 // -- get supported rates from payload and advance the pointer
387 IeType = Fr->Octet[Idx];
388 RateLen = Fr->Octet[Idx + 1];
389 if (IeType != IE_SUPP_RATES)
391 DBGPRINT(RT_DEBUG_TRACE, "PeerProbeReqSanity fail - wrong SupportRates IE(Type=%d,Len=%d)\n",Fr->Octet[Idx],Fr->Octet[Idx+1]);
392 return FALSE;
394 else
396 if ((pAd->PortCfg.AdhocMode == 2) && (RateLen < 8))
397 return (FALSE);
399 #endif
400 return TRUE;
404 ==========================================================================
405 Description:
406 MLME message sanity check
407 Return:
408 TRUE if all parameters are OK, FALSE otherwise
409 ==========================================================================
411 BOOLEAN PeerBeaconAndProbeRspSanity(
412 IN PRTMP_ADAPTER pAd,
413 IN VOID *Msg,
414 IN ULONG MsgLen,
415 OUT MACADDR *Addr2,
416 OUT MACADDR *Bssid,
417 OUT CHAR Ssid[],
418 OUT UCHAR *SsidLen,
419 OUT UCHAR *BssType,
420 OUT USHORT *BeaconPeriod,
421 OUT UCHAR *Channel,
422 OUT LARGE_INTEGER *Timestamp,
423 OUT BOOLEAN *CfExist,
424 OUT CF_PARM *CfParm,
425 OUT USHORT *AtimWin,
426 OUT USHORT *CapabilityInfo,
427 OUT UCHAR Rate[],
428 OUT UCHAR *RateLen,
429 OUT BOOLEAN *ExtendedRateIeExist,
430 OUT UCHAR *Erp,
431 OUT UCHAR *DtimCount,
432 OUT UCHAR *DtimPeriod,
433 OUT UCHAR *BcastFlag,
434 OUT UCHAR *MessageToMe,
435 OUT UCHAR *Legacy,
436 OUT UCHAR SupRate[],
437 OUT UCHAR *SupRateLen,
438 OUT UCHAR ExtRate[],
439 OUT UCHAR *ExtRateLen,
440 OUT PNDIS_802_11_VARIABLE_IEs pVIE)
442 CHAR *Ptr, TimLen;
443 MACFRAME *Fr;
444 PBEACON_EID_STRUCT eid_ptr;
445 UCHAR SubType;
446 UCHAR Sanity;
448 // Add for 3 necessary EID field check
449 Sanity = 0;
451 *ExtendedRateIeExist = FALSE;
452 *Erp = 0;
454 Fr = (MACFRAME *)Msg;
456 // get subtype from header
457 SubType = (UCHAR)Fr->Hdr.SubType;
459 // get Addr2 and BSSID from header
460 COPY_MAC_ADDR(Addr2, &Fr->Hdr.Addr2);
461 COPY_MAC_ADDR(Bssid, &Fr->Hdr.Addr3);
463 Ptr = Fr->Octet;
465 // get timestamp from payload and advance the pointer
466 NdisMoveMemory(Timestamp, Ptr, TIMESTAMP_LEN);
467 Ptr += TIMESTAMP_LEN;
469 // get beacon interval from payload and advance the pointer
470 NdisMoveMemory(BeaconPeriod, Ptr, 2);
471 Ptr += 2;
473 // get capability info from payload and advance the pointer
474 NdisMoveMemory(CapabilityInfo, Ptr, 2);
475 Ptr += 2;
476 if (CAP_IS_ESS_ON(*CapabilityInfo))
478 *BssType = BSS_INFRA;
480 else
482 *BssType = BSS_INDEP;
485 // Mask out unnecessary capability information
486 *CapabilityInfo &= SUPPORTED_CAPABILITY_INFO;
488 eid_ptr = (PBEACON_EID_STRUCT) Ptr;
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