]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/systemd/sd-bus-vtable.h
networkd: rework headers to avoid circular includes
[thirdparty/systemd.git] / src / systemd / sd-bus-vtable.h
CommitLineData
29ddb38f
LP
1#ifndef foosdbusvtablehfoo
2#define foosdbusvtablehfoo
3
4/***
5 This file is part of systemd.
6
7 Copyright 2013 Lennart Poettering
8
9 systemd is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation; either version 2.1 of the License, or
12 (at your option) any later version.
13
14 systemd is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with systemd; If not, see <http://www.gnu.org/licenses/>.
21***/
22
0095c454
LP
23#include "_sd-common.h"
24
25_SD_BEGIN_DECLARATIONS;
6695ed7a 26
29ddb38f
LP
27typedef struct sd_bus_vtable sd_bus_vtable;
28
29#include "sd-bus.h"
30
31enum {
adacb957
LP
32 _SD_BUS_VTABLE_START = '<',
33 _SD_BUS_VTABLE_END = '>',
34 _SD_BUS_VTABLE_METHOD = 'M',
35 _SD_BUS_VTABLE_SIGNAL = 'S',
36 _SD_BUS_VTABLE_PROPERTY = 'P',
e0c0b07d 37 _SD_BUS_VTABLE_WRITABLE_PROPERTY = 'W'
29ddb38f
LP
38};
39
40enum {
df98a87b
LP
41 SD_BUS_VTABLE_DEPRECATED = 1ULL << 0,
42 SD_BUS_VTABLE_HIDDEN = 1ULL << 1,
43 SD_BUS_VTABLE_UNPRIVILEGED = 1ULL << 2,
44 SD_BUS_VTABLE_METHOD_NO_REPLY = 1ULL << 3,
45 SD_BUS_VTABLE_PROPERTY_CONST = 1ULL << 4,
46 SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE = 1ULL << 5,
47 SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION = 1ULL << 6,
33702051 48 SD_BUS_VTABLE_PROPERTY_EXPLICIT = 1ULL << 7,
df98a87b 49 _SD_BUS_VTABLE_CAPABILITY_MASK = 0xFFFFULL << 40
29ddb38f
LP
50};
51
adacb957
LP
52#define SD_BUS_VTABLE_CAPABILITY(x) ((uint64_t) (((x)+1) & 0xFFFF) << 40)
53
29ddb38f
LP
54struct sd_bus_vtable {
55 /* Please do not initialize this structure directly, use the
56 * macros below instead */
57
adacb957
LP
58 uint8_t type:8;
59 uint64_t flags:56;
29ddb38f
LP
60 union {
61 struct {
62 size_t element_size;
63 } start;
64 struct {
65 const char *member;
66 const char *signature;
67 const char *result;
68 sd_bus_message_handler_t handler;
09c8a7c6 69 size_t offset;
29ddb38f
LP
70 } method;
71 struct {
72 const char *member;
73 const char *signature;
74 } signal;
75 struct {
76 const char *member;
77 const char *signature;
78 sd_bus_property_get_t get;
79 sd_bus_property_set_t set;
80 size_t offset;
81 } property;
77a874a3 82 } x;
29ddb38f
LP
83};
84
85#define SD_BUS_VTABLE_START(_flags) \
86 { \
87 .type = _SD_BUS_VTABLE_START, \
88 .flags = _flags, \
77a874a3 89 .x.start.element_size = sizeof(sd_bus_vtable), \
29ddb38f
LP
90 }
91
29ddae7b 92#define SD_BUS_METHOD_WITH_OFFSET(_member, _signature, _result, _handler, _offset, _flags) \
29ddb38f
LP
93 { \
94 .type = _SD_BUS_VTABLE_METHOD, \
95 .flags = _flags, \
77a874a3
LP
96 .x.method.member = _member, \
97 .x.method.signature = _signature, \
98 .x.method.result = _result, \
99 .x.method.handler = _handler, \
09c8a7c6 100 .x.method.offset = _offset, \
29ddb38f 101 }
09c8a7c6 102#define SD_BUS_METHOD(_member, _signature, _result, _handler, _flags) \
29ddae7b 103 SD_BUS_METHOD_WITH_OFFSET(_member, _signature, _result, _handler, 0, _flags)
29ddb38f
LP
104
105#define SD_BUS_SIGNAL(_member, _signature, _flags) \
106 { \
107 .type = _SD_BUS_VTABLE_SIGNAL, \
108 .flags = _flags, \
77a874a3
LP
109 .x.signal.member = _member, \
110 .x.signal.signature = _signature, \
29ddb38f
LP
111 }
112
77a874a3 113#define SD_BUS_PROPERTY(_member, _signature, _get, _offset, _flags) \
29ddb38f
LP
114 { \
115 .type = _SD_BUS_VTABLE_PROPERTY, \
116 .flags = _flags, \
77a874a3
LP
117 .x.property.member = _member, \
118 .x.property.signature = _signature, \
119 .x.property.get = _get, \
120 .x.property.offset = _offset, \
29ddb38f
LP
121 }
122
123#define SD_BUS_WRITABLE_PROPERTY(_member, _signature, _get, _set, _offset, _flags) \
124 { \
125 .type = _SD_BUS_VTABLE_WRITABLE_PROPERTY, \
126 .flags = _flags, \
77a874a3
LP
127 .x.property.member = _member, \
128 .x.property.signature = _signature, \
129 .x.property.get = _get, \
130 .x.property.set = _set, \
131 .x.property.offset = _offset, \
29ddb38f
LP
132 }
133
134#define SD_BUS_VTABLE_END \
135 { \
136 .type = _SD_BUS_VTABLE_END, \
137 }
138
0095c454 139_SD_END_DECLARATIONS;
6695ed7a 140
29ddb38f 141#endif