]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/libsystemd-bus/sd-bus-protocol.h
ac4d0b1dc53f304a0c49110938c2e87f66b9232f
[thirdparty/systemd.git] / src / libsystemd-bus / sd-bus-protocol.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 #ifndef foosdbusprotocolhfoo
4 #define foosdbusprotocolhfoo
5
6 /***
7 This file is part of systemd.
8
9 Copyright 2013 Lennart Poettering
10
11 systemd is free software; you can redistribute it and/or modify it
12 under the terms of the GNU Lesser General Public License as published by
13 the Free Software Foundation; either version 2.1 of the License, or
14 (at your option) any later version.
15
16 systemd is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 Lesser General Public License for more details.
20
21 You should have received a copy of the GNU Lesser General Public License
22 along with systemd; If not, see <http://www.gnu.org/licenses/>.
23 ***/
24
25 #include <endian.h>
26
27 /* Types of message */
28
29 enum {
30 _SD_BUS_MESSAGE_TYPE_INVALID = 0,
31 SD_BUS_MESSAGE_TYPE_METHOD_CALL,
32 SD_BUS_MESSAGE_TYPE_METHOD_RETURN,
33 SD_BUS_MESSAGE_TYPE_METHOD_ERROR,
34 SD_BUS_MESSAGE_TYPE_SIGNAL,
35 _SD_BUS_MESSAGE_TYPE_MAX
36 };
37
38 /* Primitive types */
39
40 enum {
41 _SD_BUS_TYPE_INVALID = 0,
42 SD_BUS_TYPE_BYTE = 'y',
43 SD_BUS_TYPE_BOOLEAN = 'b',
44 SD_BUS_TYPE_INT16 = 'n',
45 SD_BUS_TYPE_UINT16 = 'q',
46 SD_BUS_TYPE_INT32 = 'i',
47 SD_BUS_TYPE_UINT32 = 'u',
48 SD_BUS_TYPE_INT64 = 'x',
49 SD_BUS_TYPE_UINT64 = 't',
50 SD_BUS_TYPE_DOUBLE = 'd',
51 SD_BUS_TYPE_STRING = 's',
52 SD_BUS_TYPE_OBJECT_PATH = 'o',
53 SD_BUS_TYPE_SIGNATURE = 'g',
54 SD_BUS_TYPE_UNIX_FD = 'h',
55 SD_BUS_TYPE_ARRAY = 'a',
56 SD_BUS_TYPE_VARIANT = 'v',
57 SD_BUS_TYPE_STRUCT = 'r', /* not actually used in signatures */
58 SD_BUS_TYPE_STRUCT_BEGIN = '(',
59 SD_BUS_TYPE_STRUCT_END = ')',
60 SD_BUS_TYPE_DICT_ENTRY = 'e', /* not actually used in signatures */
61 SD_BUS_TYPE_DICT_ENTRY_BEGIN = '{',
62 SD_BUS_TYPE_DICT_ENTRY_END = '}',
63 };
64
65 /* Endianess */
66
67 enum {
68 _SD_BUS_INVALID_ENDIAN = 0,
69 SD_BUS_LITTLE_ENDIAN = 'l',
70 SD_BUS_BIG_ENDIAN = 'B',
71 #if __BYTE_ORDER == __BIG_ENDIAN
72 SD_BUS_NATIVE_ENDIAN = SD_BUS_BIG_ENDIAN,
73 SD_BUS_REVERSE_ENDIAN = SD_BUS_LITTLE_ENDIAN
74 #else
75 SD_BUS_NATIVE_ENDIAN = SD_BUS_LITTLE_ENDIAN,
76 SD_BUS_REVERSE_ENDIAN = SD_BUS_BIG_ENDIAN
77 #endif
78 };
79
80 /* Flags */
81
82 enum {
83 SD_BUS_MESSAGE_NO_REPLY_EXPECTED = 1,
84 SD_BUS_MESSAGE_NO_AUTO_START = 2
85 };
86
87 /* Header fields */
88
89 enum {
90 _SD_BUS_MESSAGE_HEADER_INVALID = 0,
91 SD_BUS_MESSAGE_HEADER_PATH,
92 SD_BUS_MESSAGE_HEADER_INTERFACE,
93 SD_BUS_MESSAGE_HEADER_MEMBER,
94 SD_BUS_MESSAGE_HEADER_ERROR_NAME,
95 SD_BUS_MESSAGE_HEADER_REPLY_SERIAL,
96 SD_BUS_MESSAGE_HEADER_DESTINATION,
97 SD_BUS_MESSAGE_HEADER_SENDER,
98 SD_BUS_MESSAGE_HEADER_SIGNATURE,
99 SD_BUS_MESSAGE_HEADER_UNIX_FDS,
100 _SD_BUS_MESSAGE_HEADER_MAX
101 };
102
103 #define SD_BUS_INTROSPECT_DOCTYPE \
104 "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n" \
105 "\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
106
107 #define SD_BUS_INTROSPECT_INTERFACE_PROPERTIES \
108 " <interface name=\"org.freedesktop.DBus.Properties\">\n" \
109 " <method name=\"Get\">\n" \
110 " <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n" \
111 " <arg name=\"property\" direction=\"in\" type=\"s\"/>\n" \
112 " <arg name=\"value\" direction=\"out\" type=\"v\"/>\n" \
113 " </method>\n" \
114 " <method name=\"GetAll\">\n" \
115 " <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n" \
116 " <arg name=\"properties\" direction=\"out\" type=\"a{sv}\"/>\n" \
117 " </method>\n" \
118 " <method name=\"Set\">\n" \
119 " <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n" \
120 " <arg name=\"property\" direction=\"in\" type=\"s\"/>\n" \
121 " <arg name=\"value\" direction=\"in\" type=\"v\"/>\n" \
122 " </method>\n" \
123 " <signal name=\"PropertiesChanged\">\n" \
124 " <arg type=\"s\" name=\"interface\"/>\n" \
125 " <arg type=\"a{sv}\" name=\"changed_properties\"/>\n" \
126 " <arg type=\"as\" name=\"invalidated_properties\"/>\n" \
127 " </signal>\n" \
128 " </interface>\n"
129
130 #define SD_BUS_INTROSPECT_INTERFACE_INTROSPECTABLE \
131 " <interface name=\"org.freedesktop.DBus.Introspectable\">\n" \
132 " <method name=\"Introspect\">\n" \
133 " <arg name=\"data\" type=\"s\" direction=\"out\"/>\n" \
134 " </method>\n" \
135 " </interface>\n"
136
137 #define SD_BUS_INTROSPECT_INTERFACE_PEER \
138 "<interface name=\"org.freedesktop.DBus.Peer\">\n" \
139 " <method name=\"Ping\"/>\n" \
140 " <method name=\"GetMachineId\">\n" \
141 " <arg type=\"s\" name=\"machine_uuid\" direction=\"out\"/>\n" \
142 " </method>\n" \
143 "</interface>\n"
144
145 #endif