1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
6 This file is part of systemd.
8 Copyright 2013 Lennart Poettering
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24 #include <sys/socket.h>
26 #include <netinet/in.h>
34 #include "bus-error.h"
35 #include "bus-match.h"
36 #include "bus-kernel.h"
38 struct reply_callback {
39 sd_bus_message_handler_t callback;
46 struct filter_callback {
47 sd_bus_message_handler_t callback;
50 unsigned last_iteration;
52 LIST_FIELDS(struct filter_callback, callbacks);
55 struct object_callback {
56 sd_bus_message_handler_t callback;
62 unsigned last_iteration;
82 int input_fd, output_fd;
91 bool anonymous_auth:1;
95 bool match_callbacks_modified:1;
96 bool filter_callbacks_modified:1;
97 bool object_callbacks_modified:1;
102 sd_bus_message **rqueue;
103 unsigned rqueue_size;
105 sd_bus_message **wqueue;
106 unsigned wqueue_size;
113 struct bus_match_node match_callbacks;
114 Prioq *reply_callbacks_prioq;
115 Hashmap *reply_callbacks;
116 LIST_HEAD(struct filter_callback, filter_callbacks);
117 Hashmap *object_callbacks;
121 struct sockaddr_un un;
122 struct sockaddr_in in;
123 struct sockaddr_in6 in6;
125 socklen_t sockaddr_size;
129 sd_id128_t server_id;
132 unsigned address_index;
134 int last_connect_error;
138 struct iovec auth_iovec[3];
144 char label[NAME_MAX];
152 uint64_t hello_serial;
153 unsigned iteration_counter;
157 struct memfd_cache memfd_cache[MEMFD_CACHE_MAX];
158 unsigned n_memfd_cache;
161 static inline void bus_unrefp(sd_bus **b) {
165 #define _cleanup_bus_unref_ __attribute__((cleanup(bus_unrefp)))
166 #define _cleanup_bus_error_free_ __attribute__((cleanup(sd_bus_error_free)))
168 #define BUS_DEFAULT_TIMEOUT ((usec_t) (25 * USEC_PER_SEC))
170 #define BUS_WQUEUE_MAX 128
171 #define BUS_RQUEUE_MAX 128
173 #define BUS_MESSAGE_SIZE_MAX (64*1024*1024)
174 #define BUS_AUTH_SIZE_MAX (64*1024)
176 #define BUS_CONTAINER_DEPTH 128
178 /* Defined by the specification as maximum size of an array in
180 #define BUS_ARRAY_MAX_SIZE 67108864
182 #define BUS_FDS_MAX 1024
184 #define BUS_EXEC_ARGV_MAX 256
186 bool object_path_is_valid(const char *p);
187 bool interface_name_is_valid(const char *p);
188 bool service_name_is_valid(const char *p);
189 bool member_name_is_valid(const char *p);
191 bool namespace_complex_pattern(const char *pattern, const char *value);
192 bool path_complex_pattern(const char *pattern, const char *value);
194 bool namespace_simple_pattern(const char *pattern, const char *value);
195 bool path_simple_pattern(const char *pattern, const char *value);
197 int bus_message_type_from_string(const char *s, uint8_t *u);
198 const char *bus_message_type_to_string(uint8_t u);
200 #define error_name_is_valid interface_name_is_valid
202 int bus_ensure_running(sd_bus *bus);
203 int bus_start_running(sd_bus *bus);
204 int bus_next_address(sd_bus *bus);