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       typedef int (*sd_bus_message_handler_t)(sd_bus_message *m,
14                                               void *userdata,
15                                               sd_bus_error *ret_error);
16
17       int sd_bus_request_name(sd_bus *bus, const char *name, uint64_t flags);
18
19       int sd_bus_request_name_async(sd_bus *bus, sd_bus_slot **slot,
20                                     const char *name, uint64_t flags,
21                                     sd_bus_message_handler_t callback,
22                                     void *userdata);
23
24       int sd_bus_release_name(sd_bus *bus, const char *name);
25
26       int sd_bus_release_name_async(sd_bus *bus, sd_bus_slot **slot,
27                                     const char *name,
28                                     sd_bus_message_handler_t callback,
29                                     void *userdata);
30

DESCRIPTION

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

RETURN VALUE

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

NOTES

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

SEE ALSO

132       systemd(1), sd-bus(3), sd_bus_new(3), sd_bus_slot_unref(3)
133
134
135
136systemd 253                                             SD_BUS_REQUEST_NAME(3)
Impressum