aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/bcmdhd/include/proto/802.11.h
blob: a8739a831cd40e25719b65e8853098435a54f00a (plain)
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
/*
 * Copyright (C) 1999-2014, Broadcom Corporation
 * 
 *      Unless you and Broadcom execute a separate written software license
 * agreement governing use of this software, this software is licensed to you
 * under the terms of the GNU General Public License version 2 (the "GPL"),
 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
 * following added to such license:
 * 
 *      As a special exception, the copyright holders of this software give you
 * permission to link this software with independent modules, and to copy and
 * distribute the resulting executable under terms of your choice, provided that
 * you also meet, for each linked independent module, the terms and conditions of
 * the license of that module.  An independent module is a module which is not
 * derived from this software.  The special exception does not apply to any
 * modifications of the software.
 * 
 *      Notwithstanding the above, under no circumstances may you combine this
 * software in any way with any other Broadcom software provided under a license
 * other than the GPL, without Broadcom's express prior written consent.
 *
 * Fundamental types and constants relating to 802.11
 *
 * $Id: 802.11.h 444070 2013-12-18 13:20:12Z $
 */

#ifndef _802_11_H_
#define _802_11_H_

#ifndef _TYPEDEFS_H_
#include <typedefs.h>
#endif

#ifndef _NET_ETHERNET_H_
#include <proto/ethernet.h>
#endif

#include <proto/wpa.h>


#include <packed_section_start.h>


#define DOT11_TU_TO_US			1024	


#define DOT11_A3_HDR_LEN		24	
#define DOT11_A4_HDR_LEN		30	
#define DOT11_MAC_HDR_LEN		DOT11_A3_HDR_LEN	
#define DOT11_FCS_LEN			4	
#define DOT11_ICV_LEN			4	
#define DOT11_ICV_AES_LEN		8	
#define DOT11_QOS_LEN			2	
#define DOT11_HTC_LEN			4	

#define DOT11_KEY_INDEX_SHIFT		6	
#define DOT11_IV_LEN			4	
#define DOT11_IV_TKIP_LEN		8	
#define DOT11_IV_AES_OCB_LEN		4	
#define DOT11_IV_AES_CCM_LEN		8	
#define DOT11_IV_MAX_LEN		8	


#define DOT11_MAX_MPDU_BODY_LEN		2304	

#define DOT11_MAX_MPDU_LEN		(DOT11_A4_HDR_LEN + \
					 DOT11_QOS_LEN + \
					 DOT11_IV_AES_CCM_LEN + \
					 DOT11_MAX_MPDU_BODY_LEN + \
					 DOT11_ICV_LEN + \
					 DOT11_FCS_LEN)	

#define DOT11_MAX_SSID_LEN		32	


#define DOT11_DEFAULT_RTS_LEN		2347	
#define DOT11_MAX_RTS_LEN		2347	


#define DOT11_MIN_FRAG_LEN		256	
#define DOT11_MAX_FRAG_LEN		2346	
#define DOT11_DEFAULT_FRAG_LEN		2346	


#define DOT11_MIN_BEACON_PERIOD		1	
#define DOT11_MAX_BEACON_PERIOD		0xFFFF	


#define DOT11_MIN_DTIM_PERIOD		1	
#define DOT11_MAX_DTIM_PERIOD		0xFF	


#define DOT11_LLC_SNAP_HDR_LEN		8	
#define DOT11_OUI_LEN			3	
BWL_PRE_PACKED_STRUCT struct dot11_llc_snap_header {
	uint8	dsap;				
	uint8	ssap;				
	uint8	ctl;				
	uint8	oui[DOT11_OUI_LEN];		
	uint16	type;				
} BWL_POST_PACKED_STRUCT;


#define RFC1042_HDR_LEN	(ETHER_HDR_LEN + DOT11_LLC_SNAP_HDR_LEN)	



BWL_PRE_PACKED_STRUCT struct dot11_header {
	uint16			fc;		
	uint16			durid;		
	struct ether_addr	a1;		
	struct ether_addr	a2;		
	struct ether_addr	a3;		
	uint16			seq;		
	struct ether_addr	a4;		
} BWL_POST_PACKED_STRUCT;



BWL_PRE_PACKED_STRUCT struct dot11_rts_frame {
	uint16			fc;		
	uint16			durid;		
	struct ether_addr	ra;		
	struct ether_addr	ta;		
} BWL_POST_PACKED_STRUCT;
#define	DOT11_RTS_LEN		16		

BWL_PRE_PACKED_STRUCT struct dot11_cts_frame {
	uint16			fc;		
	uint16			durid;		
	struct ether_addr	ra;		
} BWL_POST_PACKED_STRUCT;
#define	DOT11_CTS_LEN		10		

BWL_PRE_PACKED_STRUCT struct dot11_ack_frame {
	uint16			fc;		
	uint16			durid;		
	struct ether_addr	ra;		
} BWL_POST_PACKED_STRUCT;
#define	DOT11_ACK_LEN		10		

BWL_PRE_PACKED_STRUCT struct dot11_ps_poll_frame {
	uint16			fc;		
	uint16			durid;		
	struct ether_addr	bssid;		
	struct ether_addr	ta;		
} BWL_POST_PACKED_STRUCT;
#define	DOT11_PS_POLL_LEN	16		

BWL_PRE_PACKED_STRUCT struct dot11_cf_end_frame {
	uint16			fc;		
	uint16			durid;		
	struct ether_addr	ra;		
	struct ether_addr	bssid;		
} BWL_POST_PACKED_STRUCT;
#define	DOT11_CS_END_LEN	16		


