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 Copyright 2013 Lennart Poettering
11 <refentry id=
"sd_bus_message_get_monotonic_usec"
12 xmlns:
xi=
"http://www.w3.org/2001/XInclude">
15 <title>sd_bus_message_get_monotonic_usec
</title>
16 <productname>systemd
</productname>
20 <contrib>Developer
</contrib>
21 <firstname>Lennart
</firstname>
22 <surname>Poettering
</surname>
23 <email>lennart@poettering.net
</email>
29 <refentrytitle>sd_bus_message_get_monotonic_usec
</refentrytitle>
30 <manvolnum>3</manvolnum>
34 <refname>sd_bus_message_get_monotonic_usec
</refname>
35 <refname>sd_bus_message_get_realtime_usec
</refname>
36 <refname>sd_bus_message_get_seqnum
</refname>
37 <refpurpose>Retrieve the sender timestamps and sequence number of a message
</refpurpose>
42 <funcsynopsisinfo>#include
<systemd/sd-bus.h
></funcsynopsisinfo>
45 <funcdef>int
<function>sd_bus_message_get_monotonic_usec
</function></funcdef>
46 <paramdef>sd_bus_message *
<parameter>message
</parameter></paramdef>
47 <paramdef>uint64_t *
<parameter>usec
</parameter></paramdef>
51 <funcdef>int
<function>sd_bus_message_get_realtime_usec
</function></funcdef>
52 <paramdef>sd_bus_message *
<parameter>message
</parameter></paramdef>
53 <paramdef>uint64_t *
<parameter>usec
</parameter></paramdef>
57 <funcdef>int
<function>sd_bus_message_get_seqnum
</function></funcdef>
58 <paramdef>sd_bus_message *
<parameter>message
</parameter></paramdef>
59 <paramdef>uint64_t *
<parameter>seqnum
</parameter></paramdef>
65 <title>Description
</title>
67 <para><function>sd_bus_message_get_monotonic_usec()
</function>
68 returns the monotonic timestamp of the time the message was sent.
69 This value is in microseconds since the
70 <constant>CLOCK_MONOTONIC
</constant> epoch, see
71 <citerefentry><refentrytitle>clock_gettime
</refentrytitle><manvolnum>2</manvolnum></citerefentry>
75 <function>sd_bus_message_get_realtime_usec()
</function> returns
76 the realtime (wallclock) timestamp of the time the message was
77 sent. This value is in microseconds since Jan
1st,
1970, i.e. in
78 the
<constant>CLOCK_REALTIME
</constant> clock.
</para>
80 <para><function>sd_bus_message_get_seqnum()
</function> returns the
81 kernel-assigned sequence number of the message. The kernel assigns
82 a global, monotonically increasing sequence number to all messages
83 transmitted on the local system, at the time the message was sent.
84 This sequence number is useful for determining message send order,
85 even across different buses of the local system. The sequence
86 number combined with the boot ID of the system (as returned by
87 <citerefentry><refentrytitle>sd_id128_get_boot
</refentrytitle><manvolnum>3</manvolnum></citerefentry>)
88 is a suitable globally unique identifier for bus messages.
</para>
90 <para>Note that the sending order and receiving order of messages
91 might differ, in particular for broadcast messages. This means
92 that the sequence number and the timestamps of messages a client
93 reads are not necessarily monotonically increasing.
</para>
95 <para>These timestamps and the sequence number are attached to
96 each message by the kernel and cannot be manipulated by the
99 <para>Note that these timestamps are only available on some bus
100 transports, and only after support for them has been negotiated
102 <citerefentry><refentrytitle>sd_bus_negotiate_timestamp
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
107 <title>Return Value
</title>
109 <para>On success, these calls return
0 or a positive integer. On
110 failure, these calls return a negative errno-style error
113 <para>On success, the timestamp or sequence number is returned in
114 the specified
64-bit unsigned integer variable.
</para>
118 <title>Errors
</title>
120 <para>Returned errors may indicate the following problems:
</para>
124 <term><constant>-EINVAL
</constant></term>
126 <listitem><para>A specified parameter is
127 invalid.
</para></listitem>
131 <term><constant>-ENODATA
</constant></term>
133 <listitem><para>No timestamp or sequence number information is
134 attached to the passed message. This error is returned if the
135 underlying transport does not support timestamping or
136 assigning of sequence numbers, or if this feature has not been
138 <citerefentry><refentrytitle>sd_bus_negotiate_timestamp
</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
</para></listitem>
143 <xi:include href=
"libsystemd-pkgconfig.xml" />
146 <title>See Also
</title>
149 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
150 <citerefentry><refentrytitle>sd-bus
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
151 <citerefentry><refentrytitle>sd_bus_new
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
152 <citerefentry><refentrytitle>sd_bus_negotiate_timestamp
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
153 <citerefentry><refentrytitle>clock_gettime
</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
154 <citerefentry><refentrytitle>sd_id128_get_boot
</refentrytitle><manvolnum>3</manvolnum></citerefentry>