eapol/eapol_framework/eapol_common/type/tls_peap/eap/src/eap_type_tls_peap.cpp
branchRCL_3
changeset 18 bad0cc58d154
parent 2 1c7bc153c08e
child 19 c74b3d9f6b9e
--- a/eapol/eapol_framework/eapol_common/type/tls_peap/eap/src/eap_type_tls_peap.cpp	Thu Aug 19 09:58:27 2010 +0300
+++ b/eapol/eapol_framework/eapol_common/type/tls_peap/eap/src/eap_type_tls_peap.cpp	Tue Aug 31 15:16:37 2010 +0300
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 82.1.3 %
+* %version: %
 */
 
 // This is enumeration of EAPOL source code.
@@ -1629,7 +1629,7 @@
 		}
 
 		if (user_certificate_identity != 0
-			&& user_certificate_identity->get_is_valid() == true)
+			&& user_certificate_identity->get_is_valid_data() == true)
 		{
 			eap_variable_data_c username(m_am_tools);
 			eap_variable_data_c realm(m_am_tools);
@@ -1710,7 +1710,7 @@
 		else
 #endif //#if defined(USE_EAP_TLS_IDENTITY_PRIVACY)
 		if (user_certificate_identity != 0
-			&& user_certificate_identity->get_is_valid() == true)
+			&& user_certificate_identity->get_is_valid_data() == true)
 		{
 			EAP_TRACE_DEBUG(
 				m_am_tools,
@@ -1795,7 +1795,7 @@
 		}
 	}
 	else if (user_certificate_identity != 0
-		&& user_certificate_identity->get_is_valid() == true)
+		&& user_certificate_identity->get_is_valid_data() == true)
 	{
 		EAP_TRACE_DEBUG(
 			m_am_tools,
@@ -1813,14 +1813,19 @@
 	}
 	else
 	{
-		EAP_TRACE_ERROR(
+		EAP_TRACE_DEBUG(
 			m_am_tools,
 			TRACE_FLAGS_DEFAULT,
-			(EAPL("EAP_type_TLS_PEAP: %s: eap_type_tls_peap_c::handle_eap_identity_query(): no identity.\n"),
+			(EAPL("WARNING: EAP_type_TLS_PEAP: %s: eap_type_tls_peap_c::handle_eap_identity_query(): no identity configured, creates random identity.\n"),
 			(m_is_client == true ? "client": "server")));
 
-		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
-		return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_eap_identity);
+		// Last possibility is random username.
+		status = create_random_eap_identity(&local_identity);
+		if (status != eap_status_ok)
+		{
+			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
+			return EAP_STATUS_RETURN(m_am_tools, status);
+		}
 	}
 
 	status = m_current_identity.set_copy_of_buffer(&local_identity);
@@ -1942,11 +1947,13 @@
 				m_am_tools,
 				TRACE_FLAGS_TLS_PEAP_ERROR,
 				(EAPL("ERROR: eap_type_tls_peap_c::check_received_eap_identifier() failed,")
-				 EAPL("status %d=%s, received EAP-type 0x%08x, received EAP-code %d, ")
+				 EAPL("status %d=%s, received EAP-type 0xfe%06x%08x=%s, received EAP-code %d, ")
 				 EAPL("received EAP-identifier %d, current EAP-identifier %d, state %s\n"),
 				 status,
 				 status_string.get_status_string(status),
-				 convert_eap_type_to_u32_t(eap_header->get_type()),
+				 eap_header->get_type().get_vendor_id(),
+				 eap_header->get_type().get_vendor_type(),
+				 eap_header_string_c::get_eap_type_string(eap_header->get_type()),
 				 eap_header->get_code(),
 				 eap_header->get_identifier(),
 				 get_last_eap_identifier(),
@@ -1970,11 +1977,13 @@
 				m_am_tools,
 				TRACE_FLAGS_TLS_PEAP_ERROR,
 				(EAPL("ERROR: eap_type_tls_peap_c::check_received_eap_identifier() failed,")
-				 EAPL("status %d=%s, received EAP-type 0x%08x, received EAP-code %d, ")
+				 EAPL("status %d=%s, received EAP-type 0xfe%06x%08x=%s, received EAP-code %d, ")
 				 EAPL("received EAP-identifier %d, current EAP-identifier %d, state %s\n"),
 				 status,
 				 status_string.get_status_string(status),
-				 convert_eap_type_to_u32_t(eap_header->get_type()),
+				 eap_header->get_type().get_vendor_id(),
+				 eap_header->get_type().get_vendor_type(),
+				 eap_header_string_c::get_eap_type_string(eap_header->get_type()),
 				 eap_header->get_code(),
 				 eap_header->get_identifier(),
 				 get_last_eap_identifier(),
@@ -2133,11 +2142,13 @@
 					m_am_tools,
 					TRACE_FLAGS_TLS_PEAP_ERROR,
 					(EAPL("ERROR: eap_type_tls_peap_c::packet_process() failed,")
-					 EAPL("status %d=%s, received EAP-type 0x%08x, received EAP-code %d, ")
+					 EAPL("status %d=%s, received EAP-type 0xfe%06x%08x=%s, received EAP-code %d, ")
 					 EAPL("received EAP-identifier %d, current EAP-identifier %d, state %s\n"),
 					 status,
 					 status_string.get_status_string(status),
-					 convert_eap_type_to_u32_t(eap_header->get_type()),
+					 eap_header->get_type().get_vendor_id(),
+					 eap_header->get_type().get_vendor_type(),
+					 eap_header_string_c::get_eap_type_string(eap_header->get_type()),
 					 eap_header->get_code(),
 					 eap_header->get_identifier(),
 					 get_last_eap_identifier(),
@@ -3992,9 +4003,11 @@
 							EAP_TRACE_ERROR(
 								m_am_tools,
 								TRACE_FLAGS_DEFAULT|TRACE_TEST_VECTORS,
-								(EAPL("ERROR: EAP_type_TLS_PEAP: %s, unknown EAP-type 0x%08x\n"),
+								(EAPL("ERROR: EAP_type_TLS_PEAP: %s, unknown EAP-type 0xfe%06x%08x=%s\n"),
 								 (m_is_client == true) ? "client": "server",
-								 convert_eap_type_to_u32_t(m_current_eap_type)));
+								 m_current_eap_type.get_vendor_id(),
+								 m_current_eap_type.get_vendor_type(),
+								 eap_header_string_c::get_eap_type_string(m_current_eap_type)));
 
 							restore_saved_reassembly_state();
 							EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
@@ -4832,7 +4845,6 @@
 
 	//----------------------------------------------------------
 
-#if defined(USE_EAP_EXPANDED_TYPES)
 	{
 		eap_variable_data_c use_eap_expanded_type(m_am_tools);
 
@@ -4866,7 +4878,6 @@
 			}
 		}
 	}
-#endif //#if defined(USE_EAP_EXPANDED_TYPES)
 
 	//----------------------------------------------------------
 
@@ -5142,9 +5153,11 @@
 				m_am_tools,
 				TRACE_FLAGS_DEFAULT,
 				(EAPL("ERROR: %s: eap_type_tls_peap_c::state_notification(): ")
-				 EAPL("authentication failed: EAP-type 0x%08x\n"),
+				 EAPL("authentication failed: EAP-type 0xfe%06x%08x=%s\n"),
 				 (m_is_client == true ? "client": "server"),
-				 convert_eap_type_to_u32_t(m_current_eap_type)));
+				 m_current_eap_type.get_vendor_id(),
+				 m_current_eap_type.get_vendor_type(),
+				 eap_header_string_c::get_eap_type_string(m_current_eap_type)));
 
 			m_tunneled_eap_type_authentication_state
 				= eap_state_authentication_terminated_unsuccessfully;
