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" [
4 <!ENTITY % entities SYSTEM
"custom-entities.ent" >
9 This file is part of systemd.
11 Copyright 2013 Lennart Poettering
13 systemd is free software; you can redistribute it and/or modify it
14 under the terms of the GNU Lesser General Public License as published by
15 the Free Software Foundation; either version 2.1 of the License, or
16 (at your option) any later version.
18 systemd is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 Lesser General Public License for more details.
23 You should have received a copy of the GNU Lesser General Public License
24 along with systemd; If not, see <http://www.gnu.org/licenses/>.
27 <refentry id=
"sd_bus_message_get_monotonic_usec">
30 <title>sd_bus_message_get_monotonic_usec
</title>
31 <productname>systemd
</productname>
35 <contrib>Developer
</contrib>
36 <firstname>Lennart
</firstname>
37 <surname>Poettering
</surname>
38 <email>lennart@poettering.net
</email>
44 <refentrytitle>sd_bus_message_get_monotonic_usec
</refentrytitle>
45 <manvolnum>3</manvolnum>
49 <refname>sd_bus_message_get_monotonic_usec
</refname>
50 <refname>sd_bus_message_get_realtime_usec
</refname>
51 <refname>sd_bus_message_get_seqnum
</refname>
52 <refpurpose>Retrieve the sender timestamps and sequence number of a message
</refpurpose>
57 <funcsynopsisinfo>#include
<systemd/sd-bus.h
></funcsynopsisinfo>
60 <funcdef>int
<function>sd_bus_message_get_monotonic_usec
</function></funcdef>
61 <paramdef>sd_bus_message *
<parameter>message
</parameter></paramdef>
62 <paramdef>uint64_t *
<parameter>usec
</parameter></paramdef>
66 <funcdef>int
<function>sd_bus_message_get_realtime_usec
</function></funcdef>
67 <paramdef>sd_bus_message *
<parameter>message
</parameter></paramdef>
68 <paramdef>uint64_t *
<parameter>usec
</parameter></paramdef>
72 <funcdef>int
<function>sd_bus_message_get_seqnum
</function></funcdef>
73 <paramdef>sd_bus_message *
<parameter>message
</parameter></paramdef>
74 <paramdef>uint64_t *
<parameter>seqnum
</parameter></paramdef>
80 <title>Description
</title>
82 <para><function>sd_bus_message_get_monotonic_usec()
</function>
83 returns the monotonic timestamp of the time the message was sent.
84 This value is in microseconds since the
85 <constant>CLOCK_MONOTONIC
</constant> epoch, see
86 <citerefentry><refentrytitle>clock_gettime
</refentrytitle><manvolnum>2</manvolnum></citerefentry>
90 <function>sd_bus_message_get_realtime_usec()
</function> returns
91 the realtime (wallclock) timestamp of the time the message was
92 sent. This value is in microseconds since Jan
1st,
1970, i.e. in
93 the
<constant>CLOCK_REALTIME
</constant> clock.
</para>
95 <para><function>sd_bus_message_get_seqnum()
</function> returns the
96 kernel-assigned sequence number of the message. The kernel assigns
97 a global, monotonically increasing sequence number to all messages
98 transmitted on the local system, at the time the message was sent.
99 This sequence number is useful for determining message send order,
100 even across different buses of the local system. The sequence
101 number combined with the boot ID of the system (as returned by
102 <citerefentry><refentrytitle>sd_id128_get_boot
</refentrytitle><manvolnum>3</manvolnum></citerefentry>)
103 is a suitable globally unique identifier for bus messages.
</para>
105 <para>Note that the sending order and receiving order of messages
106 might differ, in particular for broadcast messages. This means
107 that the sequence number and the timestamps of messages a client
108 reads are not necessarily monotonically increasing.
</para>
110 <para>These timestamps and the sequence number are attached to
111 each message by the kernel and cannot be manipulated by the
114 <para>Note that these timestamps are only available on some bus
115 transports, and only after support for them has been negotiated
117 <citerefentry><refentrytitle>sd_bus_negotiate_timestamp
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
122 <title>Return Value
</title>
124 <para>On success, these calls return
0 or a positive integer. On
125 failure, these calls return a negative errno-style error
128 <para>On success, the timestamp or sequence number is returned in
129 the specified
64-bit unsigned integer variable.
</para>
133 <title>Errors
</title>
135 <para>Returned errors may indicate the following problems:
</para>
139 <term><constant>-EINVAL
</constant></term>
141 <listitem><para>A specified parameter is
142 invalid.
</para></listitem>
146 <term><constant>-ENODATA
</constant></term>
148 <listitem><para>No timestamp or sequence number information is
149 attached to the passed message. This error is returned if the
150 underlying transport does not support timestamping or
151 assigning of sequence numbers, or if this feature has not been
153 <citerefentry><refentrytitle>sd_bus_negotiate_timestamp
</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
</para></listitem>
162 <function>sd_bus_message_get_monotonic_usec()
</function>,
163 <function>sd_bus_message_get_realtime_usec()
</function>, and
164 <function>sd_bus_message_get_seqnum()
</function> interfaces are
165 available as a shared library, which can be compiled and linked to
167 <constant>libsystemd
</constant> <citerefentry project='die-net'
><refentrytitle>pkg-config
</refentrytitle><manvolnum>1</manvolnum></citerefentry>
172 <title>See Also
</title>
175 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
176 <citerefentry><refentrytitle>sd-bus
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
177 <citerefentry><refentrytitle>sd_bus_new
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
178 <citerefentry><refentrytitle>sd_bus_negotiate_timestamp
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
179 <citerefentry><refentrytitle>clock_gettime
</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
180 <citerefentry><refentrytitle>sd_id128_get_boot
</refentrytitle><manvolnum>3</manvolnum></citerefentry>