Command Table Entry for IPMI Provider Commands

This patch defines an entry for hooking IPMI provider commands in
the command table and to execute the commands.

Change-Id: I8a8fb7c06ccc1a3c4397540419b983556b9da6c3
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
diff --git a/command_table.cpp b/command_table.cpp
index 6550160..a49f92c 100644
--- a/command_table.cpp
+++ b/command_table.cpp
@@ -77,4 +77,29 @@
     return functor(commandData, handler);
 }
 
+std::vector<uint8_t> ProviderIpmidEntry::executeCommand(
+        std::vector<uint8_t>& commandData,
+        const message::Handler& handler)
+{
+
+    std::vector<uint8_t> response(MAX_IPMI_BUFFER);
+    size_t respSize {};
+
+    ipmi_ret_t ipmiRC = functor(0, 0,
+                                reinterpret_cast<void*>(commandData.data()),
+                                reinterpret_cast<void*>(response.data() + 1),
+                                &respSize, NULL);
+
+    /*
+     * respSize gets you the size of the response data for the IPMI command. The
+     * first byte in a response to the IPMI command is the Completion Code.
+     * So we are inserting completion code as the first byte and incrementing
+     * the response payload size by the size of the completion code.
+     */
+    response[0] = ipmiRC;
+    response.resize(respSize + sizeof(ipmi_ret_t));
+
+    return response;
+}
+
 } // namespace command