]>
Commit | Line | Data |
---|---|---|
6629161f LP |
1 | /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ |
2 | ||
3 | #pragma once | |
4 | ||
5 | /*** | |
6 | This file is part of systemd. | |
7 | ||
8 | Copyright 2013 Lennart Poettering | |
9 | ||
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. | |
14 | ||
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. | |
19 | ||
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/>. | |
22 | ***/ | |
23 | ||
f2769777 LP |
24 | #include <stdbool.h> |
25 | ||
6629161f LP |
26 | #include "sd-bus.h" |
27 | ||
a8d4cac5 | 28 | #define KDBUS_ITEM_NEXT(item) \ |
c7819669 LP |
29 | (typeof(item))(((uint8_t *)item) + ALIGN8((item)->size)) |
30 | ||
a8d4cac5 | 31 | #define KDBUS_ITEM_FOREACH(part, head, first) \ |
9eb34e82 DM |
32 | for (part = (head)->first; \ |
33 | (uint8_t *)(part) < (uint8_t *)(head) + (head)->size; \ | |
a8d4cac5 | 34 | part = KDBUS_ITEM_NEXT(part)) |
c7819669 | 35 | |
a8d4cac5 KS |
36 | #define KDBUS_ITEM_HEADER_SIZE offsetof(struct kdbus_item, data) |
37 | #define KDBUS_ITEM_SIZE(s) ALIGN8((s) + KDBUS_ITEM_HEADER_SIZE) | |
c7819669 | 38 | |
bc7fd8cd | 39 | #define MEMFD_CACHE_MAX 32 |
66b26c5c LP |
40 | |
41 | /* When we cache a memfd block for reuse, we will truncate blocks | |
42 | * longer than this in order not to keep too much data around. */ | |
832d16a6 | 43 | #define MEMFD_CACHE_ITEM_SIZE_MAX (128*1024) |
66b26c5c LP |
44 | |
45 | /* This determines at which minimum size we prefer sending memfds over | |
46 | * sending vectors */ | |
4a4c0be0 | 47 | #define MEMFD_MIN_SIZE (128*1024) |
bc7fd8cd | 48 | |
63edf05e LP |
49 | /* The size of the per-connection memory pool that we set up and where |
50 | * the kernel places our incoming messages */ | |
51 | #define KDBUS_POOL_SIZE (16*1024*1024) | |
52 | ||
bc7fd8cd LP |
53 | struct memfd_cache { |
54 | int fd; | |
55 | void *address; | |
8e959fbf LP |
56 | size_t mapped; |
57 | size_t allocated; | |
bc7fd8cd LP |
58 | }; |
59 | ||
6629161f LP |
60 | int bus_kernel_connect(sd_bus *b); |
61 | int bus_kernel_take_fd(sd_bus *b); | |
62 | ||
069f5e61 | 63 | int bus_kernel_write_message(sd_bus *bus, sd_bus_message *m, bool hint_sync_call); |
766c5809 | 64 | int bus_kernel_read_message(sd_bus *bus, bool hint_priority, int64_t priority); |
6629161f | 65 | |
f2769777 | 66 | int bus_kernel_create_bus(const char *name, bool world, char **s); |
9bd37b40 | 67 | int bus_kernel_create_namespace(const char *name, char **s); |
e821075a | 68 | int bus_kernel_create_starter(const char *bus, const char *name); |
b6c631f3 | 69 | int bus_kernel_create_monitor(const char *bus); |
bc7fd8cd | 70 | |
8e959fbf LP |
71 | int bus_kernel_pop_memfd(sd_bus *bus, void **address, size_t *mapped, size_t *allocated); |
72 | void bus_kernel_push_memfd(sd_bus *bus, int fd, void *address, size_t mapped, size_t allocated); | |
bc7fd8cd LP |
73 | |
74 | void bus_kernel_flush_memfd(sd_bus *bus); | |
c7819669 LP |
75 | |
76 | int bus_kernel_parse_unique_name(const char *s, uint64_t *id); | |
0253ddcc | 77 | |
98f17eda | 78 | int kdbus_translate_request_name_flags(uint64_t sd_bus_flags, uint64_t *kdbus_flags); |
87b522ae | 79 | int kdbus_translate_attach_flags(uint64_t sd_bus_flags, uint64_t *kdbus_flags); |
ae095f86 LP |
80 | |
81 | int bus_kernel_try_close(sd_bus *bus); |