eapol/eapol_framework/eapol_symbian/am/include/eapol_am_core_symbian.h
branchGCC_SURGE
changeset 40 60f08993dad0
parent 29 77618ad58aba
parent 39 fe6b6762fccd
equal deleted inserted replaced
29:77618ad58aba 40:60f08993dad0
     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: 11 %
       
    20 */
       
    21 
       
    22 #if !defined(_EAPOL_AM_CORE_SYMBIAN_H_)
       
    23 #define _EAPOL_AM_CORE_SYMBIAN_H_
       
    24 
       
    25 // INCLUDES
       
    26 #include <d32dbms.h>
       
    27 #include <wlanmgmtpacket.h> // For MWlanMgmtPacket
       
    28 
       
    29 #include <wdbifwlansettings.h>
       
    30 
       
    31 #include "abs_ethernet_core.h"
       
    32 #include "eapol_key_types.h"
       
    33 #include <EapType.h> // For TIndexType
       
    34 //#include "EapolTimer.h"
       
    35 
       
    36 #include <Eapol.h>
       
    37 
       
    38 // FORWARD DECLARATIONS
       
    39 class MEapolToWlmIf;
       
    40 class CEapType;
       
    41 class ethernet_core_c;
       
    42 class eap_am_tools_symbian_c;
       
    43 class eap_file_config_c;
       
    44 
       
    45 const TInt KMaxWPAPSKPasswordLength = 64;
       
    46 const TInt KWPAPSKLength = 32;
       
    47 
       
    48 // CLASS DECLARATION
       
    49 class eapol_am_core_symbian_c
       
    50 :  public CActive, public abs_ethernet_core_c,
       
    51 	public abs_eap_base_timer_c
       
    52 
       
    53 {
       
    54 public:
       
    55 
       
    56 	struct TPSKEntry {
       
    57 		TIndexType indexType;
       
    58 		TUint index;
       
    59 		TBuf8<KMaxSSIDLength> ssid;
       
    60 		TBuf8<KMaxWPAPSKPasswordLength> password;
       
    61 		TBuf8<KWPAPSKLength> psk;
       
    62 	};
       
    63 
       
    64 	virtual ~eapol_am_core_symbian_c();	
       
    65 	
       
    66 	///////////////////////////////////////////////////////////////
       
    67 	/* These are called from WLM via CEapol */
       
    68 
       
    69 	static eapol_am_core_symbian_c * NewL(
       
    70 		MEapolToWlmIf* const aPartner,
       
    71 		const bool aIsClient = ETrue,
       
    72 		const TUint aServerIndex = 0);
       
    73 
       
    74 
       
    75 	TInt Start( 
       
    76 		const TIndexType aIndexType, 
       
    77 		const TUint aIndex,
       
    78 		const TSSID& aSSID,
       
    79 		const TBool aWPAOverrideEnabled,
       
    80 		const TUint8* aWPAPSK,
       
    81 		const TUint aWPAPSKLength
       
    82 		);
       
    83 
       
    84 	TInt CompleteAssociation(
       
    85 		const TInt aResult,
       
    86 		const TMacAddress& aLocalAddress, 
       
    87 		const TMacAddress& aRemoteAddress,
       
    88 		const TUint8* const aReceivedWPAIE, // WLM must give only the WPA IE to EAPOL									        
       
    89 		const TUint aReceivedWPAIELength,
       
    90 		const TUint8* const aSentWPAIE,
       
    91 		const TUint aSentWPAIELength,
       
    92 		const TWPACipherSuite aGroupKeyCipherSuite,
       
    93 		const TWPACipherSuite aPairwiseKeyCipherSuite
       
    94 		);		
       
    95 
       
    96 	
       
    97 	TInt Disassociated(); 
       
    98 		
       
    99 	TInt ReceivePacket(
       
   100 		const TUint aLength, 
       
   101 		const TUint8* const aData);
       
   102 
       
   103 	TInt SendWPAMICFailureReport(
       
   104 		TBool aFatalMICFailure,
       
   105 		const TMICFailureType aMICFailureType); 	
       
   106 
       
   107 	/////////////////////////////////////////
       
   108 	/* These are called from ethernet_core */
       
   109 	
       
   110 	/**
       
   111 	* Sends packet to lower layers
       
   112 	*/
       
   113 	eap_status_e packet_send(
       
   114 		const eap_am_network_id_c * const send_network_id,
       
   115 		eap_buf_chain_wr_c * const sent_packet,
       
   116 		const u32_t header_offset,
       
   117 		const u32_t data_length,
       
   118 		const u32_t buffer_length); 
       
   119 
       
   120 	u32_t get_header_offset(
       
   121 		u32_t * const MTU,
       
   122 		u32_t * const trailer_length);
       
   123 
       
   124 	eap_status_e eap_acknowledge(const eap_am_network_id_c * const receive_network_id); 
       
   125 
       
   126 	eap_status_e reassociate(
       
   127 			const eap_am_network_id_c * const send_network_id,
       
   128 			const eapol_key_authentication_type_e authentication_type,
       
   129 			const eap_variable_data_c * const PMKID,
       
   130 			const eap_variable_data_c * const WPXM_WPXK1,
       
   131 			const eap_variable_data_c * const WPXM_WPXK2);
       
   132 
       
   133 	/**
       
   134 	* Loads an EAP type plug-in.
       
   135 	* @param type Type to be loaded.
       
   136 	* @param partner Pointer to the partner class for the EAP type.
       
   137 	* @param eap_type The pointer for the loaded type should be set here.
       
   138 	* @param is_client_when_true Indicates whether the loaded EAP type should be client or server.
       
   139 	* @param receive_network_id Network address.
       
   140 	*/
       
   141 	eap_status_e load_module(
       
   142 		const eap_type_value_e type,
       
   143 		const eap_type_value_e /* tunneling_type */,
       
   144 		abs_eap_base_type_c * const partner,
       
   145 		eap_base_type_c ** const eap_type,
       
   146 		const bool is_client_when_true,
       
   147 		const eap_am_network_id_c * const receive_network_id);
       
   148 
       
   149 	eap_status_e unload_module(const eap_type_value_e type); 	
       
   150 
       
   151 	void set_is_valid();
       
   152 
       
   153 	bool get_is_valid();
       
   154 
       
   155 	void increment_authentication_counter();
       
   156 
       
   157 	u32_t get_authentication_counter();
       
   158 
       
   159 	bool get_is_client();
       
   160 
       
   161 	/**
       
   162 	* This does the initial configuration of the class.
       
   163 	*/
       
   164 	eap_status_e configure();
       
   165 
       
   166 	eap_status_e shutdown();
       
   167 
       
   168 	/**
       
   169 	* Reads a configuration parameter value from the database. 
       
   170 	* In Symbian this function is only a TRAP wrapper for read_configure_L.
       
   171 	*/
       
   172 	eap_status_e read_configure(
       
   173 		const eap_configuration_field_c * const field,
       
   174 		eap_variable_data_c * const data);
       
   175 
       
   176 	eap_status_e write_configure(
       
   177 		const eap_configuration_field_c * const field,
       
   178 		eap_variable_data_c * const data);
       
   179 
       
   180 	// See abs_eap_base_type_c::state_notification().
       
   181 	void state_notification(const abs_eap_state_notification_c * const state);
       
   182 	
       
   183 	eap_status_e set_timer(
       
   184 		abs_eap_base_timer_c * const p_initializer, 
       
   185 		const u32_t p_id, 
       
   186 		void * const p_data,
       
   187 		const u32_t p_time_ms);
       
   188 
       
   189 	eap_status_e cancel_timer(
       
   190 		abs_eap_base_timer_c * const p_initializer, 
       
   191 		const u32_t p_id);
       
   192 
       
   193 	eap_status_e cancel_all_timers();
       
   194 
       
   195 	eap_status_e check_is_valid_eap_type(const eap_type_value_e eap_type);
       
   196 	
       
   197 	eap_status_e packet_data_crypto_keys(
       
   198 		const eap_am_network_id_c * const send_network_id,
       
   199 		const eap_variable_data_c * const master_session_key);
       
   200 
       
   201 	/**
       
   202 	* Forwards the keys to lower layer (= WLM).
       
   203 	*/
       
   204 	eap_status_e packet_data_session_key(
       
   205 		const eap_am_network_id_c * const send_network_id,
       
   206 		const eapol_session_key_c * const key);
       
   207 
       
   208 	/**
       
   209 	* Packet mangling routine for testing.
       
   210 	*/
       
   211 	
       
   212 	eap_status_e timer_expired(const u32_t id, void *data);
       
   213 
       
   214 	eap_status_e timer_delete_data(const u32_t id, void *data);
       
   215 
       
   216 	eap_status_e get_eap_type_list(
       
   217 		eap_array_c<eap_type_value_e> * const eap_type_list);
       
   218 
       
   219 	eap_status_e add_rogue_ap(eap_array_c<eap_rogue_ap_entry_c> & rogue_ap_list);
       
   220 
       
   221 protected:
       
   222 	
       
   223 	eapol_am_core_symbian_c(
       
   224 		MEapolToWlmIf * const aPartner,
       
   225 		const bool is_client_when_true,
       
   226 		const TUint aServerIndex);
       
   227 	
       
   228 	void ConstructL();
       
   229 
       
   230 	void RunL();
       
   231 	
       
   232 	void DoCancel();
       
   233 
       
   234 private:
       
   235 
       
   236 	eap_status_e random_error(
       
   237 		eap_buf_chain_wr_c * const sent_packet,
       
   238 		const bool forse_error,
       
   239 		const u32_t packet_index);
       
   240 
       
   241 	/**
       
   242 	* Tries to open EAPOL parameter database.
       
   243 	*/
       
   244 	void TryOpenDatabaseL(RDbNamedDatabase& aDatabase, RDbs& aSession);
       
   245 
       
   246 	/**
       
   247 	* Opening function for EAPOL parameter database.
       
   248 	*/
       
   249 	void OpenDatabaseL(RDbNamedDatabase& aDatabase, RDbs& aSession);
       
   250 	
       
   251 	void read_configureL(eap_config_string field,
       
   252 										const u32_t field_length,
       
   253 										eap_variable_data_c * const data);	
       
   254 
       
   255 	void ReadEAPSettingsL();
       
   256 
       
   257 	void SetToTopPriorityL(const TEap* const aEapType);
       
   258 
       
   259 	eap_status_e create_upper_stack();
       
   260 
       
   261 	void RetrievePSKL(TPSKEntry& entry);
       
   262 
       
   263 	void SavePSKL(TPSKEntry& entry);
       
   264 
       
   265 
       
   266 
       
   267 private:
       
   268 
       
   269 	RDbs m_session;
       
   270 	RDbNamedDatabase m_database;
       
   271 
       
   272 	/// Pointer to the lower layer in the stack
       
   273 	MEapolToWlmIf* m_partner;
       
   274 
       
   275 	/// Pointer to the upper layer in the stack
       
   276 	ethernet_core_c* m_ethernet_core;
       
   277 
       
   278 	/// Pointer to the tools class
       
   279 	eap_am_tools_symbian_c* m_am_tools;
       
   280 
       
   281 	bool m_enable_random_errors;
       
   282 
       
   283 	u32_t m_error_probability;
       
   284 
       
   285 	u32_t m_generate_multiple_error_packets;
       
   286 	
       
   287 	u32_t m_authentication_counter;
       
   288 
       
   289 	u32_t m_successful_authentications;
       
   290 
       
   291 	u32_t m_failed_authentications;
       
   292 
       
   293 	bool m_is_valid;
       
   294 
       
   295 	bool m_is_client;	
       
   296 
       
   297 	/// Array for storing the loaded EAP types.
       
   298 	RPointerArray<CEapType> m_plugin_if_array;
       
   299 	/// Array which corresponds with m_plugin_if_array and indicates the types of the loaded EAP types.
       
   300 	RArray<eap_type_value_e> m_eap_type_array;
       
   301 
       
   302 	/// EAP configuration data from CommDb
       
   303 	TEapArray m_iap_eap_array;
       
   304 	TUint m_eap_index;
       
   305 	/// Indicates the bearer type
       
   306 	TIndexType m_index_type;
       
   307 	/// Indicates the service index in CommDb
       
   308 	TUint m_index;
       
   309 
       
   310 	u32_t m_packet_index;
       
   311 
       
   312 	bool m_manipulate_ethernet_header;
       
   313 
       
   314 	bool m_send_original_packet_first;
       
   315 
       
   316 	bool m_authentication_indication_sent;
       
   317 
       
   318 	bool m_unicast_wep_key_received;
       
   319 
       
   320 	bool m_broadcast_wep_key_received;
       
   321 
       
   322 	bool m_block_packet_sends_and_notifications;
       
   323 
       
   324 	bool m_success_indication_sent;
       
   325 
       
   326 	bool m_first_authentication;
       
   327 
       
   328 	bool m_self_disassociated;
       
   329 
       
   330 	TAuthenticationMode m_802_11_authentication_mode;
       
   331 
       
   332 	EWlanSecurityMode m_security_mode;
       
   333 
       
   334 	eap_variable_data_c * m_wpa_preshared_key;
       
   335 
       
   336 	eap_variable_data_c * m_ssid;
       
   337 
       
   338 	eap_am_network_id_c* m_receive_network_id;
       
   339 	
       
   340 	eap_variable_data_c * m_wpa_psk_password_override;
       
   341 
       
   342 	bool m_wpa_override_enabled;
       
   343 
       
   344 	bool m_wpa_psk_mode_allowed;
       
   345 
       
   346 	bool m_wpa_psk_mode_active;	
       
   347 
       
   348 	bool m_stack_marked_to_be_deleted;
       
   349 
       
   350 	TMacAddress m_local_address;
       
   351 
       
   352 	TMacAddress m_remote_address;
       
   353 
       
   354 	const TUint8* m_received_wpa_ie;
       
   355 
       
   356 	TUint m_received_wpa_ie_length;
       
   357 
       
   358 	const TUint8* m_sent_wpa_ie;
       
   359 
       
   360 	TUint m_sent_wpa_ie_length;
       
   361 
       
   362 	TWPACipherSuite m_group_key_cipher_suite;
       
   363 
       
   364 	TWPACipherSuite m_pairwise_key_cipher_suite;
       
   365 
       
   366 	bool m_active_type_is_leap;
       
   367 
       
   368 	eap_file_config_c* m_fileconfig;
       
   369 
       
   370 	//--------------------------------------------------
       
   371 }; // class eapol_am_core_symbian_c
       
   372 
       
   373 #endif //#if !defined(_EAPOL_AM_CORE_SYMBIAN_H_)
       
   374 
       
   375 //--------------------------------------------------
       
   376 
       
   377 
       
   378 
       
   379 // End of file