eapol/eapol_framework/eapol_common/include/eap_core_client_message_if.h
branchRCL_3
changeset 19 c74b3d9f6b9e
parent 18 bad0cc58d154
equal deleted inserted replaced
18:bad0cc58d154 19:c74b3d9f6b9e
     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 * %version: 23 %
       
    20 */
       
    21 
       
    22 #if !defined(_EAP_CORE_CLIENT_MESSAGE_IF_H_)
       
    23 #define _EAP_CORE_CLIENT_MESSAGE_IF_H_
       
    24 
       
    25 #include "eap_tools.h"
       
    26 #include "eap_am_export.h"
       
    27 #include "eap_session_core_base.h"
       
    28 #include "abs_eap_session_core.h"
       
    29 #include "eap_core_map.h"
       
    30 #include "abs_eap_stack_interface.h"
       
    31 #include "abs_eap_am_message_if.h"
       
    32 #include "eap_am_message_if.h"
       
    33 #include "eap_process_tlv_message_data.h"
       
    34 #include "eap_database_reference_if.h"
       
    35 
       
    36 class eap_tlv_header_c;
       
    37 
       
    38 
       
    39 /// A eap_core_client_message_if_c class implements mapping of EAP authentication sessions.
       
    40 /// Network identity separates parallel EAP authentication sessions.
       
    41 class EAP_EXPORT eap_core_client_message_if_c
       
    42 : public abs_eap_am_message_if_c
       
    43 , public eap_session_core_base_c
       
    44 , public abs_eap_base_timer_c
       
    45 , public abs_eap_stack_interface_c
       
    46 {
       
    47 private:
       
    48 	//--------------------------------------------------
       
    49 
       
    50 	/// This is pointer to the tools class.
       
    51 	abs_eap_am_tools_c * const m_am_tools;
       
    52 
       
    53 	/// eap_core_client_message_if_c deletes m_server_if in destructor.
       
    54 	eap_am_message_if_c * m_server_if;
       
    55 
       
    56 	/// This is back pointer to object which created this object.
       
    57 	/// Packets are sent to the partner.
       
    58 	abs_eap_session_core_c * const m_partner;
       
    59 
       
    60 	eap_status_e m_error_code;
       
    61 
       
    62 	eap_tlv_message_type_function_e m_error_function;
       
    63 
       
    64 	/// This is offset in bytes of the EAP header.
       
    65 	u32_t m_eap_header_offset;
       
    66 
       
    67 	/// This is maximum transfer unit in bytes.
       
    68 	u32_t m_MTU;
       
    69 
       
    70 	/// This is length of the trailer in bytes.
       
    71 	u32_t m_trailer_length;
       
    72 
       
    73 	/// This indicates whether this object is client (true) or server (false).
       
    74 	/// In terms of EAP-protocol whether this network entity is EAP-supplicant (true) or EAP-authenticator (false).
       
    75 	bool m_is_client;
       
    76 
       
    77 	/// This indicates whether this object was generated successfully.
       
    78 	bool m_is_valid;
       
    79 
       
    80 	bool m_shutdown_was_called;
       
    81 
       
    82 	// This is documented in abs_eap_stack_interface_c::set_is_valid().
       
    83 	void set_is_valid();
       
    84 
       
    85 	eap_status_e process_message(eap_process_tlv_message_data_c * const message);
       
    86 
       
    87 	eap_status_e process_error_message(
       
    88 		const eap_status_e error_code,
       
    89 		const eap_tlv_message_type_function_e function);
       
    90 
       
    91 	eap_status_e process_message_type_error(
       
    92 		EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters);
       
    93 
       
    94 	eap_status_e packet_send(
       
    95 		EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters);
       
    96 
       
    97 	eap_status_e state_notification(
       
    98 		EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters);
       
    99 
       
   100 	eap_status_e packet_data_crypto_keys(
       
   101 		EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters);
       
   102 
       
   103 	eap_status_e restart_authentication(
       
   104 		EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters);
       
   105 
       
   106 	eap_status_e new_protected_setup_credentials(
       
   107 		EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters);
       
   108 
       
   109 	eap_status_e complete_get_802_11_authentication_mode(
       
   110 		EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters);
       
   111 
       
   112 	eap_status_e complete_remove_eap_session(
       
   113 		EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters);
       
   114 
       
   115 	eap_status_e eap_mtu(
       
   116 		const u32_t MTU);
       
   117 
       
   118 	//--------------------------------------------------
       
   119 protected:
       
   120 	//--------------------------------------------------
       
   121 
       
   122 	//--------------------------------------------------
       
   123 public:
       
   124 	//--------------------------------------------------
       
   125 
       
   126 	/**
       
   127 	 * The destructor of the eap_core class does nothing special.
       
   128 	 */
       
   129 	EAP_FUNC_IMPORT EAP_FUNC_IMPORT virtual ~eap_core_client_message_if_c();
       
   130 
       
   131 	/**
       
   132 	 * The constructor initializes member attributes using parameters passed to it.
       
   133 	 * @param tools is pointer to the tools class. @see abs_eap_am_tools_c.
       
   134 	 * @param partner is back pointer to object which created this object.
       
   135 	 * @param is_client_when_true indicates whether the network entity should act
       
   136 	 * as a client (true) or server (false), in terms of EAP-protocol
       
   137 	 * whether this network entity is EAP-supplicant (true) or EAP-authenticator (false).
       
   138 	 */
       
   139 	EAP_FUNC_IMPORT eap_core_client_message_if_c(
       
   140 		abs_eap_am_tools_c * const tools,
       
   141 		eap_am_message_if_c * const server,
       
   142 		abs_eap_session_core_c * const partner,
       
   143 		const bool is_client_when_true);
       
   144 
       
   145 	void set_partner(abs_eap_am_message_if_c * const client);
       
   146 
       
   147 	/**
       
   148 	 * This function must reset the state of object to same as 
       
   149 	 * state was after the configure() function call.
       
   150 	 * If object reset succeeds this function must return eap_status_ok.
       
   151 	 * If object reset fails this function must return corresponding error status.
       
   152 	 * @return This function returns the status of reset operation.
       
   153 	 */
       
   154 	EAP_FUNC_IMPORT eap_status_e reset();
       
   155 
       
   156 	/**
       
   157 	 * This function cancels all EAP-sessions.
       
   158 	 * If this succeeds this function must return eap_status_ok.
       
   159 	 * If this fails this function must return corresponding error status.
       
   160 	 * @return This function returns the status of operation.
       
   161 	 */
       
   162 	EAP_FUNC_IMPORT eap_status_e cancel_all_eap_sessions();
       
   163 
       
   164 	// This is documented in abs_eap_stack_interface_c::packet_process().
       
   165 	EAP_FUNC_IMPORT eap_status_e packet_process(
       
   166 		const eap_am_network_id_c * const receive_network_id,
       
   167 		eap_general_header_base_c * const packet_data,
       
   168 		const u32_t packet_length); 
       
   169 
       
   170 	/**
       
   171 	 * The adaptation module calls the eap_acknowledge() function after
       
   172 	 * any Network Protocol packet is received. This is used as a success indication.
       
   173 	 * This is described in RFC 2284 "PPP Extensible Authentication Protocol (EAP)".
       
   174 	 * @param connection_handle separates the context of the acknowledged session.
       
   175 	 * Mostly there is only one session in the client.
       
   176 	 * The server does not need eap_acknowledge() function because
       
   177 	 * server (EAP-authenticator) sends the EAP-success message.
       
   178 	 */
       
   179 	EAP_FUNC_IMPORT eap_status_e eap_acknowledge(
       
   180 		const eap_am_network_id_c * const receive_network_id); 
       
   181 
       
   182 #if defined(USE_EAP_CORE_SERVER)
       
   183 	/**
       
   184 	 * The EAP Core calls the send_eap_identity_request() function
       
   185 	 * when EAP-authentication is needed with another peer.
       
   186 	 * @param network_id includes the addresses (network identity) and packet type.
       
   187 	 */
       
   188 	EAP_FUNC_IMPORT eap_status_e send_eap_identity_request(
       
   189 		const eap_am_network_id_c * const network_id);
       
   190 #endif //#if defined(USE_EAP_CORE_SERVER)
       
   191 
       
   192 	// This is documented in abs_eap_stack_interface_c::configure().
       
   193 	EAP_FUNC_IMPORT eap_status_e configure();
       
   194 
       
   195 	// This is documented in abs_eap_stack_interface_c::shutdown().
       
   196 	EAP_FUNC_IMPORT eap_status_e shutdown();
       
   197 
       
   198 	// This is documented in abs_eap_stack_interface_c::get_is_valid().
       
   199 	EAP_FUNC_IMPORT bool get_is_valid();
       
   200 
       
   201 	/**
       
   202 	 * This function creates EAP session object synchronously.
       
   203 	 * @param receive_network_id identifies the removed EAP session.
       
   204 	 */
       
   205 	EAP_FUNC_IMPORT eap_status_e create_eap_session(
       
   206 		const eap_am_network_id_c * const receive_network_id);
       
   207 
       
   208 	/**
       
   209 	 * This function removes EAP session object synchronously.
       
   210 	 * @param receive_network_id identifies the removed EAP session.
       
   211 	 */
       
   212 	EAP_FUNC_IMPORT eap_status_e remove_eap_session(
       
   213 		const bool complete_to_lower_layer,
       
   214 		const eap_am_network_id_c * const receive_network_id);
       
   215 
       
   216 	// See abs_eap_base_timer_c::timer_expired().
       
   217 	EAP_FUNC_IMPORT eap_status_e timer_expired(
       
   218 		const u32_t id, void *data);
       
   219 
       
   220 	// See abs_eap_base_timer_c::timer_delete_data().
       
   221 	EAP_FUNC_IMPORT eap_status_e timer_delete_data(
       
   222 		const u32_t id, void *data);
       
   223 
       
   224 	// See abs_eap_am_message_if_c::send_data().
       
   225 	EAP_FUNC_IMPORT eap_status_e send_data(const void * const data, const u32_t length);
       
   226 
       
   227 
       
   228 	EAP_FUNC_IMPORT eap_status_e set_eap_database_reference_values(
       
   229 		const eap_variable_data_c * const reference);
       
   230 
       
   231 	EAP_FUNC_IMPORT eap_status_e get_802_11_authentication_mode(
       
   232 		const eap_am_network_id_c * const receive_network_id,
       
   233 		const eapol_key_authentication_type_e authentication_type,
       
   234 		const eap_variable_data_c * const SSID,
       
   235 		const eap_variable_data_c * const preshared_key);
       
   236 
       
   237 	EAP_FUNC_IMPORT eap_status_e complete_get_802_11_authentication_mode(
       
   238 		const eap_status_e completion_status,
       
   239 		const eap_am_network_id_c * const receive_network_id,
       
   240 		const eapol_key_802_11_authentication_mode_e mode);
       
   241 
       
   242 	//--------------------------------------------------
       
   243 }; // class eap_core_client_message_if_c
       
   244 
       
   245 //--------------------------------------------------
       
   246 
       
   247 #endif //#if !defined(_EAP_CORE_CLIENT_MESSAGE_IF_H_)
       
   248 
       
   249 //--------------------------------------------------
       
   250 
       
   251 
       
   252 
       
   253 // End.