2020-04-20 03:33:14 +08:00
|
|
|
<?xml version='1.0'?>
|
|
|
|
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
2023-12-25 22:48:33 +08:00
|
|
|
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
|
2020-11-09 12:23:58 +08:00
|
|
|
<!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
|
2020-04-20 03:33:14 +08:00
|
|
|
|
|
|
|
<refentry id="sd_bus_set_server"
|
|
|
|
xmlns:xi="http://www.w3.org/2001/XInclude">
|
|
|
|
|
|
|
|
<refentryinfo>
|
|
|
|
<title>sd_bus_set_server</title>
|
|
|
|
<productname>systemd</productname>
|
|
|
|
</refentryinfo>
|
|
|
|
|
|
|
|
<refmeta>
|
|
|
|
<refentrytitle>sd_bus_set_server</refentrytitle>
|
|
|
|
<manvolnum>3</manvolnum>
|
|
|
|
</refmeta>
|
|
|
|
|
|
|
|
<refnamediv>
|
|
|
|
<refname>sd_bus_set_server</refname>
|
2020-04-21 00:38:38 +08:00
|
|
|
<refname>sd_bus_is_server</refname>
|
2020-04-20 03:33:14 +08:00
|
|
|
<refname>sd_bus_get_bus_id</refname>
|
2020-04-21 00:38:38 +08:00
|
|
|
<refname>sd_bus_set_bus_client</refname>
|
|
|
|
<refname>sd_bus_is_bus_client</refname>
|
2020-04-22 01:33:25 +08:00
|
|
|
<refname>sd_bus_set_monitor</refname>
|
|
|
|
<refname>sd_bus_is_monitor</refname>
|
2020-04-20 03:33:14 +08:00
|
|
|
|
2020-04-22 01:33:25 +08:00
|
|
|
<refpurpose>Configure connection mode for a bus object</refpurpose>
|
2020-04-20 03:33:14 +08:00
|
|
|
</refnamediv>
|
|
|
|
|
|
|
|
<refsynopsisdiv>
|
|
|
|
<funcsynopsis>
|
|
|
|
<funcsynopsisinfo>#include <systemd/sd-bus.h></funcsynopsisinfo>
|
|
|
|
|
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>sd_bus_set_server</function></funcdef>
|
|
|
|
<paramdef>sd_bus *<parameter>bus</parameter></paramdef>
|
|
|
|
<paramdef>int <parameter>b</parameter></paramdef>
|
|
|
|
<paramdef>sd_id128_t <parameter>id</parameter></paramdef>
|
|
|
|
</funcprototype>
|
|
|
|
|
2020-04-21 00:38:38 +08:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>sd_bus_is_server</function></funcdef>
|
|
|
|
<paramdef>sd_bus *<parameter>bus</parameter></paramdef>
|
|
|
|
</funcprototype>
|
|
|
|
|
2020-04-20 03:33:14 +08:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>sd_bus_get_bus_id</function></funcdef>
|
|
|
|
<paramdef>sd_bus *<parameter>bus</parameter></paramdef>
|
|
|
|
<paramdef>sd_id128_t *<parameter>id</parameter></paramdef>
|
|
|
|
</funcprototype>
|
2020-04-21 00:38:38 +08:00
|
|
|
|
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>sd_bus_set_bus_client</function></funcdef>
|
|
|
|
<paramdef>sd_bus *<parameter>bus</parameter></paramdef>
|
|
|
|
<paramdef>int <parameter>b</parameter></paramdef>
|
|
|
|
</funcprototype>
|
|
|
|
|
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>sd_bus_is_bus_client</function></funcdef>
|
|
|
|
<paramdef>sd_bus *<parameter>bus</parameter></paramdef>
|
|
|
|
</funcprototype>
|
2020-04-22 01:33:25 +08:00
|
|
|
|
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>sd_bus_set_monitor</function></funcdef>
|
|
|
|
<paramdef>sd_bus *<parameter>bus</parameter></paramdef>
|
|
|
|
<paramdef>int <parameter>b</parameter></paramdef>
|
|
|
|
</funcprototype>
|
|
|
|
|
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>sd_bus_is_monitor</function></funcdef>
|
|
|
|
<paramdef>sd_bus *<parameter>bus</parameter></paramdef>
|
|
|
|
</funcprototype>
|
2020-04-20 03:33:14 +08:00
|
|
|
</funcsynopsis>
|
|
|
|
</refsynopsisdiv>
|
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
|
2020-04-22 01:08:25 +08:00
|
|
|
<para><function>sd_bus_set_server()</function> configures the bus object as a server for direct D-Bus
|
|
|
|
connections. <parameter>b</parameter> enables/disables the server mode. If zero, the server mode is
|
|
|
|
disabled. Otherwise, the server mode is enabled. Configuring a bus object as a server is required to
|
|
|
|
allow establishing direct connections between two peers without going via the D-Bus daemon.
|
|
|
|
<parameter>id</parameter> must contain a 128-bit integer id for the server. If clients add a guid field
|
|
|
|
to their D-Bus address string, the server id must match this guid or the D-Bus authentication handshake
|
|
|
|
will fail. If no specific id is defined for the server,
|
2020-04-20 03:33:14 +08:00
|
|
|
<citerefentry><refentrytitle>sd_id128_randomize</refentrytitle><manvolnum>3</manvolnum></citerefentry>
|
|
|
|
can be used to generate a random id instead.</para>
|
|
|
|
|
2020-04-22 01:08:25 +08:00
|
|
|
<para><function>sd_bus_is_server()</function> returns whether the server mode is enabled for the given
|
|
|
|
bus object.</para>
|
2020-04-21 00:38:38 +08:00
|
|
|
|
2020-04-20 03:33:14 +08:00
|
|
|
<para><function>sd_bus_get_bus_id()</function> stores the D-Bus server id configured using
|
2020-04-22 01:08:25 +08:00
|
|
|
<function>sd_bus_set_server()</function> (for server bus objects) or received during D-Bus authentication
|
|
|
|
(for client bus objects) in <parameter>id</parameter>.</para>
|
|
|
|
|
|
|
|
<para><function>sd_bus_set_bus_client()</function> configures the bus object as a D-Bus daemon client.
|
|
|
|
<parameter>b</parameter> enables/disables the client mode. If zero, the client mode is disabled and the
|
|
|
|
bus object should connect directly to a D-Bus server. Otherwise, the client mode is enabled and the bus
|
|
|
|
object should connect to a D-Bus daemon. When connecting to an existing bus using any of the functions in
|
|
|
|
the <citerefentry><refentrytitle>sd_bus_open</refentrytitle><manvolnum>3</manvolnum></citerefentry>
|
2020-04-21 00:38:38 +08:00
|
|
|
family of functions or any of the functions in the
|
2020-04-22 01:08:25 +08:00
|
|
|
<citerefentry><refentrytitle>sd_bus_default</refentrytitle><manvolnum>3</manvolnum></citerefentry> family
|
|
|
|
of functions, the bus object is automatically configured as a bus client. However, when connecting to a
|
|
|
|
D-Bus daemon by calling
|
2020-04-21 00:38:38 +08:00
|
|
|
<citerefentry><refentrytitle>sd_bus_set_address</refentrytitle><manvolnum>3</manvolnum></citerefentry>
|
|
|
|
followed by
|
2020-04-22 01:08:25 +08:00
|
|
|
<citerefentry><refentrytitle>sd_bus_start</refentrytitle><manvolnum>3</manvolnum></citerefentry>, the bus
|
|
|
|
object should be manually configured as a bus client using <function>sd_bus_set_bus_client()</function>.
|
|
|
|
By default, a bus object is not configured as a D-Bus daemon client.</para>
|
2020-04-21 00:38:38 +08:00
|
|
|
|
2020-04-22 01:08:25 +08:00
|
|
|
<para><function>sd_bus_is_bus_client()</function> returns whether the client mode is enabled/disabled for
|
|
|
|
the given bus object.</para>
|
2020-04-22 01:33:25 +08:00
|
|
|
|
|
|
|
<para><function>sd_bus_set_monitor()</function> configures the bus object as a D-Bus monitor object.
|
|
|
|
<parameter>b</parameter> enables/disables the monitor mode. If zero, the monitor mode is disabled. If
|
|
|
|
non-zero, the monitor mode is enabled. When the monitor mode is enabled, no messages may be sent via the
|
|
|
|
bus object and it may not expose any objects on the bus. To start monitoring messages, call the
|
|
|
|
<function>org.freedesktop.DBus.Monitoring.BecomeMonitor</function> method of the D-Bus daemon and pass
|
|
|
|
a list of matches indicating which messages to intercept. See
|
|
|
|
<ulink url="https://dbus.freedesktop.org/doc/dbus-specification.html#bus-messages-become-monitor">
|
|
|
|
The D-Bus specification</ulink> for more information.</para>
|
|
|
|
|
|
|
|
<para><function>sd_bus_is_monitor()</function> returns whether the monitor mode is enabled/disabled for
|
|
|
|
the given bus object.</para>
|
|
|
|
|
2020-04-20 03:33:14 +08:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
<title>Return Value</title>
|
|
|
|
|
2020-04-21 00:38:38 +08:00
|
|
|
<para>On success, <function>sd_bus_set_server()</function>,
|
2020-04-22 01:33:25 +08:00
|
|
|
<function>sd_bus_get_bus_id()</function>, <function>sd_bus_set_bus_client()</function> and
|
|
|
|
<function>sd_bus_set_monitor()</function> return a non-negative integer. On failure, they return a
|
|
|
|
negative errno-style error code.</para>
|
2020-04-21 00:38:38 +08:00
|
|
|
|
2020-04-22 01:33:25 +08:00
|
|
|
<para><function>sd_bus_is_server()</function>, <function>sd_bus_is_bus_client()</function> and
|
|
|
|
<function>sd_bus_is_monitor()</function> return a positive integer when the server or client mode is
|
|
|
|
enabled, respectively. Otherwise, they return zero.</para>
|
2020-04-20 03:33:14 +08:00
|
|
|
|
|
|
|
<refsect2>
|
|
|
|
<title>Errors</title>
|
|
|
|
|
|
|
|
<para>Returned errors may indicate the following problems:</para>
|
|
|
|
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
|
|
|
<term><constant>-ECHILD</constant></term>
|
|
|
|
|
2023-08-23 00:52:36 +08:00
|
|
|
<listitem><para>The bus connection has been created in a different process, library or module instance.</para>
|
|
|
|
|
|
|
|
<xi:include href="version-info.xml" xpointer="v246"/></listitem>
|
2020-04-20 03:33:14 +08:00
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><constant>-EPERM</constant></term>
|
|
|
|
|
2023-08-23 00:52:36 +08:00
|
|
|
<listitem><para>The bus connection has already been started.</para>
|
|
|
|
|
|
|
|
<xi:include href="version-info.xml" xpointer="v246"/></listitem>
|
2020-04-20 03:33:14 +08:00
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><constant>-ENOPKG</constant></term>
|
|
|
|
|
2023-08-23 00:52:36 +08:00
|
|
|
<listitem><para>The bus cannot be resolved.</para>
|
|
|
|
|
|
|
|
<xi:include href="version-info.xml" xpointer="v246"/></listitem>
|
2020-04-20 03:33:14 +08:00
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><constant>-EINVAL</constant></term>
|
|
|
|
|
|
|
|
<listitem><para>A required parameter was <constant>NULL</constant> or
|
|
|
|
<parameter>b</parameter> was zero and <parameter>id</parameter> did not equal
|
2023-08-23 00:52:36 +08:00
|
|
|
<constant>SD_ID128_NULL</constant>.</para>
|
|
|
|
|
|
|
|
<xi:include href="version-info.xml" xpointer="v246"/></listitem>
|
2020-04-20 03:33:14 +08:00
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><constant>-ENOTCONN</constant></term>
|
|
|
|
|
2023-08-23 00:52:36 +08:00
|
|
|
<listitem><para>The bus is not connected.</para>
|
|
|
|
|
|
|
|
<xi:include href="version-info.xml" xpointer="v246"/></listitem>
|
2020-04-20 03:33:14 +08:00
|
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
|
|
|
</refsect2>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<xi:include href="libsystemd-pkgconfig.xml" />
|
|
|
|
|
2023-09-04 20:46:35 +08:00
|
|
|
<refsect1>
|
|
|
|
<title>History</title>
|
2023-09-19 00:44:26 +08:00
|
|
|
<para><function>sd_bus_set_server()</function>,
|
|
|
|
<function>sd_bus_is_server()</function>,
|
|
|
|
<function>sd_bus_get_bus_id()</function>,
|
|
|
|
<function>sd_bus_set_bus_client()</function>,
|
|
|
|
<function>sd_bus_is_bus_client()</function>,
|
|
|
|
<function>sd_bus_set_monitor()</function>, and
|
|
|
|
<function>sd_bus_is_monitor()</function> were added in version 246.</para>
|
2023-09-04 20:46:35 +08:00
|
|
|
</refsect1>
|
|
|
|
|
2020-04-20 03:33:14 +08:00
|
|
|
<refsect1>
|
|
|
|
<title>See Also</title>
|
|
|
|
|
2023-12-23 02:09:32 +08:00
|
|
|
<para><simplelist type="inline">
|
|
|
|
<member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
|
|
|
|
<member><citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
|
|
|
|
</simplelist></para>
|
2020-04-20 03:33:14 +08:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
</refentry>
|