eapol/eapol_framework/eapol_common/include/eap_tlv_message_data.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_TLV_MESSAGE_DATA_H_)
       
    22 #define _EAP_TLV_MESSAGE_DATA_H_
       
    23 
       
    24 #include "eap_am_types.h"
       
    25 #include "eap_tools.h"
       
    26 #include "eap_array.h"
       
    27 #include "eap_tlv_header.h"
       
    28 
       
    29 /** @file */
       
    30 
       
    31 
       
    32 //----------------------------------------------------------------------------
       
    33 
       
    34 
       
    35 /// This class defines message data composed of Attribute-Value Pairs (See eap_tlv_header_c).
       
    36 /**
       
    37  * Here is a figure of message data composed of Attribute-Value Pairs (See eap_tlv_header_c).
       
    38  * Value data follows eap_tlv_message_data_c.
       
    39  * @code
       
    40  *  EAP-TLV-message data:
       
    41  *  0                   1                   2                   3   
       
    42  *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 
       
    43  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    44  * |                              Type                             |
       
    45  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    46  * |                             Length = 8                        |
       
    47  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    48  * |                              Value 1                          |
       
    49  * +-+-                                                         -+-+
       
    50  * |                                                               |
       
    51  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    52  * |                              Type                             |
       
    53  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    54  * |                             Length = 4                        |
       
    55  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    56  * |                              Value 2                          |
       
    57  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    58  * |                              Type                             |
       
    59  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    60  * |                             Length = 4                        |
       
    61  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    62  * |                              Value 3                          |
       
    63  * +-+-                                                         -+-+
       
    64  * |                                                               |
       
    65  * +-+-                                                         -+-+
       
    66  * |                                                               |
       
    67  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    68  *
       
    69  * NOTE, the length of value could be anythin between 0 ... (2^32)-1.
       
    70  * Only the free memory limits the length of the value.
       
    71  * There are no padding between Attribute-Value Pairs.
       
    72  * The next Attribute-Value Pair starts exactly after the previous
       
    73  * Value of previous Attribute-Value Pair.
       
    74  * @endcode
       
    75  * 
       
    76  */
       
    77 class EAP_EXPORT eap_tlv_message_data_c
       
    78 {
       
    79 private:
       
    80 	//--------------------------------------------------
       
    81 
       
    82 	abs_eap_am_tools_c * const m_am_tools;
       
    83 
       
    84 	eap_variable_data_c m_message_data;
       
    85 
       
    86 	//--------------------------------------------------
       
    87 protected:
       
    88 	//--------------------------------------------------
       
    89 
       
    90 	//--------------------------------------------------
       
    91 public:
       
    92 	//--------------------------------------------------
       
    93 
       
    94 	/**
       
    95 	 * The destructor of the eap_tlv_message_data_c class does nothing.
       
    96 	 */
       
    97 	EAP_FUNC_IMPORT virtual ~eap_tlv_message_data_c();
       
    98 
       
    99 	/**
       
   100 	 * The constructor of the eap_tlv_message_data_c class simply initializes the attributes.
       
   101 	 */
       
   102 	EAP_FUNC_IMPORT eap_tlv_message_data_c(
       
   103 		abs_eap_am_tools_c * const tools);
       
   104 
       
   105 	/**
       
   106 	 * This function should increase reference count.
       
   107 	 */
       
   108 	EAP_FUNC_IMPORT void object_increase_reference_count();
       
   109 
       
   110 	/**
       
   111 	 * This function should first decrease reference count
       
   112 	 * and second return the remaining reference count.
       
   113 	 * Reference count must not be decreased when it is zero.
       
   114 	 */
       
   115 	EAP_FUNC_IMPORT u32_t object_decrease_reference_count();
       
   116 
       
   117 	/**
       
   118 	 * This function returns the pointer to the data.
       
   119 	 * Empty message return NULL pointer.
       
   120 	 */
       
   121 	EAP_FUNC_IMPORT void * get_message_data() const;
       
   122 
       
   123 	/**
       
   124 	 * This function returns the length of the data.
       
   125 	 * Empty message return zero.
       
   126 	 */
       
   127 	EAP_FUNC_IMPORT u32_t get_message_data_length() const;
       
   128 
       
   129 	EAP_FUNC_IMPORT eap_status_e allocate_message_data_buffer(
       
   130 		const u32_t approximate_buffer_requirement);
       
   131 
       
   132 	/**
       
   133 	 * This function copies message data.
       
   134 	 * Data must be formatted as EAP-TLV-message data.
       
   135 	 */
       
   136 	EAP_FUNC_IMPORT eap_status_e copy_message_data(
       
   137 		const u32_t length,
       
   138 		const void * const value);
       
   139 
       
   140 	/**
       
   141 	 * This function sets message data.
       
   142 	 * Note the data is referenced not copied.
       
   143 	 * Data must be formatted as EAP-TLV-message data.
       
   144 	 */
       
   145 	EAP_FUNC_IMPORT eap_status_e set_message_data(
       
   146 		const u32_t length,
       
   147 		const void * const value);
       
   148 
       
   149 	/**
       
   150 	 * This function adds data to message.
       
   151 	 */
       
   152 	EAP_FUNC_IMPORT eap_status_e add_message_data(
       
   153 		const eap_tlv_type_t type,
       
   154 		const u32_t length,
       
   155 		const void * const data);
       
   156 
       
   157 	/**
       
   158 	 * This function adds array of data to message.
       
   159 	 */
       
   160 	EAP_FUNC_IMPORT eap_status_e add_message_data_array(
       
   161 		const eap_tlv_type_t type,
       
   162 		const u32_t length_of_each_data_block,
       
   163 		eap_array_c<eap_variable_data_c> * const data_array);
       
   164 	
       
   165 	/**
       
   166 	 * This function adds header of structured data to message.
       
   167 	 */
       
   168 	EAP_FUNC_IMPORT eap_status_e add_message_header(
       
   169 		const eap_tlv_type_t type,
       
   170 		const u32_t length);
       
   171 
       
   172 	/**
       
   173 	 * This function parses eap_tlv_header_c blocks from message to tlv_blocks.
       
   174 	 */
       
   175 	EAP_FUNC_IMPORT eap_status_e parse_message_data(
       
   176 		eap_array_c<eap_tlv_header_c> * const tlv_blocks);
       
   177 
       
   178 	/**
       
   179 	 * Object must indicate it's validity.
       
   180 	 * If object initialization fails this function must return false.
       
   181 	 * @return This function returns the validity of this object.
       
   182 	 */
       
   183 	EAP_FUNC_IMPORT bool get_is_valid();
       
   184 
       
   185 	/**
       
   186 	 * This function allocates buffer to message of specified type.
       
   187 	 * Function returns pointer to the value field of specified length.
       
   188 	 */
       
   189 	EAP_FUNC_IMPORT eap_status_e allocate_message_buffer(
       
   190 		const eap_tlv_type_t type,
       
   191 		const u32_t length,
       
   192 		void * * const buffer);
       
   193 
       
   194 	// 
       
   195 	//--------------------------------------------------
       
   196 }; // class eap_tlv_message_data_c
       
   197 
       
   198 
       
   199 //--------------------------------------------------
       
   200 
       
   201 #endif //#if !defined(_EAP_TLV_MESSAGE_DATA_H_)
       
   202 
       
   203 
       
   204 
       
   205 // End.