1 /* -*- mode: C; c-file-style: "gnu" -*- */
2 /* dbus-protocol.h D-Bus protocol constants
4 * Copyright (C) 2002, 2003 CodeFactory AB
5 * Copyright (C) 2004, 2005 Red Hat, Inc.
7 * Licensed under the Academic Free License version 2.1
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #ifndef DBUS_PROTOCOL_H
26 #define DBUS_PROTOCOL_H
28 /* Don't include anything in here from anywhere else. It's
29 * intended for use by any random library.
36 /* Message byte order */
37 #define DBUS_LITTLE_ENDIAN ('l') /* LSB first */
38 #define DBUS_BIG_ENDIAN ('B') /* MSB first */
40 /* Protocol version */
41 #define DBUS_MAJOR_PROTOCOL_VERSION 1
43 /* Never a legitimate type */
44 #define DBUS_TYPE_INVALID ((int) '\0')
45 #define DBUS_TYPE_INVALID_AS_STRING "\0"
48 #define DBUS_TYPE_BYTE ((int) 'y')
49 #define DBUS_TYPE_BYTE_AS_STRING "y"
50 #define DBUS_TYPE_BOOLEAN ((int) 'b')
51 #define DBUS_TYPE_BOOLEAN_AS_STRING "b"
52 #define DBUS_TYPE_INT16 ((int) 'n')
53 #define DBUS_TYPE_INT16_AS_STRING "n"
54 #define DBUS_TYPE_UINT16 ((int) 'q')
55 #define DBUS_TYPE_UINT16_AS_STRING "q"
56 #define DBUS_TYPE_INT32 ((int) 'i')
57 #define DBUS_TYPE_INT32_AS_STRING "i"
58 #define DBUS_TYPE_UINT32 ((int) 'u')
59 #define DBUS_TYPE_UINT32_AS_STRING "u"
60 #define DBUS_TYPE_INT64 ((int) 'x')
61 #define DBUS_TYPE_INT64_AS_STRING "x"
62 #define DBUS_TYPE_UINT64 ((int) 't')
63 #define DBUS_TYPE_UINT64_AS_STRING "t"
65 #define DBUS_TYPE_DOUBLE ((int) 'd')
66 #define DBUS_TYPE_DOUBLE_AS_STRING "d"
67 #define DBUS_TYPE_STRING ((int) 's')
68 #define DBUS_TYPE_STRING_AS_STRING "s"
69 #define DBUS_TYPE_OBJECT_PATH ((int) 'o')
70 #define DBUS_TYPE_OBJECT_PATH_AS_STRING "o"
71 #define DBUS_TYPE_SIGNATURE ((int) 'g')
72 #define DBUS_TYPE_SIGNATURE_AS_STRING "g"
75 #define DBUS_TYPE_ARRAY ((int) 'a')
76 #define DBUS_TYPE_ARRAY_AS_STRING "a"
77 #define DBUS_TYPE_VARIANT ((int) 'v')
78 #define DBUS_TYPE_VARIANT_AS_STRING "v"
80 /* STRUCT is sort of special since its code can't appear in a type string,
81 * instead DBUS_STRUCT_BEGIN_CHAR has to appear
83 #define DBUS_TYPE_STRUCT ((int) 'r')
84 #define DBUS_TYPE_STRUCT_AS_STRING "r"
86 /* Does not count INVALID */
87 #define DBUS_NUMBER_OF_TYPES (15)
89 /* characters other than typecodes that appear in type signatures */
90 #define DBUS_STRUCT_BEGIN_CHAR ((int) '(')
91 #define DBUS_STRUCT_BEGIN_CHAR_AS_STRING "("
92 #define DBUS_STRUCT_END_CHAR ((int) ')')
93 #define DBUS_STRUCT_END_CHAR_AS_STRING ")"
95 /* Max length in bytes of a bus name, interface, or member (not object
96 * path, paths are unlimited). This is limited because lots of stuff
97 * is O(n) in this number, plus it would be obnoxious to type in a
98 * paragraph-long method name so most likely something like that would
101 #define DBUS_MAXIMUM_NAME_LENGTH 255
103 /* This one is 255 so it fits in a byte */
104 #define DBUS_MAXIMUM_SIGNATURE_LENGTH 255
106 /* Max length of a match rule string; to keep people from hosing the
107 * daemon with some huge rule
109 #define DBUS_MAXIMUM_MATCH_RULE_LENGTH 1024
111 /* Max length of a marshaled array in bytes (64M, 2^26) We use signed
112 * int for lengths so must be INT_MAX or less. We need something a
113 * bit smaller than INT_MAX because the array is inside a message with
114 * header info, etc. so an INT_MAX array wouldn't allow the message
115 * overhead. The 64M number is an attempt at a larger number than
116 * we'd reasonably ever use, but small enough that your bus would chew
117 * through it fairly quickly without locking up forever. If you have
118 * data that's likely to be larger than this, you should probably be
119 * sending it in multiple incremental messages anyhow.
121 #define DBUS_MAXIMUM_ARRAY_LENGTH (67108864)
122 /* Number of bits you need in an unsigned to store the max array size */
123 #define DBUS_MAXIMUM_ARRAY_LENGTH_BITS 26
125 /* The maximum total message size including header and body; similar
126 * rationale to max array size.
128 #define DBUS_MAXIMUM_MESSAGE_LENGTH (DBUS_MAXIMUM_ARRAY_LENGTH * 2)
129 /* Number of bits you need in an unsigned to store the max message size */
130 #define DBUS_MAXIMUM_MESSAGE_LENGTH_BITS 27
132 /* Depth of recursion in the type tree. This is automatically limited
133 * to DBUS_MAXIMUM_SIGNATURE_LENGTH since you could only have an array
134 * of array of array of ... that fit in the max signature. But that's
135 * probably a bit too large.
137 #define DBUS_MAXIMUM_TYPE_RECURSION_DEPTH 32
139 /* Types of message */
140 #define DBUS_MESSAGE_TYPE_INVALID 0
141 #define DBUS_MESSAGE_TYPE_METHOD_CALL 1
142 #define DBUS_MESSAGE_TYPE_METHOD_RETURN 2
143 #define DBUS_MESSAGE_TYPE_ERROR 3
144 #define DBUS_MESSAGE_TYPE_SIGNAL 4
147 #define DBUS_HEADER_FLAG_NO_REPLY_EXPECTED 0x1
148 #define DBUS_HEADER_FLAG_NO_AUTO_START 0x2
151 #define DBUS_HEADER_FIELD_INVALID 0
152 #define DBUS_HEADER_FIELD_PATH 1
153 #define DBUS_HEADER_FIELD_INTERFACE 2
154 #define DBUS_HEADER_FIELD_MEMBER 3
155 #define DBUS_HEADER_FIELD_ERROR_NAME 4
156 #define DBUS_HEADER_FIELD_REPLY_SERIAL 5
157 #define DBUS_HEADER_FIELD_DESTINATION 6
158 #define DBUS_HEADER_FIELD_SENDER 7
159 #define DBUS_HEADER_FIELD_SIGNATURE 8
161 #define DBUS_HEADER_FIELD_LAST DBUS_HEADER_FIELD_SIGNATURE
163 /* Header format is defined as a signature:
165 * byte message type ID
167 * byte protocol version
170 * array of struct (byte,variant) (field name, value)
172 * The length of the header can be computed as the
173 * fixed size of the initial data, plus the length of
174 * the array at the end, plus padding to an 8-boundary.
176 #define DBUS_HEADER_SIGNATURE \
177 DBUS_TYPE_BYTE_AS_STRING \
178 DBUS_TYPE_BYTE_AS_STRING \
179 DBUS_TYPE_BYTE_AS_STRING \
180 DBUS_TYPE_BYTE_AS_STRING \
181 DBUS_TYPE_UINT32_AS_STRING \
182 DBUS_TYPE_UINT32_AS_STRING \
183 DBUS_TYPE_ARRAY_AS_STRING \
184 DBUS_STRUCT_BEGIN_CHAR_AS_STRING \
185 DBUS_TYPE_BYTE_AS_STRING \
186 DBUS_TYPE_VARIANT_AS_STRING \
187 DBUS_STRUCT_END_CHAR_AS_STRING
191 * The smallest header size that can occur. (It won't be valid due to
192 * missing required header fields.) This is 4 bytes, two uint32, an
193 * array length. This isn't any kind of resource limit, just the
194 * necessary/logical outcome of the header signature.
196 #define DBUS_MINIMUM_HEADER_SIZE 16
199 #define DBUS_SERVICE_ORG_FREEDESKTOP_DBUS "org.freedesktop.DBus"
202 #define DBUS_PATH_ORG_FREEDESKTOP_DBUS "/org/freedesktop/DBus"
203 #define DBUS_PATH_ORG_FREEDESKTOP_LOCAL "/org/freedesktop/Local"
205 /* Interfaces, these #define don't do much other than
206 * catch typos at compile time
208 #define DBUS_INTERFACE_ORG_FREEDESKTOP_DBUS "org.freedesktop.DBus"
209 #define DBUS_INTERFACE_ORG_FREEDESKTOP_INTROSPECTABLE "org.freedesktop.Introspectable"
211 /* This is a special interface whose methods can only be invoked
212 * by the local implementation (messages from remote apps aren't
213 * allowed to specify this interface).
215 #define DBUS_INTERFACE_ORG_FREEDESKTOP_LOCAL "org.freedesktop.Local"
218 #define DBUS_NAME_FLAG_PROHIBIT_REPLACEMENT 0x1
219 #define DBUS_NAME_FLAG_REPLACE_EXISTING 0x2
221 /* Replies to request for a name */
222 #define DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER 1
223 #define DBUS_REQUEST_NAME_REPLY_IN_QUEUE 2
224 #define DBUS_REQUEST_NAME_REPLY_EXISTS 3
225 #define DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER 4
227 /* Replies to service starts */
228 #define DBUS_START_REPLY_SUCCESS 1
229 #define DBUS_START_REPLY_ALREADY_RUNNING 2
232 /* WARNING these get autoconverted to an enum in dbus-glib.h. Thus,
233 * if you change the order it breaks the ABI. Keep them in order.
234 * Also, don't change the formatting since that will break the sed
237 #define DBUS_ERROR_FAILED "org.freedesktop.DBus.Error.Failed"
238 #define DBUS_ERROR_NO_MEMORY "org.freedesktop.DBus.Error.NoMemory"
239 #define DBUS_ERROR_SERVICE_UNKNOWN "org.freedesktop.DBus.Error.ServiceUnknown"
240 #define DBUS_ERROR_NAME_HAS_NO_OWNER "org.freedesktop.DBus.Error.NameHasNoOwner"
241 #define DBUS_ERROR_NO_REPLY "org.freedesktop.DBus.Error.NoReply"
242 #define DBUS_ERROR_IO_ERROR "org.freedesktop.DBus.Error.IOError"
243 #define DBUS_ERROR_BAD_ADDRESS "org.freedesktop.DBus.Error.BadAddress"
244 #define DBUS_ERROR_NOT_SUPPORTED "org.freedesktop.DBus.Error.NotSupported"
245 #define DBUS_ERROR_LIMITS_EXCEEDED "org.freedesktop.DBus.Error.LimitsExceeded"
246 #define DBUS_ERROR_ACCESS_DENIED "org.freedesktop.DBus.Error.AccessDenied"
247 #define DBUS_ERROR_AUTH_FAILED "org.freedesktop.DBus.Error.AuthFailed"
248 #define DBUS_ERROR_NO_SERVER "org.freedesktop.DBus.Error.NoServer"
249 #define DBUS_ERROR_TIMEOUT "org.freedesktop.DBus.Error.Timeout"
250 #define DBUS_ERROR_NO_NETWORK "org.freedesktop.DBus.Error.NoNetwork"
251 #define DBUS_ERROR_ADDRESS_IN_USE "org.freedesktop.DBus.Error.AddressInUse"
252 #define DBUS_ERROR_DISCONNECTED "org.freedesktop.DBus.Error.Disconnected"
253 #define DBUS_ERROR_INVALID_ARGS "org.freedesktop.DBus.Error.InvalidArgs"
254 #define DBUS_ERROR_FILE_NOT_FOUND "org.freedesktop.DBus.Error.FileNotFound"
255 #define DBUS_ERROR_UNKNOWN_METHOD "org.freedesktop.DBus.Error.UnknownMethod"
256 #define DBUS_ERROR_TIMED_OUT "org.freedesktop.DBus.Error.TimedOut"
257 #define DBUS_ERROR_MATCH_RULE_NOT_FOUND "org.freedesktop.DBus.Error.MatchRuleNotFound"
258 #define DBUS_ERROR_MATCH_RULE_INVALID "org.freedesktop.DBus.Error.MatchRuleInvalid"
259 #define DBUS_ERROR_SPAWN_EXEC_FAILED "org.freedesktop.DBus.Error.Spawn.ExecFailed"
260 #define DBUS_ERROR_SPAWN_FORK_FAILED "org.freedesktop.DBus.Error.Spawn.ForkFailed"
261 #define DBUS_ERROR_SPAWN_CHILD_EXITED "org.freedesktop.DBus.Error.Spawn.ChildExited"
262 #define DBUS_ERROR_SPAWN_CHILD_SIGNALED "org.freedesktop.DBus.Error.Spawn.ChildSignaled"
263 #define DBUS_ERROR_SPAWN_FAILED "org.freedesktop.DBus.Error.Spawn.Failed"
264 #define DBUS_ERROR_UNIX_PROCESS_ID_UNKNOWN "org.freedesktop.DBus.Error.UnixProcessIdUnknown"
270 #endif /* DBUS_PROTOCOL_H */