cm-kernel /drivers/net/wireless/tiwlan1251/common/src/core/rsn/admCtrlWpa2.c

Language C Lines 2030
MD5 Hash dcc3da453cc77bc6660bbb1bb34d78a4 Estimated Cost $35,328 (why?)
Repository git://github.com/CyanogenMod/cm-kernel.git View Raw File View Project SPDX
   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
/****************************************************************************
**+-----------------------------------------------------------------------+**
**|                                                                       |**
**| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved.      |**
**| All rights reserved.                                                  |**
**|                                                                       |**
**| Redistribution and use in source and binary forms, with or without    |**
**| modification, are permitted provided that the following conditions    |**
**| are met:                                                              |**
**|                                                                       |**
**|  * Redistributions of source code must retain the above copyright     |**
**|    notice, this list of conditions and the following disclaimer.      |**
**|  * Redistributions in binary form must reproduce the above copyright  |**
**|    notice, this list of conditions and the following disclaimer in    |**
**|    the documentation and/or other materials provided with the         |**
**|    distribution.                                                      |**
**|  * Neither the name Texas Instruments nor the names of its            |**
**|    contributors may be used to endorse or promote products derived    |**
**|    from this software without specific prior written permission.      |**
**|                                                                       |**
**| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   |**
**| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     |**
**| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |**
**| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  |**
**| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |**
**| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      |**
**| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |**
**| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |**
**| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   |**
**| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |**
**| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  |**
**|                                                                       |**
**+-----------------------------------------------------------------------+**
****************************************************************************/

/** \file admCtrlWpa2.c
 *  \brief WPA2 Admission control methods
 *
 *  \see admCtrl.h
 */

#include "osApi.h"

#include "utils.h"
#include "paramOut.h"
#include "paramIn.h"
#include "mlmeApi.h"
#include "802_11Defs.h"
#include "DataCtrl_Api.h"
#include "report.h"

/*
#include "fsm.h"
#include "utils.h"
*/

#include "rsn.h"
#include "admCtrl.h"
#include "admCtrlWpa2.h"
#include "osDot11.h"
#include "siteMgrApi.h"
#include "EvHandler.h"
#include "admCtrl.h"

#ifdef EXC_MODULE_INCLUDED
#include "admCtrlWpa.h"
#include "admCtrlExc.h"
#include "excMngr.h"
#endif

/* Constants */
#define MAX_NETWORK_MODE 2
#define MAX_WPA2_CIPHER_SUITE 6

#define PMKID_CAND_LIST_MEMBUFF_SIZE  (2*sizeof(UINT32) + (sizeof(OS_802_11_PMKID_CANDIDATE) * PMKID_MAX_NUMBER))
#define PMKID_MIN_BUFFER_SIZE    2*sizeof(UINT32) + MAC_ADDR_LEN + PMKID_VALUE_SIZE

#define TI_WLAN_COPY_UINT16_UNALIGNED(addr, val) {\
    *((UINT8 *) &(addr))   = (UINT8)(val & 0x00FF); \
    *((UINT8 *) &(addr) + 1)   = (UINT8)((val & 0xFF00) >> 8);}


/* Enumerations */

/* Typedefs */

/* Structures */

/* External data definitions */

/* Local functions definitions */

/* Global variables */
static UINT8 wpa2IeOuiIe[3] = { 0x00, 0x0f, 0xac};

/**************************************************************/
/* reduce stack usage (admCtrlWpa_setSite)*/
/**************************************************************/
static   paramInfo_t         param;
static   whalParamInfo_t     whalParam;
static   wpa2IeData_t        wpa2DataIE;
/**************************************************************/

static BOOL broadcastCipherSuiteValidity[MAX_NETWORK_MODE][MAX_WPA2_CIPHER_SUITE]=
{
    /* RSN_IBSS */  {
/* NONE       */    FALSE,
/* WEP40      */    FALSE,
/* TKIP       */    TRUE,
/* AES_WRAP   */    FALSE,
/* AES_CCMP   */    TRUE,
/* WEP104     */    FALSE},

    /* RSN_INFRASTRUCTURE */  {
/* NONE       */    FALSE,
/* WEP        */    TRUE,
/* TKIP       */    TRUE,
/* AES_WRAP   */    FALSE,
/* AES_CCMP   */    TRUE,
/* WEP104     */    TRUE}
};

/** WPA2 admission table. Used to verify admission parameters to an AP */
/* table parameters:
    Max unicast cipher in the IE
    Max broadcast cipher in the IE
    Encryption status 
*/
typedef struct
{
    TI_STATUS        status;
    cipherSuite_e    unicast;
    cipherSuite_e    broadcast;
    UINT8            evaluation; 
} admCtrlWpa2_validity_t;

static admCtrlWpa2_validity_t    admCtrlWpa2_validityTable[MAX_WPA2_CIPHER_SUITE][MAX_WPA2_CIPHER_SUITE][MAX_WPA2_CIPHER_SUITE] =
{
/* AP unicast NONE */ {
        /* AP multicast NONE */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP40 */ { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WRAP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
        /* AP multicast WEP40 */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP40 */ { OK,  RSN_CIPHER_NONE, RSN_CIPHER_WEP ,1},
            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WRAP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP104 */{ OK,  RSN_CIPHER_NONE, RSN_CIPHER_WEP104 ,1}},
        /* AP multicast TKIP */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA TKIP */  { OK,  RSN_CIPHER_NONE, RSN_CIPHER_TKIP ,2},
            /* STA WRAP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
        /* AP multicast WRAP */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WRAP */  { OK,  RSN_CIPHER_NONE, RSN_CIPHER_AES_WRAP ,3},
            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
        /* AP multicast CCMP */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WRAP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA CCMP */  { OK,  RSN_CIPHER_NONE, RSN_CIPHER_AES_CCMP ,3},
            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
        /* AP multicast WEP104 */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP40 */ { OK,  RSN_CIPHER_NONE, RSN_CIPHER_WEP ,1},
            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WRAP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP104 */{ OK,  RSN_CIPHER_NONE, RSN_CIPHER_WEP104 ,1}}},
/* AP unicast WEP */  {
        /* AP multicast NONE */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WRAP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
        /* AP multicast WEP */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WRAP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
        /* AP multicast TKIP */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
        /* AP multicast WRAP */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WRAP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
        /* AP multicast CCMP */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
        /* AP multicast WEP104 */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}}},
/* AP unicast TKIP */  {
        /* AP multicast NONE */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
        /* AP multicast WEP */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA TKIP */  { OK,  RSN_CIPHER_TKIP, RSN_CIPHER_WEP  ,4},
            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
        /* AP multicast TKIP */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA TKIP */  { OK,  RSN_CIPHER_TKIP, RSN_CIPHER_TKIP ,7},
            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
        /* AP multicast WRAP */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
        /* AP multicast CCMP */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
        /* AP multicast WEP104 */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA TKIP */  { OK,  RSN_CIPHER_TKIP, RSN_CIPHER_WEP104 ,4},
            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}}},
/* AP unicast AES_WRAP */ {
        /* AP multicast NONE */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
        /* AP multicast WEP40 */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA AES */   { OK,  RSN_CIPHER_AES_WRAP, RSN_CIPHER_WEP ,5},
            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
        /* AP multicast TKIP */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA AES */   { OK,  RSN_CIPHER_AES_WRAP, RSN_CIPHER_TKIP ,6},
            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
        /* AP multicast WRAP */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA AES */   { OK,  RSN_CIPHER_AES_WRAP, RSN_CIPHER_AES_WRAP ,8},
            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
        /* AP multicast CCMP */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
        /* AP multicast WEP104 */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA AES */   { OK,  RSN_CIPHER_AES_WRAP, RSN_CIPHER_WEP104 ,5},
            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}}},