@@ -5185,9 +5198,11 @@
 				m_am_tools,
 				TRACE_FLAGS_DEFAULT,
 				(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
-				 EAPL("PEAPv1 authentication tunneled EAP-SUCCESS: EAP-type 0x%08x\n"),
+				 EAPL("PEAPv1 authentication tunneled EAP-SUCCESS: EAP-type 0xfe%06x%08x=%s\n"),
 				 (m_is_client == true ? "client": "server"),
-				 convert_eap_type_to_u32_t(m_current_eap_type)));
+				 m_current_eap_type.get_vendor_id(),
+				 m_current_eap_type.get_vendor_type(),
+				 eap_header_string_c::get_eap_type_string(m_current_eap_type)));
 
 			m_tunneled_eap_type_authentication_state
 				= static_cast<eap_state_variable_e>(state->get_current_state());
@@ -5205,9 +5220,11 @@
 				m_am_tools,
 				TRACE_FLAGS_DEFAULT,
 				(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
-				 EAPL("authentication EAP-SUCCESS: EAP-type 0x%08x\n"),
+				 EAPL("authentication EAP-SUCCESS: EAP-type 0xfe%06x%08x=%s\n"),
 				 (m_is_client == true ? "client": "server"),
-				 convert_eap_type_to_u32_t(m_current_eap_type)));
+				 m_current_eap_type.get_vendor_id(),
+				 m_current_eap_type.get_vendor_type(),
+				 eap_header_string_c::get_eap_type_string(m_current_eap_type)));
 
 			m_tunneled_eap_type_authentication_state
 				= eap_state_authentication_finished_successfully;
