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