]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/libsystemd/sd-bus/GVARIANT-SERIALIZATION
tmpfiles: accurately report creation results
[thirdparty/systemd.git] / src / libsystemd / sd-bus / GVARIANT-SERIALIZATION
CommitLineData
c1b9d935
LP
1How we use GVariant for serializing D-Bus messages
2--------------------------------------------------
3
954871d8
KS
4We stay as close to the original dbus1 framing as possible. dbus1 has
5the following framing:
c1b9d935
LP
6
7 1. A fixed header of "yyyyuu"
8 2. Additional header fields of "a(yv)"
9 3. Padding with NUL bytes to pad up to next 8byte boundary
10 4. The body
11
12Note that the body is not padded at the end, the complete message
13hence might have a non-aligned size. Reading multiple messages at once
14will hence result in possibly unaligned messages in memory.
15
16The header consists of the following:
17
18 y Endianness, 'l' or 'B'
19 y Message Type
20 y Flags
21 y Protocol version, '1'
22 u Length of the body, i.e. the length of part 4 above
954871d8 23 u Serial number
c1b9d935
LP
24
25 = 12 bytes
26
27When using GVariant we keep the basic structure in place, only
954871d8 28slightly extend the header, and define protocol version '2'. The new
c1b9d935
LP
29header:
30
31 y Endianness, 'l' or 'B'
32 y Message Type
33 y Flags
34 y Protocol version, '2'
954871d8
KS
35 u Length of the body, i.e. the length of part 4 above
36 u Serial number
37 u Length of the additional header fields array
c1b9d935
LP
38
39 = 16 bytes
40
954871d8
KS
41This has the nice benefit that the beginning of the additional header
42fields array is aligned to an 8 byte boundary. Also, in dbus1
43marshalling arrays start with a length value of 32bit, which means in
44both dbus1 and gvariant marshallings the size of the header fields
45array will be at the same location between bytes 12 and 16. To
46visualize that:
c1b9d935
LP
47
48 0 4 8 12 16
954871d8 49 Common: | E | T | F | V | Body Length | Serial | Fields Length |
c1b9d935 50
954871d8 51 dbus1: | ... (as above) ... | Fields array ...
c1b9d935 52
954871d8 53 gvariant: | ... (as above) ... | Fields Length | Fields array ...
c1b9d935
LP
54
55And that's already it.
56
57Note: on kdbus only native endian messages marshalled in gvariant may
58 be sent. If a client receives a message in non-native endianness
59 or in dbus1 marshalling it shall ignore the message.
6647dc66
LP
60
61Note: The GVariant "MAYBE" type is not supported, so that messages can
62 be fully converted forth and back between dbus1 and gvariant
63 representations.