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

Language C Lines 1069
MD5 Hash d64413675d496ba5a388de6f541dde60 Estimated Cost $12,173 (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
/****************************************************************************
**+-----------------------------------------------------------------------+**
**|                                                                       |**
**| 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 admCtrl.c
 *  \brief Admission control API implimentation
 *
 *  \see admCtrl.h
 */

#include "osApi.h"

#include "paramOut.h"
#include "paramIn.h"

#include "utils.h"
#include "fsm.h"
#include "report.h"
#include "mlmeApi.h"
#include "DataCtrl_Api.h"

#include "TI_IPC_Api.h"

#include "rsn.h"
#include "admCtrl.h"

#include "admCtrlWpa.h"
#include "admCtrlWpa2.h"
#include "admCtrlNone.h"
#include "admCtrlWep.h"
#include "EvHandler.h"
 
/* Constants */

/* Enumerations */

/* Typedefs */

/* Structures */

/* External data definitions */

/* Local functions definitions */

/* Global variables */

/* Function prototypes */

TI_STATUS admCtrl_setAuthSuite(admCtrl_t *pAdmCtrl, authSuite_e authSuite);

TI_STATUS admCtrl_getAuthSuite(admCtrl_t *pAdmCtrl, authSuite_e *pSuite);

TI_STATUS admCtrl_setNetworkMode(admCtrl_t *pAdmCtrl, rsn_networkMode_t mode);

TI_STATUS admCtrl_setExtAuthMode(admCtrl_t *pAdmCtrl, externalAuthMode_e extAuthMode);

TI_STATUS admCtrl_getExtAuthMode(admCtrl_t *pAdmCtrl, externalAuthMode_e *pExtAuthMode);

TI_STATUS admCtrl_setUcastSuite(admCtrl_t *pAdmCtrl, cipherSuite_e suite);

TI_STATUS admCtrl_setBcastSuite(admCtrl_t *pAdmCtrl, cipherSuite_e suite);

TI_STATUS admCtrl_getCipherSuite(admCtrl_t *pAdmCtrl, cipherSuite_e *pSuite);

TI_STATUS admCtrl_setKeyMngSuite(admCtrl_t *pAdmCtrl, rsn_keyMngSuite_e suite);

TI_STATUS admCtrl_getMixedMode(admCtrl_t *pAdmCtrl, BOOL *pMixedMode);

TI_STATUS admCtrl_setMixedMode(admCtrl_t *pAdmCtrl, BOOL mixedMode);

TI_STATUS admCtrl_getAuthEncrCapability(admCtrl_t *pAdmCtrl, 
                   rsnAuthEncrCapability_t   *authEncrCapability);

TI_STATUS admCtrl_getPromoteFlags(admCtrl_t *pAdmCtrl, UINT32 *WPAPromoteFlags);

TI_STATUS admCtrl_setPromoteFlags(admCtrl_t *pAdmCtrl, UINT32 WPAPromoteFlags);

TI_STATUS admCtrl_getWPAMixedModeSupport(admCtrl_t *pAdmCtrl, UINT32 *support);

TI_STATUS admCtrl_checkSetSuite(admCtrl_t *pAdmCtrl, cipherSuite_e suite, BOOL Broadcast);

#ifdef EXC_MODULE_INCLUDED
TI_STATUS admCtrl_setNetworkEap(admCtrl_t *pAdmCtrl, OS_EXC_NETWORK_EAP networkEap);

TI_STATUS admCtrl_getNetworkEap(admCtrl_t *pAdmCtrl, OS_EXC_NETWORK_EAP *networkEap);
#endif

/**
*
* admCtrl_create
*
* \b Description: 
*
* Create the admission control context.
*
* \b ARGS:
*
*  I   - role - admission cotrol role (AP or Station)  \n
*  I   - authSuite - authentication suite to work with \n
*  
* \b RETURNS:
*
*  OK on success, NOK on failure.
*
* \sa 
*/
admCtrl_t* admCtrl_create(TI_HANDLE hOs)
{
	admCtrl_t 		*pHandle;

	/* allocate rsniation context memory */
	pHandle = (admCtrl_t*)os_memoryAlloc(hOs, sizeof(admCtrl_t));
	if (pHandle == NULL)
	{
		return NULL;
	}

	os_memoryZero(hOs, pHandle, sizeof(admCtrl_t));

    pHandle->preAuthTimerWpa2 = os_timerCreate(hOs, admCtrlWpa2_preAuthTimerExpire, pHandle);

    /* If we failed to create the timer - exit with error */
    if (pHandle->preAuthTimerWpa2 == NULL)
    {
       os_memoryFree(pHandle->hOs, pHandle, sizeof(admCtrl_t));
       return NULL;
    }
	pHandle->hOs = hOs;

	return pHandle;
}

/**
*
* admCtrl_unload
*
* \b Description: 
*
* Unload admission control module from memory
*
* \b ARGS:
*
*  I   - hAdmCtrl - Admossion control context  \n
*
* \b RETURNS:
*
*  OK if successful, NOK otherwise.
*
* \sa admCtrl_create
*/
TI_STATUS admCtrl_unload(admCtrl_t *pAdmCtrl)
{
	if (pAdmCtrl == NULL)
	{
		return NOK;
	}
	
    /* Stop and destroy the wpa2 pre-authentication timer */
   os_timerStop(pAdmCtrl->hOs, pAdmCtrl->preAuthTimerWpa2);
   utils_nullTimerDestroy(pAdmCtrl->hOs, pAdmCtrl->preAuthTimerWpa2);
	os_memoryFree(pAdmCtrl->hOs, pAdmCtrl, sizeof(admCtrl_t));

	return OK;
}

/**
*
* admCtrl_config
*
* \b Description: 
*
* Configure the admission control module.
*
* \b ARGS:
*
*  I   - role - admission cotrol role (AP or Station)  \n
*  I   - authSuite - authentication suite to work with \n
*  
* \b RETURNS:
*
*  OK on success, NOK on failure.
*
* \sa 
*/
TI_STATUS admCtrl_config(TI_HANDLE hAdmCtrl,
					  TI_HANDLE hMlme,
					  TI_HANDLE hRx,
					  TI_HANDLE hReport,
					  TI_HANDLE hOs,
					  struct _rsn_t *pRsn,
					  TI_HANDLE hExcMngr,
					  TI_HANDLE hPowerMgr,
	                  TI_HANDLE	hEvHandler,
					  rsnInitParams_t *pInitParam)
{
	admCtrl_t		*pAdmCtrl;
	TI_STATUS			status;

	if (hAdmCtrl == NULL)
	{
		return NOK;
	}
	
	pAdmCtrl = (admCtrl_t*)hAdmCtrl;

	pAdmCtrl->pRsn = pRsn;
	pAdmCtrl->hMlme = hMlme;
	pAdmCtrl->hRx = hRx;
	pAdmCtrl->hReport = hReport;
	pAdmCtrl->hOs = hOs;
	pAdmCtrl->hExcMngr = hExcMngr;
	pAdmCtrl->hPowerMgr = hPowerMgr;
    pAdmCtrl->hEvHandler = hEvHandler;

	/* Initialize admission control parameters */
	pAdmCtrl->role = RSN_PAE_SUPP;
	pAdmCtrl->networkMode = RSN_INFRASTRUCTURE;
	pAdmCtrl->authSuite	= pInitParam->authSuite;
	pAdmCtrl->externalAuthMode = pInitParam->externalAuthMode;
    pAdmCtrl->mixedMode = pInitParam->mixedMode;
	
    if (pInitParam->privacyOn)
    {
        pAdmCtrl->broadcastSuite = RSN_CIPHER_WEP;
        pAdmCtrl->unicastSuite = RSN_CIPHER_WEP;
    } else {
        pAdmCtrl->broadcastSuite = RSN_CIPHER_NONE;
        pAdmCtrl->unicastSuite = RSN_CIPHER_NONE;
    }

	pAdmCtrl->preAuthSupport     = pInitParam->preAuthSupport;
    pAdmCtrl->preAuthTimeout     = pInitParam->preAuthTimeout;
	pAdmCtrl->WPAMixedModeEnable = pInitParam->WPAMixedModeEnable;
	/*pAdmCtrl->PMKIDCandListDelay = pInitParam->PMKIDCandListDelay;*/
	pAdmCtrl->MaxNumOfPMKIDs     = PMKID_MAX_NUMBER;

	/* Initialize admission control member functions */
	pAdmCtrl->setAuthSuite = admCtrl_setAuthSuite;
	pAdmCtrl->setNetworkMode = admCtrl_setNetworkMode;
	pAdmCtrl->getAuthSuite = admCtrl_getAuthSuite;
	pAdmCtrl->setExtAuthMode = admCtrl_setExtAuthMode;
	pAdmCtrl->getExtAuthMode = admCtrl_getExtAuthMode;
	pAdmCtrl->setUcastSuite	= admCtrl_setUcastSuite;
	pAdmCtrl->setBcastSuite = admCtrl_setBcastSuite;
	pAdmCtrl->getCipherSuite = admCtrl_getCipherSuite;
	pAdmCtrl->setKeyMngSuite = admCtrl_setKeyMngSuite;
    pAdmCtrl->getMixedMode = admCtrl_getMixedMode;
    pAdmCtrl->setMixedMode = admCtrl_setMixedMode;
    pAdmCtrl->getAuthEncrCap = admCtrl_getAuthEncrCapability;
    pAdmCtrl->getPmkidList   = admCtrl_nullGetPMKIDlist;
    pAdmCtrl->setPmkidList   = admCtrl_nullSetPMKIDlist;
    pAdmCtrl->resetPmkidList = admCtrl_resetPMKIDlist;
    pAdmCtrl->getPromoteFlags = admCtrl_getPromoteFlags;
    pAdmCtrl->setPromoteFlags = admCtrl_setPromoteFlags;
    pAdmCtrl->getWPAMixedModeSupport = admCtrl_getWPAMixedModeSupport;
#ifdef EXC_MODULE_INCLUDED
	pAdmCtrl->setNetworkEap = admCtrl_setNetworkEap;
	pAdmCtrl->getNetworkEap = admCtrl_getNetworkEap;
    pAdmCtrl->networkEapMode = OS_EXC_NETWORK_EAP_OFF;
#endif

	pAdmCtrl->getPreAuthStatus = admCtrl_nullGetPreAuthStatus;
	pAdmCtrl->startPreAuth	= admCtrl_nullStartPreAuth;
    pAdmCtrl->get802_1x_AkmExists = admCtrl_nullGet802_1x_AkmExists;
    /* Zero number of sent wpa2 preauthentication candidates */
    pAdmCtrl->numberOfPreAuthCandidates = 0;

	status = admCtrl_subConfig(pAdmCtrl);

	return status;
}

/**
*
* admCtrl_subConfig
*
* \b Description: 
*
* Configure the admission control module according to the Privacy Mode.
*
* \b ARGS:
*
*  I   - pAdmCtrl - pointer to admission cotrol context  \n
*  
* \b RETURNS:
*
*  OK on success, NOK on failure.
*
* \sa 
*/
TI_STATUS admCtrl_subConfig(TI_HANDLE hAdmCtrl)

{
    admCtrl_t* pAdmCtrl = (admCtrl_t*)hAdmCtrl;
	TI_STATUS status;

	switch(pAdmCtrl->externalAuthMode)
	{
	case RSN_EXT_AUTH_MODE_WPA:
	case RSN_EXT_AUTH_MODE_WPAPSK:
	case RSN_EXT_AUTH_MODE_WPANONE:
		status = admCtrlWpa_config(pAdmCtrl);
		break;

	case RSN_EXT_AUTH_MODE_WPA2:
	case RSN_EXT_AUTH_MODE_WPA2PSK:
		status = admCtrlWpa2_config(pAdmCtrl);
		break;

	default:
		if(pAdmCtrl->unicastSuite==RSN_CIPHER_NONE)
		{
			status = admCtrlNone_config(pAdmCtrl);
		}
		else
		{
			status = admCtrlWep_config(pAdmCtrl);
		}
		break;

	}
	
	return status;

}

/**
*
* admCtrl_setNetworkMode - Change current network mode.
*
* \b Description: 
*
* Change current network mode.
*
* \b ARGS:
*
*  I   - pAdmCtrl - context \n
*  I   - mode - network association mode (Infustrucure/IBSS) \n
*  
* \b RETURNS:
*
*  OK on success, NOK on failure.
*
* \sa 
*/
TI_STATUS admCtrl_setNetworkMode(admCtrl_t *pAdmCtrl, rsn_networkMode_t mode)
{
    pAdmCtrl->networkMode = mode;

    return OK;
}

/**
*
* admCtrl_setAuthSuite - Change current authentication suite.
*
* \b Description: 
*
* Change current authentication suite.
*
* \b ARGS:
*
*  I   - pAdmCtrl - context \n
*  I   - authSuite - authentication suite to work with \n
*  
* \b RETURNS:
*
*  OK on success, NOK on failure.
*
* \sa 
*/
TI_STATUS admCtrl_setAuthSuite(admCtrl_t *pAdmCtrl, authSuite_e authSuite)
{
	TI_STATUS 		status = NOK;

	if (pAdmCtrl == NULL)
	{
		return NOK;
	}

	if (pAdmCtrl->authSuite == authSuite)
	{
		return OK;
	}

	if (pAdmCtrl->authSuite > RSN_AUTH_AUTO_SWITCH)
	{
		return NOK;
	}
	pAdmCtrl->externalAuthMode = (externalAuthMode_e)authSuite;
	pAdmCtrl->authSuite = authSuite;
	status = admCtrl_subConfig(pAdmCtrl);
	return status;
}


/**
*
* admCtrl_getAuthSuite  - Get current authentication suite.
*
* \b Description: 
*
* Get current authentication suite.
*
* \b ARGS:
*
*  I   - pAdmCtrl - context \n
*  O   - suite - key management suite to work with \n
*  
* \b RETURNS:
*
*  OK on success, NOK on failure.
*
* \sa 
*/
TI_STATUS admCtrl_getAuthSuite(admCtrl_t *pAdmCtrl, authSuite_e *pSuite)
{
	if (pAdmCtrl == NULL)
	{
		return NOK;
	}

	*pSuite = pAdmCtrl->authSuite;

	return OK;
}

/**
*
* admCtrl_setExtAuthMode  - Set current External authentication Mode Status.
*
* \b Description: 
*
* Set current External authentication Mode Status.
*
* \b ARGS:
*
*  I   - pAdmCtrl - context \n
*  I   - extAuthMode - External authentication Mode \n
*  
* \b RETURNS:
*
*  OK on success, NOK on failure.
*
* \sa 
*/
TI_STATUS admCtrl_setExtAuthMode(admCtrl_t *pAdmCtrl, externalAuthMode_e extAuthMode)
{

	if (extAuthMode >= RSN_EXT_AUTH_MODEMAX)
	{
		return NOK;
	}


	if (pAdmCtrl->externalAuthMode == extAuthMode)
	{
		return OK;
	}
	pAdmCtrl->externalAuthMode = extAuthMode;
	if (extAuthMode <= RSN_EXT_AUTH_MODE_AUTO_SWITCH)
	{
		pAdmCtrl->authSuite = (authSuite_e)extAuthMode;
	}
	else
	{
		pAdmCtrl->authSuite = RSN_AUTH_OPEN;
	}
	
	return (admCtrl_subConfig(pAdmCtrl));
}

/**
*
* admCtrl_getExtAuthMode  - Get current External authentication Mode Status.
*
* \b Description: 
*
* Get current External Mode Status.
*
* \b ARGS:
*
*  I   - pAdmCtrl - context \n
*  I   - pExtAuthMode - EXC External Mode Status \n
*  
* \b RETURNS:
*
*  OK on success, NOK on failure.
*
* \sa 
*/
TI_STATUS admCtrl_getExtAuthMode(admCtrl_t *pAdmCtrl, externalAuthMode_e *pExtAuthMode)
{
	*pExtAuthMode = pAdmCtrl->externalAuthMode;

	return OK;
}


/**
*
* admCtrl_checkSetSuite -
*
* \b Description: 
*
* Check the validity/support of the cipher suite according to
* the admission control parameters
*
* \b ARGS:
*
*  I   - pAdmCtrl - context \n
*  I   - suite - cipher suite to check \n
*  
* \b RETURNS:
*
*  OK on success, NOK on failure.
*
* \sa 
*/
TI_STATUS admCtrl_checkSetSuite(admCtrl_t *pAdmCtrl, cipherSuite_e suite, BOOL Broadcast)
{
	if (pAdmCtrl->externalAuthMode<=RSN_EXT_AUTH_MODE_AUTO_SWITCH)
	{   
		if ((suite==RSN_CIPHER_NONE) || (suite==RSN_CIPHER_WEP) || (suite==RSN_CIPHER_WEP104))
		{
			return OK;
		}
	}
	else
	{
		if ((suite==RSN_CIPHER_TKIP) || (suite==RSN_CIPHER_WEP) || 
			(suite==RSN_CIPHER_WEP104) || (suite==RSN_CIPHER_AES_CCMP))
		{
			return OK;
		}
		else if (!Broadcast && (suite==RSN_CIPHER_NONE))
		{
			return OK;
		}
	}
	return NOK;
}

/**
*
* admCtrl_setUcastSuite  - Set current unicast cipher suite support.
*
* \b Description: 
*
* Set current unicast cipher suite support.
*
* \b ARGS:
*
*  I   - pAdmCtrl - context \n
*  I   - suite - cipher suite to work with \n
*  
* \b RETURNS:
*
*  OK on success, NOK on failure.
*
* \sa 
*/
TI_STATUS admCtrl_setUcastSuite(admCtrl_t *pAdmCtrl, cipherSuite_e suite)
{
	TI_STATUS status;

	if (suite == pAdmCtrl->unicastSuite)
	{
		return OK;
	}
	status = admCtrl_checkSetSuite(pAdmCtrl, suite, FALSE);
	if (status == OK)
	{
		pAdmCtrl->unicastSuite = suite;
		status = admCtrl_subConfig(pAdmCtrl);
	}

	return status;
}

/**
*
* admCtrl_setBcastSuite  - Set current broadcast cipher suite support.
*
* \b Description: 
*
* Set current broadcast cipher suite support.
*
* \b ARGS:
*
*  I   - pAdmCtrl - context \n
*  I   - suite - cipher suite to work with \n
*  
* \b RETURNS:
*
*  OK on success, NOK on failure.
*
* \sa 
*/
TI_STATUS admCtrl_setBcastSuite(admCtrl_t *pAdmCtrl, cipherSuite_e suite)
{
	TI_STATUS status;

	if (suite == pAdmCtrl->broadcastSuite)
	{
		return OK;
	}

	status = admCtrl_checkSetSuite(pAdmCtrl, suite, TRUE);
	if (status == OK)
	{
		pAdmCtrl->broadcastSuite = suite;
		status = admCtrl_subConfig(pAdmCtrl);
	}
	return status;

}

/**
*
* admCtrl_getCipherSuite  - Set current broadcast cipher suite support.
*
* \b Description: 
*
* Set current broadcast cipher suite support.
*
* \b ARGS:
*
*  I   - pAdmCtrl - context \n
*  O   - suite - cipher suite to work with \n
*  
* \b RETURNS:
*
*  OK on success, NOK on failure.
*
* \sa 
*/
TI_STATUS admCtrl_getCipherSuite(admCtrl_t *pAdmCtrl, cipherSuite_e *pSuite)
{
	if (pAdmCtrl == NULL)
	{
		return NOK;
	}

	*pSuite = (pAdmCtrl->broadcastSuite > pAdmCtrl->unicastSuite) ? pAdmCtrl->broadcastSuite :pAdmCtrl->unicastSuite;
	 
	return OK;
}
	
/**
*
* admCtrl_setKeyMngSuite  - Set current key management suite support.
*
* \b Description: 
*
* Set current key management suite support.
*
* \b ARGS:
*
*  I   - pAdmCtrl - context \n
*  I   - suite - key management suite to work with \n
*  
* \b RETURNS:
*
*  OK on success, NOK on failure.
*
* \sa 
*/
TI_STATUS admCtrl_setKeyMngSuite(admCtrl_t *pAdmCtrl, rsn_keyMngSuite_e suite)
{
    pAdmCtrl->keyMngSuite = suite;

	return OK;
}


/**
*
* admCtrl_parseIe  - Parse a required information element.
*
* \b Description: 
*
* Parse an Aironet information element. 
* Builds a structure of all the capabilities described in the Aironet IE.
* We look at Flags field only to determine KP and MIC bits value
*
* \b ARGS:
*
*  I   - pAdmCtrl - pointer to admCtrl context
*  I   - pAironetIe - pointer to Aironet IE buffer  \n
*  O   - pAironetData - capabilities structure
*  
*  
* \b RETURNS:
*
* OK on success, NOK on failure. 
*
* \sa 
*/
TI_STATUS admCtrl_parseIe(admCtrl_t *pAdmCtrl, rsnData_t *pRsnData, UINT8 **pIe, UINT8 IeId)
{

	dot11_eleHdr_t   *eleHdr;
	INT16			 length;
	UINT8            *pCurIe;


	*pIe = NULL;

	if ((pRsnData == NULL) || (pRsnData->ieLen==0))
	{
	   return OK;	
	}

	pCurIe = pRsnData->pIe;
	
	length = pRsnData->ieLen;
	while (length>0)
	{
		eleHdr = (dot11_eleHdr_t*)pCurIe;
		
		if (length<(eleHdr->eleLen+2))
		{
			WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
								("admCtrl_parseIe ERROR: pRsnData->ieLen=%d, length=%d\n\n", pRsnData->ieLen,length));
			return OK;
		}
		
		if (eleHdr->eleId == IeId)
		{
            *pIe = (UINT8*)eleHdr;
            break;
		}
		length -= eleHdr->eleLen+2;
		pCurIe += eleHdr->eleLen+2;
	}
	return OK;
}

