eapol/eapol_framework/eapol_common/include/eap_expanded_type.h
branchRCL_3
changeset 18 bad0cc58d154
parent 2 1c7bc153c08e
child 19 c74b3d9f6b9e
equal deleted inserted replaced
17:30e048a7b597 18:bad0cc58d154
    14 * Description:  EAP and WLAN authentication protocols.
    14 * Description:  EAP and WLAN authentication protocols.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 /*
    18 /*
    19 * %version: 10.1.2 %
    19 * %version: 18 %
    20 */
    20 */
    21 
    21 
    22 #if !defined(_EAP_EXPANDED_TYPE_H_)
    22 #if !defined(_EAP_EXPANDED_TYPE_H_)
    23 #define _EAP_EXPANDED_TYPE_H_
    23 #define _EAP_EXPANDED_TYPE_H_
    24 
    24 
    41 	eap_code_success  = 3, ///< This is EAP-Success.
    41 	eap_code_success  = 3, ///< This is EAP-Success.
    42 	eap_code_failure  = 4, ///< This is EAP-Failure.
    42 	eap_code_failure  = 4, ///< This is EAP-Failure.
    43 };
    43 };
    44 
    44 
    45 
    45 
    46 #if defined(USE_EAP_EXPANDED_TYPES)
       
    47 /// Enumeration of the IETF defined EAP-Type values.
    46 /// Enumeration of the IETF defined EAP-Type values.
    48 enum eap_type_ietf_values_e
    47 enum eap_type_ietf_values_e
    49 #else
       
    50 /// This is the original enumeration of the EAP-Type values.
       
    51 enum eap_type_value_e
       
    52 #endif //#if defined(USE_EAP_EXPANDED_TYPES)
       
    53 {
    48 {
    54 	eap_type_none               = 0,  ///< This is internal value for no type case.
    49 	eap_type_none               = 0,  ///< This is internal value for no type case.
    55 	eap_type_identity           = 1,  ///< This is Identity.
    50 	eap_type_identity           = 1,  ///< This is Identity.
    56 	eap_type_notification       = 2,  ///< This is Notification.
    51 	eap_type_notification       = 2,  ///< This is Notification.
    57 	eap_type_nak                = 3,  ///< This is Nak.
    52 	eap_type_nak                = 3,  ///< This is Nak.
    69 	eap_type_tlv_extensions     = 33, ///< This is type/length/value extension type for PEAP payloads.
    64 	eap_type_tlv_extensions     = 33, ///< This is type/length/value extension type for PEAP payloads.
    70 #if defined(USE_FAST_EAP_TYPE)
    65 #if defined(USE_FAST_EAP_TYPE)
    71 	eap_type_fast               = 43, ///< This is EAP-FAST type.
    66 	eap_type_fast               = 43, ///< This is EAP-FAST type.
    72 #endif //#if defined(USE_FAST_EAP_TYPE)
    67 #endif //#if defined(USE_FAST_EAP_TYPE)
    73 
    68 
    74 	eap_type_ttls_plain_pap     = 98, // This is for TTLS/PAP.
       
    75 
       
    76 #if defined(EAP_USE_TTLS_PLAIN_MS_CHAP_V2_HACK)
       
    77 	eap_type_plain_mschapv2     = 99, ///< This is used to indicate plain MSChapv2 inside TTLS tunnel.
       
    78 #endif //#if defined(EAP_USE_TTLS_PLAIN_MS_CHAP_V2_HACK)
       
    79 
       
    80 	eap_type_saesim             = 252, ///< This is just a test EAP-type.
    69 	eap_type_saesim             = 252, ///< This is just a test EAP-type.
    81 	eap_type_dummy_sim          = 253, ///< This is just a test EAP-type.
    70 	eap_type_dummy_sim          = 253, ///< This is just a test EAP-type.
    82 
    71 
    83 	eap_type_expanded_type      = 254, ///< This is Expanded Type.
    72 	eap_type_expanded_type      = 254, ///< This is Expanded Type.
    84 	eap_type_experimental_type  = 255, ///< This is Experimental Type.
    73 	eap_type_experimental_type  = 255, ///< This is Experimental Type.
    85 };
    74 };
    86 
       
    87 
       
    88 #if !defined(USE_EAP_EXPANDED_TYPES)
       
    89 	typedef eap_type_value_e eap_type_ietf_values_e;
       
    90 #endif //#if !defined(USE_EAP_EXPANDED_TYPES)
       
    91 
       
    92 
       
    93 
    75 
    94 enum eap_type_vendor_id_e
    76 enum eap_type_vendor_id_e
    95 {
    77 {
    96 	eap_type_vendor_id_ietf = 0,
    78 	eap_type_vendor_id_ietf = 0,
    97 	eap_type_vendor_id_broadcom = 0x0000113d,
    79 	eap_type_vendor_id_broadcom = 0x0000113d,
   101 
    83 
   102 enum eap_type_vendor_type_e
    84 enum eap_type_vendor_type_e
   103 {
    85 {
   104 	eap_type_vendor_type_secure_easy_setup = 10,
    86 	eap_type_vendor_type_secure_easy_setup = 10,
   105 	eap_type_vendor_type_WFA_simple_config = 1,
    87 	eap_type_vendor_type_WFA_simple_config = 1,
   106 	eap_type_vendor_type_ttls_plain_pap_hack = eap_type_ttls_plain_pap, // This is for TTLS/PAP.
    88 	eap_type_vendor_type_ttls_plain_pap_hack = 98, // This is for TTLS/PAP.
   107 #if defined(EAP_USE_TTLS_PLAIN_MS_CHAP_V2_HACK)
    89 #if defined(EAP_USE_TTLS_PLAIN_MS_CHAP_V2_HACK)
   108 	eap_type_vendor_type_plain_MSCHAPv2_hack = eap_type_plain_mschapv2, // This is for plain MCHAPv2 and TTLS
    90 	eap_type_vendor_type_plain_MSCHAPv2_hack = 99, // This is for plain MCHAPv2 and TTLS
   109 #endif //#if defined(EAP_USE_TTLS_PLAIN_MS_CHAP_V2_HACK)
    91 #endif //#if defined(EAP_USE_TTLS_PLAIN_MS_CHAP_V2_HACK)
   110 };
    92 };
   111 
    93 
   112 //-----------------------------------------------------------------------------------------
    94 //-----------------------------------------------------------------------------------------
   113 //-----------------------------------------------------------------------------------------
    95 //-----------------------------------------------------------------------------------------
   124 		m_vendor_id_size = 3ul*sizeof(u8_t),
   106 		m_vendor_id_size = 3ul*sizeof(u8_t),
   125 		m_vendor_type_size = sizeof(u32_t),
   107 		m_vendor_type_size = sizeof(u32_t),
   126 		m_eap_expanded_type_size = m_ietf_type_size+m_vendor_id_size+m_vendor_type_size,
   108 		m_eap_expanded_type_size = m_ietf_type_size+m_vendor_id_size+m_vendor_type_size,
   127 	};
   109 	};
   128 
   110 
       
   111 	// This must not be virtual destructor.
   129 	EAP_FUNC_IMPORT ~eap_expanded_type_c();
   112 	EAP_FUNC_IMPORT ~eap_expanded_type_c();
   130 
   113 
   131 	EAP_FUNC_IMPORT eap_expanded_type_c();
   114 	EAP_FUNC_IMPORT eap_expanded_type_c();
   132 
   115 
   133 	EAP_FUNC_IMPORT eap_expanded_type_c(
   116 	EAP_FUNC_IMPORT eap_expanded_type_c(
   135 		const u32_t vendor_type);
   118 		const u32_t vendor_type);
   136 
   119 
   137 	EAP_FUNC_IMPORT eap_expanded_type_c(
   120 	EAP_FUNC_IMPORT eap_expanded_type_c(
   138 		const eap_type_ietf_values_e type);
   121 		const eap_type_ietf_values_e type);
   139 
   122 
       
   123 	EAP_FUNC_IMPORT bool get_is_valid() const;
       
   124 
       
   125 	EAP_FUNC_IMPORT bool get_is_valid_data() const;
       
   126 
       
   127 	EAP_FUNC_IMPORT eap_expanded_type_c * copy() const;
       
   128 
   140 	EAP_FUNC_IMPORT static bool is_expanded_type(const eap_type_ietf_values_e eap_type);
   129 	EAP_FUNC_IMPORT static bool is_expanded_type(const eap_type_ietf_values_e eap_type);
   141 
   130 
   142 #if defined(USE_EAP_EXPANDED_TYPES)
       
   143 	EAP_FUNC_IMPORT static bool is_ietf_type(const eap_expanded_type_c eap_type);
   131 	EAP_FUNC_IMPORT static bool is_ietf_type(const eap_expanded_type_c eap_type);
   144 #else
       
   145 	EAP_FUNC_IMPORT static bool is_ietf_type(const eap_type_ietf_values_e eap_type);
       
   146 #endif //#if defined(USE_EAP_EXPANDED_TYPES)
       
   147 
   132 
   148 	EAP_FUNC_IMPORT eap_status_e get_type_data(
   133 	EAP_FUNC_IMPORT eap_status_e get_type_data(
   149 		abs_eap_am_tools_c * const am_tools,
   134 		abs_eap_am_tools_c * const am_tools,
   150 		eap_type_ietf_values_e * const type);
   135 		eap_type_ietf_values_e * const type) const;
   151 
   136 
   152 	EAP_FUNC_IMPORT eap_status_e get_type_data(
   137 	EAP_FUNC_IMPORT eap_status_e get_type_data(
   153 		abs_eap_am_tools_c * const am_tools,
   138 		abs_eap_am_tools_c * const am_tools,
   154 		eap_expanded_type_c * const type);
   139 		eap_expanded_type_c * const type) const;
   155 
   140 
   156 	EAP_FUNC_IMPORT eap_status_e get_expanded_type_data(
   141 	EAP_FUNC_IMPORT eap_status_e get_expanded_type_data(
   157 		abs_eap_am_tools_c * const am_tools,
   142 		abs_eap_am_tools_c * const am_tools,
   158 		eap_variable_data_c * const data);
   143 		eap_variable_data_c * const data) const;
   159 
   144 
   160 	EAP_FUNC_IMPORT eap_status_e set_expanded_type_data(
   145 	EAP_FUNC_IMPORT eap_status_e set_expanded_type_data(
   161 		abs_eap_am_tools_c * const am_tools,
   146 		abs_eap_am_tools_c * const am_tools,
   162 		const eap_variable_data_c * const data);
   147 		const eap_variable_data_c * const data);
       
   148 
       
   149 	EAP_FUNC_IMPORT eap_status_e set_expanded_type_data(
       
   150 		abs_eap_am_tools_c * const am_tools,
       
   151 		const void * const data,
       
   152 		const u32_t data_length);
   163 
   153 
   164 	EAP_FUNC_IMPORT void set_eap_type_values(
   154 	EAP_FUNC_IMPORT void set_eap_type_values(
   165 		const eap_type_vendor_id_e vendor_id,
   155 		const eap_type_vendor_id_e vendor_id,
   166 		const u32_t vendor_type);
   156 		const u32_t vendor_type);
   167 
   157 
   191 	EAP_FUNC_IMPORT static eap_status_e read_type(
   181 	EAP_FUNC_IMPORT static eap_status_e read_type(
   192 		abs_eap_am_tools_c * const am_tools,
   182 		abs_eap_am_tools_c * const am_tools,
   193 		const u32_t index,
   183 		const u32_t index,
   194 		const void * const buffer,
   184 		const void * const buffer,
   195 		const u32_t buffer_length,
   185 		const u32_t buffer_length,
   196 #if defined(USE_EAP_EXPANDED_TYPES)
       
   197 		eap_expanded_type_c * const type
   186 		eap_expanded_type_c * const type
   198 #else
       
   199 		eap_type_ietf_values_e * const type
       
   200 #endif //#if defined(USE_EAP_EXPANDED_TYPES)
       
   201 		);
   187 		);
   202 
   188 
   203 	/// This function writes EAP-type to offset.
   189 	/// This function writes EAP-type to offset.
   204 	EAP_FUNC_IMPORT static eap_status_e write_type(
   190 	EAP_FUNC_IMPORT static eap_status_e write_type(
   205 		abs_eap_am_tools_c * const am_tools,
   191 		abs_eap_am_tools_c * const am_tools,
   206 		const u32_t index, ///< Index is from 0 to n. Index 0 is the first EAP type field after base EAP header.
   192 		const u32_t index, ///< Index is from 0 to n. Index 0 is the first EAP type field after base EAP header.
   207 		void * const buffer,
   193 		void * const buffer,
   208 		const u32_t buffer_length,
   194 		const u32_t buffer_length,
   209 		const bool write_extented_type_when_true, ///< True value writes always Extented Type.
   195 		const bool write_extented_type_when_true, ///< True value writes always Extented Type.
   210 #if defined(USE_EAP_EXPANDED_TYPES)
       
   211 		const eap_expanded_type_c p_type ///< The EAP type to be written.
   196 		const eap_expanded_type_c p_type ///< The EAP type to be written.
   212 #else
       
   213 		const eap_type_ietf_values_e p_type ///< The EAP type to be written.
       
   214 #endif //#if defined(USE_EAP_EXPANDED_TYPES)
       
   215 		);
   197 		);
   216 
   198 
   217 #if defined(USE_EAP_EXPANDED_TYPES)
       
   218 	EAP_FUNC_IMPORT i32_t compare(const eap_expanded_type_c * const data) const;
   199 	EAP_FUNC_IMPORT i32_t compare(const eap_expanded_type_c * const data) const;
   219 #endif //#if defined(USE_EAP_EXPANDED_TYPES)
       
   220 
   200 
   221 private:
   201 private:
   222 
   202 
   223 	eap_type_vendor_id_e   m_vendor_id; ///< Here we use only 24 least significant bits.
   203 	eap_type_vendor_id_e   m_vendor_id; ///< Here we use only 24 least significant bits.
   224 	u32_t                  m_vendor_type;
   204 	u32_t                  m_vendor_type;
   275 //-----------------------------------------------------------------------------------------
   255 //-----------------------------------------------------------------------------------------
   276 //-----------------------------------------------------------------------------------------
   256 //-----------------------------------------------------------------------------------------
   277 //-----------------------------------------------------------------------------------------
   257 //-----------------------------------------------------------------------------------------
   278 
   258 
   279 
   259 
   280 #if defined(USE_EAP_EXPANDED_TYPES)
   260 typedef eap_expanded_type_c eap_type_value_e;
   281 
   261 
   282 	typedef eap_expanded_type_c eap_type_value_e;
   262 
   283 
   263 EAP_C_FUNC_IMPORT u32_t convert_eap_type_to_u32_t(eap_type_value_e type);
   284 	EAP_C_FUNC_IMPORT u32_t convert_eap_type_to_u32_t(eap_type_value_e type);
   264 
   285 
   265 EAP_C_FUNC_IMPORT u64_t convert_eap_type_to_u64_t(eap_type_value_e type);
   286 	EAP_C_FUNC_IMPORT u64_t convert_eap_type_to_u64_t(eap_type_value_e type);
       
   287 
       
   288 #else
       
   289 
       
   290 	EAP_C_FUNC_IMPORT u32_t convert_eap_type_to_u32_t(eap_type_value_e type);
       
   291 
       
   292 	EAP_C_FUNC_IMPORT u64_t convert_eap_type_to_u64_t(eap_type_value_e type);
       
   293 
       
   294 #endif //#if defined(USE_EAP_EXPANDED_TYPES)
       
   295 
   266 
   296 
   267 
   297 //-----------------------------------------------------------------------------------------
   268 //-----------------------------------------------------------------------------------------
   298 //-----------------------------------------------------------------------------------------
   269 //-----------------------------------------------------------------------------------------
   299 //-----------------------------------------------------------------------------------------
   270 //-----------------------------------------------------------------------------------------