bus-internal.h revision 9cbfc66c621c42aa6e58e9e0da0adfb01efa7537
/*-*- 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"
#include "kdbus.h"
struct reply_callback {
unsigned prioq_idx;
};
struct filter_callback {
unsigned last_iteration;
};
struct match_callback {
unsigned last_iteration;
char *match_string;
struct bus_match_node *match_node;
};
struct node {
char *path;
};
struct node_callback {
bool is_fallback;
unsigned last_iteration;
};
struct node_enumerator {
unsigned last_iteration;
};
struct node_object_manager {
};
struct node_vtable {
char *interface;
bool is_fallback;
const sd_bus_vtable *vtable;
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;
};
typedef enum BusSlotType {
_BUS_SLOT_INVALID = -1,
} BusSlotType;
struct sd_bus_slot {
unsigned n_ref;
void *userdata;
bool floating:1;
char *description;
union {
struct reply_callback reply_callback;
struct filter_callback filter_callback;
struct match_callback match_callback;
struct node_callback node_callback;
struct node_enumerator node_enumerator;
struct node_vtable node_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;
int message_endian;
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;
bool trusted:1;
bool fake_creds_valid:1;
bool manual_peer_interface:1;
bool is_system:1;
bool is_user:1;
int use_memfd;
void *rbuffer;
unsigned rqueue_size;
unsigned wqueue_size;
char *unique_name;
struct bus_match_node match_callbacks;
union sockaddr_union 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;
int event_priority;
void *current_userdata;
struct kdbus_creds fake_creds;
char *fake_label;
char *cgroup_root;
char *description;
unsigned bloom_n_hash;
};
#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) _pure_;
bool service_name_is_valid(const char *p) _pure_;
bool member_name_is_valid(const char *p) _pure_;
bool object_path_is_valid(const char *p) _pure_;
char *object_path_startswith(const char *a, const char *b) _pure_;
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) \
int bus_remove_match_by_string(sd_bus *bus, const char *match, sd_bus_message_handler_t callback, void *userdata);