summaryrefslogtreecommitdiffstats
path: root/utils.hpp
diff options
context:
space:
mode:
authorRatan Gupta <ratagupt@in.ibm.com>2017-07-25 21:52:10 +0530
committerPatrick Williams <patrick@stwcx.xyz>2017-08-11 17:29:08 +0000
commitcc8feb4f72d1c4388f9a81727e36eb1bbc754251 (patch)
tree926530b423367e29803fcfc9bfcb191962214b33 /utils.hpp
parent18e9999232b76cc311bd307fd28adce0fb17db9a (diff)
downloadphosphor-host-ipmid-cc8feb4f72d1c4388f9a81727e36eb1bbc754251.tar.gz
phosphor-host-ipmid-cc8feb4f72d1c4388f9a81727e36eb1bbc754251.zip
Move dbus utility function to utils
Change-Id: Ief3d9ab2311a597670767cf9931913e5afef4fee Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
Diffstat (limited to 'utils.hpp')
-rw-r--r--utils.hpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/utils.hpp b/utils.hpp
index 98be82a..628b241 100644
--- a/utils.hpp
+++ b/utils.hpp
@@ -1,10 +1,27 @@
#pragma once
+#include "types.hpp"
#include <sdbusplus/server.hpp>
namespace ipmi
{
+constexpr auto MAPPER_BUS_NAME = "xyz.openbmc_project.ObjectMapper";
+constexpr auto MAPPER_OBJ = "/xyz/openbmc_project/object_mapper";
+constexpr auto MAPPER_INTF = "xyz.openbmc_project.ObjectMapper";
+
+constexpr auto ROOT = "/";
+constexpr auto HOST_MATCH = "host0";
+constexpr auto PROP_INTF = "org.freedesktop.DBus.Properties";
+
+constexpr auto IP_INTERFACE = "xyz.openbmc_project.Network.IP";
+constexpr auto MAC_INTERFACE = "xyz.openbmc_project.Network.MACAddress";
+
+constexpr auto METHOD_GET = "Get";
+constexpr auto METHOD_GET_ALL = "GetAll";
+constexpr auto METHOD_SET = "Set";
+
+
/**
* @brief Get the DBUS Service name for the input dbus path
*
@@ -16,6 +33,55 @@ namespace ipmi
std::string getService(sdbusplus::bus::bus& bus,
const std::string& intf,
const std::string& path);
+
+/** @brief Gets the dbus object info implementing the given interface
+ * from the given subtree.
+ * @param[in] interface - Dbus interface.
+ * @param[in] subtreePath - subtree from where the search should start.
+ * @param[in] match - identifier for object.
+ * @return On success returns the object having objectpath and servicename.
+ */
+DbusObjectInfo getDbusObject(const std::string& interface,
+ const std::string& subtreePath = ROOT,
+ const std::string& match = {});
+
+/** @brief Gets the value associated with the given object
+ * and the interface.
+ * @param[in] service - Dbus service name.
+ * @param[in] objPath - Dbus object path.
+ * @param[in] interface - Dbus interface.
+ * @param[in] property - name of the property.
+ * @return On success returns the value of the property.
+ */
+Value getDbusProperty(const std::string& service,
+ const std::string& objPath,
+ const std::string& interface,
+ const std::string& property);
+
+/** @brief Gets all the properties associated with the given object
+ * and the interface.
+ * @param[in] service - Dbus service name.
+ * @param[in] objPath - Dbus object path.
+ * @param[in] interface - Dbus interface.
+ * @return On success returns the map of name value pair.
+ */
+PropertyMap getAllDbusProperties(const std::string& service,
+ const std::string& objPath,
+ const std::string& interface);
+
+/** @brief Sets the property value of the given object.
+ * @param[in] service - Dbus service name.
+ * @param[in] objPath - Dbus object path.
+ * @param[in] interface - Dbus interface.
+ * @param[in] property - name of the property.
+ * @param[in] value - value which needs to be set.
+ */
+void setDbusProperty(const std::string& service,
+ const std::string& objPath,
+ const std::string& interface,
+ const std::string& property,
+ const Value& value);
+
} // namespace ipmi
OpenPOWER on IntegriCloud