]>
Commit | Line | Data |
---|---|---|
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 | |
8 | ||
9 | systemd is free software; you can redistribute it and/or modify it | |
10 | under the terms of the GNU Lesser General Public License as published by | |
11 | the Free Software Foundation; either version 2.1 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | systemd is distributed in the hope that it will be useful, but | |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 | Lesser General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU Lesser General Public License | |
20 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
21 | ***/ | |
22 | ||
6017365a | 23 | #include <endian.h> |
0461f8cd | 24 | |
2ac7c17f LP |
25 | #include "macro.h" |
26 | ||
22d097a6 LP |
27 | /* Packet header */ |
28 | ||
2ac7c17f LP |
29 | struct _packed_ bus_header { |
30 | /* The first four fields are identical for dbus1, and dbus2 */ | |
22d097a6 LP |
31 | uint8_t endian; |
32 | uint8_t type; | |
33 | uint8_t flags; | |
34 | uint8_t version; | |
2ac7c17f LP |
35 | |
36 | union _packed_ { | |
37 | /* dbus1: Used for SOCK_STREAM connections */ | |
38 | struct _packed_ { | |
39 | uint32_t body_size; | |
40 | ||
41 | /* Note that what the bus spec calls "serial" we'll call | |
42 | "cookie" instead, because we don't want to imply that the | |
43 | cookie was in any way monotonically increasing. */ | |
44 | uint32_t serial; | |
45 | uint32_t fields_size; | |
46 | } dbus1; | |
47 | ||
48 | /* dbus2: Used for kdbus connections */ | |
49 | struct _packed_ { | |
50 | uint32_t _reserved; | |
51 | uint64_t cookie; | |
52 | } dbus2; | |
53 | ||
54 | /* Note that both header versions have the same size! */ | |
55 | }; | |
56 | }; | |
22d097a6 | 57 | |
0461f8cd LP |
58 | /* Endianness */ |
59 | ||
60 | enum { | |
61 | _BUS_INVALID_ENDIAN = 0, | |
62 | BUS_LITTLE_ENDIAN = 'l', | |
63 | BUS_BIG_ENDIAN = 'B', | |
64 | #if __BYTE_ORDER == __BIG_ENDIAN | |
65 | BUS_NATIVE_ENDIAN = BUS_BIG_ENDIAN, | |
66 | BUS_REVERSE_ENDIAN = BUS_LITTLE_ENDIAN | |
67 | #else | |
68 | BUS_NATIVE_ENDIAN = BUS_LITTLE_ENDIAN, | |
69 | BUS_REVERSE_ENDIAN = BUS_BIG_ENDIAN | |
70 | #endif | |
71 | }; | |
72 | ||
73 | /* Flags */ | |
74 | ||
75 | enum { | |
76 | BUS_MESSAGE_NO_REPLY_EXPECTED = 1, | |
53a83f4b LP |
77 | BUS_MESSAGE_NO_AUTO_START = 2, |
78 | BUS_MESSAGE_ALLOW_INTERACTIVE_AUTHORIZATION = 4, | |
0461f8cd LP |
79 | }; |
80 | ||
81 | /* Header fields */ | |
82 | ||
83 | enum { | |
84 | _BUS_MESSAGE_HEADER_INVALID = 0, | |
85 | BUS_MESSAGE_HEADER_PATH, | |
86 | BUS_MESSAGE_HEADER_INTERFACE, | |
87 | BUS_MESSAGE_HEADER_MEMBER, | |
88 | BUS_MESSAGE_HEADER_ERROR_NAME, | |
89 | BUS_MESSAGE_HEADER_REPLY_SERIAL, | |
90 | BUS_MESSAGE_HEADER_DESTINATION, | |
91 | BUS_MESSAGE_HEADER_SENDER, | |
92 | BUS_MESSAGE_HEADER_SIGNATURE, | |
93 | BUS_MESSAGE_HEADER_UNIX_FDS, | |
94 | _BUS_MESSAGE_HEADER_MAX | |
95 | }; | |
96 | ||
29a07cdb LP |
97 | /* RequestName parameters */ |
98 | ||
99 | enum { | |
100 | BUS_NAME_ALLOW_REPLACEMENT = 1, | |
101 | BUS_NAME_REPLACE_EXISTING = 2, | |
102 | BUS_NAME_DO_NOT_QUEUE = 4 | |
103 | }; | |
104 | ||
0461f8cd LP |
105 | /* RequestName returns */ |
106 | enum { | |
107 | BUS_NAME_PRIMARY_OWNER = 1, | |
108 | BUS_NAME_IN_QUEUE = 2, | |
109 | BUS_NAME_EXISTS = 3, | |
110 | BUS_NAME_ALREADY_OWNER = 4 | |
111 | }; | |
112 | ||
113 | /* ReleaseName returns */ | |
114 | enum { | |
115 | BUS_NAME_RELEASED = 1, | |
116 | BUS_NAME_NON_EXISTENT = 2, | |
117 | BUS_NAME_NOT_OWNER = 3, | |
118 | }; | |
119 | ||
71ebe743 LP |
120 | /* StartServiceByName returns */ |
121 | enum { | |
122 | BUS_START_REPLY_SUCCESS = 1, | |
123 | BUS_START_REPLY_ALREADY_RUNNING = 2, | |
124 | }; | |
125 | ||
0461f8cd LP |
126 | #define BUS_INTROSPECT_DOCTYPE \ |
127 | "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n" \ | |
128 | "\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n" | |
129 | ||
130 | #define BUS_INTROSPECT_INTERFACE_PEER \ | |
131 | " <interface name=\"org.freedesktop.DBus.Peer\">\n" \ | |
132 | " <method name=\"Ping\"/>\n" \ | |
133 | " <method name=\"GetMachineId\">\n" \ | |
134 | " <arg type=\"s\" name=\"machine_uuid\" direction=\"out\"/>\n" \ | |
135 | " </method>\n" \ | |
136 | " </interface>\n" | |
137 | ||
138 | #define BUS_INTROSPECT_INTERFACE_INTROSPECTABLE \ | |
139 | " <interface name=\"org.freedesktop.DBus.Introspectable\">\n" \ | |
140 | " <method name=\"Introspect\">\n" \ | |
141 | " <arg name=\"data\" type=\"s\" direction=\"out\"/>\n" \ | |
142 | " </method>\n" \ | |
143 | " </interface>\n" | |
144 | ||
145 | #define BUS_INTROSPECT_INTERFACE_PROPERTIES \ | |
146 | " <interface name=\"org.freedesktop.DBus.Properties\">\n" \ | |
147 | " <method name=\"Get\">\n" \ | |
148 | " <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n" \ | |
149 | " <arg name=\"property\" direction=\"in\" type=\"s\"/>\n" \ | |
150 | " <arg name=\"value\" direction=\"out\" type=\"v\"/>\n" \ | |
151 | " </method>\n" \ | |
152 | " <method name=\"GetAll\">\n" \ | |
153 | " <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n" \ | |
154 | " <arg name=\"properties\" direction=\"out\" type=\"a{sv}\"/>\n" \ | |
155 | " </method>\n" \ | |
156 | " <method name=\"Set\">\n" \ | |
157 | " <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n" \ | |
158 | " <arg name=\"property\" direction=\"in\" type=\"s\"/>\n" \ | |
159 | " <arg name=\"value\" direction=\"in\" type=\"v\"/>\n" \ | |
160 | " </method>\n" \ | |
161 | " <signal name=\"PropertiesChanged\">\n" \ | |
162 | " <arg type=\"s\" name=\"interface\"/>\n" \ | |
163 | " <arg type=\"a{sv}\" name=\"changed_properties\"/>\n" \ | |
164 | " <arg type=\"as\" name=\"invalidated_properties\"/>\n" \ | |
165 | " </signal>\n" \ | |
166 | " </interface>\n" | |
167 | ||
168 | #define BUS_INTROSPECT_INTERFACE_OBJECT_MANAGER \ | |
169 | " <interface name=\"org.freedesktop.DBus.ObjectManager\">\n" \ | |
170 | " <method name=\"GetManagedObjects\">\n" \ | |
171 | " <arg type=\"a{oa{sa{sv}}}\" name=\"object_paths_interfaces_and_properties\" direction=\"out\"/>\n" \ | |
172 | " </method>\n" \ | |
173 | " <signal name=\"InterfacesAdded\">\n" \ | |
174 | " <arg type=\"o\" name=\"object_path\"/>\n" \ | |
175 | " <arg type=\"a{sa{sv}}\" name=\"interfaces_and_properties\"/>\n" \ | |
176 | " </signal>\n" \ | |
177 | " <signal name=\"InterfacesRemoved\">\n" \ | |
178 | " <arg type=\"o\" name=\"object_path\"/>\n" \ | |
179 | " <arg type=\"as\" name=\"interfaces\"/>\n" \ | |
180 | " </signal>\n" \ | |
181 | " </interface>\n" |