chiark / gitweb /
timedated: use libsystemd-bus instead of libdbus for bus communication
[elogind.git] / src / systemd / 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 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 /* Types of message */
32
33 enum {
34         _SD_BUS_MESSAGE_TYPE_INVALID = 0,
35         SD_BUS_MESSAGE_METHOD_CALL,
36         SD_BUS_MESSAGE_METHOD_RETURN,
37         SD_BUS_MESSAGE_METHOD_ERROR,
38         SD_BUS_MESSAGE_SIGNAL,
39         _SD_BUS_MESSAGE_TYPE_MAX
40 };
41
42 /* Primitive types */
43
44 enum {
45         _SD_BUS_TYPE_INVALID         = 0,
46         SD_BUS_TYPE_BYTE             = 'y',
47         SD_BUS_TYPE_BOOLEAN          = 'b',
48         SD_BUS_TYPE_INT16            = 'n',
49         SD_BUS_TYPE_UINT16           = 'q',
50         SD_BUS_TYPE_INT32            = 'i',
51         SD_BUS_TYPE_UINT32           = 'u',
52         SD_BUS_TYPE_INT64            = 'x',
53         SD_BUS_TYPE_UINT64           = 't',
54         SD_BUS_TYPE_DOUBLE           = 'd',
55         SD_BUS_TYPE_STRING           = 's',
56         SD_BUS_TYPE_OBJECT_PATH      = 'o',
57         SD_BUS_TYPE_SIGNATURE        = 'g',
58         SD_BUS_TYPE_UNIX_FD          = 'h',
59         SD_BUS_TYPE_ARRAY            = 'a',
60         SD_BUS_TYPE_VARIANT          = 'v',
61         SD_BUS_TYPE_STRUCT           = 'r', /* not actually used in signatures */
62         SD_BUS_TYPE_STRUCT_BEGIN     = '(',
63         SD_BUS_TYPE_STRUCT_END       = ')',
64         SD_BUS_TYPE_DICT_ENTRY       = 'e', /* not actually used in signatures */
65         SD_BUS_TYPE_DICT_ENTRY_BEGIN = '{',
66         SD_BUS_TYPE_DICT_ENTRY_END   = '}',
67 };
68
69 /* Endianness */
70
71 enum {
72         _SD_BUS_INVALID_ENDIAN = 0,
73         SD_BUS_LITTLE_ENDIAN   = 'l',
74         SD_BUS_BIG_ENDIAN      = 'B',
75 #if __BYTE_ORDER == __BIG_ENDIAN
76         SD_BUS_NATIVE_ENDIAN   = SD_BUS_BIG_ENDIAN,
77         SD_BUS_REVERSE_ENDIAN  = SD_BUS_LITTLE_ENDIAN
78 #else
79         SD_BUS_NATIVE_ENDIAN   = SD_BUS_LITTLE_ENDIAN,
80         SD_BUS_REVERSE_ENDIAN  = SD_BUS_BIG_ENDIAN
81 #endif
82 };
83
84 /* Flags */
85
86 enum {
87         SD_BUS_MESSAGE_NO_REPLY_EXPECTED = 1,
88         SD_BUS_MESSAGE_NO_AUTO_START = 2
89 };
90
91 /* Header fields */
92
93 enum {
94         _SD_BUS_MESSAGE_HEADER_INVALID = 0,
95         SD_BUS_MESSAGE_HEADER_PATH,
96         SD_BUS_MESSAGE_HEADER_INTERFACE,
97         SD_BUS_MESSAGE_HEADER_MEMBER,
98         SD_BUS_MESSAGE_HEADER_ERROR_NAME,
99         SD_BUS_MESSAGE_HEADER_REPLY_SERIAL,
100         SD_BUS_MESSAGE_HEADER_DESTINATION,
101         SD_BUS_MESSAGE_HEADER_SENDER,
102         SD_BUS_MESSAGE_HEADER_SIGNATURE,
103         SD_BUS_MESSAGE_HEADER_UNIX_FDS,
104         _SD_BUS_MESSAGE_HEADER_MAX
105 };
106
107 /* RequestName parameters */
108 enum  {
109         SD_BUS_NAME_ALLOW_REPLACEMENT = 1,
110         SD_BUS_NAME_REPLACE_EXISTING = 2,
111         SD_BUS_NAME_DO_NOT_QUEUE = 4
112 };
113
114 /* RequestName returns */
115 enum  {
116         SD_BUS_NAME_PRIMARY_OWNER = 1,
117         SD_BUS_NAME_IN_QUEUE = 2,
118         SD_BUS_NAME_EXISTS = 3,
119         SD_BUS_NAME_ALREADY_OWNER = 4
120 };
121
122 /* ReleaseName returns */
123 enum {
124         SD_BUS_NAME_RELEASED = 1,
125         SD_BUS_NAME_NON_EXISTENT = 2,
126         SD_BUS_NAME_NOT_OWNER = 3,
127 };
128
129 #define SD_BUS_INTROSPECT_DOCTYPE                                       \
130         "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n" \
131         "\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
132
133 #define SD_BUS_INTROSPECT_INTERFACE_PEER                                \
134         " <interface name=\"org.freedesktop.DBus.Peer\">\n"             \
135         "  <method name=\"Ping\"/>\n"                                   \
136         "  <method name=\"GetMachineId\">\n"                            \
137         "   <arg type=\"s\" name=\"machine_uuid\" direction=\"out\"/>\n" \
138         "  </method>\n"                                                 \
139         " </interface>\n"
140
141 #define SD_BUS_INTROSPECT_INTERFACE_INTROSPECTABLE                      \
142         " <interface name=\"org.freedesktop.DBus.Introspectable\">\n"   \
143         "  <method name=\"Introspect\">\n"                              \
144         "   <arg name=\"data\" type=\"s\" direction=\"out\"/>\n"        \
145         "  </method>\n"                                                 \
146         " </interface>\n"
147
148 #define SD_BUS_INTROSPECT_INTERFACE_PROPERTIES                          \
149         " <interface name=\"org.freedesktop.DBus.Properties\">\n"       \
150         "  <method name=\"Get\">\n"                                     \
151         "   <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n"    \
152         "   <arg name=\"property\" direction=\"in\" type=\"s\"/>\n"     \
153         "   <arg name=\"value\" direction=\"out\" type=\"v\"/>\n"       \
154         "  </method>\n"                                                 \
155         "  <method name=\"GetAll\">\n"                                  \
156         "   <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n"    \
157         "   <arg name=\"properties\" direction=\"out\" type=\"a{sv}\"/>\n" \
158         "  </method>\n"                                                 \
159         "  <method name=\"Set\">\n"                                     \
160         "   <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n"    \
161         "   <arg name=\"property\" direction=\"in\" type=\"s\"/>\n"     \
162         "   <arg name=\"value\" direction=\"in\" type=\"v\"/>\n"        \
163         "  </method>\n"                                                 \
164         "  <signal name=\"PropertiesChanged\">\n"                       \
165         "   <arg type=\"s\" name=\"interface\"/>\n"                     \
166         "   <arg type=\"a{sv}\" name=\"changed_properties\"/>\n"        \
167         "   <arg type=\"as\" name=\"invalidated_properties\"/>\n"       \
168         "  </signal>\n"                                                 \
169         " </interface>\n"
170
171 #define SD_BUS_INTROSPECT_INTERFACE_OBJECT_MANAGER                      \
172         " <interface name=\"org.freedesktop.DBus.ObjectManager\">\n"    \
173         "  <method name=\"GetManagedObjects\">\n"                       \
174         "   <arg type=\"a{oa{sa{sv}}}\" name=\"object_paths_interfaces_and_properties\" direction=\"out\"/>\n" \
175         "  </method>\n"                                                 \
176         "  <signal name=\"InterfacesAdded\">\n"                         \
177         "   <arg type=\"o\" name=\"object_path\"/>\n"                   \
178         "   <arg type=\"a{sa{sv}}\" name=\"interfaces_and_properties\"/>\n" \
179         "  </signal>\n"                                                 \
180         "  <signal name=\"InterfacesRemoved\">\n"                       \
181         "   <arg type=\"o\" name=\"object_path\"/>\n"                   \
182         "   <arg type=\"as\" name=\"interfaces\"/>\n"                   \
183         "  </signal>\n"                                                 \
184         " </interface>\n"
185
186 /* Well-known errors. Note that this is only a sanitized subset of the
187  * errors that the reference implementation generates. */
188 #define SD_BUS_ERROR_FAILED                     "org.freedesktop.DBus.Error.Failed"
189 #define SD_BUS_ERROR_NO_MEMORY                  "org.freedesktop.DBus.Error.NoMemory"
190 #define SD_BUS_ERROR_SERVICE_UNKNOWN            "org.freedesktop.DBus.Error.ServiceUnknown"
191 #define SD_BUS_ERROR_NAME_HAS_NO_OWNER          "org.freedesktop.DBus.Error.NameHasNoOwner"
192 #define SD_BUS_ERROR_NO_REPLY                   "org.freedesktop.DBus.Error.NoReply"
193 #define SD_BUS_ERROR_IO_ERROR                   "org.freedesktop.DBus.Error.IOError"
194 #define SD_BUS_ERROR_BAD_ADDRESS                "org.freedesktop.DBus.Error.BadAddress"
195 #define SD_BUS_ERROR_NOT_SUPPORTED              "org.freedesktop.DBus.Error.NotSupported"
196 #define SD_BUS_ERROR_LIMITS_EXCEEDED            "org.freedesktop.DBus.Error.LimitsExceeded"
197 #define SD_BUS_ERROR_ACCESS_DENIED              "org.freedesktop.DBus.Error.AccessDenied"
198 #define SD_BUS_ERROR_AUTH_FAILED                "org.freedesktop.DBus.Error.AuthFailed"
199 #define SD_BUS_ERROR_NO_SERVER                  "org.freedesktop.DBus.Error.NoServer"
200 #define SD_BUS_ERROR_TIMEOUT                    "org.freedesktop.DBus.Error.Timeout"
201 #define SD_BUS_ERROR_NO_NETWORK                 "org.freedesktop.DBus.Error.NoNetwork"
202 #define SD_BUS_ERROR_ADDRESS_IN_USE             "org.freedesktop.DBus.Error.AddressInUse"
203 #define SD_BUS_ERROR_DISCONNECTED               "org.freedesktop.DBus.Error.Disconnected"
204 #define SD_BUS_ERROR_INVALID_ARGS               "org.freedesktop.DBus.Error.InvalidArgs"
205 #define SD_BUS_ERROR_FILE_NOT_FOUND             "org.freedesktop.DBus.Error.FileNotFound"
206 #define SD_BUS_ERROR_FILE_EXISTS                "org.freedesktop.DBus.Error.FileExists"
207 #define SD_BUS_ERROR_UNKNOWN_METHOD             "org.freedesktop.DBus.Error.UnknownMethod"
208 #define SD_BUS_ERROR_UNKNOWN_OBJECT             "org.freedesktop.DBus.Error.UnknownObject"
209 #define SD_BUS_ERROR_UNKNOWN_INTERFACE          "org.freedesktop.DBus.Error.UnknownInterface"
210 #define SD_BUS_ERROR_UNKNOWN_PROPERTY           "org.freedesktop.DBus.Error.UnknownProperty"
211 #define SD_BUS_ERROR_PROPERTY_READ_ONLY         "org.freedesktop.DBus.Error.PropertyReadOnly"
212 #define SD_BUS_ERROR_UNIX_PROCESS_ID_UNKNOWN    "org.freedesktop.DBus.Error.UnixProcessIdUnknown"
213 #define SD_BUS_ERROR_INVALID_SIGNATURE          "org.freedesktop.DBus.Error.InvalidSignature"
214 #define SD_BUS_ERROR_INCONSISTENT_MESSAGE       "org.freedesktop.DBus.Error.InconsistentMessage"
215
216 #ifdef __cplusplus
217 }
218 #endif
219
220 #endif