/**
*
* admCtrl_setMixedMode  - Set current mixed Mode Status.
*
* \b Description: 
*
* Set current mixed Mode Status.
*
* \b ARGS:
*
*  I   - pAdmCtrl - context \n
*  I   - authMode - mixed Mode \n
*  
* \b RETURNS:
*
*  OK on success, NOK on failure.
*
* \sa 
*/
TI_STATUS admCtrl_setMixedMode(admCtrl_t *pAdmCtrl, BOOL mixedMode)
{

	if (pAdmCtrl->mixedMode == mixedMode)
	{
		return OK;
	}
	pAdmCtrl->mixedMode = mixedMode;

	return OK;
}

/**
*
* admCtrl_getMixedMode  - Get current mixed Mode Status.
*
* \b Description: 
*
* Get current mixed Mode Status.
*
* \b ARGS:
*
*  I   - pAdmCtrl - context \n
*  I   - pAuthMode - mixed Mode Status \n
*  
* \b RETURNS:
*
*  OK on success, NOK on failure.
*
* \sa 
*/
TI_STATUS admCtrl_getMixedMode(admCtrl_t *pAdmCtrl, BOOL *pMixedMode)
{
	*pMixedMode = pAdmCtrl->mixedMode;

	return OK;
}



/* This table presents supported pairs of auth.mode/cipher type */
static 	authEncrPairList_t  supportedAuthEncrPairs[MAX_AUTH_ENCR_PAIR] = 
{
	{RSN_EXT_AUTH_MODE_OPEN,       RSN_CIPHER_NONE},
	{RSN_EXT_AUTH_MODE_OPEN,       RSN_CIPHER_WEP},
	{RSN_EXT_AUTH_MODE_SHARED_KEY, RSN_CIPHER_NONE},
	{RSN_EXT_AUTH_MODE_SHARED_KEY, RSN_CIPHER_WEP},
	{RSN_EXT_AUTH_MODE_WPA,        RSN_CIPHER_TKIP},
	{RSN_EXT_AUTH_MODE_WPA,        RSN_CIPHER_AES_CCMP},
	{RSN_EXT_AUTH_MODE_WPAPSK,     RSN_CIPHER_TKIP},
	{RSN_EXT_AUTH_MODE_WPAPSK,     RSN_CIPHER_AES_CCMP},
	{RSN_EXT_AUTH_MODE_WPANONE,    RSN_CIPHER_NONE},    /* No encryption in IBSS mode */
	{RSN_EXT_AUTH_MODE_WPA2,       RSN_CIPHER_TKIP},
	{RSN_EXT_AUTH_MODE_WPA2,       RSN_CIPHER_AES_CCMP},
	{RSN_EXT_AUTH_MODE_WPA2PSK,    RSN_CIPHER_TKIP},
	{RSN_EXT_AUTH_MODE_WPA2PSK,    RSN_CIPHER_AES_CCMP}
};

