]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/libsystemd/sd-bus/bus-protocol.h
test: add testcases for the lines prefixed with whitespaces
[thirdparty/systemd.git] / src / libsystemd / sd-bus / bus-protocol.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 #include <endian.h>
5
6 #include "macro.h"
7
8 /* Packet header */
9
10 struct _packed_ bus_header {
11 /* The first four fields are identical for dbus1, and dbus2 */
12 uint8_t endian;
13 uint8_t type;
14 uint8_t flags;
15 uint8_t version;
16
17 union _packed_ {
18 /* dbus1: Used for SOCK_STREAM connections */
19 struct _packed_ {
20 uint32_t body_size;
21
22 /* Note that what the bus spec calls "serial" we'll call
23 "cookie" instead, because we don't want to imply that the
24 cookie was in any way monotonically increasing. */
25 uint32_t serial;
26 uint32_t fields_size;
27 } dbus1;
28
29 /* dbus2: Used for kdbus connections */
30 struct _packed_ {
31 uint32_t _reserved;
32 uint64_t cookie;
33 } dbus2;
34
35 /* Note that both header versions have the same size! */
36 };
37 };
38
39 /* Endianness */
40
41 enum {
42 _BUS_INVALID_ENDIAN = 0,
43 BUS_LITTLE_ENDIAN = 'l',
44 BUS_BIG_ENDIAN = 'B',
45 #if __BYTE_ORDER == __BIG_ENDIAN
46 BUS_NATIVE_ENDIAN = BUS_BIG_ENDIAN,
47 BUS_REVERSE_ENDIAN = BUS_LITTLE_ENDIAN
48 #else
49 BUS_NATIVE_ENDIAN = BUS_LITTLE_ENDIAN,
50 BUS_REVERSE_ENDIAN = BUS_BIG_ENDIAN
51 #endif
52 };
53
54 /* Flags */
55
56 enum {
57 BUS_MESSAGE_NO_REPLY_EXPECTED = 1,
58 BUS_MESSAGE_NO_AUTO_START = 2,
59 BUS_MESSAGE_ALLOW_INTERACTIVE_AUTHORIZATION = 4,
60 };
61
62 /* Header fields */
63
64 enum {
65 _BUS_MESSAGE_HEADER_INVALID = 0,
66 BUS_MESSAGE_HEADER_PATH,
67 BUS_MESSAGE_HEADER_INTERFACE,
68 BUS_MESSAGE_HEADER_MEMBER,
69 BUS_MESSAGE_HEADER_ERROR_NAME,
70 BUS_MESSAGE_HEADER_REPLY_SERIAL,
71 BUS_MESSAGE_HEADER_DESTINATION,
72 BUS_MESSAGE_HEADER_SENDER,
73 BUS_MESSAGE_HEADER_SIGNATURE,
74 BUS_MESSAGE_HEADER_UNIX_FDS,
75 _BUS_MESSAGE_HEADER_MAX
76 };
77
78 /* RequestName parameters */
79
80 enum {
81 BUS_NAME_ALLOW_REPLACEMENT = 1,
82 BUS_NAME_REPLACE_EXISTING = 2,
83 BUS_NAME_DO_NOT_QUEUE = 4
84 };
85
86 /* RequestName returns */
87 enum {
88 BUS_NAME_PRIMARY_OWNER = 1,
89 BUS_NAME_IN_QUEUE = 2,
90 BUS_NAME_EXISTS = 3,
91 BUS_NAME_ALREADY_OWNER = 4
92 };
93
94 /* ReleaseName returns */
95 enum {
96 BUS_NAME_RELEASED = 1,
97 BUS_NAME_NON_EXISTENT = 2,
98 BUS_NAME_NOT_OWNER = 3,
99 };
100
101 /* StartServiceByName returns */
102 enum {
103 BUS_START_REPLY_SUCCESS = 1,
104 BUS_START_REPLY_ALREADY_RUNNING = 2,
105 };
106
107 #define 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 BUS_INTROSPECT_INTERFACE_PEER \
112 " <interface name=\"org.freedesktop.DBus.Peer\">\n" \
113 " <method name=\"Ping\"/>\n" \
114 " <method name=\"GetMachineId\">\n" \
115 " <arg type=\"s\" name=\"machine_uuid\" direction=\"out\"/>\n" \
116 " </method>\n" \
117 " </interface>\n"
118
119 #define BUS_INTROSPECT_INTERFACE_INTROSPECTABLE \
120 " <interface name=\"org.freedesktop.DBus.Introspectable\">\n" \
121 " <method name=\"Introspect\">\n" \
122 " <arg name=\"data\" type=\"s\" direction=\"out\"/>\n" \
123 " </method>\n" \
124 " </interface>\n"
125
126 #define BUS_INTROSPECT_INTERFACE_PROPERTIES \
127 " <interface name=\"org.freedesktop.DBus.Properties\">\n" \
128 " <method name=\"Get\">\n" \
129 " <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n" \
130 " <arg name=\"property\" direction=\"in\" type=\"s\"/>\n" \
131 " <arg name=\"value\" direction=\"out\" type=\"v\"/>\n" \
132 " </method>\n" \
133 " <method name=\"GetAll\">\n" \
134 " <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n" \
135 " <arg name=\"properties\" direction=\"out\" type=\"a{sv}\"/>\n" \
136 " </method>\n" \
137 " <method name=\"Set\">\n" \
138 " <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n" \
139 " <arg name=\"property\" direction=\"in\" type=\"s\"/>\n" \
140 " <arg name=\"value\" direction=\"in\" type=\"v\"/>\n" \
141 " </method>\n" \
142 " <signal name=\"PropertiesChanged\">\n" \
143 " <arg type=\"s\" name=\"interface\"/>\n" \
144 " <arg type=\"a{sv}\" name=\"changed_properties\"/>\n" \
145 " <arg type=\"as\" name=\"invalidated_properties\"/>\n" \
146 " </signal>\n" \
147 " </interface>\n"
148
149 #define BUS_INTROSPECT_INTERFACE_OBJECT_MANAGER \
150 " <interface name=\"org.freedesktop.DBus.ObjectManager\">\n" \
151 " <method name=\"GetManagedObjects\">\n" \
152 " <arg type=\"a{oa{sa{sv}}}\" name=\"object_paths_interfaces_and_properties\" direction=\"out\"/>\n" \
153 " </method>\n" \
154 " <signal name=\"InterfacesAdded\">\n" \
155 " <arg type=\"o\" name=\"object_path\"/>\n" \
156 " <arg type=\"a{sa{sv}}\" name=\"interfaces_and_properties\"/>\n" \
157 " </signal>\n" \
158 " <signal name=\"InterfacesRemoved\">\n" \
159 " <arg type=\"o\" name=\"object_path\"/>\n" \
160 " <arg type=\"as\" name=\"interfaces\"/>\n" \
161 " </signal>\n" \
162 " </interface>\n"