eapol/eapol_framework/eapol_symbian/am/core/symbian/eapol_am_wlan_authentication_symbian.cpp
branchRCL_3
changeset 46 c74b3d9f6b9e
parent 45 bad0cc58d154
equal deleted inserted replaced
45:bad0cc58d154 46:c74b3d9f6b9e
    14 * Description:  EAP and WLAN authentication protocols.
    14 * Description:  EAP and WLAN authentication protocols.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 /*
    18 /*
    19 * %version: 94 %
    19 * %version: 59.1.4 %
    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
    37 #include "eap_am_file_input_symbian.h"
    37 #include "eap_am_file_input_symbian.h"
    38 #include "eap_type_selection.h"
    38 #include "eap_type_selection.h"
    39 #include "eapol_key_types.h"
    39 #include "eapol_key_types.h"
    40 #include "eap_timer_queue.h"
    40 #include "eap_timer_queue.h"
    41 #include "eap_crypto_api.h"
    41 #include "eap_crypto_api.h"
    42 #include "abs_eap_database_reference_if.h"
    42 #include "abs_eapol_wlan_database_reference_if.h"
    43 #include "abs_eap_state_notification.h"
    43 #include "abs_eap_state_notification.h"
    44 #include "eap_state_notification.h"
    44 #include "eap_state_notification.h"
    45 #include "eap_automatic_variable.h"
    45 #include "eap_automatic_variable.h"
    46 #include "eap_base_type.h"
    46 #include "eap_base_type.h"
    47 #include "abs_eap_am_message_if.h"
       
    48 #include "eap_am_message_if.h"
       
    49 #include "eap_core_client_message_if.h"
       
    50 
    47 
    51 #include "EapolDbDefaults.h"
    48 #include "EapolDbDefaults.h"
    52 #include "EapolDbParameterNames.h"
    49 #include "EapolDbParameterNames.h"
    53 #include "EapConversion.h"
       
    54 #include "EapConfigToolsSymbian.h"
       
    55 #include "EapPluginTools.h"
       
    56 
       
    57 #include <wdbifwlansettings.h>
       
    58 
    50 
    59 const TUint KMaxSqlQueryLength = 2048;
    51 const TUint KMaxSqlQueryLength = 2048;
       
    52 
       
    53 #ifdef USE_EAP_EXPANDED_TYPES
       
    54 
       
    55 const TUint KExpandedEAPSize = 8;
       
    56 
       
    57 #else
       
    58 
       
    59 const TUint KMaxEapCueLength = 3;
       
    60 
       
    61 #endif //#ifdef USE_EAP_EXPANDED_TYPES
    60 
    62 
    61 //--------------------------------------------------
    63 //--------------------------------------------------
    62 
    64 
    63 // 
    65 // 
    64 EAP_FUNC_EXPORT eapol_am_wlan_authentication_symbian_c::~eapol_am_wlan_authentication_symbian_c()
    66 EAP_FUNC_EXPORT eapol_am_wlan_authentication_symbian_c::~eapol_am_wlan_authentication_symbian_c()
    66 	EAP_TRACE_DEBUG(
    68 	EAP_TRACE_DEBUG(
    67 		m_am_tools, 
    69 		m_am_tools, 
    68 		TRACE_FLAGS_DEFAULT, 
    70 		TRACE_FLAGS_DEFAULT, 
    69 		(EAPL("eapol_am_wlan_authentication_symbian_c::~eapol_am_wlan_authentication_symbian_c(): this = 0x%08x\n"),
    71 		(EAPL("eapol_am_wlan_authentication_symbian_c::~eapol_am_wlan_authentication_symbian_c(): this = 0x%08x\n"),
    70 		this));
    72 		this));
    71 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eapol_am_wlan_authentication_symbian_c::~eapol_am_wlan_authentication_symbian_c()");
       
    72 }
    73 }
    73 
    74 
    74 //--------------------------------------------------
    75 //--------------------------------------------------
    75 
    76 
    76 // 
    77 // 
    77 EAP_FUNC_EXPORT eapol_am_wlan_authentication_symbian_c::eapol_am_wlan_authentication_symbian_c(
    78 EAP_FUNC_EXPORT eapol_am_wlan_authentication_symbian_c::eapol_am_wlan_authentication_symbian_c(
    78 	abs_eap_am_tools_c * const tools,
    79 	abs_eap_am_tools_c * const tools,
    79 	const bool is_client_when_true)
    80 	const bool is_client_when_true,
    80 : m_am_partner(0)
    81 	const abs_eapol_wlan_database_reference_if_c * const wlan_database_reference)
       
    82 : CActive(CActive::EPriorityStandard)
       
    83 , m_am_partner(0)
    81 #if defined(USE_EAP_SIMPLE_CONFIG)
    84 #if defined(USE_EAP_SIMPLE_CONFIG)
    82 , m_configuration_if(0)
    85 , m_configuration_if(0)
    83 #endif // #if defined(USE_EAP_SIMPLE_CONFIG)
    86 #endif // #if defined(USE_EAP_SIMPLE_CONFIG)
    84 , m_am_tools(tools)
    87 , m_am_tools(tools)
    85 , m_fileconfig(0)
    88 , m_fileconfig(0)
    86 , m_SSID(tools)
    89 , m_SSID(tools)
    87 , m_wpa_preshared_key(tools)
    90 , m_wpa_preshared_key(tools)
    88 , m_wpa_preshared_key_hash(tools)
    91 , m_wpa_preshared_key_hash(tools)
    89 , m_database_reference(tools)
    92 , m_wlan_database_reference(wlan_database_reference)
       
    93 #ifdef USE_EAP_EXPANDED_TYPES
       
    94 , m_eap_type_array(tools)
       
    95 #endif
    90 , m_receive_network_id(tools)
    96 , m_receive_network_id(tools)
       
    97 , m_security_mode(Wpa)
    91 , m_selected_eapol_key_authentication_type(eapol_key_authentication_type_none)
    98 , m_selected_eapol_key_authentication_type(eapol_key_authentication_type_none)
    92 , m_WPA_override_enabled(false)
    99 , m_WPA_override_enabled(false)
    93 , m_is_client(is_client_when_true)
   100 , m_is_client(is_client_when_true)
    94 , m_is_valid(false)
   101 , m_is_valid(false)
    95 
   102 
    96 {
   103 {
    97 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   104 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
    98 
   105 
    99 	EAP_TRACE_DEBUG(
       
   100 		m_am_tools, 
       
   101 		TRACE_FLAGS_DEFAULT, 
       
   102 		(EAPL("eapol_am_wlan_authentication_symbian_c::eapol_am_wlan_authentication_symbian_c(): this = 0x%08x\n"),
       
   103 		this));
       
   104 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eapol_am_wlan_authentication_symbian_c::eapol_am_wlan_authentication_symbian_c()");
       
   105 
       
   106 	m_is_valid = true;
   106 	m_is_valid = true;
   107 
   107 
   108 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   108 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   109 }
   109 }
   110 
   110 
   111 //--------------------------------------------------
   111 //--------------------------------------------------
   112 
   112 
   113 EAP_FUNC_EXPORT bool eapol_am_wlan_authentication_symbian_c::get_is_valid()
   113 EAP_FUNC_EXPORT bool eapol_am_wlan_authentication_symbian_c::get_is_valid()
   114 {
   114 {
   115 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   115 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   116 
       
   117 	EAP_TRACE_DEBUG(
       
   118 		m_am_tools, 
       
   119 		TRACE_FLAGS_DEFAULT, 
       
   120 		(EAPL("eapol_am_wlan_authentication_symbian_c::get_is_valid(): this = 0x%08x\n"),
       
   121 		this));
       
   122 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eapol_am_wlan_authentication_symbian_c::get_is_valid()");
       
   123 
   116 
   124 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   117 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   125 	return m_is_valid;
   118 	return m_is_valid;
   126 }
   119 }
   127 
   120 
   131 {
   124 {
   132 	EAP_TRACE_DEBUG(
   125 	EAP_TRACE_DEBUG(
   133 		m_am_tools,
   126 		m_am_tools,
   134 		TRACE_FLAGS_DEFAULT,
   127 		TRACE_FLAGS_DEFAULT,
   135 		(EAPL("eapol_am_wlan_authentication_symbian_c::TryOpenDatabaseL()\n")));	
   128 		(EAPL("eapol_am_wlan_authentication_symbian_c::TryOpenDatabaseL()\n")));	
   136 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eapol_am_wlan_authentication_symbian_c::TryInitDatabaseL()");
       
   137 		
   129 		
   138 	// 1. Open/create a database	
   130 	// 1. Open/create a database	
   139 	RDbNamedDatabase db;
   131 	RDbNamedDatabase db;
   140 
   132 
       
   133 #ifdef SYMBIAN_SECURE_DBMS
       
   134 	
   141 	// Create the secure shared database (if necessary) with the specified secure policy.
   135 	// Create the secure shared database (if necessary) with the specified secure policy.
   142 	// Database will be created in the data caging path for DBMS (C:\private\100012a5).
   136 	// Database will be created in the data caging path for DBMS (C:\private\100012a5).
   143 
   137 	
   144 	TFileName aPrivateDatabasePathName;
   138 	TInt err = db.Create(m_session, KDatabaseName, KSecureUIDFormat);
   145 
       
   146 	EapPluginTools::GetPrivatePathL(
       
   147 		m_session,
       
   148 		aPrivateDatabasePathName);
       
   149 
       
   150 	aPrivateDatabasePathName.Append(KEapolDatabaseName);
       
   151 
       
   152 	EAP_TRACE_DATA_DEBUG_SYMBIAN(("aPrivateDatabasePathName",
       
   153 		aPrivateDatabasePathName.Ptr(),
       
   154 		aPrivateDatabasePathName.Size()));
       
   155 
       
   156 	TInt error = db.Create(m_session, aPrivateDatabasePathName);
       
   157 	
   139 	
   158 	EAP_TRACE_DEBUG(
   140 	EAP_TRACE_DEBUG(
   159 		m_am_tools,
   141 		m_am_tools,
   160 		TRACE_FLAGS_DEFAULT,
   142 		TRACE_FLAGS_DEFAULT,
   161 		(EAPL("TryOpenDatabaseL() - Created Secure DB for eapol.dat. error=%d\n"), error ));	
   143 		(EAPL("TryOpenDatabaseL() - Created Secure DB for eapol.dat. err=%d\n"), err ));	
   162 		
   144 		
   163 	if(error == KErrNone)
   145 	if(err == KErrNone)
   164 	{	
   146 	{	
   165 		db.Close();
   147 		db.Close();
   166 		
   148 		
   167 	} else if (error != KErrAlreadyExists) 
   149 	} else if (err != KErrAlreadyExists) 
   168 	{
   150 	{
   169 		User::LeaveIfError(error);
   151 		User::LeaveIfError(err);
   170 	}
   152 	}
   171 	
   153 	
   172 	User::LeaveIfError(db.Open(m_session, aPrivateDatabasePathName));	
   154 	User::LeaveIfError(db.Open(m_session, KDatabaseName, KSecureUIDFormat));	
   173 		
   155 		
       
   156 #else
       
   157 	// For non-secured database. The database will be created in the old location (c:\system\data).
       
   158 	
       
   159 	// Create the database (if necessary)		
       
   160 	TInt err = db.Create(m_fs, KDatabaseName);
       
   161 	
       
   162 	EAP_TRACE_DEBUG(
       
   163 		m_am_tools,
       
   164 		TRACE_FLAGS_DEFAULT,
       
   165 		(EAPL("TryOpenDatabaseL() - Created Non-Secure DB for eapol.dat. err=%d\n"), err ));	
       
   166 	
       
   167 	if(err == KErrNone)
       
   168 	{
       
   169 		db.Close();
       
   170 		
       
   171 	} else if (err != KErrAlreadyExists) 
       
   172 	{
       
   173 		User::LeaveIfError(err);
       
   174 	}
       
   175 		
       
   176 	User::LeaveIfError(db.Open(m_session, KDatabaseName));
       
   177 	    
       
   178 #endif // #ifdef SYMBIAN_SECURE_DBMS		
       
   179 
   174 	CleanupClosePushL(db);
   180 	CleanupClosePushL(db);
   175 
   181 
   176 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
   182 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
   177 	TPtr sqlStatement = buf->Des();
   183 	TPtr sqlStatement = buf->Des();
   178 
   184 
   190 											 %S VARBINARY(255), \
   196 											 %S VARBINARY(255), \
   191 											 %S VARBINARY(255), \
   197 											 %S VARBINARY(255), \
   192 											 %S VARBINARY(255))");
   198 											 %S VARBINARY(255))");
   193 	sqlStatement.Format(KSQLCreateTable2, &KEapolPSKTableName, 
   199 	sqlStatement.Format(KSQLCreateTable2, &KEapolPSKTableName, 
   194 		&KServiceType, &KServiceIndex, &KSSID, &KPassword, &KPSK);
   200 		&KServiceType, &KServiceIndex, &KSSID, &KPassword, &KPSK);
   195 	error = db.Execute(sqlStatement);
   201 	err = db.Execute(sqlStatement);
   196 	if (error != KErrNone && error != KErrAlreadyExists)
   202 	if (err != KErrNone && err != KErrAlreadyExists)
   197 	{
   203 	{
   198 		User::Leave(error);
   204 		User::Leave(err);
   199 	}
   205 	}
   200 	
   206 	
   201 	CleanupStack::PopAndDestroy(buf);
   207 	CleanupStack::PopAndDestroy(); // buf
   202 	
   208 	
   203 	// If compacting is not done the database will start growing
   209 	// If compacting is not done the database will start growing
   204 	db.Compact();
   210 	db.Compact();
   205 	
   211 	
   206 	CleanupStack::PopAndDestroy(&db);
   212 	CleanupStack::PopAndDestroy(); // Close database
   207 }
   213 }
   208 
   214 
   209 //--------------------------------------------------
   215 //--------------------------------------------------
   210 
   216 
   211 void eapol_am_wlan_authentication_symbian_c::InitDatabaseL()
   217 void eapol_am_wlan_authentication_symbian_c::InitDatabaseL()
   212 {
   218 {
   213 	EAP_TRACE_DEBUG(
   219 	EAP_TRACE_DEBUG(
   214 		m_am_tools,
   220 		m_am_tools,
   215 		TRACE_FLAGS_DEFAULT,
   221 		TRACE_FLAGS_DEFAULT,
   216 		(EAPL("eapol_am_wlan_authentication_symbian_c::InitDatabaseL()\n")));
   222 		(EAPL("eapol_am_wlan_authentication_symbian_c::OpenDatabaseL()\n")));
   217 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eapol_am_wlan_authentication_symbian_c::InitDatabaseL()");
       
   218 
   223 
   219 	// Create the database (if necessary)
   224 	// Create the database (if necessary)
   220 	TRAPD(error, TryInitDatabaseL());
   225 	TRAPD(err, TryInitDatabaseL());
   221 	if (error != KErrNone)
   226 	if (err != KErrNone)
   222 	{
   227 	{
   223 		// Because of error remove the database file.
   228 		// Because of error remove the database file.
   224 		TFileName aPrivateDatabasePathName;
   229 		err = m_fs.Delete(KDatabaseName);
   225 
   230 		if(err != KErrNone)
   226 		EapPluginTools::GetPrivatePathL(
       
   227 			m_session,
       
   228 			aPrivateDatabasePathName);
       
   229 
       
   230 		aPrivateDatabasePathName.Append(KEapolDatabaseName);
       
   231 
       
   232 		EAP_TRACE_DATA_DEBUG_SYMBIAN(("aPrivateDatabasePathName",
       
   233 			aPrivateDatabasePathName.Ptr(),
       
   234 			aPrivateDatabasePathName.Size()));
       
   235 
       
   236 		error = m_session.Delete(aPrivateDatabasePathName);
       
   237 		if(error != KErrNone)
       
   238 		{
   231 		{
   239 			User::Leave(KErrCorrupt);
   232 			User::Leave(KErrCorrupt);
   240 		}		
   233 		}		
   241 
   234 
   242 		// Try open database again. This will leave if fails second time.
   235 		// Try open database again. This will leave if fails second time.
   255 		TRACE_FLAGS_DEFAULT, 
   248 		TRACE_FLAGS_DEFAULT, 
   256 		(EAPL("eapol_am_wlan_authentication_symbian_c::configure(): %s, this = 0x%08x => 0x%08x\n"),
   249 		(EAPL("eapol_am_wlan_authentication_symbian_c::configure(): %s, this = 0x%08x => 0x%08x\n"),
   257 		 (m_is_client == true) ? "client": "server",
   250 		 (m_is_client == true) ? "client": "server",
   258 		 this,
   251 		 this,
   259 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
   252 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
   260 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eapol_am_wlan_authentication_symbian_c::configure()");
       
   261 
   253 
   262 	TInt error(KErrNone);
   254 	TInt error(KErrNone);
   263 	eap_status_e status(eap_status_process_general_error);
       
   264 
   255 
   265 	// Open the database session
   256 	// Open the database session
   266 	error = m_session.Connect();
   257 	error = m_session.Connect();
   267 	if (error != KErrNone)
   258 	if (error != KErrNone)
   268 	{
   259 	{
   269 		eap_status_e status(m_am_tools->convert_am_error_to_eapol_error(error));
   260 		eap_status_e status(m_am_tools->convert_am_error_to_eapol_error(error));
   270 
   261 
   271 		EAP_TRACE_DEBUG(
   262 		EAP_TRACE_DEBUG(
   272 			m_am_tools,
   263 			m_am_tools,
   273 			TRACE_FLAGS_DEFAULT,
   264 			TRACE_FLAGS_DEFAULT,
   274 			(EAPL("ERROR: RDbs::Connect() failed %d=%s.\n"),
   265 			(EAPL("RDbs::Connect() failed %d.\n"),
   275 			status,
   266 			status));
   276 			eap_status_string_c::get_status_string(status)));
       
   277 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   267 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   278 		return EAP_STATUS_RETURN(m_am_tools, status);
   268 		return EAP_STATUS_RETURN(m_am_tools, status);
   279 	}
   269 	}
   280 
   270 
   281 	EAP_TRACE_DEBUG(
   271 	EAP_TRACE_DEBUG(
   282 		m_am_tools,
   272 		m_am_tools,
   283 		TRACE_FLAGS_DEFAULT,
   273 		TRACE_FLAGS_DEFAULT,
   284 		(EAPL("Database session initialized...\n")));
   274 		(EAPL("Database session initialized...\n")));
   285 
   275 
   286 	// Initialize database
   276 	// Connect to FS
   287 	TRAP(error, InitDatabaseL());
   277 	error = m_fs.Connect();
   288 	if (error != KErrNone)
   278 	if (error != KErrNone)
   289 	{
   279 	{
   290 		eap_status_e status(m_am_tools->convert_am_error_to_eapol_error(error));
   280 		eap_status_e status(m_am_tools->convert_am_error_to_eapol_error(error));
   291 
   281 
   292 		EAP_TRACE_DEBUG(
   282 		EAP_TRACE_DEBUG(
   293 			m_am_tools,
   283 			m_am_tools,
   294 			TRACE_FLAGS_DEFAULT,
   284 			TRACE_FLAGS_DEFAULT,
   295 			(EAPL("ERROR: InitDatabaseL failed %d=%s.\n"),
   285 			(EAPL("RFs::Connect() failed %d.\n"),
   296 			status,
   286 			status));
   297 			eap_status_string_c::get_status_string(status)));
   287 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   288 		return EAP_STATUS_RETURN(m_am_tools, status);
       
   289 	}
       
   290 
       
   291 	EAP_TRACE_DEBUG(
       
   292 		m_am_tools,
       
   293 		TRACE_FLAGS_DEFAULT,
       
   294 		(EAPL("Fileserver session initialized...\n")));
       
   295 
       
   296 	// Initialize database
       
   297 	TRAPD(err, InitDatabaseL());
       
   298 	if (err != KErrNone)
       
   299 	{
       
   300 		eap_status_e status(m_am_tools->convert_am_error_to_eapol_error(error));
       
   301 
       
   302 		EAP_TRACE_DEBUG(
       
   303 			m_am_tools,
       
   304 			TRACE_FLAGS_DEFAULT,
       
   305 			(EAPL("InitDatabaseL failed %d.\n"),
       
   306 			status));
   298 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   307 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   299 		return EAP_STATUS_RETURN(m_am_tools, status);
   308 		return EAP_STATUS_RETURN(m_am_tools, status);
   300 	}
   309 	}
   301 
   310 
   302 	EAP_TRACE_DEBUG(
   311 	EAP_TRACE_DEBUG(
   304 		TRACE_FLAGS_DEFAULT,
   313 		TRACE_FLAGS_DEFAULT,
   305 		(EAPL("Database initialized...\n")));
   314 		(EAPL("Database initialized...\n")));
   306 
   315 
   307 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   316 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   308 
   317 
   309 	status = EapConfigToolsSymbian::EapReadDefaultConfigFileSymbian(
   318 #if defined(USE_EAP_FILECONFIG)
   310 		m_am_tools,
   319 	{
   311 		&m_fileconfig);
   320 		eap_am_file_input_symbian_c * const fileio = new eap_am_file_input_symbian_c(m_am_tools);
   312 	if (status != eap_status_ok)
   321 
   313 	{
   322 		eap_automatic_variable_c<eap_am_file_input_symbian_c> automatic_fileio(m_am_tools, fileio);
   314 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   323 
   315 		return EAP_STATUS_RETURN(m_am_tools, status);
   324 		if (fileio != 0
   316 	}
   325 			&& fileio->get_is_valid() == true)
       
   326 		{
       
   327 			EAP_TRACE_DEBUG(
       
   328 				m_am_tools,
       
   329 				TRACE_FLAGS_DEFAULT,
       
   330 				(EAPL("Initialize file configuration.\n")));
       
   331 
       
   332 			eap_variable_data_c file_name_c_data(m_am_tools);
       
   333 
       
   334 			eap_status_e status(eap_status_process_general_error);
       
   335 
       
   336 			{
       
   337 				#if defined(EAPOL_SYMBIAN_VERSION_7_0_s)
       
   338 					eap_const_string const FILECONFIG_FILENAME_C
       
   339 						= "c:\\system\\data\\eap.conf";
       
   340 				#else
       
   341 					eap_const_string const FILECONFIG_FILENAME_C
       
   342 						= "c:\\private\\101F8EC5\\eap.conf";
       
   343 				#endif
       
   344 
       
   345 				status = file_name_c_data.set_copy_of_buffer(
       
   346 					FILECONFIG_FILENAME_C,
       
   347 					m_am_tools->strlen(FILECONFIG_FILENAME_C));
       
   348 				if (status != eap_status_ok)
       
   349 				{
       
   350 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   351 					return EAP_STATUS_RETURN(m_am_tools, status);
       
   352 				}
       
   353 
       
   354 				status = file_name_c_data.add_end_null();
       
   355 				if (status != eap_status_ok)
       
   356 				{
       
   357 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   358 					return EAP_STATUS_RETURN(m_am_tools, status);
       
   359 				}
       
   360 			}
       
   361 
       
   362 			eap_variable_data_c file_name_z_data(m_am_tools);
       
   363 
       
   364 			{
       
   365 				#if defined(EAPOL_SYMBIAN_VERSION_7_0_s)
       
   366 					eap_const_string const FILECONFIG_FILENAME_Z
       
   367 						= "z:\\system\\data\\eap.conf";
       
   368 				#else
       
   369 					eap_const_string const FILECONFIG_FILENAME_Z
       
   370 						= "z:\\private\\101F8EC5\\eap.conf";
       
   371 				#endif
       
   372 
       
   373 				status = file_name_z_data.set_copy_of_buffer(
       
   374 					FILECONFIG_FILENAME_Z,
       
   375 					m_am_tools->strlen(FILECONFIG_FILENAME_Z));
       
   376 				if (status != eap_status_ok)
       
   377 				{
       
   378 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   379 					return EAP_STATUS_RETURN(m_am_tools, status);
       
   380 				}
       
   381 
       
   382 				status = file_name_z_data.add_end_null();
       
   383 				if (status != eap_status_ok)
       
   384 				{
       
   385 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   386 					return EAP_STATUS_RETURN(m_am_tools, status);
       
   387 				}
       
   388 			}
       
   389 
       
   390 
       
   391 
       
   392 			if (status == eap_status_ok)
       
   393 			{
       
   394 				// First try open from C: disk.
       
   395 				status = fileio->file_open(
       
   396 					&file_name_c_data,
       
   397 					eap_file_io_direction_read);
       
   398 				if (status == eap_status_ok)
       
   399 				{
       
   400 					EAP_TRACE_DEBUG(
       
   401 						m_am_tools,
       
   402 						TRACE_FLAGS_DEFAULT,
       
   403 						(EAPL("Opens configure file %s\n"),
       
   404 						file_name_c_data.get_data(file_name_c_data.get_data_length())));
       
   405 				}
       
   406 				else if (status != eap_status_ok)
       
   407 				{
       
   408 					// Second try open from Z: disk.
       
   409 					status = fileio->file_open(
       
   410 						&file_name_z_data,
       
   411 						eap_file_io_direction_read);
       
   412 					if (status == eap_status_ok)
       
   413 					{
       
   414 						EAP_TRACE_DEBUG(
       
   415 							m_am_tools,
       
   416 							TRACE_FLAGS_DEFAULT,
       
   417 							(EAPL("Opens configure file %s\n"),
       
   418 							 file_name_z_data.get_data(file_name_z_data.get_data_length())));
       
   419 					}
       
   420 				}
       
   421 
       
   422 				if (status == eap_status_ok)
       
   423 				{
       
   424 					// Some of the files were opened.
       
   425 
       
   426 					m_fileconfig = new eap_file_config_c(m_am_tools);
       
   427 					if (m_fileconfig != 0
       
   428 						&& m_fileconfig->get_is_valid() == true)
       
   429 					{
       
   430 						status = m_fileconfig->configure(fileio);
       
   431 						if (status != eap_status_ok)
       
   432 						{
       
   433 							EAP_TRACE_DEBUG(
       
   434 								m_am_tools,
       
   435 								TRACE_FLAGS_DEFAULT,
       
   436 								(EAPL("ERROR: Configure read from %s failed.\n"),
       
   437 								file_name_c_data.get_data(file_name_c_data.get_data_length())));
       
   438 						}
       
   439 						else
       
   440 						{
       
   441 							EAP_TRACE_DEBUG(
       
   442 								m_am_tools,
       
   443 								TRACE_FLAGS_DEFAULT,
       
   444 								(EAPL("Configure read from %s\n"),
       
   445 								file_name_c_data.get_data(file_name_c_data.get_data_length())));
       
   446 						}
       
   447 					}
       
   448 					else
       
   449 					{
       
   450 						// No file configuration.
       
   451 						delete m_fileconfig;
       
   452 						m_fileconfig = 0;
       
   453 
       
   454 						EAP_TRACE_DEBUG(
       
   455 							m_am_tools,
       
   456 							TRACE_FLAGS_DEFAULT,
       
   457 							(EAPL("ERROR: Cannot create configure object for file %s\n"),
       
   458 							file_name_c_data.get_data(file_name_c_data.get_data_length())));
       
   459 					}
       
   460 				}
       
   461 				else
       
   462 				{
       
   463 					EAP_TRACE_DEBUG(
       
   464 						m_am_tools,
       
   465 						TRACE_FLAGS_DEFAULT,
       
   466 						(EAPL("ERROR: Cannot open configure file neither %s nor %s\n"),
       
   467 						file_name_c_data.get_data(file_name_c_data.get_data_length()),
       
   468 						file_name_z_data.get_data(file_name_z_data.get_data_length())));
       
   469 				}
       
   470 			}
       
   471 		}
       
   472 		else
       
   473 		{
       
   474 			EAP_TRACE_DEBUG(
       
   475 				m_am_tools,
       
   476 				TRACE_FLAGS_DEFAULT,
       
   477 				(EAPL("Skips file configuration.\n")));
       
   478 		}
       
   479 	}
       
   480 #endif //#if defined(USE_EAP_FILECONFIG)
   317 
   481 
   318 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   482 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   319 
   483 
   320 #if defined(USE_EAP_FILE_TRACE)
   484 #if defined(USE_EAP_FILE_TRACE)
   321 	{
   485 	{
   322 		eap_variable_data_c trace_output_file(m_am_tools);
   486 		eap_variable_data_c trace_output_file(m_am_tools);
   323 
   487 
   324 		status = read_configure(
   488 		eap_status_e status = read_configure(
   325 			cf_str_EAP_TRACE_output_file_name.get_field(),
   489 			cf_str_EAP_TRACE_output_file_name.get_field(),
   326 			&trace_output_file);
   490 			&trace_output_file);
   327 		if (status == eap_status_ok
   491 		if (status == eap_status_ok
   328 			&& trace_output_file.get_is_valid_data() == true)
   492 			&& trace_output_file.get_is_valid_data() == true)
   329 		{
   493 		{
   343 
   507 
   344 
   508 
   345 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   509 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   346 
   510 
   347 	{
   511 	{
   348 		eap_variable_data_c EAP_TRACE_enable_timer_traces(m_am_tools);
       
   349 
       
   350 		status = read_configure(
       
   351 			cf_str_EAP_TRACE_enable_timer_traces.get_field(),
       
   352 			&EAP_TRACE_enable_timer_traces);
       
   353 		if (status == eap_status_ok
       
   354 			&& EAP_TRACE_enable_timer_traces.get_is_valid_data() == true)
       
   355 		{
       
   356 			u32_t *enable_timer_traces = reinterpret_cast<u32_t *>(
       
   357 				EAP_TRACE_enable_timer_traces.get_data(sizeof(u32_t)));
       
   358 			if (enable_timer_traces != 0
       
   359 				&& *enable_timer_traces != 0)
       
   360 			{
       
   361 				m_am_tools->set_trace_mask(
       
   362 					m_am_tools->get_trace_mask()
       
   363 					| TRACE_FLAGS_TIMER
       
   364 					);
       
   365 			}
       
   366 		}
       
   367 	}
       
   368 
       
   369 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
   370 
       
   371 	{
       
   372 		eap_variable_data_c EAP_TRACE_enable_timer_queue_traces(m_am_tools);
   512 		eap_variable_data_c EAP_TRACE_enable_timer_queue_traces(m_am_tools);
   373 
   513 
   374 		status = read_configure(
   514 		eap_status_e status = read_configure(
   375 			cf_str_EAP_TRACE_enable_timer_queue_traces.get_field(),
   515 			cf_str_EAP_TRACE_enable_timer_queue_traces.get_field(),
   376 			&EAP_TRACE_enable_timer_queue_traces);
   516 			&EAP_TRACE_enable_timer_queue_traces);
   377 		if (status == eap_status_ok
   517 		if (status == eap_status_ok
   378 			&& EAP_TRACE_enable_timer_queue_traces.get_is_valid_data() == true)
   518 			&& EAP_TRACE_enable_timer_queue_traces.get_is_valid_data() == true)
   379 		{
   519 		{
   382 			if (enable_timer_queue_traces != 0
   522 			if (enable_timer_queue_traces != 0
   383 				&& *enable_timer_queue_traces != 0)
   523 				&& *enable_timer_queue_traces != 0)
   384 			{
   524 			{
   385 				m_am_tools->set_trace_mask(
   525 				m_am_tools->set_trace_mask(
   386 					m_am_tools->get_trace_mask()
   526 					m_am_tools->get_trace_mask()
   387 					| TRACE_FLAGS_TIMER_QUEUE
   527 					| eap_am_tools_c::eap_trace_mask_timer_queue
   388 					);
   528 					);
   389 			}
   529 			}
   390 		}
   530 		}
   391 	}
   531 	}
   392 
   532 
   393 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
   394 
       
   395 	{
   533 	{
   396 		eap_variable_data_c EAP_TRACE_enable_function_traces(m_am_tools);
   534 		eap_variable_data_c EAP_TRACE_enable_function_traces(m_am_tools);
   397 
   535 
   398 		status = read_configure(
   536 		eap_status_e status = read_configure(
   399 			cf_str_EAP_TRACE_enable_function_traces.get_field(),
   537 			cf_str_EAP_TRACE_enable_function_traces.get_field(),
   400 			&EAP_TRACE_enable_function_traces);
   538 			&EAP_TRACE_enable_function_traces);
   401 		if (status == eap_status_ok
   539 		if (status == eap_status_ok
   402 			&& EAP_TRACE_enable_function_traces.get_is_valid_data() == true)
   540 			&& EAP_TRACE_enable_function_traces.get_is_valid_data() == true)
   403 		{
   541 		{
   422 		(EAPL("Created timer...\n")));
   560 		(EAPL("Created timer...\n")));
   423 
   561 
   424 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   562 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   425 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
   563 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
   426 }
   564 }
       
   565 
       
   566 //--------------------------------------------------
       
   567 
       
   568 eap_status_e eapol_am_wlan_authentication_symbian_c::reset_eap_plugins()
       
   569 {
       
   570 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   571 
       
   572 	EAP_TRACE_DEBUG(
       
   573 		m_am_tools, 
       
   574 		TRACE_FLAGS_DEFAULT, 
       
   575 		(EAPL("eapol_am_wlan_authentication_symbian_c::reset_eap_plugins(): %s, this = 0x%08x => 0x%08x\n"),
       
   576 		 (m_is_client == true) ? "client": "server",
       
   577 		 this,
       
   578 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
       
   579 
       
   580 	// Unload all loaded plugins
       
   581 	for(int ind = 0; ind < m_plugin_if_array.Count(); ind++)
       
   582 	{
       
   583 		delete m_plugin_if_array[ind];
       
   584 	}
       
   585 
       
   586 	m_plugin_if_array.Close();
       
   587 
       
   588 #ifdef USE_EAP_EXPANDED_TYPES
       
   589 
       
   590 	m_enabled_expanded_eap_array.ResetAndDestroy();
       
   591 
       
   592 	m_disabled_expanded_eap_array.ResetAndDestroy();
       
   593 	
       
   594 	m_eap_type_array.reset();
       
   595 	
       
   596 #else
       
   597 
       
   598 	// Delete the IAP EAP type info array
       
   599 	m_iap_eap_array.ResetAndDestroy();
       
   600 	
       
   601 	m_eap_type_array.Close();	
       
   602 	
       
   603 #endif //#ifdef USE_EAP_EXPANDED_TYPES
       
   604 
       
   605 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   606 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   607 }
       
   608 
   427 
   609 
   428 //--------------------------------------------------
   610 //--------------------------------------------------
   429 
   611 
   430 EAP_FUNC_EXPORT eap_status_e eapol_am_wlan_authentication_symbian_c::shutdown()
   612 EAP_FUNC_EXPORT eap_status_e eapol_am_wlan_authentication_symbian_c::shutdown()
   431 {
   613 {
   436 		TRACE_FLAGS_DEFAULT, 
   618 		TRACE_FLAGS_DEFAULT, 
   437 		(EAPL("eapol_am_wlan_authentication_symbian_c::shutdown(): %s, this = 0x%08x => 0x%08x\n"),
   619 		(EAPL("eapol_am_wlan_authentication_symbian_c::shutdown(): %s, this = 0x%08x => 0x%08x\n"),
   438 		 (m_is_client == true) ? "client": "server",
   620 		 (m_is_client == true) ? "client": "server",
   439 		 this,
   621 		 this,
   440 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
   622 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
   441 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eapol_am_wlan_authentication_symbian_c::shutdown()");
       
   442 
   623 
   443 	m_session.Close();
   624 	m_session.Close();
       
   625 	m_fs.Close();
   444 
   626 
   445 	delete m_fileconfig;
   627 	delete m_fileconfig;
   446 	m_fileconfig = 0;
   628 	m_fileconfig = 0;
       
   629 
       
   630 	(void) reset_eap_plugins();
   447 
   631 
   448 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   632 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   449 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
   633 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
   450 }
   634 }
   451 
   635 
   464 		m_am_tools, 
   648 		m_am_tools, 
   465 		TRACE_FLAGS_DEFAULT, 
   649 		TRACE_FLAGS_DEFAULT, 
   466 		(EAPL("eapol_am_wlan_authentication_simulator_c::set_am_partner(): %s, this = 0x%08x\n"),
   650 		(EAPL("eapol_am_wlan_authentication_simulator_c::set_am_partner(): %s, this = 0x%08x\n"),
   467 		 (m_is_client == true) ? "client": "server",
   651 		 (m_is_client == true) ? "client": "server",
   468 		 this));
   652 		 this));
   469 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eapol_am_wlan_authentication_symbian_c::set_am_partner()");
       
   470 
   653 
   471 	m_am_partner = am_partner;
   654 	m_am_partner = am_partner;
   472 
   655 
   473 #if defined(USE_EAP_SIMPLE_CONFIG)
   656 #if defined(USE_EAP_SIMPLE_CONFIG)
   474 	m_configuration_if = configuration_if;
   657 	m_configuration_if = configuration_if;
   478 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
   661 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
   479 }
   662 }
   480 
   663 
   481 //--------------------------------------------------
   664 //--------------------------------------------------
   482 
   665 
   483 EAP_FUNC_EXPORT eap_status_e eapol_am_wlan_authentication_symbian_c::reset_wpa_configuration()
   666 EAP_FUNC_EXPORT eap_status_e eapol_am_wlan_authentication_symbian_c::reset_eap_configuration()
   484 {
   667 {
   485 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   668 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   486 
   669 
   487 	EAP_TRACE_DEBUG(
   670 	EAP_TRACE_DEBUG(
   488 		m_am_tools, 
   671 		m_am_tools, 
   489 		TRACE_FLAGS_DEFAULT, 
   672 		TRACE_FLAGS_DEFAULT, 
   490 		(EAPL("eapol_am_wlan_authentication_symbian_c::reset_wpa_configuration(): %s, this = 0x%08x\n"),
   673 		(EAPL("eapol_am_wlan_authentication_symbian_c::reset_eap_configuration(): %s, this = 0x%08x\n"),
   491 		 (m_is_client == true) ? "client": "server",
   674 		 (m_is_client == true) ? "client": "server",
   492 		 this));
   675 		 this));
   493 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eapol_am_wlan_authentication_symbian_c::reset_wpa_configuration()");
   676 
   494 
   677 	TRAPD(error, ReadEAPSettingsL());
   495 	TRAPD(error, ReadWPASettingsL());
       
   496 	if (error != KErrNone)
   678 	if (error != KErrNone)
   497 	{
   679 	{
   498 		EAP_TRACE_ERROR(
   680 		EAP_TRACE_ERROR(
   499 			m_am_tools,
   681 			m_am_tools,
   500 			TRACE_FLAGS_DEFAULT,
   682 			TRACE_FLAGS_DEFAULT,
   501 			(EAPL("EAP settings reading from CommDb failed or cancelled(error %d).\n"), error));
   683 			(EAPL("EAP settings reading from CommDb failed or cancelled(err %d).\n"), error));
   502 
   684 
   503 		eap_status_e status(m_am_tools->convert_am_error_to_eapol_error(error));
   685 		eap_status_e status(m_am_tools->convert_am_error_to_eapol_error(error));
   504 
   686 
   505 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
   687 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
   506 		return EAP_STATUS_RETURN(m_am_tools, status);
   688 		return EAP_STATUS_RETURN(m_am_tools, status);
   516 {
   698 {
   517 	EAP_TRACE_DEBUG(m_am_tools, 
   699 	EAP_TRACE_DEBUG(m_am_tools, 
   518 		TRACE_FLAGS_DEFAULT, 
   700 		TRACE_FLAGS_DEFAULT, 
   519 		(EAPL("eapol_am_wlan_authentication_symbian_c::send_error_notification, error=%d\n"),
   701 		(EAPL("eapol_am_wlan_authentication_symbian_c::send_error_notification, error=%d\n"),
   520 		error));	
   702 		error));	
   521 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eapol_am_wlan_authentication_symbian_c::send_error_notification()");
       
   522 
   703 
   523 	eap_general_state_variable_e general_state_variable(eap_general_state_authentication_error);
   704 	eap_general_state_variable_e general_state_variable(eap_general_state_authentication_error);
   524 	
   705 	
   525 	if (error == eap_status_user_cancel_authentication)
   706 	if (error == eap_status_user_cancel_authentication)
   526 		{
   707 		{
   565 		TRACE_FLAGS_DEFAULT, 
   746 		TRACE_FLAGS_DEFAULT, 
   566 		(EAPL("eapol_am_wlan_authentication_symbian_c::set_wlan_parameters(): %s, this = 0x%08x => 0x%08x\n"),
   747 		(EAPL("eapol_am_wlan_authentication_symbian_c::set_wlan_parameters(): %s, this = 0x%08x => 0x%08x\n"),
   567 		 (m_is_client == true) ? "client": "server",
   748 		 (m_is_client == true) ? "client": "server",
   568 		 this,
   749 		 this,
   569 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
   750 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
   570 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eapol_am_wlan_authentication_symbian_c::set_wlan_parameters()");
       
   571 
   751 
   572 	m_WPA_override_enabled = WPA_override_enabled;
   752 	m_WPA_override_enabled = WPA_override_enabled;
   573 
   753 
   574 	m_selected_eapol_key_authentication_type = selected_eapol_key_authentication_type;
   754 	m_selected_eapol_key_authentication_type = selected_eapol_key_authentication_type;
   575 
   755 
   593 }
   773 }
   594 
   774 
   595 //--------------------------------------------------
   775 //--------------------------------------------------
   596 
   776 
   597 //
   777 //
   598 EAP_FUNC_EXPORT void eapol_am_wlan_authentication_symbian_c::state_notification(
   778 void eapol_am_wlan_authentication_symbian_c::state_notification(
   599 	const abs_eap_state_notification_c * const state)
   779 	const abs_eap_state_notification_c * const state)
   600 {
   780 {
   601 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   781 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   602 
       
   603 	EAP_TRACE_DEBUG(
       
   604 		m_am_tools, 
       
   605 		TRACE_FLAGS_DEFAULT, 
       
   606 		(EAPL("eapol_am_wlan_authentication_symbian_c::state_notification(): this = 0x%08x\n"),
       
   607 		this));
       
   608 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eapol_am_wlan_authentication_symbian_c::state_notification()");
       
   609 
   782 
   610 	EAP_UNREFERENCED_PARAMETER(state);
   783 	EAP_UNREFERENCED_PARAMETER(state);
   611 
   784 
   612 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   785 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   613 }
   786 }
   624 		TRACE_FLAGS_DEFAULT, 
   797 		TRACE_FLAGS_DEFAULT, 
   625 		(EAPL("eapol_am_wlan_authentication_symbian_c::association(): %s, this = 0x%08x => 0x%08x\n"),
   798 		(EAPL("eapol_am_wlan_authentication_symbian_c::association(): %s, this = 0x%08x => 0x%08x\n"),
   626 		 (m_is_client == true) ? "client": "server",
   799 		 (m_is_client == true) ? "client": "server",
   627 		 this,
   800 		 this,
   628 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
   801 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
   629 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eapol_am_wlan_authentication_symbian_c::association()");
       
   630 
   802 
   631 	eap_status_e status = m_receive_network_id.set_copy_of_network_id(receive_network_id);
   803 	eap_status_e status = m_receive_network_id.set_copy_of_network_id(receive_network_id);
   632 
   804 
   633 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   805 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   634 	return EAP_STATUS_RETURN(m_am_tools, status);
   806 	return EAP_STATUS_RETURN(m_am_tools, status);
   648 		TRACE_FLAGS_DEFAULT, 
   820 		TRACE_FLAGS_DEFAULT, 
   649 		(EAPL("eapol_am_wlan_authentication_symbian_c::disassociation(): %s, this = 0x%08x => 0x%08x\n"),
   821 		(EAPL("eapol_am_wlan_authentication_symbian_c::disassociation(): %s, this = 0x%08x => 0x%08x\n"),
   650 		 (m_is_client == true) ? "client": "server",
   822 		 (m_is_client == true) ? "client": "server",
   651 		 this,
   823 		 this,
   652 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
   824 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
   653 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eapol_am_wlan_authentication_symbian_c::disassociation()");
       
   654 
   825 
   655 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   826 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   656 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
   827 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
   657 }
   828 }
       
   829 
       
   830 //--------------------------------------------------
       
   831 
       
   832 #ifdef USE_EAP_EXPANDED_TYPES
       
   833 
       
   834 EAP_FUNC_EXPORT eap_status_e eapol_am_wlan_authentication_symbian_c::get_selected_eap_types(
       
   835 	eap_array_c<eap_type_selection_c> * const selected_eap_types)
       
   836 {
       
   837 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   838 
       
   839 	EAP_TRACE_DEBUG(
       
   840 		m_am_tools, 
       
   841 		TRACE_FLAGS_DEFAULT, 
       
   842 		(EAPL("eapol_am_wlan_authentication_symbian_c::get_selected_eap_types(): %s, this = 0x%08x => 0x%08x\n"),
       
   843 		 (m_is_client == true) ? "client": "server",
       
   844 		 this,
       
   845 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
       
   846 
       
   847 	eap_status_e status = selected_eap_types->reset();
       
   848 	if (status != eap_status_ok)
       
   849 	{
       
   850 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   851 		return EAP_STATUS_RETURN(m_am_tools, status);
       
   852 	}
       
   853 
       
   854 	eap_header_string_c eap_string;
       
   855 	EAP_UNREFERENCED_PARAMETER(eap_string);
       
   856 
       
   857 	// We need to return only the EAP types available as enabled types.
       
   858 	// It means only the ones available in m_enabled_expanded_eap_array.
       
   859 	
       
   860 	for (TInt i = 0; i < m_enabled_expanded_eap_array.Count(); i++)
       
   861 	{	
       
   862 		TBuf8<KExpandedEAPSize> tmpExpEAP(m_enabled_expanded_eap_array[i]->EapExpandedType);
       
   863 
       
   864 		EAP_TRACE_DEBUG(
       
   865 			m_am_tools, 
       
   866 			TRACE_FLAGS_DEFAULT, 
       
   867 			(EAPL("eapol_am_wlan_authentication_symbian_c::get_selected_eap_types:Enabled expanded EAP type at index=%d\n"),
       
   868 			 i));
       
   869 
       
   870 		EAP_TRACE_DATA_DEBUG(
       
   871 			m_am_tools,
       
   872 			TRACE_FLAGS_DEFAULT,
       
   873 			(EAPL("Enabled expanded EAP type"),
       
   874 			tmpExpEAP.Ptr(),
       
   875 			tmpExpEAP.Size()));
       
   876 
       
   877 		// This is for one expanded EAP type (for the above one).
       
   878 		eap_expanded_type_c expandedEAPType;
       
   879 				
       
   880 		// Read the expanded EAP type details from an item in m_enabled_expanded_eap_array.
       
   881 		status = eap_expanded_type_c::read_type(m_am_tools,
       
   882 												0,
       
   883 												tmpExpEAP.Ptr(),
       
   884 												tmpExpEAP.Size(),
       
   885 												&expandedEAPType);
       
   886 		if (status != eap_status_ok)
       
   887 		{
       
   888 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   889 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   890 		}
       
   891 
       
   892 		// Add EAP-type to list.
       
   893 		eap_type_selection_c * selection = new eap_type_selection_c(
       
   894 			m_am_tools,
       
   895 			expandedEAPType,
       
   896 			true);
       
   897 		if (selection != 0)
       
   898 		{
       
   899 			status = selected_eap_types->add_object(selection, true);
       
   900 			if (status != eap_status_ok)
       
   901 			{
       
   902 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   903 				return EAP_STATUS_RETURN(m_am_tools, status);
       
   904 			}
       
   905 			
       
   906 			EAP_TRACE_DEBUG(
       
   907 				m_am_tools,
       
   908 				TRACE_FLAGS_DEFAULT,
       
   909 				(EAPL("get_selected_eap_types(): added EAP-type=0x%08x=%s\n"),
       
   910 				expandedEAPType.get_vendor_type(),
       
   911 				eap_string.get_eap_type_string(expandedEAPType)));			
       
   912 		}
       
   913 		else
       
   914 		{
       
   915 			// On error we ignore this EAP-type.
       
   916 			EAP_TRACE_DEBUG(
       
   917 				m_am_tools, 
       
   918 				TRACE_FLAGS_DEFAULT, 
       
   919 				(EAPL("Some problem with EAP type at index %d in m_enabled_expanded_eap_array\n"),
       
   920 				 i));
       
   921 		}
       
   922 	}
       
   923 
       
   924 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   925 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   926 }
       
   927 
       
   928 //--------------------------------------------------
       
   929 
       
   930 #else // for non-expanded (normal EAP types)
       
   931 
       
   932 //--------------------------------------------------
       
   933 
       
   934 EAP_FUNC_EXPORT eap_status_e eapol_am_wlan_authentication_symbian_c::get_selected_eap_types(
       
   935 	eap_array_c<eap_type_selection_c> * const selected_eap_types)
       
   936 {
       
   937 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   938 
       
   939 	EAP_TRACE_DEBUG(
       
   940 		m_am_tools, 
       
   941 		TRACE_FLAGS_DEFAULT, 
       
   942 		(EAPL("eapol_am_wlan_authentication_symbian_c::get_selected_eap_types(): %s, this = 0x%08x => 0x%08x\n"),
       
   943 		 (m_is_client == true) ? "client": "server",
       
   944 		 this,
       
   945 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
       
   946 
       
   947 	eap_status_e status = selected_eap_types->reset();
       
   948 	if (status != eap_status_ok)
       
   949 	{
       
   950 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   951 		return EAP_STATUS_RETURN(m_am_tools, status);
       
   952 	}
       
   953 
       
   954 	eap_header_string_c eap_string;
       
   955 	EAP_UNREFERENCED_PARAMETER(eap_string);
       
   956 
       
   957 	TEap *eapType = 0; 
       
   958 
       
   959 	for (TInt i = 0; i < m_iap_eap_array.Count(); i++)
       
   960 	{
       
   961 		// Check if type is enabled
       
   962 		eapType = m_iap_eap_array[i];
       
   963 		if (eapType->Enabled == 1)
       
   964 		{	
       
   965 			TLex8 tmp(eapType->UID);
       
   966 			TInt val(0);
       
   967 			tmp.Val(val);
       
   968 
       
   969 			EAP_TRACE_DEBUG(
       
   970 				m_am_tools,
       
   971 				TRACE_FLAGS_DEFAULT,
       
   972 				(EAPL("get_selected_eap_types(): adds EAP-type=0x%08x=%s\n"),
       
   973 				static_cast<eap_type_ietf_values_e>(val),
       
   974 				eap_string.get_eap_type_string(
       
   975 					static_cast<eap_type_value_e>(
       
   976 						static_cast<eap_type_ietf_values_e>(val)))));
       
   977 
       
   978 			// Add EAP-type to list.
       
   979 			eap_type_selection_c * selection = new eap_type_selection_c(
       
   980 				m_am_tools,
       
   981 				static_cast<eap_type_value_e>(static_cast<eap_type_ietf_values_e>(val)),
       
   982 				true);
       
   983 			if (selection != 0)
       
   984 			{
       
   985 				status = selected_eap_types->add_object(selection, true);
       
   986 				if (status != eap_status_ok)
       
   987 				{
       
   988 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   989 					return EAP_STATUS_RETURN(m_am_tools, status);
       
   990 				}
       
   991 			}
       
   992 			else
       
   993 			{
       
   994 				// On error we ignore this EAP-type.
       
   995 			}
       
   996 		}
       
   997 	}
       
   998 
       
   999 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1000 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
  1001 }
       
  1002 
       
  1003 #endif //#ifdef USE_EAP_EXPANDED_TYPES
   658 
  1004 
   659 //--------------------------------------------------
  1005 //--------------------------------------------------
   660 
  1006 
   661 EAP_FUNC_EXPORT eap_status_e eapol_am_wlan_authentication_symbian_c::get_wlan_configuration(
  1007 EAP_FUNC_EXPORT eap_status_e eapol_am_wlan_authentication_symbian_c::get_wlan_configuration(
   662 	eap_variable_data_c * const wpa_preshared_key_hash)
  1008 	eap_variable_data_c * const wpa_preshared_key_hash)
   668 		TRACE_FLAGS_DEFAULT, 
  1014 		TRACE_FLAGS_DEFAULT, 
   669 		(EAPL("eapol_am_wlan_authentication_symbian_c::get_wlan_configuration(): %s, this = 0x%08x => 0x%08x\n"),
  1015 		(EAPL("eapol_am_wlan_authentication_symbian_c::get_wlan_configuration(): %s, this = 0x%08x => 0x%08x\n"),
   670 		 (m_is_client == true) ? "client": "server",
  1016 		 (m_is_client == true) ? "client": "server",
   671 		 this,
  1017 		 this,
   672 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
  1018 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
   673 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eapol_am_wlan_authentication_symbian_c::get_wlan_configuration()");
       
   674 
  1019 
   675 	eap_status_e status = wpa_preshared_key_hash->set_copy_of_buffer(&m_wpa_preshared_key_hash);
  1020 	eap_status_e status = wpa_preshared_key_hash->set_copy_of_buffer(&m_wpa_preshared_key_hash);
   676 
  1021 
   677 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1022 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   678 	return EAP_STATUS_RETURN(m_am_tools, status);
  1023 	return EAP_STATUS_RETURN(m_am_tools, status);
   680 
  1025 
   681 //--------------------------------------------------
  1026 //--------------------------------------------------
   682 
  1027 
   683 EAP_FUNC_EXPORT eap_status_e eapol_am_wlan_authentication_symbian_c::authentication_finished(
  1028 EAP_FUNC_EXPORT eap_status_e eapol_am_wlan_authentication_symbian_c::authentication_finished(
   684 	const bool when_true_successfull,
  1029 	const bool when_true_successfull,
   685 	const eap_type_value_e /* eap_type */,
  1030 	const eap_type_value_e eap_type,
   686 	const eapol_key_authentication_type_e authentication_type)
  1031 	const eapol_key_authentication_type_e authentication_type)
   687 {
  1032 {
   688 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  1033 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   689 
  1034 
   690 	EAP_TRACE_DEBUG(
  1035 	EAP_TRACE_DEBUG(
   692 		TRACE_FLAGS_DEFAULT, 
  1037 		TRACE_FLAGS_DEFAULT, 
   693 		(EAPL("eapol_am_wlan_authentication_symbian_c::authentication_finished(): %s, this = 0x%08x => 0x%08x\n"),
  1038 		(EAPL("eapol_am_wlan_authentication_symbian_c::authentication_finished(): %s, this = 0x%08x => 0x%08x\n"),
   694 		 (m_is_client == true) ? "client": "server",
  1039 		 (m_is_client == true) ? "client": "server",
   695 		 this,
  1040 		 this,
   696 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
  1041 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
   697 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eapol_am_wlan_authentication_symbian_c::authentication_finished()");
       
   698 
  1042 
   699 	if (when_true_successfull == true)
  1043 	if (when_true_successfull == true)
   700 	{
  1044 	{
   701 		if (authentication_type != eapol_key_authentication_type_RSNA_PSK
  1045 		if (authentication_type != eapol_key_authentication_type_RSNA_PSK
   702 			&& authentication_type != eapol_key_authentication_type_WPA_PSK)
  1046 			&& authentication_type != eapol_key_authentication_type_WPA_PSK)
   703 		{
  1047 		{
       
  1048 
       
  1049 #ifdef USE_EAP_EXPANDED_TYPES
       
  1050 
       
  1051 			// This moves the successful type to be the top priority type in IAP settings.
       
  1052 			TRAPD(err, SetToTopPriorityL(eap_type));
       
  1053 			if (err != KErrNone)
       
  1054 			{
       
  1055 				// Just log the error. 
       
  1056 				EAP_TRACE_DEBUG(
       
  1057 					m_am_tools,
       
  1058 					TRACE_FLAGS_DEFAULT, 
       
  1059 					(EAPL("state_notification: SetToTopPriorityL() Expanded EAP type - leave with error=%d!\n"),
       
  1060 					err));
       
  1061 			}
       
  1062 
       
  1063 #else // For normal EAP types
       
  1064 					
       
  1065 			TEap eap;
       
  1066 			eap.Enabled = ETrue;
       
  1067 			eap.UID.Num(static_cast<TInt>(convert_eap_type_to_u32_t(eap_type)));
       
  1068 			
       
  1069 			// This moves the successful type to be the top priority type in IAP settings.
       
  1070 			TRAPD(err, SetToTopPriorityL(&eap));
       
  1071 			if (err != KErrNone)
       
  1072 			{
       
  1073 				// Just log the error. 
       
  1074 				EAP_TRACE_DEBUG(
       
  1075 					m_am_tools,
       
  1076 					TRACE_FLAGS_DEFAULT, 
       
  1077 					(EAPL("state_notification: SetToTopPriorityL leaved!\n")));
       
  1078 			}
       
  1079 
       
  1080 #endif //#ifdef USE_EAP_EXPANDED_TYPES
       
  1081 
   704 			// Move the active eap type index to the first type
  1082 			// Move the active eap type index to the first type
   705 			m_am_partner->set_current_eap_index(0ul);
  1083 			m_am_partner->set_current_eap_index(0ul);
   706 		}
  1084 		}
   707 	}
  1085 	}
   708 
  1086 
   723 		TRACE_FLAGS_DEFAULT, 
  1101 		TRACE_FLAGS_DEFAULT, 
   724 		(EAPL("eapol_am_wlan_authentication_symbian_c::read_database_reference_values(): %s, this = 0x%08x => 0x%08x\n"),
  1102 		(EAPL("eapol_am_wlan_authentication_symbian_c::read_database_reference_values(): %s, this = 0x%08x => 0x%08x\n"),
   725 		 (m_is_client == true) ? "client": "server",
  1103 		 (m_is_client == true) ? "client": "server",
   726 		 this,
  1104 		 this,
   727 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
  1105 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
   728 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eapol_am_wlan_authentication_symbian_c::read_database_reference_values()");
  1106 
       
  1107 	eap_variable_data_c database_reference(m_am_tools);
       
  1108 
       
  1109 	eap_status_e status = m_wlan_database_reference->get_wlan_database_reference_values(&database_reference);
       
  1110 	if (status != eap_status_ok)
       
  1111 	{
       
  1112 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1113 		return EAP_STATUS_RETURN(m_am_tools, status);
       
  1114 	}
   729 
  1115 
   730 	const eapol_wlan_database_reference_values_s * const database_reference_values
  1116 	const eapol_wlan_database_reference_values_s * const database_reference_values
   731 		= reinterpret_cast<eapol_wlan_database_reference_values_s *>(
  1117 		= reinterpret_cast<eapol_wlan_database_reference_values_s *>(
   732 		m_database_reference.get_data(sizeof(eapol_wlan_database_reference_values_s)));
  1118 		database_reference.get_data(sizeof(eapol_wlan_database_reference_values_s)));
   733 	if (database_reference_values == 0)
  1119 	if (database_reference_values == 0)
   734 	{
  1120 	{
   735 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1121 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   736 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
  1122 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
   737 	}
  1123 	}
   746 		 *type,
  1132 		 *type,
   747 		 *index));
  1133 		 *index));
   748 
  1134 
   749 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1135 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   750 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
  1136 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
  1137 }
       
  1138 
       
  1139 //--------------------------------------------------
       
  1140 
       
  1141 EAP_FUNC_EXPORT eap_status_e eapol_am_wlan_authentication_symbian_c::load_module(
       
  1142 	const eap_type_value_e type,
       
  1143 	const eap_type_value_e tunneling_type,
       
  1144 	abs_eap_base_type_c * const partner,
       
  1145 	eap_base_type_c ** const eap_type_if,
       
  1146 	const bool is_client_when_true,
       
  1147 	const eap_am_network_id_c * const receive_network_id ///< source includes remote address, destination includes local address.
       
  1148 	)
       
  1149 {
       
  1150 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1151 
       
  1152 	EAP_TRACE_DEBUG(
       
  1153 		m_am_tools,
       
  1154 		TRACE_FLAGS_DEFAULT,
       
  1155 		(EAPL("eapol_am_wlan_authentication_symbian_c::load_module(type %d=%s, tunneling_type %d=%s)\n"),
       
  1156 		convert_eap_type_to_u32_t(type),
       
  1157 		eap_header_string_c::get_eap_type_string(type),
       
  1158 		convert_eap_type_to_u32_t(tunneling_type),
       
  1159 		eap_header_string_c::get_eap_type_string(tunneling_type)));
       
  1160 
       
  1161 	eap_status_e status(eap_status_process_general_error);
       
  1162 	
       
  1163 #ifdef USE_EAP_EXPANDED_TYPES
       
  1164 
       
  1165 	CEapType* eapType = 0;
       
  1166 	TInt error(KErrNone);
       
  1167 
       
  1168 	// Check if this EAP type has already been loaded
       
  1169 	TInt eapArrayIndex = find<eap_type_value_e>(
       
  1170 		&m_eap_type_array,
       
  1171 		&type,
       
  1172 		m_am_tools);
       
  1173 
       
  1174 	if (eapArrayIndex >= 0)
       
  1175 	{
       
  1176 		// We found the entry in the array.
       
  1177 		EAP_TRACE_DEBUG(
       
  1178 			m_am_tools,
       
  1179 			TRACE_FLAGS_DEFAULT,
       
  1180 			(EAPL("eapol_am_wlan_authentication_symbian_c::load_module(type %d=%s, tunneling_type %d=%s) already loaded.\n"),
       
  1181 			convert_eap_type_to_u32_t(type),
       
  1182 			eap_header_string_c::get_eap_type_string(type),
       
  1183 			convert_eap_type_to_u32_t(tunneling_type),
       
  1184 			eap_header_string_c::get_eap_type_string(tunneling_type)));
       
  1185 
       
  1186 		// Yep. It was loaded already.
       
  1187 		eapType = m_plugin_if_array[eapArrayIndex];		
       
  1188 	}
       
  1189 	else 
       
  1190 	{
       
  1191 		TIndexType index_type(ELan);
       
  1192 		TUint index(0UL);
       
  1193 
       
  1194 		status = read_database_reference_values(
       
  1195 			&index_type,
       
  1196 			&index);
       
  1197 		if (status != eap_status_ok)
       
  1198 		{
       
  1199 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1200 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1201 		}
       
  1202 
       
  1203 		EAP_TRACE_DEBUG(
       
  1204 			m_am_tools,
       
  1205 			TRACE_FLAGS_DEFAULT,
       
  1206 			(EAPL("eapol_am_wlan_authentication_symbian_c::load_module(type %d=%s, tunneling_type %d=%s) load new, index type=%d, index=%d.\n"),
       
  1207 			convert_eap_type_to_u32_t(type),
       
  1208 			eap_header_string_c::get_eap_type_string(type),
       
  1209 			convert_eap_type_to_u32_t(tunneling_type),
       
  1210 			eap_header_string_c::get_eap_type_string(tunneling_type),
       
  1211 			index_type,
       
  1212 			index));
       
  1213 
       
  1214 		TBuf8<KExpandedEAPSize> ExpandedCue;
       
  1215 		
       
  1216 		// Some indirect way of forming the 8 byte string of an EAP type for the cue is needed here.		
       
  1217 		TUint8 tmpExpCue[KExpandedEAPSize];
       
  1218 
       
  1219 		// This is to make the tmpExpCue in 8 byte string with correct vendor type and vendor id details.
       
  1220 		status = eap_expanded_type_c::write_type(m_am_tools,
       
  1221 												0, // index should be zero here.
       
  1222 												tmpExpCue,
       
  1223 												KExpandedEAPSize,
       
  1224 												true,
       
  1225 												type);
       
  1226 		if (status != eap_status_ok)
       
  1227 		{
       
  1228 			EAP_TRACE_DEBUG(
       
  1229 				m_am_tools,
       
  1230 				TRACE_FLAGS_DEFAULT,
       
  1231 				(EAPL("load_module: eap_expanded_type_c::write_type failed \n")));
       
  1232 		
       
  1233 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1234 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1235 		}
       
  1236 		
       
  1237 		// Now copy the 8 byte string to the real expanded cue.
       
  1238 		ExpandedCue.Copy(tmpExpCue, KExpandedEAPSize);
       
  1239 
       
  1240 		EAP_TRACE_DATA_DEBUG(
       
  1241 			m_am_tools,
       
  1242 			TRACE_FLAGS_DEFAULT,
       
  1243 			(EAPL("EAPOL:eapol_am_wlan_authentication_symbian_c::load_module: Expanded CUE:"),
       
  1244 			ExpandedCue.Ptr(),
       
  1245 			ExpandedCue.Size()));
       
  1246 
       
  1247 
       
  1248 		// We must have a trap here since the EAPOL core knows nothing about Symbian.
       
  1249 		TRAP(error, (eapType = CEapType::NewL(
       
  1250 			ExpandedCue,
       
  1251 			index_type,
       
  1252 			index)));	
       
  1253 		if (error != KErrNone
       
  1254 			|| eapType == 0)
       
  1255 		{
       
  1256 			// Interface not found or implementation creation function failed
       
  1257 			EAP_TRACE_DEBUG(
       
  1258 				m_am_tools,
       
  1259 				TRACE_FLAGS_DEFAULT,
       
  1260 				(EAPL("ECom could not find/initiate implementation.\n")));
       
  1261 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1262 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  1263 		}
       
  1264 	}
       
  1265 
       
  1266 #else // For normal EAP types
       
  1267 	
       
  1268 	TBuf8<KMaxEapCueLength> cue;
       
  1269 	cue.Num(static_cast<TInt>(convert_eap_type_to_u32_t(type)));
       
  1270 	CEapType* eapType = 0;
       
  1271 	TInt error(KErrNone);
       
  1272 
       
  1273 	// Check if this EAP type has already been loaded
       
  1274 	TInt eapArrayIndex = m_eap_type_array.Find(type);
       
  1275 	if (eapArrayIndex != KErrNotFound)
       
  1276 	{
       
  1277 		EAP_TRACE_DEBUG(
       
  1278 			m_am_tools,
       
  1279 			TRACE_FLAGS_DEFAULT,
       
  1280 			(EAPL("eapol_am_wlan_authentication_symbian_c::load_module(type %d=%s, tunneling_type %d=%s) already loaded.\n"),
       
  1281 			convert_eap_type_to_u32_t(type),
       
  1282 			eap_header_string_c::get_eap_type_string(type),
       
  1283 			convert_eap_type_to_u32_t(tunneling_type),
       
  1284 			eap_header_string_c::get_eap_type_string(tunneling_type)));
       
  1285 
       
  1286 		// Yep. It was loaded already.
       
  1287 		eapType = m_plugin_if_array[eapArrayIndex];		
       
  1288 	}
       
  1289 	else 
       
  1290 	{
       
  1291 		TIndexType index_type(ELan);
       
  1292 		TUint index(0UL);
       
  1293 
       
  1294 		status = read_database_reference_values(
       
  1295 			&index_type,
       
  1296 			&index);
       
  1297 		if (status != eap_status_ok)
       
  1298 		{
       
  1299 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1300 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1301 		}
       
  1302 
       
  1303 		EAP_TRACE_DEBUG(
       
  1304 			m_am_tools,
       
  1305 			TRACE_FLAGS_DEFAULT,
       
  1306 			(EAPL("eapol_am_wlan_authentication_symbian_c::load_module(type %d=%s, tunneling_type %d=%s) load new, index type=%d, index=%d.\n"),
       
  1307 			convert_eap_type_to_u32_t(type),
       
  1308 			eap_header_string_c::get_eap_type_string(type),
       
  1309 			convert_eap_type_to_u32_t(tunneling_type),
       
  1310 			eap_header_string_c::get_eap_type_string(tunneling_type),
       
  1311 			index_type,
       
  1312 			index));
       
  1313 
       
  1314 		// We must have a trap here since the EAPOL core knows nothing about Symbian.
       
  1315 		TRAP(error, (eapType = CEapType::NewL(
       
  1316 			cue,
       
  1317 			index_type,
       
  1318 			index)));	
       
  1319 		if (error != KErrNone
       
  1320 			|| eapType == 0)
       
  1321 		{
       
  1322 			// Interface not found or implementation creation function failed
       
  1323 			EAP_TRACE_DEBUG(
       
  1324 				m_am_tools,
       
  1325 				TRACE_FLAGS_DEFAULT,
       
  1326 				(EAPL("ECom could not find/initiate implementation.\n")));
       
  1327 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1328 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  1329 		}
       
  1330 	}
       
  1331 
       
  1332 #endif //#ifdef USE_EAP_EXPANDED_TYPES
       
  1333 
       
  1334 	// Set the tunneling type
       
  1335 	eapType->SetTunnelingType(convert_eap_type_to_u32_t(tunneling_type));
       
  1336 
       
  1337 	// Create the EAP protocol interface implementation.
       
  1338 	
       
  1339 #ifdef USE_EAP_SIMPLE_CONFIG
       
  1340 
       
  1341 	TRAP(error, (*eap_type_if = eapType->GetStackInterfaceL(m_am_tools, 
       
  1342 		partner, 
       
  1343 		is_client_when_true, 
       
  1344 		receive_network_id,
       
  1345 		this)));
       
  1346 
       
  1347 #else
       
  1348 
       
  1349 	TRAP(error, (*eap_type_if = eapType->GetStackInterfaceL(m_am_tools, 
       
  1350 		partner, 
       
  1351 		is_client_when_true, 
       
  1352 		receive_network_id)));
       
  1353 
       
  1354 #endif // #ifdef USE_EAP_SIMPLE_CONFIG
       
  1355 	
       
  1356 		
       
  1357 	if (error != KErrNone 
       
  1358 		|| *eap_type_if == 0 
       
  1359 		|| (*eap_type_if)->get_is_valid() == false)
       
  1360 	{
       
  1361 		EAP_TRACE_DEBUG(
       
  1362 			m_am_tools,
       
  1363 			TRACE_FLAGS_DEFAULT,
       
  1364 			(EAPL("Could not create EAP type interface instance. Error: %d\n"), error));
       
  1365 
       
  1366 		status = eap_status_allocation_error;
       
  1367 		// Unload DLL (two ways, depending whether this type was already loaded...)
       
  1368 		if  (eapArrayIndex == KErrNotFound)
       
  1369 		{
       
  1370 			// No need to call shutdown here because GetStackInterfaceL has done it.
       
  1371 			delete eapType;
       
  1372 		}
       
  1373 		else
       
  1374 		{
       
  1375 			unload_module(type);
       
  1376 		}
       
  1377 		// Note: even in error cases eap_core_c deletes eap_type_if
       
  1378 	}
       
  1379 	else
       
  1380 	{
       
  1381 		status = eap_status_ok;
       
  1382 		if (eapArrayIndex  == KErrNotFound)
       
  1383 		{
       
  1384 			// Add plugin information to the member arrays. There is no need to store eap_type pointer because
       
  1385 			// the stack takes care of its deletion.
       
  1386 			if (m_plugin_if_array.Append(eapType) != KErrNone)
       
  1387 			{
       
  1388 				delete eapType;
       
  1389 				status = eap_status_allocation_error;
       
  1390 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1391 				return EAP_STATUS_RETURN(m_am_tools, status);				
       
  1392 			}
       
  1393 			
       
  1394 #ifdef USE_EAP_EXPANDED_TYPES
       
  1395 
       
  1396 			eap_type_value_e * tmpEAPType = new eap_type_value_e();
       
  1397 			if(tmpEAPType == NULL)
       
  1398 			{
       
  1399 				EAP_TRACE_DEBUG(
       
  1400 					m_am_tools,
       
  1401 					TRACE_FLAGS_DEFAULT,
       
  1402 					(EAPL("eapol_am_wlan_authentication_symbian_c::load_module() eap_type_value_e creation failed\n")));
       
  1403 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1404 				return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);				
       
  1405 			}
       
  1406 			
       
  1407 			*tmpEAPType = type;
       
  1408 			
       
  1409 			status = m_eap_type_array.add_object(tmpEAPType, true);
       
  1410 			
       
  1411 			if (status != eap_status_ok)			
       
  1412 
       
  1413 #else // For normal EAP type.			
       
  1414 			
       
  1415 			if (m_eap_type_array.Append(type) != KErrNone)
       
  1416 
       
  1417 #endif // #ifdef USE_EAP_EXPANDED_TYPES			
       
  1418 			{
       
  1419 				// Remove the eap type added just previously
       
  1420 				m_plugin_if_array.Remove(m_plugin_if_array.Count() - 1);
       
  1421 				delete eapType;
       
  1422 				status = eap_status_allocation_error;
       
  1423 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1424 				return EAP_STATUS_RETURN(m_am_tools, status);				
       
  1425 			}
       
  1426 		} 
       
  1427 	}
       
  1428 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1429 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1430 }
       
  1431 
       
  1432 //--------------------------------------------------
       
  1433 
       
  1434 EAP_FUNC_EXPORT eap_status_e eapol_am_wlan_authentication_symbian_c::unload_module(
       
  1435 	const eap_type_value_e type)
       
  1436 {
       
  1437 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1438 
       
  1439 	EAP_TRACE_DEBUG(
       
  1440 		m_am_tools, 
       
  1441 		TRACE_FLAGS_DEFAULT, 
       
  1442 		(EAPL("eapol_am_wlan_authentication_symbian_c::unload_module(): %s, this = 0x%08x => 0x%08x\n"),
       
  1443 		 (m_is_client == true) ? "client": "server",
       
  1444 		 this,
       
  1445 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
       
  1446 
       
  1447 	eap_status_e status(eap_status_type_does_not_exists_error);
       
  1448 
       
  1449 #ifdef USE_EAP_EXPANDED_TYPES
       
  1450 
       
  1451 	// Check if this EAP type has already been loaded
       
  1452 	TInt index = find<eap_type_value_e>(
       
  1453 		&m_eap_type_array,
       
  1454 		&type,
       
  1455 		m_am_tools);
       
  1456 		
       
  1457 	if (index >= 0)
       
  1458 	{
       
  1459 		// EAP was loaded before.
       
  1460 		
       
  1461 		delete m_plugin_if_array[index];
       
  1462 		m_plugin_if_array.Remove(index);
       
  1463 		
       
  1464 		status = m_eap_type_array.remove_object(index);
       
  1465 	}
       
  1466 
       
  1467 #else // For normal EAP types.
       
  1468 
       
  1469 	TInt index = m_eap_type_array.Find(type);
       
  1470 	if (index != KErrNotFound)
       
  1471 	{
       
  1472 		delete m_plugin_if_array[index];
       
  1473 		m_plugin_if_array.Remove(index);
       
  1474 		m_eap_type_array.Remove(index);
       
  1475 		status = eap_status_ok;			
       
  1476 	}
       
  1477 
       
  1478 #endif // #ifdef USE_EAP_EXPANDED_TYPES
       
  1479 
       
  1480 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1481 	return EAP_STATUS_RETURN(m_am_tools, status);
   751 }
  1482 }
   752 
  1483 
   753 //--------------------------------------------------
  1484 //--------------------------------------------------
   754 
  1485 
   755 EAP_FUNC_EXPORT eap_status_e eapol_am_wlan_authentication_symbian_c::read_configure(
  1486 EAP_FUNC_EXPORT eap_status_e eapol_am_wlan_authentication_symbian_c::read_configure(
   764 		TRACE_FLAGS_DEFAULT, 
  1495 		TRACE_FLAGS_DEFAULT, 
   765 		(EAPL("eapol_am_wlan_authentication_symbian_c::read_configure(): %s, this = 0x%08x => 0x%08x\n"),
  1496 		(EAPL("eapol_am_wlan_authentication_symbian_c::read_configure(): %s, this = 0x%08x => 0x%08x\n"),
   766 		 (m_is_client == true) ? "client": "server",
  1497 		 (m_is_client == true) ? "client": "server",
   767 		 this,
  1498 		 this,
   768 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
  1499 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
   769 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, TRACE_FLAGS_DEFAULT, "returns: eapol_am_wlan_authentication_symbian_c::read_configure()");
  1500 	
   770 
       
   771 	// Trap must be set here because the OS independent portion of EAPOL
  1501 	// Trap must be set here because the OS independent portion of EAPOL
   772 	// that calls this function does not know anything about Symbian.	
  1502 	// that calls this function does not know anything about Symbian.	
   773 	eap_status_e status(eap_status_ok);
  1503 	eap_status_e status(eap_status_ok);
   774 
  1504 
   775 	// Check if the wanted parameter is default type
  1505 	// Check if the wanted parameter is default type
   783 		false,
  1513 		false,
   784 		false);
  1514 		false);
   785 	if (status != eap_status_ok)
  1515 	if (status != eap_status_ok)
   786 	{
  1516 	{
   787 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1517 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   788 		return EAP_STATUS_RETURN(m_am_tools, status);
  1518 		return status;
   789 	}
  1519 	}
   790 	
  1520 	
   791 	status = type_field.set_buffer(
  1521 	status = type_field.set_buffer(
   792 		cf_str_EAP_default_type_hex_data.get_field()->get_field(),
  1522 		cf_str_EAP_default_type_hex_data.get_field()->get_field(),
   793 		cf_str_EAP_default_type_hex_data.get_field()->get_field_length(),
  1523 		cf_str_EAP_default_type_hex_data.get_field()->get_field_length(),
   794 		false,
  1524 		false,
   795 		false);
  1525 		false);
   796 	if (status != eap_status_ok)
  1526 	if (status != eap_status_ok)
   797 	{
  1527 	{
   798 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1528 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   799 		return EAP_STATUS_RETURN(m_am_tools, status);
  1529 		return status;
   800 	}
  1530 	}
       
  1531 
       
  1532 	eap_type_value_e aSelectedEapType;
       
  1533 	
       
  1534 #ifdef USE_EAP_EXPANDED_TYPES
       
  1535 
       
  1536 	if (!wanted_field.compare(&type_field))
       
  1537 	{
       
  1538 		TInt ind; 
       
  1539 
       
  1540 		// First check do we have read configuration from databases.
       
  1541 		if (m_enabled_expanded_eap_array.Count() == 0)
       
  1542 		{
       
  1543 			EAP_TRACE_ERROR(
       
  1544 				m_am_tools,
       
  1545 				TRACE_FLAGS_DEFAULT,
       
  1546 				(EAPL("EAP settings not read from CommsDat\n")));
       
  1547 
       
  1548 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
  1549 			return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error);
       
  1550 		}
       
  1551 
       
  1552 		// Now we need to return here the next EAP type we should try		
       
  1553 		for (ind = m_am_partner->get_current_eap_index(); ind < m_enabled_expanded_eap_array.Count(); ind++)
       
  1554 		{
       
  1555 			// Find the highest priority EAP with index "ind".
       
  1556 			
       
  1557 			TBuf8<KExpandedEAPSize> tmpExpEAP(m_enabled_expanded_eap_array[ind]->EapExpandedType);
       
  1558 			
       
  1559 			status = data->set_copy_of_buffer(tmpExpEAP.Ptr(), tmpExpEAP.Size());			
       
  1560 			if (status != eap_status_ok)
       
  1561 			{
       
  1562 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1563 				return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);			
       
  1564 			}
       
  1565 
       
  1566 			EAP_TRACE_DATA_DEBUG(
       
  1567 				m_am_tools,
       
  1568 				TRACE_FLAGS_DEFAULT,
       
  1569 				(EAPL("EAPOL:eapol_am_wlan_authentication_symbian_c::read_configure: Trying EAP type:"),
       
  1570 				tmpExpEAP.Ptr(),
       
  1571 				tmpExpEAP.Size()));
       
  1572 			status = eap_expanded_type_c::read_type(m_am_tools,
       
  1573 					0,
       
  1574 					tmpExpEAP.Ptr(),
       
  1575 					tmpExpEAP.Size(),
       
  1576 					&aSelectedEapType);
       
  1577 			if (status == eap_status_ok)
       
  1578 			{
       
  1579 				break;
       
  1580 			}
       
  1581 		}
       
  1582 
       
  1583 		// Set the index of new EAP type we are trying now.
       
  1584 		m_am_partner->set_current_eap_index(ind);
       
  1585 		
       
  1586 		if (ind >= m_enabled_expanded_eap_array.Count())
       
  1587 		{
       
  1588 			// Not found any other EAP type as enabled.
       
  1589 			// Send WLM notification because there is no way that the authentication
       
  1590 			// can be successful if we don't have any EAP types to use...
       
  1591 			if (m_is_client)
       
  1592 			{
       
  1593 				EAP_TRACE_ERROR(
       
  1594 					m_am_tools,
       
  1595 					TRACE_FLAGS_DEFAULT,
       
  1596 					(EAPL("ERROR: read_configure: No configured EAP types or all tried unsuccessfully.\n")));
       
  1597 			}
       
  1598 
       
  1599 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1600 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_configure_field);
       
  1601 		}
       
  1602 	
       
  1603 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1604 		return EAP_STATUS_RETURN(m_am_tools, status);		
       
  1605 	}
       
  1606 
       
  1607 #else // For normal non-expanded EAP
       
  1608 
       
  1609 	if (!wanted_field.compare(&type_field))
       
  1610 	{
       
  1611 		TInt ind; 
       
  1612 
       
  1613 		// First check do we have read configuration from databases.
       
  1614 		if (m_iap_eap_array.Count() == 0)
       
  1615 		{
       
  1616 			EAP_TRACE_ERROR(
       
  1617 				m_am_tools,
       
  1618 				TRACE_FLAGS_DEFAULT,
       
  1619 				(EAPL("EAP settings not read from CommDb\n")));
       
  1620 
       
  1621 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
  1622 			return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error);
       
  1623 		}
       
  1624 
       
  1625 		// We need to return here the next EAP type we should try		
       
  1626 		for (ind = m_am_partner->get_current_eap_index(); ind < m_iap_eap_array.Count(); ind++)
       
  1627 		{
       
  1628 			// Find the first enabled EAP type (highest priority)
       
  1629 			TEap *eapType = m_iap_eap_array[ind];			
       
  1630 			if (eapType->Enabled == 1)
       
  1631 			{
       
  1632 				// Convert the string to integer
       
  1633 				TLex8 tmp(eapType->UID);
       
  1634 				TInt val(0);
       
  1635 				tmp.Val(val);
       
  1636 				status = data->set_copy_of_buffer(reinterpret_cast<u8_t *>(&val), sizeof(TUint));
       
  1637 				if (status != eap_status_ok)
       
  1638 				{
       
  1639 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1640 					return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);			
       
  1641 				}
       
  1642 
       
  1643 				EAP_TRACE_DEBUG(
       
  1644 					m_am_tools,
       
  1645 					TRACE_FLAGS_DEFAULT,
       
  1646 					(EAPL("EAPOL: Trying EAP type: %d.\n"), val));
       
  1647 				aSelectedEapType = val;
       
  1648 				break;
       
  1649 			}
       
  1650 		}
       
  1651 
       
  1652 		m_am_partner->set_current_eap_index(ind);
       
  1653 		if (ind >= m_iap_eap_array.Count())
       
  1654 		{
       
  1655 			// Not found
       
  1656 			// Send WLM notification because there is no way that the authentication
       
  1657 			// can be successful if we don't have any EAP types to use...
       
  1658 			if (m_is_client)
       
  1659 			{
       
  1660 				EAP_TRACE_ERROR(
       
  1661 					m_am_tools,
       
  1662 					TRACE_FLAGS_DEFAULT,
       
  1663 					(EAPL("ERROR: No configured EAP types or all tried unsuccessfully.\n")));
       
  1664 			}
       
  1665 
       
  1666 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1667 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_configure_field);
       
  1668 		}
       
  1669 	
       
  1670 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1671 		return EAP_STATUS_RETURN(m_am_tools, status);		
       
  1672 	}
       
  1673 
       
  1674 #endif //#ifdef USE_EAP_EXPANDED_TYPES
   801 
  1675 
   802 	// It was something else than EAP type. Read it from eapol DB.
  1676 	// It was something else than EAP type. Read it from eapol DB.
   803 	_LIT( KEapolTableName, "eapol" );
  1677 	_LIT( KEapolTableName, "eapol" );
   804 
  1678 	TRAPD( err, read_configureL(
   805 	TFileName aPrivateDatabasePathName;
  1679 		KDatabaseName,
   806 
       
   807 	TRAPD(err, EapPluginTools::GetPrivatePathL(
       
   808 		m_session,
       
   809 		aPrivateDatabasePathName));
       
   810 		
       
   811 	if (err)
       
   812 		{
       
   813 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   814 		return EAP_STATUS_RETURN(m_am_tools, m_am_tools->convert_am_error_to_eapol_error(err));
       
   815 		}
       
   816 
       
   817 	aPrivateDatabasePathName.Append(KEapolDatabaseName);
       
   818 
       
   819 	EAP_TRACE_DATA_DEBUG_SYMBIAN(("aPrivateDatabasePathName",
       
   820 		aPrivateDatabasePathName.Ptr(),
       
   821 		aPrivateDatabasePathName.Size()));
       
   822 
       
   823 	TRAPD( error, read_configureL(
       
   824 		aPrivateDatabasePathName,
       
   825 		KEapolTableName,
  1680 		KEapolTableName,
   826 		field->get_field(),
  1681 		field->get_field(),
   827 		field->get_field_length(),
  1682 		field->get_field_length(),
   828 		data) );
  1683 		data) );
   829 
       
   830 	// Try to read it for eap fast DB	
  1684 	// Try to read it for eap fast DB	
   831 	HBufC8* fieldBuf = HBufC8::New( field->get_field_length() );
  1685 	HBufC8* fieldBuf = HBufC8::NewLC( field->get_field_length() );
   832 
       
   833 	eap_automatic_variable_c<HBufC8> automatic_fieldBuf(
       
   834 		m_am_tools,
       
   835 		fieldBuf);
       
   836 
       
   837 	if (fieldBuf == 0)
       
   838 	{
       
   839 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   840 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   841 	}
       
   842 	TPtr8 fieldPtr = fieldBuf->Des();
  1686 	TPtr8 fieldPtr = fieldBuf->Des();
   843 	fieldPtr.Copy( reinterpret_cast<const TUint8 *> ( field->get_field() ));
  1687 	fieldPtr.Copy( reinterpret_cast<const TUint8 *> ( field->get_field() ));
   844 
  1688 
   845 	if (error != KErrNone) 
  1689 	_LIT8(cf_str_EAP_TLS_PEAP_use_identity_privacy_literal, "EAP_TLS_PEAP_use_identity_privacy");
   846 	{
  1690 	
   847 		status = m_am_tools->convert_am_error_to_eapol_error(error);
  1691 	if ( err != KErrNone &&
       
  1692 		 fieldPtr.Compare( cf_str_EAP_TLS_PEAP_use_identity_privacy_literal() ) == 0 ) 
       
  1693 		{
       
  1694 		if (aSelectedEapType == eap_type_tls)
       
  1695 			{
       
  1696 			_LIT(KGeneralSettingsDBTableName, "KTlsDatabaseTableName");
       
  1697 			TRAP( err, read_configureL(
       
  1698 					KDatabaseName,
       
  1699 					KGeneralSettingsDBTableName,
       
  1700 					field->get_field(),
       
  1701 					field->get_field_length(),
       
  1702 					data) );		
       
  1703 
       
  1704 			}
       
  1705 		if (aSelectedEapType == eap_type_peap)
       
  1706 			{
       
  1707 			_LIT(KGeneralSettingsDBTableName, "KPeapDatabaseTableName"); 
       
  1708 			TRAP( err, read_configureL(
       
  1709 					KDatabaseName,
       
  1710 					KGeneralSettingsDBTableName,
       
  1711 					field->get_field(),
       
  1712 					field->get_field_length(),
       
  1713 					data) );		
       
  1714 			}
       
  1715 		if (aSelectedEapType == eap_type_ttls)
       
  1716 			{
       
  1717 			_LIT(KGeneralSettingsDBTableName, "KTtlsDatabaseTableName"); 
       
  1718 			TRAP( err, read_configureL(
       
  1719 					KDatabaseName,
       
  1720 					KGeneralSettingsDBTableName,
       
  1721 					field->get_field(),
       
  1722 					field->get_field_length(),
       
  1723 					data) );		
       
  1724 			}
       
  1725 #if defined (USE_FAST_EAP_TYPE)
       
  1726 		if ( aSelectedEapType == eap_type_fast)
       
  1727 			{
       
  1728 			_LIT(KFastGeneralSettingsDBTableName, "eapfast_general_settings"); 
       
  1729 			TRAP( err, read_configureL(
       
  1730 			KFastDatabaseName,
       
  1731 			KFastGeneralSettingsDBTableName,
       
  1732 			field->get_field(),
       
  1733 			field->get_field_length(),
       
  1734 			data) );		
       
  1735 			}
       
  1736 #endif
       
  1737 		}
       
  1738 	CleanupStack::PopAndDestroy( fieldBuf );
       
  1739 
       
  1740 	if (err != KErrNone) 
       
  1741 	{
       
  1742 		status = m_am_tools->convert_am_error_to_eapol_error(err);
   848 
  1743 
   849 #if defined(USE_EAP_FILECONFIG)
  1744 #if defined(USE_EAP_FILECONFIG)
   850 		if (m_fileconfig != 0
  1745 		if (m_fileconfig != 0
   851 			&& m_fileconfig->get_is_valid() == true)
  1746 			&& m_fileconfig->get_is_valid() == true)
   852 		{
  1747 		{
   855 				field,
  1750 				field,
   856 				data);
  1751 				data);
   857 		}
  1752 		}
   858 #endif //#if defined(USE_EAP_FILECONFIG)
  1753 #endif //#if defined(USE_EAP_FILECONFIG)
   859 	}
  1754 	}
   860 
       
   861 	m_am_tools->trace_configuration(
  1755 	m_am_tools->trace_configuration(
   862 		status,
  1756 		status,
   863 		field,
  1757 		field,
   864 		data);
  1758 		data);
   865 
  1759 
   875 	eap_config_string field,
  1769 	eap_config_string field,
   876 	const u32_t /*field_length*/,
  1770 	const u32_t /*field_length*/,
   877 	eap_variable_data_c * const data)
  1771 	eap_variable_data_c * const data)
   878 {	
  1772 {	
   879 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  1773 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   880 	EAP_TRACE_DEBUG(
  1774 	
   881 		m_am_tools, 
       
   882 		TRACE_FLAGS_DEFAULT, 
       
   883 		(EAPL("eapol_am_wlan_authentication_symbian_c::read_configureL(): %s, this = 0x%08x => 0x%08x\n"),
       
   884 		 (m_is_client == true) ? "client": "server",
       
   885 		 this,
       
   886 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
       
   887 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, TRACE_FLAGS_DEFAULT, "returns: eapol_am_wlan_authentication_symbian_c::read_configureL()");
       
   888 
       
   889 	// Open database
  1775 	// Open database
   890 	RDbNamedDatabase db;
  1776 	RDbNamedDatabase db;
   891 
  1777 
   892 	TInt error = db.Open(m_session, aDbName);
  1778 #ifdef SYMBIAN_SECURE_DBMS
   893 
  1779 	User::LeaveIfError(db.Open(m_session, aDbName, KSecureUIDFormat));	
   894 	EAP_TRACE_DEBUG(
  1780 #else			
   895 		m_am_tools, 
  1781 	User::LeaveIfError(db.Open(m_session, aDbName));
   896 		TRACE_FLAGS_DEFAULT, 
  1782 #endif // #ifdef SYMBIAN_SECURE_DBMS		
   897 		(EAPL("eapol_am_wlan_authentication_symbian_c::read_configureL(): db.Open(), error = %d\n"),
       
   898 		 error));
       
   899 
       
   900 	User::LeaveIfError(error);
       
   901 	
  1783 	
   902 	CleanupClosePushL(db);
  1784 	CleanupClosePushL(db);
   903 
  1785 
   904 
  1786 
   905 	// Create a buffer for the ascii strings - initialised with the argument
  1787 	// Create a buffer for the ascii strings - initialised with the argument
   938 				if (asciiString.Size() > 0)
  1820 				if (asciiString.Size() > 0)
   939 				{
  1821 				{
   940 					status = data->set_copy_of_buffer(asciiString.Ptr(), asciiString.Size());
  1822 					status = data->set_copy_of_buffer(asciiString.Ptr(), asciiString.Size());
   941 					if (status != eap_status_ok)
  1823 					if (status != eap_status_ok)
   942 					{
  1824 					{
   943 						User::Leave(m_am_tools->convert_eapol_error_to_am_error(
  1825 						User::Leave(KErrNoMemory);
   944 							EAP_STATUS_RETURN(m_am_tools, status)));
       
   945 					}
  1826 					}
   946 				} 
  1827 				} 
   947 				else 
  1828 				else 
   948 				{
  1829 				{
   949 					// Empty field. Do nothing...data remains invalid and the stack knows what to do hopefully.
  1830 					// Empty field. Do nothing...data remains invalid and the stack knows what to do hopefully.
   956 				TUint value;
  1837 				TUint value;
   957 				value = view.ColUint32(1);
  1838 				value = view.ColUint32(1);
   958 				status = data->set_copy_of_buffer((const unsigned char *) &value, sizeof(value));
  1839 				status = data->set_copy_of_buffer((const unsigned char *) &value, sizeof(value));
   959 				if (status != eap_status_ok)
  1840 				if (status != eap_status_ok)
   960 				{
  1841 				{
   961 					User::Leave(m_am_tools->convert_eapol_error_to_am_error(
  1842 					User::Leave(KErrNoMemory);
   962 						EAP_STATUS_RETURN(m_am_tools, status)));
       
   963 				}
  1843 				}
   964 			}
  1844 			}
   965 			break;
  1845 			break;
   966 		default:
  1846 		default:
   967 			EAP_TRACE_DEBUG(
  1847 			EAP_TRACE_DEBUG(
   968 				m_am_tools,
  1848 				m_am_tools,
   969 				TRACE_FLAGS_DEFAULT,
  1849 				TRACE_FLAGS_DEFAULT,
   970 				(EAPL("ERROR: read_configureL: Unexpected column type.\n")));
  1850 				(EAPL("read_configureL: Unexpected column type.\n")));
   971 			User::Panic(_L("EAPOL"), 1);			
  1851 			User::Panic(_L("EAPOL"), 1);			
   972 		}
  1852 		}
   973 	} 
  1853 	} 
   974 	else 
  1854 	else 
   975 	{
  1855 	{
   976 		// Could not find parameter
  1856 		// Could not find parameter
   977 		EAP_TRACE_DEBUG(
  1857 		EAP_TRACE_DEBUG(
   978 			m_am_tools,
  1858 			m_am_tools,
   979 			TRACE_FLAGS_DEFAULT,
  1859 			TRACE_FLAGS_DEFAULT,
   980 			(EAPL("ERROR: read_configureL: Could not find configuration parameter.\n")));
  1860 			(EAPL("read_configureL: Could not find configuration parameter.\n")));
   981 		User::Leave(m_am_tools->convert_eapol_error_to_am_error(
  1861 		User::Leave(KErrNotFound);
   982 							EAP_STATUS_RETURN(m_am_tools, eap_status_not_found)));
       
   983 	}		
  1862 	}		
   984 	
  1863 	
   985 	// Close database
  1864 	// Close database
   986 	CleanupStack::PopAndDestroy(&view);
  1865 	CleanupStack::PopAndDestroy(5); // view, 3 buffers and database
   987 	CleanupStack::PopAndDestroy(buf);
       
   988 	CleanupStack::PopAndDestroy(unicodebuf);
       
   989 	CleanupStack::PopAndDestroy(asciibuf);
       
   990 	CleanupStack::PopAndDestroy(&db);
       
   991 
  1866 
   992 
  1867 
   993 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1868 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   994 }
  1869 }
   995 
  1870 
  1015 	void * const p_data,
  1890 	void * const p_data,
  1016 	const u32_t p_time_ms)
  1891 	const u32_t p_time_ms)
  1017 {
  1892 {
  1018 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  1893 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  1019 
  1894 
  1020 	EAP_TRACE_DEBUG(
       
  1021 		m_am_tools, 
       
  1022 		TRACE_FLAGS_DEFAULT, 
       
  1023 		(EAPL("eapol_am_wlan_authentication_symbian_c::set_timer(): this = 0x%08x\n"),
       
  1024 		this));
       
  1025 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eapol_am_wlan_authentication_symbian_c::set_timer()");
       
  1026 
       
  1027 	const eap_status_e status = m_am_tools->am_set_timer(
  1895 	const eap_status_e status = m_am_tools->am_set_timer(
  1028 		p_initializer, 
  1896 		p_initializer, 
  1029 		p_id, 
  1897 		p_id, 
  1030 		p_data,
  1898 		p_data,
  1031 		p_time_ms);
  1899 		p_time_ms);
  1040 	abs_eap_base_timer_c * const p_initializer, 
  1908 	abs_eap_base_timer_c * const p_initializer, 
  1041 	const u32_t p_id)
  1909 	const u32_t p_id)
  1042 {
  1910 {
  1043 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  1911 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  1044 
  1912 
  1045 	EAP_TRACE_DEBUG(
       
  1046 		m_am_tools, 
       
  1047 		TRACE_FLAGS_DEFAULT, 
       
  1048 		(EAPL("eapol_am_wlan_authentication_symbian_c::cancel_timer(): this = 0x%08x\n"),
       
  1049 		this));
       
  1050 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eapol_am_wlan_authentication_symbian_c::cancel_timer()");
       
  1051 
       
  1052 	const eap_status_e status = m_am_tools->am_cancel_timer(
  1913 	const eap_status_e status = m_am_tools->am_cancel_timer(
  1053 		p_initializer, 
  1914 		p_initializer, 
  1054 		p_id);
  1915 		p_id);
  1055 
  1916 
  1056 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1917 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1061 
  1922 
  1062 EAP_FUNC_EXPORT eap_status_e eapol_am_wlan_authentication_symbian_c::cancel_all_timers()
  1923 EAP_FUNC_EXPORT eap_status_e eapol_am_wlan_authentication_symbian_c::cancel_all_timers()
  1063 {
  1924 {
  1064 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  1925 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  1065 
  1926 
       
  1927 	const eap_status_e status = m_am_tools->am_cancel_all_timers();
       
  1928 
       
  1929 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1930 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1931 }
       
  1932 
       
  1933 //--------------------------------------------------
       
  1934 
       
  1935 EAP_FUNC_EXPORT eap_status_e eapol_am_wlan_authentication_symbian_c::check_is_valid_eap_type(const eap_type_value_e eap_type)
       
  1936 {
       
  1937 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1938 
       
  1939 	eap_header_string_c eap_string;
       
  1940 	EAP_UNREFERENCED_PARAMETER(eap_string);
       
  1941 
       
  1942 	EAP_TRACE_DEBUG(
       
  1943 		m_am_tools,
       
  1944 		TRACE_FLAGS_DEFAULT,
       
  1945 		(EAPL("eapol_am_wlan_authentication_symbian_c::check_is_valid_eap_type():  %s, this = 0x%08x => 0x%08x, EAP-type=0x%08x=%s\n"),
       
  1946 		 (m_is_client == true) ? "client": "server",
       
  1947 		 this,
       
  1948 		 dynamic_cast<abs_eap_base_timer_c *>(this),
       
  1949 		convert_eap_type_to_u32_t(eap_type),
       
  1950 		eap_string.get_eap_type_string(eap_type)));
       
  1951 
       
  1952 #ifdef USE_EAP_EXPANDED_TYPES
       
  1953 
       
  1954 	for (int i = 0; i < m_enabled_expanded_eap_array.Count(); i++)
       
  1955 	{
       
  1956 		TBuf8<KExpandedEAPSize> tmpExpEAP(m_enabled_expanded_eap_array[i]->EapExpandedType);
       
  1957 
       
  1958 		EAP_TRACE_DEBUG(
       
  1959 			m_am_tools, 
       
  1960 			TRACE_FLAGS_DEFAULT, 
       
  1961 			(EAPL("eapol_am_wlan_authentication_symbian_c::check_is_valid_eap_type:Enabled expanded EAP type at index=%d\n"),
       
  1962 			 i));
       
  1963 
       
  1964 		EAP_TRACE_DATA_DEBUG(
       
  1965 			m_am_tools,
       
  1966 			TRACE_FLAGS_DEFAULT,
       
  1967 			(EAPL("Enabled expanded EAP type:"),
       
  1968 			tmpExpEAP.Ptr(),
       
  1969 			tmpExpEAP.Size()));
       
  1970 
       
  1971 		// This is for one expanded EAP type (for the above one).
       
  1972 		eap_expanded_type_c expandedEAPType;
       
  1973 				
       
  1974 		// Read the expanded EAP type details for this item in m_enabled_expanded_eap_array.
       
  1975 		eap_status_e status = eap_expanded_type_c::read_type(m_am_tools,
       
  1976 												0,
       
  1977 												tmpExpEAP.Ptr(),
       
  1978 												tmpExpEAP.Size(),
       
  1979 												&expandedEAPType);
       
  1980 		if (status != eap_status_ok)
       
  1981 		{
       
  1982 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1983 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1984 		}
       
  1985 
       
  1986 		if (eap_type == expandedEAPType)
       
  1987 		{
       
  1988 			// This is Allowed and Valid.
       
  1989 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1990 			return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
  1991 		}
       
  1992 	}
       
  1993 		 
       
  1994 #else // For normal unexpanded EAP type
       
  1995 
       
  1996 	TEap *eapType = 0; 
       
  1997 	
       
  1998 	for (int i = 0; i < m_iap_eap_array.Count(); i++)
       
  1999 	{
       
  2000 		// Try next EAP type
       
  2001 		eapType = m_iap_eap_array[i];
       
  2002 		if (eapType->Enabled == 1)
       
  2003 		{	
       
  2004 			// Convert the string to integer
       
  2005 			TLex8 tmp(eapType->UID);
       
  2006 			TInt val(0);
       
  2007 			tmp.Val(val);
       
  2008 
       
  2009 			if (eap_type == static_cast<eap_type_ietf_values_e>(val))
       
  2010 			{
       
  2011 				// Allowed
       
  2012 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2013 				return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
  2014 			}
       
  2015 		}
       
  2016 	}
       
  2017 	
       
  2018 #endif // #ifdef USE_EAP_EXPANDED_TYPES
       
  2019 	
       
  2020 	EAP_TRACE_DEBUG(
       
  2021 		m_am_tools,
       
  2022 		TRACE_FLAGS_DEFAULT,
       
  2023 		(EAPL("ERROR: %s: check_is_valid_eap_type(): not supported EAP-type=0x%08x=%s\n"),
       
  2024 		 (m_is_client == true ? "client": "server"),
       
  2025 		 convert_eap_type_to_u32_t(eap_type),
       
  2026 		 eap_string.get_eap_type_string(eap_type)));
       
  2027 
       
  2028 	
       
  2029 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2030 	return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_eap_type);
       
  2031 }
       
  2032 
       
  2033 //--------------------------------------------------
       
  2034 
       
  2035 EAP_FUNC_EXPORT eap_status_e eapol_am_wlan_authentication_symbian_c::get_eap_type_list(
       
  2036 	eap_array_c<eap_type_value_e> * const eap_type_list)
       
  2037 {
       
  2038 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2039 
  1066 	EAP_TRACE_DEBUG(
  2040 	EAP_TRACE_DEBUG(
  1067 		m_am_tools, 
  2041 		m_am_tools, 
  1068 		TRACE_FLAGS_DEFAULT, 
  2042 		TRACE_FLAGS_DEFAULT, 
  1069 		(EAPL("eapol_am_wlan_authentication_symbian_c::cancel_all_timers(): this = 0x%08x\n"),
  2043 		(EAPL("eapol_am_wlan_authentication_symbian_c::get_eap_type_list(): %s, this = 0x%08x => 0x%08x\n"),
  1070 		this));
  2044 		 (m_is_client == true) ? "client": "server",
  1071 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eapol_am_wlan_authentication_symbian_c::cancel_all_timers()");
  2045 		 this,
  1072 
  2046 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
  1073 	const eap_status_e status = m_am_tools->am_cancel_all_timers();
  2047 
       
  2048 
       
  2049 	eap_status_e status(eap_status_illegal_eap_type);
       
  2050 
       
  2051 	status = eap_type_list->reset();
       
  2052 	if (status != eap_status_ok)
       
  2053 	{
       
  2054 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2055 		return EAP_STATUS_RETURN(m_am_tools, status);
       
  2056 	}
       
  2057 
       
  2058 	eap_header_string_c eap_string;
       
  2059 	EAP_UNREFERENCED_PARAMETER(eap_string);
       
  2060 
       
  2061 #ifdef USE_EAP_EXPANDED_TYPES
       
  2062 
       
  2063 	// This function is same as get_selected_eap_types in behavior.
       
  2064 
       
  2065 	// We need to return only the EAP types available as enabled types.
       
  2066 	// It means only the ones available in m_enabled_expanded_eap_array.
       
  2067 	
       
  2068 	for (TInt i = 0; i < m_enabled_expanded_eap_array.Count(); i++)
       
  2069 	{	
       
  2070 		TBuf8<KExpandedEAPSize> tmpExpEAP(m_enabled_expanded_eap_array[i]->EapExpandedType);
       
  2071 
       
  2072 		EAP_TRACE_DEBUG(
       
  2073 			m_am_tools, 
       
  2074 			TRACE_FLAGS_DEFAULT, 
       
  2075 			(EAPL("eapol_am_wlan_authentication_symbian_c::get_eap_type_list:Enabled expanded EAP type at index=%d\n"),
       
  2076 			 i));
       
  2077 
       
  2078 		EAP_TRACE_DATA_DEBUG(
       
  2079 			m_am_tools,
       
  2080 			TRACE_FLAGS_DEFAULT,
       
  2081 			(EAPL("Enabled expanded EAP type:"),
       
  2082 			tmpExpEAP.Ptr(),
       
  2083 			tmpExpEAP.Size()));
       
  2084 
       
  2085 		// This is for one expanded EAP type (for the above one).
       
  2086 		eap_expanded_type_c * expandedEAPType = new eap_type_value_e();
       
  2087 				
       
  2088 		// Read the expanded EAP type details from an item in m_enabled_expanded_eap_array.
       
  2089 		status = eap_expanded_type_c::read_type(m_am_tools,
       
  2090 												0,
       
  2091 												tmpExpEAP.Ptr(),
       
  2092 												tmpExpEAP.Size(),
       
  2093 												expandedEAPType);
       
  2094 		if (status != eap_status_ok)
       
  2095 		{
       
  2096 			delete expandedEAPType;
       
  2097 			expandedEAPType = 0;
       
  2098 
       
  2099 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2100 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  2101 		}
       
  2102 
       
  2103 		// Add EAP-type to list.		
       
  2104 		status = eap_type_list->add_object(expandedEAPType, true);
       
  2105 		if (status != eap_status_ok)
       
  2106 		{
       
  2107 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2108 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  2109 		}		
       
  2110 			
       
  2111 		EAP_TRACE_DEBUG(
       
  2112 			m_am_tools,
       
  2113 			TRACE_FLAGS_DEFAULT,
       
  2114 			(EAPL("get_eap_type_list():added EAP-type=0x%08x=%s\n"),
       
  2115 			expandedEAPType->get_vendor_type(),
       
  2116 			eap_string.get_eap_type_string(*expandedEAPType)));			
       
  2117 	}
       
  2118 
       
  2119 #else // for normal EAP types.
       
  2120 
       
  2121 	TEap *eapType = 0; 
       
  2122 
       
  2123 	for (TInt i = 0; i < m_iap_eap_array.Count(); i++)
       
  2124 	{
       
  2125 		// Check if type is enabled
       
  2126 		eapType = m_iap_eap_array[i];
       
  2127 		if (eapType->Enabled == 1)
       
  2128 		{	
       
  2129 			TLex8 tmp(eapType->UID);
       
  2130 			TInt val(0);
       
  2131 			tmp.Val(val);
       
  2132 
       
  2133 			EAP_TRACE_DEBUG(
       
  2134 				m_am_tools,
       
  2135 				TRACE_FLAGS_DEFAULT,
       
  2136 				(EAPL("get_eap_type_list(): adds EAP-type=0x%08x=%s\n"),
       
  2137 				static_cast<eap_type_ietf_values_e>(val),
       
  2138 				eap_string.get_eap_type_string(
       
  2139 					static_cast<eap_type_value_e>(
       
  2140 						static_cast<eap_type_ietf_values_e>(val)))));
       
  2141 
       
  2142 			eap_type_value_e * const eap_type = new eap_type_value_e(
       
  2143 				static_cast<eap_type_ietf_values_e>(val));
       
  2144 			if (eap_type == 0)
       
  2145 			{
       
  2146 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2147 				return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  2148 			}
       
  2149 
       
  2150 			status = eap_type_list->add_object(eap_type, true);
       
  2151 			if (status != eap_status_ok)
       
  2152 			{
       
  2153 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2154 				return EAP_STATUS_RETURN(m_am_tools, status);
       
  2155 			}
       
  2156 		}
       
  2157 	}
       
  2158 
       
  2159 #endif // #ifdef USE_EAP_EXPANDED_TYPES
  1074 
  2160 
  1075 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2161 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1076 	return EAP_STATUS_RETURN(m_am_tools, status);
  2162 	return EAP_STATUS_RETURN(m_am_tools, status);
  1077 }
  2163 }
  1078 
  2164 
  1079 //--------------------------------------------------
  2165 //--------------------------------------------------
  1080 
  2166 
       
  2167 //
       
  2168 void eapol_am_wlan_authentication_symbian_c::RunL()
       
  2169 {
       
  2170 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
  2171 	EAP_TRACE_DEBUG(
       
  2172 		m_am_tools,
       
  2173 		TRACE_FLAGS_DEFAULT,
       
  2174 		(EAPL("eapol_am_wlan_authentication_symbian_c::RunL(): iStatus.Int() = %d\n"),
       
  2175 		iStatus.Int()));
       
  2176 
       
  2177 	if (iStatus.Int() != KErrNone)
       
  2178 	{
       
  2179 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2180 		return;
       
  2181 	}
       
  2182 
       
  2183 	// Authentication cancelled.
       
  2184 	EAP_TRACE_ALWAYS(
       
  2185 		m_am_tools,
       
  2186 		TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
       
  2187 		(EAPL("Authentication cancelled.\n")));
       
  2188 
       
  2189 	eap_status_e status = m_am_partner->disassociation(
       
  2190 		&m_receive_network_id);
       
  2191 	if (status != eap_status_ok)
       
  2192 	{
       
  2193 		EAP_TRACE_DEBUG(
       
  2194 			m_am_tools,
       
  2195 			TRACE_FLAGS_DEFAULT,
       
  2196 			(EAPL("set_timer(EAPOL_AM_CORE_TIMER_DELETE_STACK_ID) failed in RunL().\n")));
       
  2197 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2198 		return;
       
  2199 	}
       
  2200 	
       
  2201 	// Reset index of current EAP-type.
       
  2202 	m_am_partner->set_current_eap_index(0ul);
       
  2203 
       
  2204 	EAP_TRACE_ALWAYS(
       
  2205 		m_am_tools,
       
  2206 		TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
       
  2207 		(EAPL("Indication sent to WLM: EFailedCompletely.\n")));
       
  2208 
       
  2209 	m_am_partner->eapol_indication(
       
  2210 		&m_receive_network_id,
       
  2211 		eapol_wlan_authentication_state_failed_completely);
       
  2212 
       
  2213 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
  2214 }
       
  2215 
       
  2216 //--------------------------------------------------
       
  2217 
       
  2218 //
       
  2219 void eapol_am_wlan_authentication_symbian_c::DoCancel()
       
  2220 {	
       
  2221 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2222 
       
  2223 	EAP_TRACE_DEBUG(
       
  2224 		m_am_tools,
       
  2225 		TRACE_FLAGS_DEFAULT,
       
  2226 		(EAPL("eapol_am_wlan_authentication_symbian_c::DoCancel()\n")));
       
  2227 
       
  2228 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
  2229 }
       
  2230 
       
  2231 //--------------------------------------------------
       
  2232 
  1081 void eapol_am_wlan_authentication_symbian_c::RetrievePSKL(TPSKEntry& entry)
  2233 void eapol_am_wlan_authentication_symbian_c::RetrievePSKL(TPSKEntry& entry)
  1082 {
  2234 {
  1083 	EAP_TRACE_DEBUG(
       
  1084 		m_am_tools, 
       
  1085 		TRACE_FLAGS_DEFAULT, 
       
  1086 		(EAPL("eapol_am_wlan_authentication_symbian_c::RetrievePSKL(): this = 0x%08x\n"),
       
  1087 		this));
       
  1088 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eapol_am_wlan_authentication_symbian_c::RetrievePSKL()");
       
  1089 
  2235 
  1090 	// Open database
  2236 	// Open database
  1091 	RDbNamedDatabase db;
  2237 	RDbNamedDatabase db;
  1092 
  2238 
  1093 	TFileName aPrivateDatabasePathName;
  2239 #ifdef SYMBIAN_SECURE_DBMS
  1094 
  2240 	User::LeaveIfError(db.Open(m_session, KDatabaseName, KSecureUIDFormat));	
  1095 	EapPluginTools::GetPrivatePathL(
  2241 #else			
  1096 		m_session,
  2242 	User::LeaveIfError(db.Open(m_session, KDatabaseName));
  1097 		aPrivateDatabasePathName);
  2243 #endif // #ifdef SYMBIAN_SECURE_DBMS		
  1098 
       
  1099 	aPrivateDatabasePathName.Append(KEapolDatabaseName);
       
  1100 
       
  1101 	EAP_TRACE_DATA_DEBUG_SYMBIAN(("aPrivateDatabasePathName",
       
  1102 		aPrivateDatabasePathName.Ptr(),
       
  1103 		aPrivateDatabasePathName.Size()));
       
  1104 
       
  1105 	TInt error = db.Open(m_session, aPrivateDatabasePathName);
       
  1106 
       
  1107 	EAP_TRACE_DEBUG(
       
  1108 		m_am_tools, 
       
  1109 		TRACE_FLAGS_DEFAULT, 
       
  1110 		(EAPL("eapol_am_wlan_authentication_symbian_c::RetrievePSKL(): db.Open(), error = %d\n"),
       
  1111 		 error));
       
  1112 
       
  1113 	User::LeaveIfError(error);
       
  1114 	
  2244 	
  1115 	CleanupClosePushL(db);
  2245 	CleanupClosePushL(db);
  1116 
  2246 
  1117 	HBufC* sqlbuf = HBufC::NewLC(KMaxSqlQueryLength);
  2247 	HBufC* sqlbuf = HBufC::NewLC(KMaxSqlQueryLength);
  1118 	TPtr sqlStatement = sqlbuf->Des();
  2248 	TPtr sqlStatement = sqlbuf->Des();
  1141 
  2271 
  1142 	entry.ssid.Copy(view.ColDes8(3));
  2272 	entry.ssid.Copy(view.ColDes8(3));
  1143 	entry.password.Copy(view.ColDes8(4));
  2273 	entry.password.Copy(view.ColDes8(4));
  1144 	entry.psk.Copy(view.ColDes8(5));
  2274 	entry.psk.Copy(view.ColDes8(5));
  1145 
  2275 
  1146 	CleanupStack::PopAndDestroy(&view);
  2276 	CleanupStack::PopAndDestroy(3); // view, buf, database
  1147 	CleanupStack::PopAndDestroy(sqlbuf);
       
  1148 	CleanupStack::PopAndDestroy(&db);
       
  1149 }
  2277 }
  1150 
  2278 
  1151 //--------------------------------------------------
  2279 //--------------------------------------------------
  1152 
  2280 
  1153 void eapol_am_wlan_authentication_symbian_c::SavePSKL(TPSKEntry& entry)
  2281 void eapol_am_wlan_authentication_symbian_c::SavePSKL(TPSKEntry& entry)
  1154 {
  2282 {
  1155 	EAP_TRACE_DEBUG(
       
  1156 		m_am_tools, 
       
  1157 		TRACE_FLAGS_DEFAULT, 
       
  1158 		(EAPL("eapol_am_wlan_authentication_symbian_c::SavePSKL(): this = 0x%08x\n"),
       
  1159 		this));
       
  1160 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eapol_am_wlan_authentication_symbian_c::SavePSKL()");
       
  1161 
       
  1162 	// Connect to CommDBif so that we can delete PSK entries that have no IAP associated anymore.
  2283 	// Connect to CommDBif so that we can delete PSK entries that have no IAP associated anymore.
  1163 	CWLanSettings* wlan_settings = new(ELeave) CWLanSettings;
  2284 	CWLanSettings* wlan_settings = new(ELeave) CWLanSettings;
  1164 	CleanupStack::PushL(wlan_settings);
  2285 	CleanupStack::PushL(wlan_settings);
  1165 	
  2286 	
  1166 	SWLANSettings wlanSettings;
  2287 	SWLANSettings wlanSettings;
  1172 	}
  2293 	}
  1173 
  2294 
  1174 	// Open database
  2295 	// Open database
  1175 	RDbNamedDatabase db;
  2296 	RDbNamedDatabase db;
  1176 
  2297 
  1177 	TFileName aPrivateDatabasePathName;
  2298 #ifdef SYMBIAN_SECURE_DBMS
  1178 
  2299 	User::LeaveIfError(db.Open(m_session, KDatabaseName, KSecureUIDFormat));	
  1179 	EapPluginTools::GetPrivatePathL(
  2300 #else			
  1180 		m_session,
  2301 	User::LeaveIfError(db.Open(m_session, KDatabaseName));
  1181 		aPrivateDatabasePathName);
  2302 #endif // #ifdef SYMBIAN_SECURE_DBMS		
  1182 
       
  1183 	aPrivateDatabasePathName.Append(KEapolDatabaseName);
       
  1184 
       
  1185 	EAP_TRACE_DATA_DEBUG_SYMBIAN(("aPrivateDatabasePathName",
       
  1186 		aPrivateDatabasePathName.Ptr(),
       
  1187 		aPrivateDatabasePathName.Size()));
       
  1188 
       
  1189 	User::LeaveIfError(db.Open(m_session, aPrivateDatabasePathName));	
       
  1190 	
  2303 	
  1191 	CleanupClosePushL(db);
  2304 	CleanupClosePushL(db);
  1192 
  2305 
  1193 	HBufC* sqlbuf = HBufC::NewLC(KMaxSqlQueryLength);
  2306 	HBufC* sqlbuf = HBufC::NewLC(KMaxSqlQueryLength);
  1194 	TPtr sqlStatement = sqlbuf->Des();
  2307 	TPtr sqlStatement = sqlbuf->Des();
  1208 	CDbColSet* colSet = view.ColSetL();		
  2321 	CDbColSet* colSet = view.ColSetL();		
  1209 	CleanupStack::PushL(colSet);
  2322 	CleanupStack::PushL(colSet);
  1210 	
  2323 	
  1211 	// Delete old row and also rows that have no associated IAP settings.
  2324 	// Delete old row and also rows that have no associated IAP settings.
  1212 	if (view.FirstL())
  2325 	if (view.FirstL())
  1213 	{
  2326 	{		
  1214 		do {
  2327 		do {
  1215 			view.GetL();
  2328 			view.GetL();
  1216 
  2329 
  1217 			if ((wlan_settings->GetWlanSettingsForService(view.ColUint32(colSet->ColNo(KServiceIndex)), wlanSettings) != KErrNone)
  2330 			if ((wlan_settings->GetWlanSettingsForService(view.ColUint32(colSet->ColNo(KServiceIndex)), wlanSettings) != KErrNone)
  1218 				|| (view.ColUint32(colSet->ColNo(KServiceType)) == static_cast<TUint>(entry.indexType)
  2331 				|| (view.ColUint32(colSet->ColNo(KServiceType)) == static_cast<TUint>(entry.indexType)
  1237 	
  2350 	
  1238 	view.PutL();
  2351 	view.PutL();
  1239 	
  2352 	
  1240 	CleanupStack::PopAndDestroy( colSet ); // Delete colSet.	
  2353 	CleanupStack::PopAndDestroy( colSet ); // Delete colSet.	
  1241 
  2354 
  1242 	CleanupStack::PopAndDestroy(&view);
  2355 	CleanupStack::PopAndDestroy(4); // CWLanSettings, database, buffer, view
  1243 	CleanupStack::PopAndDestroy(sqlbuf);
       
  1244 	CleanupStack::PopAndDestroy(&db);
       
  1245 	CleanupStack::PopAndDestroy(wlan_settings);
       
  1246 
  2356 
  1247 }
  2357 }
  1248 														 
  2358 														 
  1249 //--------------------------------------------------
  2359 //--------------------------------------------------
  1250 
  2360 
  1251 //
  2361 //
  1252 void eapol_am_wlan_authentication_symbian_c::ReadWPASettingsL()
  2362 void eapol_am_wlan_authentication_symbian_c::ReadEAPSettingsL()
  1253 {
  2363 {
  1254 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  2364 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  1255 
  2365 
  1256 	EAP_TRACE_DEBUG(
  2366 	EAP_TRACE_DEBUG(
  1257 		m_am_tools, 
  2367 		m_am_tools, 
  1258 		TRACE_FLAGS_DEFAULT, 
  2368 		TRACE_FLAGS_DEFAULT, 
  1259 		(EAPL("eapol_am_wlan_authentication_symbian_c::ReadWPASettingsL(): %s, this = 0x%08x => 0x%08x\n"),
  2369 		(EAPL("eapol_am_wlan_authentication_symbian_c::ReadEAPSettingsL(): %s, this = 0x%08x => 0x%08x\n"),
  1260 		 (m_is_client == true) ? "client": "server",
  2370 		 (m_is_client == true) ? "client": "server",
  1261 		 this,
  2371 		 this,
  1262 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
  2372 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
  1263 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eapol_am_wlan_authentication_symbian_c::ReadWPASettingsL()");
       
  1264 
  2373 
  1265 	eap_status_e status(eap_status_ok);
  2374 	eap_status_e status(eap_status_ok);
  1266 
  2375 
  1267 	if (m_selected_eapol_key_authentication_type == eapol_key_authentication_type_WPS)
  2376 	status = reset_eap_plugins();
  1268 	{
  2377 	if (status != eap_status_ok)
  1269 		EAP_TRACE_DEBUG(
  2378 	{
  1270 			m_am_tools,
  2379 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1271 			TRACE_FLAGS_DEFAULT, (EAPL("WPS does not use CommDbIf anymore.\n")));
  2380 		User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
  1272 		return;
       
  1273 	}
  2381 	}
  1274 
  2382 
  1275 	TIndexType index_type(ELan);
  2383 	TIndexType index_type(ELan);
  1276 	TUint index(0UL);
  2384 	TUint index(0UL);
  1277 
  2385 
  1287 	if (index_type == ELan)
  2395 	if (index_type == ELan)
  1288 	{
  2396 	{
  1289 		EAP_TRACE_DEBUG(
  2397 		EAP_TRACE_DEBUG(
  1290 			m_am_tools,
  2398 			m_am_tools,
  1291 			TRACE_FLAGS_DEFAULT,
  2399 			TRACE_FLAGS_DEFAULT,
  1292 			(EAPL("WLAN settings: m_WPA_override_enabled=%d\n"),
  2400 			(EAPL("Beginning to read IAP settings - Type: %d, Index: %d.\n"), index_type, index));
       
  2401 
       
  2402 		CWLanSettings* wlan_settings = new(ELeave) CWLanSettings;
       
  2403 		CleanupStack::PushL(wlan_settings);
       
  2404 		SWLANSettings wlanSettings;
       
  2405 		if (wlan_settings->Connect() != KErrNone)
       
  2406 		{
       
  2407 			// Could not connect to CommDB			
       
  2408 			User::Leave(KErrCouldNotConnect);
       
  2409 		}
       
  2410 
       
  2411 		EAP_TRACE_DEBUG(
       
  2412 			m_am_tools,
       
  2413 			TRACE_FLAGS_DEFAULT, (EAPL("Connected to CommDbIf.\n")));
       
  2414 
       
  2415 		if (wlan_settings->GetWlanSettingsForService(index, wlanSettings) != KErrNone)
       
  2416 		{
       
  2417 			wlan_settings->Disconnect();
       
  2418 			User::Leave(KErrUnknown);
       
  2419 		}
       
  2420 
       
  2421 		EAP_TRACE_DEBUG(
       
  2422 			m_am_tools,
       
  2423 			TRACE_FLAGS_DEFAULT,
       
  2424 			(EAPL("Got WLAN settings: wlanSettings.EnableWpaPsk=%d, m_WPA_override_enabled=%d\n"),
       
  2425 			wlanSettings.EnableWpaPsk,
  1293 			m_WPA_override_enabled));
  2426 			m_WPA_override_enabled));
  1294 
  2427 
  1295 		EAP_TRACE_DATA_DEBUG(
  2428 		EAP_TRACE_DATA_DEBUG(
  1296 			m_am_tools,
  2429 			m_am_tools,
  1297 			TRACE_FLAGS_DEFAULT,
  2430 			TRACE_FLAGS_DEFAULT,
  1298 			(EAPL("m_wpa_preshared_key"),
  2431 			(EAPL("WPA-PSK"),
  1299 			m_wpa_preshared_key.get_data(),
  2432 			wlanSettings.WPAPreSharedKey.Ptr(),
  1300 			m_wpa_preshared_key.get_data_length()));
  2433 			wlanSettings.WPAPreSharedKey.Size()));
  1301 
  2434 
  1302 		EAP_TRACE_DATA_DEBUG(
  2435 #ifdef USE_EAP_EXPANDED_TYPES
       
  2436 
       
  2437 		EAP_TRACE_DEBUG(
  1303 			m_am_tools,
  2438 			m_am_tools,
  1304 			TRACE_FLAGS_DEFAULT,
  2439 			TRACE_FLAGS_DEFAULT,
  1305 			(EAPL("m_SSID"),
  2440 			(EAPL("Beginning to read EAP Data using new Comm_DB_if for expanded eap type\n")));
  1306 			m_SSID.get_data(),
  2441 
  1307 			m_SSID.get_data_length()));
  2442 		wlan_settings->GetEapDataL(m_enabled_expanded_eap_array, m_disabled_expanded_eap_array);
       
  2443 
       
  2444 		EAP_TRACE_DEBUG(
       
  2445 			m_am_tools,
       
  2446 			TRACE_FLAGS_DEFAULT,
       
  2447 			(EAPL("Enabled EAP count=%d, Disabled EAP count=%d\n"),
       
  2448 			m_enabled_expanded_eap_array.Count(), m_disabled_expanded_eap_array.Count()));
       
  2449 
       
  2450 			
       
  2451 	
       
  2452 #else
       
  2453 		// Without expanded EAP type. Normal EAP type stuff.
       
  2454 		wlan_settings->GetEapDataL(m_iap_eap_array);
       
  2455 
       
  2456 #endif //#ifdef USE_EAP_EXPANDED_TYPES
       
  2457 
       
  2458 		
       
  2459 		EAP_TRACE_DEBUG(
       
  2460 			m_am_tools,
       
  2461 			TRACE_FLAGS_DEFAULT,
       
  2462 			(EAPL("Got EAP data:\n")));
       
  2463 
       
  2464 #ifdef USE_EAP_EXPANDED_TYPES
       
  2465 
       
  2466 		// Reading enabled.
       
  2467 		for (TInt i = 0; i < m_enabled_expanded_eap_array.Count(); i++)
       
  2468 		{	
       
  2469 			TBuf8<KExpandedEAPSize> tmpExpEAP(m_enabled_expanded_eap_array[i]->EapExpandedType);
       
  2470 
       
  2471 			EAP_TRACE_DEBUG(
       
  2472 				m_am_tools, 
       
  2473 				TRACE_FLAGS_DEFAULT, 
       
  2474 				(EAPL("eapol_am_wlan_authentication_symbian_c::ReadEAPSettingsL:Enabled expanded EAP type at index=%d\n"),
       
  2475 				 i));
       
  2476 
       
  2477 			EAP_TRACE_DATA_DEBUG(
       
  2478 				m_am_tools,
       
  2479 				TRACE_FLAGS_DEFAULT,
       
  2480 				(EAPL("Enabled expanded EAP type:"),
       
  2481 				tmpExpEAP.Ptr(),
       
  2482 				tmpExpEAP.Size()));
       
  2483 		}
       
  2484 
       
  2485 		// Now reading disabled.
       
  2486 		for (TInt i = 0; i < m_disabled_expanded_eap_array.Count(); i++)
       
  2487 		{	
       
  2488 			TBuf8<KExpandedEAPSize> tmpExpEAP(m_disabled_expanded_eap_array[i]->EapExpandedType);
       
  2489 
       
  2490 			EAP_TRACE_DEBUG(
       
  2491 				m_am_tools, 
       
  2492 				TRACE_FLAGS_DEFAULT, 
       
  2493 				(EAPL("eapol_am_wlan_authentication_symbian_c::ReadEAPSettingsL:Disabled expanded EAP type at index=%d\n"),
       
  2494 				 i));
       
  2495 
       
  2496 			EAP_TRACE_DATA_DEBUG(
       
  2497 				m_am_tools,
       
  2498 				TRACE_FLAGS_DEFAULT,
       
  2499 				(EAPL("Disabled expanded EAP type:"),
       
  2500 				tmpExpEAP.Ptr(),
       
  2501 				tmpExpEAP.Size()));
       
  2502 		}
       
  2503 
       
  2504 #else // Normal EAP type.
       
  2505 
       
  2506 		for (TInt i = 0; i < m_iap_eap_array.Count(); i++)
       
  2507 		{
       
  2508 			EAP_TRACE_DEBUG(
       
  2509 				m_am_tools,
       
  2510 				TRACE_FLAGS_DEFAULT,
       
  2511 				(EAPL("EAP type %d\n"),
       
  2512 				i));
       
  2513 
       
  2514 			TLex8 tmp(m_iap_eap_array[i]->UID);
       
  2515 			TInt val(0);
       
  2516 			tmp.Val(val);
       
  2517 		
       
  2518 			EAP_TRACE_DEBUG(
       
  2519 				m_am_tools,
       
  2520 				TRACE_FLAGS_DEFAULT,
       
  2521 				(EAPL("  UID: %d\n"), val));
       
  2522 			EAP_TRACE_DEBUG(
       
  2523 				m_am_tools,
       
  2524 				TRACE_FLAGS_DEFAULT,
       
  2525 				(EAPL("  Enabled: %d\n"),
       
  2526 				m_iap_eap_array[i]->Enabled));
       
  2527 		}
       
  2528 
       
  2529 #endif // #ifdef USE_EAP_EXPANDED_TYPES
       
  2530 
       
  2531 		EAP_TRACE_DEBUG(
       
  2532 			m_am_tools,
       
  2533 			TRACE_FLAGS_DEFAULT,
       
  2534 			(EAPL("End EAP data:\n")));
       
  2535 
       
  2536 
       
  2537 #ifndef USE_EAP_EXPANDED_TYPES
       
  2538 
       
  2539 // There can not be a situation where all EAPs are disabled.
       
  2540 
       
  2541 		if (m_iap_eap_array.Count() == 0)
       
  2542 		{
       
  2543 
       
  2544 #if defined(USE_EAP_ALLOW_ALL_EAP_TYPES_WHEN_NONE_IS_ACTIVATED_IN_CONFIGURATION)
       
  2545 
       
  2546 			// The EAP field was empty. Allow all types.
       
  2547 
       
  2548 			EAP_TRACE_DEBUG(
       
  2549 				m_am_tools,
       
  2550 				TRACE_FLAGS_DEFAULT,
       
  2551 				(EAPL("Empty EAP field -> enable all types.\n")));
       
  2552 
       
  2553 			RImplInfoPtrArray eapArray;
       
  2554 			
       
  2555 			REComSession::ListImplementationsL(KEapTypeInterfaceUid, eapArray);
       
  2556 		
       
  2557 			TEap *eap;
       
  2558 			for (TInt i = 0; i < eapArray.Count(); i++)
       
  2559 			{
       
  2560 				eap = new(ELeave) TEap;
       
  2561 				eap->UID.Copy(eapArray[i]->DataType());
       
  2562 				eap->Enabled = ETrue;
       
  2563 				m_iap_eap_array.Append(eap);
       
  2564 			}
       
  2565 
       
  2566 			eapArray.ResetAndDestroy();
       
  2567 
       
  2568 #else
       
  2569 
       
  2570 			// The EAP field was empty. Allow EAP-SIM only.
       
  2571 
       
  2572 			EAP_TRACE_DEBUG(
       
  2573 				m_am_tools,
       
  2574 				TRACE_FLAGS_DEFAULT,
       
  2575 				(EAPL("Empty EAP field -> enable EAP-SIM only.\n")));
       
  2576 
       
  2577 			{
       
  2578 				TBuf8<3> eap_sim_uid = _L8("018");
       
  2579 
       
  2580 				TEap *eap = new(ELeave) TEap;
       
  2581 				eap->UID.Copy(eap_sim_uid);
       
  2582 				eap->Enabled = ETrue;
       
  2583 				m_iap_eap_array.Append(eap);
       
  2584 			}
       
  2585 
       
  2586 #endif //#if defined(USE_EAP_ALLOW_ALL_EAP_TYPES_WHEN_NONE_IS_ACTIVATED_IN_CONFIGURATION)
       
  2587 
       
  2588 		}
       
  2589 
       
  2590 #endif // #ifndef USE_EAP_EXPANDED_TYPES
       
  2591 
       
  2592 		// Get security mode
       
  2593 		if (m_WPA_override_enabled == false)
       
  2594 		{
       
  2595 			m_security_mode = static_cast<EWlanSecurityMode>(wlanSettings.SecurityMode);
       
  2596 		}
       
  2597 		else
       
  2598 		{
       
  2599 			// WPA override is enabled
       
  2600 			m_security_mode = Wpa;
       
  2601 		}
  1308 
  2602 
  1309 		// Get WPA pre shared key & SSID
  2603 		// Get WPA pre shared key & SSID
  1310 		if (m_is_client == true
  2604 		if (m_is_client == true
       
  2605 			&& (wlanSettings.EnableWpaPsk
       
  2606 				|| m_WPA_override_enabled == true)
  1311 			&& (m_selected_eapol_key_authentication_type == eapol_key_authentication_type_RSNA_PSK
  2607 			&& (m_selected_eapol_key_authentication_type == eapol_key_authentication_type_RSNA_PSK
  1312 				|| m_selected_eapol_key_authentication_type == eapol_key_authentication_type_WPA_PSK))
  2608 				|| m_selected_eapol_key_authentication_type == eapol_key_authentication_type_WPA_PSK))
  1313 		{
  2609 		{
       
  2610 			EAP_TRACE_DEBUG(
       
  2611 				m_am_tools,
       
  2612 				TRACE_FLAGS_DEFAULT,
       
  2613 				(EAPL("Uses WPAPSK: wlanSettings.EnableWpaPsk=%d\n"),
       
  2614 				wlanSettings.EnableWpaPsk));
       
  2615 
       
  2616 			// When not using easy WLAN there is no WPA PSK override.
       
  2617 			if (m_WPA_override_enabled == false)
       
  2618 			{
       
  2619 				status = m_wpa_preshared_key.set_copy_of_buffer(
       
  2620 					wlanSettings.WPAPreSharedKey.Ptr(),
       
  2621 					wlanSettings.WPAPreSharedKey.Size());
       
  2622 				if (status != eap_status_ok)
       
  2623 				{
       
  2624 					send_error_notification(eap_status_key_error);
       
  2625 					wlan_settings->Disconnect();
       
  2626 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2627 					User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
       
  2628 				}
       
  2629 
       
  2630 				// Here we copy the SSID read from IAP.
       
  2631 				TBuf8<K_Max_SSID_Length> tmp;
       
  2632 				tmp.Copy(wlanSettings.SSID);
       
  2633 				status = m_SSID.set_copy_of_buffer(tmp.Ptr(), tmp.Size());
       
  2634 				if (status != eap_status_ok)
       
  2635 				{
       
  2636 					wlan_settings->Disconnect();
       
  2637 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2638 					User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
       
  2639 				}
       
  2640 			}
       
  2641 			else
       
  2642 			{
       
  2643 				// In override mode SSID is stored to m_SSID
       
  2644 				// and password is stored to m_wpa_preshared_key.
       
  2645 			}
       
  2646 
  1314 			TPSKEntry pskEntry;
  2647 			TPSKEntry pskEntry;
  1315 			pskEntry.indexType = index_type;
  2648 			pskEntry.indexType = index_type;
  1316 			pskEntry.index = index;
  2649 			pskEntry.index = index;
  1317 			pskEntry.ssid.Zero();
  2650 			pskEntry.ssid.Zero();
  1318 			pskEntry.password.Zero();
  2651 			pskEntry.password.Zero();
  1319 			pskEntry.psk.Zero();
  2652 			pskEntry.psk.Zero();
  1320 
  2653 
  1321             TInt error(KErrNone);
  2654             TInt err(KErrNone);
  1322 
  2655 
  1323 			// Retrieve saved PSK only when override is not in effect
  2656 			// Retrieve saved PSK only when override is not in effect
  1324 			TRAP(error, RetrievePSKL(pskEntry));
  2657 			TRAP(err, RetrievePSKL(pskEntry));
  1325 			
  2658 			
  1326 			if (error != KErrNone
  2659 			if (err != KErrNone
  1327 				|| m_SSID.compare(pskEntry.ssid.Ptr(), pskEntry.ssid.Size()) != 0
  2660 				|| m_SSID.compare(pskEntry.ssid.Ptr(), pskEntry.ssid.Size()) != 0
  1328 				|| m_wpa_preshared_key.compare(pskEntry.password.Ptr(), pskEntry.password.Size()) != 0)
  2661 				|| m_wpa_preshared_key.compare(pskEntry.password.Ptr(), pskEntry.password.Size()) != 0)
  1329 			{
  2662 			{
  1330 				// No previous PSK or parameters were changed.
  2663 				// No previous PSK or parameters were changed.
  1331 				// We need to calculate PSK again
  2664 				// We need to calculate PSK again
  1341 
  2674 
  1342 					status = m_wpa_preshared_key_hash.set_buffer_length(EAPOL_WPA_PSK_LENGTH_BYTES);
  2675 					status = m_wpa_preshared_key_hash.set_buffer_length(EAPOL_WPA_PSK_LENGTH_BYTES);
  1343 					if (status != eap_status_ok)
  2676 					if (status != eap_status_ok)
  1344 					{
  2677 					{
  1345 						send_error_notification(eap_status_key_error);
  2678 						send_error_notification(eap_status_key_error);
       
  2679 						wlan_settings->Disconnect();							
  1346 						EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2680 						EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1347 						User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
  2681 						User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
  1348 					}
  2682 					}
  1349 
  2683 
  1350 					status = m_wpa_preshared_key_hash.set_data_length(EAPOL_WPA_PSK_LENGTH_BYTES);
  2684 					status = m_wpa_preshared_key_hash.set_data_length(EAPOL_WPA_PSK_LENGTH_BYTES);
  1351 					if (status != eap_status_ok)
  2685 					if (status != eap_status_ok)
  1352 					{
  2686 					{
  1353 						send_error_notification(eap_status_key_error);
  2687 						send_error_notification(eap_status_key_error);
       
  2688 						wlan_settings->Disconnect();							
  1354 						EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2689 						EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1355 						User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
  2690 						User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
  1356 					}
  2691 					}
  1357 
  2692 
  1358 					status = m_am_tools->convert_hex_ascii_to_bytes(
  2693 					status = m_am_tools->convert_hex_ascii_to_bytes(
  1362 						&target_length);
  2697 						&target_length);
  1363 					if (status != eap_status_ok
  2698 					if (status != eap_status_ok
  1364 						|| target_length != EAPOL_WPA_PSK_LENGTH_BYTES)
  2699 						|| target_length != EAPOL_WPA_PSK_LENGTH_BYTES)
  1365 					{
  2700 					{
  1366 						send_error_notification(eap_status_key_error);
  2701 						send_error_notification(eap_status_key_error);
       
  2702 						wlan_settings->Disconnect();							
  1367 						EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2703 						EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1368 						User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
  2704 						User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
  1369 					}
  2705 					}
  1370 				}
  2706 				}
  1371 				else
  2707 				else
  1378 						0);
  2714 						0);
  1379 
  2715 
  1380 					if (status != eap_status_ok)
  2716 					if (status != eap_status_ok)
  1381 					{
  2717 					{
  1382 						send_error_notification(eap_status_key_error);
  2718 						send_error_notification(eap_status_key_error);
       
  2719 						wlan_settings->Disconnect();							
  1383 						EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2720 						EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1384 						User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
  2721 						User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
  1385 					}
  2722 					}
  1386 				}
  2723 				}
  1387 
  2724 
  1431 				// Copy retrieved WPAPSK hash to member variable
  2768 				// Copy retrieved WPAPSK hash to member variable
  1432 				status = m_wpa_preshared_key_hash.set_copy_of_buffer(pskEntry.psk.Ptr(), pskEntry.psk.Size());
  2769 				status = m_wpa_preshared_key_hash.set_copy_of_buffer(pskEntry.psk.Ptr(), pskEntry.psk.Size());
  1433 				if (status != eap_status_ok)
  2770 				if (status != eap_status_ok)
  1434 				{
  2771 				{
  1435 					send_error_notification(eap_status_key_error);
  2772 					send_error_notification(eap_status_key_error);
       
  2773 					wlan_settings->Disconnect();
  1436 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2774 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1437 					User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
  2775 					User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
  1438 				}
  2776 				}
  1439 
  2777 
  1440 				EAP_TRACE_DATA_DEBUG(
  2778 				EAP_TRACE_DATA_DEBUG(
  1457 					(EAPL("old WPA-PSK hash"),
  2795 					(EAPL("old WPA-PSK hash"),
  1458 					m_wpa_preshared_key_hash.get_data(),
  2796 					m_wpa_preshared_key_hash.get_data(),
  1459 					m_wpa_preshared_key_hash.get_data_length()));
  2797 					m_wpa_preshared_key_hash.get_data_length()));
  1460 			}
  2798 			}
  1461 		}
  2799 		}
       
  2800 		
       
  2801 		wlan_settings->Disconnect();
       
  2802 		CleanupStack::PopAndDestroy(wlan_settings);
       
  2803 
       
  2804 		if (m_security_mode != Wlan8021x
       
  2805 			&& m_security_mode != Wpa
       
  2806 			&& m_security_mode != Wpa2Only)
       
  2807 		{
       
  2808 			// Unsupported mode
       
  2809 			User::Leave(KErrNotSupported);
       
  2810 		}
  1462 	} 
  2811 	} 
  1463 	else
  2812 	else
  1464 	{
  2813 	{
  1465 		// At the moment only LAN bearer is supported.
  2814 		// At the moment only LAN bearer is supported.
  1466 		User::Leave(KErrNotSupported);
  2815 		User::Leave(KErrNotSupported);
  1467 	}
  2816 	}
  1468 
  2817 
  1469 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2818 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1470 }
  2819 }
       
  2820 
       
  2821 //--------------------------------------------------
       
  2822 
       
  2823 #ifdef USE_EAP_EXPANDED_TYPES
       
  2824 
       
  2825 void eapol_am_wlan_authentication_symbian_c::SetToTopPriorityL(const eap_type_value_e aEapType)
       
  2826 {
       
  2827 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2828 
       
  2829 	EAP_TRACE_DEBUG(
       
  2830 		m_am_tools,
       
  2831 		TRACE_FLAGS_DEFAULT,
       
  2832 		(EAPL("eapol_am_wlan_authentication_symbian_c::SetToTopPriorityL() - for EXP EAP types\n")));
       
  2833 
       
  2834 	TIndexType index_type(ELan);
       
  2835 	TUint index(0UL);
       
  2836 	TInt priorityIndex (0);
       
  2837 
       
  2838 	eap_status_e status = read_database_reference_values(
       
  2839 		&index_type,
       
  2840 		&index);
       
  2841 	if (status != eap_status_ok)
       
  2842 	{
       
  2843 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2844 		User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
       
  2845 	}
       
  2846 
       
  2847 	if (index_type == ELan)
       
  2848 	{
       
  2849 		for (TInt i = 0; i < m_enabled_expanded_eap_array.Count(); i++)
       
  2850 		{
       
  2851 			TBuf8<KExpandedEAPSize> tmpExpEAP(m_enabled_expanded_eap_array[i]->EapExpandedType);
       
  2852 
       
  2853 			EAP_TRACE_DEBUG(
       
  2854 				m_am_tools, 
       
  2855 				TRACE_FLAGS_DEFAULT, 
       
  2856 				(EAPL("eapol_am_wlan_authentication_symbian_c::SetToTopPriorityL:Enabled expanded EAP type at index=%d\n"),
       
  2857 				 i));
       
  2858 
       
  2859 			EAP_TRACE_DATA_DEBUG(
       
  2860 				m_am_tools,
       
  2861 				TRACE_FLAGS_DEFAULT,
       
  2862 				(EAPL("Enabled expanded EAP type:"),
       
  2863 				tmpExpEAP.Ptr(),
       
  2864 				tmpExpEAP.Size()));
       
  2865 
       
  2866 			// This is for one expanded EAP type (for the above one).
       
  2867 			eap_expanded_type_c expandedEAPType;
       
  2868 					
       
  2869 			// Read the expanded EAP type details for this item in m_enabled_expanded_eap_array.
       
  2870 			eap_status_e status = eap_expanded_type_c::read_type(m_am_tools,
       
  2871 													0,
       
  2872 													tmpExpEAP.Ptr(),
       
  2873 													tmpExpEAP.Size(),
       
  2874 													&expandedEAPType);
       
  2875 			if (status != eap_status_ok)
       
  2876 			{
       
  2877 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2878 				User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
       
  2879 			}
       
  2880 
       
  2881 			if (aEapType == expandedEAPType)
       
  2882 			{
       
  2883 				// Found it. This is the EAP type which should be at top priority.
       
  2884 				priorityIndex = i;
       
  2885 				break;
       
  2886 			}
       
  2887 		}	
       
  2888 				
       
  2889 		if(priorityIndex == 0)
       
  2890 		{
       
  2891 			// This means this EAP type is already at the top priority.
       
  2892 
       
  2893 			EAP_TRACE_DEBUG(
       
  2894 				m_am_tools,
       
  2895 				TRACE_FLAGS_DEFAULT,
       
  2896 				(EAPL("eapol_am_wlan_authentication_symbian_c::SetToTopPriorityL() - This is already at top\n")));
       
  2897 			
       
  2898 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2899 			return;
       
  2900 		}
       
  2901 
       
  2902 		if (priorityIndex >= m_enabled_expanded_eap_array.Count())
       
  2903 		{
       
  2904 			// No such EAP type in enabled list. This should never happen.
       
  2905 			EAP_TRACE_DEBUG(
       
  2906 				m_am_tools,
       
  2907 				TRACE_FLAGS_DEFAULT,
       
  2908 				(EAPL("ERROR: eapol_am_wlan_authentication_symbian_c::SetToTopPriorityL() - No such EAP in the enabled list\n")));
       
  2909 			
       
  2910 			User::Leave(KErrNotFound);					
       
  2911 		}
       
  2912 
       
  2913 		CWLanSettings* wlan = new(ELeave) CWLanSettings;
       
  2914 		CleanupStack::PushL(wlan);
       
  2915 		SWLANSettings wlanSettings;
       
  2916 		if (wlan->Connect() != KErrNone)
       
  2917 		{
       
  2918 			// Could not connect to CommDB			
       
  2919 			User::Leave(KErrCouldNotConnect);
       
  2920 		}
       
  2921 		
       
  2922 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("SetToTopPriorityL():Connected to CommDbIf.\n")));
       
  2923 
       
  2924 		if (wlan->GetWlanSettingsForService(index, wlanSettings) != KErrNone)
       
  2925 		{
       
  2926 			wlan->Disconnect();
       
  2927 			User::Leave(KErrUnknown);
       
  2928 		}
       
  2929 		
       
  2930 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("SetToTopPriorityL():Got WLAN settings.\n")));
       
  2931 		
       
  2932 		// Change the order
       
  2933 		SEapExpandedType* TopPriorityEAP(m_enabled_expanded_eap_array[priorityIndex]);
       
  2934 
       
  2935 		m_enabled_expanded_eap_array.Remove(priorityIndex); // This does not delete the object	
       
  2936 				
       
  2937 		m_enabled_expanded_eap_array.Insert(TopPriorityEAP, 0); // Insert in the beginning.
       
  2938 
       
  2939 		wlan->SetEapDataL(m_enabled_expanded_eap_array, m_disabled_expanded_eap_array);
       
  2940 		
       
  2941 		wlan->Disconnect();
       
  2942 
       
  2943 		CleanupStack::PopAndDestroy(wlan);		
       
  2944 	} 
       
  2945 	else
       
  2946 	{
       
  2947 		// At the moment only LAN bearer is supported.
       
  2948 
       
  2949 		EAP_TRACE_DEBUG(
       
  2950 			m_am_tools,
       
  2951 			TRACE_FLAGS_DEFAULT,
       
  2952 			(EAPL("eapol_am_wlan_authentication_symbian_c::SetToTopPriorityL() - LEAVE - only LAN bearer is supported\n")));
       
  2953 		
       
  2954 		User::Leave(KErrNotSupported);
       
  2955 	}
       
  2956 		
       
  2957 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2958 }
       
  2959 
       
  2960 #else // For normal EAP types
       
  2961 
       
  2962 void eapol_am_wlan_authentication_symbian_c::SetToTopPriorityL(const TEap* const aEapType)
       
  2963 {
       
  2964 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2965 
       
  2966 	EAP_TRACE_DEBUG(
       
  2967 		m_am_tools,
       
  2968 		TRACE_FLAGS_DEFAULT,
       
  2969 		(EAPL("eapol_am_wlan_authentication_symbian_c::SetToTopPriorityL()\n")));
       
  2970 
       
  2971 	TIndexType index_type(ELan);
       
  2972 	TUint index(0UL);
       
  2973 
       
  2974 	eap_status_e status = read_database_reference_values(
       
  2975 		&index_type,
       
  2976 		&index);
       
  2977 	if (status != eap_status_ok)
       
  2978 	{
       
  2979 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2980 		User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
       
  2981 	}
       
  2982 
       
  2983 	if (index_type == ELan)
       
  2984 	{
       
  2985 		TInt i(0);
       
  2986 		TBuf8<3> uid;
       
  2987 		for (i = 0; i < m_iap_eap_array.Count(); i++)
       
  2988 		{
       
  2989 			TEap* eap = m_iap_eap_array[i];
       
  2990 			if (eap->UID[0] == '0')
       
  2991 			{
       
  2992 				// Cut the leading zero
       
  2993 				uid.Copy(eap->UID.Right(eap->UID.Length()-1));				
       
  2994 			}
       
  2995 			else
       
  2996 			{
       
  2997 				uid.Copy(eap->UID);
       
  2998 			}
       
  2999 			if (eap->Enabled == aEapType->Enabled
       
  3000 				&& uid.Compare(aEapType->UID) == 0)
       
  3001 			{
       
  3002 				// Found
       
  3003 				break;
       
  3004 			}
       
  3005 		}
       
  3006 		if (i >= m_iap_eap_array.Count())
       
  3007 		{
       
  3008 			// This should never happen
       
  3009 			User::Leave(KErrNotFound);					
       
  3010 		}
       
  3011 	
       
  3012 		TLex8 tmp(aEapType->UID);
       
  3013 		TInt val(0);
       
  3014 		tmp.Val(val);
       
  3015 
       
  3016 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Setting to top priority:\n")));
       
  3017 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Old index: %d\n"), i));
       
  3018 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("  UID: %d\n"), val));
       
  3019 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("  Enabled: %d\n"), aEapType->Enabled));
       
  3020 	
       
  3021 		if (i == 0)
       
  3022 		{
       
  3023 			// Already at the highest priority
       
  3024 			return;
       
  3025 		}
       
  3026 
       
  3027 		CWLanSettings* wlan = new(ELeave) CWLanSettings;
       
  3028 		CleanupStack::PushL(wlan);
       
  3029 		SWLANSettings wlanSettings;
       
  3030 		if (wlan->Connect() != KErrNone)
       
  3031 		{
       
  3032 			// Could not connect to CommDB			
       
  3033 			User::Leave(KErrCouldNotConnect);
       
  3034 		}
       
  3035 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Connected to CommDbIf.\n")));
       
  3036 
       
  3037 		if (wlan->GetWlanSettingsForService(index, wlanSettings) != KErrNone)
       
  3038 		{
       
  3039 			wlan->Disconnect();
       
  3040 			User::Leave(KErrUnknown);
       
  3041 		}
       
  3042 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Got WLAN settings.\n")));
       
  3043 		
       
  3044 		// Change the order
       
  3045 		TEap* eap = m_iap_eap_array[i];
       
  3046 
       
  3047 		m_iap_eap_array.Remove(i); // This does not delete the object	
       
  3048 				
       
  3049 		m_iap_eap_array.Insert(eap, 0);
       
  3050 
       
  3051 		wlan->SetEapDataL(m_iap_eap_array);
       
  3052 		
       
  3053 		wlan->Disconnect();
       
  3054 
       
  3055 		CleanupStack::PopAndDestroy(wlan);		
       
  3056 	} 
       
  3057 	else
       
  3058 	{
       
  3059 		// At the moment only LAN bearer is supported.
       
  3060 		User::Leave(KErrNotSupported);
       
  3061 	}
       
  3062 		
       
  3063 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3064 }
       
  3065 
       
  3066 #endif // #ifdef USE_EAP_EXPANDED_TYPES 
  1471 
  3067 
  1472 //--------------------------------------------------
  3068 //--------------------------------------------------
  1473 
  3069 
  1474 #if defined(USE_EAP_SIMPLE_CONFIG)
  3070 #if defined(USE_EAP_SIMPLE_CONFIG)
  1475 
  3071 
  1483 	EAP_TRACE_DEBUG(
  3079 	EAP_TRACE_DEBUG(
  1484 		m_am_tools,
  3080 		m_am_tools,
  1485 		TRACE_FLAGS_DEFAULT,
  3081 		TRACE_FLAGS_DEFAULT,
  1486 		(EAPL("%s: eapol_am_wlan_authentication_simulator_c::save_simple_config_session()\n"),
  3082 		(EAPL("%s: eapol_am_wlan_authentication_simulator_c::save_simple_config_session()\n"),
  1487 		(m_is_client == true ? "client": "server")));
  3083 		(m_is_client == true ? "client": "server")));
  1488 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eapol_am_wlan_authentication_symbian_c::save_simple_config_session()");
       
  1489 
  3084 
  1490 	eap_status_e status(eap_status_ok);
  3085 	eap_status_e status(eap_status_ok);
  1491 
  3086 
  1492 	status = m_configuration_if->save_simple_config_session(
  3087 	status = m_configuration_if->save_simple_config_session(
  1493 		state,
  3088 		state,
  1502 
  3097 
  1503 #endif // #if defined(USE_EAP_SIMPLE_CONFIG)
  3098 #endif // #if defined(USE_EAP_SIMPLE_CONFIG)
  1504 
  3099 
  1505 //--------------------------------------------------
  3100 //--------------------------------------------------
  1506 
  3101 
  1507 EAP_FUNC_EXPORT eap_status_e eapol_am_wlan_authentication_symbian_c::set_eap_database_reference_values(
       
  1508 	const eap_variable_data_c * const reference)
       
  1509 {
       
  1510 	EAP_TRACE_DEBUG(
       
  1511 		m_am_tools,
       
  1512 		TRACE_FLAGS_DEFAULT,
       
  1513 		(EAPL("%s: eapol_am_wlan_authentication_symbian_c::set_eap_database_reference_values()\n"),
       
  1514 		(m_is_client == true ? "client": "server")));
       
  1515 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eapol_am_wlan_authentication_symbian_c::set_eap_database_reference_values()");
       
  1516 
       
  1517 	EAP_TRACE_DATA_DEBUG(
       
  1518 		m_am_tools, 
       
  1519 		TRACE_FLAGS_DEFAULT, 
       
  1520 		(EAPL("eapol_am_wlan_authentication_symbian_c::set_eap_database_reference_values(): reference"),
       
  1521 		 reference->get_data(),
       
  1522 		 reference->get_data_length()));
       
  1523 
       
  1524 	eap_status_e status = m_database_reference.set_copy_of_buffer(reference);
       
  1525 
       
  1526 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1527 }
       
  1528 
       
  1529 //--------------------------------------------------
       
  1530 
       
  1531 EAP_FUNC_EXPORT eapol_am_wlan_authentication_c * eapol_am_wlan_authentication_c::new_eapol_am_wlan_authentication(
  3102 EAP_FUNC_EXPORT eapol_am_wlan_authentication_c * eapol_am_wlan_authentication_c::new_eapol_am_wlan_authentication(
  1532 	abs_eap_am_tools_c * const tools,
  3103 	abs_eap_am_tools_c * const tools,
  1533 	const bool is_client_when_true)
  3104 	const bool is_client_when_true,
       
  3105 	const abs_eapol_wlan_database_reference_if_c * const wlan_database_reference)
  1534 {
  3106 {
  1535 	EAP_TRACE_BEGIN(tools, TRACE_FLAGS_DEFAULT);
  3107 	EAP_TRACE_BEGIN(tools, TRACE_FLAGS_DEFAULT);
  1536 
       
  1537 	EAP_TRACE_DEBUG(
       
  1538 		tools, 
       
  1539 		TRACE_FLAGS_DEFAULT, 
       
  1540 		(EAPL("eapol_am_wlan_authentication_symbian_c::new_eapol_am_wlan_authentication()\n")));
       
  1541 	EAP_TRACE_RETURN_STRING(tools, "returns: eapol_am_wlan_authentication_symbian_c::new_eapol_am_wlan_authentication()");
       
  1542 
  3108 
  1543 	eapol_am_wlan_authentication_c * const wauth = new eapol_am_wlan_authentication_symbian_c(
  3109 	eapol_am_wlan_authentication_c * const wauth = new eapol_am_wlan_authentication_symbian_c(
  1544 		tools,
  3110 		tools,
  1545 		is_client_when_true);
  3111 		is_client_when_true,
       
  3112 		wlan_database_reference);
  1546 
  3113 
  1547 	EAP_TRACE_END(tools, TRACE_FLAGS_DEFAULT);
  3114 	EAP_TRACE_END(tools, TRACE_FLAGS_DEFAULT);
  1548 	return wauth;
  3115 	return wauth;
  1549 }
  3116 }
  1550 
  3117 
  1551 
  3118 
  1552 //--------------------------------------------------
  3119 //--------------------------------------------------
  1553 
       
  1554 //
       
  1555 eap_session_core_base_c * new_eap_core_client_message_if_c(
       
  1556 	abs_eap_am_tools_c * const tools,
       
  1557 	abs_eap_session_core_c * const partner,
       
  1558 	const bool is_client_when_true,
       
  1559 	const u32_t MTU)
       
  1560 {
       
  1561 	EAP_TRACE_DEBUG(
       
  1562 		tools, 
       
  1563 		TRACE_FLAGS_DEFAULT, 
       
  1564 		(EAPL("new_eap_core_client_message_if_c()\n")));
       
  1565 	EAP_TRACE_RETURN_STRING(tools, "returns: new_eap_core_client_message_if_c()");
       
  1566 
       
  1567 	eap_am_message_if_c *client_if = new_eap_am_client_message_if_c(
       
  1568 		tools,
       
  1569 		is_client_when_true,
       
  1570 		MTU);
       
  1571 
       
  1572 	eap_automatic_variable_c<eap_am_message_if_c> automatic_server_if(
       
  1573 		tools,
       
  1574 		client_if);
       
  1575 
       
  1576 	if (client_if == 0
       
  1577 		|| client_if->get_is_valid() == false)
       
  1578 	{
       
  1579 		// ERROR.
       
  1580 		if (client_if != 0)
       
  1581 		{
       
  1582 			EAP_TRACE_DEBUG(
       
  1583 				tools,
       
  1584 				TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, 
       
  1585 				(EAPL("ERROR: calls: eap_session_core_base_c::new_eap_core_client_message_if_c(): client_if->shutdown(): %s.\n"),
       
  1586 				(is_client_when_true == true) ? "client": "server"));
       
  1587 
       
  1588 			(void) client_if->shutdown();
       
  1589 		}
       
  1590 
       
  1591 		return 0;
       
  1592 	}
       
  1593 
       
  1594 	eap_core_client_message_if_c * new_session_core = new eap_core_client_message_if_c(tools, client_if, partner, is_client_when_true);
       
  1595 
       
  1596 	eap_automatic_variable_c<eap_core_client_message_if_c> automatic_new_session_core(
       
  1597 		tools,
       
  1598 		new_session_core);
       
  1599 
       
  1600 	if (new_session_core == 0
       
  1601 		|| new_session_core->get_is_valid() == false)
       
  1602 	{
       
  1603 		// ERROR.
       
  1604 		if (new_session_core != 0)
       
  1605 		{
       
  1606 			EAP_TRACE_DEBUG(
       
  1607 				tools,
       
  1608 				TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, 
       
  1609 				(EAPL("ERROR: calls: eap_session_core_base_c::new_eap_core_client_message_if_c(): new_session_core->shutdown(): %s.\n"),
       
  1610 				(is_client_when_true == true) ? "client": "server"));
       
  1611 
       
  1612 			new_session_core->shutdown();
       
  1613 		}
       
  1614 
       
  1615 		(void) client_if->shutdown();
       
  1616 
       
  1617 		return 0;
       
  1618 	}
       
  1619 
       
  1620 	client_if->set_partner(new_session_core);
       
  1621 
       
  1622 	automatic_server_if.do_not_free_variable();
       
  1623 	automatic_new_session_core.do_not_free_variable();
       
  1624 
       
  1625 	return new_session_core;
       
  1626 }
       
  1627 
       
  1628 //--------------------------------------------------
       
  1629 //--------------------------------------------------
  3120 //--------------------------------------------------
  1630 //--------------------------------------------------
  3121 //--------------------------------------------------
  1631 // End.
  3122 // End.