message: Add get_cookie method
The message cookie will be used to generate a unique hash id.
Change-Id: Iffb30a287659aa633b399fb1b2efaa450bf66240
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/sdbusplus/message.hpp b/sdbusplus/message.hpp
index 7cb4c1c..7ef81e6 100644
--- a/sdbusplus/message.hpp
+++ b/sdbusplus/message.hpp
@@ -114,6 +114,17 @@
return sd_bus_message_is_method_error(_msg.get(), nullptr);
}
+ /** @brief Get the transaction cookie of a message.
+ *
+ * @return The transaction cookie of a message.
+ */
+ auto get_cookie()
+ {
+ uint64_t cookie;
+ sd_bus_message_get_cookie(_msg.get(), &cookie);
+ return cookie;
+ }
+
/** @brief Check if message is a method call for an interface/method.
*
* @param[in] interface - The interface to match.