From 64b3dec812821351dbf75bf8c73c5d7f0cb0fe98 Mon Sep 17 00:00:00 2001 From: Tom Joseph Date: Mon, 3 Apr 2017 01:53:44 +0530 Subject: Add handler function for incoming SOL payload. Change-Id: I1bdff462ef43281332c6b8c2d61028bc0d9f87b0 Signed-off-by: Tom Joseph --- command/sol_cmds.cpp | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 command/sol_cmds.cpp (limited to 'command/sol_cmds.cpp') diff --git a/command/sol_cmds.cpp b/command/sol_cmds.cpp new file mode 100644 index 0000000..8f5b0c6 --- /dev/null +++ b/command/sol_cmds.cpp @@ -0,0 +1,52 @@ +#include +#include "main.hpp" +#include "sol/sol_context.hpp" +#include "sol/sol_manager.hpp" +#include "sol_cmds.hpp" + +namespace sol +{ + +namespace command +{ + +using namespace phosphor::logging; + +std::vector payloadHandler(std::vector& inPayload, + const message::Handler& handler) +{ + auto request = reinterpret_cast(inPayload.data()); + + auto solDataSize = inPayload.size() - sizeof(Payload); + + Buffer charData(solDataSize); + if( solDataSize > 0) + { + std::copy_n(inPayload.data() + sizeof(Payload), + solDataSize, + charData.begin()); + } + + try + { + auto& context = std::get(singletonPool). + getContext(handler.sessionID); + + context.processInboundPayload(request->packetSeqNum, + request->packetAckSeqNum, + request->acceptedCharCount, + request->inOperation.ack, + charData); + } + catch (std::exception& e) + { + log(e.what()); + return std::vector(); + } + + return std::vector(); +} + +} // namespace command + +} // namespace sol -- cgit v1.2.1