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
//! Netlink attribute building utilities.
//!
//! Netlink uses a TLV (Type-Length-Value) format for attributes. This module
//! provides helpers for constructing these attributes correctly.
use TCA_OPTIONS;
use ;
/// Build a nested NLA (Netlink Attribute) containing sub-attributes.
///
/// Netlink uses a TLV (Type-Length-Value) format. For qdisc options like HTB and TBF,
/// the `TCA_OPTIONS` attribute contains nested sub-attributes, each with their own type.
///
/// # NLA Header Format
///
/// ```text
/// ┌─────────────────────────────────────────┐
/// │ Length (2 bytes) │ Type (2 bytes) │ <- NLA header (4 bytes)
/// ├─────────────────────────────────────────┤
/// │ Value (variable length, padded to 4) │
/// └─────────────────────────────────────────┘
/// ```
///
/// Reference: <linux/netlink.h>
///
/// # Returns
///
/// A byte vector containing the complete NLA (header + value + padding).
pub
/// Build a nested TCA_OPTIONS attribute containing one or more sub-attributes.
///
/// This wraps sub-attributes in a `TCA_OPTIONS` container, which is what the kernel
/// expects for qdisc-specific configuration.
///
/// # Arguments
///
/// * `sub_attrs` - One or more NLA sub-attributes (already formatted with headers)
///
/// # Returns
///
/// A `DefaultNla` that can be added to a `TcMessage`.
pub