@@ -5389,9 +5406,11 @@
 				m_am_tools,
 				TRACE_FLAGS_DEFAULT,
 				(EAPL("%s: eap_type_tls_peap_c::state_notification(): TLS tunneled ")
-				 EAPL("authentication failed: EAP-type 0x%08x, tunnel type %s\n"),
+				 EAPL("authentication failed: EAP-type 0xfe%06x%08x=%s, tunnel type %s\n"),
 				 (m_is_client == true ? "client": "server"),
-				 convert_eap_type_to_u32_t(m_current_eap_type),
+				 m_current_eap_type.get_vendor_id(),
+				 m_current_eap_type.get_vendor_type(),
+				 eap_header_string_c::get_eap_type_string(m_current_eap_type),
 				 tls_trace.get_peap_version_string(m_current_peap_version)));
 
 			set_state(eap_type_tls_peap_state_failure);
@@ -5411,9 +5430,11 @@
 						TRACE_FLAGS_DEFAULT,
 						(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
 						 EAPL("TLS tunneled authentication ")
-						 EAPL("EAP-SUCCESS: EAP-type 0x%08x, tunnel type %s, style %d\n"),
+						 EAPL("EAP-SUCCESS: EAP-type 0xfe%06x%08x=%s, tunnel type %s, style %d\n"),
 						 (m_is_client == true ? "client": "server"),
-						 convert_eap_type_to_u32_t(m_current_eap_type),
+						 m_current_eap_type.get_vendor_id(),
+						 m_current_eap_type.get_vendor_type(),
+						 eap_header_string_c::get_eap_type_string(m_current_eap_type),
 						 tls_trace.get_peap_version_string(m_current_peap_version),
 						 m_use_tppd_tls_peap));
 					
@@ -5456,9 +5477,11 @@
 						TRACE_FLAGS_DEFAULT,
 						(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
 						 EAPL("TLS resumed session authentication ")
-						 EAPL("EAP-SUCCESS: EAP-type 0x%08x, m_tls_session_type=%d=%s, tunnel type %s\n"),
+						 EAPL("EAP-SUCCESS: EAP-type 0xfe%06x%08x=%s, m_tls_session_type=%d=%s, tunnel type %s\n"),
 						 (m_is_client == true ? "client": "server"),
-						 convert_eap_type_to_u32_t(m_current_eap_type),
+						 m_current_eap_type.get_vendor_id(),
+						 m_current_eap_type.get_vendor_type(),
+						 eap_header_string_c::get_eap_type_string(m_current_eap_type),
 						 get_tls_session_type(),
 						 eap_tls_trace_string_c::get_tls_session_type_string(get_tls_session_type()),
 						 tls_trace.get_peap_version_string(m_current_peap_version)));
@@ -5490,9 +5513,11 @@
 						m_am_tools,
 						TRACE_FLAGS_DEFAULT,
 						(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
-						 EAPL("plain TLS authentication EAP-SUCCESS: EAP-type 0x%08x, tunnel type %s\n"),
+						 EAPL("plain TLS authentication EAP-SUCCESS: EAP-type 0xfe%06x%08x=%s, tunnel type %s\n"),
 						 (m_is_client == true ? "client": "server"),
-						 convert_eap_type_to_u32_t(m_current_eap_type),
+						 m_current_eap_type.get_vendor_id(),
+						 m_current_eap_type.get_vendor_type(),
+						 eap_header_string_c::get_eap_type_string(m_current_eap_type),
 						 tls_trace.get_peap_version_string(m_current_peap_version)));
 
 					// Plain TLS.