/**
*
* admCtrl_getAuthEncrCapability  - Get all supported pais of
*                                  authenticationmode/cipher suite
*
* \b Description: 
*
*    Returns all supported pais of authenticationmode/cipher suite
*
* \b ARGS:
*
*  I   - pAdmCtrl - context \n
*  I   - authEncrCapability - ptr to list of auth.mode/cipher pairs \n
*  
* \b RETURNS:
*
*  OK on success, NOK on failure.
*
* \sa 
*/

TI_STATUS admCtrl_getAuthEncrCapability(admCtrl_t *pAdmCtrl, 
                                        rsnAuthEncrCapability_t   *authEncrCapability)
{
    int i = 0;

    if(!authEncrCapability)
        return NOK;

    /* The current driver code version  uses the above hardcoded list */
    /* of auth/encr pairs */

    authEncrCapability->NoOfAuthEncrPairSupported = MAX_AUTH_ENCR_PAIR;
    authEncrCapability->NoOfPMKIDs                = PMKID_MAX_NUMBER;

    WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
    ("admCtrl get AuthEncr capability:  No. of auth/encr pairs = %d, No of PMKIDs = %d \n", 
        authEncrCapability->NoOfAuthEncrPairSupported,  authEncrCapability->NoOfPMKIDs));

    /* Copy the hardcoded table of the auth.mode/cipher type */
    for (i = 0; i < MAX_AUTH_ENCR_PAIR; i++)
    {
        authEncrCapability->authEncrPairs[i].authenticationMode = 
            supportedAuthEncrPairs[i].authenticationMode;
        authEncrCapability->authEncrPairs[i].cipherSuite        = 
            supportedAuthEncrPairs[i].cipherSuite;

        WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
            ("admCtrl get AuthEncr pair list: i = %d, auth mode = %d , cipher suite = %d \n", i,
                       authEncrCapability->authEncrPairs[i].authenticationMode,
                       authEncrCapability->authEncrPairs[i].cipherSuite));
    }
    
    return OK;
}


