Ejemplo n.º 1
0
 void CProfileRepoServerClb::addProfile(const RepoRequest * req, UInt32 payloadSize, UInt8* const pResponseBuffer, UInt32& bufferSize)
 {
    LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__ );
    CError err = mProfileDB.addProfile(bufferToString(req->data));
    UInt32 code = err.getCode();
    memcpy (pResponseBuffer, &code,4);
    bufferSize = 4;
 }
Ejemplo n.º 2
0
 void CProfileRepoServerClb::removeProfileImplementationPl(const RepoRequest * req, UInt32 payloadSize, UInt8* const pResponseBuffer, UInt32& bufferSize)
 {
    LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__ );
    UID uid(bufferToString(req->data));
    int pos = stringInBufSize(uid.value);
    std::string platform = bufferToString(req->data + pos);
    CError err = mProfileDB.removeProfileImplementation(uid,platform);
    UInt32 code = err.getCode();
    memcpy (pResponseBuffer, &code, 4);
    bufferSize = 4;
 }
Ejemplo n.º 3
0
 void CProfileRepoServerClb::addProfileImplementation(const RepoRequest * req, UInt32 payloadSize, UInt8* const pResponseBuffer, UInt32& bufferSize)
 {
    LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__ );
    UID uid(bufferToString(req->data));
    int pos = stringInBufSize(uid.value);
    iviLink::LibDescriptor ld;
    ld.libPath = bufferToString(req->data + pos);
    pos += stringInBufSize(ld.libPath);
    ld.platform = bufferToString(req->data + pos);
    CError err = mProfileDB.addProfileImplementation(uid,ld);
    UInt32 code = err.getCode();
    memcpy (pResponseBuffer, &code, 4);
    bufferSize = 4;
 }
