eapol/eapol_framework/eapol_common/include/ethernet_core.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(_ETHERNET_CORE_H_)
       
    22 #define _ETHERNET_CORE_H_
       
    23 
       
    24 #include "eap_tools.h"
       
    25 #include "eap_am_export.h"
       
    26 #include "abs_ethernet_core.h"
       
    27 #include "abs_eapol_core.h"
       
    28 #include "eapol_core.h"
       
    29 #include "eap_base_type.h"
       
    30 #include "eap_variable_data.h"
       
    31 #include "eap_core_map.h"
       
    32 #include "abs_eap_stack_interface.h"
       
    33 #include "eapol_rsna_key_header.h"
       
    34 
       
    35 
       
    36 /// This class defines the ethernet protocol layer.
       
    37 class EAP_EXPORT ethernet_core_c
       
    38 : public abs_eapol_core_c
       
    39 , public abs_eap_stack_interface_c
       
    40 {
       
    41 private:
       
    42 	//--------------------------------------------------
       
    43 
       
    44 	abs_ethernet_core_c *m_partner;
       
    45 
       
    46 	eapol_core_c *m_eapol_core;
       
    47 
       
    48 	abs_eap_am_tools_c * const m_am_tools;
       
    49 
       
    50 	bool m_is_client;
       
    51 
       
    52 	bool m_is_valid;
       
    53 
       
    54 	bool m_shutdown_was_called;
       
    55 
       
    56 	//--------------------------------------------------
       
    57 protected:
       
    58 	//--------------------------------------------------
       
    59 
       
    60 	//--------------------------------------------------
       
    61 public:
       
    62 	//--------------------------------------------------
       
    63 
       
    64 	// 
       
    65 	EAP_FUNC_IMPORT virtual ~ethernet_core_c();
       
    66 
       
    67 	// 
       
    68 	EAP_FUNC_IMPORT ethernet_core_c(
       
    69 		abs_eap_am_tools_c * const m_am_tools,
       
    70 		abs_ethernet_core_c * const partner,
       
    71 		const bool is_client_when_true);
       
    72 
       
    73 	EAP_FUNC_IMPORT eap_status_e cancel_all_authentication_sessions();
       
    74 
       
    75 	//
       
    76 	EAP_FUNC_IMPORT eap_base_type_c * load_type(const eap_type_value_e type);
       
    77 
       
    78 	// This is documented in abs_eap_stack_interface_c::packet_process().
       
    79 	EAP_FUNC_IMPORT eap_status_e packet_process(
       
    80 		const eap_am_network_id_c * const receive_network_id,
       
    81 		eap_general_header_base_c * const packet_data,
       
    82 		const u32_t packet_length); 
       
    83 
       
    84 	//
       
    85 	EAP_FUNC_IMPORT eap_status_e packet_send(
       
    86 		const eap_am_network_id_c * const send_network_id,
       
    87 		eap_buf_chain_wr_c * const sent_packet,
       
    88 		const u32_t header_offset,
       
    89 		const u32_t data_length,
       
    90 		const u32_t buffer_length); 
       
    91 
       
    92 	//
       
    93 	EAP_FUNC_IMPORT u32_t get_header_offset(
       
    94 		u32_t * const MTU,
       
    95 		u32_t * const trailer_length);
       
    96 
       
    97 	//
       
    98 	EAP_FUNC_IMPORT eap_status_e eap_acknowledge(const eap_am_network_id_c * const receive_network_id); 
       
    99 
       
   100 	//
       
   101 	EAP_FUNC_IMPORT eap_status_e load_module(
       
   102 		const eap_type_value_e type,
       
   103 		const eap_type_value_e /* tunneling_type */,
       
   104 		abs_eap_base_type_c * const partner,
       
   105 		eap_base_type_c ** const eap_type,
       
   106 		const bool is_client_when_true,
       
   107 		const eap_am_network_id_c * const receive_network_id);
       
   108 
       
   109 	//
       
   110 	EAP_FUNC_IMPORT eap_status_e unload_module(const eap_type_value_e type); 
       
   111 
       
   112 	/**
       
   113 	 * This function checks whether PMKSA is cached to each eap_am_network_id_c object.
       
   114 	 * Function removes eap_am_network_id_c object from bssid_sta_receive_network_ids if there are
       
   115 	 * no cached PMKSA for removes eap_am_network_id_c object.
       
   116 	 * All eap_am_network_id_c objects that exist in bssid_sta_receive_network_ids
       
   117 	 * after function returns have PMKSA cached and read_reassociation_parameters() can be called
       
   118 	 * with those eap_am_network_id_c objects.
       
   119 	 */
       
   120 	EAP_FUNC_IMPORT eap_status_e check_pmksa_cache(
       
   121 		eap_array_c<eap_am_network_id_c> * const bssid_sta_receive_network_ids,
       
   122 		const eapol_key_authentication_type_e selected_eapol_key_authentication_type,
       
   123 		const eapol_RSNA_key_header_c::eapol_RSNA_cipher_e pairwise_key_cipher_suite,
       
   124 		const eapol_RSNA_key_header_c::eapol_RSNA_cipher_e group_key_cipher_suite);
       
   125 
       
   126 	/**
       
   127 	 * This function removes PMKSA from cache.
       
   128 	 * @param receive_network_id carries the MAC addresses.
       
   129 	 * MAC address of Authenticator should be in source address.
       
   130 	 * MAC address of Supplicant should be in destination address.
       
   131 	 */
       
   132 	EAP_FUNC_IMPORT eap_status_e remove_pmksa_from_cache(
       
   133 		const eap_am_network_id_c * const receive_network_id);
       
   134 
       
   135 	/**
       
   136 	 * This function starts the EAP-authentication.
       
   137 	 * The first parameter includes the network addresses of the protocol
       
   138 	 * over the EAP-packets are transmitted.
       
   139 	 * The type attribute of the eap_am_network_id_c object MUST be set
       
   140 	 * eapol_ethernet_type_e::eapol_ethernet_type_pae.
       
   141 	 * Value eapol_ethernet_type_e::eapol_ethernet_type_pae starts normal EA-authentication.
       
   142 	 * The second parameter is_client_when_true tells whether this stack
       
   143 	 * is client (true) or server (false).
       
   144 	 */ 
       
   145 	EAP_FUNC_IMPORT eap_status_e start_authentication(
       
   146 		const eap_am_network_id_c * const receive_network_id,
       
   147 		const bool is_client_when_true);
       
   148 
       
   149 	/**
       
   150 	 * This function starts the preauthentication.
       
   151 	 * The first parameter includes the network addresses of the protocol
       
   152 	 * over the EAP-packets are transmitted.
       
   153 	 * The type attribute of the eap_am_network_id_c object MUST be set
       
   154 	 * eapol_ethernet_type_e::eapol_ethernet_type_preauthentication.
       
   155 	 * Value eapol_ethernet_type_e::eapol_ethernet_type_preauthentication is used 802.11i preauthentication.
       
   156 	 * The adaptation module calls the start_preauthentication() function
       
   157 	 * when preauthentication is needed with another AP.
       
   158 	 */
       
   159 	EAP_FUNC_IMPORT eap_status_e start_preauthentication(
       
   160 		const eap_am_network_id_c * const receive_network_id,
       
   161 		const eapol_key_authentication_type_e authentication_type);
       
   162 
       
   163 	EAP_FUNC_IMPORT eap_status_e read_reassociation_parameters(
       
   164 		const eap_am_network_id_c * const old_receive_network_id, ///< source includes remote address, destination includes local address.
       
   165 		const eap_am_network_id_c * const new_receive_network_id, ///< source includes remote address, destination includes local address.
       
   166 		const eapol_key_authentication_type_e authentication_type,
       
   167 		eap_variable_data_c * const PMKID,
       
   168 		const eap_variable_data_c * const received_WPA_ie,
       
   169 		const eap_variable_data_c * const sent_WPA_ie);
       
   170 
       
   171 	EAP_FUNC_IMPORT eap_status_e start_reassociation(
       
   172 		const eap_am_network_id_c * const receive_network_id,
       
   173 		const eapol_key_authentication_type_e authentication_type,
       
   174 		const eap_variable_data_c * const PMKID);
       
   175 
       
   176 	EAP_FUNC_IMPORT eap_status_e complete_reassociation(
       
   177 		const eapol_wlan_authentication_state_e reassociation_result,
       
   178 		const eap_am_network_id_c * const receive_network_id,
       
   179 		const eapol_key_authentication_type_e authentication_type,
       
   180 		const eap_variable_data_c * const received_WPA_IE, // WLM must give only the WPA IE to EAPOL
       
   181 		const eap_variable_data_c * const sent_WPA_IE,
       
   182 		const eapol_RSNA_key_header_c::eapol_RSNA_cipher_e pairwise_key_cipher_suite,
       
   183 		const eapol_RSNA_key_header_c::eapol_RSNA_cipher_e group_key_cipher_suite);
       
   184 
       
   185 	EAP_FUNC_IMPORT eap_status_e start_WPXM_reassociation(
       
   186 		const eap_am_network_id_c * const receive_network_id,
       
   187 		const eapol_key_authentication_type_e authentication_type,
       
   188 		eap_variable_data_c * const send_reassociation_request_ie);
       
   189 
       
   190 	EAP_FUNC_IMPORT eap_status_e complete_WPXM_reassociation(
       
   191 		const eapol_wlan_authentication_state_e reassociation_result,
       
   192 		const eap_am_network_id_c * const receive_network_id,
       
   193 		const eapol_key_authentication_type_e authentication_type,
       
   194 		const eap_variable_data_c * const received_reassociation_ie);
       
   195 
       
   196 	EAP_FUNC_IMPORT eap_status_e send_logoff(
       
   197 		const eap_am_network_id_c * const receive_network_id);
       
   198 
       
   199 	// This is documented in abs_eap_stack_interface_c::set_is_valid().
       
   200 	EAP_FUNC_IMPORT void set_is_valid();
       
   201 
       
   202 	// This is documented in abs_eap_stack_interface_c::get_is_valid().
       
   203 	EAP_FUNC_IMPORT bool get_is_valid();
       
   204 
       
   205 	// This is documented in abs_eap_stack_interface_c::configure().
       
   206 	EAP_FUNC_IMPORT eap_status_e configure();
       
   207 
       
   208 	// This is documented in abs_eap_stack_interface_c::shutdown().
       
   209 	EAP_FUNC_IMPORT eap_status_e shutdown();
       
   210 
       
   211 	EAP_FUNC_IMPORT eap_status_e packet_data_session_key(
       
   212 		const eap_am_network_id_c * const send_network_id,
       
   213 		const eapol_session_key_c * const key);
       
   214 
       
   215 	EAP_FUNC_IMPORT eap_status_e read_configure(
       
   216 		const eap_configuration_field_c * const field,
       
   217 		eap_variable_data_c * const data);
       
   218 
       
   219 	EAP_FUNC_IMPORT eap_status_e write_configure(
       
   220 		const eap_configuration_field_c * const field,
       
   221 		eap_variable_data_c * const data);
       
   222 
       
   223 	// See abs_eap_base_type_c::state_notification().
       
   224 	EAP_FUNC_IMPORT void state_notification(
       
   225 		const abs_eap_state_notification_c * const state);
       
   226 
       
   227 
       
   228 	//
       
   229 	EAP_FUNC_IMPORT eap_status_e set_timer(
       
   230 		abs_eap_base_timer_c * const p_initializer, 
       
   231 		const u32_t p_id, 
       
   232 		void * const p_data,
       
   233 		const u32_t p_time_ms);
       
   234 
       
   235 	EAP_FUNC_IMPORT eap_status_e cancel_timer(
       
   236 		abs_eap_base_timer_c * const p_initializer, 
       
   237 		const u32_t p_id);
       
   238 
       
   239 	//
       
   240 	EAP_FUNC_IMPORT eap_status_e cancel_all_timers();
       
   241 
       
   242 	//
       
   243 	EAP_FUNC_IMPORT eap_status_e check_is_valid_eap_type(const eap_type_value_e eap_type);
       
   244 
       
   245 	// See abs_eap_core_c::get_eap_type_list().
       
   246 	EAP_FUNC_IMPORT eap_status_e get_eap_type_list(
       
   247 		eap_array_c<eap_type_value_e> * const eap_type_list);
       
   248 
       
   249 #if defined(USE_EAPOL_KEY_STATE) && defined(USE_EAPOL_KEY_STATE_OPTIMIZED_4_WAY_HANDSHAKE)
       
   250 	/**
       
   251 	 * Function creates a state for later use. This is for optimazing 4-Way Handshake.
       
   252 	 * @param receive_network_id carries the MAC addresses.
       
   253 	 * MAC address of Authenticator should be in source address. MAC address of 
       
   254 	 * Supplicant should be in destination address.
       
   255 	 * @param authentication_type is the selected authentication type.
       
   256 	 */
       
   257 	EAP_FUNC_IMPORT eap_status_e create_state(
       
   258 		const eap_am_network_id_c * const receive_network_id,
       
   259 		const eapol_key_authentication_type_e authentication_type
       
   260 		);
       
   261 #endif //#if defined(USE_EAPOL_KEY_STATE) && defined(USE_EAPOL_KEY_STATE_OPTIMIZED_4_WAY_HANDSHAKE)
       
   262 
       
   263 
       
   264 #if defined(USE_EAPOL_KEY_STATE)
       
   265 	/**
       
   266 	 * This function need to be called when client STA (re)associates to AP.
       
   267 	 * @param receive_network_id carries the MAC addresses.
       
   268 	 * MAC address of Authenticator should be in source address. MAC address of Supplicant should be in destination address.
       
   269 	 * @param authenticator_RSNA_IE is RSN IE of authenticator. Authenticator sends this in Beacon or Probe message.
       
   270 	 * @param supplicant_RSNA_IE is RSN IE of supplicant. Supplicant sends this in (re)association request message.
       
   271 	 * @param eapol_pairwise_cipher is the selected pairwise cipher.
       
   272 	 * @param eapol_group_cipher is the selected group cipher.
       
   273 	 */
       
   274 	EAP_FUNC_IMPORT eap_status_e association(
       
   275 		const eap_am_network_id_c * const receive_network_id,
       
   276 		const eapol_key_authentication_type_e authentication_type,
       
   277 		const eap_variable_data_c * const authenticator_RSNA_IE,
       
   278 		const eap_variable_data_c * const supplicant_RSNA_IE,
       
   279 		const eapol_RSNA_key_header_c::eapol_RSNA_cipher_e eapol_pairwise_cipher,
       
   280 		const eapol_RSNA_key_header_c::eapol_RSNA_cipher_e eapol_group_cipher,
       
   281 		const eap_variable_data_c * const pre_shared_key);
       
   282 #endif //#if defined(USE_EAPOL_KEY_STATE)
       
   283 
       
   284 #if defined(USE_EAPOL_KEY_STATE)
       
   285 	/**
       
   286 	 * This function need to be called when client STA disassociates from AP.
       
   287 	 * @param receive_network_id carries the MAC addresses.
       
   288 	 * MAC address of Authenticator should be in source address. MAC address of Supplicant should be in destination address.
       
   289 	 */
       
   290 	EAP_FUNC_IMPORT eap_status_e disassociation(
       
   291 		const eap_am_network_id_c * const receive_network_id
       
   292 		);
       
   293 #endif //#if defined(USE_EAPOL_KEY_STATE)
       
   294 
       
   295 	/// @see abs_eap_core_c::add_rogue_ap().
       
   296 	EAP_FUNC_IMPORT eap_status_e add_rogue_ap(eap_array_c<eap_rogue_ap_entry_c> & rogue_ap_list);
       
   297 
       
   298 	EAP_FUNC_IMPORT eap_status_e tkip_mic_failure(
       
   299 		const eap_am_network_id_c * const receive_network_id,
       
   300 		const bool fatal_failure_when_true,
       
   301 		const eapol_RSNA_key_header_c::eapol_tkip_mic_failure_type_e tkip_mic_failure_type);
       
   302 
       
   303 	//--------------------------------------------------
       
   304 }; // class ethernet_core_c
       
   305 
       
   306 #endif //#if !defined(_ETHERNET_CORE_H_)
       
   307 
       
   308 //--------------------------------------------------
       
   309 
       
   310 
       
   311 
       
   312 // End.