bmc: move Verification declaration out of single header
Split the interface declaration from the implementation declaration to
make it more obvious what would change to support more implementations.
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I6452ad85513dad1431ef946b62936c1cea89c263
diff --git a/Makefile.am b/Makefile.am
index ca14c0a..cc7f110 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -43,7 +43,7 @@
firmware_handler.cpp \
file_handler.cpp \
internal/sys.cpp \
- verify.cpp
+ verify_systemd.cpp
if ENABLE_LPC_BRIDGE
libfirmwareblob_common_la_SOURCES += lpc_handler.cpp
diff --git a/firmware_handler.cpp b/firmware_handler.cpp
index c2e935a..5f9a089 100644
--- a/firmware_handler.cpp
+++ b/firmware_handler.cpp
@@ -18,6 +18,7 @@
#include "image_handler.hpp"
#include "util.hpp"
+#include "verify.hpp"
#include <algorithm>
#include <cstdint>
diff --git a/main.cpp b/main.cpp
index b4681a6..fc690b8 100644
--- a/main.cpp
+++ b/main.cpp
@@ -25,6 +25,7 @@
#include "pci_handler.hpp"
#include "util.hpp"
#include "verify.hpp"
+#include "verify_systemd.hpp"
#include <cstdint>
#include <memory>
@@ -100,7 +101,7 @@
auto handler = blobs::FirmwareBlobHandler::CreateFirmwareBlobHandler(
blobs::supportedFirmware, blobs::supportedTransports,
- blobs::Verification::CreateDefaultVerification(
+ blobs::SystemdVerification::CreateVerification(
sdbusplus::bus::new_default(), VERIFY_STATUS_FILENAME,
VERIFY_DBUS_SERVICE));
diff --git a/verify.hpp b/verify.hpp
index 0f67a20..3a77338 100644
--- a/verify.hpp
+++ b/verify.hpp
@@ -1,26 +1,10 @@
#pragma once
-#include "config.h"
-
#include "status.hpp"
#include <memory>
#include <string>
-#if HAVE_SDBUSPLUS
-#include <sdbusplus/bus.hpp>
-#else
-namespace sdbusplus
-{
-namespace bus
-{
-class bus
-{
-};
-} // namespace bus
-} // namespace sdbusplus
-#endif
-
namespace blobs
{
@@ -43,50 +27,4 @@
virtual VerifyCheckResponses checkVerificationState() = 0;
};
-/**
- * Representation of what is used for verification. Currently, this reduces the
- * chance of error by using an object instead of two strings to control the
- * verification step, however, it leaves room for a future possibility out
- * something wholly configurable.
- */
-class Verification : public VerificationInterface
-{
- public:
- /**
- * Create a default Verification object that uses systemd to trigger the
- * process.
- *
- * @param[in] bus - an sdbusplus handler for a bus to use.
- * @param[in] path - the path to check for verification status.
- * @param[in[ service - the systemd service to start to trigger
- * verification.
- */
- static std::unique_ptr<VerificationInterface>
- CreateDefaultVerification(sdbusplus::bus::bus&& bus,
- const std::string& path,
- const std::string& service);
-
- Verification(sdbusplus::bus::bus&& bus, const std::string& path,
- const std::string& service) :
- bus(std::move(bus)),
- checkPath(path), triggerService(service)
- {
- }
-
- ~Verification() = default;
- Verification(const Verification&) = delete;
- Verification& operator=(const Verification&) = delete;
- Verification(Verification&&) = default;
- Verification& operator=(Verification&&) = default;
-
- bool triggerVerification() override;
- void abortVerification() override;
- VerifyCheckResponses checkVerificationState() override;
-
- private:
- sdbusplus::bus::bus bus;
- const std::string checkPath;
- const std::string triggerService;
-};
-
} // namespace blobs
diff --git a/verify.cpp b/verify_systemd.cpp
similarity index 87%
rename from verify.cpp
rename to verify_systemd.cpp
index 5023bf8..fd29918 100644
--- a/verify.cpp
+++ b/verify_systemd.cpp
@@ -14,9 +14,10 @@
* limitations under the License.
*/
-#include "verify.hpp"
+#include "verify_systemd.hpp"
#include "status.hpp"
+#include "verify.hpp"
#include <fstream>
#include <memory>
@@ -28,14 +29,14 @@
{
std::unique_ptr<VerificationInterface>
- Verification::CreateDefaultVerification(sdbusplus::bus::bus&& bus,
+ SystemdVerification::CreateVerification(sdbusplus::bus::bus&& bus,
const std::string& path,
const std::string& service)
{
- return std::make_unique<Verification>(std::move(bus), path, service);
+ return std::make_unique<SystemdVerification>(std::move(bus), path, service);
}
-bool Verification::triggerVerification()
+bool SystemdVerification::triggerVerification()
{
static constexpr auto systemdService = "org.freedesktop.systemd1";
static constexpr auto systemdRoot = "/org/freedesktop/systemd1";
@@ -61,12 +62,12 @@
return true;
}
-void Verification::abortVerification()
+void SystemdVerification::abortVerification()
{
/* TODO: Implement this. */
}
-VerifyCheckResponses Verification::checkVerificationState()
+VerifyCheckResponses SystemdVerification::checkVerificationState()
{
VerifyCheckResponses result = VerifyCheckResponses::other;
diff --git a/verify_systemd.hpp b/verify_systemd.hpp
new file mode 100644
index 0000000..60acbc6
--- /dev/null
+++ b/verify_systemd.hpp
@@ -0,0 +1,57 @@
+#pragma once
+
+#include "status.hpp"
+#include "verify.hpp"
+
+#include <memory>
+#include <sdbusplus/bus.hpp>
+#include <string>
+
+namespace blobs
+{
+
+/**
+ * Representation of what is used for verification. Currently, this reduces the
+ * chance of error by using an object instead of two strings to control the
+ * verification step, however, it leaves room for a future possibility out
+ * something wholly configurable.
+ */
+class SystemdVerification : public VerificationInterface
+{
+ public:
+ /**
+ * Create a default Verification object that uses systemd to trigger the
+ * process.
+ *
+ * @param[in] bus - an sdbusplus handler for a bus to use.
+ * @param[in] path - the path to check for verification status.
+ * @param[in[ service - the systemd service to start to trigger
+ * verification.
+ */
+ static std::unique_ptr<VerificationInterface>
+ CreateVerification(sdbusplus::bus::bus&& bus, const std::string& path,
+ const std::string& service);
+
+ SystemdVerification(sdbusplus::bus::bus&& bus, const std::string& path,
+ const std::string& service) :
+ bus(std::move(bus)),
+ checkPath(path), triggerService(service)
+ {
+ }
+
+ ~SystemdVerification() = default;
+ SystemdVerification(const SystemdVerification&) = delete;
+ SystemdVerification& operator=(const SystemdVerification&) = delete;
+ SystemdVerification(SystemdVerification&&) = default;
+ SystemdVerification& operator=(SystemdVerification&&) = default;
+
+ bool triggerVerification() override;
+ void abortVerification() override;
+ VerifyCheckResponses checkVerificationState() override;
+
+ private:
+ sdbusplus::bus::bus bus;
+ const std::string checkPath;
+ const std::string triggerService;
+};
+} // namespace blobs