telephonyserverplugins/simtsy/src/csimsmartcardeap.cpp
branchRCL_3
changeset 65 630d2f34d719
parent 0 3553901f7fa8
child 66 07a122eea281
equal deleted inserted replaced
61:17af172ffa5f 65:630d2f34d719
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    17 
    17 
    18 /**
    18 /**
    19  @file
    19  @file
    20 */
    20 */
    21 
    21 
       
    22 
       
    23 
       
    24 #include "OstTraceDefinitions.h"
       
    25 #ifdef OST_TRACE_COMPILER_IN_USE
       
    26 #include "csimsmartcardeapTraces.h"
       
    27 #endif
       
    28 
    22 #include <testconfigfileparser.h>
    29 #include <testconfigfileparser.h>
    23 #include "csimsmartcardeap.h"
    30 #include "csimsmartcardeap.h"
    24 #include "Simlog.h"
       
    25 #include "etelext.h"
    31 #include "etelext.h"
    26 
    32 
    27 // CSimSmartCardEapManager implementation; related to CSimSmartCardEap //
    33 // CSimSmartCardEapManager implementation; related to CSimSmartCardEap //
    28 
    34 
    29 /**
    35 /**
    66 /**
    72 /**
    67 Second-phase constructor.
    73 Second-phase constructor.
    68 */
    74 */
    69 void CSimSmartCardEapManager::ConstructL()
    75 void CSimSmartCardEapManager::ConstructL()
    70 	{
    76 	{
    71 	LOGPHONE1("CSimSmartCardEapManager second phase construction created");
    77 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_CONSTRUCTL_1, "CSimSmartCardEapManager second phase construction created");
    72 
    78 
    73 	ParseEapInfoL();
    79 	ParseEapInfoL();
    74 
    80 
    75 	LOGPHONE1("CSimSmartCardEapManager second phase construction completed");
    81 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_CONSTRUCTL_2, "CSimSmartCardEapManager second phase construction completed");
    76 	}
    82 	}
    77 
    83 
    78 /**
    84 /**
    79 If this is destroyed then so should all EAP sub-session objects.
    85 If this is destroyed then so should all EAP sub-session objects.
    80 */
    86 */
    81 CSimSmartCardEapManager::~CSimSmartCardEapManager()
    87 CSimSmartCardEapManager::~CSimSmartCardEapManager()
    82 	{
    88 	{
    83 	LOGPHONE1("CSimSmartCardEapManager destructing");
    89 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_DTOR_1, "CSimSmartCardEapManager destructing");
    84 
    90 
    85 	for (TInt jj = iSubSessionObjs.Count()-1; jj >= 0; jj--)
    91 	for (TInt jj = iSubSessionObjs.Count()-1; jj >= 0; jj--)
    86 		{
    92 		{
    87 		delete iSubSessionObjs[jj];
    93 		delete iSubSessionObjs[jj];
    88 		}
    94 		}
    89 
    95 
    90 	iSubSessionObjs.Close();
    96 	iSubSessionObjs.Close();
    91 
    97 
    92 	ClearParsedData();
    98 	ClearParsedData();
    93 
    99 
    94 	LOGPHONE1("CSimSmartCardEapManager destructed");
   100 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_DTOR_2, "CSimSmartCardEapManager destructed");
    95 	}
   101 	}
    96 
   102 
    97 void CSimSmartCardEapManager::ClearParsedData()
   103 void CSimSmartCardEapManager::ClearParsedData()
    98 	{
   104 	{
    99 	// Cleanup remaining unused parsed EAP procedure data
   105 	// Cleanup remaining unused parsed EAP procedure data
   134 /**
   140 /**
   135 Parses the UICC App EAP specific settings from the config.txt.
   141 Parses the UICC App EAP specific settings from the config.txt.
   136 */
   142 */
   137 void CSimSmartCardEapManager::ParseEapInfoL()
   143 void CSimSmartCardEapManager::ParseEapInfoL()
   138 	{
   144 	{
   139 	LOGPHONE1("CSimSmartCardEapManager::ParseEapInfoL called");
   145 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_1, "CSimSmartCardEapManager::ParseEapInfoL called");
   140 
   146 
   141 	CTestConfigItem* item = NULL;
   147 	CTestConfigItem* item = NULL;
   142 
   148 
   143 	LOGPHONE1("Starting to Parse Smart Card EAP Info");
   149 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_2, "Starting to Parse Smart Card EAP Info");
   144 	TInt count = CfgFile()->ItemCount(KScEapProcedures);
   150 	TInt count = CfgFile()->ItemCount(KScEapProcedures);
   145 
   151 
   146 	// Used in parsing to keep track of the nested items
   152 	// Used in parsing to keep track of the nested items
   147 	TInt nestedKeyTag = 0;
   153 	TInt nestedKeyTag = 0;
   148 	TInt nestedExtKeyTag = 0;
   154 	TInt nestedExtKeyTag = 0;
   161 	for (TInt index = 0; index < count; index++)
   167 	for (TInt index = 0; index < count; index++)
   162 		{
   168 		{
   163 		item = const_cast<CTestConfigItem*>(CfgFile()->Item(KScEapProcedures, index));
   169 		item = const_cast<CTestConfigItem*>(CfgFile()->Item(KScEapProcedures, index));
   164 		if(item == NULL)
   170 		if(item == NULL)
   165 			{
   171 			{
   166 			LOGPHONE2("WARNING CONFIGURATION FILE PARSING: SC EAP PROC INFO tag not read [%d]", index);
   172 			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_3, "WARNING CONFIGURATION FILE PARSING: SC EAP PROC INFO tag not read [%d]", index);
   167 			continue;
   173 			continue;
   168 			}
   174 			}
   169 
   175 
   170 		TInt dataFrmt = 0;
   176 		TInt dataFrmt = 0;
   171 		TInt numChallenges = 0;
   177 		TInt numChallenges = 0;
   177 
   183 
   178 		// Get AID; convert to bin if required
   184 		// Get AID; convert to bin if required
   179 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 0, appId);
   185 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 0, appId);
   180 		if(ret != KErrNone)
   186 		if(ret != KErrNone)
   181 			{
   187 			{
   182 			LOGPARSERR("appId", ret,0,&KScEapProcedures);
   188 			OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_4, "WARNING - CONFIGURATION FILE PARSING - Reading element APPID returned %d (element no. %d) from tag %s.", ret,0,KScEapProcedures);
   183 			continue;
   189 			continue;
   184 			}
   190 			}
   185 		else
   191 		else
   186 			{
   192 			{
   187 			procInfo.iAID = appId;
   193 			procInfo.iAID = appId;
   192 
   198 
   193 		// Get eap type
   199 		// Get eap type
   194 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 1, eapType);
   200 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 1, eapType);
   195 		if(ret != KErrNone)
   201 		if(ret != KErrNone)
   196 			{
   202 			{
   197 			LOGPARSERR("eapType", ret,1,&KScEapProcedures);
   203 			OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_5, "WARNING - CONFIGURATION FILE PARSING - Reading element EAPTYPE returned %d (element no. %d) from tag %s.", ret,1,KScEapProcedures);
   198 			continue;
   204 			continue;
   199 			}
   205 			}
   200 		else
   206 		else
   201 			{
   207 			{
   202 			// EAP type is always in ASCII
   208 			// EAP type is always in ASCII
   205 
   211 
   206 		// Find number of challenges
   212 		// Find number of challenges
   207 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 2, numChallenges);
   213 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 2, numChallenges);
   208 		if(ret != KErrNone)
   214 		if(ret != KErrNone)
   209 			{
   215 			{
   210 			LOGPARSERR("numChallenges", ret,2,&KScEapProcedures);
   216 			OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_6, "WARNING - CONFIGURATION FILE PARSING - Reading element NUMCHALLENGES returned %d (element no. %d) from tag %s.", ret,2,KScEapProcedures);
   211 			continue;
   217 			continue;
   212 			}
   218 			}
   213 		else if (numChallenges > (countChl - nestedChlTag))
   219 		else if (numChallenges > (countChl - nestedChlTag))
   214 			{
   220 			{
   215 			LOGPHONE2("ERROR CONFIGURATION FILE PARSING: error SC EAP PROC INFO specifies more challenges than available [%d]", index);
   221 			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_7, "ERROR CONFIGURATION FILE PARSING: error SC EAP PROC INFO specifies more challenges than available [%d]", index);
   216 			continue;
   222 			continue;
   217 			}
   223 			}
   218 		else if (numChallenges < 0)
   224 		else if (numChallenges < 0)
   219 			{
   225 			{
   220 			LOGPHONE2("ERROR CONFIGURATION FILE PARSING: error SC EAP PROC INFO specifies -ve challenge number [%d]", index);
   226 			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_8, "ERROR CONFIGURATION FILE PARSING: error SC EAP PROC INFO specifies -ve challenge number [%d]", index);
   221 			continue;
   227 			continue;
   222 			}
   228 			}
   223 
   229 
   224 		// Get optional data format; this format is used for all data of this parsed procedure
   230 		// Get optional data format; this format is used for all data of this parsed procedure
   225 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 3, dataFrmt);
   231 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 3, dataFrmt);
   226 		if(ret != KErrNone)
   232 		if(ret != KErrNone)
   227 			{
   233 			{
   228 			LOGPHONE2("CONFIGURATION FILE PARSING: SC EAP PROC INFO tag with no data format [%d]", index);
   234 			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_9, "CONFIGURATION FILE PARSING: SC EAP PROC INFO tag with no data format [%d]", index);
   229 			}
   235 			}
   230 		else if (dataFrmt >= EMaxConfigDataFormat)
   236 		else if (dataFrmt >= EMaxConfigDataFormat)
   231 			{
   237 			{
   232 			LOGPHONE2("WARNING IN CONFIGURATION FILE PARSING - error wrong data format value SC EAP PROC INFO tag [%d] (ASCII format will be used)", index);
   238 			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_10, "WARNING IN CONFIGURATION FILE PARSING - error wrong data format value SC EAP PROC INFO tag [%d] (ASCII format will be used)", index);
   233 			dataFrmt = EConfigDataFormatAscii;
   239 			dataFrmt = EConfigDataFormatAscii;
   234 			}
   240 			}
   235 
   241 
   236 		TPtrC8 ptr;
   242 		TPtrC8 ptr;
   237 		TPtr8 tempPtr(NULL,0);
   243 		TPtr8 tempPtr(NULL,0);
   243 			item = const_cast<CTestConfigItem*>(CfgFile()->Item(KScEapKeyMSK, nestedKeyTag++));
   249 			item = const_cast<CTestConfigItem*>(CfgFile()->Item(KScEapKeyMSK, nestedKeyTag++));
   244 
   250 
   245 			// parse delay and key
   251 			// parse delay and key
   246 			if (item == NULL)
   252 			if (item == NULL)
   247 				{
   253 				{
   248 				LOGPHONE2("WARNING CONFIGURATION FILE PARSING: could not read EAP Key tag [%d]", nestedKeyTag-1);
   254 				OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_11, "WARNING CONFIGURATION FILE PARSING: could not read EAP Key tag [%d]", nestedKeyTag-1);
   249 				}
   255 				}
   250 			else
   256 			else
   251 				{
   257 				{
   252 				ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 0, ptr);
   258 				ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 0, ptr);
   253 				if (ret != KErrNone)
   259 				if (ret != KErrNone)
   254 					{
   260 					{
   255 					LOGPHONE2("WARNING CONFIGURATION FILE PARSING: could not read EAP Key tag's data [%d]", nestedKeyTag-1);
   261 					OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_12, "WARNING CONFIGURATION FILE PARSING: could not read EAP Key tag's data [%d]", nestedKeyTag-1);
   256 					}
   262 					}
   257 				else
   263 				else
   258 					{
   264 					{
   259 					TRAPD(kAllocErr, startData = ptr.AllocL());
   265 					TRAPD(kAllocErr, startData = ptr.AllocL());
   260 					if (kAllocErr != KErrNone)
   266 					if (kAllocErr != KErrNone)
   261 						{
   267 						{
   262 						LOGPHONE2("WARNING CONFIGURATION FILE PARSING: could not allocate mem for EAP Key data [%d]", nestedKeyTag-1);
   268 						OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_13, "WARNING CONFIGURATION FILE PARSING: could not allocate mem for EAP Key data [%d]", nestedKeyTag-1);
   263 						}
   269 						}
   264 					else
   270 					else
   265 						{
   271 						{
   266 						tempPtr.Set(startData->Des());
   272 						tempPtr.Set(startData->Des());
   267 						switch (dataFrmt)
   273 						switch (dataFrmt)
   274 							}
   280 							}
   275 						// need to re-copy because converting to binary changes size
   281 						// need to re-copy because converting to binary changes size
   276 						TRAP(kAllocErr, procInfo.iEapKey = tempPtr.AllocL());
   282 						TRAP(kAllocErr, procInfo.iEapKey = tempPtr.AllocL());
   277 						if (kAllocErr != KErrNone)
   283 						if (kAllocErr != KErrNone)
   278 							{
   284 							{
   279 							LOGPHONE2("WARNING CONFIGURATION FILE PARSING: could not allocate mem for EAP Key data copy [%d]", nestedKeyTag-1);
   285 							OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_14, "WARNING CONFIGURATION FILE PARSING: could not allocate mem for EAP Key data copy [%d]", nestedKeyTag-1);
   280 							}
   286 							}
   281 						delete startData;
   287 						delete startData;
   282 						startData = NULL;
   288 						startData = NULL;
   283 						}
   289 						}
   284 					}
   290 					}
   285 				}
   291 				}
   286 			}
   292 			}
   287 		else
   293 		else
   288 			{
   294 			{
   289 			LOGPHONE1("ERROR CONFIGURATION FILE PARSING: NO SC EAP KEY INFO TAG");
   295 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_15, "ERROR CONFIGURATION FILE PARSING: NO SC EAP KEY INFO TAG");
   290 			}
   296 			}
   291 
   297 
   292 		// Get EMSK
   298 		// Get EMSK
   293 		if (nestedExtKeyTag < countExtKey)
   299 		if (nestedExtKeyTag < countExtKey)
   294 			{
   300 			{
   295 			item = const_cast<CTestConfigItem*>(CfgFile()->Item(KScEapKeyEMSK, nestedExtKeyTag++));
   301 			item = const_cast<CTestConfigItem*>(CfgFile()->Item(KScEapKeyEMSK, nestedExtKeyTag++));
   296 
   302 
   297 			// parse key
   303 			// parse key
   298 			if (item == NULL)
   304 			if (item == NULL)
   299 				{
   305 				{
   300 				LOGPHONE2("WARNING CONFIGURATION FILE PARSING: could not read EAP Ext Key tag [%d]", nestedExtKeyTag-1);
   306 				OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_16, "WARNING CONFIGURATION FILE PARSING: could not read EAP Ext Key tag [%d]", nestedExtKeyTag-1);
   301 				}
   307 				}
   302 			else
   308 			else
   303 				{
   309 				{
   304 				ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 0, ptr);
   310 				ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 0, ptr);
   305 				if (ret != KErrNone)
   311 				if (ret != KErrNone)
   306 					{
   312 					{
   307 					LOGPHONE2("WARNING CONFIGURATION FILE PARSING: could not read EAP Ext Key tag's data [%d]", nestedExtKeyTag-1);
   313 					OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_17, "WARNING CONFIGURATION FILE PARSING: could not read EAP Ext Key tag's data [%d]", nestedExtKeyTag-1);
   308 					}
   314 					}
   309 				else
   315 				else
   310 					{
   316 					{
   311 					TRAPD(kAllocErr, startData = ptr.AllocL());
   317 					TRAPD(kAllocErr, startData = ptr.AllocL());
   312 					if (kAllocErr != KErrNone)
   318 					if (kAllocErr != KErrNone)
   313 						{
   319 						{
   314 						LOGPHONE2("WARNING CONFIGURATION FILE PARSING: could not allocate mem for EAP Ext Key data [%d]", nestedExtKeyTag-1);
   320 						OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_18, "WARNING CONFIGURATION FILE PARSING: could not allocate mem for EAP Ext Key data [%d]", nestedExtKeyTag-1);
   315 						}
   321 						}
   316 					else
   322 					else
   317 						{
   323 						{
   318 						tempPtr.Set(startData->Des());
   324 						tempPtr.Set(startData->Des());
   319 						switch (dataFrmt)
   325 						switch (dataFrmt)
   326 							}
   332 							}
   327 						// need to re-copy because converting to binary changes size
   333 						// need to re-copy because converting to binary changes size
   328 						TRAP(kAllocErr, procInfo.iEapExtKey = tempPtr.AllocL());
   334 						TRAP(kAllocErr, procInfo.iEapExtKey = tempPtr.AllocL());
   329 						if (kAllocErr != KErrNone)
   335 						if (kAllocErr != KErrNone)
   330 							{
   336 							{
   331 							LOGPHONE2("WARNING CONFIGURATION FILE PARSING: could not allocate mem for EAP Ext Key data copy [%d]", nestedExtKeyTag-1);
   337 							OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_19, "WARNING CONFIGURATION FILE PARSING: could not allocate mem for EAP Ext Key data copy [%d]", nestedExtKeyTag-1);
   332 							}
   338 							}
   333 						delete startData;
   339 						delete startData;
   334 						startData = NULL;
   340 						startData = NULL;
   335 						}
   341 						}
   336 					}
   342 					}
   337 				}
   343 				}
   338 			}
   344 			}
   339 		else
   345 		else
   340 			{
   346 			{
   341 			LOGPHONE1("ERROR CONFIGURATION FILE PARSING: NO SC EAP EXT KEY INFO TAG");
   347 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_20, "ERROR CONFIGURATION FILE PARSING: NO SC EAP EXT KEY INFO TAG");
   342 			}
   348 			}
   343 
   349 
   344 		// Get Permanent Identity
   350 		// Get Permanent Identity
   345 		if (nestedIdTag < countId)
   351 		if (nestedIdTag < countId)
   346 			{
   352 			{
   347 			item = const_cast<CTestConfigItem*>(CfgFile()->Item(KScEapIdentity, nestedIdTag++));
   353 			item = const_cast<CTestConfigItem*>(CfgFile()->Item(KScEapIdentity, nestedIdTag++));
   348 
   354 
   349 			// parse id
   355 			// parse id
   350 			if (item == NULL)
   356 			if (item == NULL)
   351 				{
   357 				{
   352 				LOGPHONE2("WARNING CONFIGURATION FILE PARSING: could not read EAP id tag [%d]", nestedIdTag-1);
   358 				OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_21, "WARNING CONFIGURATION FILE PARSING: could not read EAP id tag [%d]", nestedIdTag-1);
   353 				}
   359 				}
   354 			else
   360 			else
   355 				{
   361 				{
   356 				ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 0, ptr);
   362 				ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 0, ptr);
   357 				if (ret != KErrNone)
   363 				if (ret != KErrNone)
   358 					{
   364 					{
   359 					LOGPHONE2("WARNING CONFIGURATION FILE PARSING: could not read EAP Id tag's data [%d]", nestedIdTag-1);
   365 					OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_22, "WARNING CONFIGURATION FILE PARSING: could not read EAP Id tag's data [%d]", nestedIdTag-1);
   360 					}
   366 					}
   361 				else
   367 				else
   362 					{
   368 					{
   363 					TRAPD(idAllocErr, startData = ptr.AllocL());
   369 					TRAPD(idAllocErr, startData = ptr.AllocL());
   364 					if (idAllocErr != KErrNone)
   370 					if (idAllocErr != KErrNone)
   365 						{
   371 						{
   366 						LOGPHONE2("WARNING CONFIGURATION FILE PARSING: could not allocate mem for EAP Id data [%d]", nestedIdTag-1);
   372 						OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_23, "WARNING CONFIGURATION FILE PARSING: could not allocate mem for EAP Id data [%d]", nestedIdTag-1);
   367 						}
   373 						}
   368 					else
   374 					else
   369 						{
   375 						{
   370 						TPtr8 tempPtr(NULL,0);
   376 						TPtr8 tempPtr(NULL,0);
   371 						tempPtr.Set(startData->Des());
   377 						tempPtr.Set(startData->Des());
   379 							}
   385 							}
   380 						// need to re-copy because converting to binary changes size
   386 						// need to re-copy because converting to binary changes size
   381 						TRAP(idAllocErr, procInfo.iEapId = tempPtr.AllocL());
   387 						TRAP(idAllocErr, procInfo.iEapId = tempPtr.AllocL());
   382 						if (idAllocErr != KErrNone)
   388 						if (idAllocErr != KErrNone)
   383 							{
   389 							{
   384 							LOGPHONE2("WARNING CONFIGURATION FILE PARSING: could not allocate mem for EAP Id data copy [%d]", nestedIdTag-1);
   390 							OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_24, "WARNING CONFIGURATION FILE PARSING: could not allocate mem for EAP Id data copy [%d]", nestedIdTag-1);
   385 							}
   391 							}
   386 						delete startData;
   392 						delete startData;
   387 						startData = NULL;
   393 						startData = NULL;
   388 						}
   394 						}
   389 					}
   395 					}
   390 				}
   396 				}
   391 			}
   397 			}
   392 		else
   398 		else
   393 			{
   399 			{
   394 			LOGPHONE1("WARNING CONFIGURATION FILE PARSING: NO SC EAP ID INFO TAG");
   400 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_25, "WARNING CONFIGURATION FILE PARSING: NO SC EAP ID INFO TAG");
   395 			}
   401 			}
   396 
   402 
   397 		// Get Pseudonym Identity
   403 		// Get Pseudonym Identity
   398 		if (nestedPsIdTag < countPsId)
   404 		if (nestedPsIdTag < countPsId)
   399 			{
   405 			{
   400 			item = const_cast<CTestConfigItem*>(CfgFile()->Item(KScEapPsIdentity, nestedPsIdTag++));
   406 			item = const_cast<CTestConfigItem*>(CfgFile()->Item(KScEapPsIdentity, nestedPsIdTag++));
   401 
   407 
   402 			// parse id
   408 			// parse id
   403 			if (item == NULL)
   409 			if (item == NULL)
   404 				{
   410 				{
   405 				LOGPHONE2("WARNING CONFIGURATION FILE PARSING: could not read EAP Pseudonym id tag [%d]", nestedPsIdTag-1);
   411 				OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_26, "WARNING CONFIGURATION FILE PARSING: could not read EAP Pseudonym id tag [%d]", nestedPsIdTag-1);
   406 				}
   412 				}
   407 			else
   413 			else
   408 				{
   414 				{
   409 				ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 0, ptr);
   415 				ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 0, ptr);
   410 				if (ret != KErrNone)
   416 				if (ret != KErrNone)
   411 					{
   417 					{
   412 					LOGPHONE2("WARNING CONFIGURATION FILE PARSING: could not read EAP Pseudonym Id tag's data [%d]", nestedPsIdTag-1);
   418 					OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_27, "WARNING CONFIGURATION FILE PARSING: could not read EAP Pseudonym Id tag's data [%d]", nestedPsIdTag-1);
   413 					}
   419 					}
   414 				else
   420 				else
   415 					{
   421 					{
   416 					TRAPD(idAllocErr, startData = ptr.AllocL());
   422 					TRAPD(idAllocErr, startData = ptr.AllocL());
   417 					if (idAllocErr != KErrNone)
   423 					if (idAllocErr != KErrNone)
   418 						{
   424 						{
   419 						LOGPHONE2("WARNING CONFIGURATION FILE PARSING: could not allocate mem for EAP Pseudonym Id data [%d]", nestedPsIdTag-1);
   425 						OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_28, "WARNING CONFIGURATION FILE PARSING: could not allocate mem for EAP Pseudonym Id data [%d]", nestedPsIdTag-1);
   420 						}
   426 						}
   421 					else
   427 					else
   422 						{
   428 						{
   423 						TPtr8 tempPtr(NULL,0);
   429 						TPtr8 tempPtr(NULL,0);
   424 						tempPtr.Set(startData->Des());
   430 						tempPtr.Set(startData->Des());
   432 							}
   438 							}
   433 						// need to re-copy because converting to binary changes size
   439 						// need to re-copy because converting to binary changes size
   434 						TRAP(idAllocErr, procInfo.iEapPsId = tempPtr.AllocL());
   440 						TRAP(idAllocErr, procInfo.iEapPsId = tempPtr.AllocL());
   435 						if (idAllocErr != KErrNone)
   441 						if (idAllocErr != KErrNone)
   436 							{
   442 							{
   437 							LOGPHONE2("WARNING CONFIGURATION FILE PARSING: could not allocate mem for EAP Pseudonym Id data copy [%d]", nestedPsIdTag-1);
   443 							OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_29, "WARNING CONFIGURATION FILE PARSING: could not allocate mem for EAP Pseudonym Id data copy [%d]", nestedPsIdTag-1);
   438 							}
   444 							}
   439 						delete startData;
   445 						delete startData;
   440 						startData = NULL;
   446 						startData = NULL;
   441 						}
   447 						}
   442 					}
   448 					}
   443 				}
   449 				}
   444 			}
   450 			}
   445 		else
   451 		else
   446 			{
   452 			{
   447 			LOGPHONE1("WARNING CONFIGURATION FILE PARSING: NO SC EAP PS ID INFO TAG");
   453 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_30, "WARNING CONFIGURATION FILE PARSING: NO SC EAP PS ID INFO TAG");
   448 			}
   454 			}
   449 
   455 
   450 		// Get challenges
   456 		// Get challenges
   451 		// numChallenges is what is parsed from config.txt and will be
   457 		// numChallenges is what is parsed from config.txt and will be
   452 		//    decremented in loop till zero is reached.
   458 		//    decremented in loop till zero is reached.
   455 		// countChl is the total number of KScEapChallenge found.
   461 		// countChl is the total number of KScEapChallenge found.
   456 		while (numChallenges != 0)
   462 		while (numChallenges != 0)
   457 			{
   463 			{
   458 			if (nestedChlTag >= countChl)
   464 			if (nestedChlTag >= countChl)
   459 				{
   465 				{
   460 				LOGPHONE1("WARNING CONFIGURATION FILE PARSING: NO MORE SC EAP Challenge INFO TAG");
   466 				OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_31, "WARNING CONFIGURATION FILE PARSING: NO MORE SC EAP Challenge INFO TAG");
   461 				break;
   467 				break;
   462 				}
   468 				}
   463 
   469 
   464 			item = const_cast<CTestConfigItem*>(CfgFile()->Item(KScEapChallenge, nestedChlTag++));
   470 			item = const_cast<CTestConfigItem*>(CfgFile()->Item(KScEapChallenge, nestedChlTag++));
   465 			numChallenges--;
   471 			numChallenges--;
   466 
   472 
   467 			// parse delay and challenge/response and auth status
   473 			// parse delay and challenge/response and auth status
   468 			if (item == NULL)
   474 			if (item == NULL)
   469 				{
   475 				{
   470 				LOGPHONE2("WARNING CONFIGURATION FILE PARSING: could not read EAP challenge tag [%d]", nestedChlTag-1);
   476 				OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_32, "WARNING CONFIGURATION FILE PARSING: could not read EAP challenge tag [%d]", nestedChlTag-1);
   471 				continue;
   477 				continue;
   472 				}
   478 				}
   473 
   479 
   474 			// Parse challenge
   480 			// Parse challenge
   475 			ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 0, ptr);
   481 			ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 0, ptr);
   476 			if (ret != KErrNone)
   482 			if (ret != KErrNone)
   477 				{
   483 				{
   478 				LOGPHONE2("WARNING CONFIGURATION FILE PARSING: could not read EAP challenge data [%d]", nestedChlTag-1);
   484 				OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_33, "WARNING CONFIGURATION FILE PARSING: could not read EAP challenge data [%d]", nestedChlTag-1);
   479 				continue;
   485 				continue;
   480 				}
   486 				}
   481 
   487 
   482 			TRAPD(leaveErr, startData = ptr.AllocL());
   488 			TRAPD(leaveErr, startData = ptr.AllocL());
   483 			if (leaveErr != KErrNone)
   489 			if (leaveErr != KErrNone)
   484 				{
   490 				{
   485 				LOGPHONE2("WARNING CONFIGURATION FILE PARSING: could not allocate mem for EAP challenge data [%d]", nestedChlTag-1);
   491 				OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_34, "WARNING CONFIGURATION FILE PARSING: could not allocate mem for EAP challenge data [%d]", nestedChlTag-1);
   486 				continue;
   492 				continue;
   487 				}
   493 				}
   488 			tempPtr.Set(startData->Des());
   494 			tempPtr.Set(startData->Des());
   489 			switch (dataFrmt)
   495 			switch (dataFrmt)
   490 				{
   496 				{
   496 				}
   502 				}
   497 			TEapChngResp newChRespData;
   503 			TEapChngResp newChRespData;
   498 			TRAP(leaveErr, newChRespData.iChallenge = tempPtr.AllocL());
   504 			TRAP(leaveErr, newChRespData.iChallenge = tempPtr.AllocL());
   499 			if (leaveErr != KErrNone)
   505 			if (leaveErr != KErrNone)
   500 				{
   506 				{
   501 				LOGPHONE2("WARNING CONFIGURATION FILE PARSING: could not allocate mem for EAP challenge data copy [%d]", nestedKeyTag-1);
   507 				OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_35, "WARNING CONFIGURATION FILE PARSING: could not allocate mem for EAP challenge data copy [%d]", nestedKeyTag-1);
   502 				}
   508 				}
   503 			delete startData;
   509 			delete startData;
   504 			startData = NULL;
   510 			startData = NULL;
   505 
   511 
   506 			// Parse response
   512 			// Parse response
   507 			ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 1, ptr);
   513 			ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 1, ptr);
   508 			if (ret != KErrNone)
   514 			if (ret != KErrNone)
   509 				{
   515 				{
   510 				LOGPHONE2("WARNING CONFIGURATION FILE PARSING: could not read EAP response data [%d]", nestedChlTag-1);
   516 				OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_36, "WARNING CONFIGURATION FILE PARSING: could not read EAP response data [%d]", nestedChlTag-1);
   511 				continue;
   517 				continue;
   512 				}
   518 				}
   513 
   519 
   514 			TRAP(leaveErr, startData = ptr.AllocL());
   520 			TRAP(leaveErr, startData = ptr.AllocL());
   515 			if (leaveErr != KErrNone)
   521 			if (leaveErr != KErrNone)
   516 				{
   522 				{
   517 				LOGPHONE2("WARNING CONFIGURATION FILE PARSING: could not allocate mem for EAP response data [%d]", nestedChlTag-1);
   523 				OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_37, "WARNING CONFIGURATION FILE PARSING: could not allocate mem for EAP response data [%d]", nestedChlTag-1);
   518 				continue;
   524 				continue;
   519 				}
   525 				}
   520 			tempPtr.Set(startData->Des());
   526 			tempPtr.Set(startData->Des());
   521 			switch (dataFrmt)
   527 			switch (dataFrmt)
   522 				{
   528 				{
   527 			//default:
   533 			//default:
   528 				}
   534 				}
   529 			TRAP(leaveErr, newChRespData.iResp = tempPtr.AllocL());
   535 			TRAP(leaveErr, newChRespData.iResp = tempPtr.AllocL());
   530 			if (leaveErr != KErrNone)
   536 			if (leaveErr != KErrNone)
   531 				{
   537 				{
   532 				LOGPHONE2("WARNING CONFIGURATION FILE PARSING: could not allocate mem for EAP response data copy [%d]", nestedKeyTag-1);
   538 				OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_38, "WARNING CONFIGURATION FILE PARSING: could not allocate mem for EAP response data copy [%d]", nestedKeyTag-1);
   533 				}
   539 				}
   534 			delete startData;
   540 			delete startData;
   535 			startData = NULL;
   541 			startData = NULL;
   536 
   542 
   537 			// Parse status
   543 			// Parse status
   538 			TInt stat;
   544 			TInt stat;
   539 			ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 2, stat);
   545 			ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 2, stat);
   540 			if (ret != KErrNone)
   546 			if (ret != KErrNone)
   541 				{
   547 				{
   542 				LOGPHONE2("WARNING CONFIGURATION FILE PARSING: could not read EAP auth status [%d]", nestedChlTag-1);
   548 				OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_39, "WARNING CONFIGURATION FILE PARSING: could not read EAP auth status [%d]", nestedChlTag-1);
   543 				continue;
   549 				continue;
   544 				}
   550 				}
   545 
   551 
   546 			newChRespData.iAuthStatus = static_cast<RMobileSmartCardEap::TEapAuthStatus>(stat);
   552 			newChRespData.iAuthStatus = static_cast<RMobileSmartCardEap::TEapAuthStatus>(stat);
   547 
   553 
   548 			leaveErr = procInfo.iChResp.Append(newChRespData);
   554 			leaveErr = procInfo.iChResp.Append(newChRespData);
   549 			if (leaveErr != KErrNone)
   555 			if (leaveErr != KErrNone)
   550 				{
   556 				{
   551 				LOGPHONE3("WARNING CONFIGURATION FILE PARSING: could not allocate mem for EAP challenge/resp data [%d] [err=%d]", nestedChlTag-1, leaveErr);
   557 				OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_40, "WARNING CONFIGURATION FILE PARSING: could not allocate mem for EAP challenge/resp data [%d] [err=%d]", nestedChlTag-1, leaveErr);
   552 				}
   558 				}
   553 			} // end while
   559 			} // end while
   554 
   560 
   555 		TInt errAppend = iEapProcData.Append(procInfo);
   561 		TInt errAppend = iEapProcData.Append(procInfo);
   556 		if (errAppend != KErrNone)
   562 		if (errAppend != KErrNone)
   557 			{
   563 			{
   558 			LOGPHONE2("ERROR CONFIGURATION FILE PARSING: Could not store parsed EAP procedure data [err=%d]", errAppend);
   564 			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_41, "ERROR CONFIGURATION FILE PARSING: Could not store parsed EAP procedure data [err=%d]", errAppend);
   559 			}
   565 			}
   560 		else
   566 		else
   561 			{
   567 			{
   562 			iDiscardedProcedure.Append(EFalse);
   568 			iDiscardedProcedure.Append(EFalse);
   563 			}
   569 			}
   564 		} // end for; parsing EAP procedures from config.txt
   570 		} // end for; parsing EAP procedures from config.txt
   565 
   571 
   566 	LOGPHONE1("CSimSmartCardEapManager::ParseEapInfoL completed");
   572 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_PARSEEAPINFOL_42, "CSimSmartCardEapManager::ParseEapInfoL completed");
   567 	}
   573 	}
   568 
   574 
   569 /**
   575 /**
   570 Function leaves if <aAID,aEapType> is not in config file.
   576 Function leaves if <aAID,aEapType> is not in config file.
   571 
   577 
   591 	User::Leave(KErrNotFound);
   597 	User::Leave(KErrNotFound);
   592 	}
   598 	}
   593 
   599 
   594 CTelObject* CSimSmartCardEapManager::CreateScEapSubSessionL(RMobilePhone::TAID& aAID, RMobileSmartCardEap::TEapType& aEapType)
   600 CTelObject* CSimSmartCardEapManager::CreateScEapSubSessionL(RMobilePhone::TAID& aAID, RMobileSmartCardEap::TEapType& aEapType)
   595 	{
   601 	{
   596 	LOGPHONE1("CSimSmartCardEapManager::CreateScEapSubSessionL called");
   602 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_CREATESCEAPSUBSESSIONL_1, "CSimSmartCardEapManager::CreateScEapSubSessionL called");
   597 	// If no config exists for this eapAID,eapType pair, then this will leave
   603 	// If no config exists for this eapAID,eapType pair, then this will leave
   598 	AID_EapType_ExistsInConfigL(aAID, aEapType);
   604 	AID_EapType_ExistsInConfigL(aAID, aEapType);
   599 
   605 
   600 	// If exists then phoneScEap guaranteed to get data in
   606 	// If exists then phoneScEap guaranteed to get data in
   601 	// InitialiseEapMethod, since only one object can be created
   607 	// InitialiseEapMethod, since only one object can be created
   604 	CSimSmartCardEap* phoneScEap = NULL;
   610 	CSimSmartCardEap* phoneScEap = NULL;
   605 	TRAPD(err, phoneScEap = CSimSmartCardEap::NewL(iPhone, this, aAID, aEapType));
   611 	TRAPD(err, phoneScEap = CSimSmartCardEap::NewL(iPhone, this, aAID, aEapType));
   606 
   612 
   607 	if (err != KErrNone)
   613 	if (err != KErrNone)
   608 		{
   614 		{
   609 		LOGPHONE2("ERROR could not create CSimSmartCardEap object [err=%d]", err);
   615 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAPMANAGER_CREATESCEAPSUBSESSIONL_2, "ERROR could not create CSimSmartCardEap object [err=%d]", err);
   610 		User::Leave(err);
   616 		User::Leave(err);
   611 		}
   617 		}
   612 
   618 
   613 	return phoneScEap;
   619 	return phoneScEap;
   614 	}
   620 	}
   713 	iEapType = aEapType;
   719 	iEapType = aEapType;
   714 	}
   720 	}
   715 
   721 
   716 void CSimSmartCardEap::ConstructL(CSimSmartCardEapManager* aEapMan)
   722 void CSimSmartCardEap::ConstructL(CSimSmartCardEapManager* aEapMan)
   717 	{
   723 	{
   718 	LOGPHONE1("CSimSmartCardEap: starting second phase construction");
   724 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAP_CONSTRUCTL_1, "CSimSmartCardEap: starting second phase construction");
   719 
   725 
   720 	iSemaphr.CreateGlobal(KNullDesC, EOwnerThread);
   726 	iSemaphr.CreateGlobal(KNullDesC, EOwnerThread);
   721 	aEapMan->RegisterSubSessionL(this);
   727 	aEapMan->RegisterSubSessionL(this);
   722 	iEapMan = aEapMan;
   728 	iEapMan = aEapMan;
   723 
   729 
   724 	LOGPHONE1("CSimSmartCardEap created");
   730 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAP_CONSTRUCTL_2, "CSimSmartCardEap created");
   725 	}
   731 	}
   726 
   732 
   727 CSimSmartCardEap::~CSimSmartCardEap()
   733 CSimSmartCardEap::~CSimSmartCardEap()
   728 	{
   734 	{
   729 	if (iCliTerminationListener != NULL)
   735 	if (iCliTerminationListener != NULL)
   739 		iEapMan->ProcDataUseCompleted(iProcedureData);
   745 		iEapMan->ProcDataUseCompleted(iProcedureData);
   740 		iProcedureData = NULL;
   746 		iProcedureData = NULL;
   741 		}
   747 		}
   742 
   748 
   743 	TInt err = iEapMan->DeRegisterSubSession(this);
   749 	TInt err = iEapMan->DeRegisterSubSession(this);
   744 	LOGPHONE2("CSimSmartCardEap destroyed, deregistering returned %d", err);
   750 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAP_DTOR_1, "CSimSmartCardEap destroyed, deregistering returned %d", err);
   745 
   751 
   746 	iEapMan = NULL;
   752 	iEapMan = NULL;
   747 	}
   753 	}
   748 
   754 
   749 
   755 
   945 	return &iSemaphr;
   951 	return &iSemaphr;
   946 	}
   952 	}
   947 
   953 
   948 TInt CSimSmartCardEap::SimInitialiseEapMethod(const TTsyReqHandle aTsyReqHandle, TThreadId* aThreadId)
   954 TInt CSimSmartCardEap::SimInitialiseEapMethod(const TTsyReqHandle aTsyReqHandle, TThreadId* aThreadId)
   949 	{
   955 	{
   950 	LOGPHONE1("CSimSmartCardEap::SimInitialiseEapMethod called");
   956 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAP_SIMINITIALISEEAPMETHOD_1, "CSimSmartCardEap::SimInitialiseEapMethod called");
   951 	// This can only be called through RMobileSmartCardEap for one instance
   957 	// This can only be called through RMobileSmartCardEap for one instance
   952 
   958 
   953 	if (iSSInitialised)
   959 	if (iSSInitialised)
   954 		{
   960 		{
   955 		// re-initialise request sent, so will be treated as a mistake
   961 		// re-initialise request sent, so will be treated as a mistake
   960 		{
   966 		{
   961 		delete iCliTerminationListener;
   967 		delete iCliTerminationListener;
   962 		TRAPD(err, iCliTerminationListener = CThreadTerminationListener::NewL(this, *aThreadId));
   968 		TRAPD(err, iCliTerminationListener = CThreadTerminationListener::NewL(this, *aThreadId));
   963 		if (err != KErrNone)
   969 		if (err != KErrNone)
   964 			{
   970 			{
   965 			LOGPHONE2("ERROR could not create a client termination listener [err=%d] (not initialised)", err);
   971 			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAP_SIMINITIALISEEAPMETHOD_2, "ERROR could not create a client termination listener [err=%d] (not initialised)", err);
   966 			ReqCompleted(aTsyReqHandle, err);
   972 			ReqCompleted(aTsyReqHandle, err);
   967 			}
   973 			}
   968 		else
   974 		else
   969 			{
   975 			{
   970 			iProcedureData = iEapMan->ProcData(iAID, iEapType);
   976 			iProcedureData = iEapMan->ProcData(iAID, iEapType);
   971 			if (iProcedureData == NULL)
   977 			if (iProcedureData == NULL)
   972 				{
   978 				{
   973 				LOGPHONE1("ERROR could not find sub-session's procedure");
   979 				OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAP_SIMINITIALISEEAPMETHOD_3, "ERROR could not find sub-session's procedure");
   974 				ReqCompleted(aTsyReqHandle, KErrNotFound);
   980 				ReqCompleted(aTsyReqHandle, KErrNotFound);
   975 				return KErrNone;
   981 				return KErrNone;
   976 				}
   982 				}
   977 
   983 
   978 			iSSInitialised = ETrue;
   984 			iSSInitialised = ETrue;
   986 	return KErrNone;
   992 	return KErrNone;
   987 	}
   993 	}
   988 
   994 
   989 TInt CSimSmartCardEap::SimInitialiseEapMethodCancel(const TTsyReqHandle aTsyReqHandle)
   995 TInt CSimSmartCardEap::SimInitialiseEapMethodCancel(const TTsyReqHandle aTsyReqHandle)
   990 	{
   996 	{
   991 	LOGPHONE1("CSimSmartCardEap::SimInitialiseEapMethodCancel called");
   997 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAP_SIMINITIALISEEAPMETHODCANCEL_1, "CSimSmartCardEap::SimInitialiseEapMethodCancel called");
   992 	iProcedureData = NULL;
   998 	iProcedureData = NULL;
   993 	iSSInitialised = EFalse;
   999 	iSSInitialised = EFalse;
   994 	iAccessStatus = RMobileSmartCardEap::EEapMethodAvailable;
  1000 	iAccessStatus = RMobileSmartCardEap::EEapMethodAvailable;
   995 	SimCompleteNotifyEapMethodAccessStatusChange();
  1001 	SimCompleteNotifyEapMethodAccessStatusChange();
   996 	ReqCompleted(aTsyReqHandle, KErrCancel);
  1002 	ReqCompleted(aTsyReqHandle, KErrCancel);
   997 	return KErrNone;
  1003 	return KErrNone;
   998 	}
  1004 	}
   999 
  1005 
  1000 TInt CSimSmartCardEap::SimGetUserIdentity(const TTsyReqHandle aTsyReqHandle, RMobileSmartCardEap::TEapUserIdType* aEapIdType, TDes8* aUserId)
  1006 TInt CSimSmartCardEap::SimGetUserIdentity(const TTsyReqHandle aTsyReqHandle, RMobileSmartCardEap::TEapUserIdType* aEapIdType, TDes8* aUserId)
  1001 	{
  1007 	{
  1002 	LOGPHONE1("CSimSmartCardEap::SimGetUserIdentity called");
  1008 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAP_SIMGETUSERIDENTITY_1, "CSimSmartCardEap::SimGetUserIdentity called");
  1003 
  1009 
  1004 	RMobileSmartCardEap::TEapUserIdentityV6Pckg *userIdPckg = reinterpret_cast<RMobileSmartCardEap::TEapUserIdentityV6Pckg*>(aUserId);
  1010 	RMobileSmartCardEap::TEapUserIdentityV6Pckg *userIdPckg = reinterpret_cast<RMobileSmartCardEap::TEapUserIdentityV6Pckg*>(aUserId);
  1005 	RMobileSmartCardEap::TEapUserIdentityV6 &userId = (*userIdPckg)();
  1011 	RMobileSmartCardEap::TEapUserIdentityV6 &userId = (*userIdPckg)();
  1006 	
  1012 	
  1007 	// Check that the data structure is supported by the simulated TSY version
  1013 	// Check that the data structure is supported by the simulated TSY version
  1015 	if (*aEapIdType == RMobileSmartCardEap::EPermanentIdentity)
  1021 	if (*aEapIdType == RMobileSmartCardEap::EPermanentIdentity)
  1016 		{
  1022 		{
  1017 		if (iProcedureData->iEapId == NULL)
  1023 		if (iProcedureData->iEapId == NULL)
  1018 			{
  1024 			{
  1019 			ReqCompleted(aTsyReqHandle, KErrNotFound);
  1025 			ReqCompleted(aTsyReqHandle, KErrNotFound);
  1020 			LOGPHONE1("ERROR EAP sub-session does not contain EPermanentIdentity");
  1026 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAP_SIMGETUSERIDENTITY_2, "ERROR EAP sub-session does not contain EPermanentIdentity");
  1021 			return KErrNone;
  1027 			return KErrNone;
  1022 			}
  1028 			}
  1023 
  1029 
  1024 		userId.iEapId = iProcedureData->iEapId->Des();
  1030 		userId.iEapId = iProcedureData->iEapId->Des();
  1025 		}
  1031 		}
  1026 	else if (*aEapIdType == RMobileSmartCardEap::EPseudonymIdentity)
  1032 	else if (*aEapIdType == RMobileSmartCardEap::EPseudonymIdentity)
  1027 		{
  1033 		{
  1028 		if (iProcedureData->iEapPsId == NULL)
  1034 		if (iProcedureData->iEapPsId == NULL)
  1029 			{
  1035 			{
  1030 			ReqCompleted(aTsyReqHandle, KErrNotFound);
  1036 			ReqCompleted(aTsyReqHandle, KErrNotFound);
  1031 			LOGPHONE1("ERROR EAP sub-session does not contain EPseudonymIdentity");
  1037 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAP_SIMGETUSERIDENTITY_3, "ERROR EAP sub-session does not contain EPseudonymIdentity");
  1032 			return KErrNone;
  1038 			return KErrNone;
  1033 			}
  1039 			}
  1034 
  1040 
  1035 		userId.iEapId = iProcedureData->iEapPsId->Des();
  1041 		userId.iEapId = iProcedureData->iEapPsId->Des();
  1036 		}
  1042 		}
  1037 	else
  1043 	else
  1038 		{
  1044 		{
  1039 		ReqCompleted(aTsyReqHandle, KErrArgument);
  1045 		ReqCompleted(aTsyReqHandle, KErrArgument);
  1040 		LOGPHONE2("ERROR invalid EAP id type requested [tag=%d]", *aEapIdType);
  1046 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAP_SIMGETUSERIDENTITY_4, "ERROR invalid EAP id type requested [tag=%d]", *aEapIdType);
  1041 		return KErrNone;
  1047 		return KErrNone;
  1042 		}
  1048 		}
  1043 
  1049 
  1044 	ReqCompleted(aTsyReqHandle, KErrNone);
  1050 	ReqCompleted(aTsyReqHandle, KErrNone);
  1045 	return KErrNone;
  1051 	return KErrNone;
  1046 	}
  1052 	}
  1047 
  1053 
  1048 TInt CSimSmartCardEap::SimGetUserIdentityCancel(const TTsyReqHandle aTsyReqHandle)
  1054 TInt CSimSmartCardEap::SimGetUserIdentityCancel(const TTsyReqHandle aTsyReqHandle)
  1049 	{
  1055 	{
  1050 	LOGPHONE1("CSimSmartCardEap::SimGetUserIdentityCancel called");
  1056 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAP_SIMGETUSERIDENTITYCANCEL_1, "CSimSmartCardEap::SimGetUserIdentityCancel called");
  1051 	ReqCompleted(aTsyReqHandle, KErrCancel);
  1057 	ReqCompleted(aTsyReqHandle, KErrCancel);
  1052 	return KErrNone;
  1058 	return KErrNone;
  1053 	}
  1059 	}
  1054 	
  1060 	
  1055 TInt CSimSmartCardEap::SimGetAuthenticationStatus(const TTsyReqHandle aTsyReqHandle, RMobileSmartCardEap::TEapAuthStatus* aAuthStatus)
  1061 TInt CSimSmartCardEap::SimGetAuthenticationStatus(const TTsyReqHandle aTsyReqHandle, RMobileSmartCardEap::TEapAuthStatus* aAuthStatus)
  1056 	{
  1062 	{
  1057 	LOGPHONE1("CSimSmartCardEap::SimGetAuthenticationStatus called");
  1063 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAP_SIMGETAUTHENTICATIONSTATUS_1, "CSimSmartCardEap::SimGetAuthenticationStatus called");
  1058 
  1064 
  1059 	(*aAuthStatus) = iAuthStatus;
  1065 	(*aAuthStatus) = iAuthStatus;
  1060 
  1066 
  1061 	ReqCompleted(aTsyReqHandle, KErrNone);
  1067 	ReqCompleted(aTsyReqHandle, KErrNone);
  1062 	return KErrNone;
  1068 	return KErrNone;
  1063 	}
  1069 	}
  1064 	
  1070 	
  1065 TInt CSimSmartCardEap::SimGetAuthenticationStatusCancel(const TTsyReqHandle aTsyReqHandle)
  1071 TInt CSimSmartCardEap::SimGetAuthenticationStatusCancel(const TTsyReqHandle aTsyReqHandle)
  1066 	{
  1072 	{
  1067 	LOGPHONE1("CSimSmartCardEap::SimGetAuthenticationStatusCancel called");
  1073 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAP_SIMGETAUTHENTICATIONSTATUSCANCEL_1, "CSimSmartCardEap::SimGetAuthenticationStatusCancel called");
  1068 	ReqCompleted(aTsyReqHandle, KErrCancel);
  1074 	ReqCompleted(aTsyReqHandle, KErrCancel);
  1069 	return KErrNone;
  1075 	return KErrNone;
  1070 	}
  1076 	}
  1071 
  1077 
  1072 TInt CSimSmartCardEap::SimGetEapKey(const TTsyReqHandle aTsyReqHandle, RMobileSmartCardEap::TEapKeyTag* aEapKeyTag, TDes8* aKey)
  1078 TInt CSimSmartCardEap::SimGetEapKey(const TTsyReqHandle aTsyReqHandle, RMobileSmartCardEap::TEapKeyTag* aEapKeyTag, TDes8* aKey)
  1073 	{
  1079 	{
  1074 	LOGPHONE1("CSimSmartCardEap::SimGetEapKey called");
  1080 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAP_SIMGETEAPKEY_1, "CSimSmartCardEap::SimGetEapKey called");
  1075 
  1081 
  1076 	RMobileSmartCardEap::TEapKeyV6Pckg *keyPckg = reinterpret_cast<RMobileSmartCardEap::TEapKeyV6Pckg*>(aKey);
  1082 	RMobileSmartCardEap::TEapKeyV6Pckg *keyPckg = reinterpret_cast<RMobileSmartCardEap::TEapKeyV6Pckg*>(aKey);
  1077 	RMobileSmartCardEap::TEapKeyV6 &key = (*keyPckg)();
  1083 	RMobileSmartCardEap::TEapKeyV6 &key = (*keyPckg)();
  1078 
  1084 
  1079 	// Check that the data structure is supported by the simulated TSY version
  1085 	// Check that the data structure is supported by the simulated TSY version
  1087 	if (*aEapKeyTag == RMobileSmartCardEap::EEapKeyMSK)
  1093 	if (*aEapKeyTag == RMobileSmartCardEap::EEapKeyMSK)
  1088 		{
  1094 		{
  1089 		if (iProcedureData->iEapKey == NULL)
  1095 		if (iProcedureData->iEapKey == NULL)
  1090 			{
  1096 			{
  1091 			ReqCompleted(aTsyReqHandle, KErrNotFound);
  1097 			ReqCompleted(aTsyReqHandle, KErrNotFound);
  1092 			LOGPHONE1("ERROR EAP sub-session does not contain EEapKeyMSK");
  1098 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAP_SIMGETEAPKEY_2, "ERROR EAP sub-session does not contain EEapKeyMSK");
  1093 			return KErrNone;
  1099 			return KErrNone;
  1094 			}
  1100 			}
  1095 
  1101 
  1096 		key.iEapKey = iProcedureData->iEapKey->Des();
  1102 		key.iEapKey = iProcedureData->iEapKey->Des();
  1097 		}
  1103 		}
  1098 	else if (*aEapKeyTag == RMobileSmartCardEap::EEapKeyEMSK)
  1104 	else if (*aEapKeyTag == RMobileSmartCardEap::EEapKeyEMSK)
  1099 		{
  1105 		{
  1100 		if (iProcedureData->iEapExtKey == NULL)
  1106 		if (iProcedureData->iEapExtKey == NULL)
  1101 			{
  1107 			{
  1102 			ReqCompleted(aTsyReqHandle, KErrNotFound);
  1108 			ReqCompleted(aTsyReqHandle, KErrNotFound);
  1103 			LOGPHONE1("ERROR EAP sub-session does not contain EEapKeyEMSK");
  1109 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAP_SIMGETEAPKEY_3, "ERROR EAP sub-session does not contain EEapKeyEMSK");
  1104 			return KErrNone;
  1110 			return KErrNone;
  1105 			}
  1111 			}
  1106 
  1112 
  1107 		key.iEapKey = iProcedureData->iEapExtKey->Des();
  1113 		key.iEapKey = iProcedureData->iEapExtKey->Des();
  1108 		}
  1114 		}
  1109 	else
  1115 	else
  1110 		{
  1116 		{
  1111 		ReqCompleted(aTsyReqHandle, KErrArgument);
  1117 		ReqCompleted(aTsyReqHandle, KErrArgument);
  1112 		LOGPHONE2("ERROR invalid EAP key tag requested [tag=%d]", *aEapKeyTag);
  1118 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAP_SIMGETEAPKEY_4, "ERROR invalid EAP key tag requested [tag=%d]", *aEapKeyTag);
  1113 		return KErrNone;
  1119 		return KErrNone;
  1114 		}
  1120 		}
  1115 
  1121 
  1116 	ReqCompleted(aTsyReqHandle, KErrNone);
  1122 	ReqCompleted(aTsyReqHandle, KErrNone);
  1117 	return KErrNone;
  1123 	return KErrNone;
  1118 	}
  1124 	}
  1119 
  1125 
  1120 TInt CSimSmartCardEap::SimGetEapKeyCancel(const TTsyReqHandle aTsyReqHandle)
  1126 TInt CSimSmartCardEap::SimGetEapKeyCancel(const TTsyReqHandle aTsyReqHandle)
  1121 	{
  1127 	{
  1122 	LOGPHONE1("CSimSmartCardEap::SimGetEapKeyCancel called");
  1128 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAP_SIMGETEAPKEYCANCEL_1, "CSimSmartCardEap::SimGetEapKeyCancel called");
  1123 	ReqCompleted(aTsyReqHandle, KErrCancel);
  1129 	ReqCompleted(aTsyReqHandle, KErrCancel);
  1124 	return KErrNone;
  1130 	return KErrNone;
  1125 	}
  1131 	}
  1126 
  1132 
  1127 TInt CSimSmartCardEap::SimSetAuthenticateDataForPhase1(const TTsyReqHandle aTsyReqHandle, TDes8* aEapAuthData, TInt* aPhase1Size)
  1133 TInt CSimSmartCardEap::SimSetAuthenticateDataForPhase1(const TTsyReqHandle aTsyReqHandle, TDes8* aEapAuthData, TInt* aPhase1Size)
  1128 	{
  1134 	{
  1129 	LOGPHONE1("CSimSmartCardEap::SimSetAuthenticateDataForPhase1 called");
  1135 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAP_SIMSETAUTHENTICATEDATAFORPHASE1_1, "CSimSmartCardEap::SimSetAuthenticateDataForPhase1 called");
  1130 
  1136 
  1131 	if (iCurrentChallenge >= iProcedureData->iChResp.Count())
  1137 	if (iCurrentChallenge >= iProcedureData->iChResp.Count())
  1132 		{
  1138 		{
  1133 		ReqCompleted(aTsyReqHandle, KErrAccessDenied);
  1139 		ReqCompleted(aTsyReqHandle, KErrAccessDenied);
  1134 		return KErrNone;
  1140 		return KErrNone;
  1136 
  1142 
  1137 	RMobileSmartCardEap::CEapAuthenticateRequestDataV6* authReq = NULL;
  1143 	RMobileSmartCardEap::CEapAuthenticateRequestDataV6* authReq = NULL;
  1138 	TRAPD(err, authReq = RMobileSmartCardEap::CEapAuthenticateRequestDataV6::NewL());
  1144 	TRAPD(err, authReq = RMobileSmartCardEap::CEapAuthenticateRequestDataV6::NewL());
  1139 	if (err != KErrNone)
  1145 	if (err != KErrNone)
  1140 		{
  1146 		{
  1141 		LOGPHONE2("ERR Could not allocate memory for challenge request object [err=%d]", err);
  1147 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAP_SIMSETAUTHENTICATEDATAFORPHASE1_2, "ERR Could not allocate memory for challenge request object [err=%d]", err);
  1142 		ReqCompleted(aTsyReqHandle, err);
  1148 		ReqCompleted(aTsyReqHandle, err);
  1143 		return KErrNone;
  1149 		return KErrNone;
  1144 		}
  1150 		}
  1145 
  1151 
  1146 	TRAP(err, authReq->InternalizeL(*aEapAuthData));
  1152 	TRAP(err, authReq->InternalizeL(*aEapAuthData));
  1147 	if (err != KErrNone)
  1153 	if (err != KErrNone)
  1148 		{
  1154 		{
  1149 		LOGPHONE2("ERR Could not allocate memory for challenge request [err=%d]", err);
  1155 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAP_SIMSETAUTHENTICATEDATAFORPHASE1_3, "ERR Could not allocate memory for challenge request [err=%d]", err);
  1150 		ReqCompleted(aTsyReqHandle, err);
  1156 		ReqCompleted(aTsyReqHandle, err);
  1151 		return KErrNone;
  1157 		return KErrNone;
  1152 		}
  1158 		}
  1153 
  1159 
  1154 	TPtr8 reqPacket = authReq->GetEapReqPacket();
  1160 	TPtr8 reqPacket = authReq->GetEapReqPacket();
  1156 	TPtr8 tempPtr(NULL, 0);
  1162 	TPtr8 tempPtr(NULL, 0);
  1157 	tempPtr.Set(iProcedureData->iChResp[iCurrentChallenge].iChallenge->Des());
  1163 	tempPtr.Set(iProcedureData->iChResp[iCurrentChallenge].iChallenge->Des());
  1158 
  1164 
  1159 	if (reqPacket != tempPtr)
  1165 	if (reqPacket != tempPtr)
  1160 		{
  1166 		{
  1161 		LOGPHONE2("ERR challenge request does not match config [currentChallenge=%d]", iCurrentChallenge);
  1167 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAP_SIMSETAUTHENTICATEDATAFORPHASE1_4, "ERR challenge request does not match config [currentChallenge=%d]", iCurrentChallenge);
  1162 		ReqCompleted(aTsyReqHandle, KErrCorrupt);
  1168 		ReqCompleted(aTsyReqHandle, KErrCorrupt);
  1163 		return KErrNone;
  1169 		return KErrNone;
  1164 		}
  1170 		}
  1165 
  1171 
  1166 	(*aPhase1Size) = iProcedureData->iChResp[iCurrentChallenge].iResp->Length();
  1172 	(*aPhase1Size) = iProcedureData->iChResp[iCurrentChallenge].iResp->Length();
  1169 	return KErrNone;
  1175 	return KErrNone;
  1170 	}
  1176 	}
  1171 
  1177 
  1172 TInt CSimSmartCardEap::SimGetAuthenticateDataForPhase2(const TTsyReqHandle aTsyReqHandle, TDes8* /*aEapAuthData*/, TDes8* aPhase2Resp)
  1178 TInt CSimSmartCardEap::SimGetAuthenticateDataForPhase2(const TTsyReqHandle aTsyReqHandle, TDes8* /*aEapAuthData*/, TDes8* aPhase2Resp)
  1173 	{
  1179 	{
  1174 	LOGPHONE1("CSimSmartCardEap::SimSetAuthenticateDataForPhase2 called");
  1180 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAP_SIMGETAUTHENTICATEDATAFORPHASE2_1, "CSimSmartCardEap::SimSetAuthenticateDataForPhase2 called");
  1175 
  1181 
  1176 	if (iCurrentChallenge >= iProcedureData->iChResp.Count())
  1182 	if (iCurrentChallenge >= iProcedureData->iChResp.Count())
  1177 		{
  1183 		{
  1178 		ReqCompleted(aTsyReqHandle, KErrAccessDenied);
  1184 		ReqCompleted(aTsyReqHandle, KErrAccessDenied);
  1179 		return KErrNone;
  1185 		return KErrNone;
  1190 	return KErrNone;
  1196 	return KErrNone;
  1191 	}
  1197 	}
  1192 
  1198 
  1193 TInt CSimSmartCardEap::SimSmartCardEapAuthenticationCancel(const TTsyReqHandle aTsyReqHandle)
  1199 TInt CSimSmartCardEap::SimSmartCardEapAuthenticationCancel(const TTsyReqHandle aTsyReqHandle)
  1194 	{
  1200 	{
  1195 	LOGPHONE1("CSimSmartCardEap::SimSmartCardEapAuthenticationCancel called");
  1201 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAP_SIMSMARTCARDEAPAUTHENTICATIONCANCEL_1, "CSimSmartCardEap::SimSmartCardEapAuthenticationCancel called");
  1196 	ReqCompleted(aTsyReqHandle, KErrCancel);
  1202 	ReqCompleted(aTsyReqHandle, KErrCancel);
  1197 	return KErrNone;
  1203 	return KErrNone;
  1198 	}
  1204 	}
  1199 
  1205 
  1200 TInt CSimSmartCardEap::SimReleaseEapMethod(const TTsyReqHandle aTsyReqHandle)
  1206 TInt CSimSmartCardEap::SimReleaseEapMethod(const TTsyReqHandle aTsyReqHandle)
  1201 	{
  1207 	{
  1202 	LOGPHONE1("CSimSmartCardEap::SimReleaseEapMethod called");
  1208 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAP_SIMRELEASEEAPMETHOD_1, "CSimSmartCardEap::SimReleaseEapMethod called");
  1203 	iSSInitialised = EFalse;
  1209 	iSSInitialised = EFalse;
  1204 	iAccessStatus = RMobileSmartCardEap::EEapMethodAvailable;
  1210 	iAccessStatus = RMobileSmartCardEap::EEapMethodAvailable;
  1205 	ReqCompleted(aTsyReqHandle, KErrNone);
  1211 	ReqCompleted(aTsyReqHandle, KErrNone);
  1206 
  1212 
  1207 	SimCompleteNotifyEapMethodAccessStatusChange();
  1213 	SimCompleteNotifyEapMethodAccessStatusChange();
  1213 	return KErrNone;
  1219 	return KErrNone;
  1214 	}
  1220 	}
  1215 
  1221 
  1216 TInt CSimSmartCardEap::SimGetEapMethodAccessStatus(const TTsyReqHandle aTsyReqHandle, RMobileSmartCardEap::TEapMethodAccessStatus* aEapState)
  1222 TInt CSimSmartCardEap::SimGetEapMethodAccessStatus(const TTsyReqHandle aTsyReqHandle, RMobileSmartCardEap::TEapMethodAccessStatus* aEapState)
  1217 	{
  1223 	{
  1218 	LOGPHONE1("CSimSmartCardEap::SimGetEapMethodAccessStatus called");
  1224 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAP_SIMGETEAPMETHODACCESSSTATUS_1, "CSimSmartCardEap::SimGetEapMethodAccessStatus called");
  1219 	*aEapState = iAccessStatus;
  1225 	*aEapState = iAccessStatus;
  1220 	ReqCompleted(aTsyReqHandle, KErrNone);
  1226 	ReqCompleted(aTsyReqHandle, KErrNone);
  1221 	return KErrNone;
  1227 	return KErrNone;
  1222 	}
  1228 	}
  1223 
  1229 
  1224 TInt CSimSmartCardEap::SimNotifyEapMethodAccessStatusChange(const TTsyReqHandle aTsyReqHandle, RMobileSmartCardEap::TEapMethodAccessStatus* aEapState)
  1230 TInt CSimSmartCardEap::SimNotifyEapMethodAccessStatusChange(const TTsyReqHandle aTsyReqHandle, RMobileSmartCardEap::TEapMethodAccessStatus* aEapState)
  1225 	{
  1231 	{
  1226 	LOGPHONE1("CSimSmartCardEap::SimNotifyEapMethodAccessStatusChange called");
  1232 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAP_SIMNOTIFYEAPMETHODACCESSSTATUSCHANGE_1, "CSimSmartCardEap::SimNotifyEapMethodAccessStatusChange called");
  1227 	__ASSERT_ALWAYS(!iEapAccessNotifyData.iNotifyPending, PanicClient(EEtelPanicRequestAsyncTwice));
  1233 	__ASSERT_ALWAYS(!iEapAccessNotifyData.iNotifyPending, PanicClient(EEtelPanicRequestAsyncTwice));
  1228 
  1234 
  1229 	iEapAccessNotifyData.iNotifyPending = ETrue;
  1235 	iEapAccessNotifyData.iNotifyPending = ETrue;
  1230 	iEapAccessNotifyData.iNotifyHandle = aTsyReqHandle;
  1236 	iEapAccessNotifyData.iNotifyHandle = aTsyReqHandle;
  1231 	iEapAccessNotifyData.iNotifyData = aEapState;
  1237 	iEapAccessNotifyData.iNotifyData = aEapState;
  1233 	return KErrNone;
  1239 	return KErrNone;
  1234 	}
  1240 	}
  1235 
  1241 
  1236 TInt CSimSmartCardEap::SimNotifyEapMethodAccessStatusChangeCancel(const TTsyReqHandle aTsyReqHandle)
  1242 TInt CSimSmartCardEap::SimNotifyEapMethodAccessStatusChangeCancel(const TTsyReqHandle aTsyReqHandle)
  1237 	{
  1243 	{
  1238 	LOGPHONE1("CSimSmartCardEap::SimNotifyEapMethodAccessStatusChangeCancel called");
  1244 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAP_SIMNOTIFYEAPMETHODACCESSSTATUSCHANGECANCEL_1, "CSimSmartCardEap::SimNotifyEapMethodAccessStatusChangeCancel called");
  1239 	if(iEapAccessNotifyData.iNotifyPending)
  1245 	if(iEapAccessNotifyData.iNotifyPending)
  1240 		{
  1246 		{
  1241 		iEapAccessNotifyData.iNotifyPending = EFalse;
  1247 		iEapAccessNotifyData.iNotifyPending = EFalse;
  1242 		ReqCompleted(aTsyReqHandle, KErrCancel);
  1248 		ReqCompleted(aTsyReqHandle, KErrCancel);
  1243 		return KErrNone;
  1249 		return KErrNone;
  1247 	return KErrNone;
  1253 	return KErrNone;
  1248 	}
  1254 	}
  1249 
  1255 
  1250 void CSimSmartCardEap::SimCompleteNotifyEapMethodAccessStatusChange()
  1256 void CSimSmartCardEap::SimCompleteNotifyEapMethodAccessStatusChange()
  1251 	{
  1257 	{
  1252 	LOGPHONE1("CSimSmartCardEap::SimCompleteNotifyEapMethodAccessStatusChange called");
  1258 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMARTCARDEAP_SIMCOMPLETENOTIFYEAPMETHODACCESSSTATUSCHANGE_1, "CSimSmartCardEap::SimCompleteNotifyEapMethodAccessStatusChange called");
  1253 
  1259 
  1254 	if(iEapAccessNotifyData.iNotifyPending)
  1260 	if(iEapAccessNotifyData.iNotifyPending)
  1255 		{
  1261 		{
  1256 		iEapAccessNotifyData.iNotifyPending = EFalse;
  1262 		iEapAccessNotifyData.iNotifyPending = EFalse;
  1257 		*(reinterpret_cast<RMobileSmartCardEap::TEapMethodAccessStatus*>(iEapAccessNotifyData.iNotifyData)) = iAccessStatus;
  1263 		*(reinterpret_cast<RMobileSmartCardEap::TEapMethodAccessStatus*>(iEapAccessNotifyData.iNotifyData)) = iAccessStatus;