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 ++++++++++++++++++++++++++++++++++++++++++++++++++++ command/sol_cmds.hpp | 27 +++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 command/sol_cmds.cpp create mode 100644 command/sol_cmds.hpp (limited to 'command') 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 diff --git a/command/sol_cmds.hpp b/command/sol_cmds.hpp new file mode 100644 index 0000000..3c3e23d --- /dev/null +++ b/command/sol_cmds.hpp @@ -0,0 +1,27 @@ +#pragma once + +#include +#include "message_handler.hpp" + +namespace sol +{ + +namespace command +{ + +/** @brief SOL Payload Handler + * + * This command is used for activating and deactivating a payload type under a + * given IPMI session. The UDP Port number for SOL is the same as the port that + * was used to establish the IPMI session. + * + * @param[in] inPayload - Request data for the command. + * @param[in] handler - Reference to the message handler. + * + * @return Response data for the command. + */ +std::vector payloadHandler(std::vector& inPayload, + const message::Handler& handler); +} // namespace command + +} // namespace sol -- cgit v1.2.3