/* AP unicast AES_CCMP */ {
        /* AP multicast NONE */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
        /* AP multicast WEP */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA CCMP */  { OK,  RSN_CIPHER_AES_CCMP, RSN_CIPHER_WEP ,5},
            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
        /* AP multicast TKIP */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA TKIP */  { OK, RSN_CIPHER_AES_CCMP, RSN_CIPHER_TKIP ,6},
            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA CCMP */  { OK,  RSN_CIPHER_AES_CCMP, RSN_CIPHER_TKIP ,6},
            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
        /* AP multicast WRAP */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
        /* AP multicast CCMP */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA TKIP */  { OK, RSN_CIPHER_AES_CCMP, RSN_CIPHER_AES_CCMP ,6},
            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA CCMP */  { OK, RSN_CIPHER_AES_CCMP, RSN_CIPHER_AES_CCMP ,8},
            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
        /* AP multicast WEP */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA CCMP */  { OK,  RSN_CIPHER_AES_CCMP, RSN_CIPHER_WEP104 ,5},
            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}}},
/* AP unicast WEP104 */  {
        /* AP multicast NONE */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
        /* AP multicast WEP */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
        /* AP multicast TKIP */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
        /* AP multicast WRAP */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
        /* AP multicast CCMP */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
        /* AP multicast WEP104 */ {
            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}}}


};


/* PMKID cache */
/* static wpa2_pmkid_cache_t wpa2_pmkid_cache; */

/* Function prototypes */

TI_STATUS admCtrlWpa2_parseIe(admCtrl_t *pAdmCtrl, UINT8 *pWpa2Ie, wpa2IeData_t *pWpa2Data);
UINT16 admCtrlWpa2_buildCapabilities(admCtrl_t *pAdmCtrl);
UINT32  admCtrlWpa2_parseSuiteVal(admCtrl_t *pAdmCtrl, UINT8* suiteVal, UINT32 maxVal, UINT32 unknownVal);
TI_STATUS admCtrlWpa2_checkCipherSuiteValidity(cipherSuite_e unicastSuite, cipherSuite_e broadcastSuite, cipherSuite_e encryptionStatus);
TI_STATUS admCtrlWpa2_getCipherSuiteMetric (admCtrl_t *pAdmCtrl, wpa2IeData_t *pWpa2Data, UINT32 *metric, 
                                            cipherSuite_e *uSuite,  cipherSuite_e  *bSuite);
TI_STATUS admCtrlWpa2_DynamicConfig(admCtrl_t *pAdmCtrl, rsn_paeConfig_t *pPaeConfig);

TI_STATUS admCtrlWpa2_resetPMKIDCache(admCtrl_t *pAdmCtrl);
/*TI_STATUS admCtrlWpa2_sendPMKIDCandListAfterDelay(admCtrl_t * pAdmCtrl, UINT32 delay);*/
TI_STATUS admCtrlWpa2_getPMKIDList(admCtrl_t * pAdmCtrl,OS_802_11_PMKID *pmkidList);
TI_STATUS admCtrlWpa2_setPMKIDList(admCtrl_t * pAdmCtrl, OS_802_11_PMKID *pmkidList);

TI_STATUS admCtrlWpa2_addPMKID(admCtrl_t * pAdmCtrl, macAddress_t * pBSSID, pmkidValue_t pmkID);
TI_STATUS admCtrlWpa2_findPMKID(admCtrl_t * pAdmCtrl, macAddress_t *pBSSID, 
                                pmkidValue_t *pPMKID, UINT8  *cacheIndex);

static BOOL admCtrlWpa2_getPreAuthStatus(admCtrl_t *pAdmCtrl, macAddress_t *givenAP, UINT8  *cacheIndex);

static TI_STATUS admCtrlWpa2_startPreAuth(admCtrl_t *pAdmCtrl, bssidList4PreAuth_t *pBssidList);

static void admCtrlWpa2_buildAndSendPMKIDCandList(TI_HANDLE hHandle, bssidList4PreAuth_t *apList);

static TI_STATUS admCtrlWpa2_get802_1x_AkmExists (admCtrl_t *pAdmCtrl, BOOL *wpa_802_1x_AkmExists);

/**
*
* admCtrlWpa_config  - Configure EXC admission control.
*
* \b Description: 
*
* Configure EXC admission control.
*
* \b ARGS:
*
*  I   - pAdmCtrl - context \n
*  
* \b RETURNS:
*
*  OK on success, NOK on failure.
*
* \sa 
*/
TI_STATUS admCtrlWpa2_config(admCtrl_t *pAdmCtrl)
{
    TI_STATUS           status;
    rsn_paeConfig_t     paeConfig;

    /* check and set admission control default parameters */
    pAdmCtrl->authSuite =   RSN_AUTH_OPEN;
    if (pAdmCtrl->unicastSuite == RSN_CIPHER_NONE)
    {
        pAdmCtrl->unicastSuite = RSN_CIPHER_AES_CCMP;
    }
    if (pAdmCtrl->broadcastSuite == RSN_CIPHER_NONE)
    {
        pAdmCtrl->broadcastSuite = RSN_CIPHER_AES_CCMP;
    }

    /* set callback functions (API) */
    pAdmCtrl->getInfoElement = admCtrlWpa2_getInfoElement;
    pAdmCtrl->setSite  = admCtrlWpa2_setSite;
    pAdmCtrl->evalSite = admCtrlWpa2_evalSite;

    pAdmCtrl->getPmkidList      = admCtrlWpa2_getPMKIDList;
    pAdmCtrl->setPmkidList      = admCtrlWpa2_setPMKIDList;
    pAdmCtrl->resetPmkidList    = admCtrlWpa2_resetPMKIDCache;
    pAdmCtrl->getPreAuthStatus = admCtrlWpa2_getPreAuthStatus;
    pAdmCtrl->startPreAuth = admCtrlWpa2_startPreAuth;
    pAdmCtrl->get802_1x_AkmExists = admCtrlWpa2_get802_1x_AkmExists;

    /* set key management suite (AKMP) */
    switch (pAdmCtrl->externalAuthMode)
    {
    case RSN_EXT_AUTH_MODE_WPA2:
    case RSN_EXT_AUTH_MODE_WPA2PSK:
        pAdmCtrl->keyMngSuite = RSN_KEY_MNG_802_1X;
        break;
    case RSN_EXT_AUTH_MODE_WPANONE:
        pAdmCtrl->keyMngSuite = RSN_KEY_MNG_NONE;
        /* Not supported */
    default:
        return NOK;
    }


    paeConfig.authProtocol = pAdmCtrl->externalAuthMode;
    paeConfig.unicastSuite = pAdmCtrl->unicastSuite;
    paeConfig.broadcastSuite = pAdmCtrl->broadcastSuite;
    paeConfig.keyExchangeProtocol = pAdmCtrl->keyMngSuite;
    /* set default PAE configuration */
    status = pAdmCtrl->pRsn->setPaeConfig(pAdmCtrl->pRsn, &paeConfig);

    return status;
}


/**
*
* admCtrlWpa2_getInfoElement - Get the current information element.
*
* \b Description: 
*
* Get the current information element.
*
* \b ARGS:
*
*  I   - pAdmCtrl - context \n
*  I   - pIe - IE buffer \n
*  I   - pLength - length of IE \n
*  
* \b RETURNS:
*
*  OK on success, NOK on failure.
*
* \sa 
*/

