--- a/eapol/eapol_framework/eapol_symbian/am/common/symbian/eap_am_tools_symbian.cpp Thu Aug 19 09:58:27 2010 +0300
+++ b/eapol/eapol_framework/eapol_symbian/am/common/symbian/eap_am_tools_symbian.cpp Tue Aug 31 15:16:37 2010 +0300
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2001-2006 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2001-2010 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of the License "Eclipse Public License v1.0"
@@ -11,12 +11,12 @@
*
* Contributors:
*
-* Description: EAP and WLAN authentication protocols.
+* Description: Tools for common code to run on Symbian.
*
*/
/*
-* %version: 22.1.3 %
+* %version: 36 %
*/
// This is enumeration of EAPOL source code.
@@ -28,11 +28,13 @@
#endif //#if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
+#include <e32math.h>
+#include <utf.h>
#include "eap_am_tools_symbian.h"
#include "eap_am_types.h"
-#include <e32math.h>
-#include <utf.h>
+#include "eap_automatic_variable.h"
+#include "EapTraceSymbian.h"
const TUint MAX_DB_TRANSACTION_RETRY_COUNT = 10;
const u32_t EAP_TIMER_MAX_AFTER_TIME_MILLISECONDS_SYMBIAN = 2100000ul;
@@ -47,6 +49,11 @@
EAP_FUNC_EXPORT eap_am_tools_symbian_c::~eap_am_tools_symbian_c()
{
+ EAP_TRACE_DEBUG_SYMBIAN((_L("eap_am_tools_symbian_c::~eap_am_tools_symbian_c(): this=0x%08x"),
+ this));
+
+ EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: eap_am_tools_symbian_c::~eap_am_tools_symbian_c()"));
+
// If multithreading is used the log file is not kept open all the time
// so no need to close the handles here.
#if defined(USE_EAP_FILE_TRACE)
@@ -63,6 +70,7 @@
EAP_FUNC_EXPORT eap_am_tools_symbian_c::eap_am_tools_symbian_c(eap_const_string /*pfilename*/)
: eap_am_tools_c()
, CTimer(CTimer::EPriorityStandard)
+ , m_prefix_string(this)
, m_start_ticks(0)
, m_directory_exists(false)
, m_crypto(this)
@@ -79,16 +87,40 @@
#if defined(USE_EAP_HARDWARE_TRACE)
set_trace_mask(
- eap_am_tools_c::eap_trace_mask_always
- | eap_am_tools_c::eap_trace_mask_error
+ TRACE_FLAGS_ALWAYS
+ | TRACE_FLAGS_ERROR
| eap_am_tools_c::eap_trace_mask_debug
- | eap_am_tools_c::eap_trace_mask_message_data);
+ | EAP_TRACE_FLAGS_MESSAGE_DATA
+ | TRACE_FLAGS_TIMER
+ | TRACE_FLAGS_TIMER_QUEUE);
#endif //#if defined(USE_EAP_HARDWARE_TRACE)
+ const u8_t DEFAULT_PREFIX[] = "EAPOL";
+
+ eap_status_e status = m_prefix_string.set_copy_of_buffer(DEFAULT_PREFIX, sizeof(DEFAULT_PREFIX)-1ul);;
+ if (status != eap_status_ok)
+ {
+ EAP_TRACE_END(this, TRACE_FLAGS_DEFAULT);
+ (void)EAP_STATUS_RETURN(this, status);
+ return;
+ }
+
+ status = m_prefix_string.add_end_null();
+ if (status != eap_status_ok)
+ {
+ EAP_TRACE_END(this, TRACE_FLAGS_DEFAULT);
+ (void)EAP_STATUS_RETURN(this, status);
+ return;
+ }
+
EAP_TRACE_DEBUG(
this,
TRACE_FLAGS_DEFAULT,
- (EAPL("eap_am_tools_symbian_c::eap_am_tools_symbian_c()\n")));
+ (EAPL("eap_am_tools_symbian_c::eap_am_tools_symbian_c(): this = 0x%08x => 0x%08x\n"),
+ this,
+ dynamic_cast<abs_eap_base_timer_c *>(this)));
+
+ EAP_TRACE_RETURN_STRING(this, "returns: eap_am_tools_symbian_c::eap_am_tools_symbian_c()");
if (m_crypto.get_is_valid() == false)
{
@@ -160,6 +192,8 @@
TRACE_FLAGS_DEFAULT,
(EAPL("eap_am_tools_symbian_c::configure()\n")));
+ EAP_TRACE_RETURN_STRING(this, "returns: eap_am_tools_symbian_c::configure()");
+
if (m_configure_called == true)
{
return EAP_STATUS_RETURN(this, eap_status_ok);
@@ -167,10 +201,12 @@
#if defined(USE_EAP_HARDWARE_TRACE)
set_trace_mask(
- eap_am_tools_c::eap_trace_mask_always
- | eap_am_tools_c::eap_trace_mask_error
+ TRACE_FLAGS_ALWAYS
+ | TRACE_FLAGS_ERROR
| eap_am_tools_c::eap_trace_mask_debug
- | eap_am_tools_c::eap_trace_mask_message_data);
+ | EAP_TRACE_FLAGS_MESSAGE_DATA
+ | TRACE_FLAGS_TIMER
+ | TRACE_FLAGS_TIMER_QUEUE);
#endif //#if defined(USE_EAP_HARDWARE_TRACE)
m_start_ticks = get_clock_ticks();
@@ -379,23 +415,28 @@
TInt64 _hours = _minutes / _div_60;
_minutes = _minutes - _hours* _div_60;
- _LIT8(KFormat1, "%02d:%02d:%02d.%06d:EAPOL:");
+ _LIT8(KFormat1, "%02d:%02d:%02d.%06d:%s:");
m_trace_buf.Format(
KFormat1,
static_cast<TInt32>(_hours),
static_cast<TInt32>(_minutes),
static_cast<TInt32>(_seconds),
- static_cast<TInt32>(_micro_seconds));
+ static_cast<TInt32>(_micro_seconds),
+ m_prefix_string.get_data());
}
}
else
{
- _LIT8(KFormat2, "%08x%08x:EAPOL:");
+ _LIT8(KFormat2, "%08x%08x:%s:");
u32_t *time_stamp_u32_t = reinterpret_cast<u32_t *>(&time_stamp);
- m_trace_buf.Format(KFormat2, time_stamp_u32_t[1], time_stamp_u32_t[0]);
+ m_trace_buf.Format(
+ KFormat2,
+ time_stamp_u32_t[1],
+ time_stamp_u32_t[0],
+ m_prefix_string.get_data());
}
VA_LIST args = {0,};
@@ -444,10 +485,10 @@
#if defined(USE_EAP_FILE_TRACE)
#if defined (USE_MULTITHREADING)
+ RFs session;
+
if (m_filename.Length() > 0ul)
{
- RFs session;
-
TInt result = session.Connect();
if (result != KErrNone)
{
@@ -517,6 +558,35 @@
return m_run_thread;
}
+//--------------------------------------------------
+
+//
+EAP_FUNC_EXPORT eap_status_e eap_am_tools_symbian_c::set_trace_prefix(
+ const eap_variable_data_c * const prefix8bit)
+{
+ EAP_TRACE_BEGIN(this, TRACE_FLAGS_DEFAULT);
+
+ enter_trace_mutex();
+
+ eap_status_e status = m_prefix_string.set_copy_of_buffer(prefix8bit);
+ if (status != eap_status_ok)
+ {
+ EAP_TRACE_END(this, TRACE_FLAGS_DEFAULT);
+ return EAP_STATUS_RETURN(this, status);
+ }
+
+ status = m_prefix_string.add_end_null();
+ if (status != eap_status_ok)
+ {
+ EAP_TRACE_END(this, TRACE_FLAGS_DEFAULT);
+ return EAP_STATUS_RETURN(this, status);
+ }
+
+ leave_trace_mutex();
+
+ EAP_TRACE_END(this, TRACE_FLAGS_DEFAULT);
+ return eap_status_ok;
+}
//--------------------------------------------------
@@ -524,14 +594,23 @@
EAP_FUNC_EXPORT eap_status_e eap_am_tools_symbian_c::set_trace_file_name(
const eap_variable_data_c * const trace_output_file)
{
+ EAP_TRACE_DEBUG(
+ this,
+ TRACE_FLAGS_DEFAULT,
+ (EAPL("eap_am_tools_symbian_c::set_trace_file_name()")));
+
+ EAP_TRACE_RETURN_STRING(this, "returns: eap_am_tools_symbian_c::set_trace_file_name()");
+
EAP_TRACE_BEGIN(this, TRACE_FLAGS_DEFAULT);
EAP_UNREFERENCED_PARAMETER(trace_output_file);
#if defined(USE_EAP_FILE_TRACE)
#if defined(USE_EAP_TRACE) || defined(USE_EAP_TRACE_ALWAYS)
+
TBuf8<64> tmpFilename((TUint8 *)trace_output_file->get_data(trace_output_file->get_data_length()));
tmpFilename.SetLength(trace_output_file->get_data_length());
+
enter_trace_mutex();
m_filename.Copy(tmpFilename);
@@ -764,7 +843,8 @@
//
EAP_FUNC_EXPORT u64_t eap_am_tools_symbian_c::get_clock_ticks_of_second()
{
- return 1000000u;
+ const u64_t COUNT_OF_CLOCK_TICS_IN_ONE_SECOND = 1000000ul;
+ return COUNT_OF_CLOCK_TICS_IN_ONE_SECOND;
}
//--------------------------------------------------
@@ -905,6 +985,8 @@
}
+//--------------------------------------------------
+
EAP_FUNC_EXPORT void eap_am_tools_symbian_c::leave_crypto_cs()
{
@@ -921,10 +1003,11 @@
EAP_FUNC_EXPORT void eap_am_tools_symbian_c::sleep(u32_t milli_seconds)
{
- User::After(limit_microsecond_timeout(milli_seconds));
+ After(limit_microsecond_timeout(milli_seconds));
}
//--------------------------------------------------
+
EAP_FUNC_EXPORT u32_t eap_am_tools_symbian_c::get_gmt_unix_time()
{
_LIT(KStart, "19700000:000000.000000");
@@ -935,6 +1018,7 @@
now.SecondsFrom(start, interval);
return interval.Int();
}
+
//--------------------------------------------------
EAP_FUNC_EXPORT bool eap_am_tools_symbian_c::get_is_valid() const
@@ -949,7 +1033,7 @@
EAP_TRACE_DEBUG(
this,
TRACE_FLAGS_DEFAULT,
- (EAPL("eap_am_tools_symbian_c::convert_am_error_to_eapol_error: error=%d\n"),
+ (EAPL("eap_status_e eap_am_tools_symbian_c::convert_am_error_to_eapol_error(): error=%d\n"),
aErr));
eap_status_e status;
@@ -1025,12 +1109,14 @@
return status;
}
+//--------------------------------------------------
+
EAP_FUNC_EXPORT i32_t eap_am_tools_symbian_c::convert_eapol_error_to_am_error(eap_status_e aErr)
{
EAP_TRACE_DEBUG(
this,
TRACE_FLAGS_DEFAULT,
- (EAPL("eap_am_tools_symbian_c::convert_am_error_to_eapol_error: error=%d\n"),
+ (EAPL("eap_am_tools_symbian_c::convert_eapol_error_to_am_error(): error=%d\n"),
aErr));
TInt status;
@@ -1058,6 +1144,7 @@
status = KErrCompletion;
break;
+ case eap_status_not_found:
case eap_status_illegal_configure_field:
status = KErrNotFound;
break;
@@ -1157,7 +1244,7 @@
// Wait 0 - 524287 microseconds
randomWait = randomWait & 0x7ffff;
- User::After(randomWait);
+ After(randomWait);
}
return EAP_STATUS_RETURN(this, status);
}
@@ -1192,7 +1279,7 @@
// Wait 0 - 524287 microseconds
randomWait = randomWait & 0x7ffff;
- User::After(randomWait);
+ After(randomWait);
}
return EAP_STATUS_RETURN(this, status);
}
@@ -1227,7 +1314,7 @@
// Wait 0 - 524287 microseconds
randomWait = randomWait & 0x7ffff;
- User::After(randomWait);
+ After(randomWait);
}
return EAP_STATUS_RETURN(this, status);
}
@@ -1244,6 +1331,9 @@
this,
dynamic_cast<abs_eap_base_timer_c *>(this)));
+ // Note, tools cannot be used to trace on return.
+ EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: eap_am_tools_symbian_c::shutdown()"));
+
StopTimer();
return eap_am_tools_c::shutdown_am_tools();
@@ -1493,6 +1583,10 @@
EAP_FUNC_EXPORT_INTERFACE abs_eap_am_tools_c * abs_eap_am_tools_c::new_abs_eap_am_tools_c()
{
+ EAP_TRACE_DEBUG_SYMBIAN((_L("abs_eap_am_tools_c::new_abs_eap_am_tools_c()")));
+
+ EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: abs_eap_am_tools_c::new_abs_eap_am_tools_c()"));
+
abs_eap_am_tools_c *am_tools = new eap_am_tools_symbian_c(EAP_DEFAULT_TRACE_FILE);
if (am_tools != 0)
@@ -1509,7 +1603,7 @@
EAP_TRACE_DEBUG(
am_tools,
TRACE_FLAGS_TIMER,
- (EAPL("abs_eap_am_tools_c::new_abs_eap_am_tools_c() => 0x%08x success\n"),
+ (EAPL("abs_eap_am_tools_c::new_abs_eap_am_tools_c(0x%08x): success\n"),
am_tools));
}
}
@@ -1521,15 +1615,22 @@
EAP_FUNC_EXPORT_INTERFACE void abs_eap_am_tools_c::delete_abs_eap_am_tools_c(abs_eap_am_tools_c * const am_tools)
{
- EAP_TRACE_DEBUG(
- am_tools,
- TRACE_FLAGS_TIMER,
- (EAPL("abs_eap_am_tools_c::delete_abs_eap_am_tools_c(0x%08x)\n"),
- am_tools));
+ EAP_TRACE_DEBUG_SYMBIAN((_L("abs_eap_am_tools_c::delete_abs_eap_am_tools_c()")));
+
+ EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: abs_eap_am_tools_c::delete_abs_eap_am_tools_c()"));
- (void)am_tools->shutdown();
-
- delete am_tools;
+ if (am_tools != 0)
+ {
+ EAP_TRACE_DEBUG(
+ am_tools,
+ TRACE_FLAGS_TIMER,
+ (EAPL("abs_eap_am_tools_c::delete_abs_eap_am_tools_c(0x%08x)\n"),
+ am_tools));
+
+ (void)am_tools->shutdown();
+
+ delete am_tools;
+ }
}
//--------------------------------------------------