eapol/eapol_framework/eapol_common/type/simple_config/simple_config/include/simple_config_payloads.h
changeset 52 c23bdf5a328a
parent 39 fe6b6762fccd
equal deleted inserted replaced
51:e863583e6720 52:c23bdf5a328a
    22 #if !defined(_SIMPLE_CONFIG_PAYLOADS_H_)
    22 #if !defined(_SIMPLE_CONFIG_PAYLOADS_H_)
    23 #define _SIMPLE_CONFIG_PAYLOADS_H_
    23 #define _SIMPLE_CONFIG_PAYLOADS_H_
    24 
    24 
    25 #include "eap_variable_data.h"
    25 #include "eap_variable_data.h"
    26 #include "eap_am_export.h"
    26 #include "eap_am_export.h"
       
    27 // Start: added by script change_export_macros.sh.
       
    28 #if defined(EAP_NO_EXPORT_SIMPLE_CONFIG_PAYLOADS_H)
       
    29 	#define EAP_CLASS_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H EAP_NONSHARABLE 
       
    30 	#define EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H 
       
    31 	#define EAP_C_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H 
       
    32 	#define EAP_FUNC_EXPORT_SIMPLE_CONFIG_PAYLOADS_H 
       
    33 	#define EAP_C_FUNC_EXPORT_SIMPLE_CONFIG_PAYLOADS_H 
       
    34 #elif defined(EAP_EXPORT_SIMPLE_CONFIG_PAYLOADS_H)
       
    35 	#define EAP_CLASS_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H EAP_EXPORT 
       
    36 	#define EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H EAP_FUNC_EXPORT 
       
    37 	#define EAP_C_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H EAP_C_FUNC_EXPORT 
       
    38 	#define EAP_FUNC_EXPORT_SIMPLE_CONFIG_PAYLOADS_H EAP_FUNC_EXPORT 
       
    39 	#define EAP_C_FUNC_EXPORT_SIMPLE_CONFIG_PAYLOADS_H EAP_C_FUNC_EXPORT 
       
    40 #else
       
    41 	#define EAP_CLASS_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H EAP_IMPORT 
       
    42 	#define EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H EAP_FUNC_IMPORT 
       
    43 	#define EAP_C_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H EAP_C_FUNC_IMPORT 
       
    44 	#define EAP_FUNC_EXPORT_SIMPLE_CONFIG_PAYLOADS_H 
       
    45 	#define EAP_C_FUNC_EXPORT_SIMPLE_CONFIG_PAYLOADS_H 
       
    46 #endif
       
    47 // End: added by script change_export_macros.sh.
    27 #include "simple_config_tlv_header.h"
    48 #include "simple_config_tlv_header.h"
    28 #include "simple_config_attribute_type.h"
    49 #include "simple_config_attribute_type.h"
    29 #include "eap_core_map.h"
    50 #include "eap_core_map.h"
    30 #include "eap_array.h"
    51 #include "eap_array.h"
    31 
    52 
    32 class simple_config_message_c;
    53 class simple_config_message_c;
    33 class crypto_hmac_c;
    54 class crypto_hmac_c;
    34 
    55 
    35 class EAP_EXPORT simple_config_variable_data_c
    56 class EAP_CLASS_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H simple_config_variable_data_c
    36 {
    57 {
    37 private:
    58 private:
    38 	//--------------------------------------------------
    59 	//--------------------------------------------------
    39 
    60 
    40 	abs_eap_am_tools_c * const m_am_tools;
    61 	abs_eap_am_tools_c * const m_am_tools;
    57 
    78 
    58 	//--------------------------------------------------
    79 	//--------------------------------------------------
    59 public:
    80 public:
    60 	//--------------------------------------------------
    81 	//--------------------------------------------------
    61 
    82 
    62 	EAP_FUNC_IMPORT virtual ~simple_config_variable_data_c();
    83 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H virtual ~simple_config_variable_data_c();
    63 
    84 
    64 	EAP_FUNC_IMPORT simple_config_variable_data_c(abs_eap_am_tools_c * const tools);
    85 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H simple_config_variable_data_c(abs_eap_am_tools_c * const tools);
    65 
    86 
    66 	EAP_FUNC_IMPORT bool get_is_valid() const;
    87 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H bool get_is_valid() const;
    67 
    88 
    68 	EAP_FUNC_IMPORT eap_status_e set_copy_of_buffer(
    89 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H eap_status_e set_copy_of_buffer(
    69 		const simple_config_Attribute_Type_e current_payload_code,
    90 		const simple_config_Attribute_Type_e current_payload_code,
    70 		const bool is_mandatory,
    91 		const bool is_mandatory,
    71 		const void * const buffer,
    92 		const void * const buffer,
    72 		const u32_t buffer_length);
    93 		const u32_t buffer_length);
    73 
    94 
    74 	EAP_FUNC_IMPORT eap_status_e add_data(
    95 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H eap_status_e add_data(
    75 		const void * const buffer,
    96 		const void * const buffer,
    76 		const u32_t buffer_length);
    97 		const u32_t buffer_length);
    77 
    98 
    78 	EAP_FUNC_IMPORT u32_t get_data_length() const;
    99 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H u32_t get_data_length() const;
    79 
   100 
    80 	EAP_FUNC_IMPORT u8_t * get_data(const u32_t data_length) const;
   101 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H u8_t * get_data(const u32_t data_length) const;
    81 
   102 
    82 	EAP_FUNC_IMPORT simple_config_tlv_header_c * get_header();
   103 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H simple_config_tlv_header_c * get_header();
    83 
   104 
    84 	EAP_FUNC_IMPORT eap_variable_data_c * get_full_attribute_buffer();
   105 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H eap_variable_data_c * get_full_attribute_buffer();
    85 
   106 
    86 	EAP_FUNC_IMPORT simple_config_Attribute_Type_e get_attribute_type() const;
   107 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H simple_config_Attribute_Type_e get_attribute_type() const;
    87 
   108 
    88 	EAP_FUNC_IMPORT bool get_is_mandatory() const;
   109 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H bool get_is_mandatory() const;
    89 
   110 
    90 	EAP_FUNC_IMPORT void set_attribute_type(const simple_config_Attribute_Type_e type);
   111 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H void set_attribute_type(const simple_config_Attribute_Type_e type);
    91 
   112 
    92 	EAP_FUNC_IMPORT void add_next_payload_with_same_attribute_type(simple_config_variable_data_c * const attribute);
   113 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H void add_next_payload_with_same_attribute_type(simple_config_variable_data_c * const attribute);
    93 
   114 
    94 	EAP_FUNC_IMPORT void set_next_payload_with_same_attribute_type(simple_config_variable_data_c * attribute);
   115 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H void set_next_payload_with_same_attribute_type(simple_config_variable_data_c * attribute);
    95 
   116 
    96 	EAP_FUNC_IMPORT simple_config_variable_data_c * get_next_payload_with_same_attribute_type();
   117 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H simple_config_variable_data_c * get_next_payload_with_same_attribute_type();
    97 
   118 
    98 	EAP_FUNC_IMPORT simple_config_variable_data_c * copy() const;
   119 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H simple_config_variable_data_c * copy() const;
    99 
   120 
   100 	EAP_FUNC_IMPORT void object_increase_reference_count();
   121 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H void object_increase_reference_count();
   101 
   122 
   102 	EAP_FUNC_IMPORT eap_status_e check_header() const;
   123 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H eap_status_e check_header() const;
   103 
   124 
   104 	//--------------------------------------------------
   125 	//--------------------------------------------------
   105 }; // class simple_config_variable_data_c
   126 }; // class simple_config_variable_data_c
   106 
   127 
   107 
   128 
   108 //--------------------------------------------------
   129 //--------------------------------------------------
   109 
   130 
   110 
   131 
   111 // 
   132 // 
   112 class EAP_EXPORT simple_config_payloads_c
   133 class EAP_CLASS_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H simple_config_payloads_c
   113 : public abs_eap_core_map_c
   134 : public abs_eap_core_map_c
   114 {
   135 {
   115 private:
   136 private:
   116 	//--------------------------------------------------
   137 	//--------------------------------------------------
   117 
   138 
   144 
   165 
   145 	//--------------------------------------------------
   166 	//--------------------------------------------------
   146 public:
   167 public:
   147 	//--------------------------------------------------
   168 	//--------------------------------------------------
   148 
   169 
   149 	EAP_FUNC_IMPORT virtual ~simple_config_payloads_c();
   170 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H virtual ~simple_config_payloads_c();
   150 
   171 
   151 	EAP_FUNC_IMPORT simple_config_payloads_c(
   172 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H simple_config_payloads_c(
   152 		abs_eap_am_tools_c * const tools);
   173 		abs_eap_am_tools_c * const tools);
   153 
   174 
   154 	EAP_FUNC_IMPORT simple_config_variable_data_c * get_attribute_pointer(
   175 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H simple_config_variable_data_c * get_attribute_pointer(
   155 		const simple_config_Attribute_Type_e current_payload,
   176 		const simple_config_Attribute_Type_e current_payload,
   156 		u32_t index) const;
   177 		u32_t index) const;
   157 
   178 
   158 	EAP_FUNC_IMPORT simple_config_variable_data_c * get_attribute_pointer(
   179 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H simple_config_variable_data_c * get_attribute_pointer(
   159 		const simple_config_Attribute_Type_e current_payload) const;
   180 		const simple_config_Attribute_Type_e current_payload) const;
   160 
   181 
   161 
   182 
   162 	EAP_FUNC_IMPORT u32_t get_attribute_count() const;
   183 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H u32_t get_attribute_count() const;
   163 
   184 
   164 	EAP_FUNC_IMPORT simple_config_variable_data_c * get_attribute(const u32_t attribute_index) const;
   185 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H simple_config_variable_data_c * get_attribute(const u32_t attribute_index) const;
   165 
   186 
   166 	/**
   187 	/**
   167 	 * This function adds new_payload object to payloads.
   188 	 * This function adds new_payload object to payloads.
   168 	 * NOTE the data is NOT copied.
   189 	 * NOTE the data is NOT copied.
   169 	 */
   190 	 */
   170 	EAP_FUNC_IMPORT eap_status_e add_attribute(
   191 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H eap_status_e add_attribute(
   171 		simple_config_variable_data_c *new_payload);
   192 		simple_config_variable_data_c *new_payload);
   172 
   193 
   173 	/**
   194 	/**
   174 	 * This function copies the selected attribute from source to payloads.
   195 	 * This function copies the selected attribute from source to payloads.
   175 	 */
   196 	 */
   176 	EAP_FUNC_IMPORT eap_status_e copy_attribute(
   197 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H eap_status_e copy_attribute(
   177 		const simple_config_payloads_c * const source,
   198 		const simple_config_payloads_c * const source,
   178 		const simple_config_Attribute_Type_e attribute);
   199 		const simple_config_Attribute_Type_e attribute);
   179 
   200 
   180 	/**
   201 	/**
   181 	 * This function copies the attribute data to payloads.
   202 	 * This function copies the attribute data to payloads.
   182 	 */
   203 	 */
   183 	EAP_FUNC_IMPORT eap_status_e copy_attribute_data(
   204 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H eap_status_e copy_attribute_data(
   184 		const simple_config_Attribute_Type_e current_payload,
   205 		const simple_config_Attribute_Type_e current_payload,
   185 		const bool is_mandatory,
   206 		const bool is_mandatory,
   186 		const void * const data,
   207 		const void * const data,
   187 		const u32_t data_length);
   208 		const u32_t data_length);
   188 
   209 
   189 	/**
   210 	/**
   190 	 *	Function retrieves data of attribute type to data object.
   211 	 *	Function retrieves data of attribute type to data object.
   191 	 */
   212 	 */
   192 	EAP_FUNC_IMPORT eap_status_e get_attribute_data(
   213 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H eap_status_e get_attribute_data(
   193 		const simple_config_Attribute_Type_e copied_attribute_type,
   214 		const simple_config_Attribute_Type_e copied_attribute_type,
   194 		eap_variable_data_c * const data) const;
   215 		eap_variable_data_c * const data) const;
   195 
   216 
   196 	/**
   217 	/**
   197 	 *	Function retrieves data of attribute type to data object.
   218 	 *	Function retrieves data of attribute type to data object.
   198 	 */
   219 	 */
   199 	EAP_FUNC_IMPORT eap_status_e get_attribute_data(
   220 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H eap_status_e get_attribute_data(
   200 		const simple_config_Attribute_Type_e copied_attribute_type,
   221 		const simple_config_Attribute_Type_e copied_attribute_type,
   201 		u8_t * const data) const;
   222 		u8_t * const data) const;
   202 
   223 
   203 	/**
   224 	/**
   204 	 *	Function retrieves data of attribute type to data object.
   225 	 *	Function retrieves data of attribute type to data object.
   205 	 */
   226 	 */
   206 	EAP_FUNC_IMPORT eap_status_e get_attribute_data(
   227 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H eap_status_e get_attribute_data(
   207 		const simple_config_Attribute_Type_e copied_attribute_type,
   228 		const simple_config_Attribute_Type_e copied_attribute_type,
   208 		u16_t * const data) const;
   229 		u16_t * const data) const;
   209 
   230 
   210 	/**
   231 	/**
   211 	 *	Function retrieves data of attribute type to data object.
   232 	 *	Function retrieves data of attribute type to data object.
   212 	 */
   233 	 */
   213 	EAP_FUNC_IMPORT eap_status_e get_attribute_data(
   234 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H eap_status_e get_attribute_data(
   214 		const simple_config_Attribute_Type_e copied_attribute_type,
   235 		const simple_config_Attribute_Type_e copied_attribute_type,
   215 		u32_t * const data) const;
   236 		u32_t * const data) const;
   216 
   237 
   217 	/**
   238 	/**
   218 	 *	Function retrieves data of attribute type to data object.
   239 	 *	Function retrieves data of attribute type to data object.
   219 	 */
   240 	 */
   220 	EAP_FUNC_IMPORT eap_status_e get_attribute_data(
   241 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H eap_status_e get_attribute_data(
   221 		const simple_config_Attribute_Type_e copied_attribute_type,
   242 		const simple_config_Attribute_Type_e copied_attribute_type,
   222 		u64_t * const data) const;
   243 		u64_t * const data) const;
   223 
   244 
   224 	/**
   245 	/**
   225 	 * This function parses the payloads starting from specified payload (p_payload).
   246 	 * This function parses the payloads starting from specified payload (p_payload).
   227 	 * Payloads are stored to member variables.
   248 	 * Payloads are stored to member variables.
   228 	 * @return If the length of the buffer and sum of the length of all payloads does not match
   249 	 * @return If the length of the buffer and sum of the length of all payloads does not match
   229 	 * function returns eap_status_header_corrupted.
   250 	 * function returns eap_status_header_corrupted.
   230 	 * Also error is returned when illegal payload attribute is recognised.
   251 	 * Also error is returned when illegal payload attribute is recognised.
   231 	 */
   252 	 */
   232 	EAP_FUNC_IMPORT eap_status_e parse_simple_config_payloads(
   253 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H eap_status_e parse_simple_config_payloads(
   233 		void * const message_buffer, ///< This is the start of the message buffer.
   254 		void * const message_buffer, ///< This is the start of the message buffer.
   234 		u32_t * const buffer_length, ///< This is the length of the buffer. This must match with the length of all payloads.
   255 		u32_t * const buffer_length, ///< This is the length of the buffer. This must match with the length of all payloads.
   235 		u32_t * const padding_length ///< Length of possible padding is set to this variable.
   256 		u32_t * const padding_length ///< Length of possible padding is set to this variable.
   236 		);
   257 		);
   237 
   258 
   238 	/**
   259 	/**
   239 	 * This function parses each payload attributes.
   260 	 * This function parses each payload attributes.
   240 	 * @return If payload attribute is illegal function returns eap_status_header_corrupted.
   261 	 * @return If payload attribute is illegal function returns eap_status_header_corrupted.
   241 	 * If payload attribute is unknown function returns eap_status_unsupported_payload.
   262 	 * If payload attribute is unknown function returns eap_status_unsupported_payload.
   242 	 */
   263 	 */
   243 	EAP_FUNC_IMPORT eap_status_e parse_generic_payload(
   264 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H eap_status_e parse_generic_payload(
   244 		const simple_config_Attribute_Type_e current_payload, ///< This is the type of current payload attribute.
   265 		const simple_config_Attribute_Type_e current_payload, ///< This is the type of current payload attribute.
   245 		const simple_config_tlv_header_c * const payload ///< This is the current parsed payload.
   266 		const simple_config_tlv_header_c * const payload ///< This is the current parsed payload.
   246 		);
   267 		);
   247 
   268 
   248 	EAP_FUNC_IMPORT eap_status_e check_payloads_existense(
   269 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H eap_status_e check_payloads_existense(
   249 		const simple_config_Attribute_Type_e * const needed_payloads,
   270 		const simple_config_Attribute_Type_e * const needed_payloads,
   250 		const u32_t count_of_needed_payloads) const;
   271 		const u32_t count_of_needed_payloads) const;
   251 
   272 
   252 	/**
   273 	/**
   253 	 * This function checks all mandatory AVPs are used.
   274 	 * This function checks all mandatory AVPs are used.
   254 	 */
   275 	 */
   255 	EAP_FUNC_IMPORT eap_status_e check_mandatory_payloads(
   276 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H eap_status_e check_mandatory_payloads(
   256 		EAP_TEMPLATE_CONST eap_array_c<simple_config_Attribute_Type_e> * const used_payloads) const;
   277 		EAP_TEMPLATE_CONST eap_array_c<simple_config_Attribute_Type_e> * const used_payloads) const;
   257 
   278 
   258 	/**
   279 	/**
   259 	 * This function checks all required AVPs are received.
   280 	 * This function checks all required AVPs are received.
   260 	 */
   281 	 */
   261 	EAP_FUNC_IMPORT eap_status_e check_payloads_existense(
   282 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H eap_status_e check_payloads_existense(
   262 		EAP_TEMPLATE_CONST eap_array_c<simple_config_Attribute_Type_e> * const needed_payloads) const;
   283 		EAP_TEMPLATE_CONST eap_array_c<simple_config_Attribute_Type_e> * const needed_payloads) const;
   263 
   284 
   264 	EAP_FUNC_IMPORT bool get_is_valid() const;
   285 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H bool get_is_valid() const;
   265 
   286 
   266 	EAP_FUNC_IMPORT eap_status_e create_simple_config_message(
   287 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H eap_status_e create_simple_config_message(
   267 		simple_config_message_c * const new_simple_config_message_data,
   288 		simple_config_message_c * const new_simple_config_message_data,
   268 		const bool add_payloads) const;
   289 		const bool add_payloads) const;
   269 
   290 
   270 	EAP_FUNC_IMPORT eap_status_e add_payloads_to_simple_config_authenticator(
   291 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H eap_status_e add_payloads_to_simple_config_authenticator(
   271 		crypto_hmac_c * const hmac_sha_256,
   292 		crypto_hmac_c * const hmac_sha_256,
   272 		const bool include_authenticator_attribute) const;
   293 		const bool include_authenticator_attribute) const;
   273 
   294 
   274 	EAP_FUNC_IMPORT eap_status_e reset();
   295 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H eap_status_e reset();
   275 
   296 
   276 	EAP_FUNC_IMPORT simple_config_payloads_c * copy() const;
   297 	EAP_FUNC_VISIBILITY_SIMPLE_CONFIG_PAYLOADS_H simple_config_payloads_c * copy() const;
   277 
   298 
   278 	//--------------------------------------------------
   299 	//--------------------------------------------------
   279 }; // class simple_config_payloads_c
   300 }; // class simple_config_payloads_c
   280 
   301 
   281 
   302