TI_STATUS admCtrlWpa2_getInfoElement(admCtrl_t *pAdmCtrl, UINT8 *pIe, UINT8 *pLength)
{
    wpa2IePacket_t     *pWpa2IePacket;
    UINT8              length = 0;
    macAddress_t       assocBssid;
    paramInfo_t        param;
    pmkidValue_t       pmkId;
    TI_STATUS          status;
    UINT8              index;

    #ifdef FOUR_ALIGNMENT
	  UINT16				tempInt;
    #endif

    if (pIe==NULL)
    {
        *pLength = 0;
        return NOK;
    }

    /* check Group suite validity */
    if (!broadcastCipherSuiteValidity[pAdmCtrl->networkMode][pAdmCtrl->broadcastSuite])
    {
        *pLength = 0;
        return NOK;
    }

    /* Init Wpa2 IE (RSN IE) */
    pWpa2IePacket = (wpa2IePacket_t*)pIe;
    os_memoryZero(pAdmCtrl->hOs, pWpa2IePacket, sizeof(wpa2IePacket_t));


    /* Fill the element ID */
    pWpa2IePacket->elementid = RSN_IE_ID;


    #ifndef FOUR_ALIGNMENT
       pWpa2IePacket->version   = ENDIAN_HANDLE_WORD(WPA2_OUI_MAX_VERSION);
    #else 
      /* required for WinCe, when the pointer is not even */
      tempInt = ENDIAN_HANDLE_WORD(WPA2_OUI_MAX_VERSION);
      os_memoryCopy(pAdmCtrl->hOs, (UINT8 *)&pWpa2IePacket->version, &tempInt, sizeof(pWpa2IePacket->version));
    #endif
    length += 2;

    /* build group suite */
    os_memoryCopy(pAdmCtrl->hOs, (void *)pWpa2IePacket->groupSuite, wpa2IeOuiIe, 3);
    pWpa2IePacket->groupSuite[3] = (UINT8)pAdmCtrl->pRsn->paeConfig.broadcastSuite;
    length += 4;

    /* build pairwise suite - we always send only one pairwise suite */
    #ifndef FOUR_ALIGNMENT
      pWpa2IePacket->pairwiseSuiteCnt = ENDIAN_HANDLE_WORD(0x0001);
    #else
    /* required for WinCe, when the pointer is not even */
      tempInt = ENDIAN_HANDLE_WORD(0x0001);
      os_memoryCopy(pAdmCtrl->hOs, (UINT8 *)&pWpa2IePacket->pairwiseSuiteCnt, &tempInt, sizeof(pWpa2IePacket->pairwiseSuiteCnt));
    #endif

    length += 2;

    os_memoryCopy(pAdmCtrl->hOs, (void *)pWpa2IePacket->pairwiseSuite, wpa2IeOuiIe, 3);
    pWpa2IePacket->pairwiseSuite[3] = (UINT8)pAdmCtrl->pRsn->paeConfig.unicastSuite;
    length += 4;

    
    /* build keyMng suite - we always send only one key mgmt  suite*/
    #ifndef FOUR_ALIGNMENT
       pWpa2IePacket->authKeyMngSuiteCnt = ENDIAN_HANDLE_WORD(0x0001);
    #else
    /* required for WinCe, when the pointer is not even */
      tempInt = ENDIAN_HANDLE_WORD(0x0001);
      os_memoryCopy(pAdmCtrl->hOs, (UINT8 *)&pWpa2IePacket->authKeyMngSuiteCnt, &tempInt, sizeof(pWpa2IePacket->authKeyMngSuiteCnt));
    #endif
    
    length += 2;

    os_memoryCopy(pAdmCtrl->hOs, (void *)pWpa2IePacket->authKeyMngSuite, wpa2IeOuiIe, 3);
    
    switch (pAdmCtrl->externalAuthMode)
    {
    case RSN_EXT_AUTH_MODE_OPEN:
    case RSN_EXT_AUTH_MODE_SHARED_KEY:
    case RSN_EXT_AUTH_MODE_AUTO_SWITCH:
        pWpa2IePacket->authKeyMngSuite[3] = WPA2_IE_KEY_MNG_NONE;
        break;
    case RSN_EXT_AUTH_MODE_WPA2:
    case RSN_EXT_AUTH_MODE_WPA:   /* for Any-WPA/WPA-Mixed mode */
        {
#ifdef EXC_MODULE_INCLUDED
            UINT8   akmSuite[DOT11_OUI_LEN+1];

            if (admCtrlExc_getCckmAkm(pAdmCtrl, akmSuite))
            {
                os_memoryCopy(pAdmCtrl->hOs, (PVOID)pWpa2IePacket->authKeyMngSuite, akmSuite, DOT11_OUI_LEN+1);
            }
            else
#endif
            {
                pWpa2IePacket->authKeyMngSuite[3] = WPA2_IE_KEY_MNG_801_1X;
            }
        }
        break;
    case RSN_EXT_AUTH_MODE_WPA2PSK:
    case RSN_EXT_AUTH_MODE_WPAPSK:
        pWpa2IePacket->authKeyMngSuite[3] = WPA2_IE_KEY_MNG_PSK_801_1X;
        break;
    default:
        pWpa2IePacket->authKeyMngSuite[3] = WPA2_IE_KEY_MNG_NONE;
        break;
    }

    length += 4;
    
    /* build Capabilities */
    #ifndef FOUR_ALIGNMENT
       pWpa2IePacket->capabilities = ENDIAN_HANDLE_WORD(admCtrlWpa2_buildCapabilities(pAdmCtrl));
    #else
	/* required for WinCe, when the pointer is not even */
      tempInt = ENDIAN_HANDLE_WORD(admCtrlWpa2_buildCapabilities(pAdmCtrl));
      os_memoryCopy(pAdmCtrl->hOs, (UINT8 *)&pWpa2IePacket->capabilities, &tempInt, sizeof(pWpa2IePacket->capabilities));
    #endif
    
    length += 2;

    /* build PMKID list: we support no more than 1 PMKSA per AP, */
    /* so no more than 1 PMKID can be sent in the RSN IE         */
    if(pAdmCtrl->preAuthSupport && 
       (pAdmCtrl->pRsn->paeConfig.authProtocol == RSN_EXT_AUTH_MODE_WPA2))
    {
        /* Init value of PMKID count is 0 */
	#ifndef FOUR_ALIGNMENT
           pWpa2IePacket->pmkIdCnt = ENDIAN_HANDLE_WORD(0);
	#else
          /* required for WinCe, when the pointer is not even */
          tempInt = ENDIAN_HANDLE_WORD(0);
 	  os_memoryCopy(pAdmCtrl->hOs, (UINT8 *)&pWpa2IePacket->pmkIdCnt, &tempInt, sizeof(pWpa2IePacket->pmkIdCnt));
	#endif
        
        length += 2;

        param.paramType = CTRL_DATA_CURRENT_BSSID_PARAM;
        status          = ctrlData_getParam(pAdmCtrl->pRsn->hCtrlData, &param);

        assocBssid      = param.content.ctrlDataCurrentBSSID;

        WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
                                ("admCtrlWpa2_getInfoElement - find PMKID \n"));

        status = admCtrlWpa2_findPMKID(pAdmCtrl, &assocBssid, &pmkId, &index);
        if(status == OK)
        {
            WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
                                    ("admCtrlWpa2_getInfoElement - PMKID was found! \n"));

	#ifndef FOUR_ALIGNMENT
            pWpa2IePacket->pmkIdCnt = ENDIAN_HANDLE_WORD(1);
        #else
           /* required for WinCe, when the pointer is not even */
           tempInt = ENDIAN_HANDLE_WORD(1);
           os_memoryCopy(pAdmCtrl->hOs, (UINT8 *)&pWpa2IePacket->pmkIdCnt, &tempInt, sizeof(pWpa2IePacket->pmkIdCnt));
        #endif

            os_memoryCopy(pAdmCtrl->hOs, (UINT8 *)pWpa2IePacket->pmkId, 
                      (UINT8 *)pmkId, PMKID_VALUE_SIZE);

            length += PMKID_VALUE_SIZE;
        }
    }

    pWpa2IePacket->length = length;    /* RSN IE length without IEid and length field */
    *pLength              = length+2;  /* The whole length of the RSN IE */

    WLAN_REPORT_HEX_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
                                    pIe, *pLength);
    return OK;

}
/**
*
* admCtrlWpa2_setSite  - Set current primary site parameters for registration.
*
* \b Description: 
*
* Set current primary site parameters for registration.
*
* \b ARGS:
*
*  I   - pAdmCtrl - context \n
*  I   - pRsnData - site's RSN data \n
*  O   - pAssocIe - result IE of evaluation \n
*  O   - pAssocIeLen - length of result IE of evaluation \n
*  
* \b RETURNS:
*
*  OK on site is aproved, NOK on site is rejected.
*
* \sa 
*/
TI_STATUS admCtrlWpa2_setSite(admCtrl_t *pAdmCtrl, rsnData_t *pRsnData, UINT8 *pAssocIe, UINT8 *pAssocIeLen)
{
    TI_STATUS               status;
    rsn_paeConfig_t         paeConfig;
    UINT8                   *pWpa2Ie;
    cipherSuite_e           uSuite, bSuite;


    *pAssocIeLen = 0;

    if (pRsnData==NULL)
    {
        return NOK;
    }
    if (pRsnData->pIe==NULL)
    {
        /* configure the MLME module with the 802.11 OPEN authentication suite, 
            THe MLME will configure later the authentication module */
        param.paramType = MLME_LEGACY_TYPE_PARAM;
        param.content.mlmeLegacyAuthType = AUTH_LEGACY_OPEN_SYSTEM;
        status = mlme_setParam(pAdmCtrl->hMlme, &param);
        if (status != OK)
        {
            return status;
        }

        return OK;
    }

#ifdef EXC_MODULE_INCLUDED
    /* Clean MIC and KP flags in the HAL.                */
    /* It is needed if the previous privacy mode was EXC */
    whalParam.paramType = HAL_CTRL_RSN_EXC_SW_ENC_ENABLE_PARAM; 
    whalParam.content.rsnExcSwEncFlag = FALSE;
    status = whalCtrl_SetParam(pAdmCtrl->pRsn->hWhalCtrl, &whalParam);

    whalParam.paramType = HAL_CTRL_RSN_EXC_MIC_FIELD_ENABLE_PARAM; 
    whalParam.content.rsnExcMicFieldFlag = FALSE;
    status = whalCtrl_SetParam(pAdmCtrl->pRsn->hWhalCtrl, &whalParam);

    /* Check if Aironet IE exists */
    admCtrlExc_setExtendedParams(pAdmCtrl, pRsnData);

#endif /*EXC_MODULE_INCLUDED*/
    
    status = admCtrl_parseIe(pAdmCtrl, pRsnData, &pWpa2Ie, RSN_IE_ID);
    if (status != OK)                                                         
    {                                                                                    
        return status;                                                        
    }
    WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
                            ("admCtrlWpa2_setSite: RSN_IE=\n"));
    WLAN_REPORT_HEX_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, pRsnData->pIe, pRsnData->ieLen);
    status = admCtrlWpa2_parseIe(pAdmCtrl, pWpa2Ie, &wpa2DataIE);
    if (status != OK)
    {
        return status;
    }
    if ((wpa2DataIE.unicastSuite[0]>=MAX_WPA2_CIPHER_SUITE) ||
        (wpa2DataIE.broadcastSuite>=MAX_WPA2_CIPHER_SUITE) ||
        (pAdmCtrl->unicastSuite>=MAX_WPA2_CIPHER_SUITE))
    {
        return NOK;
    }
    /* Check validity of Group suite */
    if (!broadcastCipherSuiteValidity[pAdmCtrl->networkMode][wpa2DataIE.broadcastSuite])
    {   /* check Group suite validity */                                          
        return NOK;
    }

    
    if(admCtrlWpa2_getCipherSuiteMetric (pAdmCtrl, &wpa2DataIE, NULL, &uSuite, &bSuite) != OK)
        return NOK;

    /* set replay counter */
    pAdmCtrl->replayCnt = wpa2DataIE.ptkReplayCounters;

    *pAssocIeLen = pRsnData->ieLen;
    if (pAssocIe != NULL)
    {
        os_memoryCopy(pAdmCtrl->hOs, pAssocIe, &wpa2DataIE, sizeof(wpa2IeData_t));
    }

    /* re-config PAE with updated unicast and broadcast suite values            */
    /* If STA works in WpaMixed mode/AnyWpa mode, set PAE auth. mode to WPA2    */
    paeConfig.authProtocol = pAdmCtrl->externalAuthMode;

    if(pAdmCtrl->WPAPromoteFlags)
    {
       if(pAdmCtrl->externalAuthMode == RSN_EXT_AUTH_MODE_WPA)
          paeConfig.authProtocol   = RSN_EXT_AUTH_MODE_WPA2;
       if(pAdmCtrl->externalAuthMode == RSN_EXT_AUTH_MODE_WPAPSK)
          paeConfig.authProtocol   = RSN_EXT_AUTH_MODE_WPA2PSK;
    }


