summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdriana Kobylak <anoo@us.ibm.com>2017-01-26 15:09:00 -0600
committerPatrick Williams <patrick@stwcx.xyz>2017-02-01 23:08:11 +0000
commit6312225706a0aaafc37c090f963dde3a923d3acb (patch)
tree114e62420412e5733562be92abcd5312f494d43e
parent990cbce33e9c0a2b80573b8cc310b9de6b68ade6 (diff)
downloadsdbusplus-6312225706a0aaafc37c090f963dde3a923d3acb.tar.gz
sdbusplus-6312225706a0aaafc37c090f963dde3a923d3acb.zip
message: Add get bus function
Function to get the dbus bus from a dbus message. Forward declare it and implement it in bus.hpp so that the return type is sdbusplus::bus::bus. Change-Id: Ice55c8ce484ae1b575e762cc0d9e2826b4ba6504 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
-rw-r--r--sdbusplus/bus.hpp11
-rw-r--r--sdbusplus/message.hpp4
2 files changed, 15 insertions, 0 deletions
diff --git a/sdbusplus/bus.hpp b/sdbusplus/bus.hpp
index d0536d7..5ec1ff7 100644
--- a/sdbusplus/bus.hpp
+++ b/sdbusplus/bus.hpp
@@ -211,4 +211,15 @@ inline bus new_system()
} // namespace bus
+/** @brief Get the dbus bus from the message.
+ *
+ * @return The dbus bus.
+ */
+inline auto message::message::get_bus()
+{
+ sd_bus* b = nullptr;
+ b = sd_bus_message_get_bus(_msg.get());
+ return bus::bus(sd_bus_ref(b));
+}
+
} // namespace sdbusplus
diff --git a/sdbusplus/message.hpp b/sdbusplus/message.hpp
index 7ef81e6..8c9414e 100644
--- a/sdbusplus/message.hpp
+++ b/sdbusplus/message.hpp
@@ -96,6 +96,10 @@ struct message
sdbusplus::message::read(_msg.get(), std::forward<Args>(args)...);
}
+ /** @brief Get the dbus bus from the message. */
+ // Forward declare.
+ auto get_bus();
+
/** @brief Get the signature of a message.
*
* @return A [weak] pointer to the signature of the message.
OpenPOWER on IntegriCloud