blob: bcd1e2d4dda91b2bb92f458709f29a93b8800dc9 [file] [log] [blame] [view]
Dave Watson792db4e2015-01-16 11:22:01 -08001<link href="http://kevinburke.bitbucket.org/markdowncss/markdown.css" rel="stylesheet"></link>
2
3Header format for the THeader.h
4===============================
5
6 0 1 2 3 4 5 6 7 8 9 a b c d e f 0 1 2 3 4 5 6 7 8 9 a b c d e f
7 +----------------------------------------------------------------+
8 | 0| LENGTH |
9 +----------------------------------------------------------------+
10 | 0| HEADER MAGIC | FLAGS |
11 +----------------------------------------------------------------+
12 | SEQUENCE NUMBER |
13 +----------------------------------------------------------------+
14 | 0| Header Size(/32) | ...
15 +---------------------------------
16
17 Header is of variable size:
18 (and starts at offset 14)
19
20 +----------------------------------------------------------------+
21 | PROTOCOL ID (varint) | NUM TRANSFORMS (varint) |
22 +----------------------------------------------------------------+
23 | TRANSFORM 0 ID (varint) | TRANSFORM 0 DATA ...
24 +----------------------------------------------------------------+
25 | ... ... |
26 +----------------------------------------------------------------+
27 | INFO 0 ID (varint) | INFO 0 DATA ...
28 +----------------------------------------------------------------+
29 | ... ... |
30 +----------------------------------------------------------------+
31 | |
32 | PAYLOAD |
33 | |
34 +----------------------------------------------------------------+
35
36The `LENGTH` field is 32 bits, and counts the remaining bytes in the
37packet, NOT including the length field. The header size field is 16
38bits, and defines the size of the header remaining NOT including the
39`HEADER MAGIC`, `FLAGS`, `SEQUENCE NUMBER` and header size fields. The
40Header size field is in bytes/4.
41
42The transform ID's are varints. The data for each transform is
43defined by the transform ID in the code - no size is given in the
44header. If a transform ID is specified from a client and the server
45doesn't know about the transform ID, an error MUST be returned as we
46don't know how to transform the data.
47
48Conversely, data in the info headers is ignorable. This should only
PoojaChandak20205b82020-11-06 11:33:40 +010049be things like timestamps, debugging tracing, etc. Using the header
Dave Watson792db4e2015-01-16 11:22:01 -080050size you should be able to skip this data and read the payload safely
51if you don't know the info ID.
52
53Info's should be oldest supported to newest supported order, so that
54if we read an info ID we don't support, none of the remaining info
55ID's will be supported either, and we can safely skip to the payload.
56
57Info ID's and transform ID's should share the same ID space.
58
59### PADDING:
60
61Header will be padded out to next 4-byte boundary with `0x00`.
62
63Max frame size is `0x3FFFFFFF`, which is slightly less than `HTTP_MAGIC`.
PoojaChandak20205b82020-11-06 11:33:40 +010064This allows us to distinguish between different (older) transports.
Dave Watson792db4e2015-01-16 11:22:01 -080065
66### Transform IDs:
67
68 ZLIB_TRANSFORM 0x01 - No data for this. Use zlib to (de)compress the
69 data.
70
71 HMAC_TRANSFORM 0x02 - Variable amount of mac data. One byte to specify
72 size. Mac data is appended at the end of the packet.
73 SNAPPY_TRANSFORM 0x03 - No data for this. Use snappy to (de)compress the
74 data.
75
76
Wenqiang Yang23aabcc2020-04-07 18:45:41 +080077### Info IDs:
Dave Watson792db4e2015-01-16 11:22:01 -080078
79 INFO_KEYVALUE 0x01 - varint32 number of headers.
80 - key/value pairs of varstrings (varint16 length plus
Yuxuan 'fishy' Wange165fa32022-03-30 13:37:19 -070081 no-trailing-null string). Implementations MUST NOT
82 alter either key or value in any way.
Dave Watson792db4e2015-01-16 11:22:01 -080083