#ifdef EXC_MODULE_INCLUDED
    param.paramType = EXC_CCKM_EXISTS;
    param.content.excCckmExists = (wpa2Data.KeyMngSuite[0]==WPA2_IE_KEY_MNG_CCKM) ? TRUE : FALSE;
    excMngr_setParam(pAdmCtrl->hExcMngr, &param);
#endif


    paeConfig.keyExchangeProtocol = pAdmCtrl->keyMngSuite;
    paeConfig.unicastSuite        = uSuite;    /* Updated value */
    paeConfig.broadcastSuite      = bSuite;    /* Updated value */
    status = admCtrlWpa2_DynamicConfig(pAdmCtrl, &paeConfig);

    if (status != OK)
    {
        return status;
    }

    /* Now we configure the MLME module with the 802.11 legacy authentication suite, 
        THe MLME will configure later the authentication module */
    param.paramType = MLME_LEGACY_TYPE_PARAM;
#ifdef EXC_MODULE_INCLUDED
    if (pAdmCtrl->networkEapMode!=OS_EXC_NETWORK_EAP_OFF)
    {
        param.content.mlmeLegacyAuthType = AUTH_LEGACY_RESERVED1;
    }
    else
#endif
    {
        param.content.mlmeLegacyAuthType = AUTH_LEGACY_OPEN_SYSTEM;
    }
    status = mlme_setParam(pAdmCtrl->hMlme, &param);
    if (status != OK)
    {
        return status;
    }

    param.paramType = RX_DATA_EAPOL_DESTINATION_PARAM;
    param.content.rxDataEapolDestination = OS_ABS_LAYER;
    status = rxData_setParam(pAdmCtrl->hRx, &param);
    if (status != OK)
    {
        return status;
    }

    /* Configure privacy status in HAL so that HW is prepared to recieve keys */
    whalParam.paramType = HAL_CTRL_RSN_SECURITY_MODE_PARAM;
    whalParam.content.rsnEncryptionStatus = (halCtrl_CipherSuite_e)paeConfig.unicastSuite;
    status = whalCtrl_SetParam(pAdmCtrl->pRsn->hWhalCtrl, &whalParam);

    return status;
}

