1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//! Decoder for lldpd's internal "marshal" payload encoding (`src/marshal.c`
//! upstream).
//!
//! Each message payload is a tree of chunks. A chunk is:
//!
//! ```text
//! [padding to align(pointer width)] [orig: usize] [size: usize] [content]
//! ```
//!
//! `size` is **not** `content`'s length - it's `lldpd`'s own bookkeeping
//! value, the *entire* serialized length of this chunk (header included)
//! plus every chunk nested inside it, recursively. For a leaf chunk (a
//! string, or a fixed-length byte string - never anything nested inside it),
//! that means `content`'s real length is `size` minus the 2-`usize` header.
//! For a struct chunk, `content` is the flat, `#[repr(C)]`-compatible raw
//! bytes of a C struct (see [`raw`]) - always exactly `size_of` that struct,
//! regardless of what the header's `size` says, because the *nested* chunks
//! for the struct's own pointer-shaped fields (a `char *`, a
//! `TAILQ_HEAD`/`TAILQ_ENTRY` link) come right after `content`, not inside
//! the range `size` would suggest if you (wrongly, as this crate did until
//! it was tested against a real `lldpd` for the first time) treated it as a
//! content length. A pointer-shaped field's raw value is either zero (the
//! field was absent) or a small "dummy" reference id, telling you whether
//! the next chunk exists at all - never its size. Lists (`TAILQ`) are just
//! chains of such pointers - there's no explicit length prefix, you follow
//! pointers until you hit zero.
//!
//! This is not a designed wire format: it is `lldpd`'s internal C structures,
//! `memcpy`'d. See the crate-level docs for what that implies.
pub
pub use ;
/// Encodes the payload for a `GET_INTERFACE` request: a single chunk holding
/// the interface name as a null-terminated string (mirrors
/// `marshal_serialize(string, name, buffer)` on the client side upstream).
pub