• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3  * All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  *
20  * File: vntwifi.c
21  *
22  * Purpose: export functions for vntwifi lib
23  *
24  * Functions:
25  *
26  * Revision History:
27  *
28  * Author: Yiching Chen
29  *
30  * Date: feb. 2, 2005
31  *
32  */
33 
34 #include "vntwifi.h"
35 #include "IEEE11h.h"
36 #include "country.h"
37 #include "device.h"
38 #include "wmgr.h"
39 #include "datarate.h"
40 
41 /*---------------------  Static Definitions -------------------------*/
42 
43 /*---------------------  Static Classes  ----------------------------*/
44 
45 /*---------------------  Static Variables  --------------------------*/
46 
47 /*---------------------  Static Functions  --------------------------*/
48 
49 /*---------------------  Export Variables  --------------------------*/
50 
51 /*---------------------  Export Functions  --------------------------*/
52 
53 /*+
54  *
55  * Description:
56  *    Set Operation Mode
57  *
58  * Parameters:
59  *  In:
60  *      pMgmtHandle - pointer to management object
61  *      eOPMode     - Operation Mode
62  *  Out:
63  *      none
64  *
65  * Return Value: none
66  *
67  -*/
68 void
VNTWIFIvSetOPMode(void * pMgmtHandle,WMAC_CONFIG_MODE eOPMode)69 VNTWIFIvSetOPMode(
70 	void *pMgmtHandle,
71 	WMAC_CONFIG_MODE eOPMode
72 )
73 {
74 	PSMgmtObject        pMgmt = (PSMgmtObject)pMgmtHandle;
75 
76 	pMgmt->eConfigMode = eOPMode;
77 }
78 
79 /*+
80  *
81  * Description:
82  *    Set Operation Mode
83  *
84  * Parameters:
85  *  In:
86  *      pMgmtHandle - pointer to management object
87  *      wBeaconPeriod - Beacon Period
88  *      wATIMWindow - ATIM window
89  *      uChannel - channel number
90  *  Out:
91  *      none
92  *
93  * Return Value: none
94  *
95  -*/
96 void
VNTWIFIvSetIBSSParameter(void * pMgmtHandle,unsigned short wBeaconPeriod,unsigned short wATIMWindow,unsigned int uChannel)97 VNTWIFIvSetIBSSParameter(
98 	void *pMgmtHandle,
99 	unsigned short wBeaconPeriod,
100 	unsigned short wATIMWindow,
101 	unsigned int uChannel
102 )
103 {
104 	PSMgmtObject        pMgmt = (PSMgmtObject)pMgmtHandle;
105 
106 	pMgmt->wIBSSBeaconPeriod = wBeaconPeriod;
107 	pMgmt->wIBSSATIMWindow = wATIMWindow;
108 	pMgmt->uIBSSChannel = uChannel;
109 }
110 
111 /*+
112  *
113  * Description:
114  *    Get current SSID
115  *
116  * Parameters:
117  *  In:
118  *      pMgmtHandle - pointer to management object
119  *  Out:
120  *      none
121  *
122  * Return Value: current SSID pointer.
123  *
124  -*/
125 PWLAN_IE_SSID
VNTWIFIpGetCurrentSSID(void * pMgmtHandle)126 VNTWIFIpGetCurrentSSID(
127 	void *pMgmtHandle
128 )
129 {
130 	PSMgmtObject        pMgmt = (PSMgmtObject)pMgmtHandle;
131 
132 	return (PWLAN_IE_SSID) pMgmt->abyCurrSSID;
133 }
134 
135 /*+
136  *
137  * Description:
138  *    Get current link channel
139  *
140  * Parameters:
141  *  In:
142  *      pMgmtHandle - pointer to management object
143  *  Out:
144  *      none
145  *
146  * Return Value: current Channel.
147  *
148  -*/
149 unsigned int
VNTWIFIpGetCurrentChannel(void * pMgmtHandle)150 VNTWIFIpGetCurrentChannel(
151 	void *pMgmtHandle
152 )
153 {
154 	PSMgmtObject        pMgmt = (PSMgmtObject)pMgmtHandle;
155 
156 	if (pMgmtHandle != NULL)
157 		return pMgmt->uCurrChannel;
158 
159 	return 0;
160 }
161 
162 /*+
163  *
164  * Description:
165  *    Get current Assoc ID
166  *
167  * Parameters:
168  *  In:
169  *      pMgmtHandle - pointer to management object
170  *  Out:
171  *      none
172  *
173  * Return Value: current Assoc ID
174  *
175  -*/
176 unsigned short
VNTWIFIwGetAssocID(void * pMgmtHandle)177 VNTWIFIwGetAssocID(
178 	void *pMgmtHandle
179 )
180 {
181 	PSMgmtObject        pMgmt = (PSMgmtObject)pMgmtHandle;
182 
183 	return pMgmt->wCurrAID;
184 }
185 
186 /*+
187  *
188  * Description:
189  *    This routine return max support rate of IES
190  *
191  * Parameters:
192  *  In:
193  *      pSupportRateIEs
194  *      pExtSupportRateIEs
195  *
196  *  Out:
197  *
198  * Return Value: max support rate
199  *
200  -*/
201 unsigned char
VNTWIFIbyGetMaxSupportRate(PWLAN_IE_SUPP_RATES pSupportRateIEs,PWLAN_IE_SUPP_RATES pExtSupportRateIEs)202 VNTWIFIbyGetMaxSupportRate(
203 	PWLAN_IE_SUPP_RATES pSupportRateIEs,
204 	PWLAN_IE_SUPP_RATES pExtSupportRateIEs
205 )
206 {
207 	unsigned char byMaxSupportRate = RATE_1M;
208 	unsigned char bySupportRate = RATE_1M;
209 	unsigned int ii = 0;
210 
211 	if (pSupportRateIEs) {
212 		for (ii = 0; ii < pSupportRateIEs->len; ii++) {
213 			bySupportRate = DATARATEbyGetRateIdx(pSupportRateIEs->abyRates[ii]);
214 			if (bySupportRate > byMaxSupportRate)
215 				byMaxSupportRate = bySupportRate;
216 
217 		}
218 	}
219 	if (pExtSupportRateIEs) {
220 		for (ii = 0; ii < pExtSupportRateIEs->len; ii++) {
221 			bySupportRate = DATARATEbyGetRateIdx(pExtSupportRateIEs->abyRates[ii]);
222 			if (bySupportRate > byMaxSupportRate)
223 				byMaxSupportRate = bySupportRate;
224 
225 		}
226 	}
227 
228 	return byMaxSupportRate;
229 }
230 
231 /*+
232  *
233  * Description:
234  *    This routine return data rate of ACK packtet
235  *
236  * Parameters:
237  *  In:
238  *      byRxDataRate
239  *      pSupportRateIEs
240  *      pExtSupportRateIEs
241  *
242  *  Out:
243  *
244  * Return Value: max support rate
245  *
246  -*/
247 unsigned char
VNTWIFIbyGetACKTxRate(unsigned char byRxDataRate,PWLAN_IE_SUPP_RATES pSupportRateIEs,PWLAN_IE_SUPP_RATES pExtSupportRateIEs)248 VNTWIFIbyGetACKTxRate(
249 	unsigned char byRxDataRate,
250 	PWLAN_IE_SUPP_RATES pSupportRateIEs,
251 	PWLAN_IE_SUPP_RATES pExtSupportRateIEs
252 )
253 {
254 	unsigned char byMaxAckRate;
255 	unsigned char byBasicRate;
256 	unsigned int ii;
257 
258 	if (byRxDataRate <= RATE_11M) {
259 		byMaxAckRate = RATE_1M;
260 	} else  {
261 		/* 24M is mandatory for 802.11a and 802.11g */
262 		byMaxAckRate = RATE_24M;
263 	}
264 	if (pSupportRateIEs) {
265 		for (ii = 0; ii < pSupportRateIEs->len; ii++) {
266 			if (pSupportRateIEs->abyRates[ii] & 0x80) {
267 				byBasicRate = DATARATEbyGetRateIdx(pSupportRateIEs->abyRates[ii]);
268 				if ((byBasicRate <= byRxDataRate) &&
269 				    (byBasicRate > byMaxAckRate))  {
270 					byMaxAckRate = byBasicRate;
271 				}
272 			}
273 		}
274 	}
275 	if (pExtSupportRateIEs) {
276 		for (ii = 0; ii < pExtSupportRateIEs->len; ii++) {
277 			if (pExtSupportRateIEs->abyRates[ii] & 0x80) {
278 				byBasicRate = DATARATEbyGetRateIdx(pExtSupportRateIEs->abyRates[ii]);
279 				if ((byBasicRate <= byRxDataRate) &&
280 				    (byBasicRate > byMaxAckRate))  {
281 					byMaxAckRate = byBasicRate;
282 				}
283 			}
284 		}
285 	}
286 
287 	return byMaxAckRate;
288 }
289 
290 /*+
291  *
292  * Description:
293  *    Set Authentication Mode
294  *
295  * Parameters:
296  *  In:
297  *      pMgmtHandle - pointer to management object
298  *      eAuthMode   - Authentication mode
299  *  Out:
300  *      none
301  *
302  * Return Value: none
303  *
304  -*/
305 void
VNTWIFIvSetAuthenticationMode(void * pMgmtHandle,WMAC_AUTHENTICATION_MODE eAuthMode)306 VNTWIFIvSetAuthenticationMode(
307 	void *pMgmtHandle,
308 	WMAC_AUTHENTICATION_MODE eAuthMode
309 )
310 {
311 	PSMgmtObject        pMgmt = (PSMgmtObject)pMgmtHandle;
312 
313 	pMgmt->eAuthenMode = eAuthMode;
314 	if ((eAuthMode == WMAC_AUTH_SHAREKEY) ||
315 	    (eAuthMode == WMAC_AUTH_AUTO)) {
316 		pMgmt->bShareKeyAlgorithm = true;
317 	} else {
318 		pMgmt->bShareKeyAlgorithm = false;
319 	}
320 }
321 
322 /*+
323  *
324  * Description:
325  *    Set Encryption Mode
326  *
327  * Parameters:
328  *  In:
329  *      pMgmtHandle - pointer to management object
330  *      eAuthMode   - Authentication mode
331  *  Out:
332  *      none
333  *
334  * Return Value: none
335  *
336  -*/
337 void
VNTWIFIvSetEncryptionMode(void * pMgmtHandle,WMAC_ENCRYPTION_MODE eEncryptionMode)338 VNTWIFIvSetEncryptionMode(
339 	void *pMgmtHandle,
340 	WMAC_ENCRYPTION_MODE eEncryptionMode
341 )
342 {
343 	PSMgmtObject        pMgmt = (PSMgmtObject)pMgmtHandle;
344 
345 	pMgmt->eEncryptionMode = eEncryptionMode;
346 	if ((eEncryptionMode == WMAC_ENCRYPTION_WEPEnabled) ||
347 	    (eEncryptionMode == WMAC_ENCRYPTION_TKIPEnabled) ||
348 	    (eEncryptionMode == WMAC_ENCRYPTION_AESEnabled)) {
349 		pMgmt->bPrivacyInvoked = true;
350 	} else {
351 		pMgmt->bPrivacyInvoked = false;
352 	}
353 }
354 
355 bool
VNTWIFIbConfigPhyMode(void * pMgmtHandle,CARD_PHY_TYPE ePhyType)356 VNTWIFIbConfigPhyMode(
357 	void *pMgmtHandle,
358 	CARD_PHY_TYPE ePhyType
359 )
360 {
361 	PSMgmtObject        pMgmt = (PSMgmtObject)pMgmtHandle;
362 
363 	if ((ePhyType != PHY_TYPE_AUTO) &&
364 	    (ePhyType != pMgmt->eCurrentPHYMode)) {
365 		if (CARDbSetPhyParameter(pMgmt->pAdapter, ePhyType, 0, 0, NULL, NULL) == true)
366 			pMgmt->eCurrentPHYMode = ePhyType;
367 		else
368 			return false;
369 	}
370 	pMgmt->eConfigPHYMode = ePhyType;
371 	return true;
372 }
373 
374 void
VNTWIFIbGetConfigPhyMode(void * pMgmtHandle,void * pePhyType)375 VNTWIFIbGetConfigPhyMode(
376 	void *pMgmtHandle,
377 	void *pePhyType
378 )
379 {
380 	PSMgmtObject        pMgmt = (PSMgmtObject)pMgmtHandle;
381 
382 	if ((pMgmt != NULL) && (pePhyType != NULL))
383 		*(PCARD_PHY_TYPE)pePhyType = pMgmt->eConfigPHYMode;
384 }
385 
386 /*+
387  *
388  * Description:
389  *      Clear BSS List Database except current assoc BSS
390  *
391  * Parameters:
392  *  In:
393  *      pMgmtHandle     - Management Object structure
394  *      bLinkPass       - Current Link status
395  *  Out:
396  *
397  * Return Value: None.
398  *
399  -*/
400 
401 /*+
402  *
403  * Description:
404  *      Query BSS List in management database
405  *
406  * Parameters:
407  *  In:
408  *      pMgmtHandle     - Management Object structure
409  *  Out:
410  *      puBSSCount      - BSS count
411  *      pvFirstBSS      - pointer to first BSS
412  *
413  * Return Value: None.
414  *
415  -*/
416 
417 void
VNTWIFIvQueryBSSList(void * pMgmtHandle,unsigned int * puBSSCount,void ** pvFirstBSS)418 VNTWIFIvQueryBSSList(void *pMgmtHandle, unsigned int *puBSSCount, void **pvFirstBSS)
419 {
420 	unsigned int ii = 0;
421 	PSMgmtObject    pMgmt = (PSMgmtObject)pMgmtHandle;
422 	PKnownBSS       pBSS = NULL;
423 	unsigned int uCount = 0;
424 
425 	*pvFirstBSS = NULL;
426 
427 	for (ii = 0; ii < MAX_BSS_NUM; ii++) {
428 		pBSS = &(pMgmt->sBSSList[ii]);
429 		if (!pBSS->bActive)
430 			continue;
431 
432 		if (*pvFirstBSS == NULL)
433 			*pvFirstBSS = &(pMgmt->sBSSList[ii]);
434 
435 		uCount++;
436 	}
437 	*puBSSCount = uCount;
438 }
439 
440 void
VNTWIFIvGetNextBSS(void * pMgmtHandle,void * pvCurrentBSS,void ** pvNextBSS)441 VNTWIFIvGetNextBSS(
442 	void *pMgmtHandle,
443 	void *pvCurrentBSS,
444 	void **pvNextBSS
445 )
446 {
447 	PKnownBSS       pBSS = (PKnownBSS) pvCurrentBSS;
448 	PSMgmtObject    pMgmt = (PSMgmtObject)pMgmtHandle;
449 
450 	*pvNextBSS = NULL;
451 
452 	while (*pvNextBSS == NULL) {
453 		pBSS++;
454 		if (pBSS > &(pMgmt->sBSSList[MAX_BSS_NUM]))
455 			return;
456 
457 		if (pBSS->bActive == true) {
458 			*pvNextBSS = pBSS;
459 			return;
460 		}
461 	}
462 }
463 
464 /*+
465  *
466  * Description:
467  *      Update Tx attemps, Tx failure counter in Node DB
468  *
469  *  In:
470  *  Out:
471  *      none
472  *
473  * Return Value: none
474  *
475  -*/
476 void
VNTWIFIvUpdateNodeTxCounter(void * pMgmtHandle,unsigned char * pbyDestAddress,bool bTxOk,unsigned short wRate,unsigned char * pbyTxFailCount)477 VNTWIFIvUpdateNodeTxCounter(
478 	void *pMgmtHandle,
479 	unsigned char *pbyDestAddress,
480 	bool bTxOk,
481 	unsigned short wRate,
482 	unsigned char *pbyTxFailCount
483 )
484 {
485 	PSMgmtObject    pMgmt = (PSMgmtObject)pMgmtHandle;
486 	unsigned int uNodeIndex = 0;
487 	unsigned int ii;
488 
489 	if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) ||
490 	    (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) {
491 		if (BSSDBbIsSTAInNodeDB(pMgmt, pbyDestAddress, &uNodeIndex) == false)
492 			return;
493 	}
494 
495 	pMgmt->sNodeDBTable[uNodeIndex].uTxAttempts++;
496 	if (bTxOk) {
497 		/* transmit success, TxAttempts at least plus one */
498 		pMgmt->sNodeDBTable[uNodeIndex].uTxOk[MAX_RATE]++;
499 		pMgmt->sNodeDBTable[uNodeIndex].uTxOk[wRate]++;
500 	} else {
501 		pMgmt->sNodeDBTable[uNodeIndex].uTxFailures++;
502 	}
503 	pMgmt->sNodeDBTable[uNodeIndex].uTxRetry += pbyTxFailCount[MAX_RATE];
504 	for (ii = 0; ii < MAX_RATE; ii++)
505 		pMgmt->sNodeDBTable[uNodeIndex].uTxFail[ii] += pbyTxFailCount[ii];
506 }
507 
508 void
VNTWIFIvGetTxRate(void * pMgmtHandle,unsigned char * pbyDestAddress,unsigned short * pwTxDataRate,unsigned char * pbyACKRate,unsigned char * pbyCCKBasicRate,unsigned char * pbyOFDMBasicRate)509 VNTWIFIvGetTxRate(
510 	void *pMgmtHandle,
511 	unsigned char *pbyDestAddress,
512 	unsigned short *pwTxDataRate,
513 	unsigned char *pbyACKRate,
514 	unsigned char *pbyCCKBasicRate,
515 	unsigned char *pbyOFDMBasicRate
516 )
517 {
518 	PSMgmtObject        pMgmt = (PSMgmtObject)pMgmtHandle;
519 	unsigned int uNodeIndex = 0;
520 	unsigned short wTxDataRate = RATE_1M;
521 	unsigned char byACKRate = RATE_1M;
522 	unsigned char byCCKBasicRate = RATE_1M;
523 	unsigned char byOFDMBasicRate = RATE_24M;
524 	PWLAN_IE_SUPP_RATES pSupportRateIEs = NULL;
525 	PWLAN_IE_SUPP_RATES pExtSupportRateIEs = NULL;
526 
527 	if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) ||
528 	    (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) {
529 		/* Adhoc Tx rate decided from node DB */
530 		if (BSSDBbIsSTAInNodeDB(pMgmt, pbyDestAddress, &uNodeIndex)) {
531 			wTxDataRate = (pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate);
532 			pSupportRateIEs = (PWLAN_IE_SUPP_RATES) (pMgmt->sNodeDBTable[uNodeIndex].abyCurrSuppRates);
533 			pExtSupportRateIEs = (PWLAN_IE_SUPP_RATES) (pMgmt->sNodeDBTable[uNodeIndex].abyCurrExtSuppRates);
534 		} else {
535 			if (pMgmt->eCurrentPHYMode != PHY_TYPE_11A)
536 				wTxDataRate = RATE_2M;
537 			else
538 				wTxDataRate = RATE_24M;
539 
540 			pSupportRateIEs = (PWLAN_IE_SUPP_RATES) pMgmt->abyCurrSuppRates;
541 			pExtSupportRateIEs = (PWLAN_IE_SUPP_RATES) pMgmt->abyCurrExtSuppRates;
542 		}
543 	} else { /* Infrastructure: rate decided from AP Node, index = 0 */
544 
545 		wTxDataRate = (pMgmt->sNodeDBTable[0].wTxDataRate);
546 
547 		pSupportRateIEs = (PWLAN_IE_SUPP_RATES) pMgmt->abyCurrSuppRates;
548 		pExtSupportRateIEs = (PWLAN_IE_SUPP_RATES) pMgmt->abyCurrExtSuppRates;
549 	}
550 	byACKRate = VNTWIFIbyGetACKTxRate((unsigned char) wTxDataRate,
551 					    pSupportRateIEs,
552 					    pExtSupportRateIEs
553 );
554 	if (byACKRate > (unsigned char) wTxDataRate)
555 		byACKRate = (unsigned char) wTxDataRate;
556 
557 	byCCKBasicRate = VNTWIFIbyGetACKTxRate(RATE_11M,
558 						pSupportRateIEs,
559 						pExtSupportRateIEs
560 );
561 	byOFDMBasicRate = VNTWIFIbyGetACKTxRate(RATE_54M,
562 						pSupportRateIEs,
563 						pExtSupportRateIEs
564 );
565 	*pwTxDataRate = wTxDataRate;
566 	*pbyACKRate = byACKRate;
567 	*pbyCCKBasicRate = byCCKBasicRate;
568 	*pbyOFDMBasicRate = byOFDMBasicRate;
569 }
570 
571 unsigned char
VNTWIFIbyGetKeyCypher(void * pMgmtHandle,bool bGroupKey)572 VNTWIFIbyGetKeyCypher(
573 	void *pMgmtHandle,
574 	bool bGroupKey
575 )
576 {
577 	PSMgmtObject    pMgmt = (PSMgmtObject)pMgmtHandle;
578 
579 	if (bGroupKey)
580 		return pMgmt->byCSSGK;
581 	else
582 		return pMgmt->byCSSPK;
583 }
584 
585 bool
VNTWIFIbSetPMKIDCache(void * pMgmtObject,unsigned long ulCount,void * pPMKIDInfo)586 VNTWIFIbSetPMKIDCache(
587 	void *pMgmtObject,
588 	unsigned long ulCount,
589 	void *pPMKIDInfo
590 )
591 {
592 	PSMgmtObject    pMgmt = (PSMgmtObject) pMgmtObject;
593 
594 	if (ulCount > MAX_PMKID_CACHE)
595 		return false;
596 
597 	pMgmt->gsPMKIDCache.BSSIDInfoCount = ulCount;
598 	memcpy(pMgmt->gsPMKIDCache.BSSIDInfo, pPMKIDInfo, (ulCount*sizeof(PMKIDInfo)));
599 	return true;
600 }
601 
602 unsigned short
VNTWIFIwGetMaxSupportRate(void * pMgmtObject)603 VNTWIFIwGetMaxSupportRate(
604 	void *pMgmtObject
605 )
606 {
607 	unsigned short wRate = RATE_54M;
608 	PSMgmtObject    pMgmt = (PSMgmtObject) pMgmtObject;
609 
610 	for (wRate = RATE_54M; wRate > RATE_1M; wRate--) {
611 		if (pMgmt->sNodeDBTable[0].wSuppRate & (1<<wRate))
612 			return wRate;
613 	}
614 
615 	if (pMgmt->eCurrentPHYMode == PHY_TYPE_11A)
616 		return RATE_6M;
617 	else
618 		return RATE_1M;
619 }
620 
621 void
VNTWIFIvSet11h(void * pMgmtObject,bool b11hEnable)622 VNTWIFIvSet11h(
623 	void *pMgmtObject,
624 	bool b11hEnable
625 )
626 {
627 	PSMgmtObject    pMgmt = (PSMgmtObject) pMgmtObject;
628 
629 	pMgmt->b11hEnable = b11hEnable;
630 }
631 
632 bool
VNTWIFIbMeasureReport(void * pMgmtObject,bool bEndOfReport,void * pvMeasureEID,unsigned char byReportMode,unsigned char byBasicMap,unsigned char byCCAFraction,unsigned char * pbyRPIs)633 VNTWIFIbMeasureReport(
634 	void *pMgmtObject,
635 	bool bEndOfReport,
636 	void *pvMeasureEID,
637 	unsigned char byReportMode,
638 	unsigned char byBasicMap,
639 	unsigned char byCCAFraction,
640 	unsigned char *pbyRPIs
641 )
642 {
643 	PSMgmtObject    pMgmt = (PSMgmtObject) pMgmtObject;
644 	unsigned char *pbyCurrentEID = (unsigned char *)(pMgmt->pCurrMeasureEIDRep);
645 
646 	if ((pvMeasureEID != NULL) &&
647 	    (pMgmt->uLengthOfRepEIDs < (WLAN_A3FR_MAXLEN - sizeof(MEASEURE_REP) - sizeof(WLAN_80211HDR_A3) - 3))
648 ) {
649 		pMgmt->pCurrMeasureEIDRep->byElementID = WLAN_EID_MEASURE_REP;
650 		pMgmt->pCurrMeasureEIDRep->len = 3;
651 		pMgmt->pCurrMeasureEIDRep->byToken = ((PWLAN_IE_MEASURE_REQ)pvMeasureEID)->byToken;
652 		pMgmt->pCurrMeasureEIDRep->byMode = byReportMode;
653 		pMgmt->pCurrMeasureEIDRep->byType = ((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->byType;
654 		switch (pMgmt->pCurrMeasureEIDRep->byType) {
655 		case MEASURE_TYPE_BASIC:
656 			pMgmt->pCurrMeasureEIDRep->len += sizeof(MEASEURE_REP_BASIC);
657 			memcpy(&(pMgmt->pCurrMeasureEIDRep->sRep.sBasic),
658 			       &(((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->sReq),
659 			       sizeof(MEASEURE_REQ));
660 			pMgmt->pCurrMeasureEIDRep->sRep.sBasic.byMap = byBasicMap;
661 			break;
662 		case MEASURE_TYPE_CCA:
663 			pMgmt->pCurrMeasureEIDRep->len += sizeof(MEASEURE_REP_CCA);
664 			memcpy(&(pMgmt->pCurrMeasureEIDRep->sRep.sCCA),
665 			       &(((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->sReq),
666 			       sizeof(MEASEURE_REQ));
667 			pMgmt->pCurrMeasureEIDRep->sRep.sCCA.byCCABusyFraction = byCCAFraction;
668 			break;
669 		case MEASURE_TYPE_RPI:
670 			pMgmt->pCurrMeasureEIDRep->len += sizeof(MEASEURE_REP_RPI);
671 			memcpy(&(pMgmt->pCurrMeasureEIDRep->sRep.sRPI),
672 			       &(((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->sReq),
673 			       sizeof(MEASEURE_REQ));
674 			memcpy(pMgmt->pCurrMeasureEIDRep->sRep.sRPI.abyRPIdensity, pbyRPIs, 8);
675 			break;
676 		default:
677 			break;
678 		}
679 		pbyCurrentEID += (2 + pMgmt->pCurrMeasureEIDRep->len);
680 		pMgmt->uLengthOfRepEIDs += (2 + pMgmt->pCurrMeasureEIDRep->len);
681 		pMgmt->pCurrMeasureEIDRep = (PWLAN_IE_MEASURE_REP) pbyCurrentEID;
682 	}
683 	if (bEndOfReport)
684 		IEEE11hbMSRRepTx(pMgmt);
685 
686 	return true;
687 }
688 
689 bool
VNTWIFIbChannelSwitch(void * pMgmtObject,unsigned char byNewChannel)690 VNTWIFIbChannelSwitch(
691 	void *pMgmtObject,
692 	unsigned char byNewChannel
693 )
694 {
695 	PSMgmtObject    pMgmt = (PSMgmtObject) pMgmtObject;
696 
697 	pMgmt->uCurrChannel = byNewChannel;
698 	pMgmt->bSwitchChannel = false;
699 	return true;
700 }
701