eapol/eapol_framework/eapol_common/include/eap_tools.h
changeset 52 c23bdf5a328a
parent 39 fe6b6762fccd
equal deleted inserted replaced
51:e863583e6720 52:c23bdf5a328a
    27 #include "eap_am_compiler_flags.h"
    27 #include "eap_am_compiler_flags.h"
    28 
    28 
    29 #include "eap_variable_data.h"
    29 #include "eap_variable_data.h"
    30 #include "eap_status.h"
    30 #include "eap_status.h"
    31 #include "eap_am_export.h"
    31 #include "eap_am_export.h"
       
    32 // Start: added by script change_export_macros.sh.
       
    33 #if defined(EAP_NO_EXPORT_EAP_TOOLS_H)
       
    34 	#define EAP_CLASS_VISIBILITY_EAP_TOOLS_H EAP_NONSHARABLE 
       
    35 	#define EAP_FUNC_VISIBILITY_EAP_TOOLS_H 
       
    36 	#define EAP_C_FUNC_VISIBILITY_EAP_TOOLS_H 
       
    37 	#define EAP_FUNC_EXPORT_EAP_TOOLS_H 
       
    38 	#define EAP_C_FUNC_EXPORT_EAP_TOOLS_H 
       
    39 #elif defined(EAP_EXPORT_EAP_TOOLS_H)
       
    40 	#define EAP_CLASS_VISIBILITY_EAP_TOOLS_H EAP_EXPORT 
       
    41 	#define EAP_FUNC_VISIBILITY_EAP_TOOLS_H EAP_FUNC_EXPORT 
       
    42 	#define EAP_C_FUNC_VISIBILITY_EAP_TOOLS_H EAP_C_FUNC_EXPORT 
       
    43 	#define EAP_FUNC_EXPORT_EAP_TOOLS_H EAP_FUNC_EXPORT 
       
    44 	#define EAP_C_FUNC_EXPORT_EAP_TOOLS_H EAP_C_FUNC_EXPORT 
       
    45 #else
       
    46 	#define EAP_CLASS_VISIBILITY_EAP_TOOLS_H EAP_IMPORT 
       
    47 	#define EAP_FUNC_VISIBILITY_EAP_TOOLS_H EAP_FUNC_IMPORT 
       
    48 	#define EAP_C_FUNC_VISIBILITY_EAP_TOOLS_H EAP_C_FUNC_IMPORT 
       
    49 	#define EAP_FUNC_EXPORT_EAP_TOOLS_H 
       
    50 	#define EAP_C_FUNC_EXPORT_EAP_TOOLS_H 
       
    51 #endif
       
    52 // End: added by script change_export_macros.sh.
    32 
    53 
    33 #if defined(USE_EAP_STACK_TRACE) || defined(USE_EAP_ASSERT_STACK_TRACE)
    54 #if defined(USE_EAP_STACK_TRACE) || defined(USE_EAP_ASSERT_STACK_TRACE)
    34 	#include "eap_am_stack_trace.h"
    55 	#include "eap_am_stack_trace.h"
    35 #endif //#if defined(EAP_STACK_TRACE)
    56 #endif //#if defined(EAP_STACK_TRACE)
    36 
    57 
    38 //----------------------------------------------------------------------------------
    59 //----------------------------------------------------------------------------------
    39 
    60 
    40 /**
    61 /**
    41  * This function changes 16-bit unsigned integer from host order to network order.
    62  * This function changes 16-bit unsigned integer from host order to network order.
    42  */
    63  */
    43 EAP_C_FUNC_IMPORT u16_t eap_htons(const u16_t value);
    64 EAP_C_FUNC_VISIBILITY_EAP_TOOLS_H u16_t eap_htons(const u16_t value);
    44 
    65 
    45 /**
    66 /**
    46  * This function changes 32-bit unsigned integer from host order to network order.
    67  * This function changes 32-bit unsigned integer from host order to network order.
    47  */
    68  */
    48 EAP_C_FUNC_IMPORT u32_t eap_htonl(const u32_t value);
    69 EAP_C_FUNC_VISIBILITY_EAP_TOOLS_H u32_t eap_htonl(const u32_t value);
    49 
    70 
    50 /**
    71 /**
    51  * This function changes 64-bit unsigned integer from host order to network order.
    72  * This function changes 64-bit unsigned integer from host order to network order.
    52  */
    73  */
    53 EAP_C_FUNC_IMPORT u64_t eap_htonll(const u64_t value);
    74 EAP_C_FUNC_VISIBILITY_EAP_TOOLS_H u64_t eap_htonll(const u64_t value);
    54 
    75 
    55 
    76 
    56 /**
    77 /**
    57  * This function changes 16-bit unsigned integer from network order to host order.
    78  * This function changes 16-bit unsigned integer from network order to host order.
    58  */
    79  */
    71 
    92 
    72 /**
    93 /**
    73  * This function changes 16-bit unsigned integer from host order to little endian order.
    94  * This function changes 16-bit unsigned integer from host order to little endian order.
    74  * This is used in some crypto algorithms.
    95  * This is used in some crypto algorithms.
    75  */
    96  */
    76 EAP_C_FUNC_IMPORT u16_t eap_host_to_little_endian_short(const u16_t value);
    97 EAP_C_FUNC_VISIBILITY_EAP_TOOLS_H u16_t eap_host_to_little_endian_short(const u16_t value);
    77 
    98 
    78 /**
    99 /**
    79  * This function changes 32-bit unsigned integer from host order to little endian order.
   100  * This function changes 32-bit unsigned integer from host order to little endian order.
    80  * This is used in some crypto algorithms.
   101  * This is used in some crypto algorithms.
    81  */
   102  */
    82 EAP_C_FUNC_IMPORT u32_t eap_host_to_little_endian_long(const u32_t value);
   103 EAP_C_FUNC_VISIBILITY_EAP_TOOLS_H u32_t eap_host_to_little_endian_long(const u32_t value);
    83 
   104 
    84 /**
   105 /**
    85  * This function changes 64-bit unsigned integer from host order to little endian order.
   106  * This function changes 64-bit unsigned integer from host order to little endian order.
    86  * This is used in some crypto algorithms.
   107  * This is used in some crypto algorithms.
    87  */
   108  */
    88 EAP_C_FUNC_IMPORT u64_t eap_host_to_little_endian_long(const u64_t value);
   109 EAP_C_FUNC_VISIBILITY_EAP_TOOLS_H u64_t eap_host_to_little_endian_long(const u64_t value);
    89 
   110 
    90 /**
   111 /**
    91  * This function write 16-bit unsigned integer which is in little endian order to memory.
   112  * This function write 16-bit unsigned integer which is in little endian order to memory.
    92  */
   113  */
    93 EAP_C_FUNC_IMPORT eap_status_e eap_write_u16_t_little_endian_order(
   114 EAP_C_FUNC_VISIBILITY_EAP_TOOLS_H eap_status_e eap_write_u16_t_little_endian_order(
    94 	void * const p_data,
   115 	void * const p_data,
    95 	const u32_t data_length,
   116 	const u32_t data_length,
    96 	const u16_t value);
   117 	const u16_t value);
    97 
   118 
    98 /**
   119 /**
    99  * This function write 32-bit unsigned integer which is in little endian order to memory.
   120  * This function write 32-bit unsigned integer which is in little endian order to memory.
   100  */
   121  */
   101 EAP_C_FUNC_IMPORT eap_status_e eap_write_u32_t_little_endian_order(
   122 EAP_C_FUNC_VISIBILITY_EAP_TOOLS_H eap_status_e eap_write_u32_t_little_endian_order(
   102 	void * const p_data,
   123 	void * const p_data,
   103 	const u32_t data_length,
   124 	const u32_t data_length,
   104 	const u32_t value);
   125 	const u32_t value);
   105 
   126 
   106 /**
   127 /**
   107  * This function write 64-bit unsigned integer which is in little endian order to memory.
   128  * This function write 64-bit unsigned integer which is in little endian order to memory.
   108  */
   129  */
   109 EAP_C_FUNC_IMPORT eap_status_e eap_write_u64_t_little_endian_order(
   130 EAP_C_FUNC_VISIBILITY_EAP_TOOLS_H eap_status_e eap_write_u64_t_little_endian_order(
   110 	void * const p_data,
   131 	void * const p_data,
   111 	const u32_t data_length,
   132 	const u32_t data_length,
   112 	const u64_t value);
   133 	const u64_t value);
   113 
   134 
   114 /**
   135 /**
   115  * This function reads 16-bit unsigned integer which is in little endian order from memory
   136  * This function reads 16-bit unsigned integer which is in little endian order from memory
   116  * and returns value in host order.
   137  * and returns value in host order.
   117  */
   138  */
   118 EAP_C_FUNC_IMPORT u16_t eap_read_u16_t_little_endian_order(
   139 EAP_C_FUNC_VISIBILITY_EAP_TOOLS_H u16_t eap_read_u16_t_little_endian_order(
   119 	const void * const data,
   140 	const void * const data,
   120 	const u32_t data_length);
   141 	const u32_t data_length);
   121 
   142 
   122 /**
   143 /**
   123  * This function reads 32-bit unsigned integer which is in little endian order from memory
   144  * This function reads 32-bit unsigned integer which is in little endian order from memory
   124  * and returns value in host order.
   145  * and returns value in host order.
   125  */
   146  */
   126 EAP_C_FUNC_IMPORT u32_t eap_read_u32_t_little_endian_order(
   147 EAP_C_FUNC_VISIBILITY_EAP_TOOLS_H u32_t eap_read_u32_t_little_endian_order(
   127 	const void * const p_data,
   148 	const void * const p_data,
   128 	const u32_t data_length);
   149 	const u32_t data_length);
   129 
   150 
   130 /**
   151 /**
   131  * This function reads 64-bit unsigned integer which is in little endian order from memory
   152  * This function reads 64-bit unsigned integer which is in little endian order from memory
   132  * and returns value in host order.
   153  * and returns value in host order.
   133  */
   154  */
   134 EAP_C_FUNC_IMPORT u64_t eap_read_u64_t_little_endian_order(
   155 EAP_C_FUNC_VISIBILITY_EAP_TOOLS_H u64_t eap_read_u64_t_little_endian_order(
   135 	const void * const p_data,
   156 	const void * const p_data,
   136 	const u32_t data_length);
   157 	const u32_t data_length);
   137 
   158 
   138 /**
   159 /**
   139  * This function reads 16-bit unsigned integer which is in network order from memory
   160  * This function reads 16-bit unsigned integer which is in network order from memory
   140  * and returns value in host order.
   161  * and returns value in host order.
   141  */
   162  */
   142 EAP_C_FUNC_IMPORT u16_t eap_read_u16_t_network_order(
   163 EAP_C_FUNC_VISIBILITY_EAP_TOOLS_H u16_t eap_read_u16_t_network_order(
   143 	const void * const data,
   164 	const void * const data,
   144 	const u32_t data_length);
   165 	const u32_t data_length);
   145 
   166 
   146 /**
   167 /**
   147  * This function reads 24-bit unsigned integer which is in network order from memory
   168  * This function reads 24-bit unsigned integer which is in network order from memory
   148  * and returns it in 32-bit value in host order.
   169  * and returns it in 32-bit value in host order.
   149  */
   170  */
   150 EAP_C_FUNC_IMPORT u32_t eap_read_u24_t_network_order(
   171 EAP_C_FUNC_VISIBILITY_EAP_TOOLS_H u32_t eap_read_u24_t_network_order(
   151 	const void * const data,
   172 	const void * const data,
   152 	const u32_t data_length);
   173 	const u32_t data_length);
   153 
   174 
   154 /**
   175 /**
   155  * This function reads 32-bit unsigned integer which is in network order from memory
   176  * This function reads 32-bit unsigned integer which is in network order from memory
   156  * and returns value in host order.
   177  * and returns value in host order.
   157  */
   178  */
   158 EAP_C_FUNC_IMPORT u32_t eap_read_u32_t_network_order(
   179 EAP_C_FUNC_VISIBILITY_EAP_TOOLS_H u32_t eap_read_u32_t_network_order(
   159 	const void * const data,
   180 	const void * const data,
   160 	const u32_t data_length);
   181 	const u32_t data_length);
   161 
   182 
   162 /**
   183 /**
   163  * This function reads 64-bit unsigned integer which is in network order from memory
   184  * This function reads 64-bit unsigned integer which is in network order from memory
   164  * and returns value in host order.
   185  * and returns value in host order.
   165  */
   186  */
   166 EAP_C_FUNC_IMPORT u64_t eap_read_u64_t_network_order(
   187 EAP_C_FUNC_VISIBILITY_EAP_TOOLS_H u64_t eap_read_u64_t_network_order(
   167 	const void * const data,
   188 	const void * const data,
   168 	const u32_t data_length);
   189 	const u32_t data_length);
   169 
   190 
   170 
   191 
   171 /**
   192 /**
   172  * This function writes 16-bit unsigned integer to network order to memory
   193  * This function writes 16-bit unsigned integer to network order to memory
   173  * and returns status eap_status_ok when successfull.
   194  * and returns status eap_status_ok when successfull.
   174  */
   195  */
   175 EAP_C_FUNC_IMPORT eap_status_e eap_write_u16_t_network_order(
   196 EAP_C_FUNC_VISIBILITY_EAP_TOOLS_H eap_status_e eap_write_u16_t_network_order(
   176 	void * const data,
   197 	void * const data,
   177 	const u32_t data_length,
   198 	const u32_t data_length,
   178 	const u16_t value);
   199 	const u16_t value);
   179 
   200 
   180 /**
   201 /**
   181  * This function writes 24-bit unsigned integer to network order to memory
   202  * This function writes 24-bit unsigned integer to network order to memory
   182  * and returns status eap_status_ok when successfull.
   203  * and returns status eap_status_ok when successfull.
   183  * Note only 24-bit least significant bits are written from 32-bit value.
   204  * Note only 24-bit least significant bits are written from 32-bit value.
   184  */
   205  */
   185 EAP_C_FUNC_IMPORT eap_status_e eap_write_u24_t_network_order(
   206 EAP_C_FUNC_VISIBILITY_EAP_TOOLS_H eap_status_e eap_write_u24_t_network_order(
   186 	void * const data,
   207 	void * const data,
   187 	const u32_t data_length,
   208 	const u32_t data_length,
   188 	const u32_t value);
   209 	const u32_t value);
   189 
   210 
   190 /**
   211 /**
   191  * This function writes 32-bit unsigned integer to network order to memory
   212  * This function writes 32-bit unsigned integer to network order to memory
   192  * and returns status eap_status_ok when successfull.
   213  * and returns status eap_status_ok when successfull.
   193  */
   214  */
   194 EAP_C_FUNC_IMPORT eap_status_e eap_write_u32_t_network_order(
   215 EAP_C_FUNC_VISIBILITY_EAP_TOOLS_H eap_status_e eap_write_u32_t_network_order(
   195 	void * const data,
   216 	void * const data,
   196 	const u32_t data_length,
   217 	const u32_t data_length,
   197 	const u32_t value);
   218 	const u32_t value);
   198 
   219 
   199 /**
   220 /**
   200  * This function writes 64-bit unsigned integer to network order to memory
   221  * This function writes 64-bit unsigned integer to network order to memory
   201  * and returns status eap_status_ok when successfull.
   222  * and returns status eap_status_ok when successfull.
   202  */
   223  */
   203 EAP_C_FUNC_IMPORT eap_status_e eap_write_u64_t_network_order(
   224 EAP_C_FUNC_VISIBILITY_EAP_TOOLS_H eap_status_e eap_write_u64_t_network_order(
   204 	void * const data,
   225 	void * const data,
   205 	const u32_t data_length,
   226 	const u32_t data_length,
   206 	const u64_t value);
   227 	const u64_t value);
   207 
   228 
   208 
   229 
   209 
   230 
   210 EAP_C_FUNC_IMPORT u64_t eap_shift_left_64_bit(u64_t value, u32_t shift);
   231 EAP_C_FUNC_VISIBILITY_EAP_TOOLS_H u64_t eap_shift_left_64_bit(u64_t value, u32_t shift);
   211 
   232 
   212 EAP_C_FUNC_IMPORT u64_t eap_shift_right_64_bit(u64_t value, u32_t shift);
   233 EAP_C_FUNC_VISIBILITY_EAP_TOOLS_H u64_t eap_shift_right_64_bit(u64_t value, u32_t shift);
   213 
   234 
   214 
   235 
   215 inline u64_t eap_read_u64_t_host_order(
   236 inline u64_t eap_read_u64_t_host_order(
   216 	const void * const p_data,
   237 	const void * const p_data,
   217 	const u32_t data_length)
   238 	const u32_t data_length)