bus-internal.h revision 718db96199eb307751264e4163555662c9a389fa
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
#pragma once
/***
This file is part of systemd.
Copyright 2013 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <pthread.h>
#include "hashmap.h"
#include "prioq.h"
#include "list.h"
#include "util.h"
#include "refcnt.h"
#include "sd-bus.h"
#include "bus-error.h"
#include "bus-match.h"
#include "bus-kernel.h"
struct reply_callback {
void *userdata;
unsigned prioq_idx;
};
struct filter_callback {
void *userdata;
unsigned last_iteration;
};
struct node {
char *path;
bool object_manager;
};
struct node_callback {
bool is_fallback;
void *userdata;
unsigned last_iteration;
};
struct node_enumerator {
void *userdata;
unsigned last_iteration;
};
struct node_vtable {
char *interface;
bool is_fallback;
const sd_bus_vtable *vtable;
void *userdata;
unsigned last_iteration;
};
struct vtable_member {
const char *path;
const char *interface;
const char *member;
struct node_vtable *parent;
unsigned last_iteration;
const sd_bus_vtable *vtable;
};
enum bus_state {
};
}
enum bus_auth {
};
struct sd_bus {
/* We use atomic ref counting here since sd_bus_message
objects retain references to their originating sd_bus but
we want to allow them to be processed in a different
thread. We won't provide full thread safety, but only the
bare minimum that makes it possible to use sd_bus and
sd_bus_message objects independently and on different
threads as long as each object is used only once at the
same time. */
int message_version;
bool is_kernel:1;
bool can_fds:1;
bool bus_client:1;
bool ucred_valid:1;
bool is_server:1;
bool anonymous_auth:1;
bool prefer_readv:1;
bool prefer_writev:1;
bool match_callbacks_modified:1;
bool filter_callbacks_modified:1;
bool nodes_modified:1;
int use_memfd;
void *rbuffer;
unsigned rqueue_size;
unsigned wqueue_size;
char *unique_name;
struct bus_match_node match_callbacks;
union {
struct sockaddr_un un;
struct sockaddr_in in;
struct sockaddr_in6 in6;
} sockaddr;
char *kernel;
char *machine;
char *address;
unsigned address_index;
int last_connect_error;
unsigned auth_index;
char *auth_buffer;
int *fds;
unsigned n_fds;
char *exec_path;
char **exec_argv;
unsigned iteration_counter;
void *kdbus_buffer;
/* We do locking around the memfd cache, since we want to
* allow people to process a sd_bus_message in a different
* thread then it was generated on and free it there. Since
* adding something to the memfd cache might happen when a
* message is released, we hence need to protect this bit with
* a mutex. */
unsigned n_memfd_cache;
};
#define BUS_WQUEUE_MAX 1024
#define BUS_CONTAINER_DEPTH 128
/* Defined by the specification as maximum size of an array in
* bytes */
#define BUS_ARRAY_MAX_SIZE 67108864
#define BUS_FDS_MAX 1024
#define BUS_EXEC_ARGV_MAX 256
bool interface_name_is_valid(const char *p);
bool service_name_is_valid(const char *p);
bool sender_name_is_valid(const char *p);
bool member_name_is_valid(const char *p);
bool object_path_is_valid(const char *p);
char *object_path_startswith(const char *a, const char *b);
int bus_message_type_from_string(const char *s, uint8_t *u);
const char *bus_message_type_to_string(uint8_t u);
char *bus_address_escape(const char *v);
for (char *_slash = ({ strcpy((prefix), (path)); streq((prefix), "/") ? NULL : strrchr((prefix), '/'); }) ; \
/* If we are invoking callbacks of a bus object, ensure unreffing the
* bus from the callback doesn't destroy the object we are working
* on */
#define BUS_DONT_DESTROY(bus) \