google-ipmi-sys: Refactor to use new version of OEM IPMI Handler

Using the new version of ipmi handler provide a higher level wrapper
over the same functionalities. It helps us parse the input and output to
have more control of the input/output we see.

The input and output will be
`std::uint8_t, std::optional<std::vector<uint8_t>>`.

This represents `subcommand` and any input data.

Changes to note,
- all subcommand in the request/response struct are removed. It will be
  managed by the wrapper directly.
    - Unit tests checking for input with only the subcommand are
      removed.
- Move all reply struct to header files to be accessible in unit test.

Tested:
All IPMI OEM command still works the same as before this change.

Change-Id: I4230ab84a497a867248fe82224e32cc69b314b64
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/ipmi.cpp b/ipmi.cpp
index a271d34..0451c6e 100644
--- a/ipmi.cpp
+++ b/ipmi.cpp
@@ -30,52 +30,46 @@
 
 #include <cstdint>
 #include <cstdio>
+#include <ipmid/api-types.hpp>
+#include <ipmid/message.hpp>
+#include <optional>
+#include <vector>
 
 namespace google
 {
 namespace ipmi
 {
 
-ipmi_ret_t handleSysCommand(HandlerInterface* handler, ipmi_cmd_t,
-                            const uint8_t* reqBuf, uint8_t* replyCmdBuf,
-                            size_t* dataLen)
+Resp handleSysCommand(HandlerInterface* handler, ::ipmi::Context::ptr,
+                      uint8_t cmd, const std::vector<uint8_t>& data)
 {
-    // Verify it's at least as long as it needs to be for a subcommand.
-    if ((*dataLen) < 1)
-    {
-        std::fprintf(stderr, "*dataLen too small: %u\n",
-                     static_cast<uint32_t>(*dataLen));
-        return IPMI_CC_REQ_DATA_LEN_INVALID;
-    }
-
-    switch (reqBuf[0])
+    switch (cmd)
     {
         case SysCableCheck:
-            return cableCheck(reqBuf, replyCmdBuf, dataLen, handler);
+            return cableCheck(data, handler);
         case SysCpldVersion:
-            return cpldVersion(reqBuf, replyCmdBuf, dataLen, handler);
+            return cpldVersion(data, handler);
         case SysGetEthDevice:
-            return getEthDevice(reqBuf, replyCmdBuf, dataLen, handler);
+            return getEthDevice(data, handler);
         case SysPsuHardReset:
-            return psuHardReset(reqBuf, replyCmdBuf, dataLen, handler);
+            return psuHardReset(data, handler);
         case SysPcieSlotCount:
-            return pcieSlotCount(reqBuf, replyCmdBuf, dataLen, handler);
+            return pcieSlotCount(data, handler);
         case SysPcieSlotI2cBusMapping:
-            return pcieSlotI2cBusMapping(reqBuf, replyCmdBuf, dataLen, handler);
+            return pcieSlotI2cBusMapping(data, handler);
         case SysEntityName:
-            return getEntityName(reqBuf, replyCmdBuf, dataLen, handler);
+            return getEntityName(data, handler);
         case SysMachineName:
-            return getMachineName(reqBuf, replyCmdBuf, dataLen, handler);
+            return getMachineName(data, handler);
         case SysPsuHardResetOnShutdown:
-            return psuHardResetOnShutdown(reqBuf, replyCmdBuf, dataLen,
-                                          handler);
+            return psuHardResetOnShutdown(data, handler);
         case SysGetFlashSize:
-            return getFlashSize(reqBuf, replyCmdBuf, dataLen, handler);
+            return getFlashSize(data, handler);
         case SysHostPowerOff:
-            return hostPowerOff(reqBuf, replyCmdBuf, dataLen, handler);
+            return hostPowerOff(data, handler);
         default:
-            std::fprintf(stderr, "Invalid subcommand: 0x%x\n", reqBuf[0]);
-            return IPMI_CC_INVALID;
+            std::fprintf(stderr, "Invalid subcommand: 0x%x\n", cmd);
+            return ::ipmi::responseInvalidCommand();
     }
 }