eapol/eapol_framework/eapol_symbian/am/type/aka/symbian/EapAkaInterface.cpp
changeset 0 c8830336c852
child 2 1c7bc153c08e
equal deleted inserted replaced
-1:000000000000 0:c8830336c852
       
     1 /*
       
     2 * Copyright (c) 2001-2006 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 // This is enumeration of EAPOL source code.
       
    20 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
       
    21 	#undef EAP_FILE_NUMBER_ENUM
       
    22 	#define EAP_FILE_NUMBER_ENUM 603 
       
    23 	#undef EAP_FILE_NUMBER_DATE 
       
    24 	#define EAP_FILE_NUMBER_DATE 1127594498 
       
    25 #endif //#if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
       
    26 
       
    27 // INCLUDE FILES
       
    28 #include "EapAkaInterface.h"
       
    29 #include "eap_type_aka_types.h"
       
    30 
       
    31 #include <mmtsy_names.h>
       
    32 #include <etelmmerr.h>
       
    33 
       
    34 // ================= MEMBER FUNCTIONS =======================
       
    35 
       
    36 CEapAkaInterface::CEapAkaInterface(abs_eap_am_tools_c* const aTools, eap_am_type_aka_symbian_c* const aParent)
       
    37 : CActive(CActive::EPriorityStandard)
       
    38 , iParent(aParent)
       
    39 , m_am_tools(aTools)
       
    40 , iAuthenticationData(NULL)
       
    41 , iQueryId(EQueryNone)
       
    42 , iMMETELConnectionStatus(EFalse)
       
    43 {
       
    44 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
    45 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
    46 }
       
    47 
       
    48 //--------------------------------------------------
       
    49 
       
    50 CEapAkaInterface* CEapAkaInterface::NewL(abs_eap_am_tools_c* const aTools, 
       
    51 											   eap_am_type_aka_symbian_c* const aParent)
       
    52 {
       
    53 	CEapAkaInterface* self = new(ELeave) CEapAkaInterface(aTools, aParent);
       
    54 	CleanupStack::PushL(self);
       
    55 	self->ConstructL();
       
    56 	CleanupStack::Pop();
       
    57 	return self;
       
    58 }
       
    59 
       
    60 //--------------------------------------------------
       
    61 
       
    62 void CEapAkaInterface::ConstructL()
       
    63 {
       
    64 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
    65 	
       
    66 	CActiveScheduler::Add(this);	
       
    67 	
       
    68 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
    69 }
       
    70 
       
    71 //--------------------------------------------------
       
    72 
       
    73 CEapAkaInterface::~CEapAkaInterface()
       
    74 {
       
    75 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
    76 
       
    77 	if(IsActive())
       
    78 	{
       
    79 		Cancel();		
       
    80 	}
       
    81 	
       
    82 	/*
       
    83 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Closing RMobilePhone and MMETEL.\n")));
       
    84 	
       
    85 	iPhone.Close();
       
    86 	iServer.Close(); // Phone module is unloaded automatically when RTelServer session is closed
       
    87 	*/
       
    88 	DisconnectMMETel();
       
    89 	
       
    90 	delete iAuthenticationData;
       
    91 	iAuthenticationData = NULL;		
       
    92 	
       
    93 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
    94 }
       
    95 
       
    96 //--------------------------------------------------
       
    97 
       
    98 void CEapAkaInterface::QueryIMSIL()
       
    99 {	
       
   100 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   101 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("AKA interface: Querying IMSI.\n")));
       
   102 	
       
   103 	iQueryId = EQueryIMSI;
       
   104 		
       
   105 	// Create MMETEl connection.
       
   106 	User::LeaveIfError( CreateMMETelConnectionL() );
       
   107 	
       
   108    	iPhone.GetSubscriberId( iStatus, iSubscriberId ); 
       
   109  	
       
   110 	if( !IsActive() )
       
   111 	{
       
   112 		SetActive();
       
   113 	}  
       
   114 
       
   115 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   116 }
       
   117 
       
   118 //--------------------------------------------------
       
   119 
       
   120 void CEapAkaInterface::QueryRESL( eap_variable_data_c * const aRand, eap_variable_data_c * const aAUTN )
       
   121 {
       
   122 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   123 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("AKA interface: Querying RES, CK, IK and AUTS.\n")));
       
   124 
       
   125 	iQueryId = EQueryRES;
       
   126 
       
   127 	EAP_TRACE_DATA_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT,(EAPL("RAND"),
       
   128 			aRand->get_data(aRand->get_data_length()),
       
   129 			aRand->get_data_length()));
       
   130 			
       
   131 	EAP_TRACE_DATA_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT,(EAPL("AUTN"),
       
   132 			aAUTN->get_data(aAUTN->get_data_length()),
       
   133 			aAUTN->get_data_length()));
       
   134 			
       
   135 	// Rand must be 16 bytes
       
   136 	if (static_cast<u16_t>( aRand->get_data_length() ) != EAP_TYPE_AKA_MINIMUM_RAND_LENGTH)
       
   137 	{
       
   138 		EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("AKA interface: Illegal RAND - Incorrect length.\n")));
       
   139 		User::Leave(KErrArgument);
       
   140 	}
       
   141 
       
   142 	// AUTN must be 16 bytes
       
   143 	if (static_cast<u16_t>( aAUTN->get_data_length() ) != EAP_TYPE_AKA_MINIMUM_AUTN_LENGTH)
       
   144 	{
       
   145 		EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("AKA interface: Illegal AUTN - Incorrect length.\n")));
       
   146 		User::Leave(KErrArgument);
       
   147 	}
       
   148 	
       
   149 	// Create MMETEL connection.
       
   150 	User::LeaveIfError( CreateMMETelConnectionL() );
       
   151 	
       
   152 	// Open CustomAPI.
       
   153 	User::LeaveIfError( iCustomAPI.Open(iPhone) );
       
   154 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("AKA interface: OPENED CUSTOM API \n")));
       
   155 	
       
   156 	u8_t *rand = aRand->get_data(aRand->get_data_length());
       
   157 	u8_t *autn = aAUTN->get_data(aAUTN->get_data_length());
       
   158 	
       
   159 	iEAPAka.iRandomParameters.Copy( rand, EAP_TYPE_AKA_MINIMUM_RAND_LENGTH); //Copy the rand to iEAPAka
       
   160 	
       
   161 	iEAPAka.iAUTN.Copy( autn, EAP_TYPE_AKA_MINIMUM_AUTN_LENGTH); //Copy the AUTN to iEAPAka
       
   162 
       
   163 	//Pack iEAPAka to iAuthenticationData for passing it to the custom API.
       
   164 	iAuthenticationData = new (ELeave) RMmCustomAPI::TAkaDataPckg( iEAPAka );
       
   165 	
       
   166 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("AKA interface: Before querying CustomAPI GetWlanSimAuthenticationData \n")));
       
   167 		
       
   168     iCustomAPI.GetWlanSimAuthenticationData( iStatus, *iAuthenticationData );	
       
   169     
       
   170 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("AKA interface: After querying CustomAPI. iStatus.Int() =%d \n"), iStatus.Int() ));
       
   171     
       
   172 	if( !IsActive() )
       
   173 	{
       
   174 		SetActive();
       
   175 	}  
       
   176 
       
   177 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   178 }
       
   179 
       
   180 //--------------------------------------------------
       
   181  
       
   182 void CEapAkaInterface::DoCancel()
       
   183 {
       
   184 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("CEapAkaInterface::DoCancel() - Cancelling MMETEL query.\n") ) );
       
   185 
       
   186 	// Cancel the request.
       
   187 	iCustomAPI.CancelAsyncRequest( ECustomGetSimAuthenticationDataIPC );
       
   188 	
       
   189 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("CEapAkaInterface::DoCancel(): CANCELLED CUSTOM API REQUEST \n")));
       
   190 }
       
   191 
       
   192 //--------------------------------------------------
       
   193 
       
   194 void CEapAkaInterface::RunL()
       
   195 {
       
   196 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   197 	
       
   198 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("CEapAkaInterface::RunL(). iStatus.Int() =%d \n"), iStatus.Int() ));
       
   199 
       
   200 	
       
   201 	TInt error = KErrNone;
       
   202 	eap_status_e completion_status = eap_status_ok;
       
   203 	eap_status_e AuthenticationStatus = eap_status_ok;
       
   204 	
       
   205 	eap_variable_data_c imsi(m_am_tools); // Keeping it here to avoid "error" in ARMV5 build.
       
   206 	
       
   207 	// This is to store the IMSI, which is in Unicode form.
       
   208 	eap_variable_data_c imsiInUnicode(m_am_tools); // Keeping it here to avoid "error" in ARMV5 build.
       
   209 	
       
   210 	eap_variable_data_c res(m_am_tools);
       
   211 	eap_variable_data_c ck(m_am_tools);
       
   212 	eap_variable_data_c ik(m_am_tools);
       
   213 	eap_variable_data_c auts(m_am_tools);	
       
   214 	
       
   215 	if (iStatus.Int() == KErrNone)
       
   216 	{	
       
   217 		switch( iQueryId )
       
   218 		{
       
   219 			case EQueryIMSI:
       
   220 				EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("AKA interface: Got IMSI reply.\n")));
       
   221 						
       
   222 				EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("IMSI"),
       
   223 						iSubscriberId.Ptr(),
       
   224 						iSubscriberId.Size()));
       
   225 				
       
   226 				// Convert the IMSI from unicode to UTF8 characters.
       
   227 
       
   228 				completion_status = imsiInUnicode.set_buffer(iSubscriberId.Ptr(), iSubscriberId.Size(), false, false);
       
   229 
       
   230 				if (completion_status != eap_status_ok)
       
   231 				{
       
   232 					imsiInUnicode.reset();
       
   233 					EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("AKA interface: Could not set buffer for IMSI.\n")));
       
   234 					
       
   235 					// No need to continue. The request will be completed towards the end, in this kind of error situation.
       
   236 					break;
       
   237 				}
       
   238 				
       
   239 				completion_status = m_am_tools->convert_unicode_to_utf8(imsi, imsiInUnicode);
       
   240 				
       
   241 				if (completion_status != eap_status_ok)
       
   242 				{
       
   243 					imsi.reset();
       
   244 					EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("AKA interface: Could not convert IMSI from UNICODE to UTF8.\n")));
       
   245 					break;					
       
   246 				}
       
   247 				
       
   248 				// Complete. This happens only if completion_status is eap_status_ok so far.
       
   249 				TRAP(error, iParent->complete_AKA_imsi_L(&imsi, completion_status));
       
   250 			
       
   251 			break;
       
   252 			
       
   253 			case EQueryRES:
       
   254 				EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("####AKA interface: Got RES, CK, IK and AUTS reply. ####\n")));			
       
   255 				
       
   256 				EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("RES"),
       
   257 						iEAPAka.iRES.Ptr(),
       
   258 						iEAPAka.iRES.Size()));
       
   259 						
       
   260 				EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("CK"),
       
   261 						iEAPAka.iCK.Ptr(),
       
   262 						iEAPAka.iCK.Size()));
       
   263 
       
   264 				EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("IK"),
       
   265 						iEAPAka.iIK.Ptr(),
       
   266 						iEAPAka.iIK.Size()));
       
   267 						
       
   268 				EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("AUTS"),
       
   269 						iEAPAka.iAUTS.Ptr(),
       
   270 						iEAPAka.iAUTS.Size()));
       
   271 										
       
   272 				delete iAuthenticationData;
       
   273 				iAuthenticationData = NULL;	
       
   274 						
       
   275 				// Close the custom API since we don't need it any more.
       
   276 				iCustomAPI.Close();				
       
   277 				EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("CEapAkaInterface::RunL() - KErrNone case: CLOSED CUSTOM API \n")));
       
   278 				
       
   279 				completion_status = res.set_buffer(iEAPAka.iRES.Ptr(), iEAPAka.iRES.Size(), false, false);
       
   280 				if (completion_status != eap_status_ok)
       
   281 				{
       
   282 					res.reset();
       
   283 					EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("AKA interface: Could not set buffer for RES.\n")));
       
   284 					break;
       
   285 				}
       
   286 
       
   287 				completion_status = ck.set_buffer(iEAPAka.iCK.Ptr(), iEAPAka.iCK.Size(), false, false);
       
   288 				if (completion_status != eap_status_ok)
       
   289 				{
       
   290 					ck.reset();
       
   291 					EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("AKA interface: Could not set buffer for CK.\n")));
       
   292 					break;
       
   293 				}
       
   294 
       
   295 				completion_status = ik.set_buffer(iEAPAka.iIK.Ptr(), iEAPAka.iIK.Size(), false, false);
       
   296 				if (completion_status != eap_status_ok)
       
   297 				{
       
   298 					ik.reset();
       
   299 					EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("AKA interface: Could not set buffer for IK.\n")));
       
   300 					break;
       
   301 				}
       
   302 
       
   303 				completion_status = auts.set_buffer(iEAPAka.iAUTS.Ptr(), iEAPAka.iAUTS.Size(), false, false);
       
   304 				if (completion_status != eap_status_ok)
       
   305 				{
       
   306 					auts.reset();
       
   307 					EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("AKA interface: Could not set buffer for AUTS.\n")));
       
   308 					break;
       
   309 				}
       
   310 			
       
   311 				// Complete. This happens only if completion_status is eap_status_ok so far.		
       
   312 				TRAP(error, iParent->complete_AKA_RES_L( &res, &ck, &ik, &auts ) );			
       
   313 			
       
   314 			break;
       
   315 		}
       
   316 	} 
       
   317 	else 
       
   318 	{
       
   319 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("AKA interface: Got error reply.\n")));	
       
   320 	
       
   321 		switch( iQueryId )
       
   322 		{
       
   323 			case EQueryIMSI:
       
   324 			
       
   325 				// Error with IMSI. Reset it and complete the request.			
       
   326 				imsi.reset();
       
   327 				EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("AKA interface: Error in IMSI.\n")));
       
   328 							
       
   329 				TRAP(error, iParent->complete_AKA_imsi_L(&imsi));
       
   330 			break;
       
   331 			
       
   332 			case EQueryRES:
       
   333 			
       
   334 				// Re-synchronization needed or error with RES or CK or IK.
       
   335 				
       
   336 				// We have to close the custom API anyway. 
       
   337 				iCustomAPI.Close();				
       
   338 				EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("CEapAkaInterface::RunL() - error case: CLOSED CUSTOM API \n")));
       
   339 				
       
   340 				// Just to verify if there is any values set.
       
   341 				
       
   342 				EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("RES"),
       
   343 						iEAPAka.iRES.Ptr(),
       
   344 						iEAPAka.iRES.Size()));
       
   345 						
       
   346 				EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("CK"),
       
   347 						iEAPAka.iCK.Ptr(),
       
   348 						iEAPAka.iCK.Size()));
       
   349 
       
   350 				EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("IK"),
       
   351 						iEAPAka.iIK.Ptr(),
       
   352 						iEAPAka.iIK.Size()));
       
   353 						
       
   354 				EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("AUTS"),
       
   355 						iEAPAka.iAUTS.Ptr(),
       
   356 						iEAPAka.iAUTS.Size()));				
       
   357 				
       
   358 				// Complete the request after resetting res, ck and ik.
       
   359 				// auts might have some value if the error is related to re-synchronization. So don't reset it.
       
   360 				res.reset();
       
   361 				ck.reset();
       
   362 				ik.reset();
       
   363 				
       
   364 				completion_status = auts.set_buffer(iEAPAka.iAUTS.Ptr(), iEAPAka.iAUTS.Size(), false, false);
       
   365 				if (completion_status != eap_status_ok)
       
   366 				{
       
   367 					auts.reset();
       
   368 					EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("AKA interface: Could not set buffer for AUTS.\n")));
       
   369 					break;
       
   370 				}
       
   371 				
       
   372 				// Check if the failure is due to re-synchronization fail.
       
   373 				if(	iStatus.Int() == KErrMMEtelSqnVerificationFailed ) 
       
   374 				{
       
   375 					// Re-synchronization failure.
       
   376 					AuthenticationStatus = eap_status_syncronization_failure;
       
   377 				}
       
   378 				else
       
   379 				{
       
   380 					// Authentication failed. Errors could be KErrMMEtelMacVerificationFailed or KErrMMEtelAuthenticateFailed also.
       
   381 					AuthenticationStatus = eap_status_authentication_failure;
       
   382 				}
       
   383 			
       
   384 				// Complete. This happens only if completion_status is eap_status_ok so far.
       
   385 				TRAP(error, iParent->complete_AKA_RES_L( &res, &ck, &ik, &auts, AuthenticationStatus, completion_status ) );
       
   386 			break;
       
   387 		}
       
   388 	}
       
   389 	
       
   390 	if( completion_status != eap_status_ok  && iQueryId == EQueryIMSI )
       
   391 	{
       
   392 		TRAP(error, iParent->complete_AKA_imsi_L(&imsi, completion_status));		
       
   393 	}
       
   394 
       
   395 	if( completion_status != eap_status_ok  && iQueryId == EQueryRES )
       
   396 	{
       
   397 		TRAP(error, iParent->complete_AKA_RES_L( &res, &ck, &ik, &auts, AuthenticationStatus, completion_status ) );
       
   398 	}	
       
   399 
       
   400 	DisconnectMMETel();
       
   401 	
       
   402 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   403 }
       
   404 
       
   405 TInt CEapAkaInterface::CreateMMETelConnectionL()
       
   406 {
       
   407 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   408 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Creating MMETel connection.\n")));
       
   409 
       
   410 	TInt errorCode = KErrNone;
       
   411 	
       
   412 	// MMETel need to be connected only once.    
       
   413     if( !iMMETELConnectionStatus )
       
   414     {
       
   415 		RTelServer::TPhoneInfo phoneInfo;
       
   416 		TInt phoneCount = 0;
       
   417 
       
   418 		// Connect to ETel server
       
   419 		User::LeaveIfError( iServer.Connect() ); 	
       
   420 		
       
   421 	    EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Connected to ETel server.\n")));	
       
   422 
       
   423 		// This function loads an ETel TSY module, mmtsy.
       
   424 		errorCode = iServer.LoadPhoneModule( KMmTsyModuleName );	
       
   425 		
       
   426 	    EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Loaded phone module.\n")));	    
       
   427 		
       
   428 		if ( errorCode != KErrNone && errorCode != KErrAlreadyExists )
       
   429 		{
       
   430 			User::Leave( errorCode );
       
   431 		}
       
   432 
       
   433 		iServer.SetExtendedErrorGranularity( RTelServer::EErrorExtended );
       
   434 
       
   435 		// This function retrieves the total number of phones supported by all 
       
   436 		// the currently loaded ETel (TSY) modules.
       
   437 		User::LeaveIfError( iServer.EnumeratePhones( phoneCount ) );	
       
   438 		
       
   439 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Number of phones supported by the loaded ETel = %d.\n"), phoneCount));
       
   440 		
       
   441 		// This function retrieves information associated with the specified phone
       
   442 		while ( ( phoneCount-- ) && ( phoneInfo.iName != KMmTsyPhoneName ) ) 
       
   443 		{ 
       
   444 			User::LeaveIfError( iServer.GetPhoneInfo( phoneCount, phoneInfo ) );		
       
   445 			
       
   446 		    EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Got phone info.\n")));
       
   447 		} 
       
   448 
       
   449 		// This function opens a phone subsession by name. ("DefaultPhone").
       
   450 		User::LeaveIfError( iPhone.Open( iServer, phoneInfo.iName ) );	
       
   451 		
       
   452 	    EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Opened phone subsession.\n")));
       
   453 		
       
   454 		// MMETel connected and the phone module loaded fine.	
       
   455 		iMMETELConnectionStatus = ETrue; 	
       
   456     }
       
   457     else
       
   458     {
       
   459     	// MMETel already connected.
       
   460 	    EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("MMETel connected once already.\n")));
       
   461     }
       
   462 	    
       
   463 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   464     
       
   465     return errorCode;	
       
   466 }
       
   467 
       
   468 void CEapAkaInterface::DisconnectMMETel()
       
   469 {
       
   470     if( iMMETELConnectionStatus )
       
   471     {
       
   472 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Closing RMobilePhone and MMETEL.\n")));
       
   473 		
       
   474 		iPhone.Close();
       
   475 		iServer.Close(); // Phone module is unloaded automatically when RTelServer session is closed
       
   476 		
       
   477 		iMMETELConnectionStatus = EFalse;
       
   478     }
       
   479     else
       
   480     {
       
   481 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("RMobilePhone and MMETEL already closed.\n")));    	
       
   482     }	
       
   483 }
       
   484 
       
   485 // End of file