Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GEODE-10096: Replaced macro definitions with enumerations. #938

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 22 additions & 16 deletions cppcache/src/TcrConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,20 @@ bool TcrConnection::initTcrConnection(
if (isClientNotification) {
isNotificationChannel = true;
if (isSecondary) {
handShakeMsg.write(static_cast<int8_t>(SECONDARY_SERVER_TO_CLIENT));
handShakeMsg.write(
static_cast<int8_t>(acceptor::SECONDARY_SERVER_TO_CLIENT));
} else {
handShakeMsg.write(static_cast<int8_t>(PRIMARY_SERVER_TO_CLIENT));
handShakeMsg.write(
static_cast<int8_t>(acceptor::PRIMARY_SERVER_TO_CLIENT));
}
} else {
handShakeMsg.write(static_cast<int8_t>(CLIENT_TO_SERVER));
handShakeMsg.write(static_cast<int8_t>(acceptor::CLIENT_TO_SERVER));
}

Version::write(handShakeMsg, Version::current());
LOGFINE("Client version ordinal is %d", Version::current().getOrdinal());

handShakeMsg.write(static_cast<int8_t>(REPLY_OK));
handShakeMsg.write(static_cast<int8_t>(acceptance_codes::REPLY_OK));

// Send byte REPLY_OK = (byte)58;
if (!isClientNotification) {
Expand Down Expand Up @@ -241,11 +243,13 @@ bool TcrConnection::initTcrConnection(

if (isNotificationChannel && !doIneedToSendCreds) {
handShakeMsg.write(
static_cast<uint8_t>(SECURITY_MULTIUSER_NOTIFICATIONCHANNEL));
static_cast<uint8_t>(security::SECURITY_MULTIUSER_NOTIFICATIONCHANNEL));
} else if (tmpIsSecurityOn) {
handShakeMsg.write(static_cast<uint8_t>(SECURITY_CREDENTIALS_NORMAL));
handShakeMsg.write(
static_cast<uint8_t>(security::SECURITY_CREDENTIALS_NORMAL));
} else {
handShakeMsg.write(static_cast<uint8_t>(SECURITY_CREDENTIALS_NONE));
handShakeMsg.write(
static_cast<uint8_t>(security::SECURITY_CREDENTIALS_NONE));
}

if (tmpIsSecurityOn) {
Expand Down Expand Up @@ -304,7 +308,9 @@ bool TcrConnection::initTcrConnection(

LOGDEBUG(" Handshake: Got Accept Code %d", acceptanceCode[0]);
/* adongre */
if (acceptanceCode[0] == REPLY_SSL_ENABLED && !sysProp.sslEnabled()) {
if (acceptanceCode[0] ==
static_cast<int8_t>(acceptance_codes::REPLY_SSL_ENABLED) &&
!sysProp.sslEnabled()) {
LOGERROR("SSL is enabled on server, enable SSL in client as well");
AuthenticationRequiredException ex(
"SSL is enabled on server, enable SSL in client as well");
Expand Down Expand Up @@ -380,33 +386,33 @@ bool TcrConnection::initTcrConnection(
}

switch (acceptanceCode[0]) {
case REPLY_OK:
case SUCCESSFUL_SERVER_TO_CLIENT:
case static_cast<int>(acceptance_codes::REPLY_OK):
mreddington marked this conversation as resolved.
Show resolved Hide resolved
case static_cast<int>(acceptance_codes::SUCCESSFUL_SERVER_TO_CLIENT):
LOGFINER("Handshake reply: %u,%u,%u", acceptanceCode[0],
serverQueueStatus[0], recvMsgLen2);
if (isClientNotification) readHandshakeInstantiatorMsg(connectTimeout);
break;
case REPLY_AUTHENTICATION_FAILED: {
case static_cast<int>(acceptance_codes::REPLY_AUTHENTICATION_FAILED): {
AuthenticationFailedException ex(
reinterpret_cast<char*>(recvMessage.data()));
m_conn.reset();
throwException(ex);
}
case REPLY_AUTHENTICATION_REQUIRED: {
case static_cast<int>(acceptance_codes::REPLY_AUTHENTICATION_REQUIRED): {
AuthenticationRequiredException ex(
reinterpret_cast<char*>(recvMessage.data()));
m_conn.reset();
throwException(ex);
}
case REPLY_DUPLICATE_DURABLE_CLIENT: {
case static_cast<int>(acceptance_codes::REPLY_DUPLICATE_DURABLE_CLIENT): {
DuplicateDurableClientException ex(
reinterpret_cast<char*>(recvMessage.data()));
m_conn.reset();
throwException(ex);
}
case REPLY_REFUSED:
case REPLY_INVALID:
case UNSUCCESSFUL_SERVER_TO_CLIENT: {
case static_cast<int>(acceptance_codes::REPLY_REFUSED):
case static_cast<int>(acceptance_codes::REPLY_INVALID):
case static_cast<int>(acceptance_codes::UNSUCCESSFUL_SERVER_TO_CLIENT): {
LOGERROR("Handshake rejected by server[%s]: %s",
m_endpointObj->name().c_str(),
reinterpret_cast<char*>(recvMessage.data()));
Expand Down
38 changes: 22 additions & 16 deletions cppcache/src/TcrConnection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,28 @@
#include "util/synchronized_set.hpp"

#define DEFAULT_TIMEOUT_RETRIES 12
#define PRIMARY_SERVER_TO_CLIENT 101
#define SECONDARY_SERVER_TO_CLIENT 102
#define SUCCESSFUL_SERVER_TO_CLIENT 105
#define UNSUCCESSFUL_SERVER_TO_CLIENT 106
#define CLIENT_TO_SERVER 100
#define REPLY_OK 59
#define REPLY_REFUSED 60
#define REPLY_INVALID 61
#define REPLY_SSL_ENABLED 21
#define REPLY_AUTHENTICATION_REQUIRED 62
#define REPLY_AUTHENTICATION_FAILED 63
#define REPLY_DUPLICATE_DURABLE_CLIENT 64

#define SECURITY_CREDENTIALS_NONE 0
#define SECURITY_CREDENTIALS_NORMAL 1
#define SECURITY_MULTIUSER_NOTIFICATIONCHANNEL 3

enum class acceptor : ::std::int8_t {
mreddington marked this conversation as resolved.
Show resolved Hide resolved
CLIENT_TO_SERVER = 100,
PRIMARY_SERVER_TO_CLIENT = 101,
SECONDARY_SERVER_TO_CLIENT = 102
};
enum class acceptance_codes : ::std::int8_t {
REPLY_SSL_ENABLED = 21,
REPLY_OK = 59,
REPLY_REFUSED = 60,
REPLY_INVALID = 61,
REPLY_AUTHENTICATION_REQUIRED = 62,
REPLY_AUTHENTICATION_FAILED = 63,
REPLY_DUPLICATE_DURABLE_CLIENT = 64,
SUCCESSFUL_SERVER_TO_CLIENT = 105,
UNSUCCESSFUL_SERVER_TO_CLIENT = 106
};
enum class security : ::std::uint8_t {
SECURITY_CREDENTIALS_NONE = 0,
SECURITY_CREDENTIALS_NORMAL = 1,
SECURITY_MULTIUSER_NOTIFICATIONCHANNEL = 3
};
mreddington marked this conversation as resolved.
Show resolved Hide resolved

namespace apache {
namespace geode {
Expand Down