TI_STATUS admCtrl_nullSetPMKIDlist(admCtrl_t *pAdmCtrl, OS_802_11_PMKID  *pmkIdList)
{

    return CONFIGURATION_NOT_VALID;
}

TI_STATUS admCtrl_nullGetPMKIDlist(admCtrl_t *pAdmCtrl, OS_802_11_PMKID  *pmkIdList)
{

    return CONFIGURATION_NOT_VALID;
}


TI_STATUS admCtrl_resetPMKIDlist(admCtrl_t *pAdmCtrl)
{

    os_memoryZero(pAdmCtrl->hOs, (PVOID)&pAdmCtrl->pmkid_cache, sizeof(pmkid_cache_t));
    return OK;
}

TI_STATUS admCtrl_getWPAMixedModeSupport(admCtrl_t *pAdmCtrl, UINT32 *support)
{
    
    if(pAdmCtrl->WPAMixedModeEnable)
       *support = ADMCTRL_WPA_OPTION_MAXVALUE;
    else
       *support = 0;

    return OK;
}

TI_STATUS admCtrl_getPromoteFlags(admCtrl_t *pAdmCtrl, UINT32 *WPAPromoteFlags)
{
    *WPAPromoteFlags = pAdmCtrl->WPAPromoteFlags;
    return OK;
}

