eapol/eapol_framework/eapol_common/include/eapol_rsna_key_data_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(_EAPOL_RSNA_KEY_DATA_HEADER_H_)
       
    22 #define _EAPOL_RSNA_KEY_DATA_HEADER_H_
       
    23 
       
    24 #include "eapol_header.h"
       
    25 #include "eap_general_header_base.h"
       
    26 #include "eapol_key_header.h"
       
    27 
       
    28 
       
    29 //------------------------------------------------------
       
    30 
       
    31 enum eapol_RSNA_key_descriptor_type_e
       
    32 {
       
    33 	eapol_RSNA_key_data_type_none             = 0x00,
       
    34 	eapol_RSNA_key_data_type_RSN_IE           = 0x30,
       
    35 	eapol_RSNA_key_data_type_RSN_key_data     = 0xdd,
       
    36 	eapol_RSNA_key_data_type_WPA_IE           = 0xdd,
       
    37 #if defined(EAP_USE_WPXM)
       
    38 	eapol_RSNA_key_data_type_WPXM_reassoc_IE  = 0x9c,
       
    39 #endif //#if defined(EAP_USE_WPXM)
       
    40 };
       
    41 
       
    42 enum eapol_RSNA_key_payload_type_e
       
    43 {
       
    44 	eapol_RSNA_key_payload_type_reserved         = 0x00,
       
    45 	eapol_RSNA_key_payload_type_group_key_and_id = 0x01,
       
    46 	eapol_RSNA_key_payload_type_sta_key          = 0x02,
       
    47 	eapol_RSNA_key_payload_type_mac_address      = 0x03,
       
    48 	eapol_RSNA_key_payload_type_pmkid            = 0x04,
       
    49 	eapol_RSNA_key_payload_type_none             = 0xff,
       
    50 };
       
    51 
       
    52 enum eapol_RSNA_key_data_oui_e
       
    53 {
       
    54 	eapol_RSNA_key_data_oui_IEEE = 0x00000fac,
       
    55 };
       
    56 
       
    57 /**
       
    58  * This is the default trace mask for EAPOL Key Data.
       
    59  */
       
    60 const u32_t TRACE_FLAGS_EAPOL_KEY_DATA_ERROR = eap_am_tools_c::eap_trace_mask_error;
       
    61 
       
    62 
       
    63 /// This is base class of EAPOL RSNA key data header.
       
    64 /**
       
    65  * RSN IE have identical first two bytes, Type and Length fields.
       
    66  * @code
       
    67  *  0                   1                   2                   3
       
    68  *  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
       
    69  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    70  * | Type = 0xdd   | Length        | OUI 3 octets               ...|
       
    71  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    72  * | ... OUI       | Data Type     | Data (Length - 4) octets ...  :
       
    73  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-                             -+
       
    74  * |                                                               |
       
    75  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    76  * @endcode
       
    77  */
       
    78 class EAP_EXPORT eapol_rsna_key_data_header_c
       
    79 : public eap_general_header_base_c
       
    80 {
       
    81 private:
       
    82 	//--------------------------------------------------
       
    83 
       
    84 	/// This is pointer to the tools class.
       
    85 	abs_eap_am_tools_c * const m_am_tools;
       
    86 
       
    87 	/// This flag indicates whether the message is RSNA (true) or WPA (false).
       
    88 	bool m_is_RSNA_when_true;
       
    89 
       
    90 	/// This flag indicates whether the message is WPXM (true) or other (false).
       
    91 	/// The other cases are separated with m_is_RSNA_when_true flag.
       
    92 	bool m_is_WPXM_when_true;
       
    93 
       
    94 	//--------------------------------------------------
       
    95 public:
       
    96 	//--------------------------------------------------
       
    97 
       
    98 	enum eapol_RSNA_key_data_header_constants_e
       
    99 	{
       
   100 		EAPOL_RSNA_KEY_DATA_TYPE_FIELD_SIZE           = sizeof(u8_t),
       
   101 		EAPOL_RSNA_KEY_DATA_LENGTH_FIELD_SIZE         = sizeof(u8_t),
       
   102 		EAPOL_RSNA_KEY_DATA_OUI_FIELD_SIZE            = 3ul*sizeof(u8_t),
       
   103 		EAPOL_RSNA_KEY_PAYLOAD_TYPE_FIELD_SIZE        = sizeof(u8_t),
       
   104 		EAPOL_RSNA_KEY_DATA_LENGTH_FIELD_MINIMUM_SIZE = 4ul,
       
   105 		EAPOL_RSNA_KEY_ID_AND_GROUP_KEY_MINIMUM_SIZE  = 2ul,
       
   106 		EAPOL_RSNA_KEY_ID_AND_GROUP_KEY_HEADER_SIZE   = 2ul,
       
   107 		EAPOL_RSNA_STAKEY_MINIMUM_SIZE                = 1ul,
       
   108 		EAPOL_RSNA_PMKID_MINIMUM_SIZE                 = 1ul,
       
   109 		EAPOL_RSNA_IE_MINIMUM_SIZE                    = 4ul,
       
   110 	};
       
   111 
       
   112 	//--------------------------------------------------
       
   113 protected:
       
   114 	//--------------------------------------------------
       
   115 
       
   116 	enum offsets_e
       
   117 	{
       
   118 		m_offset_type                  = 0ul,
       
   119 		m_offset_length                = m_offset_type                  + EAPOL_RSNA_KEY_DATA_TYPE_FIELD_SIZE,
       
   120 		m_offset_oui                   = m_offset_length                + EAPOL_RSNA_KEY_DATA_LENGTH_FIELD_SIZE,
       
   121 		m_offset_key_data_payload_type = m_offset_oui                   + EAPOL_RSNA_KEY_DATA_OUI_FIELD_SIZE,
       
   122 		m_offset_key_data_payload      = m_offset_key_data_payload_type + EAPOL_RSNA_KEY_PAYLOAD_TYPE_FIELD_SIZE,
       
   123 	};
       
   124 
       
   125 	//--------------------------------------------------
       
   126 public:
       
   127 	//--------------------------------------------------
       
   128 
       
   129 	enum eapol_RSNA_key_data_header_constants_part_2_e
       
   130 	{
       
   131 		EAPOL_RSNA_KEY_HEADER_LENGTH = m_offset_key_data_payload,
       
   132 	};
       
   133 
       
   134 	//--------------------------------------------------
       
   135 public:
       
   136 	//--------------------------------------------------
       
   137 
       
   138 	// 
       
   139 	virtual ~eapol_rsna_key_data_header_c();
       
   140 
       
   141 	// 
       
   142 	eapol_rsna_key_data_header_c(
       
   143 		abs_eap_am_tools_c * const tools,
       
   144 		const bool is_RSNA_when_true,
       
   145 		const bool is_WPXM_when_true,
       
   146 		void * const header_begin,
       
   147 		const u32_t header_buffer_length);
       
   148 
       
   149 	eapol_RSNA_key_descriptor_type_e get_descriptor_type() const;
       
   150 
       
   151 	u32_t get_header_and_body_length() const;
       
   152 
       
   153 	u8_t get_length() const;
       
   154 
       
   155 	u32_t get_oui() const;
       
   156 
       
   157 	eapol_RSNA_key_payload_type_e get_payload_type() const;
       
   158 
       
   159 	u32_t get_key_data_payload_length() const;
       
   160 
       
   161 	/**
       
   162 	 * This function returns pointer to the offset of Data of Key Data.
       
   163 	 * @param offset is the offset of queried data in bytes.
       
   164 	 * @param contignuous_bytes is the length of queried data in bytes.
       
   165 	 */
       
   166 	u8_t * get_key_data_payload_offset(const u32_t offset, const u32_t contignuous_bytes) const;
       
   167 
       
   168 	/**
       
   169 	 * This function returns pointer to the Data of Key Data.
       
   170 	 * @param contignuous_bytes is the length of queried data in bytes.
       
   171 	 */
       
   172 	u8_t * get_key_data_payload(const u32_t contignuous_bytes) const;
       
   173 
       
   174 	/**
       
   175 	 * This function return pointer to the next eapol_rsna_key_data_header_c in the same buffer.
       
   176 	 */
       
   177 	u8_t * get_next_header() const;
       
   178 
       
   179 	static u16_t get_header_length();
       
   180 
       
   181 	eap_status_e set_type(const eapol_RSNA_key_descriptor_type_e type);
       
   182 
       
   183 	eap_status_e set_length(const u8_t length);
       
   184 
       
   185 	eap_status_e set_oui(const u32_t oui);
       
   186 
       
   187 	eap_status_e set_payload_type(const eapol_RSNA_key_payload_type_e type);
       
   188 
       
   189 	eap_status_e check_header() const;
       
   190 	
       
   191 	eap_status_e reset_header();
       
   192 	
       
   193 	/**
       
   194 	 * This function returns debug strings of the EAPOL Descriptor type.
       
   195 	 */
       
   196 	eap_const_string get_descriptor_type_string() const;
       
   197 
       
   198 	/**
       
   199 	 * This function returns debug strings of the EAPOL Key Data type.
       
   200 	 */
       
   201 	eap_const_string get_payload_type_string() const;
       
   202 
       
   203 	// 
       
   204 	//--------------------------------------------------
       
   205 }; // class eapol_rsna_key_data_header_c
       
   206 
       
   207 
       
   208 #endif //#if !defined(_EAPOL_KEY_H_)
       
   209 
       
   210 //------------------------------------------------------
       
   211 
       
   212 
       
   213 
       
   214 // End.