@@ -5535,9 +5560,11 @@
 							EAP_TRACE_ERROR(
 								m_am_tools,
 								TRACE_FLAGS_DEFAULT|TRACE_TEST_VECTORS,
-								(EAPL("ERROR: EAP_type_TLS_PEAP: %s, unknown EAP-type 0x%08x\n"),
+								(EAPL("ERROR: EAP_type_TLS_PEAP: %s, unknown EAP-type 0xfe%06x%08x=%s\n"),
 								 (m_is_client == true) ? "client": "server",
-								 convert_eap_type_to_u32_t(m_current_eap_type)));
+								 m_current_eap_type.get_vendor_id(),
+								 m_current_eap_type.get_vendor_type(),
+								 eap_header_string_c::get_eap_type_string(m_current_eap_type)));
 							
 							EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
 							set_state(eap_type_tls_peap_state_failure);
@@ -5572,9 +5599,11 @@
 				m_am_tools,
 				TRACE_FLAGS_DEFAULT,
 				(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
-				 EAPL("full TLS authentication: EAP-type 0x%08x\n"),
+				 EAPL("full TLS authentication: EAP-type 0xfe%06x%08x=%s\n"),
 				 (m_is_client == true ? "client": "server"),
-				 convert_eap_type_to_u32_t(m_current_eap_type)));
+				 m_current_eap_type.get_vendor_id(),
+				 m_current_eap_type.get_vendor_type(),
+				 eap_header_string_c::get_eap_type_string(m_current_eap_type)));
 		}
 		else if (state->get_current_state() == tls_peap_state_original_session_resumption)
 		{
@@ -5582,9 +5611,11 @@
 				m_am_tools,
 				TRACE_FLAGS_DEFAULT,
 				(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
-				 EAPL("TLS session resumption: EAP-type 0x%08x\n"),
+				 EAPL("TLS session resumption: EAP-type 0xfe%06x%08x=%s\n"),
 				 (m_is_client == true ? "client": "server"),
-				 convert_eap_type_to_u32_t(m_current_eap_type)));
+				 m_current_eap_type.get_vendor_id(),
+				 m_current_eap_type.get_vendor_type(),
+				 eap_header_string_c::get_eap_type_string(m_current_eap_type)));
 		}
 #if defined(USE_EAP_TLS_SESSION_TICKET)
 		else if (state->get_current_state() == tls_peap_state_stateless_session_resumption)
@@ -5593,9 +5624,11 @@
 				m_am_tools,
 				TRACE_FLAGS_DEFAULT,
 				(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
-				 EAPL("TLS stateless session resumption: EAP-type 0x%08x\n"),
+				 EAPL("TLS stateless session resumption: EAP-type 0xfe%06x%08x=%s\n"),
 				 (m_is_client == true ? "client": "server"),
-				 convert_eap_type_to_u32_t(m_current_eap_type)));
+				 m_current_eap_type.get_vendor_id(),
+				 m_current_eap_type.get_vendor_type(),
+				 eap_header_string_c::get_eap_type_string(m_current_eap_type)));
 		}
 #endif // #if defined(USE_EAP_TLS_SESSION_TICKET)
 #if defined(USE_EAP_TLS_PEAP_TPPD_PEAP_V1_NEW_FIXES)
@@ -5606,9 +5639,11 @@
 				m_am_tools,
 				TRACE_FLAGS_DEFAULT,
 				(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
-				 EAPL("PEAPv1 waits EAP-Success or tunneled packet: EAP-type 0x%08x\n"),
+				 EAPL("PEAPv1 waits EAP-Success or tunneled packet: EAP-type 0xfe%06x%08x=%s\n"),
 				 (m_is_client == true ? "client": "server"),
-				 convert_eap_type_to_u32_t(m_current_eap_type)));
+				 m_current_eap_type.get_vendor_id(),
+				 m_current_eap_type.get_vendor_type(),
+				 eap_header_string_c::get_eap_type_string(m_current_eap_type)));
 
 			set_state(eap_type_tls_peap_state_tppd_peapv1_waits_eap_success_or_tunneled_packet);
 		}
