eapol/eapol_framework/eapol_common/include/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(_EAP_BASE_TYPE_H_)
       
    22 #define _EAP_BASE_TYPE_H_
       
    23 
       
    24 #include "eap_am_export.h"
       
    25 #include "abs_eap_base_type.h"
       
    26 #include "eap_header.h"
       
    27 
       
    28 
       
    29 class abs_eap_base_type_c;
       
    30 class eap_am_network_id_c;
       
    31 
       
    32 /// The eap_base_type_c class declares pure virtual functions 
       
    33 /// a user class of EAP-type class could call.
       
    34 /// See also abs_eap_stack_interface_c. It includes
       
    35 /// important functions too.
       
    36 class EAP_EXPORT eap_base_type_c
       
    37 //: public abs_eap_stack_interface_c This is not used here because packet_process() function differs.
       
    38 {
       
    39 
       
    40 private:
       
    41 	//--------------------------------------------------
       
    42 
       
    43 	/// This is back pointer to object which created this object.
       
    44 	/// The eap_base_type_c object sends packets to the network using m_type_partner object.
       
    45 	/// @see abs_eap_base_type_c.
       
    46 	abs_eap_base_type_c *m_type_partner;
       
    47 
       
    48 	/// This is pointer to the tools class. @see abs_eap_am_tools_c.
       
    49 	abs_eap_am_tools_c * const m_am_tools;
       
    50 
       
    51 	/// This is count of references to this EAP-type.
       
    52 	/// EAP-type is removed from eap_core_map_c after the reference count is zero.
       
    53 	u32_t m_reference_count;
       
    54 
       
    55 	/**
       
    56 	 * The set_is_valid() function sets the state of the object valid.
       
    57 	 * The creator of this object calls this function after it is initialized. 
       
    58 	 */
       
    59 	virtual void set_is_valid() = 0;
       
    60 
       
    61 	//--------------------------------------------------
       
    62 protected:
       
    63 	//--------------------------------------------------
       
    64 
       
    65 	//--------------------------------------------------
       
    66 public:
       
    67 	//--------------------------------------------------
       
    68 
       
    69 	/**
       
    70 	 * The destructor of the eap_base_type class does nothing special.
       
    71 	 */
       
    72 	EAP_FUNC_IMPORT virtual ~eap_base_type_c();
       
    73 
       
    74 	/**
       
    75 	 * The constructor of the eap_base_type class simply initializes the attributes.
       
    76 	 * @param tools is pointer to the tools class. @see abs_eap_am_tools_c.
       
    77 	 * @param partner is back pointer to object which created this object.
       
    78 	 * The eap_base_type_c object sends packets to the network using m_type_partner object.
       
    79 	 */
       
    80 	EAP_FUNC_IMPORT eap_base_type_c(
       
    81 		abs_eap_am_tools_c * const tools,
       
    82 		abs_eap_base_type_c * const partner);
       
    83 
       
    84 	/**
       
    85 	 * The object_increase_reference_count() function increases the reference count.
       
    86 	 */
       
    87 	EAP_FUNC_IMPORT void object_increase_reference_count();
       
    88 
       
    89 	/**
       
    90 	 * The object_decrease_reference_count () function decreases 
       
    91 	 * the reference count and returns the remaining value.
       
    92 	 * The EAP type is removed after there is no references to it.
       
    93 	 */
       
    94 	EAP_FUNC_IMPORT u32_t object_decrease_reference_count();
       
    95 
       
    96 	/**
       
    97 	 * Type partner is object below the EAP-type object.
       
    98 	 * @return The get_type_partner() function returns the pointer to the partner class.
       
    99 	 */
       
   100 	EAP_FUNC_IMPORT abs_eap_base_type_c * get_type_partner();
       
   101 
       
   102 	/**
       
   103 	 * This function queries the identity of user using this type.
       
   104 	 * @param must_be_synchronous tells whether this call must be synchronous.
       
   105 	 * @param identity is buffer for queried identity in synchronous call.
       
   106 	 * @param receive_network_id carries the addresses and type of the received packet.
       
   107 	 * @param eap_identifier is EAP-Identifier for EAP-Response/Identity packet.
       
   108 	 *
       
   109 	 * Parameters receive_network_id and eap_identifier are used in asynchronous 
       
   110 	 * completion of this call. See abs_eap_base_type_c::complete_eap_identity_query().
       
   111 	 */
       
   112 	virtual eap_status_e query_eap_identity(
       
   113 		const bool must_be_synchronous,
       
   114 		eap_variable_data_c * const identity,
       
   115 		const eap_am_network_id_c * const receive_network_id,
       
   116 		const u8_t eap_identifier) = 0;
       
   117 
       
   118 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
   119 
       
   120 	/**
       
   121 	 * The configure() function is called after the constructor of the 
       
   122 	 * object is successfully executed. During the function call the object 
       
   123 	 * could query the configuration. Each derived class must define this function.
       
   124 	 * Needed configuration depends on the EAP-type.
       
   125 	 */
       
   126 	virtual eap_status_e configure() = 0;
       
   127 
       
   128 	/**
       
   129 	 * The shutdown() function is called before the destructor of the 
       
   130 	 * object is executed. During the function call the object 
       
   131 	 * could shutdown the operations, for example cancel timers.
       
   132 	 * Each derived class must define this function.
       
   133 	 */
       
   134 	virtual eap_status_e shutdown() = 0;
       
   135 
       
   136 	/**
       
   137 	 * This function processes the received packet.
       
   138 	 * The return value of this function should be used only for traces
       
   139 	 * and error counters. You MUST NOT make any decision of authentication session
       
   140 	 * based on the return value. The stack calls abs_eap_core_c::state_notification()
       
   141 	 * function when authentication session terminates unsuccessfully or ends successfully.
       
   142 	 * You MUST make decision of authentication session based on the state_notification() call.
       
   143 	 * See more abs_eap_core_c::state_notification().
       
   144 	 * @param receive_network_id carries the addresses and type of the received packet.
       
   145 	 * @param eap includes the buffer of the packet.
       
   146 	 * @param packet_length is length in bytes of the EAP-packet.
       
   147 	 */
       
   148 	virtual eap_status_e packet_process(
       
   149 		const eap_am_network_id_c * const receive_network_id,
       
   150 		eap_header_wr_c * const eap,
       
   151 		const u32_t packet_length) = 0;
       
   152 
       
   153 	/**
       
   154 	 * Object must indicate it's validity.
       
   155 	 * If object initialization fails this function must return false.
       
   156 	 * @return This function returns the validity of this object.
       
   157 	 */
       
   158 	virtual bool get_is_valid() = 0;
       
   159 
       
   160 	/**
       
   161 	 * This function resets the reused object.
       
   162 	 */
       
   163 	virtual eap_status_e reset() = 0;
       
   164 
       
   165 	/**
       
   166 	 * This function sets the initial EAP-Identifier to be used for the first sent packet.
       
   167 	 * This function is only needed in Windows RAS.
       
   168 	 */
       
   169 	virtual eap_status_e set_initial_eap_identifier(
       
   170 		const eap_am_network_id_c * const receive_network_id,
       
   171 		const u8_t initial_identifier) = 0;
       
   172 
       
   173 	/**
       
   174 	 * The adaptation module calls the eap_acknowledge() function after
       
   175 	 * any Network Protocol packet is received. This is used as a success indication.
       
   176 	 * This is described in RFC 2284 "PPP Extensible Authentication Protocol (EAP)".
       
   177 	 * Mostly there is only one session in the client.
       
   178 	 * The server does not need eap_acknowledge() function because
       
   179 	 * server (EAP-authenticator) sends the EAP-success message.
       
   180 	 */
       
   181 	virtual eap_status_e eap_acknowledge(
       
   182 		const eap_am_network_id_c * const receive_network_id) = 0;
       
   183 
       
   184 	//--------------------------------------------------
       
   185 }; // class eap_base_type_c
       
   186 
       
   187 #endif //#if !defined(_EAP_BASE_TYPE_H_)
       
   188 
       
   189 //--------------------------------------------------
       
   190 
       
   191 
       
   192 
       
   193 // End.