1SD_BUS_REQUEST_NAME(3)        sd_bus_request_name       SD_BUS_REQUEST_NAME(3)
2
3
4

NAME

6       sd_bus_request_name, sd_bus_request_name_async, sd_bus_release_name,
7       sd_bus_release_name_async - Request or release a well-known service
8       name on a bus
9

SYNOPSIS

11       #include <systemd/sd-bus.h>
12
13       int sd_bus_request_name(sd_bus *bus, const char *name, uint64_t flags);
14
15       int sd_bus_request_name_async(sd_bus *bus, sd_bus_slot **slot,
16                                     const char *name, uint64_t flags,
17                                     sd_bus_message_handler_t callback,
18                                     void *userdata);
19
20       int sd_bus_release_name(sd_bus *bus, const char *name);
21
22       int sd_bus_release_name_async(sd_bus *bus, sd_bus_slot **slot,
23                                     const char *name,
24                                     sd_bus_message_handler_t callback,
25                                     void *userdata);
26

DESCRIPTION

28       sd_bus_request_name() requests a well-known service name on a bus. It
29       takes a bus connection, a valid bus name, and a flags parameter. The
30       flags parameter is a combination of zero or more of the following
31       flags:
32
33       SD_BUS_NAME_ALLOW_REPLACEMENT
34           After acquiring the name successfully, permit other peers to take
35           over the name when they try to acquire it with the
36           SD_BUS_NAME_REPLACE_EXISTING flag set. If
37           SD_BUS_NAME_ALLOW_REPLACEMENT is not set on the original request,
38           such a request by other peers will be denied.
39
40       SD_BUS_NAME_REPLACE_EXISTING
41           Take over the name if it was already acquired by another peer, and
42           that other peer has permitted takeover by setting
43           SD_BUS_NAME_ALLOW_REPLACEMENT while acquiring it.
44
45       SD_BUS_NAME_QUEUE
46           Queue the acquisition of the name when the name is already taken.
47
48       sd_bus_request_name() operates in a synchronous fashion: a message
49       requesting the name is sent to the bus broker, and the call waits until
50       the broker responds.
51
52       sd_bus_request_name_async() is an asynchronous version of
53       sd_bus_release_name(). Instead of waiting for the request to complete,
54       the request message is enqueued. The specified callback will be called
55       when the broker's response is received. If the parameter is specified
56       as NULL a default implementation is used instead which will terminate
57       the connection when the name cannot be acquired. The function returns a
58       slot object in its slot parameter — if it is passed as non-NULL — which
59       may be used as a reference to the name request operation. Use
60       sd_bus_slot_unref(3) to destroy this reference. Note that destroying
61       the reference will not unregister the name, but simply ensure the
62       specified callback is no longer called.
63
64       sd_bus_release_name() releases an acquired well-known name. It takes a
65       bus connection and a valid bus name as parameters. This function
66       operates synchronously, sending a release request message to the bus
67       broker and waiting for it to reply.
68
69       sd_bus_release_name_async() is an asynchronous version of
70       sd_bus_release_name(). The specified callback function is called when
71       the name has been released successfully. If specified as NULL a generic
72       implementation is used that ignores the result of the operation. As
73       above, the slot (if non-NULL) is set to an object that may be used to
74       reference the operation.
75
76       These functions are supported only on bus connections, i.e. connections
77       to a bus broker and not on direct connections.
78

RETURN VALUE

80       On success, these calls return 0 or a positive integer. On failure,
81       these calls return a negative errno-style error code.
82
83       If SD_BUS_NAME_QUEUE is specified, sd_bus_request_name() will return 0
84       when the name is already taken by another peer and the client has been
85       added to the queue for the name. In that case, the caller can subscribe
86       to "NameOwnerChanged" signals to be notified when the name is
87       successfully acquired.  sd_bus_request_name() returns > 0 when the name
88       has immediately been acquired successfully.
89
90   Errors
91       Returned errors may indicate the following problems:
92
93       -EALREADY
94           The caller already is the owner of the specified name.
95
96       -EEXIST
97           The name has already been acquired by a different peer, and
98           SD_BUS_NAME_REPLACE_EXISTING was not specified or the other peer
99           did not specify SD_BUS_NAME_ALLOW_REPLACEMENT while acquiring the
100           name.
101
102       -ESRCH
103           It was attempted to release a name that is currently not registered
104           on the bus.
105
106       -EADDRINUSE
107           It was attempted to release a name that is owned by a different
108           peer on the bus.
109
110       -EINVAL
111           A specified parameter is invalid. This is also generated when the
112           requested name is a special service name reserved by the D-Bus
113           specification, or when the operation is requested on a connection
114           that does not refer to a bus.
115
116       -ENOTCONN
117           The bus connection has been disconnected.
118
119       -ECHILD
120           The bus connection has been created in a different process than the
121           current one.
122

NOTES

124       These APIs are implemented as a shared library, which can be compiled
125       and linked to with the libsystemd pkg-config(1) file.
126

SEE ALSO

128       systemd(1), sd-bus(3), sd_bus_new(3), sd_bus_slot_unref(3)
129
130
131
132systemd 245                                             SD_BUS_REQUEST_NAME(3)
Impressum