1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72void
73VNTWIFIvSetOPMode (
74 void *pMgmtHandle,
75 WMAC_CONFIG_MODE eOPMode
76 )
77{
78 PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
79
80 pMgmt->eConfigMode = eOPMode;
81}
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101void
102VNTWIFIvSetIBSSParameter (
103 void *pMgmtHandle,
104 unsigned short wBeaconPeriod,
105 unsigned short wATIMWindow,
106 unsigned int uChannel
107 )
108{
109 PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
110
111 pMgmt->wIBSSBeaconPeriod = wBeaconPeriod;
112 pMgmt->wIBSSATIMWindow = wATIMWindow;
113 pMgmt->uIBSSChannel = uChannel;
114}
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130PWLAN_IE_SSID
131VNTWIFIpGetCurrentSSID (
132 void *pMgmtHandle
133 )
134{
135 PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
136 return((PWLAN_IE_SSID) pMgmt->abyCurrSSID);
137}
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153unsigned int
154VNTWIFIpGetCurrentChannel (
155 void *pMgmtHandle
156 )
157{
158 PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
159 if (pMgmtHandle != NULL) {
160 return (pMgmt->uCurrChannel);
161 }
162 return 0;
163}
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179unsigned short
180VNTWIFIwGetAssocID (
181 void *pMgmtHandle
182 )
183{
184 PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
185 return(pMgmt->wCurrAID);
186}
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205unsigned char
206VNTWIFIbyGetMaxSupportRate (
207 PWLAN_IE_SUPP_RATES pSupportRateIEs,
208 PWLAN_IE_SUPP_RATES pExtSupportRateIEs
209 )
210{
211 unsigned char byMaxSupportRate = RATE_1M;
212 unsigned char bySupportRate = RATE_1M;
213 unsigned int ii = 0;
214
215 if (pSupportRateIEs) {
216 for (ii = 0; ii < pSupportRateIEs->len; ii++) {
217 bySupportRate = DATARATEbyGetRateIdx(pSupportRateIEs->abyRates[ii]);
218 if (bySupportRate > byMaxSupportRate) {
219 byMaxSupportRate = bySupportRate;
220 }
221 }
222 }
223 if (pExtSupportRateIEs) {
224 for (ii = 0; ii < pExtSupportRateIEs->len; ii++) {
225 bySupportRate = DATARATEbyGetRateIdx(pExtSupportRateIEs->abyRates[ii]);
226 if (bySupportRate > byMaxSupportRate) {
227 byMaxSupportRate = bySupportRate;
228 }
229 }
230 }
231
232 return byMaxSupportRate;
233}
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251unsigned char
252VNTWIFIbyGetACKTxRate (
253 unsigned char byRxDataRate,
254 PWLAN_IE_SUPP_RATES pSupportRateIEs,
255 PWLAN_IE_SUPP_RATES pExtSupportRateIEs
256 )
257{
258 unsigned char byMaxAckRate;
259 unsigned char byBasicRate;
260 unsigned int ii;
261
262 if (byRxDataRate <= RATE_11M) {
263 byMaxAckRate = RATE_1M;
264 } else {
265
266 byMaxAckRate = RATE_24M;
267 }
268 if (pSupportRateIEs) {
269 for (ii = 0; ii < pSupportRateIEs->len; ii++) {
270 if (pSupportRateIEs->abyRates[ii] & 0x80) {
271 byBasicRate = DATARATEbyGetRateIdx(pSupportRateIEs->abyRates[ii]);
272 if ((byBasicRate <= byRxDataRate) &&
273 (byBasicRate > byMaxAckRate)) {
274 byMaxAckRate = byBasicRate;
275 }
276 }
277 }
278 }
279 if (pExtSupportRateIEs) {
280 for (ii = 0; ii < pExtSupportRateIEs->len; ii++) {
281 if (pExtSupportRateIEs->abyRates[ii] & 0x80) {
282 byBasicRate = DATARATEbyGetRateIdx(pExtSupportRateIEs->abyRates[ii]);
283 if ((byBasicRate <= byRxDataRate) &&
284 (byBasicRate > byMaxAckRate)) {
285 byMaxAckRate = byBasicRate;
286 }
287 }
288 }
289 }
290
291 return byMaxAckRate;
292}
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309void
310VNTWIFIvSetAuthenticationMode (
311 void *pMgmtHandle,
312 WMAC_AUTHENTICATION_MODE eAuthMode
313 )
314{
315 PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
316
317 pMgmt->eAuthenMode = eAuthMode;
318 if ((eAuthMode == WMAC_AUTH_SHAREKEY) ||
319 (eAuthMode == WMAC_AUTH_AUTO)) {
320 pMgmt->bShareKeyAlgorithm = true;
321 } else {
322 pMgmt->bShareKeyAlgorithm = false;
323 }
324}
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341void
342VNTWIFIvSetEncryptionMode (
343 void *pMgmtHandle,
344 WMAC_ENCRYPTION_MODE eEncryptionMode
345 )
346{
347 PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
348
349 pMgmt->eEncryptionMode = eEncryptionMode;
350 if ((eEncryptionMode == WMAC_ENCRYPTION_WEPEnabled) ||
351 (eEncryptionMode == WMAC_ENCRYPTION_TKIPEnabled) ||
352 (eEncryptionMode == WMAC_ENCRYPTION_AESEnabled) ) {
353 pMgmt->bPrivacyInvoked = true;
354 } else {
355 pMgmt->bPrivacyInvoked = false;
356 }
357}
358
359
360
361bool
362VNTWIFIbConfigPhyMode (
363 void *pMgmtHandle,
364 CARD_PHY_TYPE ePhyType
365 )
366{
367 PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
368
369 if ((ePhyType != PHY_TYPE_AUTO) &&
370 (ePhyType != pMgmt->eCurrentPHYMode)) {
371 if (CARDbSetPhyParameter(pMgmt->pAdapter, ePhyType, 0, 0, NULL, NULL)==true) {
372 pMgmt->eCurrentPHYMode = ePhyType;
373 } else {
374 return(false);
375 }
376 }
377 pMgmt->eConfigPHYMode = ePhyType;
378 return(true);
379}
380
381
382void
383VNTWIFIbGetConfigPhyMode (
384 void *pMgmtHandle,
385 void *pePhyType
386 )
387{
388 PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
389
390 if ((pMgmt != NULL) && (pePhyType != NULL)) {
391 *(PCARD_PHY_TYPE)pePhyType = pMgmt->eConfigPHYMode;
392 }
393}
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427void
428VNTWIFIvQueryBSSList(void *pMgmtHandle, unsigned int *puBSSCount, void **pvFirstBSS)
429{
430 unsigned int ii = 0;
431 PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
432 PKnownBSS pBSS = NULL;
433 unsigned int uCount = 0;
434
435 *pvFirstBSS = NULL;
436
437 for (ii = 0; ii < MAX_BSS_NUM; ii++) {
438 pBSS = &(pMgmt->sBSSList[ii]);
439 if (!pBSS->bActive) {
440 continue;
441 }
442 if (*pvFirstBSS == NULL) {
443 *pvFirstBSS = &(pMgmt->sBSSList[ii]);
444 }
445 uCount++;
446 }
447 *puBSSCount = uCount;
448}
449
450
451
452
453void
454VNTWIFIvGetNextBSS (
455 void *pMgmtHandle,
456 void *pvCurrentBSS,
457 void **pvNextBSS
458 )
459{
460 PKnownBSS pBSS = (PKnownBSS) pvCurrentBSS;
461 PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
462
463 *pvNextBSS = NULL;
464
465 while (*pvNextBSS == NULL) {
466 pBSS++;
467 if (pBSS > &(pMgmt->sBSSList[MAX_BSS_NUM])) {
468 return;
469 }
470 if (pBSS->bActive == true) {
471 *pvNextBSS = pBSS;
472 return;
473 }
474 }
475}
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493void
494VNTWIFIvUpdateNodeTxCounter(
495 void *pMgmtHandle,
496 unsigned char *pbyDestAddress,
497 bool bTxOk,
498 unsigned short wRate,
499 unsigned char *pbyTxFailCount
500 )
501{
502 PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
503 unsigned int uNodeIndex = 0;
504 unsigned int ii;
505
506 if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) ||
507 (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) {
508 if (BSSDBbIsSTAInNodeDB(pMgmt, pbyDestAddress, &uNodeIndex) == false) {
509 return;
510 }
511 }
512 pMgmt->sNodeDBTable[uNodeIndex].uTxAttempts++;
513 if (bTxOk == true) {
514
515 pMgmt->sNodeDBTable[uNodeIndex].uTxOk[MAX_RATE]++;
516 pMgmt->sNodeDBTable[uNodeIndex].uTxOk[wRate]++;
517 } else {
518 pMgmt->sNodeDBTable[uNodeIndex].uTxFailures++;
519 }
520 pMgmt->sNodeDBTable[uNodeIndex].uTxRetry += pbyTxFailCount[MAX_RATE];
521 for(ii=0;ii<MAX_RATE;ii++) {
522 pMgmt->sNodeDBTable[uNodeIndex].uTxFail[ii] += pbyTxFailCount[ii];
523 }
524 return;
525}
526
527
528void
529VNTWIFIvGetTxRate(
530 void *pMgmtHandle,
531 unsigned char *pbyDestAddress,
532 unsigned short *pwTxDataRate,
533 unsigned char *pbyACKRate,
534 unsigned char *pbyCCKBasicRate,
535 unsigned char *pbyOFDMBasicRate
536 )
537{
538 PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
539 unsigned int uNodeIndex = 0;
540 unsigned short wTxDataRate = RATE_1M;
541 unsigned char byACKRate = RATE_1M;
542 unsigned char byCCKBasicRate = RATE_1M;
543 unsigned char byOFDMBasicRate = RATE_24M;
544 PWLAN_IE_SUPP_RATES pSupportRateIEs = NULL;
545 PWLAN_IE_SUPP_RATES pExtSupportRateIEs = NULL;
546
547
548 if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) ||
549 (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) {
550
551 if(BSSDBbIsSTAInNodeDB(pMgmt, pbyDestAddress, &uNodeIndex)) {
552 wTxDataRate = (pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate);
553 pSupportRateIEs = (PWLAN_IE_SUPP_RATES) (pMgmt->sNodeDBTable[uNodeIndex].abyCurrSuppRates);
554 pExtSupportRateIEs = (PWLAN_IE_SUPP_RATES) (pMgmt->sNodeDBTable[uNodeIndex].abyCurrExtSuppRates);
555 } else {
556 if (pMgmt->eCurrentPHYMode != PHY_TYPE_11A) {
557 wTxDataRate = RATE_2M;
558 } else {
559 wTxDataRate = RATE_24M;
560 }
561 pSupportRateIEs = (PWLAN_IE_SUPP_RATES) pMgmt->abyCurrSuppRates;
562 pExtSupportRateIEs = (PWLAN_IE_SUPP_RATES) pMgmt->abyCurrExtSuppRates;
563 }
564 } else {
565
566 wTxDataRate = (pMgmt->sNodeDBTable[0].wTxDataRate);
567#ifdef PLICE_DEBUG
568 printk(KERN_DEBUG "GetTxRate:AP MAC is %pM,TxRate is %d\n",
569 pMgmt->sNodeDBTable[0].abyMACAddr, wTxDataRate);
570#endif
571
572
573 pSupportRateIEs = (PWLAN_IE_SUPP_RATES) pMgmt->abyCurrSuppRates;
574 pExtSupportRateIEs = (PWLAN_IE_SUPP_RATES) pMgmt->abyCurrExtSuppRates;
575 }
576 byACKRate = VNTWIFIbyGetACKTxRate( (unsigned char) wTxDataRate,
577 pSupportRateIEs,
578 pExtSupportRateIEs
579 );
580 if (byACKRate > (unsigned char) wTxDataRate) {
581 byACKRate = (unsigned char) wTxDataRate;
582 }
583 byCCKBasicRate = VNTWIFIbyGetACKTxRate( RATE_11M,
584 pSupportRateIEs,
585 pExtSupportRateIEs
586 );
587 byOFDMBasicRate = VNTWIFIbyGetACKTxRate(RATE_54M,
588 pSupportRateIEs,
589 pExtSupportRateIEs
590 );
591 *pwTxDataRate = wTxDataRate;
592 *pbyACKRate = byACKRate;
593 *pbyCCKBasicRate = byCCKBasicRate;
594 *pbyOFDMBasicRate = byOFDMBasicRate;
595 return;
596}
597
598unsigned char
599VNTWIFIbyGetKeyCypher(
600 void *pMgmtHandle,
601 bool bGroupKey
602 )
603{
604 PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
605
606 if (bGroupKey == true) {
607 return (pMgmt->byCSSGK);
608 } else {
609 return (pMgmt->byCSSPK);
610 }
611}
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659bool
660VNTWIFIbSetPMKIDCache (
661 void *pMgmtObject,
662 unsigned long ulCount,
663 void *pPMKIDInfo
664 )
665{
666 PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject;
667
668 if (ulCount > MAX_PMKID_CACHE) {
669 return (false);
670 }
671 pMgmt->gsPMKIDCache.BSSIDInfoCount = ulCount;
672 memcpy(pMgmt->gsPMKIDCache.BSSIDInfo, pPMKIDInfo, (ulCount*sizeof(PMKIDInfo)));
673 return (true);
674}
675
676
677
678unsigned short
679VNTWIFIwGetMaxSupportRate(
680 void *pMgmtObject
681 )
682{
683 unsigned short wRate = RATE_54M;
684 PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject;
685
686 for(wRate = RATE_54M; wRate > RATE_1M; wRate--) {
687 if (pMgmt->sNodeDBTable[0].wSuppRate & (1<<wRate)) {
688 return (wRate);
689 }
690 }
691 if (pMgmt->eCurrentPHYMode == PHY_TYPE_11A) {
692 return (RATE_6M);
693 } else {
694 return (RATE_1M);
695 }
696}
697
698
699void
700VNTWIFIvSet11h (
701 void *pMgmtObject,
702 bool b11hEnable
703 )
704{
705 PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject;
706
707 pMgmt->b11hEnable = b11hEnable;
708}
709
710bool
711VNTWIFIbMeasureReport(
712 void *pMgmtObject,
713 bool bEndOfReport,
714 void *pvMeasureEID,
715 unsigned char byReportMode,
716 unsigned char byBasicMap,
717 unsigned char byCCAFraction,
718 unsigned char *pbyRPIs
719 )
720{
721 PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject;
722 unsigned char *pbyCurrentEID = (unsigned char *) (pMgmt->pCurrMeasureEIDRep);
723
724
725 if ((pvMeasureEID != NULL) &&
726 (pMgmt->uLengthOfRepEIDs < (WLAN_A3FR_MAXLEN - sizeof(MEASEURE_REP) - sizeof(WLAN_80211HDR_A3) - 3))
727 ) {
728 pMgmt->pCurrMeasureEIDRep->byElementID = WLAN_EID_MEASURE_REP;
729 pMgmt->pCurrMeasureEIDRep->len = 3;
730 pMgmt->pCurrMeasureEIDRep->byToken = ((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->byToken;
731 pMgmt->pCurrMeasureEIDRep->byMode = byReportMode;
732 pMgmt->pCurrMeasureEIDRep->byType = ((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->byType;
733 switch (pMgmt->pCurrMeasureEIDRep->byType) {
734 case MEASURE_TYPE_BASIC :
735 pMgmt->pCurrMeasureEIDRep->len += sizeof(MEASEURE_REP_BASIC);
736 memcpy( &(pMgmt->pCurrMeasureEIDRep->sRep.sBasic),
737 &(((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->sReq),
738 sizeof(MEASEURE_REQ));
739 pMgmt->pCurrMeasureEIDRep->sRep.sBasic.byMap = byBasicMap;
740 break;
741 case MEASURE_TYPE_CCA :
742 pMgmt->pCurrMeasureEIDRep->len += sizeof(MEASEURE_REP_CCA);
743 memcpy( &(pMgmt->pCurrMeasureEIDRep->sRep.sCCA),
744 &(((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->sReq),
745 sizeof(MEASEURE_REQ));
746 pMgmt->pCurrMeasureEIDRep->sRep.sCCA.byCCABusyFraction = byCCAFraction;
747 break;
748 case MEASURE_TYPE_RPI :
749 pMgmt->pCurrMeasureEIDRep->len += sizeof(MEASEURE_REP_RPI);
750 memcpy( &(pMgmt->pCurrMeasureEIDRep->sRep.sRPI),
751 &(((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->sReq),
752 sizeof(MEASEURE_REQ));
753 memcpy(pMgmt->pCurrMeasureEIDRep->sRep.sRPI.abyRPIdensity, pbyRPIs, 8);
754 break;
755 default :
756 break;
757 }
758 pbyCurrentEID += (2 + pMgmt->pCurrMeasureEIDRep->len);
759 pMgmt->uLengthOfRepEIDs += (2 + pMgmt->pCurrMeasureEIDRep->len);
760 pMgmt->pCurrMeasureEIDRep = (PWLAN_IE_MEASURE_REP) pbyCurrentEID;
761 }
762 if (bEndOfReport == true) {
763 IEEE11hbMSRRepTx(pMgmt);
764 }
765
766 return (true);
767}
768
769
770bool
771VNTWIFIbChannelSwitch(
772 void *pMgmtObject,
773 unsigned char byNewChannel
774 )
775{
776 PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject;
777
778
779 pMgmt->uCurrChannel = byNewChannel;
780 pMgmt->bSwitchChannel = false;
781
782 return true;
783}
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808