Commit 37102bb6 authored by Marco De Marco's avatar Marco De Marco
Browse files

Remote endpoint added to protocol manager

parent 02ec78a7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -170,7 +170,7 @@ protected:
    std::string m_status;

    //Address and port of remote endpoint
    std::string remoteEndpoint;
    std::string m_remoteEndpoint;
};

}   //End of namespace
+6 −6
Original line number Diff line number Diff line
@@ -103,13 +103,13 @@ void PlainClient::handleConnect(const boost::system::error_code& errorCode,

    if(!errorCode)
    {
        remoteEndpoint = boost::lexical_cast<std::string>(
        m_remoteEndpoint = boost::lexical_cast<std::string>(
            m_plainSocket.remote_endpoint());

        std::stringstream infoStream;
        infoStream << "Connected to " << remoteEndpoint;
        infoStream << "Connected to " << m_remoteEndpoint;

        INFO_STREAM << "PlainClient::handleConnect() " << remoteEndpoint << endl;
        INFO_STREAM << "PlainClient::handleConnect() " << m_remoteEndpoint << endl;

        writeStatus(infoStream.str());

@@ -144,7 +144,7 @@ void PlainClient::startWriteRequest()

        #ifdef VERBOSE_DEBUG
            INFO_STREAM << "PlainClient::startRequest() "
                << remoteEndpoint << " <<<< " << bodySize << " byte" << endl;
                << m_remoteEndpoint << " <<<< " << bodySize << " byte" << endl;
        #endif

        std::vector<boost::uint8_t> writeBuff;
@@ -201,7 +201,7 @@ void PlainClient::startReadResponseBody(boost::uint32_t bodySize)

    #ifdef VERBOSE_DEBUG
        INFO_STREAM << "PlainClient::startReadResponseBody() "
            << remoteEndpoint << " >>>> " << bodySize << " byte" << endl;
            << m_remoteEndpoint << " >>>> " << bodySize << " byte" << endl;
    #endif

    m_readBuff.resize(HEADER_SIZE + bodySize);
@@ -222,7 +222,7 @@ void PlainClient::closeConnection()
    DEBUG_STREAM << "PlainClient::closeConnection()" << endl;

    std::stringstream infoStream;
    infoStream << "Disconnected from " << remoteEndpoint;
    infoStream << "Disconnected from " << m_remoteEndpoint;

    INFO_STREAM << "PlainClient::closeConnection() " << infoStream.str() << endl;

+31 −15
Original line number Diff line number Diff line
@@ -37,6 +37,16 @@ ProtocolManager::SP ProtocolManager::create(Tango::DeviceImpl* deviceImpl_p,
    return d_sp;
}

//==============================================================================
//      ProtocolManager::ProtocolManager()
//==============================================================================
void ProtocolManager::setRemoteEndpoint(std::string remoteEndpoint)
{
    DEBUG_STREAM << "ProtocolManager::setRemoteEndpoint()" << endl;

    m_remoteEndpoint = remoteEndpoint;
}

//==============================================================================
//      ProtocolManager::createRequest()
//==============================================================================
@@ -110,7 +120,11 @@ RequestSP ProtocolManager::createAuthroisation() throw(std::runtime_error)
    std::string password = m_configuration_sp->getRemotePassword();

    #ifdef VERBOSE_DEBUG
        INFO_STREAM << "USER " << user << " PASSWORD " << password << endl;
        INFO_STREAM << "ProtocolManager::createAuthroisation() Send username "
            << user << " password " << password << " to " << m_remoteEndpoint << endl;
    #else
        INFO_STREAM << "ProtocolManager::createAuthroisation() Send to "
            << m_remoteEndpoint << endl;
    #endif

    Request::Authorization* authorization = request_sp->mutable_authorization();
@@ -134,7 +148,8 @@ RequestSP ProtocolManager::createValidation() throw(std::runtime_error)
    std::string schema = m_configuration_sp->getDatabaseSchema();
    std::string table = m_configuration_sp->getDatabaseTable();

    INFO_STREAM << "SCHEMA " << schema << " TABLE " << table << endl;
    INFO_STREAM << "ProtocolManager::createValidation() Send schema "
        << schema << " table " << table << " to " << m_remoteEndpoint << endl;

    Request::Validation* validation = request_sp->mutable_validation();
    validation->set_schema(schema);
@@ -192,7 +207,8 @@ RequestSP ProtocolManager::createMetadata() throw(std::runtime_error)

    Request::Metadata* metadata = request_sp->mutable_metadata();

    INFO_STREAM << "SCHEMA " << schema << " TABLE " << table << endl;
    INFO_STREAM << "ProtocolManager::createMetadata() Send schema "
        << schema << " table " << table << " to " << m_remoteEndpoint << endl;

    metadata->set_schema(m_configuration_sp->getDatabaseSchema());
    metadata->set_table(m_configuration_sp->getDatabaseTable());
@@ -213,15 +229,15 @@ void ProtocolManager::processAuthroisation(ResponseSP response_sp)

    if(authorization.state() == Response::Authorization::ACCEPTED)
    {
        INFO_STREAM << "ProtocolManager::processAuthroisation() "
            << "state: ACCEPTED status: " << authorization.status() << endl;
        INFO_STREAM << "ProtocolManager::processAuthroisation() State ACCEPTED "
            << "status " << authorization.status() << " from " << m_remoteEndpoint << endl;

        m_isAuthorised = true;
    }
    else
    {
        ERROR_STREAM << "ProtocolManager::processAuthroisation() "
            << "state: REJECTED status: " << authorization.status() << endl;
        ERROR_STREAM << "ProtocolManager::processAuthroisation() State REJECTED "
            << "status " << authorization.status() << " from " << m_remoteEndpoint << endl;

        throw std::runtime_error(authorization.status());
    }
@@ -239,15 +255,15 @@ void ProtocolManager::processValidation(ResponseSP response_sp)

    if(validation.state() == Response::Validation::ACCEPTED)
    {
        INFO_STREAM << "ProtocolManager::processValidation() "
            << "state: ACCEPTED status: " << validation.status() << endl;
        INFO_STREAM << "ProtocolManager::processValidation() State ACCEPTED "
            << "status " << validation.status() << " from " << m_remoteEndpoint << endl;

        m_isValidated = true;
    }
    else
    {
        ERROR_STREAM << "ProtocolManager::processValidation() "
            << " state: REJECTED status: " << validation.status() << endl;
        ERROR_STREAM << "ProtocolManager::processValidation() State REJECTED "
            << "status " << validation.status() << " from " << m_remoteEndpoint << endl;

        throw std::runtime_error(validation.status());
    }
@@ -265,13 +281,13 @@ void ProtocolManager::processMetadata(ResponseSP response_sp)

    if(metadata.state() == Response::Metadata::ACCEPTED)
    {
        INFO_STREAM << "ProtocolManager::processMetadata() "
            << "state: ACCEPTED status: " << metadata.status() << endl;
        INFO_STREAM << "ProtocolManager::processMetadata() State ACCEPTED "
            << "status " << metadata.status() << " from " << m_remoteEndpoint << endl;
    }
    else
    {
        ERROR_STREAM << "ProtocolManager::processMetadata() "
            << "state: REJECTED status: " << metadata.status() << endl;
        ERROR_STREAM << "ProtocolManager::processMetadata() State REJECTED "
            << "status " << metadata.status() << " from " << m_remoteEndpoint << endl;

        throw std::runtime_error(metadata.status());
    }
+8 −0
Original line number Diff line number Diff line
@@ -48,6 +48,11 @@ public:
    static ProtocolManager::SP create(Tango::DeviceImpl*, Configuration::SP,
        DBManager::SP);

//------------------------------------------------------------------------------
//	[Public] Remote endpoint setter method
//------------------------------------------------------------------------------
    void setRemoteEndpoint(std::string);

//------------------------------------------------------------------------------
//  [Public] Request response management method
//------------------------------------------------------------------------------
@@ -88,6 +93,9 @@ protected:

    //Table structure is validated
    bool m_isValidated;

    //Address and port of remote endpoint
    std::string m_remoteEndpoint;
};

}   //End of namespace
+5 −5
Original line number Diff line number Diff line
@@ -161,11 +161,11 @@ void SSLClient::handleHandShake(const boost::system::error_code& errorCode)

    if(!errorCode)
    {
        remoteEndpoint = boost::lexical_cast<std::string>(
        m_remoteEndpoint = boost::lexical_cast<std::string>(
            m_sSLSocket.lowest_layer().remote_endpoint());

        std::stringstream infoStream;
        infoStream << "Connected to " << remoteEndpoint;
        infoStream << "Connected to " << m_remoteEndpoint;

        INFO_STREAM << "SSLClient::handleHandShake() " << infoStream.str() << endl;

@@ -197,7 +197,7 @@ void SSLClient::startWriteRequest()

        #ifdef VERBOSE_DEBUG
            INFO_STREAM << "SSLClient::startWriteRequest() "
                << remoteEndpoint << " <<<< " << bodySize << " byte" << endl;
                << m_remoteEndpoint << " <<<< " << bodySize << " byte" << endl;
        #endif

        std::vector<boost::uint8_t> writeBuff;
@@ -254,7 +254,7 @@ void SSLClient::startReadResponseBody(boost::uint32_t bodySize)

    #ifdef VERBOSE_DEBUG
        INFO_STREAM << "SSLClient::startReadResponseBody() "
            << remoteEndpoint << " >>>> " << bodySize << " byte" << endl;
            << m_remoteEndpoint << " >>>> " << bodySize << " byte" << endl;
    #endif

    m_readBuff.resize(HEADER_SIZE + bodySize);
@@ -275,7 +275,7 @@ void SSLClient::closeConnection()
    DEBUG_STREAM << "SSLClient::closeConnection()" << endl;

    std::stringstream infoStream;
    infoStream << "Disconnected from " << remoteEndpoint;
    infoStream << "Disconnected from " << m_remoteEndpoint;

    INFO_STREAM << "SSLClient::closeConnection() " << infoStream.str() << endl;