eapol/eapol_framework/eapol_common/include/abs_eap_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(_ABS_EAP_CORE_H_)
       
    22 #define _ABS_EAP_CORE_H_
       
    23 
       
    24 #include "eap_header.h"
       
    25 #include "eap_array.h"
       
    26 
       
    27 class eap_am_network_id_c;
       
    28 class eap_buf_chain_wr_c;
       
    29 class eap_configuration_field_c;
       
    30 class eap_variable_data_c;
       
    31 class abs_eap_base_type_c;
       
    32 class abs_eap_state_notification_c;
       
    33 class eap_base_type_c;
       
    34 class eap_rogue_ap_entry_c;
       
    35 class eap_master_session_key_c;
       
    36 
       
    37 
       
    38 /// This class defines the interface the eap_core_c class
       
    39 /// will use with the partner class (lower layer).
       
    40 class EAP_EXPORT abs_eap_core_c
       
    41 {
       
    42 private:
       
    43 	//--------------------------------------------------
       
    44 
       
    45 	//--------------------------------------------------
       
    46 protected:
       
    47 	//--------------------------------------------------
       
    48 
       
    49 	//--------------------------------------------------
       
    50 public:
       
    51 	//--------------------------------------------------
       
    52 
       
    53 	/**
       
    54 	 * The destructor of the abs_eap_core class does nothing special.
       
    55 	 */
       
    56 	virtual ~abs_eap_core_c()
       
    57 	{
       
    58 	}
       
    59 
       
    60 	/**
       
    61 	 * The constructor of the abs_eap_core class does nothing special.
       
    62 	 */
       
    63 	abs_eap_core_c()
       
    64 	{
       
    65 	}
       
    66 
       
    67 	/**
       
    68 	 * The derived class could send packets to partner class with this function.
       
    69 	 * @see abs_eap_base_type_c::packet_send().
       
    70 	 */
       
    71 	virtual eap_status_e packet_send(
       
    72 		const eap_am_network_id_c * const network_id,
       
    73 		eap_buf_chain_wr_c * const sent_packet,
       
    74 		const u32_t header_offset,
       
    75 		const u32_t data_length,
       
    76 		const u32_t buffer_length) = 0;
       
    77 
       
    78 	/**
       
    79 	 * The get_header_offset() function obtains the header offset of EAP-packet.
       
    80 	 * @see abs_eap_base_type_c::get_header_offset().
       
    81 	 */
       
    82 	virtual u32_t get_header_offset(
       
    83 		u32_t * const MTU,
       
    84 		u32_t * const trailer_length) = 0;
       
    85 
       
    86 	/**
       
    87 	 * The load_module() function function indicates the lower level to
       
    88 	 * load new module of EAP-type.
       
    89 	 * @param type is the requested EAP-type.
       
    90 	 * @param partner is pointer to the caller object.
       
    91 	 * The partner of the new created EAP-type object is the caller object.
       
    92 	 * @param eap_type is a pointer to a pointer of EAP-type object.
       
    93 	 * Adaptation module sets eap_type pointer to created EAP-type object.
       
    94 	 * @param is_client_when_true parameter indicates whether the network entity should
       
    95 	 * act as a client (true) or server (false), in terms of EAP-protocol whether
       
    96 	 * this network entity is EAP-supplicant (true) or EAP-authenticator (false).
       
    97 	 * @param receive_network_id includes the addresses (network identity) and packet type.
       
    98 	 */
       
    99 	virtual eap_status_e load_module(
       
   100 		const eap_type_value_e type,
       
   101 		const eap_type_value_e /* tunneling_type */,
       
   102 		abs_eap_base_type_c * const partner,
       
   103 		eap_base_type_c ** const eap_type,
       
   104 		const bool is_client_when_true,
       
   105 		const eap_am_network_id_c * const receive_network_id) = 0;
       
   106 
       
   107 	/**
       
   108 	 * The unload_module() function unloads the module of a EAP-type. 
       
   109 	 * @param eap_type is the requested EAP-type.
       
   110 	 */
       
   111 	virtual eap_status_e unload_module(const eap_type_value_e eap_type) = 0;
       
   112 
       
   113 	/**
       
   114 	 * The session calls the restart_authentication() function
       
   115 	 * when EAP-authentication is needed with another peer.
       
   116 	 * This is also used when session restarts authentication.
       
   117 	 * @param receive_network_id includes the addresses (network identity) and packet type.
       
   118 	 * @param is_client_when_true indicates whether the EAP-type should act as a client or server,
       
   119 	 * in terms of EAP-protocol whether this network entity is EAP-supplicant (true) or EAP-authenticator (false).
       
   120 	 * @param force_clean_restart this selects whether the server removes this session (true) or not (false).
       
   121 	 * @param from_timer tells whether the timer calls this function (true) or not (false).
       
   122 	 */
       
   123 	virtual eap_status_e restart_authentication(
       
   124 		const eap_am_network_id_c * const receive_network_id,
       
   125 		const bool is_client_when_true,
       
   126 		const bool force_clean_restart,
       
   127 		const bool from_timer = false) = 0;
       
   128 
       
   129 	/**
       
   130 	 * Note this function is just an example. Parameters will change later.
       
   131 	 * The packet_data_crypto_keys() function gives the generated keys to lower level.
       
   132 	 * After EAP-authentication has generated the keys it calls this function
       
   133 	 * to offer the keys to lower level.
       
   134 	 * @see abs_eap_base_type_c::packet_data_crypto_keys().
       
   135 	 */
       
   136 	virtual eap_status_e packet_data_crypto_keys(
       
   137 		const eap_am_network_id_c * const send_network_id,
       
   138 		const eap_master_session_key_c * const master_session_key
       
   139 		) = 0;
       
   140 
       
   141 	/**
       
   142 	 * The read_configure() function reads the configuration data identified
       
   143 	 * by the field string of field_length bytes length. Adaptation module must direct
       
   144 	 * the query to some persistent store.
       
   145 	 * @see abs_eap_base_type_c::read_configure().
       
   146 	 */
       
   147 	virtual eap_status_e read_configure(
       
   148 		const eap_configuration_field_c * const field,
       
   149 		eap_variable_data_c * const data) = 0;
       
   150 
       
   151 	/**
       
   152 	 * The write_configure() function writes the configuration data identified
       
   153 	 * by the field string of field_length bytes length. Adaptation module must direct
       
   154 	 * the action to some persistent store.
       
   155 	 * @see abs_eap_base_type_c::write_configure().
       
   156 	 */
       
   157 	virtual eap_status_e write_configure(
       
   158 		const eap_configuration_field_c * const field,
       
   159 		eap_variable_data_c * const data) = 0;
       
   160 
       
   161 	/**
       
   162 	 * This is notification of internal state transition.
       
   163 	 * This is used for notifications, debugging and protocol testing.
       
   164 	 * The primal notifications are eap_state_variable_e::eap_state_authentication_finished_successfully
       
   165 	 * and eap_state_variable_e::eap_state_authentication_terminated_unsuccessfully.
       
   166 	 * These two notifications are sent from EAP-protocol layer (eap_protocol_layer_e::eap_protocol_layer_eap).
       
   167 	 * These two notifications tells the end state of authentication session. These are the only
       
   168 	 * reliable indications of the final status of authentication session.
       
   169 	 * You MUST NOT make decision based on the return value of abs_eap_stack_interface_c::packet_process().
       
   170 	 */
       
   171 	virtual void state_notification(
       
   172 		const abs_eap_state_notification_c * const state) = 0;
       
   173 
       
   174 	/**
       
   175 	 * This function tells lower layer to remove EAP session object asyncronously.
       
   176 	 * @param eap_type is pointer to selector that identifies the removed EAP session.
       
   177 	 */
       
   178 	virtual eap_status_e asynchronous_init_remove_eap_session(
       
   179 		const eap_am_network_id_c * const send_network_id) = 0;
       
   180 
       
   181 	/**
       
   182 	 * The set_timer() function initializes timer to be elapsed after time_ms milliseconds.
       
   183 	 * @param initializer is pointer to object which timer_expired() function will
       
   184 	 * be called after timer elapses.
       
   185 	 * @param id is identifier which will be returned in timer_expired() function.
       
   186 	 * The user selects and interprets the id for this timer.
       
   187 	 * @param data is pointer to any user selected data which will be returned in timer_expired() function.
       
   188 	 * @param time_ms is the time of timer in milli seconds.
       
   189 	 *
       
   190 	 * Adaptation module internally implements the timer.
       
   191 	 */
       
   192 	virtual eap_status_e set_timer(
       
   193 		abs_eap_base_timer_c * const initializer, 
       
   194 		const u32_t id, 
       
   195 		void * const data,
       
   196 		const u32_t time_ms) = 0;
       
   197 
       
   198 	/**
       
   199 	 * The cancel_timer() function cancels the timer id initiated by initializer.
       
   200 	 * @param initializer is pointer to object which set the cancelled timer.
       
   201 	 * @param id is identifier which will be returned in timer_expired() function.
       
   202 	 * The user selects and interprets the id for this timer.
       
   203 	 *
       
   204 	 * Adaptation module internally implements the timer.
       
   205 	 */
       
   206 	virtual eap_status_e cancel_timer(
       
   207 		abs_eap_base_timer_c * const initializer, 
       
   208 		const u32_t id) = 0;
       
   209 
       
   210 	/**
       
   211 	 * The cancel_all_timers() function cancels all timers.
       
   212 	 * User should use this in termination of the stack before
       
   213 	 * the adaptation module of tools is deleted.
       
   214 	 * Preferred mode is to cancel each timer directly
       
   215 	 * using cancel_timer() function.
       
   216 	 *
       
   217 	 * Adaptation module internally implements the timer.
       
   218 	 */
       
   219 	virtual eap_status_e cancel_all_timers() = 0;
       
   220 
       
   221 	/**
       
   222 	 * This function queries the validity of EAP-type.
       
   223 	 * Lower layer should return eap_status_ok if this EAP-type is supported.
       
   224 	 * @param eap_type is the requested EAP-type.
       
   225 	 */
       
   226 	virtual eap_status_e check_is_valid_eap_type(const eap_type_value_e eap_type) = 0;
       
   227 
       
   228 	/**
       
   229 	 * This function queries the list of supported EAP-types.
       
   230 	 * Lower layer should return eap_status_ok if this call succeeds.
       
   231 	 * @param eap_type_list will include the list of supported EAP-types. Each value in list
       
   232 	 * is type of u32_t and represent one supported EAP-type. List consists of subsequent u32_t type values.
       
   233 	 */
       
   234 	virtual eap_status_e get_eap_type_list(
       
   235 		eap_array_c<eap_type_value_e> * const eap_type_list) = 0;
       
   236 
       
   237 	virtual eap_status_e add_rogue_ap(eap_array_c<eap_rogue_ap_entry_c> & rogue_ap_list) = 0;
       
   238 
       
   239 	/**
       
   240 	 * The set_session_timeout() function changes the session timeout timer to be elapsed after session_timeout_ms milliseconds.
       
   241 	 */
       
   242 	virtual eap_status_e set_session_timeout(
       
   243 		const u32_t session_timeout_ms) = 0;
       
   244 
       
   245 	//--------------------------------------------------
       
   246 }; // class abs_eap_core_c
       
   247 
       
   248 #endif //#if !defined(_ABS_EAP_CORE_H_)
       
   249 
       
   250 //--------------------------------------------------
       
   251 
       
   252 
       
   253 
       
   254 // End.