Add handler function for incoming SOL payload.

Change-Id: I1bdff462ef43281332c6b8c2d61028bc0d9f87b0
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
diff --git a/Makefile.am b/Makefile.am
index 35e5353..ad42d8d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -46,7 +46,9 @@
 	sol/sol_manager.hpp \
 	sd_event_loop.cpp \
 	sol/sol_manager.cpp \
-	sol/sol_context.cpp
+	sol/sol_context.cpp \
+	command/sol_cmds.hpp \
+	command/sol_cmds.cpp
 
 netipmid_CPPFLAGS = -DNET_IPMID_LIB_PATH=\"/usr/lib/net-ipmid/\"
 netipmid_LDFLAGS = $(SYSTEMD_LIBS) $(CRYPTO_LIBS) $(libmapper_LIBS) $(PHOSPHOR_LOGGING_LIBS) $(LIBADD_DLOPEN) -export-dynamic
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 <phosphor-logging/log.hpp>
+#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<uint8_t> payloadHandler(std::vector<uint8_t>& inPayload,
+                                    const message::Handler& handler)
+{
+    auto request = reinterpret_cast<Payload*>(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<sol::Manager&>(singletonPool).
+                getContext(handler.sessionID);
+
+        context.processInboundPayload(request->packetSeqNum,
+                                      request->packetAckSeqNum,
+                                      request->acceptedCharCount,
+                                      request->inOperation.ack,
+                                      charData);
+    }
+    catch (std::exception& e)
+    {
+        log<level::ERR>(e.what());
+        return std::vector<uint8_t>();
+    }
+
+    return std::vector<uint8_t>();
+}
+
+} // 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 <vector>
+#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<uint8_t> payloadHandler(std::vector<uint8_t>& inPayload,
+                                    const message::Handler& handler);
+} // namespace command
+
+} // namespace sol