eapol/eapol_framework/eapol_common/type/tls_peap/eap/include/eap_type_tls_peap_header.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_TLS_PEAP_HEADER_H_)
       
    22 #define _EAP_TLS_PEAP_HEADER_H_
       
    23 
       
    24 #include "eap_tools.h"
       
    25 #include "eap_header.h"
       
    26 #include "tls_peap_types.h"
       
    27 
       
    28 /** @file */
       
    29 
       
    30 const u32_t TLS_PEAP_FIRST_SEQUENCE = 1u;
       
    31 const u8_t TLS_PEAP_NAI_AT_BYTE = '@';
       
    32 
       
    33 
       
    34 //----------------------------------------------------------------------------
       
    35 
       
    36 
       
    37 /// This class defines header of TLS_PEAP EAP-type.
       
    38 /**
       
    39  * Here is a figure of header of TLS_PEAP EAP-type.
       
    40  * Subtype-Data is m_length-sizeof(eap_tls_peap_header_c) data octets that follows eap_tls_peap_header_c.
       
    41  * @code
       
    42  *  EAP/TLS-header:
       
    43  *  0                   1                   2                   3
       
    44  *  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
       
    45  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    46  *  |     Code      |   Identifier  |            Length             |
       
    47  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    48  *  |     Type      |     Flags     |      TLS Message Length       |
       
    49  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    50  *  |     TLS Message Length        |       TLS Data...
       
    51  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    52  *
       
    53  *  PEAP-header:
       
    54  *  0                   1                   2                   3
       
    55  *  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
       
    56  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    57  * |     Code      |   Identifier  |            Length             |
       
    58  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    59  * |     Type      |   Flags   |Ver|      TLS Message Length opt.  |
       
    60  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    61  * |     TLS Message Length  opt.  |       TLS Data...
       
    62  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    63  * @endcode
       
    64  *
       
    65  */
       
    66 class EAP_EXPORT eap_tls_peap_header_c
       
    67 : public eap_header_base_c
       
    68 {
       
    69 private:
       
    70 	//--------------------------------------------------
       
    71 
       
    72 	/// This is pointer to the tools class.
       
    73 	abs_eap_am_tools_c * const m_am_tools;
       
    74 
       
    75 	enum message_fields
       
    76 	{
       
    77 		TLS_MESSAGE_LENGTH_FIELD_SIZE = 4u,
       
    78 	};
       
    79 
       
    80 	enum bit_shifts
       
    81 	{
       
    82 		m_flag_shift_reserved = 0x02,
       
    83 		m_flag_shift_version = 0x00,
       
    84 	};
       
    85 
       
    86 	//--------------------------------------------------
       
    87 protected:
       
    88 	//--------------------------------------------------
       
    89 
       
    90 	enum delta_offsets
       
    91 	{
       
    92 		m_flag_delta_offset = 0ul,
       
    93 		m_tls_length_delta_offset = m_flag_delta_offset+sizeof(u8_t),
       
    94 	};
       
    95 
       
    96 	//--------------------------------------------------
       
    97 public:
       
    98 	//--------------------------------------------------
       
    99 
       
   100 	enum bit_masks
       
   101 	{
       
   102 		m_flag_mask_tls_length_included = 0x80,
       
   103 		m_flag_mask_more_fragments = 0x40,
       
   104 		m_flag_mask_start = 0x20,
       
   105 		m_flag_mask_reserved = 0x1c,
       
   106 		m_flag_mask_version = 0x03,
       
   107 	};
       
   108 
       
   109 
       
   110 	EAP_FUNC_IMPORT virtual ~eap_tls_peap_header_c();
       
   111 
       
   112 	// 
       
   113 	EAP_FUNC_IMPORT eap_tls_peap_header_c(
       
   114 		abs_eap_am_tools_c * const tools,
       
   115 		u8_t * const header_begin,
       
   116 		const u32_t header_buffer_length);
       
   117 
       
   118 	EAP_FUNC_IMPORT eap_code_value_e get_eap_code() const;
       
   119 
       
   120 	EAP_FUNC_IMPORT u8_t get_eap_identifier() const;
       
   121 
       
   122 	EAP_FUNC_IMPORT u16_t get_eap_length() const;
       
   123 
       
   124 	EAP_FUNC_IMPORT eap_type_value_e get_eap_type() const;
       
   125 
       
   126 	EAP_FUNC_IMPORT u16_t get_data_length() const;
       
   127 
       
   128 	EAP_FUNC_IMPORT u32_t get_tls_min_header_length() const;
       
   129 
       
   130 	EAP_FUNC_IMPORT static u32_t get_tls_max_header_length();
       
   131 
       
   132 	EAP_FUNC_IMPORT u32_t get_header_length() const;
       
   133 
       
   134 	EAP_FUNC_IMPORT u32_t get_tls_flags_offset() const;
       
   135 
       
   136 	EAP_FUNC_IMPORT u32_t get_tls_length_offset() const;
       
   137 
       
   138 	EAP_FUNC_IMPORT u32_t get_start_offset_of_data() const;
       
   139 
       
   140 	EAP_FUNC_IMPORT u8_t * get_data_offset(
       
   141 		abs_eap_am_tools_c * const m_am_tools,
       
   142 		const u32_t offset,
       
   143 		const u32_t contignuous_bytes) const;
       
   144 
       
   145 
       
   146 	EAP_FUNC_IMPORT u8_t * get_data(
       
   147 		abs_eap_am_tools_c * const m_am_tools,
       
   148 		const u32_t contignuous_bytes) const;
       
   149 
       
   150 
       
   151 	EAP_FUNC_IMPORT u8_t * get_tls_flags() const;
       
   152 
       
   153 	EAP_FUNC_IMPORT bool get_tls_flag_bit(
       
   154 		const u32_t mask) const;
       
   155 
       
   156 	EAP_FUNC_IMPORT u8_t get_tls_flag_value(
       
   157 		const u32_t mask,
       
   158 		const u32_t shift) const;
       
   159 
       
   160 	EAP_FUNC_IMPORT bool get_flag_tls_length_included() const;
       
   161 
       
   162 	EAP_FUNC_IMPORT bool get_flag_more_fragments() const;
       
   163 	
       
   164 	EAP_FUNC_IMPORT bool get_flag_start() const;
       
   165 	
       
   166 	EAP_FUNC_IMPORT u8_t get_flag_reserved() const;
       
   167 
       
   168 	EAP_FUNC_IMPORT u8_t get_flag_version() const;
       
   169 
       
   170 	EAP_FUNC_IMPORT eap_status_e get_tls_message_length(
       
   171 		u32_t * const tls_length) const;
       
   172 
       
   173 
       
   174 	EAP_FUNC_IMPORT eap_status_e check_header(
       
   175 		abs_eap_am_tools_c * const tools,
       
   176 		const eap_type_value_e required_eap_type,
       
   177 		const bool is_client_when_true,
       
   178 		const peap_version_e peap_version,
       
   179 		const bool check_peap_version_when_true) const;
       
   180 
       
   181 	EAP_FUNC_IMPORT eap_const_string get_code_string() const;
       
   182 
       
   183 	EAP_FUNC_IMPORT eap_const_string get_eap_type_string() const;
       
   184 
       
   185 	EAP_FUNC_IMPORT void set_eap_code(const eap_code_value_e p_code);
       
   186 
       
   187 	EAP_FUNC_IMPORT void set_eap_identifier(const u8_t p_identifier);
       
   188 
       
   189 	EAP_FUNC_IMPORT void set_eap_length(
       
   190 		const u16_t p_length,
       
   191 		const bool expanded_type_when_true);
       
   192 
       
   193 	EAP_FUNC_IMPORT void set_eap_type(
       
   194 		const eap_type_value_e p_type,
       
   195 		const bool expanded_type_when_true);
       
   196 
       
   197 
       
   198 	EAP_FUNC_IMPORT void set_tls_flag_value(
       
   199 		const u8_t value,
       
   200 		const u32_t mask,
       
   201 		const u32_t shift) const;
       
   202 
       
   203 	EAP_FUNC_IMPORT void set_tls_flag_bit(const bool flag, u32_t mask) const;
       
   204 
       
   205 	EAP_FUNC_IMPORT void set_flag_reserved(const u8_t reserved);
       
   206 
       
   207 	EAP_FUNC_IMPORT void set_flag_version(const u8_t version);
       
   208 
       
   209 	EAP_FUNC_IMPORT void set_flag_tls_length_included(const bool tls_length_included);
       
   210 
       
   211 	EAP_FUNC_IMPORT void set_flag_more_fragments(const bool more_fragments);
       
   212 
       
   213 	EAP_FUNC_IMPORT void set_flag_start(const bool start);
       
   214 
       
   215 
       
   216 	EAP_FUNC_IMPORT void set_data_length(
       
   217 		const u32_t p_data_length,
       
   218 		const bool expanded_type_when_true);
       
   219 
       
   220 	EAP_FUNC_IMPORT void set_tls_message_length(const u32_t tls_length);
       
   221 
       
   222 
       
   223 	EAP_FUNC_IMPORT void reset_header(
       
   224 		abs_eap_am_tools_c * const m_am_tools,
       
   225 		const eap_type_value_e required_eap_type,
       
   226 		const u32_t buffer_length,
       
   227 		const peap_version_e peap_version,
       
   228 		const bool expanded_type_when_true);
       
   229 
       
   230 	// 
       
   231 	//--------------------------------------------------
       
   232 }; // class eap_tls_peap_header_c
       
   233 
       
   234 
       
   235 //--------------------------------------------------
       
   236 
       
   237 #endif //#if !defined(_EAP_TLS_PEAP_HEADER_H_)
       
   238 
       
   239 
       
   240 
       
   241 // End.