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

RETURN VALUE

79       On success, these calls return 0 or a positive integer. On failure,
80       these calls return a negative errno-style error code.
81
82       If SD_BUS_NAME_QUEUE is specified, sd_bus_request_name() will return 0
83       when the name is already taken by another peer and the client has been
84       added to the queue for the name. In that case, the caller can subscribe
85       to "NameOwnerChanged" signals to be notified when the name is
86       successfully acquired.  sd_bus_request_name() returns > 0 when the name
87       has immediately been acquired successfully.
88

ERRORS

90       Returned errors may indicate the following problems:
91
92       -EALREADY
93           The caller already is the owner of the specified name.
94
95       -EEXIST
96           The name has already been acquired by a different peer, and
97           SD_BUS_NAME_REPLACE_EXISTING was not specified or the other peer
98           did not specify SD_BUS_NAME_ALLOW_REPLACEMENT while acquiring the
99           name.
100
101       -ESRCH
102           It was attempted to release a name that is currently not registered
103           on the bus.
104
105       -EADDRINUSE
106           It was attempted to release a name that is owned by a different
107           peer on the bus.
108
109       -EINVAL
110           A specified parameter is invalid. This is also generated when the
111           requested name is a special service name reserved by the D-Bus
112           specification, or when the operation is requested on a connection
113           that does not refer to a bus.
114
115       -ENOTCONN
116           The bus connection has been disconnected.
117
118       -ECHILD
119           The bus connection has been created in a different process than the
120           current one.
121

NOTES

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

SEE ALSO

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