chiark / gitweb /
bus: parse capability kdbus meta data of messages
[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_TYPE_METHOD_CALL,
36         SD_BUS_MESSAGE_TYPE_METHOD_RETURN,
37         SD_BUS_MESSAGE_TYPE_METHOD_ERROR,
38         SD_BUS_MESSAGE_TYPE_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 #define SD_BUS_INTROSPECT_DOCTYPE                                       \
108         "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n" \
109         "\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
110
111 #define SD_BUS_INTROSPECT_INTERFACE_PROPERTIES                          \
112         " <interface name=\"org.freedesktop.DBus.Properties\">\n"       \
113         "  <method name=\"Get\">\n"                                     \
114         "   <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n"    \
115         "   <arg name=\"property\" direction=\"in\" type=\"s\"/>\n"     \
116         "   <arg name=\"value\" direction=\"out\" type=\"v\"/>\n"       \
117         "  </method>\n"                                                 \
118         "  <method name=\"GetAll\">\n"                                  \
119         "   <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n"    \
120         "   <arg name=\"properties\" direction=\"out\" type=\"a{sv}\"/>\n" \
121         "  </method>\n"                                                 \
122         "  <method name=\"Set\">\n"                                     \
123         "   <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n"    \
124         "   <arg name=\"property\" direction=\"in\" type=\"s\"/>\n"     \
125         "   <arg name=\"value\" direction=\"in\" type=\"v\"/>\n"        \
126         "  </method>\n"                                                 \
127         "  <signal name=\"PropertiesChanged\">\n"                       \
128         "   <arg type=\"s\" name=\"interface\"/>\n"                     \
129         "   <arg type=\"a{sv}\" name=\"changed_properties\"/>\n"        \
130         "   <arg type=\"as\" name=\"invalidated_properties\"/>\n"       \
131         "  </signal>\n"                                                 \
132         " </interface>\n"
133
134 #define SD_BUS_INTROSPECT_INTERFACE_INTROSPECTABLE                      \
135         " <interface name=\"org.freedesktop.DBus.Introspectable\">\n"   \
136         "  <method name=\"Introspect\">\n"                              \
137         "   <arg name=\"data\" type=\"s\" direction=\"out\"/>\n"        \
138         "  </method>\n"                                                 \
139         " </interface>\n"
140
141 #define SD_BUS_INTROSPECT_INTERFACE_PEER                                \
142         "<interface name=\"org.freedesktop.DBus.Peer\">\n"              \
143         " <method name=\"Ping\"/>\n"                                    \
144         " <method name=\"GetMachineId\">\n"                             \
145         "  <arg type=\"s\" name=\"machine_uuid\" direction=\"out\"/>\n" \
146         " </method>\n"                                                  \
147         "</interface>\n"
148
149 #ifdef __cplusplus
150 }
151 #endif
152
153 #endif