eapol/eapol_framework/eapol_common/type/diameter/include/eap_diameter_payloads.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_DIAMETER_RESULT_H_)
       
    22 #define _EAP_DIAMETER_RESULT_H_
       
    23 
       
    24 #include "eap_variable_data.h"
       
    25 #include "eap_am_export.h"
       
    26 #include "eap_diameter_avp_header.h"
       
    27 #include "eap_diameter_avp_code.h"
       
    28 #include "eap_core_map.h"
       
    29 #include "eap_array.h"
       
    30 
       
    31 
       
    32 class EAP_EXPORT eap_diameter_variable_data_c
       
    33 {
       
    34 private:
       
    35 	//--------------------------------------------------
       
    36 
       
    37 	abs_eap_am_tools_c * const m_am_tools;
       
    38 
       
    39 	eap_variable_data_c m_data;
       
    40 
       
    41 	eap_diameter_avp_code_c m_payload_code;
       
    42 
       
    43 	bool m_is_mandatory;
       
    44 
       
    45 	//--------------------------------------------------
       
    46 protected:
       
    47 	//--------------------------------------------------
       
    48 
       
    49 	//--------------------------------------------------
       
    50 public:
       
    51 	//--------------------------------------------------
       
    52 
       
    53 	EAP_FUNC_IMPORT virtual ~eap_diameter_variable_data_c();
       
    54 
       
    55 	EAP_FUNC_IMPORT eap_diameter_variable_data_c(abs_eap_am_tools_c * const tools);
       
    56 
       
    57 	EAP_FUNC_IMPORT eap_status_e set_buffer(
       
    58 		const eap_diameter_avp_code_c current_payload_code,
       
    59 		const bool is_mandatory,
       
    60 		const u8_t * const buffer,
       
    61 		const u32_t buffer_length,
       
    62 		const bool free_buffer,
       
    63 		const bool is_writable);
       
    64 
       
    65 	EAP_FUNC_IMPORT eap_status_e add_data(
       
    66 		const u8_t * const buffer,
       
    67 		const u32_t buffer_length);
       
    68 
       
    69 	EAP_FUNC_IMPORT u32_t get_data_length() const;
       
    70 
       
    71 	EAP_FUNC_IMPORT u8_t * get_data(const u32_t data_length) const;
       
    72 
       
    73 	EAP_FUNC_IMPORT eap_variable_data_c * get_payload_buffer();
       
    74 
       
    75 	EAP_FUNC_IMPORT eap_diameter_avp_code_c get_payload_code() const;
       
    76 
       
    77 	EAP_FUNC_IMPORT bool get_is_mandatory() const;
       
    78 
       
    79 	EAP_FUNC_IMPORT void set_payload_code(const eap_diameter_avp_code_c code);
       
    80 
       
    81 	EAP_FUNC_IMPORT eap_diameter_variable_data_c * copy() const;
       
    82 
       
    83 	EAP_FUNC_IMPORT  void object_increase_reference_count();
       
    84 
       
    85 	//--------------------------------------------------
       
    86 }; // class eap_diameter_variable_data_c
       
    87 
       
    88 
       
    89 //--------------------------------------------------
       
    90 
       
    91 
       
    92 // 
       
    93 class EAP_EXPORT eap_diameter_payloads_c
       
    94 : public abs_eap_core_map_c
       
    95 {
       
    96 private:
       
    97 	//--------------------------------------------------
       
    98 
       
    99 	abs_eap_am_tools_c * const m_am_tools;
       
   100 
       
   101 	/// This stores the eap_diameter_variable_data_c objects using eap_variable_data selector.
       
   102 	eap_core_map_c<eap_diameter_variable_data_c, abs_eap_core_map_c, eap_variable_data_c> m_payload_map;
       
   103 
       
   104 	/// This stores the same eap_diameter_variable_data_c objects to array.
       
   105 	/// This is to speed the sequential check of all payloads.
       
   106 	eap_array_c<eap_diameter_variable_data_c> m_read_payloads;
       
   107 
       
   108 	bool m_is_valid;
       
   109 
       
   110 	//--------------------------------------------------
       
   111 protected:
       
   112 	//--------------------------------------------------
       
   113 
       
   114 	//--------------------------------------------------
       
   115 public:
       
   116 	//--------------------------------------------------
       
   117 
       
   118 	EAP_FUNC_IMPORT virtual ~eap_diameter_payloads_c();
       
   119 
       
   120 	EAP_FUNC_IMPORT eap_diameter_payloads_c(
       
   121 		abs_eap_am_tools_c * const tools);
       
   122 
       
   123 	EAP_FUNC_IMPORT eap_diameter_variable_data_c * get_payload(
       
   124 		const eap_diameter_avp_code_c current_payload);
       
   125 
       
   126 	EAP_FUNC_IMPORT eap_status_e add_payload(
       
   127 		const eap_diameter_avp_code_c current_payload,
       
   128 		const bool is_mandatory,
       
   129 		const u8_t * const data,
       
   130 		const u32_t data_length,
       
   131 		const bool free_buffer,
       
   132 		const bool is_writable,
       
   133 		const bool fragments_allowed);
       
   134 
       
   135 	/**
       
   136 	 * This function parses the payloads starting from specified payload (p_payload).
       
   137 	 * Function parses all payloads from the buffer.
       
   138 	 * Payloads are stored to p_radius_payloads.
       
   139 	 * @return If the length of the buffer and sum of the length of all payloads does not match
       
   140 	 * function returns eap_status_header_corrupted.
       
   141 	 * Also error is returned when illegal payload attribute is recognised.
       
   142 	 */
       
   143 	EAP_FUNC_IMPORT eap_status_e parse_diameter_payloads(
       
   144 		const eap_diameter_avp_header_c * const p_payload, ///< This is the start of the buffer and the first parsed payload.
       
   145 		u32_t * const buffer_length ///< This is the length of the buffer. This must match with the length of all payloads.
       
   146 		);
       
   147 
       
   148 	/**
       
   149 	 * This function parses each payload attributes.
       
   150 	 * @return If payload attribute is illegal function returns eap_status_header_corrupted.
       
   151 	 * If payload attribute is unknown function returns eap_status_unsupported_payload.
       
   152 	 */
       
   153 	EAP_FUNC_IMPORT eap_status_e parse_generic_payload(
       
   154 		const eap_diameter_avp_code_c current_payload, ///< This is the type of current payload attribute.
       
   155 		const eap_diameter_avp_header_c * const payload ///< This is the current parsed payload.
       
   156 		);
       
   157 
       
   158 	/**
       
   159 	 * This function checks all mandatory AVPs are used.
       
   160 	 */
       
   161 	EAP_FUNC_IMPORT eap_status_e check_mandatory_payloads(
       
   162 		EAP_TEMPLATE_CONST eap_array_c<eap_diameter_avp_code_c> * const used_payloads);
       
   163 
       
   164 	/**
       
   165 	 * This function checks all required AVPs are received.
       
   166 	 */
       
   167 	EAP_FUNC_IMPORT eap_status_e check_payloads_existense(
       
   168 		EAP_TEMPLATE_CONST eap_array_c<eap_diameter_avp_code_c> * const needed_payloads);
       
   169 
       
   170 	EAP_FUNC_IMPORT bool get_is_valid() const;
       
   171 
       
   172 	EAP_FUNC_IMPORT eap_status_e reset();
       
   173 
       
   174 	//--------------------------------------------------
       
   175 }; // class eap_diameter_payloads_c
       
   176 
       
   177 
       
   178 #endif //#if !defined(_EAP_DIAMETER_RESULT_H_)
       
   179 
       
   180 //--------------------------------------------------
       
   181 
       
   182 
       
   183 
       
   184 // End.