/**
*
* admCtrlWpa_evalSite  - Evaluate site for registration.
*
* \b Description: 
*
* evaluate site RSN capabilities against the station's cap.
* If the BSS type is infrastructure, the station matches the site only if it's WEP status is same as the site
* In IBSS, it does not matter
*
* \b ARGS:
*
*  I   - pAdmCtrl - Context \n
*  I   - pRsnData - site's RSN data \n
*  O   - pEvaluation - Result of evaluation \n
*  
* \b RETURNS:
*
*  OK 
*
* \sa 
*/
TI_STATUS admCtrlWpa2_evalSite(admCtrl_t *pAdmCtrl, rsnData_t *pRsnData, bssType_e bssType, UINT32 *pEvaluation)
{
    TI_STATUS               status;
    wpa2IeData_t            wpa2Data;
    UINT8                   *pWpa2Ie;
    cipherSuite_e           uSuite, bSuite; 
    UINT8                   i = 0;


    *pEvaluation = 0;

    if (pRsnData==NULL)
    {
        return NOK;
    }
    if (pRsnData->pIe==NULL)
    {
        return NOK;
    }
    
    if (bssType != BSS_INFRASTRUCTURE)
    {
        return NOK;
    }

    status = admCtrl_parseIe(pAdmCtrl, pRsnData, &pWpa2Ie, RSN_IE_ID);
    if (status != OK)                                                         
    {                                                                                    
        return status;                                                        
    }
    WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
                            ("admCtrlWpa2_evalSite, IE=\n"));

    WLAN_REPORT_HEX_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, pRsnData->pIe, pRsnData->ieLen);

    status = admCtrlWpa2_parseIe(pAdmCtrl, pWpa2Ie, &wpa2Data);
    if (status != OK)
    {
        return status;
    }

    /* check keyMngSuite validity */
    status = NOK;
    for(i = 0; 
       (i < wpa2Data.KeyMngSuiteCnt) &&(i<MAX_WPA2_KEY_MNG_SUITES)&& (status != OK);
        i++)
    {
       switch (wpa2Data.KeyMngSuite[i])
       {
          case WPA2_IE_KEY_MNG_NONE:
              status = (pAdmCtrl->externalAuthMode <= RSN_EXT_AUTH_MODE_AUTO_SWITCH) ? OK : NOK;
              break;
          case WPA2_IE_KEY_MNG_801_1X:
#ifdef EXC_MODULE_INCLUDED
          case WPA2_IE_KEY_MNG_CCKM:
                /* CCKM is allowed only in 802.1x auth */
#endif

              if(!pAdmCtrl->WPAPromoteFlags)
               status = (pAdmCtrl->externalAuthMode == RSN_EXT_AUTH_MODE_WPA2) ? OK : NOK;
              else
                 /* Any-WPA mode is supported */
                 status = ((pAdmCtrl->externalAuthMode == RSN_EXT_AUTH_MODE_WPA2) ||
                        (pAdmCtrl->externalAuthMode == RSN_EXT_AUTH_MODE_WPA)) ? OK : NOK;
              break;
          case WPA2_IE_KEY_MNG_PSK_801_1X:
             if(!pAdmCtrl->WPAPromoteFlags)
                 status = (pAdmCtrl->externalAuthMode == RSN_EXT_AUTH_MODE_WPA2PSK) ? OK : NOK;
             else
                 /* Any-WPA mode is supported */
                status = ((pAdmCtrl->externalAuthMode == RSN_EXT_AUTH_MODE_WPA2PSK) ||
                       (pAdmCtrl->externalAuthMode == RSN_EXT_AUTH_MODE_WPAPSK)) ? OK : NOK;
             break;
       default:
           WLAN_REPORT_ERROR(pAdmCtrl->hReport, RSN_MODULE_LOG, 
                            ("admCtrlWpa2_evalSite, default, wpa2Data.KeyMngSuite[i]=%d \n",wpa2Data.KeyMngSuite[i]));
             status = NOK;
             break;
       }
    }

    if (status != OK)
    {
        WLAN_REPORT_ERROR(pAdmCtrl->hReport, RSN_MODULE_LOG, 
                         ("admCtrlWpa2_evalSite, status=%d, externalAuthMode=%d, WPAPromoteFlags=%d \n", 
                          status, pAdmCtrl->externalAuthMode,
                          pAdmCtrl->WPAPromoteFlags));
        return status;
    }

    /* Check cipher suite validity */
    if(admCtrlWpa2_getCipherSuiteMetric(pAdmCtrl, &wpa2Data, pEvaluation, &uSuite, &bSuite) != OK)
        return NOK;

    /* Check privacy bit if not in mixed mode */
    if (!pAdmCtrl->mixedMode)
    {   /* There's no mixed mode, so make sure that the privacy Bit matches the privacy mode*/
        if (((pRsnData->privacy) && (uSuite == RSN_CIPHER_NONE)) ||
            ((!pRsnData->privacy) && (uSuite > RSN_CIPHER_NONE)))
        {
            *pEvaluation = 0;
            WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
                             ("admCtrlWpa2_evalSite, mixedMode is FALSE, privacy=%d, uSuite=%d\n",
                              pRsnData->privacy, uSuite));
            return NOK;
        }
    }

    /* always return OK */
    return OK;
}


/**
*
* admCtrlWpa2_parseIe  - Parse an WPA information element.
*
* \b Description: 
*
* Parse an WPA information element. 
* Builds a structure of the unicast adn broadcast cihper suites,
* the key management suite and the capabilities.
*
* \b ARGS:
*
*  I   - pAdmCtrl - pointer to admCtrl context
*  I   - pWpa2Ie  - pointer to WPA IE (RSN IE) buffer  \n
*  O   - pWpa2Data - WPA2 IE (RSN IE) structure after parsing
*  
*  
* \b RETURNS:
*
* OK on success, NOK on failure. 
*
* \sa 
*/
TI_STATUS admCtrlWpa2_parseIe(admCtrl_t *pAdmCtrl, UINT8 *pWpa2Ie, wpa2IeData_t *pWpa2Data)
{
    dot11_RSN_t      *wpa2Ie       =  (dot11_RSN_t *)pWpa2Ie;
    UINT16            temp2bytes, capabilities;
    UINT16 KeyMngSuiteCntTemp=0;
    UINT8             dataOffset = 0, i = 0, j = 0, curKeyMngSuite = 0;
    cipherSuite_e     curCipherSuite = RSN_CIPHER_NONE;

    WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
                            ("Wpa2_IE: DEBUG: admCtrlWpa2_parseIe\n\n"));

    if ((pWpa2Data == NULL) || (pWpa2Ie == NULL))
    {
        return NOK;
    }

    /* get Version value from the info element */
    temp2bytes = ENDIAN_HANDLE_WORD(*wpa2Ie->rsnIeData);
    dataOffset += 2;

    /* Check the header fields and the version */
    if((wpa2Ie->hdr.eleId != RSN_IE_ID) || (wpa2Ie->hdr.eleLen < WPA2_IE_MIN_LENGTH) ||
       (temp2bytes != WPA2_OUI_MAX_VERSION))
    {
        WLAN_REPORT_ERROR(pAdmCtrl->hReport, RSN_MODULE_LOG, 
           ("Wpa2_ParseIe Error: length=0x%x, elementid=0x%x, version=0x%x\n", 
             wpa2Ie->hdr.eleLen,wpa2Ie->hdr.eleId,temp2bytes));

        return NOK; 
    }


    /* Set default values */
    os_memoryZero(pAdmCtrl->hOs, pWpa2Data, sizeof(wpa2IeData_t));

    pWpa2Data->broadcastSuite = RSN_CIPHER_AES_CCMP;
    pWpa2Data->unicastSuiteCnt = 1;
    pWpa2Data->unicastSuite[0] = RSN_CIPHER_AES_CCMP;
    pWpa2Data->KeyMngSuiteCnt = 1;
    pWpa2Data->KeyMngSuite[0] = WPA2_IE_KEY_MNG_801_1X;

    /* If we've reached the end of the received RSN IE */
    if(wpa2Ie->hdr.eleLen < WPA2_IE_GROUP_SUITE_LENGTH)
        return OK;
    
    /* Processing of Group Suite field - 4 bytes*/
    pWpa2Data->broadcastSuite = (cipherSuite_e)admCtrlWpa2_parseSuiteVal(pAdmCtrl, (UINT8 *)wpa2Ie->rsnIeData + dataOffset,
                                                          RSN_CIPHER_WEP104, RSN_CIPHER_UNKNOWN);
    dataOffset +=4;
    WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
           ("Wpa2_IE: GroupSuite %x \n", pWpa2Data->broadcastSuite));


    /* Processing of Pairwise (Unicast) Cipher Suite - 2 bytes counter and list of 4-byte entries */
    if(wpa2Ie->hdr.eleLen < WPA2_IE_MIN_PAIRWISE_SUITE_LENGTH)
        return OK;

    pWpa2Data->unicastSuiteCnt = ENDIAN_HANDLE_WORD(*(wpa2Ie->rsnIeData + dataOffset));
    dataOffset += 2;

    if(pWpa2Data->unicastSuiteCnt > UNICAST_CIPHER_MAXNO_IN_RSNIE)
    {
        /* something wrong in the RSN IE */
        WLAN_REPORT_ERROR(pAdmCtrl->hReport, RSN_MODULE_LOG, 
           ("Wpa2_ParseIe Error: Pairwise cipher suite count is  %d \n", pWpa2Data->unicastSuiteCnt));
        return NOK;
    }

    /* Get unicast cipher suites */
    for(i = 0; i < pWpa2Data->unicastSuiteCnt; i++)
    {
        curCipherSuite = (cipherSuite_e)admCtrlWpa2_parseSuiteVal(pAdmCtrl, (UINT8 *)wpa2Ie->rsnIeData + dataOffset, 
                                                   RSN_CIPHER_WEP104, RSN_CIPHER_UNKNOWN);
        if(curCipherSuite == RSN_CIPHER_NONE)
            curCipherSuite = pWpa2Data->broadcastSuite;

        pWpa2Data->unicastSuite[i] = curCipherSuite;
        dataOffset +=4;

        WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
                               ("Wpa_IE: unicast suite %x \n", curCipherSuite));
    }

    /* Sort all the unicast suites supported by the AP in the decreasing order */
    /* (so the best cipher suite will be the first)                            */
    if(pWpa2Data->unicastSuiteCnt > 1)
    {
       for(i = 0; i < (pWpa2Data->unicastSuiteCnt -1); i ++)
       {
           for(j = 0; j < i; j ++)
           {
               if(pWpa2Data->unicastSuite[j] > pWpa2Data->unicastSuite[j + 1])
               {
                   curCipherSuite               = pWpa2Data->unicastSuite[j];
                   pWpa2Data->unicastSuite[j]   = pWpa2Data->unicastSuite[j+1];
                   pWpa2Data->unicastSuite[j+1] = curCipherSuite;
               }
           }
       }
    }

    /* If we've reached the end of the received RSN IE */
    if (wpa2Ie->hdr.eleLen == dataOffset)
        return OK;

     /* KeyMng Suite */
