1 <?xml version='
1.0'
?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC
"-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
6 SPDX-License-Identifier: LGPL-2.1+
8 This file is part of systemd.
10 Copyright 2013 Lennart Poettering
12 systemd is free software; you can redistribute it and/or modify it
13 under the terms of the GNU Lesser General Public License as published by
14 the Free Software Foundation; either version 2.1 of the License, or
15 (at your option) any later version.
17 systemd is distributed in the hope that it will be useful, but
18 WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 Lesser General Public License for more details.
22 You should have received a copy of the GNU Lesser General Public License
23 along with systemd; If not, see <http://www.gnu.org/licenses/>.
26 <refentry id=
"sd_bus_message_get_cookie">
29 <title>sd_bus_message_get_cookie
</title>
30 <productname>systemd
</productname>
34 <contrib>Developer
</contrib>
35 <firstname>Lennart
</firstname>
36 <surname>Poettering
</surname>
37 <email>lennart@poettering.net
</email>
43 <refentrytitle>sd_bus_message_get_cookie
</refentrytitle>
44 <manvolnum>3</manvolnum>
48 <refname>sd_bus_message_get_cookie
</refname>
49 <refname>sd_bus_message_get_reply_cookie
</refname>
50 <refpurpose>Returns the transaction cookie of a message
</refpurpose>
55 <funcsynopsisinfo>#include
<systemd/sd-bus.h
></funcsynopsisinfo>
58 <funcdef>int
<function>sd_bus_message_get_cookie
</function></funcdef>
59 <paramdef>sd_bus_message *
<parameter>message
</parameter></paramdef>
60 <paramdef>uint64_t *
<parameter>cookie
</parameter></paramdef>
64 <funcdef>int
<function>sd_bus_message_get_reply_cookie
</function></funcdef>
65 <paramdef>sd_bus_message *
<parameter>message
</parameter></paramdef>
66 <paramdef>uint64_t *
<parameter>cookie
</parameter></paramdef>
72 <title>Description
</title>
74 <para><function>sd_bus_message_get_cookie()
</function> returns the
75 transaction cookie of a message. The cookie uniquely identifies a
76 message within each bus peer, but is not globally unique. It is
77 assigned when a message is sent.
</para>
79 <para><function>sd_bus_message_get_reply_cookie()
</function>
80 returns the transaction cookie of the message the specified
81 message is a response to. When a reply message is generated for a
82 method call message, its cookie is copied over into this field.
83 Note that while every message that is transferred is identified by
84 a cookie, only response messages carry a reply cookie
87 <para>Both functions take a message object as first parameter and
88 a place to store the
64-bit cookie in.
</para>
92 <title>Return Value
</title>
94 <para>On success, these calls return
0 or a positive integer. On
95 failure, these calls return a negative errno-style error
98 <para>On success, the cookie/reply cookie is returned in the
99 specified
64-bit unsigned integer variable.
</para>
103 <title>Errors
</title>
105 <para>Returned errors may indicate the following problems:
</para>
109 <term><constant>-EINVAL
</constant></term>
111 <listitem><para>A specified parameter
112 is invalid.
</para></listitem>
116 <term><constant>-ENODATA
</constant></term>
118 <listitem><para>No cookie has been assigned to this message.
119 This either indicates that the message has not been sent yet
120 and hence has no cookie assigned, or that the message is not a
121 method response message and hence carries a reply cookie
122 field.
</para></listitem>
130 <para>The
<function>sd_bus_message_get_cookie()
</function> and
131 <function>sd_bus_message_get_reply_cookie()
</function> interfaces
132 are available as a shared library, which can be compiled and
134 <constant>libsystemd
</constant> <citerefentry project='die-net'
><refentrytitle>pkg-config
</refentrytitle><manvolnum>1</manvolnum></citerefentry>
139 <title>See Also
</title>
142 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
143 <citerefentry><refentrytitle>sd-bus
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
144 <citerefentry><refentrytitle>sd_bus_new
</refentrytitle><manvolnum>3</manvolnum></citerefentry>