tools: add data interface type

Add data interface type to the object, to allow checking against what
stat() returns.

Change-Id: I72aed1ffbca63dbfb003359c4bbe570f966a8649
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/tools/bt.hpp b/tools/bt.hpp
index e005937..10050b6 100644
--- a/tools/bt.hpp
+++ b/tools/bt.hpp
@@ -9,7 +9,13 @@
     explicit BtDataHandler(BlobInterface* blob) : blob(blob){};
 
     bool sendContents(const std::string& input, std::uint16_t session) override;
+    blobs::FirmwareBlobHandler::UpdateFlags supportedType() const override
+    {
+        return flags;
+    }
 
   private:
     BlobInterface* blob;
+    blobs::FirmwareBlobHandler::UpdateFlags flags =
+        blobs::FirmwareBlobHandler::UpdateFlags::ipmi;
 };
diff --git a/tools/interface.hpp b/tools/interface.hpp
index 39f3fb8..0294c1d 100644
--- a/tools/interface.hpp
+++ b/tools/interface.hpp
@@ -1,5 +1,7 @@
 #pragma once
 
+#include "firmware_handler.hpp"
+
 #include <cstdint>
 #include <string>
 
@@ -19,4 +21,11 @@
      */
     virtual bool sendContents(const std::string& input,
                               std::uint16_t session) = 0;
+
+    /**
+     * Return the supported data interface for this.
+     *
+     * @return the enum value corresponding to the supported type.
+     */
+    virtual blobs::FirmwareBlobHandler::UpdateFlags supportedType() const = 0;
 };
diff --git a/tools/lpc.hpp b/tools/lpc.hpp
index c60fd99..4b53f26 100644
--- a/tools/lpc.hpp
+++ b/tools/lpc.hpp
@@ -9,7 +9,13 @@
     explicit LpcDataHandler(BlobInterface* blob) : blob(blob){};
 
     bool sendContents(const std::string& input, std::uint16_t session) override;
+    blobs::FirmwareBlobHandler::UpdateFlags supportedType() const override
+    {
+        return flags;
+    }
 
   private:
     BlobInterface* blob;
+    blobs::FirmwareBlobHandler::UpdateFlags flags =
+        blobs::FirmwareBlobHandler::UpdateFlags::lpc;
 };
diff --git a/tools/updater.cpp b/tools/updater.cpp
index 7b5ec0f..a7f9c96 100644
--- a/tools/updater.cpp
+++ b/tools/updater.cpp
@@ -44,6 +44,11 @@
      * is supported.
      */
     auto stat = blob->getStat(goalFirmware);
+    if ((stat.blob_state & handler->supportedType()) == 0)
+    {
+        std::fprintf(stderr, "data interface selected not supported.\n");
+        return -1; /* throw custom exception. */
+    }
 
     return 0;
 }