ipmi: add zone controller interface

Implementations of this interface can make the library mode testable and
work in environments other than dbus.

The main entry point to the IPMI handler now expects to receive a
handler pointer.  The handler itself is implemented to process IPMI
requests and responses in the expected way.  The default object receives
a dbus implementation for the zone controls.

Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I6d7be871bdc5cce3c3cc53c16d80b501aaaafc7d
diff --git a/ipmi/dbus_mode.hpp b/ipmi/dbus_mode.hpp
index 05e9734..b063ac4 100644
--- a/ipmi/dbus_mode.hpp
+++ b/ipmi/dbus_mode.hpp
@@ -1,5 +1,7 @@
 #pragma once
 
+#include "control.hpp"
+
 #include <cstdint>
 #include <string>
 
@@ -8,21 +10,31 @@
 namespace ipmi
 {
 
-/*
- * busctl call xyz.openbmc_project.State.FanCtrl \
- *     /xyz/openbmc_project/settings/fanctrl/zone1 \
- *     org.freedesktop.DBus.Properties \
- *     GetAll \
- *     s \
- *     xyz.openbmc_project.Control.Mode
- * a{sv} 2 "Manual" b false "FailSafe" b false
- *
- * This returns an IPMI code as a uint8_t (which will always be sufficient to
- * hold the result). NOTE: This does not return the typedef value to avoid
- * including a header with conflicting types.
- */
-uint8_t getFanCtrlProperty(uint8_t zoneId, bool* value,
-                           const std::string& property);
+class DbusZoneControl : public ZoneControlInterface
+{
+  public:
+    DbusZoneControl() = default;
+    ~DbusZoneControl() = default;
+
+    /*
+     * busctl call xyz.openbmc_project.State.FanCtrl \
+     *     /xyz/openbmc_project/settings/fanctrl/zone1 \
+     *     org.freedesktop.DBus.Properties \
+     *     GetAll \
+     *     s \
+     *     xyz.openbmc_project.Control.Mode
+     * a{sv} 2 "Manual" b false "FailSafe" b false
+     *
+     * This returns an IPMI code as a uint8_t (which will always be sufficient
+     * to hold the result). NOTE: This does not return the typedef value to
+     * avoid including a header with conflicting types.
+     */
+    uint8_t getFanCtrlProperty(uint8_t zoneId, bool* value,
+                               const std::string& property) override;
+
+    uint8_t setFanCtrlProperty(uint8_t zoneId, bool value,
+                               const std::string& property) override;
+};
 
 } // namespace ipmi
 } // namespace pid_control