eapol/eapol_framework/eapol_symbian/am/type/gsmsim/symbian/EapSimInterface.cpp
branchRCL_3
changeset 17 30e048a7b597
parent 2 1c7bc153c08e
child 18 bad0cc58d154
equal deleted inserted replaced
15:75a6055b8ce3 17:30e048a7b597
    14 * Description:  EAP and WLAN authentication protocols.
    14 * Description:  EAP and WLAN authentication protocols.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 /*
    18 /*
    19 * %version: 15 %
    19 * %version: 15.1.5 %
    20 */
    20 */
    21 
    21 
    22 // This is enumeration of EAPOL source code.
    22 // This is enumeration of EAPOL source code.
    23 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
    23 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
    24 	#undef EAP_FILE_NUMBER_ENUM
    24 	#undef EAP_FILE_NUMBER_ENUM
    28 #endif //#if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
    28 #endif //#if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
    29 
    29 
    30 
    30 
    31 // INCLUDE FILES
    31 // INCLUDE FILES
    32 #include "EapSimInterface.h"
    32 #include "EapSimInterface.h"
       
    33 #include "eap_automatic_variable.h"
    33 
    34 
    34 #include <mmtsy_names.h>
    35 #include <mmtsy_names.h>
    35 #include "eap_sim_triplets.h" // For SIM_SRES_LENGTH.
    36 #include "eap_sim_triplets.h" // For SIM_SRES_LENGTH.
    36 
    37 
    37 
    38 
    44 , iAuthenticationData(NULL)
    45 , iAuthenticationData(NULL)
    45 , iQueryId(EQueryNone)
    46 , iQueryId(EQueryNone)
    46 , iMMETELConnectionStatus(EFalse)
    47 , iMMETELConnectionStatus(EFalse)
    47 {
    48 {
    48 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
    49 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
    50 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("CEapSimIsaInterface::CEapSimIsaInterface()\n")));
       
    51 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: CEapSimIsaInterface::CEapSimIsaInterface()");
    49 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
    52 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
    50 }
    53 }
    51 
    54 
    52 //--------------------------------------------------
    55 //--------------------------------------------------
    53 
    56 
    75 //--------------------------------------------------
    78 //--------------------------------------------------
    76 
    79 
    77 CEapSimIsaInterface::~CEapSimIsaInterface()
    80 CEapSimIsaInterface::~CEapSimIsaInterface()
    78 {
    81 {
    79 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
    82 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
    83 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("CEapSimIsaInterface::~CEapSimIsaInterface()\n")));
       
    84 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: CEapSimIsaInterface::~CEapSimIsaInterface()");
    80 
    85 
    81 	if(IsActive())
    86 	if(IsActive())
    82 	{
    87 	{
    83 		Cancel();		
    88 		Cancel();
    84 	}
    89 	}
    85 	
    90 	
    86 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Closing RMobilePhone and MMETEL.\n")));
    91 	DisconnectMMETel();
    87 	
    92 
    88 	iPhone.Close();
       
    89 	iServer.Close(); // Phone module is unloaded automatically when RTelServer session is closed
       
    90 		
       
    91 	delete iAuthenticationData;
    93 	delete iAuthenticationData;
    92 	iAuthenticationData = NULL;
    94 	iAuthenticationData = NULL;
    93 		
    95 		
    94 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
    96 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
    95 }
    97 }
    97 //--------------------------------------------------
    99 //--------------------------------------------------
    98 
   100 
    99 void CEapSimIsaInterface::QueryIMSIL()
   101 void CEapSimIsaInterface::QueryIMSIL()
   100 {	
   102 {	
   101 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   103 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   102 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ISA interface: Querying IMSI.\n")));
   104 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("CEapSimIsaInterface::QueryIMSIL()\n")));
   103 	
   105 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: CEapSimIsaInterface::QueryIMSIL()");
       
   106 
   104 	iQueryId = EQueryIMSI;
   107 	iQueryId = EQueryIMSI;
   105 
   108 
   106 	// Create MMETEl connection.
   109 	// Create MMETEl connection.
   107 	User::LeaveIfError( CreateMMETelConnectionL() );
   110 	User::LeaveIfError( CreateMMETelConnectionL() );
   108 	
   111 	
   119 //--------------------------------------------------
   122 //--------------------------------------------------
   120 
   123 
   121 void CEapSimIsaInterface::QueryKcAndSRESL(const TDesC8& aRand)
   124 void CEapSimIsaInterface::QueryKcAndSRESL(const TDesC8& aRand)
   122 {
   125 {
   123 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   126 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   124 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ISA interface: Querying Kc and SRES.\n")));
   127 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("CEapSimIsaInterface::QueryKcAndSRESL()\n")));
       
   128 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: CEapSimIsaInterface::QueryKcAndSRESL()");
   125 
   129 
   126 	iQueryId = EQuerySRESandKC;
   130 	iQueryId = EQuerySRESandKC;
   127 
   131 
   128 	EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("RAND"),
   132 	EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("RAND"),
   129 			aRand.Ptr(),
   133 			aRand.Ptr(),
   159 
   163 
   160 //--------------------------------------------------
   164 //--------------------------------------------------
   161  
   165  
   162 void CEapSimIsaInterface::DoCancel()
   166 void CEapSimIsaInterface::DoCancel()
   163 {
   167 {
   164 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("CEapSimIsaInterface::DoCancel() - Cancelling MMETEL query.\n") ) );
   168 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("CEapSimIsaInterface::DoCancel(): iQueryId=%d\n"),
   165 	
   169 		iQueryId) );
   166 	// Cancel the request.
   170 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: CEapSimIsaInterface::DoCancel()");
   167 	iCustomAPI.CancelAsyncRequest( ECustomGetSimAuthenticationDataIPC );
   171 
       
   172 	if (iQueryId == EQuerySRESandKC)
       
   173 	{
       
   174 		iQueryId = EQueryNone;
       
   175 
       
   176 		// Cancel the request.
       
   177 		iCustomAPI.CancelAsyncRequest( ECustomGetSimAuthenticationDataIPC );
       
   178 
       
   179 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("CEapSimIsaInterface::DoCancel(): CANCELLED CUSTOM API REQUEST\n") ) );
       
   180 	}
   168 }
   181 }
   169 
   182 
   170 //--------------------------------------------------
   183 //--------------------------------------------------
   171 
   184 
   172 void CEapSimIsaInterface::RunL()
   185 void CEapSimIsaInterface::RunL()
   173 {
   186 {
   174 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   187 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   175 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("CEapSimIsaInterface::RunL(). iStatus.Int() =%d \n"), iStatus.Int() ));
   188 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("CEapSimIsaInterface::RunL(). iStatus.Int()=%d, iQueryId=%d\n"),
   176 	
   189 		iStatus.Int(),
       
   190 		iQueryId));
       
   191 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: CEapSimIsaInterface::RunL()");
       
   192 
   177 	TInt error = KErrNone;
   193 	TInt error = KErrNone;
   178 	eap_variable_data_c imsi(m_am_tools); // Keeping it here to avoid "error" in ARMV5 build.
   194 	eap_variable_data_c imsi(m_am_tools); // Keeping it here to avoid "error" in ARMV5 build.
   179 	
   195 	
   180 	// This is to store the IMSI, which is in Unicode form.
   196 	// This is to store the IMSI, which is in Unicode form.
   181 	eap_variable_data_c imsiInUnicode(m_am_tools); // Keeping it here to avoid "error" in ARMV5 build.
   197 	eap_variable_data_c imsiInUnicode(m_am_tools); // Keeping it here to avoid "error" in ARMV5 build.
   191 				EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ISA interface: Got IMSI reply.\n")));
   207 				EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ISA interface: Got IMSI reply.\n")));
   192 						
   208 						
   193 				EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("IMSI"),
   209 				EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("IMSI"),
   194 						iSubscriberId.Ptr(),
   210 						iSubscriberId.Ptr(),
   195 						iSubscriberId.Size()));
   211 						iSubscriberId.Size()));
   196 				
   212 
       
   213 				iQueryId = EQueryNone;
       
   214 
   197 				// Convert the IMSI from unicode to UTF8 characters.
   215 				// Convert the IMSI from unicode to UTF8 characters.
   198 
   216 
   199 				completion_status = imsiInUnicode.set_buffer(iSubscriberId.Ptr(), iSubscriberId.Size(), false, false);
   217 				completion_status = imsiInUnicode.set_buffer(iSubscriberId.Ptr(), iSubscriberId.Size(), false, false);
   200 
   218 
   201 				if (completion_status != eap_status_ok)
   219 				if (completion_status != eap_status_ok)
   211 					{
   229 					{
   212 						imsi.reset();
   230 						imsi.reset();
   213 						EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ISA interface: Could not convert IMSI from UNICODE to UTF8. Not proceeding further here.\n")));
   231 						EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ISA interface: Could not convert IMSI from UNICODE to UTF8. Not proceeding further here.\n")));
   214 					}
   232 					}
   215 				}
   233 				}
   216 							
   234 
       
   235 				DisconnectMMETel();
       
   236 
   217 				TRAP(error, iParent->complete_SIM_imsi_L(&imsi, completion_status));
   237 				TRAP(error, iParent->complete_SIM_imsi_L(&imsi, completion_status));
   218 			
   238 			
   219 			break;
   239 			break;
   220 			
   240 			
   221 			case EQuerySRESandKC:
   241 			case EQuerySRESandKC:
   227 						
   247 						
   228 				EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("KC"),
   248 				EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("KC"),
   229 						iEAPSim.iKC.Ptr(),
   249 						iEAPSim.iKC.Ptr(),
   230 						iEAPSim.iKC.Size()));
   250 						iEAPSim.iKC.Size()));
   231 						
   251 						
       
   252 				iQueryId = EQueryNone;
       
   253 
   232 				// Trim the length of SRES -  Remove once the correct length is set for SRES, may be by the API or some where else.
   254 				// Trim the length of SRES -  Remove once the correct length is set for SRES, may be by the API or some where else.
   233 				iEAPSim.iSRES.SetLength(SIM_SRES_LENGTH);
   255 				iEAPSim.iSRES.SetLength(SIM_SRES_LENGTH);
   234 				EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("SRES after Trimming"),
   256 				EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("SRES after Trimming"),
   235 						iEAPSim.iSRES.Ptr(),
   257 						iEAPSim.iSRES.Ptr(),
   236 						iEAPSim.iSRES.Size()));				
   258 						iEAPSim.iSRES.Size()));				
   237 								
   259 								
   238 				delete iAuthenticationData;
   260 				delete iAuthenticationData;
   239 				iAuthenticationData = NULL;
   261 				iAuthenticationData = NULL;
   240 							
   262 							
   241 				// Close the custom API since we don't need it any more.
   263 				DisconnectMMETel();
   242 				iCustomAPI.Close();
   264 
   243 			
       
   244 				// Complete
   265 				// Complete
   245 				TRAP(error, iParent->complete_SIM_kc_and_sres_L(iEAPSim.iKC, iEAPSim.iSRES, completion_status));			
   266 				TRAP(error, iParent->complete_SIM_kc_and_sres_L(iEAPSim.iKC, iEAPSim.iSRES, completion_status));			
   246 			
   267 			
   247 			break;
   268 			break;
   248 		}
   269 		}
   251 	{
   272 	{
   252 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ISA interface: Got error reply.\n")));
   273 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ISA interface: Got error reply.\n")));
   253 		
   274 		
   254 		if( EQuerySRESandKC == iQueryId )
   275 		if( EQuerySRESandKC == iQueryId )
   255 		{
   276 		{
   256 			// We have to close the custom API anyway. 
   277 			iQueryId = EQueryNone;
   257 			// Rest will be taken care in destructor.
   278 
   258 			iCustomAPI.Close();	
   279 			DisconnectMMETel();
   259 			
   280 			
   260 			// Handle duplicate RAND values.
   281 			// Handle duplicate RAND values.
   261 			// If duplicate RAND values are being used, we get KErrArgument here.
   282 			// If duplicate RAND values are being used, we get KErrArgument here.
   262 			if(iStatus.Int() == KErrArgument)
   283 			if(iStatus.Int() == KErrArgument)
   263 			{
   284 			{
   274 		}
   295 		}
   275 		else if(EQueryIMSI == iQueryId)
   296 		else if(EQueryIMSI == iQueryId)
   276 		{
   297 		{
   277 			completion_status = m_am_tools->convert_am_error_to_eapol_error(iStatus.Int());
   298 			completion_status = m_am_tools->convert_am_error_to_eapol_error(iStatus.Int());
   278 			
   299 			
       
   300 			iQueryId = EQueryNone;
       
   301 
       
   302 			DisconnectMMETel();
       
   303 
   279 			TRAP(error, iParent->complete_SIM_imsi_L(&imsi, completion_status));
   304 			TRAP(error, iParent->complete_SIM_imsi_L(&imsi, completion_status));
   280 		}
   305 		}
   281 	}	
   306 	}	
   282 	
   307 
   283 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   308 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   284 }
   309 }
       
   310 
       
   311 //--------------------------------------------------
   285 
   312 
   286 TInt CEapSimIsaInterface::CreateMMETelConnectionL()
   313 TInt CEapSimIsaInterface::CreateMMETelConnectionL()
   287 {
   314 {
   288 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   315 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   289 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Creating MMETel connection.\n")));
   316 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("CEapSimIsaInterface::CreateMMETelConnectionL()\n")));
       
   317 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: CEapSimIsaInterface::CreateMMETelConnectionL()");
   290 
   318 
   291 	TInt errorCode = KErrNone;
   319 	TInt errorCode = KErrNone;
   292 	
   320 	
   293 	// MMETel need to be connected only once.    
   321 	// MMETel need to be connected only once.    
   294     if( !iMMETELConnectionStatus )
   322     if( !iMMETELConnectionStatus )
   344 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   372 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   345     
   373     
   346     return errorCode;	
   374     return errorCode;	
   347 }
   375 }
   348 
   376 
       
   377 void CEapSimIsaInterface::DisconnectMMETel()
       
   378 {
       
   379 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("CEapSimIsaInterface::DisconnectMMETel()\n")));
       
   380 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: CEapSimIsaInterface::DisconnectMMETel()");
       
   381 
       
   382 	iQueryId = EQueryNone;
       
   383 
       
   384 	// Close the custom API since we don't need it any more.
       
   385 	iCustomAPI.Close();
       
   386 
       
   387     if( iMMETELConnectionStatus )
       
   388     {
       
   389 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Closing RMobilePhone and MMETEL.\n")));
       
   390 		
       
   391 		iPhone.Close();
       
   392 		iServer.Close(); // Phone module is unloaded automatically when RTelServer session is closed
       
   393 		
       
   394 		iMMETELConnectionStatus = EFalse;
       
   395     }
       
   396     else
       
   397     {
       
   398 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("RMobilePhone and MMETEL already closed.\n")));    	
       
   399     }	
       
   400 }
       
   401 
       
   402 
   349 // End of file
   403 // End of file