1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
6 systemd is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
11 systemd is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with systemd; If not, see <https://www.gnu.org/licenses/>.
23 #include <sys/types.h>
29 #include "_sd-common.h"
31 _SD_BEGIN_DECLARATIONS
;
33 #define SD_BUS_DEFAULT ((sd_bus *) 1)
34 #define SD_BUS_DEFAULT_USER ((sd_bus *) 2)
35 #define SD_BUS_DEFAULT_SYSTEM ((sd_bus *) 3)
39 typedef struct sd_bus sd_bus
;
40 typedef struct sd_bus_message sd_bus_message
;
41 typedef struct sd_bus_slot sd_bus_slot
;
42 typedef struct sd_bus_creds sd_bus_creds
;
43 typedef struct sd_bus_track sd_bus_track
;
59 SD_BUS_CREDS_PID
= 1ULL << 0,
60 SD_BUS_CREDS_TID
= 1ULL << 1,
61 SD_BUS_CREDS_PPID
= 1ULL << 2,
62 SD_BUS_CREDS_UID
= 1ULL << 3,
63 SD_BUS_CREDS_EUID
= 1ULL << 4,
64 SD_BUS_CREDS_SUID
= 1ULL << 5,
65 SD_BUS_CREDS_FSUID
= 1ULL << 6,
66 SD_BUS_CREDS_GID
= 1ULL << 7,
67 SD_BUS_CREDS_EGID
= 1ULL << 8,
68 SD_BUS_CREDS_SGID
= 1ULL << 9,
69 SD_BUS_CREDS_FSGID
= 1ULL << 10,
70 SD_BUS_CREDS_SUPPLEMENTARY_GIDS
= 1ULL << 11,
71 SD_BUS_CREDS_COMM
= 1ULL << 12,
72 SD_BUS_CREDS_TID_COMM
= 1ULL << 13,
73 SD_BUS_CREDS_EXE
= 1ULL << 14,
74 SD_BUS_CREDS_CMDLINE
= 1ULL << 15,
75 SD_BUS_CREDS_CGROUP
= 1ULL << 16,
76 SD_BUS_CREDS_UNIT
= 1ULL << 17,
77 SD_BUS_CREDS_SLICE
= 1ULL << 18,
78 SD_BUS_CREDS_USER_UNIT
= 1ULL << 19,
79 SD_BUS_CREDS_USER_SLICE
= 1ULL << 20,
80 SD_BUS_CREDS_SESSION
= 1ULL << 21,
81 SD_BUS_CREDS_OWNER_UID
= 1ULL << 22,
82 SD_BUS_CREDS_EFFECTIVE_CAPS
= 1ULL << 23,
83 SD_BUS_CREDS_PERMITTED_CAPS
= 1ULL << 24,
84 SD_BUS_CREDS_INHERITABLE_CAPS
= 1ULL << 25,
85 SD_BUS_CREDS_BOUNDING_CAPS
= 1ULL << 26,
86 SD_BUS_CREDS_SELINUX_CONTEXT
= 1ULL << 27,
87 SD_BUS_CREDS_AUDIT_SESSION_ID
= 1ULL << 28,
88 SD_BUS_CREDS_AUDIT_LOGIN_UID
= 1ULL << 29,
89 SD_BUS_CREDS_TTY
= 1ULL << 30,
90 SD_BUS_CREDS_UNIQUE_NAME
= 1ULL << 31,
91 SD_BUS_CREDS_WELL_KNOWN_NAMES
= 1ULL << 32,
92 SD_BUS_CREDS_DESCRIPTION
= 1ULL << 33,
93 SD_BUS_CREDS_AUGMENT
= 1ULL << 63, /* special flag, if on sd-bus will augment creds struct, in a potentially race-full way. */
94 _SD_BUS_CREDS_ALL
= (1ULL << 34) -1
98 SD_BUS_NAME_REPLACE_EXISTING
= 1ULL << 0,
99 SD_BUS_NAME_ALLOW_REPLACEMENT
= 1ULL << 1,
100 SD_BUS_NAME_QUEUE
= 1ULL << 2
104 SD_BUS_MESSAGE_DUMP_WITH_HEADER
= 1ULL << 0,
105 SD_BUS_MESSAGE_DUMP_SUBTREE_ONLY
= 1ULL << 1,
106 _SD_BUS_MESSAGE_DUMP_KNOWN_FLAGS
= SD_BUS_MESSAGE_DUMP_WITH_HEADER
| SD_BUS_MESSAGE_DUMP_SUBTREE_ONLY
111 typedef int (*sd_bus_message_handler_t
)(sd_bus_message
*m
, void *userdata
, sd_bus_error
*ret_error
);
112 typedef int (*sd_bus_property_get_t
) (sd_bus
*bus
, const char *path
, const char *interface
, const char *property
, sd_bus_message
*reply
, void *userdata
, sd_bus_error
*ret_error
);
113 typedef int (*sd_bus_property_set_t
) (sd_bus
*bus
, const char *path
, const char *interface
, const char *property
, sd_bus_message
*value
, void *userdata
, sd_bus_error
*ret_error
);
114 typedef int (*sd_bus_object_find_t
) (sd_bus
*bus
, const char *path
, const char *interface
, void *userdata
, void **ret_found
, sd_bus_error
*ret_error
);
115 typedef int (*sd_bus_node_enumerator_t
) (sd_bus
*bus
, const char *prefix
, void *userdata
, char ***ret_nodes
, sd_bus_error
*ret_error
);
116 typedef int (*sd_bus_track_handler_t
) (sd_bus_track
*track
, void *userdata
);
117 typedef _sd_destroy_t sd_bus_destroy_t
;
119 #include "sd-bus-protocol.h"
120 #include "sd-bus-vtable.h"
124 int sd_bus_interface_name_is_valid(const char *p
);
125 int sd_bus_service_name_is_valid(const char *p
);
126 int sd_bus_member_name_is_valid(const char *p
);
127 int sd_bus_object_path_is_valid(const char *p
);
131 int sd_bus_default(sd_bus
**ret
);
132 int sd_bus_default_user(sd_bus
**ret
);
133 int sd_bus_default_system(sd_bus
**ret
);
135 int sd_bus_open(sd_bus
**ret
);
136 int sd_bus_open_with_description(sd_bus
**ret
, const char *description
);
137 int sd_bus_open_user(sd_bus
**ret
);
138 int sd_bus_open_user_with_description(sd_bus
**ret
, const char *description
);
139 int sd_bus_open_user_machine(sd_bus
**ret
, const char *machine
);
140 int sd_bus_open_system(sd_bus
**ret
);
141 int sd_bus_open_system_with_description(sd_bus
**ret
, const char *description
);
142 int sd_bus_open_system_remote(sd_bus
**ret
, const char *host
);
143 int sd_bus_open_system_machine(sd_bus
**ret
, const char *machine
);
145 int sd_bus_new(sd_bus
**ret
);
147 int sd_bus_set_address(sd_bus
*bus
, const char *address
);
148 int sd_bus_set_fd(sd_bus
*bus
, int input_fd
, int output_fd
);
149 int sd_bus_set_exec(sd_bus
*bus
, const char *path
, char *const *argv
);
150 int sd_bus_get_address(sd_bus
*bus
, const char **address
);
151 int sd_bus_set_bus_client(sd_bus
*bus
, int b
);
152 int sd_bus_is_bus_client(sd_bus
*bus
);
153 int sd_bus_set_server(sd_bus
*bus
, int b
, sd_id128_t bus_id
);
154 int sd_bus_is_server(sd_bus
*bus
);
155 int sd_bus_set_anonymous(sd_bus
*bus
, int b
);
156 int sd_bus_is_anonymous(sd_bus
*bus
);
157 int sd_bus_set_trusted(sd_bus
*bus
, int b
);
158 int sd_bus_is_trusted(sd_bus
*bus
);
159 int sd_bus_set_monitor(sd_bus
*bus
, int b
);
160 int sd_bus_is_monitor(sd_bus
*bus
);
161 int sd_bus_set_description(sd_bus
*bus
, const char *description
);
162 int sd_bus_get_description(sd_bus
*bus
, const char **description
);
163 int sd_bus_negotiate_creds(sd_bus
*bus
, int b
, uint64_t creds_mask
);
164 int sd_bus_negotiate_timestamp(sd_bus
*bus
, int b
);
165 int sd_bus_negotiate_fds(sd_bus
*bus
, int b
);
166 int sd_bus_can_send(sd_bus
*bus
, char type
);
167 int sd_bus_get_creds_mask(sd_bus
*bus
, uint64_t *creds_mask
);
168 int sd_bus_set_allow_interactive_authorization(sd_bus
*bus
, int b
);
169 int sd_bus_get_allow_interactive_authorization(sd_bus
*bus
);
170 int sd_bus_set_exit_on_disconnect(sd_bus
*bus
, int b
);
171 int sd_bus_get_exit_on_disconnect(sd_bus
*bus
);
172 int sd_bus_set_close_on_exit(sd_bus
*bus
, int b
);
173 int sd_bus_get_close_on_exit(sd_bus
*bus
);
174 int sd_bus_set_watch_bind(sd_bus
*bus
, int b
);
175 int sd_bus_get_watch_bind(sd_bus
*bus
);
176 int sd_bus_set_connected_signal(sd_bus
*bus
, int b
);
177 int sd_bus_get_connected_signal(sd_bus
*bus
);
178 int sd_bus_set_sender(sd_bus
*bus
, const char *sender
);
179 int sd_bus_get_sender(sd_bus
*bus
, const char **ret
);
181 int sd_bus_start(sd_bus
*bus
);
183 int sd_bus_try_close(sd_bus
*bus
) _sd_deprecated_
;
184 void sd_bus_close(sd_bus
*bus
);
186 sd_bus
* sd_bus_ref(sd_bus
*bus
);
187 sd_bus
* sd_bus_unref(sd_bus
*bus
);
188 sd_bus
* sd_bus_close_unref(sd_bus
*bus
);
189 sd_bus
* sd_bus_flush_close_unref(sd_bus
*bus
);
191 void sd_bus_default_flush_close(void);
193 int sd_bus_is_open(sd_bus
*bus
);
194 int sd_bus_is_ready(sd_bus
*bus
);
196 int sd_bus_get_bus_id(sd_bus
*bus
, sd_id128_t
*id
);
197 int sd_bus_get_scope(sd_bus
*bus
, const char **scope
);
198 int sd_bus_get_tid(sd_bus
*bus
, pid_t
*tid
);
199 int sd_bus_get_owner_creds(sd_bus
*bus
, uint64_t creds_mask
, sd_bus_creds
**ret
);
201 int sd_bus_send(sd_bus
*bus
, sd_bus_message
*m
, uint64_t *cookie
);
202 int sd_bus_send_to(sd_bus
*bus
, sd_bus_message
*m
, const char *destination
, uint64_t *cookie
);
203 int sd_bus_call(sd_bus
*bus
, sd_bus_message
*m
, uint64_t usec
, sd_bus_error
*ret_error
, sd_bus_message
**reply
);
204 int sd_bus_call_async(sd_bus
*bus
, sd_bus_slot
**slot
, sd_bus_message
*m
, sd_bus_message_handler_t callback
, void *userdata
, uint64_t usec
);
206 int sd_bus_get_fd(sd_bus
*bus
);
207 int sd_bus_get_events(sd_bus
*bus
);
208 int sd_bus_get_timeout(sd_bus
*bus
, uint64_t *timeout_usec
);
209 int sd_bus_process(sd_bus
*bus
, sd_bus_message
**r
);
210 int sd_bus_process_priority(sd_bus
*bus
, int64_t max_priority
, sd_bus_message
**r
) _sd_deprecated_
;
211 int sd_bus_wait(sd_bus
*bus
, uint64_t timeout_usec
);
212 int sd_bus_flush(sd_bus
*bus
);
213 int sd_bus_enqueue_for_read(sd_bus
*bus
, sd_bus_message
*m
);
215 sd_bus_slot
* sd_bus_get_current_slot(sd_bus
*bus
);
216 sd_bus_message
* sd_bus_get_current_message(sd_bus
*bus
);
217 sd_bus_message_handler_t
sd_bus_get_current_handler(sd_bus
*bus
);
218 void* sd_bus_get_current_userdata(sd_bus
*bus
);
220 int sd_bus_attach_event(sd_bus
*bus
, sd_event
*e
, int priority
);
221 int sd_bus_detach_event(sd_bus
*bus
);
222 sd_event
* sd_bus_get_event(sd_bus
*bus
);
224 int sd_bus_get_n_queued_read(sd_bus
*bus
, uint64_t *ret
);
225 int sd_bus_get_n_queued_write(sd_bus
*bus
, uint64_t *ret
);
227 int sd_bus_set_method_call_timeout(sd_bus
*bus
, uint64_t usec
);
228 int sd_bus_get_method_call_timeout(sd_bus
*bus
, uint64_t *ret
);
230 int sd_bus_add_filter(sd_bus
*bus
, sd_bus_slot
**slot
, sd_bus_message_handler_t callback
, void *userdata
);
231 int sd_bus_add_match(sd_bus
*bus
, sd_bus_slot
**slot
, const char *match
, sd_bus_message_handler_t callback
, void *userdata
);
232 int sd_bus_add_match_async(sd_bus
*bus
, sd_bus_slot
**slot
, const char *match
, sd_bus_message_handler_t callback
, sd_bus_message_handler_t install_callback
, void *userdata
);
233 int sd_bus_add_object(sd_bus
*bus
, sd_bus_slot
**slot
, const char *path
, sd_bus_message_handler_t callback
, void *userdata
);
234 int sd_bus_add_fallback(sd_bus
*bus
, sd_bus_slot
**slot
, const char *prefix
, sd_bus_message_handler_t callback
, void *userdata
);
235 int sd_bus_add_object_vtable(sd_bus
*bus
, sd_bus_slot
**slot
, const char *path
, const char *interface
, const sd_bus_vtable
*vtable
, void *userdata
);
236 int sd_bus_add_fallback_vtable(sd_bus
*bus
, sd_bus_slot
**slot
, const char *prefix
, const char *interface
, const sd_bus_vtable
*vtable
, sd_bus_object_find_t find
, void *userdata
);
237 int sd_bus_add_node_enumerator(sd_bus
*bus
, sd_bus_slot
**slot
, const char *path
, sd_bus_node_enumerator_t callback
, void *userdata
);
238 int sd_bus_add_object_manager(sd_bus
*bus
, sd_bus_slot
**slot
, const char *path
);
242 sd_bus_slot
* sd_bus_slot_ref(sd_bus_slot
*slot
);
243 sd_bus_slot
* sd_bus_slot_unref(sd_bus_slot
*slot
);
245 sd_bus
* sd_bus_slot_get_bus(sd_bus_slot
*slot
);
246 void* sd_bus_slot_get_userdata(sd_bus_slot
*slot
);
247 void* sd_bus_slot_set_userdata(sd_bus_slot
*slot
, void *userdata
);
248 int sd_bus_slot_set_description(sd_bus_slot
*slot
, const char *description
);
249 int sd_bus_slot_get_description(sd_bus_slot
*slot
, const char **description
);
250 int sd_bus_slot_get_floating(sd_bus_slot
*slot
);
251 int sd_bus_slot_set_floating(sd_bus_slot
*slot
, int b
);
252 int sd_bus_slot_set_destroy_callback(sd_bus_slot
*s
, sd_bus_destroy_t callback
);
253 int sd_bus_slot_get_destroy_callback(sd_bus_slot
*s
, sd_bus_destroy_t
*callback
);
255 sd_bus_message
* sd_bus_slot_get_current_message(sd_bus_slot
*slot
);
256 sd_bus_message_handler_t
sd_bus_slot_get_current_handler(sd_bus_slot
*slot
);
257 void* sd_bus_slot_get_current_userdata(sd_bus_slot
*slot
);
261 int sd_bus_message_new(sd_bus
*bus
, sd_bus_message
**m
, uint8_t type
);
262 int sd_bus_message_new_signal(sd_bus
*bus
, sd_bus_message
**m
, const char *path
, const char *interface
, const char *member
);
263 int sd_bus_message_new_signal_to(sd_bus
*bus
, sd_bus_message
**m
, const char *destination
, const char *path
, const char *interface
, const char *member
);
264 int sd_bus_message_new_method_call(sd_bus
*bus
, sd_bus_message
**m
, const char *destination
, const char *path
, const char *interface
, const char *member
);
265 int sd_bus_message_new_method_return(sd_bus_message
*call
, sd_bus_message
**m
);
266 int sd_bus_message_new_method_error(sd_bus_message
*call
, sd_bus_message
**m
, const sd_bus_error
*e
);
267 int sd_bus_message_new_method_errorf(sd_bus_message
*call
, sd_bus_message
**m
, const char *name
, const char *format
, ...) _sd_printf_(4, 5);
268 int sd_bus_message_new_method_errno(sd_bus_message
*call
, sd_bus_message
**m
, int error
, const sd_bus_error
*e
);
269 int sd_bus_message_new_method_errnof(sd_bus_message
*call
, sd_bus_message
**m
, int error
, const char *format
, ...) _sd_printf_(4, 5);
271 sd_bus_message
* sd_bus_message_ref(sd_bus_message
*m
);
272 sd_bus_message
* sd_bus_message_unref(sd_bus_message
*m
);
274 int sd_bus_message_seal(sd_bus_message
*m
, uint64_t cookie
, uint64_t timeout_usec
);
276 int sd_bus_message_get_type(sd_bus_message
*m
, uint8_t *type
);
277 int sd_bus_message_get_cookie(sd_bus_message
*m
, uint64_t *cookie
);
278 int sd_bus_message_get_reply_cookie(sd_bus_message
*m
, uint64_t *cookie
);
279 int sd_bus_message_get_priority(sd_bus_message
*m
, int64_t *priority
) _sd_deprecated_
;
281 int sd_bus_message_get_expect_reply(sd_bus_message
*m
);
282 int sd_bus_message_get_auto_start(sd_bus_message
*m
);
283 int sd_bus_message_get_allow_interactive_authorization(sd_bus_message
*m
);
285 const char* sd_bus_message_get_signature(sd_bus_message
*m
, int complete
);
286 const char* sd_bus_message_get_path(sd_bus_message
*m
);
287 const char* sd_bus_message_get_interface(sd_bus_message
*m
);
288 const char* sd_bus_message_get_member(sd_bus_message
*m
);
289 const char* sd_bus_message_get_destination(sd_bus_message
*m
);
290 const char* sd_bus_message_get_sender(sd_bus_message
*m
);
291 const sd_bus_error
* sd_bus_message_get_error(sd_bus_message
*m
);
292 int sd_bus_message_get_errno(sd_bus_message
*m
);
294 int sd_bus_message_get_monotonic_usec(sd_bus_message
*m
, uint64_t *usec
);
295 int sd_bus_message_get_realtime_usec(sd_bus_message
*m
, uint64_t *usec
);
296 int sd_bus_message_get_seqnum(sd_bus_message
*m
, uint64_t *seqnum
);
298 sd_bus
* sd_bus_message_get_bus(sd_bus_message
*m
);
299 sd_bus_creds
* sd_bus_message_get_creds(sd_bus_message
*m
); /* do not unref the result */
301 int sd_bus_message_is_signal(sd_bus_message
*m
, const char *interface
, const char *member
);
302 int sd_bus_message_is_method_call(sd_bus_message
*m
, const char *interface
, const char *member
);
303 int sd_bus_message_is_method_error(sd_bus_message
*m
, const char *name
);
304 int sd_bus_message_is_empty(sd_bus_message
*m
);
305 int sd_bus_message_has_signature(sd_bus_message
*m
, const char *signature
);
307 int sd_bus_message_set_expect_reply(sd_bus_message
*m
, int b
);
308 int sd_bus_message_set_auto_start(sd_bus_message
*m
, int b
);
309 int sd_bus_message_set_allow_interactive_authorization(sd_bus_message
*m
, int b
);
311 int sd_bus_message_set_destination(sd_bus_message
*m
, const char *destination
);
312 int sd_bus_message_set_sender(sd_bus_message
*m
, const char *sender
);
313 int sd_bus_message_set_priority(sd_bus_message
*m
, int64_t priority
) _sd_deprecated_
;
315 int sd_bus_message_append(sd_bus_message
*m
, const char *types
, ...);
316 int sd_bus_message_appendv(sd_bus_message
*m
, const char *types
, va_list ap
);
317 int sd_bus_message_append_basic(sd_bus_message
*m
, char type
, const void *p
);
318 int sd_bus_message_append_array(sd_bus_message
*m
, char type
, const void *ptr
, size_t size
);
319 int sd_bus_message_append_array_space(sd_bus_message
*m
, char type
, size_t size
, void **ptr
);
320 int sd_bus_message_append_array_iovec(sd_bus_message
*m
, char type
, const struct iovec
*iov
, unsigned n
);
321 int sd_bus_message_append_array_memfd(sd_bus_message
*m
, char type
, int memfd
, uint64_t offset
, uint64_t size
);
322 int sd_bus_message_append_string_space(sd_bus_message
*m
, size_t size
, char **s
);
323 int sd_bus_message_append_string_iovec(sd_bus_message
*m
, const struct iovec
*iov
, unsigned n
);
324 int sd_bus_message_append_string_memfd(sd_bus_message
*m
, int memfd
, uint64_t offset
, uint64_t size
);
325 int sd_bus_message_append_strv(sd_bus_message
*m
, char **l
);
326 int sd_bus_message_open_container(sd_bus_message
*m
, char type
, const char *contents
);
327 int sd_bus_message_close_container(sd_bus_message
*m
);
328 int sd_bus_message_copy(sd_bus_message
*m
, sd_bus_message
*source
, int all
);
330 int sd_bus_message_read(sd_bus_message
*m
, const char *types
, ...);
331 int sd_bus_message_readv(sd_bus_message
*m
, const char *types
, va_list ap
);
332 int sd_bus_message_read_basic(sd_bus_message
*m
, char type
, void *p
);
333 int sd_bus_message_read_array(sd_bus_message
*m
, char type
, const void **ptr
, size_t *size
);
334 int sd_bus_message_read_strv(sd_bus_message
*m
, char ***l
); /* free the result! */
335 int sd_bus_message_read_strv_extend(sd_bus_message
*m
, char ***l
);
336 int sd_bus_message_skip(sd_bus_message
*m
, const char *types
);
337 int sd_bus_message_enter_container(sd_bus_message
*m
, char type
, const char *contents
);
338 int sd_bus_message_exit_container(sd_bus_message
*m
);
339 int sd_bus_message_peek_type(sd_bus_message
*m
, char *type
, const char **contents
);
340 int sd_bus_message_verify_type(sd_bus_message
*m
, char type
, const char *contents
);
341 int sd_bus_message_at_end(sd_bus_message
*m
, int complete
);
342 int sd_bus_message_rewind(sd_bus_message
*m
, int complete
);
343 int sd_bus_message_sensitive(sd_bus_message
*m
);
345 int sd_bus_message_dump(sd_bus_message
*m
, FILE *f
, uint64_t flags
);
349 int sd_bus_get_unique_name(sd_bus
*bus
, const char **unique
);
350 int sd_bus_request_name(sd_bus
*bus
, const char *name
, uint64_t flags
);
351 int sd_bus_request_name_async(sd_bus
*bus
, sd_bus_slot
**ret_slot
, const char *name
, uint64_t flags
, sd_bus_message_handler_t callback
, void *userdata
);
352 int sd_bus_release_name(sd_bus
*bus
, const char *name
);
353 int sd_bus_release_name_async(sd_bus
*bus
, sd_bus_slot
**ret_slot
, const char *name
, sd_bus_message_handler_t callback
, void *userdata
);
354 int sd_bus_list_names(sd_bus
*bus
, char ***acquired
, char ***activatable
); /* free the results */
355 int sd_bus_get_name_creds(sd_bus
*bus
, const char *name
, uint64_t mask
, sd_bus_creds
**creds
); /* unref the result! */
356 int sd_bus_get_name_machine_id(sd_bus
*bus
, const char *name
, sd_id128_t
*machine
);
358 /* Convenience calls */
360 int sd_bus_message_send(sd_bus_message
*m
);
361 int sd_bus_call_methodv(sd_bus
*bus
, const char *destination
, const char *path
, const char *interface
, const char *member
, sd_bus_error
*ret_error
, sd_bus_message
**reply
, const char *types
, va_list ap
);
362 int sd_bus_call_method(sd_bus
*bus
, const char *destination
, const char *path
, const char *interface
, const char *member
, sd_bus_error
*ret_error
, sd_bus_message
**reply
, const char *types
, ...);
363 int sd_bus_call_method_asyncv(sd_bus
*bus
, sd_bus_slot
**slot
, const char *destination
, const char *path
, const char *interface
, const char *member
, sd_bus_message_handler_t callback
, void *userdata
, const char *types
, va_list ap
);
364 int sd_bus_call_method_async(sd_bus
*bus
, sd_bus_slot
**slot
, const char *destination
, const char *path
, const char *interface
, const char *member
, sd_bus_message_handler_t callback
, void *userdata
, const char *types
, ...);
365 int sd_bus_get_property(sd_bus
*bus
, const char *destination
, const char *path
, const char *interface
, const char *member
, sd_bus_error
*ret_error
, sd_bus_message
**reply
, const char *type
);
366 int sd_bus_get_property_trivial(sd_bus
*bus
, const char *destination
, const char *path
, const char *interface
, const char *member
, sd_bus_error
*ret_error
, char type
, void *ret_ptr
);
367 int sd_bus_get_property_string(sd_bus
*bus
, const char *destination
, const char *path
, const char *interface
, const char *member
, sd_bus_error
*ret_error
, char **ret
); /* free the result! */
368 int sd_bus_get_property_strv(sd_bus
*bus
, const char *destination
, const char *path
, const char *interface
, const char *member
, sd_bus_error
*ret_error
, char ***ret
); /* free the result! */
369 int sd_bus_set_propertyv(sd_bus
*bus
, const char *destination
, const char *path
, const char *interface
, const char *member
, sd_bus_error
*ret_error
, const char *type
, va_list ap
);
370 int sd_bus_set_property(sd_bus
*bus
, const char *destination
, const char *path
, const char *interface
, const char *member
, sd_bus_error
*ret_error
, const char *type
, ...);
372 int sd_bus_reply_method_returnv(sd_bus_message
*call
, const char *types
, va_list ap
);
373 int sd_bus_reply_method_return(sd_bus_message
*call
, const char *types
, ...);
374 int sd_bus_reply_method_error(sd_bus_message
*call
, const sd_bus_error
*e
);
375 int sd_bus_reply_method_errorfv(sd_bus_message
*call
, const char *name
, const char *format
, va_list ap
) _sd_printf_(3, 0);
376 int sd_bus_reply_method_errorf(sd_bus_message
*call
, const char *name
, const char *format
, ...) _sd_printf_(3, 4);
377 int sd_bus_reply_method_errno(sd_bus_message
*call
, int error
, const sd_bus_error
*e
);
378 int sd_bus_reply_method_errnofv(sd_bus_message
*call
, int error
, const char *format
, va_list ap
) _sd_printf_(3, 0);
379 int sd_bus_reply_method_errnof(sd_bus_message
*call
, int error
, const char *format
, ...) _sd_printf_(3, 4);
381 int sd_bus_emit_signalv(sd_bus
*bus
, const char *path
, const char *interface
, const char *member
, const char *types
, va_list ap
);
382 int sd_bus_emit_signal(sd_bus
*bus
, const char *path
, const char *interface
, const char *member
, const char *types
, ...);
383 int sd_bus_emit_signal_tov(sd_bus
*bus
, const char *destination
, const char *path
, const char *interface
, const char *member
, const char *types
, va_list ap
);
384 int sd_bus_emit_signal_to(sd_bus
*bus
, const char *destination
, const char *path
, const char *interface
, const char *member
, const char *types
, ...);
386 int sd_bus_emit_properties_changed_strv(sd_bus
*bus
, const char *path
, const char *interface
, char **names
);
387 int sd_bus_emit_properties_changed(sd_bus
*bus
, const char *path
, const char *interface
, const char *name
, ...) _sd_sentinel_
;
389 int sd_bus_emit_object_added(sd_bus
*bus
, const char *path
);
390 int sd_bus_emit_object_removed(sd_bus
*bus
, const char *path
);
391 int sd_bus_emit_interfaces_added_strv(sd_bus
*bus
, const char *path
, char **interfaces
);
392 int sd_bus_emit_interfaces_added(sd_bus
*bus
, const char *path
, const char *interface
, ...) _sd_sentinel_
;
393 int sd_bus_emit_interfaces_removed_strv(sd_bus
*bus
, const char *path
, char **interfaces
);
394 int sd_bus_emit_interfaces_removed(sd_bus
*bus
, const char *path
, const char *interface
, ...) _sd_sentinel_
;
396 int sd_bus_query_sender_creds(sd_bus_message
*m
, uint64_t mask
, sd_bus_creds
**creds
);
397 int sd_bus_query_sender_privilege(sd_bus_message
*m
, int capability
);
399 int sd_bus_match_signal(sd_bus
*bus
, sd_bus_slot
**ret
, const char *sender
, const char *path
, const char *interface
, const char *member
, sd_bus_message_handler_t callback
, void *userdata
);
400 int sd_bus_match_signal_async(sd_bus
*bus
, sd_bus_slot
**ret
, const char *sender
, const char *path
, const char *interface
, const char *member
, sd_bus_message_handler_t match_callback
, sd_bus_message_handler_t add_callback
, void *userdata
);
402 /* Credential handling */
404 int sd_bus_creds_new_from_pid(sd_bus_creds
**ret
, pid_t pid
, uint64_t creds_mask
);
405 sd_bus_creds
* sd_bus_creds_ref(sd_bus_creds
*c
);
406 sd_bus_creds
* sd_bus_creds_unref(sd_bus_creds
*c
);
407 uint64_t sd_bus_creds_get_mask(const sd_bus_creds
*c
);
408 uint64_t sd_bus_creds_get_augmented_mask(const sd_bus_creds
*c
);
410 int sd_bus_creds_get_pid(sd_bus_creds
*c
, pid_t
*pid
);
411 int sd_bus_creds_get_ppid(sd_bus_creds
*c
, pid_t
*ppid
);
412 int sd_bus_creds_get_tid(sd_bus_creds
*c
, pid_t
*tid
);
413 int sd_bus_creds_get_uid(sd_bus_creds
*c
, uid_t
*uid
);
414 int sd_bus_creds_get_euid(sd_bus_creds
*c
, uid_t
*euid
);
415 int sd_bus_creds_get_suid(sd_bus_creds
*c
, uid_t
*suid
);
416 int sd_bus_creds_get_fsuid(sd_bus_creds
*c
, uid_t
*fsuid
);
417 int sd_bus_creds_get_gid(sd_bus_creds
*c
, gid_t
*gid
);
418 int sd_bus_creds_get_egid(sd_bus_creds
*c
, gid_t
*egid
);
419 int sd_bus_creds_get_sgid(sd_bus_creds
*c
, gid_t
*sgid
);
420 int sd_bus_creds_get_fsgid(sd_bus_creds
*c
, gid_t
*fsgid
);
421 int sd_bus_creds_get_supplementary_gids(sd_bus_creds
*c
, const gid_t
**gids
);
422 int sd_bus_creds_get_comm(sd_bus_creds
*c
, const char **comm
);
423 int sd_bus_creds_get_tid_comm(sd_bus_creds
*c
, const char **comm
);
424 int sd_bus_creds_get_exe(sd_bus_creds
*c
, const char **exe
);
425 int sd_bus_creds_get_cmdline(sd_bus_creds
*c
, char ***cmdline
);
426 int sd_bus_creds_get_cgroup(sd_bus_creds
*c
, const char **cgroup
);
427 int sd_bus_creds_get_unit(sd_bus_creds
*c
, const char **unit
);
428 int sd_bus_creds_get_slice(sd_bus_creds
*c
, const char **slice
);
429 int sd_bus_creds_get_user_unit(sd_bus_creds
*c
, const char **unit
);
430 int sd_bus_creds_get_user_slice(sd_bus_creds
*c
, const char **slice
);
431 int sd_bus_creds_get_session(sd_bus_creds
*c
, const char **session
);
432 int sd_bus_creds_get_owner_uid(sd_bus_creds
*c
, uid_t
*uid
);
433 int sd_bus_creds_has_effective_cap(sd_bus_creds
*c
, int capability
);
434 int sd_bus_creds_has_permitted_cap(sd_bus_creds
*c
, int capability
);
435 int sd_bus_creds_has_inheritable_cap(sd_bus_creds
*c
, int capability
);
436 int sd_bus_creds_has_bounding_cap(sd_bus_creds
*c
, int capability
);
437 int sd_bus_creds_get_selinux_context(sd_bus_creds
*c
, const char **context
);
438 int sd_bus_creds_get_audit_session_id(sd_bus_creds
*c
, uint32_t *sessionid
);
439 int sd_bus_creds_get_audit_login_uid(sd_bus_creds
*c
, uid_t
*loginuid
);
440 int sd_bus_creds_get_tty(sd_bus_creds
*c
, const char **tty
);
441 int sd_bus_creds_get_unique_name(sd_bus_creds
*c
, const char **name
);
442 int sd_bus_creds_get_well_known_names(sd_bus_creds
*c
, char ***names
);
443 int sd_bus_creds_get_description(sd_bus_creds
*c
, const char **name
);
445 /* Error structures */
447 #define SD_BUS_ERROR_MAKE_CONST(name, message) ((const sd_bus_error) {(name), (message), 0})
448 #define SD_BUS_ERROR_NULL SD_BUS_ERROR_MAKE_CONST(NULL, NULL)
450 void sd_bus_error_free(sd_bus_error
*e
);
451 int sd_bus_error_set(sd_bus_error
*e
, const char *name
, const char *message
);
452 int sd_bus_error_setf(sd_bus_error
*e
, const char *name
, const char *format
, ...) _sd_printf_(3, 4);
453 int sd_bus_error_setfv(sd_bus_error
*e
, const char *name
, const char *format
, va_list ap
) _sd_printf_(3,0);
455 int sd_bus_error_set_const(sd_bus_error
*e
, const char *name
, const char *message
);
456 int sd_bus_error_set_errno(sd_bus_error
*e
, int error
);
457 int sd_bus_error_set_errnof(sd_bus_error
*e
, int error
, const char *format
, ...) _sd_printf_(3, 4);
458 int sd_bus_error_set_errnofv(sd_bus_error
*e
, int error
, const char *format
, va_list ap
) _sd_printf_(3,0);
459 int sd_bus_error_get_errno(const sd_bus_error
*e
);
460 int sd_bus_error_copy(sd_bus_error
*dest
, const sd_bus_error
*e
);
461 int sd_bus_error_move(sd_bus_error
*dest
, sd_bus_error
*e
);
462 int sd_bus_error_is_set(const sd_bus_error
*e
);
463 int sd_bus_error_has_name(const sd_bus_error
*e
, const char *name
);
464 int sd_bus_error_has_names_sentinel(const sd_bus_error
*e
, ...) _sd_sentinel_
;
465 #define sd_bus_error_has_names(e, ...) sd_bus_error_has_names_sentinel(e, __VA_ARGS__, NULL)
467 #define SD_BUS_ERROR_MAP(_name, _code) \
472 #define SD_BUS_ERROR_MAP_END \
478 int sd_bus_error_add_map(const sd_bus_error_map
*map
);
480 /* Auxiliary macros */
482 #define SD_BUS_MESSAGE_APPEND_ID128(x) 16, \
483 (x).bytes[0], (x).bytes[1], (x).bytes[2], (x).bytes[3], \
484 (x).bytes[4], (x).bytes[5], (x).bytes[6], (x).bytes[7], \
485 (x).bytes[8], (x).bytes[9], (x).bytes[10], (x).bytes[11], \
486 (x).bytes[12], (x).bytes[13], (x).bytes[14], (x).bytes[15]
488 #define SD_BUS_MESSAGE_READ_ID128(x) 16, \
489 &(x).bytes[0], &(x).bytes[1], &(x).bytes[2], &(x).bytes[3], \
490 &(x).bytes[4], &(x).bytes[5], &(x).bytes[6], &(x).bytes[7], \
491 &(x).bytes[8], &(x).bytes[9], &(x).bytes[10], &(x).bytes[11], \
492 &(x).bytes[12], &(x).bytes[13], &(x).bytes[14], &(x).bytes[15]
496 int sd_bus_path_encode(const char *prefix
, const char *external_id
, char **ret_path
);
497 int sd_bus_path_encode_many(char **out
, const char *path_template
, ...);
498 int sd_bus_path_decode(const char *path
, const char *prefix
, char **ret_external_id
);
499 int sd_bus_path_decode_many(const char *path
, const char *path_template
, ...);
503 int sd_bus_track_new(sd_bus
*bus
, sd_bus_track
**track
, sd_bus_track_handler_t handler
, void *userdata
);
504 sd_bus_track
* sd_bus_track_ref(sd_bus_track
*track
);
505 sd_bus_track
* sd_bus_track_unref(sd_bus_track
*track
);
507 sd_bus
* sd_bus_track_get_bus(sd_bus_track
*track
);
508 void* sd_bus_track_get_userdata(sd_bus_track
*track
);
509 void* sd_bus_track_set_userdata(sd_bus_track
*track
, void *userdata
);
511 int sd_bus_track_add_sender(sd_bus_track
*track
, sd_bus_message
*m
);
512 int sd_bus_track_remove_sender(sd_bus_track
*track
, sd_bus_message
*m
);
513 int sd_bus_track_add_name(sd_bus_track
*track
, const char *name
);
514 int sd_bus_track_remove_name(sd_bus_track
*track
, const char *name
);
516 int sd_bus_track_set_recursive(sd_bus_track
*track
, int b
);
517 int sd_bus_track_get_recursive(sd_bus_track
*track
);
519 unsigned sd_bus_track_count(sd_bus_track
*track
);
520 int sd_bus_track_count_sender(sd_bus_track
*track
, sd_bus_message
*m
);
521 int sd_bus_track_count_name(sd_bus_track
*track
, const char *name
);
523 const char* sd_bus_track_contains(sd_bus_track
*track
, const char *name
);
524 const char* sd_bus_track_first(sd_bus_track
*track
);
525 const char* sd_bus_track_next(sd_bus_track
*track
);
527 int sd_bus_track_set_destroy_callback(sd_bus_track
*s
, sd_bus_destroy_t callback
);
528 int sd_bus_track_get_destroy_callback(sd_bus_track
*s
, sd_bus_destroy_t
*ret
);
530 /* Define helpers so that __attribute__((cleanup(sd_bus_unrefp))) and similar may be used. */
531 _SD_DEFINE_POINTER_CLEANUP_FUNC(sd_bus
, sd_bus_unref
);
532 _SD_DEFINE_POINTER_CLEANUP_FUNC(sd_bus
, sd_bus_close_unref
);
533 _SD_DEFINE_POINTER_CLEANUP_FUNC(sd_bus
, sd_bus_flush_close_unref
);
534 _SD_DEFINE_POINTER_CLEANUP_FUNC(sd_bus_slot
, sd_bus_slot_unref
);
535 _SD_DEFINE_POINTER_CLEANUP_FUNC(sd_bus_message
, sd_bus_message_unref
);
536 _SD_DEFINE_POINTER_CLEANUP_FUNC(sd_bus_creds
, sd_bus_creds_unref
);
537 _SD_DEFINE_POINTER_CLEANUP_FUNC(sd_bus_track
, sd_bus_track_unref
);
539 _SD_END_DECLARATIONS
;