Main Page | Modules | Data Structures | Directories | File List | Data Fields | Related Pages

dbus-protocol.h

00001 /* -*- mode: C; c-file-style: "gnu" -*- */
00002 /* dbus-protocol.h  D-Bus protocol constants
00003  *
00004  * Copyright (C) 2002, 2003  CodeFactory AB
00005  * Copyright (C) 2004, 2005 Red Hat, Inc.
00006  *
00007  * Licensed under the Academic Free License version 2.1
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022  *
00023  */
00024 
00025 #ifndef DBUS_PROTOCOL_H
00026 #define DBUS_PROTOCOL_H
00027 
00028 /* Don't include anything in here from anywhere else. It's
00029  * intended for use by any random library.
00030  */
00031 
00032 #ifdef  __cplusplus
00033 extern "C" {
00034 #endif
00035 
00036 /* Message byte order */
00037 #define DBUS_LITTLE_ENDIAN ('l')  /* LSB first */
00038 #define DBUS_BIG_ENDIAN    ('B')  /* MSB first */
00039 
00040 /* Protocol version */
00041 #define DBUS_MAJOR_PROTOCOL_VERSION 1
00042 
00043 /* Never a legitimate type */
00044 #define DBUS_TYPE_INVALID       ((int) '\0')
00045 #define DBUS_TYPE_INVALID_AS_STRING        "\0"
00046 
00047 /* Primitive types */
00048 #define DBUS_TYPE_BYTE          ((int) 'y')
00049 #define DBUS_TYPE_BYTE_AS_STRING           "y"
00050 #define DBUS_TYPE_BOOLEAN       ((int) 'b')
00051 #define DBUS_TYPE_BOOLEAN_AS_STRING        "b"
00052 #define DBUS_TYPE_INT16         ((int) 'n')
00053 #define DBUS_TYPE_INT16_AS_STRING          "n"
00054 #define DBUS_TYPE_UINT16        ((int) 'q')
00055 #define DBUS_TYPE_UINT16_AS_STRING         "q"
00056 #define DBUS_TYPE_INT32         ((int) 'i')
00057 #define DBUS_TYPE_INT32_AS_STRING          "i"
00058 #define DBUS_TYPE_UINT32        ((int) 'u')
00059 #define DBUS_TYPE_UINT32_AS_STRING         "u"
00060 #define DBUS_TYPE_INT64         ((int) 'x')
00061 #define DBUS_TYPE_INT64_AS_STRING          "x"
00062 #define DBUS_TYPE_UINT64        ((int) 't')
00063 #define DBUS_TYPE_UINT64_AS_STRING         "t"
00064 
00065 #define DBUS_TYPE_DOUBLE        ((int) 'd')
00066 #define DBUS_TYPE_DOUBLE_AS_STRING         "d"
00067 #define DBUS_TYPE_STRING        ((int) 's')
00068 #define DBUS_TYPE_STRING_AS_STRING         "s"
00069 #define DBUS_TYPE_OBJECT_PATH   ((int) 'o')
00070 #define DBUS_TYPE_OBJECT_PATH_AS_STRING    "o"
00071 #define DBUS_TYPE_SIGNATURE     ((int) 'g')
00072 #define DBUS_TYPE_SIGNATURE_AS_STRING      "g"
00073 
00074 /* Compound types */
00075 #define DBUS_TYPE_ARRAY         ((int) 'a')
00076 #define DBUS_TYPE_ARRAY_AS_STRING          "a"
00077 #define DBUS_TYPE_VARIANT       ((int) 'v')
00078 #define DBUS_TYPE_VARIANT_AS_STRING        "v"
00079 
00080 /* STRUCT and DICT_ENTRY are sort of special since their codes can't
00081  * appear in a type string, instead
00082  * DBUS_STRUCT_BEGIN_CHAR/DBUS_DICT_ENTRY_BEGIN_CHAR have to appear
00083  */
00084 #define DBUS_TYPE_STRUCT        ((int) 'r')
00085 #define DBUS_TYPE_STRUCT_AS_STRING         "r"
00086 #define DBUS_TYPE_DICT_ENTRY    ((int) 'e')
00087 #define DBUS_TYPE_DICT_ENTRY_AS_STRING     "e"
00088 
00089 /* Does not count INVALID */
00090 #define DBUS_NUMBER_OF_TYPES    (16)
00091 
00092 /* characters other than typecodes that appear in type signatures */
00093 #define DBUS_STRUCT_BEGIN_CHAR   ((int) '(')
00094 #define DBUS_STRUCT_BEGIN_CHAR_AS_STRING   "("
00095 #define DBUS_STRUCT_END_CHAR     ((int) ')')
00096 #define DBUS_STRUCT_END_CHAR_AS_STRING     ")"
00097 #define DBUS_DICT_ENTRY_BEGIN_CHAR   ((int) '{')
00098 #define DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING   "{"
00099 #define DBUS_DICT_ENTRY_END_CHAR     ((int) '}')
00100 #define DBUS_DICT_ENTRY_END_CHAR_AS_STRING     "}"
00101 
00102 /* Max length in bytes of a bus name, interface, or member (not object
00103  * path, paths are unlimited). This is limited because lots of stuff
00104  * is O(n) in this number, plus it would be obnoxious to type in a
00105  * paragraph-long method name so most likely something like that would
00106  * be an exploit.
00107  */
00108 #define DBUS_MAXIMUM_NAME_LENGTH 255
00109 
00110 /* This one is 255 so it fits in a byte */
00111 #define DBUS_MAXIMUM_SIGNATURE_LENGTH 255
00112 
00113 /* Max length of a match rule string; to keep people from hosing the
00114  * daemon with some huge rule
00115  */
00116 #define DBUS_MAXIMUM_MATCH_RULE_LENGTH 1024
00117 
00118 /* Max arg number you can match on in a match rule, e.g.
00119  * arg0='hello' is OK, arg3489720987='hello' is not
00120  */
00121 #define DBUS_MAXIMUM_MATCH_RULE_ARG_NUMBER 63
00122   
00123 /* Max length of a marshaled array in bytes (64M, 2^26) We use signed
00124  * int for lengths so must be INT_MAX or less.  We need something a
00125  * bit smaller than INT_MAX because the array is inside a message with
00126  * header info, etc.  so an INT_MAX array wouldn't allow the message
00127  * overhead.  The 64M number is an attempt at a larger number than
00128  * we'd reasonably ever use, but small enough that your bus would chew
00129  * through it fairly quickly without locking up forever. If you have
00130  * data that's likely to be larger than this, you should probably be
00131  * sending it in multiple incremental messages anyhow.
00132  */
00133 #define DBUS_MAXIMUM_ARRAY_LENGTH (67108864)
00134 /* Number of bits you need in an unsigned to store the max array size */
00135 #define DBUS_MAXIMUM_ARRAY_LENGTH_BITS 26
00136 
00137 /* The maximum total message size including header and body; similar
00138  * rationale to max array size.
00139  */
00140 #define DBUS_MAXIMUM_MESSAGE_LENGTH (DBUS_MAXIMUM_ARRAY_LENGTH * 2)
00141 /* Number of bits you need in an unsigned to store the max message size */
00142 #define DBUS_MAXIMUM_MESSAGE_LENGTH_BITS 27
00143 
00144 /* Depth of recursion in the type tree. This is automatically limited
00145  * to DBUS_MAXIMUM_SIGNATURE_LENGTH since you could only have an array
00146  * of array of array of ... that fit in the max signature.  But that's
00147  * probably a bit too large.
00148  */
00149 #define DBUS_MAXIMUM_TYPE_RECURSION_DEPTH 32
00150 
00151 /* Types of message */
00152 #define DBUS_MESSAGE_TYPE_INVALID       0
00153 #define DBUS_MESSAGE_TYPE_METHOD_CALL   1
00154 #define DBUS_MESSAGE_TYPE_METHOD_RETURN 2
00155 #define DBUS_MESSAGE_TYPE_ERROR         3
00156 #define DBUS_MESSAGE_TYPE_SIGNAL        4
00157 
00158 /* Header flags */
00159 #define DBUS_HEADER_FLAG_NO_REPLY_EXPECTED 0x1
00160 #define DBUS_HEADER_FLAG_NO_AUTO_START     0x2
00161 
00162 /* Header fields */
00163 #define DBUS_HEADER_FIELD_INVALID        0
00164 #define DBUS_HEADER_FIELD_PATH           1
00165 #define DBUS_HEADER_FIELD_INTERFACE      2
00166 #define DBUS_HEADER_FIELD_MEMBER         3
00167 #define DBUS_HEADER_FIELD_ERROR_NAME     4
00168 #define DBUS_HEADER_FIELD_REPLY_SERIAL   5
00169 #define DBUS_HEADER_FIELD_DESTINATION    6
00170 #define DBUS_HEADER_FIELD_SENDER         7
00171 #define DBUS_HEADER_FIELD_SIGNATURE      8
00172 
00173 #define DBUS_HEADER_FIELD_LAST DBUS_HEADER_FIELD_SIGNATURE
00174 
00175 /* Header format is defined as a signature:
00176  *   byte                            byte order
00177  *   byte                            message type ID
00178  *   byte                            flags
00179  *   byte                            protocol version
00180  *   uint32                          body length
00181  *   uint32                          serial
00182  *   array of struct (byte,variant)  (field name, value)
00183  *
00184  * The length of the header can be computed as the
00185  * fixed size of the initial data, plus the length of
00186  * the array at the end, plus padding to an 8-boundary.
00187  */
00188 #define DBUS_HEADER_SIGNATURE                   \
00189      DBUS_TYPE_BYTE_AS_STRING                   \
00190      DBUS_TYPE_BYTE_AS_STRING                   \
00191      DBUS_TYPE_BYTE_AS_STRING                   \
00192      DBUS_TYPE_BYTE_AS_STRING                   \
00193      DBUS_TYPE_UINT32_AS_STRING                 \
00194      DBUS_TYPE_UINT32_AS_STRING                 \
00195      DBUS_TYPE_ARRAY_AS_STRING                  \
00196      DBUS_STRUCT_BEGIN_CHAR_AS_STRING           \
00197      DBUS_TYPE_BYTE_AS_STRING                   \
00198      DBUS_TYPE_VARIANT_AS_STRING                \
00199      DBUS_STRUCT_END_CHAR_AS_STRING
00200 
00201 
00208 #define DBUS_MINIMUM_HEADER_SIZE 16
00209 
00210 /* Errors */
00211 /* WARNING these get autoconverted to an enum in dbus-glib.h. Thus,
00212  * if you change the order it breaks the ABI. Keep them in order.
00213  * Also, don't change the formatting since that will break the sed
00214  * script.
00215  */
00216 #define DBUS_ERROR_FAILED                     "org.freedesktop.DBus.Error.Failed"
00217 #define DBUS_ERROR_NO_MEMORY                  "org.freedesktop.DBus.Error.NoMemory"
00218 #define DBUS_ERROR_SERVICE_UNKNOWN            "org.freedesktop.DBus.Error.ServiceUnknown"
00219 #define DBUS_ERROR_NAME_HAS_NO_OWNER          "org.freedesktop.DBus.Error.NameHasNoOwner"
00220 #define DBUS_ERROR_NO_REPLY                   "org.freedesktop.DBus.Error.NoReply"
00221 #define DBUS_ERROR_IO_ERROR                   "org.freedesktop.DBus.Error.IOError"
00222 #define DBUS_ERROR_BAD_ADDRESS                "org.freedesktop.DBus.Error.BadAddress"
00223 #define DBUS_ERROR_NOT_SUPPORTED              "org.freedesktop.DBus.Error.NotSupported"
00224 #define DBUS_ERROR_LIMITS_EXCEEDED            "org.freedesktop.DBus.Error.LimitsExceeded"
00225 #define DBUS_ERROR_ACCESS_DENIED              "org.freedesktop.DBus.Error.AccessDenied"
00226 #define DBUS_ERROR_AUTH_FAILED                "org.freedesktop.DBus.Error.AuthFailed"
00227 #define DBUS_ERROR_NO_SERVER                  "org.freedesktop.DBus.Error.NoServer"
00228 #define DBUS_ERROR_TIMEOUT                    "org.freedesktop.DBus.Error.Timeout"
00229 #define DBUS_ERROR_NO_NETWORK                 "org.freedesktop.DBus.Error.NoNetwork"
00230 #define DBUS_ERROR_ADDRESS_IN_USE             "org.freedesktop.DBus.Error.AddressInUse"
00231 #define DBUS_ERROR_DISCONNECTED               "org.freedesktop.DBus.Error.Disconnected"
00232 #define DBUS_ERROR_INVALID_ARGS               "org.freedesktop.DBus.Error.InvalidArgs"
00233 #define DBUS_ERROR_FILE_NOT_FOUND             "org.freedesktop.DBus.Error.FileNotFound"
00234 #define DBUS_ERROR_UNKNOWN_METHOD             "org.freedesktop.DBus.Error.UnknownMethod"
00235 #define DBUS_ERROR_TIMED_OUT                  "org.freedesktop.DBus.Error.TimedOut"
00236 #define DBUS_ERROR_MATCH_RULE_NOT_FOUND       "org.freedesktop.DBus.Error.MatchRuleNotFound"
00237 #define DBUS_ERROR_MATCH_RULE_INVALID         "org.freedesktop.DBus.Error.MatchRuleInvalid"
00238 #define DBUS_ERROR_SPAWN_EXEC_FAILED          "org.freedesktop.DBus.Error.Spawn.ExecFailed"
00239 #define DBUS_ERROR_SPAWN_FORK_FAILED          "org.freedesktop.DBus.Error.Spawn.ForkFailed"
00240 #define DBUS_ERROR_SPAWN_CHILD_EXITED         "org.freedesktop.DBus.Error.Spawn.ChildExited"
00241 #define DBUS_ERROR_SPAWN_CHILD_SIGNALED       "org.freedesktop.DBus.Error.Spawn.ChildSignaled"
00242 #define DBUS_ERROR_SPAWN_FAILED               "org.freedesktop.DBus.Error.Spawn.Failed"
00243 #define DBUS_ERROR_UNIX_PROCESS_ID_UNKNOWN    "org.freedesktop.DBus.Error.UnixProcessIdUnknown"
00244 #define DBUS_ERROR_INVALID_SIGNATURE          "org.freedesktop.DBus.Error.InvalidSignature"
00245 #define DBUS_ERROR_SELINUX_SECURITY_CONTEXT_UNKNOWN    "org.freedesktop.DBus.Error.SELinuxSecurityContextUnknown"
00246 
00247 #define DBUS_INTROSPECT_1_0_XML_NAMESPACE         "http://www.freedesktop.org/standards/dbus"
00248 #define DBUS_INTROSPECT_1_0_XML_PUBLIC_IDENTIFIER "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
00249 #define DBUS_INTROSPECT_1_0_XML_SYSTEM_IDENTIFIER "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"
00250 #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"
00251 
00252 
00253 #ifdef __cplusplus
00254 }
00255 #endif
00256 
00257 #endif /* DBUS_PROTOCOL_H */

Generated on Tue Aug 30 16:35:51 2005 for D-BUS by  doxygen 1.4.3