Ejemplo n.º 4
0
void NegotiatorIPCHandler::ProcessIPCClientMessage(std::string message, std::string &response)
{
    LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__);
    ChannelSupervisor::Messages::Message * msg = NULL;
    CError err = CSError(CSError::ERROR_OTHER);

    LOG4CPLUS_TRACE(msLogger,
            "NegotiatorIPCHandler::ProcessIPCClientMessage() message = \n" + message);

    pugi::xml_document* doc = new pugi::xml_document();
    ParseResponse(doc, (Int8*) message.c_str());

    if (Notification::NOTIFICATIONTTYPE_ALLOCATE == Notification::GetNotificationType(doc))
    {
        LOG4CPLUS_INFO(msLogger, "NegotiatorIPCHandler::ProcessIPCClientMessage()==>ALLOCATE=====");
        AllocateChannelRequest * request = new AllocateChannelRequest(doc);
        std::string tag = request->GetTag();
        UInt32 channel = request->GetChannelID();
        delete request;
        err = NegotiateChannel(tag, channel);
        LOG4CPLUS_INFO(msLogger,
                "NegotiatorIPCHandler::ProcessIPCClientMessage()==>IDLE====="
                        + convertIntegerToString(channel));
        msg = new AllocateChannelResponse(tag.c_str(), channel);
        if (!err.isNoError())
        {
            // TODO correctly set other types of errors
            if (err.getCode() == CSError::NEGOTIATION_CHANNEL_TIMEOUT)
            {
                ((AllocateChannelResponse*) msg)->SetError(ERRORCODE_TIMEOUT_OCCURRED, "timeout");
            } else
            {
                ((AllocateChannelResponse*) msg)->SetError(ERRORCODE_OTHER, "other error");
            }
        }
    } else if (Notification::NOTIFICATIONTTYPE_DEALLOCATE == Notification::GetNotificationType(doc))
    {
        LOG4CPLUS_INFO(msLogger,
                "NegotiatorIPCHandler::ProcessIPCClientMessage()==>DEALLOCATE=====");
        DeallocateChannelRequest * request = new DeallocateChannelRequest(doc);
        UInt32 channel = request->GetChannelId();
        delete request;
        err = ChannelDeallocated(channel);
        msg = new DeallocateChannelResponse(channel);
        if (!err.isNoError())
        {
            // TODO correctly set other types of errors
            if (err.getCode() == CSError::DEALLOCATION_CHANNEL_MAP_WRONG_CID)
                ((DeallocateChannelResponse*) msg)->SetError(ERRORCODE_WRONG_CHANNELID,
                        "wrong cid");
            else if (err.getCode() == CSError::DEALLOCATION_CHANNEL_MAP_TIMEOUT)
                ((DeallocateChannelResponse*) msg)->SetError(ERRORCODE_TIMEOUT_OCCURRED, "timeout");
            else
                ((DeallocateChannelResponse*) msg)->SetError(ERRORCODE_OTHER, "other error");
        }
    } else if (Request::REQUESTTYPE_CA_ALLOCATION_DONE == Request::GetRequestType(doc))
    {
        LOG4CPLUS_INFO(msLogger,
                "NegotiatorIPCHandler::ProcessIPCClientMessage()==>CA_ALLOCATION_DONE=====");
        CAAllocateDoneRequest * request = new CAAllocateDoneRequest(doc);
        std::string tag = request->GetTag();
        UInt32 channel = request->GetChannelId();
        delete request;
        err = UpdateMap(tag, channel);
        msg = new CAAllocateDoneResponse(tag.c_str(), channel);
        if (!err.isNoError())
        {
            // TODO correctly set other types of errors
            if (err.getCode() == CSError::UPDATE_MAP_TIMEOUT)
            {
                ((CAAllocateDoneResponse*) msg)->SetError(ERRORCODE_TIMEOUT_OCCURRED, "timeout");
            } else
            {
                ((CAAllocateDoneResponse*) msg)->SetError(ERRORCODE_OTHER, "other error");
            }
        }
    } else //error here
    {
        LOG4CPLUS_ERROR(msLogger,
                "NegotiatorIPCHandler::ProcessIPCClientMessage()==> UNKNOWN REQUEST");
        msg = new CommandRejectResponse("");
    }

    std::stringstream messageToBeSent;

    msg->Write(messageToBeSent);
    response = messageToBeSent.str();

    if (msg)
        delete msg;
    msg = NULL;
}
Ejemplo n.º 5
0
void NegotiatorIPCHandler::ProcessIPCClientMessage(std::string message, std::string &response)
{
    LOG4CPLUS_TRACE_METHOD(msLogger, "NegotiatorIPCHandler::ProcessIPCClientMessage()==>START=====");
    Message * msg = NULL;
    CError err = CSError(CSError::ERROR_OTHER);

    LOG4CPLUS_TRACE(msLogger, "NegotiatorIPCHandler::ProcessIPCClientMessage() message = \n" + message);

    pugi::xml_document* doc = new pugi::xml_document();
    ParseResponse(doc, (Int8*) message.c_str());

    if (m_state == IDLE) //process allocate and deallocate
    {

        LOG4CPLUS_TRACE(msLogger, "NegotiatorIPCHandler::ProcessIPCClientMessage()==>IDLE=====");
        if (Notification::NOTIFICATIONTTYPE_ALLOCATE == Notification::GetNotificationType(doc))
        {
            LOG4CPLUS_TRACE(msLogger, "NegotiatorIPCHandler::ProcessIPCClientMessage()==>ALLOCATE=====");
            AllocateChannelRequest * request = new AllocateChannelRequest(doc);
            std::string tag = request->GetTag();
            UInt32 channel = 0;
            err = NegotiateChannel(tag, channel);
            LOG4CPLUS_TRACE(msLogger, "NegotiatorIPCHandler::ProcessIPCClientMessage()==>IDLE=====" + convertIntegerToString(channel));
            msg = new AllocateChannelResponse(tag.c_str(), channel);

            if (!err.isNoError())
            {
                if (err.getCode() == CSError::UPDATE_MAP_WRONG_CID)
                    ((AllocateChannelResponse*) msg)->SetError(ERRORCODE_WRONG_CHANNELID, "wrong cid");
                else if (err.getCode() == CSError::UPDATE_MAP_TIMEOUT)
                    ((AllocateChannelResponse*) msg)->SetError(ERRORCODE_TIMEOUT_OCCURRED, "timeout");
                else
                    ((AllocateChannelResponse*) msg)->SetError(ERRORCODE_OTHER, "other error");
            }

            if (request)
            {
                delete request;
            }
            request = 0;

            m_state = NEGOTIATED;
        }
        else if (Notification::NOTIFICATIONTTYPE_DEALLOCATE == Notification::GetNotificationType(doc))
        {
            LOG4CPLUS_TRACE(msLogger, "NegotiatorIPCHandler::ProcessIPCClientMessage()==>DEALLOCATE=====");
            DeallocateChannelRequest * request = new DeallocateChannelRequest(doc);
            std::string tag = request->GetTag();
            UInt32 channel = request->GetChannelId();
            err = ChannelDeallocated(tag, channel);
            msg = new DeallocateChannelResponse(tag.c_str(), channel);

            if (!err.isNoError())
            {
                if (err.getCode() == CSError::DEALLOCATION_CHANNEL_MAP_WRONG_CID)
                    ((DeallocateChannelResponse*) msg)->SetError(ERRORCODE_WRONG_CHANNELID, "wrong cid");
                else if (err.getCode() == CSError::DEALLOCATION_CHANNEL_MAP_TIMEOUT)
                    ((DeallocateChannelResponse*) msg)->SetError(ERRORCODE_TIMEOUT_OCCURRED, "timeout");
                else
                    ((DeallocateChannelResponse*) msg)->SetError(ERRORCODE_OTHER, "other error");
            }

            if (request)
                delete request;
            request = 0;

            m_state = IDLE;
        }
        else
        {
            msg = new CommandRejectResponse("");
        }
    }
    else if (m_state == NEGOTIATED) //process update map only
    {
        LOG4CPLUS_TRACE(msLogger, "NegotiatorIPCHandler::ProcessIPCClientMessage()==>CA_ALLOCATION_DONE=====");
        if (Request::REQUESTTYPE_CA_ALLOCATION_DONE == Request::GetRequestType(doc))
        {
            CAAllocateDoneRequest * request = new CAAllocateDoneRequest(doc);
            std::string tag = request->GetTag();
            UInt32 channel  = request->GetChannelId();
            err = UpdateMap(tag, channel);

            msg = new CAAllocateDoneResponse(tag.c_str(), channel);

            if (!err.isNoError())
            {
                if (err.getCode() == CSError::UPDATE_MAP_WRONG_CID)
                    ((CAAllocateDoneResponse*) msg)->SetError(ERRORCODE_WRONG_CHANNELID, "wrong cid");
                else if (err.getCode() == CSError::UPDATE_MAP_TIMEOUT)
                    ((CAAllocateDoneResponse*) msg)->SetError(ERRORCODE_TIMEOUT_OCCURRED, "timeout");
                else
                    ((CAAllocateDoneResponse*) msg)->SetError(ERRORCODE_OTHER, "other error");
            }

            if (request)
            {
                delete request;
            }
            request = 0;

            m_state = IDLE;
        }
        else
        {
            LOG4CPLUS_TRACE(msLogger, "NegotiatorIPCHandler::ProcessIPCClientMessage()==>REJECT=====");
            msg = new CommandRejectResponse("");
        }
    }
    else //error here
    {
        LOG4CPLUS_TRACE(msLogger, "NegotiatorIPCHandler::ProcessIPCClientMessage()==>ERROR===== State = "+  convertIntegerToString((int)m_state));
        msg = new CommandRejectResponse("");
    }

    std::stringstream messageToBeSent;

    msg->Write(messageToBeSent);
    response = messageToBeSent.str();

    if (msg)
        delete msg;
    msg = NULL;
}