/*     pWpa2Data->KeyMngSuiteCnt = ENDIAN_HANDLE_WORD(*((UINT16 *)(wpa2Ie->rsnIeData + dataOffset))); */

     /*Fixing unaligned half word access */

     COPY_UNALIGNED_WORD(&KeyMngSuiteCntTemp,((UINT16 *)(wpa2Ie->rsnIeData + dataOffset)));
     KeyMngSuiteCntTemp = ENDIAN_HANDLE_WORD(KeyMngSuiteCntTemp);
     TI_WLAN_COPY_UINT16_UNALIGNED(pWpa2Data->KeyMngSuiteCnt, KeyMngSuiteCntTemp);


     dataOffset += 2;
     pAdmCtrl->wpaAkmExists = FALSE;
     for(i = 0; i < pWpa2Data->KeyMngSuiteCnt; i++)
     {
#ifdef EXC_MODULE_INCLUDED
            curKeyMngSuite = admCtrlExc_parseCckmSuiteVal4Wpa2(pAdmCtrl, (UINT8 *)(wpa2Ie->rsnIeData + dataOffset));
            if (curKeyMngSuite == WPA2_IE_KEY_MNG_CCKM)
            {  /* CCKM is the maximum AKM */
                pWpa2Data->KeyMngSuite[i] = curKeyMngSuite;
            }
            else
#endif
            {
                curKeyMngSuite = admCtrlWpa2_parseSuiteVal(pAdmCtrl, (UINT8 *)wpa2Ie->rsnIeData + dataOffset, 
                            WPA2_IE_KEY_MNG_PSK_801_1X, WPA2_IE_KEY_MNG_NA);
            }


        WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
           ("Wpa2_IE: authKeyMng %x  \n", curKeyMngSuite));

         if ((curKeyMngSuite != WPA2_IE_KEY_MNG_NA) && 
             (curKeyMngSuite != WPA2_IE_KEY_MNG_CCKM))
         {
             pWpa2Data->KeyMngSuite[i] = curKeyMngSuite;
         }

         if (curKeyMngSuite==WPA2_IE_KEY_MNG_801_1X)
         {   /* If 2 AKM exist, save also the second priority */
             pAdmCtrl->wpaAkmExists = TRUE;
         }

         dataOffset += 4;
     }

    /* If we've reached the end of the received RSN IE */
    if (wpa2Ie->hdr.eleLen == dataOffset)
        return OK;

    /* Parse capabilities */

/*    capabilities = ENDIAN_HANDLE_WORD(*((UINT16 *)(wpa2Ie->rsnIeData + dataOffset))); */

   /* Fixing unaligned half word access */

    COPY_UNALIGNED_WORD(&capabilities,((UINT16 *)(wpa2Ie->rsnIeData + dataOffset)));
    capabilities = ENDIAN_HANDLE_WORD(capabilities);


    pWpa2Data->bcastForUnicatst  = (UINT8)(capabilities & WPA2_GROUP_4_UNICAST_CAPABILITY_MASK)>> 
                                           WPA2_GROUP_4_UNICAST_CAPABILITY_SHIFT;
    pWpa2Data->ptkReplayCounters = (UINT8)(capabilities &  WPA2_PTK_REPLAY_COUNTERS_CAPABILITY_MASK)>> 
                                           WPA2_PTK_REPLAY_COUNTERS_CAPABILITY_SHIFT;

    switch (pWpa2Data->ptkReplayCounters)
    {
    case 0: pWpa2Data->ptkReplayCounters=1;
            break;
    case 1: pWpa2Data->ptkReplayCounters=2;
            break;
    case 2: pWpa2Data->ptkReplayCounters=4;
            break;
    case 3: pWpa2Data->ptkReplayCounters=16;
            break;
    default: pWpa2Data->ptkReplayCounters=1;
            break;
   }
   pWpa2Data->gtkReplayCounters = (UINT8)(capabilities & 
                                        WPA2_GTK_REPLAY_COUNTERS_CAPABILITY_MASK) >> 
                                        WPA2_GTK_REPLAY_COUNTERS_CAPABILITY_SHIFT;
   switch (pWpa2Data->gtkReplayCounters)
   {
   case 0: pWpa2Data->gtkReplayCounters=1;
            break;
   case 1: pWpa2Data->gtkReplayCounters=2;
            break;
   case 2: pWpa2Data->gtkReplayCounters=4;
            break;
   case 3: pWpa2Data->gtkReplayCounters=16;
            break;
   default: pWpa2Data->gtkReplayCounters=1;
            break;
   }

   pWpa2Data->preAuthentication = (UINT8)(capabilities & WPA2_PRE_AUTH_CAPABILITY_MASK);

   WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
                                ("Wpa2_IE: capabilities %x, preAuthentication = %x, bcastForUnicatst %x, ptk = %x, gtk = %x\n", 
                                 capabilities, pWpa2Data->preAuthentication,
                                 pWpa2Data->bcastForUnicatst, pWpa2Data->ptkReplayCounters,
                                 pWpa2Data->gtkReplayCounters));

    return OK;

}


UINT16 admCtrlWpa2_buildCapabilities(admCtrl_t *pAdmCtrl)
{
   UINT16 capabilities = 0;
   UINT16 replayCnt;


   /* Bit 0 - Pre-authentication is set to 0             */
   /* when RSN IE is sent from a STA (in assoc request)  */

   /* Bit1: group key for unicast is set to 0*/

   /* Bits 2&3: PTKSA Replay counter; bits 4&5 GTKSA replay Counters */
   switch (pAdmCtrl->replayCnt)
   {
   case 1:  replayCnt=0;
       break;
   case 2:  replayCnt=1;
       break;
   case 4:  replayCnt=2;
       break;
   case 16: replayCnt=3;
       break;
   default: replayCnt=0;
       break;
   }

   capabilities |= replayCnt << WPA2_PTK_REPLAY_COUNTERS_CAPABILITY_SHIFT;
   capabilities |= replayCnt << WPA2_GTK_REPLAY_COUNTERS_CAPABILITY_SHIFT;

   return   capabilities;

}


UINT32  admCtrlWpa2_parseSuiteVal(admCtrl_t *pAdmCtrl, UINT8* suiteVal, UINT32 maxVal, UINT32 unknownVal)
{
    UINT32  suite;

    if ((pAdmCtrl==NULL) || (suiteVal==NULL))
    {
        return RSN_CIPHER_UNKNOWN;
    }
    if (!os_memoryCompare(pAdmCtrl->hOs, suiteVal, wpa2IeOuiIe, 3))
    {
        suite =  (cipherSuite_e)((suiteVal[3]<=maxVal) ? suiteVal[3] : unknownVal); 
    } else
    {
        suite = unknownVal;
    }
    return  suite;

}