TI_STATUS admCtrl_setPromoteFlags(admCtrl_t *pAdmCtrl, UINT32 WPAPromoteFlags)
{
    if(WPAPromoteFlags > ADMCTRL_WPA_OPTION_MAXVALUE)
        return NOK;

    if(!pAdmCtrl->WPAMixedModeEnable)
       return NOK;

    pAdmCtrl->WPAPromoteFlags = WPAPromoteFlags;
    return OK;
}

BOOL admCtrl_nullGetPreAuthStatus(admCtrl_t *pAdmCtrl, macAddress_t *givenAP, UINT8 *cacheIndex)
{
    return FALSE;
}


TI_STATUS admCtrl_nullStartPreAuth(admCtrl_t *pAdmCtrl, bssidList4PreAuth_t *pBssidList)
{
	return OK;
}

TI_STATUS admCtrl_nullGet802_1x_AkmExists (admCtrl_t *pAdmCtrl, BOOL *wpa_802_1x_AkmExists)
{
    *wpa_802_1x_AkmExists = FALSE;
    return OK;
}

/*-----------------------------------------------------------------------------
Routine Name: admCtrl_notifyPreAuthStatus
Routine Description: This routine is used to notify higher level application of the pre-authentication status
Arguments: newStatus - pre authentication status
Return Value:
-----------------------------------------------------------------------------*/
void admCtrl_notifyPreAuthStatus (admCtrl_t *pAdmCtrl, preAuthStatusEvent_e newStatus)
{
    UINT32 memBuff;

    memBuff = (UINT32) newStatus;

    EvHandlerSendEvent(pAdmCtrl->hEvHandler, IPC_EVENT_WPA2_PREAUTHENTICATION,
                            (UINT8*)&memBuff, sizeof(UINT32));

}

