summaryrefslogtreecommitdiffstats
path: root/ipmid.cpp
diff options
context:
space:
mode:
authorVishwanatha Subbanna <vishwa@linux.vnet.ibm.com>2017-07-12 16:13:49 +0530
committerPatrick Williams <patrick@stwcx.xyz>2017-08-14 18:47:08 +0000
commit3eb117a322aca11f049bb05beea5eb2f6385cb8e (patch)
treef3352df962e284c1d239e38a57955c1fa8b6ddca /ipmid.cpp
parentac149a94543c9fae468cf45e47103998153c89a5 (diff)
downloadphosphor-host-ipmid-3eb117a322aca11f049bb05beea5eb2f6385cb8e.tar.gz
phosphor-host-ipmid-3eb117a322aca11f049bb05beea5eb2f6385cb8e.zip
Use Host Command Manager in host interface implementation
Change-Id: Icefce510a3a0022bf0288fa99518459b732a2e04 Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
Diffstat (limited to 'ipmid.cpp')
-rw-r--r--ipmid.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/ipmid.cpp b/ipmid.cpp
index 7583bb8..f41e27f 100644
--- a/ipmid.cpp
+++ b/ipmid.cpp
@@ -25,6 +25,8 @@
#include "sensorhandler.h"
#include "ipmid.hpp"
#include "settings.hpp"
+#include <host-cmd-manager.hpp>
+#include <ipmid-host-cmd.hpp>
using namespace phosphor::logging;
namespace sdbusRule = sdbusplus::bus::match::rules;
@@ -33,6 +35,17 @@ sd_bus *bus = NULL;
sd_bus_slot *ipmid_slot = NULL;
sd_event *events = nullptr;
+// Need this to use new sdbusplus compatible interfaces
+sdbusPtr sdbusp;
+
+// Global Host Bound Command manager
+using cmdManagerPtr = std::unique_ptr<phosphor::host::command::Manager>;
+cmdManagerPtr cmdManager;
+
+// Command and handler tuple. Used when clients ask the command to be put
+// into host message queue
+using CommandHandler = phosphor::host::command::CommandHandler;
+
// Initialise restricted mode to true
bool restricted_mode = true;
@@ -238,7 +251,9 @@ static int send_ipmi_message(sd_bus_message *req, unsigned char seq, unsigned ch
dest = sd_bus_message_get_sender(req);
path = sd_bus_message_get_path(req);
- r = sd_bus_message_new_method_call(bus,&m,dest,path,DBUS_INTF,"sendMessage");
+ r = sd_bus_message_new_method_call(bus,&m,dest,path,
+ DBUS_INTF,
+ "sendMessage");
if (r < 0) {
fprintf(stderr, "Failed to add the method object: %s\n", strerror(-r));
return -1;
@@ -486,6 +501,19 @@ sd_bus_slot *ipmid_get_sd_bus_slot(void) {
return ipmid_slot;
}
+// Calls host command manager to do the right thing for the command
+void ipmid_send_cmd_to_host(CommandHandler&& cmd) {
+ return cmdManager->execute(std::move(cmd));
+}
+
+cmdManagerPtr& ipmid_get_host_cmd_manager() {
+ return cmdManager;
+}
+
+sdbusPtr& ipmid_get_sdbus_plus_handler() {
+ return sdbusp;
+}
+
int main(int argc, char *argv[])
{
int r;
@@ -536,6 +564,11 @@ int main(int argc, char *argv[])
goto finish;
}
+ // Now create the Host Bound Command manager. Need sdbusplus
+ // to use the generated bindings
+ sdbusp = std::make_unique<sdbusplus::bus::bus>(bus);
+ cmdManager = std::make_unique<phosphor::host::command::Manager>(
+ *sdbusp, events);
// Register all the handlers that provider implementation to IPMI commands.
ipmi_register_callback_handlers(HOST_IPMI_LIB_PATH);
OpenPOWER on IntegriCloud