@@ -5620,9 +5655,11 @@
 				m_am_tools,
 				TRACE_FLAGS_DEFAULT,
 				(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
-				 EAPL("sends TTLS/plain MsChapv2 empty Ack: EAP-type 0x%08x\n"),
+				 EAPL("sends TTLS/plain MsChapv2 empty Ack: EAP-type 0xfe%06x%08x=%s\n"),
 				 (m_is_client == true ? "client": "server"),
-				 convert_eap_type_to_u32_t(m_current_eap_type)));
+				 m_current_eap_type.get_vendor_id(),
+				 m_current_eap_type.get_vendor_type(),
+				 eap_header_string_c::get_eap_type_string(m_current_eap_type)));
 
 			// Send empty acknowledge message.
 			eap_status_e status = send_empty_eap_ack();
@@ -5642,9 +5679,11 @@
 				m_am_tools,
 				TRACE_FLAGS_DEFAULT,
 				(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
-				 EAPL("waits TTLS/plain MsChapv2 empty Ack: EAP-type 0x%08x\n"),
+				 EAPL("waits TTLS/plain MsChapv2 empty Ack: EAP-type 0xfe%06x%08x=%s\n"),
 				 (m_is_client == true ? "client": "server"),
-				 convert_eap_type_to_u32_t(m_current_eap_type)));
+				 m_current_eap_type.get_vendor_id(),
+				 m_current_eap_type.get_vendor_type(),
+				 eap_header_string_c::get_eap_type_string(m_current_eap_type)));
 
 			set_state(eap_type_tls_peap_state_server_waits_ttls_plain_ms_chap_v2_empty_ack);
 		}
@@ -5655,9 +5694,11 @@
 				m_am_tools,
 				TRACE_FLAGS_DEFAULT,
 				(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
-				 EAPL("TLS tunnel ready: EAP-type 0x%08x\n"),
+				 EAPL("TLS tunnel ready: EAP-type 0xfe%06x%08x=%s\n"),
 				 (m_is_client == true ? "client": "server"),
-				 convert_eap_type_to_u32_t(m_current_eap_type)));
+				 m_current_eap_type.get_vendor_id(),
+				 m_current_eap_type.get_vendor_type(),
+				 eap_header_string_c::get_eap_type_string(m_current_eap_type)));
 
 			if (m_is_client == true)
 			{
@@ -5769,9 +5810,11 @@
 					EAP_TRACE_ERROR(
 						m_am_tools,
 						TRACE_FLAGS_DEFAULT|TRACE_TEST_VECTORS,
-						(EAPL("ERROR: EAP_type_TLS_PEAP: %s, unknown EAP-type 0x%08x\n"),
+						(EAPL("ERROR: EAP_type_TLS_PEAP: %s, unknown EAP-type 0xfe%06x%08x=%s\n"),
 						 (m_is_client == true) ? "client": "server",
-						 convert_eap_type_to_u32_t(m_current_eap_type)));
+						 m_current_eap_type.get_vendor_id(),
+						 m_current_eap_type.get_vendor_type(),
+						 eap_header_string_c::get_eap_type_string(m_current_eap_type)));
 					
 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
 					set_state(eap_type_tls_peap_state_failure);
@@ -5808,9 +5851,11 @@
 				m_am_tools,
 				TRACE_FLAGS_DEFAULT,
 				(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
-				 EAPL("TLS tunnel ready: EAP-type 0x%08x\n"),
+				 EAPL("TLS tunnel ready: EAP-type 0xfe%06x%08x=%s\n"),
 				 (m_is_client == true ? "client": "server"),
-				 convert_eap_type_to_u32_t(m_current_eap_type)));
+				 m_current_eap_type.get_vendor_id(),
+				 m_current_eap_type.get_vendor_type(),
+				 eap_header_string_c::get_eap_type_string(m_current_eap_type)));
 
 			if (m_is_client == true)
 			{
@@ -6201,19 +6246,6 @@
 
 //--------------------------------------------------
 
-//
-EAP_FUNC_EXPORT eap_status_e eap_type_tls_peap_c::cancel_all_timers()
-{
-	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
-
-	eap_status_e status = get_type_partner()->cancel_all_timers();
-
-	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
-	return EAP_STATUS_RETURN(m_am_tools, status);
-}
-
-//--------------------------------------------------
-
 // This is commented in abs_tls_base_application_c.
 EAP_FUNC_EXPORT eap_status_e eap_type_tls_peap_c::load_module(
 	const eap_type_value_e type,