wlan_bearer/wlanldd/wlan_common/umac_common/src/UmacWsaAddKey.cpp
changeset 0 c40eb8fe8501
equal deleted inserted replaced
-1:000000000000 0:c40eb8fe8501
       
     1 /*
       
     2 * Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   Implementation of the WlanWsaAddKey class
       
    15 *
       
    16 */
       
    17 
       
    18 /*
       
    19 * %version: 14 %
       
    20 */
       
    21 
       
    22 #include "config.h"
       
    23 #include "UmacWsaAddKey.h"
       
    24 #include "UmacContextImpl.h"
       
    25 
       
    26 #ifndef NDEBUG 
       
    27 const TInt8 WlanWsaAddKey::iName[] = "wsa-addkey";
       
    28 #endif // !NDEBUG 
       
    29 
       
    30 // ======== MEMBER FUNCTIONS ========
       
    31 
       
    32 // -----------------------------------------------------------------------------
       
    33 // 
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 void WlanWsaAddKey::Entry( WlanContextImpl& aCtxImpl )
       
    37     {
       
    38     // mark WSA cmd active
       
    39     aCtxImpl.ActivateWsaCmd();
       
    40 
       
    41     OsTracePrint( 
       
    42         KWsaCmdStateDetails, 
       
    43         (TUint8*)("UMAC: WlanWsaAddKey::Entry: KeyType: %d"), 
       
    44         iKeyType);
       
    45     OsTracePrint( 
       
    46         KWsaCmdStateDetails, 
       
    47         (TUint8*)("UMAC: WlanWsaAddKey::Entry: iEntryIndex: %d"), 
       
    48         iEntryIndex);
       
    49 
       
    50 #ifndef NDEBUG 
       
    51     TUint keyDataLen( 0 );
       
    52     
       
    53     switch ( iKeyType )
       
    54         {
       
    55         case WHA::EWepGroupKey:
       
    56             keyDataLen = 
       
    57                 sizeof(WHA::SWepGroupKey) 
       
    58                 - sizeof(reinterpret_cast<const WHA::SWepGroupKey*>(iKey)->iKey) 
       
    59                 + (reinterpret_cast<const WHA::SWepGroupKey*>
       
    60                 (iKey))->iKeyLengthInBytes;                               
       
    61             break;
       
    62         case WHA::EWepPairWiseKey:
       
    63             keyDataLen = 
       
    64                 sizeof(WHA::SWepPairwiseKey) 
       
    65                 - sizeof(reinterpret_cast<const WHA::SWepPairwiseKey*>
       
    66                 (iKey)->iKey) 
       
    67                 + (reinterpret_cast<const WHA::SWepPairwiseKey*>
       
    68                 (iKey))->iKeyLengthInBytes;
       
    69             break;            
       
    70         case WHA::ETkipGroupKey: 
       
    71             keyDataLen = sizeof( WHA::STkipGroupKey );
       
    72             break;
       
    73         case WHA::ETkipPairWiseKey:
       
    74             keyDataLen = sizeof( WHA::STkipPairwiseKey );
       
    75             break;            
       
    76         case WHA::EAesGroupKey: 
       
    77             keyDataLen = sizeof( WHA::SAesGroupKey );
       
    78             break;
       
    79         case WHA::EAesPairWiseKey:        
       
    80             keyDataLen = sizeof( WHA::SAesPairwiseKey );
       
    81             break;
       
    82         case WHA::EWapiGroupKey: 
       
    83             keyDataLen = sizeof( WHA::SWapiGroupKey );
       
    84             break;
       
    85         case WHA::EWapiPairWiseKey:        
       
    86             keyDataLen = sizeof( WHA::SWapiPairwiseKey );
       
    87             break;
       
    88         default:
       
    89             OsTracePrint( KErrorLevel, 
       
    90                 (TUint8*)("UMAC: iKeyType: %d"), iKeyType );
       
    91             OsAssert( (TUint8*)("UMAC: panic"), (TUint8*)(WLAN_FILE), __LINE__ );
       
    92         }
       
    93 
       
    94     OsTracePrint( KWsaCmdStateDetails, 
       
    95         (TUint8*)("UMAC: WlanWsaAddKey::Entry: complete key data contents:"), 
       
    96         reinterpret_cast<const TUint8*>(iKey), 
       
    97         reinterpret_cast<const TUint8*>(iKey) + keyDataLen );            
       
    98 
       
    99     OsTracePrint( KWsaCmdState, (TUint8*)
       
   100         ("UMAC: WHA-CMD-AddKey") );
       
   101             
       
   102 #endif // !NDEBUG 
       
   103 
       
   104     // execute the command
       
   105     aCtxImpl.Wha().AddKey( iKeyType, iKey, iEntryIndex );
       
   106     }
       
   107 
       
   108 // -----------------------------------------------------------------------------
       
   109 // 
       
   110 // -----------------------------------------------------------------------------
       
   111 //
       
   112 void WlanWsaAddKey::CommandResponse( 
       
   113     WlanContextImpl& aCtxImpl, 
       
   114     WHA::TCommandId aCommandId, 
       
   115     WHA::TStatus aStatus,
       
   116     const WHA::UCommandResponseParams& aCommandResponseParams )
       
   117     {
       
   118     if ( aCommandId != WHA::EAddKeyResponse )
       
   119         {
       
   120         OsTracePrint( KErrorLevel, 
       
   121             (TUint8*)("UMAC: aCommandId: %d"), aCommandId );
       
   122         OsAssert( (TUint8*)("UMAC: panic"), (TUint8*)(WLAN_FILE), __LINE__ );
       
   123         }
       
   124     
       
   125     TraverseToHistoryState( aCtxImpl, 
       
   126         aCommandId, aStatus, aCommandResponseParams );    
       
   127     }
       
   128 
       
   129 // -----------------------------------------------------------------------------
       
   130 // 
       
   131 // -----------------------------------------------------------------------------
       
   132 //
       
   133 #ifndef NDEBUG
       
   134 const TInt8* WlanWsaAddKey::GetStateName( TUint8& aLength ) const
       
   135     {
       
   136     aLength = sizeof( iName );
       
   137     return iName;
       
   138     }
       
   139 #endif