eapol/eapol_framework/eapol_common/am/include/eap_file_config.h
branchRCL_3
changeset 46 c74b3d9f6b9e
parent 45 bad0cc58d154
equal deleted inserted replaced
45:bad0cc58d154 46:c74b3d9f6b9e
    14 * Description:  EAP and WLAN authentication protocols.
    14 * Description:  EAP and WLAN authentication protocols.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 /*
    18 /*
    19 * %version: 18 %
    19 * %version: 11.1.2 %
    20 */
    20 */
    21 
    21 
    22 #ifndef _FILECONFIG_H
    22 #ifndef _FILECONFIG_H
    23 #define _FILECONFIG_H
    23 #define _FILECONFIG_H
    24 
    24 
    25 #include "eap_core_map.h"
    25 #include "eap_core_map.h"
    26 #include "eap_configuration_field.h"
    26 #include "eap_configuration_field.h"
    27 #include "abs_eap_am_file_input.h"
    27 #include "abs_eap_am_file_input.h"
    28 
    28 
    29 class eap_tlv_header_c;
       
    30 
       
    31 
    29 
    32 template <class Type>
    30 template <class Type>
    33 Type minimum( Type a, Type b )
    31 Type minimum( Type a, Type b )
    34 {
    32 {
    35 	return a < b ? a : b;
    33 	return a < b ? a : b;
    36 }
    34 }
    37 
    35 
    38 
    36 
    39 class EAP_EXPORT eap_config_value_c
    37 class eap_config_value_c
    40 {
    38 {
    41 private:
    39 private:
    42 
    40 
    43 	abs_eap_am_tools_c* const m_am_tools;
    41 	abs_eap_am_tools_c* const m_am_tools;
    44 
    42 
    50 
    48 
    51 	bool m_is_valid;
    49 	bool m_is_valid;
    52 
    50 
    53 public:
    51 public:
    54 
    52 
    55 	EAP_FUNC_IMPORT virtual ~eap_config_value_c();
    53 	virtual ~eap_config_value_c();
    56 
    54 
    57 	EAP_FUNC_IMPORT eap_config_value_c(
    55 	eap_config_value_c(
    58 		abs_eap_am_tools_c* const tools);
    56 		abs_eap_am_tools_c* const tools);
    59 
    57 
    60 	EAP_FUNC_IMPORT void set_subsection(
    58 	void set_subsection(
    61 		eap_core_map_c<eap_config_value_c, abs_eap_core_map_c, eap_variable_data_c> * const subsection_map);
    59 		eap_core_map_c<eap_config_value_c, abs_eap_core_map_c, eap_variable_data_c> * const subsection_map);
    62 
    60 
    63 	EAP_FUNC_IMPORT eap_core_map_c<eap_config_value_c, abs_eap_core_map_c, eap_variable_data_c> * get_subsection();
    61 	eap_core_map_c<eap_config_value_c, abs_eap_core_map_c, eap_variable_data_c> * get_subsection();
    64 
    62 
    65 	EAP_FUNC_IMPORT eap_variable_data_c * get_data();
    63 	eap_variable_data_c * get_data();
    66 
    64 
    67 	EAP_FUNC_IMPORT const eap_variable_data_c * get_const_data() const;
    65 	void set_type(const eap_configure_type_e type);
    68 
    66 
    69 	EAP_FUNC_IMPORT void set_type(const eap_configure_type_e type);
    67 	eap_configure_type_e get_type();
    70 
    68 
    71 	EAP_FUNC_IMPORT eap_configure_type_e get_type();
    69 	void object_increase_reference_count();
    72 
    70 
    73 	EAP_FUNC_IMPORT eap_configure_type_e get_const_type() const;
    71 	bool get_is_valid();
    74 
       
    75 	EAP_FUNC_IMPORT void object_increase_reference_count();
       
    76 
       
    77 	EAP_FUNC_IMPORT bool get_is_valid() const;
       
    78 
    72 
    79 };
    73 };
    80 
    74 
    81 const u32_t MAX_LINE_LENGTH = 1024;
    75 const u32_t MAX_LINE_LENGTH = 1024;
    82 const u32_t MAX_CONFIG_TYPE_LENGTH = 32;
    76 const u32_t MAX_CONFIG_TYPE_LENGTH = 32;
   143 class EAP_EXPORT eap_file_config_c
   137 class EAP_EXPORT eap_file_config_c
   144 : public abs_eap_core_map_c
   138 : public abs_eap_core_map_c
   145 {
   139 {
   146   
   140   
   147  private:
   141  private:
   148 
       
   149 	abs_eap_am_tools_c* const m_am_tools;
   142 	abs_eap_am_tools_c* const m_am_tools;
   150 
   143 
   151 	/// This stores eap_config_value_c objects using eap_variable_data selector.
   144 	/// This stores eap_config_value_c objects using eap_variable_data selector.
   152 	eap_core_map_c<eap_config_value_c, abs_eap_core_map_c, eap_variable_data_c> m_config_map;
   145 	eap_core_map_c<eap_config_value_c, abs_eap_core_map_c, eap_variable_data_c> m_config_map;
   153 
   146 
   154 	eap_variable_data_c m_value_buffer;
       
   155 
       
   156 	bool m_is_valid;
   147 	bool m_is_valid;
   157 
   148 
   158 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   149 	EAP_FUNC_IMPORT eap_status_e expand_environment_variables(
   159 
       
   160 	eap_status_e expand_environment_variables(
       
   161 		eap_core_map_c<eap_config_value_c, abs_eap_core_map_c, eap_variable_data_c> * const config_map,
   150 		eap_core_map_c<eap_config_value_c, abs_eap_core_map_c, eap_variable_data_c> * const config_map,
   162 		const eap_variable_data_c * const value,
   151 		const eap_variable_data_c * const value,
   163 		eap_variable_data_c * const expanded_value
   152 		eap_variable_data_c * const expanded_value
   164 		);
   153 		);
   165 
   154 
   166 	eap_status_e remove_spaces(eap_variable_data_c * const buffer);
   155 	EAP_FUNC_IMPORT eap_status_e remove_spaces(eap_variable_data_c * const buffer);
   167 
   156 
   168 	eap_status_e remove_leading_spaces(eap_variable_data_c * const line);
   157 	EAP_FUNC_IMPORT eap_status_e remove_leading_spaces(eap_variable_data_c * const line);
   169 
   158 
   170 	eap_status_e read_section(
   159 	EAP_FUNC_IMPORT eap_status_e read_section(
   171 		abs_eap_am_file_input_c * const file,
   160 		abs_eap_am_file_input_c * const file,
   172 		eap_core_map_c<eap_config_value_c, abs_eap_core_map_c, eap_variable_data_c> * const config_map);
   161 		eap_core_map_c<eap_config_value_c, abs_eap_core_map_c, eap_variable_data_c> * const config_map);
   173 
   162 
   174 	eap_status_e read_subsections(
   163 	EAP_FUNC_IMPORT eap_status_e  read_subsections(
   175 		abs_eap_am_file_input_c * const file,
   164 		abs_eap_am_file_input_c * const file,
   176 		eap_core_map_c<eap_config_value_c, abs_eap_core_map_c, eap_variable_data_c> * const config_map);
   165 		eap_core_map_c<eap_config_value_c, abs_eap_core_map_c, eap_variable_data_c> * const config_map);
   177 
   166 
   178 	eap_status_e get_subsect(
   167 	EAP_FUNC_IMPORT eap_status_e get_subsect(
   179 		abs_eap_am_file_input_c * const file,
   168 		abs_eap_am_file_input_c * const file,
   180 		eap_variable_data_c * const line);
   169 		eap_variable_data_c * const line);
   181 
   170 
   182 	eap_status_e convert_value(
   171 	EAP_FUNC_IMPORT eap_status_e convert_value(
   183 		eap_core_map_c<eap_config_value_c, abs_eap_core_map_c, eap_variable_data_c> * const config_map,
   172 		eap_core_map_c<eap_config_value_c, abs_eap_core_map_c, eap_variable_data_c> * const config_map,
   184 		const eap_variable_data_c * const value_buffer,
   173 		const eap_variable_data_c * const value_buffer,
   185 		const eap_configure_type_e type,
   174 		const eap_configure_type_e type,
   186 		eap_variable_data_c * const value_data);
   175 		eap_variable_data_c * const value_data);
   187 
   176 
   188 	eap_status_e store_configure(
   177 	EAP_FUNC_IMPORT eap_status_e store_configure(
   189 		abs_eap_am_file_input_c * const file,
   178 		abs_eap_am_file_input_c * const file,
   190 		const eap_variable_data_c * const line,
   179 		const eap_variable_data_c * const line,
   191 		eap_core_map_c<eap_config_value_c, abs_eap_core_map_c, eap_variable_data_c> * const config_map);
   180 		eap_core_map_c<eap_config_value_c, abs_eap_core_map_c, eap_variable_data_c> * const config_map);
   192 
   181 
   193 	eap_status_e cnf_parse_value(
   182 	EAP_FUNC_IMPORT eap_status_e cnf_parse_value(
   194 		const eap_variable_data_c * const found_type_value,
   183 		const eap_variable_data_c * const found_type_value,
   195 		const eap_variable_data_c * const found_type_name,
   184 		const eap_variable_data_c * const found_type_name,
   196 		eap_configure_type_e * const parsed_type,
   185 		eap_configure_type_e * const parsed_type,
   197 		eap_variable_data_c * const parsed_type_value,
   186 		eap_variable_data_c * const parsed_type_value,
   198 		const bool is_environment_variable);
   187 		const bool is_environment_variable);
   199 
   188 
   200 	eap_status_e cnf_get_string(
   189 	EAP_FUNC_IMPORT eap_status_e cnf_get_string(
   201 		const eap_variable_data_c * const param,
   190 		const eap_variable_data_c * const param,
   202 		eap_variable_data_c * const param_name,
   191 		eap_variable_data_c * const param_name,
   203 		eap_variable_data_c * const param_value,
   192 		eap_variable_data_c * const param_value,
   204 		eap_configure_type_e * const type);
   193 		eap_configure_type_e * const type);
   205 
   194 
   206 	eap_status_e find_rvalue(
   195 	EAP_FUNC_IMPORT eap_status_e find_rvalue(
   207 		const eap_variable_data_c * const config_param,
   196 		const eap_variable_data_c * const config_param,
   208 		bool * const read_env_value,
   197 		bool * const read_env_value,
   209 		eap_variable_data_c * const param_name,
   198 		eap_variable_data_c * const param_name,
   210 		eap_variable_data_c * const param_value
   199 		eap_variable_data_c * const param_value
   211 		);
   200 		);
   212 
   201 
   213 	u8_t * read_hex_byte(
   202 	EAP_FUNC_IMPORT u8_t * read_hex_byte(u8_t * cursor, const u8_t * const end, u8_t * const hex_byte);
   214 		u8_t * cursor,
   203 
   215 		const u8_t * const end,
   204 	EAP_FUNC_IMPORT u8_t * read_u32_t(u8_t * cursor, const u8_t * const end, u32_t * const hex_byte);
   216 		u8_t * const hex_byte,
   205 
   217 		const u32_t hex_byte_length);
   206 	EAP_FUNC_IMPORT eap_status_e read_configure(
   218 
       
   219 	u8_t * read_u32_t(u8_t * cursor, const u8_t * const end, u32_t * const hex_byte);
       
   220 
       
   221 	eap_status_e read_configure(
       
   222 		eap_core_map_c<eap_config_value_c, abs_eap_core_map_c, eap_variable_data_c> * const config_map,
   207 		eap_core_map_c<eap_config_value_c, abs_eap_core_map_c, eap_variable_data_c> * const config_map,
   223 		const eap_configuration_field_c * const field,
   208 		const eap_configuration_field_c * const field,
   224 		eap_variable_data_c* const data,
   209 		eap_variable_data_c* const data,
   225 		eap_configure_type_e * const configuration_data_type,
   210 		eap_configure_type_e * const configuration_data_type,
   226 		const bool existence_test);
   211 		const bool existence_test);
   227 
   212 
   228 	eap_status_e file_read_line(
   213 	EAP_FUNC_IMPORT eap_status_e file_read_line(
   229 		abs_eap_am_file_input_c * const file,
   214 		abs_eap_am_file_input_c * const file,
   230 		eap_variable_data_c * const line);
   215 		eap_variable_data_c * const line);
   231 
   216 
   232 	eap_status_e read_configure(
   217 	EAP_FUNC_IMPORT eap_status_e read_configure(
   233 		const eap_configuration_field_c * const field,
   218 		const eap_configuration_field_c * const field,
   234 		eap_variable_data_c* const data,
   219 		eap_variable_data_c* const data,
   235 		eap_core_map_c<eap_config_value_c, abs_eap_core_map_c, eap_variable_data_c> * const config_map,
   220 		eap_core_map_c<eap_config_value_c, abs_eap_core_map_c, eap_variable_data_c> * const config_map,
   236 		const bool check_subsection_when_true);
   221 		const bool check_subsection_when_true);
   237 
   222 
   238 	eap_status_e read_all_configurations(
       
   239 		const eap_configuration_field_c * const field,
       
   240 		eap_variable_data_c* const data,
       
   241 		eap_core_map_c<eap_config_value_c, abs_eap_core_map_c, eap_variable_data_c> * const config_map);
       
   242 
       
   243 	eap_status_e add_option(
       
   244 		const eap_tlv_header_c * const option_header);
       
   245 
       
   246  public:
   223  public:
   247 
   224 
   248 	EAP_FUNC_IMPORT eap_file_config_c(
   225 	EAP_FUNC_IMPORT eap_file_config_c(
   249 		abs_eap_am_tools_c* const tools);
   226 		abs_eap_am_tools_c* const tools);
   250 
   227 
   251 	EAP_FUNC_IMPORT virtual ~eap_file_config_c();
   228 	EAP_FUNC_IMPORT virtual ~eap_file_config_c();
   252 
   229 
   253 	EAP_FUNC_IMPORT eap_status_e configure(
   230 	EAP_FUNC_IMPORT eap_status_e configure(
   254 		abs_eap_am_file_input_c * const file);
   231 		abs_eap_am_file_input_c * const file);
   255 
       
   256 	EAP_FUNC_IMPORT eap_status_e read_configuration_message(
       
   257 		const eap_variable_data_c * const configuration_message);
       
   258 
   232 
   259 	EAP_FUNC_IMPORT eap_status_e read_configure(
   233 	EAP_FUNC_IMPORT eap_status_e read_configure(
   260 		const eap_configuration_field_c * const field,
   234 		const eap_configuration_field_c * const field,
   261 		eap_variable_data_c* const data);
   235 		eap_variable_data_c* const data);
   262 
   236