eapol/eapol_framework/eapol_common/include/eap_tools.h
changeset 0 c8830336c852
child 2 1c7bc153c08e
equal deleted inserted replaced
-1:000000000000 0:c8830336c852
       
     1 /*
       
     2 * Copyright (c) 2001-2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  EAP and WLAN authentication protocols.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #if !defined( _EAP_TOOLS_H_ )
       
    22 #define _EAP_TOOLS_H_
       
    23 
       
    24 /** @file */
       
    25 
       
    26 #include "eap_am_compiler_flags.h"
       
    27 
       
    28 #include "eap_variable_data.h"
       
    29 #include "eap_status.h"
       
    30 #include "eap_am_export.h"
       
    31 
       
    32 #if defined(USE_EAP_STACK_TRACE) || defined(USE_EAP_ASSERT_STACK_TRACE)
       
    33 	#include "eap_am_stack_trace.h"
       
    34 #endif //#if defined(EAP_STACK_TRACE)
       
    35 
       
    36 
       
    37 //----------------------------------------------------------------------------------
       
    38 
       
    39 /**
       
    40  * This function changes 16-bit unsigned integer from host order to network order.
       
    41  */
       
    42 EAP_C_FUNC_IMPORT u16_t eap_htons(const u16_t value);
       
    43 
       
    44 /**
       
    45  * This function changes 32-bit unsigned integer from host order to network order.
       
    46  */
       
    47 EAP_C_FUNC_IMPORT u32_t eap_htonl(const u32_t value);
       
    48 
       
    49 /**
       
    50  * This function changes 64-bit unsigned integer from host order to network order.
       
    51  */
       
    52 EAP_C_FUNC_IMPORT u64_t eap_htonll(const u64_t value);
       
    53 
       
    54 
       
    55 /**
       
    56  * This function changes 16-bit unsigned integer from network order to host order.
       
    57  */
       
    58 #define eap_ntohs(addr) eap_htons(addr)
       
    59 
       
    60 /**
       
    61  * This function changes 32-bit unsigned integer from network order to host order.
       
    62  */
       
    63 #define eap_ntohl(addr) eap_htonl(addr)
       
    64 
       
    65 /**
       
    66  * This function changes 64-bit unsigned integer from network order to host order.
       
    67  */
       
    68 #define eap_ntohll(addr) eap_htonll(addr)
       
    69 
       
    70 
       
    71 /**
       
    72  * This function changes 16-bit unsigned integer from host order to little endian order.
       
    73  * This is used in some crypto algorithms.
       
    74  */
       
    75 EAP_C_FUNC_IMPORT u16_t eap_host_to_little_endian_short(const u16_t value);
       
    76 
       
    77 /**
       
    78  * This function changes 32-bit unsigned integer from host order to little endian order.
       
    79  * This is used in some crypto algorithms.
       
    80  */
       
    81 EAP_C_FUNC_IMPORT u32_t eap_host_to_little_endian_long(const u32_t value);
       
    82 
       
    83 /**
       
    84  * This function changes 64-bit unsigned integer from host order to little endian order.
       
    85  * This is used in some crypto algorithms.
       
    86  */
       
    87 EAP_C_FUNC_IMPORT u64_t eap_host_to_little_endian_long(const u64_t value);
       
    88 
       
    89 /**
       
    90  * This function write 16-bit unsigned integer which is in little endian order to memory.
       
    91  */
       
    92 EAP_C_FUNC_IMPORT eap_status_e eap_write_u16_t_little_endian_order(
       
    93 	void * const p_data,
       
    94 	const u32_t data_length,
       
    95 	const u16_t value);
       
    96 
       
    97 /**
       
    98  * This function write 32-bit unsigned integer which is in little endian order to memory.
       
    99  */
       
   100 EAP_C_FUNC_IMPORT eap_status_e eap_write_u32_t_little_endian_order(
       
   101 	void * const p_data,
       
   102 	const u32_t data_length,
       
   103 	const u32_t value);
       
   104 
       
   105 /**
       
   106  * This function write 64-bit unsigned integer which is in little endian order to memory.
       
   107  */
       
   108 EAP_C_FUNC_IMPORT eap_status_e eap_write_u64_t_little_endian_order(
       
   109 	void * const p_data,
       
   110 	const u32_t data_length,
       
   111 	const u64_t value);
       
   112 
       
   113 /**
       
   114  * This function reads 16-bit unsigned integer which is in little endian order from memory
       
   115  * and returns value in host order.
       
   116  */
       
   117 EAP_C_FUNC_IMPORT u16_t eap_read_u16_t_little_endian_order(
       
   118 	const void * const data,
       
   119 	const u32_t data_length);
       
   120 
       
   121 /**
       
   122  * This function reads 32-bit unsigned integer which is in little endian order from memory
       
   123  * and returns value in host order.
       
   124  */
       
   125 EAP_C_FUNC_IMPORT u32_t eap_read_u32_t_little_endian_order(
       
   126 	const void * const p_data,
       
   127 	const u32_t data_length);
       
   128 
       
   129 /**
       
   130  * This function reads 64-bit unsigned integer which is in little endian order from memory
       
   131  * and returns value in host order.
       
   132  */
       
   133 EAP_C_FUNC_IMPORT u64_t eap_read_u64_t_little_endian_order(
       
   134 	const void * const p_data,
       
   135 	const u32_t data_length);
       
   136 
       
   137 /**
       
   138  * This function reads 16-bit unsigned integer which is in network order from memory
       
   139  * and returns value in host order.
       
   140  */
       
   141 EAP_C_FUNC_IMPORT u16_t eap_read_u16_t_network_order(
       
   142 	const void * const data,
       
   143 	const u32_t data_length);
       
   144 
       
   145 /**
       
   146  * This function reads 24-bit unsigned integer which is in network order from memory
       
   147  * and returns it in 32-bit value in host order.
       
   148  */
       
   149 EAP_C_FUNC_IMPORT u32_t eap_read_u24_t_network_order(
       
   150 	const void * const data,
       
   151 	const u32_t data_length);
       
   152 
       
   153 /**
       
   154  * This function reads 32-bit unsigned integer which is in network order from memory
       
   155  * and returns value in host order.
       
   156  */
       
   157 EAP_C_FUNC_IMPORT u32_t eap_read_u32_t_network_order(
       
   158 	const void * const data,
       
   159 	const u32_t data_length);
       
   160 
       
   161 /**
       
   162  * This function reads 64-bit unsigned integer which is in network order from memory
       
   163  * and returns value in host order.
       
   164  */
       
   165 EAP_C_FUNC_IMPORT u64_t eap_read_u64_t_network_order(
       
   166 	const void * const data,
       
   167 	const u32_t data_length);
       
   168 
       
   169 
       
   170 /**
       
   171  * This function writes 16-bit unsigned integer to network order to memory
       
   172  * and returns status eap_status_ok when successfull.
       
   173  */
       
   174 EAP_C_FUNC_IMPORT eap_status_e eap_write_u16_t_network_order(
       
   175 	void * const data,
       
   176 	const u32_t data_length,
       
   177 	const u16_t value);
       
   178 
       
   179 /**
       
   180  * This function writes 24-bit unsigned integer to network order to memory
       
   181  * and returns status eap_status_ok when successfull.
       
   182  * Note only 24-bit least significant bits are written from 32-bit value.
       
   183  */
       
   184 EAP_C_FUNC_IMPORT eap_status_e eap_write_u24_t_network_order(
       
   185 	void * const data,
       
   186 	const u32_t data_length,
       
   187 	const u32_t value);
       
   188 
       
   189 /**
       
   190  * This function writes 32-bit unsigned integer to network order to memory
       
   191  * and returns status eap_status_ok when successfull.
       
   192  */
       
   193 EAP_C_FUNC_IMPORT eap_status_e eap_write_u32_t_network_order(
       
   194 	void * const data,
       
   195 	const u32_t data_length,
       
   196 	const u32_t value);
       
   197 
       
   198 /**
       
   199  * This function writes 64-bit unsigned integer to network order to memory
       
   200  * and returns status eap_status_ok when successfull.
       
   201  */
       
   202 EAP_C_FUNC_IMPORT eap_status_e eap_write_u64_t_network_order(
       
   203 	void * const data,
       
   204 	const u32_t data_length,
       
   205 	const u64_t value);
       
   206 
       
   207 
       
   208 
       
   209 EAP_C_FUNC_IMPORT u64_t eap_shift_left_64_bit(u64_t value, u32_t shift);
       
   210 
       
   211 EAP_C_FUNC_IMPORT u64_t eap_shift_right_64_bit(u64_t value, u32_t shift);
       
   212 
       
   213 
       
   214 inline u64_t eap_read_u64_t_host_order(
       
   215 	const void * const p_data,
       
   216 	const u32_t data_length)
       
   217 {
       
   218 	#if defined(EAP_LITTLE_ENDIAN) /// byte 0 is least significant (i386)
       
   219 		return eap_read_u64_t_little_endian_order(
       
   220 			p_data,
       
   221 			data_length);
       
   222 	#elif defined(EAP_BIG_ENDIAN) /// byte 0 is most significant (mc68k)
       
   223 		return eap_read_u64_t_network_order(
       
   224 			p_data,
       
   225 			data_length);
       
   226 	#else
       
   227 		#error ERROR: define EAP_LITTLE_ENDIAN (byte 0 is least significant (i386)) \
       
   228 				or EAP_BIG_ENDIAN (byte 0 is most significant (mc68k)).
       
   229 	#endif
       
   230 }
       
   231 
       
   232 
       
   233 inline eap_status_e eap_write_u64_t_host_order(
       
   234 	void * const data,
       
   235 	const u32_t data_length,
       
   236 	const u64_t value)
       
   237 {
       
   238 	#if defined(EAP_LITTLE_ENDIAN) /// byte 0 is least significant (i386)
       
   239 		return eap_write_u64_t_little_endian_order(
       
   240 			data,
       
   241 			data_length,
       
   242 			value);
       
   243 	#elif defined(EAP_BIG_ENDIAN) /// byte 0 is most significant (mc68k)
       
   244 		return eap_write_u64_t_network_order(
       
   245 			data,
       
   246 			data_length,
       
   247 			value);
       
   248 	#else
       
   249 		#error ERROR: define EAP_LITTLE_ENDIAN (byte 0 is least significant (i386)) \
       
   250 				or EAP_BIG_ENDIAN (byte 0 is most significant (mc68k)).
       
   251 	#endif
       
   252 }
       
   253 
       
   254 //----------------------------------------------------------------------------------
       
   255 
       
   256 #if defined(__SYMBIAN32__)
       
   257 	/// This is name of default file for EAP Core traces.
       
   258 	const eap_const_string EAP_DEFAULT_TRACE_FILE = EAPL("c:\\logs\\eapol\\eap_core.log");
       
   259 	#define __PRETTY_FUNCTION__ "function()"
       
   260 #elif defined(__GNUC__) || defined(__arm)
       
   261 	/// This is name of default file for EAP Core traces.
       
   262 	const char * const EAP_DEFAULT_TRACE_FILE = "/tmp/eap_core.log";
       
   263 #elif defined(_WIN32) && !defined(__GNUC__)
       
   264 	#define __PRETTY_FUNCTION__ "function()"
       
   265 	/// This is name of default file for EAP Core traces.
       
   266 	const char * const EAP_DEFAULT_TRACE_FILE = "c:\\temp\\eap_core.log";
       
   267 #endif
       
   268 
       
   269 
       
   270 #define EAP_NULL_FUNCTION  /* do{}while(0) // This causes a lot of warning C4127: conditional expression is constant. */
       
   271 
       
   272 
       
   273 #if defined(NO_EAP_TRACE)
       
   274 #error Use of NO_EAP_TRACE is deprecated. Please, define USE_EAP_TRACE when EAP traces are needed.
       
   275 #endif //defined(NO_EAP_TRACE)
       
   276 
       
   277 #if defined(NO_EAP_DEBUG_TRACE)
       
   278 #error Use of NO_EAP_DEBUG_TRACE is deprecated. Please, define USE_EAP_DEBUG_TRACE when EAP debug traces are needed.
       
   279 #endif //defined(NO_EAP_DEBUG_TRACE)
       
   280 
       
   281 #if defined(NO_EAP_TRACE_STRINGS)
       
   282 #error Use of NO_EAP_TRACE_STRINGS is deprecated. Please, define USE_EAP_TRACE_STRINGS when EAP debug trace strings are needed.
       
   283 #endif //defined(NO_EAP_TRACE_STRINGS)
       
   284 
       
   285 #if defined(NO_EAP_ASSERTS)
       
   286 #error Use of NO_EAP_ASSERTS is deprecated. Please, define USE_EAP_ASSERTS when EAP assertions are needed.
       
   287 #endif //!defined(USE_EAP_ASSERTS)
       
   288 
       
   289 #if defined(NO_EAP_STATUS_RETURN)
       
   290 #error Use of NO_EAP_STATUS_RETURN is deprecated. Please, define USE_EAP_STATUS_RETURN when EAP status return traces are needed.
       
   291 #endif //!defined(NO_EAP_STATUS_RETURN)
       
   292 
       
   293 #if defined(NO_EAP_FUNCTION_TRACE)
       
   294 #error Use of NO_EAP_FUNCTION_TRACE is deprecated. Please, define USE_EAP_FUNCTION_TRACE when heavy EAP function traces are needed.
       
   295 #endif //!defined(NO_EAP_FUNCTION_TRACE)
       
   296 
       
   297 
       
   298 #if !defined(USE_EAP_TRACE_ALWAYS) && !defined(USE_EAP_TRACE)
       
   299 
       
   300 	#define EAP_TRACE_ALWAYS(object_name, flags, _parameter_list_) EAP_NULL_FUNCTION
       
   301 
       
   302 	#define EAP_TRACE_DATA_ALWAYS(object_name, flags, _parameter_list_) EAP_NULL_FUNCTION
       
   303 
       
   304 #else
       
   305 
       
   306 	/**
       
   307 	 * This function traces formatted string with parameters to a file.
       
   308 	 * For example
       
   309 	 * @code
       
   310 	 * EAP_TRACE_ALWAYS(m_am_tools, TRACE_FLAGS_TIMER, (EAPL("~eap_type_gsmsim_c(): 0x%08x\n"), this));
       
   311 	 * @endcode
       
   312 	 *
       
   313 	 */
       
   314 	#define EAP_TRACE_ALWAYS(object_name, flags, _parameter_list_) \
       
   315 			if (object_name != 0 && ((*(object_name)).get_trace_mask() & (flags))) \
       
   316 			{ \
       
   317 				(*(object_name)).formatted_print _parameter_list_ ; \
       
   318 			} \
       
   319 
       
   320 	/**
       
   321 	 * This function traces data bytes to a file.
       
   322 	 * For example
       
   323 	 * @code
       
   324 	 * EAP_TRACE_DATA_ALWAYS(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("new_nai"),
       
   325 	 *	new_nai->get_data(new_nai->get_data_length()),
       
   326 	 *	new_nai->get_data_length()));".
       
   327 	 * @endcode
       
   328 	 *
       
   329 	 */
       
   330 	#define EAP_TRACE_DATA_ALWAYS(object_name, flags, _parameter_list_) \
       
   331 			if (object_name != 0 && ((*(object_name)).get_trace_mask() & (flags))) \
       
   332 			{ \
       
   333 				(*(object_name)).trace_data _parameter_list_ ; \
       
   334 			} \
       
   335 
       
   336 #endif //#if !defined(USE_EAP_TRACE_ALWAYS)
       
   337 
       
   338 
       
   339 #if !defined(USE_EAP_TRACE)
       
   340 
       
   341 	#define EAP_TRACE_ERROR(object_name, flags, _parameter_list_) EAP_NULL_FUNCTION
       
   342 
       
   343 	#define EAP_TRACE_DEBUG(object_name, flags, _parameter_list_) EAP_NULL_FUNCTION
       
   344 
       
   345 	#define EAP_TRACE_FORMAT(object_name, _parameter_list_) EAP_NULL_FUNCTION
       
   346 
       
   347 	#define EAP_TRACE_RETURN_STRING(object_name, string) EAP_NULL_FUNCTION
       
   348 
       
   349 	#define EAP_TRACE_DATA_ERROR(object_name, flags, _parameter_list_) EAP_NULL_FUNCTION
       
   350 
       
   351 	#define EAP_TRACE_DATA_DEBUG(object_name, flags, _parameter_list_) EAP_NULL_FUNCTION
       
   352 
       
   353 	#define EAP_TRACE_BEGIN(object_name, flags) EAP_NULL_FUNCTION
       
   354 
       
   355 	#define EAP_TRACE_END(object_name, flags) EAP_NULL_FUNCTION
       
   356 
       
   357 #else
       
   358 
       
   359 	/**
       
   360 	 * This function traces formatted string with parameters to a file.
       
   361 	 * Trace includes ERROR string, file name and line number.
       
   362 	 * For example
       
   363 	 * @code
       
   364 	 * EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_TIMER, (EAPL("~eap_type_gsmsim_c(): 0x%08x\n"), this));
       
   365 	 * @endcode
       
   366 	 *
       
   367 	 */
       
   368 	#define EAP_TRACE_ERROR(object_name, flags, _parameter_list_) \
       
   369 		if (object_name != 0) \
       
   370 		{ \
       
   371 			(*(object_name)).check_activate_trace_on_error(); \
       
   372 			if (((*(object_name)).get_trace_mask() & ((flags) | eap_am_tools_c::eap_trace_mask_error))) \
       
   373 			{ \
       
   374 				(*(object_name)).formatted_print(EAPL("ERROR: source: %s:%d\n"), __FILE__, __LINE__); \
       
   375 				(*(object_name)).formatted_print _parameter_list_ ; \
       
   376 			} \
       
   377 		} \
       
   378 
       
   379 	/**
       
   380 	 * This function traces data bytes to a file.
       
   381 	 * For example
       
   382 	 * @code
       
   383 	 * EAP_TRACE_DATA_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("new_nai"),
       
   384 	 *	new_nai->get_data(new_nai->get_data_length()),
       
   385 	 *	new_nai->get_data_length()));".
       
   386 	 * @endcode
       
   387 	 *
       
   388 	 */
       
   389 	#define EAP_TRACE_DATA_ERROR(object_name, flags, _parameter_list_) \
       
   390 		if (object_name != 0) \
       
   391 		{ \
       
   392 			(*(object_name)).check_activate_trace_on_error(); \
       
   393 			if (((*(object_name)).get_trace_mask() & ((flags) | eap_am_tools_c::eap_trace_mask_error))) \
       
   394 			{ \
       
   395 				(*(object_name)).trace_data _parameter_list_ ; \
       
   396 			} \
       
   397 		} \
       
   398 
       
   399 	/**
       
   400 	 * @{ Remove debug traces in release version when appropriate. }
       
   401 	 */
       
   402 	//#if defined(_DEBUG) && defined(USE_EAP_DEBUG_TRACE)
       
   403 	#if defined(USE_EAP_DEBUG_TRACE)
       
   404 
       
   405 		/**
       
   406 		 * This function traces formatted string with parameters to a file.
       
   407 		 * This is used only in debug version.
       
   408 		 * For example
       
   409 		 * @code
       
   410 		 * EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_TIMER, (EAPL("~eap_type_gsmsim_c(): 0x%08x\n"), this));
       
   411 		 * @endcode
       
   412 		 *
       
   413 		 */
       
   414 		#define EAP_TRACE_DEBUG(object_name, flags, _parameter_list_) \
       
   415 				if (object_name != 0 && ((*(object_name)).get_trace_mask() & ((flags) | eap_am_tools_c::eap_trace_mask_error))) \
       
   416 				{ \
       
   417 					if (((*(object_name)).get_trace_mask() & ((flags) & eap_am_tools_c::eap_trace_mask_error))) \
       
   418 					{ \
       
   419 						(*(object_name)).formatted_print(EAPL("ERROR: source: %s:%d\n"), __FILE__, __LINE__); \
       
   420 						(*(object_name)).formatted_print _parameter_list_ ; \
       
   421 					} \
       
   422 					else if (((*(object_name)).get_trace_mask() & (flags))) \
       
   423 					{ \
       
   424 						(*(object_name)).formatted_print _parameter_list_ ; \
       
   425 					} \
       
   426 					else \
       
   427 					{ \
       
   428 						/* Do nothing. This else is because lint complains the missing else. */ \
       
   429 					} \
       
   430 				} \
       
   431 
       
   432 		/**
       
   433 		 * This function traces data bytes to a file.
       
   434 		 * This is used only in debug version.
       
   435 		 * For example
       
   436 		 * @code
       
   437 		 * EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("new_nai"),
       
   438 		 *	new_nai->get_data(new_nai->get_data_length()),
       
   439 		 *	new_nai->get_data_length()));".
       
   440 		 * @endcode
       
   441 		 *
       
   442 		 */
       
   443 		#define EAP_TRACE_DATA_DEBUG(object_name, flags, _parameter_list_) \
       
   444 				if (object_name != 0 && ((*(object_name)).get_trace_mask() & (flags))) \
       
   445 				{ \
       
   446 					(*(object_name)).trace_data _parameter_list_ ; \
       
   447 				} \
       
   448 
       
   449 		/**
       
   450 		 * This function formats string to a buffer.
       
   451 		 * This is used only in debug version.
       
   452 		 * For example
       
   453 		 * @code
       
   454 		 * EAP_TRACE_FORMAT(m_am_tools, (buffer, buffer_size, EAPL("new_nai %d, %s"),
       
   455 		 *	foo,
       
   456 		 *	EAPL("some string")));".
       
   457 		 * @endcode
       
   458 		 *
       
   459 		 */
       
   460 		#define EAP_TRACE_FORMAT(object_name, _parameter_list_) \
       
   461 				if (object_name != 0 && (*(object_name)).get_trace_mask()) \
       
   462 				{ \
       
   463 					(*(object_name)).snprintf _parameter_list_; \
       
   464 				} \
       
   465 
       
   466 		#define EAP_TRACE_RETURN_STRING(object_name, string) \
       
   467 			eap_automatic_trace_string_c __eap_trace_function_returns__(object_name, string);
       
   468 
       
   469 		/**
       
   470 		 * This flag indicates that the debug traces are active.
       
   471 		 * Functions can use this flag to deduce whether debug related
       
   472 		 * parameters should be introduced.
       
   473 		 */
       
   474 		#define	EAP_DEBUG_TRACE_ACTIVE
       
   475 
       
   476 	#else
       
   477 
       
   478 		#define EAP_TRACE_DEBUG(object_name, flags, _parameter_list_) EAP_NULL_FUNCTION
       
   479 
       
   480 		#define EAP_TRACE_DATA_DEBUG(object_name, flags, _parameter_list_) EAP_NULL_FUNCTION
       
   481 
       
   482 		#define EAP_TRACE_FORMAT(object_name, _parameter_list_) EAP_NULL_FUNCTION
       
   483 
       
   484 		#define EAP_TRACE_RETURN_STRING(object_name, string) EAP_NULL_FUNCTION
       
   485 
       
   486 	#endif
       
   487 
       
   488 
       
   489 	#if !defined(USE_EAP_FUNCTION_TRACE)
       
   490 
       
   491 		#define EAP_TRACE_BEGIN(object_name, flags) EAP_NULL_FUNCTION
       
   492 
       
   493 		#define EAP_TRACE_END(object_name, flags) EAP_NULL_FUNCTION
       
   494 
       
   495 	#else
       
   496 		/**
       
   497 		 * This function traces begin of the function with name, file and line number to a file.
       
   498 		 * For example
       
   499 		 * @code
       
   500 		 * EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   501 		 * @endcode
       
   502 		 *
       
   503 		 */
       
   504 		#define EAP_TRACE_BEGIN(object_name, flags) \
       
   505 				if (object_name != 0 && ((*(object_name)).get_trace_mask() & (eap_am_tools_c::eap_trace_mask_functions))) \
       
   506 				{ \
       
   507 					(*(object_name)).formatted_print(EAPL("-> %s:%s:%d\n"), __PRETTY_FUNCTION__, __FILE__, __LINE__); \
       
   508 				} \
       
   509 
       
   510 		/**
       
   511 		 * This function traces end of the function with name, file and line number to a file.
       
   512 		 * For example
       
   513 		 * @code
       
   514 		 * EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   515 		 * @endcode
       
   516 		 *
       
   517 		 */
       
   518 		#define EAP_TRACE_END(object_name, flags) \
       
   519 				if (object_name != 0 && ((*(object_name)).get_trace_mask() & (eap_am_tools_c::eap_trace_mask_functions))) \
       
   520 				{ \
       
   521 					(*(object_name)).formatted_print(EAPL("<- %s:%s:%d\n"), __PRETTY_FUNCTION__, __FILE__, __LINE__); \
       
   522 				} \
       
   523 
       
   524 	#endif
       
   525 
       
   526 #endif //#if !defined(USE_EAP_TRACE)
       
   527 
       
   528 
       
   529 
       
   530 #if defined(USE_EAP_STACK_TRACE)
       
   531 
       
   532 		#define EAP_STACK_TRACE_TOOLS(am_tools, address) \
       
   533 				{ \
       
   534 					stack_trace st_trace(am_tools); \
       
   535 					st_trace.trace(address); \
       
   536 				} \
       
   537 
       
   538 		#define EAP_STACK_TRACE(address) \
       
   539 			EAP_STACK_TRACE_TOOLS(m_am_tools, address)
       
   540 
       
   541 #else
       
   542 
       
   543 		#define EAP_STACK_TRACE_TOOLS(am_tools, address) EAP_NULL_FUNCTION
       
   544 
       
   545 		#define EAP_STACK_TRACE(address) EAP_NULL_FUNCTION
       
   546 
       
   547 #endif //#if defined(EAP_STACK_TRACE)
       
   548 
       
   549 
       
   550 #if defined(USE_EAP_ASSERT_STACK_TRACE)
       
   551 
       
   552 		#define EAP_ASSERT_STACK_TRACE_TOOLS(am_tools, address) \
       
   553 				{ \
       
   554 					stack_trace st_trace(am_tools); \
       
   555 					st_trace.trace(address); \
       
   556 				} \
       
   557 
       
   558 		#define EAP_ASSERT_STACK_TRACE(address) \
       
   559 			EAP_ASSERT_STACK_TRACE_TOOLS(m_am_tools, address)
       
   560 
       
   561 #else
       
   562 
       
   563 		#define EAP_ASSERT_STACK_TRACE_TOOLS(am_tools, address) EAP_NULL_FUNCTION
       
   564 
       
   565 		#define EAP_ASSERT_STACK_TRACE(address) EAP_NULL_FUNCTION
       
   566 
       
   567 #endif //#if defined(EAP_STACK_TRACE)
       
   568 
       
   569 
       
   570 
       
   571 /// This defines one if case for a constant
       
   572 /// that returns constant name string.
       
   573 #define EAP_IF_RETURN_STRING(type, const_type) \
       
   574 		if ((type) == (const_type)) \
       
   575 		{ \
       
   576 			return EAPL(#const_type); \
       
   577 		}
       
   578 
       
   579 
       
   580 #if !defined(lint)
       
   581 	#if defined(__GNUC__) || defined(__ARMCC__) || defined(__arm)
       
   582 		/// This prevent compiler warning of unused variable.
       
   583 		#define EAP_UNREFERENCED_PARAMETER(P) \
       
   584 				if ((&(P)) == (&(P))) \
       
   585 					; \
       
   586 
       
   587 	#else
       
   588 		/// This prevent compiler warning of unused variable.
       
   589 		#define EAP_UNREFERENCED_PARAMETER(P) (P)
       
   590 	#endif
       
   591 #else // lint
       
   592 	// Note: lint -e530 says don't complain about uninitialized variables for
       
   593 	// this varible.  Error 527 has to do with unreachable code.
       
   594 	// -restore restores checking to the -save state
       
   595 	/// This prevent compiler warning of unused variable.
       
   596 	#define EAP_UNREFERENCED_PARAMETER(P)          \
       
   597 		/*lint -save -e527 -e530 */ \
       
   598 		{\
       
   599 				(P) = (P); \
       
   600 		} \
       
   601 
       
   602 		/*lint -restore */
       
   603 #endif // lint
       
   604 
       
   605 //----------------------------------------------------------------------------------
       
   606 
       
   607 #endif //#if !defined( _EAP_TOOLS_H_ )
       
   608 
       
   609 
       
   610 
       
   611 // End.