This repository has been archived by the owner on Oct 5, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cmm_profile.c
2341 lines (2012 loc) · 65.2 KB
/
cmm_profile.c
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
35
36
37
38
39
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
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
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
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
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
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
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2010, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************/
#include "rt_config.h"
#define ETH_MAC_ADDR_STR_LEN 17 // in format of xx:xx:xx:xx:xx:xx
// We assume the s1 is a sting, s2 is a memory space with 6 bytes. and content of s1 will be changed.
BOOLEAN rtstrmactohex(PSTRING s1, PSTRING s2)
{
int i = 0;
PSTRING ptokS = s1, ptokE = s1;
if (strlen(s1) != ETH_MAC_ADDR_STR_LEN)
return FALSE;
while((*ptokS) != '\0')
{
if((ptokE = strchr(ptokS, ':')) != NULL)
*ptokE++ = '\0';
if ((strlen(ptokS) != 2) || (!isxdigit(*ptokS)) || (!isxdigit(*(ptokS+1))))
break; // fail
AtoH(ptokS, (PUCHAR)&s2[i++], 1);
ptokS = ptokE;
if (ptokS == NULL)
break;
if (i == 6)
break; // parsing finished
}
return ( i == 6 ? TRUE : FALSE);
}
// we assume the s1 and s2 both are strings.
BOOLEAN rtstrcasecmp(PSTRING s1, PSTRING s2)
{
PSTRING p1 = s1, p2 = s2;
if (strlen(s1) != strlen(s2))
return FALSE;
while(*p1 != '\0')
{
if((*p1 != *p2) && ((*p1 ^ *p2) != 0x20))
return FALSE;
p1++;
p2++;
}
return TRUE;
}
// we assume the s1 (buffer) and s2 (key) both are strings.
PSTRING rtstrstruncasecmp(PSTRING s1, PSTRING s2)
{
INT l1, l2, i;
char temp1, temp2;
l2 = strlen(s2);
if (!l2)
return (char *) s1;
l1 = strlen(s1);
while (l1 >= l2)
{
l1--;
for(i=0; i<l2; i++)
{
temp1 = *(s1+i);
temp2 = *(s2+i);
if (('a' <= temp1) && (temp1 <= 'z'))
temp1 = 'A'+(temp1-'a');
if (('a' <= temp2) && (temp2 <= 'z'))
temp2 = 'A'+(temp2-'a');
if (temp1 != temp2)
break;
}
if (i == l2)
return (char *) s1;
s1++;
}
return NULL; // not found
}
//add by kathy
/**
* strstr - Find the first substring in a %NUL terminated string
* @s1: The string to be searched
* @s2: The string to search for
*/
PSTRING rtstrstr(PSTRING s1,const PSTRING s2)
{
INT l1, l2;
l2 = strlen(s2);
if (!l2)
return s1;
l1 = strlen(s1);
while (l1 >= l2)
{
l1--;
if (!memcmp(s1,s2,l2))
return s1;
s1++;
}
return NULL;
}
/**
* rstrtok - Split a string into tokens
* @s: The string to be searched
* @ct: The characters to search for
* * WARNING: strtok is deprecated, use strsep instead. However strsep is not compatible with old architecture.
*/
PSTRING __rstrtok;
PSTRING rstrtok(PSTRING s,const PSTRING ct)
{
PSTRING sbegin, send;
sbegin = s ? s : __rstrtok;
if (!sbegin)
{
return NULL;
}
sbegin += strspn(sbegin,ct);
if (*sbegin == '\0')
{
__rstrtok = NULL;
return( NULL );
}
send = strpbrk( sbegin, ct);
if (send && *send != '\0')
*send++ = '\0';
__rstrtok = send;
return (sbegin);
}
/**
* delimitcnt - return the count of a given delimiter in a given string.
* @s: The string to be searched.
* @ct: The delimiter to search for.
* Notice : We suppose the delimiter is a single-char string(for example : ";").
*/
INT delimitcnt(PSTRING s,PSTRING ct)
{
INT count = 0;
/* point to the beginning of the line */
PSTRING token = s;
for ( ;; )
{
token = strpbrk(token, ct); /* search for delimiters */
if ( token == NULL )
{
/* advanced to the terminating null character */
break;
}
/* skip the delimiter */
++token;
/*
* Print the found text: use len with %.*s to specify field width.
*/
/* accumulate delimiter count */
++count;
}
return count;
}
/*
* converts the Internet host address from the standard numbers-and-dots notation
* into binary data.
* returns nonzero if the address is valid, zero if not.
*/
int rtinet_aton(PSTRING cp, unsigned int *addr)
{
unsigned int val;
int base, n;
STRING c;
unsigned int parts[4];
unsigned int *pp = parts;
for (;;)
{
/*
* Collect number up to ``.''.
* Values are specified as for C:
* 0x=hex, 0=octal, other=decimal.
*/
val = 0;
base = 10;
if (*cp == '0')
{
if (*++cp == 'x' || *cp == 'X')
base = 16, cp++;
else
base = 8;
}
while ((c = *cp) != '\0')
{
if (isdigit((unsigned char) c))
{
val = (val * base) + (c - '0');
cp++;
continue;
}
if (base == 16 && isxdigit((unsigned char) c))
{
val = (val << 4) +
(c + 10 - (islower((unsigned char) c) ? 'a' : 'A'));
cp++;
continue;
}
break;
}
if (*cp == '.')
{
/*
* Internet format: a.b.c.d a.b.c (with c treated as 16-bits)
* a.b (with b treated as 24 bits)
*/
if (pp >= parts + 3 || val > 0xff)
return 0;
*pp++ = val, cp++;
}
else
break;
}
/*
* Check for trailing junk.
*/
while (*cp)
if (!isspace((unsigned char) *cp++))
return 0;
/*
* Concoct the address according to the number of parts specified.
*/
n = pp - parts + 1;
switch (n)
{
case 1: /* a -- 32 bits */
break;
case 2: /* a.b -- 8.24 bits */
if (val > 0xffffff)
return 0;
val |= parts[0] << 24;
break;
case 3: /* a.b.c -- 8.8.16 bits */
if (val > 0xffff)
return 0;
val |= (parts[0] << 24) | (parts[1] << 16);
break;
case 4: /* a.b.c.d -- 8.8.8.8 bits */
if (val > 0xff)
return 0;
val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
break;
}
*addr = htonl(val);
return 1;
}
/*
========================================================================
Routine Description:
Find key section for Get key parameter.
Arguments:
buffer Pointer to the buffer to start find the key section
section the key of the secion to be find
Return Value:
NULL Fail
Others Success
========================================================================
*/
PSTRING RTMPFindSection(
IN PSTRING buffer)
{
STRING temp_buf[32];
PSTRING ptr;
strcpy(temp_buf, "Default");
if((ptr = rtstrstr(buffer, temp_buf)) != NULL)
return (ptr+strlen("\n"));
else
return NULL;
}
/*
========================================================================
Routine Description:
Get key parameter.
Arguments:
key Pointer to key string
dest Pointer to destination
destsize The datasize of the destination
buffer Pointer to the buffer to start find the key
bTrimSpace Set true if you want to strip the space character of the result pattern
Return Value:
TRUE Success
FALSE Fail
Note:
This routine get the value with the matched key (case case-sensitive)
For SSID and security key related parameters, we SHALL NOT trim the space(' ') character.
========================================================================
*/
INT RTMPGetKeyParameter(
IN PSTRING key,
OUT PSTRING dest,
IN INT destsize,
IN PSTRING buffer,
IN BOOLEAN bTrimSpace)
{
PSTRING pMemBuf, temp_buf1 = NULL, temp_buf2 = NULL;
PSTRING start_ptr, end_ptr;
PSTRING ptr;
PSTRING offset = NULL;
INT len, keyLen;
keyLen = strlen(key);
os_alloc_mem(NULL, (PUCHAR *)&pMemBuf, MAX_PARAM_BUFFER_SIZE * 2);
if (pMemBuf == NULL)
return (FALSE);
memset(pMemBuf, 0, MAX_PARAM_BUFFER_SIZE * 2);
temp_buf1 = pMemBuf;
temp_buf2 = (PSTRING)(pMemBuf + MAX_PARAM_BUFFER_SIZE);
//find section
if((offset = RTMPFindSection(buffer)) == NULL)
{
os_free_mem(NULL, (PUCHAR)pMemBuf);
return (FALSE);
}
strcpy(temp_buf1, "\n");
strcat(temp_buf1, key);
strcat(temp_buf1, "=");
//search key
if((start_ptr=rtstrstr(offset, temp_buf1)) == NULL)
{
os_free_mem(NULL, (PUCHAR)pMemBuf);
return (FALSE);
}
start_ptr += strlen("\n");
if((end_ptr = rtstrstr(start_ptr, "\n"))==NULL)
end_ptr = start_ptr+strlen(start_ptr);
if (end_ptr<start_ptr)
{
os_free_mem(NULL, (PUCHAR)pMemBuf);
return (FALSE);
}
NdisMoveMemory(temp_buf2, start_ptr, end_ptr-start_ptr);
temp_buf2[end_ptr-start_ptr]='\0';
if((start_ptr=rtstrstr(temp_buf2, "=")) == NULL)
{
os_free_mem(NULL, (PUCHAR)pMemBuf);
return (FALSE);
}
ptr = (start_ptr +1);
//trim special characters, i.e., TAB or space
while(*start_ptr != 0x00)
{
if( ((*ptr == ' ') && bTrimSpace) || (*ptr == '\t') )
ptr++;
else
break;
}
len = strlen(start_ptr);
memset(dest, 0x00, destsize);
strncpy(dest, ptr, ((len >= destsize) ? destsize: len));
os_free_mem(NULL, (PUCHAR)pMemBuf);
return TRUE;
}
/*
========================================================================
Routine Description:
Get multiple key parameter.
Arguments:
key Pointer to key string
dest Pointer to destination
destsize The datasize of the destination
buffer Pointer to the buffer to start find the key
Return Value:
TRUE Success
FALSE Fail
Note:
This routine get the value with the matched key (case case-sensitive)
========================================================================
*/
INT RTMPGetKeyParameterWithOffset(
IN PSTRING key,
OUT PSTRING dest,
OUT USHORT *end_offset,
IN INT destsize,
IN PSTRING buffer,
IN BOOLEAN bTrimSpace)
{
PSTRING temp_buf1 = NULL;
PSTRING temp_buf2 = NULL;
PSTRING start_ptr;
PSTRING end_ptr;
PSTRING ptr;
PSTRING offset = 0;
INT len;
if (*end_offset >= MAX_INI_BUFFER_SIZE)
return (FALSE);
os_alloc_mem(NULL, (PUCHAR *)&temp_buf1, MAX_PARAM_BUFFER_SIZE);
if(temp_buf1 == NULL)
return (FALSE);
os_alloc_mem(NULL, (PUCHAR *)&temp_buf2, MAX_PARAM_BUFFER_SIZE);
if(temp_buf2 == NULL)
{
os_free_mem(NULL, (PUCHAR)temp_buf1);
return (FALSE);
}
//find section
if(*end_offset == 0)
{
if ((offset = RTMPFindSection(buffer)) == NULL)
{
os_free_mem(NULL, (PUCHAR)temp_buf1);
os_free_mem(NULL, (PUCHAR)temp_buf2);
return (FALSE);
}
}
else
offset = buffer + (*end_offset);
strcpy(temp_buf1, "\n");
strcat(temp_buf1, key);
strcat(temp_buf1, "=");
//search key
if((start_ptr=rtstrstr(offset, temp_buf1))==NULL)
{
os_free_mem(NULL, (PUCHAR)temp_buf1);
os_free_mem(NULL, (PUCHAR)temp_buf2);
return (FALSE);
}
start_ptr+=strlen("\n");
if((end_ptr=rtstrstr(start_ptr, "\n"))==NULL)
end_ptr=start_ptr+strlen(start_ptr);
if (end_ptr<start_ptr)
{
os_free_mem(NULL, (PUCHAR)temp_buf1);
os_free_mem(NULL, (PUCHAR)temp_buf2);
return (FALSE);
}
*end_offset = end_ptr - buffer;
NdisMoveMemory(temp_buf2, start_ptr, end_ptr-start_ptr);
temp_buf2[end_ptr-start_ptr]='\0';
len = strlen(temp_buf2);
strcpy(temp_buf1, temp_buf2);
if((start_ptr=rtstrstr(temp_buf1, "=")) == NULL)
{
os_free_mem(NULL, (PUCHAR)temp_buf1);
os_free_mem(NULL, (PUCHAR)temp_buf2);
return (FALSE);
}
strcpy(temp_buf2, start_ptr+1);
ptr = temp_buf2;
//trim space or tab
while(*ptr != 0x00)
{
if((bTrimSpace && (*ptr == ' ')) || (*ptr == '\t') )
ptr++;
else
break;
}
len = strlen(ptr);
memset(dest, 0x00, destsize);
strncpy(dest, ptr, len >= destsize ? destsize: len);
os_free_mem(NULL, (PUCHAR)temp_buf1);
os_free_mem(NULL, (PUCHAR)temp_buf2);
return TRUE;
}
#ifdef CONFIG_STA_SUPPORT
inline void RTMPSetSTADefKeyId(RTMP_ADAPTER *pAd, ULONG KeyIdx)
{
if((KeyIdx >= 1 ) && (KeyIdx <= 4))
pAd->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1);
else
pAd->StaCfg.DefaultKeyId = 0;
}
#endif // CONFIG_STA_SUPPORT //
static int rtmp_parse_key_buffer_from_file(IN PRTMP_ADAPTER pAd,IN PSTRING buffer,IN ULONG KeyType,IN INT BSSIdx,IN INT KeyIdx)
{
PSTRING keybuff;
//INT i = BSSIdx, idx = KeyIdx, retVal;
ULONG KeyLen;
//UCHAR CipherAlg = CIPHER_WEP64;
CIPHER_KEY *pSharedKey;
keybuff = buffer;
KeyLen = strlen(keybuff);
pSharedKey = &pAd->SharedKey[BSSIdx][KeyIdx];
if(((KeyType != 0) && (KeyType != 1)) ||
((KeyType == 0) && (KeyLen != 10) && (KeyLen != 26)) ||
((KeyType== 1) && (KeyLen != 5) && (KeyLen != 13)))
{
DBGPRINT(RT_DEBUG_WARN, ("Key%dStr is Invalid key length(%ld) or Type(%ld)\n",
KeyIdx+1, KeyLen, KeyType));
return FALSE;
}
else
{
return RT_CfgSetWepKey(pAd, buffer, pSharedKey, KeyIdx);
}
}
static void rtmp_read_key_parms_from_file(IN PRTMP_ADAPTER pAd, PSTRING tmpbuf, PSTRING buffer)
{
STRING tok_str[16];
PSTRING macptr;
INT i = 0, idx;
ULONG KeyType[MAX_MBSSID_NUM];
ULONG KeyIdx;
NdisZeroMemory(KeyType, sizeof(KeyType));
//DefaultKeyID
if(RTMPGetKeyParameter("DefaultKeyID", tmpbuf, 25, buffer, TRUE))
{
#ifdef CONFIG_STA_SUPPORT
IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
KeyIdx = simple_strtol(tmpbuf, 0, 10);
RTMPSetSTADefKeyId(pAd, KeyIdx);
DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyID(0~3)=%d\n", pAd->StaCfg.DefaultKeyId));
}
#endif // CONFIG_STA_SUPPORT //
}
for (idx = 0; idx < 4; idx++)
{
sprintf(tok_str, "Key%dType", idx + 1);
//Key1Type
if (RTMPGetKeyParameter(tok_str, tmpbuf, 128, buffer, TRUE))
{
for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
{
/*
do sanity check for KeyType length;
or in station mode, the KeyType length > 1,
the code will overwrite the stack of caller
(RTMPSetProfileParameters) and cause srcbuf = NULL
*/
if (i < MAX_MBSSID_NUM)
KeyType[i] = simple_strtol(macptr, 0, 10);
}
#ifdef CONFIG_STA_SUPPORT
IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
sprintf(tok_str, "Key%dStr", idx + 1);
if (RTMPGetKeyParameter(tok_str, tmpbuf, 128, buffer, FALSE))
{
rtmp_parse_key_buffer_from_file(pAd, tmpbuf, KeyType[BSS0], BSS0, idx);
}
}
#endif // CONFIG_STA_SUPPORT //
}
}
}
#ifdef CONFIG_STA_SUPPORT
static void rtmp_read_sta_wmm_parms_from_file(IN PRTMP_ADAPTER pAd, char *tmpbuf, char *buffer)
{
PSTRING macptr;
INT i=0;
BOOLEAN bWmmEnable = FALSE;
//WmmCapable
if(RTMPGetKeyParameter("WmmCapable", tmpbuf, 32, buffer, TRUE))
{
if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
{
pAd->CommonCfg.bWmmCapable = TRUE;
bWmmEnable = TRUE;
}
else //Disable
{
pAd->CommonCfg.bWmmCapable = FALSE;
}
DBGPRINT(RT_DEBUG_TRACE, ("WmmCapable=%d\n", pAd->CommonCfg.bWmmCapable));
}
#ifdef QOS_DLS_SUPPORT
//DLSCapable
if(RTMPGetKeyParameter("DLSCapable", tmpbuf, 32, buffer, TRUE))
{
if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
{
pAd->CommonCfg.bDLSCapable = TRUE;
}
else //Disable
{
pAd->CommonCfg.bDLSCapable = FALSE;
}
DBGPRINT(RT_DEBUG_TRACE, ("bDLSCapable=%d\n", pAd->CommonCfg.bDLSCapable));
}
#endif // QOS_DLS_SUPPORT //
//AckPolicy for AC_BK, AC_BE, AC_VI, AC_VO
if(RTMPGetKeyParameter("AckPolicy", tmpbuf, 32, buffer, TRUE))
{
for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
{
pAd->CommonCfg.AckPolicy[i] = (UCHAR)simple_strtol(macptr, 0, 10);
DBGPRINT(RT_DEBUG_TRACE, ("AckPolicy[%d]=%d\n", i, pAd->CommonCfg.AckPolicy[i]));
}
}
if (bWmmEnable)
{
//APSDCapable
if(RTMPGetKeyParameter("APSDCapable", tmpbuf, 10, buffer, TRUE))
{
if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
pAd->CommonCfg.bAPSDCapable = TRUE;
else
pAd->CommonCfg.bAPSDCapable = FALSE;
DBGPRINT(RT_DEBUG_TRACE, ("APSDCapable=%d\n", pAd->CommonCfg.bAPSDCapable));
}
//MaxSPLength
if(RTMPGetKeyParameter("MaxSPLength", tmpbuf, 10, buffer, TRUE))
{
pAd->CommonCfg.MaxSPLength = simple_strtol(tmpbuf, 0, 10);
DBGPRINT(RT_DEBUG_TRACE, ("MaxSPLength=%d\n", pAd->CommonCfg.MaxSPLength));
}
//APSDAC for AC_BE, AC_BK, AC_VI, AC_VO
if(RTMPGetKeyParameter("APSDAC", tmpbuf, 32, buffer, TRUE))
{
BOOLEAN apsd_ac[4];
for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
{
apsd_ac[i] = (BOOLEAN)simple_strtol(macptr, 0, 10);
DBGPRINT(RT_DEBUG_TRACE, ("APSDAC%d %d\n", i, apsd_ac[i]));
}
pAd->CommonCfg.bAPSDAC_BE = apsd_ac[0];
pAd->CommonCfg.bAPSDAC_BK = apsd_ac[1];
pAd->CommonCfg.bAPSDAC_VI = apsd_ac[2];
pAd->CommonCfg.bAPSDAC_VO = apsd_ac[3];
pAd->CommonCfg.bACMAPSDTr[0] = apsd_ac[0];
pAd->CommonCfg.bACMAPSDTr[1] = apsd_ac[1];
pAd->CommonCfg.bACMAPSDTr[2] = apsd_ac[2];
pAd->CommonCfg.bACMAPSDTr[3] = apsd_ac[3];
}
}
}
#ifdef XLINK_SUPPORT
static void rtmp_get_psp_xlink_mode_from_file(IN PRTMP_ADAPTER pAd, char *tmpbuf, char *buffer)
{
UINT32 Value = 0;
// Xlink Mode
if (RTMPGetKeyParameter("PSP_XLINK_MODE", tmpbuf, 32, buffer, TRUE))
{
if(simple_strtol(tmpbuf, 0, 10) != 0) // enable
{
pAd->StaCfg.PSPXlink = TRUE;
}
else // disable
{
pAd->StaCfg.PSPXlink = FALSE;
}
if (pAd->StaCfg.PSPXlink)
Value = PSPXLINK;
else
Value = STANORMAL;
RTMP_IO_WRITE32(pAd, RX_FILTR_CFG, Value);
DBGPRINT(RT_DEBUG_TRACE, ("PSP_XLINK_MODE=%d\n", pAd->StaCfg.PSPXlink));
}
}
#endif // XLINK_SUPPORT //
#endif // CONFIG_STA_SUPPORT //
#ifdef DOT11_N_SUPPORT
static void HTParametersHook(
IN PRTMP_ADAPTER pAd,
IN PSTRING pValueStr,
IN PSTRING pInput)
{
long Value;
if (RTMPGetKeyParameter("HT_PROTECT", pValueStr, 25, pInput, TRUE))
{
Value = simple_strtol(pValueStr, 0, 10);
if (Value == 0)
{
pAd->CommonCfg.bHTProtect = FALSE;
}
else
{
pAd->CommonCfg.bHTProtect = TRUE;
}
DBGPRINT(RT_DEBUG_TRACE, ("HT: Protection = %s\n", (Value==0) ? "Disable" : "Enable"));
}
if (RTMPGetKeyParameter("HT_MIMOPSMode", pValueStr, 25, pInput, TRUE))
{
Value = simple_strtol(pValueStr, 0, 10);
if (Value > MMPS_ENABLE)
{
pAd->CommonCfg.BACapability.field.MMPSmode = MMPS_ENABLE;
}
else
{
//TODO: add mimo power saving mechanism
pAd->CommonCfg.BACapability.field.MMPSmode = MMPS_ENABLE;
//pAd->CommonCfg.BACapability.field.MMPSmode = Value;
}
DBGPRINT(RT_DEBUG_TRACE, ("HT: MIMOPS Mode = %d\n", (INT) Value));
}
if (RTMPGetKeyParameter("HT_BADecline", pValueStr, 25, pInput, TRUE))
{
Value = simple_strtol(pValueStr, 0, 10);
if (Value == 0)
{
pAd->CommonCfg.bBADecline = FALSE;
}
else
{
pAd->CommonCfg.bBADecline = TRUE;
}
DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Decline = %s\n", (Value==0) ? "Disable" : "Enable"));
}
if (RTMPGetKeyParameter("HT_AutoBA", pValueStr, 25, pInput, TRUE))
{
Value = simple_strtol(pValueStr, 0, 10);
if (Value == 0)
{
pAd->CommonCfg.BACapability.field.AutoBA = FALSE;
pAd->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
}
else
{
pAd->CommonCfg.BACapability.field.AutoBA = TRUE;
pAd->CommonCfg.BACapability.field.Policy = IMMED_BA;
}
pAd->CommonCfg.REGBACapability.field.AutoBA = pAd->CommonCfg.BACapability.field.AutoBA;
pAd->CommonCfg.REGBACapability.field.Policy = pAd->CommonCfg.BACapability.field.Policy;
DBGPRINT(RT_DEBUG_TRACE, ("HT: Auto BA = %s\n", (Value==0) ? "Disable" : "Enable"));
}
// Tx_+HTC frame
if (RTMPGetKeyParameter("HT_HTC", pValueStr, 25, pInput, TRUE))
{
Value = simple_strtol(pValueStr, 0, 10);
if (Value == 0)
{
pAd->HTCEnable = FALSE;
}
else
{
pAd->HTCEnable = TRUE;
}
DBGPRINT(RT_DEBUG_TRACE, ("HT: Tx +HTC frame = %s\n", (Value==0) ? "Disable" : "Enable"));
}
// Reverse Direction Mechanism
if (RTMPGetKeyParameter("HT_RDG", pValueStr, 25, pInput, TRUE))
{
Value = simple_strtol(pValueStr, 0, 10);
if (Value == 0)
{
pAd->CommonCfg.bRdg = FALSE;
}
else
{
pAd->HTCEnable = TRUE;
pAd->CommonCfg.bRdg = TRUE;
}
DBGPRINT(RT_DEBUG_TRACE, ("HT: RDG = %s\n", (Value==0) ? "Disable" : "Enable(+HTC)"));
}
// Tx A-MSUD ?
if (RTMPGetKeyParameter("HT_AMSDU", pValueStr, 25, pInput, TRUE))
{
Value = simple_strtol(pValueStr, 0, 10);
if (Value == 0)
{
pAd->CommonCfg.BACapability.field.AmsduEnable = FALSE;
}
else
{
pAd->CommonCfg.BACapability.field.AmsduEnable = TRUE;
}
DBGPRINT(RT_DEBUG_TRACE, ("HT: Tx A-MSDU = %s\n", (Value==0) ? "Disable" : "Enable"));
}
// MPDU Density
if (RTMPGetKeyParameter("HT_MpduDensity", pValueStr, 25, pInput, TRUE))
{
Value = simple_strtol(pValueStr, 0, 10);
if (Value <=7 && Value >= 0)
{
pAd->CommonCfg.BACapability.field.MpduDensity = Value;
DBGPRINT(RT_DEBUG_TRACE, ("HT: MPDU Density = %d\n", (INT) Value));
}
else
{
pAd->CommonCfg.BACapability.field.MpduDensity = 4;
DBGPRINT(RT_DEBUG_TRACE, ("HT: MPDU Density = %d (Default)\n", 4));
}
}
// Max Rx BA Window Size
if (RTMPGetKeyParameter("HT_BAWinSize", pValueStr, 25, pInput, TRUE))
{
Value = simple_strtol(pValueStr, 0, 10);
if (Value >=1 && Value <= 64)
{
pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = Value;
pAd->CommonCfg.BACapability.field.RxBAWinLimit = Value;
DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Windw Size = %d\n", (INT) Value));
}
else
{
pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = 64;
pAd->CommonCfg.BACapability.field.RxBAWinLimit = 64;
DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Windw Size = 64 (Defualt)\n"));
}
}
// Guard Interval
if (RTMPGetKeyParameter("HT_GI", pValueStr, 25, pInput, TRUE))
{
Value = simple_strtol(pValueStr, 0, 10);
if (Value == GI_400)
{
pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_400;
}
else
{
pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_800;
}
DBGPRINT(RT_DEBUG_TRACE, ("HT: Guard Interval = %s\n", (Value==GI_400) ? "400" : "800" ));
}
// HT Operation Mode : Mixed Mode , Green Field
if (RTMPGetKeyParameter("HT_OpMode", pValueStr, 25, pInput, TRUE))
{
Value = simple_strtol(pValueStr, 0, 10);
if (Value == HTMODE_GF)
{
pAd->CommonCfg.RegTransmitSetting.field.HTMODE = HTMODE_GF;
}
else
{
pAd->CommonCfg.RegTransmitSetting.field.HTMODE = HTMODE_MM;
}
DBGPRINT(RT_DEBUG_TRACE, ("HT: Operate Mode = %s\n", (Value==HTMODE_GF) ? "Green Field" : "Mixed Mode" ));
}
// Fixed Tx mode : CCK, OFDM
if (RTMPGetKeyParameter("FixedTxMode", pValueStr, 25, pInput, TRUE))
{
#ifdef CONFIG_STA_SUPPORT
IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode =
RT_CfgSetFixedTxPhyMode(pValueStr);
DBGPRINT(RT_DEBUG_TRACE, ("Fixed Tx Mode = %d\n",
pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode));
}
#endif // CONFIG_STA_SUPPORT //
}