TI_STATUS admCtrlWpa2_checkCipherSuiteValidity (cipherSuite_e unicastSuite, cipherSuite_e broadcastSuite, cipherSuite_e encryptionStatus)
{
    cipherSuite_e maxCipher;

    maxCipher = (unicastSuite>=broadcastSuite) ? unicastSuite : broadcastSuite ;
    if (maxCipher != encryptionStatus)
    {
        return NOK;
    }
    if ((unicastSuite != RSN_CIPHER_NONE) && (broadcastSuite>unicastSuite))
    {
        return NOK;
    }
    return OK;
}

TI_STATUS admCtrlWpa2_getCipherSuiteMetric (admCtrl_t *pAdmCtrl, wpa2IeData_t *pWpa2Data, UINT32 *metric, 
                                            cipherSuite_e *uSuite, cipherSuite_e  *bSuite)
{
   cipherSuite_e   encryption   = RSN_CIPHER_NONE;
   cipherSuite_e   unicastSuite = RSN_CIPHER_NONE, brdcstSuite = RSN_CIPHER_NONE;
   admCtrlWpa2_validity_t  admCtrlWpa2_validity;
   UINT32     maxMetric = 0, index = 0;
   TI_STATUS  status = NOK;

   /* Set admCtrlWpa2_validity initial values */
   admCtrlWpa2_validity = admCtrlWpa2_validityTable[RSN_CIPHER_NONE][RSN_CIPHER_NONE][RSN_CIPHER_NONE];

   /* Check validity of configured encryption (cipher) and validity of */
   /* promoted cipher (in case of AnyWPA (WPAmixed mode))              */
   pAdmCtrl->getCipherSuite(pAdmCtrl, &encryption);
   WLAN_REPORT_INFORMATION (pAdmCtrl->hReport, RSN_MODULE_LOG, 
                               ("admCtrlWpa2_getCipherSuiteMetric, encryption=%d\n", encryption));

   while(encryption != RSN_CIPHER_NONE) 
   {
      for (index=0; index<pWpa2Data->unicastSuiteCnt; index++)
      {
          admCtrlWpa2_validity = 
          admCtrlWpa2_validityTable[pWpa2Data->unicastSuite[index]][pWpa2Data->broadcastSuite][encryption];
          if (admCtrlWpa2_validity.status == OK)
          {
              WLAN_REPORT_INFORMATION (pAdmCtrl->hReport, RSN_MODULE_LOG, 
                                          ("admCtrlWpa2_getCipherSuiteMetric, break: validity.evaluation=%d\n", 
                                           admCtrlWpa2_validity.evaluation));
              break;
          }
      }

      if ((admCtrlWpa2_validity.status == OK) && (admCtrlWpa2_validity.evaluation > maxMetric))
      {
          WLAN_REPORT_INFORMATION (pAdmCtrl->hReport, RSN_MODULE_LOG, 
                                      ("admCtrlWpa2_getCipherSuiteMetric, validity.evaluation=%d, maxMetric=%d\n", 
                                       admCtrlWpa2_validity.evaluation, maxMetric));

          maxMetric       = admCtrlWpa2_validity.evaluation;
          status          = admCtrlWpa2_validity.status;
          unicastSuite    = admCtrlWpa2_validity.unicast;
          brdcstSuite     = admCtrlWpa2_validity.broadcast;
      }

      if((pAdmCtrl->WPAPromoteFlags & ADMCTRL_WPA_OPTION_ENABLE_PROMOTE_CIPHER) &&
         (encryption != RSN_CIPHER_AES_CCMP))
         encryption = RSN_CIPHER_AES_CCMP;
      else
         encryption = RSN_CIPHER_NONE;

    }  /* End of "while encryption" stmt */

   if(metric)
      *metric = maxMetric;

   if(uSuite)
      *uSuite = unicastSuite;

   if(bSuite)
      *bSuite = brdcstSuite;

    return status;
}


/**
*
* admCtrlWpa2_DynamicConfig  - Dynamic setting of WPA2 config parameters.
*
* \b Description: 
*
*   Sets  WPA2 callback procedures and PAE configuration parameters.
*   This procedure is similar to admCtrlWpa2_Config procedure.
*   The main difference is that admCtrlWpa2_Config sets the DEFAULT VALUES
*   of the configuration parameters and so it should be called during
*   initialization of the driver code or when Auth mode or Encryption status
*   parameters are beeing set.
*   admCtrlWpa2_DynamicConfig set the updated values of WPA2 configuration  
*   parameters which gets after negotiation with an AP. So the procedure 
*   should be called during setSite stage.
*   
* \b ARGS:
*
*  I   - pAdmCtrl    - pointer to admCtrl context
*  I   - pPaeConfig  - pointer to PAE structure
*
* \b RETURNS:
*
* OK on success, NOK on failure. 
*
* \sa 
*/

TI_STATUS admCtrlWpa2_DynamicConfig(admCtrl_t *pAdmCtrl, rsn_paeConfig_t *pPaeConfig)
{
    TI_STATUS status = OK;

    /* Set those WPA2 params and callback procedures used after setSite stage */
    pAdmCtrl->getInfoElement = admCtrlWpa2_getInfoElement;

    pAdmCtrl->getPmkidList      = admCtrlWpa2_getPMKIDList;
    pAdmCtrl->setPmkidList      = admCtrlWpa2_setPMKIDList;
    pAdmCtrl->resetPmkidList    = admCtrlWpa2_resetPMKIDCache;
    pAdmCtrl->getPreAuthStatus = admCtrlWpa2_getPreAuthStatus;
    pAdmCtrl->startPreAuth = admCtrlWpa2_startPreAuth;

    /* set key management suite */
    switch (pAdmCtrl->externalAuthMode)
    {
    case RSN_EXT_AUTH_MODE_WPA2:
    case RSN_EXT_AUTH_MODE_WPA2PSK:
        pAdmCtrl->keyMngSuite = RSN_KEY_MNG_802_1X;
        break;
    case RSN_EXT_AUTH_MODE_WPA:  /* It is any-WPA (WPA-mixed mode ) */
    case RSN_EXT_AUTH_MODE_WPAPSK:
        pAdmCtrl->keyMngSuite = RSN_KEY_MNG_802_1X;
        break;
    case RSN_EXT_AUTH_MODE_WPANONE:
        pAdmCtrl->keyMngSuite = RSN_KEY_MNG_NONE;
        /* Not supported */
    default:
        return NOK;
    }

    /* Config PAE (if needed) */
    if(pPaeConfig)
       status = pAdmCtrl->pRsn->setPaeConfig(pAdmCtrl->pRsn, pPaeConfig);

    return status;
}




/**
*
* admCtrlWpa2_findPMKID 
*
* \b Description: 
*
* Retrieve an AP's PMKID (if exist)

* \b ARGS:
*
*  I   - pAdmCtrl - pointer to admCtrl context
*  I   - pBSSID   - pointer to AP's BSSID address 
*  O   - pmkID    - pointer to AP's PMKID (if it is NULL ptr, only
*                   cache index will be returned to the caller)
*  O   - cacheIndex  - index of the cache table entry containing the 
                       bssid
*  
* \b RETURNS:
*
* OK on success, NOK on failure. 
*
* \sa 
*/
TI_STATUS admCtrlWpa2_findPMKID (admCtrl_t * pAdmCtrl, macAddress_t *pBSSID, 
                                 pmkidValue_t *pPMKID, UINT8  *cacheIndex)
{

    UINT8           i     = 0;
    BOOL            found = FALSE;
    macAddress_t    entryMac;
    TI_STATUS       status = NOK;

    while(!found && (i < ADMCTRL_PMKID_CACHE_SIZE) && 
                    (i <= pAdmCtrl->pmkid_cache.entriesNumber))
    {
        entryMac = pAdmCtrl->pmkid_cache.pmkidTbl[i].bssId;
        if(MAC_EQUAL ((&entryMac),pBSSID))
        {
            found       = TRUE;
            *cacheIndex = i;
            if(pPMKID)
            {
               os_memoryCopy(pAdmCtrl->hOs, (PVOID)pPMKID,
                             pAdmCtrl->pmkid_cache.pmkidTbl[i].pmkId, 
                             PMKID_VALUE_SIZE);
            }
        }
        i++;
    }

    if(found)
        status = OK;

    return status;

}