#ifdef EXC_MODULE_INCLUDED

/**
*
* admCtrl_setNetworkEap  - Set current Network EAP Mode Status.
*
* \b Description: 
*
* Set current Network EAP Mode Status..
*
* \b ARGS:
*
*  I   - pAdmCtrl - context \n
*  I   - networkEap - Network EAP Mode \n
*
* \b RETURNS:
*
*  OK on success, NOK on failure.
*
* \sa 
*/
TI_STATUS admCtrl_setNetworkEap(admCtrl_t *pAdmCtrl, OS_EXC_NETWORK_EAP networkEap)
{
	if (pAdmCtrl==NULL)
		return NOK;

	if (pAdmCtrl->networkEapMode == networkEap)
	{
		return OK;
	}
	pAdmCtrl->networkEapMode = networkEap;
	
	return OK;
}

/**
*
* admCtrl_getNetworkEap  - Get current Network EAP Mode Status.
*
* \b Description: 
*
* Get current Network EAP Mode Status.
*
* \b ARGS:
*
*  I   - pAdmCtrl - context \n
*  I   - networkEap - Network EAP Mode \n
*  
* \b RETURNS:
*
*  OK on success, NOK on failure.
*
* \sa 
*/
TI_STATUS admCtrl_getNetworkEap(admCtrl_t *pAdmCtrl, OS_EXC_NETWORK_EAP *networkEap)
{
	
	if (pAdmCtrl==NULL)
	{
		return NOK;
	}

	switch (pAdmCtrl->networkEapMode)
	{
	case OS_EXC_NETWORK_EAP_OFF: 
		*networkEap = OS_EXC_NETWORK_EAP_OFF;
		break; 
	case OS_EXC_NETWORK_EAP_ON:      
	case OS_EXC_NETWORK_EAP_ALLOWED:
	case OS_EXC_NETWORK_EAP_PREFERRED:
		*networkEap = OS_EXC_NETWORK_EAP_ON;
		break;
	default:
		return NOK;
/*		break; - unreachable */
	}

	return OK;
}
#endif /* EXC_MODULE_INCLUDED*/
Back to Top