eapol/eapol_framework/eapol_symbian/am/include/eap_am_tools_symbian.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 // INCLUDES
       
    21 #if !defined( _EAP_AM_TOOLS_SYMBIAN_H_ )
       
    22 #define _EAP_AM_TOOLS_SYMBIAN_H_
       
    23 
       
    24 #include <e32std.h>
       
    25 #include <e32svr.h>
       
    26 
       
    27 //#include "eap_am_memory.h"
       
    28 
       
    29 #include "eap_am_tools.h"
       
    30 #include "eap_variable_data.h"
       
    31 #include "eap_tools.h"
       
    32 #include "eap_status.h"
       
    33 #include "eap_am_export.h"
       
    34 #include "eap_am_crypto_symbian.h"
       
    35 #include "eap_timer_queue.h"
       
    36 #include "eap_am_mutex_symbian.h"
       
    37 #include <f32file.h>
       
    38 #include <d32dbms.h>
       
    39 
       
    40 /// This class implements functionality of platform adaptation of Symbian.
       
    41 /**
       
    42  *	See function comments on abs_eap_am_tools_c and eap_am_tools_c.
       
    43  */
       
    44 class EAP_EXPORT eap_am_tools_symbian_c
       
    45 : public eap_am_tools_c
       
    46 //, public CActive
       
    47 , public CTimer
       
    48 {
       
    49 private:
       
    50 
       
    51 #if defined(USE_EAP_FILE_TRACE)
       
    52 	/// File server used in filetrace.
       
    53 	RFs m_Fs;
       
    54 
       
    55 	/// File used in filetrace.
       
    56 	RFile m_LogFile;
       
    57 
       
    58 	/// File name used in filetrace.
       
    59 	TBuf<64> m_filename;
       
    60 #endif //#if defined(USE_EAP_FILE_TRACE)
       
    61 
       
    62 	u64_t m_start_ticks;
       
    63 
       
    64 	bool m_directory_exists;
       
    65 
       
    66 	eap_am_crypto_symbian_c m_crypto;
       
    67 
       
    68 	eap_timer_queue_c m_timer_queue;
       
    69 
       
    70 	eap_am_mutex_symbian_c m_global_mutex;
       
    71 	
       
    72 	eap_am_mutex_symbian_c m_trace_mutex;
       
    73 
       
    74 	bool m_run_thread;
       
    75 
       
    76 	bool m_is_valid;
       
    77 
       
    78 	bool m_configure_called;
       
    79 
       
    80 #if defined(USE_EAP_TRACE) || defined(USE_EAP_TRACE_ALWAYS)
       
    81 	/// Bufers are used in traces.
       
    82 	TBuf8<1024> m_args_buf;
       
    83 #if defined(USE_EAP_HARDWARE_TRACE)
       
    84 	TBuf16<1024> m_trace_buf_16;
       
    85 #endif //#if defined(USE_EAP_HARDWARE_TRACE)
       
    86 #endif //#if defined(USE_EAP_TRACE) || defined(USE_EAP_TRACE_ALWAYS)
       
    87 
       
    88 	/// Buffers are used in string conversions.
       
    89 	TBuf8<1024> m_format_buf;
       
    90 	TBuf8<1024> m_trace_buf;
       
    91 
       
    92 	/// These member variables are used in Symbian timer.
       
    93 	TUint iInterval;
       
    94 	u64_t iStartTime;
       
    95 	u64_t iLastTime;
       
    96 
       
    97 	// This flag tells whether the trace log file is open.
       
    98 	bool m_logfile_open;
       
    99 
       
   100 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
   101 
       
   102 	EAP_FUNC_IMPORT void sprint(TDes& KPrintBuf, eap_const_string format, ...);
       
   103 
       
   104 	EAP_FUNC_IMPORT void KFormatVArgs(TDes& aDes, const TDesC& aFmt, VA_LIST aList);
       
   105 
       
   106 	// Member function to support active sceduler timer.
       
   107 	void StartTimer(const TUint aInterval);
       
   108 	void StopTimer();
       
   109 	TBool TimerRunning();
       
   110 	void RunL();
       
   111 	void DoCancel();
       
   112 
       
   113 	u32_t limit_microsecond_timeout(u32_t next_timeout_millisecond);
       
   114 
       
   115 	// On purpose unimplemented constructors.
       
   116 	eap_am_tools_symbian_c(eap_am_tools_symbian_c &source);
       
   117 	const eap_am_tools_symbian_c & operator=(const eap_am_tools_symbian_c& source);
       
   118 
       
   119 public:
       
   120 
       
   121 	EAP_FUNC_IMPORT virtual ~eap_am_tools_symbian_c();
       
   122 
       
   123 	EAP_FUNC_IMPORT eap_am_tools_symbian_c(eap_const_string pfilename);
       
   124 
       
   125 
       
   126 	/// See function comments on abs_eap_am_tools_c and eap_am_tools_c.
       
   127 
       
   128 	EAP_FUNC_IMPORT eap_status_e configure();
       
   129 
       
   130 	EAP_FUNC_IMPORT bool get_use_eap_milli_second_timer();
       
   131 
       
   132 	EAP_FUNC_IMPORT void set_use_eap_milli_second_timer(
       
   133 		const bool use_eap_millisecond_timer);
       
   134 
       
   135 	EAP_FUNC_IMPORT void enter_global_mutex();
       
   136 
       
   137 	EAP_FUNC_IMPORT void leave_global_mutex();
       
   138 
       
   139 	EAP_FUNC_IMPORT abs_eap_am_mutex_c * get_global_mutex();
       
   140 
       
   141 	EAP_FUNC_IMPORT void enter_trace_mutex();
       
   142 
       
   143 	EAP_FUNC_IMPORT void leave_trace_mutex();
       
   144 
       
   145 	EAP_FUNC_IMPORT abs_eap_am_mutex_c * get_trace_mutex();
       
   146 
       
   147 
       
   148 	EAP_FUNC_IMPORT void set_timer_resolution_ms(const u32_t timer_resolution_ms);
       
   149 
       
   150 	EAP_FUNC_IMPORT u32_t get_timer_resolution_ms();
       
   151 
       
   152 	EAP_FUNC_IMPORT u32_t pulse_timer(const u32_t elapsed_time_in_ms);
       
   153 
       
   154 	EAP_FUNC_IMPORT bool get_timer_queue_is_empty();
       
   155 
       
   156 
       
   157 	EAP_FUNC_IMPORT eap_status_e start_timer_thread();
       
   158 
       
   159 	EAP_FUNC_IMPORT eap_status_e stop_timer_thread();
       
   160 
       
   161 	EAP_FUNC_IMPORT bool get_is_timer_thread_active();
       
   162 
       
   163 
       
   164 	EAP_FUNC_IMPORT eap_status_e set_trace_file_name(const eap_variable_data_c * const trace_output_file);
       
   165 
       
   166 	EAP_FUNC_IMPORT void set_max_trace_file_size(const u32_t max_trace_file_size);
       
   167 
       
   168 	EAP_FUNC_IMPORT u32_t snprintf(u8_t * const buffer, u32_t buffer_size, eap_format_string format, ...);
       
   169 
       
   170 	EAP_FUNC_IMPORT void formatted_print(eap_format_string format, ...);
       
   171 
       
   172 	EAP_FUNC_IMPORT void memmove(void *dest, const void *src, const u32_t count);
       
   173 
       
   174 	EAP_FUNC_IMPORT i32_t memcmp(const void * const dest, const void * const src, const u32_t count);
       
   175 
       
   176 	EAP_FUNC_IMPORT void memset(void * const src, const i32_t fill_byte, const u32_t count);
       
   177 
       
   178 	EAP_FUNC_IMPORT void *memchr(
       
   179 		const void *buf,
       
   180 		u8_t character,
       
   181 		u32_t count);
       
   182 
       
   183 	EAP_FUNC_IMPORT void *memrchr(
       
   184 		const void *buf,
       
   185 		u8_t character,
       
   186 		u32_t count);
       
   187 
       
   188 	EAP_FUNC_IMPORT u32_t strlen(
       
   189 		eap_const_string string);
       
   190 
       
   191 	EAP_FUNC_IMPORT u32_t config_strlen(
       
   192 		eap_config_string string);
       
   193 
       
   194 	EAP_FUNC_IMPORT abs_eap_am_crypto_c * get_crypto();
       
   195 
       
   196 	EAP_FUNC_IMPORT u64_t get_hardware_ticks();
       
   197 
       
   198 	EAP_FUNC_IMPORT u64_t get_hardware_ticks_of_second();
       
   199 
       
   200 	EAP_FUNC_IMPORT u64_t get_clock_ticks();
       
   201 
       
   202 	EAP_FUNC_IMPORT u64_t get_clock_ticks_of_second();
       
   203 
       
   204 	EAP_FUNC_IMPORT u32_t get_gmt_unix_time();
       
   205 
       
   206 	EAP_FUNC_IMPORT eap_status_e am_set_timer(
       
   207 		abs_eap_base_timer_c * const initializer, 
       
   208 		const u32_t id, 
       
   209 		void * const data,
       
   210 		const u32_t p_time_ms);
       
   211 
       
   212 	EAP_FUNC_IMPORT eap_status_e am_cancel_timer(
       
   213 		abs_eap_base_timer_c * const initializer, 
       
   214 		const u32_t id);
       
   215 
       
   216 	EAP_FUNC_IMPORT eap_status_e am_cancel_all_timers();
       
   217 
       
   218 	EAP_FUNC_IMPORT eap_status_e re_activate_timer_queue();
       
   219 
       
   220 	EAP_FUNC_IMPORT void enter_crypto_cs();
       
   221 	EAP_FUNC_IMPORT void leave_crypto_cs();
       
   222 
       
   223 	EAP_FUNC_IMPORT void timer_sleep(u32_t milli_seconds);
       
   224 
       
   225 	EAP_FUNC_IMPORT void sleep(u32_t milli_seconds);
       
   226 
       
   227 	EAP_FUNC_IMPORT bool get_is_valid() const;
       
   228 
       
   229 	EAP_FUNC_IMPORT eap_status_e begin_db_transaction(RDbNamedDatabase& aDatabase);
       
   230 
       
   231 	EAP_FUNC_IMPORT eap_status_e begin_db_update(RDbView& aView);
       
   232 	
       
   233 	EAP_FUNC_IMPORT eap_status_e begin_db_delete(RDbView& aView);
       
   234 
       
   235 	/// This function must call eap_am_tools_c::shutdown_am_tools().
       
   236 	EAP_FUNC_IMPORT eap_status_e shutdown();
       
   237 
       
   238 	EAP_FUNC_IMPORT eap_status_e convert_unicode_to_utf8(
       
   239 		eap_variable_data_c & dest,
       
   240 		const eap_variable_data_c & src);
       
   241 
       
   242 	EAP_FUNC_IMPORT eap_status_e convert_utf8_to_unicode(
       
   243 		eap_variable_data_c & dest,
       
   244 		const eap_variable_data_c & src);
       
   245 
       
   246 	EAP_FUNC_IMPORT eap_status_e convert_am_error_to_eapol_error(const i32_t am_error_value);
       
   247 
       
   248 	EAP_FUNC_IMPORT i32_t convert_eapol_error_to_am_error(eap_status_e aErr);
       
   249 
       
   250 	EAP_FUNC_IMPORT eap_status_e getenv(
       
   251 		const eap_variable_data_c * const environment_variable_name,
       
   252 		eap_variable_data_c * const environment_variable_value);
       
   253 
       
   254 	EAP_FUNC_IMPORT bool isspace(const u8_t character);
       
   255 
       
   256 	EAP_FUNC_IMPORT u64_struct u64_t_to_u64_struct(const u64_t value);
       
   257 
       
   258 	EAP_FUNC_IMPORT u64_t u64_struct_to_u64_t(const u64_struct value);
       
   259 };
       
   260 
       
   261 #endif //#if !defined( _EAP_AM_TOOLS_SYMBIAN_H_ )
       
   262 
       
   263 
       
   264 
       
   265 // End of file