eapol/eapol_framework/eapol_symbian/eap_if/src/EapCoreInterface.cpp
branchRCL_3
changeset 46 c74b3d9f6b9e
parent 45 bad0cc58d154
child 55 9c2aa05919d9
equal deleted inserted replaced
45:bad0cc58d154 46:c74b3d9f6b9e
     1 /*
       
     2 * Copyright (c) 2001-2010 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:  EAP and WLAN authentication protocols.
       
    15 *
       
    16 */
       
    17 
       
    18 /*
       
    19 * %version: 21 %
       
    20 */
       
    21 
       
    22 #include "EapCoreInterface.h"
       
    23 #include "eap_am_tools.h"
       
    24 #include "EapolUID.h"
       
    25 #include "EapPluginTools.h"
       
    26 
       
    27 CEapCoreInterface::CEapCoreInterface(const u32_t MTU):
       
    28   iClient(NULL)
       
    29   ,iIsValid(FALSE)
       
    30   ,iTools(0)
       
    31   ,iEapCoreInterface(0)
       
    32   ,iServer(0)
       
    33   ,iMTU(MTU)
       
    34      {
       
    35      }
       
    36 
       
    37 CEapCoreInterface::~CEapCoreInterface()
       
    38     {
       
    39     delete iEapCoreInterface;
       
    40     }
       
    41 
       
    42 EAP_FUNC_EXPORT CEapProcessInterface* CEapCoreInterface::ConstrucL(abs_eap_am_tools_c * const tools)
       
    43     {
       
    44     iTools = tools;
       
    45 
       
    46     //TInt implementationUid( EAP_CORE_INTERFACEIMPLEMENTATION_IMPLEMENTATION_UID );
       
    47 
       
    48 	const TUid KimplementationInterfaceUid = { EAP_CORE_INTERFACEIMPLEMENTATION_INTERFACE_UID };
       
    49 		
       
    50     RImplInfoPtrArray aImplInfoArray;
       
    51 
       
    52 	CleanupStack::PushL( TCleanupItem( EapPluginTools::CleanupImplArray, &aImplInfoArray ) );
       
    53 
       
    54     REComSession::ListImplementationsL(KimplementationInterfaceUid,
       
    55             aImplInfoArray);
       
    56 
       
    57 	   	EAP_TRACE_DEBUG(
       
    58 	      tools, 
       
    59 	      TRACE_FLAGS_DEFAULT, 
       
    60 	      (EAPL("CEapCoreInterface::ConstrucL Implementation %d\n"),aImplInfoArray[0]->ImplementationUid().iUid));
       
    61 
       
    62     iServer = CEapProcessInterface::NewL(
       
    63             aImplInfoArray[0]->ImplementationUid().iUid,
       
    64             this);
       
    65 
       
    66     EAP_TRACE_DEBUG(
       
    67       tools, 
       
    68       TRACE_FLAGS_DEFAULT, 
       
    69       (EAPL("CEapCoreInterface::ConstrucL CEapProcessInterface::NewL done\n")));
       
    70 
       
    71     iIsValid = TRUE;
       
    72 
       
    73 	CleanupStack::PopAndDestroy(&aImplInfoArray);
       
    74 
       
    75     return iServer;
       
    76     
       
    77     }
       
    78 
       
    79 EAP_FUNC_EXPORT eap_am_message_if_c * new_eap_am_client_message_if_c(
       
    80         abs_eap_am_tools_c * const tools,
       
    81         const bool /* is_client_when_true */,
       
    82         const u32_t MTU)
       
    83     {   
       
    84      CEapCoreInterface * aEapCoreInterface = 0;
       
    85      CEapProcessInterface* aServer =0;
       
    86      
       
    87 	   	EAP_TRACE_DEBUG(
       
    88 	      tools, 
       
    89 	      TRACE_FLAGS_DEFAULT, 
       
    90 	      (EAPL("new_eap_am_client_message_if_c()\n")));
       
    91 	      
       
    92      aEapCoreInterface = new CEapCoreInterface(MTU);
       
    93      if (aEapCoreInterface != 0)
       
    94          {
       
    95 		 TRAPD( err, aServer = aEapCoreInterface->ConstrucL(tools));
       
    96          if (err)
       
    97              {    
       
    98              	EAP_TRACE_DEBUG(
       
    99 				        tools, 
       
   100 				        TRACE_FLAGS_DEFAULT, 
       
   101 				        (EAPL("new_eap_am_client_message_if_c() NO SERVER IF, err = %d\n"),err));
       
   102 
       
   103                return 0;
       
   104              }
       
   105          else if(aServer == NULL)
       
   106             {
       
   107              	EAP_TRACE_DEBUG(
       
   108 				        tools, 
       
   109 				        TRACE_FLAGS_DEFAULT, 
       
   110 				        (EAPL("new_eap_am_client_message_if_c() SERVER IF == 0\n")));
       
   111           	}   
       
   112          else
       
   113   	       {
       
   114 	    	   aServer->SetEnv(tools, MTU);
       
   115   	       }
       
   116           
       
   117          }
       
   118        else
       
   119        		{
       
   120           EAP_TRACE_DEBUG(
       
   121 				        tools, 
       
   122 				        TRACE_FLAGS_DEFAULT, 
       
   123 				        (EAPL("new_eap_am_client_message_if_c() new(ELeave) CEapCoreInterface(MTU) failed\n")));
       
   124        	 	return 0;
       
   125 					}
       
   126      return aEapCoreInterface;
       
   127 
       
   128     }
       
   129 
       
   130 EAP_FUNC_EXPORT bool CEapCoreInterface::get_is_valid()
       
   131     {
       
   132     EAP_TRACE_DEBUG(
       
   133              iTools, 
       
   134              TRACE_FLAGS_DEFAULT, 
       
   135              (EAPL("CEapCoreInterface::get_is_valid() = %d\n"),iIsValid ));
       
   136       return iIsValid;
       
   137     }
       
   138 
       
   139 EAP_FUNC_EXPORT eap_status_e CEapCoreInterface::process_data(const void * const data, const u32_t length)
       
   140     {
       
   141     EAP_TRACE_DEBUG(
       
   142             iTools, 
       
   143             TRACE_FLAGS_DEFAULT, 
       
   144             (EAPL("CEapCoreInterface::process_data()\n")));
       
   145 
       
   146     TInt err = iServer->ProcessData(data, length);
       
   147 
       
   148     return EAP_STATUS_RETURN(iTools, iTools->convert_am_error_to_eapol_error(err));
       
   149     }
       
   150 
       
   151 
       
   152 EAP_FUNC_EXPORT eap_status_e CEapCoreInterface::configure(
       
   153 	const eap_variable_data_c * const client_configuration)
       
   154     {
       
   155     EAP_TRACE_DEBUG(
       
   156             iTools, 
       
   157             TRACE_FLAGS_DEFAULT, 
       
   158             (EAPL("CEapCoreInterface::configure()\n")));
       
   159 
       
   160     TInt err = iServer->Configure(0,0,0, client_configuration->get_data(), client_configuration->get_data_length());
       
   161 
       
   162     return EAP_STATUS_RETURN(iTools, iTools->convert_am_error_to_eapol_error(err));
       
   163     }
       
   164 
       
   165 // This is documented in abs_eap_stack_interface_c::shutdown().
       
   166 EAP_FUNC_EXPORT eap_status_e CEapCoreInterface::shutdown()
       
   167     {
       
   168     EAP_TRACE_DEBUG(
       
   169             iTools, 
       
   170             TRACE_FLAGS_DEFAULT, 
       
   171             (EAPL("CEapCoreInterface::shutdown()\n")));
       
   172 
       
   173     TInt err = iServer->Shutdown();
       
   174 
       
   175     return EAP_STATUS_RETURN(iTools, iTools->convert_am_error_to_eapol_error(err));
       
   176     }
       
   177 
       
   178 EAP_FUNC_EXPORT void CEapCoreInterface::set_partner(abs_eap_am_message_if_c * const client)
       
   179     {
       
   180     EAP_TRACE_DEBUG(
       
   181             iTools, 
       
   182             TRACE_FLAGS_DEFAULT, 
       
   183             (EAPL("CEapCoreInterface::set_partner()\n")));
       
   184     iClient = client;
       
   185     }
       
   186 
       
   187 EAP_FUNC_EXPORT TInt CEapCoreInterface::SendData(
       
   188     const void * const aData, 
       
   189     const TInt aLength )
       
   190     {
       
   191     EAP_TRACE_DEBUG(
       
   192             iTools, 
       
   193             TRACE_FLAGS_DEFAULT, 
       
   194             (EAPL("CEapCoreInterface::SendData()\n")));
       
   195     if (iClient != NULL)
       
   196         {
       
   197         return iClient->send_data( aData, aLength);
       
   198         }
       
   199     else
       
   200         {
       
   201         return KErrNone;
       
   202         }
       
   203     }
       
   204