tools: start implementing ipmi interface

Start implementing ipmi interface to handle sending the actual IPMI
packet contents.

Change-Id: Idf55c1594992d0f188ee6b2940bfe3842509d91d
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 66cfa0e..acc6657 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -11,4 +11,5 @@
 	updater.cpp \
 	bt.cpp \
 	lpc.cpp \
-	blob_handler.cpp
+	blob_handler.cpp \
+	ipmi_handler.cpp
diff --git a/tools/blob_handler.hpp b/tools/blob_handler.hpp
index 042953b..285bbf1 100644
--- a/tools/blob_handler.hpp
+++ b/tools/blob_handler.hpp
@@ -1,11 +1,15 @@
 #pragma once
 
 #include "blob_interface.hpp"
+#include "ipmi_interface.hpp"
 
 class BlobHandler : public BlobInterface
 {
   public:
-    BlobHandler() = default;
+    explicit BlobHandler(IpmiInterface* ipmi) : ipmi(ipmi){};
 
     std::vector<std::string> getBlobList() override;
+
+  private:
+    IpmiInterface* ipmi;
 };
diff --git a/tools/ipmi_handler.cpp b/tools/ipmi_handler.cpp
new file mode 100644
index 0000000..7a6e407
--- /dev/null
+++ b/tools/ipmi_handler.cpp
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2018 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "ipmi_handler.hpp"
+
+int IpmiHandler::sendPacket(const std::vector<std::uint8_t>& data)
+{
+    return 0;
+}
diff --git a/tools/ipmi_handler.hpp b/tools/ipmi_handler.hpp
new file mode 100644
index 0000000..ea42507
--- /dev/null
+++ b/tools/ipmi_handler.hpp
@@ -0,0 +1,11 @@
+#pragma once
+
+#include "ipmi_interface.hpp"
+
+class IpmiHandler : public IpmiInterface
+{
+  public:
+    IpmiHandler() = default;
+
+    int sendPacket(const std::vector<std::uint8_t>& data) override;
+};
diff --git a/tools/ipmi_interface.hpp b/tools/ipmi_interface.hpp
new file mode 100644
index 0000000..932d2e8
--- /dev/null
+++ b/tools/ipmi_interface.hpp
@@ -0,0 +1,18 @@
+#pragma once
+
+#include <cstdint>
+#include <vector>
+
+class IpmiInterface
+{
+  public:
+    virtual ~IpmiInterface() = default;
+
+    /**
+     * Send an IPMI packet to the BMC.
+     *
+     * @param[in] data - a vector of the IPMI packet contents.
+     * @return non-zero on failure.
+     */
+    virtual int sendPacket(const std::vector<std::uint8_t>& data) = 0;
+};
diff --git a/tools/main.cpp b/tools/main.cpp
index 07a169b..95657dc 100644
--- a/tools/main.cpp
+++ b/tools/main.cpp
@@ -15,6 +15,7 @@
  */
 
 #include "blob_handler.hpp"
+#include "ipmi_handler.hpp"
 #include "updater.hpp"
 
 /* Use CLI11 argument parser once in openbmc/meta-oe or whatever. */
@@ -106,7 +107,8 @@
             exit(EXIT_FAILURE);
         }
 
-        BlobHandler blob;
+        IpmiHandler ipmi;
+        BlobHandler blob(&ipmi);
 
         /* The parameters are all filled out. */
         return updaterMain(&blob, interface, imagePath, signaturePath);
diff --git a/tools/test/ipmi_interface_mock.hpp b/tools/test/ipmi_interface_mock.hpp
new file mode 100644
index 0000000..f4ca0cf
--- /dev/null
+++ b/tools/test/ipmi_interface_mock.hpp
@@ -0,0 +1,8 @@
+#pragma once
+
+class IpmiInterfaceMock : public IpmiInterface
+{
+  public:
+    virtual ~IpmiInterfaceMock() = default;
+    MOCK_METHOD1(sendPacket, int(const std::vector<std::uint8_t>&));
+};