1 /* -*- mode: C; c-file-style: "gnu" -*- */ 2 /* dbus-protocol.h D-Bus protocol constants 3 * 4 * Copyright (C) 2002, 2003 CodeFactory AB 5 * Copyright (C) 2004, 2005 Red Hat, Inc. 6 * 7 * Licensed under the Academic Free License version 2.1 8 * 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. 13 * 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. 18 * 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 22 * 23 */ 24 25 #ifndef DBUS_PROTOCOL_H 26 #define DBUS_PROTOCOL_H 27 28 /* Don't include anything in here from anywhere else. It's 29 * intended for use by any random library. 30 */ 31 32 #ifdef __cplusplus 33 extern "C" { 34 #if 0 35 } /* avoids confusing emacs indentation */ 36 #endif 37 #endif 38 39 /* Normally docs are in .c files, but there isn't a .c file for this. */ 40 /** 41 * @defgroup DBusProtocol Protocol constants 42 * @ingroup DBus 43 * 44 * @brief Defines constants which are part of the D-Bus protocol 45 * 46 * This header is intended for use by any library, not only libdbus. 47 * 48 * @{ 49 */ 50 51 52 /* Message byte order */ 53 #define DBUS_LITTLE_ENDIAN ('l') /**< Code marking LSB-first byte order in the wire protocol. */ 54 #define DBUS_BIG_ENDIAN ('B') /**< Code marking MSB-first byte order in the wire protocol. */ 55 56 /** Protocol version. */ 57 #define DBUS_MAJOR_PROTOCOL_VERSION 1 58 59 /** Type code that is never equal to a legitimate type code */ 60 #define DBUS_TYPE_INVALID ((int) '\0') 61 /** #DBUS_TYPE_INVALID as a string literal instead of a int literal */ 62 #define DBUS_TYPE_INVALID_AS_STRING "\0" 63 64 /* Primitive types */ 65 /** Type code marking an 8-bit unsigned integer */ 66 #define DBUS_TYPE_BYTE ((int) 'y') 67 /** #DBUS_TYPE_BYTE as a string literal instead of a int literal */ 68 #define DBUS_TYPE_BYTE_AS_STRING "y" 69 /** Type code marking a boolean */ 70 #define DBUS_TYPE_BOOLEAN ((int) 'b') 71 /** #DBUS_TYPE_BOOLEAN as a string literal instead of a int literal */ 72 #define DBUS_TYPE_BOOLEAN_AS_STRING "b" 73 /** Type code marking a 16-bit signed integer */ 74 #define DBUS_TYPE_INT16 ((int) 'n') 75 /** #DBUS_TYPE_INT16 as a string literal instead of a int literal */ 76 #define DBUS_TYPE_INT16_AS_STRING "n" 77 /** Type code marking a 16-bit unsigned integer */ 78 #define DBUS_TYPE_UINT16 ((int) 'q') 79 /** #DBUS_TYPE_UINT16 as a string literal instead of a int literal */ 80 #define DBUS_TYPE_UINT16_AS_STRING "q" 81 /** Type code marking a 32-bit signed integer */ 82 #define DBUS_TYPE_INT32 ((int) 'i') 83 /** #DBUS_TYPE_INT32 as a string literal instead of a int literal */ 84 #define DBUS_TYPE_INT32_AS_STRING "i" 85 /** Type code marking a 32-bit unsigned integer */ 86 #define DBUS_TYPE_UINT32 ((int) 'u') 87 /** #DBUS_TYPE_UINT32 as a string literal instead of a int literal */ 88 #define DBUS_TYPE_UINT32_AS_STRING "u" 89 /** Type code marking a 64-bit signed integer */ 90 #define DBUS_TYPE_INT64 ((int) 'x') 91 /** #DBUS_TYPE_INT64 as a string literal instead of a int literal */ 92 #define DBUS_TYPE_INT64_AS_STRING "x" 93 /** Type code marking a 64-bit unsigned integer */ 94 #define DBUS_TYPE_UINT64 ((int) 't') 95 /** #DBUS_TYPE_UINT64 as a string literal instead of a int literal */ 96 #define DBUS_TYPE_UINT64_AS_STRING "t" 97 /** Type code marking an 8-byte double in IEEE 754 format */ 98 #define DBUS_TYPE_DOUBLE ((int) 'd') 99 /** #DBUS_TYPE_DOUBLE as a string literal instead of a int literal */ 100 #define DBUS_TYPE_DOUBLE_AS_STRING "d" 101 /** Type code marking a UTF-8 encoded, nul-terminated Unicode string */ 102 #define DBUS_TYPE_STRING ((int) 's') 103 /** #DBUS_TYPE_STRING as a string literal instead of a int literal */ 104 #define DBUS_TYPE_STRING_AS_STRING "s" 105 /** Type code marking a D-Bus object path */ 106 #define DBUS_TYPE_OBJECT_PATH ((int) 'o') 107 /** #DBUS_TYPE_OBJECT_PATH as a string literal instead of a int literal */ 108 #define DBUS_TYPE_OBJECT_PATH_AS_STRING "o" 109 /** Type code marking a D-Bus type signature */ 110 #define DBUS_TYPE_SIGNATURE ((int) 'g') 111 /** #DBUS_TYPE_SIGNATURE as a string literal instead of a int literal */ 112 #define DBUS_TYPE_SIGNATURE_AS_STRING "g" 113 114 /* Compound types */ 115 /** Type code marking a D-Bus array type */ 116 #define DBUS_TYPE_ARRAY ((int) 'a') 117 /** #DBUS_TYPE_ARRAY as a string literal instead of a int literal */ 118 #define DBUS_TYPE_ARRAY_AS_STRING "a" 119 /** Type code marking a D-Bus variant type */ 120 #define DBUS_TYPE_VARIANT ((int) 'v') 121 /** #DBUS_TYPE_VARIANT as a string literal instead of a int literal */ 122 #define DBUS_TYPE_VARIANT_AS_STRING "v" 123 124 /** STRUCT and DICT_ENTRY are sort of special since their codes can't 125 * appear in a type string, instead 126 * DBUS_STRUCT_BEGIN_CHAR/DBUS_DICT_ENTRY_BEGIN_CHAR have to appear 127 */ 128 /** Type code used to represent a struct; however, this type code does not appear 129 * in type signatures, instead #DBUS_STRUCT_BEGIN_CHAR and #DBUS_STRUCT_END_CHAR will 130 * appear in a signature. 131 */ 132 #define DBUS_TYPE_STRUCT ((int) 'r') 133 /** #DBUS_TYPE_STRUCT as a string literal instead of a int literal */ 134 #define DBUS_TYPE_STRUCT_AS_STRING "r" 135 /** Type code used to represent a dict entry; however, this type code does not appear 136 * in type signatures, instead #DBUS_DICT_ENTRY_BEGIN_CHAR and #DBUS_DICT_ENTRY_END_CHAR will 137 * appear in a signature. 138 */ 139 #define DBUS_TYPE_DICT_ENTRY ((int) 'e') 140 /** #DBUS_TYPE_DICT_ENTRY as a string literal instead of a int literal */ 141 #define DBUS_TYPE_DICT_ENTRY_AS_STRING "e" 142 143 /** Does not include #DBUS_TYPE_INVALID, #DBUS_STRUCT_BEGIN_CHAR, #DBUS_STRUCT_END_CHAR, 144 * #DBUS_DICT_ENTRY_BEGIN_CHAR, or #DBUS_DICT_ENTRY_END_CHAR - i.e. it is the number of 145 * valid types, not the number of distinct characters that may appear in a type signature. 146 */ 147 #define DBUS_NUMBER_OF_TYPES (16) 148 149 /* characters other than typecodes that appear in type signatures */ 150 151 /** Code marking the start of a struct type in a type signature */ 152 #define DBUS_STRUCT_BEGIN_CHAR ((int) '(') 153 /** #DBUS_STRUCT_BEGIN_CHAR as a string literal instead of a int literal */ 154 #define DBUS_STRUCT_BEGIN_CHAR_AS_STRING "(" 155 /** Code marking the end of a struct type in a type signature */ 156 #define DBUS_STRUCT_END_CHAR ((int) ')') 157 /** #DBUS_STRUCT_END_CHAR a string literal instead of a int literal */ 158 #define DBUS_STRUCT_END_CHAR_AS_STRING ")" 159 /** Code marking the start of a dict entry type in a type signature */ 160 #define DBUS_DICT_ENTRY_BEGIN_CHAR ((int) '{') 161 /** #DBUS_DICT_ENTRY_BEGIN_CHAR as a string literal instead of a int literal */ 162 #define DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING "{" 163 /** Code marking the end of a dict entry type in a type signature */ 164 #define DBUS_DICT_ENTRY_END_CHAR ((int) '}') 165 /** #DBUS_DICT_ENTRY_END_CHAR as a string literal instead of a int literal */ 166 #define DBUS_DICT_ENTRY_END_CHAR_AS_STRING "}" 167 168 /** Max length in bytes of a bus name, interface, or member (not object 169 * path, paths are unlimited). This is limited because lots of stuff 170 * is O(n) in this number, plus it would be obnoxious to type in a 171 * paragraph-long method name so most likely something like that would 172 * be an exploit. 173 */ 174 #define DBUS_MAXIMUM_NAME_LENGTH 255 175 176 /** This one is 255 so it fits in a byte */ 177 #define DBUS_MAXIMUM_SIGNATURE_LENGTH 255 178 179 /** Max length of a match rule string; to keep people from hosing the 180 * daemon with some huge rule 181 */ 182 #define DBUS_MAXIMUM_MATCH_RULE_LENGTH 1024 183 184 /** Max arg number you can match on in a match rule, e.g. 185 * arg0='hello' is OK, arg3489720987='hello' is not 186 */ 187 #define DBUS_MAXIMUM_MATCH_RULE_ARG_NUMBER 63 188 189 /** Max length of a marshaled array in bytes (64M, 2^26) We use signed 190 * int for lengths so must be INT_MAX or less. We need something a 191 * bit smaller than INT_MAX because the array is inside a message with 192 * header info, etc. so an INT_MAX array wouldn't allow the message 193 * overhead. The 64M number is an attempt at a larger number than 194 * we'd reasonably ever use, but small enough that your bus would chew 195 * through it fairly quickly without locking up forever. If you have 196 * data that's likely to be larger than this, you should probably be 197 * sending it in multiple incremental messages anyhow. 198 */ 199 #define DBUS_MAXIMUM_ARRAY_LENGTH (67108864) 200 /** Number of bits you need in an unsigned to store the max array size */ 201 #define DBUS_MAXIMUM_ARRAY_LENGTH_BITS 26 202 203 /** The maximum total message size including header and body; similar 204 * rationale to max array size. 205 */ 206 #define DBUS_MAXIMUM_MESSAGE_LENGTH (DBUS_MAXIMUM_ARRAY_LENGTH * 2) 207 /** Number of bits you need in an unsigned to store the max message size */ 208 #define DBUS_MAXIMUM_MESSAGE_LENGTH_BITS 27 209 210 /** Depth of recursion in the type tree. This is automatically limited 211 * to DBUS_MAXIMUM_SIGNATURE_LENGTH since you could only have an array 212 * of array of array of ... that fit in the max signature. But that's 213 * probably a bit too large. 214 */ 215 #define DBUS_MAXIMUM_TYPE_RECURSION_DEPTH 32 216 217 /* Types of message */ 218 219 /** This value is never a valid message type, see dbus_message_get_type() */ 220 #define DBUS_MESSAGE_TYPE_INVALID 0 221 /** Message type of a method call message, see dbus_message_get_type() */ 222 #define DBUS_MESSAGE_TYPE_METHOD_CALL 1 223 /** Message type of a method return message, see dbus_message_get_type() */ 224 #define DBUS_MESSAGE_TYPE_METHOD_RETURN 2 225 /** Message type of an error reply message, see dbus_message_get_type() */ 226 #define DBUS_MESSAGE_TYPE_ERROR 3 227 /** Message type of a signal message, see dbus_message_get_type() */ 228 #define DBUS_MESSAGE_TYPE_SIGNAL 4 229 230 /* Header flags */ 231 232 /** If set, this flag means that the sender of a message does not care about getting 233 * a reply, so the recipient need not send one. See dbus_message_set_no_reply(). 234 */ 235 #define DBUS_HEADER_FLAG_NO_REPLY_EXPECTED 0x1 236 /** 237 * If set, this flag means that even if the message bus knows how to start an owner for 238 * the destination bus name (see dbus_message_set_destination()), it should not 239 * do so. If this flag is not set, the bus may launch a program to process the 240 * message. 241 */ 242 #define DBUS_HEADER_FLAG_NO_AUTO_START 0x2 243 244 /* Header fields */ 245 246 /** Not equal to any valid header field code */ 247 #define DBUS_HEADER_FIELD_INVALID 0 248 /** Header field code for the path - the path is the object emitting a signal or the object receiving a method call. 249 * See dbus_message_set_path(). 250 */ 251 #define DBUS_HEADER_FIELD_PATH 1 252 /** Header field code for the interface containing a member (method or signal). 253 * See dbus_message_set_interface(). 254 */ 255 #define DBUS_HEADER_FIELD_INTERFACE 2 256 /** Header field code for a member (method or signal). See dbus_message_set_member(). */ 257 #define DBUS_HEADER_FIELD_MEMBER 3 258 /** Header field code for an error name (found in #DBUS_MESSAGE_TYPE_ERROR messages). 259 * See dbus_message_set_error_name(). 260 */ 261 #define DBUS_HEADER_FIELD_ERROR_NAME 4 262 /** Header field code for a reply serial, used to match a #DBUS_MESSAGE_TYPE_METHOD_RETURN message with the 263 * message that it's a reply to. See dbus_message_set_reply_serial(). 264 */ 265 #define DBUS_HEADER_FIELD_REPLY_SERIAL 5 266 /** 267 * Header field code for the destination bus name of a message. See dbus_message_set_destination(). 268 */ 269 #define DBUS_HEADER_FIELD_DESTINATION 6 270 /** 271 * Header field code for the sender of a message; usually initialized by the message bus. 272 * See dbus_message_set_sender(). 273 */ 274 #define DBUS_HEADER_FIELD_SENDER 7 275 /** 276 * Header field code for the type signature of a message. 277 */ 278 #define DBUS_HEADER_FIELD_SIGNATURE 8 279 280 /** 281 * Value of the highest-numbered header field code, can be used to determine 282 * the size of an array indexed by header field code. Remember though 283 * that unknown codes must be ignored, so check for that before 284 * indexing the array. 285 */ 286 #define DBUS_HEADER_FIELD_LAST DBUS_HEADER_FIELD_SIGNATURE 287 288 /** Header format is defined as a signature: 289 * byte byte order 290 * byte message type ID 291 * byte flags 292 * byte protocol version 293 * uint32 body length 294 * uint32 serial 295 * array of struct (byte,variant) (field name, value) 296 * 297 * The length of the header can be computed as the 298 * fixed size of the initial data, plus the length of 299 * the array at the end, plus padding to an 8-boundary. 300 */ 301 #define DBUS_HEADER_SIGNATURE \ 302 DBUS_TYPE_BYTE_AS_STRING \ 303 DBUS_TYPE_BYTE_AS_STRING \ 304 DBUS_TYPE_BYTE_AS_STRING \ 305 DBUS_TYPE_BYTE_AS_STRING \ 306 DBUS_TYPE_UINT32_AS_STRING \ 307 DBUS_TYPE_UINT32_AS_STRING \ 308 DBUS_TYPE_ARRAY_AS_STRING \ 309 DBUS_STRUCT_BEGIN_CHAR_AS_STRING \ 310 DBUS_TYPE_BYTE_AS_STRING \ 311 DBUS_TYPE_VARIANT_AS_STRING \ 312 DBUS_STRUCT_END_CHAR_AS_STRING 313 314 315 /** 316 * The smallest header size that can occur. (It won't be valid due to 317 * missing required header fields.) This is 4 bytes, two uint32, an 318 * array length. This isn't any kind of resource limit, just the 319 * necessary/logical outcome of the header signature. 320 */ 321 #define DBUS_MINIMUM_HEADER_SIZE 16 322 323 /* Errors */ 324 /* WARNING these get autoconverted to an enum in dbus-glib.h. Thus, 325 * if you change the order it breaks the ABI. Keep them in order. 326 * Also, don't change the formatting since that will break the sed 327 * script. 328 */ 329 /** A generic error; "something went wrong" - see the error message for more. */ 330 #define DBUS_ERROR_FAILED "org.freedesktop.DBus.Error.Failed" 331 /** There was not enough memory to complete an operation. */ 332 #define DBUS_ERROR_NO_MEMORY "org.freedesktop.DBus.Error.NoMemory" 333 /** The bus doesn't know how to launch a service to supply the bus name you wanted. */ 334 #define DBUS_ERROR_SERVICE_UNKNOWN "org.freedesktop.DBus.Error.ServiceUnknown" 335 /** The bus name you referenced doesn't exist (i.e. no application owns it). */ 336 #define DBUS_ERROR_NAME_HAS_NO_OWNER "org.freedesktop.DBus.Error.NameHasNoOwner" 337 /** No reply to a message expecting one, usually means a timeout occurred. */ 338 #define DBUS_ERROR_NO_REPLY "org.freedesktop.DBus.Error.NoReply" 339 /** Something went wrong reading or writing to a socket, for example. */ 340 #define DBUS_ERROR_IO_ERROR "org.freedesktop.DBus.Error.IOError" 341 /** A D-Bus bus address was malformed. */ 342 #define DBUS_ERROR_BAD_ADDRESS "org.freedesktop.DBus.Error.BadAddress" 343 /** Requested operation isn't supported (like ENOSYS on UNIX). */ 344 #define DBUS_ERROR_NOT_SUPPORTED "org.freedesktop.DBus.Error.NotSupported" 345 /** Some limited resource is exhausted. */ 346 #define DBUS_ERROR_LIMITS_EXCEEDED "org.freedesktop.DBus.Error.LimitsExceeded" 347 /** Security restrictions don't allow doing what you're trying to do. */ 348 #define DBUS_ERROR_ACCESS_DENIED "org.freedesktop.DBus.Error.AccessDenied" 349 /** Authentication didn't work. */ 350 #define DBUS_ERROR_AUTH_FAILED "org.freedesktop.DBus.Error.AuthFailed" 351 /** Unable to connect to server (probably caused by ECONNREFUSED on a socket). */ 352 #define DBUS_ERROR_NO_SERVER "org.freedesktop.DBus.Error.NoServer" 353 /** Certain timeout errors, possibly ETIMEDOUT on a socket. 354 * Note that #DBUS_ERROR_NO_REPLY is used for message reply timeouts. 355 * @warning this is confusingly-named given that #DBUS_ERROR_TIMED_OUT also exists. We can't fix 356 * it for compatibility reasons so just be careful. 357 */ 358 #define DBUS_ERROR_TIMEOUT "org.freedesktop.DBus.Error.Timeout" 359 /** No network access (probably ENETUNREACH on a socket). */ 360 #define DBUS_ERROR_NO_NETWORK "org.freedesktop.DBus.Error.NoNetwork" 361 /** Can't bind a socket since its address is in use (i.e. EADDRINUSE). */ 362 #define DBUS_ERROR_ADDRESS_IN_USE "org.freedesktop.DBus.Error.AddressInUse" 363 /** The connection is disconnected and you're trying to use it. */ 364 #define DBUS_ERROR_DISCONNECTED "org.freedesktop.DBus.Error.Disconnected" 365 /** Invalid arguments passed to a method call. */ 366 #define DBUS_ERROR_INVALID_ARGS "org.freedesktop.DBus.Error.InvalidArgs" 367 /** Missing file. */ 368 #define DBUS_ERROR_FILE_NOT_FOUND "org.freedesktop.DBus.Error.FileNotFound" 369 /** Existing file and the operation you're using does not silently overwrite. */ 370 #define DBUS_ERROR_FILE_EXISTS "org.freedesktop.DBus.Error.FileExists" 371 /** Method name you invoked isn't known by the object you invoked it on. */ 372 #define DBUS_ERROR_UNKNOWN_METHOD "org.freedesktop.DBus.Error.UnknownMethod" 373 /** Certain timeout errors, e.g. while starting a service. 374 * @warning this is confusingly-named given that #DBUS_ERROR_TIMEOUT also exists. We can't fix 375 * it for compatibility reasons so just be careful. 376 */ 377 #define DBUS_ERROR_TIMED_OUT "org.freedesktop.DBus.Error.TimedOut" 378 /** Tried to remove or modify a match rule that didn't exist. */ 379 #define DBUS_ERROR_MATCH_RULE_NOT_FOUND "org.freedesktop.DBus.Error.MatchRuleNotFound" 380 /** The match rule isn't syntactically valid. */ 381 #define DBUS_ERROR_MATCH_RULE_INVALID "org.freedesktop.DBus.Error.MatchRuleInvalid" 382 /** While starting a new process, the exec() call failed. */ 383 #define DBUS_ERROR_SPAWN_EXEC_FAILED "org.freedesktop.DBus.Error.Spawn.ExecFailed" 384 /** While starting a new process, the fork() call failed. */ 385 #define DBUS_ERROR_SPAWN_FORK_FAILED "org.freedesktop.DBus.Error.Spawn.ForkFailed" 386 /** While starting a new process, the child exited with a status code. */ 387 #define DBUS_ERROR_SPAWN_CHILD_EXITED "org.freedesktop.DBus.Error.Spawn.ChildExited" 388 /** While starting a new process, the child exited on a signal. */ 389 #define DBUS_ERROR_SPAWN_CHILD_SIGNALED "org.freedesktop.DBus.Error.Spawn.ChildSignaled" 390 /** While starting a new process, something went wrong. */ 391 #define DBUS_ERROR_SPAWN_FAILED "org.freedesktop.DBus.Error.Spawn.Failed" 392 /** Tried to get a UNIX process ID and it wasn't available. */ 393 #define DBUS_ERROR_UNIX_PROCESS_ID_UNKNOWN "org.freedesktop.DBus.Error.UnixProcessIdUnknown" 394 /** A type signature is not valid. */ 395 #define DBUS_ERROR_INVALID_SIGNATURE "org.freedesktop.DBus.Error.InvalidSignature" 396 /** A file contains invalid syntax or is otherwise broken. */ 397 #define DBUS_ERROR_INVALID_FILE_CONTENT "org.freedesktop.DBus.Error.InvalidFileContent" 398 /** Asked for SELinux security context and it wasn't available. */ 399 #define DBUS_ERROR_SELINUX_SECURITY_CONTEXT_UNKNOWN "org.freedesktop.DBus.Error.SELinuxSecurityContextUnknown" 400 401 /* XML introspection format */ 402 403 /** XML namespace of the introspection format version 1.0 */ 404 #define DBUS_INTROSPECT_1_0_XML_NAMESPACE "http://www.freedesktop.org/standards/dbus" 405 /** XML public identifier of the introspection format version 1.0 */ 406 #define DBUS_INTROSPECT_1_0_XML_PUBLIC_IDENTIFIER "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" 407 /** XML system identifier of the introspection format version 1.0 */ 408 #define DBUS_INTROSPECT_1_0_XML_SYSTEM_IDENTIFIER "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd" 409 /** XML document type declaration of the introspection format version 1.0 */ 410 #define DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE "<!DOCTYPE node PUBLIC \""DBUS_INTROSPECT_1_0_XML_PUBLIC_IDENTIFIER"\"\n\""DBUS_INTROSPECT_1_0_XML_SYSTEM_IDENTIFIER"\">\n" 411 412 /** @} */ 413 414 #ifdef __cplusplus 415 #if 0 416 { /* avoids confusing emacs indentation */ 417 #endif 418 } 419 #endif 420 421 #endif /* DBUS_PROTOCOL_H */ 422