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+ -->
6 <refentry id=
"sd_bus_message_get_type" xmlns:
xi=
"http://www.w3.org/2001/XInclude">
9 <title>sd_bus_message_get_type
</title>
10 <productname>systemd
</productname>
14 <refentrytitle>sd_bus_message_get_type
</refentrytitle>
15 <manvolnum>3</manvolnum>
19 <refname>sd_bus_message_get_type
</refname>
20 <refname>sd_bus_message_get_error
</refname>
21 <refname>sd_bus_message_get_errno
</refname>
22 <refname>sd_bus_message_get_creds
</refname>
23 <refname>sd_bus_message_is_signal
</refname>
24 <refname>sd_bus_message_is_method_call
</refname>
25 <refname>sd_bus_message_is_method_error
</refname>
27 <refpurpose>Query bus message addressing/credentials metadata
</refpurpose>
32 <funcsynopsisinfo>#include
<systemd/sd-bus.h
></funcsynopsisinfo>
35 <funcdef>int
<function>sd_bus_message_get_type
</function></funcdef>
36 <paramdef>sd_bus_message *
<parameter>m
</parameter></paramdef>
37 <paramdef>uint8_t *
<parameter>type
</parameter></paramdef>
41 <funcdef>sd_bus_error*
<function>sd_bus_message_get_error
</function></funcdef>
42 <paramdef>sd_bus_message *
<parameter>m
</parameter></paramdef>
46 <funcdef>int
<function>sd_bus_message_get_errno
</function></funcdef>
47 <paramdef>sd_bus_message *
<parameter>m
</parameter></paramdef>
51 <funcdef>sd_bus_creds*
<function>sd_bus_message_get_creds
</function></funcdef>
52 <paramdef>sd_bus_message *
<parameter>m
</parameter></paramdef>
56 <funcdef>int
<function>sd_bus_message_is_signal
</function></funcdef>
57 <paramdef>sd_bus_message *
<parameter>m
</parameter></paramdef>
58 <paramdef>const char *
<parameter>interface
</parameter></paramdef>
59 <paramdef>const char *
<parameter>member
</parameter></paramdef>
63 <funcdef>int
<function>sd_bus_message_is_method_call
</function></funcdef>
64 <paramdef>sd_bus_message *
<parameter>m
</parameter></paramdef>
65 <paramdef>const char *
<parameter>interface
</parameter></paramdef>
66 <paramdef>const char *
<parameter>member
</parameter></paramdef>
70 <funcdef>int
<function>sd_bus_message_is_method_error
</function></funcdef>
71 <paramdef>sd_bus_message *
<parameter>m
</parameter></paramdef>
72 <paramdef>const char *
<parameter>name
</parameter></paramdef>
79 <title>Description
</title>
81 <para><function>sd_bus_message_get_type()
</function> returns the type of a message in the output
82 parameter
<parameter>type
</parameter>, one of
<constant>SD_BUS_MESSAGE_METHOD_CALL
</constant>,
83 <constant>SD_BUS_MESSAGE_METHOD_RETURN
</constant>,
<constant>SD_BUS_MESSAGE_METHOD_ERROR
</constant>,
84 <constant>SD_BUS_MESSAGE_SIGNAL
</constant>. This type is either specified as a parameter when the message
86 <citerefentry><refentrytitle>sd_bus_message_new
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
87 or is set automatically when the message is created using
88 <citerefentry><refentrytitle>sd_bus_message_new_signal
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
89 <citerefentry><refentrytitle>sd_bus_message_new_method_call
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
90 <citerefentry><refentrytitle>sd_bus_message_new_method_error
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
91 and similar functions.
</para>
93 <para><function>sd_bus_message_get_error()
</function> returns the error stored in the message
94 <parameter>m
</parameter>, if there is any. Otherwise, it returns
<constant>NULL
</constant>.
95 <function>sd_bus_message_get_errno()
</function> returns the error stored in the message
96 <parameter>m
</parameter> as a positive errno-style value, if there is any. Otherwise, it returns zero.
97 Errors are mapped to errno values according to the default and any additional registered error mappings.
98 See
<citerefentry><refentrytitle>sd-bus-errors
</refentrytitle><manvolnum>3</manvolnum></citerefentry> and
99 <citerefentry><refentrytitle>sd_bus_error_add_map
</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
102 <para><function>sd_bus_message_get_creds()
</function> returns the message credentials attached to the
103 message
<parameter>m
</parameter>. If no credentials are attached to the message, it returns
104 <constant>NULL
</constant>. Ownership of the credentials instance is not transferred to the caller and
105 hence should not be freed.
</para>
107 <para><function>sd_bus_message_is_signal()
</function> checks if message
<parameter>m
</parameter> is a
108 signal message. If
<parameter>interface
</parameter> is non-null, it also checks if the message has the
109 same interface set. If
<parameter>member
</parameter> is non-null, it also checks if the message has the
110 same member set. Also see
111 <citerefentry><refentrytitle>sd_bus_message_new_signal
</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
112 It returns true when all checks pass.
</para>
114 <para><function>sd_bus_message_is_method_call()
</function> checks if message
<parameter>m
</parameter>
115 is a method call message. If
<parameter>interface
</parameter> is non-null, it also checks if the message
116 has the same interface set. If
<parameter>member
</parameter> is non-null, it also checks if the message
117 has the same member set. Also see
118 <citerefentry><refentrytitle>sd_bus_message_new_method_call
</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
119 It returns true when all checks pass.
</para>
121 <para><function>sd_bus_message_is_method_error()
</function> checks if message
<parameter>m
</parameter>
122 is an error reply message. If
<parameter>name
</parameter> is non-null, it also checks if the message has
123 the same error identifier set. Also see
124 <citerefentry><refentrytitle>sd_bus_message_new_method_error
</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
125 It returns true when all checks pass.
</para>
129 <title>Return Value
</title>
131 <para>On success, these functions (except
<function>sd_bus_message_get_error()
</function> and
132 <function>sd_bus_message_get_creds()
</function>) return a non-negative integer. On failure, they return a
133 negative errno-style error code.
<function>sd_bus_message_get_errno()
</function> always returns a
134 non-negative integer, even on failure.
</para>
137 <title>Errors
</title>
139 <para>Returned errors may indicate the following problems:
</para>
143 <term><constant>-EINVAL
</constant></term>
145 <listitem><para>The message parameter
<parameter>m
</parameter> or an output parameter is
146 <constant>NULL
</constant>.
</para></listitem>
152 <xi:include href=
"libsystemd-pkgconfig.xml" />
155 <title>See Also
</title>
158 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
159 <citerefentry><refentrytitle>sd-bus
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
160 <citerefentry><refentrytitle>sd_bus_message_new
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
161 <citerefentry><refentrytitle>sd_bus_message_set_destination
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
162 <citerefentry><refentrytitle>sd-bus-errors
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
163 <citerefentry><refentrytitle>sd_bus_error_add_map
</refentrytitle><manvolnum>3</manvolnum></citerefentry>