eapol/eapol_framework/eapol_symbian/am/common/symbian/eap_am_tools_symbian.cpp
changeset 39 fe6b6762fccd
parent 33 938269283a16
child 49 43351a4f2da3
equal deleted inserted replaced
38:7a0216d033ac 39:fe6b6762fccd
     1 /*
     1 /*
     2 * Copyright (c) 2001-2006 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2001-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:  EAP and WLAN authentication protocols.
    14 * Description:  Tools for common code to run on Symbian.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 /*
    18 /*
    19 * %version: 32 %
    19 * %version: 36 %
    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
    32 #include <utf.h>
    32 #include <utf.h>
    33 
    33 
    34 #include "eap_am_tools_symbian.h"
    34 #include "eap_am_tools_symbian.h"
    35 #include "eap_am_types.h"
    35 #include "eap_am_types.h"
    36 #include "eap_automatic_variable.h"
    36 #include "eap_automatic_variable.h"
       
    37 #include "EapTraceSymbian.h"
    37 
    38 
    38 const TUint MAX_DB_TRANSACTION_RETRY_COUNT = 10;
    39 const TUint MAX_DB_TRANSACTION_RETRY_COUNT = 10;
    39 const u32_t EAP_TIMER_MAX_AFTER_TIME_MILLISECONDS_SYMBIAN = 2100000ul;
    40 const u32_t EAP_TIMER_MAX_AFTER_TIME_MILLISECONDS_SYMBIAN = 2100000ul;
    40 
    41 
    41 //--------------------------------------------------
    42 //--------------------------------------------------
    46 
    47 
    47 //--------------------------------------------------
    48 //--------------------------------------------------
    48 
    49 
    49 EAP_FUNC_EXPORT eap_am_tools_symbian_c::~eap_am_tools_symbian_c()
    50 EAP_FUNC_EXPORT eap_am_tools_symbian_c::~eap_am_tools_symbian_c()
    50 {
    51 {
       
    52     EAP_TRACE_DEBUG_SYMBIAN((_L("eap_am_tools_symbian_c::~eap_am_tools_symbian_c(): this=0x%08x"),
       
    53 		this));
       
    54 
       
    55 	EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: eap_am_tools_symbian_c::~eap_am_tools_symbian_c()"));
       
    56 
    51 	// If multithreading is used the log file is not kept open all the time
    57 	// If multithreading is used the log file is not kept open all the time
    52 	// so no need to close the handles here.
    58 	// so no need to close the handles here.
    53 #if defined(USE_EAP_FILE_TRACE)
    59 #if defined(USE_EAP_FILE_TRACE)
    54 #if !defined (USE_MULTITHREADING)
    60 #if !defined (USE_MULTITHREADING)
    55 	m_LogFile.Close();
    61 	m_LogFile.Close();
   108 	}
   114 	}
   109 
   115 
   110 	EAP_TRACE_DEBUG(
   116 	EAP_TRACE_DEBUG(
   111 		this,
   117 		this,
   112 		TRACE_FLAGS_DEFAULT,
   118 		TRACE_FLAGS_DEFAULT,
   113 		(EAPL("eap_am_tools_symbian_c::eap_am_tools_symbian_c()\n")));
   119 		(EAPL("eap_am_tools_symbian_c::eap_am_tools_symbian_c(): this = 0x%08x => 0x%08x\n"),
       
   120 		 this,
       
   121 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
   114 
   122 
   115 	EAP_TRACE_RETURN_STRING(this, "returns: eap_am_tools_symbian_c::eap_am_tools_symbian_c()");
   123 	EAP_TRACE_RETURN_STRING(this, "returns: eap_am_tools_symbian_c::eap_am_tools_symbian_c()");
   116 
   124 
   117 	if (m_crypto.get_is_valid() == false)
   125 	if (m_crypto.get_is_valid() == false)
   118 	{
   126 	{
   475 
   483 
   476 
   484 
   477 #if defined(USE_EAP_FILE_TRACE)
   485 #if defined(USE_EAP_FILE_TRACE)
   478 
   486 
   479 	#if defined (USE_MULTITHREADING)
   487 	#if defined (USE_MULTITHREADING)
       
   488 		RFs session;
       
   489 
   480 		if (m_filename.Length() > 0ul)
   490 		if (m_filename.Length() > 0ul)
   481 		{
   491 		{
   482 			RFs session;
       
   483 			
       
   484 			TInt result = session.Connect();	
   492 			TInt result = session.Connect();	
   485 			if (result != KErrNone)
   493 			if (result != KErrNone)
   486 			{
   494 			{
   487 				leave_trace_mutex();
   495 				leave_trace_mutex();
   488 				EAP_TRACE_END(this, TRACE_FLAGS_DEFAULT);
   496 				EAP_TRACE_END(this, TRACE_FLAGS_DEFAULT);
   833 //--------------------------------------------------
   841 //--------------------------------------------------
   834 
   842 
   835 //
   843 //
   836 EAP_FUNC_EXPORT u64_t eap_am_tools_symbian_c::get_clock_ticks_of_second()
   844 EAP_FUNC_EXPORT u64_t eap_am_tools_symbian_c::get_clock_ticks_of_second()
   837 {
   845 {
   838 	return 1000000u;
   846 	const u64_t COUNT_OF_CLOCK_TICS_IN_ONE_SECOND = 1000000ul;
       
   847 	return COUNT_OF_CLOCK_TICS_IN_ONE_SECOND;
   839 }
   848 }
   840 
   849 
   841 //--------------------------------------------------
   850 //--------------------------------------------------
   842 
   851 
   843 /**
   852 /**
   974 EAP_FUNC_EXPORT void eap_am_tools_symbian_c::enter_crypto_cs()
   983 EAP_FUNC_EXPORT void eap_am_tools_symbian_c::enter_crypto_cs()
   975 {
   984 {
   976 
   985 
   977 }
   986 }
   978 
   987 
       
   988 //--------------------------------------------------
       
   989 
   979 EAP_FUNC_EXPORT void eap_am_tools_symbian_c::leave_crypto_cs()
   990 EAP_FUNC_EXPORT void eap_am_tools_symbian_c::leave_crypto_cs()
   980 {
   991 {
   981 
   992 
   982 }
   993 }
   983 
   994 
   994 {
  1005 {
   995 	After(limit_microsecond_timeout(milli_seconds));
  1006 	After(limit_microsecond_timeout(milli_seconds));
   996 }
  1007 }
   997 
  1008 
   998 //--------------------------------------------------
  1009 //--------------------------------------------------
       
  1010 
   999 EAP_FUNC_EXPORT u32_t eap_am_tools_symbian_c::get_gmt_unix_time()
  1011 EAP_FUNC_EXPORT u32_t eap_am_tools_symbian_c::get_gmt_unix_time()
  1000 {
  1012 {
  1001 	_LIT(KStart, "19700000:000000.000000");
  1013 	_LIT(KStart, "19700000:000000.000000");
  1002 	TTime start(KStart);
  1014 	TTime start(KStart);
  1003 	TTime now;
  1015 	TTime now;
  1004 	now.UniversalTime();
  1016 	now.UniversalTime();
  1005 	TTimeIntervalSeconds interval;
  1017 	TTimeIntervalSeconds interval;
  1006 	now.SecondsFrom(start, interval);
  1018 	now.SecondsFrom(start, interval);
  1007 	return interval.Int();
  1019 	return interval.Int();
  1008 }
  1020 }
       
  1021 
  1009 //--------------------------------------------------
  1022 //--------------------------------------------------
  1010 
  1023 
  1011 EAP_FUNC_EXPORT bool eap_am_tools_symbian_c::get_is_valid() const
  1024 EAP_FUNC_EXPORT bool eap_am_tools_symbian_c::get_is_valid() const
  1012 {
  1025 {
  1013 	return m_is_valid;
  1026 	return m_is_valid;
  1018 EAP_FUNC_EXPORT eap_status_e eap_am_tools_symbian_c::convert_am_error_to_eapol_error(const i32_t aErr)
  1031 EAP_FUNC_EXPORT eap_status_e eap_am_tools_symbian_c::convert_am_error_to_eapol_error(const i32_t aErr)
  1019 {
  1032 {
  1020 	EAP_TRACE_DEBUG(
  1033 	EAP_TRACE_DEBUG(
  1021 		this,
  1034 		this,
  1022 		TRACE_FLAGS_DEFAULT,
  1035 		TRACE_FLAGS_DEFAULT,
  1023 		(EAPL("eap_am_tools_symbian_c::convert_am_error_to_eapol_error: error=%d\n"),
  1036 		(EAPL("eap_status_e eap_am_tools_symbian_c::convert_am_error_to_eapol_error(): error=%d\n"),
  1024 		aErr));
  1037 		aErr));
  1025 
  1038 
  1026 	eap_status_e status;
  1039 	eap_status_e status;
  1027 	switch (aErr)
  1040 	switch (aErr)
  1028 	{
  1041 	{
  1094 		break;		
  1107 		break;		
  1095 	}
  1108 	}
  1096 	return status;
  1109 	return status;
  1097 }
  1110 }
  1098 
  1111 
       
  1112 //--------------------------------------------------
       
  1113 
  1099 EAP_FUNC_EXPORT i32_t eap_am_tools_symbian_c::convert_eapol_error_to_am_error(eap_status_e aErr)
  1114 EAP_FUNC_EXPORT i32_t eap_am_tools_symbian_c::convert_eapol_error_to_am_error(eap_status_e aErr)
  1100 {
  1115 {
  1101 	EAP_TRACE_DEBUG(
  1116 	EAP_TRACE_DEBUG(
  1102 		this,
  1117 		this,
  1103 		TRACE_FLAGS_DEFAULT,
  1118 		TRACE_FLAGS_DEFAULT,
  1104 		(EAPL("eap_am_tools_symbian_c::convert_am_error_to_eapol_error: error=%d\n"),
  1119 		(EAPL("eap_am_tools_symbian_c::convert_eapol_error_to_am_error(): error=%d\n"),
  1105 		aErr));
  1120 		aErr));
  1106 
  1121 
  1107 	TInt status;
  1122 	TInt status;
  1108 	switch (aErr)
  1123 	switch (aErr)
  1109 	{
  1124 	{
  1314 		TRACE_FLAGS_DEFAULT, 
  1329 		TRACE_FLAGS_DEFAULT, 
  1315 		(EAPL("eap_am_tools_symbian_c::shutdown(): this = 0x%08x => 0x%08x, "),
  1330 		(EAPL("eap_am_tools_symbian_c::shutdown(): this = 0x%08x => 0x%08x, "),
  1316 		 this,
  1331 		 this,
  1317 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
  1332 		 dynamic_cast<abs_eap_base_timer_c *>(this)));
  1318 
  1333 
       
  1334 	// Note, tools cannot be used to trace on return.
       
  1335 	EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: eap_am_tools_symbian_c::shutdown()"));
       
  1336 
  1319 	StopTimer();
  1337 	StopTimer();
  1320 	
  1338 	
  1321 	return eap_am_tools_c::shutdown_am_tools();
  1339 	return eap_am_tools_c::shutdown_am_tools();
  1322 }
  1340 }
  1323 
  1341 
  1563 //--------------------------------------------------
  1581 //--------------------------------------------------
  1564 //--------------------------------------------------
  1582 //--------------------------------------------------
  1565 
  1583 
  1566 EAP_FUNC_EXPORT_INTERFACE abs_eap_am_tools_c * abs_eap_am_tools_c::new_abs_eap_am_tools_c()
  1584 EAP_FUNC_EXPORT_INTERFACE abs_eap_am_tools_c * abs_eap_am_tools_c::new_abs_eap_am_tools_c()
  1567 {
  1585 {
       
  1586     EAP_TRACE_DEBUG_SYMBIAN((_L("abs_eap_am_tools_c::new_abs_eap_am_tools_c()")));
       
  1587 
       
  1588 	EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: abs_eap_am_tools_c::new_abs_eap_am_tools_c()"));
       
  1589 
  1568 	abs_eap_am_tools_c *am_tools = new eap_am_tools_symbian_c(EAP_DEFAULT_TRACE_FILE);
  1590 	abs_eap_am_tools_c *am_tools = new eap_am_tools_symbian_c(EAP_DEFAULT_TRACE_FILE);
  1569 
  1591 
  1570 	if (am_tools != 0)
  1592 	if (am_tools != 0)
  1571 	{
  1593 	{
  1572 		eap_status_e status = am_tools->configure();
  1594 		eap_status_e status = am_tools->configure();
  1591 
  1613 
  1592 //--------------------------------------------------
  1614 //--------------------------------------------------
  1593 
  1615 
  1594 EAP_FUNC_EXPORT_INTERFACE void abs_eap_am_tools_c::delete_abs_eap_am_tools_c(abs_eap_am_tools_c * const am_tools)
  1616 EAP_FUNC_EXPORT_INTERFACE void abs_eap_am_tools_c::delete_abs_eap_am_tools_c(abs_eap_am_tools_c * const am_tools)
  1595 {
  1617 {
       
  1618     EAP_TRACE_DEBUG_SYMBIAN((_L("abs_eap_am_tools_c::delete_abs_eap_am_tools_c()")));
       
  1619 
       
  1620 	EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: abs_eap_am_tools_c::delete_abs_eap_am_tools_c()"));
       
  1621 
  1596 	if (am_tools != 0)
  1622 	if (am_tools != 0)
  1597 		{
  1623 		{
  1598 		EAP_TRACE_DEBUG(
  1624 		EAP_TRACE_DEBUG(
  1599 			am_tools,
  1625 			am_tools,
  1600 			TRACE_FLAGS_TIMER,
  1626 			TRACE_FLAGS_TIMER,