blob: 628b2415fd7b1e8f93997db291acd636daa2957c [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.
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 */
44DbusObjectInfo 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 */
56Value 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 */
68PropertyMap 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 */
79void 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 Josephbe703f72017-03-09 12:34:35 +053085} // namespace ipmi
86
87