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
13 <refentry id=
"sd_bus_message_get_monotonic_usec">
16 <title>sd_bus_message_get_monotonic_usec
</title>
17 <productname>systemd
</productname>
21 <contrib>Developer
</contrib>
22 <firstname>Lennart
</firstname>
23 <surname>Poettering
</surname>
24 <email>lennart@poettering.net
</email>
30 <refentrytitle>sd_bus_message_get_monotonic_usec
</refentrytitle>
31 <manvolnum>3</manvolnum>
35 <refname>sd_bus_message_get_monotonic_usec
</refname>
36 <refname>sd_bus_message_get_realtime_usec
</refname>
37 <refname>sd_bus_message_get_seqnum
</refname>
38 <refpurpose>Retrieve the sender timestamps and sequence number of a message
</refpurpose>
43 <funcsynopsisinfo>#include
<systemd/sd-bus.h
></funcsynopsisinfo>
46 <funcdef>int
<function>sd_bus_message_get_monotonic_usec
</function></funcdef>
47 <paramdef>sd_bus_message *
<parameter>message
</parameter></paramdef>
48 <paramdef>uint64_t *
<parameter>usec
</parameter></paramdef>
52 <funcdef>int
<function>sd_bus_message_get_realtime_usec
</function></funcdef>
53 <paramdef>sd_bus_message *
<parameter>message
</parameter></paramdef>
54 <paramdef>uint64_t *
<parameter>usec
</parameter></paramdef>
58 <funcdef>int
<function>sd_bus_message_get_seqnum
</function></funcdef>
59 <paramdef>sd_bus_message *
<parameter>message
</parameter></paramdef>
60 <paramdef>uint64_t *
<parameter>seqnum
</parameter></paramdef>
66 <title>Description
</title>
68 <para><function>sd_bus_message_get_monotonic_usec()
</function>
69 returns the monotonic timestamp of the time the message was sent.
70 This value is in microseconds since the
71 <constant>CLOCK_MONOTONIC
</constant> epoch, see
72 <citerefentry><refentrytitle>clock_gettime
</refentrytitle><manvolnum>2</manvolnum></citerefentry>
76 <function>sd_bus_message_get_realtime_usec()
</function> returns
77 the realtime (wallclock) timestamp of the time the message was
78 sent. This value is in microseconds since Jan
1st,
1970, i.e. in
79 the
<constant>CLOCK_REALTIME
</constant> clock.
</para>
81 <para><function>sd_bus_message_get_seqnum()
</function> returns the
82 kernel-assigned sequence number of the message. The kernel assigns
83 a global, monotonically increasing sequence number to all messages
84 transmitted on the local system, at the time the message was sent.
85 This sequence number is useful for determining message send order,
86 even across different buses of the local system. The sequence
87 number combined with the boot ID of the system (as returned by
88 <citerefentry><refentrytitle>sd_id128_get_boot
</refentrytitle><manvolnum>3</manvolnum></citerefentry>)
89 is a suitable globally unique identifier for bus messages.
</para>
91 <para>Note that the sending order and receiving order of messages
92 might differ, in particular for broadcast messages. This means
93 that the sequence number and the timestamps of messages a client
94 reads are not necessarily monotonically increasing.
</para>
96 <para>These timestamps and the sequence number are attached to
97 each message by the kernel and cannot be manipulated by the
100 <para>Note that these timestamps are only available on some bus
101 transports, and only after support for them has been negotiated
103 <citerefentry><refentrytitle>sd_bus_negotiate_timestamp
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
108 <title>Return Value
</title>
110 <para>On success, these calls return
0 or a positive integer. On
111 failure, these calls return a negative errno-style error
114 <para>On success, the timestamp or sequence number is returned in
115 the specified
64-bit unsigned integer variable.
</para>
119 <title>Errors
</title>
121 <para>Returned errors may indicate the following problems:
</para>
125 <term><constant>-EINVAL
</constant></term>
127 <listitem><para>A specified parameter is
128 invalid.
</para></listitem>
132 <term><constant>-ENODATA
</constant></term>
134 <listitem><para>No timestamp or sequence number information is
135 attached to the passed message. This error is returned if the
136 underlying transport does not support timestamping or
137 assigning of sequence numbers, or if this feature has not been
139 <citerefentry><refentrytitle>sd_bus_negotiate_timestamp
</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
</para></listitem>
148 <function>sd_bus_message_get_monotonic_usec()
</function>,
149 <function>sd_bus_message_get_realtime_usec()
</function>, and
150 <function>sd_bus_message_get_seqnum()
</function> interfaces are
151 available as a shared library, which can be compiled and linked to
153 <constant>libsystemd
</constant> <citerefentry project='die-net'
><refentrytitle>pkg-config
</refentrytitle><manvolnum>1</manvolnum></citerefentry>
158 <title>See Also
</title>
161 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
162 <citerefentry><refentrytitle>sd-bus
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
163 <citerefentry><refentrytitle>sd_bus_new
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
164 <citerefentry><refentrytitle>sd_bus_negotiate_timestamp
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
165 <citerefentry><refentrytitle>clock_gettime
</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
166 <citerefentry><refentrytitle>sd_id128_get_boot
</refentrytitle><manvolnum>3</manvolnum></citerefentry>