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