Make enums scoped

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
2020-01-04 12:17:16 +01:00
parent 6db816cd60
commit 5a7827e85e
35 changed files with 254 additions and 254 deletions

View File

@@ -48,9 +48,9 @@ namespace eap
///
/// Authentication mode
///
enum auth_mode_t {
auth_mode_response = 0, ///< Challenge/Response
auth_mode_password, ///< Password
enum class auth_mode_t {
response = 0, ///< Challenge/Response
password, ///< Password
};
public:
@@ -111,7 +111,7 @@ namespace eap
///
/// @copydoc eap::config_method::get_method_id()
/// \returns This implementation always returns `winstd::eap_type_gtc`
/// \returns This implementation always returns `winstd::eap_type_t::gtc`
///
virtual winstd::eap_type_t get_method_id() const;

View File

@@ -119,9 +119,9 @@ void eap::config_method_eapgtc::operator<<(_Inout_ cursor_out &cursor) const
{
// Save authentication mode first, as credential loading will require this information.
if (dynamic_cast<credentials_identity*>(m_cred.get()))
cursor << auth_mode_response;
cursor << auth_mode_t::response;
else if (dynamic_cast<credentials_pass*>(m_cred.get()))
cursor << auth_mode_password;
cursor << auth_mode_t::password;
else
throw invalid_argument(__FUNCTION__ " Unsupported authentication mode.");
@@ -133,9 +133,9 @@ size_t eap::config_method_eapgtc::get_pk_size() const
{
auth_mode_t auth_mode;
if (dynamic_cast<credentials_identity*>(m_cred.get()))
auth_mode = auth_mode_response;
auth_mode = auth_mode_t::response;
else if (dynamic_cast<credentials_pass*>(m_cred.get()))
auth_mode = auth_mode_password;
auth_mode = auth_mode_t::password;
else
throw invalid_argument(__FUNCTION__ " Unsupported authentication mode.");
@@ -151,9 +151,9 @@ void eap::config_method_eapgtc::operator>>(_Inout_ cursor_in &cursor)
auth_mode_t auth_mode;
cursor >> auth_mode;
switch (auth_mode) {
case auth_mode_response: m_cred.reset(new eap::credentials_identity(m_module)); break;
case auth_mode_password: m_cred.reset(new eap::credentials_pass (m_module)); break;
default : throw invalid_argument(string_printf(__FUNCTION__ " Unsupported authentication mode (%u).", auth_mode));
case auth_mode_t::response: m_cred.reset(new eap::credentials_identity(m_module)); break;
case auth_mode_t::password: m_cred.reset(new eap::credentials_pass (m_module)); break;
default : throw invalid_argument(string_printf(__FUNCTION__ " Unsupported authentication mode (%u).", auth_mode));
}
config_method_with_cred::operator>>(cursor);
@@ -162,7 +162,7 @@ void eap::config_method_eapgtc::operator>>(_Inout_ cursor_in &cursor)
eap_type_t eap::config_method_eapgtc::get_method_id() const
{
return eap_type_gtc;
return eap_type_t::gtc;
}

View File

@@ -70,7 +70,7 @@ void eap::method_gtc::begin_session(
// Presume authentication will fail with generic protocol failure. (Pesimist!!!)
// We will reset once we get get_result(Success) call.
m_cfg.m_last_status = config_method::status_auth_failed;
m_cfg.m_last_status = config_method::status_t::auth_failed;
m_cfg.m_last_msg.clear();
}
@@ -81,14 +81,14 @@ EapPeerMethodResponseAction eap::method_gtc::process_request_packet(
{
assert(pReceivedPacket || dwReceivedPacketSize == 0);
m_module.log_event(&EAPMETHOD_METHOD_HANDSHAKE_START2, event_data((unsigned int)eap_type_gtc), event_data::blank);
m_module.log_event(&EAPMETHOD_METHOD_HANDSHAKE_START2, event_data((unsigned int)eap_type_t::gtc), event_data::blank);
credentials_pass *cred_pass;
if (dynamic_cast<credentials_identity*>(&m_cred)) {
// Read authenticator challenge as UTF-8 encoded string.
MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)pReceivedPacket, dwReceivedPacketSize, m_challenge);
m_module.log_event(&EAPMETHOD_GTC_RESPONSE_REQ, event_data((unsigned int)eap_type_gtc), event_data::blank);
m_module.log_event(&EAPMETHOD_GTC_RESPONSE_REQ, event_data((unsigned int)eap_type_t::gtc), event_data::blank);
// User must respond to the challenge.
return EapPeerMethodResponseActionInvokeUI;
@@ -97,7 +97,7 @@ EapPeerMethodResponseAction eap::method_gtc::process_request_packet(
m_response = cred_pass->m_password;
// Send the response.
m_cfg.m_last_status = config_method::status_cred_invalid; // Blame "credentials" if we fail beyond this point.
m_cfg.m_last_status = config_method::status_t::cred_invalid; // Blame "credentials" if we fail beyond this point.
return EapPeerMethodResponseActionSend;
} else
throw invalid_argument(__FUNCTION__ " Unsupported authentication mode.");
@@ -128,7 +128,7 @@ void eap::method_gtc::get_result(
method::get_result(reason, pResult);
if (reason == EapPeerMethodResultSuccess)
m_cfg.m_last_status = config_method::status_success;
m_cfg.m_last_status = config_method::status_t::success;
// Always ask EAP host to save the connection data. And it will save it *only* when we report "success".
// Don't worry. EapHost is well aware of failed authentication condition.
@@ -150,7 +150,7 @@ EapPeerMethodResponseAction eap::method_gtc::set_ui_context(
_In_count_(dwUIContextDataSize) const BYTE *pUIContextData,
_In_ DWORD dwUIContextDataSize)
{
m_module.log_event(&EAPMETHOD_GTC_RESPONSE, event_data((unsigned int)eap_type_gtc), event_data::blank);
m_module.log_event(&EAPMETHOD_GTC_RESPONSE, event_data((unsigned int)eap_type_t::gtc), event_data::blank);
// Save GTC response.
m_response.assign(
@@ -158,6 +158,6 @@ EapPeerMethodResponseAction eap::method_gtc::set_ui_context(
reinterpret_cast<sanitizing_wstring::const_pointer>(pUIContextData + dwUIContextDataSize));
// Send the response.
m_cfg.m_last_status = config_method::status_cred_invalid; // Blame "credentials" if we fail beyond this point.
m_cfg.m_last_status = config_method::status_t::cred_invalid; // Blame "credentials" if we fail beyond this point.
return EapPeerMethodResponseActionSend;
}