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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
|
/*
** Id: tdls.c#1
*/
/*! \file tdls.c
\brief This file includes IEEE802.11z TDLS support.
*/
/*
** Log: tdls.c
*
* 11 13 2013 vend_samp.lin
* NULL
* Initial version.
*/
/*******************************************************************************
* C O M P I L E R F L A G S
********************************************************************************
*/
/*******************************************************************************
* E X T E R N A L R E F E R E N C E S
********************************************************************************
*/
#include "precomp.h"
#if (CFG_SUPPORT_TDLS == 1)
#include "gl_wext.h"
#include "tdls.h"
#include "gl_cfg80211.h"
#include <uapi/linux/nl80211.h>
/*******************************************************************************
* C O N S T A N T S
********************************************************************************
*/
/*******************************************************************************
* F U N C T I O N D E C L A R A T I O N S
********************************************************************************
*/
static VOID TdlsCmdTestRxIndicatePkts(GLUE_INFO_T *prGlueInfo, struct sk_buff *prSkb);
#if TDLS_CFG_CMD_TEST
static void TdlsCmdTestAddPeer(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen);
static void TdlsCmdTestChSwProhibitedBitSet(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen);
static void TdlsCmdTestChSwReqRecv(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen);
static void TdlsCmdTestChSwRspRecv(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen);
static void TdlsCmdTestChSwTimeoutSkip(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen);
static void TdlsCmdTestDataContSend(GLUE_INFO_T *prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen);
static void TdlsCmdTestDataRecv(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen);
static void TdlsCmdTestDataSend(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen);
static void TdlsCmdTestDelay(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen);
static void TdlsCmdTestDiscoveryReqRecv(GLUE_INFO_T *prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen);
static void TdlsCmdTestKeepAliveSkip(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen);
static void TdlsCmdTestProhibitedBitSet(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen);
static void TdlsCmdTestPtiReqRecv(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen);
static void TdlsCmdTestPtiRspRecv(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen);
static void TdlsCmdTestPtiTxDoneFail(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen);
static void TdlsCmdTestRvFrame(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen);
static void TdlsCmdTestSetupConfirmRecv(GLUE_INFO_T *prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen);
static void TdlsCmdTestSetupReqRecv(GLUE_INFO_T *prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen);
static void TdlsCmdTestSetupRspRecv(GLUE_INFO_T *prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen);
static void TdlsCmdTestScanCtrl(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen);
static void TdlsCmdTestTearDownRecv(GLUE_INFO_T *prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen);
static void TdlsCmdTestTxFailSkip(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen);
static void TdlsCmdTestTxTdlsFrame(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen);
static void TdlsCmdTestTxFrame(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen);
static TDLS_STATUS
TdlsCmdTestTxFmeSetupReqBufTranslate(UINT_8 *pCmdBuf, UINT_32 u4BufLen, PARAM_CUSTOM_TDLS_CMD_STRUCT_T *prCmd);
static void TdlsCmdTestUpdatePeer(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen);
static void TdlsCmdTestNullRecv(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen);
static VOID TdlsTimerTestDataContSend(ADAPTER_T *prAdapter, UINT_32 u4Param);
static TDLS_STATUS
TdlsTestChStReqRecv(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen);
static TDLS_STATUS
TdlsTestChStRspRecv(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen);
static TDLS_STATUS
TdlsTestFrameSend(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen);
static TDLS_STATUS
TdlsTestNullRecv(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen);
static TDLS_STATUS
TdlsTestPtiReqRecv(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen);
static TDLS_STATUS
TdlsTestPtiRspRecv(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen);
static TDLS_STATUS
TdlsTestTearDownRecv(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen);
static TDLS_STATUS
TdlsTestDataRecv(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen);
static TDLS_STATUS
TdlsTestPtiTxFail(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen);
static TDLS_STATUS
TdlsTestTdlsFrameSend(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen);
static TDLS_STATUS
TdlsTestTxFailSkip(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen);
static TDLS_STATUS
TdlsTestKeepAliveSkip(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen);
static TDLS_STATUS
TdlsTestChSwTimeoutSkip(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen);
static TDLS_STATUS
TdlsTestScanSkip(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen);
static TDLS_STATUS
TdlsChSwConf(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen);
static void TdlsCmdChSwConf(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen);
static void TdlsCmdInfoDisplay(GLUE_INFO_T *prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen);
static void TdlsCmdKeyInfoDisplay(GLUE_INFO_T *prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen);
static void TdlsCmdMibParamUpdate(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen);
static void TdlsCmdSetupConf(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen);
static void TdlsCmdUapsdConf(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen);
static TDLS_STATUS
TdlsInfoDisplay(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen);
static TDLS_STATUS
TdlsKeyInfoDisplay(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen);
static VOID
TdlsLinkHistoryRecord(GLUE_INFO_T *prGlueInfo,
BOOLEAN fgIsTearDown,
UINT8 *pucPeerMac, BOOLEAN fgIsFromUs, UINT16 u2ReasonCode, VOID *prOthers);
static VOID
TdlsLinkHistoryRecordUpdate(GLUE_INFO_T *prGlueInfo,
UINT8 *pucPeerMac, TDLS_EVENT_HOST_SUBID_SPECIFIC_FRAME eFmeStatus, VOID *pInfo);
static TDLS_STATUS
TdlsMibParamUpdate(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen);
static TDLS_STATUS
TdlsSetupConf(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen);
static TDLS_STATUS
TdlsUapsdConf(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen);
static void TdlsEventStatistics(GLUE_INFO_T *prGlueInfo, UINT8 *prInBuf, UINT32 u4InBufLen);
static void TdlsEventTearDown(GLUE_INFO_T *prGlueInfo, UINT8 *prInBuf, UINT32 u4InBufLen);
#endif /* TDLS_CFG_CMD_TEST */
/*******************************************************************************
* P R I V A T E D A T A
********************************************************************************
*/
static BOOLEAN fgIsPtiTimeoutSkip = FALSE;
/*******************************************************************************
* P R I V A T E F U N C T I O N S
********************************************************************************
*/
/*----------------------------------------------------------------------------*/
/*!
* \brief This routine is called to indicate packets to upper layer.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prSkb A pointer to the received packet
*
* \retval None
*
*/
/*----------------------------------------------------------------------------*/
static VOID TdlsCmdTestRxIndicatePkts(GLUE_INFO_T *prGlueInfo, struct sk_buff *prSkb)
{
struct net_device *prNetDev;
/* init */
prNetDev = prGlueInfo->prDevHandler;
prGlueInfo->rNetDevStats.rx_bytes += prSkb->len;
prGlueInfo->rNetDevStats.rx_packets++;
/* pass to upper layer */
prNetDev->last_rx = jiffies;
prSkb->protocol = eth_type_trans(prSkb, prNetDev);
prSkb->dev = prNetDev;
if (!in_interrupt())
netif_rx_ni(prSkb); /* only in non-interrupt context */
else
netif_rx(prSkb);
}
#if TDLS_CFG_CMD_TEST
#define LR_TDLS_FME_FIELD_FILL(__Len) \
do { \
pPkt += __Len; \
u4PktLen += __Len; \
} while (0)
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to add a TDLS peer.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
* EX: iwpriv wlan0 set_str_cmd 0_2_[Responder MAC]
iwpriv wlan0 set_str_cmd 0_2_00:11:22:33:44:01
*/
/*----------------------------------------------------------------------------*/
static void TdlsCmdTestAddPeer(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen)
{
PARAM_CUSTOM_TDLS_CMD_STRUCT_T rCmd;
struct wireless_dev *prWdev;
/* reset */
kalMemZero(&rCmd, sizeof(rCmd));
/* parse arguments */
CmdStringMacParse(prInBuf, &prInBuf, &u4InBufLen, rCmd.arRspAddr);
/* init */
rCmd.rPeerInfo.supported_rates = NULL;
rCmd.rPeerInfo.ht_capa = &rCmd.rHtCapa;
rCmd.rPeerInfo.vht_capa = &rCmd.rVhtCapa; /* LINUX_KERNEL_VERSION >= 3.10.0 */
rCmd.rPeerInfo.sta_flags_set = BIT(NL80211_STA_FLAG_TDLS_PEER);
/* send command to wifi task to handle */
prWdev = prGlueInfo->prDevHandler->ieee80211_ptr;
mtk_cfg80211_add_station(prWdev->wiphy, (void *)0x1, rCmd.arRspAddr, &rCmd.rPeerInfo);
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to simulate to set the TDLS Prohibited bit.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
* EX: iwpriv wlan0 set_str_cmd 0_16_[Enable/Disable]_[Set/Clear]
iwpriv wlan0 set_str_cmd 0_16_1_1
*/
/*----------------------------------------------------------------------------*/
static void TdlsCmdTestChSwProhibitedBitSet(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen)
{
TDLS_CMD_CORE_T rCmd;
/* parse arguments */
kalMemZero(rCmd.aucPeerMac, sizeof(rCmd.aucPeerMac));
rCmd.Content.rCmdProhibit.fgIsEnable = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
rCmd.Content.rCmdProhibit.fgIsSet = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
DBGLOG(TDLS, INFO, "%s: fgIsEnable = %d\n", __func__, rCmd.Content.rCmdProhibit.fgIsEnable);
/* command to do this */
flgTdlsTestExtCapElm = rCmd.Content.rCmdProhibit.fgIsEnable;
aucTdlsTestExtCapElm[0] = ELEM_ID_EXTENDED_CAP;
aucTdlsTestExtCapElm[1] = 5;
aucTdlsTestExtCapElm[2] = 0;
aucTdlsTestExtCapElm[3] = 0;
aucTdlsTestExtCapElm[4] = 0;
aucTdlsTestExtCapElm[5] = 0;
aucTdlsTestExtCapElm[6] = (rCmd.Content.rCmdProhibit.fgIsSet << 7); /* bit39 */
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to receive a channel switch request from the peer.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
* EX: iwpriv wlan0 set_str_cmd 0_1_5_[TDLS Peer MAC]_[Chan]_[RegulatoryClass]_
[SecondaryChannelOffset]_[SwitchTime]_[SwitchTimeout]
iwpriv wlan0 set_str_cmd 0_1_5_00:11:22:33:44:01_1_255_0_15000_30000
RegulatoryClass: TODO (reference to Annex I of 802.11n spec.)
Secondary Channel Offset: 0 (SCN - no secondary channel)
1 (SCA - secondary channel above)
2 (SCB - secondary channel below)
SwitchTime: units of microseconds
*/
/*----------------------------------------------------------------------------*/
static void TdlsCmdTestChSwReqRecv(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen)
{
WLAN_STATUS rStatus;
TDLS_CMD_CORE_T rCmd;
UINT_32 u4BufLen;
/* parse arguments */
CmdStringMacParse(prInBuf, &prInBuf, &u4InBufLen, rCmd.aucPeerMac);
rCmd.Content.rCmdChStReqRcv.u4Chan = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
rCmd.Content.rCmdChStReqRcv.u4RegClass = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
rCmd.Content.rCmdChStReqRcv.u4SecChanOff = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
rCmd.Content.rCmdChStReqRcv.u4SwitchTime = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
rCmd.Content.rCmdChStReqRcv.u4SwitchTimeout = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
DBGLOG(TDLS, INFO, "%s:[%pM]u4Chan=%u u4RegClass=%u u4SecChanOff=%u u4SwitchTime=%u u4SwitchTimeout=%u\n",
__func__, rCmd.aucPeerMac,
(UINT32) rCmd.Content.rCmdChStReqRcv.u4Chan,
(UINT32) rCmd.Content.rCmdChStReqRcv.u4RegClass,
(UINT32) rCmd.Content.rCmdChStReqRcv.u4SecChanOff,
(UINT32) rCmd.Content.rCmdChStReqRcv.u4SwitchTime,
(UINT32) rCmd.Content.rCmdChStReqRcv.u4SwitchTimeout);
/* command to do this */
rStatus = kalIoctl(prGlueInfo, TdlsTestChStReqRecv, &rCmd, sizeof(rCmd), FALSE, FALSE, FALSE, FALSE, &u4BufLen);
if (rStatus != WLAN_STATUS_SUCCESS) {
DBGLOG(TDLS, ERROR, "%s kalIoctl fail:%x\n", __func__, rStatus);
return;
}
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to receive a channel switch response from the peer.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
* EX: iwpriv wlan0 set_str_cmd 0_1_6_[TDLS Peer MAC]_[Chan]_
[SwitchTime]_[SwitchTimeout]_[StatusCode]
iwpriv wlan0 set_str_cmd 0_1_6_00:11:22:33:44:01_11_15000_30000_0
RegulatoryClass: TODO (reference to Annex I of 802.11n spec.)
Secondary Channel Offset: 0 (SCN - no secondary channel)
1 (SCA - secondary channel above)
2 (SCB - secondary channel below)
SwitchTime: units of microseconds
*/
/*----------------------------------------------------------------------------*/
static void TdlsCmdTestChSwRspRecv(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen)
{
WLAN_STATUS rStatus;
TDLS_CMD_CORE_T rCmd;
UINT_32 u4BufLen;
/* parse arguments */
CmdStringMacParse(prInBuf, &prInBuf, &u4InBufLen, rCmd.aucPeerMac);
rCmd.Content.rCmdChStRspRcv.u4Chan = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
rCmd.Content.rCmdChStRspRcv.u4SwitchTime = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
rCmd.Content.rCmdChStRspRcv.u4SwitchTimeout = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
rCmd.Content.rCmdChStRspRcv.u4StatusCode = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
DBGLOG(TDLS, INFO, "%s: [ %pM ] u4Chan=%u u4SwitchTime=%u u4SwitchTimeout=%u u4StatusCode=%u\n",
__func__, rCmd.aucPeerMac,
(UINT32) rCmd.Content.rCmdChStRspRcv.u4Chan,
(UINT32) rCmd.Content.rCmdChStRspRcv.u4SwitchTime,
(UINT32) rCmd.Content.rCmdChStRspRcv.u4SwitchTimeout,
(UINT32) rCmd.Content.rCmdChStRspRcv.u4StatusCode);
/* command to do this */
rStatus = kalIoctl(prGlueInfo, TdlsTestChStRspRecv, &rCmd, sizeof(rCmd), FALSE, FALSE, FALSE, FALSE, &u4BufLen);
if (rStatus != WLAN_STATUS_SUCCESS) {
DBGLOG(TDLS, ERROR, "%s kalIoctl fail:%x\n", __func__, rStatus);
return;
}
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to inform firmware to skip channel switch timeout function.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
* EX: iwpriv wlan0 set_str_cmd 0_11_[Enable/Disable]
iwpriv wlan0 set_str_cmd 0_11_1
*/
/*----------------------------------------------------------------------------*/
static void TdlsCmdTestChSwTimeoutSkip(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen)
{
WLAN_STATUS rStatus;
TDLS_CMD_CORE_T rCmd;
UINT_32 u4BufLen;
/* parse arguments */
kalMemZero(rCmd.aucPeerMac, sizeof(rCmd.aucPeerMac));
rCmd.Content.rCmdKeepAliveSkip.fgIsEnable = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
DBGLOG(TDLS, INFO, "%s: fgIsEnable = %d\n", __func__, rCmd.Content.rCmdKeepAliveSkip.fgIsEnable);
/* command to do this */
rStatus = kalIoctl(prGlueInfo,
TdlsTestChSwTimeoutSkip, &rCmd, sizeof(rCmd), FALSE, FALSE, FALSE, FALSE, &u4BufLen);
if (rStatus != WLAN_STATUS_SUCCESS) {
DBGLOG(TDLS, ERROR, "%s kalIoctl fail:%x\n", __func__, rStatus);
return;
}
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to send a data frame to the peer periodically.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
*/
/*----------------------------------------------------------------------------*/
static TIMER_T rTdlsTimerTestDataSend;
static UINT_8 aucTdlsTestDataSPeerMac[6];
static UINT_16 u2TdlsTestDataSInterval;
static void TdlsCmdTestDataContSend(GLUE_INFO_T *prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen)
{
ADAPTER_T *prAdapter;
BOOLEAN fgIsEnabled;
/* init */
prAdapter = prGlueInfo->prAdapter;
/* parse arguments */
CmdStringMacParse(prInBuf, &prInBuf, &u4InBufLen, aucTdlsTestDataSPeerMac);
u2TdlsTestDataSInterval = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
fgIsEnabled = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
cnmTimerStopTimer(prAdapter, &rTdlsTimerTestDataSend);
if (fgIsEnabled == FALSE) {
/* stop test timer */
return;
}
/* re-init test timer */
cnmTimerInitTimer(prAdapter,
&rTdlsTimerTestDataSend, (PFN_MGMT_TIMEOUT_FUNC) TdlsTimerTestDataContSend, (ULONG) NULL);
cnmTimerStartTimer(prAdapter, &rTdlsTimerTestDataSend, u2TdlsTestDataSInterval);
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to receive a data frame from the peer.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
* EX: iwpriv wlan0 set_str_cmd 0_0_x80_[TDLS Peer MAC]_[PM]_[UP]_[EOSP]_[IsNull]
iwpriv wlan0 set_str_cmd 0_1_x80_00:11:22:33:44:01_0_0_0_0
*/
/*----------------------------------------------------------------------------*/
static void TdlsCmdTestDataRecv(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen)
{
WLAN_STATUS rStatus;
TDLS_CMD_CORE_T rCmd;
UINT_32 u4BufLen;
/* parse arguments */
CmdStringMacParse(prInBuf, &prInBuf, &u4InBufLen, rCmd.aucPeerMac);
rCmd.Content.rCmdDatRcv.u4PM = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
rCmd.Content.rCmdDatRcv.u4UP = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
rCmd.Content.rCmdDatRcv.u4EOSP = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
rCmd.Content.rCmdDatRcv.u4IsNull = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
DBGLOG(TDLS, INFO,
"<tdls_cmd> %s: [%pM] PM(%u) UP(%u) EOSP(%u) NULL(%u)\n",
__func__, rCmd.aucPeerMac,
(UINT32) rCmd.Content.rCmdDatRcv.u4PM,
(UINT32) rCmd.Content.rCmdDatRcv.u4UP,
(UINT32) rCmd.Content.rCmdDatRcv.u4EOSP, (UINT32) rCmd.Content.rCmdDatRcv.u4IsNull);
/* command to do this */
rStatus = kalIoctl(prGlueInfo, TdlsTestDataRecv, &rCmd, sizeof(rCmd), FALSE, FALSE, FALSE, FALSE, &u4BufLen);
if (rStatus != WLAN_STATUS_SUCCESS) {
DBGLOG(TDLS, ERROR, "%s kalIoctl fail:%x\n", __func__, rStatus);
return;
}
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to send a data frame to the peer.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
* EX: iwpriv wlan0 set_str_cmd 0_4_[Responder MAC]_[tx status]
iwpriv wlan0 set_str_cmd 0_4_00:11:22:33:44:01_0
*/
/*----------------------------------------------------------------------------*/
static void TdlsCmdTestDataSend(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen)
{
P_ADAPTER_T prAdapter;
struct sk_buff *prMsduInfo;
UINT_8 *prPkt;
UINT_8 MAC[6];
UINT_8 ucTxStatus;
/* init */
prAdapter = prGlueInfo->prAdapter;
/* parse arguments */
CmdStringMacParse(prInBuf, &prInBuf, &u4InBufLen, MAC);
ucTxStatus = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
/* allocate a data frame */
prMsduInfo = kalPacketAlloc(prGlueInfo, 1000, &prPkt);
if (prMsduInfo == NULL) {
DBGLOG(TDLS, ERROR, "<tdls_cmd> %s allocate pkt fail!\n", __func__);
return;
}
/* init dev */
prMsduInfo->dev = prGlueInfo->prDevHandler;
if (prMsduInfo->dev == NULL) {
DBGLOG(TDLS, ERROR, "<tdls_cmd> %s prMsduInfo->dev == NULL!\n", __func__);
kalPacketFree(prGlueInfo, prMsduInfo);
return;
}
/* init packet */
prMsduInfo->len = 1000;
kalMemZero(prMsduInfo->data, 100); /* for QoS field */
kalMemCopy(prMsduInfo->data, MAC, 6);
kalMemCopy(prMsduInfo->data + 6, prAdapter->rMyMacAddr, 6);
*(UINT_16 *) (prMsduInfo->data + 12) = 0x0800;
/* simulate OS to send the packet */
wlanHardStartXmit(prMsduInfo, prMsduInfo->dev);
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to simulate to set the TDLS Prohibited bit.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
* EX: iwpriv wlan0 set_str_cmd 0_16_[mili seconds]
iwpriv wlan0 set_str_cmd 0_19_1000
*/
/*----------------------------------------------------------------------------*/
static void TdlsCmdTestDelay(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen)
{
UINT32 u4Delay;
u4Delay = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
DBGLOG(TDLS, INFO, "%s: Delay = %d\n", __func__, u4Delay);
kalMdelay(u4Delay);
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to receive a test discovery request frame command.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
* EX: iwpriv wlan0 set_str_cmd 0_1_10_[DialogToken]_[Peer MAC]_[BSSID]
iwpriv wlan0 set_str_cmd 0_1_10_1_00:11:22:33:44:01
iwpriv wlan0 set_str_cmd 0_1_10_1_00:11:22:33:44:01_00:22:33:44:11:22
*/
/*----------------------------------------------------------------------------*/
static void TdlsCmdTestDiscoveryReqRecv(GLUE_INFO_T *prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen)
{
ADAPTER_T *prAdapter;
P_BSS_INFO_T prBssInfo;
struct sk_buff *prMsduInfo;
UINT_8 *pPkt;
UINT_32 u4PktLen, u4IeLen;
UINT_8 ucDialogToken, aucPeerMac[6], aucBSSID[6], aucZeroMac[6];
/* parse arguments */
ucDialogToken = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
CmdStringMacParse(prInBuf, &prInBuf, &u4InBufLen, aucPeerMac);
kalMemZero(aucZeroMac, sizeof(aucZeroMac));
kalMemZero(aucBSSID, sizeof(aucBSSID));
CmdStringMacParse(prInBuf, &prInBuf, &u4InBufLen, aucBSSID);
DBGLOG(TDLS, INFO,
"<tdls_fme> %s: DialogToken=%d from %pM\n", __func__, ucDialogToken, aucPeerMac);
/* allocate/init packet */
prAdapter = prGlueInfo->prAdapter;
prBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
u4PktLen = 0;
prMsduInfo = kalPacketAlloc(prGlueInfo, 1600, &pPkt);
if (prMsduInfo == NULL) {
DBGLOG(TDLS, ERROR, "<tdls_cmd> %s: allocate pkt fail\n", __func__);
return;
}
prMsduInfo->dev = prGlueInfo->prDevHandler;
if (prMsduInfo->dev == NULL) {
DBGLOG(TDLS, ERROR, "<tdls_cmd> %s: MsduInfo->dev == NULL\n", __func__);
kalPacketFree(prGlueInfo, prMsduInfo);
return;
}
/* make up frame content */
/* 1. 802.3 header */
kalMemCopy(pPkt, prAdapter->rMyMacAddr, TDLS_FME_MAC_ADDR_LEN);
LR_TDLS_FME_FIELD_FILL(TDLS_FME_MAC_ADDR_LEN);
kalMemCopy(pPkt, aucPeerMac, TDLS_FME_MAC_ADDR_LEN);
LR_TDLS_FME_FIELD_FILL(TDLS_FME_MAC_ADDR_LEN);
*(UINT_16 *) pPkt = htons(TDLS_FRM_PROT_TYPE);
LR_TDLS_FME_FIELD_FILL(2);
/* 2. payload type */
*pPkt = TDLS_FRM_PAYLOAD_TYPE;
LR_TDLS_FME_FIELD_FILL(1);
/* 3. Frame Formation - (1) Category */
*pPkt = TDLS_FRM_CATEGORY;
LR_TDLS_FME_FIELD_FILL(1);
/* 3. Frame Formation - (2) Action */
*pPkt = TDLS_FRM_ACTION_DISCOVERY_REQ;
LR_TDLS_FME_FIELD_FILL(1);
/* 3. Frame Formation - (3) Dialog token */
*pPkt = ucDialogToken;
LR_TDLS_FME_FIELD_FILL(1);
/* 3. Frame Formation - (16) Link identifier element */
TDLS_LINK_IDENTIFIER_IE(pPkt)->ucId = ELEM_ID_LINK_IDENTIFIER;
TDLS_LINK_IDENTIFIER_IE(pPkt)->ucLength = 18;
if (kalMemCmp(aucBSSID, aucZeroMac, 6) == 0)
kalMemCopy(TDLS_LINK_IDENTIFIER_IE(pPkt)->aBSSID, prBssInfo->aucBSSID, 6);
else
kalMemCopy(TDLS_LINK_IDENTIFIER_IE(pPkt)->aBSSID, aucBSSID, 6);
kalMemCopy(TDLS_LINK_IDENTIFIER_IE(pPkt)->aInitiator, aucPeerMac, 6);
kalMemCopy(TDLS_LINK_IDENTIFIER_IE(pPkt)->aResponder, prAdapter->rMyMacAddr, 6);
u4IeLen = IE_SIZE(pPkt);
LR_TDLS_FME_FIELD_FILL(u4IeLen);
/* 4. Update packet length */
prMsduInfo->len = u4PktLen;
dumpMemory8(prMsduInfo->data, u4PktLen);
/* pass to OS */
TdlsCmdTestRxIndicatePkts(prGlueInfo, prMsduInfo);
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to inform firmware to skip keep alive function.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
* EX: iwpriv wlan0 set_str_cmd 0_10_[Enable/Disable]
iwpriv wlan0 set_str_cmd 0_10_1
*/
/*----------------------------------------------------------------------------*/
static void TdlsCmdTestKeepAliveSkip(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen)
{
WLAN_STATUS rStatus;
TDLS_CMD_CORE_T rCmd;
UINT_32 u4BufLen;
/* parse arguments */
kalMemZero(rCmd.aucPeerMac, sizeof(rCmd.aucPeerMac));
rCmd.Content.rCmdKeepAliveSkip.fgIsEnable = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
DBGLOG(TDLS, INFO, "%s: fgIsEnable = %d\n", __func__, rCmd.Content.rCmdKeepAliveSkip.fgIsEnable);
/* command to do this */
rStatus = kalIoctl(prGlueInfo,
TdlsTestKeepAliveSkip, &rCmd, sizeof(rCmd), FALSE, FALSE, FALSE, FALSE, &u4BufLen);
if (rStatus != WLAN_STATUS_SUCCESS) {
DBGLOG(TDLS, ERROR, "%s kalIoctl fail:%x\n", __func__, rStatus);
return;
}
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to simulate to set the TDLS Prohibited bit.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
* EX: iwpriv wlan0 set_str_cmd 0_11_[Enable/Disable]_[Set/Clear]
iwpriv wlan0 set_str_cmd 0_13_1_1
*/
/*----------------------------------------------------------------------------*/
static void TdlsCmdTestProhibitedBitSet(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen)
{
TDLS_CMD_CORE_T rCmd;
/* parse arguments */
kalMemZero(rCmd.aucPeerMac, sizeof(rCmd.aucPeerMac));
rCmd.Content.rCmdProhibit.fgIsEnable = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
rCmd.Content.rCmdProhibit.fgIsSet = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
DBGLOG(TDLS, INFO, "%s: fgIsEnable = %d\n", __func__, rCmd.Content.rCmdProhibit.fgIsEnable);
/* command to do this */
flgTdlsTestExtCapElm = rCmd.Content.rCmdProhibit.fgIsEnable;
aucTdlsTestExtCapElm[0] = ELEM_ID_EXTENDED_CAP;
aucTdlsTestExtCapElm[1] = 5;
aucTdlsTestExtCapElm[2] = 0;
aucTdlsTestExtCapElm[3] = 0;
aucTdlsTestExtCapElm[4] = 0;
aucTdlsTestExtCapElm[5] = 0;
aucTdlsTestExtCapElm[6] = (rCmd.Content.rCmdProhibit.fgIsSet << 6); /* bit38 */
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to receive a PTI request from the AP.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
* EX: iwpriv wlan0 set_str_cmd 0_1_4_[TDLS Peer MAC]_[Dialog Token]
iwpriv wlan0 set_str_cmd 0_1_4_00:11:22:33:44:01_0
*/
/*----------------------------------------------------------------------------*/
static void TdlsCmdTestPtiReqRecv(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen)
{
WLAN_STATUS rStatus;
TDLS_CMD_CORE_T rCmd;
UINT_32 u4BufLen;
/* parse arguments */
CmdStringMacParse(prInBuf, &prInBuf, &u4InBufLen, rCmd.aucPeerMac);
rCmd.Content.rCmdPtiRspRcv.u4DialogToken = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
DBGLOG(TDLS, INFO, "%s: [ %pM ] u4DialogToken = %u\n",
__func__, rCmd.aucPeerMac, (UINT32) rCmd.Content.rCmdPtiRspRcv.u4DialogToken);
/* command to do this */
rStatus = kalIoctl(prGlueInfo, TdlsTestPtiReqRecv, &rCmd, sizeof(rCmd), FALSE, FALSE, FALSE, FALSE, &u4BufLen);
if (rStatus != WLAN_STATUS_SUCCESS) {
DBGLOG(TDLS, ERROR, "%s kalIoctl fail:%x\n", __func__, rStatus);
return;
}
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to receive a PTI response from the peer.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
* EX: iwpriv wlan0 set_str_cmd 0_1_9_[TDLS Peer MAC]_[Dialog Token]_[PM]
iwpriv wlan0 set_str_cmd 0_1_9_00:11:22:33:44:01_0_1
*/
/*----------------------------------------------------------------------------*/
static void TdlsCmdTestPtiRspRecv(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen)
{
WLAN_STATUS rStatus;
TDLS_CMD_CORE_T rCmd;
UINT_32 u4BufLen;
/* parse arguments */
CmdStringMacParse(prInBuf, &prInBuf, &u4InBufLen, rCmd.aucPeerMac);
rCmd.Content.rCmdPtiRspRcv.u4DialogToken = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
rCmd.Content.rCmdPtiRspRcv.u4PM = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
DBGLOG(TDLS, INFO, "%s: [%pM] u4DialogToken = %u %u\n",
__func__, rCmd.aucPeerMac,
(UINT32) rCmd.Content.rCmdPtiRspRcv.u4DialogToken,
(UINT32) rCmd.Content.rCmdPtiRspRcv.u4PM);
/* command to do this */
rStatus = kalIoctl(prGlueInfo, TdlsTestPtiRspRecv, &rCmd, sizeof(rCmd), FALSE, FALSE, FALSE, FALSE, &u4BufLen);
if (rStatus != WLAN_STATUS_SUCCESS) {
DBGLOG(TDLS, ERROR, "%s kalIoctl fail:%x\n", __func__, rStatus);
return;
}
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to inform firmware to simulate PTI tx done fail case.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
* EX: iwpriv wlan0 set_str_cmd 0_21_[Enable/Disable]
iwpriv wlan0 set_str_cmd 0_21_1
*/
/*----------------------------------------------------------------------------*/
static void TdlsCmdTestPtiTxDoneFail(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen)
{
WLAN_STATUS rStatus;
TDLS_CMD_CORE_T rCmd;
UINT_32 u4BufLen;
/* parse arguments */
kalMemZero(rCmd.aucPeerMac, sizeof(rCmd.aucPeerMac));
rCmd.Content.rCmdPtiTxFail.fgIsEnable = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
DBGLOG(TDLS, INFO, "%s: fgIsEnable = %d\n", __func__, rCmd.Content.rCmdPtiTxFail.fgIsEnable);
/* command to do this */
rStatus = kalIoctl(prGlueInfo, TdlsTestPtiTxFail, &rCmd, sizeof(rCmd), FALSE, FALSE, FALSE, FALSE, &u4BufLen);
if (rStatus != WLAN_STATUS_SUCCESS) {
DBGLOG(TDLS, ERROR, "%s kalIoctl fail:%x\n", __func__, rStatus);
return;
}
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to receive a test frame.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
*/
/*----------------------------------------------------------------------------*/
static void TdlsCmdTestRvFrame(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen)
{
/* PARAM_CUSTOM_TDLS_CMD_STRUCT_T rCmd; */
/* TDLS_STATUS u4Status; */
UINT_32 u4Subcmd;
/* UINT_32 u4BufLen; */
/* parse sub-command */
u4Subcmd = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
DBGLOG(TDLS, INFO, "<tdls_cmd> test rv frame sub command = %u\n", (UINT32) u4Subcmd);
/* parse command arguments */
switch (u4Subcmd) {
case TDLS_FRM_ACTION_SETUP_REQ:
/* simulate to receive a setup request frame */
TdlsCmdTestSetupReqRecv(prGlueInfo, prInBuf, u4InBufLen);
break;
case TDLS_FRM_ACTION_SETUP_RSP:
/* simulate to receive a setup response frame */
TdlsCmdTestSetupRspRecv(prGlueInfo, prInBuf, u4InBufLen);
break;
case TDLS_FRM_ACTION_CONFIRM:
/* simulate to receive a setup confirm frame */
TdlsCmdTestSetupConfirmRecv(prGlueInfo, prInBuf, u4InBufLen);
break;
case TDLS_FRM_ACTION_TEARDOWN:
/* simulate to receive a tear down frame */
TdlsCmdTestTearDownRecv(prGlueInfo, prInBuf, u4InBufLen);
break;
case TDLS_FRM_ACTION_PTI:
/* simulate to receive a PTI request frame */
TdlsCmdTestPtiReqRecv(prGlueInfo, prInBuf, u4InBufLen);
break;
case TDLS_FRM_ACTION_PTI_RSP:
/* simulate to receive a PTI response frame */
TdlsCmdTestPtiRspRecv(prGlueInfo, prInBuf, u4InBufLen);
break;
case TDLS_FRM_DATA_TEST_DATA:
/* simulate to receive a DATA frame */
TdlsCmdTestDataRecv(prGlueInfo, prInBuf, u4InBufLen);
break;
case TDLS_FRM_ACTION_CHAN_SWITCH_REQ:
/* simulate to receive a channel switch request frame */
TdlsCmdTestChSwReqRecv(prGlueInfo, prInBuf, u4InBufLen);
break;
case TDLS_FRM_ACTION_CHAN_SWITCH_RSP:
/* simulate to receive a channel switch response frame */
TdlsCmdTestChSwRspRecv(prGlueInfo, prInBuf, u4InBufLen);
break;
case TDLS_FRM_ACTION_DISCOVERY_REQ:
/* simulate to receive a discovery request frame */
TdlsCmdTestDiscoveryReqRecv(prGlueInfo, prInBuf, u4InBufLen);
break;
default:
DBGLOG(TDLS, ERROR, "<tdls_cmd> wrong test rv frame sub command\n");
return;
}
/* if (u4Status != TDLS_STATUS_SUCCESS) */
{
/* DBGLOG(TDLS, ERROR, ("<tdls_cmd> command parse fail\n")); */
/* return; */
}
/* send command to wifi task to handle */
#if 0
kalIoctl(prGlueInfo,
TdlsTestFrameSend,
(PVOID)&rCmd, sizeof(PARAM_CUSTOM_TDLS_CMD_STRUCT_T), FALSE, FALSE, TRUE, FALSE, &u4BufLen);
#endif
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to receive a test setup confirm frame command.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
* EX: iwpriv wlan0 set_str_cmd 0_1_2_[DialogToken]_[StatusCode]_[Peer MAC]
iwpriv wlan0 set_str_cmd 0_1_2_1_0_00:11:22:33:44:01
*/
/*----------------------------------------------------------------------------*/
static void TdlsCmdTestSetupConfirmRecv(GLUE_INFO_T *prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen)
{
ADAPTER_T *prAdapter;
P_BSS_INFO_T prBssInfo;
PM_PROFILE_SETUP_INFO_T *prPmProfSetupInfo;
struct sk_buff *prMsduInfo;
UINT_8 *pPkt;
UINT_32 u4PktLen, u4IeLen;
UINT_8 ucDialogToken, ucStatusCode, aucPeerMac[6];
/* parse arguments */
ucDialogToken = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
ucStatusCode = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
CmdStringMacParse(prInBuf, &prInBuf, &u4InBufLen, aucPeerMac);
DBGLOG(TDLS, INFO,
"<tdls_fme> %s: DialogToken=%d StatusCode=%d from %pM\n",
__func__, ucDialogToken, ucStatusCode, aucPeerMac);
/* allocate/init packet */
prAdapter = prGlueInfo->prAdapter;
prBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
prPmProfSetupInfo = &prBssInfo->rPmProfSetupInfo;
u4PktLen = 0;
prMsduInfo = kalPacketAlloc(prGlueInfo, 1600, &pPkt);
if (prMsduInfo == NULL) {
DBGLOG(TDLS, ERROR, "<tdls_cmd> %s: allocate pkt fail\n", __func__);
return;
}
prMsduInfo->dev = prGlueInfo->prDevHandler;
if (prMsduInfo->dev == NULL) {
DBGLOG(TDLS, ERROR, "<tdls_cmd> %s: MsduInfo->dev == NULL\n", __func__);
kalPacketFree(prGlueInfo, prMsduInfo);
return;
}
/* make up frame content */
/* 1. 802.3 header */
kalMemCopy(pPkt, prAdapter->rMyMacAddr, TDLS_FME_MAC_ADDR_LEN);
LR_TDLS_FME_FIELD_FILL(TDLS_FME_MAC_ADDR_LEN);
kalMemCopy(pPkt, aucPeerMac, TDLS_FME_MAC_ADDR_LEN);
LR_TDLS_FME_FIELD_FILL(TDLS_FME_MAC_ADDR_LEN);
*(UINT_16 *) pPkt = htons(TDLS_FRM_PROT_TYPE);
LR_TDLS_FME_FIELD_FILL(2);
/* 2. payload type */
*pPkt = TDLS_FRM_PAYLOAD_TYPE;
LR_TDLS_FME_FIELD_FILL(1);
/* 3. Frame Formation - (1) Category */
*pPkt = TDLS_FRM_CATEGORY;
LR_TDLS_FME_FIELD_FILL(1);
/* 3. Frame Formation - (2) Action */
*pPkt = TDLS_FRM_ACTION_CONFIRM;
LR_TDLS_FME_FIELD_FILL(1);
/* 3. Frame Formation - (3) Status Code */
*pPkt = ucStatusCode;
*(pPkt + 1) = 0x00;
LR_TDLS_FME_FIELD_FILL(2);
/* 3. Frame Formation - (4) Dialog token */
*pPkt = ucDialogToken;
LR_TDLS_FME_FIELD_FILL(1);
/* 3. Frame Formation - (17) WMM Information element */
if (prAdapter->rWifiVar.fgSupportQoS) {
u4IeLen = mqmGenerateWmmParamIEByParam(prAdapter, prBssInfo, pPkt, OP_MODE_INFRASTRUCTURE);
LR_TDLS_FME_FIELD_FILL(u4IeLen);
}
/* 3. Frame Formation - (16) Link identifier element */
TDLS_LINK_IDENTIFIER_IE(pPkt)->ucId = ELEM_ID_LINK_IDENTIFIER;
TDLS_LINK_IDENTIFIER_IE(pPkt)->ucLength = ELEM_LEN_LINK_IDENTIFIER;
kalMemCopy(TDLS_LINK_IDENTIFIER_IE(pPkt)->aBSSID, prBssInfo->aucBSSID, 6);
kalMemCopy(TDLS_LINK_IDENTIFIER_IE(pPkt)->aInitiator, aucPeerMac, 6);
kalMemCopy(TDLS_LINK_IDENTIFIER_IE(pPkt)->aResponder, prAdapter->rMyMacAddr, 6);
u4IeLen = IE_SIZE(pPkt);
LR_TDLS_FME_FIELD_FILL(u4IeLen);
/* 4. Update packet length */
prMsduInfo->len = u4PktLen;
dumpMemory8(prMsduInfo->data, u4PktLen);
/* pass to OS */
TdlsCmdTestRxIndicatePkts(prGlueInfo, prMsduInfo);
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to receive a test setup request frame command.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
* EX: iwpriv wlan0 set_str_cmd 0_1_0_[DialogToken]_[Peer MAC]_[BSSID]
iwpriv wlan0 set_str_cmd 0_1_0_1_00:11:22:33:44:01
iwpriv wlan0 set_str_cmd 0_1_0_1_00:11:22:33:44:01_00:22:33:44:11:22
*/
/*----------------------------------------------------------------------------*/
static void TdlsCmdTestSetupReqRecv(GLUE_INFO_T *prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen)
{
ADAPTER_T *prAdapter;
P_BSS_INFO_T prBssInfo;
struct sk_buff *prMsduInfo;
UINT_8 *pPkt;
UINT_32 u4PktLen, u4IeLen;
UINT_8 ucDialogToken, aucPeerMac[6], aucBSSID[6], aucZeroMac[6];
UINT_16 u2CapInfo;
/* parse arguments */
ucDialogToken = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
CmdStringMacParse(prInBuf, &prInBuf, &u4InBufLen, aucPeerMac);
kalMemZero(aucZeroMac, sizeof(aucZeroMac));
kalMemZero(aucBSSID, sizeof(aucBSSID));
CmdStringMacParse(prInBuf, &prInBuf, &u4InBufLen, aucBSSID);
DBGLOG(TDLS, INFO,
"<tdls_fme> %s: DialogToken=%d from %pM\n", __func__, ucDialogToken, aucPeerMac);
/* allocate/init packet */
prAdapter = prGlueInfo->prAdapter;
prBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
u4PktLen = 0;
prMsduInfo = kalPacketAlloc(prGlueInfo, 1600, &pPkt);
if (prMsduInfo == NULL) {
DBGLOG(TDLS, ERROR, "<tdls_cmd> %s: allocate pkt fail\n", __func__);
return;
}
prMsduInfo->dev = prGlueInfo->prDevHandler;
if (prMsduInfo->dev == NULL) {
DBGLOG(TDLS, ERROR, "<tdls_cmd> %s: MsduInfo->dev == NULL\n", __func__);
kalPacketFree(prGlueInfo, prMsduInfo);
return;
}
/* make up frame content */
/* 1. 802.3 header */
kalMemCopy(pPkt, prAdapter->rMyMacAddr, TDLS_FME_MAC_ADDR_LEN);
LR_TDLS_FME_FIELD_FILL(TDLS_FME_MAC_ADDR_LEN);
kalMemCopy(pPkt, aucPeerMac, TDLS_FME_MAC_ADDR_LEN);
LR_TDLS_FME_FIELD_FILL(TDLS_FME_MAC_ADDR_LEN);
*(UINT_16 *) pPkt = htons(TDLS_FRM_PROT_TYPE);
LR_TDLS_FME_FIELD_FILL(2);
/* 2. payload type */
*pPkt = TDLS_FRM_PAYLOAD_TYPE;
LR_TDLS_FME_FIELD_FILL(1);
/* 3. Frame Formation - (1) Category */
*pPkt = TDLS_FRM_CATEGORY;
LR_TDLS_FME_FIELD_FILL(1);
/* 3. Frame Formation - (2) Action */
*pPkt = TDLS_FRM_ACTION_SETUP_REQ;
LR_TDLS_FME_FIELD_FILL(1);
/* 3. Frame Formation - (3) Dialog token */
*pPkt = ucDialogToken;
LR_TDLS_FME_FIELD_FILL(1);
/* 3. Frame Formation - (4) Capability */
u2CapInfo = assocBuildCapabilityInfo(prAdapter, NULL);
WLAN_SET_FIELD_16(pPkt, u2CapInfo);
LR_TDLS_FME_FIELD_FILL(2);
/* 4. Append general IEs */
u4IeLen = TdlsFrameGeneralIeAppend(prAdapter, NULL, 0, pPkt);
LR_TDLS_FME_FIELD_FILL(u4IeLen);
/* 3. Frame Formation - (10) Extended capabilities element */
EXT_CAP_IE(pPkt)->ucId = ELEM_ID_EXTENDED_CAP;
EXT_CAP_IE(pPkt)->ucLength = 5;
EXT_CAP_IE(pPkt)->aucCapabilities[0] = 0x00; /* bit0 ~ bit7 */
EXT_CAP_IE(pPkt)->aucCapabilities[1] = 0x00; /* bit8 ~ bit15 */
EXT_CAP_IE(pPkt)->aucCapabilities[2] = 0x00; /* bit16 ~ bit23 */
EXT_CAP_IE(pPkt)->aucCapabilities[3] = 0x00; /* bit24 ~ bit31 */
EXT_CAP_IE(pPkt)->aucCapabilities[4] = 0x00; /* bit32 ~ bit39 */
/* TDLS_EX_CAP_PEER_UAPSD */
EXT_CAP_IE(pPkt)->aucCapabilities[3] |= BIT((28 - 24));
/* TDLS_EX_CAP_CHAN_SWITCH */
EXT_CAP_IE(pPkt)->aucCapabilities[3] |= BIT((30 - 24));
/* TDLS_EX_CAP_TDLS */
EXT_CAP_IE(pPkt)->aucCapabilities[4] |= BIT((37 - 32));
u4IeLen = IE_SIZE(pPkt);
LR_TDLS_FME_FIELD_FILL(u4IeLen);
/* 3. Frame Formation - (16) Link identifier element */
TDLS_LINK_IDENTIFIER_IE(pPkt)->ucId = ELEM_ID_LINK_IDENTIFIER;
TDLS_LINK_IDENTIFIER_IE(pPkt)->ucLength = 18;
if (kalMemCmp(aucBSSID, aucZeroMac, 6) == 0)
kalMemCopy(TDLS_LINK_IDENTIFIER_IE(pPkt)->aBSSID, prBssInfo->aucBSSID, 6);
else
kalMemCopy(TDLS_LINK_IDENTIFIER_IE(pPkt)->aBSSID, aucBSSID, 6);
kalMemCopy(TDLS_LINK_IDENTIFIER_IE(pPkt)->aInitiator, aucPeerMac, 6);
kalMemCopy(TDLS_LINK_IDENTIFIER_IE(pPkt)->aResponder, prAdapter->rMyMacAddr, 6);
u4IeLen = IE_SIZE(pPkt);
LR_TDLS_FME_FIELD_FILL(u4IeLen);
/* 4. Update packet length */
prMsduInfo->len = u4PktLen;
dumpMemory8(prMsduInfo->data, u4PktLen);
/* pass to OS */
TdlsCmdTestRxIndicatePkts(prGlueInfo, prMsduInfo);
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to receive a test setup response frame command.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
* EX: iwpriv wlan0 set_str_cmd 0_1_1_[DialogToken]_[StatusCode]_[Peer MAC]
iwpriv wlan0 set_str_cmd 0_1_1_1_0_00:11:22:33:44:01
*/
/*----------------------------------------------------------------------------*/
static void TdlsCmdTestSetupRspRecv(GLUE_INFO_T *prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen)
{
ADAPTER_T *prAdapter;
P_BSS_INFO_T prBssInfo;
struct sk_buff *prMsduInfo;
UINT_8 *pPkt;
UINT_32 u4PktLen, u4IeLen;
UINT_8 ucDialogToken, ucStatusCode, aucPeerMac[6];
UINT_16 u2CapInfo;
/* parse arguments */
ucDialogToken = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
ucStatusCode = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
CmdStringMacParse(prInBuf, &prInBuf, &u4InBufLen, aucPeerMac);
DBGLOG(TDLS, INFO,
"<tdls_fme> %s: DialogToken=%d StatusCode=%d from %pM\n",
__func__, ucDialogToken, ucStatusCode, aucPeerMac);
/* allocate/init packet */
prAdapter = prGlueInfo->prAdapter;
prBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
u4PktLen = 0;
prMsduInfo = kalPacketAlloc(prGlueInfo, 1600, &pPkt);
if (prMsduInfo == NULL) {
DBGLOG(TDLS, ERROR, "<tdls_cmd> %s: allocate pkt fail\n", __func__);
return;
}
prMsduInfo->dev = prGlueInfo->prDevHandler;
if (prMsduInfo->dev == NULL) {
DBGLOG(TDLS, ERROR, "<tdls_cmd> %s: MsduInfo->dev == NULL\n", __func__);
kalPacketFree(prGlueInfo, prMsduInfo);
return;
}
/* make up frame content */
/* 1. 802.3 header */
kalMemCopy(pPkt, prAdapter->rMyMacAddr, TDLS_FME_MAC_ADDR_LEN);
LR_TDLS_FME_FIELD_FILL(TDLS_FME_MAC_ADDR_LEN);
kalMemCopy(pPkt, aucPeerMac, TDLS_FME_MAC_ADDR_LEN);
LR_TDLS_FME_FIELD_FILL(TDLS_FME_MAC_ADDR_LEN);
*(UINT_16 *) pPkt = htons(TDLS_FRM_PROT_TYPE);
LR_TDLS_FME_FIELD_FILL(2);
/* 2. payload type */
*pPkt = TDLS_FRM_PAYLOAD_TYPE;
LR_TDLS_FME_FIELD_FILL(1);
/* 3. Frame Formation - (1) Category */
*pPkt = TDLS_FRM_CATEGORY;
LR_TDLS_FME_FIELD_FILL(1);
/* 3. Frame Formation - (2) Action */
*pPkt = TDLS_FRM_ACTION_SETUP_RSP;
LR_TDLS_FME_FIELD_FILL(1);
/* 3. Frame Formation - (3) Status Code */
*pPkt = ucStatusCode;
*(pPkt + 1) = 0x00;
LR_TDLS_FME_FIELD_FILL(2);
/* 3. Frame Formation - (4) Dialog token */
*pPkt = ucDialogToken;
LR_TDLS_FME_FIELD_FILL(1);
/* 3. Frame Formation - (5) Capability */
u2CapInfo = assocBuildCapabilityInfo(prAdapter, NULL);
WLAN_SET_FIELD_16(pPkt, u2CapInfo);
LR_TDLS_FME_FIELD_FILL(2);
/* 4. Append general IEs */
u4IeLen = TdlsFrameGeneralIeAppend(prAdapter, NULL, 0, pPkt);
LR_TDLS_FME_FIELD_FILL(u4IeLen);
/* 3. Frame Formation - (10) Extended capabilities element */
EXT_CAP_IE(pPkt)->ucId = ELEM_ID_EXTENDED_CAP;
EXT_CAP_IE(pPkt)->ucLength = 5;
EXT_CAP_IE(pPkt)->aucCapabilities[0] = 0x00; /* bit0 ~ bit7 */
EXT_CAP_IE(pPkt)->aucCapabilities[1] = 0x00; /* bit8 ~ bit15 */
EXT_CAP_IE(pPkt)->aucCapabilities[2] = 0x00; /* bit16 ~ bit23 */
EXT_CAP_IE(pPkt)->aucCapabilities[3] = 0x00; /* bit24 ~ bit31 */
EXT_CAP_IE(pPkt)->aucCapabilities[4] = 0x00; /* bit32 ~ bit39 */
/* TDLS_EX_CAP_PEER_UAPSD */
EXT_CAP_IE(pPkt)->aucCapabilities[3] |= BIT((28 - 24));
/* TDLS_EX_CAP_CHAN_SWITCH */
EXT_CAP_IE(pPkt)->aucCapabilities[3] |= BIT((30 - 24));
/* TDLS_EX_CAP_TDLS */
EXT_CAP_IE(pPkt)->aucCapabilities[4] |= BIT((37 - 32));
u4IeLen = IE_SIZE(pPkt);
LR_TDLS_FME_FIELD_FILL(u4IeLen);
/* 3. Frame Formation - (16) Link identifier element */
TDLS_LINK_IDENTIFIER_IE(pPkt)->ucId = ELEM_ID_LINK_IDENTIFIER;
TDLS_LINK_IDENTIFIER_IE(pPkt)->ucLength = ELEM_LEN_LINK_IDENTIFIER;
kalMemCopy(TDLS_LINK_IDENTIFIER_IE(pPkt)->aBSSID, prBssInfo->aucBSSID, 6);
kalMemCopy(TDLS_LINK_IDENTIFIER_IE(pPkt)->aInitiator, prAdapter->rMyMacAddr, 6);
kalMemCopy(TDLS_LINK_IDENTIFIER_IE(pPkt)->aResponder, aucPeerMac, 6);
u4IeLen = IE_SIZE(pPkt);
LR_TDLS_FME_FIELD_FILL(u4IeLen);
/* 4. Update packet length */
prMsduInfo->len = u4PktLen;
dumpMemory8(prMsduInfo->data, u4PktLen);
/* pass to OS */
TdlsCmdTestRxIndicatePkts(prGlueInfo, prMsduInfo);
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to inform firmware to skip channel switch timeout function.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
* EX: iwpriv wlan0 set_str_cmd 0_14_[Enable/Disable]
iwpriv wlan0 set_str_cmd 0_14_0
*/
/*----------------------------------------------------------------------------*/
static void TdlsCmdTestScanCtrl(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen)
{
WLAN_STATUS rStatus;
TDLS_CMD_CORE_T rCmd;
UINT_32 u4BufLen;
/* parse arguments */
kalMemZero(rCmd.aucPeerMac, sizeof(rCmd.aucPeerMac));
rCmd.Content.rCmdScanSkip.fgIsEnable = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
DBGLOG(TDLS, INFO, "%s: fgIsEnable = %d\n", __func__, rCmd.Content.rCmdScanSkip.fgIsEnable);
/* command to do this */
rStatus = kalIoctl(prGlueInfo, TdlsTestScanSkip, &rCmd, sizeof(rCmd), FALSE, FALSE, FALSE, FALSE, &u4BufLen);
if (rStatus != WLAN_STATUS_SUCCESS) {
DBGLOG(TDLS, ERROR, "%s kalIoctl fail:%x\n", __func__, rStatus);
return;
}
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to receive a test tear down frame command.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
* EX: iwpriv wlan0 set_str_cmd 0_1_3_[IsInitiator]_[ReasonCode]_[Peer MAC]_[Where]
Where 0 (From driver) or 1 (From FW)
iwpriv wlan0 set_str_cmd 0_1_3_1_26_00:11:22:33:44:01_0
*/
/*----------------------------------------------------------------------------*/
static void TdlsCmdTestTearDownRecv(GLUE_INFO_T *prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen)
{
ADAPTER_T *prAdapter;
P_BSS_INFO_T prBssInfo;
struct sk_buff *prMsduInfo;
UINT_8 *pPkt;
UINT_32 u4PktLen, u4IeLen;
BOOLEAN fgIsInitiator;
UINT_8 ucReasonCode, aucPeerMac[6];
BOOLEAN fgIsFromWhich;
WLAN_STATUS rStatus;
TDLS_CMD_CORE_T rCmd;
UINT_32 u4BufLen;
/* parse arguments */
fgIsInitiator = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
ucReasonCode = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
CmdStringMacParse(prInBuf, &prInBuf, &u4InBufLen, aucPeerMac);
fgIsFromWhich = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
DBGLOG(TDLS, INFO,
"<tdls_fme> %s: ReasonCode=%d from %pM %d\n",
__func__, ucReasonCode, aucPeerMac, fgIsFromWhich);
if (fgIsFromWhich == 0) {
/* allocate/init packet */
prAdapter = prGlueInfo->prAdapter;
prBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
u4PktLen = 0;
prMsduInfo = kalPacketAlloc(prGlueInfo, 1600, &pPkt);
if (prMsduInfo == NULL) {
DBGLOG(TDLS, ERROR, "<tdls_cmd> %s: allocate pkt fail\n", __func__);
return;
}
prMsduInfo->dev = prGlueInfo->prDevHandler;
if (prMsduInfo->dev == NULL) {
DBGLOG(TDLS, ERROR, "<tdls_cmd> %s: MsduInfo->dev == NULL\n", __func__);
kalPacketFree(prGlueInfo, prMsduInfo);
return;
}
/* make up frame content */
/* 1. 802.3 header */
kalMemCopy(pPkt, prAdapter->rMyMacAddr, TDLS_FME_MAC_ADDR_LEN);
LR_TDLS_FME_FIELD_FILL(TDLS_FME_MAC_ADDR_LEN);
kalMemCopy(pPkt, aucPeerMac, TDLS_FME_MAC_ADDR_LEN);
LR_TDLS_FME_FIELD_FILL(TDLS_FME_MAC_ADDR_LEN);
*(UINT_16 *) pPkt = htons(TDLS_FRM_PROT_TYPE);
LR_TDLS_FME_FIELD_FILL(2);
/* 2. payload type */
*pPkt = TDLS_FRM_PAYLOAD_TYPE;
LR_TDLS_FME_FIELD_FILL(1);
/* 3. Frame Formation - (1) Category */
*pPkt = TDLS_FRM_CATEGORY;
LR_TDLS_FME_FIELD_FILL(1);
/* 3. Frame Formation - (2) Action */
*pPkt = TDLS_FRM_ACTION_TEARDOWN;
LR_TDLS_FME_FIELD_FILL(1);
/* 3. Frame Formation - (3) Reason Code */
*pPkt = ucReasonCode;
*(pPkt + 1) = 0x00;
LR_TDLS_FME_FIELD_FILL(2);
/* 3. Frame Formation - (16) Link identifier element */
TDLS_LINK_IDENTIFIER_IE(pPkt)->ucId = ELEM_ID_LINK_IDENTIFIER;
TDLS_LINK_IDENTIFIER_IE(pPkt)->ucLength = ELEM_LEN_LINK_IDENTIFIER;
kalMemCopy(TDLS_LINK_IDENTIFIER_IE(pPkt)->aBSSID, prBssInfo->aucBSSID, 6);
if (fgIsInitiator == 1) {
kalMemCopy(TDLS_LINK_IDENTIFIER_IE(pPkt)->aInitiator, aucPeerMac, 6);
kalMemCopy(TDLS_LINK_IDENTIFIER_IE(pPkt)->aResponder, prAdapter->rMyMacAddr, 6);
} else {
kalMemCopy(TDLS_LINK_IDENTIFIER_IE(pPkt)->aInitiator, prAdapter->rMyMacAddr, 6);
kalMemCopy(TDLS_LINK_IDENTIFIER_IE(pPkt)->aResponder, aucPeerMac, 6);
}
u4IeLen = IE_SIZE(pPkt);
LR_TDLS_FME_FIELD_FILL(u4IeLen);
/* 4. Update packet length */
prMsduInfo->len = u4PktLen;
dumpMemory8(prMsduInfo->data, u4PktLen);
/* pass to OS */
TdlsCmdTestRxIndicatePkts(prGlueInfo, prMsduInfo);
} else {
kalMemZero(&rCmd, sizeof(rCmd));
kalMemCopy(rCmd.aucPeerMac, aucPeerMac, 6);
rCmd.Content.rCmdTearDownRcv.u4ReasonCode = (UINT32) ucReasonCode;
/* command to do this */
rStatus = kalIoctl(prGlueInfo,
TdlsTestTearDownRecv, &rCmd, sizeof(rCmd), FALSE, FALSE, FALSE, FALSE, &u4BufLen);
if (rStatus != WLAN_STATUS_SUCCESS) {
DBGLOG(TDLS, ERROR, "%s kalIoctl fail:%x\n", __func__, rStatus);
return;
}
}
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to inform firmware to skip tx fail case.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
* EX: iwpriv wlan0 set_str_cmd 0_7_[Enable/Disable]
iwpriv wlan0 set_str_cmd 0_7_1
*/
/*----------------------------------------------------------------------------*/
static void TdlsCmdTestTxFailSkip(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen)
{
WLAN_STATUS rStatus;
TDLS_CMD_CORE_T rCmd;
UINT_32 u4BufLen;
/* parse arguments */
kalMemZero(rCmd.aucPeerMac, sizeof(rCmd.aucPeerMac));
rCmd.Content.rCmdTxFailSkip.fgIsEnable = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
DBGLOG(TDLS, INFO, "%s: fgIsEnable = %d\n", __func__, rCmd.Content.rCmdTxFailSkip.fgIsEnable);
/* command to do this */
rStatus = kalIoctl(prGlueInfo, TdlsTestTxFailSkip, &rCmd, sizeof(rCmd), FALSE, FALSE, FALSE, FALSE, &u4BufLen);
if (rStatus != WLAN_STATUS_SUCCESS) {
DBGLOG(TDLS, ERROR, "%s kalIoctl fail:%x\n", __func__, rStatus);
return;
}
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to send a test frame command to wifi task.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
* EX: iwpriv wlan0 set_str_cmd 0_12_0_[FrameType]_[DialogToken]_[Peer MAC]
iwpriv wlan0 set_str_cmd 0_12_0_0_1_00:11:22:33:44:01
*
* EX: iwpriv wlan0 set_str_cmd 0_12_2_[FrameType]_[DialogToken]_[Peer MAC]
iwpriv wlan0 set_str_cmd 0_12_2_0_1_00:11:22:33:44:01
*/
/*----------------------------------------------------------------------------*/
static void TdlsCmdTestTxTdlsFrame(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen)
{
PARAM_CUSTOM_TDLS_CMD_STRUCT_T rCmd;
UINT32 u4Subcmd;
UINT_32 u4BufLen;
/* parse sub-command */
u4Subcmd = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
DBGLOG(TDLS, INFO, "<tdls_cmd> test tx tdls frame sub command = %u\n", u4Subcmd);
/* parse command arguments */
rCmd.ucFmeType = CmdStringDecParse(prInBuf, &prInBuf, &u4BufLen);
switch (u4Subcmd) {
case TDLS_FRM_ACTION_SETUP_REQ:
case TDLS_FRM_ACTION_SETUP_RSP:
case TDLS_FRM_ACTION_CONFIRM:
rCmd.ucToken = CmdStringDecParse(prInBuf, &prInBuf, &u4BufLen);
CmdStringMacParse(prInBuf, &prInBuf, &u4InBufLen, rCmd.arRspAddr);
DBGLOG(TDLS, INFO, "<tdls_cmd> setup FmeType=%d Token=%d to [%pM]\n",
rCmd.ucFmeType, rCmd.ucToken, rCmd.arRspAddr);
break;
default:
DBGLOG(TDLS, ERROR, "<tdls_cmd> wrong test tx frame sub command\n");
return;
}
/* send command to wifi task to handle */
kalIoctl(prGlueInfo,
TdlsTestTdlsFrameSend,
(PVOID)&rCmd, sizeof(PARAM_CUSTOM_TDLS_CMD_STRUCT_T), FALSE, FALSE, TRUE, FALSE, &u4BufLen);
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to send a test frame command to wifi task.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
* EX: iwpriv wlan0 set_str_cmd 0_0_0_[FrameType]_[DialogToken]_[Cap]_[ExCap]_
[SupRate0]_[SupRate1]_[SupRate2]_[SupRate3]_
[SupChan0]_[SupChan1]_[SupChan2]_[SupChan3]_
[Timeout]_[Peer MAC]
iwpriv wlan0 set_str_cmd 0_0_0_0_1_1_7_0_0_0_0_0_0_0_0_300_00:11:22:33:44:01
*/
/*----------------------------------------------------------------------------*/
static void TdlsCmdTestTxFrame(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen)
{
PARAM_CUSTOM_TDLS_CMD_STRUCT_T rCmd;
TDLS_STATUS u4Status;
UINT_32 u4Subcmd;
UINT_32 u4BufLen;
/* parse sub-command */
u4Subcmd = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
DBGLOG(TDLS, INFO, "<tdls_cmd> test tx frame sub command = %u\n", (UINT32) u4Subcmd);
/* parse command arguments */
switch (u4Subcmd) {
case TDLS_FRM_ACTION_SETUP_REQ:
u4Status = TdlsCmdTestTxFmeSetupReqBufTranslate(prInBuf, u4InBufLen, &rCmd);
break;
default:
DBGLOG(TDLS, ERROR, "<tdls_cmd> wrong test tx frame sub command\n");
return;
}
if (u4Status != TDLS_STATUS_SUCCESS) {
DBGLOG(TDLS, ERROR, "<tdls_cmd> command parse fail\n");
return;
}
/* send command to wifi task to handle */
kalIoctl(prGlueInfo,
TdlsTestFrameSend,
(PVOID)&rCmd, sizeof(PARAM_CUSTOM_TDLS_CMD_STRUCT_T), FALSE, FALSE, TRUE, FALSE, &u4BufLen);
}
/*----------------------------------------------------------------------------*/
/*!
* @brief Parse the TDLS test frame command, setup request
*
* @param CmdBuf Pointer to the buffer.
* @param BufLen Record buffer length.
* @param CmdTspec Pointer to the structure.
*
* @retval WLAN_STATUS_SUCCESS: Translate OK.
* @retval WLAN_STATUS_FAILURE: Translate fail.
* @usage iwpriv wlan0 set_str_cmd [tdls]_[command]
*
* EX: iwpriv wlan0 set_str_cmd 0_0_0_[FrameType]_[DialogToken]_[Cap]_[ExCap]_
[SupRate0]_[SupRate1]_[SupRate2]_[SupRate3]_
[SupChan0]_[SupChan1]_[SupChan2]_[SupChan3]_
[Timeout]_[Peer MAC]
iwpriv wlan0 set_str_cmd 0_0_0_0_1_1_7_0_0_0_0_0_0_0_0_300_00:11:22:33:44:01
*/
/*----------------------------------------------------------------------------*/
static TDLS_STATUS
TdlsCmdTestTxFmeSetupReqBufTranslate(UINT_8 *pCmdBuf, UINT_32 u4BufLen, PARAM_CUSTOM_TDLS_CMD_STRUCT_T *prCmd)
{
/* dumpMemory8(ANDROID_LOG_INFO, pCmdBuf, u4BufLen); */
prCmd->ucFmeType = CmdStringDecParse(pCmdBuf, &pCmdBuf, &u4BufLen);
prCmd->ucToken = CmdStringDecParse(pCmdBuf, &pCmdBuf, &u4BufLen);
prCmd->u2Cap = CmdStringDecParse(pCmdBuf, &pCmdBuf, &u4BufLen);
prCmd->ucExCap = CmdStringDecParse(pCmdBuf, &pCmdBuf, &u4BufLen);
prCmd->arSupRate[0] = CmdStringDecParse(pCmdBuf, &pCmdBuf, &u4BufLen);
prCmd->arSupRate[1] = CmdStringDecParse(pCmdBuf, &pCmdBuf, &u4BufLen);
prCmd->arSupRate[2] = CmdStringDecParse(pCmdBuf, &pCmdBuf, &u4BufLen);
prCmd->arSupRate[3] = CmdStringDecParse(pCmdBuf, &pCmdBuf, &u4BufLen);
prCmd->arSupChan[0] = CmdStringDecParse(pCmdBuf, &pCmdBuf, &u4BufLen);
prCmd->arSupChan[1] = CmdStringDecParse(pCmdBuf, &pCmdBuf, &u4BufLen);
prCmd->arSupChan[2] = CmdStringDecParse(pCmdBuf, &pCmdBuf, &u4BufLen);
prCmd->arSupChan[3] = CmdStringDecParse(pCmdBuf, &pCmdBuf, &u4BufLen);
prCmd->u4Timeout = CmdStringDecParse(pCmdBuf, &pCmdBuf, &u4BufLen);
CmdStringMacParse(pCmdBuf, &pCmdBuf, &u4BufLen, prCmd->arRspAddr);
DBGLOG(TDLS, INFO, "<tdls_cmd> command content =\n");
DBGLOG(TDLS, INFO, "\tPeer MAC = %pM\n", (prCmd->arRspAddr));
DBGLOG(TDLS, INFO, "\tToken = %u, Cap = 0x%x, ExCap = 0x%x, Timeout = %us FrameType = %u\n",
(UINT32) prCmd->ucToken, prCmd->u2Cap, prCmd->ucExCap,
(UINT32) prCmd->u4Timeout, (UINT32) prCmd->ucFmeType);
DBGLOG(TDLS, INFO, "\tSupRate = 0x%x %x %x %x\n",
prCmd->arSupRate[0], prCmd->arSupRate[1], prCmd->arSupRate[2], prCmd->arSupRate[3]);
DBGLOG(TDLS, INFO, "\tSupChan = %d %d %d %d\n",
prCmd->arSupChan[0], prCmd->arSupChan[1], prCmd->arSupChan[2], prCmd->arSupChan[3]);
return TDLS_STATUS_SUCCESS;
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to update a TDLS peer.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
* EX: iwpriv wlan0 set_str_cmd 0_3_[Responder MAC]
iwpriv wlan0 set_str_cmd 0_3_00:11:22:33:44:01
*/
/*----------------------------------------------------------------------------*/
static void TdlsCmdTestUpdatePeer(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen)
{
PARAM_CUSTOM_TDLS_CMD_STRUCT_T rCmd;
struct wireless_dev *prWdev;
/* reset */
kalMemZero(&rCmd, sizeof(rCmd));
/* parse arguments */
CmdStringMacParse(prInBuf, &prInBuf, &u4InBufLen, rCmd.arRspAddr);
/* init */
rCmd.rPeerInfo.supported_rates = rCmd.arSupRate;
rCmd.rPeerInfo.ht_capa = &rCmd.rHtCapa;
rCmd.rPeerInfo.vht_capa = &rCmd.rVhtCapa; /* LINUX_KERNEL_VERSION >= 3.10.0 */
rCmd.rPeerInfo.sta_flags_set = BIT(NL80211_STA_FLAG_TDLS_PEER);
rCmd.rPeerInfo.uapsd_queues = 0xf; /* all AC */
rCmd.rPeerInfo.max_sp = 0; /* delivery all packets */
/* send command to wifi task to handle */
prWdev = prGlueInfo->prDevHandler->ieee80211_ptr;
mtk_cfg80211_add_station(prWdev->wiphy, (void *)0x1, rCmd.arRspAddr, &rCmd.rPeerInfo);
/* update */
TdlsexCfg80211TdlsOper(prWdev->wiphy, (void *)0x1, rCmd.arRspAddr, NL80211_TDLS_ENABLE_LINK);
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to receive a Null frame from the peer.
*
* \param[in] prAdapter Pointer to the Adapter structure
* \param[in] pvSetBuffer A pointer to the buffer that holds the data to be set
* \param[in] u4SetBufferLen The length of the set buffer
* \param[out] pu4SetInfoLen If the call is successful, returns the number of
* bytes read from the set buffer. If the call failed due to invalid length of
* the set buffer, returns the amount of storage needed.
*
* \retval TDLS_STATUS_xx
*
* EX: iwpriv wlan0 set_str_cmd 0_5_[Responder MAC]_[PM bit]
iwpriv wlan0 set_str_cmd 0_5_00:11:22:33:44:01_1
*/
/*----------------------------------------------------------------------------*/
static void TdlsCmdTestNullRecv(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen)
{
WLAN_STATUS rStatus;
TDLS_CMD_CORE_T rCmd;
UINT_32 u4BufLen;
/* parse arguments */
CmdStringMacParse(prInBuf, &prInBuf, &u4InBufLen, rCmd.aucPeerMac);
rCmd.Content.rCmdNullRcv.u4PM = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
DBGLOG(TDLS, INFO, "%s: [%pM] u4PM = %u\n",
__func__, (rCmd.aucPeerMac), (UINT32) rCmd.Content.rCmdNullRcv.u4PM);
/* command to do this */
rStatus = kalIoctl(prGlueInfo, TdlsTestNullRecv, &rCmd, sizeof(rCmd), FALSE, FALSE, FALSE, FALSE, &u4BufLen);
if (rStatus != WLAN_STATUS_SUCCESS) {
DBGLOG(TDLS, ERROR, "%s kalIoctl fail:%x\n", __func__, rStatus);
return;
}
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to send a data frame to the peer periodically.
*
* \param[in] prAdapter Pointer to the Adapter structure
* \param[in] u4Param no use
* \param[out] None
*
* \retval None
*
* EX: iwpriv wlan0 set_str_cmd 0_15_[Responder MAC]_[Interval: ms]_[Enable/Disable]
iwpriv wlan0 set_str_cmd 0_15_00:11:22:33:44:01_5000_1
*/
/*----------------------------------------------------------------------------*/
static VOID TdlsTimerTestDataContSend(ADAPTER_T *prAdapter, UINT_32 u4Param)
{
GLUE_INFO_T *prGlueInfo;
struct sk_buff *prMsduInfo;
UINT_8 *prPkt;
/* init */
prGlueInfo = prAdapter->prGlueInfo;
/* allocate a data frame */
prMsduInfo = kalPacketAlloc(prGlueInfo, 1000, &prPkt);
if (prMsduInfo == NULL) {
DBGLOG(TDLS, ERROR, "<tdls_cmd> %s allocate pkt fail!\n", __func__);
return;
}
/* init dev */
prMsduInfo->dev = prGlueInfo->prDevHandler;
if (prMsduInfo->dev == NULL) {
DBGLOG(TDLS, ERROR, "<tdls_cmd> %s prMsduInfo->dev == NULL!\n", __func__);
kalPacketFree(prGlueInfo, prMsduInfo);
return;
}
/* init packet */
prMsduInfo->len = 1000;
kalMemCopy(prMsduInfo->data, aucTdlsTestDataSPeerMac, 6);
kalMemCopy(prMsduInfo->data + 6, prAdapter->rMyMacAddr, 6);
*(UINT_16 *) (prMsduInfo->data + 12) = 0x0800;
DBGLOG(TDLS, INFO, "<tdls_cmd> %s try to send a data frame to %pM\n",
__func__, aucTdlsTestDataSPeerMac);
/* simulate OS to send the packet */
wlanHardStartXmit(prMsduInfo, prMsduInfo->dev);
/* restart test timer */
cnmTimerStartTimer(prAdapter, &rTdlsTimerTestDataSend, u2TdlsTestDataSInterval);
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to receive a Channel Switch Request frame.
*
* \param[in] prAdapter Pointer to the Adapter structure
* \param[in] pvSetBuffer A pointer to the buffer that holds the data to be set
* \param[in] u4SetBufferLen The length of the set buffer
* \param[out] pu4SetInfoLen If the call is successful, returns the number of
* bytes read from the set buffer. If the call failed due to invalid length of
* the set buffer, returns the amount of storage needed.
*
* \retval TDLS_STATUS_xx
*
*/
/*----------------------------------------------------------------------------*/
static TDLS_STATUS
TdlsTestChStReqRecv(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen)
{
TDLS_CMD_CORE_T *prCmdContent;
WLAN_STATUS rStatus;
/* init command buffer */
prCmdContent = (TDLS_CMD_CORE_T *) pvSetBuffer;
prCmdContent->u4Command = TDLS_CORE_CMD_TEST_CHSW_REQ;
/* send the command */
rStatus = wlanSendSetQueryCmd(prAdapter, /* prAdapter */
CMD_ID_TDLS_CORE, /* ucCID */
TRUE, /* fgSetQuery */
FALSE, /* fgNeedResp */
FALSE, /* fgIsOid */
NULL, NULL, /* pfCmdTimeoutHandler */
sizeof(TDLS_CMD_CORE_T), /* u4SetQueryInfoLen */
(PUINT_8) prCmdContent, /* pucInfoBuffer */
NULL, /* pvSetQueryBuffer */
0 /* u4SetQueryBufferLen */
);
if (rStatus != WLAN_STATUS_PENDING) {
DBGLOG(TDLS, ERROR, "%s wlanSendSetQueryCmd allocation fail!\n", __func__);
return TDLS_STATUS_RESOURCES;
}
DBGLOG(TDLS, INFO, "%s cmd ok.\n", __func__);
return TDLS_STATUS_SUCCESS;
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to receive a Channel Switch Response frame.
*
* \param[in] prAdapter Pointer to the Adapter structure
* \param[in] pvSetBuffer A pointer to the buffer that holds the data to be set
* \param[in] u4SetBufferLen The length of the set buffer
* \param[out] pu4SetInfoLen If the call is successful, returns the number of
* bytes read from the set buffer. If the call failed due to invalid length of
* the set buffer, returns the amount of storage needed.
*
* \retval TDLS_STATUS_xx
*
*/
/*----------------------------------------------------------------------------*/
static TDLS_STATUS
TdlsTestChStRspRecv(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen)
{
TDLS_CMD_CORE_T *prCmdContent;
WLAN_STATUS rStatus;
/* init command buffer */
prCmdContent = (TDLS_CMD_CORE_T *) pvSetBuffer;
prCmdContent->u4Command = TDLS_CORE_CMD_TEST_CHSW_RSP;
/* send the command */
rStatus = wlanSendSetQueryCmd(prAdapter, /* prAdapter */
CMD_ID_TDLS_CORE, /* ucCID */
TRUE, /* fgSetQuery */
FALSE, /* fgNeedResp */
FALSE, /* fgIsOid */
NULL, NULL, /* pfCmdTimeoutHandler */
sizeof(TDLS_CMD_CORE_T), /* u4SetQueryInfoLen */
(PUINT_8) prCmdContent, /* pucInfoBuffer */
NULL, /* pvSetQueryBuffer */
0 /* u4SetQueryBufferLen */
);
if (rStatus != WLAN_STATUS_PENDING) {
DBGLOG(TDLS, ERROR, "%s wlanSendSetQueryCmd allocation fail!\n", __func__);
return TDLS_STATUS_RESOURCES;
}
DBGLOG(TDLS, INFO, "%s cmd ok.\n", __func__);
return TDLS_STATUS_SUCCESS;
}
/*----------------------------------------------------------------------------*/
/*!
* \brief This routine is called to send a test frame.
*
* \param[in] prAdapter Pointer to the Adapter structure
* \param[in] pvSetBuffer A pointer to the buffer that holds the data to be set
* \param[in] u4SetBufferLen The length of the set buffer
* \param[out] pu4SetInfoLen If the call is successful, returns the number of
* bytes read from the set buffer. If the call failed due to invalid length of
* the set buffer, returns the amount of storage needed.
*
* \retval TDLS_STATUS_xx
*
*/
/*----------------------------------------------------------------------------*/
static TDLS_STATUS
TdlsTestFrameSend(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen)
{
GLUE_INFO_T *prGlueInfo;
PARAM_CUSTOM_TDLS_CMD_STRUCT_T *prCmd;
P_BSS_INFO_T prBssInfo;
struct sk_buff *prMsduInfo;
UINT_8 *pPkt;
UINT_32 u4PktLen, u4IeLen;
/* sanity check */
ASSERT(prAdapter);
ASSERT(pvSetBuffer);
ASSERT(pu4SetInfoLen);
DBGLOG(TDLS, INFO, "<tdls_fme> %s\n", __func__);
if (u4SetBufferLen == 0)
return TDLS_STATUS_INVALID_LENGTH;
/* allocate/init packet */
prGlueInfo = (GLUE_INFO_T *) prAdapter->prGlueInfo;
prCmd = (PARAM_CUSTOM_TDLS_CMD_STRUCT_T *) pvSetBuffer;
prBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
*pu4SetInfoLen = u4SetBufferLen;
u4PktLen = 0;
prMsduInfo = kalPacketAlloc(prGlueInfo, 1600, &pPkt);
if (prMsduInfo == NULL) {
DBGLOG(TDLS, ERROR, "<tdls_cmd> %s: allocate pkt fail\n", __func__);
return TDLS_STATUS_RESOURCES;
}
prMsduInfo->dev = prGlueInfo->prDevHandler;
if (prMsduInfo->dev == NULL) {
DBGLOG(TDLS, ERROR, "<tdls_cmd> %s: MsduInfo->dev == NULL\n", __func__);
kalPacketFree(prGlueInfo, prMsduInfo);
return TDLS_STATUS_FAILURE;
}
/* make up frame content */
/* 1. 802.3 header */
kalMemCopy(pPkt, prCmd->arRspAddr, TDLS_FME_MAC_ADDR_LEN);
LR_TDLS_FME_FIELD_FILL(TDLS_FME_MAC_ADDR_LEN);
kalMemCopy(pPkt, prAdapter->rMyMacAddr, TDLS_FME_MAC_ADDR_LEN);
LR_TDLS_FME_FIELD_FILL(TDLS_FME_MAC_ADDR_LEN);
*(UINT_16 *) pPkt = htons(TDLS_FRM_PROT_TYPE);
LR_TDLS_FME_FIELD_FILL(2);
/* 2. payload type */
*pPkt = TDLS_FRM_PAYLOAD_TYPE;
LR_TDLS_FME_FIELD_FILL(1);
/* 3. Frame Formation - (1) Category */
*pPkt = TDLS_FRM_CATEGORY;
LR_TDLS_FME_FIELD_FILL(1);
/* 3. Frame Formation - (2) Action */
*pPkt = prCmd->ucFmeType;
LR_TDLS_FME_FIELD_FILL(1);
/* 3. Frame Formation - (3) Dialog token */
*pPkt = prCmd->ucToken;
LR_TDLS_FME_FIELD_FILL(1);
/* 3. Frame Formation - (4) Capability */
WLAN_SET_FIELD_16(pPkt, prCmd->u2Cap);
LR_TDLS_FME_FIELD_FILL(2);
/* 4. Append general IEs */
u4IeLen = TdlsFrameGeneralIeAppend(prAdapter, NULL, 0, pPkt);
LR_TDLS_FME_FIELD_FILL(u4IeLen);
/* 3. Frame Formation - (10) Extended capabilities element */
EXT_CAP_IE(pPkt)->ucId = ELEM_ID_EXTENDED_CAP;
EXT_CAP_IE(pPkt)->ucLength = 5;
EXT_CAP_IE(pPkt)->aucCapabilities[0] = 0x00; /* bit0 ~ bit7 */
EXT_CAP_IE(pPkt)->aucCapabilities[1] = 0x00; /* bit8 ~ bit15 */
EXT_CAP_IE(pPkt)->aucCapabilities[2] = 0x00; /* bit16 ~ bit23 */
EXT_CAP_IE(pPkt)->aucCapabilities[3] = 0x00; /* bit24 ~ bit31 */
EXT_CAP_IE(pPkt)->aucCapabilities[4] = 0x00; /* bit32 ~ bit39 */
if (prCmd->ucExCap & TDLS_EX_CAP_PEER_UAPSD)
EXT_CAP_IE(pPkt)->aucCapabilities[3] |= BIT((28 - 24));
if (prCmd->ucExCap & TDLS_EX_CAP_CHAN_SWITCH)
EXT_CAP_IE(pPkt)->aucCapabilities[3] |= BIT((30 - 24));
if (prCmd->ucExCap & TDLS_EX_CAP_TDLS)
EXT_CAP_IE(pPkt)->aucCapabilities[4] |= BIT((37 - 32));
u4IeLen = IE_SIZE(pPkt);
LR_TDLS_FME_FIELD_FILL(u4IeLen);
/* 3. Frame Formation - (12) Timeout interval element (TPK Key Lifetime) */
TIMEOUT_INTERVAL_IE(pPkt)->ucId = ELEM_ID_TIMEOUT_INTERVAL;
TIMEOUT_INTERVAL_IE(pPkt)->ucLength = 5;
TIMEOUT_INTERVAL_IE(pPkt)->ucType = IE_TIMEOUT_INTERVAL_TYPE_KEY_LIFETIME;
TIMEOUT_INTERVAL_IE(pPkt)->u4Value = htonl(prCmd->u4Timeout);
u4IeLen = IE_SIZE(pPkt);
LR_TDLS_FME_FIELD_FILL(u4IeLen);
/* 3. Frame Formation - (16) Link identifier element */
TDLS_LINK_IDENTIFIER_IE(pPkt)->ucId = ELEM_ID_LINK_IDENTIFIER;
TDLS_LINK_IDENTIFIER_IE(pPkt)->ucLength = ELEM_LEN_LINK_IDENTIFIER;
kalMemCopy(TDLS_LINK_IDENTIFIER_IE(pPkt)->aBSSID, prBssInfo->aucBSSID, 6);
kalMemCopy(TDLS_LINK_IDENTIFIER_IE(pPkt)->aInitiator, prAdapter->rMyMacAddr, 6);
kalMemCopy(TDLS_LINK_IDENTIFIER_IE(pPkt)->aResponder, prCmd->arRspAddr, 6);
u4IeLen = IE_SIZE(pPkt);
LR_TDLS_FME_FIELD_FILL(u4IeLen);
/* 4. Update packet length */
prMsduInfo->len = u4PktLen;
dumpMemory8(prMsduInfo->data, u4PktLen);
/* 5. send the data frame */
wlanHardStartXmit(prMsduInfo, prMsduInfo->dev);
return TDLS_STATUS_SUCCESS;
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to receive a NULL frame.
*
* \param[in] prAdapter Pointer to the Adapter structure
* \param[in] pvSetBuffer A pointer to the buffer that holds the data to be set
* \param[in] u4SetBufferLen The length of the set buffer
* \param[out] pu4SetInfoLen If the call is successful, returns the number of
* bytes read from the set buffer. If the call failed due to invalid length of
* the set buffer, returns the amount of storage needed.
*
* \retval TDLS_STATUS_xx
*
*/
/*----------------------------------------------------------------------------*/
static TDLS_STATUS
TdlsTestNullRecv(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen)
{
TDLS_CMD_CORE_T *prCmdContent;
WLAN_STATUS rStatus;
/* init command buffer */
prCmdContent = (TDLS_CMD_CORE_T *) pvSetBuffer;
prCmdContent->u4Command = TDLS_CORE_CMD_TEST_NULL_RCV;
/* send the command */
rStatus = wlanSendSetQueryCmd(prAdapter, /* prAdapter */
CMD_ID_TDLS_CORE, /* ucCID */
TRUE, /* fgSetQuery */
FALSE, /* fgNeedResp */
FALSE, /* fgIsOid */
NULL, NULL, /* pfCmdTimeoutHandler */
sizeof(TDLS_CMD_CORE_T), /* u4SetQueryInfoLen */
(PUINT_8) prCmdContent, /* pucInfoBuffer */
NULL, /* pvSetQueryBuffer */
0 /* u4SetQueryBufferLen */
);
if (rStatus != WLAN_STATUS_PENDING) {
DBGLOG(TDLS, ERROR, "%s wlanSendSetQueryCmd allocation fail!\n", __func__);
return TDLS_STATUS_RESOURCES;
}
DBGLOG(TDLS, INFO, "%s cmd ok.\n", __func__);
return TDLS_STATUS_SUCCESS;
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to receive a PTI frame.
*
* \param[in] prAdapter Pointer to the Adapter structure
* \param[in] pvSetBuffer A pointer to the buffer that holds the data to be set
* \param[in] u4SetBufferLen The length of the set buffer
* \param[out] pu4SetInfoLen If the call is successful, returns the number of
* bytes read from the set buffer. If the call failed due to invalid length of
* the set buffer, returns the amount of storage needed.
*
* \retval TDLS_STATUS_xx
*
*/
/*----------------------------------------------------------------------------*/
static TDLS_STATUS
TdlsTestPtiReqRecv(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen)
{
TDLS_CMD_CORE_T *prCmdContent;
WLAN_STATUS rStatus;
/* init command buffer */
prCmdContent = (TDLS_CMD_CORE_T *) pvSetBuffer;
prCmdContent->u4Command = TDLS_CORE_CMD_TEST_PTI_REQ;
/* send the command */
rStatus = wlanSendSetQueryCmd(prAdapter, /* prAdapter */
CMD_ID_TDLS_CORE, /* ucCID */
TRUE, /* fgSetQuery */
FALSE, /* fgNeedResp */
FALSE, /* fgIsOid */
NULL, NULL, /* pfCmdTimeoutHandler */
sizeof(TDLS_CMD_CORE_T), /* u4SetQueryInfoLen */
(PUINT_8) prCmdContent, /* pucInfoBuffer */
NULL, /* pvSetQueryBuffer */
0 /* u4SetQueryBufferLen */
);
if (rStatus != WLAN_STATUS_PENDING) {
DBGLOG(TDLS, ERROR, "%s wlanSendSetQueryCmd allocation fail!\n", __func__);
return TDLS_STATUS_RESOURCES;
}
DBGLOG(TDLS, INFO, "%s cmd ok.\n", __func__);
return TDLS_STATUS_SUCCESS;
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to receive a PTI response frame.
*
* \param[in] prAdapter Pointer to the Adapter structure
* \param[in] pvSetBuffer A pointer to the buffer that holds the data to be set
* \param[in] u4SetBufferLen The length of the set buffer
* \param[out] pu4SetInfoLen If the call is successful, returns the number of
* bytes read from the set buffer. If the call failed due to invalid length of
* the set buffer, returns the amount of storage needed.
*
* \retval TDLS_STATUS_xx
*
*/
/*----------------------------------------------------------------------------*/
static TDLS_STATUS
TdlsTestPtiRspRecv(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen)
{
TDLS_CMD_CORE_T *prCmdContent;
WLAN_STATUS rStatus;
/* init command buffer */
prCmdContent = (TDLS_CMD_CORE_T *) pvSetBuffer;
prCmdContent->u4Command = TDLS_CORE_CMD_TEST_PTI_RSP;
/* send the command */
rStatus = wlanSendSetQueryCmd(prAdapter, /* prAdapter */
CMD_ID_TDLS_CORE, /* ucCID */
TRUE, /* fgSetQuery */
FALSE, /* fgNeedResp */
FALSE, /* fgIsOid */
NULL, NULL, /* pfCmdTimeoutHandler */
sizeof(TDLS_CMD_CORE_T), /* u4SetQueryInfoLen */
(PUINT_8) prCmdContent, /* pucInfoBuffer */
NULL, /* pvSetQueryBuffer */
0 /* u4SetQueryBufferLen */
);
if (rStatus != WLAN_STATUS_PENDING) {
DBGLOG(TDLS, ERROR, "%s wlanSendSetQueryCmd allocation fail!\n", __func__);
return TDLS_STATUS_RESOURCES;
}
DBGLOG(TDLS, INFO, "%s cmd ok.\n", __func__);
return TDLS_STATUS_SUCCESS;
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to receive a Tear Down frame.
*
* \param[in] prAdapter Pointer to the Adapter structure
* \param[in] pvSetBuffer A pointer to the buffer that holds the data to be set
* \param[in] u4SetBufferLen The length of the set buffer
* \param[out] pu4SetInfoLen If the call is successful, returns the number of
* bytes read from the set buffer. If the call failed due to invalid length of
* the set buffer, returns the amount of storage needed.
*
* \retval TDLS_STATUS_xx
*
*/
/*----------------------------------------------------------------------------*/
static TDLS_STATUS
TdlsTestTearDownRecv(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen)
{
TDLS_CMD_CORE_T *prCmdContent;
WLAN_STATUS rStatus;
/* init command buffer */
prCmdContent = (TDLS_CMD_CORE_T *) pvSetBuffer;
prCmdContent->u4Command = TDLS_CORE_CMD_TEST_TEAR_DOWN;
/* send the command */
rStatus = wlanSendSetQueryCmd(prAdapter, /* prAdapter */
CMD_ID_TDLS_CORE, /* ucCID */
TRUE, /* fgSetQuery */
FALSE, /* fgNeedResp */
FALSE, /* fgIsOid */
NULL, NULL, /* pfCmdTimeoutHandler */
sizeof(TDLS_CMD_CORE_T), /* u4SetQueryInfoLen */
(PUINT_8) prCmdContent, /* pucInfoBuffer */
NULL, /* pvSetQueryBuffer */
0 /* u4SetQueryBufferLen */
);
if (rStatus != WLAN_STATUS_PENDING) {
DBGLOG(TDLS, ERROR, "%s wlanSendSetQueryCmd allocation fail!\n", __func__);
return TDLS_STATUS_RESOURCES;
}
DBGLOG(TDLS, INFO, "%s cmd ok.\n", __func__);
return TDLS_STATUS_SUCCESS;
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to receive a data frame.
*
* \param[in] prAdapter Pointer to the Adapter structure
* \param[in] pvSetBuffer A pointer to the buffer that holds the data to be set
* \param[in] u4SetBufferLen The length of the set buffer
* \param[out] pu4SetInfoLen If the call is successful, returns the number of
* bytes read from the set buffer. If the call failed due to invalid length of
* the set buffer, returns the amount of storage needed.
*
* \retval TDLS_STATUS_xx
*
*/
/*----------------------------------------------------------------------------*/
static TDLS_STATUS
TdlsTestDataRecv(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen)
{
TDLS_CMD_CORE_T *prCmdContent;
WLAN_STATUS rStatus;
/* init command buffer */
prCmdContent = (TDLS_CMD_CORE_T *) pvSetBuffer;
prCmdContent->u4Command = TDLS_CORE_CMD_TEST_DATA_RCV;
/* send the command */
rStatus = wlanSendSetQueryCmd(prAdapter, /* prAdapter */
CMD_ID_TDLS_CORE, /* ucCID */
TRUE, /* fgSetQuery */
FALSE, /* fgNeedResp */
FALSE, /* fgIsOid */
NULL, NULL, /* pfCmdTimeoutHandler */
sizeof(TDLS_CMD_CORE_T), /* u4SetQueryInfoLen */
(PUINT_8) prCmdContent, /* pucInfoBuffer */
NULL, /* pvSetQueryBuffer */
0 /* u4SetQueryBufferLen */
);
if (rStatus != WLAN_STATUS_PENDING) {
DBGLOG(TDLS, ERROR, "%s wlanSendSetQueryCmd allocation fail!\n", __func__);
return TDLS_STATUS_RESOURCES;
}
DBGLOG(TDLS, INFO, "%s cmd ok.\n", __func__);
return TDLS_STATUS_SUCCESS;
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to skip PTI tx fail status.
*
* \param[in] prAdapter Pointer to the Adapter structure
* \param[in] pvSetBuffer A pointer to the buffer that holds the data to be set
* \param[in] u4SetBufferLen The length of the set buffer
* \param[out] pu4SetInfoLen If the call is successful, returns the number of
* bytes read from the set buffer. If the call failed due to invalid length of
* the set buffer, returns the amount of storage needed.
*
* \retval TDLS_STATUS_xx
*
*/
/*----------------------------------------------------------------------------*/
static TDLS_STATUS
TdlsTestPtiTxFail(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen)
{
TDLS_CMD_CORE_T *prCmdContent;
WLAN_STATUS rStatus;
/* init command buffer */
prCmdContent = (TDLS_CMD_CORE_T *) pvSetBuffer;
prCmdContent->u4Command = TDLS_CORE_CMD_TEST_PTI_TX_FAIL;
/* send the command */
rStatus = wlanSendSetQueryCmd(prAdapter, /* prAdapter */
CMD_ID_TDLS_CORE, /* ucCID */
TRUE, /* fgSetQuery */
FALSE, /* fgNeedResp */
FALSE, /* fgIsOid */
NULL, NULL, /* pfCmdTimeoutHandler */
sizeof(TDLS_CMD_CORE_T), /* u4SetQueryInfoLen */
(PUINT_8) prCmdContent, /* pucInfoBuffer */
NULL, /* pvSetQueryBuffer */
0 /* u4SetQueryBufferLen */
);
if (rStatus != WLAN_STATUS_PENDING) {
DBGLOG(TDLS, ERROR, "%s wlanSendSetQueryCmd allocation fail!\n", __func__);
return TDLS_STATUS_RESOURCES;
}
DBGLOG(TDLS, INFO, "%s cmd ok.\n", __func__);
return TDLS_STATUS_SUCCESS;
}
/*----------------------------------------------------------------------------*/
/*!
* \brief This routine is called to send a TDLS action frame.
*
* \param[in] prAdapter Pointer to the Adapter structure
* \param[in] pvSetBuffer A pointer to the buffer that holds the data to be set
* \param[in] u4SetBufferLen The length of the set buffer
* \param[out] pu4SetInfoLen If the call is successful, returns the number of
* bytes read from the set buffer. If the call failed due to invalid length of
* the set buffer, returns the amount of storage needed.
*
* \retval TDLS_STATUS_xx
*
* EX: iwpriv wlan0 set_str_cmd 0_12_0_[FrameType]_[DialogToken]_[Peer MAC]
iwpriv wlan0 set_str_cmd 0_12_0_0_1_00:11:22:33:44:01
*/
/*----------------------------------------------------------------------------*/
static TDLS_STATUS
TdlsTestTdlsFrameSend(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen)
{
GLUE_INFO_T *prGlueInfo;
PARAM_CUSTOM_TDLS_CMD_STRUCT_T *prCmd;
struct wireless_dev *prWdev;
/* sanity check */
ASSERT(prAdapter);
ASSERT(pvSetBuffer);
ASSERT(pu4SetInfoLen);
DBGLOG(TDLS, INFO, "<tdls_fme> %s\n", __func__);
if (u4SetBufferLen == 0)
return TDLS_STATUS_INVALID_LENGTH;
/* allocate/init packet */
prGlueInfo = (GLUE_INFO_T *) prAdapter->prGlueInfo;
prCmd = (PARAM_CUSTOM_TDLS_CMD_STRUCT_T *) pvSetBuffer;
prWdev = (struct wireless_dev *)prGlueInfo->prDevHandler->ieee80211_ptr;
TdlsexCfg80211TdlsMgmt(prWdev->wiphy, NULL,
prCmd->arRspAddr, prCmd->ucFmeType, 1,
0, 0, /* open/none */
FALSE, NULL, 0);
return TDLS_STATUS_SUCCESS;
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to skip tx fail status. So always success in tx done in firmware.
*
* \param[in] prAdapter Pointer to the Adapter structure
* \param[in] pvSetBuffer A pointer to the buffer that holds the data to be set
* \param[in] u4SetBufferLen The length of the set buffer
* \param[out] pu4SetInfoLen If the call is successful, returns the number of
* bytes read from the set buffer. If the call failed due to invalid length of
* the set buffer, returns the amount of storage needed.
*
* \retval TDLS_STATUS_xx
*
*/
/*----------------------------------------------------------------------------*/
static TDLS_STATUS
TdlsTestTxFailSkip(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen)
{
TDLS_CMD_CORE_T *prCmdContent;
WLAN_STATUS rStatus;
/* init command buffer */
prCmdContent = (TDLS_CMD_CORE_T *) pvSetBuffer;
prCmdContent->u4Command = TDLS_CORE_CMD_TEST_TX_FAIL_SKIP;
/* send the command */
rStatus = wlanSendSetQueryCmd(prAdapter, /* prAdapter */
CMD_ID_TDLS_CORE, /* ucCID */
TRUE, /* fgSetQuery */
FALSE, /* fgNeedResp */
FALSE, /* fgIsOid */
NULL, NULL, /* pfCmdTimeoutHandler */
sizeof(TDLS_CMD_CORE_T), /* u4SetQueryInfoLen */
(PUINT_8) prCmdContent, /* pucInfoBuffer */
NULL, /* pvSetQueryBuffer */
0 /* u4SetQueryBufferLen */
);
if (rStatus != WLAN_STATUS_PENDING) {
DBGLOG(TDLS, ERROR, "%s wlanSendSetQueryCmd allocation fail!\n", __func__);
return TDLS_STATUS_RESOURCES;
}
DBGLOG(TDLS, INFO, "%s cmd ok.\n", __func__);
return TDLS_STATUS_SUCCESS;
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to skip to do keep alive function in firmware.
*
* \param[in] prAdapter Pointer to the Adapter structure
* \param[in] pvSetBuffer A pointer to the buffer that holds the data to be set
* \param[in] u4SetBufferLen The length of the set buffer
* \param[out] pu4SetInfoLen If the call is successful, returns the number of
* bytes read from the set buffer. If the call failed due to invalid length of
* the set buffer, returns the amount of storage needed.
*
* \retval TDLS_STATUS_xx
*
*/
/*----------------------------------------------------------------------------*/
static TDLS_STATUS
TdlsTestKeepAliveSkip(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen)
{
TDLS_CMD_CORE_T *prCmdContent;
WLAN_STATUS rStatus;
/* init command buffer */
prCmdContent = (TDLS_CMD_CORE_T *) pvSetBuffer;
prCmdContent->u4Command = TDLS_CORE_CMD_TEST_KEEP_ALIVE_SKIP;
/* send the command */
rStatus = wlanSendSetQueryCmd(prAdapter, /* prAdapter */
CMD_ID_TDLS_CORE, /* ucCID */
TRUE, /* fgSetQuery */
FALSE, /* fgNeedResp */
FALSE, /* fgIsOid */
NULL, NULL, /* pfCmdTimeoutHandler */
sizeof(TDLS_CMD_CORE_T), /* u4SetQueryInfoLen */
(PUINT_8) prCmdContent, /* pucInfoBuffer */
NULL, /* pvSetQueryBuffer */
0 /* u4SetQueryBufferLen */
);
if (rStatus != WLAN_STATUS_PENDING) {
DBGLOG(TDLS, ERROR, "%s wlanSendSetQueryCmd allocation fail!\n", __func__);
return TDLS_STATUS_RESOURCES;
}
DBGLOG(TDLS, INFO, "%s cmd ok.\n", __func__);
return TDLS_STATUS_SUCCESS;
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to skip channel switch timeout.
*
* \param[in] prAdapter Pointer to the Adapter structure
* \param[in] pvSetBuffer A pointer to the buffer that holds the data to be set
* \param[in] u4SetBufferLen The length of the set buffer
* \param[out] pu4SetInfoLen If the call is successful, returns the number of
* bytes read from the set buffer. If the call failed due to invalid length of
* the set buffer, returns the amount of storage needed.
*
* \retval TDLS_STATUS_xx
*
*/
/*----------------------------------------------------------------------------*/
static TDLS_STATUS
TdlsTestChSwTimeoutSkip(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen)
{
TDLS_CMD_CORE_T *prCmdContent;
WLAN_STATUS rStatus;
/* init command buffer */
prCmdContent = (TDLS_CMD_CORE_T *) pvSetBuffer;
prCmdContent->u4Command = TDLS_CORE_CMD_TEST_CHSW_TIMEOUT_SKIP;
/* send the command */
rStatus = wlanSendSetQueryCmd(prAdapter, /* prAdapter */
CMD_ID_TDLS_CORE, /* ucCID */
TRUE, /* fgSetQuery */
FALSE, /* fgNeedResp */
FALSE, /* fgIsOid */
NULL, NULL, /* pfCmdTimeoutHandler */
sizeof(TDLS_CMD_CORE_T), /* u4SetQueryInfoLen */
(PUINT_8) prCmdContent, /* pucInfoBuffer */
NULL, /* pvSetQueryBuffer */
0 /* u4SetQueryBufferLen */
);
if (rStatus != WLAN_STATUS_PENDING) {
DBGLOG(TDLS, ERROR, "%s wlanSendSetQueryCmd allocation fail!\n", __func__);
return TDLS_STATUS_RESOURCES;
}
DBGLOG(TDLS, INFO, "%s cmd ok.\n", __func__);
return TDLS_STATUS_SUCCESS;
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to skip scan request.
*
* \param[in] prAdapter Pointer to the Adapter structure
* \param[in] pvSetBuffer A pointer to the buffer that holds the data to be set
* \param[in] u4SetBufferLen The length of the set buffer
* \param[out] pu4SetInfoLen If the call is successful, returns the number of
* bytes read from the set buffer. If the call failed due to invalid length of
* the set buffer, returns the amount of storage needed.
*
* \retval TDLS_STATUS_xx
*
*/
/*----------------------------------------------------------------------------*/
static TDLS_STATUS
TdlsTestScanSkip(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen)
{
TDLS_CMD_CORE_T *prCmdContent;
WLAN_STATUS rStatus;
/* init command buffer */
prCmdContent = (TDLS_CMD_CORE_T *) pvSetBuffer;
prCmdContent->u4Command = TDLS_CORE_CMD_TEST_SCAN_SKIP;
/* send the command */
rStatus = wlanSendSetQueryCmd(prAdapter, /* prAdapter */
CMD_ID_TDLS_CORE, /* ucCID */
TRUE, /* fgSetQuery */
FALSE, /* fgNeedResp */
FALSE, /* fgIsOid */
NULL, NULL, /* pfCmdTimeoutHandler */
sizeof(TDLS_CMD_CORE_T), /* u4SetQueryInfoLen */
(PUINT_8) prCmdContent, /* pucInfoBuffer */
NULL, /* pvSetQueryBuffer */
0 /* u4SetQueryBufferLen */
);
if (rStatus != WLAN_STATUS_PENDING) {
DBGLOG(TDLS, ERROR, "%s wlanSendSetQueryCmd allocation fail!\n", __func__);
return TDLS_STATUS_RESOURCES;
}
DBGLOG(TDLS, INFO, "%s cmd ok.\n", __func__);
return TDLS_STATUS_SUCCESS;
}
#endif /* TDLS_CFG_CMD_TEST */
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to configure channel switch parameters.
*
* \param[in] prAdapter Pointer to the Adapter structure
* \param[in] pvSetBuffer A pointer to the buffer that holds the data to be set
* \param[in] u4SetBufferLen The length of the set buffer
* \param[out] pu4SetInfoLen If the call is successful, returns the number of
* bytes read from the set buffer. If the call failed due to invalid length of
* the set buffer, returns the amount of storage needed.
*
* \retval TDLS_STATUS_xx
*
*/
/*----------------------------------------------------------------------------*/
static TDLS_STATUS
TdlsChSwConf(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen)
{
TDLS_CMD_CORE_T *prCmdContent;
WLAN_STATUS rStatus;
/* init command buffer */
prCmdContent = (TDLS_CMD_CORE_T *) pvSetBuffer;
prCmdContent->u4Command = TDLS_CORE_CMD_CHSW_CONF;
/* send the command */
rStatus = wlanSendSetQueryCmd(prAdapter, /* prAdapter */
CMD_ID_TDLS_CORE, /* ucCID */
TRUE, /* fgSetQuery */
FALSE, /* fgNeedResp */
FALSE, /* fgIsOid */
NULL, NULL, /* pfCmdTimeoutHandler */
sizeof(TDLS_CMD_CORE_T), /* u4SetQueryInfoLen */
(PUINT_8) prCmdContent, /* pucInfoBuffer */
NULL, /* pvSetQueryBuffer */
0 /* u4SetQueryBufferLen */
);
if (rStatus != WLAN_STATUS_PENDING) {
DBGLOG(TDLS, ERROR, "%s wlanSendSetQueryCmd allocation fail!\n", __func__);
return TDLS_STATUS_RESOURCES;
}
DBGLOG(TDLS, INFO, "%s cmd ok.\n", __func__);
return TDLS_STATUS_SUCCESS;
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to update channel switch parameters.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
* EX: iwpriv wlan0 set_str_cmd 0_9_[TDLS Peer MAC]_
[NetworkTypeIndex]_[1 (Enable) or (0) Disable]_[1 (Start) or 0 (Stop)]_
[RegClass]_[Chan]_[SecChanOff]_[1 (Reqular) or (0) One Shot]
RegulatoryClass: TODO (reference to Annex I of 802.11n spec.)
Secondary Channel Offset: 0 (SCN - no secondary channel)
1 (SCA - secondary channel above)
2 (SCB - secondary channel below)
SwitchTime: units of microseconds
iwpriv wlan0 set_str_cmd 0_9_00:11:22:33:44:01_0_1_0_0_1_0_0
*/
/*----------------------------------------------------------------------------*/
static void TdlsCmdChSwConf(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen)
{
WLAN_STATUS rStatus;
TDLS_CMD_CORE_T rCmd;
UINT_32 u4BufLen;
/* parse arguments */
CmdStringMacParse(prInBuf, &prInBuf, &u4InBufLen, rCmd.aucPeerMac);
rCmd.Content.rCmdChSwConf.ucNetTypeIndex = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
rCmd.Content.rCmdChSwConf.fgIsChSwEnabled = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
rCmd.Content.rCmdChSwConf.fgIsChSwStarted = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
rCmd.Content.rCmdChSwConf.ucRegClass = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
rCmd.Content.rCmdChSwConf.ucTargetChan = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
rCmd.Content.rCmdChSwConf.ucSecChanOff = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
rCmd.Content.rCmdChSwConf.fgIsChSwRegular = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
DBGLOG(TDLS, INFO, "%s: %pM ucNetTypeIndex=%d, fgIsChSwEnabled=%d, fgIsChSwStarted=%d",
__func__, (rCmd.aucPeerMac),
rCmd.Content.rCmdChSwConf.ucNetTypeIndex,
rCmd.Content.rCmdChSwConf.fgIsChSwEnabled,
rCmd.Content.rCmdChSwConf.fgIsChSwStarted);
DBGLOG(TDLS, INFO, " RegClass=%d, TargetChan=%d, SecChanOff=%d, Regular=%d\n",
rCmd.Content.rCmdChSwConf.ucRegClass,
rCmd.Content.rCmdChSwConf.ucTargetChan,
rCmd.Content.rCmdChSwConf.ucSecChanOff, rCmd.Content.rCmdChSwConf.fgIsChSwRegular);
/* command to do this */
rStatus = kalIoctl(prGlueInfo, TdlsChSwConf, &rCmd, sizeof(rCmd), FALSE, FALSE, FALSE, FALSE, &u4BufLen);
if (rStatus != WLAN_STATUS_SUCCESS) {
DBGLOG(TDLS, ERROR, "%s kalIoctl fail:%x\n", __func__, rStatus);
return;
}
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to display TDLS related information.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
* EX: iwpriv wlan0 set_str_cmd 0_18_[Peer MAC]_[Network Interface ID]_[IsClear]
Network Interface ID: reference to ENUM_NETWORK_TYPE_INDEX_T
typedef enum _ENUM_NETWORK_TYPE_INDEX_T {
NETWORK_TYPE_AIS_INDEX = 0,
NETWORK_TYPE_P2P_INDEX,
NETWORK_TYPE_BOW_INDEX,
NETWORK_TYPE_INDEX_NUM
} ENUM_NETWORK_TYPE_INDEX_T;
iwpriv wlan0 set_str_cmd 0_18_00:00:00:00:00:00_0_0
*/
/*----------------------------------------------------------------------------*/
static void TdlsCmdInfoDisplay(GLUE_INFO_T *prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen)
{
WLAN_STATUS rStatus;
TDLS_CMD_CORE_T rCmd;
UINT_32 u4BufLen;
/* parse arguments */
kalMemZero(&rCmd, sizeof(rCmd));
CmdStringMacParse(prInBuf, &prInBuf, &u4InBufLen, rCmd.aucPeerMac);
rCmd.ucNetTypeIndex = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
rCmd.Content.rCmdInfoDisplay.fgIsToClearAllHistory = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
DBGLOG(TDLS, INFO, "<tdls_cmd> %s: Command PeerMac=%pM in BSS%u\n",
__func__, (rCmd.aucPeerMac), rCmd.ucNetTypeIndex);
/* command to do this */
rStatus = kalIoctl(prGlueInfo, TdlsInfoDisplay, &rCmd, sizeof(rCmd), FALSE, FALSE, FALSE, FALSE, &u4BufLen);
if (rStatus != WLAN_STATUS_SUCCESS) {
DBGLOG(TDLS, ERROR, "%s kalIoctl fail:%x\n", __func__, rStatus);
return;
}
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to display key related information.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
* EX: iwpriv wlan0 set_str_cmd 0_20
iwpriv wlan0 set_str_cmd 0_20
*/
/*----------------------------------------------------------------------------*/
static void TdlsCmdKeyInfoDisplay(GLUE_INFO_T *prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen)
{
WLAN_STATUS rStatus;
TDLS_CMD_CORE_T rCmd;
UINT_32 u4BufLen;
/* parse arguments */
kalMemZero(&rCmd, sizeof(rCmd));
DBGLOG(TDLS, INFO, "<tdls_cmd> %s\n", __func__);
/* command to do this */
rStatus = kalIoctl(prGlueInfo, TdlsKeyInfoDisplay, &rCmd, sizeof(rCmd), FALSE, FALSE, FALSE, FALSE, &u4BufLen);
if (rStatus != WLAN_STATUS_SUCCESS) {
DBGLOG(TDLS, ERROR, "%s kalIoctl fail:%x\n", __func__, rStatus);
return;
}
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to update MIB parameters.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
* EX: iwpriv wlan0 set_str_cmd 0_6_[TdlsEn]_[UapsdEn]_[PsmEn]_[PtiWin]_[CWCap]_
[AckMisRetry]_[RspTimeout]_[CWPbDelay]_[DRWin]_[LowestAcInt]
iwpriv wlan0 set_str_cmd 0_6_1_1_0_1_1_3_5_1000_2_1
reference to TDLS_CMD_CORE_MIB_PARAM_UPDATE_T
*/
/*----------------------------------------------------------------------------*/
static void TdlsCmdMibParamUpdate(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen)
{
WLAN_STATUS rStatus;
TDLS_CMD_CORE_T rCmd;
UINT_32 u4BufLen;
/* reset */
kalMemZero(&rCmd, sizeof(rCmd));
/* parse arguments */
rCmd.Content.rCmdMibUpdate.Tdlsdot11TunneledDirectLinkSetupImplemented =
CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
rCmd.Content.rCmdMibUpdate.Tdlsdot11TDLSPeerUAPSDBufferSTAActivated =
CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
rCmd.Content.rCmdMibUpdate.Tdlsdot11TDLSPeerPSMActivated = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
rCmd.Content.rCmdMibUpdate.Tdlsdot11TDLSPeerUAPSDIndicationWindow =
CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
rCmd.Content.rCmdMibUpdate.Tdlsdot11TDLSChannelSwitchingActivated =
CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
rCmd.Content.rCmdMibUpdate.Tdlsdot11TDLSPeerSTAMissingAckRetryLimit =
CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
rCmd.Content.rCmdMibUpdate.Tdlsdot11TDLSResponseTimeout = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
rCmd.Content.rCmdMibUpdate.Tdlsdot11TDLSProbeDelay = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
rCmd.Content.rCmdMibUpdate.Tdlsdot11TDLSDiscoveryRequestWindow =
CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
rCmd.Content.rCmdMibUpdate.Tdlsdot11TDLSACDeterminationInterval =
CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
DBGLOG(TDLS, INFO, "<tdls_cmd> MIB param = %d %d %d %d %d %d %d %d %d %d\n",
rCmd.Content.rCmdMibUpdate.Tdlsdot11TunneledDirectLinkSetupImplemented,
rCmd.Content.rCmdMibUpdate.Tdlsdot11TDLSPeerUAPSDBufferSTAActivated,
rCmd.Content.rCmdMibUpdate.Tdlsdot11TDLSPeerPSMActivated,
rCmd.Content.rCmdMibUpdate.Tdlsdot11TDLSPeerUAPSDIndicationWindow,
rCmd.Content.rCmdMibUpdate.Tdlsdot11TDLSChannelSwitchingActivated,
rCmd.Content.rCmdMibUpdate.Tdlsdot11TDLSPeerSTAMissingAckRetryLimit,
rCmd.Content.rCmdMibUpdate.Tdlsdot11TDLSResponseTimeout,
rCmd.Content.rCmdMibUpdate.Tdlsdot11TDLSProbeDelay,
rCmd.Content.rCmdMibUpdate.Tdlsdot11TDLSDiscoveryRequestWindow,
rCmd.Content.rCmdMibUpdate.Tdlsdot11TDLSACDeterminationInterval);
/* command to do this */
rStatus = kalIoctl(prGlueInfo, TdlsMibParamUpdate, &rCmd, sizeof(rCmd), FALSE, FALSE, FALSE, FALSE, &u4BufLen);
if (rStatus != WLAN_STATUS_SUCCESS) {
DBGLOG(TDLS, ERROR, "%s kalIoctl fail:%x\n", __func__, rStatus);
return;
}
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to update setup parameters.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
* EX: iwpriv wlan0 set_str_cmd 0_17_[20/40 Support]
iwpriv wlan0 set_str_cmd 0_17_1
*/
/*----------------------------------------------------------------------------*/
static void TdlsCmdSetupConf(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen)
{
WLAN_STATUS rStatus;
TDLS_CMD_CORE_T rCmd;
UINT_32 u4BufLen;
/* parse arguments */
kalMemZero(rCmd.aucPeerMac, sizeof(rCmd.aucPeerMac));
rCmd.Content.rCmdSetupConf.fgIs2040Supported = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
DBGLOG(TDLS, INFO, "%s: rCmdSetupConf=%d\n", __func__, rCmd.Content.rCmdSetupConf.fgIs2040Supported);
/* command to do this */
prGlueInfo->rTdlsLink.fgIs2040Sup = rCmd.Content.rCmdSetupConf.fgIs2040Supported;
rStatus = kalIoctl(prGlueInfo, TdlsSetupConf, &rCmd, sizeof(rCmd), FALSE, FALSE, FALSE, FALSE, &u4BufLen);
if (rStatus != WLAN_STATUS_SUCCESS) {
DBGLOG(TDLS, ERROR, "%s kalIoctl fail:%x\n", __func__, rStatus);
return;
}
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to update UAPSD parameters.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
* EX: iwpriv wlan0 set_str_cmd 0_8_[SP timeout skip]_[PTI timeout skip]
iwpriv wlan0 set_str_cmd 0_8_1_1
*/
/*----------------------------------------------------------------------------*/
static void TdlsCmdUapsdConf(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen)
{
WLAN_STATUS rStatus;
TDLS_CMD_CORE_T rCmd;
UINT_32 u4BufLen;
/* parse arguments */
kalMemZero(rCmd.aucPeerMac, sizeof(rCmd.aucPeerMac));
/* UAPSD Service Period */
rCmd.Content.rCmdUapsdConf.fgIsSpTimeoutSkip = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
rCmd.Content.rCmdUapsdConf.fgIsPtiTimeoutSkip = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
/* PTI Service Period */
fgIsPtiTimeoutSkip = rCmd.Content.rCmdUapsdConf.fgIsPtiTimeoutSkip;
DBGLOG(TDLS, INFO, "%s: fgIsSpTimeoutSkip=%d, fgIsPtiTimeoutSkip=%d\n",
__func__, rCmd.Content.rCmdUapsdConf.fgIsSpTimeoutSkip, fgIsPtiTimeoutSkip);
/* command to do this */
rStatus = kalIoctl(prGlueInfo, TdlsUapsdConf, &rCmd, sizeof(rCmd), FALSE, FALSE, FALSE, FALSE, &u4BufLen);
if (rStatus != WLAN_STATUS_SUCCESS) {
DBGLOG(TDLS, ERROR, "%s kalIoctl fail:%x\n", __func__, rStatus);
return;
}
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to display TDLS all information.
*
* \param[in] prAdapter Pointer to the Adapter structure
* \param[in] pvSetBuffer A pointer to the buffer that holds the data to be set
* \param[in] u4SetBufferLen The length of the set buffer
* \param[out] pu4SetInfoLen If the call is successful, returns the number of
* bytes read from the set buffer. If the call failed due to invalid length of
* the set buffer, returns the amount of storage needed.
*
* \retval TDLS_STATUS_xx
*
* iwpriv wlan0 set_str_cmd 0_18_00:00:00:00:00:00_0_0
*
*/
/*----------------------------------------------------------------------------*/
static TDLS_STATUS
TdlsInfoDisplay(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen)
{
GLUE_INFO_T *prGlueInfo;
TDLS_CMD_CORE_T *prCmdContent;
STA_RECORD_T *prStaRec;
TDLS_INFO_LINK_T *prLink;
UINT32 u4StartIdx;
UINT32 u4PeerNum;
BOOLEAN fgIsListAll;
UINT8 ucMacZero[6];
UINT32 u4HisIdx;
UINT8 ucNetTypeIndex;
/* init */
prGlueInfo = prAdapter->prGlueInfo;
prCmdContent = (TDLS_CMD_CORE_T *) pvSetBuffer;
u4StartIdx = 0;
u4PeerNum = 1;
fgIsListAll = TRUE;
kalMemZero(ucMacZero, sizeof(ucMacZero));
ucNetTypeIndex = NETWORK_TYPE_AIS_INDEX;
/* display common information */
DBGLOG(TDLS, TRACE, "TDLS common:\n");
DBGLOG(TDLS, TRACE, "\t\trFreeSwRfbList=%u\n", (UINT32) prAdapter->rRxCtrl.rFreeSwRfbList.u4NumElem);
DBGLOG(TDLS, TRACE, "\t\tjiffies=%u %ums (HZ=%d)\n", (UINT32) jiffies, (UINT32) kalGetTimeTick(), HZ);
/* display disconnection history information */
DBGLOG(TDLS, TRACE, "TDLS link history: %d\n", prGlueInfo->rTdlsLink.u4LinkIdx);
for (u4HisIdx = prGlueInfo->rTdlsLink.u4LinkIdx + 1; u4HisIdx < TDLS_LINK_HISTORY_MAX; u4HisIdx++) {
prLink = &prGlueInfo->rTdlsLink.rLinkHistory[u4HisIdx];
if (kalMemCmp(prLink->aucPeerMac, ucMacZero, 6) == 0)
continue; /* skip all zero */
DBGLOG(TDLS, TRACE,
"\t\t%d. %pM jiffies start(%lu %ums)end(%lu %ums)Reason(%u)fromUs(%u)Dup(%u)HT(%u)\n",
u4HisIdx, prLink->aucPeerMac,
prLink->jiffies_start, jiffies_to_msecs(prLink->jiffies_start),
prLink->jiffies_end, jiffies_to_msecs(prLink->jiffies_end),
prLink->ucReasonCode,
prLink->fgIsFromUs, prLink->ucDupCount, (prLink->ucHtCap & TDLS_INFO_LINK_HT_CAP_SUP));
if (prLink->ucHtCap & TDLS_INFO_LINK_HT_CAP_SUP) {
DBGLOG(TDLS, TRACE,
"\t\t\tBA (0x%x %x %x %x %x %x %x %x)\n",
prLink->ucHtBa[0], prLink->ucHtBa[1],
prLink->ucHtBa[2], prLink->ucHtBa[3],
prLink->ucHtBa[4], prLink->ucHtBa[5], prLink->ucHtBa[6], prLink->ucHtBa[7]);
}
}
for (u4HisIdx = 0; u4HisIdx <= prGlueInfo->rTdlsLink.u4LinkIdx; u4HisIdx++) {
prLink = &prGlueInfo->rTdlsLink.rLinkHistory[u4HisIdx];
if (kalMemCmp(prLink->aucPeerMac, ucMacZero, 6) == 0)
continue; /* skip all zero, use continue, not break */
DBGLOG(TDLS, TRACE,
"\t\t%d. %pM jiffies start(%lu %ums)end(%lu %ums)Reason(%u)fromUs(%u)Dup(%u)HT(%u)\n",
u4HisIdx, (prLink->aucPeerMac),
prLink->jiffies_start, jiffies_to_msecs(prLink->jiffies_start),
prLink->jiffies_end, jiffies_to_msecs(prLink->jiffies_end),
prLink->ucReasonCode,
prLink->fgIsFromUs, prLink->ucDupCount, (prLink->ucHtCap & TDLS_INFO_LINK_HT_CAP_SUP));
if (prLink->ucHtCap & TDLS_INFO_LINK_HT_CAP_SUP) {
DBGLOG(TDLS, TRACE,
"\t\t\tBA (0x%x %x %x %x %x %x %x %x)\n",
prLink->ucHtBa[0], prLink->ucHtBa[1],
prLink->ucHtBa[2], prLink->ucHtBa[3],
prLink->ucHtBa[4], prLink->ucHtBa[5], prLink->ucHtBa[6], prLink->ucHtBa[7]);
}
}
DBGLOG(TDLS, TRACE, "\n");
/* display link information */
if (prCmdContent != NULL) {
if (kalMemCmp(prCmdContent->aucPeerMac, ucMacZero, 6) != 0) {
prStaRec = cnmGetStaRecByAddress(prAdapter,
prCmdContent->ucNetTypeIndex, prCmdContent->aucPeerMac);
if (prStaRec == NULL)
fgIsListAll = TRUE;
}
ucNetTypeIndex = prCmdContent->ucNetTypeIndex;
}
while (1) {
if (fgIsListAll == TRUE) {
/* list all TDLS peers */
prStaRec = cnmStaTheTypeGet(prAdapter, ucNetTypeIndex, STA_TYPE_TDLS_PEER, &u4StartIdx);
if (prStaRec == NULL)
break;
}
DBGLOG(TDLS, TRACE, "-------- TDLS %d: 0x %pM\n", u4PeerNum, (prStaRec->aucMacAddr));
DBGLOG(TDLS, TRACE, "\t\t\t State %d, PM %d, Cap 0x%x\n",
prStaRec->ucStaState, prStaRec->fgIsInPS, prStaRec->u2CapInfo);
DBGLOG(TDLS, TRACE, "\t\t\t SetupDisable %d, ChSwDisable %d\n",
prStaRec->fgTdlsIsProhibited, prStaRec->fgTdlsIsChSwProhibited);
if (fgIsListAll == FALSE)
break; /* only list one */
}
/* check if we need to clear all histories */
if ((prCmdContent != NULL) && (prCmdContent->Content.rCmdInfoDisplay.fgIsToClearAllHistory == TRUE)) {
kalMemZero(&prGlueInfo->rTdlsLink, sizeof(prGlueInfo->rTdlsLink));
prGlueInfo->rTdlsLink.u4LinkIdx = TDLS_LINK_HISTORY_MAX - 1;
}
DBGLOG(TDLS, INFO, "%s cmd ok.\n", __func__);
return TDLS_STATUS_SUCCESS;
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to display key information.
*
* \param[in] prAdapter Pointer to the Adapter structure
* \param[in] pvSetBuffer A pointer to the buffer that holds the data to be set
* \param[in] u4SetBufferLen The length of the set buffer
* \param[out] pu4SetInfoLen If the call is successful, returns the number of
* bytes read from the set buffer. If the call failed due to invalid length of
* the set buffer, returns the amount of storage needed.
*
* \retval TDLS_STATUS_xx
*
*/
/*----------------------------------------------------------------------------*/
static TDLS_STATUS
TdlsKeyInfoDisplay(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen)
{
TDLS_CMD_CORE_T *prCmdContent;
WLAN_STATUS rStatus;
/* init command buffer */
prCmdContent = (TDLS_CMD_CORE_T *) pvSetBuffer;
prCmdContent->u4Command = TDLS_CORE_CMD_KEY_INFO;
/* send the command */
rStatus = wlanSendSetQueryCmd(prAdapter, /* prAdapter */
CMD_ID_TDLS_CORE, /* ucCID */
TRUE, /* fgSetQuery */
FALSE, /* fgNeedResp */
FALSE, /* fgIsOid */
NULL, NULL, /* pfCmdTimeoutHandler */
sizeof(TDLS_CMD_CORE_T), /* u4SetQueryInfoLen */
(PUINT_8) prCmdContent, /* pucInfoBuffer */
NULL, /* pvSetQueryBuffer */
0 /* u4SetQueryBufferLen */
);
if (rStatus != WLAN_STATUS_PENDING) {
DBGLOG(TDLS, ERROR, "%s wlanSendSetQueryCmd allocation fail!\n", __func__);
return TDLS_STATUS_RESOURCES;
}
DBGLOG(TDLS, INFO, "%s cmd ok.\n", __func__);
return TDLS_STATUS_SUCCESS;
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to record a disconnection event.
*
* \param[in] prGlueInfo Pointer to the GLUE_INFO_T structure
* \param[in] fgIsTearDown TRUE: the link is torn down
* \param[in] pucPeerMac Pointer to the MAC of the TDLS peer
* \param[in] fgIsFromUs TRUE: tear down is from us
* \param[in] u2ReasonCode Disconnection reason (TDLS_REASON_CODE)
*
* \retval none
*/
/*----------------------------------------------------------------------------*/
static VOID
TdlsLinkHistoryRecord(GLUE_INFO_T *prGlueInfo,
BOOLEAN fgIsTearDown,
UINT8 *pucPeerMac, BOOLEAN fgIsFromUs, UINT16 u2ReasonCode, VOID *prOthers)
{
TDLS_INFO_LINK_T *prLink;
DBGLOG(TDLS, INFO,
"<tdls_evt> %s: record history for %pM %d %d %d %d\n",
__func__, pucPeerMac, prGlueInfo->rTdlsLink.u4LinkIdx,
fgIsTearDown, fgIsFromUs, u2ReasonCode);
/* check duplicate one */
if (prGlueInfo->rTdlsLink.u4LinkIdx >= TDLS_LINK_HISTORY_MAX) {
DBGLOG(TDLS, ERROR, "<tdls_evt> %s: u4LinkIdx >= TDLS_LINK_HISTORY_MAX\n", __func__);
/* reset to 0 */
prGlueInfo->rTdlsLink.u4LinkIdx = 0;
}
prLink = &prGlueInfo->rTdlsLink.rLinkHistory[prGlueInfo->rTdlsLink.u4LinkIdx];
if (kalMemCmp(&prLink->aucPeerMac, pucPeerMac, 6) == 0) {
if ((prLink->ucReasonCode == u2ReasonCode) && (prLink->fgIsFromUs == fgIsFromUs)) {
/* same Peer MAC, Reason Code, Trigger source */
if (fgIsTearDown == TRUE) {
if (prLink->jiffies_end != 0) {
/* already torn down */
prLink->ucDupCount++;
return;
}
} else {
/* already built */
prLink->ucDupCount++;
return;
}
}
}
/* search old entry */
if (fgIsTearDown == TRUE) {
/* TODO: need to search all entries to find it if we support multiple TDLS link design */
if (kalMemCmp(&prLink->aucPeerMac, pucPeerMac, 6) != 0) {
/* error! can not find the link entry */
DBGLOG(TDLS, INFO, "<tdls_evt> %s: cannot find the same entry!!!\n", __func__);
return;
}
prLink->jiffies_end = jiffies;
prLink->ucReasonCode = (UINT8) u2ReasonCode;
prLink->fgIsFromUs = fgIsFromUs;
} else {
/* record new one */
prGlueInfo->rTdlsLink.u4LinkIdx++;
if (prGlueInfo->rTdlsLink.u4LinkIdx >= TDLS_LINK_HISTORY_MAX)
prGlueInfo->rTdlsLink.u4LinkIdx = 0;
prLink = &prGlueInfo->rTdlsLink.rLinkHistory[prGlueInfo->rTdlsLink.u4LinkIdx];
prLink->jiffies_start = jiffies;
prLink->jiffies_end = 0;
kalMemCopy(&prLink->aucPeerMac, pucPeerMac, 6);
prLink->ucReasonCode = 0;
prLink->fgIsFromUs = (UINT8) fgIsFromUs;
prLink->ucDupCount = 0;
if (prOthers != NULL) {
/* record other parameters */
TDLS_LINK_HIS_OTHERS_T *prHisOthers;
prHisOthers = (TDLS_LINK_HIS_OTHERS_T *) prOthers;
if (prHisOthers->fgIsHt == TRUE)
prLink->ucHtCap |= TDLS_INFO_LINK_HT_CAP_SUP;
}
}
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to update a disconnection event.
*
* \param[in] prGlueInfo Pointer to the GLUE_INFO_T structure
* \param[in] pucPeerMac Pointer to the MAC of the TDLS peer
* \param[in] eFmeStatus TDLS_EVENT_HOST_SUBID_SPECIFIC_FRAME
* \param[in] pInfo other information
*
* \retval none
*/
/*----------------------------------------------------------------------------*/
static VOID
TdlsLinkHistoryRecordUpdate(GLUE_INFO_T *prGlueInfo,
UINT8 *pucPeerMac, TDLS_EVENT_HOST_SUBID_SPECIFIC_FRAME eFmeStatus, VOID *pInfo)
{
TDLS_INFO_LINK_T *prLink;
UINT32 u4LinkIdx;
UINT32 u4Tid;
/* sanity check */
if ((eFmeStatus < TDLS_HOST_EVENT_SF_BA) || (eFmeStatus > TDLS_HOST_EVENT_SF_BA_RSP_DECLINE)) {
/* do not care these frames */
return;
}
DBGLOG(TDLS, INFO,
"<tdls_evt> %s: update history for %pM %d %d\n",
__func__, (pucPeerMac), prGlueInfo->rTdlsLink.u4LinkIdx, eFmeStatus);
/* init */
u4LinkIdx = prGlueInfo->rTdlsLink.u4LinkIdx;
prLink = &prGlueInfo->rTdlsLink.rLinkHistory[u4LinkIdx];
/* TODO: need to search all entries to find it if we support multiple TDLS link design */
if (kalMemCmp(&prLink->aucPeerMac, pucPeerMac, 6) != 0) {
/* error! can not find the link entry */
DBGLOG(TDLS, INFO, "<tdls_evt> %s: cannot find the same entry!!!\n", __func__);
return;
}
/* update */
u4Tid = *(UINT32 *) pInfo;
switch (eFmeStatus) {
case TDLS_HOST_EVENT_SF_BA:
prLink->ucHtBa[u4Tid] |= TDLS_INFO_LINK_HT_BA_SETUP;
break;
case TDLS_HOST_EVENT_SF_BA_OK:
prLink->ucHtBa[u4Tid] |= TDLS_INFO_LINK_HT_BA_SETUP_OK;
break;
case TDLS_HOST_EVENT_SF_BA_DECLINE:
prLink->ucHtBa[u4Tid] |= TDLS_INFO_LINK_HT_BA_SETUP_DECLINE;
break;
case TDLS_HOST_EVENT_SF_BA_PEER:
prLink->ucHtBa[u4Tid] |= TDLS_INFO_LINK_HT_BA_PEER;
break;
case TDLS_HOST_EVENT_SF_BA_RSP_OK:
prLink->ucHtBa[u4Tid] |= TDLS_INFO_LINK_HT_BA_RSP_OK;
break;
case TDLS_HOST_EVENT_SF_BA_RSP_DECLINE:
prLink->ucHtBa[u4Tid] |= TDLS_INFO_LINK_HT_BA_RSP_DECLINE;
break;
}
/* display TDLS link history */
TdlsInfoDisplay(prGlueInfo->prAdapter, NULL, 0, NULL);
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to configure TDLS MIB parameters.
*
* \param[in] prAdapter Pointer to the Adapter structure
* \param[in] pvSetBuffer A pointer to the buffer that holds the data to be set
* \param[in] u4SetBufferLen The length of the set buffer
* \param[out] pu4SetInfoLen If the call is successful, returns the number of
* bytes read from the set buffer. If the call failed due to invalid length of
* the set buffer, returns the amount of storage needed.
*
* \retval TDLS_STATUS_xx
*
*/
/*----------------------------------------------------------------------------*/
static TDLS_STATUS
TdlsMibParamUpdate(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen)
{
TDLS_CMD_CORE_T *prCmdContent;
WLAN_STATUS rStatus;
/* init command buffer */
prCmdContent = (TDLS_CMD_CORE_T *) pvSetBuffer;
prCmdContent->u4Command = TDLS_CORE_CMD_MIB_UPDATE;
/* send the command */
rStatus = wlanSendSetQueryCmd(prAdapter, /* prAdapter */
CMD_ID_TDLS_CORE, /* ucCID */
TRUE, /* fgSetQuery */
FALSE, /* fgNeedResp */
FALSE, /* fgIsOid */
NULL, NULL, /* pfCmdTimeoutHandler */
sizeof(TDLS_CMD_CORE_T), /* u4SetQueryInfoLen */
(PUINT_8) prCmdContent, /* pucInfoBuffer */
NULL, /* pvSetQueryBuffer */
0 /* u4SetQueryBufferLen */
);
if (rStatus != WLAN_STATUS_PENDING) {
DBGLOG(TDLS, ERROR, "%s wlanSendSetQueryCmd allocation fail!\n", __func__);
return TDLS_STATUS_RESOURCES;
}
DBGLOG(TDLS, INFO, "%s cmd ok.\n", __func__);
return TDLS_STATUS_SUCCESS;
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to configure TDLS SETUP parameters.
*
* \param[in] prAdapter Pointer to the Adapter structure
* \param[in] pvSetBuffer A pointer to the buffer that holds the data to be set
* \param[in] u4SetBufferLen The length of the set buffer
* \param[out] pu4SetInfoLen If the call is successful, returns the number of
* bytes read from the set buffer. If the call failed due to invalid length of
* the set buffer, returns the amount of storage needed.
*
* \retval TDLS_STATUS_xx
*
*/
/*----------------------------------------------------------------------------*/
static TDLS_STATUS
TdlsSetupConf(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen)
{
TDLS_CMD_CORE_T *prCmdContent;
WLAN_STATUS rStatus;
/* init command buffer */
prCmdContent = (TDLS_CMD_CORE_T *) pvSetBuffer;
prCmdContent->u4Command = TDLS_CORE_CMD_SETUP_CONF;
/* send the command */
rStatus = wlanSendSetQueryCmd(prAdapter, /* prAdapter */
CMD_ID_TDLS_CORE, /* ucCID */
TRUE, /* fgSetQuery */
FALSE, /* fgNeedResp */
FALSE, /* fgIsOid */
NULL, NULL, /* pfCmdTimeoutHandler */
sizeof(TDLS_CMD_CORE_T), /* u4SetQueryInfoLen */
(PUINT_8) prCmdContent, /* pucInfoBuffer */
NULL, /* pvSetQueryBuffer */
0 /* u4SetQueryBufferLen */
);
if (rStatus != WLAN_STATUS_PENDING) {
DBGLOG(TDLS, ERROR, "%s wlanSendSetQueryCmd allocation fail!\n", __func__);
return TDLS_STATUS_RESOURCES;
}
DBGLOG(TDLS, INFO, "%s cmd ok.\n", __func__);
return TDLS_STATUS_SUCCESS;
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to configure UAPSD parameters.
*
* \param[in] prAdapter Pointer to the Adapter structure
* \param[in] pvSetBuffer A pointer to the buffer that holds the data to be set
* \param[in] u4SetBufferLen The length of the set buffer
* \param[out] pu4SetInfoLen If the call is successful, returns the number of
* bytes read from the set buffer. If the call failed due to invalid length of
* the set buffer, returns the amount of storage needed.
*
* \retval TDLS_STATUS_xx
*
*/
/*----------------------------------------------------------------------------*/
static TDLS_STATUS
TdlsUapsdConf(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen)
{
TDLS_CMD_CORE_T *prCmdContent;
WLAN_STATUS rStatus;
/* init command buffer */
prCmdContent = (TDLS_CMD_CORE_T *) pvSetBuffer;
prCmdContent->u4Command = TDLS_CORE_CMD_UAPSD_CONF;
/* send the command */
rStatus = wlanSendSetQueryCmd(prAdapter, /* prAdapter */
CMD_ID_TDLS_CORE, /* ucCID */
TRUE, /* fgSetQuery */
FALSE, /* fgNeedResp */
FALSE, /* fgIsOid */
NULL, NULL, /* pfCmdTimeoutHandler */
sizeof(TDLS_CMD_CORE_T), /* u4SetQueryInfoLen */
(PUINT_8) prCmdContent, /* pucInfoBuffer */
NULL, /* pvSetQueryBuffer */
0 /* u4SetQueryBufferLen */
);
if (rStatus != WLAN_STATUS_PENDING) {
DBGLOG(TDLS, ERROR, "%s wlanSendSetQueryCmd allocation fail!\n", __func__);
return TDLS_STATUS_RESOURCES;
}
DBGLOG(TDLS, INFO, "%s cmd ok.\n", __func__);
return TDLS_STATUS_SUCCESS;
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to update frame status.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer, from u4EventSubId
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
*/
/*----------------------------------------------------------------------------*/
static void TdlsEventFmeStatus(GLUE_INFO_T *prGlueInfo, UINT8 *prInBuf, UINT32 u4InBufLen)
{
TDLS_EVENT_HOST_SUBID_SPECIFIC_FRAME eFmeStatus;
STA_RECORD_T *prStaRec;
UINT32 u4Tid;
/* init */
u4Tid = *(UINT32 *) prInBuf;
prInBuf += 4; /* skip u4EventSubId */
/* sanity check */
prStaRec = cnmGetStaRecByIndex(prGlueInfo->prAdapter, *prInBuf);
if ((prStaRec == NULL) || (!IS_TDLS_STA(prStaRec)))
return;
prInBuf++;
/* update status */
eFmeStatus = *prInBuf;
TdlsLinkHistoryRecordUpdate(prGlueInfo, prStaRec->aucMacAddr, eFmeStatus, &u4Tid);
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to collect TDLS statistics from firmware.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer, from u4EventSubId
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
*/
/*----------------------------------------------------------------------------*/
static void TdlsEventStatistics(GLUE_INFO_T *prGlueInfo, UINT8 *prInBuf, UINT32 u4InBufLen)
{
STA_RECORD_T *prStaRec;
STAT_CNT_INFO_FW_T *prStat;
UINT32 u4RateId;
/* init */
prStaRec = cnmGetStaRecByIndex(prGlueInfo->prAdapter, *prInBuf);
if ((prStaRec == NULL) || (!IS_TDLS_STA(prStaRec)))
return;
prInBuf += 4; /* skip prStaRec->ucIndex */
/* update statistics */
kalMemCopy(&prStaRec->rTdlsStatistics.rFw, prInBuf, sizeof(prStaRec->rTdlsStatistics.rFw));
/* display statistics */
prStat = &prStaRec->rTdlsStatistics.rFw;
DBGLOG(TDLS, TRACE, "<tdls_evt> peer [%pM] statistics:\n", (prStaRec->aucMacAddr));
DBGLOG(TDLS, TRACE, "\t\tT%d %d %d (P%d %d) (%dus) - E%d 0x%x - R%d (P%d)\n",
prStat->u4NumOfTx, prStat->u4NumOfTxOK, prStat->u4NumOfTxRetry,
prStat->u4NumOfPtiRspTxOk, prStat->u4NumOfPtiRspTxErr,
prStat->u4TxDoneAirTimeMax,
prStat->u4NumOfTxErr, prStat->u4TxErrBitmap, prStat->u4NumOfRx, prStat->u4NumOfPtiRspRx);
DBGLOG(TDLS, TRACE, "\t\t");
for (u4RateId = prStat->u4TxRateOkHisId; u4RateId < STAT_CNT_INFO_MAX_TX_RATE_OK_HIS_NUM; u4RateId++)
DBGLOG(TDLS, TRACE,
"%d(%d) ", prStat->aucTxRateOkHis[u4RateId][0], prStat->aucTxRateOkHis[u4RateId][1]);
for (u4RateId = 0; u4RateId < prStat->u4TxRateOkHisId; u4RateId++)
DBGLOG(TDLS, TRACE,
"%d(%d) ", prStat->aucTxRateOkHis[u4RateId][0], prStat->aucTxRateOkHis[u4RateId][1]);
DBGLOG(TDLS, TRACE, "\n\n");
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to do tear down.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer, from u4EventSubId
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
*/
/*----------------------------------------------------------------------------*/
static void TdlsEventTearDown(GLUE_INFO_T *prGlueInfo, UINT8 *prInBuf, UINT32 u4InBufLen)
{
STA_RECORD_T *prStaRec;
UINT16 u2ReasonCode;
UINT32 u4TearDownSubId;
UINT8 *pMac, aucZeroMac[6];
/* init */
u4TearDownSubId = *(UINT32 *) prInBuf;
kalMemZero(aucZeroMac, sizeof(aucZeroMac));
pMac = aucZeroMac;
prStaRec = cnmGetStaRecByIndex(prGlueInfo->prAdapter, *(prInBuf + 4));
if (prStaRec != NULL)
pMac = prStaRec->aucMacAddr;
/* handle */
if (u4TearDownSubId == TDLS_HOST_EVENT_TD_PTI_TIMEOUT) {
DBGLOG(TDLS, WARN, "<tdls_evt> %s: peer [%pM] Reason=PTI timeout\n",
__func__, pMac);
} else if (u4TearDownSubId == TDLS_HOST_EVENT_TD_AGE_TIMEOUT) {
DBGLOG(TDLS, WARN, "<tdls_evt> %s: peer [%pM] Reason=AGE timeout\n",
__func__, pMac);
} else {
DBGLOG(TDLS, WARN, "<tdls_evt> %s: peer [%pM] Reason=%d\n",
__func__, pMac, u4TearDownSubId);
}
/* sanity check */
if (prStaRec == NULL)
return;
if (fgIsPtiTimeoutSkip == TRUE) {
/* skip PTI timeout event */
if (u4TearDownSubId == TDLS_HOST_EVENT_TD_PTI_TIMEOUT) {
DBGLOG(TDLS, WARN, "<tdls_evt> %s: skip PTI timeout\n", __func__);
return;
}
}
/* record history */
if (u4TearDownSubId == TDLS_HOST_EVENT_TD_AGE_TIMEOUT)
u2ReasonCode = TDLS_REASON_CODE_MTK_DIS_BY_US_DUE_TO_AGE_TIMEOUT;
else if (u4TearDownSubId == TDLS_HOST_EVENT_TD_PTI_TIMEOUT)
u2ReasonCode = TDLS_REASON_CODE_MTK_DIS_BY_US_DUE_TO_PTI_TIMEOUT;
else if (u4TearDownSubId == TDLS_HOST_EVENT_TD_PTI_SEND_FAIL)
u2ReasonCode = TDLS_REASON_CODE_MTK_DIS_BY_US_DUE_TO_PTI_SEND_FAIL;
else if (u4TearDownSubId == TDLS_HOST_EVENT_TD_PTI_SEND_MAX_FAIL)
u2ReasonCode = TDLS_REASON_CODE_MTK_DIS_BY_US_DUE_TO_PTI_SEND_MAX_FAIL;
else if (u4TearDownSubId == TDLS_HOST_EVENT_TD_WRONG_NETWORK_IDX)
u2ReasonCode = TDLS_REASON_CODE_MTK_DIS_BY_US_DUE_TO_WRONG_NETWORK_IDX;
else if (u4TearDownSubId == TDLS_HOST_EVENT_TD_NON_STATE3)
u2ReasonCode = TDLS_REASON_CODE_MTK_DIS_BY_US_DUE_TO_NON_STATE3;
else if (u4TearDownSubId == TDLS_HOST_EVENT_TD_LOST_TEAR_DOWN)
u2ReasonCode = TDLS_REASON_CODE_MTK_DIS_BY_US_DUE_TO_LOST_TEAR_DOWN;
else {
/* shall not be here */
u2ReasonCode = TDLS_REASON_CODE_MTK_DIS_BY_US_DUE_TO_UNKNOWN;
}
TdlsLinkHistoryRecord(prGlueInfo, TRUE, prStaRec->aucMacAddr, TRUE, u2ReasonCode, NULL);
/* correct correct reason code for PTI or AGE timeout to supplicant */
if ((u2ReasonCode == TDLS_REASON_CODE_MTK_DIS_BY_US_DUE_TO_AGE_TIMEOUT) ||
(u2ReasonCode == TDLS_REASON_CODE_MTK_DIS_BY_US_DUE_TO_PTI_TIMEOUT)) {
u2ReasonCode = TDLS_REASON_CODE_UNREACHABLE;
}
/* 16 Nov 21:49 2012 http://permalink.gmane.org/gmane.linux.kernel.wireless.general/99712 */
cfg80211_tdls_oper_request(prGlueInfo->prDevHandler,
prStaRec->aucMacAddr, NL80211_TDLS_TEARDOWN, u2ReasonCode, GFP_ATOMIC);
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to do tx down.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer, from u4EventSubId
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*
*/
/*----------------------------------------------------------------------------*/
static void TdlsEventTxDone(GLUE_INFO_T *prGlueInfo, UINT8 *prInBuf, UINT32 u4InBufLen)
{
/* UINT32 u4FmeIdx; */
UINT8 *pucFmeHdr;
UINT8 ucErrStatus;
ucErrStatus = *(UINT32 *) prInBuf;
pucFmeHdr = prInBuf + 4; /* skip ucErrStatus */
if (ucErrStatus == 0)
DBGLOG(TDLS, TRACE, "<tdls_evt> %s: OK to tx a TDLS action:", __func__);
else
DBGLOG(TDLS, TRACE, "<tdls_evt> %s: fail to tx a TDLS action (err=0x%x):", __func__, ucErrStatus);
#if 0
/* dump TX packet content from wlan header */
for (u4FmeIdx = 0; u4FmeIdx < (u4InBufLen - 4); u4FmeIdx++) {
if ((u4FmeIdx % 16) == 0)
DBGLOG(TDLS, TRACE, "\n");
DBGLOG(TDLS, TRACE, "%02x ", *pucFmeHdr++);
}
DBGLOG(TDLS, TRACE, "\n\n");
#endif
}
/*******************************************************************************
* P U B L I C F U N C T I O N S
********************************************************************************
*/
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to parse TDLS Extended Capabilities element.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*/
/*----------------------------------------------------------------------------*/
VOID TdlsexBssExtCapParse(STA_RECORD_T *prStaRec, UINT_8 *pucIE)
{
UINT_8 *pucIeExtCap;
/* sanity check */
if ((prStaRec == NULL) || (pucIE == NULL))
return;
if (IE_ID(pucIE) != ELEM_ID_EXTENDED_CAP)
return;
/*
from bit0 ~
bit 38: TDLS Prohibited
The TDLS Prohibited subfield indicates whether the use of TDLS is prohibited. The
field is set to 1 to indicate that TDLS is prohibited and to 0 to indicate that TDLS is
allowed.
*/
if (IE_LEN(pucIE) < 5)
return; /* we need 39/8 = 5 bytes */
/* init */
prStaRec->fgTdlsIsProhibited = FALSE;
prStaRec->fgTdlsIsChSwProhibited = FALSE;
/* parse */
pucIeExtCap = pucIE + 2;
pucIeExtCap += 4; /* shift to the byte we care about */
if ((*pucIeExtCap) & BIT(38 - 32))
prStaRec->fgTdlsIsProhibited = TRUE;
if ((*pucIeExtCap) & BIT(39 - 32))
prStaRec->fgTdlsIsChSwProhibited = TRUE;
DBGLOG(TDLS, TRACE,
"<tdls> %s: AP [%pM] tdls prohibit bit=%d %d\n",
__func__,
prStaRec->aucMacAddr, prStaRec->fgTdlsIsProhibited, prStaRec->fgTdlsIsChSwProhibited);
}
/*----------------------------------------------------------------------------*/
/*!
* \brief This routine is called to transmit a TDLS data frame from nl80211.
*
* \param[in] pvAdapter Pointer to the Adapter structure.
* \param[in]
* \param[in]
* \param[in] buf includes RSN IE + FT IE + Lifetimeout IE
*
* \retval WLAN_STATUS_SUCCESS
* \retval WLAN_STATUS_INVALID_LENGTH
*/
/*----------------------------------------------------------------------------*/
int
TdlsexCfg80211TdlsMgmt(struct wiphy *wiphy, struct net_device *dev,
const u8 *peer, u8 action_code, u8 dialog_token,
u16 status_code, u32 peer_capability,
bool initiator, const u8 *buf, size_t len)
{
ADAPTER_T *prAdapter;
GLUE_INFO_T *prGlueInfo;
BSS_INFO_T *prAisBssInfo;
WLAN_STATUS rStatus;
UINT_32 u4BufLen;
TDLS_MGMT_TX_INFO *prMgmtTxInfo;
/*
Have correct behavior for STAUT receiving TDLS Setup Request after sending TDLS
Set Request and before receiving TDLS Setup Response:
-- Source Address of received Request is higher than own MAC address
-- Source Address of received Request is lower than own MAC address
==> STA with larger MAC address will send the response frame.
Supplicant will do this in wpa_tdls_process_tpk_m1().
*/
/* sanity check */
if ((wiphy == NULL) || (peer == NULL)) {
DBGLOG(TDLS, ERROR, "<tdls_cfg> %s: wrong 0x%p 0x%p!\n", __func__, wiphy, peer);
return -EINVAL;
}
DBGLOG(TDLS, INFO, "<tdls_cfg> %s: [%pM] %d %d %d 0x%p %u\n",
__func__, peer, action_code, dialog_token, status_code, buf, (UINT32) len);
/* init */
prGlueInfo = (GLUE_INFO_T *) wiphy_priv(wiphy);
if (prGlueInfo == NULL) {
DBGLOG(TDLS, ERROR, "<tdls_cfg> %s: wrong prGlueInfo 0x%p!\n", __func__, prGlueInfo);
return -EINVAL;
}
prAdapter = prGlueInfo->prAdapter;
if (prAdapter->fgTdlsIsSup == FALSE) {
DBGLOG(TDLS, ERROR, "<tdls_cfg> %s: firmware TDLS is not supported!\n", __func__);
return -EBUSY;
}
prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
if (prAisBssInfo->fgTdlsIsProhibited == TRUE) {
/* do not send anything if TDLS is prohibited in the BSS */
return 0;
}
prMgmtTxInfo = kalMemAlloc(sizeof(TDLS_MGMT_TX_INFO), VIR_MEM_TYPE);
if (prMgmtTxInfo == NULL) {
DBGLOG(TDLS, ERROR, "<tdls_cfg> %s: allocate fail!\n", __func__);
return -ENOMEM;
}
kalMemZero(prMgmtTxInfo, sizeof(TDLS_MGMT_TX_INFO));
if (peer != NULL)
kalMemCopy(prMgmtTxInfo->aucPeer, peer, 6);
prMgmtTxInfo->ucActionCode = action_code;
prMgmtTxInfo->ucDialogToken = dialog_token;
prMgmtTxInfo->u2StatusCode = status_code;
if (buf != NULL) {
if (len > sizeof(prMgmtTxInfo->aucSecBuf)) {
kalMemFree(prMgmtTxInfo, VIR_MEM_TYPE, sizeof(TDLS_MGMT_TX_INFO));
return -EINVAL;
}
prMgmtTxInfo->u4SecBufLen = len;
kalMemCopy(prMgmtTxInfo->aucSecBuf, buf, len);
}
/* send the TDLS action data frame */
rStatus = kalIoctl(prGlueInfo,
TdlsexMgmtCtrl,
prMgmtTxInfo, sizeof(TDLS_MGMT_TX_INFO), FALSE, FALSE, FALSE, FALSE, &u4BufLen);
/*
clear all content to avoid any bug if we dont yet execute TdlsexMgmtCtrl()
then kalIoctl finishes
*/
kalMemZero(prMgmtTxInfo, sizeof(TDLS_MGMT_TX_INFO));
if (rStatus != WLAN_STATUS_SUCCESS) {
DBGLOG(TDLS, ERROR, "%s enable or disable link fail:%x\n", __func__, rStatus);
kalMemFree(prMgmtTxInfo, VIR_MEM_TYPE, sizeof(TDLS_MGMT_TX_INFO));
return -EINVAL;
}
kalMemFree(prMgmtTxInfo, VIR_MEM_TYPE, sizeof(TDLS_MGMT_TX_INFO));
return 0;
}
/*----------------------------------------------------------------------------*/
/*!
* \brief This routine is called to enable or disable TDLS link from upper layer.
*
* \param[in] pvAdapter Pointer to the Adapter structure.
* \param[in]
* \param[in]
* \param[in] buf includes RSN IE + FT IE + Lifetimeout IE
*
* \retval WLAN_STATUS_SUCCESS
* \retval WLAN_STATUS_INVALID_LENGTH
*/
/*----------------------------------------------------------------------------*/
int TdlsexCfg80211TdlsOper(struct wiphy *wiphy, struct net_device *dev,
const u8 *peer, enum nl80211_tdls_operation oper)
{
ADAPTER_T *prAdapter;
GLUE_INFO_T *prGlueInfo;
WLAN_STATUS rStatus;
UINT_32 u4BufLen;
TDLS_CMD_LINK_T rCmdLink;
/* sanity check */
if (peer == NULL) {
DBGLOG(TDLS, ERROR, "<tdls_cfg> %s: peer == NULL!\n", __func__);
return -EINVAL;
}
DBGLOG(TDLS, INFO, "<tdls_cfg> %s: [%pM] %d %d\n",
__func__, peer, oper, (wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS));
if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS))
return -ENOTSUPP;
/* init */
prGlueInfo = (GLUE_INFO_T *) wiphy_priv(wiphy);
if (prGlueInfo == NULL) {
DBGLOG(TDLS, ERROR, "<tdls_cfg> %s: wrong prGlueInfo 0x%p!\n", __func__, prGlueInfo);
return -EINVAL;
}
prAdapter = prGlueInfo->prAdapter;
kalMemCopy(rCmdLink.aucPeerMac, peer, sizeof(rCmdLink.aucPeerMac));
rCmdLink.fgIsEnabled = FALSE;
/*
enum nl80211_tdls_operation {
NL80211_TDLS_DISCOVERY_REQ,
NL80211_TDLS_SETUP,
NL80211_TDLS_TEARDOWN,
NL80211_TDLS_ENABLE_LINK,
NL80211_TDLS_DISABLE_LINK,
};
*/
switch (oper) {
case NL80211_TDLS_ENABLE_LINK:
rCmdLink.fgIsEnabled = TRUE;
break;
case NL80211_TDLS_DISABLE_LINK:
rCmdLink.fgIsEnabled = FALSE;
break;
case NL80211_TDLS_TEARDOWN:
case NL80211_TDLS_SETUP:
case NL80211_TDLS_DISCOVERY_REQ:
/* we do not support setup/teardown/discovery from driver */
return -ENOTSUPP;
default:
return -ENOTSUPP;
}
/* enable or disable TDLS link */
rStatus = kalIoctl(prGlueInfo,
TdlsexLinkCtrl, &rCmdLink, sizeof(TDLS_CMD_LINK_T), FALSE, FALSE, FALSE, FALSE, &u4BufLen);
if (rStatus != WLAN_STATUS_SUCCESS) {
DBGLOG(TDLS, ERROR, "%s enable or disable link fail:%x\n", __func__, rStatus);
return -EINVAL;
}
return 0;
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to send a command to TDLS module.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*/
/*----------------------------------------------------------------------------*/
VOID TdlsexCmd(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen)
{
UINT_32 u4Subcmd;
static void (*TdlsCmdTestFunc)(P_GLUE_INFO_T, UINT_8 *, UINT_32);
/* parse TDLS sub-command */
u4Subcmd = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
DBGLOG(TDLS, INFO, "<tdls_cmd> sub command = %u\n", (UINT32) u4Subcmd);
TdlsCmdTestFunc = NULL;
/* handle different sub-command */
switch (u4Subcmd) {
#if TDLS_CFG_CMD_TEST /* only for unit test */
case TDLS_CMD_TEST_TX_FRAME:
/* simulate to send a TDLS frame */
/* TdlsCmdTestTxFrame(prGlueInfo, prInBuf, u4InBufLen); */
TdlsCmdTestFunc = TdlsCmdTestTxFrame;
break;
case TDLS_CMD_TEST_TX_TDLS_FRAME:
/* simulate to send a TDLS frame from supplicant */
/* TdlsCmdTestTxTdlsFrame(prGlueInfo, prInBuf, u4InBufLen); */
TdlsCmdTestFunc = TdlsCmdTestTxTdlsFrame;
break;
case TDLS_CMD_TEST_RCV_FRAME:
/* simulate to receive a TDLS frame */
/* TdlsCmdTestRvFrame(prGlueInfo, prInBuf, u4InBufLen); */
TdlsCmdTestFunc = TdlsCmdTestRvFrame;
break;
case TDLS_CMD_TEST_PEER_ADD:
/* simulate to add a TDLS peer */
/* TdlsCmdTestAddPeer(prGlueInfo, prInBuf, u4InBufLen); */
TdlsCmdTestFunc = TdlsCmdTestAddPeer;
break;
case TDLS_CMD_TEST_PEER_UPDATE:
/* simulate to update a TDLS peer */
/* TdlsCmdTestUpdatePeer(prGlueInfo, prInBuf, u4InBufLen); */
TdlsCmdTestFunc = TdlsCmdTestUpdatePeer;
break;
case TDLS_CMD_TEST_DATA_FRAME:
/* simulate to send a data frame to the peer */
/* TdlsCmdTestDataSend(prGlueInfo, prInBuf, u4InBufLen); */
TdlsCmdTestFunc = TdlsCmdTestDataSend;
break;
case TDLS_CMD_TEST_RCV_NULL:
/* simulate to receive a QoS null frame from the peer */
/* TdlsCmdTestNullRecv(prGlueInfo, prInBuf, u4InBufLen); */
TdlsCmdTestFunc = TdlsCmdTestNullRecv;
break;
case TDLS_CMD_TEST_SKIP_TX_FAIL:
/* command firmware to skip tx fail case */
/* TdlsCmdTestTxFailSkip(prGlueInfo, prInBuf, u4InBufLen); */
TdlsCmdTestFunc = TdlsCmdTestTxFailSkip;
break;
case TDLS_CMD_TEST_SKIP_KEEP_ALIVE:
/* command firmware to skip keep alive function */
/* TdlsCmdTestKeepAliveSkip(prGlueInfo, prInBuf, u4InBufLen); */
TdlsCmdTestFunc = TdlsCmdTestKeepAliveSkip;
break;
case TDLS_CMD_TEST_SKIP_CHSW_TIMEOUT:
/* command firmware to skip channel switch timeout function */
/* TdlsCmdTestChSwTimeoutSkip(prGlueInfo, prInBuf, u4InBufLen); */
TdlsCmdTestFunc = TdlsCmdTestChSwTimeoutSkip;
break;
case TDLS_CMD_TEST_PROHIBIT_SET_IN_AP:
/* simulate to set Prohibited Bit in AP */
/* TdlsCmdTestProhibitedBitSet(prGlueInfo, prInBuf, u4InBufLen); */
TdlsCmdTestFunc = TdlsCmdTestProhibitedBitSet;
break;
case TDLS_CMD_TEST_SCAN_DISABLE:
/* command to disable scan request to do channel switch */
/* TdlsCmdTestScanCtrl(prGlueInfo, prInBuf, u4InBufLen); */
TdlsCmdTestFunc = TdlsCmdTestScanCtrl;
break;
case TDLS_CMD_TEST_DATA_FRAME_CONT:
/* simulate to send a data frame to the peer periodically */
/* TdlsCmdTestDataContSend(prGlueInfo, prInBuf, u4InBufLen); */
TdlsCmdTestFunc = TdlsCmdTestDataContSend;
break;
case TDLS_CMD_TEST_CH_SW_PROHIBIT_SET_IN_AP:
/* simulate to set channel switch Prohibited Bit in AP */
/* TdlsCmdTestChSwProhibitedBitSet(prGlueInfo, prInBuf, u4InBufLen); */
TdlsCmdTestFunc = TdlsCmdTestChSwProhibitedBitSet;
break;
case TDLS_CMD_TEST_DELAY:
/* delay a where */
/* TdlsCmdTestDelay(prGlueInfo, prInBuf, u4InBufLen); */
TdlsCmdTestFunc = TdlsCmdTestDelay;
break;
case TDLS_CMD_TEST_PTI_TX_FAIL:
/* simulate the tx done fail for PTI */
/* TdlsCmdTestPtiTxDoneFail(prGlueInfo, prInBuf, u4InBufLen); */
TdlsCmdTestFunc = TdlsCmdTestPtiTxDoneFail;
break;
#endif /* TDLS_CFG_CMD_TEST */
case TDLS_CMD_MIB_UPDATE:
/* update MIB parameters */
/* TdlsCmdMibParamUpdate(prGlueInfo, prInBuf, u4InBufLen); */
TdlsCmdTestFunc = TdlsCmdMibParamUpdate;
break;
case TDLS_CMD_UAPSD_CONF:
/* config UAPSD parameters */
/* TdlsCmdUapsdConf(prGlueInfo, prInBuf, u4InBufLen); */
TdlsCmdTestFunc = TdlsCmdUapsdConf;
break;
case TDLS_CMD_CH_SW_CONF:
/* enable or disable or start or stop channel switch function */
/* TdlsCmdChSwConf(prGlueInfo, prInBuf, u4InBufLen); */
TdlsCmdTestFunc = TdlsCmdChSwConf;
break;
case TDLS_CMD_SETUP_CONF:
/* config setup parameters */
/* TdlsCmdSetupConf(prGlueInfo, prInBuf, u4InBufLen); */
TdlsCmdTestFunc = TdlsCmdSetupConf;
break;
case TDLS_CMD_INFO:
/* display all TDLS information */
/* TdlsCmdInfoDisplay(prGlueInfo, prInBuf, u4InBufLen); */
TdlsCmdTestFunc = TdlsCmdInfoDisplay;
break;
case TDLS_CMD_KEY_INFO:
/* display key information */
/* TdlsCmdKeyInfoDisplay(prGlueInfo, prInBuf, u4InBufLen); */
TdlsCmdTestFunc = TdlsCmdKeyInfoDisplay;
break;
default:
break;
}
if (TdlsCmdTestFunc != NULL)
TdlsCmdTestFunc(prGlueInfo, prInBuf, u4InBufLen);
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to record a disconnection event.
*
* \param[in] prGlueInfo Pointer to the GLUE_INFO_T structure
* \param[in] fgIsTearDown TRUE: tear down
* \param[in] pucPeerMac Pointer to the MAC of the TDLS peer
* \param[in] fgIsFromUs TRUE: tear down is from us
* \param[in] u2ReasonCode Disconnection reason (TDLS_REASON_CODE)
*
* \retval none
*
*/
/*----------------------------------------------------------------------------*/
VOID
TdlsexLinkHistoryRecord(GLUE_INFO_T *prGlueInfo,
BOOLEAN fgIsTearDown, UINT8 *pucPeerMac, BOOLEAN fgIsFromUs, UINT16 u2ReasonCode)
{
/* sanity check */
if ((prGlueInfo == NULL) || (pucPeerMac == NULL))
return;
DBGLOG(TDLS, INFO,
"<tdls_evt> %s: Rcv a inform from %pM %d %d\n",
__func__, pucPeerMac, fgIsFromUs, u2ReasonCode);
/* record */
TdlsLinkHistoryRecord(prGlueInfo, fgIsTearDown, pucPeerMac, fgIsFromUs, u2ReasonCode, NULL);
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to send a command to TDLS module.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval None
*/
/*----------------------------------------------------------------------------*/
VOID TdlsexEventHandle(GLUE_INFO_T *prGlueInfo, UINT8 *prInBuf, UINT32 u4InBufLen)
{
UINT32 u4EventId;
/* sanity check */
if ((prGlueInfo == NULL) || (prInBuf == NULL))
return; /* shall not be here */
/* handle */
u4EventId = *(UINT32 *) prInBuf;
u4InBufLen -= 4;
DBGLOG(TDLS, INFO, "<tdls> %s: Rcv a event: %d\n", __func__, u4EventId);
switch (u4EventId) {
case TDLS_HOST_EVENT_TEAR_DOWN:
TdlsEventTearDown(prGlueInfo, prInBuf + 4, u4InBufLen);
break;
case TDLS_HOST_EVENT_TX_DONE:
TdlsEventTxDone(prGlueInfo, prInBuf + 4, u4InBufLen);
break;
case TDLS_HOST_EVENT_FME_STATUS:
TdlsEventFmeStatus(prGlueInfo, prInBuf + 4, u4InBufLen);
break;
case TDLS_HOST_EVENT_STATISTICS:
TdlsEventStatistics(prGlueInfo, prInBuf + 4, u4InBufLen);
break;
}
}
/*----------------------------------------------------------------------------*/
/*!
* @brief This function is used to initialize variables in TDLS.
*
* \param[in] prAdapter Pointer to the Adapter structure
*
* @return TDLS_STATUS_SUCCESS: do not set key and key infor. is queued
TDLS_STATUS_FAILURE: set key
*/
/*----------------------------------------------------------------------------*/
TDLS_STATUS TdlsexKeyHandle(ADAPTER_T *prAdapter, PARAM_KEY_T *prNewKey)
{
STA_RECORD_T *prStaRec;
/* sanity check */
if ((prAdapter == NULL) || (prNewKey == NULL))
return TDLS_STATUS_FAILURE;
/*
supplicant will set key before updating station & enabling the link so we need to
backup the key information and set key when link is enabled
*/
prStaRec = cnmGetStaRecByAddress(prAdapter, NETWORK_TYPE_AIS_INDEX, prNewKey->arBSSID);
if ((prStaRec != NULL) && IS_TDLS_STA(prStaRec)) {
DBGLOG(TDLS, TRACE, "<tdls> %s: [%pM] queue key (len=%d) until link is enabled\n",
__func__, prNewKey->arBSSID, (UINT32) prNewKey->u4KeyLength);
if (prStaRec->ucStaState == STA_STATE_3) {
DBGLOG(TDLS, TRACE, "<tdls> %s: [%pM] tear down the link due to STA_STATE_3\n",
__func__, prNewKey->arBSSID);
/* re-key */
TdlsLinkHistoryRecord(prAdapter->prGlueInfo, TRUE,
prStaRec->aucMacAddr, TRUE,
TDLS_REASON_CODE_MTK_DIS_BY_US_DUE_TO_REKEY, NULL);
/* 16 Nov 21:49 2012 http://permalink.gmane.org/gmane.linux.kernel.wireless.general/99712 */
cfg80211_tdls_oper_request(prAdapter->prGlueInfo->prDevHandler,
prStaRec->aucMacAddr, TDLS_FRM_ACTION_TEARDOWN,
TDLS_REASON_CODE_UNSPECIFIED, GFP_ATOMIC);
return TDLS_STATUS_SUCCESS;
}
/* backup the key */
kalMemCopy(&prStaRec->rTdlsKeyTemp, prNewKey, sizeof(prStaRec->rTdlsKeyTemp));
return TDLS_STATUS_SUCCESS;
}
return TDLS_STATUS_FAILURE;
}
/*----------------------------------------------------------------------------*/
/*!
* @brief This function is used to initialize variables in TDLS.
*
* \param[in] prAdapter Pointer to the Adapter structure
*
* @return (none)
*/
/*----------------------------------------------------------------------------*/
VOID TdlsexInit(ADAPTER_T *prAdapter)
{
GLUE_INFO_T *prGlueInfo;
/* init */
prGlueInfo = (GLUE_INFO_T *) prAdapter->prGlueInfo;
/* reset */
kalMemZero(&prGlueInfo->rTdlsLink, sizeof(prGlueInfo->rTdlsLink));
}
/*----------------------------------------------------------------------------*/
/*!
* \brief This routine is called to get any peer is in power save.
*
* \param[in] prAdapter Pointer to the Adapter structure
*
* \retval TRUE (at least one peer is in power save)
*/
/*----------------------------------------------------------------------------*/
BOOLEAN TdlsexIsAnyPeerInPowerSave(ADAPTER_T *prAdapter)
{
STA_RECORD_T *prStaRec;
UINT32 u4StaId, u4StartIdx;
for (u4StaId = 0, u4StartIdx = 0; u4StaId < CFG_STA_REC_NUM; u4StaId++) {
/* list all TDLS peers */
prStaRec = cnmStaTheTypeGet(prAdapter, NETWORK_TYPE_AIS_INDEX, STA_TYPE_TDLS_PEER, &u4StartIdx);
if (prStaRec == NULL)
break;
if (prStaRec->fgIsInPS == TRUE) {
DBGLOG(TDLS, TRACE, "<tx> yes, at least one peer is in ps\n");
return TRUE;
}
}
return FALSE;
}
/*----------------------------------------------------------------------------*/
/*!
* \brief This routine is called to enable or disable a TDLS link.
*
* \param[in] prAdapter Pointer to the Adapter structure
* \param[in] pvSetBuffer A pointer to the buffer that holds the data to be set
* \param[in] u4SetBufferLen The length of the set buffer
* \param[out] pu4SetInfoLen If the call is successful, returns the number of
* bytes read from the set buffer. If the call failed due to invalid length of
* the set buffer, returns the amount of storage needed.
*
* \retval TDLS_STATUS_xx
*/
/*----------------------------------------------------------------------------*/
TDLS_STATUS TdlsexLinkCtrl(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen)
{
GLUE_INFO_T *prGlueInfo;
TDLS_CMD_LINK_T *prCmd;
BSS_INFO_T *prBssInfo;
STA_RECORD_T *prStaRec;
TDLS_LINK_HIS_OTHERS_T rHisOthers;
/* sanity check */
if ((prAdapter == NULL) || (pvSetBuffer == NULL) || (pu4SetInfoLen == NULL)) {
DBGLOG(TDLS, ERROR, "<tdls_cmd> %s: sanity fail!\n", __func__);
return TDLS_STATUS_FAILURE;
}
/* init */
prGlueInfo = (GLUE_INFO_T *) prAdapter->prGlueInfo;
*pu4SetInfoLen = sizeof(TDLS_CMD_LINK_T);
prCmd = (TDLS_CMD_LINK_T *) pvSetBuffer;
/* search old entry */
prStaRec = cnmGetStaRecByAddress(prAdapter, (UINT_8) NETWORK_TYPE_AIS_INDEX, prCmd->aucPeerMac);
if (prStaRec == NULL) {
DBGLOG(TDLS, ERROR, "<tdls_cfg> %s: cannot find the peer! %pM\n",
__func__, prCmd->aucPeerMac);
return TDLS_STATUS_FAILURE;
}
if (prCmd->fgIsEnabled == TRUE) {
cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_3);
DBGLOG(TDLS, TRACE, "<tdls_cfg> %s: NL80211_TDLS_ENABLE_LINK\n", __func__);
/* update key information after cnmStaRecChangeState(STA_STATE_3) */
prStaRec->fgTdlsInSecurityMode = FALSE;
if (prStaRec->rTdlsKeyTemp.u4Length > 0) {
UINT_32 u4BufLen; /* no use */
DBGLOG(TDLS, INFO, "<tdls_cfg> %s: key len=%d\n",
__func__, (UINT32) prStaRec->rTdlsKeyTemp.u4Length);
/*
reminder the function that we are CIPHER_SUITE_CCMP,
do not change cipher type to CIPHER_SUITE_WEP128
*/
_wlanoidSetAddKey(prAdapter, &prStaRec->rTdlsKeyTemp,
prStaRec->rTdlsKeyTemp.u4Length, FALSE, CIPHER_SUITE_CCMP, &u4BufLen);
/* clear the temp key */
prStaRec->fgTdlsInSecurityMode = TRUE;
kalMemZero(&prStaRec->rTdlsKeyTemp, sizeof(prStaRec->rTdlsKeyTemp));
}
/* check if we need to disable channel switch function */
prBssInfo = &(prAdapter->rWifiVar.arBssInfo[prStaRec->ucNetTypeIndex]);
if (prBssInfo->fgTdlsIsChSwProhibited == TRUE) {
TDLS_CMD_CORE_T rCmd;
kalMemZero(&rCmd, sizeof(TDLS_CMD_CORE_T));
rCmd.Content.rCmdChSwConf.ucNetTypeIndex = prStaRec->ucNetTypeIndex;
rCmd.Content.rCmdChSwConf.fgIsChSwEnabled = FALSE;
kalMemCopy(rCmd.aucPeerMac, prStaRec->aucMacAddr, 6);
TdlsChSwConf(prAdapter, &rCmd, 0, 0);
DBGLOG(TDLS, INFO, "<tdls_cfg> %s: disable channel switch\n", __func__);
}
TDLS_LINK_INCREASE(prGlueInfo);
/* record link */
if (prStaRec->ucDesiredPhyTypeSet & PHY_TYPE_SET_802_11N)
rHisOthers.fgIsHt = TRUE;
else
rHisOthers.fgIsHt = FALSE;
TdlsLinkHistoryRecord(prAdapter->prGlueInfo, FALSE,
prStaRec->aucMacAddr, !prStaRec->flgTdlsIsInitiator, 0, &rHisOthers);
} else {
cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_1);
cnmStaRecFree(prAdapter, prStaRec, TRUE); /* release to other TDLS peers */
DBGLOG(TDLS, TRACE, "<tdls_cfg> %s: NL80211_TDLS_DISABLE_LINK\n", __func__);
TDLS_LINK_DECREASE(prGlueInfo);
/* while(1); //sample debug */
}
/* work-around link count */
if ((TDLS_LINK_COUNT(prGlueInfo) < 0) || (TDLS_LINK_COUNT(prGlueInfo) > 1)) {
/* ERROR case: work-around to recount by searching all station records */
UINT32 u4Idx;
TDLS_LINK_COUNT_RESET(prGlueInfo);
for (u4Idx = 0; u4Idx < CFG_STA_REC_NUM; u4Idx++) {
prStaRec = &prAdapter->arStaRec[u4Idx];
if (prStaRec->fgIsInUse && IS_TDLS_STA(prStaRec))
TDLS_LINK_INCREASE(prGlueInfo);
}
if (TDLS_LINK_COUNT(prGlueInfo) > 1) {
/* number of links is still > 1 */
DBGLOG(TDLS, INFO, "<tdls_cfg> %s: cTdlsLinkCnt %d > 1?\n",
__func__, TDLS_LINK_COUNT(prGlueInfo));
TDLS_LINK_COUNT_RESET(prGlueInfo);
/* free all TDLS links */
for (u4Idx = 0; u4Idx < CFG_STA_REC_NUM; u4Idx++) {
prStaRec = &prAdapter->arStaRec[u4Idx];
if (prStaRec->fgIsInUse && IS_TDLS_STA(prStaRec))
cnmStaRecFree(prAdapter, prStaRec, TRUE);
}
/* maybe inform supplicant ? */
}
}
/* display TDLS link history */
TdlsInfoDisplay(prAdapter, NULL, 0, NULL);
return TDLS_STATUS_SUCCESS;
}
/*----------------------------------------------------------------------------*/
/*!
* \brief This routine is called to send a TDLS action data frame.
*
* \param[in] prAdapter Pointer to the Adapter structure
* \param[in] pvSetBuffer A pointer to the buffer that holds the data to be set
* \param[in] u4SetBufferLen The length of the set buffer
* \param[out] pu4SetInfoLen If the call is successful, returns the number of
* bytes read from the set buffer. If the call failed due to invalid length of
* the set buffer, returns the amount of storage needed.
*
* \retval TDLS_STATUS_xx
*/
/*----------------------------------------------------------------------------*/
TDLS_STATUS TdlsexMgmtCtrl(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen)
{
GLUE_INFO_T *prGlueInfo;
TDLS_MGMT_TX_INFO *prMgmtTxInfo;
STA_RECORD_T *prStaRec;
/* sanity check */
if ((prAdapter == NULL) || (pvSetBuffer == NULL) || (pu4SetInfoLen == NULL)) {
DBGLOG(TDLS, ERROR, "<tdls_cmd> %s: sanity fail!\n", __func__);
return TDLS_STATUS_FAILURE;
}
/* init */
prGlueInfo = (GLUE_INFO_T *) prAdapter->prGlueInfo;
*pu4SetInfoLen = sizeof(TDLS_MGMT_TX_INFO);
prMgmtTxInfo = (TDLS_MGMT_TX_INFO *) pvSetBuffer;
switch (prMgmtTxInfo->ucActionCode) {
case TDLS_FRM_ACTION_DISCOVERY_RESPONSE:
prStaRec = NULL;
break;
case TDLS_FRM_ACTION_SETUP_REQ:
prStaRec = cnmGetStaRecByAddress(prAdapter, (UINT_8) NETWORK_TYPE_AIS_INDEX, prMgmtTxInfo->aucPeer);
if ((prStaRec != NULL) && (prStaRec->ucStaState == STA_STATE_3)) {
/* rekey? we reject re-setup link currently */
/* TODO: Still can setup link during rekey */
/*
return success to avoid supplicant clear TDLS entry;
Or we cannot send out any TDLS tear down frame to the peer
*/
DBGLOG(TDLS, TRACE, "<tdls_cmd> %s: skip new setup on the exist link!\n", __func__);
return TDLS_STATUS_SUCCESS;
}
prStaRec = NULL;
break;
case TDLS_FRM_ACTION_SETUP_RSP:
case TDLS_FRM_ACTION_CONFIRM:
case TDLS_FRM_ACTION_TEARDOWN:
prStaRec = cnmGetStaRecByAddress(prAdapter, (UINT_8) NETWORK_TYPE_AIS_INDEX, prMgmtTxInfo->aucPeer);
#if 0 /* in some cases, the prStaRec is still NULL */
/*
EX: if a peer sends us a TDLS setup request with wrong BSSID,
supplicant will not call TdlsexPeerAdd() to create prStaRec and
supplicant will send a TDLS setup response with status code 7.
So in the case, prStaRec will be NULL.
*/
if (prStaRec == NULL) {
DBGLOG(TDLS, ERROR, "<tdls_cfg> %s: cannot find the peer!\n", __func__);
return -EINVAL;
}
#endif
break;
/*
TODO: Discovery response frame
Note that the TDLS Discovery Response frame is not a TDLS frame but a 11
Public Action frame.
In WiFi TDLS Tech Minutes June 8 2010.doc,
a public action frame (i.e. it is no longer an encapsulated data frame)
*/
default:
DBGLOG(TDLS, ERROR,
"<tdls_cfg> %s: wrong action_code %d!\n", __func__, prMgmtTxInfo->ucActionCode);
return TDLS_STATUS_FAILURE;
}
/* send the TDLS data frame */
if (prStaRec != NULL) {
DBGLOG(TDLS, INFO, "<tdls_cfg> %s: [%pM] ps=%d status=%d\n",
__func__, prStaRec->aucMacAddr,
prStaRec->fgIsInPS, prMgmtTxInfo->u2StatusCode);
if (prMgmtTxInfo->ucActionCode == TDLS_FRM_ACTION_TEARDOWN) {
/* record disconnect history */
TdlsLinkHistoryRecord(prGlueInfo, TRUE, prMgmtTxInfo->aucPeer,
TRUE, prMgmtTxInfo->u2StatusCode, NULL);
}
}
return TdlsDataFrameSend(prAdapter,
prStaRec,
prMgmtTxInfo->aucPeer,
prMgmtTxInfo->ucActionCode,
prMgmtTxInfo->ucDialogToken,
prMgmtTxInfo->u2StatusCode,
(UINT_8 *) prMgmtTxInfo->aucSecBuf, prMgmtTxInfo->u4SecBufLen);
}
/*----------------------------------------------------------------------------*/
/*!
* \brief This routine is called to add a peer record.
*
* \param[in] prAdapter Pointer to the Adapter structure
* \param[in] pvSetBuffer A pointer to the buffer that holds the data to be set
* \param[in] u4SetBufferLen The length of the set buffer
* \param[out] pu4SetInfoLen If the call is successful, returns the number of
* bytes read from the set buffer. If the call failed due to invalid length of
* the set buffer, returns the amount of storage needed.
*
* \retval TDLS_STATUS_xx
*/
/*----------------------------------------------------------------------------*/
TDLS_STATUS TdlsexPeerAdd(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen)
{
GLUE_INFO_T *prGlueInfo;
TDLS_CMD_PEER_ADD_T *prCmd;
BSS_INFO_T *prAisBssInfo;
STA_RECORD_T *prStaRec;
UINT_8 ucNonHTPhyTypeSet;
UINT32 u4StartIdx;
OS_SYSTIME rCurTime;
/* sanity check */
DBGLOG(TDLS, INFO, "<tdls_cmd> %s\n", __func__);
if ((prAdapter == NULL) || (pvSetBuffer == NULL) || (pu4SetInfoLen == NULL)) {
DBGLOG(TDLS, ERROR, "<tdls_cmd> %s: sanity fail!\n", __func__);
return TDLS_STATUS_FAILURE;
}
/* init */
prGlueInfo = (GLUE_INFO_T *) prAdapter->prGlueInfo;
*pu4SetInfoLen = sizeof(TDLS_CMD_PEER_ADD_T);
prCmd = (TDLS_CMD_PEER_ADD_T *) pvSetBuffer;
prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
u4StartIdx = 0;
/* search old entry */
prStaRec = cnmGetStaRecByAddress(prAdapter, (UINT_8) NETWORK_TYPE_AIS_INDEX, prCmd->aucPeerMac);
/* check if any TDLS link exists because we only support one TDLS link currently */
if (prStaRec == NULL) {
/* the MAC is new peer */
prStaRec = cnmStaTheTypeGet(prAdapter, NETWORK_TYPE_AIS_INDEX, STA_TYPE_TDLS_PEER, &u4StartIdx);
if (prStaRec != NULL) {
/* a building TDLS link exists */
DBGLOG(TDLS, ERROR,
"<tdls_cmd> %s: one TDLS link setup [%pM] is going...\n",
__func__, prStaRec->aucMacAddr);
if (prStaRec->ucStaState != STA_STATE_3) {
/* check timeout */
GET_CURRENT_SYSTIME(&rCurTime);
if (CHECK_FOR_TIMEOUT(rCurTime, prStaRec->rTdlsSetupStartTime,
SEC_TO_SYSTIME(TDLS_SETUP_TIMEOUT_SEC))) {
/* free the StaRec */
cnmStaRecFree(prAdapter, prStaRec, TRUE);
DBGLOG(TDLS, ERROR,
"<tdls_cmd> %s: free going TDLS link setup [%pM]\n",
__func__, (prStaRec->aucMacAddr));
/* handle new setup */
prStaRec = NULL;
} else
return TDLS_STATUS_FAILURE;
} else {
/* the TDLS is built and works fine, reject new one */
return TDLS_STATUS_FAILURE;
}
}
} else {
if (prStaRec->ucStaState == STA_STATE_3) {
/* the peer exists, maybe TPK lifetime expired, supplicant wants to renew key */
TdlsLinkHistoryRecord(prAdapter->prGlueInfo, TRUE,
prStaRec->aucMacAddr, TRUE,
TDLS_REASON_CODE_MTK_DIS_BY_US_DUE_TO_REKEY, NULL);
/* 16 Nov 21:49 2012 http://permalink.gmane.org/gmane.linux.kernel.wireless.general/99712 */
cfg80211_tdls_oper_request(prAdapter->prGlueInfo->prDevHandler,
prStaRec->aucMacAddr, TDLS_FRM_ACTION_TEARDOWN,
TDLS_REASON_CODE_UNSPECIFIED, GFP_ATOMIC);
DBGLOG(TDLS, TRACE,
"<tdls_cmd> %s: re-setup link for [%pM] maybe re-key?\n",
__func__, (prStaRec->aucMacAddr));
return TDLS_STATUS_FAILURE;
}
}
/*
create new entry if not exist
1. we are initiator
(1) send TDLS setup request
wpa_sm_tdls_peer_addset(sm, peer->addr, 1, 0, 0, NULL, 0, NULL, NULL, 0, NULL, 0);
create a station record with STA_STATE_1.
(2) got TDLS setup response and send TDLS setup confirm
wpa_tdls_enable_link()
update a station record with STA_STATE_3.
2. we are responder
(1) got TDLS setup request
wpa_sm_tdls_peer_addset(sm, peer->addr, 1, 0, 0, NULL, 0, NULL, NULL, 0, NULL, 0);
create a station record with STA_STATE_1.
(2) send TDLS setup response
(3) got TDLS setup confirm
wpa_tdls_enable_link()
update a station record with STA_STATE_3.
*/
if (prStaRec == NULL) {
prStaRec = cnmStaRecAlloc(prAdapter, (UINT_8) NETWORK_TYPE_AIS_INDEX);
if (prStaRec == NULL) {
/* shall not be here */
DBGLOG(TDLS, ERROR, "<tdls_cmd> %s: alloc prStaRec fail!\n", __func__);
return TDLS_STATUS_RESOURCES;
}
/* init the prStaRec */
/* prStaRec will be zero first in cnmStaRecAlloc() */
COPY_MAC_ADDR(prStaRec->aucMacAddr, prCmd->aucPeerMac);
/* cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_1); */
} else {
#if 0
if ((prStaRec->ucStaState > STA_STATE_1) && (IS_TDLS_STA(prStaRec))) {
/*
test plan: The STAUT should locally tear down existing TDLS direct link and
respond with Set up Response frame.
*/
cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_1);
}
#endif
}
/* reference to bssCreateStaRecFromBssDesc() and use our best capability */
/* reference to assocBuildReAssocReqFrameCommonIEs() to fill elements */
/* prStaRec->u2CapInfo */
/* TODO: Need to parse elements from setup request frame */
prStaRec->u2OperationalRateSet = prAisBssInfo->u2OperationalRateSet;
prStaRec->u2BSSBasicRateSet = prAisBssInfo->u2BSSBasicRateSet;
prStaRec->u2DesiredNonHTRateSet = prAdapter->rWifiVar.ucAvailablePhyTypeSet;
prStaRec->ucPhyTypeSet = prAisBssInfo->ucPhyTypeSet;
prStaRec->eStaType = STA_TYPE_TDLS_PEER;
prStaRec->ucDesiredPhyTypeSet = /*prStaRec->ucPhyTypeSet & */
prAdapter->rWifiVar.ucAvailablePhyTypeSet;
ucNonHTPhyTypeSet = prStaRec->ucDesiredPhyTypeSet & PHY_TYPE_SET_802_11ABG;
/* check for Target BSS's non HT Phy Types */
if (ucNonHTPhyTypeSet) {
if (ucNonHTPhyTypeSet & PHY_TYPE_BIT_ERP) {
prStaRec->ucNonHTBasicPhyType = PHY_TYPE_ERP_INDEX;
} else if (ucNonHTPhyTypeSet & PHY_TYPE_BIT_OFDM) {
prStaRec->ucNonHTBasicPhyType = PHY_TYPE_OFDM_INDEX;
} else { /* if (ucNonHTPhyTypeSet & PHY_TYPE_HR_DSSS_INDEX) */
prStaRec->ucNonHTBasicPhyType = PHY_TYPE_HR_DSSS_INDEX;
}
prStaRec->fgHasBasicPhyType = TRUE;
} else {
/* use mandatory for 11N only BSS */
/* ASSERT(prStaRec->ucPhyTypeSet & PHY_TYPE_SET_802_11N); */
prStaRec->ucNonHTBasicPhyType = PHY_TYPE_HR_DSSS_INDEX;
prStaRec->fgHasBasicPhyType = FALSE;
}
/* update non HT Desired Rate Set */
{
P_CONNECTION_SETTINGS_T prConnSettings;
prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
prStaRec->u2DesiredNonHTRateSet =
(prStaRec->u2OperationalRateSet & prConnSettings->u2DesiredNonHTRateSet);
}
#if 0 /* TdlsexPeerAdd() will be called before we receive setup rsp in TdlsexRxFrameHandle() */
/* check if the add is from the same peer in the 1st unhandled setup request frame */
DBGLOG(TDLS, INFO, "<tdls_cmd> %s: [%pM] [%pM]\n",
__func__, prGlueInfo->aucTdlsHtPeerMac, prCmd->aucPeerMac);
if (kalMemCmp(prGlueInfo->aucTdlsHtPeerMac, prCmd->aucPeerMac, 6) == 0) {
/* copy the HT capability from its setup request */
kalMemCopy(&prStaRec->rTdlsHtCap, &prGlueInfo->rTdlsHtCap, sizeof(IE_HT_CAP_T));
prStaRec->ucPhyTypeSet |= PHY_TYPE_SET_802_11N;
prStaRec->u2DesiredNonHTRateSet |= BIT(RATE_HT_PHY_INDEX);
/* reset backup */
kalMemZero(&prGlueInfo->rTdlsHtCap, sizeof(prStaRec->rTdlsHtCap));
kalMemZero(prGlueInfo->aucTdlsHtPeerMac, sizeof(prGlueInfo->aucTdlsHtPeerMac));
DBGLOG(TDLS, INFO, "<tdls_cmd> %s: peer is a HT device\n", __func__);
}
#endif
/* update WMM: must support due to UAPSD in TDLS link */
prStaRec->fgIsWmmSupported = TRUE;
prStaRec->fgIsUapsdSupported = TRUE;
/* update station record to firmware */
cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_1);
/* update time */
GET_CURRENT_SYSTIME(&prStaRec->rTdlsSetupStartTime);
DBGLOG(TDLS, INFO, "<tdls_cmd> %s: create a peer [%pM]\n",
__func__, (prStaRec->aucMacAddr));
return TDLS_STATUS_SUCCESS;
}
/*----------------------------------------------------------------------------*/
/*!
* \brief This routine is called to update a peer record.
*
* \param[in] prAdapter Pointer to the Adapter structure
* \param[in] pvSetBuffer A pointer to the buffer that holds the data to be set
* \param[in] u4SetBufferLen The length of the set buffer
* \param[out] pu4SetInfoLen If the call is successful, returns the number of
* bytes read from the set buffer. If the call failed due to invalid length of
* the set buffer, returns the amount of storage needed.
*
* \retval TDLS_STATUS_xx
*/
/*----------------------------------------------------------------------------*/
TDLS_STATUS TdlsexPeerUpdate(ADAPTER_T *prAdapter, VOID *pvSetBuffer, UINT_32 u4SetBufferLen, UINT_32 *pu4SetInfoLen)
{
GLUE_INFO_T *prGlueInfo;
TDLS_CMD_PEER_UPDATE_T *prCmd;
BSS_INFO_T *prAisBssInfo;
STA_RECORD_T *prStaRec;
IE_HT_CAP_T *prHtCap;
/* sanity check */
DBGLOG(TDLS, INFO, "<tdls_cmd> %s\n", __func__);
if ((prAdapter == NULL) || (pvSetBuffer == NULL) || (pu4SetInfoLen == NULL)) {
DBGLOG(TDLS, ERROR, "<tdls_cmd> %s: sanity fail!\n", __func__);
return TDLS_STATUS_FAILURE;
}
/* init */
prGlueInfo = (GLUE_INFO_T *) prAdapter->prGlueInfo;
*pu4SetInfoLen = sizeof(TDLS_CMD_PEER_ADD_T);
prCmd = (TDLS_CMD_PEER_UPDATE_T *) pvSetBuffer;
prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
/* search old entry */
prStaRec = cnmGetStaRecByAddress(prAdapter, (UINT_8) NETWORK_TYPE_AIS_INDEX, prCmd->aucPeerMac);
/*
create new entry if not exist
1. we are initiator
(1) send TDLS setup request
wpa_sm_tdls_peer_addset(sm, peer->addr, 1, 0, 0, NULL, 0, NULL, NULL, 0, NULL, 0);
create a station record with STA_STATE_1.
(2) got TDLS setup response and send TDLS setup confirm
wpa_tdls_enable_link()
update a station record with STA_STATE_3.
2. we are responder
(1) got TDLS setup request
wpa_sm_tdls_peer_addset(sm, peer->addr, 1, 0, 0, NULL, 0, NULL, NULL, 0, NULL, 0);
create a station record with STA_STATE_1.
(2) send TDLS setup response
(3) got TDLS setup confirm
wpa_tdls_enable_link()
update a station record with STA_STATE_3.
*/
if ((prStaRec == NULL) || (prStaRec->fgIsInUse == 0)) {
DBGLOG(TDLS, ERROR, "<tdls_cmd> %s: cannot find the peer!\n", __func__);
return TDLS_STATUS_FAILURE;
}
DBGLOG(TDLS, INFO, "<tdls_cmd> %s: update a peer [%pM] %d -> %d, 0x%x\n",
__func__, (prStaRec->aucMacAddr),
prStaRec->ucStaState, STA_STATE_3, prStaRec->eStaType);
if (!IS_TDLS_STA(prStaRec)) {
DBGLOG(TDLS, ERROR, "<tdls_cmd> %s: peer is not TDLS one!\n", __func__);
return TDLS_STATUS_FAILURE;
}
/* check if the add is from the same peer in the 1st unhandled setup request frame */
DBGLOG(TDLS, INFO, "<tdls_cmd> %s: [%pM] [%pM]\n",
__func__, (prGlueInfo->aucTdlsHtPeerMac), (prCmd->aucPeerMac));
if (kalMemCmp(prGlueInfo->aucTdlsHtPeerMac, prCmd->aucPeerMac, 6) == 0) {
/* copy the HT capability from its setup request */
kalMemCopy(&prStaRec->rTdlsHtCap, &prGlueInfo->rTdlsHtCap, sizeof(IE_HT_CAP_T));
prStaRec->ucPhyTypeSet |= PHY_TYPE_SET_802_11N;
prStaRec->u2DesiredNonHTRateSet |= BIT(RATE_HT_PHY_INDEX);
/* reset backup */
kalMemZero(&prGlueInfo->rTdlsHtCap, sizeof(prStaRec->rTdlsHtCap));
kalMemZero(prGlueInfo->aucTdlsHtPeerMac, sizeof(prGlueInfo->aucTdlsHtPeerMac));
DBGLOG(TDLS, INFO, "<tdls_cmd> %s: peer is a HT device\n", __func__);
}
/* update the record join time. */
GET_CURRENT_SYSTIME(&prStaRec->rUpdateTime);
/* update Station Record - Status/Reason Code */
prStaRec->u2StatusCode = prCmd->u2StatusCode;
/* prStaRec->ucStaState shall be STA_STATE_1 */
prStaRec->u2CapInfo = prCmd->u2Capability;
/* prStaRec->u2OperationalRateSet */
prStaRec->u2AssocId = 0; /* no use */
prStaRec->u2ListenInterval = 0; /* unknown */
/* prStaRec->ucDesiredPhyTypeSet */
/* prStaRec->u2DesiredNonHTRateSet */
/* prStaRec->u2BSSBasicRateSet */
/* prStaRec->ucMcsSet */
/* prStaRec->fgSupMcs32 */
/* prStaRec->u2HtCapInfo */
prStaRec->fgIsQoS = TRUE;
prStaRec->fgIsUapsdSupported = (prCmd->UapsdBitmap == 0) ? FALSE : TRUE;
/* prStaRec->ucAmpduParam */
/* prStaRec->u2HtExtendedCap */
prStaRec->u4TxBeamformingCap = 0; /* no use */
prStaRec->ucAselCap = 0; /* no use */
prStaRec->ucRCPI = 0;
prStaRec->ucBmpTriggerAC = prCmd->UapsdBitmap;
prStaRec->ucBmpDeliveryAC = prCmd->UapsdBitmap;
prStaRec->ucUapsdSp = prCmd->UapsdMaxSp;
/* update HT */
#if (TDLS_CFG_HT_SUP == 1)
if (prCmd->fgIsSupHt == FALSE) {
/* no HT IE is from supplicant so we use the backup */
prHtCap = (IE_HT_CAP_T *) &prStaRec->rTdlsHtCap;
DBGLOG(TDLS, INFO, "<tdls_cmd> %s: [%pM] update ht ie 0x%x\n",
__func__, (prStaRec->aucMacAddr), prHtCap->ucId);
if (prHtCap->ucId == ELEM_ID_HT_CAP) {
prStaRec->ucMcsSet = prHtCap->rSupMcsSet.aucRxMcsBitmask[0];
prStaRec->fgSupMcs32 = (prHtCap->rSupMcsSet.aucRxMcsBitmask[32 / 8] & BIT(0)) ? TRUE : FALSE;
prStaRec->u2HtCapInfo = prHtCap->u2HtCapInfo;
prStaRec->ucAmpduParam = prHtCap->ucAmpduParam;
prStaRec->u2HtExtendedCap = prHtCap->u2HtExtendedCap;
prStaRec->u4TxBeamformingCap = prHtCap->u4TxBeamformingCap;
prStaRec->ucAselCap = prHtCap->ucAselCap;
prStaRec->ucDesiredPhyTypeSet |= PHY_TYPE_SET_802_11N;
}
} else {
/* TODO: use the HT IE from supplicant */
}
#endif /* TDLS_CFG_HT_SUP */
DBGLOG(TDLS, INFO, "<tdls_cmd> %s: UAPSD 0x%x %d MCS=0x%x\n",
__func__, prCmd->UapsdBitmap, prCmd->UapsdMaxSp, prStaRec->ucMcsSet);
/* cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_3); */
DBGLOG(TDLS, INFO, "<tdls_cmd> %s: update a peer [%pM]\n",
__func__, (prStaRec->aucMacAddr));
return TDLS_STATUS_SUCCESS;
}
/*----------------------------------------------------------------------------*/
/*!
* \brief This routine is called to check if we need to drop a TDLS action frame.
*
* \param[in] *pPkt Pointer to the struct sk_buff->data.
* \param[in]
* \param[in]
*
* \retval None
*/
/*----------------------------------------------------------------------------*/
BOOLEAN TdlsexRxFrameDrop(GLUE_INFO_T *prGlueInfo, UINT_8 *pPkt)
{
ADAPTER_T *prAdapter;
UINT8 ucActionId;
/* sanity check */
if ((pPkt == NULL) || (*(pPkt + 12) != 0x89) || (*(pPkt + 13) != 0x0d))
return FALSE; /* not TDLS data frame htons(0x890d) */
#if 0 /* supplicant handles this check */
if (prStaRec == NULL)
return FALSE; /* shall not be here */
DBGLOG(TDLS, INFO,
"<tdls_fme> %s: Rcv a TDLS action frame (id=%d) %d %d\n",
__func__, *(pPkt + 13 + 4), prStaRec->fgTdlsIsProhibited, fgIsPtiTimeoutSkip);
/* check if TDLS Prohibited bit is set in AP's beacon */
if (prStaRec->fgTdlsIsProhibited == TRUE)
return TRUE;
#endif
ucActionId = *(pPkt + 12 + 2 + 2); /* skip dst, src MAC, type, payload type, category */
if (fgIsPtiTimeoutSkip == TRUE) {
/* also skip any tear down frame from the peer */
if (ucActionId == TDLS_FRM_ACTION_TEARDOWN)
return TRUE;
}
prAdapter = prGlueInfo->prAdapter;
DBGLOG(TDLS, INFO,
"<tdls_fme> %s: Rcv a TDLS action frame %d (%u)\n",
__func__, ucActionId, (UINT32) prAdapter->rRxCtrl.rFreeSwRfbList.u4NumElem);
if (ucActionId == TDLS_FRM_ACTION_TEARDOWN) {
DBGLOG(TDLS, WARN, "<tdls_fme> %s: Rcv a TDLS tear down frame %d, will DISABLE link\n",
__func__, *(pPkt + 13 + 4)); /* reason code */
/* record disconnect history */
TdlsLinkHistoryRecord(prGlueInfo, TRUE, pPkt + 6, FALSE, *(pPkt + 13 + 4), NULL);
/* inform tear down to supplicant only in OPEN/NONE mode */
/*
we need to tear down the link manually; or supplicant will display
"No FTIE in TDLS Teardown" and it will not tear down the link
*/
cfg80211_tdls_oper_request(prGlueInfo->prDevHandler,
pPkt + 6, TDLS_FRM_ACTION_TEARDOWN, *(pPkt + 13 + 4), GFP_ATOMIC);
}
#if 0 /* pass all to supplicant except same thing is handled in supplicant */
if (((*(pPkt + 13 + 3)) == TDLS_FRM_ACTION_PTI) ||
((*(pPkt + 13 + 3)) == TDLS_FRM_ACTION_CHAN_SWITCH_REQ) ||
((*(pPkt + 13 + 3)) == TDLS_FRM_ACTION_CHAN_SWITCH_RSP) ||
((*(pPkt + 13 + 3)) == TDLS_FRM_ACTION_PTI_RSP)) {
return TRUE;
}
#endif
return FALSE;
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to parse some IEs in the setup frame from the peer.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] pPkt Pointer to the ethernet packet
*
* \retval None
*
*/
/*----------------------------------------------------------------------------*/
VOID TdlsexRxFrameHandle(GLUE_INFO_T *prGlueInfo, UINT8 *pPkt, UINT16 u2PktLen)
{
ADAPTER_T *prAdapter;
STA_RECORD_T *prStaRec;
UINT8 ucActionId;
UINT8 *pucPeerMac, ucElmId, ucElmLen;
INT16 s2FmeLen;
/* sanity check */
if ((prGlueInfo == NULL) || (pPkt == NULL) || (*(pPkt + 12) != 0x89) || (*(pPkt + 13) != 0x0d))
return;
ucActionId = *(pPkt + 12 + 2 + 2); /* skip dst, src MAC, type, payload type, category */
if ((ucActionId != TDLS_FRM_ACTION_SETUP_REQ) && (ucActionId != TDLS_FRM_ACTION_SETUP_RSP))
return;
/* init */
prAdapter = prGlueInfo->prAdapter;
pucPeerMac = pPkt + 6;
s2FmeLen = (INT16) u2PktLen;
DBGLOG(TDLS, TRACE,
"<tdls_fme> %s: get a setup frame %d from %pM\n",
__func__, ucActionId, (pucPeerMac));
if (ucActionId == TDLS_FRM_ACTION_SETUP_REQ)
pPkt += 12 + 2 + 2 + 1 + 1 + 2; /* skip action, dialog token, capability */
else
pPkt += 12 + 2 + 2 + 1 + 2 + 1 + 2; /* skip action, status code, dialog token, capability */
/* check station record */
prStaRec = cnmGetStaRecByAddress(prGlueInfo->prAdapter, (UINT_8) NETWORK_TYPE_AIS_INDEX, pucPeerMac);
if (prStaRec == NULL) {
prStaRec = cnmStaRecAlloc(prAdapter, (UINT_8) NETWORK_TYPE_AIS_INDEX);
if (prStaRec == NULL) {
/* TODO: only one TDLS entry, need to free old one if timeout */
DBGLOG(TDLS, ERROR, "<tdls_cmd> %s: alloc prStaRec fail!\n", __func__);
return;
}
/* init the prStaRec */
/* prStaRec will be zero first in cnmStaRecAlloc() */
COPY_MAC_ADDR(prStaRec->aucMacAddr, pucPeerMac);
cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_1);
}
/* backup HT IE to station record */
/* TODO: Maybe our TDLS only supports non-11n */
while (s2FmeLen > 0) {
ucElmId = *pPkt++;
ucElmLen = *pPkt++;
switch (ucElmId) {
case ELEM_ID_HT_CAP: /* 0x2d */
/* backup the HT IE of 1st unhandled setup request frame */
if (prGlueInfo->rTdlsHtCap.ucId == 0x00 &&
ucElmLen <= sizeof(IE_HT_CAP_T) - 2) {
kalMemCopy(prGlueInfo->aucTdlsHtPeerMac, pucPeerMac, 6);
kalMemCopy(&prGlueInfo->rTdlsHtCap, pPkt - 2, ucElmLen + 2);
/*
cannot backup in prStaRec; or
1. we build a TDLS link
2. peer re-sends setup req
3. we backup HT cap element
4. supplicant disables the link
5. we clear the prStaRec
*/
DBGLOG(TDLS, TRACE,
"<tdls_fme> %s: %pM: find a HT IE\n",
__func__, (pucPeerMac));
}
return;
case ELEM_ID_EXTENDED_CAP:
/* TODO: backup the extended capability IE */
break;
}
pPkt += ucElmLen;
s2FmeLen -= (2 + ucElmLen);
}
}
/*----------------------------------------------------------------------------*/
/*! \brief This routine is called to get the TDLS station record.
*
* \param[in] prGlueInfo Pointer to the Adapter structure
* \param[in] prInBuf A pointer to the command string buffer
* \param[in] u4InBufLen The length of the buffer
* \param[out] None
*
* \retval TDLS_STATUS_SUCCESS: this is TDLS packet
* TDLS_STATUS_FAILURE: this is not TDLS packet
*/
/*----------------------------------------------------------------------------*/
TDLS_STATUS TdlsexStaRecIdxGet(ADAPTER_T *prAdapter, MSDU_INFO_T *prMsduInfo)
{
BSS_INFO_T *prBssInfo;
STA_RECORD_T *prStaRec;
TDLS_STATUS Status;
/* sanity check */
if ((prAdapter == NULL) || (prMsduInfo == NULL))
return TDLS_STATUS_FAILURE;
if (prAdapter->prGlueInfo == NULL)
return TDLS_STATUS_FAILURE;
if (TDLS_IS_NO_LINK_GOING(prAdapter->prGlueInfo))
return TDLS_STATUS_FAILURE;
/* init */
prMsduInfo->ucStaRecIndex = STA_REC_INDEX_NOT_FOUND;
Status = TDLS_STATUS_SUCCESS;
/* get record by ether dest */
prStaRec = cnmGetStaRecByAddress(prAdapter, (UINT_8) NETWORK_TYPE_AIS_INDEX, prMsduInfo->aucEthDestAddr);
/*
TDLS Setup Request frames, TDLS Setup Response frames and TDLS Setup Confirm
frames shall be transmitted through the AP and shall not be transmitted to a group
address.
1. In first time, prStaRec == NULL or prStaRec->ucStaState != STA_STATE_3,
we will send them to AP;
2. When link is still on, if you command to send TDLS setup from supplicant,
supplicant will DISABLE LINK first, prStaRec will be NULL then send TDLS
setup frame to the peer.
*/
do {
if ((prStaRec != NULL) && (prStaRec->ucStaState == STA_STATE_3) && (IS_TDLS_STA(prStaRec))) {
/*
TDLS Test Case 5.3 Tear Down
Automatically sends TDLS Teardown frame to STA 2 via AP
11.21.5 TDLS Direct Link Teardown
The TDLS Teardown frame shall be sent over the direct path and the reason
code shall be set to "TDLS 40 direct link teardown for unspecified reason",
except when the TDLS peer STA is unreachable via the TDLS direct link,
in which case, the TDLS Teardown frame shall be sent through the AP and
the reason code shall be set to "TDLS direct link teardown due to TDLS peer
STA unreachable via the TDLS direct link".
*/
/* if (prStaRec->fgIsInPS == TRUE) */
/*
check if the packet is tear down:
we do not want to use PTI to indicate the tear down and
we want to send the tear down to AP then AP help us to send it
*/
struct sk_buff *prSkb;
UINT8 *pEth;
UINT_16 u2EtherTypeLen;
prSkb = (struct sk_buff *)prMsduInfo->prPacket;
if (prSkb != NULL) {
UINT8 ucActionCode, ucReasonCode;
/* init */
pEth = prSkb->data;
u2EtherTypeLen = (pEth[ETH_TYPE_LEN_OFFSET] << 8) |
(pEth[ETH_TYPE_LEN_OFFSET + 1]);
ucActionCode = pEth[ETH_TYPE_LEN_OFFSET + 1 + 3];
ucReasonCode = pEth[ETH_TYPE_LEN_OFFSET + 1 + 4] |
(pEth[ETH_TYPE_LEN_OFFSET + 1 + 5] << 8);
/* TDLS_REASON_CODE_UNREACHABLE: keep alive fail or PTI timeout */
if ((u2EtherTypeLen == TDLS_FRM_PROT_TYPE) &&
(ucActionCode == TDLS_FRM_ACTION_TEARDOWN) &&
(ucReasonCode == TDLS_REASON_CODE_UNREACHABLE)) {
/*
when we cannot reach the peer,
we need AP's help to send the tear down frame
*/
prBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
prStaRec = prBssInfo->prStaRecOfAP;
if (prStaRec == NULL) {
Status = TDLS_STATUS_FAILURE;
break;
}
#if 0
/* change status code */
pEth[ETH_TYPE_LEN_OFFSET + 1 + 4] = TDLS_REASON_CODE_UNREACHABLE;
#endif
}
}
prMsduInfo->ucStaRecIndex = prStaRec->ucIndex;
}
} while (FALSE);
DBGLOG(TDLS, INFO, "<tdls> %s: (Status=%x) [%pM] ucStaRecIndex = %d!\n",
__func__, (INT32) Status, (prMsduInfo->aucEthDestAddr),
prMsduInfo->ucStaRecIndex);
return Status;
}
/*----------------------------------------------------------------------------*/
/*!
* @brief This function is used to check if we suffer timeout for TX quota empty case.
*
* \param[in] prAdapter Pointer to the Adapter structure
*
* @return (none)
*/
/*----------------------------------------------------------------------------*/
VOID TdlsexTxQuotaCheck(GLUE_INFO_T *prGlueInfo, STA_RECORD_T *prStaRec, UINT8 FreeQuota)
{
OS_SYSTIME rCurTime;
/* sanity check */
if (!IS_TDLS_STA(prStaRec))
return;
if (FreeQuota != 0) {
/* reset timeout */
prStaRec->rTdlsTxQuotaEmptyTime = 0;
return;
}
/* work-around: check if the no free quota case is too long */
GET_CURRENT_SYSTIME(&rCurTime);
if (prStaRec->rTdlsTxQuotaEmptyTime == 0) {
prStaRec->rTdlsTxQuotaEmptyTime = rCurTime;
} else {
if (CHECK_FOR_TIMEOUT(rCurTime, prStaRec->rTdlsTxQuotaEmptyTime,
SEC_TO_SYSTIME(TDLS_TX_QUOTA_EMPTY_TIMEOUT))) {
/* tear down the link */
DBGLOG(TDLS, WARN,
"<tdls> %s: [%pM] TX quota empty timeout!\n",
__func__, (prStaRec->aucMacAddr));
/* record disconnect history */
TdlsLinkHistoryRecord(prGlueInfo, TRUE, prStaRec->aucMacAddr,
TRUE, TDLS_REASON_CODE_MTK_DIS_BY_US_DUE_TO_TX_QUOTA_EMPTY, NULL);
/* inform tear down to supplicant only in OPEN/NONE mode */
/*
we need to tear down the link manually; or supplicant will display
"No FTIE in TDLS Teardown" and it will not tear down the link
*/
cfg80211_tdls_oper_request(prGlueInfo->prDevHandler,
prStaRec->aucMacAddr, TDLS_FRM_ACTION_TEARDOWN,
TDLS_REASON_CODE_UNREACHABLE, GFP_ATOMIC);
}
}
}
/*----------------------------------------------------------------------------*/
/*!
* @brief This function is used to un-initialize variables in TDLS.
*
* \param[in] prAdapter Pointer to the Adapter structure
*
* @return (none)
*/
/*----------------------------------------------------------------------------*/
VOID TdlsexUninit(ADAPTER_T *prAdapter)
{
#if TDLS_CFG_CMD_TEST
cnmTimerStopTimer(prAdapter, &rTdlsTimerTestDataSend);
#endif /* TDLS_CFG_CMD_TEST */
}
#endif /* CFG_SUPPORT_TDLS */
/* End of tdls.c */
|