2013-04-11 23:09:29 +02:00
|
|
|
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
/***
|
|
|
|
This file is part of systemd.
|
|
|
|
|
|
|
|
Copyright 2013 Lennart Poettering
|
|
|
|
|
|
|
|
systemd is free software; you can redistribute it and/or modify it
|
|
|
|
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/>.
|
|
|
|
***/
|
|
|
|
|
2013-12-26 03:08:15 +01:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
2013-04-11 23:09:29 +02:00
|
|
|
#include "sd-bus.h"
|
|
|
|
|
2013-12-06 14:31:43 +01:00
|
|
|
#define KDBUS_ITEM_NEXT(item) \
|
2013-05-19 18:39:08 +02:00
|
|
|
(typeof(item))(((uint8_t *)item) + ALIGN8((item)->size))
|
|
|
|
|
2013-12-06 14:31:43 +01:00
|
|
|
#define KDBUS_ITEM_FOREACH(part, head, first) \
|
2013-11-15 15:55:27 +01:00
|
|
|
for (part = (head)->first; \
|
|
|
|
(uint8_t *)(part) < (uint8_t *)(head) + (head)->size; \
|
2013-12-06 14:31:43 +01:00
|
|
|
part = KDBUS_ITEM_NEXT(part))
|
2013-05-19 18:39:08 +02:00
|
|
|
|
2013-12-06 14:31:43 +01:00
|
|
|
#define KDBUS_ITEM_HEADER_SIZE offsetof(struct kdbus_item, data)
|
|
|
|
#define KDBUS_ITEM_SIZE(s) ALIGN8((s) + KDBUS_ITEM_HEADER_SIZE)
|
2013-05-19 18:39:08 +02:00
|
|
|
|
2013-05-14 22:24:26 +02:00
|
|
|
#define MEMFD_CACHE_MAX 32
|
2013-05-16 16:26:35 +02:00
|
|
|
|
|
|
|
/* When we cache a memfd block for reuse, we will truncate blocks
|
|
|
|
* longer than this in order not to keep too much data around. */
|
2013-05-29 09:59:10 +02:00
|
|
|
#define MEMFD_CACHE_ITEM_SIZE_MAX (128*1024)
|
2013-05-16 16:26:35 +02:00
|
|
|
|
|
|
|
/* This determines at which minimum size we prefer sending memfds over
|
|
|
|
* sending vectors */
|
2013-06-05 12:24:41 +02:00
|
|
|
#define MEMFD_MIN_SIZE (128*1024)
|
2013-05-14 22:24:26 +02:00
|
|
|
|
2013-05-17 02:32:32 +02:00
|
|
|
/* The size of the per-connection memory pool that we set up and where
|
|
|
|
* the kernel places our incoming messages */
|
|
|
|
#define KDBUS_POOL_SIZE (16*1024*1024)
|
|
|
|
|
2013-05-14 22:24:26 +02:00
|
|
|
struct memfd_cache {
|
|
|
|
int fd;
|
|
|
|
void *address;
|
2013-12-18 18:46:23 +01:00
|
|
|
size_t mapped;
|
|
|
|
size_t allocated;
|
2013-05-14 22:24:26 +02:00
|
|
|
};
|
|
|
|
|
2013-04-11 23:09:29 +02:00
|
|
|
int bus_kernel_connect(sd_bus *b);
|
|
|
|
int bus_kernel_take_fd(sd_bus *b);
|
|
|
|
|
|
|
|
int bus_kernel_write_message(sd_bus *bus, sd_bus_message *m);
|
2013-11-29 21:29:16 +01:00
|
|
|
int bus_kernel_read_message(sd_bus *bus);
|
2013-04-11 23:09:29 +02:00
|
|
|
|
2013-12-26 03:08:15 +01:00
|
|
|
int bus_kernel_create_bus(const char *name, bool world, char **s);
|
2013-11-30 16:36:46 +01:00
|
|
|
int bus_kernel_create_namespace(const char *name, char **s);
|
2013-12-02 23:30:19 +01:00
|
|
|
int bus_kernel_create_starter(const char *bus, const char *name);
|
2013-12-15 16:56:28 +01:00
|
|
|
int bus_kernel_create_monitor(const char *bus);
|
2013-05-14 22:24:26 +02:00
|
|
|
|
2013-12-18 18:46:23 +01:00
|
|
|
int bus_kernel_pop_memfd(sd_bus *bus, void **address, size_t *mapped, size_t *allocated);
|
|
|
|
void bus_kernel_push_memfd(sd_bus *bus, int fd, void *address, size_t mapped, size_t allocated);
|
2013-05-14 22:24:26 +02:00
|
|
|
|
|
|
|
void bus_kernel_flush_memfd(sd_bus *bus);
|
2013-05-19 18:39:08 +02:00
|
|
|
|
|
|
|
int bus_kernel_parse_unique_name(const char *s, uint64_t *id);
|
2013-11-26 16:45:50 +01:00
|
|
|
|
2013-11-29 21:14:07 +01:00
|
|
|
int kdbus_translate_request_name_flags(uint64_t sd_bus_flags, uint64_t *kdbus_flags);
|
2013-11-29 17:21:39 +01:00
|
|
|
int kdbus_translate_attach_flags(uint64_t sd_bus_flags, uint64_t *kdbus_flags);
|
2013-12-20 23:25:43 +01:00
|
|
|
|
|
|
|
int bus_kernel_try_close(sd_bus *bus);
|