blob: 0c7ae76a4092e6a1b37ee57965edbfc44f04d3a3 [file] [log] [blame]
Tom Josephbe703f72017-03-09 12:34:35 +05301#pragma once
2
Ratan Guptacc8feb42017-07-25 21:52:10 +05303#include "types.hpp"
Tom Josephbe703f72017-03-09 12:34:35 +05304#include <sdbusplus/server.hpp>
5
6namespace ipmi
7{
8
Ratan Guptacc8feb42017-07-25 21:52:10 +05309constexpr auto MAPPER_BUS_NAME = "xyz.openbmc_project.ObjectMapper";
10constexpr auto MAPPER_OBJ = "/xyz/openbmc_project/object_mapper";
11constexpr auto MAPPER_INTF = "xyz.openbmc_project.ObjectMapper";
12
13constexpr auto ROOT = "/";
14constexpr auto HOST_MATCH = "host0";
15constexpr auto PROP_INTF = "org.freedesktop.DBus.Properties";
16
17constexpr auto IP_INTERFACE = "xyz.openbmc_project.Network.IP";
18constexpr auto MAC_INTERFACE = "xyz.openbmc_project.Network.MACAddress";
19
20constexpr auto METHOD_GET = "Get";
21constexpr auto METHOD_GET_ALL = "GetAll";
22constexpr auto METHOD_SET = "Set";
23
24
Tom Josephbe703f72017-03-09 12:34:35 +053025/**
26 * @brief Get the DBUS Service name for the input dbus path
27 *
28 * @param[in] bus - DBUS Bus Object
29 * @param[in] intf - DBUS Interface
30 * @param[in] path - DBUS Object Path
31 *
32 */
33std::string getService(sdbusplus::bus::bus& bus,
34 const std::string& intf,
35 const std::string& path);
Ratan Guptacc8feb42017-07-25 21:52:10 +053036
37/** @brief Gets the dbus object info implementing the given interface
38 * from the given subtree.
Ratan Gupta01d4bd12017-08-07 15:53:25 +053039 * @param[in] bus - DBUS Bus Object.
Ratan Guptacc8feb42017-07-25 21:52:10 +053040 * @param[in] interface - Dbus interface.
41 * @param[in] subtreePath - subtree from where the search should start.
42 * @param[in] match - identifier for object.
43 * @return On success returns the object having objectpath and servicename.
44 */
Ratan Gupta01d4bd12017-08-07 15:53:25 +053045DbusObjectInfo getDbusObject(sdbusplus::bus::bus& bus,
46 const std::string& interface,
Ratan Guptacc8feb42017-07-25 21:52:10 +053047 const std::string& subtreePath = ROOT,
48 const std::string& match = {});
49
50/** @brief Gets the value associated with the given object
51 * and the interface.
Ratan Gupta01d4bd12017-08-07 15:53:25 +053052 * @param[in] bus - DBUS Bus Object.
Ratan Guptacc8feb42017-07-25 21:52:10 +053053 * @param[in] service - Dbus service name.
54 * @param[in] objPath - Dbus object path.
55 * @param[in] interface - Dbus interface.
56 * @param[in] property - name of the property.
57 * @return On success returns the value of the property.
58 */
Ratan Gupta01d4bd12017-08-07 15:53:25 +053059Value getDbusProperty(sdbusplus::bus::bus& bus,
60 const std::string& service,
Ratan Guptacc8feb42017-07-25 21:52:10 +053061 const std::string& objPath,
62 const std::string& interface,
63 const std::string& property);
64
65/** @brief Gets all the properties associated with the given object
66 * and the interface.
Ratan Gupta01d4bd12017-08-07 15:53:25 +053067 * @param[in] bus - DBUS Bus Object.
Ratan Guptacc8feb42017-07-25 21:52:10 +053068 * @param[in] service - Dbus service name.
69 * @param[in] objPath - Dbus object path.
70 * @param[in] interface - Dbus interface.
71 * @return On success returns the map of name value pair.
72 */
Ratan Gupta01d4bd12017-08-07 15:53:25 +053073PropertyMap getAllDbusProperties(sdbusplus::bus::bus& bus,
74 const std::string& service,
Ratan Guptacc8feb42017-07-25 21:52:10 +053075 const std::string& objPath,
76 const std::string& interface);
77
78/** @brief Sets the property value of the given object.
Ratan Gupta01d4bd12017-08-07 15:53:25 +053079 * @param[in] bus - DBUS Bus Object.
Ratan Guptacc8feb42017-07-25 21:52:10 +053080 * @param[in] service - Dbus service name.
81 * @param[in] objPath - Dbus object path.
82 * @param[in] interface - Dbus interface.
83 * @param[in] property - name of the property.
84 * @param[in] value - value which needs to be set.
85 */
Ratan Gupta01d4bd12017-08-07 15:53:25 +053086void setDbusProperty(sdbusplus::bus::bus& bus,
87 const std::string& service,
Ratan Guptacc8feb42017-07-25 21:52:10 +053088 const std::string& objPath,
89 const std::string& interface,
90 const std::string& property,
91 const Value& value);
92
Tom Josephbe703f72017-03-09 12:34:35 +053093} // namespace ipmi
94
95