Tom Joseph | be703f7 | 2017-03-09 12:34:35 +0530 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Ratan Gupta | cc8feb4 | 2017-07-25 21:52:10 +0530 | [diff] [blame] | 3 | #include "types.hpp" |
Tom Joseph | be703f7 | 2017-03-09 12:34:35 +0530 | [diff] [blame] | 4 | #include <sdbusplus/server.hpp> |
| 5 | |
| 6 | namespace ipmi |
| 7 | { |
| 8 | |
Ratan Gupta | cc8feb4 | 2017-07-25 21:52:10 +0530 | [diff] [blame] | 9 | constexpr auto MAPPER_BUS_NAME = "xyz.openbmc_project.ObjectMapper"; |
| 10 | constexpr auto MAPPER_OBJ = "/xyz/openbmc_project/object_mapper"; |
| 11 | constexpr auto MAPPER_INTF = "xyz.openbmc_project.ObjectMapper"; |
| 12 | |
| 13 | constexpr auto ROOT = "/"; |
| 14 | constexpr auto HOST_MATCH = "host0"; |
| 15 | constexpr auto PROP_INTF = "org.freedesktop.DBus.Properties"; |
| 16 | |
| 17 | constexpr auto IP_INTERFACE = "xyz.openbmc_project.Network.IP"; |
| 18 | constexpr auto MAC_INTERFACE = "xyz.openbmc_project.Network.MACAddress"; |
| 19 | |
| 20 | constexpr auto METHOD_GET = "Get"; |
| 21 | constexpr auto METHOD_GET_ALL = "GetAll"; |
| 22 | constexpr auto METHOD_SET = "Set"; |
| 23 | |
| 24 | |
Tom Joseph | be703f7 | 2017-03-09 12:34:35 +0530 | [diff] [blame] | 25 | /** |
| 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 | */ |
| 33 | std::string getService(sdbusplus::bus::bus& bus, |
| 34 | const std::string& intf, |
| 35 | const std::string& path); |
Ratan Gupta | cc8feb4 | 2017-07-25 21:52:10 +0530 | [diff] [blame] | 36 | |
| 37 | /** @brief Gets the dbus object info implementing the given interface |
| 38 | * from the given subtree. |
| 39 | * @param[in] interface - Dbus interface. |
| 40 | * @param[in] subtreePath - subtree from where the search should start. |
| 41 | * @param[in] match - identifier for object. |
| 42 | * @return On success returns the object having objectpath and servicename. |
| 43 | */ |
| 44 | DbusObjectInfo getDbusObject(const std::string& interface, |
| 45 | const std::string& subtreePath = ROOT, |
| 46 | const std::string& match = {}); |
| 47 | |
| 48 | /** @brief Gets the value associated with the given object |
| 49 | * and the interface. |
| 50 | * @param[in] service - Dbus service name. |
| 51 | * @param[in] objPath - Dbus object path. |
| 52 | * @param[in] interface - Dbus interface. |
| 53 | * @param[in] property - name of the property. |
| 54 | * @return On success returns the value of the property. |
| 55 | */ |
| 56 | Value getDbusProperty(const std::string& service, |
| 57 | const std::string& objPath, |
| 58 | const std::string& interface, |
| 59 | const std::string& property); |
| 60 | |
| 61 | /** @brief Gets all the properties associated with the given object |
| 62 | * and the interface. |
| 63 | * @param[in] service - Dbus service name. |
| 64 | * @param[in] objPath - Dbus object path. |
| 65 | * @param[in] interface - Dbus interface. |
| 66 | * @return On success returns the map of name value pair. |
| 67 | */ |
| 68 | PropertyMap getAllDbusProperties(const std::string& service, |
| 69 | const std::string& objPath, |
| 70 | const std::string& interface); |
| 71 | |
| 72 | /** @brief Sets the property value of the given object. |
| 73 | * @param[in] service - Dbus service name. |
| 74 | * @param[in] objPath - Dbus object path. |
| 75 | * @param[in] interface - Dbus interface. |
| 76 | * @param[in] property - name of the property. |
| 77 | * @param[in] value - value which needs to be set. |
| 78 | */ |
| 79 | void setDbusProperty(const std::string& service, |
| 80 | const std::string& objPath, |
| 81 | const std::string& interface, |
| 82 | const std::string& property, |
| 83 | const Value& value); |
| 84 | |
Tom Joseph | be703f7 | 2017-03-09 12:34:35 +0530 | [diff] [blame] | 85 | } // namespace ipmi |
| 86 | |
| 87 | |