1<?xml version='1.0'?> <!--*-nxml-*--> 2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" 3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> 4<!-- SPDX-License-Identifier: LGPL-2.1-or-later --> 5 6<refentry id="sd_bus_message_get_cookie" 7 xmlns:xi="http://www.w3.org/2001/XInclude"> 8 9 <refentryinfo> 10 <title>sd_bus_message_get_cookie</title> 11 <productname>systemd</productname> 12 </refentryinfo> 13 14 <refmeta> 15 <refentrytitle>sd_bus_message_get_cookie</refentrytitle> 16 <manvolnum>3</manvolnum> 17 </refmeta> 18 19 <refnamediv> 20 <refname>sd_bus_message_get_cookie</refname> 21 <refname>sd_bus_message_get_reply_cookie</refname> 22 <refpurpose>Returns the transaction cookie of a message</refpurpose> 23 </refnamediv> 24 25 <refsynopsisdiv> 26 <funcsynopsis> 27 <funcsynopsisinfo>#include <systemd/sd-bus.h></funcsynopsisinfo> 28 29 <funcprototype> 30 <funcdef>int <function>sd_bus_message_get_cookie</function></funcdef> 31 <paramdef>sd_bus_message *<parameter>message</parameter></paramdef> 32 <paramdef>uint64_t *<parameter>cookie</parameter></paramdef> 33 </funcprototype> 34 35 <funcprototype> 36 <funcdef>int <function>sd_bus_message_get_reply_cookie</function></funcdef> 37 <paramdef>sd_bus_message *<parameter>message</parameter></paramdef> 38 <paramdef>uint64_t *<parameter>cookie</parameter></paramdef> 39 </funcprototype> 40 </funcsynopsis> 41 </refsynopsisdiv> 42 43 <refsect1> 44 <title>Description</title> 45 46 <para><function>sd_bus_message_get_cookie()</function> returns the 47 transaction cookie of a message. The cookie uniquely identifies a 48 message within each bus peer, but is not globally unique. It is 49 assigned when a message is sent.</para> 50 51 <para><function>sd_bus_message_get_reply_cookie()</function> 52 returns the transaction cookie of the message the specified 53 message is a response to. When a reply message is generated for a 54 method call message, its cookie is copied over into this field. 55 Note that while every message that is transferred is identified by 56 a cookie, only response messages carry a reply cookie 57 field.</para> 58 59 <para>Both functions take a message object as first parameter and 60 a place to store the 64-bit cookie in.</para> 61 </refsect1> 62 63 <refsect1> 64 <title>Return Value</title> 65 66 <para>On success, these calls return 0 or a positive integer. On failure, they return a negative 67 errno-style error code.</para> 68 69 <para>On success, the cookie/reply cookie is returned in the specified 64-bit unsigned integer 70 variable.</para> 71 72 <refsect2> 73 <title>Errors</title> 74 75 <para>Returned errors may indicate the following problems:</para> 76 77 <variablelist> 78 <varlistentry> 79 <term><constant>-EINVAL</constant></term> 80 81 <listitem><para>A specified parameter is invalid.</para></listitem> 82 </varlistentry> 83 84 <varlistentry> 85 <term><constant>-ENODATA</constant></term> 86 87 <listitem><para>No cookie has been assigned to this message. This either indicates that the 88 message has not been sent yet and hence has no cookie assigned, or that the message is not a method 89 response message and hence carries a reply cookie field.</para></listitem> 90 </varlistentry> 91 </variablelist> 92 </refsect2> 93 </refsect1> 94 95 <xi:include href="libsystemd-pkgconfig.xml" /> 96 97 <refsect1> 98 <title>See Also</title> 99 100 <para> 101 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, 102 <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>, 103 <citerefentry><refentrytitle>sd_bus_new</refentrytitle><manvolnum>3</manvolnum></citerefentry> 104 </para> 105 </refsect1> 106 107</refentry> 108