BWL_PRE_PACKED_STRUCT struct dot11_action_wifi_vendor_specific {
	uint8	category;
	uint8	OUI[3];
	uint8	type;
	uint8	subtype;
	uint8	data[1040];
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_action_wifi_vendor_specific dot11_action_wifi_vendor_specific_t;


BWL_PRE_PACKED_STRUCT struct dot11_action_vs_frmhdr {
	uint8	category;
	uint8	OUI[3];
	uint8	type;
	uint8	subtype;
	uint8	data[1];
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_action_vs_frmhdr dot11_action_vs_frmhdr_t;
#define DOT11_ACTION_VS_HDR_LEN	6

#define BCM_ACTION_OUI_BYTE0	0x00
#define BCM_ACTION_OUI_BYTE1	0x90
#define BCM_ACTION_OUI_BYTE2	0x4c


#define DOT11_BA_CTL_POLICY_NORMAL	0x0000	
#define DOT11_BA_CTL_POLICY_NOACK	0x0001	
#define DOT11_BA_CTL_POLICY_MASK	0x0001	

#define DOT11_BA_CTL_MTID		0x0002	
#define DOT11_BA_CTL_COMPRESSED		0x0004	

#define DOT11_BA_CTL_NUMMSDU_MASK	0x0FC0	
#define DOT11_BA_CTL_NUMMSDU_SHIFT	6	

#define DOT11_BA_CTL_TID_MASK		0xF000	
#define DOT11_BA_CTL_TID_SHIFT		12	


BWL_PRE_PACKED_STRUCT struct dot11_ctl_header {
	uint16			fc;		
	uint16			durid;		
	struct ether_addr	ra;		
	struct ether_addr	ta;		
} BWL_POST_PACKED_STRUCT;
#define DOT11_CTL_HDR_LEN	16		


BWL_PRE_PACKED_STRUCT struct dot11_bar {
	uint16			bar_control;	
	uint16			seqnum;		
} BWL_POST_PACKED_STRUCT;
#define DOT11_BAR_LEN		4		

#define DOT11_BA_BITMAP_LEN	128		
#define DOT11_BA_CMP_BITMAP_LEN	8		

BWL_PRE_PACKED_STRUCT struct dot11_ba {
	uint16			ba_control;	
	uint16			seqnum;		
	uint8			bitmap[DOT11_BA_BITMAP_LEN];	
} BWL_POST_PACKED_STRUCT;
#define DOT11_BA_LEN		4		


BWL_PRE_PACKED_STRUCT struct dot11_management_header {
	uint16			fc;		
	uint16			durid;		
	struct ether_addr	da;		
	struct ether_addr	sa;		
	struct ether_addr	bssid;		
	uint16			seq;		
} BWL_POST_PACKED_STRUCT;
#define	DOT11_MGMT_HDR_LEN	24		



BWL_PRE_PACKED_STRUCT struct dot11_bcn_prb {
	uint32			timestamp[2];
	uint16			beacon_interval;
	uint16			capability;
} BWL_POST_PACKED_STRUCT;
#define	DOT11_BCN_PRB_LEN	12		
#define	DOT11_BCN_PRB_FIXED_LEN	12		

BWL_PRE_PACKED_STRUCT struct dot11_auth {
	uint16			alg;		
	uint16			seq;		
	uint16			status;		
} BWL_POST_PACKED_STRUCT;
#define DOT11_AUTH_FIXED_LEN	6		

BWL_PRE_PACKED_STRUCT struct dot11_assoc_req {
	uint16			capability;	
	uint16			listen;		
} BWL_POST_PACKED_STRUCT;
#define DOT11_ASSOC_REQ_FIXED_LEN	4	

BWL_PRE_PACKED_STRUCT struct dot11_reassoc_req {
	uint16			capability;	
	uint16			listen;		
	struct ether_addr	ap;		
} BWL_POST_PACKED_STRUCT;
#define DOT11_REASSOC_REQ_FIXED_LEN	10	

BWL_PRE_PACKED_STRUCT struct dot11_assoc_resp {
	uint16			capability;	
	uint16			status;		
	uint16			aid;		
} BWL_POST_PACKED_STRUCT;
#define DOT11_ASSOC_RESP_FIXED_LEN	6	

BWL_PRE_PACKED_STRUCT struct dot11_action_measure {
	uint8	category;
	uint8	action;
	uint8	token;
	uint8	data[1];
} BWL_POST_PACKED_STRUCT;
#define DOT11_ACTION_MEASURE_LEN	3	

BWL_PRE_PACKED_STRUCT struct dot11_action_ht_ch_width {
	uint8	category;
	uint8	action;
	uint8	ch_width;
} BWL_POST_PACKED_STRUCT;

BWL_PRE_PACKED_STRUCT struct dot11_action_ht_mimops {
	uint8	category;
	uint8	action;
	uint8	control;
} BWL_POST_PACKED_STRUCT;

BWL_PRE_PACKED_STRUCT struct dot11_action_sa_query {
	uint8	category;
	uint8	action;
	uint16	id;
} BWL_POST_PACKED_STRUCT;

#define SM_PWRSAVE_ENABLE	1
#define SM_PWRSAVE_MODE		2


BWL_PRE_PACKED_STRUCT struct dot11_power_cnst {
	uint8 id;
	uint8 len;
	uint8 power;
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_power_cnst dot11_power_cnst_t;

BWL_PRE_PACKED_STRUCT struct dot11_power_cap {
	uint8 min;
	uint8 max;
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_power_cap dot11_power_cap_t;

BWL_PRE_PACKED_STRUCT struct dot11_tpc_rep {
	uint8 id;
	uint8 len;
	uint8 tx_pwr;
	uint8 margin;
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_tpc_rep dot11_tpc_rep_t;
#define DOT11_MNG_IE_TPC_REPORT_LEN	2 	

BWL_PRE_PACKED_STRUCT struct dot11_supp_channels {
	uint8 id;
	uint8 len;
	uint8 first_channel;
	uint8 num_channels;
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_supp_channels dot11_supp_channels_t;


BWL_PRE_PACKED_STRUCT struct dot11_extch {
	uint8	id;		
	uint8	len;		
	uint8	extch;
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_extch dot11_extch_ie_t;

BWL_PRE_PACKED_STRUCT struct dot11_brcm_extch {
	uint8	id;		/* IE ID, 221, DOT11_MNG_PROPR_ID */
	uint8	len;		/* IE length */
	uint8	oui[3];
	uint8	type;           /* type inidicates what follows */
	uint8	extch;
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_brcm_extch dot11_brcm_extch_ie_t;

#define BRCM_EXTCH_IE_LEN	5
#define BRCM_EXTCH_IE_TYPE	53	
#define DOT11_EXTCH_IE_LEN	1
#define DOT11_EXT_CH_MASK	0x03	
#define DOT11_EXT_CH_UPPER	0x01	
#define DOT11_EXT_CH_LOWER	0x03	
#define DOT11_EXT_CH_NONE	0x00	

BWL_PRE_PACKED_STRUCT struct dot11_action_frmhdr {
	uint8	category;
	uint8	action;
	uint8	data[1];
} BWL_POST_PACKED_STRUCT;
#define DOT11_ACTION_FRMHDR_LEN	2


BWL_PRE_PACKED_STRUCT struct dot11_channel_switch {
	uint8 id;	
	uint8 len;	
	uint8 mode;	
	uint8 channel;	
	uint8 count;	
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_channel_switch dot11_chan_switch_ie_t;

#define DOT11_SWITCH_IE_LEN	3	

#define DOT11_CSA_MODE_ADVISORY		0	
#define DOT11_CSA_MODE_NO_TX		1	

BWL_PRE_PACKED_STRUCT struct dot11_action_switch_channel {
	uint8	category;
	uint8	action;
	dot11_chan_switch_ie_t chan_switch_ie;	
	dot11_brcm_extch_ie_t extch_ie;		
} BWL_POST_PACKED_STRUCT;

BWL_PRE_PACKED_STRUCT struct dot11_csa_body {
	uint8 mode;	
	uint8 reg;	
	uint8 channel;	
	uint8 count;	
} BWL_POST_PACKED_STRUCT;


BWL_PRE_PACKED_STRUCT struct dot11_ext_csa {
	uint8 id;	
	uint8 len;	
	struct dot11_csa_body b;	
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_ext_csa dot11_ext_csa_ie_t;
#define DOT11_EXT_CSA_IE_LEN	4	

BWL_PRE_PACKED_STRUCT struct dot11_action_ext_csa {
	uint8	category;
	uint8	action;
	dot11_ext_csa_ie_t chan_switch_ie;	
} BWL_POST_PACKED_STRUCT;

BWL_PRE_PACKED_STRUCT struct dot11y_action_ext_csa {
	uint8	category;
	uint8	action;
	struct dot11_csa_body b;	
} BWL_POST_PACKED_STRUCT;


BWL_PRE_PACKED_STRUCT struct dot11_wide_bw_channel_switch {
	uint8 id;				
	uint8 len;				
	uint8 channel_width;			
	uint8 center_frequency_segment_0;	
	uint8 center_frequency_segment_1;	
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_wide_bw_channel_switch dot11_wide_bw_chan_switch_ie_t;

#define DOT11_WIDE_BW_SWITCH_IE_LEN     3       


BWL_PRE_PACKED_STRUCT struct dot11_channel_switch_wrapper {
	uint8 id;				
	uint8 len;				
	dot11_wide_bw_chan_switch_ie_t wb_chan_switch_ie;
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_channel_switch_wrapper dot11_chan_switch_wrapper_ie_t;


BWL_PRE_PACKED_STRUCT struct dot11_vht_transmit_power_envelope {
	uint8 id;				
	uint8 len;				
	uint8 transmit_power_info;
	uint8 local_max_transmit_power_20;
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_vht_transmit_power_envelope dot11_vht_transmit_power_envelope_ie_t;


BWL_PRE_PACKED_STRUCT struct dot11_obss_coex {
	uint8	id;
	uint8	len;
	uint8	info;
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_obss_coex dot11_obss_coex_t;
#define DOT11_OBSS_COEXINFO_LEN	1	

#define	DOT11_OBSS_COEX_INFO_REQ		0x01
#define	DOT11_OBSS_COEX_40MHZ_INTOLERANT	0x02
#define	DOT11_OBSS_COEX_20MHZ_WIDTH_REQ	0x04

BWL_PRE_PACKED_STRUCT struct dot11_obss_chanlist {
	uint8	id;
	uint8	len;
	uint8	regclass;
	uint8	chanlist[1];
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_obss_chanlist dot11_obss_chanlist_t;
#define DOT11_OBSS_CHANLIST_FIXED_LEN	1	

BWL_PRE_PACKED_STRUCT struct dot11_extcap_ie {
	uint8 id;
	uint8 len;
	uint8 cap[1];
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_extcap_ie dot11_extcap_ie_t;

#define DOT11_EXTCAP_LEN_MAX	7
#define DOT11_EXTCAP_LEN_COEX	1
#define DOT11_EXTCAP_LEN_BT	3
#define DOT11_EXTCAP_LEN_IW	4
#define DOT11_EXTCAP_LEN_SI	6

#define DOT11_EXTCAP_LEN_TDLS	5
BWL_PRE_PACKED_STRUCT struct dot11_extcap {
	uint8 extcap[DOT11_EXTCAP_LEN_TDLS];
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_extcap dot11_extcap_t;


#define TDLS_CAP_TDLS			37		
#define TDLS_CAP_PU_BUFFER_STA	28		
#define TDLS_CAP_PEER_PSM		20		
#define TDLS_CAP_CH_SW			30		
#define TDLS_CAP_PROH			38		
#define TDLS_CAP_CH_SW_PROH		39		

#define TDLS_CAP_MAX_BIT		39		



#define DOT11_MEASURE_TYPE_BASIC 	0	
#define DOT11_MEASURE_TYPE_CCA 		1	
#define DOT11_MEASURE_TYPE_RPI		2	
#define DOT11_MEASURE_TYPE_CHLOAD		3	
#define DOT11_MEASURE_TYPE_NOISE		4	
#define DOT11_MEASURE_TYPE_BEACON		5	
#define DOT11_MEASURE_TYPE_FRAME	6	
#define DOT11_MEASURE_TYPE_STAT		7	
#define DOT11_MEASURE_TYPE_LCI		8	
#define DOT11_MEASURE_TYPE_TXSTREAM		9	
#define DOT11_MEASURE_TYPE_PAUSE		255	


#define DOT11_MEASURE_MODE_PARALLEL 	(1<<0)	
#define DOT11_MEASURE_MODE_ENABLE 	(1<<1)	
#define DOT11_MEASURE_MODE_REQUEST	(1<<2)	
#define DOT11_MEASURE_MODE_REPORT 	(1<<3)	
#define DOT11_MEASURE_MODE_DUR 	(1<<4)	

#define DOT11_MEASURE_MODE_LATE 	(1<<0)	
#define DOT11_MEASURE_MODE_INCAPABLE	(1<<1)	
#define DOT11_MEASURE_MODE_REFUSED	(1<<2)	

#define DOT11_MEASURE_BASIC_MAP_BSS	((uint8)(1<<0))	
#define DOT11_MEASURE_BASIC_MAP_OFDM	((uint8)(1<<1))	
#define DOT11_MEASURE_BASIC_MAP_UKNOWN	((uint8)(1<<2))	
#define DOT11_MEASURE_BASIC_MAP_RADAR	((uint8)(1<<3))	
#define DOT11_MEASURE_BASIC_MAP_UNMEAS	((uint8)(1<<4))	

BWL_PRE_PACKED_STRUCT struct dot11_meas_req {
	uint8 id;
	uint8 len;
	uint8 token;
	uint8 mode;
	uint8 type;
	uint8 channel;
	uint8 start_time[8];
	uint16 duration;
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_meas_req dot11_meas_req_t;
#define DOT11_MNG_IE_MREQ_LEN 14	

#define DOT11_MNG_IE_MREQ_FIXED_LEN 3	

BWL_PRE_PACKED_STRUCT struct dot11_meas_rep {
	uint8 id;
	uint8 len;
	uint8 token;
	uint8 mode;
	uint8 type;
	BWL_PRE_PACKED_STRUCT union
	{
		BWL_PRE_PACKED_STRUCT struct {
			uint8 channel;
			uint8 start_time[8];
			uint16 duration;
			uint8 map;
		} BWL_POST_PACKED_STRUCT basic;
		uint8 data[1];
	} BWL_POST_PACKED_STRUCT rep;
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_meas_rep dot11_meas_rep_t;


#define DOT11_MNG_IE_MREP_FIXED_LEN	3	

BWL_PRE_PACKED_STRUCT struct dot11_meas_rep_basic {
	uint8 channel;
	uint8 start_time[8];
	uint16 duration;
	uint8 map;
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_meas_rep_basic dot11_meas_rep_basic_t;
#define DOT11_MEASURE_BASIC_REP_LEN	12	

BWL_PRE_PACKED_STRUCT struct dot11_quiet {
	uint8 id;
	uint8 len;
	uint8 count;	
	uint8 period;	
	uint16 duration;	
	uint16 offset;	
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_quiet dot11_quiet_t;

BWL_PRE_PACKED_STRUCT struct chan_map_tuple {
	uint8 channel;
	uint8 map;
} BWL_POST_PACKED_STRUCT;
typedef struct chan_map_tuple chan_map_tuple_t;

BWL_PRE_PACKED_STRUCT struct dot11_ibss_dfs {
	uint8 id;
	uint8 len;
	uint8 eaddr[ETHER_ADDR_LEN];
	uint8 interval;
	chan_map_tuple_t map[1];
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_ibss_dfs dot11_ibss_dfs_t;


#define WME_OUI			"\x00\x50\xf2"	
#define WME_OUI_TYPE		2	
#define WME_OUI_LEN		3
#define WME_TYPE		2	
#define WME_SUBTYPE_IE		0	
#define WME_SUBTYPE_PARAM_IE	1	
#define WME_SUBTYPE_TSPEC	2	
#define WME_VER			1	


#define AC_BE			0	
#define AC_BK			1	
#define AC_VI			2	
#define AC_VO			3	
#define AC_COUNT		4	

typedef uint8 ac_bitmap_t;	

#define AC_BITMAP_NONE		0x0	
#define AC_BITMAP_ALL		0xf	
#define AC_BITMAP_TST(ab, ac)	(((ab) & (1 << (ac))) != 0)
#define AC_BITMAP_SET(ab, ac)	(((ab) |= (1 << (ac))))
#define AC_BITMAP_RESET(ab, ac) (((ab) &= ~(1 << (ac))))


BWL_PRE_PACKED_STRUCT struct wme_ie {
	uint8 oui[3];
	uint8 type;
	uint8 subtype;
	uint8 version;
	uint8 qosinfo;
} BWL_POST_PACKED_STRUCT;
typedef struct wme_ie wme_ie_t;
#define WME_IE_LEN 7	

BWL_PRE_PACKED_STRUCT struct edcf_acparam {
	uint8	ACI;
	uint8	ECW;
	uint16  TXOP;		
} BWL_POST_PACKED_STRUCT;
typedef struct edcf_acparam edcf_acparam_t;


BWL_PRE_PACKED_STRUCT struct wme_param_ie {
	uint8 oui[3];
	uint8 type;
	uint8 subtype;
	uint8 version;
	uint8 qosinfo;
	uint8 rsvd;
	edcf_acparam_t acparam[AC_COUNT];
} BWL_POST_PACKED_STRUCT;
typedef struct wme_param_ie wme_param_ie_t;
#define WME_PARAM_IE_LEN            24          


#define WME_QI_AP_APSD_MASK         0x80        
#define WME_QI_AP_APSD_SHIFT        7           
#define WME_QI_AP_COUNT_MASK        0x0f        
#define WME_QI_AP_COUNT_SHIFT       0           


#define WME_QI_STA_MAXSPLEN_MASK    0x60        
#define WME_QI_STA_MAXSPLEN_SHIFT   5           
#define WME_QI_STA_APSD_ALL_MASK    0xf         
#define WME_QI_STA_APSD_ALL_SHIFT   0           
#define WME_QI_STA_APSD_BE_MASK     0x8         
#define WME_QI_STA_APSD_BE_SHIFT    3           
#define WME_QI_STA_APSD_BK_MASK     0x4         
#define WME_QI_STA_APSD_BK_SHIFT    2           
#define WME_QI_STA_APSD_VI_MASK     0x2         
#define WME_QI_STA_APSD_VI_SHIFT    1           
#define WME_QI_STA_APSD_VO_MASK     0x1         
#define WME_QI_STA_APSD_VO_SHIFT    0           


#define EDCF_AIFSN_MIN               1           
#define EDCF_AIFSN_MAX               15          
#define EDCF_AIFSN_MASK              0x0f        
#define EDCF_ACM_MASK                0x10        
#define EDCF_ACI_MASK                0x60        
#define EDCF_ACI_SHIFT               5           
#define EDCF_AIFSN_SHIFT             12          


#define EDCF_ECW_MIN                 0           
#define EDCF_ECW_MAX                 15          
#define EDCF_ECW2CW(exp)             ((1 << (exp)) - 1)
#define EDCF_ECWMIN_MASK             0x0f        
#define EDCF_ECWMAX_MASK             0xf0        
#define EDCF_ECWMAX_SHIFT            4           


#define EDCF_TXOP_MIN                0           
#define EDCF_TXOP_MAX                65535       
#define EDCF_TXOP2USEC(txop)         ((txop) << 5)


#define NON_EDCF_AC_BE_ACI_STA          0x02


#define EDCF_AC_BE_ACI_STA           0x03	
#define EDCF_AC_BE_ECW_STA           0xA4	
#define EDCF_AC_BE_TXOP_STA          0x0000	
#define EDCF_AC_BK_ACI_STA           0x27	
#define EDCF_AC_BK_ECW_STA           0xA4	
#define EDCF_AC_BK_TXOP_STA          0x0000	
#define EDCF_AC_VI_ACI_STA           0x42	
#define EDCF_AC_VI_ECW_STA           0x43	
#define EDCF_AC_VI_TXOP_STA          0x005e	
#define EDCF_AC_VO_ACI_STA           0x62	
#define EDCF_AC_VO_ECW_STA           0x32	
#define EDCF_AC_VO_TXOP_STA          0x002f	


#define EDCF_AC_BE_ACI_AP            0x03	
#define EDCF_AC_BE_ECW_AP            0x64	
#define EDCF_AC_BE_TXOP_AP           0x0000	
#define EDCF_AC_BK_ACI_AP            0x27	
#define EDCF_AC_BK_ECW_AP            0xA4	
#define EDCF_AC_BK_TXOP_AP           0x0000	
#define EDCF_AC_VI_ACI_AP            0x41	
#define EDCF_AC_VI_ECW_AP            0x43	
#define EDCF_AC_VI_TXOP_AP           0x005e	
#define EDCF_AC_VO_ACI_AP            0x61	
#define EDCF_AC_VO_ECW_AP            0x32	
#define EDCF_AC_VO_TXOP_AP           0x002f	


BWL_PRE_PACKED_STRUCT struct edca_param_ie {
	uint8 qosinfo;
	uint8 rsvd;
	edcf_acparam_t acparam[AC_COUNT];
} BWL_POST_PACKED_STRUCT;
typedef struct edca_param_ie edca_param_ie_t;
#define EDCA_PARAM_IE_LEN            18          


BWL_PRE_PACKED_STRUCT struct qos_cap_ie {
	uint8 qosinfo;
} BWL_POST_PACKED_STRUCT;
typedef struct qos_cap_ie qos_cap_ie_t;

BWL_PRE_PACKED_STRUCT struct dot11_qbss_load_ie {
	uint8 id; 			
	uint8 length;
	uint16 station_count; 		
	uint8 channel_utilization;	
	uint16 aac; 			
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_qbss_load_ie dot11_qbss_load_ie_t;
#define BSS_LOAD_IE_SIZE 	7	


#define FIXED_MSDU_SIZE 0x8000		
#define MSDU_SIZE_MASK	0x7fff		



#define	INTEGER_SHIFT	13	
#define FRACTION_MASK	0x1FFF	


BWL_PRE_PACKED_STRUCT struct dot11_management_notification {
	uint8 category;			
	uint8 action;
	uint8 token;
	uint8 status;
	uint8 data[1];			
} BWL_POST_PACKED_STRUCT;
#define DOT11_MGMT_NOTIFICATION_LEN 4	


BWL_PRE_PACKED_STRUCT struct ti_ie {
	uint8 ti_type;
	uint32 ti_val;
} BWL_POST_PACKED_STRUCT;
typedef struct ti_ie ti_ie_t;
#define TI_TYPE_REASSOC_DEADLINE	1
#define TI_TYPE_KEY_LIFETIME		2


#define WME_ADDTS_REQUEST	0	
#define WME_ADDTS_RESPONSE	1	
#define WME_DELTS_REQUEST	2	


#define WME_ADMISSION_ACCEPTED		0	
#define WME_INVALID_PARAMETERS		1	
#define WME_ADMISSION_REFUSED		3	


#define BCN_PRB_SSID(body) ((char*)(body) + DOT11_BCN_PRB_LEN)


#define DOT11_OPEN_SYSTEM	0	
#define DOT11_SHARED_KEY	1	
#define DOT11_FAST_BSS		2	
#define DOT11_CHALLENGE_LEN	128	


#define FC_PVER_MASK		0x3	
#define FC_PVER_SHIFT		0	
#define FC_TYPE_MASK		0xC	
#define FC_TYPE_SHIFT		2	
#define FC_SUBTYPE_MASK		0xF0	
#define FC_SUBTYPE_SHIFT	4	
#define FC_TODS			0x100	
#define FC_TODS_SHIFT		8	
#define FC_FROMDS		0x200	
#define FC_FROMDS_SHIFT		9	
#define FC_MOREFRAG		0x400	
#define FC_MOREFRAG_SHIFT	10	
#define FC_RETRY		0x800	
#define FC_RETRY_SHIFT		11	
#define FC_PM			0x1000	
#define FC_PM_SHIFT		12	
#define FC_MOREDATA		0x2000	
#define FC_MOREDATA_SHIFT	13	
#define FC_WEP			0x4000	
#define FC_WEP_SHIFT		14	
#define FC_ORDER		0x8000	
#define FC_ORDER_SHIFT		15	


#define SEQNUM_SHIFT		4	
#define SEQNUM_MAX		0x1000	
#define FRAGNUM_MASK		0xF	




#define FC_TYPE_MNG		0	
#define FC_TYPE_CTL		1	
#define FC_TYPE_DATA		2	


#define FC_SUBTYPE_ASSOC_REQ		0	
#define FC_SUBTYPE_ASSOC_RESP		1	
#define FC_SUBTYPE_REASSOC_REQ		2	
#define FC_SUBTYPE_REASSOC_RESP		3	
#define FC_SUBTYPE_PROBE_REQ		4	
#define FC_SUBTYPE_PROBE_RESP		5	
#define FC_SUBTYPE_BEACON		8	
#define FC_SUBTYPE_ATIM			9	
#define FC_SUBTYPE_DISASSOC		10	
#define FC_SUBTYPE_AUTH			11	
#define FC_SUBTYPE_DEAUTH		12	
#define FC_SUBTYPE_ACTION		13	
#define FC_SUBTYPE_ACTION_NOACK		14	


#define FC_SUBTYPE_CTL_WRAPPER		7	
#define FC_SUBTYPE_BLOCKACK_REQ		8	
#define FC_SUBTYPE_BLOCKACK		9	
#define FC_SUBTYPE_PS_POLL		10	
#define FC_SUBTYPE_RTS			11	
#define FC_SUBTYPE_CTS			12	
#define FC_SUBTYPE_ACK			13	
#define FC_SUBTYPE_CF_END		14	
#define FC_SUBTYPE_CF_END_ACK		15	


#define FC_SUBTYPE_DATA			0	
#define FC_SUBTYPE_DATA_CF_ACK		1	
#define FC_SUBTYPE_DATA_CF_POLL		2	
#define FC_SUBTYPE_DATA_CF_ACK_POLL	3	
#define FC_SUBTYPE_NULL			4	
#define FC_SUBTYPE_CF_ACK		5	
#define FC_SUBTYPE_CF_POLL		6	
#define FC_SUBTYPE_CF_ACK_POLL		7	
#define FC_SUBTYPE_QOS_DATA		8	
#define FC_SUBTYPE_QOS_DATA_CF_ACK	9	
#define FC_SUBTYPE_QOS_DATA_CF_POLL	10	
#define FC_SUBTYPE_QOS_DATA_CF_ACK_POLL	11	
#define FC_SUBTYPE_QOS_NULL		12	
#define FC_SUBTYPE_QOS_CF_POLL		14	
#define FC_SUBTYPE_QOS_CF_ACK_POLL	15	


#define FC_SUBTYPE_ANY_QOS(s)		(((s) & 8) != 0)
#define FC_SUBTYPE_ANY_NULL(s)		(((s) & 4) != 0)
#define FC_SUBTYPE_ANY_CF_POLL(s)	(((s) & 2) != 0)
#define FC_SUBTYPE_ANY_CF_ACK(s)	(((s) & 1) != 0)


#define FC_KIND_MASK		(FC_TYPE_MASK | FC_SUBTYPE_MASK)	

#define FC_KIND(t, s)	(((t) << FC_TYPE_SHIFT) | ((s) << FC_SUBTYPE_SHIFT))	

#define FC_SUBTYPE(fc)	(((fc) & FC_SUBTYPE_MASK) >> FC_SUBTYPE_SHIFT)	
#define FC_TYPE(fc)	(((fc) & FC_TYPE_MASK) >> FC_TYPE_SHIFT)	

#define FC_ASSOC_REQ	FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_ASSOC_REQ)	
#define FC_ASSOC_RESP	FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_ASSOC_RESP)	
#define FC_REASSOC_REQ	FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_REASSOC_REQ)	
#define FC_REASSOC_RESP	FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_REASSOC_RESP)	
#define FC_PROBE_REQ	FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_PROBE_REQ)	
#define FC_PROBE_RESP	FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_PROBE_RESP)	
#define FC_BEACON	FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_BEACON)		
#define FC_DISASSOC	FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_DISASSOC)	
#define FC_AUTH		FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_AUTH)		
#define FC_DEAUTH	FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_DEAUTH)		
#define FC_ACTION	FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_ACTION)		
#define FC_ACTION_NOACK	FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_ACTION_NOACK)	

#define FC_CTL_WRAPPER	FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_CTL_WRAPPER)	
#define FC_BLOCKACK_REQ	FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_BLOCKACK_REQ)	
#define FC_BLOCKACK	FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_BLOCKACK)	
#define FC_PS_POLL	FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_PS_POLL)	
#define FC_RTS		FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_RTS)		
#define FC_CTS		FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_CTS)		
#define FC_ACK		FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_ACK)		
#define FC_CF_END	FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_CF_END)		
#define FC_CF_END_ACK	FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_CF_END_ACK)	

#define FC_DATA		FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_DATA)		
#define FC_NULL_DATA	FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_NULL)		
#define FC_DATA_CF_ACK	FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_DATA_CF_ACK)	
#define FC_QOS_DATA	FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_QOS_DATA)	
#define FC_QOS_NULL	FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_QOS_NULL)	




#define QOS_PRIO_SHIFT		0	
#define QOS_PRIO_MASK		0x0007	
#define QOS_PRIO(qos)		(((qos) & QOS_PRIO_MASK) >> QOS_PRIO_SHIFT)	


#define QOS_TID_SHIFT		0	
#define QOS_TID_MASK		0x000f	
#define QOS_TID(qos)		(((qos) & QOS_TID_MASK) >> QOS_TID_SHIFT)	


#define QOS_EOSP_SHIFT		4	
#define QOS_EOSP_MASK		0x0010	
#define QOS_EOSP(qos)		(((qos) & QOS_EOSP_MASK) >> QOS_EOSP_SHIFT)	


#define QOS_ACK_NORMAL_ACK	0	
#define QOS_ACK_NO_ACK		1	
#define QOS_ACK_NO_EXP_ACK	2	
#define QOS_ACK_BLOCK_ACK	3	
#define QOS_ACK_SHIFT		5	
#define QOS_ACK_MASK		0x0060	
#define QOS_ACK(qos)		(((qos) & QOS_ACK_MASK) >> QOS_ACK_SHIFT)	


#define QOS_AMSDU_SHIFT		7	
#define QOS_AMSDU_MASK		0x0080	






#define DOT11_MNG_AUTH_ALGO_LEN		2	
#define DOT11_MNG_AUTH_SEQ_LEN		2	
#define DOT11_MNG_BEACON_INT_LEN	2	
#define DOT11_MNG_CAP_LEN		2	
#define DOT11_MNG_AP_ADDR_LEN		6	
#define DOT11_MNG_LISTEN_INT_LEN	2	
#define DOT11_MNG_REASON_LEN		2	
#define DOT11_MNG_AID_LEN		2	
#define DOT11_MNG_STATUS_LEN		2	
#define DOT11_MNG_TIMESTAMP_LEN		8	


#define DOT11_AID_MASK			0x3fff	


#define DOT11_RC_RESERVED		0	
#define DOT11_RC_UNSPECIFIED		1	
#define DOT11_RC_AUTH_INVAL		2	
#define DOT11_RC_DEAUTH_LEAVING		3	
#define DOT11_RC_INACTIVITY		4	
#define DOT11_RC_BUSY			5	
#define DOT11_RC_INVAL_CLASS_2		6	
#define DOT11_RC_INVAL_CLASS_3		7	
#define DOT11_RC_DISASSOC_LEAVING	8	
#define DOT11_RC_NOT_AUTH		9	
#define DOT11_RC_BAD_PC			10	
#define DOT11_RC_BAD_CHANNELS		11	



#define DOT11_RC_UNSPECIFIED_QOS	32	
#define DOT11_RC_INSUFFCIENT_BW		33	
#define DOT11_RC_EXCESSIVE_FRAMES	34	
#define DOT11_RC_TX_OUTSIDE_TXOP	35	
#define DOT11_RC_LEAVING_QBSS		36	
#define DOT11_RC_BAD_MECHANISM		37	
#define DOT11_RC_SETUP_NEEDED		38	
#define DOT11_RC_TIMEOUT		39	

#define DOT11_RC_MAX			23	

#define DOT11_RC_TDLS_PEER_UNREACH	25
#define DOT11_RC_TDLS_DOWN_UNSPECIFIED	26

/* Status Codes */
#define DOT11_SC_SUCCESS		0	/* Successful */
#define DOT11_SC_FAILURE		1	/* Unspecified failure */
#define DOT11_SC_TDLS_WAKEUP_SCH_ALT 2	/* TDLS wakeup schedule rejected but alternative  */
					/* schedule provided */
#define DOT11_SC_TDLS_WAKEUP_SCH_REJ 3	/* TDLS wakeup schedule rejected */
#define DOT11_SC_TDLS_SEC_DISABLED	5	/* TDLS Security disabled */
#define DOT11_SC_LIFETIME_REJ		6	/* Unacceptable lifetime */
#define DOT11_SC_NOT_SAME_BSS		7	/* Not in same BSS */
#define DOT11_SC_CAP_MISMATCH		10	/* Cannot support all requested
						 * capabilities in the Capability
						 * Information field
						 */
#define DOT11_SC_REASSOC_FAIL		11	/* Reassociation denied due to inability
						 * to confirm that association exists
						 */
#define DOT11_SC_ASSOC_FAIL		12	/* Association denied due to reason
						 * outside the scope of this standard
						 */
#define DOT11_SC_AUTH_MISMATCH		13	/* Responding station does not support
						 * the specified authentication
						 * algorithm
						 */
#define DOT11_SC_AUTH_SEQ		14	/* Received an Authentication frame
						 * with authentication transaction
						 * sequence number out of expected
						 * sequence
						 */
#define DOT11_SC_AUTH_CHALLENGE_FAIL	15	/* Authentication rejected because of
						 * challenge failure
						 */
#define DOT11_SC_AUTH_TIMEOUT		16	/* Authentication rejected due to timeout
						 * waiting for next frame in sequence
						 */
#define DOT11_SC_ASSOC_BUSY_FAIL	17	/* Association denied because AP is
						 * unable to handle additional
						 * associated stations
						 */
#define DOT11_SC_ASSOC_RATE_MISMATCH	18	/* Association denied due to requesting
						 * station not supporting all of the
						 * data rates in the BSSBasicRateSet
						 * parameter
						 */
#define DOT11_SC_ASSOC_SHORT_REQUIRED	19	/* Association denied due to requesting
						 * station not supporting the Short
						 * Preamble option
						 */
#define DOT11_SC_ASSOC_PBCC_REQUIRED	20	/* Association denied due to requesting
						 * station not supporting the PBCC
						 * Modulation option
						 */
#define DOT11_SC_ASSOC_AGILITY_REQUIRED	21	/* Association denied due to requesting
						 * station not supporting the Channel
						 * Agility option
						 */
#define DOT11_SC_ASSOC_SPECTRUM_REQUIRED	22	/* Association denied because Spectrum
							 * Management capability is required.
							 */
#define DOT11_SC_ASSOC_BAD_POWER_CAP	23	/* Association denied because the info
						 * in the Power Cap element is
						 * unacceptable.
						 */
#define DOT11_SC_ASSOC_BAD_SUP_CHANNELS	24	/* Association denied because the info
						 * in the Supported Channel element is
						 * unacceptable
						 */
#define DOT11_SC_ASSOC_SHORTSLOT_REQUIRED	25	/* Association denied due to requesting
							 * station not supporting the Short Slot
							 * Time option
							 */
#define DOT11_SC_ASSOC_DSSSOFDM_REQUIRED 26	/* Association denied because requesting station
						 * does not support the DSSS-OFDM option
						 */
#define DOT11_SC_ASSOC_HT_REQUIRED	27	/* Association denied because the requesting
						 * station does not support HT features
						 */
#define DOT11_SC_ASSOC_R0KH_UNREACHABLE	28	/* Association denied due to AP
						 * being unable to reach the R0 Key Holder
						 */
#define DOT11_SC_ASSOC_TRY_LATER	30	/* Association denied temporarily, try again later
						 */
#define DOT11_SC_ASSOC_MFP_VIOLATION	31	/* Association denied due to Robust Management
						 * frame policy violation
						 */

#define	DOT11_SC_DECLINED		37	/* request declined */
#define	DOT11_SC_INVALID_PARAMS		38	/* One or more params have invalid values */
#define DOT11_SC_INVALID_PAIRWISE_CIPHER	42 /* invalid pairwise cipher */
#define	DOT11_SC_INVALID_AKMP		43	/* Association denied due to invalid AKMP */
#define DOT11_SC_INVALID_RSNIE_CAP	45	/* invalid RSN IE capabilities */
#define DOT11_SC_DLS_NOT_ALLOWED	48	/* DLS is not allowed in the BSS by policy */
#define	DOT11_SC_INVALID_PMKID		53	/* Association denied due to invalid PMKID */
#define	DOT11_SC_INVALID_MDID		54	/* Association denied due to invalid MDID */
#define	DOT11_SC_INVALID_FTIE		55	/* Association denied due to invalid FTIE */

#define DOT11_SC_ADV_PROTO_NOT_SUPPORTED	59	/* ad proto not supported */
#define DOT11_SC_NO_OUTSTAND_REQ			60	/* no outstanding req */
#define DOT11_SC_RSP_NOT_RX_FROM_SERVER		61	/* no response from server */
#define DOT11_SC_TIMEOUT					62	/* timeout */
#define DOT11_SC_QUERY_RSP_TOO_LARGE		63	/* query rsp too large */
#define DOT11_SC_SERVER_UNREACHABLE			65	/* server unreachable */

#define DOT11_SC_UNEXP_MSG			70	/* Unexpected message */
#define DOT11_SC_INVALID_SNONCE		71	/* Invalid SNonce */
#define DOT11_SC_INVALID_RSNIE		72	/* Invalid contents of RSNIE */
#define DOT11_SC_ASSOC_VHT_REQUIRED	104	/* Association denied because the requesting
						 * station does not support VHT features.
						 */

#define DOT11_SC_TRANSMIT_FAILURE	79	/* transmission failure */

/* Info Elts, length of INFORMATION portion of Info Elts */
#define DOT11_MNG_DS_PARAM_LEN			1	/* d11 management DS parameter length */
#define DOT11_MNG_IBSS_PARAM_LEN		2	/* d11 management IBSS parameter length */

/* TIM Info element has 3 bytes fixed info in INFORMATION field,
 * followed by 1 to 251 bytes of Partial Virtual Bitmap
 */
#define DOT11_MNG_TIM_FIXED_LEN			3	/* d11 management TIM fixed length */
#define DOT11_MNG_TIM_DTIM_COUNT		0	/* d11 management DTIM count */
#define DOT11_MNG_TIM_DTIM_PERIOD		1	/* d11 management DTIM period */
#define DOT11_MNG_TIM_BITMAP_CTL		2	/* d11 management TIM BITMAP control  */
#define DOT11_MNG_TIM_PVB			3	/* d11 management TIM PVB */

/* TLV defines */
#define TLV_TAG_OFF		0	/* tag offset */
#define TLV_LEN_OFF		1	/* length offset */
#define TLV_HDR_LEN		2	/* header length */
#define TLV_BODY_OFF		2	/* body offset */
#define TLV_BODY_LEN_MAX	255	/* max body length */

/* Management Frame Information Element IDs */
#define DOT11_MNG_SSID_ID			0	/* d11 management SSID id */
#define DOT11_MNG_RATES_ID			1	/* d11 management rates id */
#define DOT11_MNG_FH_PARMS_ID			2	/* d11 management FH parameter id */
#define DOT11_MNG_DS_PARMS_ID			3	/* d11 management DS parameter id */
#define DOT11_MNG_CF_PARMS_ID			4	/* d11 management CF parameter id */
#define DOT11_MNG_TIM_ID			5	/* d11 management TIM id */
#define DOT11_MNG_IBSS_PARMS_ID			6	/* d11 management IBSS parameter id */
#define DOT11_MNG_COUNTRY_ID			7	/* d11 management country id */
#define DOT11_MNG_HOPPING_PARMS_ID		8	/* d11 management hopping parameter id */
#define DOT11_MNG_HOPPING_TABLE_ID		9	/* d11 management hopping table id */
#define DOT11_MNG_REQUEST_ID			10	/* d11 management request id */
#define DOT11_MNG_QBSS_LOAD_ID 			11	/* d11 management QBSS Load id */
#define DOT11_MNG_EDCA_PARAM_ID			12	/* 11E EDCA Parameter id */
#define DOT11_MNG_TSPEC_ID			13	/* d11 management TSPEC id */
#define DOT11_MNG_TCLAS_ID			14	/* d11 management TCLAS id */
#define DOT11_MNG_CHALLENGE_ID			16	/* d11 management chanllenge id */
#define DOT11_MNG_PWR_CONSTRAINT_ID		32	/* 11H PowerConstraint */
#define DOT11_MNG_PWR_CAP_ID			33	/* 11H PowerCapability */
#define DOT11_MNG_TPC_REQUEST_ID 		34	/* 11H TPC Request */
#define DOT11_MNG_TPC_REPORT_ID			35	/* 11H TPC Report */
#define DOT11_MNG_SUPP_CHANNELS_ID		36	/* 11H Supported Channels */
#define DOT11_MNG_CHANNEL_SWITCH_ID		37	/* 11H ChannelSwitch Announcement */
#define DOT11_MNG_MEASURE_REQUEST_ID		38	/* 11H MeasurementRequest */
#define DOT11_MNG_MEASURE_REPORT_ID		39	/* 11H MeasurementReport */
#define DOT11_MNG_QUIET_ID			40	/* 11H Quiet */
#define DOT11_MNG_IBSS_DFS_ID			41	/* 11H IBSS_DFS */
#define DOT11_MNG_ERP_ID			42	/* d11 management ERP id */
#define DOT11_MNG_TS_DELAY_ID			43	/* d11 management TS Delay id */
#define DOT11_MNG_TCLAS_PROC_ID			44	/* d11 management TCLAS processing id */
#define	DOT11_MNG_HT_CAP			45	/* d11 mgmt HT cap id */
#define DOT11_MNG_QOS_CAP_ID			46	/* 11E QoS Capability id */
#define DOT11_MNG_NONERP_ID			47	/* d11 management NON-ERP id */
#define DOT11_MNG_RSN_ID			48	/* d11 management RSN id */
#define DOT11_MNG_EXT_RATES_ID			50	/* d11 management ext. rates id */
#define DOT11_MNG_AP_CHREP_ID			51	/* 11k AP Channel report id */
#define DOT11_MNG_NEIGHBOR_REP_ID		52	/* 11k & 11v Neighbor report id */
#define DOT11_MNG_RCPI_ID			53	/* 11k RCPI */
#define DOT11_MNG_MDIE_ID			54	/* 11r Mobility domain id */
#define DOT11_MNG_FTIE_ID			55	/* 11r Fast Bss Transition id */
#define DOT11_MNG_FT_TI_ID			56	/* 11r Timeout Interval id */
#define DOT11_MNG_RDE_ID			57	/* 11r RIC Data Element id */
#define	DOT11_MNG_REGCLASS_ID			59	/* d11 management regulatory class id */
#define DOT11_MNG_EXT_CSA_ID			60	/* d11 Extended CSA */
#define	DOT11_MNG_HT_ADD			61	/* d11 mgmt additional HT info */
#define	DOT11_MNG_EXT_CHANNEL_OFFSET		62	/* d11 mgmt ext channel offset */
#define DOT11_MNG_BSS_AVR_ACCESS_DELAY_ID	63	/* 11k bss average access delay */
#define DOT11_MNG_ANTENNA_ID			64	/* 11k antenna id */
#define DOT11_MNG_RSNI_ID			65	/* 11k RSNI id */
#define DOT11_MNG_MEASUREMENT_PILOT_TX_ID	66	/* 11k measurement pilot tx info id */
#define DOT11_MNG_BSS_AVAL_ADMISSION_CAP_ID	67	/* 11k bss aval admission cap id */
#define DOT11_MNG_BSS_AC_ACCESS_DELAY_ID	68	/* 11k bss AC access delay id */
#define DOT11_MNG_WAPI_ID			68	/* d11 management WAPI id */
#define DOT11_MNG_TIME_ADVERTISE_ID	69	/* 11p time advertisement */
#define DOT11_MNG_RRM_CAP_ID		70	/* 11k radio measurement capability */
#define DOT11_MNG_MULTIPLE_BSSID_ID		71	/* 11k multiple BSSID id */
#define	DOT11_MNG_HT_BSS_COEXINFO_ID		72	/* d11 mgmt OBSS Coexistence INFO */
#define	DOT11_MNG_HT_BSS_CHANNEL_REPORT_ID	73	/* d11 mgmt OBSS Intolerant Channel list */
#define	DOT11_MNG_HT_OBSS_ID			74	/* d11 mgmt OBSS HT info */
#define DOT11_MNG_MMIE_ID			76	/* d11 mgmt MIC IE */
#define DOT11_MNG_FMS_DESCR_ID			86	/* 11v FMS descriptor */
#define DOT11_MNG_FMS_REQ_ID			87	/* 11v FMS request id */
#define DOT11_MNG_FMS_RESP_ID			88	/* 11v FMS response id */
#define DOT11_MNG_BSS_MAX_IDLE_PERIOD_ID	90	/* 11v bss max idle id */
#define DOT11_MNG_TFS_REQUEST_ID		91	/* 11v tfs request id */
#define DOT11_MNG_TFS_RESPONSE_ID		92	/* 11v tfs response id */
#define DOT11_MNG_WNM_SLEEP_MODE_ID		93	/* 11v wnm-sleep mode id */
#define DOT11_MNG_TIMBC_REQ_ID			94	/* 11v TIM broadcast request id */
#define DOT11_MNG_TIMBC_RESP_ID			95	/* 11v TIM broadcast response id */
#define DOT11_MNG_CHANNEL_USAGE			97	/* 11v channel usage */
#define DOT11_MNG_TIME_ZONE_ID			98	/* 11v time zone */
#define DOT11_MNG_DMS_REQUEST_ID		99	/* 11v dms request id */
#define DOT11_MNG_DMS_RESPONSE_ID		100	/* 11v dms response id */
#define DOT11_MNG_LINK_IDENTIFIER_ID		101	/* 11z TDLS Link Identifier IE */
#define DOT11_MNG_WAKEUP_SCHEDULE_ID		102	/* 11z TDLS Wakeup Schedule IE */
#define DOT11_MNG_CHANNEL_SWITCH_TIMING_ID	104	/* 11z TDLS Channel Switch Timing IE */
#define DOT11_MNG_PTI_CONTROL_ID		105	/* 11z TDLS PTI Control IE */
#define DOT11_MNG_PU_BUFFER_STATUS_ID	106	/* 11z TDLS PU Buffer Status IE */
#define DOT11_MNG_INTERWORKING_ID		107	/* 11u interworking */
#define DOT11_MNG_ADVERTISEMENT_ID		108	/* 11u advertisement protocol */
#define DOT11_MNG_EXP_BW_REQ_ID			109	/* 11u expedited bandwith request */
#define DOT11_MNG_QOS_MAP_ID			110	/* 11u QoS map set */
#define DOT11_MNG_ROAM_CONSORT_ID		111	/* 11u roaming consortium */
#define DOT11_MNG_EMERGCY_ALERT_ID		112	/* 11u emergency alert identifier */
#define	DOT11_MNG_EXT_CAP_ID			127	/* d11 mgmt ext capability */
#define	DOT11_MNG_VHT_CAP_ID			191	/* d11 mgmt VHT cap id */
#define	DOT11_MNG_VHT_OPERATION_ID		192	/* d11 mgmt VHT op id */
#define DOT11_MNG_WIDE_BW_CHANNEL_SWITCH_ID		194	/* Wide BW Channel Switch IE */
#define DOT11_MNG_VHT_TRANSMIT_POWER_ENVELOPE_ID	195	/* VHT transmit Power Envelope IE */
#define DOT11_MNG_CHANNEL_SWITCH_WRAPPER_ID		196	/* Channel Switch Wrapper IE */
#define DOT11_MNG_AID_ID					197	/* Association ID  IE */
#define	DOT11_MNG_OPER_MODE_NOTIF_ID	199	/* d11 mgmt VHT oper mode notif */


#define DOT11_MNG_WPA_ID			221	/* d11 management WPA id */
#define DOT11_MNG_PROPR_ID			221
/* should start using this one instead of above two */
#define DOT11_MNG_VS_ID				221	/* d11 management Vendor Specific IE */

/* Rate Defines */

/* Valid rates for the Supported Rates and Extended Supported Rates IEs.
 * Encoding is the rate in 500kbps units, rouding up for fractional values.
 * 802.11-2012, section 6.5.5.2, DATA_RATE parameter enumerates all the values.
 * The rate values cover DSSS, HR/DSSS, ERP, and OFDM phy rates.
 * The defines below do not cover the rates specific to 10MHz, {3, 4.5, 27},
 * and 5MHz, {1.5, 2.25, 3, 4.5, 13.5}, which are not supported by Broadcom devices.
 */

#define DOT11_SC_SUCCESS		0	
#define DOT11_SC_FAILURE		1	
#define DOT11_SC_TDLS_WAKEUP_SCH_ALT 2	
					
#define DOT11_SC_TDLS_WAKEUP_SCH_REJ 3	
#define DOT11_SC_TDLS_SEC_DISABLED	5	
#define DOT11_SC_LIFETIME_REJ		6	
#define DOT11_SC_NOT_SAME_BSS		7	
#define DOT11_SC_CAP_MISMATCH		10	
#define DOT11_SC_REASSOC_FAIL		11	
#define DOT11_SC_ASSOC_FAIL		12	
#define DOT11_SC_AUTH_MISMATCH		13	
#define DOT11_SC_AUTH_SEQ		14	
#define DOT11_SC_AUTH_CHALLENGE_FAIL	15	
#define DOT11_SC_AUTH_TIMEOUT		16	
#define DOT11_SC_ASSOC_BUSY_FAIL	17	
#define DOT11_SC_ASSOC_RATE_MISMATCH	18	
#define DOT11_SC_ASSOC_SHORT_REQUIRED	19	
#define DOT11_SC_ASSOC_PBCC_REQUIRED	20	
#define DOT11_SC_ASSOC_AGILITY_REQUIRED	21	
#define DOT11_SC_ASSOC_SPECTRUM_REQUIRED	22	
#define DOT11_SC_ASSOC_BAD_POWER_CAP	23	
#define DOT11_SC_ASSOC_BAD_SUP_CHANNELS	24	
#define DOT11_SC_ASSOC_SHORTSLOT_REQUIRED	25	
#define DOT11_SC_ASSOC_ERPBCC_REQUIRED	26	
#define DOT11_SC_ASSOC_DSSOFDM_REQUIRED	27	
#define DOT11_SC_ASSOC_R0KH_UNREACHABLE	28	
#define DOT11_SC_ASSOC_TRY_LATER	30	
#define DOT11_SC_ASSOC_MFP_VIOLATION	31	

#define	DOT11_SC_DECLINED		37	
#define	DOT11_SC_INVALID_PARAMS		38	
#define DOT11_SC_INVALID_PAIRWISE_CIPHER	42 
#define	DOT11_SC_INVALID_AKMP		43	
#define DOT11_SC_INVALID_RSNIE_CAP	45	
#define DOT11_SC_DLS_NOT_ALLOWED	48	
#define	DOT11_SC_INVALID_PMKID		53	
#define	DOT11_SC_INVALID_MDID		54	
#define	DOT11_SC_INVALID_FTIE		55	

#define DOT11_SC_UNEXP_MSG			70	
#define DOT11_SC_INVALID_SNONCE		71	
#define DOT11_SC_INVALID_RSNIE		72	


#define DOT11_MNG_DS_PARAM_LEN			1	
#define DOT11_MNG_IBSS_PARAM_LEN		2	


#define DOT11_MNG_TIM_FIXED_LEN			3	
#define DOT11_MNG_TIM_DTIM_COUNT		0	
#define DOT11_MNG_TIM_DTIM_PERIOD		1	
#define DOT11_MNG_TIM_BITMAP_CTL		2	
#define DOT11_MNG_TIM_PVB			3	


#define TLV_TAG_OFF		0	
#define TLV_LEN_OFF		1	
#define TLV_HDR_LEN		2	
#define TLV_BODY_OFF		2	


#define DOT11_MNG_SSID_ID			0	
#define DOT11_MNG_RATES_ID			1	
#define DOT11_MNG_FH_PARMS_ID			2	
#define DOT11_MNG_DS_PARMS_ID			3	
#define DOT11_MNG_CF_PARMS_ID			4	
#define DOT11_MNG_TIM_ID			5	
#define DOT11_MNG_IBSS_PARMS_ID			6	
#define DOT11_MNG_COUNTRY_ID			7	
#define DOT11_MNG_HOPPING_PARMS_ID		8	
#define DOT11_MNG_HOPPING_TABLE_ID		9	
#define DOT11_MNG_REQUEST_ID			10	
#define DOT11_MNG_QBSS_LOAD_ID 			11	
#define DOT11_MNG_EDCA_PARAM_ID			12	
#define DOT11_MNG_CHALLENGE_ID			16	
#define DOT11_MNG_PWR_CONSTRAINT_ID		32	
#define DOT11_MNG_PWR_CAP_ID			33	
#define DOT11_MNG_TPC_REQUEST_ID 		34	
#define DOT11_MNG_TPC_REPORT_ID			35	
#define DOT11_MNG_SUPP_CHANNELS_ID		36	
#define DOT11_MNG_CHANNEL_SWITCH_ID		37	
#define DOT11_MNG_MEASURE_REQUEST_ID		38	
#define DOT11_MNG_MEASURE_REPORT_ID		39	
#define DOT11_MNG_QUIET_ID			40	
#define DOT11_MNG_IBSS_DFS_ID			41	
#define DOT11_MNG_ERP_ID			42	
#define DOT11_MNG_TS_DELAY_ID			43	
#define	DOT11_MNG_HT_CAP			45	
#define DOT11_MNG_QOS_CAP_ID			46	
#define DOT11_MNG_NONERP_ID			47	
#define DOT11_MNG_RSN_ID			48	
#define DOT11_MNG_EXT_RATES_ID			50	
#define DOT11_MNG_AP_CHREP_ID		51	
#define DOT11_MNG_NBR_REP_ID		52	
#define DOT11_MNG_RCPI_ID		53	
#define DOT11_MNG_MDIE_ID		54	
#define DOT11_MNG_FTIE_ID		55	
#define DOT11_MNG_FT_TI_ID		56	
#define	DOT11_MNG_REGCLASS_ID			59	
#define DOT11_MNG_EXT_CSA_ID			60	
#define	DOT11_MNG_HT_ADD			61	
#define	DOT11_MNG_EXT_CHANNEL_OFFSET		62	
#define DOT11_MNG_BSS_AVR_ACCESS_DELAY_ID	63	
#define DOT11_MNG_ANTENNA_ID			64	
#define DOT11_MNG_RSNI_ID			65	
#define DOT11_MNG_MEASUREMENT_PILOT_TX_ID	66	
#define DOT11_MNG_BSS_AVAL_ADMISSION_CAP_ID	67	
#define DOT11_MNG_BSS_AC_ACCESS_DELAY_ID	68	
#define DOT11_MNG_WAPI_ID			68	
#define DOT11_MNG_TIME_ADVERTISE_ID	69	
#define DOT11_MNG_RRM_CAP_ID		70	
#define DOT11_MNG_MULTIPLE_BSSID_ID		71	
#define	DOT11_MNG_HT_BSS_COEXINFO_ID		72	
#define	DOT11_MNG_HT_BSS_CHANNEL_REPORT_ID	73	
#define	DOT11_MNG_HT_OBSS_ID			74	
#define DOT11_MNG_MMIE_ID				76  
#define DOT11_MNG_CHANNEL_USAGE			97 
#define DOT11_MNG_TIME_ZONE_ID			98	
#define DOT11_MNG_LINK_IDENTIFIER_ID	101	
#define DOT11_MNG_WAKEUP_SCHEDULE_ID	102 
#define DOT11_MNG_CHANNEL_SWITCH_TIMING_ID	104 
#define DOT11_MNG_PTI_CONTROL_ID		105	
#define DOT11_MNG_PU_BUFFER_STATUS_ID	106	
#define DOT11_MNG_INTERWORKING_ID		107	
#define DOT11_MNG_ADVERTISEMENT_ID		108	
#define DOT11_MNG_EXP_BW_REQ_ID			109	
#define DOT11_MNG_QOS_MAP_ID			110	
#define DOT11_MNG_ROAM_CONSORT_ID		111	
#define DOT11_MNG_EMERGCY_ALERT_ID		112	
#define	DOT11_MNG_EXT_CAP_ID		127	
#define	DOT11_MNG_VHT_CAP_ID		191	
#define	DOT11_MNG_VHT_OPERATION_ID	192	
#define DOT11_MNG_WIDE_BW_CHANNEL_SWITCH_ID		194	
#define DOT11_MNG_VHT_TRANSMIT_POWER_ENVELOPE_ID	195	
#define DOT11_MNG_CHANNEL_SWITCH_WRAPPER_ID		196	


#define DOT11_MNG_WPA_ID			221	
#define DOT11_MNG_PROPR_ID			221	

#define DOT11_MNG_VS_ID				221	





#define DOT11_RATE_1M   2       
#define DOT11_RATE_2M   4       
#define DOT11_RATE_5M5  11      
#define DOT11_RATE_11M  22      
#define DOT11_RATE_6M   12      
#define DOT11_RATE_9M   18      
#define DOT11_RATE_12M  24      
#define DOT11_RATE_18M  36      
#define DOT11_RATE_24M  48      
#define DOT11_RATE_36M  72      
#define DOT11_RATE_48M  96      
#define DOT11_RATE_54M  108     
#define DOT11_RATE_MAX  108     


#define DOT11_RATE_BASIC                0x80 
#define DOT11_RATE_MASK                 0x7F 



#define DOT11_MNG_ERP_LEN			1	
#define DOT11_MNG_NONERP_PRESENT		0x01	
#define DOT11_MNG_USE_PROTECTION		0x02	
#define DOT11_MNG_BARKER_PREAMBLE		0x04	

#define DOT11_MGN_TS_DELAY_LEN		4	
#define TS_DELAY_FIELD_SIZE			4	


#define DOT11_CAP_ESS				0x0001	
#define DOT11_CAP_IBSS				0x0002	
#define DOT11_CAP_POLLABLE			0x0004	
#define DOT11_CAP_POLL_RQ			0x0008	
#define DOT11_CAP_PRIVACY			0x0010	
#define DOT11_CAP_SHORT				0x0020	
#define DOT11_CAP_PBCC				0x0040	
#define DOT11_CAP_AGILITY			0x0080	
#define DOT11_CAP_SPECTRUM			0x0100	
#define DOT11_CAP_SHORTSLOT			0x0400	
#define DOT11_CAP_RRM			0x1000	
#define DOT11_CAP_CCK_OFDM			0x2000	



#define DOT11_EXT_CAP_OBSS_COEX_MGMT		0

#define DOT11_EXT_CAP_SPSMP					6

#define DOT11_EXT_CAP_PROXY_ARP				12

#define DOT11_EXT_CAP_BSS_TRANSITION_MGMT	19

#define DOT11_EXT_CAP_IW						31

#define DOT11_EXT_CAP_SI						41
#define DOT11_EXT_CAP_SI_MASK					0x0E


#define DOT11_ACTION_HDR_LEN		2	
#define DOT11_ACTION_CAT_OFF		0	
#define DOT11_ACTION_ACT_OFF		1	


#define DOT11_ACTION_CAT_ERR_MASK	0x80	
#define DOT11_ACTION_CAT_MASK		0x7F	
#define DOT11_ACTION_CAT_SPECT_MNG	0	
#define DOT11_ACTION_CAT_QOS		1	
#define DOT11_ACTION_CAT_DLS		2	
#define DOT11_ACTION_CAT_BLOCKACK	3	
#define DOT11_ACTION_CAT_PUBLIC		4	
#define DOT11_ACTION_CAT_RRM		5	
#define DOT11_ACTION_CAT_FBT	6	
#define DOT11_ACTION_CAT_HT		7	
#define	DOT11_ACTION_CAT_SA_QUERY	8	
#define	DOT11_ACTION_CAT_PDPA		9	
#define DOT11_ACTION_CAT_WNM		10	
#define DOT11_ACTION_NOTIFICATION	17
#define DOT11_ACTION_CAT_VSP		126	
#define DOT11_ACTION_CAT_VS		127	


#define DOT11_SM_ACTION_M_REQ		0	
#define DOT11_SM_ACTION_M_REP		1	
#define DOT11_SM_ACTION_TPC_REQ		2	
#define DOT11_SM_ACTION_TPC_REP		3	
#define DOT11_SM_ACTION_CHANNEL_SWITCH	4	
#define DOT11_SM_ACTION_EXT_CSA		5	


#define DOT11_ACTION_ID_HT_CH_WIDTH	0	
#define DOT11_ACTION_ID_HT_MIMO_PS	1	


#define DOT11_PUB_ACTION_BSS_COEX_MNG	0	
#define DOT11_PUB_ACTION_CHANNEL_SWITCH	4	


#define DOT11_BA_ACTION_ADDBA_REQ	0	
#define DOT11_BA_ACTION_ADDBA_RESP	1	
#define DOT11_BA_ACTION_DELBA		2	


#define DOT11_ADDBA_PARAM_AMSDU_SUP	0x0001	
#define DOT11_ADDBA_PARAM_POLICY_MASK	0x0002	
#define DOT11_ADDBA_PARAM_POLICY_SHIFT	1	
#define DOT11_ADDBA_PARAM_TID_MASK	0x003c	
#define DOT11_ADDBA_PARAM_TID_SHIFT	2	
#define DOT11_ADDBA_PARAM_BSIZE_MASK	0xffc0	
#define DOT11_ADDBA_PARAM_BSIZE_SHIFT	6	

#define DOT11_ADDBA_POLICY_DELAYED	0	
#define DOT11_ADDBA_POLICY_IMMEDIATE	1	


#define DOT11_FT_ACTION_FT_RESERVED		0
#define DOT11_FT_ACTION_FT_REQ			1	
#define DOT11_FT_ACTION_FT_RES			2	
#define DOT11_FT_ACTION_FT_CON			3	
#define DOT11_FT_ACTION_FT_ACK			4	


#define DOT11_DLS_ACTION_REQ				0	
#define DOT11_DLS_ACTION_RESP				1	
#define DOT11_DLS_ACTION_TD				2	


#define DOT11_WNM_ACTION_EVENT_REQ			0
#define DOT11_WNM_ACTION_EVENT_REP			1
#define DOT11_WNM_ACTION_DIAG_REQ			2
#define DOT11_WNM_ACTION_DIAG_REP			3
#define DOT11_WNM_ACTION_LOC_CFG_REQ		4
#define DOT11_WNM_ACTION_LOC_RFG_RESP		5
#define DOT11_WNM_ACTION_BSS_TRANS_QURY		6
#define DOT11_WNM_ACTION_BSS_TRANS_REQ		7
#define DOT11_WNM_ACTION_BSS_TRANS_RESP		8
#define DOT11_WNM_ACTION_FMS_REQ			9
#define DOT11_WNM_ACTION_FMS_RESP			10
#define DOT11_WNM_ACTION_COL_INTRFRNCE_REQ	11
#define DOT11_WNM_ACTION_COL_INTRFRNCE_REP	12
#define DOT11_WNM_ACTION_TFS_REQ			13
#define DOT11_WNM_ACTION_TFS_RESP			14
#define DOT11_WNM_ACTION_TFS_NOTIFY			15
#define DOT11_WNM_ACTION_WNM_SLEEP_REQ		16
#define DOT11_WNM_ACTION_WNM_SLEEP_RESP		17
#define DOT11_WNM_ACTION_TIM_BCAST_REQ		18
#define DOT11_WNM_ACTION_TIM_BCAST_RESP		19
#define DOT11_WNM_ACTION_QOS_TRFC_CAP_UPD	20
#define DOT11_WNM_ACTION_CHAN_USAGE_REQ		21
#define DOT11_WNM_ACTION_CHAN_USAGE_RESP	22
#define DOT11_WNM_ACTION_DMS_REQ			23
#define DOT11_WNM_ACTION_DMS_RESP			24
#define DOT11_WNM_ACTION_TMNG_MEASUR_REQ	25
#define DOT11_WNM_ACTION_NOTFCTN_REQ		26
#define DOT11_WNM_ACTION_NOTFCTN_RES		27

#define DOT11_MNG_COUNTRY_ID_LEN 3


BWL_PRE_PACKED_STRUCT struct dot11_dls_req {
	uint8 category;			
	uint8 action;				
	struct ether_addr	da;		
	struct ether_addr	sa;		
	uint16 cap;				
	uint16 timeout;			
	uint8 data[1];				
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_dls_req dot11_dls_req_t;
#define DOT11_DLS_REQ_LEN 18	


BWL_PRE_PACKED_STRUCT struct dot11_dls_resp {
	uint8 category;			
	uint8 action;				
	uint16 status;				
	struct ether_addr	da;		
	struct ether_addr	sa;		
	uint8 data[1];				
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_dls_resp dot11_dls_resp_t;
#define DOT11_DLS_RESP_LEN 16	



BWL_PRE_PACKED_STRUCT struct dot11_bss_trans_query {
	uint8 category;				
	uint8 action;				
	uint8 token;				
	uint8 reason;				
	uint8 data[1];				
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_bss_trans_query dot11_bss_trans_query_t;
#define DOT11_BSS_TRANS_QUERY_LEN 4	


BWL_PRE_PACKED_STRUCT struct dot11_bss_trans_req {
	uint8 category;				
	uint8 action;				
	uint8 token;				
	uint8 reqmode;				
	uint16 disassoc_tmr;		
	uint8 validity_intrvl;		
	uint8 data[1];				
								
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_bss_trans_req dot11_bss_trans_req_t;
#define DOT11_BSS_TRANS_REQ_LEN 7	

#define DOT11_BSS_TERM_DUR_LEN 12	



#define DOT11_BSS_TRNS_REQMODE_PREF_LIST_INCL		0x01
#define DOT11_BSS_TRNS_REQMODE_ABRIDGED				0x02
#define DOT11_BSS_TRNS_REQMODE_DISASSOC_IMMINENT	0x04
#define DOT11_BSS_TRNS_REQMODE_BSS_TERM_INCL		0x08
#define DOT11_BSS_TRNS_REQMODE_ESS_DISASSOC_IMNT	0x10



BWL_PRE_PACKED_STRUCT struct dot11_bss_trans_res {
	uint8 category;				
	uint8 action;				
	uint8 token;				
	uint8 status;				
	uint8 term_delay;			
	uint8 data[1];				
								
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_bss_trans_res dot11_bss_trans_res_t;
#define DOT11_BSS_TRANS_RES_LEN 5	


#define DOT11_BSS_TRNS_RES_STATUS_ACCEPT				0
#define DOT11_BSS_TRNS_RES_STATUS_REJECT				1
#define DOT11_BSS_TRNS_RES_STATUS_REJ_INSUFF_BCN		2
#define DOT11_BSS_TRNS_RES_STATUS_REJ_INSUFF_CAP		3
#define DOT11_BSS_TRNS_RES_STATUS_REJ_TERM_UNDESIRED	4
#define DOT11_BSS_TRNS_RES_STATUS_REJ_TERM_DELAY_REQ	5
#define DOT11_BSS_TRNS_RES_STATUS_REJ_BSS_LIST_PROVIDED	6
#define DOT11_BSS_TRNS_RES_STATUS_REJ_NO_SUITABLE_BSS	7
#define DOT11_BSS_TRNS_RES_STATUS_REJ_LEAVING_ESS		8



#define DOT11_NBR_RPRT_BSSID_INFO_REACHABILTY		0x0003
#define DOT11_NBR_RPRT_BSSID_INFO_SEC				0x0004
#define DOT11_NBR_RPRT_BSSID_INFO_KEY_SCOPE			0x0008
#define DOT11_NBR_RPRT_BSSID_INFO_CAP				0x03f0

#define DOT11_NBR_RPRT_BSSID_INFO_CAP_SPEC_MGMT		0x0010
#define DOT11_NBR_RPRT_BSSID_INFO_CAP_QOS			0x0020
#define DOT11_NBR_RPRT_BSSID_INFO_CAP_APSD			0x0040
#define DOT11_NBR_RPRT_BSSID_INFO_CAP_RDIO_MSMT		0x0080
#define DOT11_NBR_RPRT_BSSID_INFO_CAP_DEL_BA		0x0100
#define DOT11_NBR_RPRT_BSSID_INFO_CAP_IMM_BA		0x0200


#define DOT11_NBR_RPRT_SUBELEM_BSS_CANDDT_PREF_ID	3


BWL_PRE_PACKED_STRUCT struct dot11_addba_req {
	uint8 category;				
	uint8 action;				
	uint8 token;				
	uint16 addba_param_set;		
	uint16 timeout;				
	uint16 start_seqnum;		
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_addba_req dot11_addba_req_t;
#define DOT11_ADDBA_REQ_LEN		9	

BWL_PRE_PACKED_STRUCT struct dot11_addba_resp {
	uint8 category;				
	uint8 action;				
	uint8 token;				
	uint16 status;				
	uint16 addba_param_set;			
	uint16 timeout;				
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_addba_resp dot11_addba_resp_t;
#define DOT11_ADDBA_RESP_LEN		9	


#define DOT11_DELBA_PARAM_INIT_MASK	0x0800	
#define DOT11_DELBA_PARAM_INIT_SHIFT	11	
#define DOT11_DELBA_PARAM_TID_MASK	0xf000	
#define DOT11_DELBA_PARAM_TID_SHIFT	12	

BWL_PRE_PACKED_STRUCT struct dot11_delba {
	uint8 category;				
	uint8 action;				
	uint16 delba_param_set;			
	uint16 reason;				
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_delba dot11_delba_t;
#define DOT11_DELBA_LEN			6	


#define SA_QUERY_REQUEST		0
#define SA_QUERY_RESPONSE		1




BWL_PRE_PACKED_STRUCT struct dot11_ft_req {
	uint8 category;			
	uint8 action;			
	uint8 sta_addr[ETHER_ADDR_LEN];
	uint8 tgt_ap_addr[ETHER_ADDR_LEN];
	uint8 data[1];			
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_ft_req dot11_ft_req_t;
#define DOT11_FT_REQ_FIXED_LEN 14


BWL_PRE_PACKED_STRUCT struct dot11_ft_res {
	uint8 category;			
	uint8 action;			
	uint8 sta_addr[ETHER_ADDR_LEN];
	uint8 tgt_ap_addr[ETHER_ADDR_LEN];
	uint16 status;			
	uint8 data[1];			
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_ft_res dot11_ft_res_t;
#define DOT11_FT_RES_FIXED_LEN 16






#define DOT11_RRM_CAP_LEN		5	
#define RCPI_IE_LEN 1
#define RSNI_IE_LEN 1
BWL_PRE_PACKED_STRUCT struct dot11_rrm_cap_ie {
	uint8 cap[DOT11_RRM_CAP_LEN];
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_rrm_cap_ie dot11_rrm_cap_ie_t;


#define DOT11_RRM_CAP_LINK			0
#define DOT11_RRM_CAP_NEIGHBOR_REPORT	1
#define DOT11_RRM_CAP_PARALLEL		2
#define DOT11_RRM_CAP_REPEATED		3
#define DOT11_RRM_CAP_BCN_PASSIVE	4
#define DOT11_RRM_CAP_BCN_ACTIVE	5
#define DOT11_RRM_CAP_BCN_TABLE		6
#define DOT11_RRM_CAP_BCN_REP_COND	7
#define DOT11_RRM_CAP_AP_CHANREP	16



#define DOT11_OP_CLASS_NONE			255



#define DOT11_RM_ACTION_RM_REQ		0	
#define DOT11_RM_ACTION_RM_REP		1	
#define DOT11_RM_ACTION_LM_REQ		2	
#define DOT11_RM_ACTION_LM_REP		3	
#define DOT11_RM_ACTION_NR_REQ		4	
#define DOT11_RM_ACTION_NR_REP		5	


BWL_PRE_PACKED_STRUCT struct dot11_rm_action {
	uint8 category;				
	uint8 action;				
	uint8 token;				
	uint8 data[1];
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_rm_action dot11_rm_action_t;
#define DOT11_RM_ACTION_LEN 3

BWL_PRE_PACKED_STRUCT struct dot11_rmreq {
	uint8 category;				
	uint8 action;				
	uint8 token;				
	uint16 reps;				
	uint8 data[1];
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_rmreq dot11_rmreq_t;
#define DOT11_RMREQ_LEN	5

BWL_PRE_PACKED_STRUCT struct dot11_rm_ie {
	uint8 id;
	uint8 len;
	uint8 token;
	uint8 mode;
	uint8 type;
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_rm_ie dot11_rm_ie_t;
#define DOT11_RM_IE_LEN	5


#define DOT11_RMREQ_MODE_PARALLEL	1
#define DOT11_RMREQ_MODE_ENABLE		2
#define DOT11_RMREQ_MODE_REQUEST	4
#define DOT11_RMREQ_MODE_REPORT		8
#define DOT11_RMREQ_MODE_DURMAND	0x10	


#define DOT11_RMREP_MODE_LATE		1
#define DOT11_RMREP_MODE_INCAPABLE	2
#define DOT11_RMREP_MODE_REFUSED	4

BWL_PRE_PACKED_STRUCT struct dot11_rmreq_bcn {
	uint8 id;
	uint8 len;
	uint8 token;
	uint8 mode;
	uint8 type;
	uint8 reg;
	uint8 channel;
	uint16 interval;
	uint16 duration;
	uint8 bcn_mode;
	struct ether_addr	bssid;
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_rmreq_bcn dot11_rmreq_bcn_t;
#define DOT11_RMREQ_BCN_LEN	18

BWL_PRE_PACKED_STRUCT struct dot11_rmrep_bcn {
	uint8 reg;
	uint8 channel;
	uint32 starttime[2];
	uint16 duration;
	uint8 frame_info;
	uint8 rcpi;
	uint8 rsni;
	struct ether_addr	bssid;
	uint8 antenna_id;
	uint32 parent_tsf;
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_rmrep_bcn dot11_rmrep_bcn_t;
#define DOT11_RMREP_BCN_LEN	26


#define DOT11_RMREQ_BCN_PASSIVE	0
#define DOT11_RMREQ_BCN_ACTIVE	1
#define DOT11_RMREQ_BCN_TABLE	2


#define DOT11_RMREQ_BCN_SSID_ID	0
#define DOT11_RMREQ_BCN_REPINFO_ID	1
#define DOT11_RMREQ_BCN_REPDET_ID	2
#define DOT11_RMREQ_BCN_REQUEST_ID	10
#define DOT11_RMREQ_BCN_APCHREP_ID	51


#define DOT11_RMREQ_BCN_REPDET_FIXED	0	
#define DOT11_RMREQ_BCN_REPDET_REQUEST	1	
#define DOT11_RMREQ_BCN_REPDET_ALL	2	


#define DOT11_RMREP_BCN_FRM_BODY	1


#define DOT11_RMREP_FRAME_COUNT_REPORT 1


BWL_PRE_PACKED_STRUCT struct dot11_rmreq_chanload {
	uint8 id;
	uint8 len;
	uint8 token;
	uint8 mode;
	uint8 type;
	uint8 reg;
	uint8 channel;
	uint16 interval;
	uint16 duration;
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_rmreq_chanload dot11_rmreq_chanload_t;
#define DOT11_RMREQ_CHANLOAD_LEN	11


BWL_PRE_PACKED_STRUCT struct dot11_rmrep_chanload {
	uint8 reg;
	uint8 channel;
	uint32 starttime[2];
	uint16 duration;
	uint8 channel_load;
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_rmrep_chanload dot11_rmrep_chanload_t;
#define DOT11_RMREP_CHANLOAD_LEN	13


BWL_PRE_PACKED_STRUCT struct dot11_rmreq_noise {
	uint8 id;
	uint8 len;
	uint8 token;
	uint8 mode;
	uint8 type;
	uint8 reg;
	uint8 channel;
	uint16 interval;
	uint16 duration;
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_rmreq_noise dot11_rmreq_noise_t;
#define DOT11_RMREQ_NOISE_LEN 11


BWL_PRE_PACKED_STRUCT struct dot11_rmrep_noise {
	uint8 reg;
	uint8 channel;
	uint32 starttime[2];
	uint16 duration;
	uint8 antid;
	uint8 anpi;
	uint8 ipi0_dens;
	uint8 ipi1_dens;
	uint8 ipi2_dens;
	uint8 ipi3_dens;
	uint8 ipi4_dens;
	uint8 ipi5_dens;
	uint8 ipi6_dens;
	uint8 ipi7_dens;
	uint8 ipi8_dens;
	uint8 ipi9_dens;
	uint8 ipi10_dens;
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_rmrep_noise dot11_rmrep_noise_t;
#define DOT11_RMREP_NOISE_LEN 25


BWL_PRE_PACKED_STRUCT struct dot11_rmreq_frame {
	uint8 id;
	uint8 len;
	uint8 token;
	uint8 mode;
	uint8 type;
	uint8 reg;
	uint8 channel;
	uint16 interval;
	uint16 duration;
	uint8 req_type;
	struct ether_addr	ta;
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_rmreq_frame dot11_rmreq_frame_t;
#define DOT11_RMREQ_FRAME_LEN 18


BWL_PRE_PACKED_STRUCT struct dot11_rmrep_frame {
	uint8 reg;
	uint8 channel;
	uint32 starttime[2];
	uint16 duration;
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_rmrep_frame dot11_rmrep_frame_t;
#define DOT11_RMREP_FRAME_LEN 12


BWL_PRE_PACKED_STRUCT struct dot11_rmrep_frmentry {
	struct ether_addr	ta;
	struct ether_addr	bssid;
	uint8 phy_type;
	uint8 avg_rcpi;
	uint8 last_rsni;
	uint8 last_rcpi;
	uint8 ant_id;
	uint16 frame_cnt;
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_rmrep_frmentry dot11_rmrep_frmentry_t;
#define DOT11_RMREP_FRMENTRY_LEN 19


BWL_PRE_PACKED_STRUCT struct dot11_rmreq_stat {
	uint8 id;
	uint8 len;
	uint8 token;
	uint8 mode;
	uint8 type;
	struct ether_addr	peer;
	uint16 interval;
	uint16 duration;
	uint8 group_id;
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_rmreq_stat dot11_rmreq_stat_t;
#define DOT11_RMREQ_STAT_LEN 16


BWL_PRE_PACKED_STRUCT struct dot11_rmrep_stat {
	uint16 duration;
	uint8 group_id;
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_rmrep_stat dot11_rmrep_stat_t;


BWL_PRE_PACKED_STRUCT struct dot11_rmreq_tx_stream {
	uint8 id;
	uint8 len;
	uint8 token;
	uint8 mode;
	uint8 type;
	uint16 interval;
	uint16 duration;
	struct ether_addr	peer;
	uint8 traffic_id;
	uint8 bin0_range;
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_rmreq_tx_stream dot11_rmreq_tx_stream_t;


BWL_PRE_PACKED_STRUCT struct dot11_rmrep_tx_stream {
	uint32 starttime[2];
	uint16 duration;
	struct ether_addr	peer;
	uint8 traffic_id;
	uint8 reason;
	uint32 txmsdu_cnt;
	uint32 msdu_discarded_cnt;
	uint32 msdufailed_cnt;
	uint32 msduretry_cnt;
	uint32 cfpolls_lost_cnt;
	uint32 avrqueue_delay;
	uint32 avrtx_delay;
	uint8 bin0_range;
	uint32 bin0;
	uint32 bin1;
	uint32 bin2;
	uint32 bin3;
	uint32 bin4;
	uint32 bin5;
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_rmrep_tx_stream dot11_rmrep_tx_stream_t;


BWL_PRE_PACKED_STRUCT struct dot11_rmreq_pause_time {
	uint8 id;
	uint8 len;
	uint8 token;
	uint8 mode;
	uint8 type;
	uint16 pause_time;
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_rmreq_pause_time dot11_rmreq_pause_time_t;


BWL_PRE_PACKED_STRUCT struct dot11_rmrep_nbr {
	struct ether_addr bssid;
	uint32 bssid_info;
	uint8 reg;
	uint8 channel;
	uint8 phytype;
	uchar sub_elements[1]; 	
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_rmrep_nbr dot11_rmrep_nbr_t;
#define DOT11_RMREP_NBR_LEN	13


BWL_PRE_PACKED_STRUCT struct dot11_rrmrep_nbr {
	uint8 id;
	uint8 len;
	dot11_rmrep_nbr_t nbr_rrmrep;
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_rrmrep_nbr dot11_rrmrep_nbr_t;
#define DOT11_RRMREP_NBR_LEN	15


#define DOT11_BSSTYPE_INFRASTRUCTURE		0	
#define DOT11_BSSTYPE_INDEPENDENT		1	
#define DOT11_BSSTYPE_ANY			2	
#define DOT11_SCANTYPE_ACTIVE			0	
#define DOT11_SCANTYPE_PASSIVE			1	


BWL_PRE_PACKED_STRUCT struct dot11_lmreq {
	uint8 category;				
	uint8 action;				
	uint8 token;				
	uint8 txpwr;				
	uint8 maxtxpwr;				
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_lmreq dot11_lmreq_t;
#define DOT11_LMREQ_LEN	5

BWL_PRE_PACKED_STRUCT struct dot11_lmrep {
	uint8 category;				
	uint8 action;				
	uint8 token;				
	dot11_tpc_rep_t tpc;			
	uint8 rxant;				
	uint8 txant;				
	uint8 rcpi;				
	uint8 rsni;				
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_lmrep dot11_lmrep_t;
#define DOT11_LMREP_LEN	11


#define PREN_PREAMBLE		24	
#define PREN_MM_EXT		12	
#define PREN_PREAMBLE_EXT	4	


#define RIFS_11N_TIME		2	



#define HT_SIG1_MCS_MASK        0x00007F
#define HT_SIG1_CBW             0x000080
#define HT_SIG1_HT_LENGTH       0xFFFF00


#define HT_SIG2_SMOOTHING       0x000001
#define HT_SIG2_NOT_SOUNDING    0x000002
#define HT_SIG2_RESERVED        0x000004
#define HT_SIG2_AGGREGATION     0x000008
#define HT_SIG2_STBC_MASK       0x000030
#define HT_SIG2_STBC_SHIFT      4
#define HT_SIG2_FEC_CODING      0x000040
#define HT_SIG2_SHORT_GI        0x000080
#define HT_SIG2_ESS_MASK        0x000300
#define HT_SIG2_ESS_SHIFT       8
#define HT_SIG2_CRC             0x03FC00
#define HT_SIG2_TAIL            0x1C0000


#define HT_T_LEG_PREAMBLE      16
#define HT_T_L_SIG              4
#define HT_T_SIG                8
#define HT_T_LTF1               4
#define HT_T_GF_LTF1            8
#define HT_T_LTFs               4
#define HT_T_STF                4
#define HT_T_GF_STF             8
#define HT_T_SYML               4

#define HT_N_SERVICE           16       
#define HT_N_TAIL               6       


#define APHY_SLOT_TIME          9       
#define APHY_SIFS_TIME          16      
#define APHY_DIFS_TIME          (APHY_SIFS_TIME + (2 * APHY_SLOT_TIME))  
#define APHY_PREAMBLE_TIME      16      
#define APHY_SIGNAL_TIME        4       
#define APHY_SYMBOL_TIME        4       
#define APHY_SERVICE_NBITS      16      
#define APHY_TAIL_NBITS         6       
#define APHY_CWMIN              15      


#define BPHY_SLOT_TIME          20      
#define BPHY_SIFS_TIME          10      
#define BPHY_DIFS_TIME          50      
#define BPHY_PLCP_TIME          192     
#define BPHY_PLCP_SHORT_TIME    96      
#define BPHY_CWMIN              31      


#define DOT11_OFDM_SIGNAL_EXTENSION	6	

#define PHY_CWMAX		1023	

#define	DOT11_MAXNUMFRAGS	16	



typedef int vht_group_id_t;



#define VHT_SIGA1_CONST_MASK            0x800004

#define VHT_SIGA1_BW_MASK               0x000003
#define VHT_SIGA1_20MHZ_VAL             0x000000
#define VHT_SIGA1_40MHZ_VAL             0x000001
#define VHT_SIGA1_80MHZ_VAL             0x000002
#define VHT_SIGA1_160MHZ_VAL            0x000003

#define VHT_SIGA1_STBC                  0x000008

#define VHT_SIGA1_GID_MASK              0x0003f0
#define VHT_SIGA1_GID_SHIFT             4
#define VHT_SIGA1_GID_TO_AP             0x00
#define VHT_SIGA1_GID_NOT_TO_AP         0x3f
#define VHT_SIGA1_GID_MAX_GID           0x3f

#define VHT_SIGA1_NSTS_SHIFT_MASK_USER0 0x001C00
#define VHT_SIGA1_NSTS_SHIFT            10

#define VHT_SIGA1_PARTIAL_AID_MASK      0x3fe000
#define VHT_SIGA1_PARTIAL_AID_SHIFT     13

#define VHT_SIGA1_TXOP_PS_NOT_ALLOWED   0x400000


#define VHT_SIGA2_GI_NONE               0x000000
#define VHT_SIGA2_GI_SHORT              0x000001
#define VHT_SIGA2_GI_W_MOD10            0x000002
#define VHT_SIGA2_CODING_LDPC           0x000004
#define VHT_SIGA2_LDPC_EXTRA_OFDM_SYM   0x000008
#define VHT_SIGA2_BEAMFORM_ENABLE       0x000100
#define VHT_SIGA2_MCS_SHIFT             4

#define VHT_SIGA2_B9_RESERVED           0x000200
#define VHT_SIGA2_TAIL_MASK             0xfc0000
#define VHT_SIGA2_TAIL_VALUE            0x000000


#define VHT_T_LEG_PREAMBLE      16
#define VHT_T_L_SIG              4
#define VHT_T_SIG_A              8
#define VHT_T_LTF                4
#define VHT_T_STF                4
#define VHT_T_SIG_B              4
#define VHT_T_SYML               4

#define VHT_N_SERVICE           16	
#define VHT_N_TAIL               6	



typedef struct d11cnt {
	uint32		txfrag;		
	uint32		txmulti;	
	uint32		txfail;		
	uint32		txretry;	
	uint32		txretrie;	
	uint32		rxdup;		
	uint32		txrts;		
	uint32		txnocts;	
	uint32		txnoack;	
	uint32		rxfrag;		
	uint32		rxmulti;	
	uint32		rxcrc;		
	uint32		txfrmsnt;	
	uint32		rxundec;	
} d11cnt_t;

#define BRCM_PROP_OUI		"\x00\x90\x4C"


/* Action frame type for RWL */
#define RWL_WIFI_DEFAULT		0
#define RWL_WIFI_FIND_MY_PEER		9 /* Used while finding server */
#define RWL_WIFI_FOUND_PEER		10 /* Server response to the client  */
#define RWL_ACTION_WIFI_FRAG_TYPE	85 /* Fragment indicator for receiver */

#define BRCM_PROP_OUI		"\x00\x90\x4C"	

#define BRCM_OUI		"\x00\x10\x18"	

BWL_PRE_PACKED_STRUCT struct brcm_ie {
	uint8	id;		/* IE ID, 221, DOT11_MNG_PROPR_ID */
	uint8	len;		/* IE length */
	uint8	oui[3];
	uint8	ver;		/* type/ver of this IE */
	uint8	assoc;		/* # of assoc STAs */
	uint8	flags;		/* misc flags */
	uint8	flags1;		/* misc flags */
	uint16	amsdu_mtu_pref;	/* preferred A-MSDU MTU */
} BWL_POST_PACKED_STRUCT;
typedef	struct brcm_ie brcm_ie_t;
#define BRCM_IE_LEN		11	
#define BRCM_IE_VER		2	
#define BRCM_IE_LEGACY_AES_VER	1	


#define	BRF_LZWDS		0x4	
#define	BRF_BLOCKACK		0x8	


#define	BRF1_AMSDU		0x1	
#define BRF1_WMEPS		0x4	
#define BRF1_PSOFIX		0x8	
#define	BRF1_RX_LARGE_AGG	0x10	
#define BRF1_RFAWARE_DCS	0x20    
#define BRF1_SOFTAP		0x40    
#define BRF1_DWDS		0x80    


BWL_PRE_PACKED_STRUCT struct vndr_ie {
	uchar id;
	uchar len;
	uchar oui [3];
	uchar data [1]; 	
} BWL_POST_PACKED_STRUCT;
typedef struct vndr_ie vndr_ie_t;

#define VNDR_IE_HDR_LEN		2	
#define VNDR_IE_MIN_LEN		3	
#define VNDR_IE_FIXED_LEN	(VNDR_IE_HDR_LEN + VNDR_IE_MIN_LEN)
#define VNDR_IE_MAX_LEN		256	


#define MCSSET_LEN	16	
#define MAX_MCS_NUM	(128)	

BWL_PRE_PACKED_STRUCT struct ht_cap_ie {
	uint16	cap;
	uint8	params;
	uint8	supp_mcs[MCSSET_LEN];
	uint16	ext_htcap;
	uint32	txbf_cap;
	uint8	as_cap;
} BWL_POST_PACKED_STRUCT;
typedef struct ht_cap_ie ht_cap_ie_t;



BWL_PRE_PACKED_STRUCT struct ht_prop_cap_ie {
	uint8	id;		/* IE ID, 221, DOT11_MNG_PROPR_ID */
	uint8	len;		/* IE length */
	uint8	oui[3];
	uint8	type;           /* type inidicates what follows */
	ht_cap_ie_t cap_ie;
} BWL_POST_PACKED_STRUCT;
typedef struct ht_prop_cap_ie ht_prop_cap_ie_t;

#define HT_PROP_IE_OVERHEAD	4	
#define HT_CAP_IE_LEN		26	
#define HT_CAP_IE_TYPE		51

#define HT_CAP_LDPC_CODING	0x0001	
#define HT_CAP_40MHZ		0x0002  
#define HT_CAP_MIMO_PS_MASK	0x000C  
#define HT_CAP_MIMO_PS_SHIFT	0x0002	
#define HT_CAP_MIMO_PS_OFF	0x0003	
#define HT_CAP_MIMO_PS_RTS	0x0001	
#define HT_CAP_MIMO_PS_ON	0x0000	
#define HT_CAP_GF		0x0010	
#define HT_CAP_SHORT_GI_20	0x0020	
#define HT_CAP_SHORT_GI_40	0x0040	
#define HT_CAP_TX_STBC		0x0080	
#define HT_CAP_RX_STBC_MASK	0x0300	
#define HT_CAP_RX_STBC_SHIFT	8	
#define HT_CAP_DELAYED_BA	0x0400	
#define HT_CAP_MAX_AMSDU	0x0800	

#define HT_CAP_DSSS_CCK	0x1000	
#define HT_CAP_PSMP		0x2000	
#define HT_CAP_40MHZ_INTOLERANT 0x4000	
#define HT_CAP_LSIG_TXOP	0x8000	

#define HT_CAP_RX_STBC_NO		0x0	
#define HT_CAP_RX_STBC_ONE_STREAM	0x1	
#define HT_CAP_RX_STBC_TWO_STREAM	0x2	
#define HT_CAP_RX_STBC_THREE_STREAM	0x3	

#define VHT_MAX_MPDU		11454	
#define VHT_MPDU_MSDU_DELTA	56		

#define VHT_MAX_AMSDU		(VHT_MAX_MPDU - VHT_MPDU_MSDU_DELTA)

#define HT_MAX_AMSDU		7935	
#define HT_MIN_AMSDU		3835	

#define HT_PARAMS_RX_FACTOR_MASK	0x03	
#define HT_PARAMS_DENSITY_MASK		0x1C	
#define HT_PARAMS_DENSITY_SHIFT	2	


#define AMPDU_MAX_MPDU_DENSITY  7       
#define AMPDU_DENSITY_NONE      0       
#define AMPDU_DENSITY_1over4_US 1       
#define AMPDU_DENSITY_1over2_US 2       
#define AMPDU_DENSITY_1_US      3       
#define AMPDU_DENSITY_2_US      4       
#define AMPDU_DENSITY_4_US      5       
#define AMPDU_DENSITY_8_US      6       
#define AMPDU_DENSITY_16_US     7       
#define AMPDU_RX_FACTOR_8K      0       
#define AMPDU_RX_FACTOR_16K     1       
#define AMPDU_RX_FACTOR_32K     2       
#define AMPDU_RX_FACTOR_64K     3       
#define AMPDU_RX_FACTOR_BASE    8*1024  

#define AMPDU_DELIMITER_LEN	4	
#define AMPDU_DELIMITER_LEN_MAX	63	

#define HT_CAP_EXT_PCO			0x0001
#define HT_CAP_EXT_PCO_TTIME_MASK	0x0006
#define HT_CAP_EXT_PCO_TTIME_SHIFT	1
#define HT_CAP_EXT_MCS_FEEDBACK_MASK	0x0300
#define HT_CAP_EXT_MCS_FEEDBACK_SHIFT	8
#define HT_CAP_EXT_HTC			0x0400
#define HT_CAP_EXT_RD_RESP		0x0800

BWL_PRE_PACKED_STRUCT struct ht_add_ie {
	uint8	ctl_ch;			
	uint8	byte1;			
	uint16	opmode;			
	uint16	misc_bits;		
	uint8	basic_mcs[MCSSET_LEN];  
} BWL_POST_PACKED_STRUCT;
typedef struct ht_add_ie ht_add_ie_t;



BWL_PRE_PACKED_STRUCT struct ht_prop_add_ie {
	uint8	id;		/* IE ID, 221, DOT11_MNG_PROPR_ID */
	uint8	len;		/* IE length */
	uint8	oui[3];
	uint8	type;		/* indicates what follows */
	ht_add_ie_t add_ie;
} BWL_POST_PACKED_STRUCT;
typedef struct ht_prop_add_ie ht_prop_add_ie_t;

#define HT_ADD_IE_LEN	22
#define HT_ADD_IE_TYPE	52


#define HT_BW_ANY		0x04	
#define HT_RIFS_PERMITTED     	0x08	


#define HT_OPMODE_MASK	        0x0003	
#define HT_OPMODE_SHIFT		0	
#define HT_OPMODE_PURE		0x0000	
#define HT_OPMODE_OPTIONAL	0x0001	
#define HT_OPMODE_HT20IN40	0x0002	
#define HT_OPMODE_MIXED	0x0003	
#define HT_OPMODE_NONGF	0x0004	
#define DOT11N_TXBURST		0x0008	
#define DOT11N_OBSS_NONHT	0x0010	


#define HT_BASIC_STBC_MCS	0x007f	
#define HT_DUAL_STBC_PROT	0x0080	
#define HT_SECOND_BCN		0x0100	
#define HT_LSIG_TXOP		0x0200	
#define HT_PCO_ACTIVE		0x0400	
#define HT_PCO_PHASE		0x0800	
#define HT_DUALCTS_PROTECTION	0x0080	


#define DOT11N_2G_TXBURST_LIMIT	6160	
#define DOT11N_5G_TXBURST_LIMIT	3080	


#define GET_HT_OPMODE(add_ie)		((ltoh16_ua(&add_ie->opmode) & HT_OPMODE_MASK) \
					>> HT_OPMODE_SHIFT)
#define HT_MIXEDMODE_PRESENT(add_ie)	((ltoh16_ua(&add_ie->opmode) & HT_OPMODE_MASK) \
					== HT_OPMODE_MIXED)	
#define HT_HT20_PRESENT(add_ie)	((ltoh16_ua(&add_ie->opmode) & HT_OPMODE_MASK) \
					== HT_OPMODE_HT20IN40)	
#define HT_OPTIONAL_PRESENT(add_ie)	((ltoh16_ua(&add_ie->opmode) & HT_OPMODE_MASK) \
					== HT_OPMODE_OPTIONAL)	
#define HT_USE_PROTECTION(add_ie)	(HT_HT20_PRESENT((add_ie)) || \
					HT_MIXEDMODE_PRESENT((add_ie))) 
#define HT_NONGF_PRESENT(add_ie)	((ltoh16_ua(&add_ie->opmode) & HT_OPMODE_NONGF) \
					== HT_OPMODE_NONGF)	
#define DOT11N_TXBURST_PRESENT(add_ie)	((ltoh16_ua(&add_ie->opmode) & DOT11N_TXBURST) \
					== DOT11N_TXBURST)	
#define DOT11N_OBSS_NONHT_PRESENT(add_ie)	((ltoh16_ua(&add_ie->opmode) & DOT11N_OBSS_NONHT) \
					== DOT11N_OBSS_NONHT)	

BWL_PRE_PACKED_STRUCT struct obss_params {
	uint16	passive_dwell;
	uint16	active_dwell;
	uint16	bss_widthscan_interval;
	uint16	passive_total;
	uint16	active_total;
	uint16	chanwidth_transition_dly;
	uint16	activity_threshold;
} BWL_POST_PACKED_STRUCT;
typedef struct obss_params obss_params_t;

BWL_PRE_PACKED_STRUCT struct dot11_obss_ie {
	uint8	id;
	uint8	len;
	obss_params_t obss_params;
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_obss_ie dot11_obss_ie_t;
#define DOT11_OBSS_SCAN_IE_LEN	sizeof(obss_params_t)	


#define HT_CTRL_LA_TRQ		0x00000002	
#define HT_CTRL_LA_MAI		0x0000003C	
#define HT_CTRL_LA_MAI_SHIFT	2
#define HT_CTRL_LA_MAI_MRQ	0x00000004	
#define HT_CTRL_LA_MAI_MSI	0x00000038	
#define HT_CTRL_LA_MFSI		0x000001C0	
#define HT_CTRL_LA_MFSI_SHIFT	6
#define HT_CTRL_LA_MFB_ASELC	0x0000FE00	
#define HT_CTRL_LA_MFB_ASELC_SH	9
#define HT_CTRL_LA_ASELC_CMD	0x00000C00	
#define HT_CTRL_LA_ASELC_DATA	0x0000F000	
#define HT_CTRL_CAL_POS		0x00030000	
#define HT_CTRL_CAL_SEQ		0x000C0000	
#define HT_CTRL_CSI_STEERING	0x00C00000	
#define HT_CTRL_CSI_STEER_SHIFT	22
#define HT_CTRL_CSI_STEER_NFB	0		
#define HT_CTRL_CSI_STEER_CSI	1		
#define HT_CTRL_CSI_STEER_NCOM	2		
#define HT_CTRL_CSI_STEER_COM	3		
#define HT_CTRL_NDP_ANNOUNCE	0x01000000	
#define HT_CTRL_AC_CONSTRAINT	0x40000000	
#define HT_CTRL_RDG_MOREPPDU	0x80000000	

#define HT_OPMODE_OPTIONAL	0x0001	
#define HT_OPMODE_HT20IN40	0x0002	
#define HT_OPMODE_MIXED	0x0003	
#define HT_OPMODE_NONGF	0x0004	
#define DOT11N_TXBURST		0x0008	
#define DOT11N_OBSS_NONHT	0x0010	





BWL_PRE_PACKED_STRUCT struct vht_cap_ie {
	uint32  vht_cap_info;
	
	uint16	rx_mcs_map;
	uint16  rx_max_rate;
	uint16  tx_mcs_map;
	uint16	tx_max_rate;
} BWL_POST_PACKED_STRUCT;
typedef struct vht_cap_ie vht_cap_ie_t;


#define VHT_CAP_IE_LEN 12


#define VHT_CAP_INFO_MAX_MPDU_LEN_MASK          0x00000003
#define VHT_CAP_INFO_SUPP_CHAN_WIDTH_MASK       0x0000000c
#define VHT_CAP_INFO_LDPC                       0x00000010
#define VHT_CAP_INFO_SGI_80MHZ                  0x00000020
#define VHT_CAP_INFO_SGI_160MHZ                 0x00000040
#define VHT_CAP_INFO_TX_STBC                    0x00000080
#define VHT_CAP_INFO_RX_STBC_MASK               0x00000700
#define VHT_CAP_INFO_RX_STBC_SHIFT              8
#define VHT_CAP_INFO_SU_BEAMFMR                 0x00000800
#define VHT_CAP_INFO_SU_BEAMFMEE                0x00001000
#define VHT_CAP_INFO_NUM_BMFMR_ANT_MASK         0x0000e000
#define VHT_CAP_INFO_NUM_BMFMR_ANT_SHIFT        13
#define VHT_CAP_INFO_NUM_SOUNDING_DIM_MASK      0x00070000
#define VHT_CAP_INFO_NUM_SOUNDING_DIM_SHIFT     16
#define VHT_CAP_INFO_MU_BEAMFMR                 0x00080000
#define VHT_CAP_INFO_MU_BEAMFMEE                0x00100000
#define VHT_CAP_INFO_TXOPPS                     0x00200000
#define VHT_CAP_INFO_HTCVHT                     0x00400000
#define VHT_CAP_INFO_AMPDU_MAXLEN_EXP_MASK      0x03800000
#define VHT_CAP_INFO_AMPDU_MAXLEN_EXP_SHIFT     23
#define VHT_CAP_INFO_LINK_ADAPT_CAP_MASK        0x0c000000
#define VHT_CAP_INFO_LINK_ADAPT_CAP_SHIFT       26


#define VHT_CAP_SUPP_MCS_RX_HIGHEST_RATE_MASK   0x1fff
#define VHT_CAP_SUPP_MCS_RX_HIGHEST_RATE_SHIFT  0

#define VHT_CAP_SUPP_MCS_TX_HIGHEST_RATE_MASK   0x1fff
#define VHT_CAP_SUPP_MCS_TX_HIGHEST_RATE_SHIFT  0

#define VHT_CAP_MCS_MAP_0_7                     0
#define VHT_CAP_MCS_MAP_0_8                     1
#define VHT_CAP_MCS_MAP_0_9                     2
#define VHT_CAP_MCS_MAP_NONE                    3
#define VHT_CAP_MCS_MAP_S                       2 
#define VHT_CAP_MCS_MAP_M                       0x3 

#define VHT_CAP_MCS_MAP_NONE_ALL                0xffff

#define VHT_CAP_MCS_MAP_0_9_NSS3 \
	        ((VHT_CAP_MCS_MAP_0_9 << VHT_MCS_MAP_GET_SS_IDX(1)) | \
	         (VHT_CAP_MCS_MAP_0_9 << VHT_MCS_MAP_GET_SS_IDX(2)) | \
	         (VHT_CAP_MCS_MAP_0_9 << VHT_MCS_MAP_GET_SS_IDX(3)))

#define VHT_CAP_MCS_MAP_NSS_MAX                 8


#define VHT_CAP_MCS_MAP_CREATE(mcsmap, nss, mcs) \
	do { \
		int i; \
		for (i = 1; i <= nss; i++) { \
			VHT_MCS_MAP_SET_MCS_PER_SS(i, mcs, mcsmap); \
		} \
	} while (0)


#define VHT_MCS_CODE_TO_MCS_MAP(mcs_code) \
	((mcs_code == VHT_CAP_MCS_MAP_0_7) ? 0xff : \
	 (mcs_code == VHT_CAP_MCS_MAP_0_8) ? 0x1ff : \
	 (mcs_code == VHT_CAP_MCS_MAP_0_9) ? 0x3ff : 0)


#define VHT_MCS_MAP_TO_MCS_CODE(mcs_map) \
	((mcs_map == 0xff)  ? VHT_CAP_MCS_MAP_0_7 : \
	 (mcs_map == 0x1ff) ? VHT_CAP_MCS_MAP_0_8 : \
	 (mcs_map == 0x3ff) ? VHT_CAP_MCS_MAP_0_9 : VHT_CAP_MCS_MAP_NONE)


typedef enum vht_cap_chan_width {
	VHT_CAP_CHAN_WIDTH_SUPPORT_MANDATORY = 0x00,
	VHT_CAP_CHAN_WIDTH_SUPPORT_160       = 0x04,
	VHT_CAP_CHAN_WIDTH_SUPPORT_160_8080  = 0x08
} vht_cap_chan_width_t;


typedef enum vht_cap_max_mpdu_len {
	VHT_CAP_MPDU_MAX_4K     = 0x00,
	VHT_CAP_MPDU_MAX_8K     = 0x01,
	VHT_CAP_MPDU_MAX_11K    = 0x02
} vht_cap_max_mpdu_len_t;


#define VHT_MPDU_LIMIT_4K        3895
#define VHT_MPDU_LIMIT_8K        7991
#define VHT_MPDU_LIMIT_11K      11454




BWL_PRE_PACKED_STRUCT struct vht_op_ie {
	uint8	chan_width;
	uint8	chan1;
	uint8	chan2;
	uint16	supp_mcs;  
} BWL_POST_PACKED_STRUCT;
typedef struct vht_op_ie vht_op_ie_t;


#define VHT_OP_IE_LEN 5

typedef enum vht_op_chan_width {
	VHT_OP_CHAN_WIDTH_20_40	= 0,
	VHT_OP_CHAN_WIDTH_80	= 1,
	VHT_OP_CHAN_WIDTH_160	= 2,
	VHT_OP_CHAN_WIDTH_80_80	= 3
} vht_op_chan_width_t;


#define BRCM_VHT_FEATURES_OUITYPE	0x4
BWL_PRE_PACKED_STRUCT struct vht_features_ie_hdr {
	uint8 oui[3];
	uint8 type;		/* type of this IE = 4 */
	uint8 rate_mask;	/* VHT rate mask */
} BWL_POST_PACKED_STRUCT;
typedef struct vht_features_ie_hdr vht_features_ie_hdr_t;


#define VHT_MCS_MAP_GET_SS_IDX(nss) (((nss)-1) * VHT_CAP_MCS_MAP_S)
#define VHT_MCS_MAP_GET_MCS_PER_SS(nss, mcsMap) \
	(((mcsMap) >> VHT_MCS_MAP_GET_SS_IDX(nss)) & VHT_CAP_MCS_MAP_M)
#define VHT_MCS_MAP_SET_MCS_PER_SS(nss, numMcs, mcsMap) \
	do { \
	 (mcsMap) &= (~(VHT_CAP_MCS_MAP_M << VHT_MCS_MAP_GET_SS_IDX(nss))); \
	 (mcsMap) |= (((numMcs) & VHT_CAP_MCS_MAP_M) << VHT_MCS_MAP_GET_SS_IDX(nss)); \
	} while (0)
#define VHT_MCS_SS_SUPPORTED(nss, mcsMap) \
		 (VHT_MCS_MAP_GET_MCS_PER_SS((nss), (mcsMap)) != VHT_CAP_MCS_MAP_NONE)



#define WPA_OUI			"\x00\x50\xF2"	
#define WPA_OUI_TYPE		1
#define WPA_OUI_LEN		3		
#define WPA_VERSION		1		
#define WPA2_OUI		"\x00\x0F\xAC"	
#define WPA2_OUI_LEN		3		
#define WPA2_VERSION		1		
#define WPA2_VERSION_LEN	2		


#define WPS_OUI			"\x00\x50\xF2"	
#define WPS_OUI_LEN		3		
#define WPS_OUI_TYPE		4



#ifdef P2P_IE_OVRD
#define WFA_OUI			MAC_OUI
#else
#define WFA_OUI			"\x50\x6F\x9A"	
#endif 
#define WFA_OUI_LEN		3		
#ifdef P2P_IE_OVRD
#define WFA_OUI_TYPE_P2P	MAC_OUI_TYPE_P2P
#else
#define WFA_OUI_TYPE_P2P	9
#endif

#define WFA_OUI_TYPE_TPC	8
#ifdef WLTDLS
#define WFA_OUI_TYPE_TPQ	4	
#define WFA_OUI_TYPE_TPS	5	
#define WFA_OUI_TYPE_WFD	10
#endif 


#define RSN_AKM_NONE		0	
#define RSN_AKM_UNSPECIFIED	1	
#define RSN_AKM_PSK		2	
#define RSN_AKM_FBT_1X		3	
#define RSN_AKM_FBT_PSK		4	
#define RSN_AKM_MFP_1X		5	
#define RSN_AKM_MFP_PSK		6	
#define RSN_AKM_TPK			7	


#define DOT11_MAX_DEFAULT_KEYS	4	
#define DOT11_MAX_KEY_SIZE	32	
#define DOT11_MAX_IV_SIZE	16	
#define DOT11_EXT_IV_FLAG	(1<<5)	
#define DOT11_WPA_KEY_RSC_LEN   8       

#define WEP1_KEY_SIZE		5	
#define WEP1_KEY_HEX_SIZE	10	
#define WEP128_KEY_SIZE		13	
#define WEP128_KEY_HEX_SIZE	26	
#define TKIP_MIC_SIZE		8	
#define TKIP_EOM_SIZE		7	
#define TKIP_EOM_FLAG		0x5a	
#define TKIP_KEY_SIZE		32	
#define TKIP_MIC_AUTH_TX	16	
#define TKIP_MIC_AUTH_RX	24	
#define TKIP_MIC_SUP_RX		TKIP_MIC_AUTH_TX	
#define TKIP_MIC_SUP_TX		TKIP_MIC_AUTH_RX	
#define AES_KEY_SIZE		16	
#define AES_MIC_SIZE		8	
#define BIP_KEY_SIZE		16	
#define BIP_MIC_SIZE		8   


#define WCN_OUI			"\x00\x50\xf2"	
#define WCN_TYPE		4	

#ifdef BCMWAPI_WPI
#define SMS4_KEY_LEN		16
#define SMS4_WPI_CBC_MAC_LEN	16
#endif




BWL_PRE_PACKED_STRUCT struct dot11_mdid_ie {
	uint8 id;
	uint8 len;
	uint16 mdid;		
	uint8 cap;
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_mdid_ie dot11_mdid_ie_t;

#define FBT_MDID_CAP_OVERDS	0x01	
#define FBT_MDID_CAP_RRP	0x02	


BWL_PRE_PACKED_STRUCT struct dot11_ft_ie {
	uint8 id;
	uint8 len;
	uint16 mic_control;		
	uint8 mic[16];
	uint8 anonce[32];
	uint8 snonce[32];
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_ft_ie dot11_ft_ie_t;

#define TIE_TYPE_RESERVED		0
#define TIE_TYPE_REASSOC_DEADLINE	1
#define TIE_TYPE_KEY_LIEFTIME		2
#define TIE_TYPE_ASSOC_COMEBACK		3
BWL_PRE_PACKED_STRUCT struct dot11_timeout_ie {
	uint8 id;
	uint8 len;
	uint8 type;		
	uint32 value;		
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_timeout_ie dot11_timeout_ie_t;


BWL_PRE_PACKED_STRUCT struct dot11_gtk_ie {
	uint8 id;
	uint8 len;
	uint16 key_info;
	uint8 key_len;
	uint8 rsc[8];
	uint8 data[1];
} BWL_POST_PACKED_STRUCT;
typedef struct dot11_gtk_ie dot11_gtk_ie_t;


BWL_PRE_PACKED_STRUCT struct mmic_ie {
	uint8   id;					
	uint8   len;				
	uint16  key_id;				
	uint8   ipn[6];				
	uint8   mic[BIP_MIC_SIZE];	
} BWL_POST_PACKED_STRUCT;
typedef struct mmic_ie mmic_ie_t;

#define BSSID_INVALID           "\x00\x00\x00\x00\x00\x00"
#define BSSID_BROADCAST         "\xFF\xFF\xFF\xFF\xFF\xFF"

#ifdef BCMWAPI_WAI
#define WAPI_IE_MIN_LEN 	20	
#define WAPI_VERSION		1	
#define WAPI_VERSION_LEN	2	
#define WAPI_OUI		"\x00\x14\x72"	
#define WAPI_OUI_LEN		DOT11_OUI_LEN	
#endif 


#define WMM_OUI			"\x00\x50\xF2"	
#define WMM_OUI_LEN		3		
#define WMM_OUI_TYPE	2		
#define WMM_VERSION		1
#define WMM_VERSION_LEN	1


#define WMM_OUI_SUBTYPE_PARAMETER	1
#define WMM_PARAMETER_IE_LEN		24


BWL_PRE_PACKED_STRUCT struct link_id_ie {
	uint8 id;
	uint8 len;
	struct ether_addr	bssid;
	struct ether_addr	tdls_init_mac;
	struct ether_addr	tdls_resp_mac;
} BWL_POST_PACKED_STRUCT;
typedef struct link_id_ie link_id_ie_t;
#define TDLS_LINK_ID_IE_LEN		18


BWL_PRE_PACKED_STRUCT struct wakeup_sch_ie {
	uint8 id;
	uint8 len;
	uint32 offset;			
	uint32 interval;		
	uint32 awake_win_slots;	
	uint32 max_wake_win;	
	uint16 idle_cnt;		
} BWL_POST_PACKED_STRUCT;
typedef struct wakeup_sch_ie wakeup_sch_ie_t;
#define TDLS_WAKEUP_SCH_IE_LEN		18


BWL_PRE_PACKED_STRUCT struct channel_switch_timing_ie {
	uint8 id;
	uint8 len;
	uint16 switch_time;		
	uint16 switch_timeout;	
} BWL_POST_PACKED_STRUCT;
typedef struct channel_switch_timing_ie channel_switch_timing_ie_t;
#define TDLS_CHANNEL_SWITCH_TIMING_IE_LEN		4


BWL_PRE_PACKED_STRUCT struct pti_control_ie {
	uint8 id;
	uint8 len;
	uint8 tid;
	uint16 seq_control;
} BWL_POST_PACKED_STRUCT;
typedef struct pti_control_ie pti_control_ie_t;
#define TDLS_PTI_CONTROL_IE_LEN		3


BWL_PRE_PACKED_STRUCT struct pu_buffer_status_ie {
	uint8 id;
	uint8 len;
	uint8 status;
} BWL_POST_PACKED_STRUCT;
typedef struct pu_buffer_status_ie pu_buffer_status_ie_t;
#define TDLS_PU_BUFFER_STATUS_IE_LEN	1
#define TDLS_PU_BUFFER_STATUS_AC_BK		1
#define TDLS_PU_BUFFER_STATUS_AC_BE		2
#define TDLS_PU_BUFFER_STATUS_AC_VI		4
#define TDLS_PU_BUFFER_STATUS_AC_VO		8


#include <packed_section_end.h>

#endif