eapol/eapol_framework/eapol_symbian/am/common/symbian/eap_am_trace_symbian.cpp
branchRCL_3
changeset 18 bad0cc58d154
parent 2 1c7bc153c08e
child 19 c74b3d9f6b9e
equal deleted inserted replaced
17:30e048a7b597 18:bad0cc58d154
     1 /*
     1 /*
     2 * Copyright (c) 2001-2005 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:  Trace functions on Symbian.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 /*
    18 /*
    19 * %version: 7.1.3 %
    19 * %version: 16 %
    20 */
    20 */
    21 
    21 
    22 #if defined(_DEBUG) || defined(DEBUG)
    22 #include "EapTraceSymbian.h"
    23 
    23 #include "eap_tools.h"
    24 #include "eap_am_trace_symbian.h"
    24 
    25 
    25 const TInt KMaxBufferSize = 512;
    26 const TInt KMaxBufferSize = 256;
    26 
    27 
    27 //-------------------------------------------------------------------------
    28 u8_t octet_to_ascii(i32_t octet)
    28 
       
    29 TUint8 octet_to_ascii(i32_t octet)
    29 {
    30 {
    30 	if (0 <= octet && octet <= 9)
    31 	if (0 <= octet && octet <= 9)
    31 	{
    32 	{
    32 		return static_cast<u8_t>('0' + octet);
    33 		return static_cast<TUint8>('0' + octet);
    33 	}
    34 	}
    34 	else if (10 <= octet && octet <= 16)
    35 	else if (10 <= octet && octet <= 16)
    35 	{
    36 	{
    36 		return static_cast<u8_t>('a' + (octet-10u));
    37 		return static_cast<TUint8>('a' + (octet-10u));
    37 	}
    38 	}
    38 	else
    39 	else
    39 	{
    40 	{
    40 		return 0;
    41 		return 0;
    41 	}
    42 	}
    42 }
    43 }
    43 
    44 
    44 void formatted_print(eap_format_string format, ...)
    45 //-------------------------------------------------------------------------
       
    46 
       
    47 void formatted_print(const char * const format, ...)
    45 {
    48 {
    46 	EAP_UNREFERENCED_PARAMETER(format);
    49 	EAP_UNREFERENCED_PARAMETER(format);
    47 
    50 
    48 #if defined(USE_EAP_TRACE) || defined(USE_EAP_TRACE_ALWAYS)
    51 #if defined(USE_EAP_TRACE) || defined(USE_EAP_TRACE_ALWAYS)
    49 
    52 
    74 	TPtr8 m_args_buf = args_buf->Des();
    77 	TPtr8 m_args_buf = args_buf->Des();
    75 	TPtr8 m_format_buf = format_buf->Des();
    78 	TPtr8 m_format_buf = format_buf->Des();
    76 	TPtr8 m_trace_buf = trace_buf->Des();
    79 	TPtr8 m_trace_buf = trace_buf->Des();
    77 	TPtr16 m_trace_buf_16 = trace_buf_16->Des();
    80 	TPtr16 m_trace_buf_16 = trace_buf_16->Des();
    78 
    81 
    79 	VA_LIST args;
    82 	VA_LIST args = {0, };
    80 	VA_START(args, format);
    83 	VA_START(args, format);
    81 	m_format_buf.Copy((const TUint8 *)format);
    84 	m_format_buf.Copy((const TUint8 *)format);
    82 	
    85 	
    83 	m_args_buf.FormatList(m_format_buf, args);
    86 	m_args_buf.FormatList(m_format_buf, args);
    84 	m_trace_buf.Append(m_args_buf);			
    87 	m_trace_buf.Append(m_args_buf);			
   109 		m_trace_buf_16.Copy(m_trace_buf);
   112 		m_trace_buf_16.Copy(m_trace_buf);
   110 
   113 
   111 		#if defined(USE_EAP_HARDWARE_TRACE_RAW_PRINT)
   114 		#if defined(USE_EAP_HARDWARE_TRACE_RAW_PRINT)
   112 			RDebug::RawPrint(m_trace_buf_16);
   115 			RDebug::RawPrint(m_trace_buf_16);
   113 		#else
   116 		#else
   114 			formatted_print(_L("%S"), &m_trace_buf_16);
   117 			RDebug::Print(_L("%S"), &m_trace_buf_16);
   115 		#endif //#if defined(USE_EAP_HARDWARE_TRACE_RAW_PRINT)
   118 		#endif //#if defined(USE_EAP_HARDWARE_TRACE_RAW_PRINT)
   116 	}
   119 	}
   117 
   120 
   118 #endif //#if defined(USE_EAP_HARDWARE_TRACE)
   121 #endif //#if defined(USE_EAP_HARDWARE_TRACE)
   119 
   122 
   124 
   127 
   125 #endif //#if defined(USE_EAP_TRACE) || defined(USE_EAP_TRACE_ALWAYS)
   128 #endif //#if defined(USE_EAP_TRACE) || defined(USE_EAP_TRACE_ALWAYS)
   126 
   129 
   127 }
   130 }
   128 
   131 
   129 
   132 //-------------------------------------------------------------------------
   130 void trace_data(
   133 
   131 	eap_const_string prefix,
   134 EXPORT_C void eap_trace_data_symbian(
       
   135 	const char * const prefix,
   132 	const void * const p_data,
   136 	const void * const p_data,
   133 	const u32_t data_length)
   137 	const TUint data_length)
   134 {
   138 {
   135 
   139 
   136 	u8_t* m_tmp_buffer = NULL;	
   140 	TUint8* m_tmp_buffer = NULL;	
   137 	u8_t* m_tmp_ascii_buffer = NULL;
   141 	TUint8* m_tmp_ascii_buffer = NULL;
   138 		
   142 		
   139 	m_tmp_buffer = new u8_t[KMaxBufferSize];	
   143 	m_tmp_buffer = new TUint8[KMaxBufferSize];	
   140 	m_tmp_ascii_buffer = new u8_t[KMaxBufferSize];
   144 	m_tmp_ascii_buffer = new TUint8[KMaxBufferSize];
   141 		
   145 		
   142 	if( m_tmp_buffer == NULL || m_tmp_ascii_buffer == NULL)
   146 	if( m_tmp_buffer == NULL || m_tmp_ascii_buffer == NULL)
   143 	{
   147 	{
   144 		// Not enough memory.
   148 		// Not enough memory.
   145 		RDebug::Print(_L("trace_data: ERROR - Not enough Memory!\n"));
   149 		RDebug::Print(_L("trace_data: ERROR - Not enough Memory!\n"));
   148 		delete [] m_tmp_ascii_buffer;
   152 		delete [] m_tmp_ascii_buffer;
   149 		
   153 		
   150 		return;
   154 		return;
   151 	}
   155 	}
   152 
   156 
   153 	u8_t *cursor = m_tmp_buffer;
   157 	TUint8 *cursor = m_tmp_buffer;
   154 	u8_t *cursor_ascii = m_tmp_ascii_buffer;
   158 	TUint8 *cursor_ascii = m_tmp_ascii_buffer;
   155 	
   159 	
   156 	const u8_t *data = reinterpret_cast<const u8_t *>(p_data);
   160 	const TUint8 *data = reinterpret_cast<const TUint8 *>(p_data);
   157 	u32_t ind;
   161 	TUint ind;
   158 	bool must_print = false;
   162 	bool must_print = false;
   159 	u32_t data_start = 0u;
   163 	TUint data_start = 0u;
   160 
   164 
   161 	const u32_t EAP_DATA_TRACE_BYTE_GROUP_SIZE = 1;
   165 	const TUint EAP_DATA_TRACE_BYTE_GROUP_SIZE = 1;
   162 	u32_t byte_group_size = EAP_DATA_TRACE_BYTE_GROUP_SIZE;
   166 	TUint byte_group_size = EAP_DATA_TRACE_BYTE_GROUP_SIZE;
   163 
   167 
   164 #if !defined(USE_EAP_DEBUG_TRACE)
   168 #if !defined(USE_EAP_DEBUG_TRACE)
   165 	// This does not trace the pointer of the data.
   169 	// This does not trace the pointer of the data.
   166 	formatted_print(
   170 	formatted_print(
   167 		"%s: data: %d (0x%x) bytes\n",
   171 		"%s: data: %d (0x%x) bytes\n",
   244 			m_tmp_ascii_buffer);
   248 			m_tmp_ascii_buffer);
   245 	}
   249 	}
   246 	
   250 	
   247 	delete [] m_tmp_buffer;
   251 	delete [] m_tmp_buffer;
   248 	delete [] m_tmp_ascii_buffer;
   252 	delete [] m_tmp_ascii_buffer;
       
   253 
       
   254 #if !defined(USE_EAP_DEBUG_TRACE)
       
   255 	// This does not trace the pointer of the data.
       
   256 	formatted_print(
       
   257 		"%s: data ends: %d (0x%x) bytes\n",
       
   258 		prefix,
       
   259 		data_length,
       
   260 		data_length);
       
   261 #else
       
   262 	formatted_print(
       
   263 		"%s: data ends 0x%08x: %d (0x%x) bytes\n",
       
   264 		prefix,
       
   265 		p_data,
       
   266 		data_length,
       
   267 		data_length);
       
   268 #endif
       
   269 
   249 }
   270 }
   250 
   271 
   251 #endif
   272 //-------------------------------------------------------------------------
   252 
       
   253 // End of file
   273 // End of file