/**
*
* admCtrlWpa2_getPMKIDList 
*
* \b Description: 
*
* Returns content of the PMKID cache 
*
* \b ARGS:
*
*  I   - pAdmCtrl        - pointer to admCtrl context
*  O   - pmkidList       - memory buffer where the procedure writes the PMKIDs
*                          Supplied by the caller procedure. .
*  
* \b RETURNS:
*
* OK on success, NOK on failure. 
*
* \sa 
*/
TI_STATUS admCtrlWpa2_getPMKIDList (admCtrl_t * pAdmCtrl,OS_802_11_PMKID *pmkidList)
{

    UINT8   neededLength, i = 0;
    UINT8   NumOfEntries = pAdmCtrl->pmkid_cache.entriesNumber;
    UINT8   *bssid, *pmkid;

    if(!pAdmCtrl->preAuthSupport)
        return PARAM_NOT_SUPPORTED;

    /* Check the buffer length */
    if(NumOfEntries > 1)
       neededLength = 30 + ((NumOfEntries - 1) * (MAC_ADDR_LEN + PMKID_VALUE_SIZE));
    else
       neededLength = 30;

    if(neededLength > pmkidList->Length)
    {
        /* The buffer length is not enough */
        pmkidList->Length = neededLength;
        return NOK;
    }

    /* The buffer is big enough. Fill the info */
    pmkidList->Length         = neededLength;
    pmkidList->BSSIDInfoCount = NumOfEntries;

    WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG,
      ("RSN:  Get PMKID cache.  Number of entries  = %d \n", NumOfEntries));

    for (i = 0; i < NumOfEntries; i++ )
    {
        bssid = (UINT8 *) pAdmCtrl->pmkid_cache.pmkidTbl[i].bssId.addr;
        pmkid = (UINT8 *)pAdmCtrl->pmkid_cache.pmkidTbl[i].pmkId;

        os_memoryCopy(pAdmCtrl->hOs, (void *)pmkidList->osBSSIDInfo[i].BSSID,
                      &bssid, MAC_ADDR_LEN);

        os_memoryCopy(pAdmCtrl->hOs,(void *)pmkidList->osBSSIDInfo[i].PMKID,
                      &pmkid, PMKID_VALUE_SIZE);

        WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG,
        ("RSN:  BSSID:  %.2X-%.2X-%.2X-%.2X-%.2X-%.2X   PMKID: %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X  \n",
           bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5],
           pmkid[0], pmkid[1], pmkid[2], pmkid[3],
           pmkid[4], pmkid[5], pmkid[6], pmkid[7],
           pmkid[8], pmkid[9], pmkid[10],pmkid[11],
           pmkid[12],pmkid[13],pmkid[14],pmkid[15]));
    }

    return OK;

}

/**
*
* admCtrlWpa2_addPMKID 
*
* \b Description: 
*
* Add/Set an AP's PMKID received from the Supplicant 
*
* \b ARGS:
*
*  I   - pAdmCtrl - pointer to admCtrl context
*  I   - pBSSID   - pointer to AP's BSSID address 
*  I   - pmkID    - AP's PMKID
*  
* \b RETURNS:
*
* OK on success, NOK on failure. 
*
* \sa 
*/
TI_STATUS admCtrlWpa2_addPMKID (admCtrl_t * pAdmCtrl, macAddress_t *pBSSID, pmkidValue_t pmkID)
{
   UINT8         cacheIndex;
   TI_STATUS     status = NOK;

   /* Try to find the pBSSId in the PMKID cache */
   status = admCtrlWpa2_findPMKID (pAdmCtrl, pBSSID, NULL, &cacheIndex);

   if(status == OK)
   {
       /* Entry for the bssid has been found; Update PMKID */
       os_memoryCopy(pAdmCtrl->hOs, 
                    (PVOID)&pAdmCtrl->pmkid_cache.pmkidTbl[cacheIndex].pmkId,
                    pmkID, PMKID_VALUE_SIZE);
       /*pAdmCtrl->pmkid_cache.pmkidTbl[cacheIndex].generationTs = os_timeStampMs(pAdmCtrl->hOs); */
   }
   else
   {
       /* The new entry is added to the next free entry. */
       /* Copy the new entry to the next free place.     */
       cacheIndex = pAdmCtrl->pmkid_cache.nextFreeEntry;
       os_memoryCopy(pAdmCtrl->hOs, 
                    (PVOID)&pAdmCtrl->pmkid_cache.pmkidTbl[cacheIndex].bssId.addr,
                    &(pBSSID->addr), MAC_ADDR_LEN);
       os_memoryCopy(pAdmCtrl->hOs, 
                    (PVOID)&pAdmCtrl->pmkid_cache.pmkidTbl[cacheIndex].pmkId,
                    (PVOID)pmkID, PMKID_VALUE_SIZE);

       /* Update the next free entry index. (If the table is full, a new entry */
       /* will override the oldest entries from the beginning of the table)    */
       /* Update the number of entries. (it cannot be more than max cach size) */
       pAdmCtrl->pmkid_cache.nextFreeEntry  = (cacheIndex + 1) % ADMCTRL_PMKID_CACHE_SIZE;

       if(pAdmCtrl->pmkid_cache.entriesNumber < ADMCTRL_PMKID_CACHE_SIZE)
          pAdmCtrl->pmkid_cache.entriesNumber ++;
   }

        WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
         ("RSN   Add PMKID   Entry index is %d \n", cacheIndex));
        WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG,
        ("RSN:  BSSID: %.2X-%.2X-%.2X-%.2X-%.2X-%.2X  PMKID: %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X  \n",
            pBSSID->addr[0], pBSSID->addr[1], pBSSID->addr[2], 
            pBSSID->addr[3], pBSSID->addr[4], pBSSID->addr[5],
            pmkID[0], pmkID[1], pmkID[2], pmkID[3],
            pmkID[4], pmkID[5], pmkID[6], pmkID[7],
            pmkID[8], pmkID[9], pmkID[10],pmkID[11],
            pmkID[12],pmkID[13],pmkID[14],pmkID[15]));



   return OK;
}

/**
*
* admCtrlWpa2_setPMKIDList 
*
* \b Description: 
*
* Set PMKID cache 
*
* \b ARGS:
*
*  I   - pAdmCtrl        - pointer to admCtrl context
*  O   - pmkidList       - memory buffer where the procedure reads the PMKIDs from
*                          Supplied by the caller procedure. 
* \b RETURNS:
*
* OK on success, NOK on failure. 
*
* \sa 
*/
TI_STATUS admCtrlWpa2_setPMKIDList (admCtrl_t * pAdmCtrl, OS_802_11_PMKID *pmkidList)
{
    UINT8          neededLength, i = 0;
    UINT8          NumOfEntries;
    macAddress_t   macAddr;

    /* Check the minimal buffer length */
    if (pmkidList->Length < 2*sizeof(UINT32))
    {
        WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG,
        ("RSN: Set PMKID list - Buffer size < min length (8 bytes). Supplied length is %d .\n",
          pmkidList->Length));
        return NOK;
    }

    /* Check the num of entries in the buffer: if 0 it means that */
    /* PMKID cache has to be cleaned                              */
    if(pmkidList->BSSIDInfoCount == 0)
    {
        admCtrlWpa2_resetPMKIDCache(pAdmCtrl);
        return OK;
    }

    /* Check the buffer length */
    NumOfEntries = (UINT8)pmkidList->BSSIDInfoCount;
    neededLength =  2*sizeof(UINT32) + (NumOfEntries  *(MAC_ADDR_LEN + PMKID_VALUE_SIZE));

    if(pmkidList->Length < neededLength)
    {
        /* Something wrong goes with the buffer */
        WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG,
        ("
Back to Top