eapol/eapol_framework/eapol_common/type/radius/include/abs_eap_radius.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_RADIUS_H_)
       
    22 #define _ABS_EAP_RADIUS_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 
       
    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_radius_c
       
    39 {
       
    40 private:
       
    41 	//--------------------------------------------------
       
    42 
       
    43 	//--------------------------------------------------
       
    44 protected:
       
    45 	//--------------------------------------------------
       
    46 
       
    47 	//--------------------------------------------------
       
    48 public:
       
    49 	//--------------------------------------------------
       
    50 
       
    51 	/**
       
    52 	 * The destructor of the abs_eap_radius_c class does nothing special.
       
    53 	 */
       
    54 	virtual ~abs_eap_radius_c()
       
    55 	{
       
    56 	}
       
    57 
       
    58 	/**
       
    59 	 * The constructor of the abs_eap_radius_c class does nothing special.
       
    60 	 */
       
    61 	abs_eap_radius_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 	 * The get_header_offset() function obtains the header offset of EAP-packet.
       
    98 	 * @param MTU_length is pointer to variable to store the maximum transfer unit (MTU).
       
    99 	 * MTU is the maximum EAP-packet length in bytes
       
   100 	 * @param trailer_length is pointer to the variable to store length
       
   101 	 * of trailer needed by lower levels.
       
   102 	 * @return Function returns the offset of EAP-header.
       
   103 	 *
       
   104 	 * The needed buffer length is ((offset) + (EAP-packet length) + (trailer)) bytes.
       
   105 	 * Each layer adds the length of the header to offset.
       
   106 	 * Each layer removes the length of the header and trailer from MTU.
       
   107 	 *
       
   108 	 * Now some ascii graphics follows.
       
   109 	 * @code
       
   110 	 * |<-------------------------buffer length----------------------------------------->|
       
   111 	 * |                                                                                 |
       
   112 	 * |                     +-----+---------------------------------------+             |
       
   113 	 * |                     | EAP |  data                                 |             |
       
   114 	 * |                     +-----+---------------------------------------+             |
       
   115 	 * |<----offset--------->|<----MTU------------------------------------>|<--trailer-->|
       
   116 	 * |                     |                                             |             |
       
   117 	 * |             +-------+---------------------------------------------+             |
       
   118 	 * |             | EAPOL |  data                                       |             |
       
   119 	 * |             +-------+---------------------------------------------+             |
       
   120 	 * |<--offset--->|<----MTU-------------------------------------------->|<--trailer-->|
       
   121 	 * |             |                                                     |             |
       
   122 	 * +-------------+-----------------------------------------------------+-------------+
       
   123 	 * |  ETHERNET   |  data                                               |  trailer    |
       
   124 	 * +-------------+-----------------------------------------------------+-------------+
       
   125 	 * |<----MTU------------------------------------------------------------------------>|
       
   126 	 * @endcode
       
   127 	 *
       
   128 	 */
       
   129 	virtual u32_t get_header_offset(
       
   130 		u32_t * const MTU_length,
       
   131 		u32_t * const trailer_length) = 0;
       
   132 
       
   133 	/**
       
   134 	 * Note this function is just an example. Parameters will change later.
       
   135 	 * The packet_data_crypto_keys() function gives the generated keys to lower level.
       
   136 	 * After EAP-authentication has generated the keys it calls this function
       
   137 	 * to offer the keys to lower level.
       
   138 	 * @param master_session_key is pointer to the first byte of the master session key.
       
   139 	 * @param master_session_length is count of bytes in the master session key.
       
   140 	 */
       
   141 	virtual eap_status_e packet_data_crypto_keys(
       
   142 		const eap_am_network_id_c * const send_network_id,
       
   143 		const eap_master_session_key_c * const master_session_key
       
   144 		) = 0;
       
   145 
       
   146 	/**
       
   147 	 * The read_configure() function reads the configuration data identified
       
   148 	 * by the field string of field_length bytes length. Adaptation module must direct
       
   149 	 * the query to some persistent store.
       
   150 	 * @param field is generic configure string idenfying the required configure data.
       
   151 	 * @param field_length is length of the field string.
       
   152 	 * @param data is pointer to existing eap_variable_data object.
       
   153 	 * 
       
   154 	 * EAP-type should store it's parameters to an own database. The own database should be accessed
       
   155 	 * through adaptation module of EAP-type. See eap_am_type_gsmsim_simulator_c::type_configure_read.
       
   156 	 */
       
   157 	virtual eap_status_e read_configure(
       
   158 		const eap_configuration_field_c * const field,
       
   159 		eap_variable_data_c * const data) = 0;
       
   160 
       
   161 	/**
       
   162 	 * The write_configure() function writes the configuration data identified
       
   163 	 * by the field string of field_length bytes length. Adaptation module must direct
       
   164 	 * the action to some persistent store.
       
   165 	 * @param field is generic configure string idenfying the required configure data.
       
   166 	 * @param field_length is length of the field string.
       
   167 	 * @param data is pointer to existing eap_variable_data object.
       
   168 	 * 
       
   169 	 * EAP-type should store it's parameters to an own database. The own database should be accessed
       
   170 	 * through adaptation module of EAP-type. See eap_am_type_gsmsim_simulator_c::type_configure_write.
       
   171 	 */
       
   172 	virtual eap_status_e write_configure(
       
   173 		const eap_configuration_field_c * const field,
       
   174 		eap_variable_data_c * const data) = 0;
       
   175 
       
   176 	/**
       
   177 	 * This is notification of internal state transition.
       
   178 	 * This is used for notifications, debugging and protocol testing.
       
   179 	 * The primal notifications are eap_state_variable_e::eap_state_authentication_finished_successfully
       
   180 	 * and eap_state_variable_e::eap_state_authentication_terminated_unsuccessfully. EAP-type MUST send these
       
   181 	 * two notifications to lower layer.
       
   182 	 * These two notifications are sent using EAP-protocol layer (eap_protocol_layer_e::eap_protocol_layer_eap).
       
   183 	 * See also eap_state_notification_c.
       
   184 	 */
       
   185 	virtual void state_notification(
       
   186 		const abs_eap_state_notification_c * const state) = 0;
       
   187 
       
   188 	/**
       
   189 	 * The set_timer() function initializes timer to be elapsed after time_ms milliseconds.
       
   190 	 * @param initializer is pointer to object which timer_expired() function will
       
   191 	 * be called after timer elapses.
       
   192 	 * @param id is identifier which will be returned in timer_expired() function.
       
   193 	 * The user selects and interprets the id for this timer.
       
   194 	 * @param data is pointer to any user selected data which will be returned in timer_expired() function.
       
   195 	 * @param time_ms is the time of timer in milli seconds.
       
   196 	 *
       
   197 	 * Adaptation module internally implements the timer.
       
   198 	 */
       
   199 	virtual eap_status_e set_timer(
       
   200 		abs_eap_base_timer_c * const initializer, 
       
   201 		const u32_t id, 
       
   202 		void * const data,
       
   203 		const u32_t time_ms) = 0;
       
   204 
       
   205 	/**
       
   206 	 * The cancel_timer() function cancels the timer id initiated by initializer.
       
   207 	 * @param initializer is pointer to object which set the cancelled timer.
       
   208 	 * @param id is identifier which will be returned in timer_expired() function.
       
   209 	 * The user selects and interprets the id for this timer.
       
   210 	 *
       
   211 	 * Adaptation module internally implements the timer.
       
   212 	 */
       
   213 	virtual eap_status_e cancel_timer(
       
   214 		abs_eap_base_timer_c * const initializer, 
       
   215 		const u32_t id) = 0;
       
   216 
       
   217 	/**
       
   218 	 * The cancel_all_timers() function cancels all timers.
       
   219 	 * User should use this in termination of the stack before
       
   220 	 * the adaptation module of tools is deleted.
       
   221 	 * Preferred mode is to cancel each timer directly
       
   222 	 * using cancel_timer() function.
       
   223 	 *
       
   224 	 * Adaptation module internally implements the timer.
       
   225 	 */
       
   226 	virtual eap_status_e cancel_all_timers() = 0;
       
   227 
       
   228 	/**
       
   229 	 * This is needed by PEAP type.
       
   230 	 * The load_module() function function indicates the lower level to
       
   231 	 * load new module of EAP-type.
       
   232 	 * @param type is the requested EAP-type.
       
   233 	 * @param partner is pointer to the caller object.
       
   234 	 * The partner of the new created EAP-type object is the caller object.
       
   235 	 * @param eap_type is a pointer to a pointer of EAP-type object.
       
   236 	 * Adaptation module sets eap_type pointer to created EAP-type object.
       
   237 	 * @param is_client_when_true parameter indicates whether the network entity should
       
   238 	 * act as a client (true) or server (false), in terms of EAP-protocol whether
       
   239 	 * this network entity is EAP-supplicant (true) or EAP-authenticator (false).
       
   240 	 * @param receive_network_id includes the addresses (network identity) and packet type.
       
   241 	 */
       
   242 	virtual eap_status_e load_module(
       
   243 		const eap_type_value_e type,
       
   244 		const eap_type_value_e tunneling_type,
       
   245 		abs_eap_base_type_c * const partner,
       
   246 		eap_base_type_c ** const eap_type,
       
   247 		const bool is_client_when_true,
       
   248 		const eap_am_network_id_c * const receive_network_id) = 0;
       
   249 
       
   250 	/**
       
   251 	 * This is needed by PEAP type.
       
   252 	 * The unload_module() function unloads the module of a EAP-type. 
       
   253 	 * @param eap_type is the requested EAP-type.
       
   254 	 */
       
   255 	virtual eap_status_e unload_module(const eap_type_value_e eap_type) = 0;
       
   256 
       
   257 	/**
       
   258 	 * This is needed by PEAP type.
       
   259 	 * This function queries the validity of EAP-type.
       
   260 	 * Lower layer should return eap_status_ok if this EAP-type is supported.
       
   261 	 * @param eap_type is the requested EAP-type.
       
   262 	 */
       
   263 	virtual eap_status_e check_is_valid_eap_type(const eap_type_value_e eap_type) = 0;
       
   264 
       
   265 	/**
       
   266 	 * This function queries the list of supported EAP-types.
       
   267 	 * Lower layer should return eap_status_ok if this call succeeds.
       
   268 	 * @param eap_type_list will include the list of supported EAP-types. Each value in list
       
   269 	 * is type of u32_t and represent one supported EAP-type. List consists of subsequent u32_t type values.
       
   270 	 */
       
   271 	virtual eap_status_e get_eap_type_list(
       
   272 		eap_array_c<eap_type_value_e> * const eap_type_list) = 0;
       
   273 
       
   274 	virtual eap_status_e add_rogue_ap(eap_array_c<eap_rogue_ap_entry_c> & rogue_ap_list) = 0;
       
   275 
       
   276 	//--------------------------------------------------
       
   277 }; // class abs_eap_radius_c
       
   278 
       
   279 #endif //#if !defined(_ABS_EAP_RADIUS_H_)
       
   280 
       
   281 //--------------------------------------------------
       
   282 
       
   283 
       
   284 
       
   285 // End.