5 This describes the encoding used to serialize data. It doesn't cover specific
6 objects/messages but focuses on the base types.
8 The types are not self documenting in any way. They can not be decoded unless
9 you know what they are.
17 The integer types used will be named ``{signed}{size}{endian}``. For example
18 ``u16le`` is an unsigned 16 bit integer encoded in little endian byte order
19 while ``s64be`` is a signed 64 bit integer in big endian. Additionally ``u8``
20 and ``s8`` will represent signed and unsigned bytes respectively. Signed
21 integers use two's complement encoding.
26 This document will use a c-like syntax for describing structures. The
27 structure represents the data that will go over the wire. There will be no
28 padding between the elements and the elements will be sent in the order they
36 When encoding the values ``0x05`` and ``0x12345678`` respectively will appear on
37 the wire as ``05 78 56 34 12``.
42 Unlike c, length arrays can be used anywhere in structures and will be inline in
43 the protocol. Furthermore the length may be described using an earlier item in
54 This structure is encoded as a 32 bit size, followed by ``size`` data bytes,
55 then a 32 bit checksum.
60 These types are just aliases for primitive types.
64 // From /src/include/types.h
66 typedef u32le epoch_t;
67 typedef u32le ceph_seq_t;
68 typedef u64le ceph_tid_t;
69 typedef u64le version_t;
75 These are the way structures are encoded. Note that these structures don't
76 actually exist in the source but are the way that different types are encoded.
81 Optionals are represented as a presence byte, followed by the item if it exists.
85 struct ceph_optional<T> {
87 T element[present? 1 : 0]; // Only if present is non-zero.
90 Optionals are used to encode ``boost::optional``.
95 Pairs are simply the first item followed by the second.
99 struct ceph_pair<A,B> {
104 Pairs are used to encode ``std::pair``.
109 Triples are simply the tree elements one after another.
113 struct ceph_triple<A,B,C> {
119 Triples are used to encode ``ceph::triple``.
125 Lists are represented as an element count followed by that many elements.
129 struct ceph_list<T> {
135 The size of the elements in the list are not necessarily uniform.
137 Lists are used to encode ``std::list``, ``std::vector``, ``std::deque``,
138 ``std::set`` and ``ceph::unordered_set``.
143 A Blob is simply a list of bytes.
158 Blobs are used to encode ``std::string``, ``const char *`` and ``bufferlist``.
161 The content of a Blob is arbratrary binary data.
166 Maps are a list of pairs.
170 struct ceph_map<K,V> {
171 ceph_list<ceph_pair<K,V>>;
176 struct ceph_map<K,V> {
178 ceph_pair<K,V> entries[length];
181 Maps are used to encode ``std::map``, ``std::multimap`` and
182 ``ceph::unordered_map``.
187 These aren't hard to find in the source but the common ones are listed here for
195 // From /src/include/utime.h
197 u32le tv_sec; // Seconds since epoch.
198 u32le tv_nsec; // Nanoseconds since the last second.
206 // From /src/include/msgr.h
207 struct ceph_entity_name {
208 u8 type; // CEPH_ENTITY_TYPE_*
212 // CEPH_ENTITY_TYPE_* defined in /src/include/msgr.h
214 .. vi: textwidth=80 noexpandtab