eapol/eapol_framework/wapi_symbian/wapi_core/symbian/wapi_am_wlan_authentication_symbian.cpp
changeset 17 8840d3e38314
equal deleted inserted replaced
2:1c7bc153c08e 17:8840d3e38314
       
     1 /*
       
     2 * ============================================================================
       
     3 *  Name        : ./accesssec/eapol/eapol_framework/wapi_symbian/wapi_core/symbian/wapi_am_wlan_authentication_symbian.cpp
       
     4 *  Part of     : WAPI / WAPI       *** Info from the SWAD
       
     5 *  Description : WAPI authentication
       
     6 *  Version     : %version: 22.1.1 % << Don't touch! Updated by Synergy at check-out.
       
     7 *
       
     8 *  Copyright © 2001-2009 Nokia.  All rights reserved.
       
     9 *  This material, including documentation and any related computer
       
    10 *  programs, is protected by copyright controlled by Nokia.  All
       
    11 *  rights are reserved.  Copying, including reproducing, storing,
       
    12 *  adapting or translating, any or all of this material requires the
       
    13 *  prior written consent of Nokia.  This material also contains
       
    14 *  confidential information which may not be disclosed to others
       
    15 *  without the prior written consent of Nokia.
       
    16 * ============================================================================
       
    17 * Template version: 4.1.1
       
    18 */
       
    19 
       
    20 // This is enumeration of EAPOL source code.
       
    21 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
       
    22 	#undef EAP_FILE_NUMBER_ENUM
       
    23 	#define EAP_FILE_NUMBER_ENUM 151 
       
    24 	#undef EAP_FILE_NUMBER_DATE 
       
    25 	#define EAP_FILE_NUMBER_DATE 1127594498 
       
    26 #endif //#if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
       
    27 
       
    28 #include "wapi_am_wlan_authentication_symbian.h"
       
    29 #include "abs_wapi_am_wlan_authentication.h"
       
    30 
       
    31 #include "eap_header_string.h"
       
    32 #include "eap_config.h"
       
    33 #include "eap_file_config.h"
       
    34 #include "eap_am_file_input_symbian.h"
       
    35 #include "eap_type_selection.h"
       
    36 #include "eapol_key_types.h"
       
    37 #include "eap_timer_queue.h"
       
    38 #include "eap_crypto_api.h"
       
    39 #include "abs_eapol_wlan_database_reference_if.h"
       
    40 #include "abs_eap_state_notification.h"
       
    41 #include "eap_state_notification.h"
       
    42 #include "eap_automatic_variable.h"
       
    43 #include "wapi_core.h"
       
    44 #include "WapiDbDefaults.h"
       
    45 #include "certificate_store_db_parameters.h"
       
    46 
       
    47 //--------------------------------------------------
       
    48 
       
    49 EAP_FUNC_EXPORT wapi_am_wlan_authentication_symbian_c::~wapi_am_wlan_authentication_symbian_c()
       
    50     {
       
    51 	EAP_TRACE_DEBUG(
       
    52 		m_am_tools, 
       
    53 		TRACE_FLAGS_DEFAULT, 
       
    54 		(EAPL("wapi_am_wlan_authentication_symbian_c::~wapi_am_wlan_authentication_symbian_c(): this = 0x%08x\n"),
       
    55 		this));
       
    56     }
       
    57 
       
    58 //--------------------------------------------------
       
    59 
       
    60 EAP_FUNC_EXPORT wapi_am_wlan_authentication_symbian_c::wapi_am_wlan_authentication_symbian_c(
       
    61 	abs_eap_am_tools_c * const tools,
       
    62 	const bool is_client_when_true,
       
    63 	const abs_eapol_wlan_database_reference_if_c * const wlan_database_reference)
       
    64 : CActive(CActive::EPriorityStandard)
       
    65 , m_am_partner(0)
       
    66 , m_am_tools(tools)
       
    67 , m_fileconfig(0)
       
    68 , m_SSID(tools)
       
    69 , m_wlan_database_reference(wlan_database_reference)
       
    70 , m_receive_network_id(tools)
       
    71 , m_selected_eapol_key_authentication_type(eapol_key_authentication_type_none)
       
    72 , m_is_client(is_client_when_true)
       
    73 , m_is_valid(false)
       
    74 , m_wapi_preshared_key(tools)
       
    75 , m_wapi_psk(tools)
       
    76 , iIapIndex(0)
       
    77     {
       
    78 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
    79 
       
    80 	m_is_valid = true;
       
    81 
       
    82 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
    83     }
       
    84 
       
    85 //--------------------------------------------------
       
    86 
       
    87 EAP_FUNC_EXPORT bool wapi_am_wlan_authentication_symbian_c::get_is_valid()
       
    88     {
       
    89 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
    90 
       
    91 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
    92 	return m_is_valid;
       
    93     }
       
    94 
       
    95 //--------------------------------------------------
       
    96 
       
    97 EAP_FUNC_EXPORT eap_status_e wapi_am_wlan_authentication_symbian_c::reset_wapi_configuration()
       
    98 	{
       
    99 	
       
   100 	return eap_status_ok;
       
   101 	}
       
   102 
       
   103 
       
   104 //--------------------------------------------------
       
   105 
       
   106 EAP_FUNC_EXPORT eap_status_e wapi_am_wlan_authentication_symbian_c::configure()
       
   107     {
       
   108 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   109 
       
   110 	EAP_TRACE_DEBUG(
       
   111 		m_am_tools, 
       
   112 		TRACE_FLAGS_DEFAULT, 
       
   113 		(EAPL("wapi_am_wlan_authentication_symbian_c::configure(): %s, this = 0x%08x => 0x%08x\n"),
       
   114 		 (m_is_client == true) ? "client": "server",
       
   115 		 this,
       
   116 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
       
   117 
       
   118 #if defined(USE_EAP_FILECONFIG)
       
   119 	{
       
   120 		eap_am_file_input_symbian_c * const fileio = new eap_am_file_input_symbian_c(m_am_tools);
       
   121 
       
   122 		eap_automatic_variable_c<eap_am_file_input_symbian_c> automatic_fileio(m_am_tools, fileio);
       
   123 
       
   124 		if (fileio != 0
       
   125 			&& fileio->get_is_valid() == true)
       
   126 		{
       
   127 			EAP_TRACE_DEBUG(
       
   128 				m_am_tools,
       
   129 				TRACE_FLAGS_DEFAULT,
       
   130 				(EAPL("Initialize file configuration.\n")));
       
   131 
       
   132 			eap_variable_data_c file_name_c_data(m_am_tools);
       
   133 
       
   134 			eap_status_e status(eap_status_process_general_error);
       
   135 
       
   136 			{
       
   137 				#if defined(EAPOL_SYMBIAN_VERSION_7_0_s)
       
   138 					eap_const_string const FILECONFIG_FILENAME_C
       
   139 						= "c:\\system\\data\\wapi.conf";
       
   140 				#else
       
   141 					eap_const_string const FILECONFIG_FILENAME_C
       
   142 						= "c:\\private\\101F8EC5\\wapi.conf";
       
   143 				#endif
       
   144 
       
   145 				status = file_name_c_data.set_copy_of_buffer(
       
   146 					FILECONFIG_FILENAME_C,
       
   147 					m_am_tools->strlen(FILECONFIG_FILENAME_C));
       
   148 				if (status != eap_status_ok)
       
   149 				{
       
   150 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   151 					return EAP_STATUS_RETURN(m_am_tools, status);
       
   152 				}
       
   153 
       
   154 				status = file_name_c_data.add_end_null();
       
   155 				if (status != eap_status_ok)
       
   156 				{
       
   157 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   158 					return EAP_STATUS_RETURN(m_am_tools, status);
       
   159 				}
       
   160 			}
       
   161 
       
   162 			eap_variable_data_c file_name_z_data(m_am_tools);
       
   163 
       
   164 			{
       
   165 				#if defined(EAPOL_SYMBIAN_VERSION_7_0_s)
       
   166 					eap_const_string const FILECONFIG_FILENAME_Z
       
   167 						= "z:\\system\\data\\wapi.conf";
       
   168 				#else
       
   169 					eap_const_string const FILECONFIG_FILENAME_Z
       
   170 						= "z:\\private\\101F8EC5\\wapi.conf";
       
   171 				#endif
       
   172 
       
   173 				status = file_name_z_data.set_copy_of_buffer(
       
   174 					FILECONFIG_FILENAME_Z,
       
   175 					m_am_tools->strlen(FILECONFIG_FILENAME_Z));
       
   176 				if (status != eap_status_ok)
       
   177 				{
       
   178 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   179 					return EAP_STATUS_RETURN(m_am_tools, status);
       
   180 				}
       
   181 
       
   182 				status = file_name_z_data.add_end_null();
       
   183 				if (status != eap_status_ok)
       
   184 				{
       
   185 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   186 					return EAP_STATUS_RETURN(m_am_tools, status);
       
   187 				}
       
   188 			}
       
   189 
       
   190 
       
   191 
       
   192 			if (status == eap_status_ok)
       
   193 			{
       
   194 				// First try open from C: disk.
       
   195 				status = fileio->file_open(
       
   196 					&file_name_c_data,
       
   197 					eap_file_io_direction_read);
       
   198 				if (status == eap_status_ok)
       
   199 				{
       
   200 					EAP_TRACE_DEBUG(
       
   201 						m_am_tools,
       
   202 						TRACE_FLAGS_DEFAULT,
       
   203 						(EAPL("Opens configure file %s\n"),
       
   204 						file_name_c_data.get_data(file_name_c_data.get_data_length())));
       
   205 				}
       
   206 				else if (status != eap_status_ok)
       
   207 				{
       
   208 					// Second try open from Z: disk.
       
   209 					status = fileio->file_open(
       
   210 						&file_name_z_data,
       
   211 						eap_file_io_direction_read);
       
   212 					if (status == eap_status_ok)
       
   213 					{
       
   214 						EAP_TRACE_DEBUG(
       
   215 							m_am_tools,
       
   216 							TRACE_FLAGS_DEFAULT,
       
   217 							(EAPL("Opens configure file %s\n"),
       
   218 							 file_name_z_data.get_data(file_name_z_data.get_data_length())));
       
   219 					}
       
   220 				}
       
   221 
       
   222 				if (status == eap_status_ok)
       
   223 				{
       
   224 					// Some of the files were opened.
       
   225 
       
   226 					m_fileconfig = new eap_file_config_c(m_am_tools);
       
   227 					if (m_fileconfig != 0
       
   228 						&& m_fileconfig->get_is_valid() == true)
       
   229 					{
       
   230 						status = m_fileconfig->configure(fileio);
       
   231 						if (status != eap_status_ok)
       
   232 						{
       
   233 							EAP_TRACE_DEBUG(
       
   234 								m_am_tools,
       
   235 								TRACE_FLAGS_DEFAULT,
       
   236 								(EAPL("ERROR: Configure read from %s failed.\n"),
       
   237 								file_name_c_data.get_data(file_name_c_data.get_data_length())));
       
   238 						}
       
   239 						else
       
   240 						{
       
   241 							EAP_TRACE_DEBUG(
       
   242 								m_am_tools,
       
   243 								TRACE_FLAGS_DEFAULT,
       
   244 								(EAPL("Configure read from %s\n"),
       
   245 								file_name_c_data.get_data(file_name_c_data.get_data_length())));
       
   246 						}
       
   247 					}
       
   248 					else
       
   249 					{
       
   250 						// No file configuration.
       
   251 						delete m_fileconfig;
       
   252 						m_fileconfig = 0;
       
   253 
       
   254 						EAP_TRACE_DEBUG(
       
   255 							m_am_tools,
       
   256 							TRACE_FLAGS_DEFAULT,
       
   257 							(EAPL("ERROR: Cannot create configure object for file %s\n"),
       
   258 							file_name_c_data.get_data(file_name_c_data.get_data_length())));
       
   259 					}
       
   260 				}
       
   261 				else
       
   262 				{
       
   263 					EAP_TRACE_DEBUG(
       
   264 						m_am_tools,
       
   265 						TRACE_FLAGS_DEFAULT,
       
   266 						(EAPL("ERROR: Cannot open configure file neither %s nor %s\n"),
       
   267 						file_name_c_data.get_data(file_name_c_data.get_data_length()),
       
   268 						file_name_z_data.get_data(file_name_z_data.get_data_length())));
       
   269 				}
       
   270 			}
       
   271 		}
       
   272 		else
       
   273 		{
       
   274 			EAP_TRACE_DEBUG(
       
   275 				m_am_tools,
       
   276 				TRACE_FLAGS_DEFAULT,
       
   277 				(EAPL("Skips file configuration.\n")));
       
   278 		}
       
   279 	}
       
   280 
       
   281 #endif //#if defined(USE_EAP_FILECONFIG)
       
   282 
       
   283 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
   284 
       
   285 #if defined(USE_EAP_FILE_TRACE)
       
   286 	{
       
   287 		eap_variable_data_c trace_output_file(m_am_tools);
       
   288 
       
   289 		eap_status_e status = read_configure(
       
   290 			cf_str_EAP_TRACE_output_file_name.get_field(),
       
   291 			&trace_output_file);
       
   292 		if (status == eap_status_ok
       
   293 			&& trace_output_file.get_is_valid_data() == true)
       
   294 		    {
       
   295 			status = m_am_tools->set_trace_file_name(&trace_output_file);
       
   296 			if (status == eap_status_ok)
       
   297 			    {
       
   298 				m_am_tools->set_trace_mask(
       
   299 					eap_am_tools_c::eap_trace_mask_debug
       
   300 					| eap_am_tools_c::eap_trace_mask_always
       
   301 					| eap_am_tools_c::eap_trace_mask_error
       
   302 					| eap_am_tools_c::eap_trace_mask_message_data);
       
   303 			    }
       
   304             }
       
   305 	}
       
   306 #endif //#if defined(USE_EAP_FILE_TRACE)
       
   307 
       
   308 
       
   309 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
   310 
       
   311 	{
       
   312 		eap_variable_data_c EAP_TRACE_enable_timer_queue_traces(m_am_tools);
       
   313 
       
   314 		eap_status_e status = read_configure(
       
   315 			cf_str_EAP_TRACE_enable_timer_queue_traces.get_field(),
       
   316 			&EAP_TRACE_enable_timer_queue_traces);
       
   317 		if (status == eap_status_ok
       
   318 			&& EAP_TRACE_enable_timer_queue_traces.get_is_valid_data() == true)
       
   319 		    {
       
   320 			u32_t *enable_timer_queue_traces = reinterpret_cast<u32_t *>(
       
   321 				EAP_TRACE_enable_timer_queue_traces.get_data(sizeof(u32_t)));
       
   322 			if (enable_timer_queue_traces != 0
       
   323 				&& *enable_timer_queue_traces != 0)
       
   324 			    {
       
   325 				m_am_tools->set_trace_mask(
       
   326 					m_am_tools->get_trace_mask()
       
   327 					| eap_am_tools_c::eap_trace_mask_timer_queue
       
   328 					);
       
   329 			    }
       
   330 		    }
       
   331 	}
       
   332 
       
   333 	{
       
   334 		eap_variable_data_c EAP_TRACE_enable_function_traces(m_am_tools);
       
   335 
       
   336 		eap_status_e status = read_configure(
       
   337 			cf_str_EAP_TRACE_enable_function_traces.get_field(),
       
   338 			&EAP_TRACE_enable_function_traces);
       
   339 		if (status == eap_status_ok
       
   340 			&& EAP_TRACE_enable_function_traces.get_is_valid_data() == true)
       
   341 		{
       
   342 			u32_t *enable_function_traces = reinterpret_cast<u32_t *>(
       
   343 				EAP_TRACE_enable_function_traces.get_data(sizeof(u32_t)));
       
   344 			if (enable_function_traces != 0
       
   345 				&& *enable_function_traces != 0)
       
   346 			{
       
   347 				m_am_tools->set_trace_mask(
       
   348 					m_am_tools->get_trace_mask()
       
   349 					| eap_am_tools_c::eap_trace_mask_functions
       
   350 					);
       
   351 			}
       
   352 		}
       
   353 	}
       
   354 
       
   355 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   356 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   357     }
       
   358 
       
   359 //--------------------------------------------------
       
   360 
       
   361 EAP_FUNC_EXPORT eap_status_e wapi_am_wlan_authentication_symbian_c::shutdown()
       
   362     {
       
   363 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   364 
       
   365 	EAP_TRACE_ALWAYS(
       
   366 		m_am_tools, 
       
   367 		TRACE_FLAGS_DEFAULT, 
       
   368 		(EAPL("wapi_am_wlan_authentication_symbian_c::shutdown(): %s, this = 0x%08x => 0x%08x\n"),
       
   369 		 (m_is_client == true) ? "client": "server",
       
   370 		 this,
       
   371 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
       
   372 
       
   373 	delete m_fileconfig;
       
   374     m_fileconfig = 0;
       
   375 
       
   376 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   377 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   378     }
       
   379 
       
   380 //--------------------------------------------------
       
   381 
       
   382 EAP_FUNC_EXPORT eap_status_e wapi_am_wlan_authentication_symbian_c::set_am_partner(
       
   383 	abs_wapi_am_wlan_authentication_c * am_partner
       
   384 	)
       
   385     {
       
   386 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   387 
       
   388 	EAP_TRACE_DEBUG(
       
   389 		m_am_tools, 
       
   390 		TRACE_FLAGS_DEFAULT, 
       
   391 		(EAPL("wapi_am_wlan_authentication_simulator_c::set_am_partner(): %s, this = 0x%08x\n"),
       
   392 		 (m_is_client == true) ? "client": "server",
       
   393 		 this));
       
   394 
       
   395 	m_am_partner = am_partner;
       
   396 
       
   397 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   398 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   399     }
       
   400 
       
   401 //--------------------------------------------------
       
   402 //--------------------------------------------------
       
   403 
       
   404 void wapi_am_wlan_authentication_symbian_c::send_error_notification(const eap_status_e error)
       
   405     {
       
   406 	EAP_TRACE_DEBUG(m_am_tools, 
       
   407 		TRACE_FLAGS_DEFAULT, 
       
   408 		(EAPL("wapi_am_wlan_authentication_symbian_c::send_error_notification, error=%d\n"),
       
   409 		error));	
       
   410 
       
   411    eap_general_state_variable_e general_state_variable(eap_general_state_authentication_error);
       
   412     
       
   413     if (error == eap_status_user_cancel_authentication)
       
   414         {
       
   415         general_state_variable = eap_general_state_authentication_cancelled;
       
   416         }
       
   417 
       
   418     // Here we swap the addresses.
       
   419 	eap_am_network_id_c send_network_id(m_am_tools,
       
   420 		m_receive_network_id.get_destination_id(),
       
   421 		m_receive_network_id.get_source_id(),
       
   422 		m_receive_network_id.get_type());
       
   423 
       
   424 	// Notifies the lower level of an authentication error.
       
   425     eap_state_notification_c notification(
       
   426         m_am_tools,
       
   427         &send_network_id,
       
   428         m_is_client,
       
   429         eap_state_notification_eap,
       
   430         eap_protocol_layer_general,
       
   431         eap_type_none,
       
   432         eap_state_none,
       
   433         general_state_variable,
       
   434         0,
       
   435         false);
       
   436 
       
   437     notification.set_authentication_error(error);
       
   438 
       
   439     m_am_partner->state_notification(&notification);
       
   440 
       
   441 
       
   442     }
       
   443 
       
   444 //--------------------------------------------------
       
   445 
       
   446 EAP_FUNC_EXPORT eap_status_e wapi_am_wlan_authentication_symbian_c::set_wlan_parameters(
       
   447 	const eap_variable_data_c * const SSID,
       
   448 	const bool WPA_override_enabled,
       
   449 	const eap_variable_data_c * const wapi_preshared_key,
       
   450 	const eapol_key_authentication_type_e selected_eapol_key_authentication_type)
       
   451     {
       
   452 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   453 
       
   454 	EAP_TRACE_DEBUG(
       
   455 		m_am_tools, 
       
   456 		TRACE_FLAGS_DEFAULT, 
       
   457 		(EAPL("wapi_am_wlan_authentication_symbian_c::set_wlan_parameters(): %s, this = 0x%08x => 0x%08x\n"),
       
   458 		 (m_is_client == true) ? "client": "server",
       
   459 		 this,
       
   460 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
       
   461 
       
   462 	m_selected_eapol_key_authentication_type = selected_eapol_key_authentication_type;
       
   463 
       
   464 	eap_status_e status = m_SSID.set_copy_of_buffer(SSID);
       
   465 	if (status != eap_status_ok)
       
   466 	    {
       
   467 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   468 		return EAP_STATUS_RETURN(m_am_tools, status);
       
   469 	   }
       
   470 
       
   471 	status = m_wapi_preshared_key.set_copy_of_buffer(&m_wapi_psk);
       
   472 	if (status != eap_status_ok)
       
   473 	    {
       
   474 		send_error_notification(eap_status_key_error);
       
   475 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   476 		return EAP_STATUS_RETURN(m_am_tools, status);
       
   477 	    }
       
   478 
       
   479 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   480 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   481     }
       
   482 
       
   483 //--------------------------------------------------
       
   484 
       
   485 //
       
   486 void wapi_am_wlan_authentication_symbian_c::state_notification(
       
   487 	const abs_eap_state_notification_c * const state)
       
   488     {
       
   489 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   490 
       
   491 	EAP_UNREFERENCED_PARAMETER(state);
       
   492 	
       
   493 	// nothing to show to user, so do nothing
       
   494 	
       
   495 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   496     }
       
   497 
       
   498 //--------------------------------------------------
       
   499 
       
   500 EAP_FUNC_EXPORT eap_status_e wapi_am_wlan_authentication_symbian_c::association(
       
   501 	const eap_am_network_id_c * const receive_network_id)
       
   502     {
       
   503 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   504 
       
   505 	EAP_TRACE_DEBUG(
       
   506 		m_am_tools, 
       
   507 		TRACE_FLAGS_DEFAULT, 
       
   508 		(EAPL("wapi_am_wlan_authentication_symbian_c::association(): %s, this = 0x%08x => 0x%08x\n"),
       
   509 		 (m_is_client == true) ? "client": "server",
       
   510 		 this,
       
   511 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
       
   512 
       
   513 	eap_status_e status = m_receive_network_id.set_copy_of_network_id(receive_network_id);
       
   514 
       
   515 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   516 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   517     }
       
   518 
       
   519 //--------------------------------------------------
       
   520 
       
   521 //
       
   522 EAP_FUNC_EXPORT eap_status_e wapi_am_wlan_authentication_symbian_c::disassociation(
       
   523 	const eap_am_network_id_c * const /* receive_network_id */ ///< source includes remote address, destination includes local address.
       
   524 	)
       
   525     {
       
   526 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   527 
       
   528 	EAP_TRACE_DEBUG(
       
   529 		m_am_tools, 
       
   530 		TRACE_FLAGS_DEFAULT, 
       
   531 		(EAPL("wapi_am_wlan_authentication_symbian_c::disassociation(): %s, this = 0x%08x => 0x%08x\n"),
       
   532 		 (m_is_client == true) ? "client": "server",
       
   533 		 this,
       
   534 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
       
   535 
       
   536 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   537 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   538     }
       
   539 
       
   540 //--------------------------------------------------
       
   541 
       
   542 EAP_FUNC_EXPORT eap_status_e wapi_am_wlan_authentication_symbian_c::get_wlan_configuration(
       
   543 	eap_variable_data_c * const wapi_psk)
       
   544     {
       
   545 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   546 
       
   547 	eap_status_e status = eap_status_ok;
       
   548 	
       
   549 	EAP_TRACE_DEBUG(
       
   550 		m_am_tools, 
       
   551 		TRACE_FLAGS_DEFAULT, 
       
   552 		(EAPL("wapi_am_wlan_authentication_symbian_c::get_wlan_configuration(): %s, this = 0x%08x => 0x%08x\n"),
       
   553 		 (m_is_client == true) ? "client": "server",
       
   554 		 this,
       
   555 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
       
   556 
       
   557 
       
   558 	TRAPD(err, status = GetWlanConfigurationL(wapi_psk ));
       
   559 	if (err)
       
   560 	    {
       
   561 	    EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   562 	    return m_am_tools->convert_am_error_to_eapol_error(err);
       
   563 	    }
       
   564 	  
       
   565 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   566 	return status;
       
   567     }
       
   568 
       
   569 eap_status_e wapi_am_wlan_authentication_symbian_c::GetWlanConfigurationL(eap_variable_data_c * const wapi_psk )
       
   570     {
       
   571 
       
   572     EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   573     
       
   574     TIndexType index_type(ELan);
       
   575     TUint index(0UL);
       
   576 
       
   577     eap_status_e status = read_database_reference_values(
       
   578         &index_type,
       
   579         &index);
       
   580     if (status != eap_status_ok)
       
   581         {
       
   582         EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   583         User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
       
   584         }
       
   585 
       
   586     if (index_type == ELan)
       
   587         {
       
   588         EAP_TRACE_DEBUG(
       
   589             m_am_tools,
       
   590             TRACE_FLAGS_DEFAULT,
       
   591             (EAPL("Beginning to read IAP settings - Type: %d, Index: %d.\n"), index_type, index));
       
   592         
       
   593         iIapIndex = index;
       
   594         
       
   595         CWLanSettings* wlan_settings = new(ELeave) CWLanSettings;
       
   596         CleanupStack::PushL(wlan_settings);
       
   597         SWLANSettings wlanSettings;
       
   598         if (wlan_settings->Connect() != KErrNone)
       
   599             {
       
   600             // Could not connect to CommDB          
       
   601             CleanupStack::PopAndDestroy(wlan_settings);
       
   602             User::Leave(KErrCouldNotConnect);
       
   603             }
       
   604 
       
   605         EAP_TRACE_DEBUG(
       
   606                 m_am_tools,
       
   607                 TRACE_FLAGS_DEFAULT, (EAPL("Connected to CommDbIf.\n")));
       
   608 
       
   609         if (wlan_settings->GetWlanSettingsForService(index, wlanSettings) != KErrNone)
       
   610             {
       
   611             wlan_settings->Disconnect();
       
   612             CleanupStack::PopAndDestroy(wlan_settings);
       
   613             User::Leave(KErrUnknown);
       
   614             }
       
   615 
       
   616         status = m_wapi_preshared_key.set_copy_of_buffer(
       
   617                 wlanSettings.WPAPreSharedKey.Ptr(),
       
   618                 wlanSettings.WPAPreSharedKey.Size());
       
   619         if (status != eap_status_ok)
       
   620             {
       
   621             send_error_notification(eap_status_key_error);
       
   622             wlan_settings->Disconnect();
       
   623             CleanupStack::PopAndDestroy(wlan_settings);
       
   624             EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   625             User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
       
   626            }
       
   627 
       
   628        // Here we copy the SSID read from IAP.
       
   629        TBuf8<32> tmp;
       
   630        tmp.Copy(wlanSettings.SSID);
       
   631        status = m_SSID.set_copy_of_buffer(tmp.Ptr(), tmp.Size());
       
   632         if (status != eap_status_ok)
       
   633            {
       
   634            wlan_settings->Disconnect();
       
   635            CleanupStack::PopAndDestroy(wlan_settings);
       
   636            EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   637            User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
       
   638            }
       
   639  
       
   640         EAP_TRACE_DATA_DEBUG(
       
   641                m_am_tools,
       
   642                TRACE_FLAGS_DEFAULT,
       
   643                (EAPL("m_wapi_preshared_key"),
       
   644                        m_wapi_preshared_key.get_data(),
       
   645                        m_wapi_preshared_key.get_data_length()));
       
   646 
       
   647         TInt aPskType = wlanSettings.PresharedKeyFormat;
       
   648  
       
   649         if (aPskType == EWlanPresharedKeyFormatHex)
       
   650             {
       
   651             EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("PSK HEX\n")));
       
   652     
       
   653             m_wapi_psk.reset();
       
   654             wapi_psk->reset();
       
   655     
       
   656             u32_t target_length(m_wapi_preshared_key.get_data_length() / 2);
       
   657                  
       
   658             status = m_wapi_psk.set_buffer_length(target_length);
       
   659         
       
   660             if (status != eap_status_ok)
       
   661                 {
       
   662                 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("set_buffer_length NOT OK \n")));
       
   663                 send_error_notification(eap_status_key_error);
       
   664                 wlan_settings->Disconnect();                            
       
   665                 CleanupStack::PopAndDestroy(wlan_settings); 
       
   666                 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   667                 return eap_status_key_error;
       
   668                 }
       
   669             
       
   670             status = m_wapi_psk.set_data_length(target_length);
       
   671             if (status != eap_status_ok)
       
   672                 {
       
   673                 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("set_data_length NOT OK \n")));
       
   674                 send_error_notification(eap_status_key_error);
       
   675                 wlan_settings->Disconnect();                            
       
   676                 CleanupStack::PopAndDestroy(wlan_settings); 
       
   677                 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   678                 return eap_status_key_error;
       
   679                 }
       
   680     
       
   681             status = m_am_tools->convert_hex_ascii_to_bytes(
       
   682                     m_wapi_preshared_key.get_data(m_wapi_preshared_key.get_data_length()),
       
   683                     m_wapi_preshared_key.get_data_length(),
       
   684                     m_wapi_psk.get_data(target_length),
       
   685                     &target_length);
       
   686             
       
   687             if (status != eap_status_ok
       
   688                     || target_length != (m_wapi_preshared_key.get_data_length()/2))
       
   689                     {
       
   690                     EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("convert_hex_ascii_to_bytes NOT OK \n")));
       
   691                     send_error_notification(eap_status_key_error);
       
   692                     wlan_settings->Disconnect();                            
       
   693                     EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   694                     CleanupStack::PopAndDestroy(wlan_settings);
       
   695                    return eap_status_key_error;
       
   696                     }
       
   697                 
       
   698             status = wapi_psk->set_copy_of_buffer(&m_wapi_psk);
       
   699             if (status != eap_status_ok)
       
   700                 {
       
   701                 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("set_copy_of_buffer NOT OK \n")));
       
   702                 send_error_notification(eap_status_key_error);
       
   703                 wlan_settings->Disconnect();                            
       
   704                 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   705                 CleanupStack::PopAndDestroy(wlan_settings); 
       
   706                 return eap_status_key_error;
       
   707                 }
       
   708             }
       
   709         else
       
   710             {
       
   711             EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("PSK ASCII\n")));
       
   712             m_wapi_psk.reset();
       
   713             wapi_psk->reset();
       
   714 
       
   715             status = m_wapi_psk.set_copy_of_buffer(&m_wapi_preshared_key);
       
   716             if (status != eap_status_ok)
       
   717                 {
       
   718                 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("set_copy_of_buffer NOT OK \n")));
       
   719                 send_error_notification(eap_status_key_error);
       
   720                 wlan_settings->Disconnect();                            
       
   721                 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   722                 CleanupStack::PopAndDestroy(wlan_settings); 
       
   723                 return eap_status_key_error;
       
   724                 }
       
   725             
       
   726             status = wapi_psk->set_copy_of_buffer(&m_wapi_psk); 
       
   727             if (status != eap_status_ok)
       
   728                 {
       
   729                 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("set_copy_of_buffer NOT OK \n")));
       
   730                 send_error_notification(eap_status_key_error);
       
   731                 wlan_settings->Disconnect();                            
       
   732                 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   733                 CleanupStack::PopAndDestroy(wlan_settings); 
       
   734                return eap_status_key_error;
       
   735                 }
       
   736             }
       
   737     
       
   738         EAP_TRACE_DATA_DEBUG(
       
   739                 m_am_tools,
       
   740                 TRACE_FLAGS_DEFAULT,
       
   741                 (EAPL("new WPA-PSK SSID"),
       
   742                         m_SSID.get_data(),
       
   743                         m_SSID.get_data_length()));
       
   744         
       
   745         EAP_TRACE_DATA_DEBUG(
       
   746                 m_am_tools,
       
   747                 TRACE_FLAGS_DEFAULT,
       
   748                 (EAPL("new WPA-PSK preshared key"),
       
   749                 m_wapi_preshared_key.get_data(),
       
   750                 m_wapi_preshared_key.get_data_length()));
       
   751             
       
   752         EAP_TRACE_DATA_DEBUG(
       
   753                 m_am_tools,
       
   754                 TRACE_FLAGS_DEFAULT,
       
   755                 (EAPL("new WPA-PSK hash"),
       
   756                 m_wapi_psk.get_data(),
       
   757                 m_wapi_psk.get_data_length()));
       
   758     
       
   759         CleanupStack::PopAndDestroy(wlan_settings);
       
   760         }
       
   761     
       
   762     EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   763     return status;
       
   764 
       
   765     }
       
   766                                                          
       
   767 //--------------------------------------------------
       
   768 
       
   769 EAP_FUNC_EXPORT eap_status_e wapi_am_wlan_authentication_symbian_c::authentication_finished(
       
   770 	const bool when_true_successfull,
       
   771 	const eapol_key_authentication_type_e authentication_type)
       
   772 {
       
   773 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   774 
       
   775 	EAP_TRACE_DEBUG(
       
   776 		m_am_tools, 
       
   777 		TRACE_FLAGS_DEFAULT, 
       
   778 		(EAPL("wapi_am_wlan_authentication_symbian_c::authentication_finished(): %s, this = 0x%08x => 0x%08x\n"),
       
   779 		 (m_is_client == true) ? "client": "server",
       
   780 		 this,
       
   781 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
       
   782 
       
   783 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   784 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   785 }
       
   786 
       
   787 //--------------------------------------------------
       
   788 
       
   789 eap_status_e wapi_am_wlan_authentication_symbian_c::read_database_reference_values(
       
   790 	TIndexType * const type,
       
   791 	TUint * const index)
       
   792 {
       
   793 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   794 
       
   795 	EAP_TRACE_DEBUG(
       
   796 		m_am_tools, 
       
   797 		TRACE_FLAGS_DEFAULT, 
       
   798 		(EAPL("wapi_am_wlan_authentication_symbian_c::read_database_reference_values(): %s, this = 0x%08x => 0x%08x\n"),
       
   799 		 (m_is_client == true) ? "client": "server",
       
   800 		 this,
       
   801 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
       
   802 
       
   803 	eap_variable_data_c database_reference(m_am_tools);
       
   804 
       
   805 	eap_status_e status = m_wlan_database_reference->get_wlan_database_reference_values(&database_reference);
       
   806 	if (status != eap_status_ok)
       
   807 	{
       
   808 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   809 		return EAP_STATUS_RETURN(m_am_tools, status);
       
   810 	}
       
   811 
       
   812 	const eapol_wlan_database_reference_values_s * const database_reference_values
       
   813 		= reinterpret_cast<eapol_wlan_database_reference_values_s *>(
       
   814 		database_reference.get_data(sizeof(eapol_wlan_database_reference_values_s)));
       
   815 	if (database_reference_values == 0)
       
   816 	{
       
   817 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   818 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   819 	}
       
   820 
       
   821 	*type = static_cast<TIndexType>(database_reference_values->m_database_index_type);
       
   822 	*index = database_reference_values->m_database_index;
       
   823 
       
   824 	EAP_TRACE_DEBUG(
       
   825 		m_am_tools,
       
   826 		TRACE_FLAGS_DEFAULT,
       
   827 		(EAPL("wapi_am_wlan_authentication_symbian_c::read_database_reference_values(): Type=%d, Index=%d.\n"),
       
   828 		 *type,
       
   829 		 *index));
       
   830 
       
   831 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   832 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   833 }
       
   834 
       
   835 //--------------------------------------------------
       
   836 
       
   837 
       
   838 //--------------------------------------------------
       
   839 
       
   840 EAP_FUNC_EXPORT eap_status_e wapi_am_wlan_authentication_symbian_c::read_configure(
       
   841 	const eap_configuration_field_c * const field,
       
   842 	eap_variable_data_c * const data)
       
   843 {
       
   844 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   845 	EAP_ASSERT_ALWAYS(data != NULL);
       
   846 	
       
   847 	EAP_TRACE_DEBUG(
       
   848 		m_am_tools, 
       
   849 		TRACE_FLAGS_DEFAULT, 
       
   850 		(EAPL("wapi_am_wlan_authentication_symbian_c::read_configure(): %s, this = 0x%08x => 0x%08x\n"),
       
   851 		 (m_is_client == true) ? "client": "server",
       
   852 		 this,
       
   853 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
       
   854 	
       
   855 	eap_status_e status(eap_status_ok);
       
   856 
       
   857 	eap_variable_data_c wanted_field(m_am_tools);
       
   858 	eap_variable_data_c type_field(m_am_tools);
       
   859 	
       
   860 	status = wanted_field.set_buffer(
       
   861 		field->get_field(),
       
   862 		field->get_field_length(),
       
   863 		false,
       
   864 		false);
       
   865 	if (status != eap_status_ok)
       
   866 	{
       
   867 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   868 		return status;
       
   869 	}
       
   870 	
       
   871 	TInt err = KErrNone;
       
   872 	HBufC8* asciibuf = NULL;
       
   873 	TRAP( err, asciibuf = HBufC8::NewL(128));
       
   874     if (err != KErrNone) 
       
   875         {
       
   876         EAP_TRACE_DEBUG(
       
   877             m_am_tools,
       
   878             TRACE_FLAGS_DEFAULT,
       
   879             (EAPL("wapi_am_wlan_authentication_symbian_c::read_configure HBufC8::NewL LEAVE(): Type=%d.\n"),
       
   880                     err));
       
   881             status = m_am_tools->convert_am_error_to_eapol_error(err);
       
   882             EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   883             return status;
       
   884         }
       
   885    
       
   886     if((cf_str_WAPI_database_reference_index.get_field()->compare((m_am_tools), field)) == true)
       
   887         {
       
   888         if (iIapIndex == 0)
       
   889             {
       
   890             TIndexType index_type(ELan);
       
   891 
       
   892             eap_status_e status = read_database_reference_values(
       
   893                 &index_type,
       
   894                 &iIapIndex);
       
   895             if (status != eap_status_ok)
       
   896                 {
       
   897                 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   898                 User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
       
   899                 }
       
   900             else
       
   901                 {
       
   902                 status = data->set_copy_of_buffer(&iIapIndex, sizeof(iIapIndex));
       
   903                 if (status != eap_status_ok)
       
   904                     {
       
   905                     EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   906                     User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
       
   907                     }
       
   908                 
       
   909                  }
       
   910             }
       
   911         else
       
   912             {
       
   913             status = data->set_copy_of_buffer(&iIapIndex, sizeof(iIapIndex));
       
   914             if (status != eap_status_ok)
       
   915                 {
       
   916                 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   917                 User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
       
   918                 }
       
   919             }
       
   920         EAP_TRACE_DEBUG(
       
   921               m_am_tools,
       
   922               TRACE_FLAGS_DEFAULT,
       
   923               (EAPL("wapi_am_wlan_authentication_symbian_c::read_configure(): index = %d\n"), iIapIndex));
       
   924  
       
   925         }
       
   926 
       
   927     TPtr8 asciiString = asciibuf->Des();
       
   928     asciiString.Copy(reinterpret_cast<const unsigned char *>(field));
       
   929 
       
   930     eap_variable_data_c aConfigField(m_am_tools);
       
   931     aConfigField.set_copy_of_buffer(asciiString.Ptr(), asciiString.Size());
       
   932 
       
   933     if ((cf_str_WAPI_CORE_PSK.get_field()->compare((m_am_tools), field)) == true)
       
   934         {
       
   935         TRAP( err, ReadConfigureL(
       
   936             field->get_field(),
       
   937             field,
       
   938             field->get_field_length(),
       
   939             data) );
       
   940         }
       
   941     delete asciibuf; 
       
   942    
       
   943 	if (err != KErrNone) 
       
   944         {
       
   945         EAP_TRACE_DEBUG(
       
   946             m_am_tools,
       
   947             TRACE_FLAGS_DEFAULT,
       
   948             (EAPL("wapi_am_wlan_authentication_symbian_c::read_configure ReadConfigureL LEAVE(): Type=%d.\n"),
       
   949                     err));
       
   950             status = m_am_tools->convert_am_error_to_eapol_error(err);
       
   951 
       
   952 
       
   953 #if defined(USE_EAP_FILECONFIG)
       
   954 		if (m_fileconfig != 0
       
   955 			&& m_fileconfig->get_is_valid() == true)
       
   956 		    {
       
   957 			status = m_fileconfig->read_configure(
       
   958 				field,
       
   959 				data);
       
   960 		    }
       
   961 #endif //#if defined(USE_EAP_FILECONFIG)
       
   962         }
       
   963 	m_am_tools->trace_configuration(
       
   964 		status,
       
   965 		field,
       
   966 		data);
       
   967 
       
   968 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   969 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   970 }
       
   971 
       
   972 //--------------------------------------------------
       
   973 
       
   974 void wapi_am_wlan_authentication_symbian_c::ReadConfigureL(
       
   975 	eap_config_string fieldx,
       
   976 	const eap_configuration_field_c * const field,
       
   977 	const u32_t /*field_length*/,
       
   978 	eap_variable_data_c * const data)
       
   979 {	
       
   980 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   981 	
       
   982 	// Create a buffer for the ascii strings - initialised with the argument
       
   983 	HBufC8* asciibuf = HBufC8::NewLC(128);
       
   984 	TPtr8 asciiString = asciibuf->Des();
       
   985 	asciiString.Copy(reinterpret_cast<const unsigned char *>(field));
       
   986 		
       
   987 	// Buffer for unicode parameter
       
   988 	HBufC* unicodebuf = HBufC::NewLC(128);
       
   989 	TPtr unicodeString = unicodebuf->Des();
       
   990 	
       
   991 	// Convert to unicode 
       
   992 	unicodeString.Copy(asciiString);
       
   993 
       
   994     eap_variable_data_c aConfigField(m_am_tools);
       
   995 
       
   996     if ((cf_str_WAPI_CORE_PSK.get_field()->compare((m_am_tools), field)) == true )
       
   997         {
       
   998         if(m_wapi_psk.get_data_length()>0)
       
   999             {
       
  1000             data->set_copy_of_buffer(&m_wapi_psk);
       
  1001             }
       
  1002         else
       
  1003             {
       
  1004             GetWlanConfigurationL(&aConfigField);
       
  1005             data->set_copy_of_buffer(&aConfigField);
       
  1006             }
       
  1007         CleanupStack::PopAndDestroy(2); // 2 buffers
       
  1008         return;
       
  1009         }
       
  1010 
       
  1011 	CleanupStack::PopAndDestroy(2); // 2 buffers
       
  1012 
       
  1013 
       
  1014 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1015 }
       
  1016 
       
  1017 //--------------------------------------------------
       
  1018 
       
  1019 EAP_FUNC_EXPORT eap_status_e wapi_am_wlan_authentication_symbian_c::write_configure(
       
  1020 	const eap_configuration_field_c * const /* field */,
       
  1021 	eap_variable_data_c * const /* data */)
       
  1022 {
       
  1023 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1024 
       
  1025 	const eap_status_e status = eap_status_illegal_configure_field;
       
  1026 
       
  1027 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1028 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1029 }
       
  1030 
       
  1031 //--------------------------------------------------
       
  1032 
       
  1033 EAP_FUNC_EXPORT eap_status_e wapi_am_wlan_authentication_symbian_c::set_timer(
       
  1034 	abs_eap_base_timer_c * const p_initializer, 
       
  1035 	const u32_t p_id, 
       
  1036 	void * const p_data,
       
  1037 	const u32_t p_time_ms)
       
  1038 {
       
  1039 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1040 
       
  1041 	const eap_status_e status = m_am_tools->am_set_timer(
       
  1042 		p_initializer, 
       
  1043 		p_id, 
       
  1044 		p_data,
       
  1045 		p_time_ms);
       
  1046 
       
  1047 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1048 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1049 }
       
  1050 
       
  1051 //--------------------------------------------------
       
  1052 
       
  1053 EAP_FUNC_EXPORT eap_status_e wapi_am_wlan_authentication_symbian_c::cancel_timer(
       
  1054 	abs_eap_base_timer_c * const p_initializer, 
       
  1055 	const u32_t p_id)
       
  1056 {
       
  1057 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1058 
       
  1059 	const eap_status_e status = m_am_tools->am_cancel_timer(
       
  1060 		p_initializer, 
       
  1061 		p_id);
       
  1062 
       
  1063 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1064 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1065 }
       
  1066 
       
  1067 //--------------------------------------------------
       
  1068 
       
  1069 EAP_FUNC_EXPORT eap_status_e wapi_am_wlan_authentication_symbian_c::cancel_all_timers()
       
  1070 {
       
  1071 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1072 
       
  1073 	const eap_status_e status = m_am_tools->am_cancel_all_timers();
       
  1074 
       
  1075 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1076 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1077 }
       
  1078 
       
  1079 //--------------------------------------------------
       
  1080 
       
  1081 void wapi_am_wlan_authentication_symbian_c::RunL()
       
  1082 {
       
  1083 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
  1084 	EAP_TRACE_DEBUG(
       
  1085 		m_am_tools,
       
  1086 		TRACE_FLAGS_DEFAULT,
       
  1087 		(EAPL("wapi_am_wlan_authentication_symbian_c::RunL(): iStatus.Int() = %d\n"),
       
  1088 		iStatus.Int()));
       
  1089 
       
  1090 	if (iStatus.Int() != KErrNone)
       
  1091 	{
       
  1092 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1093 		return;
       
  1094 	}
       
  1095 
       
  1096 	// Authentication cancelled.
       
  1097 	EAP_TRACE_ALWAYS(
       
  1098 		m_am_tools,
       
  1099 		TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
       
  1100 		(EAPL("Authentication cancelled.\n")));
       
  1101 
       
  1102     eap_status_e status = m_am_partner->disassociation(
       
  1103         &m_receive_network_id);
       
  1104 
       
  1105     if (status != eap_status_ok)
       
  1106     {
       
  1107         EAP_TRACE_DEBUG(
       
  1108             m_am_tools,
       
  1109             TRACE_FLAGS_DEFAULT,
       
  1110             (EAPL("Disassociation failed in RunL().\n")));
       
  1111         EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1112         return;
       
  1113     }
       
  1114 
       
  1115     EAP_TRACE_ALWAYS(
       
  1116 		m_am_tools,
       
  1117 		TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
       
  1118 		(EAPL("Indication sent to WLM: EFailedCompletely.\n")));
       
  1119 
       
  1120 	   m_am_partner->wapi_indication(
       
  1121 	        &m_receive_network_id,
       
  1122 	        eapol_wlan_authentication_state_failed_completely);
       
  1123 
       
  1124 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
  1125 }
       
  1126 
       
  1127 //--------------------------------------------------
       
  1128 
       
  1129 void wapi_am_wlan_authentication_symbian_c::DoCancel()
       
  1130 {	
       
  1131 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1132 
       
  1133 	EAP_TRACE_DEBUG(
       
  1134 		m_am_tools,
       
  1135 		TRACE_FLAGS_DEFAULT,
       
  1136 		(EAPL("wapi_am_wlan_authentication_symbian_c::DoCancel()\n")));
       
  1137 
       
  1138 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
  1139 }
       
  1140 
       
  1141 //--------------------------------------------------
       
  1142 
       
  1143 EAP_FUNC_EXPORT wapi_am_wlan_authentication_c * wapi_am_wlan_authentication_c::new_wapi_am_wlan_authentication(
       
  1144 	abs_eap_am_tools_c * const tools,
       
  1145 	const bool is_client_when_true,
       
  1146 	const abs_eapol_wlan_database_reference_if_c * const wlan_database_reference)
       
  1147 {
       
  1148 	EAP_TRACE_BEGIN(tools, TRACE_FLAGS_DEFAULT);
       
  1149 
       
  1150 	wapi_am_wlan_authentication_c * const wauth = new wapi_am_wlan_authentication_symbian_c(
       
  1151 		tools,
       
  1152 		is_client_when_true,
       
  1153 		wlan_database_reference);
       
  1154 
       
  1155 	EAP_TRACE_END(tools, TRACE_FLAGS_DEFAULT);
       
  1156 	return wauth;
       
  1157 }
       
  1158 
       
  1159 
       
  1160 //--------------------------------------------------
       
  1161 // End.