]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/libsystemd-bus/GVARIANT-SERIALIZATION
bus: add support for serializing to gvariant
[thirdparty/systemd.git] / src / libsystemd-bus / GVARIANT-SERIALIZATION
CommitLineData
c1b9d935
LP
1How we use GVariant for serializing D-Bus messages
2--------------------------------------------------
3
4We stay as close to the original dbus1 framing as possible. dbus1 has
5the following framing:
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
23 u Serial number
24
25 = 12 bytes
26
27When using GVariant we keep the basic structure in place, only
28slightly extend the header, and define protocol version '2'. The new
29header:
30
31 y Endianness, 'l' or 'B'
32 y Message Type
33 y Flags
34 y Protocol version, '2'
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
38
39 = 16 bytes
40
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:
47
48 0 4 8 12 16
49 Common: | E | T | F | V | Body Length | Serial | Fields Length |
50
51 dbus1: | ... (as above) ... | Fields array ...
52
53 gvariant: | ... (as above) ... | Fields Length | Fields array ...
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.