eapol/eapol_framework/eapol_common/include/abs_eap_base_type.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(_ABS_EAP_BASE_TYPE_H_)
       
    22 #define _ABS_EAP_BASE_TYPE_H_
       
    23 
       
    24 #include "eap_am_export.h"
       
    25 #include "eap_header.h"
       
    26 #include "eap_array.h"
       
    27 
       
    28 class eap_base_type_c;
       
    29 class eap_am_network_id_c;
       
    30 class eap_network_id_selector_c;
       
    31 class eap_configuration_field_c;
       
    32 class abs_eap_state_notification_c;
       
    33 class eap_rogue_ap_entry_c;
       
    34 class eap_master_session_key_c;
       
    35 
       
    36 /// The class is the interface to partner class of the eap_base_type class.
       
    37 /// This declares the pure virtual member functions EAP-type class could call.
       
    38 class EAP_EXPORT abs_eap_base_type_c
       
    39 {
       
    40 private:
       
    41 	//--------------------------------------------------
       
    42 
       
    43 	//--------------------------------------------------
       
    44 protected:
       
    45 	//--------------------------------------------------
       
    46 
       
    47 	//--------------------------------------------------
       
    48 public:
       
    49 	//--------------------------------------------------
       
    50 
       
    51 	/**
       
    52 	 * The destructor of the abs_eap_base_type_c class does nothing special.
       
    53 	 */
       
    54 	virtual ~abs_eap_base_type_c()
       
    55 	{
       
    56 	}
       
    57 
       
    58 	/**
       
    59 	 * The constructor of the abs_eap_base_type_c class does nothing special.
       
    60 	 */
       
    61 	abs_eap_base_type_c()
       
    62 	{
       
    63 	}
       
    64 
       
    65 	/**
       
    66 	 * The derived class could send packets to partner class with this function.
       
    67 	 * @param network_id carries the addresses (network identity) and type of the packet.
       
    68 	 * @param sent_packet includes the buffer for the whole packet and initialized 
       
    69 	 * EAP-packet in correct offset.
       
    70 	 * @param header_offset is offset of the EAP-header within the sent_packet.
       
    71 	 * @param data_length is length in bytes of the EAP-packet.
       
    72 	 * @param buffer_length is length in bytes of the whole packet buffer.
       
    73 	 *
       
    74 	 * Now some ascii graphics follows.
       
    75 	 * @code
       
    76 	 *                                                                                    
       
    77 	 * +---------------------+-----+---------------------------------------+-------------+
       
    78 	 * |                     | EAP |  data                                 |             |
       
    79 	 * +---------------------+-----+---------------------------------------+-------------+
       
    80 	 * |                     |                                             |             |
       
    81 	 * |<---header_offset--->|<-------------data_length------------------->|<--trailer-->|
       
    82 	 * |                                                                                 |
       
    83 	 * |<------------------------buffer_length------------------------------------------>|
       
    84 	 *
       
    85 	 * trailer is the free space in the end of the packet buffer.
       
    86 	 * @endcode
       
    87 	 *
       
    88 	 */
       
    89 	virtual eap_status_e packet_send(
       
    90 		const eap_am_network_id_c * const network_id,
       
    91 		eap_buf_chain_wr_c * const sent_packet,
       
    92 		const u32_t header_offset,
       
    93 		const u32_t data_length,
       
    94 		const u32_t buffer_length) = 0;
       
    95 
       
    96 	/**
       
    97 	 * This function restarts authentication to send_network_id.
       
    98 	 * @param send_network_id is network identity of target.
       
    99 	 * @param is_client_when_true indicates whether this object should act as a client (true)
       
   100 	 * or server (false), in terms of EAP-protocol whether this network entity is EAP-supplicant (true)
       
   101 	 * or EAP-authenticator (false).
       
   102 	 */
       
   103 	virtual eap_status_e restart_authentication(
       
   104 		const eap_am_network_id_c * const send_network_id,
       
   105 		const bool is_client_when_true) = 0;
       
   106 
       
   107 	/**
       
   108 	 * The get_header_offset() function obtains the header offset of EAP-packet.
       
   109 	 * @param MTU_length is pointer to variable to store the maximum transfer unit (MTU).
       
   110 	 * MTU is the maximum EAP-packet length in bytes
       
   111 	 * @param trailer_length is pointer to the variable to store length
       
   112 	 * of trailer needed by lower levels.
       
   113 	 * @return Function returns the offset of EAP-header.
       
   114 	 *
       
   115 	 * The needed buffer length is ((offset) + (EAP-packet length) + (trailer)) bytes.
       
   116 	 * Each layer adds the length of the header to offset.
       
   117 	 * Each layer removes the length of the header and trailer from MTU.
       
   118 	 *
       
   119 	 * Now some ascii graphics follows.
       
   120 	 * @code
       
   121 	 * |<-------------------------buffer length----------------------------------------->|
       
   122 	 * |                                                                                 |
       
   123 	 * |                     +-----+---------------------------------------+             |
       
   124 	 * |                     | EAP |  data                                 |             |
       
   125 	 * |                     +-----+---------------------------------------+             |
       
   126 	 * |<----offset--------->|<----MTU------------------------------------>|<--trailer-->|
       
   127 	 * |                     |                                             |             |
       
   128 	 * |             +-------+---------------------------------------------+             |
       
   129 	 * |             | EAPOL |  data                                       |             |
       
   130 	 * |             +-------+---------------------------------------------+             |
       
   131 	 * |<--offset--->|<----MTU-------------------------------------------->|<--trailer-->|
       
   132 	 * |             |                                                     |             |
       
   133 	 * +-------------+-----------------------------------------------------+-------------+
       
   134 	 * |  ETHERNET   |  data                                               |  trailer    |
       
   135 	 * +-------------+-----------------------------------------------------+-------------+
       
   136 	 * |<----MTU------------------------------------------------------------------------>|
       
   137 	 * @endcode
       
   138 	 *
       
   139 	 */
       
   140 	virtual u32_t get_header_offset(
       
   141 		u32_t * const MTU_length,
       
   142 		u32_t * const trailer_length) = 0;
       
   143 
       
   144 	/**
       
   145 	 * Note this function is just an example. Parameters will change later.
       
   146 	 * The packet_data_crypto_keys() function gives the generated keys to lower level.
       
   147 	 * After EAP-authentication has generated the keys it calls this function
       
   148 	 * to offer the keys to lower level.
       
   149 	 * @param master_session_key is pointer to the first byte of the master session key.
       
   150 	 * @param master_session_length is count of bytes in the master session key.
       
   151 	 */
       
   152 	virtual eap_status_e packet_data_crypto_keys(
       
   153 		const eap_am_network_id_c * const send_network_id,
       
   154 		const eap_master_session_key_c * const master_session_key
       
   155 		) = 0;
       
   156 
       
   157 	/**
       
   158 	 * The read_configure() function reads the configuration data identified
       
   159 	 * by the field string of field_length bytes length. Adaptation module must direct
       
   160 	 * the query to some persistent store.
       
   161 	 * @param field is generic configure string idenfying the required configure data.
       
   162 	 * @param field_length is length of the field string.
       
   163 	 * @param data is pointer to existing eap_variable_data object.
       
   164 	 * 
       
   165 	 * EAP-type should store it's parameters to an own database. The own database should be accessed
       
   166 	 * through adaptation module of EAP-type. See eap_am_type_gsmsim_simulator_c::type_configure_read.
       
   167 	 */
       
   168 	virtual eap_status_e read_configure(
       
   169 		const eap_configuration_field_c * const field,
       
   170 		eap_variable_data_c * const data) = 0;
       
   171 
       
   172 	/**
       
   173 	 * The write_configure() function writes the configuration data identified
       
   174 	 * by the field string of field_length bytes length. Adaptation module must direct
       
   175 	 * the action to some persistent store.
       
   176 	 * @param field is generic configure string idenfying the required configure data.
       
   177 	 * @param field_length is length of the field string.
       
   178 	 * @param data is pointer to existing eap_variable_data object.
       
   179 	 * 
       
   180 	 * EAP-type should store it's parameters to an own database. The own database should be accessed
       
   181 	 * through adaptation module of EAP-type. See eap_am_type_gsmsim_simulator_c::type_configure_write.
       
   182 	 */
       
   183 	virtual eap_status_e write_configure(
       
   184 		const eap_configuration_field_c * const field,
       
   185 		eap_variable_data_c * const data) = 0;
       
   186 
       
   187 	/**
       
   188 	 * This is notification of internal state transition.
       
   189 	 * This is used for notifications, debugging and protocol testing.
       
   190 	 * The primal notifications are eap_state_variable_e::eap_state_authentication_finished_successfully
       
   191 	 * and eap_state_variable_e::eap_state_authentication_terminated_unsuccessfully. EAP-type MUST send these
       
   192 	 * two notifications to lower layer.
       
   193 	 * These two notifications are sent using EAP-protocol layer (eap_protocol_layer_e::eap_protocol_layer_eap).
       
   194 	 * See also eap_state_notification_c.
       
   195 	 */
       
   196 	virtual void state_notification(
       
   197 		const abs_eap_state_notification_c * const state) = 0;
       
   198 
       
   199 	/**
       
   200 	 * Client object of EAP-type calls this function.
       
   201 	 *  This function completes asyncronously query_eap_identity() function call.
       
   202 	 * @param send_network_id is network identity of target.
       
   203 	 * @param identity is pointer to object that includes the identity.
       
   204 	 * @param eap_identifier is EAP-Identifier for EAP-Response/Identity packet.
       
   205 	 */
       
   206 	virtual eap_status_e complete_eap_identity_query(
       
   207 		const eap_am_network_id_c * const send_network_id,
       
   208 		const eap_variable_data_c * const identity,
       
   209 		const u8_t eap_identifier) = 0;
       
   210 
       
   211 	/**
       
   212 	 * Client object of EAP-type calls this function.
       
   213 	 * This function gets the EAP-identity queried from previous EAP-type.
       
   214 	 * 
       
   215 	 * First EAP-type A is default. The eap_core_c object queries EAP-identity from EAP-type A.
       
   216 	 * Server process EAP-Response/Identity but there the default EAP-type is B.
       
   217 	 * Server sends EAP-Request/B. Client loads new EAP-type B 
       
   218 	 * and forwards EAP-Request/B to it. EAP-Request/B is the first EAP-packet EAP-type B receive.
       
   219 	 * It must continue using the EAP-identity obtained with EAP-type A. Now EAP-type B could get the EAP-identity
       
   220 	 * obtained with EAP-type A with this function.
       
   221 	 */
       
   222 	virtual eap_status_e get_saved_eap_identity(eap_variable_data_c * const identity) = 0;
       
   223 
       
   224 	/**
       
   225 	 * The set_session_timeout() function changes the session timeout timer to be elapsed after session_timeout_ms milliseconds.
       
   226 	 */
       
   227 	virtual eap_status_e set_session_timeout(
       
   228 		const u32_t session_timeout_ms) = 0;
       
   229 
       
   230 	/**
       
   231 	 * The set_timer() function initializes timer to be elapsed after time_ms milliseconds.
       
   232 	 * @param initializer is pointer to object which timer_expired() function will
       
   233 	 * be called after timer elapses.
       
   234 	 * @param id is identifier which will be returned in timer_expired() function.
       
   235 	 * The user selects and interprets the id for this timer.
       
   236 	 * @param data is pointer to any user selected data which will be returned in timer_expired() function.
       
   237 	 * @param time_ms is the time of timer in milli seconds.
       
   238 	 *
       
   239 	 * Adaptation module internally implements the timer.
       
   240 	 */
       
   241 	virtual eap_status_e set_timer(
       
   242 		abs_eap_base_timer_c * const initializer, 
       
   243 		const u32_t id, 
       
   244 		void * const data,
       
   245 		const u32_t time_ms) = 0;
       
   246 
       
   247 	/**
       
   248 	 * The cancel_timer() function cancels the timer id initiated by initializer.
       
   249 	 * @param initializer is pointer to object which set the cancelled timer.
       
   250 	 * @param id is identifier which will be returned in timer_expired() function.
       
   251 	 * The user selects and interprets the id for this timer.
       
   252 	 *
       
   253 	 * Adaptation module internally implements the timer.
       
   254 	 */
       
   255 	virtual eap_status_e cancel_timer(
       
   256 		abs_eap_base_timer_c * const initializer, 
       
   257 		const u32_t id) = 0;
       
   258 
       
   259 	/**
       
   260 	 * The cancel_all_timers() function cancels all timers.
       
   261 	 * User should use this in termination of the stack before
       
   262 	 * the adaptation module of tools is deleted.
       
   263 	 * Preferred mode is to cancel each timer directly
       
   264 	 * using cancel_timer() function.
       
   265 	 *
       
   266 	 * Adaptation module internally implements the timer.
       
   267 	 */
       
   268 	virtual eap_status_e cancel_all_timers() = 0;
       
   269 
       
   270 	/**
       
   271 	 * This is needed by PEAP type.
       
   272 	 * The load_module() function function indicates the lower level to
       
   273 	 * load new module of EAP-type.
       
   274 	 * @param type is the requested EAP-type.
       
   275 	 * @param partner is pointer to the caller object.
       
   276 	 * The partner of the new created EAP-type object is the caller object.
       
   277 	 * @param eap_type is a pointer to a pointer of EAP-type object.
       
   278 	 * Adaptation module sets eap_type pointer to created EAP-type object.
       
   279 	 * @param is_client_when_true parameter indicates whether the network entity should
       
   280 	 * act as a client (true) or server (false), in terms of EAP-protocol whether
       
   281 	 * this network entity is EAP-supplicant (true) or EAP-authenticator (false).
       
   282 	 * @param receive_network_id includes the addresses (network identity) and packet type.
       
   283 	 */
       
   284 	virtual eap_status_e load_module(
       
   285 		const eap_type_value_e type,
       
   286 		const eap_type_value_e /* tunneling_type */,
       
   287 		abs_eap_base_type_c * const partner,
       
   288 		eap_base_type_c ** const eap_type,
       
   289 		const bool is_client_when_true,
       
   290 		const eap_am_network_id_c * const receive_network_id) = 0;
       
   291 
       
   292 	/**
       
   293 	 * This is needed by PEAP type.
       
   294 	 * The unload_module() function unloads the module of a EAP-type. 
       
   295 	 * @param eap_type is the requested EAP-type.
       
   296 	 */
       
   297 	virtual eap_status_e unload_module(const eap_type_value_e eap_type) = 0;
       
   298 
       
   299 	/**
       
   300 	 * This is needed by PEAP type.
       
   301 	 * This function queries the validity of EAP-type.
       
   302 	 * Lower layer should return eap_status_ok if this EAP-type is supported.
       
   303 	 * @param eap_type is the requested EAP-type.
       
   304 	 */
       
   305 	virtual eap_status_e check_is_valid_eap_type(const eap_type_value_e eap_type) = 0;
       
   306 
       
   307 	/**
       
   308 	 * This function queries the list of supported EAP-types.
       
   309 	 * Lower layer should return eap_status_ok if this call succeeds.
       
   310 	 * @param eap_type_list will include the list of supported EAP-types. Each value in list
       
   311 	 * is type of u32_t and represent one supported EAP-type. List consists of subsequent u32_t type values.
       
   312 	 */
       
   313 	virtual eap_status_e get_eap_type_list(
       
   314 		eap_array_c<eap_type_value_e> * const eap_type_list) = 0;
       
   315 
       
   316 	virtual eap_status_e set_authentication_role(const bool when_true_set_client) = 0;
       
   317 
       
   318 	virtual eap_status_e add_rogue_ap(eap_array_c<eap_rogue_ap_entry_c> & rogue_ap_list) = 0;
       
   319 
       
   320 	virtual bool get_is_tunneled_eap() const = 0;
       
   321 
       
   322 	//--------------------------------------------------
       
   323 }; // class abs_eap_base_type_c
       
   324 
       
   325 #endif //#if !defined(_ABS_EAP_BASE_TYPE_H_)
       
   326 
       
   327 //--------------------------------------------------
       
   328 
       
   329 
       
   330 
       
   331 // End.